Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200 and G400 |
| 4 | * |
| 5 | * (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz> |
| 6 | * |
| 7 | * Portions Copyright (c) 2001 Matrox Graphics Inc. |
| 8 | * |
| 9 | * Version: 1.65 2002/08/14 |
| 10 | * |
| 11 | * MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org> |
| 12 | * |
| 13 | * Contributors: "menion?" <menion@mindless.com> |
| 14 | * Betatesting, fixes, ideas |
| 15 | * |
| 16 | * "Kurt Garloff" <garloff@suse.de> |
| 17 | * Betatesting, fixes, ideas, videomodes, videomodes timmings |
| 18 | * |
| 19 | * "Tom Rini" <trini@kernel.crashing.org> |
| 20 | * MTRR stuff, PPC cleanups, betatesting, fixes, ideas |
| 21 | * |
| 22 | * "Bibek Sahu" <scorpio@dodds.net> |
| 23 | * Access device through readb|w|l and write b|w|l |
| 24 | * Extensive debugging stuff |
| 25 | * |
| 26 | * "Daniel Haun" <haund@usa.net> |
| 27 | * Testing, hardware cursor fixes |
| 28 | * |
| 29 | * "Scott Wood" <sawst46+@pitt.edu> |
| 30 | * Fixes |
| 31 | * |
| 32 | * "Gerd Knorr" <kraxel@goldbach.isdn.cs.tu-berlin.de> |
| 33 | * Betatesting |
| 34 | * |
| 35 | * "Kelly French" <targon@hazmat.com> |
| 36 | * "Fernando Herrera" <fherrera@eurielec.etsit.upm.es> |
| 37 | * Betatesting, bug reporting |
| 38 | * |
| 39 | * "Pablo Bianucci" <pbian@pccp.com.ar> |
| 40 | * Fixes, ideas, betatesting |
| 41 | * |
| 42 | * "Inaky Perez Gonzalez" <inaky@peloncho.fis.ucm.es> |
| 43 | * Fixes, enhandcements, ideas, betatesting |
| 44 | * |
| 45 | * "Ryuichi Oikawa" <roikawa@rr.iiij4u.or.jp> |
| 46 | * PPC betatesting, PPC support, backward compatibility |
| 47 | * |
| 48 | * "Paul Womar" <Paul@pwomar.demon.co.uk> |
| 49 | * "Owen Waller" <O.Waller@ee.qub.ac.uk> |
| 50 | * PPC betatesting |
| 51 | * |
| 52 | * "Thomas Pornin" <pornin@bolet.ens.fr> |
| 53 | * Alpha betatesting |
| 54 | * |
| 55 | * "Pieter van Leuven" <pvl@iae.nl> |
| 56 | * "Ulf Jaenicke-Roessler" <ujr@physik.phy.tu-dresden.de> |
| 57 | * G100 testing |
| 58 | * |
| 59 | * "H. Peter Arvin" <hpa@transmeta.com> |
| 60 | * Ideas |
| 61 | * |
| 62 | * "Cort Dougan" <cort@cs.nmt.edu> |
| 63 | * CHRP fixes and PReP cleanup |
| 64 | * |
| 65 | * "Mark Vojkovich" <mvojkovi@ucsd.edu> |
| 66 | * G400 support |
| 67 | * |
| 68 | * "Samuel Hocevar" <sam@via.ecp.fr> |
| 69 | * Fixes |
| 70 | * |
| 71 | * "Anton Altaparmakov" <AntonA@bigfoot.com> |
| 72 | * G400 MAX/non-MAX distinction |
| 73 | * |
| 74 | * "Ken Aaker" <kdaaker@rchland.vnet.ibm.com> |
| 75 | * memtype extension (needed for GXT130P RS/6000 adapter) |
| 76 | * |
| 77 | * "Uns Lider" <unslider@miranda.org> |
| 78 | * G100 PLNWT fixes |
| 79 | * |
| 80 | * "Denis Zaitsev" <zzz@cd-club.ru> |
| 81 | * Fixes |
| 82 | * |
| 83 | * "Mike Pieper" <mike@pieper-family.de> |
| 84 | * TVOut enhandcements, V4L2 control interface. |
| 85 | * |
| 86 | * "Diego Biurrun" <diego@biurrun.de> |
| 87 | * DFP testing |
| 88 | * |
| 89 | * (following author is not in any relation with this code, but his code |
| 90 | * is included in this driver) |
| 91 | * |
| 92 | * Based on framebuffer driver for VBE 2.0 compliant graphic boards |
| 93 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> |
| 94 | * |
| 95 | * (following author is not in any relation with this code, but his ideas |
Robert P. J. Day | beb7dd8 | 2007-05-09 07:14:03 +0200 | [diff] [blame] | 96 | * were used when writing this driver) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | * |
| 98 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> |
| 99 | * |
| 100 | */ |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #include <linux/version.h> |
| 103 | |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 104 | #define __OLD_VIDIOC_ |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #include "matroxfb_base.h" |
| 107 | #include "matroxfb_misc.h" |
| 108 | #include "matroxfb_accel.h" |
| 109 | #include "matroxfb_DAC1064.h" |
| 110 | #include "matroxfb_Ti3026.h" |
| 111 | #include "matroxfb_maven.h" |
| 112 | #include "matroxfb_crtc2.h" |
| 113 | #include "matroxfb_g450.h" |
| 114 | #include <linux/matroxfb.h> |
| 115 | #include <linux/interrupt.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 116 | #include <linux/slab.h> |
Krzysztof Helt | 84902b7 | 2007-10-16 01:29:04 -0700 | [diff] [blame] | 117 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
| 119 | #ifdef CONFIG_PPC_PMAC |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 120 | #include <asm/machdep.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | unsigned char nvram_read_byte(int); |
| 122 | static int default_vmode = VMODE_NVRAM; |
| 123 | static int default_cmode = CMODE_NVRAM; |
| 124 | #endif |
| 125 | |
| 126 | static void matroxfb_unregister_device(struct matrox_fb_info* minfo); |
| 127 | |
| 128 | /* --------------------------------------------------------------------- */ |
| 129 | |
| 130 | /* |
| 131 | * card parameters |
| 132 | */ |
| 133 | |
| 134 | /* --------------------------------------------------------------------- */ |
| 135 | |
| 136 | static struct fb_var_screeninfo vesafb_defined = { |
| 137 | 640,480,640,480,/* W,H, W, H (virtual) load xres,xres_virtual*/ |
| 138 | 0,0, /* virtual -> visible no offset */ |
| 139 | 8, /* depth -> load bits_per_pixel */ |
| 140 | 0, /* greyscale ? */ |
| 141 | {0,0,0}, /* R */ |
| 142 | {0,0,0}, /* G */ |
| 143 | {0,0,0}, /* B */ |
| 144 | {0,0,0}, /* transparency */ |
| 145 | 0, /* standard pixel format */ |
| 146 | FB_ACTIVATE_NOW, |
| 147 | -1,-1, |
| 148 | FB_ACCELF_TEXT, /* accel flags */ |
| 149 | 39721L,48L,16L,33L,10L, |
| 150 | 96L,2L,~0, /* No sync info */ |
| 151 | FB_VMODE_NONINTERLACED, |
| 152 | 0, {0,0,0,0,0} |
| 153 | }; |
| 154 | |
| 155 | |
| 156 | |
| 157 | /* --------------------------------------------------------------------- */ |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 158 | static void update_crtc2(struct matrox_fb_info *minfo, unsigned int pos) |
| 159 | { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 160 | struct matroxfb_dh_fb_info *info = minfo->crtc2.info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | /* Make sure that displays are compatible */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 163 | if (info && (info->fbcon.var.bits_per_pixel == minfo->fbcon.var.bits_per_pixel) |
| 164 | && (info->fbcon.var.xres_virtual == minfo->fbcon.var.xres_virtual) |
| 165 | && (info->fbcon.var.green.length == minfo->fbcon.var.green.length) |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 166 | ) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 167 | switch (minfo->fbcon.var.bits_per_pixel) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | case 16: |
| 169 | case 32: |
| 170 | pos = pos * 8; |
| 171 | if (info->interlaced) { |
| 172 | mga_outl(0x3C2C, pos); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 173 | mga_outl(0x3C28, pos + minfo->fbcon.var.xres_virtual * minfo->fbcon.var.bits_per_pixel / 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } else { |
| 175 | mga_outl(0x3C28, pos); |
| 176 | } |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 182 | static void matroxfb_crtc1_panpos(struct matrox_fb_info *minfo) |
| 183 | { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 184 | if (minfo->crtc1.panpos >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | unsigned long flags; |
| 186 | int panpos; |
| 187 | |
| 188 | matroxfb_DAC_lock_irqsave(flags); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 189 | panpos = minfo->crtc1.panpos; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | if (panpos >= 0) { |
| 191 | unsigned int extvga_reg; |
| 192 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 193 | minfo->crtc1.panpos = -1; /* No update pending anymore */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | extvga_reg = mga_inb(M_EXTVGA_INDEX); |
| 195 | mga_setr(M_EXTVGA_INDEX, 0x00, panpos); |
| 196 | if (extvga_reg != 0x00) { |
| 197 | mga_outb(M_EXTVGA_INDEX, extvga_reg); |
| 198 | } |
| 199 | } |
| 200 | matroxfb_DAC_unlock_irqrestore(flags); |
| 201 | } |
| 202 | } |
| 203 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 204 | static irqreturn_t matrox_irq(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | { |
| 206 | u_int32_t status; |
| 207 | int handled = 0; |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 208 | struct matrox_fb_info *minfo = dev_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
| 210 | status = mga_inl(M_STATUS); |
| 211 | |
| 212 | if (status & 0x20) { |
| 213 | mga_outl(M_ICLEAR, 0x20); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 214 | minfo->crtc1.vsync.cnt++; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 215 | matroxfb_crtc1_panpos(minfo); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 216 | wake_up_interruptible(&minfo->crtc1.vsync.wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | handled = 1; |
| 218 | } |
| 219 | if (status & 0x200) { |
| 220 | mga_outl(M_ICLEAR, 0x200); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 221 | minfo->crtc2.vsync.cnt++; |
| 222 | wake_up_interruptible(&minfo->crtc2.vsync.wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | handled = 1; |
| 224 | } |
| 225 | return IRQ_RETVAL(handled); |
| 226 | } |
| 227 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 228 | int matroxfb_enable_irq(struct matrox_fb_info *minfo, int reenable) |
| 229 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | u_int32_t bm; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 231 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 232 | if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | bm = 0x220; |
| 234 | else |
| 235 | bm = 0x020; |
| 236 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 237 | if (!test_and_set_bit(0, &minfo->irq_flags)) { |
| 238 | if (request_irq(minfo->pcidev->irq, matrox_irq, |
| 239 | IRQF_SHARED, "matroxfb", minfo)) { |
| 240 | clear_bit(0, &minfo->irq_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | return -EINVAL; |
| 242 | } |
| 243 | /* Clear any pending field interrupts */ |
| 244 | mga_outl(M_ICLEAR, bm); |
| 245 | mga_outl(M_IEN, mga_inl(M_IEN) | bm); |
| 246 | } else if (reenable) { |
| 247 | u_int32_t ien; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | ien = mga_inl(M_IEN); |
| 250 | if ((ien & bm) != bm) { |
| 251 | printk(KERN_DEBUG "matroxfb: someone disabled IRQ [%08X]\n", ien); |
| 252 | mga_outl(M_IEN, ien | bm); |
| 253 | } |
| 254 | } |
| 255 | return 0; |
| 256 | } |
| 257 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 258 | static void matroxfb_disable_irq(struct matrox_fb_info *minfo) |
| 259 | { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 260 | if (test_and_clear_bit(0, &minfo->irq_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | /* Flush pending pan-at-vbl request... */ |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 262 | matroxfb_crtc1_panpos(minfo); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 263 | if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | mga_outl(M_IEN, mga_inl(M_IEN) & ~0x220); |
| 265 | else |
| 266 | mga_outl(M_IEN, mga_inl(M_IEN) & ~0x20); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 267 | free_irq(minfo->pcidev->irq, minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 271 | int matroxfb_wait_for_sync(struct matrox_fb_info *minfo, u_int32_t crtc) |
| 272 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | struct matrox_vsync *vs; |
| 274 | unsigned int cnt; |
| 275 | int ret; |
| 276 | |
| 277 | switch (crtc) { |
| 278 | case 0: |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 279 | vs = &minfo->crtc1.vsync; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | break; |
| 281 | case 1: |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 282 | if (minfo->devflags.accelerator != FB_ACCEL_MATROX_MGAG400) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | return -ENODEV; |
| 284 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 285 | vs = &minfo->crtc2.vsync; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | break; |
| 287 | default: |
| 288 | return -ENODEV; |
| 289 | } |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 290 | ret = matroxfb_enable_irq(minfo, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | if (ret) { |
| 292 | return ret; |
| 293 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
| 295 | cnt = vs->cnt; |
| 296 | ret = wait_event_interruptible_timeout(vs->wait, cnt != vs->cnt, HZ/10); |
| 297 | if (ret < 0) { |
| 298 | return ret; |
| 299 | } |
| 300 | if (ret == 0) { |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 301 | matroxfb_enable_irq(minfo, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | return -ETIMEDOUT; |
| 303 | } |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | /* --------------------------------------------------------------------- */ |
| 308 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 309 | static void matrox_pan_var(struct matrox_fb_info *minfo, |
| 310 | struct fb_var_screeninfo *var) |
| 311 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | unsigned int pos; |
| 313 | unsigned short p0, p1, p2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | unsigned int p3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | int vbl; |
| 316 | unsigned long flags; |
| 317 | |
| 318 | CRITFLAGS |
| 319 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 320 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 322 | if (minfo->dead) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | return; |
| 324 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 325 | minfo->fbcon.var.xoffset = var->xoffset; |
| 326 | minfo->fbcon.var.yoffset = var->yoffset; |
| 327 | pos = (minfo->fbcon.var.yoffset * minfo->fbcon.var.xres_virtual + minfo->fbcon.var.xoffset) * minfo->curr.final_bppShift / 32; |
| 328 | pos += minfo->curr.ydstorg.chunks; |
| 329 | p0 = minfo->hw.CRTC[0x0D] = pos & 0xFF; |
| 330 | p1 = minfo->hw.CRTC[0x0C] = (pos & 0xFF00) >> 8; |
| 331 | p2 = minfo->hw.CRTCEXT[0] = (minfo->hw.CRTCEXT[0] & 0xB0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 332 | p3 = minfo->hw.CRTCEXT[8] = pos >> 21; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | /* FB_ACTIVATE_VBL and we can acquire interrupts? Honor FB_ACTIVATE_VBL then... */ |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 335 | vbl = (var->activate & FB_ACTIVATE_VBL) && (matroxfb_enable_irq(minfo, 0) == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
| 337 | CRITBEGIN |
| 338 | |
| 339 | matroxfb_DAC_lock_irqsave(flags); |
| 340 | mga_setr(M_CRTC_INDEX, 0x0D, p0); |
| 341 | mga_setr(M_CRTC_INDEX, 0x0C, p1); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 342 | if (minfo->devflags.support32MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | mga_setr(M_EXTVGA_INDEX, 0x08, p3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | if (vbl) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 345 | minfo->crtc1.panpos = p2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } else { |
| 347 | /* Abort any pending change */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 348 | minfo->crtc1.panpos = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | mga_setr(M_EXTVGA_INDEX, 0x00, p2); |
| 350 | } |
| 351 | matroxfb_DAC_unlock_irqrestore(flags); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 352 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 353 | update_crtc2(minfo, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
| 355 | CRITEND |
| 356 | } |
| 357 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 358 | static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy) |
| 359 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | /* Currently we are holding big kernel lock on all dead & usecount updates. |
| 361 | * Destroy everything after all users release it. Especially do not unregister |
| 362 | * framebuffer and iounmap memory, neither fbmem nor fbcon-cfb* does not check |
| 363 | * for device unplugged when in use. |
| 364 | * In future we should point mmio.vbase & video.vbase somewhere where we can |
| 365 | * write data without causing too much damage... |
| 366 | */ |
| 367 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 368 | minfo->dead = 1; |
| 369 | if (minfo->usecount) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | /* destroy it later */ |
| 371 | return; |
| 372 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 373 | matroxfb_unregister_device(minfo); |
| 374 | unregister_framebuffer(&minfo->fbcon); |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 375 | matroxfb_g450_shutdown(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | #ifdef CONFIG_MTRR |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 377 | if (minfo->mtrr.vram_valid) |
| 378 | mtrr_del(minfo->mtrr.vram, minfo->video.base, minfo->video.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | #endif |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 380 | mga_iounmap(minfo->mmio.vbase); |
| 381 | mga_iounmap(minfo->video.vbase); |
| 382 | release_mem_region(minfo->video.base, minfo->video.len_maximum); |
| 383 | release_mem_region(minfo->mmio.base, 16384); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | kfree(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* |
| 388 | * Open/Release the frame buffer device |
| 389 | */ |
| 390 | |
| 391 | static int matroxfb_open(struct fb_info *info, int user) |
| 392 | { |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 393 | struct matrox_fb_info *minfo = info2minfo(info); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 394 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 395 | DBG_LOOP(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 397 | if (minfo->dead) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | return -ENXIO; |
| 399 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 400 | minfo->usecount++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | if (user) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 402 | minfo->userusecount++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | return(0); |
| 405 | } |
| 406 | |
| 407 | static int matroxfb_release(struct fb_info *info, int user) |
| 408 | { |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 409 | struct matrox_fb_info *minfo = info2minfo(info); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 410 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 411 | DBG_LOOP(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | |
| 413 | if (user) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 414 | if (0 == --minfo->userusecount) { |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 415 | matroxfb_disable_irq(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | } |
| 417 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 418 | if (!(--minfo->usecount) && minfo->dead) { |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 419 | matroxfb_remove(minfo, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } |
| 421 | return(0); |
| 422 | } |
| 423 | |
| 424 | static int matroxfb_pan_display(struct fb_var_screeninfo *var, |
| 425 | struct fb_info* info) { |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 426 | struct matrox_fb_info *minfo = info2minfo(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 428 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 430 | matrox_pan_var(minfo, var); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | return 0; |
| 432 | } |
| 433 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 434 | static int matroxfb_get_final_bppShift(const struct matrox_fb_info *minfo, |
| 435 | int bpp) |
| 436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | int bppshft2; |
| 438 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 439 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
| 441 | bppshft2 = bpp; |
| 442 | if (!bppshft2) { |
| 443 | return 8; |
| 444 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 445 | if (isInterleave(minfo)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | bppshft2 >>= 1; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 447 | if (minfo->devflags.video64bits) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | bppshft2 >>= 1; |
| 449 | return bppshft2; |
| 450 | } |
| 451 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 452 | static int matroxfb_test_and_set_rounding(const struct matrox_fb_info *minfo, |
| 453 | int xres, int bpp) |
| 454 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | int over; |
| 456 | int rounding; |
| 457 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 458 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
| 460 | switch (bpp) { |
| 461 | case 0: return xres; |
| 462 | case 4: rounding = 128; |
| 463 | break; |
| 464 | case 8: rounding = 64; /* doc says 64; 32 is OK for G400 */ |
| 465 | break; |
| 466 | case 16: rounding = 32; |
| 467 | break; |
| 468 | case 24: rounding = 64; /* doc says 64; 32 is OK for G400 */ |
| 469 | break; |
| 470 | default: rounding = 16; |
| 471 | /* on G400, 16 really does not work */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 472 | if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | rounding = 32; |
| 474 | break; |
| 475 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 476 | if (isInterleave(minfo)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | rounding *= 2; |
| 478 | } |
| 479 | over = xres % rounding; |
| 480 | if (over) |
| 481 | xres += rounding-over; |
| 482 | return xres; |
| 483 | } |
| 484 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 485 | static int matroxfb_pitch_adjust(const struct matrox_fb_info *minfo, int xres, |
| 486 | int bpp) |
| 487 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | const int* width; |
| 489 | int xres_new; |
| 490 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 491 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
| 493 | if (!bpp) return xres; |
| 494 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 495 | width = minfo->capable.vxres; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 497 | if (minfo->devflags.precise_width) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | while (*width) { |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 499 | if ((*width >= xres) && (matroxfb_test_and_set_rounding(minfo, *width, bpp) == *width)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | break; |
| 501 | } |
| 502 | width++; |
| 503 | } |
| 504 | xres_new = *width; |
| 505 | } else { |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 506 | xres_new = matroxfb_test_and_set_rounding(minfo, xres, bpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | return xres_new; |
| 509 | } |
| 510 | |
| 511 | static int matroxfb_get_cmap_len(struct fb_var_screeninfo *var) { |
| 512 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 513 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
| 515 | switch (var->bits_per_pixel) { |
| 516 | case 4: |
| 517 | return 16; /* pseudocolor... 16 entries HW palette */ |
| 518 | case 8: |
| 519 | return 256; /* pseudocolor... 256 entries HW palette */ |
| 520 | case 16: |
| 521 | return 16; /* directcolor... 16 entries SW palette */ |
| 522 | /* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */ |
| 523 | case 24: |
| 524 | return 16; /* directcolor... 16 entries SW palette */ |
| 525 | /* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */ |
| 526 | case 32: |
| 527 | return 16; /* directcolor... 16 entries SW palette */ |
| 528 | /* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */ |
| 529 | } |
| 530 | return 16; /* return something reasonable... or panic()? */ |
| 531 | } |
| 532 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 533 | static int matroxfb_decode_var(const struct matrox_fb_info *minfo, |
| 534 | struct fb_var_screeninfo *var, int *visual, |
| 535 | int *video_cmap_len, unsigned int* ydstorg) |
| 536 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | struct RGBT { |
| 538 | unsigned char bpp; |
| 539 | struct { |
| 540 | unsigned char offset, |
| 541 | length; |
| 542 | } red, |
| 543 | green, |
| 544 | blue, |
| 545 | transp; |
| 546 | signed char visual; |
| 547 | }; |
| 548 | static const struct RGBT table[]= { |
| 549 | { 8,{ 0,8},{0,8},{0,8},{ 0,0},MX_VISUAL_PSEUDOCOLOR}, |
| 550 | {15,{10,5},{5,5},{0,5},{15,1},MX_VISUAL_DIRECTCOLOR}, |
| 551 | {16,{11,5},{5,6},{0,5},{ 0,0},MX_VISUAL_DIRECTCOLOR}, |
| 552 | {24,{16,8},{8,8},{0,8},{ 0,0},MX_VISUAL_DIRECTCOLOR}, |
| 553 | {32,{16,8},{8,8},{0,8},{24,8},MX_VISUAL_DIRECTCOLOR} |
| 554 | }; |
| 555 | struct RGBT const *rgbt; |
| 556 | unsigned int bpp = var->bits_per_pixel; |
| 557 | unsigned int vramlen; |
| 558 | unsigned int memlen; |
| 559 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 560 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | |
| 562 | switch (bpp) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 563 | case 4: if (!minfo->capable.cfb4) return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | break; |
| 565 | case 8: break; |
| 566 | case 16: break; |
| 567 | case 24: break; |
| 568 | case 32: break; |
| 569 | default: return -EINVAL; |
| 570 | } |
| 571 | *ydstorg = 0; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 572 | vramlen = minfo->video.len_usable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | if (var->yres_virtual < var->yres) |
| 574 | var->yres_virtual = var->yres; |
| 575 | if (var->xres_virtual < var->xres) |
| 576 | var->xres_virtual = var->xres; |
| 577 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 578 | var->xres_virtual = matroxfb_pitch_adjust(minfo, var->xres_virtual, bpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | memlen = var->xres_virtual * bpp * var->yres_virtual / 8; |
| 580 | if (memlen > vramlen) { |
| 581 | var->yres_virtual = vramlen * 8 / (var->xres_virtual * bpp); |
| 582 | memlen = var->xres_virtual * bpp * var->yres_virtual / 8; |
| 583 | } |
| 584 | /* There is hardware bug that no line can cross 4MB boundary */ |
| 585 | /* give up for CFB24, it is impossible to easy workaround it */ |
| 586 | /* for other try to do something */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 587 | if (!minfo->capable.cross4MB && (memlen > 0x400000)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | if (bpp == 24) { |
| 589 | /* sorry */ |
| 590 | } else { |
| 591 | unsigned int linelen; |
| 592 | unsigned int m1 = linelen = var->xres_virtual * bpp / 8; |
| 593 | unsigned int m2 = PAGE_SIZE; /* or 128 if you do not need PAGE ALIGNED address */ |
| 594 | unsigned int max_yres; |
| 595 | |
| 596 | while (m1) { |
| 597 | int t; |
| 598 | |
| 599 | while (m2 >= m1) m2 -= m1; |
| 600 | t = m1; |
| 601 | m1 = m2; |
| 602 | m2 = t; |
| 603 | } |
| 604 | m2 = linelen * PAGE_SIZE / m2; |
| 605 | *ydstorg = m2 = 0x400000 % m2; |
| 606 | max_yres = (vramlen - m2) / linelen; |
| 607 | if (var->yres_virtual > max_yres) |
| 608 | var->yres_virtual = max_yres; |
| 609 | } |
| 610 | } |
| 611 | /* YDSTLEN contains only signed 16bit value */ |
| 612 | if (var->yres_virtual > 32767) |
| 613 | var->yres_virtual = 32767; |
| 614 | /* we must round yres/xres down, we already rounded y/xres_virtual up |
| 615 | if it was possible. We should return -EINVAL, but I disagree */ |
| 616 | if (var->yres_virtual < var->yres) |
| 617 | var->yres = var->yres_virtual; |
| 618 | if (var->xres_virtual < var->xres) |
| 619 | var->xres = var->xres_virtual; |
| 620 | if (var->xoffset + var->xres > var->xres_virtual) |
| 621 | var->xoffset = var->xres_virtual - var->xres; |
| 622 | if (var->yoffset + var->yres > var->yres_virtual) |
| 623 | var->yoffset = var->yres_virtual - var->yres; |
| 624 | |
| 625 | if (bpp == 16 && var->green.length == 5) { |
| 626 | bpp--; /* an artifical value - 15 */ |
| 627 | } |
| 628 | |
| 629 | for (rgbt = table; rgbt->bpp < bpp; rgbt++); |
| 630 | #define SETCLR(clr)\ |
| 631 | var->clr.offset = rgbt->clr.offset;\ |
| 632 | var->clr.length = rgbt->clr.length |
| 633 | SETCLR(red); |
| 634 | SETCLR(green); |
| 635 | SETCLR(blue); |
| 636 | SETCLR(transp); |
| 637 | #undef SETCLR |
| 638 | *visual = rgbt->visual; |
| 639 | |
| 640 | if (bpp > 8) |
| 641 | dprintk("matroxfb: truecolor: " |
| 642 | "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n", |
| 643 | var->transp.length, var->red.length, var->green.length, var->blue.length, |
| 644 | var->transp.offset, var->red.offset, var->green.offset, var->blue.offset); |
| 645 | |
| 646 | *video_cmap_len = matroxfb_get_cmap_len(var); |
| 647 | dprintk(KERN_INFO "requested %d*%d/%dbpp (%d*%d)\n", var->xres, var->yres, var->bits_per_pixel, |
| 648 | var->xres_virtual, var->yres_virtual); |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 653 | unsigned blue, unsigned transp, |
| 654 | struct fb_info *fb_info) |
| 655 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 658 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
| 660 | /* |
| 661 | * Set a single color register. The values supplied are |
| 662 | * already rounded down to the hardware's capabilities |
| 663 | * (according to the entries in the `var' structure). Return |
| 664 | * != 0 for invalid regno. |
| 665 | */ |
| 666 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 667 | if (regno >= minfo->curr.cmap_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | return 1; |
| 669 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 670 | if (minfo->fbcon.var.grayscale) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | /* gray = 0.30*R + 0.59*G + 0.11*B */ |
| 672 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; |
| 673 | } |
| 674 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 675 | red = CNVT_TOHW(red, minfo->fbcon.var.red.length); |
| 676 | green = CNVT_TOHW(green, minfo->fbcon.var.green.length); |
| 677 | blue = CNVT_TOHW(blue, minfo->fbcon.var.blue.length); |
| 678 | transp = CNVT_TOHW(transp, minfo->fbcon.var.transp.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 680 | switch (minfo->fbcon.var.bits_per_pixel) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | case 4: |
| 682 | case 8: |
| 683 | mga_outb(M_DAC_REG, regno); |
| 684 | mga_outb(M_DAC_VAL, red); |
| 685 | mga_outb(M_DAC_VAL, green); |
| 686 | mga_outb(M_DAC_VAL, blue); |
| 687 | break; |
| 688 | case 16: |
Antonino A. Daplas | 08a498d | 2007-07-17 04:05:45 -0700 | [diff] [blame] | 689 | if (regno >= 16) |
| 690 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | { |
| 692 | u_int16_t col = |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 693 | (red << minfo->fbcon.var.red.offset) | |
| 694 | (green << minfo->fbcon.var.green.offset) | |
| 695 | (blue << minfo->fbcon.var.blue.offset) | |
| 696 | (transp << minfo->fbcon.var.transp.offset); /* for 1:5:5:5 */ |
| 697 | minfo->cmap[regno] = col | (col << 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | } |
| 699 | break; |
| 700 | case 24: |
| 701 | case 32: |
Antonino A. Daplas | 08a498d | 2007-07-17 04:05:45 -0700 | [diff] [blame] | 702 | if (regno >= 16) |
| 703 | break; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 704 | minfo->cmap[regno] = |
| 705 | (red << minfo->fbcon.var.red.offset) | |
| 706 | (green << minfo->fbcon.var.green.offset) | |
| 707 | (blue << minfo->fbcon.var.blue.offset) | |
| 708 | (transp << minfo->fbcon.var.transp.offset); /* 8:8:8:8 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | break; |
| 710 | } |
| 711 | return 0; |
| 712 | } |
| 713 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 714 | static void matroxfb_init_fix(struct matrox_fb_info *minfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 716 | struct fb_fix_screeninfo *fix = &minfo->fbcon.fix; |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 717 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | |
| 719 | strcpy(fix->id,"MATROX"); |
| 720 | |
| 721 | fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */ |
| 722 | fix->ypanstep = 1; |
| 723 | fix->ywrapstep = 0; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 724 | fix->mmio_start = minfo->mmio.base; |
| 725 | fix->mmio_len = minfo->mmio.len; |
| 726 | fix->accel = minfo->devflags.accelerator; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 729 | static void matroxfb_update_fix(struct matrox_fb_info *minfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 731 | struct fb_fix_screeninfo *fix = &minfo->fbcon.fix; |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 732 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 734 | mutex_lock(&minfo->fbcon.mm_lock); |
| 735 | fix->smem_start = minfo->video.base + minfo->curr.ydstorg.bytes; |
| 736 | fix->smem_len = minfo->video.len_usable - minfo->curr.ydstorg.bytes; |
| 737 | mutex_unlock(&minfo->fbcon.mm_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
| 741 | { |
| 742 | int err; |
| 743 | int visual; |
| 744 | int cmap_len; |
| 745 | unsigned int ydstorg; |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 746 | struct matrox_fb_info *minfo = info2minfo(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 748 | if (minfo->dead) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | return -ENXIO; |
| 750 | } |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 751 | if ((err = matroxfb_decode_var(minfo, var, &visual, &cmap_len, &ydstorg)) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | return err; |
| 753 | return 0; |
| 754 | } |
| 755 | |
| 756 | static int matroxfb_set_par(struct fb_info *info) |
| 757 | { |
| 758 | int err; |
| 759 | int visual; |
| 760 | int cmap_len; |
| 761 | unsigned int ydstorg; |
| 762 | struct fb_var_screeninfo *var; |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 763 | struct matrox_fb_info *minfo = info2minfo(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 765 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 767 | if (minfo->dead) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | return -ENXIO; |
| 769 | } |
| 770 | |
| 771 | var = &info->var; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 772 | if ((err = matroxfb_decode_var(minfo, var, &visual, &cmap_len, &ydstorg)) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | return err; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 774 | minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase) + ydstorg; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 775 | matroxfb_update_fix(minfo); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 776 | minfo->fbcon.fix.visual = visual; |
| 777 | minfo->fbcon.fix.type = FB_TYPE_PACKED_PIXELS; |
| 778 | minfo->fbcon.fix.type_aux = 0; |
| 779 | minfo->fbcon.fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | { |
| 781 | unsigned int pos; |
| 782 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 783 | minfo->curr.cmap_len = cmap_len; |
| 784 | ydstorg += minfo->devflags.ydstorg; |
| 785 | minfo->curr.ydstorg.bytes = ydstorg; |
| 786 | minfo->curr.ydstorg.chunks = ydstorg >> (isInterleave(minfo) ? 3 : 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | if (var->bits_per_pixel == 4) |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 788 | minfo->curr.ydstorg.pixels = ydstorg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | else |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 790 | minfo->curr.ydstorg.pixels = (ydstorg * 8) / var->bits_per_pixel; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 791 | minfo->curr.final_bppShift = matroxfb_get_final_bppShift(minfo, var->bits_per_pixel); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | { struct my_timming mt; |
| 793 | struct matrox_hw_state* hw; |
| 794 | int out; |
| 795 | |
| 796 | matroxfb_var2my(var, &mt); |
| 797 | mt.crtc = MATROXFB_SRC_CRTC1; |
| 798 | /* CRTC1 delays */ |
| 799 | switch (var->bits_per_pixel) { |
| 800 | case 0: mt.delay = 31 + 0; break; |
| 801 | case 16: mt.delay = 21 + 8; break; |
| 802 | case 24: mt.delay = 17 + 8; break; |
| 803 | case 32: mt.delay = 16 + 8; break; |
| 804 | default: mt.delay = 31 + 8; break; |
| 805 | } |
| 806 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 807 | hw = &minfo->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 809 | down_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 811 | if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && |
| 812 | minfo->outputs[out].output->compute) { |
| 813 | minfo->outputs[out].output->compute(minfo->outputs[out].data, &mt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | } |
| 815 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 816 | up_read(&minfo->altout.lock); |
| 817 | minfo->crtc1.pixclock = mt.pixclock; |
| 818 | minfo->crtc1.mnp = mt.mnp; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 819 | minfo->hw_switch->init(minfo, &mt); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 820 | pos = (var->yoffset * var->xres_virtual + var->xoffset) * minfo->curr.final_bppShift / 32; |
| 821 | pos += minfo->curr.ydstorg.chunks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | |
| 823 | hw->CRTC[0x0D] = pos & 0xFF; |
| 824 | hw->CRTC[0x0C] = (pos & 0xFF00) >> 8; |
| 825 | hw->CRTCEXT[0] = (hw->CRTCEXT[0] & 0xF0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40); |
| 826 | hw->CRTCEXT[8] = pos >> 21; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 827 | minfo->hw_switch->restore(minfo); |
| 828 | update_crtc2(minfo, pos); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 829 | down_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 831 | if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && |
| 832 | minfo->outputs[out].output->program) { |
| 833 | minfo->outputs[out].output->program(minfo->outputs[out].data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 837 | if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && |
| 838 | minfo->outputs[out].output->start) { |
| 839 | minfo->outputs[out].output->start(minfo->outputs[out].data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | } |
| 841 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 842 | up_read(&minfo->altout.lock); |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 843 | matrox_cfbX_init(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | } |
| 845 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 846 | minfo->initialized = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | return 0; |
| 848 | } |
| 849 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 850 | static int matroxfb_get_vblank(struct matrox_fb_info *minfo, |
| 851 | struct fb_vblank *vblank) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | { |
| 853 | unsigned int sts1; |
| 854 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 855 | matroxfb_enable_irq(minfo, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | memset(vblank, 0, sizeof(*vblank)); |
| 857 | vblank->flags = FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VSYNC | |
| 858 | FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_HBLANK; |
| 859 | sts1 = mga_inb(M_INSTS1); |
| 860 | vblank->vcount = mga_inl(M_VCOUNT); |
| 861 | /* BTW, on my PIII/450 with G400, reading M_INSTS1 |
| 862 | byte makes this call about 12% slower (1.70 vs. 2.05 us |
| 863 | per ioctl()) */ |
| 864 | if (sts1 & 1) |
| 865 | vblank->flags |= FB_VBLANK_HBLANKING; |
| 866 | if (sts1 & 8) |
| 867 | vblank->flags |= FB_VBLANK_VSYNCING; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 868 | if (vblank->vcount >= minfo->fbcon.var.yres) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | vblank->flags |= FB_VBLANK_VBLANKING; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 870 | if (test_bit(0, &minfo->irq_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | vblank->flags |= FB_VBLANK_HAVE_COUNT; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 872 | /* Only one writer, aligned int value... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | it should work without lock and without atomic_t */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 874 | vblank->count = minfo->crtc1.vsync.cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } |
| 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | static struct matrox_altout panellink_output = { |
| 880 | .name = "Panellink output", |
| 881 | }; |
| 882 | |
Christoph Hellwig | 67a6680 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 883 | static int matroxfb_ioctl(struct fb_info *info, |
| 884 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | { |
| 886 | void __user *argp = (void __user *)arg; |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 887 | struct matrox_fb_info *minfo = info2minfo(info); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 888 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 889 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 891 | if (minfo->dead) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | return -ENXIO; |
| 893 | } |
| 894 | |
| 895 | switch (cmd) { |
| 896 | case FBIOGET_VBLANK: |
| 897 | { |
| 898 | struct fb_vblank vblank; |
| 899 | int err; |
| 900 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 901 | err = matroxfb_get_vblank(minfo, &vblank); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | if (err) |
| 903 | return err; |
| 904 | if (copy_to_user(argp, &vblank, sizeof(vblank))) |
| 905 | return -EFAULT; |
| 906 | return 0; |
| 907 | } |
| 908 | case FBIO_WAITFORVSYNC: |
| 909 | { |
| 910 | u_int32_t crt; |
| 911 | |
| 912 | if (get_user(crt, (u_int32_t __user *)arg)) |
| 913 | return -EFAULT; |
| 914 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 915 | return matroxfb_wait_for_sync(minfo, crt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | } |
| 917 | case MATROXFB_SET_OUTPUT_MODE: |
| 918 | { |
| 919 | struct matroxioc_output_mode mom; |
| 920 | struct matrox_altout *oproc; |
| 921 | int val; |
| 922 | |
| 923 | if (copy_from_user(&mom, argp, sizeof(mom))) |
| 924 | return -EFAULT; |
| 925 | if (mom.output >= MATROXFB_MAX_OUTPUTS) |
| 926 | return -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 927 | down_read(&minfo->altout.lock); |
| 928 | oproc = minfo->outputs[mom.output].output; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | if (!oproc) { |
| 930 | val = -ENXIO; |
| 931 | } else if (!oproc->verifymode) { |
| 932 | if (mom.mode == MATROXFB_OUTPUT_MODE_MONITOR) { |
| 933 | val = 0; |
| 934 | } else { |
| 935 | val = -EINVAL; |
| 936 | } |
| 937 | } else { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 938 | val = oproc->verifymode(minfo->outputs[mom.output].data, mom.mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | } |
| 940 | if (!val) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 941 | if (minfo->outputs[mom.output].mode != mom.mode) { |
| 942 | minfo->outputs[mom.output].mode = mom.mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | val = 1; |
| 944 | } |
| 945 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 946 | up_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | if (val != 1) |
| 948 | return val; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 949 | switch (minfo->outputs[mom.output].src) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | case MATROXFB_SRC_CRTC1: |
| 951 | matroxfb_set_par(info); |
| 952 | break; |
| 953 | case MATROXFB_SRC_CRTC2: |
| 954 | { |
| 955 | struct matroxfb_dh_fb_info* crtc2; |
| 956 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 957 | down_read(&minfo->crtc2.lock); |
| 958 | crtc2 = minfo->crtc2.info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | if (crtc2) |
| 960 | crtc2->fbcon.fbops->fb_set_par(&crtc2->fbcon); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 961 | up_read(&minfo->crtc2.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | } |
| 963 | break; |
| 964 | } |
| 965 | return 0; |
| 966 | } |
| 967 | case MATROXFB_GET_OUTPUT_MODE: |
| 968 | { |
| 969 | struct matroxioc_output_mode mom; |
| 970 | struct matrox_altout *oproc; |
| 971 | int val; |
| 972 | |
| 973 | if (copy_from_user(&mom, argp, sizeof(mom))) |
| 974 | return -EFAULT; |
| 975 | if (mom.output >= MATROXFB_MAX_OUTPUTS) |
| 976 | return -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 977 | down_read(&minfo->altout.lock); |
| 978 | oproc = minfo->outputs[mom.output].output; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | if (!oproc) { |
| 980 | val = -ENXIO; |
| 981 | } else { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 982 | mom.mode = minfo->outputs[mom.output].mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | val = 0; |
| 984 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 985 | up_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | if (val) |
| 987 | return val; |
| 988 | if (copy_to_user(argp, &mom, sizeof(mom))) |
| 989 | return -EFAULT; |
| 990 | return 0; |
| 991 | } |
| 992 | case MATROXFB_SET_OUTPUT_CONNECTION: |
| 993 | { |
| 994 | u_int32_t tmp; |
| 995 | int i; |
| 996 | int changes; |
| 997 | |
| 998 | if (copy_from_user(&tmp, argp, sizeof(tmp))) |
| 999 | return -EFAULT; |
| 1000 | for (i = 0; i < 32; i++) { |
| 1001 | if (tmp & (1 << i)) { |
| 1002 | if (i >= MATROXFB_MAX_OUTPUTS) |
| 1003 | return -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1004 | if (!minfo->outputs[i].output) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | return -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1006 | switch (minfo->outputs[i].src) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | case MATROXFB_SRC_NONE: |
| 1008 | case MATROXFB_SRC_CRTC1: |
| 1009 | break; |
| 1010 | default: |
| 1011 | return -EBUSY; |
| 1012 | } |
| 1013 | } |
| 1014 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1015 | if (minfo->devflags.panellink) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | if (tmp & MATROXFB_OUTPUT_CONN_DFP) { |
| 1017 | if (tmp & MATROXFB_OUTPUT_CONN_SECONDARY) |
| 1018 | return -EINVAL; |
| 1019 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1020 | if (minfo->outputs[i].src == MATROXFB_SRC_CRTC2) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | return -EBUSY; |
| 1022 | } |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | changes = 0; |
| 1027 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
| 1028 | if (tmp & (1 << i)) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1029 | if (minfo->outputs[i].src != MATROXFB_SRC_CRTC1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | changes = 1; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1031 | minfo->outputs[i].src = MATROXFB_SRC_CRTC1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1033 | } else if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | changes = 1; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1035 | minfo->outputs[i].src = MATROXFB_SRC_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | } |
| 1037 | } |
| 1038 | if (!changes) |
| 1039 | return 0; |
| 1040 | matroxfb_set_par(info); |
| 1041 | return 0; |
| 1042 | } |
| 1043 | case MATROXFB_GET_OUTPUT_CONNECTION: |
| 1044 | { |
| 1045 | u_int32_t conn = 0; |
| 1046 | int i; |
| 1047 | |
| 1048 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1049 | if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | conn |= 1 << i; |
| 1051 | } |
| 1052 | } |
| 1053 | if (put_user(conn, (u_int32_t __user *)arg)) |
| 1054 | return -EFAULT; |
| 1055 | return 0; |
| 1056 | } |
| 1057 | case MATROXFB_GET_AVAILABLE_OUTPUTS: |
| 1058 | { |
| 1059 | u_int32_t conn = 0; |
| 1060 | int i; |
| 1061 | |
| 1062 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1063 | if (minfo->outputs[i].output) { |
| 1064 | switch (minfo->outputs[i].src) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | case MATROXFB_SRC_NONE: |
| 1066 | case MATROXFB_SRC_CRTC1: |
| 1067 | conn |= 1 << i; |
| 1068 | break; |
| 1069 | } |
| 1070 | } |
| 1071 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1072 | if (minfo->devflags.panellink) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | if (conn & MATROXFB_OUTPUT_CONN_DFP) |
| 1074 | conn &= ~MATROXFB_OUTPUT_CONN_SECONDARY; |
| 1075 | if (conn & MATROXFB_OUTPUT_CONN_SECONDARY) |
| 1076 | conn &= ~MATROXFB_OUTPUT_CONN_DFP; |
| 1077 | } |
| 1078 | if (put_user(conn, (u_int32_t __user *)arg)) |
| 1079 | return -EFAULT; |
| 1080 | return 0; |
| 1081 | } |
| 1082 | case MATROXFB_GET_ALL_OUTPUTS: |
| 1083 | { |
| 1084 | u_int32_t conn = 0; |
| 1085 | int i; |
| 1086 | |
| 1087 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1088 | if (minfo->outputs[i].output) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | conn |= 1 << i; |
| 1090 | } |
| 1091 | } |
| 1092 | if (put_user(conn, (u_int32_t __user *)arg)) |
| 1093 | return -EFAULT; |
| 1094 | return 0; |
| 1095 | } |
| 1096 | case VIDIOC_QUERYCAP: |
| 1097 | { |
| 1098 | struct v4l2_capability r; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1099 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | memset(&r, 0, sizeof(r)); |
| 1101 | strcpy(r.driver, "matroxfb"); |
| 1102 | strcpy(r.card, "Matrox"); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1103 | sprintf(r.bus_info, "PCI:%s", pci_name(minfo->pcidev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | r.version = KERNEL_VERSION(1,0,0); |
| 1105 | r.capabilities = V4L2_CAP_VIDEO_OUTPUT; |
| 1106 | if (copy_to_user(argp, &r, sizeof(r))) |
| 1107 | return -EFAULT; |
| 1108 | return 0; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | } |
| 1111 | case VIDIOC_QUERYCTRL: |
| 1112 | { |
| 1113 | struct v4l2_queryctrl qctrl; |
| 1114 | int err; |
| 1115 | |
| 1116 | if (copy_from_user(&qctrl, argp, sizeof(qctrl))) |
| 1117 | return -EFAULT; |
| 1118 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1119 | down_read(&minfo->altout.lock); |
| 1120 | if (!minfo->outputs[1].output) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | err = -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1122 | } else if (minfo->outputs[1].output->getqueryctrl) { |
| 1123 | err = minfo->outputs[1].output->getqueryctrl(minfo->outputs[1].data, &qctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | } else { |
| 1125 | err = -EINVAL; |
| 1126 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1127 | up_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | if (err >= 0 && |
| 1129 | copy_to_user(argp, &qctrl, sizeof(qctrl))) |
| 1130 | return -EFAULT; |
| 1131 | return err; |
| 1132 | } |
| 1133 | case VIDIOC_G_CTRL: |
| 1134 | { |
| 1135 | struct v4l2_control ctrl; |
| 1136 | int err; |
| 1137 | |
| 1138 | if (copy_from_user(&ctrl, argp, sizeof(ctrl))) |
| 1139 | return -EFAULT; |
| 1140 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1141 | down_read(&minfo->altout.lock); |
| 1142 | if (!minfo->outputs[1].output) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | err = -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1144 | } else if (minfo->outputs[1].output->getctrl) { |
| 1145 | err = minfo->outputs[1].output->getctrl(minfo->outputs[1].data, &ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | } else { |
| 1147 | err = -EINVAL; |
| 1148 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1149 | up_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | if (err >= 0 && |
| 1151 | copy_to_user(argp, &ctrl, sizeof(ctrl))) |
| 1152 | return -EFAULT; |
| 1153 | return err; |
| 1154 | } |
| 1155 | case VIDIOC_S_CTRL_OLD: |
| 1156 | case VIDIOC_S_CTRL: |
| 1157 | { |
| 1158 | struct v4l2_control ctrl; |
| 1159 | int err; |
| 1160 | |
| 1161 | if (copy_from_user(&ctrl, argp, sizeof(ctrl))) |
| 1162 | return -EFAULT; |
| 1163 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1164 | down_read(&minfo->altout.lock); |
| 1165 | if (!minfo->outputs[1].output) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | err = -ENXIO; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1167 | } else if (minfo->outputs[1].output->setctrl) { |
| 1168 | err = minfo->outputs[1].output->setctrl(minfo->outputs[1].data, &ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | } else { |
| 1170 | err = -EINVAL; |
| 1171 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1172 | up_read(&minfo->altout.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | return err; |
| 1174 | } |
| 1175 | } |
| 1176 | return -ENOTTY; |
| 1177 | } |
| 1178 | |
| 1179 | /* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */ |
| 1180 | |
| 1181 | static int matroxfb_blank(int blank, struct fb_info *info) |
| 1182 | { |
| 1183 | int seq; |
| 1184 | int crtc; |
| 1185 | CRITFLAGS |
Jean Delvare | ee5a274 | 2009-09-22 16:47:50 -0700 | [diff] [blame] | 1186 | struct matrox_fb_info *minfo = info2minfo(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 1188 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1190 | if (minfo->dead) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | return 1; |
| 1192 | |
| 1193 | switch (blank) { |
| 1194 | case FB_BLANK_NORMAL: seq = 0x20; crtc = 0x00; break; /* works ??? */ |
| 1195 | case FB_BLANK_VSYNC_SUSPEND: seq = 0x20; crtc = 0x10; break; |
| 1196 | case FB_BLANK_HSYNC_SUSPEND: seq = 0x20; crtc = 0x20; break; |
| 1197 | case FB_BLANK_POWERDOWN: seq = 0x20; crtc = 0x30; break; |
| 1198 | default: seq = 0x00; crtc = 0x00; break; |
| 1199 | } |
| 1200 | |
| 1201 | CRITBEGIN |
| 1202 | |
| 1203 | mga_outb(M_SEQ_INDEX, 1); |
| 1204 | mga_outb(M_SEQ_DATA, (mga_inb(M_SEQ_DATA) & ~0x20) | seq); |
| 1205 | mga_outb(M_EXTVGA_INDEX, 1); |
| 1206 | mga_outb(M_EXTVGA_DATA, (mga_inb(M_EXTVGA_DATA) & ~0x30) | crtc); |
| 1207 | |
| 1208 | CRITEND |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
| 1212 | static struct fb_ops matroxfb_ops = { |
| 1213 | .owner = THIS_MODULE, |
| 1214 | .fb_open = matroxfb_open, |
| 1215 | .fb_release = matroxfb_release, |
| 1216 | .fb_check_var = matroxfb_check_var, |
| 1217 | .fb_set_par = matroxfb_set_par, |
| 1218 | .fb_setcolreg = matroxfb_setcolreg, |
| 1219 | .fb_pan_display =matroxfb_pan_display, |
| 1220 | .fb_blank = matroxfb_blank, |
| 1221 | .fb_ioctl = matroxfb_ioctl, |
| 1222 | /* .fb_fillrect = <set by matrox_cfbX_init>, */ |
| 1223 | /* .fb_copyarea = <set by matrox_cfbX_init>, */ |
| 1224 | /* .fb_imageblit = <set by matrox_cfbX_init>, */ |
| 1225 | /* .fb_cursor = <set by matrox_cfbX_init>, */ |
| 1226 | }; |
| 1227 | |
| 1228 | #define RSDepth(X) (((X) >> 8) & 0x0F) |
| 1229 | #define RS8bpp 0x1 |
| 1230 | #define RS15bpp 0x2 |
| 1231 | #define RS16bpp 0x3 |
| 1232 | #define RS32bpp 0x4 |
| 1233 | #define RS4bpp 0x5 |
| 1234 | #define RS24bpp 0x6 |
| 1235 | #define RSText 0x7 |
| 1236 | #define RSText8 0x8 |
| 1237 | /* 9-F */ |
| 1238 | static struct { struct fb_bitfield red, green, blue, transp; int bits_per_pixel; } colors[] = { |
| 1239 | { { 0, 8, 0}, { 0, 8, 0}, { 0, 8, 0}, { 0, 0, 0}, 8 }, |
| 1240 | { { 10, 5, 0}, { 5, 5, 0}, { 0, 5, 0}, { 15, 1, 0}, 16 }, |
| 1241 | { { 11, 5, 0}, { 5, 6, 0}, { 0, 5, 0}, { 0, 0, 0}, 16 }, |
| 1242 | { { 16, 8, 0}, { 8, 8, 0}, { 0, 8, 0}, { 24, 8, 0}, 32 }, |
| 1243 | { { 0, 8, 0}, { 0, 8, 0}, { 0, 8, 0}, { 0, 0, 0}, 4 }, |
| 1244 | { { 16, 8, 0}, { 8, 8, 0}, { 0, 8, 0}, { 0, 0, 0}, 24 }, |
| 1245 | { { 0, 6, 0}, { 0, 6, 0}, { 0, 6, 0}, { 0, 0, 0}, 0 }, /* textmode with (default) VGA8x16 */ |
| 1246 | { { 0, 6, 0}, { 0, 6, 0}, { 0, 6, 0}, { 0, 0, 0}, 0 }, /* textmode hardwired to VGA8x8 */ |
| 1247 | }; |
| 1248 | |
| 1249 | /* initialized by setup, see explanation at end of file (search for MODULE_PARM_DESC) */ |
| 1250 | static unsigned int mem; /* "matrox:mem:xxxxxM" */ |
| 1251 | static int option_precise_width = 1; /* cannot be changed, option_precise_width==0 must imply noaccel */ |
| 1252 | static int inv24; /* "matrox:inv24" */ |
| 1253 | static int cross4MB = -1; /* "matrox:cross4MB" */ |
| 1254 | static int disabled; /* "matrox:disabled" */ |
| 1255 | static int noaccel; /* "matrox:noaccel" */ |
| 1256 | static int nopan; /* "matrox:nopan" */ |
| 1257 | static int no_pci_retry; /* "matrox:nopciretry" */ |
| 1258 | static int novga; /* "matrox:novga" */ |
| 1259 | static int nobios; /* "matrox:nobios" */ |
| 1260 | static int noinit = 1; /* "matrox:init" */ |
| 1261 | static int inverse; /* "matrox:inverse" */ |
| 1262 | static int sgram; /* "matrox:sgram" */ |
| 1263 | #ifdef CONFIG_MTRR |
| 1264 | static int mtrr = 1; /* "matrox:nomtrr" */ |
| 1265 | #endif |
| 1266 | static int grayscale; /* "matrox:grayscale" */ |
| 1267 | static int dev = -1; /* "matrox:dev:xxxxx" */ |
| 1268 | static unsigned int vesa = ~0; /* "matrox:vesa:xxxxx" */ |
| 1269 | static int depth = -1; /* "matrox:depth:xxxxx" */ |
| 1270 | static unsigned int xres; /* "matrox:xres:xxxxx" */ |
| 1271 | static unsigned int yres; /* "matrox:yres:xxxxx" */ |
| 1272 | static unsigned int upper = ~0; /* "matrox:upper:xxxxx" */ |
| 1273 | static unsigned int lower = ~0; /* "matrox:lower:xxxxx" */ |
| 1274 | static unsigned int vslen; /* "matrox:vslen:xxxxx" */ |
| 1275 | static unsigned int left = ~0; /* "matrox:left:xxxxx" */ |
| 1276 | static unsigned int right = ~0; /* "matrox:right:xxxxx" */ |
| 1277 | static unsigned int hslen; /* "matrox:hslen:xxxxx" */ |
| 1278 | static unsigned int pixclock; /* "matrox:pixclock:xxxxx" */ |
| 1279 | static int sync = -1; /* "matrox:sync:xxxxx" */ |
| 1280 | static unsigned int fv; /* "matrox:fv:xxxxx" */ |
| 1281 | static unsigned int fh; /* "matrox:fh:xxxxxk" */ |
| 1282 | static unsigned int maxclk; /* "matrox:maxclk:xxxxM" */ |
| 1283 | static int dfp; /* "matrox:dfp */ |
| 1284 | static int dfp_type = -1; /* "matrox:dfp:xxx */ |
| 1285 | static int memtype = -1; /* "matrox:memtype:xxx" */ |
| 1286 | static char outputs[8]; /* "matrox:outputs:xxx" */ |
| 1287 | |
| 1288 | #ifndef MODULE |
| 1289 | static char videomode[64]; /* "matrox:mode:xxxxx" or "matrox:xxxxx" */ |
| 1290 | #endif |
| 1291 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1292 | static int matroxfb_getmemory(struct matrox_fb_info *minfo, |
| 1293 | unsigned int maxSize, unsigned int *realSize) |
| 1294 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | vaddr_t vm; |
| 1296 | unsigned int offs; |
| 1297 | unsigned int offs2; |
Ville Syrjälä | 6c12f30 | 2005-11-07 01:00:58 -0800 | [diff] [blame] | 1298 | unsigned char orig; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1299 | unsigned char bytes[32]; |
| 1300 | unsigned char* tmp; |
| 1301 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 1302 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1303 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1304 | vm = minfo->video.vbase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | maxSize &= ~0x1FFFFF; /* must be X*2MB (really it must be 2 or X*4MB) */ |
| 1306 | /* at least 2MB */ |
| 1307 | if (maxSize < 0x0200000) return 0; |
| 1308 | if (maxSize > 0x2000000) maxSize = 0x2000000; |
| 1309 | |
| 1310 | mga_outb(M_EXTVGA_INDEX, 0x03); |
Jan Beulich | 438e5c5 | 2005-09-13 01:25:45 -0700 | [diff] [blame] | 1311 | orig = mga_inb(M_EXTVGA_DATA); |
| 1312 | mga_outb(M_EXTVGA_DATA, orig | 0x80); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | tmp = bytes; |
| 1315 | for (offs = 0x100000; offs < maxSize; offs += 0x200000) |
| 1316 | *tmp++ = mga_readb(vm, offs); |
| 1317 | for (offs = 0x100000; offs < maxSize; offs += 0x200000) |
| 1318 | mga_writeb(vm, offs, 0x02); |
Ville Syrjälä | 6c12f30 | 2005-11-07 01:00:58 -0800 | [diff] [blame] | 1319 | mga_outb(M_CACHEFLUSH, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | for (offs = 0x100000; offs < maxSize; offs += 0x200000) { |
| 1321 | if (mga_readb(vm, offs) != 0x02) |
| 1322 | break; |
| 1323 | mga_writeb(vm, offs, mga_readb(vm, offs) - 0x02); |
| 1324 | if (mga_readb(vm, offs)) |
| 1325 | break; |
| 1326 | } |
| 1327 | tmp = bytes; |
| 1328 | for (offs2 = 0x100000; offs2 < maxSize; offs2 += 0x200000) |
| 1329 | mga_writeb(vm, offs2, *tmp++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | |
| 1331 | mga_outb(M_EXTVGA_INDEX, 0x03); |
Jan Beulich | 438e5c5 | 2005-09-13 01:25:45 -0700 | [diff] [blame] | 1332 | mga_outb(M_EXTVGA_DATA, orig); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | |
| 1334 | *realSize = offs - 0x100000; |
| 1335 | #ifdef CONFIG_FB_MATROX_MILLENIUM |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1336 | minfo->interleave = !(!isMillenium(minfo) || ((offs - 0x100000) & 0x3FFFFF)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | #endif |
| 1338 | return 1; |
| 1339 | } |
| 1340 | |
| 1341 | struct video_board { |
| 1342 | int maxvram; |
| 1343 | int maxdisplayable; |
| 1344 | int accelID; |
| 1345 | struct matrox_switch* lowlevel; |
| 1346 | }; |
| 1347 | #ifdef CONFIG_FB_MATROX_MILLENIUM |
| 1348 | static struct video_board vbMillennium = {0x0800000, 0x0800000, FB_ACCEL_MATROX_MGA2064W, &matrox_millennium}; |
| 1349 | static struct video_board vbMillennium2 = {0x1000000, 0x0800000, FB_ACCEL_MATROX_MGA2164W, &matrox_millennium}; |
| 1350 | static struct video_board vbMillennium2A = {0x1000000, 0x0800000, FB_ACCEL_MATROX_MGA2164W_AGP, &matrox_millennium}; |
| 1351 | #endif /* CONFIG_FB_MATROX_MILLENIUM */ |
| 1352 | #ifdef CONFIG_FB_MATROX_MYSTIQUE |
| 1353 | static struct video_board vbMystique = {0x0800000, 0x0800000, FB_ACCEL_MATROX_MGA1064SG, &matrox_mystique}; |
| 1354 | #endif /* CONFIG_FB_MATROX_MYSTIQUE */ |
| 1355 | #ifdef CONFIG_FB_MATROX_G |
| 1356 | static struct video_board vbG100 = {0x0800000, 0x0800000, FB_ACCEL_MATROX_MGAG100, &matrox_G100}; |
| 1357 | static struct video_board vbG200 = {0x1000000, 0x1000000, FB_ACCEL_MATROX_MGAG200, &matrox_G100}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | /* from doc it looks like that accelerator can draw only to low 16MB :-( Direct accesses & displaying are OK for |
| 1359 | whole 32MB */ |
| 1360 | static struct video_board vbG400 = {0x2000000, 0x1000000, FB_ACCEL_MATROX_MGAG400, &matrox_G100}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | #endif |
| 1362 | |
| 1363 | #define DEVF_VIDEO64BIT 0x0001 |
| 1364 | #define DEVF_SWAPS 0x0002 |
| 1365 | #define DEVF_SRCORG 0x0004 |
| 1366 | #define DEVF_DUALHEAD 0x0008 |
| 1367 | #define DEVF_CROSS4MB 0x0010 |
| 1368 | #define DEVF_TEXT4B 0x0020 |
| 1369 | /* #define DEVF_recycled 0x0040 */ |
| 1370 | /* #define DEVF_recycled 0x0080 */ |
| 1371 | #define DEVF_SUPPORT32MB 0x0100 |
| 1372 | #define DEVF_ANY_VXRES 0x0200 |
| 1373 | #define DEVF_TEXT16B 0x0400 |
| 1374 | #define DEVF_CRTC2 0x0800 |
| 1375 | #define DEVF_MAVEN_CAPABLE 0x1000 |
| 1376 | #define DEVF_PANELLINK_CAPABLE 0x2000 |
| 1377 | #define DEVF_G450DAC 0x4000 |
| 1378 | |
| 1379 | #define DEVF_GCORE (DEVF_VIDEO64BIT | DEVF_SWAPS | DEVF_CROSS4MB) |
| 1380 | #define DEVF_G2CORE (DEVF_GCORE | DEVF_ANY_VXRES | DEVF_MAVEN_CAPABLE | DEVF_PANELLINK_CAPABLE | DEVF_SRCORG | DEVF_DUALHEAD) |
| 1381 | #define DEVF_G100 (DEVF_GCORE) /* no doc, no vxres... */ |
| 1382 | #define DEVF_G200 (DEVF_G2CORE) |
| 1383 | #define DEVF_G400 (DEVF_G2CORE | DEVF_SUPPORT32MB | DEVF_TEXT16B | DEVF_CRTC2) |
| 1384 | /* if you'll find how to drive DFP... */ |
| 1385 | #define DEVF_G450 (DEVF_GCORE | DEVF_ANY_VXRES | DEVF_SUPPORT32MB | DEVF_TEXT16B | DEVF_CRTC2 | DEVF_G450DAC | DEVF_SRCORG | DEVF_DUALHEAD) |
| 1386 | #define DEVF_G550 (DEVF_G450) |
| 1387 | |
| 1388 | static struct board { |
| 1389 | unsigned short vendor, device, rev, svid, sid; |
| 1390 | unsigned int flags; |
| 1391 | unsigned int maxclk; |
| 1392 | enum mga_chip chip; |
| 1393 | struct video_board* base; |
| 1394 | const char* name; |
| 1395 | } dev_list[] = { |
| 1396 | #ifdef CONFIG_FB_MATROX_MILLENIUM |
| 1397 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL, 0xFF, |
| 1398 | 0, 0, |
| 1399 | DEVF_TEXT4B, |
| 1400 | 230000, |
| 1401 | MGA_2064, |
| 1402 | &vbMillennium, |
| 1403 | "Millennium (PCI)"}, |
| 1404 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL_2, 0xFF, |
| 1405 | 0, 0, |
| 1406 | DEVF_SWAPS, |
| 1407 | 220000, |
| 1408 | MGA_2164, |
| 1409 | &vbMillennium2, |
| 1410 | "Millennium II (PCI)"}, |
| 1411 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL_2_AGP, 0xFF, |
| 1412 | 0, 0, |
| 1413 | DEVF_SWAPS, |
| 1414 | 250000, |
| 1415 | MGA_2164, |
| 1416 | &vbMillennium2A, |
| 1417 | "Millennium II (AGP)"}, |
| 1418 | #endif |
| 1419 | #ifdef CONFIG_FB_MATROX_MYSTIQUE |
| 1420 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS, 0x02, |
| 1421 | 0, 0, |
| 1422 | DEVF_VIDEO64BIT | DEVF_CROSS4MB, |
| 1423 | 180000, |
| 1424 | MGA_1064, |
| 1425 | &vbMystique, |
| 1426 | "Mystique (PCI)"}, |
| 1427 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS, 0xFF, |
| 1428 | 0, 0, |
| 1429 | DEVF_VIDEO64BIT | DEVF_SWAPS | DEVF_CROSS4MB, |
| 1430 | 220000, |
| 1431 | MGA_1164, |
| 1432 | &vbMystique, |
| 1433 | "Mystique 220 (PCI)"}, |
Ville Syrjälä | 63921fb | 2005-11-07 01:00:57 -0800 | [diff] [blame] | 1434 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS_AGP, 0x02, |
| 1435 | 0, 0, |
| 1436 | DEVF_VIDEO64BIT | DEVF_CROSS4MB, |
| 1437 | 180000, |
| 1438 | MGA_1064, |
| 1439 | &vbMystique, |
| 1440 | "Mystique (AGP)"}, |
| 1441 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS_AGP, 0xFF, |
| 1442 | 0, 0, |
| 1443 | DEVF_VIDEO64BIT | DEVF_SWAPS | DEVF_CROSS4MB, |
| 1444 | 220000, |
| 1445 | MGA_1164, |
| 1446 | &vbMystique, |
| 1447 | "Mystique 220 (AGP)"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | #endif |
| 1449 | #ifdef CONFIG_FB_MATROX_G |
| 1450 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_MM, 0xFF, |
| 1451 | 0, 0, |
| 1452 | DEVF_G100, |
| 1453 | 230000, |
| 1454 | MGA_G100, |
| 1455 | &vbG100, |
| 1456 | "MGA-G100 (PCI)"}, |
| 1457 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP, 0xFF, |
| 1458 | 0, 0, |
| 1459 | DEVF_G100, |
| 1460 | 230000, |
| 1461 | MGA_G100, |
| 1462 | &vbG100, |
| 1463 | "MGA-G100 (AGP)"}, |
Darrick J. Wong | e3a1938 | 2008-10-15 22:03:52 -0700 | [diff] [blame] | 1464 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI, 0xFF, |
| 1465 | 0, 0, |
| 1466 | DEVF_G200, |
| 1467 | 230000, |
| 1468 | MGA_G200, |
| 1469 | &vbG200, |
| 1470 | "MGA-G200eV (PCI)"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 0xFF, |
| 1472 | 0, 0, |
| 1473 | DEVF_G200, |
| 1474 | 250000, |
| 1475 | MGA_G200, |
| 1476 | &vbG200, |
| 1477 | "MGA-G200 (PCI)"}, |
| 1478 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1479 | PCI_SS_VENDOR_ID_MATROX, PCI_SS_ID_MATROX_GENERIC, |
| 1480 | DEVF_G200, |
| 1481 | 220000, |
| 1482 | MGA_G200, |
| 1483 | &vbG200, |
| 1484 | "MGA-G200 (AGP)"}, |
| 1485 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1486 | PCI_SS_VENDOR_ID_MATROX, PCI_SS_ID_MATROX_MYSTIQUE_G200_AGP, |
| 1487 | DEVF_G200, |
| 1488 | 230000, |
| 1489 | MGA_G200, |
| 1490 | &vbG200, |
| 1491 | "Mystique G200 (AGP)"}, |
| 1492 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1493 | PCI_SS_VENDOR_ID_MATROX, PCI_SS_ID_MATROX_MILLENIUM_G200_AGP, |
| 1494 | DEVF_G200, |
| 1495 | 250000, |
| 1496 | MGA_G200, |
| 1497 | &vbG200, |
| 1498 | "Millennium G200 (AGP)"}, |
| 1499 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1500 | PCI_SS_VENDOR_ID_MATROX, PCI_SS_ID_MATROX_MARVEL_G200_AGP, |
| 1501 | DEVF_G200, |
| 1502 | 230000, |
| 1503 | MGA_G200, |
| 1504 | &vbG200, |
| 1505 | "Marvel G200 (AGP)"}, |
| 1506 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1507 | PCI_SS_VENDOR_ID_SIEMENS_NIXDORF, PCI_SS_ID_SIEMENS_MGA_G200_AGP, |
| 1508 | DEVF_G200, |
| 1509 | 230000, |
| 1510 | MGA_G200, |
| 1511 | &vbG200, |
| 1512 | "MGA-G200 (AGP)"}, |
| 1513 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 0xFF, |
| 1514 | 0, 0, |
| 1515 | DEVF_G200, |
| 1516 | 230000, |
| 1517 | MGA_G200, |
| 1518 | &vbG200, |
| 1519 | "G200 (AGP)"}, |
| 1520 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, 0x80, |
| 1521 | PCI_SS_VENDOR_ID_MATROX, PCI_SS_ID_MATROX_MILLENNIUM_G400_MAX_AGP, |
| 1522 | DEVF_G400, |
| 1523 | 360000, |
| 1524 | MGA_G400, |
| 1525 | &vbG400, |
| 1526 | "Millennium G400 MAX (AGP)"}, |
| 1527 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, 0x80, |
| 1528 | 0, 0, |
| 1529 | DEVF_G400, |
| 1530 | 300000, |
| 1531 | MGA_G400, |
| 1532 | &vbG400, |
| 1533 | "G400 (AGP)"}, |
| 1534 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, 0xFF, |
| 1535 | 0, 0, |
| 1536 | DEVF_G450, |
| 1537 | 360000, |
| 1538 | MGA_G450, |
| 1539 | &vbG400, |
| 1540 | "G450"}, |
| 1541 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G550, 0xFF, |
| 1542 | 0, 0, |
| 1543 | DEVF_G550, |
| 1544 | 360000, |
| 1545 | MGA_G550, |
| 1546 | &vbG400, |
| 1547 | "G550"}, |
| 1548 | #endif |
| 1549 | {0, 0, 0xFF, |
| 1550 | 0, 0, |
| 1551 | 0, |
| 1552 | 0, |
| 1553 | 0, |
| 1554 | NULL, |
| 1555 | NULL}}; |
| 1556 | |
| 1557 | #ifndef MODULE |
| 1558 | static struct fb_videomode defaultmode = { |
| 1559 | /* 640x480 @ 60Hz, 31.5 kHz */ |
| 1560 | NULL, 60, 640, 480, 39721, 40, 24, 32, 11, 96, 2, |
| 1561 | 0, FB_VMODE_NONINTERLACED |
| 1562 | }; |
| 1563 | #endif /* !MODULE */ |
| 1564 | |
| 1565 | static int hotplug = 0; |
| 1566 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1567 | static void setDefaultOutputs(struct matrox_fb_info *minfo) |
| 1568 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | unsigned int i; |
| 1570 | const char* ptr; |
| 1571 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1572 | minfo->outputs[0].default_src = MATROXFB_SRC_CRTC1; |
| 1573 | if (minfo->devflags.g450dac) { |
| 1574 | minfo->outputs[1].default_src = MATROXFB_SRC_CRTC1; |
| 1575 | minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | } else if (dfp) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1577 | minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | } |
| 1579 | ptr = outputs; |
| 1580 | for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { |
| 1581 | char c = *ptr++; |
| 1582 | |
| 1583 | if (c == 0) { |
| 1584 | break; |
| 1585 | } |
| 1586 | if (c == '0') { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1587 | minfo->outputs[i].default_src = MATROXFB_SRC_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | } else if (c == '1') { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1589 | minfo->outputs[i].default_src = MATROXFB_SRC_CRTC1; |
| 1590 | } else if (c == '2' && minfo->devflags.crtc2) { |
| 1591 | minfo->outputs[i].default_src = MATROXFB_SRC_CRTC2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | } else { |
| 1593 | printk(KERN_ERR "matroxfb: Unknown outputs setting\n"); |
| 1594 | break; |
| 1595 | } |
| 1596 | } |
| 1597 | /* Nullify this option for subsequent adapters */ |
| 1598 | outputs[0] = 0; |
| 1599 | } |
| 1600 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1601 | static int initMatrox2(struct matrox_fb_info *minfo, struct board *b) |
| 1602 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | unsigned long ctrlptr_phys = 0; |
| 1604 | unsigned long video_base_phys = 0; |
| 1605 | unsigned int memsize; |
| 1606 | int err; |
| 1607 | |
| 1608 | static struct pci_device_id intel_82437[] = { |
| 1609 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437) }, |
| 1610 | { }, |
| 1611 | }; |
| 1612 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 1613 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | |
| 1615 | /* set default values... */ |
| 1616 | vesafb_defined.accel_flags = FB_ACCELF_TEXT; |
| 1617 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1618 | minfo->hw_switch = b->base->lowlevel; |
| 1619 | minfo->devflags.accelerator = b->base->accelID; |
| 1620 | minfo->max_pixel_clock = b->maxclk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
| 1622 | printk(KERN_INFO "matroxfb: Matrox %s detected\n", b->name); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1623 | minfo->capable.plnwt = 1; |
| 1624 | minfo->chip = b->chip; |
| 1625 | minfo->capable.srcorg = b->flags & DEVF_SRCORG; |
| 1626 | minfo->devflags.video64bits = b->flags & DEVF_VIDEO64BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | if (b->flags & DEVF_TEXT4B) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1628 | minfo->devflags.vgastep = 4; |
| 1629 | minfo->devflags.textmode = 4; |
| 1630 | minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1631 | } else if (b->flags & DEVF_TEXT16B) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1632 | minfo->devflags.vgastep = 16; |
| 1633 | minfo->devflags.textmode = 1; |
| 1634 | minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1635 | } else { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1636 | minfo->devflags.vgastep = 8; |
| 1637 | minfo->devflags.textmode = 1; |
| 1638 | minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1640 | minfo->devflags.support32MB = (b->flags & DEVF_SUPPORT32MB) != 0; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1641 | minfo->devflags.precise_width = !(b->flags & DEVF_ANY_VXRES); |
| 1642 | minfo->devflags.crtc2 = (b->flags & DEVF_CRTC2) != 0; |
| 1643 | minfo->devflags.maven_capable = (b->flags & DEVF_MAVEN_CAPABLE) != 0; |
| 1644 | minfo->devflags.dualhead = (b->flags & DEVF_DUALHEAD) != 0; |
| 1645 | minfo->devflags.dfp_type = dfp_type; |
| 1646 | minfo->devflags.g450dac = (b->flags & DEVF_G450DAC) != 0; |
| 1647 | minfo->devflags.textstep = minfo->devflags.vgastep * minfo->devflags.textmode; |
| 1648 | minfo->devflags.textvram = 65536 / minfo->devflags.textmode; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1649 | setDefaultOutputs(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | if (b->flags & DEVF_PANELLINK_CAPABLE) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1651 | minfo->outputs[2].data = minfo; |
| 1652 | minfo->outputs[2].output = &panellink_output; |
| 1653 | minfo->outputs[2].src = minfo->outputs[2].default_src; |
| 1654 | minfo->outputs[2].mode = MATROXFB_OUTPUT_MODE_MONITOR; |
| 1655 | minfo->devflags.panellink = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1658 | if (minfo->capable.cross4MB < 0) |
| 1659 | minfo->capable.cross4MB = b->flags & DEVF_CROSS4MB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | if (b->flags & DEVF_SWAPS) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1661 | ctrlptr_phys = pci_resource_start(minfo->pcidev, 1); |
| 1662 | video_base_phys = pci_resource_start(minfo->pcidev, 0); |
| 1663 | minfo->devflags.fbResource = PCI_BASE_ADDRESS_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | } else { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1665 | ctrlptr_phys = pci_resource_start(minfo->pcidev, 0); |
| 1666 | video_base_phys = pci_resource_start(minfo->pcidev, 1); |
| 1667 | minfo->devflags.fbResource = PCI_BASE_ADDRESS_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | } |
| 1669 | err = -EINVAL; |
| 1670 | if (!ctrlptr_phys) { |
| 1671 | printk(KERN_ERR "matroxfb: control registers are not available, matroxfb disabled\n"); |
| 1672 | goto fail; |
| 1673 | } |
| 1674 | if (!video_base_phys) { |
| 1675 | printk(KERN_ERR "matroxfb: video RAM is not available in PCI address space, matroxfb disabled\n"); |
| 1676 | goto fail; |
| 1677 | } |
| 1678 | memsize = b->base->maxvram; |
| 1679 | if (!request_mem_region(ctrlptr_phys, 16384, "matroxfb MMIO")) { |
| 1680 | goto fail; |
| 1681 | } |
| 1682 | if (!request_mem_region(video_base_phys, memsize, "matroxfb FB")) { |
| 1683 | goto failCtrlMR; |
| 1684 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1685 | minfo->video.len_maximum = memsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | /* convert mem (autodetect k, M) */ |
| 1687 | if (mem < 1024) mem *= 1024; |
| 1688 | if (mem < 0x00100000) mem *= 1024; |
| 1689 | |
| 1690 | if (mem && (mem < memsize)) |
| 1691 | memsize = mem; |
| 1692 | err = -ENOMEM; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1693 | if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, &minfo->mmio.vbase)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys); |
| 1695 | goto failVideoMR; |
| 1696 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1697 | minfo->mmio.base = ctrlptr_phys; |
| 1698 | minfo->mmio.len = 16384; |
| 1699 | minfo->video.base = video_base_phys; |
| 1700 | if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, &minfo->video.vbase)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n", |
| 1702 | video_base_phys, memsize); |
| 1703 | goto failCtrlIO; |
| 1704 | } |
| 1705 | { |
| 1706 | u_int32_t cmd; |
| 1707 | u_int32_t mga_option; |
| 1708 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1709 | pci_read_config_dword(minfo->pcidev, PCI_OPTION_REG, &mga_option); |
| 1710 | pci_read_config_dword(minfo->pcidev, PCI_COMMAND, &cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | mga_option &= 0x7FFFFFFF; /* clear BIG_ENDIAN */ |
| 1712 | mga_option |= MX_OPTION_BSWAP; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1713 | /* disable palette snooping */ |
| 1714 | cmd &= ~PCI_COMMAND_VGA_PALETTE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | if (pci_dev_present(intel_82437)) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1716 | if (!(mga_option & 0x20000000) && !minfo->devflags.nopciretry) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | printk(KERN_WARNING "matroxfb: Disabling PCI retries due to i82437 present\n"); |
| 1718 | } |
| 1719 | mga_option |= 0x20000000; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1720 | minfo->devflags.nopciretry = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1722 | pci_write_config_dword(minfo->pcidev, PCI_COMMAND, cmd); |
| 1723 | pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, mga_option); |
| 1724 | minfo->hw.MXoptionReg = mga_option; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | |
| 1726 | /* select non-DMA memory for PCI_MGA_DATA, otherwise dump of PCI cfg space can lock PCI bus */ |
| 1727 | /* maybe preinit() candidate, but it is same... for all devices... at this time... */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1728 | pci_write_config_dword(minfo->pcidev, PCI_MGA_INDEX, 0x00003C00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | } |
| 1730 | |
| 1731 | err = -ENXIO; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1732 | matroxfb_read_pins(minfo); |
| 1733 | if (minfo->hw_switch->preinit(minfo)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | goto failVideoIO; |
| 1735 | } |
| 1736 | |
| 1737 | err = -ENOMEM; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1738 | if (!matroxfb_getmemory(minfo, memsize, &minfo->video.len) || !minfo->video.len) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | printk(KERN_ERR "matroxfb: cannot determine memory size\n"); |
| 1740 | goto failVideoIO; |
| 1741 | } |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1742 | minfo->devflags.ydstorg = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1744 | minfo->video.base = video_base_phys; |
| 1745 | minfo->video.len_usable = minfo->video.len; |
| 1746 | if (minfo->video.len_usable > b->base->maxdisplayable) |
| 1747 | minfo->video.len_usable = b->base->maxdisplayable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | #ifdef CONFIG_MTRR |
| 1749 | if (mtrr) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1750 | minfo->mtrr.vram = mtrr_add(video_base_phys, minfo->video.len, MTRR_TYPE_WRCOMB, 1); |
| 1751 | minfo->mtrr.vram_valid = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | printk(KERN_INFO "matroxfb: MTRR's turned on\n"); |
| 1753 | } |
| 1754 | #endif /* CONFIG_MTRR */ |
| 1755 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1756 | if (!minfo->devflags.novga) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | request_region(0x3C0, 32, "matrox"); |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1758 | matroxfb_g450_connect(minfo); |
| 1759 | minfo->hw_switch->reset(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1761 | minfo->fbcon.monspecs.hfmin = 0; |
| 1762 | minfo->fbcon.monspecs.hfmax = fh; |
| 1763 | minfo->fbcon.monspecs.vfmin = 0; |
| 1764 | minfo->fbcon.monspecs.vfmax = fv; |
| 1765 | minfo->fbcon.monspecs.dpms = 0; /* TBD */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | |
| 1767 | /* static settings */ |
| 1768 | vesafb_defined.red = colors[depth-1].red; |
| 1769 | vesafb_defined.green = colors[depth-1].green; |
| 1770 | vesafb_defined.blue = colors[depth-1].blue; |
| 1771 | vesafb_defined.bits_per_pixel = colors[depth-1].bits_per_pixel; |
| 1772 | vesafb_defined.grayscale = grayscale; |
| 1773 | vesafb_defined.vmode = 0; |
| 1774 | if (noaccel) |
| 1775 | vesafb_defined.accel_flags &= ~FB_ACCELF_TEXT; |
| 1776 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1777 | minfo->fbops = matroxfb_ops; |
| 1778 | minfo->fbcon.fbops = &minfo->fbops; |
| 1779 | minfo->fbcon.pseudo_palette = minfo->cmap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | /* after __init time we are like module... no logo */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1781 | minfo->fbcon.flags = hotplug ? FBINFO_FLAG_MODULE : FBINFO_FLAG_DEFAULT; |
| 1782 | minfo->fbcon.flags |= FBINFO_PARTIAL_PAN_OK | /* Prefer panning for scroll under MC viewer/edit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | FBINFO_HWACCEL_COPYAREA | /* We have hw-assisted bmove */ |
| 1784 | FBINFO_HWACCEL_FILLRECT | /* And fillrect */ |
| 1785 | FBINFO_HWACCEL_IMAGEBLIT | /* And imageblit */ |
| 1786 | FBINFO_HWACCEL_XPAN | /* And we support both horizontal */ |
| 1787 | FBINFO_HWACCEL_YPAN; /* And vertical panning */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1788 | minfo->video.len_usable &= PAGE_MASK; |
| 1789 | fb_alloc_cmap(&minfo->fbcon.cmap, 256, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | |
| 1791 | #ifndef MODULE |
| 1792 | /* mode database is marked __init!!! */ |
| 1793 | if (!hotplug) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1794 | fb_find_mode(&vesafb_defined, &minfo->fbcon, videomode[0] ? videomode : NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | NULL, 0, &defaultmode, vesafb_defined.bits_per_pixel); |
| 1796 | } |
| 1797 | #endif /* !MODULE */ |
| 1798 | |
| 1799 | /* mode modifiers */ |
| 1800 | if (hslen) |
| 1801 | vesafb_defined.hsync_len = hslen; |
| 1802 | if (vslen) |
| 1803 | vesafb_defined.vsync_len = vslen; |
| 1804 | if (left != ~0) |
| 1805 | vesafb_defined.left_margin = left; |
| 1806 | if (right != ~0) |
| 1807 | vesafb_defined.right_margin = right; |
| 1808 | if (upper != ~0) |
| 1809 | vesafb_defined.upper_margin = upper; |
| 1810 | if (lower != ~0) |
| 1811 | vesafb_defined.lower_margin = lower; |
| 1812 | if (xres) |
| 1813 | vesafb_defined.xres = xres; |
| 1814 | if (yres) |
| 1815 | vesafb_defined.yres = yres; |
| 1816 | if (sync != -1) |
| 1817 | vesafb_defined.sync = sync; |
| 1818 | else if (vesafb_defined.sync == ~0) { |
| 1819 | vesafb_defined.sync = 0; |
| 1820 | if (yres < 400) |
| 1821 | vesafb_defined.sync |= FB_SYNC_HOR_HIGH_ACT; |
| 1822 | else if (yres < 480) |
| 1823 | vesafb_defined.sync |= FB_SYNC_VERT_HIGH_ACT; |
| 1824 | } |
| 1825 | |
| 1826 | /* fv, fh, maxclk limits was specified */ |
| 1827 | { |
| 1828 | unsigned int tmp; |
| 1829 | |
| 1830 | if (fv) { |
| 1831 | tmp = fv * (vesafb_defined.upper_margin + vesafb_defined.yres |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1832 | + vesafb_defined.lower_margin + vesafb_defined.vsync_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1833 | if ((tmp < fh) || (fh == 0)) fh = tmp; |
| 1834 | } |
| 1835 | if (fh) { |
| 1836 | tmp = fh * (vesafb_defined.left_margin + vesafb_defined.xres |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1837 | + vesafb_defined.right_margin + vesafb_defined.hsync_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | if ((tmp < maxclk) || (maxclk == 0)) maxclk = tmp; |
| 1839 | } |
| 1840 | tmp = (maxclk + 499) / 500; |
| 1841 | if (tmp) { |
| 1842 | tmp = (2000000000 + tmp) / tmp; |
| 1843 | if (tmp > pixclock) pixclock = tmp; |
| 1844 | } |
| 1845 | } |
| 1846 | if (pixclock) { |
| 1847 | if (pixclock < 2000) /* > 500MHz */ |
| 1848 | pixclock = 4000; /* 250MHz */ |
| 1849 | if (pixclock > 1000000) |
| 1850 | pixclock = 1000000; /* 1MHz */ |
| 1851 | vesafb_defined.pixclock = pixclock; |
| 1852 | } |
| 1853 | |
| 1854 | /* FIXME: Where to move this?! */ |
| 1855 | #if defined(CONFIG_PPC_PMAC) |
| 1856 | #ifndef MODULE |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 1857 | if (machine_is(powermac)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | struct fb_var_screeninfo var; |
| 1859 | if (default_vmode <= 0 || default_vmode > VMODE_MAX) |
| 1860 | default_vmode = VMODE_640_480_60; |
| 1861 | #ifdef CONFIG_NVRAM |
| 1862 | if (default_cmode == CMODE_NVRAM) |
| 1863 | default_cmode = nvram_read_byte(NV_CMODE); |
| 1864 | #endif |
| 1865 | if (default_cmode < CMODE_8 || default_cmode > CMODE_32) |
| 1866 | default_cmode = CMODE_8; |
| 1867 | if (!mac_vmode_to_var(default_vmode, default_cmode, &var)) { |
| 1868 | var.accel_flags = vesafb_defined.accel_flags; |
| 1869 | var.xoffset = var.yoffset = 0; |
| 1870 | /* Note: mac_vmode_to_var() does not set all parameters */ |
| 1871 | vesafb_defined = var; |
| 1872 | } |
| 1873 | } |
| 1874 | #endif /* !MODULE */ |
| 1875 | #endif /* CONFIG_PPC_PMAC */ |
| 1876 | vesafb_defined.xres_virtual = vesafb_defined.xres; |
| 1877 | if (nopan) { |
| 1878 | vesafb_defined.yres_virtual = vesafb_defined.yres; |
| 1879 | } else { |
| 1880 | vesafb_defined.yres_virtual = 65536; /* large enough to be INF, but small enough |
| 1881 | to yres_virtual * xres_virtual < 2^32 */ |
| 1882 | } |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1883 | matroxfb_init_fix(minfo); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1884 | minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | /* Normalize values (namely yres_virtual) */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1886 | matroxfb_check_var(&vesafb_defined, &minfo->fbcon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over |
| 1888 | * vgacon correctly. fbcon_startup will call fb_set_par for us, WITHOUT check_var, |
| 1889 | * and unfortunately it will do it BEFORE vgacon contents is saved, so it won't work |
| 1890 | * anyway. But we at least tried... */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1891 | minfo->fbcon.var = vesafb_defined; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1892 | err = -EINVAL; |
| 1893 | |
| 1894 | printk(KERN_INFO "matroxfb: %dx%dx%dbpp (virtual: %dx%d)\n", |
| 1895 | vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, |
| 1896 | vesafb_defined.xres_virtual, vesafb_defined.yres_virtual); |
| 1897 | printk(KERN_INFO "matroxfb: framebuffer at 0x%lX, mapped to 0x%p, size %d\n", |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1898 | minfo->video.base, vaddr_va(minfo->video.vbase), minfo->video.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | |
| 1900 | /* We do not have to set currcon to 0... register_framebuffer do it for us on first console |
| 1901 | * and we do not want currcon == 0 for subsequent framebuffers */ |
| 1902 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1903 | minfo->fbcon.device = &minfo->pcidev->dev; |
| 1904 | if (register_framebuffer(&minfo->fbcon) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1905 | goto failVideoIO; |
| 1906 | } |
| 1907 | printk("fb%d: %s frame buffer device\n", |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1908 | minfo->fbcon.node, minfo->fbcon.fix.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | |
| 1910 | /* there is no console on this fb... but we have to initialize hardware |
| 1911 | * until someone tells me what is proper thing to do */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1912 | if (!minfo->initialized) { |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1913 | printk(KERN_INFO "fb%d: initializing hardware\n", |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1914 | minfo->fbcon.node); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1915 | /* We have to use FB_ACTIVATE_FORCE, as we had to put vesafb_defined to the fbcon.var |
| 1916 | * already before, so register_framebuffer works correctly. */ |
| 1917 | vesafb_defined.activate |= FB_ACTIVATE_FORCE; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1918 | fb_set_var(&minfo->fbcon, &vesafb_defined); |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 1919 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | |
| 1921 | return 0; |
| 1922 | failVideoIO:; |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 1923 | matroxfb_g450_shutdown(minfo); |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1924 | mga_iounmap(minfo->video.vbase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | failCtrlIO:; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1926 | mga_iounmap(minfo->mmio.vbase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | failVideoMR:; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1928 | release_mem_region(video_base_phys, minfo->video.len_maximum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1929 | failCtrlMR:; |
| 1930 | release_mem_region(ctrlptr_phys, 16384); |
| 1931 | fail:; |
| 1932 | return err; |
| 1933 | } |
| 1934 | |
| 1935 | static LIST_HEAD(matroxfb_list); |
| 1936 | static LIST_HEAD(matroxfb_driver_list); |
| 1937 | |
| 1938 | #define matroxfb_l(x) list_entry(x, struct matrox_fb_info, next_fb) |
| 1939 | #define matroxfb_driver_l(x) list_entry(x, struct matroxfb_driver, node) |
| 1940 | int matroxfb_register_driver(struct matroxfb_driver* drv) { |
| 1941 | struct matrox_fb_info* minfo; |
| 1942 | |
| 1943 | list_add(&drv->node, &matroxfb_driver_list); |
| 1944 | for (minfo = matroxfb_l(matroxfb_list.next); |
| 1945 | minfo != matroxfb_l(&matroxfb_list); |
| 1946 | minfo = matroxfb_l(minfo->next_fb.next)) { |
| 1947 | void* p; |
| 1948 | |
| 1949 | if (minfo->drivers_count == MATROXFB_MAX_FB_DRIVERS) |
| 1950 | continue; |
| 1951 | p = drv->probe(minfo); |
| 1952 | if (p) { |
| 1953 | minfo->drivers_data[minfo->drivers_count] = p; |
| 1954 | minfo->drivers[minfo->drivers_count++] = drv; |
| 1955 | } |
| 1956 | } |
| 1957 | return 0; |
| 1958 | } |
| 1959 | |
| 1960 | void matroxfb_unregister_driver(struct matroxfb_driver* drv) { |
| 1961 | struct matrox_fb_info* minfo; |
| 1962 | |
| 1963 | list_del(&drv->node); |
| 1964 | for (minfo = matroxfb_l(matroxfb_list.next); |
| 1965 | minfo != matroxfb_l(&matroxfb_list); |
| 1966 | minfo = matroxfb_l(minfo->next_fb.next)) { |
| 1967 | int i; |
| 1968 | |
| 1969 | for (i = 0; i < minfo->drivers_count; ) { |
| 1970 | if (minfo->drivers[i] == drv) { |
| 1971 | if (drv && drv->remove) |
| 1972 | drv->remove(minfo, minfo->drivers_data[i]); |
| 1973 | minfo->drivers[i] = minfo->drivers[--minfo->drivers_count]; |
| 1974 | minfo->drivers_data[i] = minfo->drivers_data[minfo->drivers_count]; |
| 1975 | } else |
| 1976 | i++; |
| 1977 | } |
| 1978 | } |
| 1979 | } |
| 1980 | |
| 1981 | static void matroxfb_register_device(struct matrox_fb_info* minfo) { |
| 1982 | struct matroxfb_driver* drv; |
| 1983 | int i = 0; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 1984 | list_add(&minfo->next_fb, &matroxfb_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1985 | for (drv = matroxfb_driver_l(matroxfb_driver_list.next); |
| 1986 | drv != matroxfb_driver_l(&matroxfb_driver_list); |
| 1987 | drv = matroxfb_driver_l(drv->node.next)) { |
| 1988 | if (drv && drv->probe) { |
| 1989 | void *p = drv->probe(minfo); |
| 1990 | if (p) { |
| 1991 | minfo->drivers_data[i] = p; |
| 1992 | minfo->drivers[i++] = drv; |
| 1993 | if (i == MATROXFB_MAX_FB_DRIVERS) |
| 1994 | break; |
| 1995 | } |
| 1996 | } |
| 1997 | } |
| 1998 | minfo->drivers_count = i; |
| 1999 | } |
| 2000 | |
| 2001 | static void matroxfb_unregister_device(struct matrox_fb_info* minfo) { |
| 2002 | int i; |
| 2003 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2004 | list_del(&minfo->next_fb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | for (i = 0; i < minfo->drivers_count; i++) { |
| 2006 | struct matroxfb_driver* drv = minfo->drivers[i]; |
| 2007 | |
| 2008 | if (drv && drv->remove) |
| 2009 | drv->remove(minfo, minfo->drivers_data[i]); |
| 2010 | } |
| 2011 | } |
| 2012 | |
| 2013 | static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dummy) { |
| 2014 | struct board* b; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2015 | u_int16_t svid; |
| 2016 | u_int16_t sid; |
| 2017 | struct matrox_fb_info* minfo; |
| 2018 | int err; |
| 2019 | u_int32_t cmd; |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 2020 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | svid = pdev->subsystem_vendor; |
| 2023 | sid = pdev->subsystem_device; |
| 2024 | for (b = dev_list; b->vendor; b++) { |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 2025 | if ((b->vendor != pdev->vendor) || (b->device != pdev->device) || (b->rev < pdev->revision)) continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2026 | if (b->svid) |
| 2027 | if ((b->svid != svid) || (b->sid != sid)) continue; |
| 2028 | break; |
| 2029 | } |
| 2030 | /* not match... */ |
| 2031 | if (!b->vendor) |
Jan Beulich | 438e5c5 | 2005-09-13 01:25:45 -0700 | [diff] [blame] | 2032 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2033 | if (dev > 0) { |
| 2034 | /* not requested one... */ |
| 2035 | dev--; |
Jan Beulich | 438e5c5 | 2005-09-13 01:25:45 -0700 | [diff] [blame] | 2036 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | } |
| 2038 | pci_read_config_dword(pdev, PCI_COMMAND, &cmd); |
| 2039 | if (pci_enable_device(pdev)) { |
| 2040 | return -1; |
| 2041 | } |
| 2042 | |
Robert P. J. Day | 5cbded5 | 2006-12-13 00:35:56 -0800 | [diff] [blame] | 2043 | minfo = kmalloc(sizeof(*minfo), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | if (!minfo) |
| 2045 | return -1; |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2046 | memset(minfo, 0, sizeof(*minfo)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2048 | minfo->pcidev = pdev; |
| 2049 | minfo->dead = 0; |
| 2050 | minfo->usecount = 0; |
| 2051 | minfo->userusecount = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2052 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2053 | pci_set_drvdata(pdev, minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | /* DEVFLAGS */ |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2055 | minfo->devflags.memtype = memtype; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | if (memtype != -1) |
| 2057 | noinit = 0; |
| 2058 | if (cmd & PCI_COMMAND_MEMORY) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2059 | minfo->devflags.novga = novga; |
| 2060 | minfo->devflags.nobios = nobios; |
| 2061 | minfo->devflags.noinit = noinit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | /* subsequent heads always needs initialization and must not enable BIOS */ |
| 2063 | novga = 1; |
| 2064 | nobios = 1; |
| 2065 | noinit = 0; |
| 2066 | } else { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2067 | minfo->devflags.novga = 1; |
| 2068 | minfo->devflags.nobios = 1; |
| 2069 | minfo->devflags.noinit = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | } |
| 2071 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2072 | minfo->devflags.nopciretry = no_pci_retry; |
| 2073 | minfo->devflags.mga_24bpp_fix = inv24; |
| 2074 | minfo->devflags.precise_width = option_precise_width; |
| 2075 | minfo->devflags.sgram = sgram; |
| 2076 | minfo->capable.cross4MB = cross4MB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2078 | spin_lock_init(&minfo->lock.DAC); |
| 2079 | spin_lock_init(&minfo->lock.accel); |
| 2080 | init_rwsem(&minfo->crtc2.lock); |
| 2081 | init_rwsem(&minfo->altout.lock); |
| 2082 | mutex_init(&minfo->fbcon.mm_lock); |
| 2083 | minfo->irq_flags = 0; |
| 2084 | init_waitqueue_head(&minfo->crtc1.vsync.wait); |
| 2085 | init_waitqueue_head(&minfo->crtc2.vsync.wait); |
| 2086 | minfo->crtc1.panpos = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 2088 | err = initMatrox2(minfo, b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | if (!err) { |
Jean Delvare | fc2d10d | 2009-09-22 16:47:48 -0700 | [diff] [blame] | 2090 | matroxfb_register_device(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | return 0; |
| 2092 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | kfree(minfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | return -1; |
| 2095 | } |
| 2096 | |
| 2097 | static void pci_remove_matrox(struct pci_dev* pdev) { |
| 2098 | struct matrox_fb_info* minfo; |
| 2099 | |
| 2100 | minfo = pci_get_drvdata(pdev); |
Jean Delvare | 316b4d6 | 2009-09-22 16:47:49 -0700 | [diff] [blame] | 2101 | matroxfb_remove(minfo, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2102 | } |
| 2103 | |
| 2104 | static struct pci_device_id matroxfb_devices[] = { |
| 2105 | #ifdef CONFIG_FB_MATROX_MILLENIUM |
| 2106 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL, |
| 2107 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2108 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL_2, |
| 2109 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2110 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL_2_AGP, |
| 2111 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2112 | #endif |
| 2113 | #ifdef CONFIG_FB_MATROX_MYSTIQUE |
| 2114 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS, |
| 2115 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2116 | #endif |
| 2117 | #ifdef CONFIG_FB_MATROX_G |
| 2118 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_MM, |
| 2119 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2120 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP, |
| 2121 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
Darrick J. Wong | e3a1938 | 2008-10-15 22:03:52 -0700 | [diff] [blame] | 2122 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI, |
| 2123 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, |
| 2125 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2126 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, |
| 2127 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2128 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400, |
| 2129 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2130 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G550, |
| 2131 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
| 2132 | #endif |
| 2133 | {0, 0, |
| 2134 | 0, 0, 0, 0, 0} |
| 2135 | }; |
| 2136 | |
| 2137 | MODULE_DEVICE_TABLE(pci, matroxfb_devices); |
| 2138 | |
| 2139 | |
| 2140 | static struct pci_driver matroxfb_driver = { |
| 2141 | .name = "matroxfb", |
| 2142 | .id_table = matroxfb_devices, |
| 2143 | .probe = matroxfb_probe, |
| 2144 | .remove = pci_remove_matrox, |
| 2145 | }; |
| 2146 | |
| 2147 | /* **************************** init-time only **************************** */ |
| 2148 | |
| 2149 | #define RSResolution(X) ((X) & 0x0F) |
| 2150 | #define RS640x400 1 |
| 2151 | #define RS640x480 2 |
| 2152 | #define RS800x600 3 |
| 2153 | #define RS1024x768 4 |
| 2154 | #define RS1280x1024 5 |
| 2155 | #define RS1600x1200 6 |
| 2156 | #define RS768x576 7 |
| 2157 | #define RS960x720 8 |
| 2158 | #define RS1152x864 9 |
| 2159 | #define RS1408x1056 10 |
| 2160 | #define RS640x350 11 |
| 2161 | #define RS1056x344 12 /* 132 x 43 text */ |
| 2162 | #define RS1056x400 13 /* 132 x 50 text */ |
| 2163 | #define RS1056x480 14 /* 132 x 60 text */ |
| 2164 | #define RSNoxNo 15 |
| 2165 | /* 10-FF */ |
| 2166 | static struct { int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = { |
| 2167 | { 640, 400, 48, 16, 39, 8, 96, 2, 70 }, |
| 2168 | { 640, 480, 48, 16, 33, 10, 96, 2, 60 }, |
| 2169 | { 800, 600, 144, 24, 28, 8, 112, 6, 60 }, |
| 2170 | { 1024, 768, 160, 32, 30, 4, 128, 4, 60 }, |
| 2171 | { 1280, 1024, 224, 32, 32, 4, 136, 4, 60 }, |
| 2172 | { 1600, 1200, 272, 48, 32, 5, 152, 5, 60 }, |
| 2173 | { 768, 576, 144, 16, 28, 6, 112, 4, 60 }, |
| 2174 | { 960, 720, 144, 24, 28, 8, 112, 4, 60 }, |
| 2175 | { 1152, 864, 192, 32, 30, 4, 128, 4, 60 }, |
| 2176 | { 1408, 1056, 256, 40, 32, 5, 144, 5, 60 }, |
| 2177 | { 640, 350, 48, 16, 39, 8, 96, 2, 70 }, |
| 2178 | { 1056, 344, 96, 24, 59, 44, 160, 2, 70 }, |
| 2179 | { 1056, 400, 96, 24, 39, 8, 160, 2, 70 }, |
| 2180 | { 1056, 480, 96, 24, 36, 12, 160, 3, 60 }, |
| 2181 | { 0, 0, ~0, ~0, ~0, ~0, 0, 0, 0 } |
| 2182 | }; |
| 2183 | |
| 2184 | #define RSCreate(X,Y) ((X) | ((Y) << 8)) |
| 2185 | static struct { unsigned int vesa; unsigned int info; } *RSptr, vesamap[] __initdata = { |
| 2186 | /* default must be first */ |
| 2187 | { ~0, RSCreate(RSNoxNo, RS8bpp ) }, |
| 2188 | { 0x101, RSCreate(RS640x480, RS8bpp ) }, |
| 2189 | { 0x100, RSCreate(RS640x400, RS8bpp ) }, |
| 2190 | { 0x180, RSCreate(RS768x576, RS8bpp ) }, |
| 2191 | { 0x103, RSCreate(RS800x600, RS8bpp ) }, |
| 2192 | { 0x188, RSCreate(RS960x720, RS8bpp ) }, |
| 2193 | { 0x105, RSCreate(RS1024x768, RS8bpp ) }, |
| 2194 | { 0x190, RSCreate(RS1152x864, RS8bpp ) }, |
| 2195 | { 0x107, RSCreate(RS1280x1024, RS8bpp ) }, |
| 2196 | { 0x198, RSCreate(RS1408x1056, RS8bpp ) }, |
| 2197 | { 0x11C, RSCreate(RS1600x1200, RS8bpp ) }, |
| 2198 | { 0x110, RSCreate(RS640x480, RS15bpp) }, |
| 2199 | { 0x181, RSCreate(RS768x576, RS15bpp) }, |
| 2200 | { 0x113, RSCreate(RS800x600, RS15bpp) }, |
| 2201 | { 0x189, RSCreate(RS960x720, RS15bpp) }, |
| 2202 | { 0x116, RSCreate(RS1024x768, RS15bpp) }, |
| 2203 | { 0x191, RSCreate(RS1152x864, RS15bpp) }, |
| 2204 | { 0x119, RSCreate(RS1280x1024, RS15bpp) }, |
| 2205 | { 0x199, RSCreate(RS1408x1056, RS15bpp) }, |
| 2206 | { 0x11D, RSCreate(RS1600x1200, RS15bpp) }, |
| 2207 | { 0x111, RSCreate(RS640x480, RS16bpp) }, |
| 2208 | { 0x182, RSCreate(RS768x576, RS16bpp) }, |
| 2209 | { 0x114, RSCreate(RS800x600, RS16bpp) }, |
| 2210 | { 0x18A, RSCreate(RS960x720, RS16bpp) }, |
| 2211 | { 0x117, RSCreate(RS1024x768, RS16bpp) }, |
| 2212 | { 0x192, RSCreate(RS1152x864, RS16bpp) }, |
| 2213 | { 0x11A, RSCreate(RS1280x1024, RS16bpp) }, |
| 2214 | { 0x19A, RSCreate(RS1408x1056, RS16bpp) }, |
| 2215 | { 0x11E, RSCreate(RS1600x1200, RS16bpp) }, |
| 2216 | { 0x1B2, RSCreate(RS640x480, RS24bpp) }, |
| 2217 | { 0x184, RSCreate(RS768x576, RS24bpp) }, |
| 2218 | { 0x1B5, RSCreate(RS800x600, RS24bpp) }, |
| 2219 | { 0x18C, RSCreate(RS960x720, RS24bpp) }, |
| 2220 | { 0x1B8, RSCreate(RS1024x768, RS24bpp) }, |
| 2221 | { 0x194, RSCreate(RS1152x864, RS24bpp) }, |
| 2222 | { 0x1BB, RSCreate(RS1280x1024, RS24bpp) }, |
| 2223 | { 0x19C, RSCreate(RS1408x1056, RS24bpp) }, |
| 2224 | { 0x1BF, RSCreate(RS1600x1200, RS24bpp) }, |
| 2225 | { 0x112, RSCreate(RS640x480, RS32bpp) }, |
| 2226 | { 0x183, RSCreate(RS768x576, RS32bpp) }, |
| 2227 | { 0x115, RSCreate(RS800x600, RS32bpp) }, |
| 2228 | { 0x18B, RSCreate(RS960x720, RS32bpp) }, |
| 2229 | { 0x118, RSCreate(RS1024x768, RS32bpp) }, |
| 2230 | { 0x193, RSCreate(RS1152x864, RS32bpp) }, |
| 2231 | { 0x11B, RSCreate(RS1280x1024, RS32bpp) }, |
| 2232 | { 0x19B, RSCreate(RS1408x1056, RS32bpp) }, |
| 2233 | { 0x11F, RSCreate(RS1600x1200, RS32bpp) }, |
| 2234 | { 0x010, RSCreate(RS640x350, RS4bpp ) }, |
| 2235 | { 0x012, RSCreate(RS640x480, RS4bpp ) }, |
| 2236 | { 0x102, RSCreate(RS800x600, RS4bpp ) }, |
| 2237 | { 0x104, RSCreate(RS1024x768, RS4bpp ) }, |
| 2238 | { 0x106, RSCreate(RS1280x1024, RS4bpp ) }, |
| 2239 | { 0, 0 }}; |
| 2240 | |
| 2241 | static void __init matroxfb_init_params(void) { |
| 2242 | /* fh from kHz to Hz */ |
| 2243 | if (fh < 1000) |
| 2244 | fh *= 1000; /* 1kHz minimum */ |
| 2245 | /* maxclk */ |
| 2246 | if (maxclk < 1000) maxclk *= 1000; /* kHz -> Hz, MHz -> kHz */ |
| 2247 | if (maxclk < 1000000) maxclk *= 1000; /* kHz -> Hz, 1MHz minimum */ |
| 2248 | /* fix VESA number */ |
| 2249 | if (vesa != ~0) |
| 2250 | vesa &= 0x1DFF; /* mask out clearscreen, acceleration and so on */ |
| 2251 | |
| 2252 | /* static settings */ |
| 2253 | for (RSptr = vesamap; RSptr->vesa; RSptr++) { |
| 2254 | if (RSptr->vesa == vesa) break; |
| 2255 | } |
| 2256 | if (!RSptr->vesa) { |
| 2257 | printk(KERN_ERR "Invalid vesa mode 0x%04X\n", vesa); |
| 2258 | RSptr = vesamap; |
| 2259 | } |
| 2260 | { |
| 2261 | int res = RSResolution(RSptr->info)-1; |
| 2262 | if (left == ~0) |
| 2263 | left = timmings[res].left; |
| 2264 | if (!xres) |
| 2265 | xres = timmings[res].xres; |
| 2266 | if (right == ~0) |
| 2267 | right = timmings[res].right; |
| 2268 | if (!hslen) |
| 2269 | hslen = timmings[res].hslen; |
| 2270 | if (upper == ~0) |
| 2271 | upper = timmings[res].upper; |
| 2272 | if (!yres) |
| 2273 | yres = timmings[res].yres; |
| 2274 | if (lower == ~0) |
| 2275 | lower = timmings[res].lower; |
| 2276 | if (!vslen) |
| 2277 | vslen = timmings[res].vslen; |
| 2278 | if (!(fv||fh||maxclk||pixclock)) |
| 2279 | fv = timmings[res].vfreq; |
| 2280 | if (depth == -1) |
| 2281 | depth = RSDepth(RSptr->info); |
| 2282 | } |
| 2283 | } |
| 2284 | |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2285 | static int __init matrox_init(void) { |
| 2286 | int err; |
| 2287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | matroxfb_init_params(); |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2289 | err = pci_register_driver(&matroxfb_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | dev = -1; /* accept all new devices... */ |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2291 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | } |
| 2293 | |
| 2294 | /* **************************** exit-time only **************************** */ |
| 2295 | |
| 2296 | static void __exit matrox_done(void) { |
| 2297 | pci_unregister_driver(&matroxfb_driver); |
| 2298 | } |
| 2299 | |
| 2300 | #ifndef MODULE |
| 2301 | |
| 2302 | /* ************************* init in-kernel code ************************** */ |
| 2303 | |
| 2304 | static int __init matroxfb_setup(char *options) { |
| 2305 | char *this_opt; |
| 2306 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 2307 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | |
| 2309 | if (!options || !*options) |
| 2310 | return 0; |
| 2311 | |
| 2312 | while ((this_opt = strsep(&options, ",")) != NULL) { |
| 2313 | if (!*this_opt) continue; |
| 2314 | |
| 2315 | dprintk("matroxfb_setup: option %s\n", this_opt); |
| 2316 | |
| 2317 | if (!strncmp(this_opt, "dev:", 4)) |
| 2318 | dev = simple_strtoul(this_opt+4, NULL, 0); |
| 2319 | else if (!strncmp(this_opt, "depth:", 6)) { |
| 2320 | switch (simple_strtoul(this_opt+6, NULL, 0)) { |
| 2321 | case 0: depth = RSText; break; |
| 2322 | case 4: depth = RS4bpp; break; |
| 2323 | case 8: depth = RS8bpp; break; |
| 2324 | case 15:depth = RS15bpp; break; |
| 2325 | case 16:depth = RS16bpp; break; |
| 2326 | case 24:depth = RS24bpp; break; |
| 2327 | case 32:depth = RS32bpp; break; |
| 2328 | default: |
| 2329 | printk(KERN_ERR "matroxfb: unsupported color depth\n"); |
| 2330 | } |
| 2331 | } else if (!strncmp(this_opt, "xres:", 5)) |
| 2332 | xres = simple_strtoul(this_opt+5, NULL, 0); |
| 2333 | else if (!strncmp(this_opt, "yres:", 5)) |
| 2334 | yres = simple_strtoul(this_opt+5, NULL, 0); |
| 2335 | else if (!strncmp(this_opt, "vslen:", 6)) |
| 2336 | vslen = simple_strtoul(this_opt+6, NULL, 0); |
| 2337 | else if (!strncmp(this_opt, "hslen:", 6)) |
| 2338 | hslen = simple_strtoul(this_opt+6, NULL, 0); |
| 2339 | else if (!strncmp(this_opt, "left:", 5)) |
| 2340 | left = simple_strtoul(this_opt+5, NULL, 0); |
| 2341 | else if (!strncmp(this_opt, "right:", 6)) |
| 2342 | right = simple_strtoul(this_opt+6, NULL, 0); |
| 2343 | else if (!strncmp(this_opt, "upper:", 6)) |
| 2344 | upper = simple_strtoul(this_opt+6, NULL, 0); |
| 2345 | else if (!strncmp(this_opt, "lower:", 6)) |
| 2346 | lower = simple_strtoul(this_opt+6, NULL, 0); |
| 2347 | else if (!strncmp(this_opt, "pixclock:", 9)) |
| 2348 | pixclock = simple_strtoul(this_opt+9, NULL, 0); |
| 2349 | else if (!strncmp(this_opt, "sync:", 5)) |
| 2350 | sync = simple_strtoul(this_opt+5, NULL, 0); |
| 2351 | else if (!strncmp(this_opt, "vesa:", 5)) |
| 2352 | vesa = simple_strtoul(this_opt+5, NULL, 0); |
| 2353 | else if (!strncmp(this_opt, "maxclk:", 7)) |
| 2354 | maxclk = simple_strtoul(this_opt+7, NULL, 0); |
| 2355 | else if (!strncmp(this_opt, "fh:", 3)) |
| 2356 | fh = simple_strtoul(this_opt+3, NULL, 0); |
| 2357 | else if (!strncmp(this_opt, "fv:", 3)) |
| 2358 | fv = simple_strtoul(this_opt+3, NULL, 0); |
| 2359 | else if (!strncmp(this_opt, "mem:", 4)) |
| 2360 | mem = simple_strtoul(this_opt+4, NULL, 0); |
| 2361 | else if (!strncmp(this_opt, "mode:", 5)) |
| 2362 | strlcpy(videomode, this_opt+5, sizeof(videomode)); |
| 2363 | else if (!strncmp(this_opt, "outputs:", 8)) |
| 2364 | strlcpy(outputs, this_opt+8, sizeof(outputs)); |
| 2365 | else if (!strncmp(this_opt, "dfp:", 4)) { |
| 2366 | dfp_type = simple_strtoul(this_opt+4, NULL, 0); |
| 2367 | dfp = 1; |
Andrew Morton | a50d913 | 2006-06-21 01:57:39 -0300 | [diff] [blame] | 2368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | #ifdef CONFIG_PPC_PMAC |
| 2370 | else if (!strncmp(this_opt, "vmode:", 6)) { |
| 2371 | unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0); |
| 2372 | if (vmode > 0 && vmode <= VMODE_MAX) |
| 2373 | default_vmode = vmode; |
| 2374 | } else if (!strncmp(this_opt, "cmode:", 6)) { |
| 2375 | unsigned int cmode = simple_strtoul(this_opt+6, NULL, 0); |
| 2376 | switch (cmode) { |
| 2377 | case 0: |
| 2378 | case 8: |
| 2379 | default_cmode = CMODE_8; |
| 2380 | break; |
| 2381 | case 15: |
| 2382 | case 16: |
| 2383 | default_cmode = CMODE_16; |
| 2384 | break; |
| 2385 | case 24: |
| 2386 | case 32: |
| 2387 | default_cmode = CMODE_32; |
| 2388 | break; |
| 2389 | } |
| 2390 | } |
| 2391 | #endif |
| 2392 | else if (!strcmp(this_opt, "disabled")) /* nodisabled does not exist */ |
| 2393 | disabled = 1; |
| 2394 | else if (!strcmp(this_opt, "enabled")) /* noenabled does not exist */ |
| 2395 | disabled = 0; |
| 2396 | else if (!strcmp(this_opt, "sgram")) /* nosgram == sdram */ |
| 2397 | sgram = 1; |
| 2398 | else if (!strcmp(this_opt, "sdram")) |
| 2399 | sgram = 0; |
| 2400 | else if (!strncmp(this_opt, "memtype:", 8)) |
| 2401 | memtype = simple_strtoul(this_opt+8, NULL, 0); |
| 2402 | else { |
| 2403 | int value = 1; |
| 2404 | |
| 2405 | if (!strncmp(this_opt, "no", 2)) { |
| 2406 | value = 0; |
| 2407 | this_opt += 2; |
| 2408 | } |
| 2409 | if (! strcmp(this_opt, "inverse")) |
| 2410 | inverse = value; |
| 2411 | else if (!strcmp(this_opt, "accel")) |
| 2412 | noaccel = !value; |
| 2413 | else if (!strcmp(this_opt, "pan")) |
| 2414 | nopan = !value; |
| 2415 | else if (!strcmp(this_opt, "pciretry")) |
| 2416 | no_pci_retry = !value; |
| 2417 | else if (!strcmp(this_opt, "vga")) |
| 2418 | novga = !value; |
| 2419 | else if (!strcmp(this_opt, "bios")) |
| 2420 | nobios = !value; |
| 2421 | else if (!strcmp(this_opt, "init")) |
| 2422 | noinit = !value; |
| 2423 | #ifdef CONFIG_MTRR |
| 2424 | else if (!strcmp(this_opt, "mtrr")) |
| 2425 | mtrr = value; |
| 2426 | #endif |
| 2427 | else if (!strcmp(this_opt, "inv24")) |
| 2428 | inv24 = value; |
| 2429 | else if (!strcmp(this_opt, "cross4MB")) |
| 2430 | cross4MB = value; |
| 2431 | else if (!strcmp(this_opt, "grayscale")) |
| 2432 | grayscale = value; |
| 2433 | else if (!strcmp(this_opt, "dfp")) |
| 2434 | dfp = value; |
| 2435 | else { |
| 2436 | strlcpy(videomode, this_opt, sizeof(videomode)); |
| 2437 | } |
| 2438 | } |
| 2439 | } |
| 2440 | return 0; |
| 2441 | } |
| 2442 | |
| 2443 | static int __initdata initialized = 0; |
| 2444 | |
| 2445 | static int __init matroxfb_init(void) |
| 2446 | { |
| 2447 | char *option = NULL; |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2448 | int err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 2450 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2451 | |
| 2452 | if (fb_get_options("matroxfb", &option)) |
| 2453 | return -ENODEV; |
| 2454 | matroxfb_setup(option); |
| 2455 | |
| 2456 | if (disabled) |
| 2457 | return -ENXIO; |
| 2458 | if (!initialized) { |
| 2459 | initialized = 1; |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2460 | err = matrox_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | } |
| 2462 | hotplug = 1; |
| 2463 | /* never return failure, user can hotplug matrox later... */ |
Antonino A. Daplas | b0b1032 | 2006-10-03 01:14:52 -0700 | [diff] [blame] | 2464 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | } |
| 2466 | |
| 2467 | module_init(matroxfb_init); |
| 2468 | |
| 2469 | #else |
| 2470 | |
| 2471 | /* *************************** init module code **************************** */ |
| 2472 | |
| 2473 | MODULE_AUTHOR("(c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>"); |
| 2474 | MODULE_DESCRIPTION("Accelerated FBDev driver for Matrox Millennium/Mystique/G100/G200/G400/G450/G550"); |
| 2475 | MODULE_LICENSE("GPL"); |
| 2476 | |
| 2477 | module_param(mem, int, 0); |
| 2478 | MODULE_PARM_DESC(mem, "Size of available memory in MB, KB or B (2,4,8,12,16MB, default=autodetect)"); |
| 2479 | module_param(disabled, int, 0); |
| 2480 | MODULE_PARM_DESC(disabled, "Disabled (0 or 1=disabled) (default=0)"); |
| 2481 | module_param(noaccel, int, 0); |
| 2482 | MODULE_PARM_DESC(noaccel, "Do not use accelerating engine (0 or 1=disabled) (default=0)"); |
| 2483 | module_param(nopan, int, 0); |
| 2484 | MODULE_PARM_DESC(nopan, "Disable pan on startup (0 or 1=disabled) (default=0)"); |
| 2485 | module_param(no_pci_retry, int, 0); |
| 2486 | MODULE_PARM_DESC(no_pci_retry, "PCI retries enabled (0 or 1=disabled) (default=0)"); |
| 2487 | module_param(novga, int, 0); |
| 2488 | MODULE_PARM_DESC(novga, "VGA I/O (0x3C0-0x3DF) disabled (0 or 1=disabled) (default=0)"); |
| 2489 | module_param(nobios, int, 0); |
| 2490 | MODULE_PARM_DESC(nobios, "Disables ROM BIOS (0 or 1=disabled) (default=do not change BIOS state)"); |
| 2491 | module_param(noinit, int, 0); |
| 2492 | MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not initialize) (default=0)"); |
| 2493 | module_param(memtype, int, 0); |
| 2494 | MODULE_PARM_DESC(memtype, "Memory type for G200/G400 (see Documentation/fb/matroxfb.txt for explanation) (default=3 for G200, 0 for G400)"); |
| 2495 | #ifdef CONFIG_MTRR |
| 2496 | module_param(mtrr, int, 0); |
| 2497 | MODULE_PARM_DESC(mtrr, "This speeds up video memory accesses (0=disabled or 1) (default=1)"); |
| 2498 | #endif |
| 2499 | module_param(sgram, int, 0); |
| 2500 | MODULE_PARM_DESC(sgram, "Indicates that G100/G200/G400 has SGRAM memory (0=SDRAM, 1=SGRAM) (default=0)"); |
| 2501 | module_param(inv24, int, 0); |
| 2502 | MODULE_PARM_DESC(inv24, "Inverts clock polarity for 24bpp and loop frequency > 100MHz (default=do not invert polarity)"); |
| 2503 | module_param(inverse, int, 0); |
| 2504 | MODULE_PARM_DESC(inverse, "Inverse (0 or 1) (default=0)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | module_param(dev, int, 0); |
| 2506 | MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=all working)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2507 | module_param(vesa, int, 0); |
| 2508 | MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)"); |
| 2509 | module_param(xres, int, 0); |
| 2510 | MODULE_PARM_DESC(xres, "Horizontal resolution (px), overrides xres from vesa (default=vesa)"); |
| 2511 | module_param(yres, int, 0); |
| 2512 | MODULE_PARM_DESC(yres, "Vertical resolution (scans), overrides yres from vesa (default=vesa)"); |
| 2513 | module_param(upper, int, 0); |
| 2514 | MODULE_PARM_DESC(upper, "Upper blank space (scans), overrides upper from vesa (default=vesa)"); |
| 2515 | module_param(lower, int, 0); |
| 2516 | MODULE_PARM_DESC(lower, "Lower blank space (scans), overrides lower from vesa (default=vesa)"); |
| 2517 | module_param(vslen, int, 0); |
| 2518 | MODULE_PARM_DESC(vslen, "Vertical sync length (scans), overrides lower from vesa (default=vesa)"); |
| 2519 | module_param(left, int, 0); |
| 2520 | MODULE_PARM_DESC(left, "Left blank space (px), overrides left from vesa (default=vesa)"); |
| 2521 | module_param(right, int, 0); |
| 2522 | MODULE_PARM_DESC(right, "Right blank space (px), overrides right from vesa (default=vesa)"); |
| 2523 | module_param(hslen, int, 0); |
| 2524 | MODULE_PARM_DESC(hslen, "Horizontal sync length (px), overrides hslen from vesa (default=vesa)"); |
| 2525 | module_param(pixclock, int, 0); |
| 2526 | MODULE_PARM_DESC(pixclock, "Pixelclock (ns), overrides pixclock from vesa (default=vesa)"); |
| 2527 | module_param(sync, int, 0); |
| 2528 | MODULE_PARM_DESC(sync, "Sync polarity, overrides sync from vesa (default=vesa)"); |
| 2529 | module_param(depth, int, 0); |
| 2530 | MODULE_PARM_DESC(depth, "Color depth (0=text,8,15,16,24,32) (default=vesa)"); |
| 2531 | module_param(maxclk, int, 0); |
| 2532 | MODULE_PARM_DESC(maxclk, "Startup maximal clock, 0-999MHz, 1000-999999kHz, 1000000-INF Hz"); |
| 2533 | module_param(fh, int, 0); |
| 2534 | MODULE_PARM_DESC(fh, "Startup horizontal frequency, 0-999kHz, 1000-INF Hz"); |
| 2535 | module_param(fv, int, 0); |
| 2536 | MODULE_PARM_DESC(fv, "Startup vertical frequency, 0-INF Hz\n" |
Niels de Vos | 61a2d07 | 2008-07-31 00:07:23 -0700 | [diff] [blame] | 2537 | "You should specify \"fv:max_monitor_vsync,fh:max_monitor_hsync,maxclk:max_monitor_dotclock\""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | module_param(grayscale, int, 0); |
| 2539 | MODULE_PARM_DESC(grayscale, "Sets display into grayscale. Works perfectly with paletized videomode (4, 8bpp), some limitations apply to 16, 24 and 32bpp videomodes (default=nograyscale)"); |
| 2540 | module_param(cross4MB, int, 0); |
| 2541 | MODULE_PARM_DESC(cross4MB, "Specifies that 4MB boundary can be in middle of line. (default=autodetected)"); |
| 2542 | module_param(dfp, int, 0); |
| 2543 | MODULE_PARM_DESC(dfp, "Specifies whether to use digital flat panel interface of G200/G400 (0 or 1) (default=0)"); |
| 2544 | module_param(dfp_type, int, 0); |
| 2545 | MODULE_PARM_DESC(dfp_type, "Specifies DFP interface type (0 to 255) (default=read from hardware)"); |
| 2546 | module_param_string(outputs, outputs, sizeof(outputs), 0); |
| 2547 | MODULE_PARM_DESC(outputs, "Specifies which CRTC is mapped to which output (string of up to three letters, consisting of 0 (disabled), 1 (CRTC1), 2 (CRTC2)) (default=111 for Gx50, 101 for G200/G400 with DFP, and 100 for all other devices)"); |
| 2548 | #ifdef CONFIG_PPC_PMAC |
| 2549 | module_param_named(vmode, default_vmode, int, 0); |
| 2550 | MODULE_PARM_DESC(vmode, "Specify the vmode mode number that should be used (640x480 default)"); |
| 2551 | module_param_named(cmode, default_cmode, int, 0); |
| 2552 | MODULE_PARM_DESC(cmode, "Specify the video depth that should be used (8bit default)"); |
| 2553 | #endif |
| 2554 | |
| 2555 | int __init init_module(void){ |
| 2556 | |
Harvey Harrison | 5ae1217 | 2008-04-28 02:15:47 -0700 | [diff] [blame] | 2557 | DBG(__func__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | |
| 2559 | if (disabled) |
| 2560 | return -ENXIO; |
| 2561 | |
| 2562 | if (depth == 0) |
| 2563 | depth = RSText; |
| 2564 | else if (depth == 4) |
| 2565 | depth = RS4bpp; |
| 2566 | else if (depth == 8) |
| 2567 | depth = RS8bpp; |
| 2568 | else if (depth == 15) |
| 2569 | depth = RS15bpp; |
| 2570 | else if (depth == 16) |
| 2571 | depth = RS16bpp; |
| 2572 | else if (depth == 24) |
| 2573 | depth = RS24bpp; |
| 2574 | else if (depth == 32) |
| 2575 | depth = RS32bpp; |
| 2576 | else if (depth != -1) { |
| 2577 | printk(KERN_ERR "matroxfb: depth %d is not supported, using default\n", depth); |
| 2578 | depth = -1; |
| 2579 | } |
| 2580 | matrox_init(); |
| 2581 | /* never return failure; user can hotplug matrox later... */ |
| 2582 | return 0; |
| 2583 | } |
| 2584 | #endif /* MODULE */ |
| 2585 | |
| 2586 | module_exit(matrox_done); |
| 2587 | EXPORT_SYMBOL(matroxfb_register_driver); |
| 2588 | EXPORT_SYMBOL(matroxfb_unregister_driver); |
| 2589 | EXPORT_SYMBOL(matroxfb_wait_for_sync); |
| 2590 | EXPORT_SYMBOL(matroxfb_enable_irq); |
| 2591 | |
| 2592 | /* |
| 2593 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 2594 | * --------------------------------------------------------------------------- |
| 2595 | * Local variables: |
| 2596 | * c-basic-offset: 8 |
| 2597 | * End: |
| 2598 | */ |
| 2599 | |