Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Frame buffer driver for Trident Blade and Image series |
| 3 | * |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 4 | * Copyright 2001, 2002 - Jani Monoses <jani@iv.ro> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 6 | * |
| 7 | * CREDITS:(in order of appearance) |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 8 | * skeletonfb.c by Geert Uytterhoeven and other fb code in drivers/video |
| 9 | * Special thanks ;) to Mattia Crivellini <tia@mclink.it> |
| 10 | * much inspired by the XFree86 4.x Trident driver sources |
| 11 | * by Alan Hourihane the FreeVGA project |
| 12 | * Francesco Salvestrini <salvestrini@users.sf.net> XP support, |
| 13 | * code, suggestions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * TODO: |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 15 | * timing value tweaking so it looks good on every monitor in every mode |
| 16 | * TGUI acceleration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/fb.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/pci.h> |
| 23 | |
| 24 | #include <linux/delay.h> |
| 25 | #include <video/trident.h> |
| 26 | |
| 27 | #define VERSION "0.7.8-NEWAPI" |
| 28 | |
| 29 | struct tridentfb_par { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 30 | void __iomem *io_virt; /* iospace virtual memory address */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 33 | static unsigned char eng_oper; /* engine operation... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | static struct fb_ops tridentfb_ops; |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | /* FIXME:kmalloc these 3 instead */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | static u32 pseudo_pal[16]; |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | static struct fb_var_screeninfo default_var; |
| 40 | |
| 41 | static struct fb_fix_screeninfo tridentfb_fix = { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 42 | .id = "Trident", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | .type = FB_TYPE_PACKED_PIXELS, |
| 44 | .ypanstep = 1, |
| 45 | .visual = FB_VISUAL_PSEUDOCOLOR, |
| 46 | .accel = FB_ACCEL_NONE, |
| 47 | }; |
| 48 | |
| 49 | static int chip_id; |
| 50 | |
| 51 | static int defaultaccel; |
| 52 | static int displaytype; |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* defaults which are normally overriden by user values */ |
| 55 | |
| 56 | /* video mode */ |
Krzysztof Helt | 07f41e4 | 2008-04-28 02:15:06 -0700 | [diff] [blame] | 57 | static char *mode_option __devinitdata = "640x480"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | static int bpp = 8; |
| 59 | |
| 60 | static int noaccel; |
| 61 | |
| 62 | static int center; |
| 63 | static int stretch; |
| 64 | |
| 65 | static int fp; |
| 66 | static int crt; |
| 67 | |
| 68 | static int memsize; |
| 69 | static int memdiff; |
| 70 | static int nativex; |
| 71 | |
Krzysztof Helt | 07f41e4 | 2008-04-28 02:15:06 -0700 | [diff] [blame] | 72 | module_param(mode_option, charp, 0); |
| 73 | MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'"); |
Krzysztof Helt | 9e3f0ca | 2008-04-28 02:15:10 -0700 | [diff] [blame] | 74 | module_param_named(mode, mode_option, charp, 0); |
| 75 | MODULE_PARM_DESC(mode, "Initial video mode e.g. '648x480-8@60' (deprecated)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | module_param(bpp, int, 0); |
| 77 | module_param(center, int, 0); |
| 78 | module_param(stretch, int, 0); |
| 79 | module_param(noaccel, int, 0); |
| 80 | module_param(memsize, int, 0); |
| 81 | module_param(memdiff, int, 0); |
| 82 | module_param(nativex, int, 0); |
| 83 | module_param(fp, int, 0); |
| 84 | module_param(crt, int, 0); |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | static int chip3D; |
| 87 | static int chipcyber; |
| 88 | |
| 89 | static int is3Dchip(int id) |
| 90 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 91 | return ((id == BLADE3D) || (id == CYBERBLADEE4) || |
| 92 | (id == CYBERBLADEi7) || (id == CYBERBLADEi7D) || |
| 93 | (id == CYBER9397) || (id == CYBER9397DVD) || |
| 94 | (id == CYBER9520) || (id == CYBER9525DVD) || |
| 95 | (id == IMAGE975) || (id == IMAGE985) || |
| 96 | (id == CYBERBLADEi1) || (id == CYBERBLADEi1D) || |
| 97 | (id == CYBERBLADEAi1) || (id == CYBERBLADEAi1D) || |
| 98 | (id == CYBERBLADEXPm8) || (id == CYBERBLADEXPm16) || |
| 99 | (id == CYBERBLADEXPAi1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static int iscyber(int id) |
| 103 | { |
| 104 | switch (id) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 105 | case CYBER9388: |
| 106 | case CYBER9382: |
| 107 | case CYBER9385: |
| 108 | case CYBER9397: |
| 109 | case CYBER9397DVD: |
| 110 | case CYBER9520: |
| 111 | case CYBER9525DVD: |
| 112 | case CYBERBLADEE4: |
| 113 | case CYBERBLADEi7D: |
| 114 | case CYBERBLADEi1: |
| 115 | case CYBERBLADEi1D: |
| 116 | case CYBERBLADEAi1: |
| 117 | case CYBERBLADEAi1D: |
| 118 | case CYBERBLADEXPAi1: |
| 119 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 121 | case CYBER9320: |
| 122 | case TGUI9660: |
| 123 | case IMAGE975: |
| 124 | case IMAGE985: |
| 125 | case BLADE3D: |
| 126 | case CYBERBLADEi7: /* VIA MPV4 integrated version */ |
| 127 | |
| 128 | default: |
| 129 | /* case CYBERBLDAEXPm8: Strange */ |
| 130 | /* case CYBERBLDAEXPm16: Strange */ |
| 131 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 135 | #define CRT 0x3D0 /* CRTC registers offset for color display */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 137 | static inline void t_outb(struct tridentfb_par *p, u8 val, u16 reg) |
| 138 | { |
| 139 | fb_writeb(val, p->io_virt + reg); |
| 140 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 142 | static inline u8 t_inb(struct tridentfb_par *p, u16 reg) |
| 143 | { |
| 144 | return fb_readb(p->io_virt + reg); |
| 145 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | static struct accel_switch { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 148 | void (*init_accel) (struct tridentfb_par *, int, int); |
| 149 | void (*wait_engine) (struct tridentfb_par *); |
| 150 | void (*fill_rect) |
| 151 | (struct tridentfb_par *par, u32, u32, u32, u32, u32, u32); |
| 152 | void (*copy_rect) |
| 153 | (struct tridentfb_par *par, u32, u32, u32, u32, u32, u32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } *acc; |
| 155 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 156 | static inline void writemmr(struct tridentfb_par *par, u16 r, u32 v) |
| 157 | { |
| 158 | fb_writel(v, par->io_virt + r); |
| 159 | } |
| 160 | |
| 161 | static inline u32 readmmr(struct tridentfb_par *par, u16 r) |
| 162 | { |
| 163 | return fb_readl(par->io_virt + r); |
| 164 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | /* |
| 167 | * Blade specific acceleration. |
| 168 | */ |
| 169 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 170 | #define point(x, y) ((y) << 16 | (x)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | #define STA 0x2120 |
| 172 | #define CMD 0x2144 |
| 173 | #define ROP 0x2148 |
| 174 | #define CLR 0x2160 |
| 175 | #define SR1 0x2100 |
| 176 | #define SR2 0x2104 |
| 177 | #define DR1 0x2108 |
| 178 | #define DR2 0x210C |
| 179 | |
| 180 | #define ROP_S 0xCC |
| 181 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 182 | static void blade_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 184 | int v1 = (pitch >> 3) << 20; |
| 185 | int tmp = 0, v2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 187 | case 8: |
| 188 | tmp = 0; |
| 189 | break; |
| 190 | case 15: |
| 191 | tmp = 5; |
| 192 | break; |
| 193 | case 16: |
| 194 | tmp = 1; |
| 195 | break; |
| 196 | case 24: |
| 197 | case 32: |
| 198 | tmp = 2; |
| 199 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 201 | v2 = v1 | (tmp << 29); |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 202 | writemmr(par, 0x21C0, v2); |
| 203 | writemmr(par, 0x21C4, v2); |
| 204 | writemmr(par, 0x21B8, v2); |
| 205 | writemmr(par, 0x21BC, v2); |
| 206 | writemmr(par, 0x21D0, v1); |
| 207 | writemmr(par, 0x21D4, v1); |
| 208 | writemmr(par, 0x21C8, v1); |
| 209 | writemmr(par, 0x21CC, v1); |
| 210 | writemmr(par, 0x216C, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 213 | static void blade_wait_engine(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 215 | while (readmmr(par, STA) & 0xFA800000) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 218 | static void blade_fill_rect(struct tridentfb_par *par, |
| 219 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 221 | writemmr(par, CLR, c); |
| 222 | writemmr(par, ROP, rop ? 0x66 : ROP_S); |
| 223 | writemmr(par, CMD, 0x20000000 | 1 << 19 | 1 << 4 | 2 << 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 225 | writemmr(par, DR1, point(x, y)); |
| 226 | writemmr(par, DR2, point(x + w - 1, y + h - 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 229 | static void blade_copy_rect(struct tridentfb_par *par, |
| 230 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 232 | u32 s1, s2, d1, d2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | int direction = 2; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 234 | s1 = point(x1, y1); |
| 235 | s2 = point(x1 + w - 1, y1 + h - 1); |
| 236 | d1 = point(x2, y2); |
| 237 | d2 = point(x2 + w - 1, y2 + h - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
| 239 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 240 | direction = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 242 | writemmr(par, ROP, ROP_S); |
| 243 | writemmr(par, CMD, 0xE0000000 | 1 << 19 | 1 << 4 | 1 << 2 | direction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 245 | writemmr(par, SR1, direction ? s2 : s1); |
| 246 | writemmr(par, SR2, direction ? s1 : s2); |
| 247 | writemmr(par, DR1, direction ? d2 : d1); |
| 248 | writemmr(par, DR2, direction ? d1 : d2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static struct accel_switch accel_blade = { |
| 252 | blade_init_accel, |
| 253 | blade_wait_engine, |
| 254 | blade_fill_rect, |
| 255 | blade_copy_rect, |
| 256 | }; |
| 257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /* |
| 259 | * BladeXP specific acceleration functions |
| 260 | */ |
| 261 | |
| 262 | #define ROP_P 0xF0 |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 263 | #define masked_point(x, y) ((y & 0xffff)<<16|(x & 0xffff)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 265 | static void xp_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 267 | int tmp = 0, v1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | unsigned char x = 0; |
| 269 | |
| 270 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 271 | case 8: |
| 272 | x = 0; |
| 273 | break; |
| 274 | case 16: |
| 275 | x = 1; |
| 276 | break; |
| 277 | case 24: |
| 278 | x = 3; |
| 279 | break; |
| 280 | case 32: |
| 281 | x = 2; |
| 282 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | switch (pitch << (bpp >> 3)) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 286 | case 8192: |
| 287 | case 512: |
| 288 | x |= 0x00; |
| 289 | break; |
| 290 | case 1024: |
| 291 | x |= 0x04; |
| 292 | break; |
| 293 | case 2048: |
| 294 | x |= 0x08; |
| 295 | break; |
| 296 | case 4096: |
| 297 | x |= 0x0C; |
| 298 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 301 | t_outb(par, x, 0x2125); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | eng_oper = x | 0x40; |
| 304 | |
| 305 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 306 | case 8: |
| 307 | tmp = 18; |
| 308 | break; |
| 309 | case 15: |
| 310 | case 16: |
| 311 | tmp = 19; |
| 312 | break; |
| 313 | case 24: |
| 314 | case 32: |
| 315 | tmp = 20; |
| 316 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | v1 = pitch << tmp; |
| 320 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 321 | writemmr(par, 0x2154, v1); |
| 322 | writemmr(par, 0x2150, v1); |
| 323 | t_outb(par, 3, 0x2126); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 326 | static void xp_wait_engine(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | { |
| 328 | int busy; |
| 329 | int count, timeout; |
| 330 | |
| 331 | count = 0; |
| 332 | timeout = 0; |
| 333 | for (;;) { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 334 | busy = t_inb(par, STA) & 0x80; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (busy != 0x80) |
| 336 | return; |
| 337 | count++; |
| 338 | if (count == 10000000) { |
| 339 | /* Timeout */ |
| 340 | count = 9990000; |
| 341 | timeout++; |
| 342 | if (timeout == 8) { |
| 343 | /* Reset engine */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 344 | t_outb(par, 0x00, 0x2120); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | return; |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 351 | static void xp_fill_rect(struct tridentfb_par *par, |
| 352 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 354 | writemmr(par, 0x2127, ROP_P); |
| 355 | writemmr(par, 0x2158, c); |
| 356 | writemmr(par, 0x2128, 0x4000); |
| 357 | writemmr(par, 0x2140, masked_point(h, w)); |
| 358 | writemmr(par, 0x2138, masked_point(y, x)); |
| 359 | t_outb(par, 0x01, 0x2124); |
| 360 | t_outb(par, eng_oper, 0x2125); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 363 | static void xp_copy_rect(struct tridentfb_par *par, |
| 364 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | { |
| 366 | int direction; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 367 | u32 x1_tmp, x2_tmp, y1_tmp, y2_tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
| 369 | direction = 0x0004; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 370 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | if ((x1 < x2) && (y1 == y2)) { |
| 372 | direction |= 0x0200; |
| 373 | x1_tmp = x1 + w - 1; |
| 374 | x2_tmp = x2 + w - 1; |
| 375 | } else { |
| 376 | x1_tmp = x1; |
| 377 | x2_tmp = x2; |
| 378 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | if (y1 < y2) { |
| 381 | direction |= 0x0100; |
| 382 | y1_tmp = y1 + h - 1; |
| 383 | y2_tmp = y2 + h - 1; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 384 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | y1_tmp = y1; |
| 386 | y2_tmp = y2; |
| 387 | } |
| 388 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 389 | writemmr(par, 0x2128, direction); |
| 390 | t_outb(par, ROP_S, 0x2127); |
| 391 | writemmr(par, 0x213C, masked_point(y1_tmp, x1_tmp)); |
| 392 | writemmr(par, 0x2138, masked_point(y2_tmp, x2_tmp)); |
| 393 | writemmr(par, 0x2140, masked_point(h, w)); |
| 394 | t_outb(par, 0x01, 0x2124); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | static struct accel_switch accel_xp = { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 398 | xp_init_accel, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | xp_wait_engine, |
| 400 | xp_fill_rect, |
| 401 | xp_copy_rect, |
| 402 | }; |
| 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | /* |
| 405 | * Image specific acceleration functions |
| 406 | */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 407 | static void image_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | { |
| 409 | int tmp = 0; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 410 | switch (bpp) { |
| 411 | case 8: |
| 412 | tmp = 0; |
| 413 | break; |
| 414 | case 15: |
| 415 | tmp = 5; |
| 416 | break; |
| 417 | case 16: |
| 418 | tmp = 1; |
| 419 | break; |
| 420 | case 24: |
| 421 | case 32: |
| 422 | tmp = 2; |
| 423 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 425 | writemmr(par, 0x2120, 0xF0000000); |
| 426 | writemmr(par, 0x2120, 0x40000000 | tmp); |
| 427 | writemmr(par, 0x2120, 0x80000000); |
| 428 | writemmr(par, 0x2144, 0x00000000); |
| 429 | writemmr(par, 0x2148, 0x00000000); |
| 430 | writemmr(par, 0x2150, 0x00000000); |
| 431 | writemmr(par, 0x2154, 0x00000000); |
| 432 | writemmr(par, 0x2120, 0x60000000 | (pitch << 16) | pitch); |
| 433 | writemmr(par, 0x216C, 0x00000000); |
| 434 | writemmr(par, 0x2170, 0x00000000); |
| 435 | writemmr(par, 0x217C, 0x00000000); |
| 436 | writemmr(par, 0x2120, 0x10000000); |
| 437 | writemmr(par, 0x2130, (2047 << 16) | 2047); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 440 | static void image_wait_engine(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 442 | while (readmmr(par, 0x2164) & 0xF0000000) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
| 444 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 445 | static void image_fill_rect(struct tridentfb_par *par, |
| 446 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 448 | writemmr(par, 0x2120, 0x80000000); |
| 449 | writemmr(par, 0x2120, 0x90000000 | ROP_S); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 451 | writemmr(par, 0x2144, c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 453 | writemmr(par, DR1, point(x, y)); |
| 454 | writemmr(par, DR2, point(x + w - 1, y + h - 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 456 | writemmr(par, 0x2124, 0x80000000 | 3 << 22 | 1 << 10 | 1 << 9); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 459 | static void image_copy_rect(struct tridentfb_par *par, |
| 460 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 462 | u32 s1, s2, d1, d2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | int direction = 2; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 464 | s1 = point(x1, y1); |
| 465 | s2 = point(x1 + w - 1, y1 + h - 1); |
| 466 | d1 = point(x2, y2); |
| 467 | d2 = point(x2 + w - 1, y2 + h - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 469 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) |
| 470 | direction = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 472 | writemmr(par, 0x2120, 0x80000000); |
| 473 | writemmr(par, 0x2120, 0x90000000 | ROP_S); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 475 | writemmr(par, SR1, direction ? s2 : s1); |
| 476 | writemmr(par, SR2, direction ? s1 : s2); |
| 477 | writemmr(par, DR1, direction ? d2 : d1); |
| 478 | writemmr(par, DR2, direction ? d1 : d2); |
| 479 | writemmr(par, 0x2124, |
| 480 | 0x80000000 | 1 << 22 | 1 << 10 | 1 << 7 | direction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | } |
| 482 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | static struct accel_switch accel_image = { |
| 484 | image_init_accel, |
| 485 | image_wait_engine, |
| 486 | image_fill_rect, |
| 487 | image_copy_rect, |
| 488 | }; |
| 489 | |
| 490 | /* |
| 491 | * Accel functions called by the upper layers |
| 492 | */ |
| 493 | #ifdef CONFIG_FB_TRIDENT_ACCEL |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 494 | static void tridentfb_fillrect(struct fb_info *info, |
| 495 | const struct fb_fillrect *fr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 497 | struct tridentfb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | int bpp = info->var.bits_per_pixel; |
Antonino A. Daplas | 8dad46c | 2005-08-01 23:46:44 +0800 | [diff] [blame] | 499 | int col = 0; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 502 | default: |
| 503 | case 8: |
| 504 | col |= fr->color; |
| 505 | col |= col << 8; |
| 506 | col |= col << 16; |
| 507 | break; |
| 508 | case 16: |
| 509 | col = ((u32 *)(info->pseudo_palette))[fr->color]; |
| 510 | break; |
| 511 | case 32: |
| 512 | col = ((u32 *)(info->pseudo_palette))[fr->color]; |
| 513 | break; |
| 514 | } |
| 515 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 516 | acc->fill_rect(par, fr->dx, fr->dy, fr->width, |
| 517 | fr->height, col, fr->rop); |
| 518 | acc->wait_engine(par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 520 | static void tridentfb_copyarea(struct fb_info *info, |
| 521 | const struct fb_copyarea *ca) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 523 | struct tridentfb_par *par = info->par; |
| 524 | |
| 525 | acc->copy_rect(par, ca->sx, ca->sy, ca->dx, ca->dy, |
| 526 | ca->width, ca->height); |
| 527 | acc->wait_engine(par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | #else /* !CONFIG_FB_TRIDENT_ACCEL */ |
| 530 | #define tridentfb_fillrect cfb_fillrect |
| 531 | #define tridentfb_copyarea cfb_copyarea |
| 532 | #endif /* CONFIG_FB_TRIDENT_ACCEL */ |
| 533 | |
| 534 | |
| 535 | /* |
| 536 | * Hardware access functions |
| 537 | */ |
| 538 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 539 | static inline unsigned char read3X4(struct tridentfb_par *par, int reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | writeb(reg, par->io_virt + CRT + 4); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 542 | return readb(par->io_virt + CRT + 5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | } |
| 544 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 545 | static inline void write3X4(struct tridentfb_par *par, int reg, |
| 546 | unsigned char val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | writeb(reg, par->io_virt + CRT + 4); |
| 549 | writeb(val, par->io_virt + CRT + 5); |
| 550 | } |
| 551 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 552 | static inline unsigned char read3C4(struct tridentfb_par *par, int reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 554 | t_outb(par, reg, 0x3C4); |
| 555 | return t_inb(par, 0x3C5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 558 | static inline void write3C4(struct tridentfb_par *par, int reg, |
| 559 | unsigned char val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 561 | t_outb(par, reg, 0x3C4); |
| 562 | t_outb(par, val, 0x3C5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | } |
| 564 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 565 | static inline unsigned char read3CE(struct tridentfb_par *par, int reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 567 | t_outb(par, reg, 0x3CE); |
| 568 | return t_inb(par, 0x3CF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 571 | static inline void writeAttr(struct tridentfb_par *par, int reg, |
| 572 | unsigned char val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 574 | fb_readb(par->io_virt + CRT + 0x0A); /* flip-flop to index */ |
| 575 | t_outb(par, reg, 0x3C0); |
| 576 | t_outb(par, val, 0x3C0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 579 | static inline void write3CE(struct tridentfb_par *par, int reg, |
| 580 | unsigned char val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 582 | t_outb(par, reg, 0x3CE); |
| 583 | t_outb(par, val, 0x3CF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | } |
| 585 | |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 586 | static void enable_mmio(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | { |
| 588 | /* Goto New Mode */ |
| 589 | outb(0x0B, 0x3C4); |
| 590 | inb(0x3C5); |
| 591 | |
| 592 | /* Unprotect registers */ |
| 593 | outb(NewMode1, 0x3C4); |
| 594 | outb(0x80, 0x3C5); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 595 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | /* Enable MMIO */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 597 | outb(PCIReg, 0x3D4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | outb(inb(0x3D5) | 0x01, 0x3D5); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 599 | } |
| 600 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 601 | static void disable_mmio(struct tridentfb_par *par) |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 602 | { |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 603 | /* Goto New Mode */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 604 | t_outb(par, 0x0B, 0x3C4); |
| 605 | t_inb(par, 0x3C5); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 606 | |
| 607 | /* Unprotect registers */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 608 | t_outb(par, NewMode1, 0x3C4); |
| 609 | t_outb(par, 0x80, 0x3C5); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 610 | |
| 611 | /* Disable MMIO */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 612 | t_outb(par, PCIReg, 0x3D4); |
| 613 | t_outb(par, t_inb(par, 0x3D5) & ~0x01, 0x3D5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | } |
| 615 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 616 | static void crtc_unlock(struct tridentfb_par *par) |
| 617 | { |
| 618 | write3X4(par, CRTVSyncEnd, read3X4(par, CRTVSyncEnd) & 0x7F); |
| 619 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
| 621 | /* Return flat panel's maximum x resolution */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 622 | static int __devinit get_nativex(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 624 | int x, y, tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | |
| 626 | if (nativex) |
| 627 | return nativex; |
| 628 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 629 | tmp = (read3CE(par, VertStretch) >> 4) & 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
| 631 | switch (tmp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 632 | case 0: |
| 633 | x = 1280; y = 1024; |
| 634 | break; |
| 635 | case 2: |
| 636 | x = 1024; y = 768; |
| 637 | break; |
| 638 | case 3: |
| 639 | x = 800; y = 600; |
| 640 | break; |
| 641 | case 4: |
| 642 | x = 1400; y = 1050; |
| 643 | break; |
| 644 | case 1: |
| 645 | default: |
| 646 | x = 640; y = 480; |
| 647 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | output("%dx%d flat panel found\n", x, y); |
| 651 | return x; |
| 652 | } |
| 653 | |
| 654 | /* Set pitch */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 655 | static void set_lwidth(struct tridentfb_par *par, int width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 657 | write3X4(par, Offset, width & 0xFF); |
| 658 | write3X4(par, AddColReg, |
| 659 | (read3X4(par, AddColReg) & 0xCF) | ((width & 0x300) >> 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | /* For resolutions smaller than FP resolution stretch */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 663 | static void screen_stretch(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 665 | if (chip_id != CYBERBLADEXPAi1) |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 666 | write3CE(par, BiosReg, 0); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 667 | else |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 668 | write3CE(par, BiosReg, 8); |
| 669 | write3CE(par, VertStretch, (read3CE(par, VertStretch) & 0x7C) | 1); |
| 670 | write3CE(par, HorStretch, (read3CE(par, HorStretch) & 0x7C) | 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | /* For resolutions smaller than FP resolution center */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 674 | static void screen_center(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 676 | write3CE(par, VertStretch, (read3CE(par, VertStretch) & 0x7C) | 0x80); |
| 677 | write3CE(par, HorStretch, (read3CE(par, HorStretch) & 0x7C) | 0x80); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | /* Address of first shown pixel in display memory */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 681 | static void set_screen_start(struct tridentfb_par *par, int base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 683 | u8 tmp; |
| 684 | write3X4(par, StartAddrLow, base & 0xFF); |
| 685 | write3X4(par, StartAddrHigh, (base & 0xFF00) >> 8); |
| 686 | tmp = read3X4(par, CRTCModuleTest) & 0xDF; |
| 687 | write3X4(par, CRTCModuleTest, tmp | ((base & 0x10000) >> 11)); |
| 688 | tmp = read3X4(par, CRTHiOrd) & 0xF8; |
| 689 | write3X4(par, CRTHiOrd, tmp | ((base & 0xE0000) >> 17)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | /* Set dotclock frequency */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 693 | static void set_vclk(struct tridentfb_par *par, unsigned long freq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 695 | int m, n, k; |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 696 | unsigned long f, fi, d, di; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 697 | unsigned char lo = 0, hi = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 699 | d = 20000; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 700 | for (k = 2; k >= 0; k--) |
| 701 | for (m = 0; m < 63; m++) |
| 702 | for (n = 0; n < 128; n++) { |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 703 | fi = ((14318l * (n + 8)) / (m + 2)) >> k; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 704 | if ((di = abs(fi - freq)) < d) { |
| 705 | d = di; |
| 706 | f = fi; |
| 707 | lo = n; |
| 708 | hi = (k << 6) | m; |
| 709 | } |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 710 | if (fi > freq) |
| 711 | break; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 712 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | if (chip3D) { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 714 | write3C4(par, ClockHigh, hi); |
| 715 | write3C4(par, ClockLow, lo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | } else { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 717 | outb(lo, 0x43C8); |
| 718 | outb(hi, 0x43C9); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 720 | debug("VCLK = %X %X\n", hi, lo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | /* Set number of lines for flat panels*/ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 724 | static void set_number_of_lines(struct tridentfb_par *par, int lines) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 726 | int tmp = read3CE(par, CyberEnhance) & 0x8F; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | if (lines > 1024) |
| 728 | tmp |= 0x50; |
| 729 | else if (lines > 768) |
| 730 | tmp |= 0x30; |
| 731 | else if (lines > 600) |
| 732 | tmp |= 0x20; |
| 733 | else if (lines > 480) |
| 734 | tmp |= 0x10; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 735 | write3CE(par, CyberEnhance, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | /* |
| 739 | * If we see that FP is active we assume we have one. |
| 740 | * Otherwise we have a CRT display.User can override. |
| 741 | */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 742 | static unsigned int __devinit get_displaytype(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | { |
| 744 | if (fp) |
| 745 | return DISPLAY_FP; |
| 746 | if (crt || !chipcyber) |
| 747 | return DISPLAY_CRT; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 748 | return (read3CE(par, FPConfig) & 0x10) ? DISPLAY_FP : DISPLAY_CRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | /* Try detecting the video memory size */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 752 | static unsigned int __devinit get_memsize(struct tridentfb_par *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | { |
| 754 | unsigned char tmp, tmp2; |
| 755 | unsigned int k; |
| 756 | |
| 757 | /* If memory size provided by user */ |
| 758 | if (memsize) |
| 759 | k = memsize * Kb; |
| 760 | else |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 761 | switch (chip_id) { |
| 762 | case CYBER9525DVD: |
| 763 | k = 2560 * Kb; |
| 764 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | default: |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 766 | tmp = read3X4(par, SPR) & 0x0F; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | switch (tmp) { |
| 768 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 769 | case 0x01: |
Krzysztof Helt | b614ce8 | 2008-03-10 11:43:37 -0700 | [diff] [blame] | 770 | k = 512 * Kb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | break; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 772 | case 0x02: |
| 773 | k = 6 * Mb; /* XP */ |
| 774 | break; |
| 775 | case 0x03: |
| 776 | k = 1 * Mb; |
| 777 | break; |
| 778 | case 0x04: |
| 779 | k = 8 * Mb; |
| 780 | break; |
| 781 | case 0x06: |
| 782 | k = 10 * Mb; /* XP */ |
| 783 | break; |
| 784 | case 0x07: |
| 785 | k = 2 * Mb; |
| 786 | break; |
| 787 | case 0x08: |
| 788 | k = 12 * Mb; /* XP */ |
| 789 | break; |
| 790 | case 0x0A: |
| 791 | k = 14 * Mb; /* XP */ |
| 792 | break; |
| 793 | case 0x0C: |
| 794 | k = 16 * Mb; /* XP */ |
| 795 | break; |
| 796 | case 0x0E: /* XP */ |
| 797 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 798 | tmp2 = read3C4(par, 0xC1); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 799 | switch (tmp2) { |
| 800 | case 0x00: |
| 801 | k = 20 * Mb; |
| 802 | break; |
| 803 | case 0x01: |
| 804 | k = 24 * Mb; |
| 805 | break; |
| 806 | case 0x10: |
| 807 | k = 28 * Mb; |
| 808 | break; |
| 809 | case 0x11: |
| 810 | k = 32 * Mb; |
| 811 | break; |
| 812 | default: |
| 813 | k = 1 * Mb; |
| 814 | break; |
| 815 | } |
| 816 | break; |
| 817 | |
| 818 | case 0x0F: |
| 819 | k = 4 * Mb; |
| 820 | break; |
| 821 | default: |
| 822 | k = 1 * Mb; |
| 823 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 825 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | |
| 827 | k -= memdiff * Kb; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 828 | output("framebuffer size = %d Kb\n", k / Kb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | return k; |
| 830 | } |
| 831 | |
| 832 | /* See if we can handle the video mode described in var */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 833 | static int tridentfb_check_var(struct fb_var_screeninfo *var, |
| 834 | struct fb_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | { |
| 836 | int bpp = var->bits_per_pixel; |
| 837 | debug("enter\n"); |
| 838 | |
| 839 | /* check color depth */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 840 | if (bpp == 24) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | bpp = var->bits_per_pixel = 32; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 842 | /* check whether resolution fits on panel and in memory */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | if (flatpanel && nativex && var->xres > nativex) |
| 844 | return -EINVAL; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 845 | if (var->xres * var->yres_virtual * bpp / 8 > info->fix.smem_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | return -EINVAL; |
| 847 | |
| 848 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 849 | case 8: |
| 850 | var->red.offset = 0; |
| 851 | var->green.offset = 0; |
| 852 | var->blue.offset = 0; |
| 853 | var->red.length = 6; |
| 854 | var->green.length = 6; |
| 855 | var->blue.length = 6; |
| 856 | break; |
| 857 | case 16: |
| 858 | var->red.offset = 11; |
| 859 | var->green.offset = 5; |
| 860 | var->blue.offset = 0; |
| 861 | var->red.length = 5; |
| 862 | var->green.length = 6; |
| 863 | var->blue.length = 5; |
| 864 | break; |
| 865 | case 32: |
| 866 | var->red.offset = 16; |
| 867 | var->green.offset = 8; |
| 868 | var->blue.offset = 0; |
| 869 | var->red.length = 8; |
| 870 | var->green.length = 8; |
| 871 | var->blue.length = 8; |
| 872 | break; |
| 873 | default: |
| 874 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } |
| 876 | debug("exit\n"); |
| 877 | |
| 878 | return 0; |
| 879 | |
| 880 | } |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | /* Pan the display */ |
| 883 | static int tridentfb_pan_display(struct fb_var_screeninfo *var, |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 884 | struct fb_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 886 | struct tridentfb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | unsigned int offset; |
| 888 | |
| 889 | debug("enter\n"); |
| 890 | offset = (var->xoffset + (var->yoffset * var->xres)) |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 891 | * var->bits_per_pixel / 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | info->var.xoffset = var->xoffset; |
| 893 | info->var.yoffset = var->yoffset; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 894 | set_screen_start(par, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | debug("exit\n"); |
| 896 | return 0; |
| 897 | } |
| 898 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 899 | static void shadowmode_on(struct tridentfb_par *par) |
| 900 | { |
| 901 | write3CE(par, CyberControl, read3CE(par, CyberControl) | 0x81); |
| 902 | } |
| 903 | |
| 904 | static void shadowmode_off(struct tridentfb_par *par) |
| 905 | { |
| 906 | write3CE(par, CyberControl, read3CE(par, CyberControl) & 0x7E); |
| 907 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | |
| 909 | /* Set the hardware to the requested video mode */ |
| 910 | static int tridentfb_set_par(struct fb_info *info) |
| 911 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 912 | struct tridentfb_par *par = (struct tridentfb_par *)(info->par); |
| 913 | u32 htotal, hdispend, hsyncstart, hsyncend, hblankstart, hblankend; |
| 914 | u32 vtotal, vdispend, vsyncstart, vsyncend, vblankstart, vblankend; |
| 915 | struct fb_var_screeninfo *var = &info->var; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | int bpp = var->bits_per_pixel; |
| 917 | unsigned char tmp; |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 918 | unsigned long vclk; |
| 919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | debug("enter\n"); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 921 | hdispend = var->xres / 8 - 1; |
| 922 | hsyncstart = (var->xres + var->right_margin) / 8; |
| 923 | hsyncend = var->hsync_len / 8; |
| 924 | htotal = |
| 925 | (var->xres + var->left_margin + var->right_margin + |
| 926 | var->hsync_len) / 8 - 10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | hblankstart = hdispend + 1; |
| 928 | hblankend = htotal + 5; |
| 929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | vdispend = var->yres - 1; |
| 931 | vsyncstart = var->yres + var->lower_margin; |
| 932 | vsyncend = var->vsync_len; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 933 | vtotal = var->upper_margin + vsyncstart + vsyncend - 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | vblankstart = var->yres; |
| 935 | vblankend = vtotal + 2; |
| 936 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 937 | crtc_unlock(par); |
| 938 | write3CE(par, CyberControl, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | |
| 940 | if (flatpanel && var->xres < nativex) { |
| 941 | /* |
| 942 | * on flat panels with native size larger |
| 943 | * than requested resolution decide whether |
| 944 | * we stretch or center |
| 945 | */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 946 | t_outb(par, 0xEB, 0x3C2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 948 | shadowmode_on(par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 950 | if (center) |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 951 | screen_center(par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | else if (stretch) |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 953 | screen_stretch(par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | |
| 955 | } else { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 956 | t_outb(par, 0x2B, 0x3C2); |
| 957 | write3CE(par, CyberControl, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | /* vertical timing values */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 961 | write3X4(par, CRTVTotal, vtotal & 0xFF); |
| 962 | write3X4(par, CRTVDispEnd, vdispend & 0xFF); |
| 963 | write3X4(par, CRTVSyncStart, vsyncstart & 0xFF); |
| 964 | write3X4(par, CRTVSyncEnd, (vsyncend & 0x0F)); |
| 965 | write3X4(par, CRTVBlankStart, vblankstart & 0xFF); |
| 966 | write3X4(par, CRTVBlankEnd, 0 /* p->vblankend & 0xFF */); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | |
| 968 | /* horizontal timing values */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 969 | write3X4(par, CRTHTotal, htotal & 0xFF); |
| 970 | write3X4(par, CRTHDispEnd, hdispend & 0xFF); |
| 971 | write3X4(par, CRTHSyncStart, hsyncstart & 0xFF); |
| 972 | write3X4(par, CRTHSyncEnd, |
| 973 | (hsyncend & 0x1F) | ((hblankend & 0x20) << 2)); |
| 974 | write3X4(par, CRTHBlankStart, hblankstart & 0xFF); |
| 975 | write3X4(par, CRTHBlankEnd, 0 /* (p->hblankend & 0x1F) */); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | |
| 977 | /* higher bits of vertical timing values */ |
| 978 | tmp = 0x10; |
| 979 | if (vtotal & 0x100) tmp |= 0x01; |
| 980 | if (vdispend & 0x100) tmp |= 0x02; |
| 981 | if (vsyncstart & 0x100) tmp |= 0x04; |
| 982 | if (vblankstart & 0x100) tmp |= 0x08; |
| 983 | |
| 984 | if (vtotal & 0x200) tmp |= 0x20; |
| 985 | if (vdispend & 0x200) tmp |= 0x40; |
| 986 | if (vsyncstart & 0x200) tmp |= 0x80; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 987 | write3X4(par, CRTOverflow, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 989 | tmp = read3X4(par, CRTHiOrd) | 0x08; /* line compare bit 10 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | if (vtotal & 0x400) tmp |= 0x80; |
| 991 | if (vblankstart & 0x400) tmp |= 0x40; |
| 992 | if (vsyncstart & 0x400) tmp |= 0x20; |
| 993 | if (vdispend & 0x400) tmp |= 0x10; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 994 | write3X4(par, CRTHiOrd, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | |
| 996 | tmp = 0; |
| 997 | if (htotal & 0x800) tmp |= 0x800 >> 11; |
| 998 | if (hblankstart & 0x800) tmp |= 0x800 >> 7; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 999 | write3X4(par, HorizOverflow, tmp); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1000 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | tmp = 0x40; |
| 1002 | if (vblankstart & 0x200) tmp |= 0x20; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1003 | //FIXME if (info->var.vmode & FB_VMODE_DOUBLE) tmp |= 0x80; /* double scan for 200 line modes */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1004 | write3X4(par, CRTMaxScanLine, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1006 | write3X4(par, CRTLineCompare, 0xFF); |
| 1007 | write3X4(par, CRTPRowScan, 0); |
| 1008 | write3X4(par, CRTModeControl, 0xC3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1010 | write3X4(par, LinearAddReg, 0x20); /* enable linear addressing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1012 | tmp = (info->var.vmode & FB_VMODE_INTERLACED) ? 0x84 : 0x80; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1013 | /* enable access extended memory */ |
| 1014 | write3X4(par, CRTCModuleTest, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1016 | /* enable GE for text acceleration */ |
| 1017 | write3X4(par, GraphEngReg, 0x80); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1019 | #ifdef CONFIG_FB_TRIDENT_ACCEL |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1020 | acc->init_accel(par, info->var.xres, bpp); |
Antonino A. Daplas | 8dad46c | 2005-08-01 23:46:44 +0800 | [diff] [blame] | 1021 | #endif |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1022 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1024 | case 8: |
| 1025 | tmp = 0x00; |
| 1026 | break; |
| 1027 | case 16: |
| 1028 | tmp = 0x05; |
| 1029 | break; |
| 1030 | case 24: |
| 1031 | tmp = 0x29; |
| 1032 | break; |
| 1033 | case 32: |
| 1034 | tmp = 0x09; |
| 1035 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1038 | write3X4(par, PixelBusReg, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | |
| 1040 | tmp = 0x10; |
| 1041 | if (chipcyber) |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1042 | tmp |= 0x20; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1043 | write3X4(par, DRAMControl, tmp); /* both IO, linear enable */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1045 | write3X4(par, InterfaceSel, read3X4(par, InterfaceSel) | 0x40); |
| 1046 | write3X4(par, Performance, 0x92); |
| 1047 | /* MMIO & PCI read and write burst enable */ |
| 1048 | write3X4(par, PCIReg, 0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 1050 | /* convert from picoseconds to kHz */ |
| 1051 | vclk = PICOS2KHZ(info->var.pixclock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | if (bpp == 32) |
Krzysztof Helt | 3f275ea | 2008-05-12 14:02:11 -0700 | [diff] [blame] | 1053 | vclk *= 2; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1054 | set_vclk(par, vclk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1056 | write3C4(par, 0, 3); |
| 1057 | write3C4(par, 1, 1); /* set char clock 8 dots wide */ |
| 1058 | /* enable 4 maps because needed in chain4 mode */ |
| 1059 | write3C4(par, 2, 0x0F); |
| 1060 | write3C4(par, 3, 0); |
| 1061 | write3C4(par, 4, 0x0E); /* memory mode enable bitmaps ?? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1063 | /* divide clock by 2 if 32bpp chain4 mode display and CPU path */ |
| 1064 | write3CE(par, MiscExtFunc, (bpp == 32) ? 0x1A : 0x12); |
| 1065 | write3CE(par, 0x5, 0x40); /* no CGA compat, allow 256 col */ |
| 1066 | write3CE(par, 0x6, 0x05); /* graphics mode */ |
| 1067 | write3CE(par, 0x7, 0x0F); /* planes? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
| 1069 | if (chip_id == CYBERBLADEXPAi1) { |
| 1070 | /* This fixes snow-effect in 32 bpp */ |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1071 | write3X4(par, CRTHSyncStart, 0x84); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1074 | /* graphics mode and support 256 color modes */ |
| 1075 | writeAttr(par, 0x10, 0x41); |
| 1076 | writeAttr(par, 0x12, 0x0F); /* planes */ |
| 1077 | writeAttr(par, 0x13, 0); /* horizontal pel panning */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1079 | /* colors */ |
| 1080 | for (tmp = 0; tmp < 0x10; tmp++) |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1081 | writeAttr(par, tmp, tmp); |
| 1082 | fb_readb(par->io_virt + CRT + 0x0A); /* flip-flop to index */ |
| 1083 | t_outb(par, 0x20, 0x3C0); /* enable attr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | |
| 1085 | switch (bpp) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1086 | case 8: |
| 1087 | tmp = 0; |
| 1088 | break; |
| 1089 | case 15: |
| 1090 | tmp = 0x10; |
| 1091 | break; |
| 1092 | case 16: |
| 1093 | tmp = 0x30; |
| 1094 | break; |
| 1095 | case 24: |
| 1096 | case 32: |
| 1097 | tmp = 0xD0; |
| 1098 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1101 | t_inb(par, 0x3C8); |
| 1102 | t_inb(par, 0x3C6); |
| 1103 | t_inb(par, 0x3C6); |
| 1104 | t_inb(par, 0x3C6); |
| 1105 | t_inb(par, 0x3C6); |
| 1106 | t_outb(par, tmp, 0x3C6); |
| 1107 | t_inb(par, 0x3C8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | |
| 1109 | if (flatpanel) |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1110 | set_number_of_lines(par, info->var.yres); |
| 1111 | set_lwidth(par, info->var.xres * bpp / (4 * 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | info->fix.visual = (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1113 | info->fix.line_length = info->var.xres * (bpp >> 3); |
| 1114 | info->cmap.len = (bpp == 8) ? 256 : 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | debug("exit\n"); |
| 1116 | return 0; |
| 1117 | } |
| 1118 | |
| 1119 | /* Set one color register */ |
| 1120 | static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1121 | unsigned blue, unsigned transp, |
| 1122 | struct fb_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | { |
| 1124 | int bpp = info->var.bits_per_pixel; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1125 | struct tridentfb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | |
| 1127 | if (regno >= info->cmap.len) |
| 1128 | return 1; |
| 1129 | |
Antonino A. Daplas | 973d9ab | 2007-07-17 04:05:41 -0700 | [diff] [blame] | 1130 | if (bpp == 8) { |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1131 | t_outb(par, 0xFF, 0x3C6); |
| 1132 | t_outb(par, regno, 0x3C8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1134 | t_outb(par, red >> 10, 0x3C9); |
| 1135 | t_outb(par, green >> 10, 0x3C9); |
| 1136 | t_outb(par, blue >> 10, 0x3C9); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | |
Antonino A. Daplas | 973d9ab | 2007-07-17 04:05:41 -0700 | [diff] [blame] | 1138 | } else if (regno < 16) { |
| 1139 | if (bpp == 16) { /* RGB 565 */ |
| 1140 | u32 col; |
Antonino A. Daplas | 8dad46c | 2005-08-01 23:46:44 +0800 | [diff] [blame] | 1141 | |
Antonino A. Daplas | 973d9ab | 2007-07-17 04:05:41 -0700 | [diff] [blame] | 1142 | col = (red & 0xF800) | ((green & 0xFC00) >> 5) | |
| 1143 | ((blue & 0xF800) >> 11); |
| 1144 | col |= col << 16; |
| 1145 | ((u32 *)(info->pseudo_palette))[regno] = col; |
| 1146 | } else if (bpp == 32) /* ARGB 8888 */ |
| 1147 | ((u32*)info->pseudo_palette)[regno] = |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1148 | ((transp & 0xFF00) << 16) | |
| 1149 | ((red & 0xFF00) << 8) | |
Antonino A. Daplas | 973d9ab | 2007-07-17 04:05:41 -0700 | [diff] [blame] | 1150 | ((green & 0xFF00)) | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1151 | ((blue & 0xFF00) >> 8); |
Antonino A. Daplas | 973d9ab | 2007-07-17 04:05:41 -0700 | [diff] [blame] | 1152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1154 | /* debug("exit\n"); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | return 0; |
| 1156 | } |
| 1157 | |
| 1158 | /* Try blanking the screen.For flat panels it does nothing */ |
| 1159 | static int tridentfb_blank(int blank_mode, struct fb_info *info) |
| 1160 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1161 | unsigned char PMCont, DPMSCont; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1162 | struct tridentfb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | |
| 1164 | debug("enter\n"); |
| 1165 | if (flatpanel) |
| 1166 | return 0; |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1167 | t_outb(par, 0x04, 0x83C8); /* Read DPMS Control */ |
| 1168 | PMCont = t_inb(par, 0x83C6) & 0xFC; |
| 1169 | DPMSCont = read3CE(par, PowerStatus) & 0xFC; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1170 | switch (blank_mode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | case FB_BLANK_UNBLANK: |
| 1172 | /* Screen: On, HSync: On, VSync: On */ |
| 1173 | case FB_BLANK_NORMAL: |
| 1174 | /* Screen: Off, HSync: On, VSync: On */ |
| 1175 | PMCont |= 0x03; |
| 1176 | DPMSCont |= 0x00; |
| 1177 | break; |
| 1178 | case FB_BLANK_HSYNC_SUSPEND: |
| 1179 | /* Screen: Off, HSync: Off, VSync: On */ |
| 1180 | PMCont |= 0x02; |
| 1181 | DPMSCont |= 0x01; |
| 1182 | break; |
| 1183 | case FB_BLANK_VSYNC_SUSPEND: |
| 1184 | /* Screen: Off, HSync: On, VSync: Off */ |
| 1185 | PMCont |= 0x02; |
| 1186 | DPMSCont |= 0x02; |
| 1187 | break; |
| 1188 | case FB_BLANK_POWERDOWN: |
| 1189 | /* Screen: Off, HSync: Off, VSync: Off */ |
| 1190 | PMCont |= 0x00; |
| 1191 | DPMSCont |= 0x03; |
| 1192 | break; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1193 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | |
Krzysztof Helt | 306fa6f6 | 2008-07-23 21:30:50 -0700 | [diff] [blame] | 1195 | write3CE(par, PowerStatus, DPMSCont); |
| 1196 | t_outb(par, 4, 0x83C8); |
| 1197 | t_outb(par, PMCont, 0x83C6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | |
| 1199 | debug("exit\n"); |
| 1200 | |
| 1201 | /* let fbcon do a softblank for us */ |
| 1202 | return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0; |
| 1203 | } |
| 1204 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1205 | static struct fb_ops tridentfb_ops = { |
| 1206 | .owner = THIS_MODULE, |
| 1207 | .fb_setcolreg = tridentfb_setcolreg, |
| 1208 | .fb_pan_display = tridentfb_pan_display, |
| 1209 | .fb_blank = tridentfb_blank, |
| 1210 | .fb_check_var = tridentfb_check_var, |
| 1211 | .fb_set_par = tridentfb_set_par, |
| 1212 | .fb_fillrect = tridentfb_fillrect, |
| 1213 | .fb_copyarea = tridentfb_copyarea, |
| 1214 | .fb_imageblit = cfb_imageblit, |
| 1215 | }; |
| 1216 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1217 | static int __devinit trident_pci_probe(struct pci_dev *dev, |
| 1218 | const struct pci_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | { |
| 1220 | int err; |
| 1221 | unsigned char revision; |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1222 | struct fb_info *info; |
| 1223 | struct tridentfb_par *default_par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | |
| 1225 | err = pci_enable_device(dev); |
| 1226 | if (err) |
| 1227 | return err; |
| 1228 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1229 | info = framebuffer_alloc(sizeof(struct tridentfb_par), &dev->dev); |
| 1230 | if (!info) |
| 1231 | return -ENOMEM; |
| 1232 | default_par = info->par; |
| 1233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | chip_id = id->device; |
| 1235 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1236 | if (chip_id == CYBERBLADEi1) |
Knut Petersen | 9fa68ea | 2005-09-09 13:04:56 -0700 | [diff] [blame] | 1237 | output("*** Please do use cyblafb, Cyberblade/i1 support " |
| 1238 | "will soon be removed from tridentfb!\n"); |
| 1239 | |
| 1240 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1241 | /* If PCI id is 0x9660 then further detect chip type */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1242 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | if (chip_id == TGUI9660) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1244 | outb(RevisionID, 0x3C4); |
| 1245 | revision = inb(0x3C5); |
| 1246 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | switch (revision) { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1248 | case 0x22: |
| 1249 | case 0x23: |
| 1250 | chip_id = CYBER9397; |
| 1251 | break; |
| 1252 | case 0x2A: |
| 1253 | chip_id = CYBER9397DVD; |
| 1254 | break; |
| 1255 | case 0x30: |
| 1256 | case 0x33: |
| 1257 | case 0x34: |
| 1258 | case 0x35: |
| 1259 | case 0x38: |
| 1260 | case 0x3A: |
| 1261 | case 0xB3: |
| 1262 | chip_id = CYBER9385; |
| 1263 | break; |
| 1264 | case 0x40 ... 0x43: |
| 1265 | chip_id = CYBER9382; |
| 1266 | break; |
| 1267 | case 0x4A: |
| 1268 | chip_id = CYBER9388; |
| 1269 | break; |
| 1270 | default: |
| 1271 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | chip3D = is3Dchip(chip_id); |
| 1276 | chipcyber = iscyber(chip_id); |
| 1277 | |
| 1278 | if (is_xp(chip_id)) { |
| 1279 | acc = &accel_xp; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1280 | } else if (is_blade(chip_id)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | acc = &accel_blade; |
| 1282 | } else { |
| 1283 | acc = &accel_image; |
| 1284 | } |
| 1285 | |
| 1286 | /* acceleration is on by default for 3D chips */ |
| 1287 | defaultaccel = chip3D && !noaccel; |
| 1288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | /* setup MMIO region */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1290 | tridentfb_fix.mmio_start = pci_resource_start(dev, 1); |
| 1291 | tridentfb_fix.mmio_len = chip3D ? 0x20000 : 0x10000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | |
| 1293 | if (!request_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len, "tridentfb")) { |
| 1294 | debug("request_region failed!\n"); |
| 1295 | return -1; |
| 1296 | } |
| 1297 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1298 | default_par->io_virt = ioremap_nocache(tridentfb_fix.mmio_start, |
| 1299 | tridentfb_fix.mmio_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1301 | if (!default_par->io_virt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | debug("ioremap failed\n"); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1303 | err = -1; |
| 1304 | goto out_unmap1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | enable_mmio(); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | /* setup framebuffer memory */ |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1310 | tridentfb_fix.smem_start = pci_resource_start(dev, 0); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1311 | tridentfb_fix.smem_len = get_memsize(default_par); |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) { |
| 1314 | debug("request_mem_region failed!\n"); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1315 | disable_mmio(info->par); |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1316 | err = -1; |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1317 | goto out_unmap1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1320 | info->screen_base = ioremap_nocache(tridentfb_fix.smem_start, |
| 1321 | tridentfb_fix.smem_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1323 | if (!info->screen_base) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | debug("ioremap failed\n"); |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1325 | err = -1; |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1326 | goto out_unmap2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | output("%s board found\n", pci_name(dev)); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1330 | displaytype = get_displaytype(default_par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1332 | if (flatpanel) |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1333 | nativex = get_nativex(default_par); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1335 | info->fix = tridentfb_fix; |
| 1336 | info->fbops = &tridentfb_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | |
| 1338 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1339 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | #ifdef CONFIG_FB_TRIDENT_ACCEL |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1341 | info->flags |= FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | #endif |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1343 | info->pseudo_palette = pseudo_pal; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1345 | if (!fb_find_mode(&default_var, info, |
Krzysztof Helt | 07f41e4 | 2008-04-28 02:15:06 -0700 | [diff] [blame] | 1346 | mode_option, NULL, 0, NULL, bpp)) { |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1347 | err = -EINVAL; |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1348 | goto out_unmap2; |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1349 | } |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1350 | err = fb_alloc_cmap(&info->cmap, 256, 0); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1351 | if (err < 0) |
| 1352 | goto out_unmap2; |
| 1353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | if (defaultaccel && acc) |
| 1355 | default_var.accel_flags |= FB_ACCELF_TEXT; |
| 1356 | else |
| 1357 | default_var.accel_flags &= ~FB_ACCELF_TEXT; |
| 1358 | default_var.activate |= FB_ACTIVATE_NOW; |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1359 | info->var = default_var; |
| 1360 | info->device = &dev->dev; |
| 1361 | if (register_framebuffer(info) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n"); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1363 | fb_dealloc_cmap(&info->cmap); |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1364 | err = -EINVAL; |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1365 | goto out_unmap2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | } |
| 1367 | output("fb%d: %s frame buffer device %dx%d-%dbpp\n", |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1368 | info->node, info->fix.id, default_var.xres, |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1369 | default_var.yres, default_var.bits_per_pixel); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1370 | |
| 1371 | pci_set_drvdata(dev, info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | return 0; |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1373 | |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1374 | out_unmap2: |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1375 | if (info->screen_base) |
| 1376 | iounmap(info->screen_base); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1377 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1378 | disable_mmio(info->par); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1379 | out_unmap1: |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1380 | if (default_par->io_virt) |
| 1381 | iounmap(default_par->io_virt); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1382 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1383 | framebuffer_release(info); |
Amol Lad | a02f640 | 2006-12-08 02:40:03 -0800 | [diff] [blame] | 1384 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | } |
| 1386 | |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1387 | static void __devexit trident_pci_remove(struct pci_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | { |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1389 | struct fb_info *info = pci_get_drvdata(dev); |
| 1390 | struct tridentfb_par *par = info->par; |
| 1391 | |
| 1392 | unregister_framebuffer(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | iounmap(par->io_virt); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1394 | iounmap(info->screen_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); |
Krzysztof Helt | e8ed857 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1396 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); |
Krzysztof Helt | e09ed09 | 2008-07-23 21:30:51 -0700 | [diff] [blame^] | 1397 | pci_set_drvdata(dev, NULL); |
| 1398 | framebuffer_release(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | /* List of boards that we are trying to support */ |
| 1402 | static struct pci_device_id trident_devices[] = { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1403 | {PCI_VENDOR_ID_TRIDENT, BLADE3D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1404 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1405 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1406 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1407 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1408 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1409 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1410 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEE4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1411 | {PCI_VENDOR_ID_TRIDENT, TGUI9660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1412 | {PCI_VENDOR_ID_TRIDENT, IMAGE975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1413 | {PCI_VENDOR_ID_TRIDENT, IMAGE985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1414 | {PCI_VENDOR_ID_TRIDENT, CYBER9320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1415 | {PCI_VENDOR_ID_TRIDENT, CYBER9388, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1416 | {PCI_VENDOR_ID_TRIDENT, CYBER9520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1417 | {PCI_VENDOR_ID_TRIDENT, CYBER9525DVD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1418 | {PCI_VENDOR_ID_TRIDENT, CYBER9397, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1419 | {PCI_VENDOR_ID_TRIDENT, CYBER9397DVD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1420 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1421 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 1422 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm16, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | {0,} |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1424 | }; |
| 1425 | |
| 1426 | MODULE_DEVICE_TABLE(pci, trident_devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | |
| 1428 | static struct pci_driver tridentfb_pci_driver = { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1429 | .name = "tridentfb", |
| 1430 | .id_table = trident_devices, |
| 1431 | .probe = trident_pci_probe, |
| 1432 | .remove = __devexit_p(trident_pci_remove) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | }; |
| 1434 | |
| 1435 | /* |
| 1436 | * Parse user specified options (`video=trident:') |
| 1437 | * example: |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1438 | * video=trident:800x600,bpp=16,noaccel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | */ |
| 1440 | #ifndef MODULE |
Krzysztof Helt | 07f41e4 | 2008-04-28 02:15:06 -0700 | [diff] [blame] | 1441 | static int __init tridentfb_setup(char *options) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | { |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1443 | char *opt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | if (!options || !*options) |
| 1445 | return 0; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1446 | while ((opt = strsep(&options, ",")) != NULL) { |
| 1447 | if (!*opt) |
| 1448 | continue; |
| 1449 | if (!strncmp(opt, "noaccel", 7)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | noaccel = 1; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1451 | else if (!strncmp(opt, "fp", 2)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1452 | displaytype = DISPLAY_FP; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1453 | else if (!strncmp(opt, "crt", 3)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | displaytype = DISPLAY_CRT; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1455 | else if (!strncmp(opt, "bpp=", 4)) |
| 1456 | bpp = simple_strtoul(opt + 4, NULL, 0); |
| 1457 | else if (!strncmp(opt, "center", 6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | center = 1; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1459 | else if (!strncmp(opt, "stretch", 7)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1460 | stretch = 1; |
Krzysztof Helt | 245a2c2 | 2007-10-16 01:28:42 -0700 | [diff] [blame] | 1461 | else if (!strncmp(opt, "memsize=", 8)) |
| 1462 | memsize = simple_strtoul(opt + 8, NULL, 0); |
| 1463 | else if (!strncmp(opt, "memdiff=", 8)) |
| 1464 | memdiff = simple_strtoul(opt + 8, NULL, 0); |
| 1465 | else if (!strncmp(opt, "nativex=", 8)) |
| 1466 | nativex = simple_strtoul(opt + 8, NULL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | else |
Krzysztof Helt | 07f41e4 | 2008-04-28 02:15:06 -0700 | [diff] [blame] | 1468 | mode_option = opt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | } |
| 1470 | return 0; |
| 1471 | } |
| 1472 | #endif |
| 1473 | |
| 1474 | static int __init tridentfb_init(void) |
| 1475 | { |
| 1476 | #ifndef MODULE |
| 1477 | char *option = NULL; |
| 1478 | |
| 1479 | if (fb_get_options("tridentfb", &option)) |
| 1480 | return -ENODEV; |
| 1481 | tridentfb_setup(option); |
| 1482 | #endif |
| 1483 | output("Trident framebuffer %s initializing\n", VERSION); |
| 1484 | return pci_register_driver(&tridentfb_pci_driver); |
| 1485 | } |
| 1486 | |
| 1487 | static void __exit tridentfb_exit(void) |
| 1488 | { |
| 1489 | pci_unregister_driver(&tridentfb_pci_driver); |
| 1490 | } |
| 1491 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | module_init(tridentfb_init); |
| 1493 | module_exit(tridentfb_exit); |
| 1494 | |
| 1495 | MODULE_AUTHOR("Jani Monoses <jani@iv.ro>"); |
| 1496 | MODULE_DESCRIPTION("Framebuffer driver for Trident cards"); |
| 1497 | MODULE_LICENSE("GPL"); |
| 1498 | |