aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/matrox/matroxfb_base.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-09-24 16:22:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-09-24 16:22:33 -0400
commitbaea7b946f00a291b166ccae7fcfed6c01530cc6 (patch)
tree4aa275fbdbec9c7b9b4629e8bee2bbecd3c6a6af /drivers/video/matrox/matroxfb_base.c
parentae19ffbadc1b2100285a5b5b3d0a4e0a11390904 (diff)
parent94e0fb086fc5663c38bbc0fe86d698be8314f82f (diff)
Merge branch 'origin' into for-linus
Conflicts: MAINTAINERS
Diffstat (limited to 'drivers/video/matrox/matroxfb_base.c')
-rw-r--r--drivers/video/matrox/matroxfb_base.c772
1 files changed, 379 insertions, 393 deletions
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 0c1049b308bf..7064fb4427b6 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -154,21 +154,22 @@ static struct fb_var_screeninfo vesafb_defined = {
154 154
155 155
156/* --------------------------------------------------------------------- */ 156/* --------------------------------------------------------------------- */
157static void update_crtc2(WPMINFO unsigned int pos) { 157static void update_crtc2(struct matrox_fb_info *minfo, unsigned int pos)
158 struct matroxfb_dh_fb_info* info = ACCESS_FBINFO(crtc2.info); 158{
159 struct matroxfb_dh_fb_info *info = minfo->crtc2.info;
159 160
160 /* Make sure that displays are compatible */ 161 /* Make sure that displays are compatible */
161 if (info && (info->fbcon.var.bits_per_pixel == ACCESS_FBINFO(fbcon).var.bits_per_pixel) 162 if (info && (info->fbcon.var.bits_per_pixel == minfo->fbcon.var.bits_per_pixel)
162 && (info->fbcon.var.xres_virtual == ACCESS_FBINFO(fbcon).var.xres_virtual) 163 && (info->fbcon.var.xres_virtual == minfo->fbcon.var.xres_virtual)
163 && (info->fbcon.var.green.length == ACCESS_FBINFO(fbcon).var.green.length) 164 && (info->fbcon.var.green.length == minfo->fbcon.var.green.length)
164 ) { 165 ) {
165 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) { 166 switch (minfo->fbcon.var.bits_per_pixel) {
166 case 16: 167 case 16:
167 case 32: 168 case 32:
168 pos = pos * 8; 169 pos = pos * 8;
169 if (info->interlaced) { 170 if (info->interlaced) {
170 mga_outl(0x3C2C, pos); 171 mga_outl(0x3C2C, pos);
171 mga_outl(0x3C28, pos + ACCESS_FBINFO(fbcon).var.xres_virtual * ACCESS_FBINFO(fbcon).var.bits_per_pixel / 8); 172 mga_outl(0x3C28, pos + minfo->fbcon.var.xres_virtual * minfo->fbcon.var.bits_per_pixel / 8);
172 } else { 173 } else {
173 mga_outl(0x3C28, pos); 174 mga_outl(0x3C28, pos);
174 } 175 }
@@ -177,17 +178,18 @@ static void update_crtc2(WPMINFO unsigned int pos) {
177 } 178 }
178} 179}
179 180
180static void matroxfb_crtc1_panpos(WPMINFO2) { 181static void matroxfb_crtc1_panpos(struct matrox_fb_info *minfo)
181 if (ACCESS_FBINFO(crtc1.panpos) >= 0) { 182{
183 if (minfo->crtc1.panpos >= 0) {
182 unsigned long flags; 184 unsigned long flags;
183 int panpos; 185 int panpos;
184 186
185 matroxfb_DAC_lock_irqsave(flags); 187 matroxfb_DAC_lock_irqsave(flags);
186 panpos = ACCESS_FBINFO(crtc1.panpos); 188 panpos = minfo->crtc1.panpos;
187 if (panpos >= 0) { 189 if (panpos >= 0) {
188 unsigned int extvga_reg; 190 unsigned int extvga_reg;
189 191
190 ACCESS_FBINFO(crtc1.panpos) = -1; /* No update pending anymore */ 192 minfo->crtc1.panpos = -1; /* No update pending anymore */
191 extvga_reg = mga_inb(M_EXTVGA_INDEX); 193 extvga_reg = mga_inb(M_EXTVGA_INDEX);
192 mga_setr(M_EXTVGA_INDEX, 0x00, panpos); 194 mga_setr(M_EXTVGA_INDEX, 0x00, panpos);
193 if (extvga_reg != 0x00) { 195 if (extvga_reg != 0x00) {
@@ -202,39 +204,39 @@ static irqreturn_t matrox_irq(int irq, void *dev_id)
202{ 204{
203 u_int32_t status; 205 u_int32_t status;
204 int handled = 0; 206 int handled = 0;
205 207 struct matrox_fb_info *minfo = dev_id;
206 MINFO_FROM(dev_id);
207 208
208 status = mga_inl(M_STATUS); 209 status = mga_inl(M_STATUS);
209 210
210 if (status & 0x20) { 211 if (status & 0x20) {
211 mga_outl(M_ICLEAR, 0x20); 212 mga_outl(M_ICLEAR, 0x20);
212 ACCESS_FBINFO(crtc1.vsync.cnt)++; 213 minfo->crtc1.vsync.cnt++;
213 matroxfb_crtc1_panpos(PMINFO2); 214 matroxfb_crtc1_panpos(minfo);
214 wake_up_interruptible(&ACCESS_FBINFO(crtc1.vsync.wait)); 215 wake_up_interruptible(&minfo->crtc1.vsync.wait);
215 handled = 1; 216 handled = 1;
216 } 217 }
217 if (status & 0x200) { 218 if (status & 0x200) {
218 mga_outl(M_ICLEAR, 0x200); 219 mga_outl(M_ICLEAR, 0x200);
219 ACCESS_FBINFO(crtc2.vsync.cnt)++; 220 minfo->crtc2.vsync.cnt++;
220 wake_up_interruptible(&ACCESS_FBINFO(crtc2.vsync.wait)); 221 wake_up_interruptible(&minfo->crtc2.vsync.wait);
221 handled = 1; 222 handled = 1;
222 } 223 }
223 return IRQ_RETVAL(handled); 224 return IRQ_RETVAL(handled);
224} 225}
225 226
226int matroxfb_enable_irq(WPMINFO int reenable) { 227int matroxfb_enable_irq(struct matrox_fb_info *minfo, int reenable)
228{
227 u_int32_t bm; 229 u_int32_t bm;
228 230
229 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG400) 231 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400)
230 bm = 0x220; 232 bm = 0x220;
231 else 233 else
232 bm = 0x020; 234 bm = 0x020;
233 235
234 if (!test_and_set_bit(0, &ACCESS_FBINFO(irq_flags))) { 236 if (!test_and_set_bit(0, &minfo->irq_flags)) {
235 if (request_irq(ACCESS_FBINFO(pcidev)->irq, matrox_irq, 237 if (request_irq(minfo->pcidev->irq, matrox_irq,
236 IRQF_SHARED, "matroxfb", MINFO)) { 238 IRQF_SHARED, "matroxfb", minfo)) {
237 clear_bit(0, &ACCESS_FBINFO(irq_flags)); 239 clear_bit(0, &minfo->irq_flags);
238 return -EINVAL; 240 return -EINVAL;
239 } 241 }
240 /* Clear any pending field interrupts */ 242 /* Clear any pending field interrupts */
@@ -252,37 +254,39 @@ int matroxfb_enable_irq(WPMINFO int reenable) {
252 return 0; 254 return 0;
253} 255}
254 256
255static void matroxfb_disable_irq(WPMINFO2) { 257static void matroxfb_disable_irq(struct matrox_fb_info *minfo)
256 if (test_and_clear_bit(0, &ACCESS_FBINFO(irq_flags))) { 258{
259 if (test_and_clear_bit(0, &minfo->irq_flags)) {
257 /* Flush pending pan-at-vbl request... */ 260 /* Flush pending pan-at-vbl request... */
258 matroxfb_crtc1_panpos(PMINFO2); 261 matroxfb_crtc1_panpos(minfo);
259 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG400) 262 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400)
260 mga_outl(M_IEN, mga_inl(M_IEN) & ~0x220); 263 mga_outl(M_IEN, mga_inl(M_IEN) & ~0x220);
261 else 264 else
262 mga_outl(M_IEN, mga_inl(M_IEN) & ~0x20); 265 mga_outl(M_IEN, mga_inl(M_IEN) & ~0x20);
263 free_irq(ACCESS_FBINFO(pcidev)->irq, MINFO); 266 free_irq(minfo->pcidev->irq, minfo);
264 } 267 }
265} 268}
266 269
267int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) { 270int matroxfb_wait_for_sync(struct matrox_fb_info *minfo, u_int32_t crtc)
271{
268 struct matrox_vsync *vs; 272 struct matrox_vsync *vs;
269 unsigned int cnt; 273 unsigned int cnt;
270 int ret; 274 int ret;
271 275
272 switch (crtc) { 276 switch (crtc) {
273 case 0: 277 case 0:
274 vs = &ACCESS_FBINFO(crtc1.vsync); 278 vs = &minfo->crtc1.vsync;
275 break; 279 break;
276 case 1: 280 case 1:
277 if (ACCESS_FBINFO(devflags.accelerator) != FB_ACCEL_MATROX_MGAG400) { 281 if (minfo->devflags.accelerator != FB_ACCEL_MATROX_MGAG400) {
278 return -ENODEV; 282 return -ENODEV;
279 } 283 }
280 vs = &ACCESS_FBINFO(crtc2.vsync); 284 vs = &minfo->crtc2.vsync;
281 break; 285 break;
282 default: 286 default:
283 return -ENODEV; 287 return -ENODEV;
284 } 288 }
285 ret = matroxfb_enable_irq(PMINFO 0); 289 ret = matroxfb_enable_irq(minfo, 0);
286 if (ret) { 290 if (ret) {
287 return ret; 291 return ret;
288 } 292 }
@@ -293,7 +297,7 @@ int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) {
293 return ret; 297 return ret;
294 } 298 }
295 if (ret == 0) { 299 if (ret == 0) {
296 matroxfb_enable_irq(PMINFO 1); 300 matroxfb_enable_irq(minfo, 1);
297 return -ETIMEDOUT; 301 return -ETIMEDOUT;
298 } 302 }
299 return 0; 303 return 0;
@@ -301,12 +305,12 @@ int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) {
301 305
302/* --------------------------------------------------------------------- */ 306/* --------------------------------------------------------------------- */
303 307
304static void matrox_pan_var(WPMINFO struct fb_var_screeninfo *var) { 308static void matrox_pan_var(struct matrox_fb_info *minfo,
309 struct fb_var_screeninfo *var)
310{
305 unsigned int pos; 311 unsigned int pos;
306 unsigned short p0, p1, p2; 312 unsigned short p0, p1, p2;
307#ifdef CONFIG_FB_MATROX_32MB
308 unsigned int p3; 313 unsigned int p3;
309#endif
310 int vbl; 314 int vbl;
311 unsigned long flags; 315 unsigned long flags;
312 316
@@ -314,47 +318,44 @@ static void matrox_pan_var(WPMINFO struct fb_var_screeninfo *var) {
314 318
315 DBG(__func__) 319 DBG(__func__)
316 320
317 if (ACCESS_FBINFO(dead)) 321 if (minfo->dead)
318 return; 322 return;
319 323
320 ACCESS_FBINFO(fbcon).var.xoffset = var->xoffset; 324 minfo->fbcon.var.xoffset = var->xoffset;
321 ACCESS_FBINFO(fbcon).var.yoffset = var->yoffset; 325 minfo->fbcon.var.yoffset = var->yoffset;
322 pos = (ACCESS_FBINFO(fbcon).var.yoffset * ACCESS_FBINFO(fbcon).var.xres_virtual + ACCESS_FBINFO(fbcon).var.xoffset) * ACCESS_FBINFO(curr.final_bppShift) / 32; 326 pos = (minfo->fbcon.var.yoffset * minfo->fbcon.var.xres_virtual + minfo->fbcon.var.xoffset) * minfo->curr.final_bppShift / 32;
323 pos += ACCESS_FBINFO(curr.ydstorg.chunks); 327 pos += minfo->curr.ydstorg.chunks;
324 p0 = ACCESS_FBINFO(hw).CRTC[0x0D] = pos & 0xFF; 328 p0 = minfo->hw.CRTC[0x0D] = pos & 0xFF;
325 p1 = ACCESS_FBINFO(hw).CRTC[0x0C] = (pos & 0xFF00) >> 8; 329 p1 = minfo->hw.CRTC[0x0C] = (pos & 0xFF00) >> 8;
326 p2 = ACCESS_FBINFO(hw).CRTCEXT[0] = (ACCESS_FBINFO(hw).CRTCEXT[0] & 0xB0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40); 330 p2 = minfo->hw.CRTCEXT[0] = (minfo->hw.CRTCEXT[0] & 0xB0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40);
327#ifdef CONFIG_FB_MATROX_32MB 331 p3 = minfo->hw.CRTCEXT[8] = pos >> 21;
328 p3 = ACCESS_FBINFO(hw).CRTCEXT[8] = pos >> 21;
329#endif
330 332
331 /* FB_ACTIVATE_VBL and we can acquire interrupts? Honor FB_ACTIVATE_VBL then... */ 333 /* FB_ACTIVATE_VBL and we can acquire interrupts? Honor FB_ACTIVATE_VBL then... */
332 vbl = (var->activate & FB_ACTIVATE_VBL) && (matroxfb_enable_irq(PMINFO 0) == 0); 334 vbl = (var->activate & FB_ACTIVATE_VBL) && (matroxfb_enable_irq(minfo, 0) == 0);
333 335
334 CRITBEGIN 336 CRITBEGIN
335 337
336 matroxfb_DAC_lock_irqsave(flags); 338 matroxfb_DAC_lock_irqsave(flags);
337 mga_setr(M_CRTC_INDEX, 0x0D, p0); 339 mga_setr(M_CRTC_INDEX, 0x0D, p0);
338 mga_setr(M_CRTC_INDEX, 0x0C, p1); 340 mga_setr(M_CRTC_INDEX, 0x0C, p1);
339#ifdef CONFIG_FB_MATROX_32MB 341 if (minfo->devflags.support32MB)
340 if (ACCESS_FBINFO(devflags.support32MB))
341 mga_setr(M_EXTVGA_INDEX, 0x08, p3); 342 mga_setr(M_EXTVGA_INDEX, 0x08, p3);
342#endif
343 if (vbl) { 343 if (vbl) {
344 ACCESS_FBINFO(crtc1.panpos) = p2; 344 minfo->crtc1.panpos = p2;
345 } else { 345 } else {
346 /* Abort any pending change */ 346 /* Abort any pending change */
347 ACCESS_FBINFO(crtc1.panpos) = -1; 347 minfo->crtc1.panpos = -1;
348 mga_setr(M_EXTVGA_INDEX, 0x00, p2); 348 mga_setr(M_EXTVGA_INDEX, 0x00, p2);
349 } 349 }
350 matroxfb_DAC_unlock_irqrestore(flags); 350 matroxfb_DAC_unlock_irqrestore(flags);
351 351
352 update_crtc2(PMINFO pos); 352 update_crtc2(minfo, pos);
353 353
354 CRITEND 354 CRITEND
355} 355}
356 356
357static void matroxfb_remove(WPMINFO int dummy) { 357static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
358{
358 /* Currently we are holding big kernel lock on all dead & usecount updates. 359 /* Currently we are holding big kernel lock on all dead & usecount updates.
359 * Destroy everything after all users release it. Especially do not unregister 360 * Destroy everything after all users release it. Especially do not unregister
360 * framebuffer and iounmap memory, neither fbmem nor fbcon-cfb* does not check 361 * framebuffer and iounmap memory, neither fbmem nor fbcon-cfb* does not check
@@ -363,25 +364,23 @@ static void matroxfb_remove(WPMINFO int dummy) {
363 * write data without causing too much damage... 364 * write data without causing too much damage...
364 */ 365 */
365 366
366 ACCESS_FBINFO(dead) = 1; 367 minfo->dead = 1;
367 if (ACCESS_FBINFO(usecount)) { 368 if (minfo->usecount) {
368 /* destroy it later */ 369 /* destroy it later */
369 return; 370 return;
370 } 371 }
371 matroxfb_unregister_device(MINFO); 372 matroxfb_unregister_device(minfo);
372 unregister_framebuffer(&ACCESS_FBINFO(fbcon)); 373 unregister_framebuffer(&minfo->fbcon);
373 matroxfb_g450_shutdown(PMINFO2); 374 matroxfb_g450_shutdown(minfo);
374#ifdef CONFIG_MTRR 375#ifdef CONFIG_MTRR
375 if (ACCESS_FBINFO(mtrr.vram_valid)) 376 if (minfo->mtrr.vram_valid)
376 mtrr_del(ACCESS_FBINFO(mtrr.vram), ACCESS_FBINFO(video.base), ACCESS_FBINFO(video.len)); 377 mtrr_del(minfo->mtrr.vram, minfo->video.base, minfo->video.len);
377#endif 378#endif
378 mga_iounmap(ACCESS_FBINFO(mmio.vbase)); 379 mga_iounmap(minfo->mmio.vbase);
379 mga_iounmap(ACCESS_FBINFO(video.vbase)); 380 mga_iounmap(minfo->video.vbase);
380 release_mem_region(ACCESS_FBINFO(video.base), ACCESS_FBINFO(video.len_maximum)); 381 release_mem_region(minfo->video.base, minfo->video.len_maximum);
381 release_mem_region(ACCESS_FBINFO(mmio.base), 16384); 382 release_mem_region(minfo->mmio.base, 16384);
382#ifdef CONFIG_FB_MATROX_MULTIHEAD
383 kfree(minfo); 383 kfree(minfo);
384#endif
385} 384}
386 385
387 /* 386 /*
@@ -390,48 +389,50 @@ static void matroxfb_remove(WPMINFO int dummy) {
390 389
391static int matroxfb_open(struct fb_info *info, int user) 390static int matroxfb_open(struct fb_info *info, int user)
392{ 391{
393 MINFO_FROM_INFO(info); 392 struct matrox_fb_info *minfo = info2minfo(info);
394 393
395 DBG_LOOP(__func__) 394 DBG_LOOP(__func__)
396 395
397 if (ACCESS_FBINFO(dead)) { 396 if (minfo->dead) {
398 return -ENXIO; 397 return -ENXIO;
399 } 398 }
400 ACCESS_FBINFO(usecount)++; 399 minfo->usecount++;
401 if (user) { 400 if (user) {
402 ACCESS_FBINFO(userusecount)++; 401 minfo->userusecount++;
403 } 402 }
404 return(0); 403 return(0);
405} 404}
406 405
407static int matroxfb_release(struct fb_info *info, int user) 406static int matroxfb_release(struct fb_info *info, int user)
408{ 407{
409 MINFO_FROM_INFO(info); 408 struct matrox_fb_info *minfo = info2minfo(info);
410 409
411 DBG_LOOP(__func__) 410 DBG_LOOP(__func__)
412 411
413 if (user) { 412 if (user) {
414 if (0 == --ACCESS_FBINFO(userusecount)) { 413 if (0 == --minfo->userusecount) {
415 matroxfb_disable_irq(PMINFO2); 414 matroxfb_disable_irq(minfo);
416 } 415 }
417 } 416 }
418 if (!(--ACCESS_FBINFO(usecount)) && ACCESS_FBINFO(dead)) { 417 if (!(--minfo->usecount) && minfo->dead) {
419 matroxfb_remove(PMINFO 0); 418 matroxfb_remove(minfo, 0);
420 } 419 }
421 return(0); 420 return(0);
422} 421}
423 422
424static int matroxfb_pan_display(struct fb_var_screeninfo *var, 423static int matroxfb_pan_display(struct fb_var_screeninfo *var,
425 struct fb_info* info) { 424 struct fb_info* info) {
426 MINFO_FROM_INFO(info); 425 struct matrox_fb_info *minfo = info2minfo(info);
427 426
428 DBG(__func__) 427 DBG(__func__)
429 428
430 matrox_pan_var(PMINFO var); 429 matrox_pan_var(minfo, var);
431 return 0; 430 return 0;
432} 431}
433 432
434static int matroxfb_get_final_bppShift(CPMINFO int bpp) { 433static int matroxfb_get_final_bppShift(const struct matrox_fb_info *minfo,
434 int bpp)
435{
435 int bppshft2; 436 int bppshft2;
436 437
437 DBG(__func__) 438 DBG(__func__)
@@ -440,14 +441,16 @@ static int matroxfb_get_final_bppShift(CPMINFO int bpp) {
440 if (!bppshft2) { 441 if (!bppshft2) {
441 return 8; 442 return 8;
442 } 443 }
443 if (isInterleave(MINFO)) 444 if (isInterleave(minfo))
444 bppshft2 >>= 1; 445 bppshft2 >>= 1;
445 if (ACCESS_FBINFO(devflags.video64bits)) 446 if (minfo->devflags.video64bits)
446 bppshft2 >>= 1; 447 bppshft2 >>= 1;
447 return bppshft2; 448 return bppshft2;
448} 449}
449 450
450static int matroxfb_test_and_set_rounding(CPMINFO int xres, int bpp) { 451static int matroxfb_test_and_set_rounding(const struct matrox_fb_info *minfo,
452 int xres, int bpp)
453{
451 int over; 454 int over;
452 int rounding; 455 int rounding;
453 456
@@ -465,11 +468,11 @@ static int matroxfb_test_and_set_rounding(CPMINFO int xres, int bpp) {
465 break; 468 break;
466 default: rounding = 16; 469 default: rounding = 16;
467 /* on G400, 16 really does not work */ 470 /* on G400, 16 really does not work */
468 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG400) 471 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400)
469 rounding = 32; 472 rounding = 32;
470 break; 473 break;
471 } 474 }
472 if (isInterleave(MINFO)) { 475 if (isInterleave(minfo)) {
473 rounding *= 2; 476 rounding *= 2;
474 } 477 }
475 over = xres % rounding; 478 over = xres % rounding;
@@ -478,7 +481,9 @@ static int matroxfb_test_and_set_rounding(CPMINFO int xres, int bpp) {
478 return xres; 481 return xres;
479} 482}
480 483
481static int matroxfb_pitch_adjust(CPMINFO int xres, int bpp) { 484static int matroxfb_pitch_adjust(const struct matrox_fb_info *minfo, int xres,
485 int bpp)
486{
482 const int* width; 487 const int* width;
483 int xres_new; 488 int xres_new;
484 489
@@ -486,18 +491,18 @@ static int matroxfb_pitch_adjust(CPMINFO int xres, int bpp) {
486 491
487 if (!bpp) return xres; 492 if (!bpp) return xres;
488 493
489 width = ACCESS_FBINFO(capable.vxres); 494 width = minfo->capable.vxres;
490 495
491 if (ACCESS_FBINFO(devflags.precise_width)) { 496 if (minfo->devflags.precise_width) {
492 while (*width) { 497 while (*width) {
493 if ((*width >= xres) && (matroxfb_test_and_set_rounding(PMINFO *width, bpp) == *width)) { 498 if ((*width >= xres) && (matroxfb_test_and_set_rounding(minfo, *width, bpp) == *width)) {
494 break; 499 break;
495 } 500 }
496 width++; 501 width++;
497 } 502 }
498 xres_new = *width; 503 xres_new = *width;
499 } else { 504 } else {
500 xres_new = matroxfb_test_and_set_rounding(PMINFO xres, bpp); 505 xres_new = matroxfb_test_and_set_rounding(minfo, xres, bpp);
501 } 506 }
502 return xres_new; 507 return xres_new;
503} 508}
@@ -524,7 +529,10 @@ static int matroxfb_get_cmap_len(struct fb_var_screeninfo *var) {
524 return 16; /* return something reasonable... or panic()? */ 529 return 16; /* return something reasonable... or panic()? */
525} 530}
526 531
527static int matroxfb_decode_var(CPMINFO struct fb_var_screeninfo *var, int *visual, int *video_cmap_len, unsigned int* ydstorg) { 532static int matroxfb_decode_var(const struct matrox_fb_info *minfo,
533 struct fb_var_screeninfo *var, int *visual,
534 int *video_cmap_len, unsigned int* ydstorg)
535{
528 struct RGBT { 536 struct RGBT {
529 unsigned char bpp; 537 unsigned char bpp;
530 struct { 538 struct {
@@ -551,7 +559,7 @@ static int matroxfb_decode_var(CPMINFO struct fb_var_screeninfo *var, int *visua
551 DBG(__func__) 559 DBG(__func__)
552 560
553 switch (bpp) { 561 switch (bpp) {
554 case 4: if (!ACCESS_FBINFO(capable.cfb4)) return -EINVAL; 562 case 4: if (!minfo->capable.cfb4) return -EINVAL;
555 break; 563 break;
556 case 8: break; 564 case 8: break;
557 case 16: break; 565 case 16: break;
@@ -560,13 +568,13 @@ static int matroxfb_decode_var(CPMINFO struct fb_var_screeninfo *var, int *visua
560 default: return -EINVAL; 568 default: return -EINVAL;
561 } 569 }
562 *ydstorg = 0; 570 *ydstorg = 0;
563 vramlen = ACCESS_FBINFO(video.len_usable); 571 vramlen = minfo->video.len_usable;
564 if (var->yres_virtual < var->yres) 572 if (var->yres_virtual < var->yres)
565 var->yres_virtual = var->yres; 573 var->yres_virtual = var->yres;
566 if (var->xres_virtual < var->xres) 574 if (var->xres_virtual < var->xres)
567 var->xres_virtual = var->xres; 575 var->xres_virtual = var->xres;
568 576
569 var->xres_virtual = matroxfb_pitch_adjust(PMINFO var->xres_virtual, bpp); 577 var->xres_virtual = matroxfb_pitch_adjust(minfo, var->xres_virtual, bpp);
570 memlen = var->xres_virtual * bpp * var->yres_virtual / 8; 578 memlen = var->xres_virtual * bpp * var->yres_virtual / 8;
571 if (memlen > vramlen) { 579 if (memlen > vramlen) {
572 var->yres_virtual = vramlen * 8 / (var->xres_virtual * bpp); 580 var->yres_virtual = vramlen * 8 / (var->xres_virtual * bpp);
@@ -575,7 +583,7 @@ static int matroxfb_decode_var(CPMINFO struct fb_var_screeninfo *var, int *visua
575 /* There is hardware bug that no line can cross 4MB boundary */ 583 /* There is hardware bug that no line can cross 4MB boundary */
576 /* give up for CFB24, it is impossible to easy workaround it */ 584 /* give up for CFB24, it is impossible to easy workaround it */
577 /* for other try to do something */ 585 /* for other try to do something */
578 if (!ACCESS_FBINFO(capable.cross4MB) && (memlen > 0x400000)) { 586 if (!minfo->capable.cross4MB && (memlen > 0x400000)) {
579 if (bpp == 24) { 587 if (bpp == 24) {
580 /* sorry */ 588 /* sorry */
581 } else { 589 } else {
@@ -644,9 +652,7 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
644 unsigned blue, unsigned transp, 652 unsigned blue, unsigned transp,
645 struct fb_info *fb_info) 653 struct fb_info *fb_info)
646{ 654{
647#ifdef CONFIG_FB_MATROX_MULTIHEAD
648 struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon); 655 struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon);
649#endif
650 656
651 DBG(__func__) 657 DBG(__func__)
652 658
@@ -657,20 +663,20 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
657 * != 0 for invalid regno. 663 * != 0 for invalid regno.
658 */ 664 */
659 665
660 if (regno >= ACCESS_FBINFO(curr.cmap_len)) 666 if (regno >= minfo->curr.cmap_len)
661 return 1; 667 return 1;
662 668
663 if (ACCESS_FBINFO(fbcon).var.grayscale) { 669 if (minfo->fbcon.var.grayscale) {
664 /* gray = 0.30*R + 0.59*G + 0.11*B */ 670 /* gray = 0.30*R + 0.59*G + 0.11*B */
665 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; 671 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
666 } 672 }
667 673
668 red = CNVT_TOHW(red, ACCESS_FBINFO(fbcon).var.red.length); 674 red = CNVT_TOHW(red, minfo->fbcon.var.red.length);
669 green = CNVT_TOHW(green, ACCESS_FBINFO(fbcon).var.green.length); 675 green = CNVT_TOHW(green, minfo->fbcon.var.green.length);
670 blue = CNVT_TOHW(blue, ACCESS_FBINFO(fbcon).var.blue.length); 676 blue = CNVT_TOHW(blue, minfo->fbcon.var.blue.length);
671 transp = CNVT_TOHW(transp, ACCESS_FBINFO(fbcon).var.transp.length); 677 transp = CNVT_TOHW(transp, minfo->fbcon.var.transp.length);
672 678
673 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) { 679 switch (minfo->fbcon.var.bits_per_pixel) {
674 case 4: 680 case 4:
675 case 8: 681 case 8:
676 mga_outb(M_DAC_REG, regno); 682 mga_outb(M_DAC_REG, regno);
@@ -683,30 +689,30 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
683 break; 689 break;
684 { 690 {
685 u_int16_t col = 691 u_int16_t col =
686 (red << ACCESS_FBINFO(fbcon).var.red.offset) | 692 (red << minfo->fbcon.var.red.offset) |
687 (green << ACCESS_FBINFO(fbcon).var.green.offset) | 693 (green << minfo->fbcon.var.green.offset) |
688 (blue << ACCESS_FBINFO(fbcon).var.blue.offset) | 694 (blue << minfo->fbcon.var.blue.offset) |
689 (transp << ACCESS_FBINFO(fbcon).var.transp.offset); /* for 1:5:5:5 */ 695 (transp << minfo->fbcon.var.transp.offset); /* for 1:5:5:5 */
690 ACCESS_FBINFO(cmap[regno]) = col | (col << 16); 696 minfo->cmap[regno] = col | (col << 16);
691 } 697 }
692 break; 698 break;
693 case 24: 699 case 24:
694 case 32: 700 case 32:
695 if (regno >= 16) 701 if (regno >= 16)
696 break; 702 break;
697 ACCESS_FBINFO(cmap[regno]) = 703 minfo->cmap[regno] =
698 (red << ACCESS_FBINFO(fbcon).var.red.offset) | 704 (red << minfo->fbcon.var.red.offset) |
699 (green << ACCESS_FBINFO(fbcon).var.green.offset) | 705 (green << minfo->fbcon.var.green.offset) |
700 (blue << ACCESS_FBINFO(fbcon).var.blue.offset) | 706 (blue << minfo->fbcon.var.blue.offset) |
701 (transp << ACCESS_FBINFO(fbcon).var.transp.offset); /* 8:8:8:8 */ 707 (transp << minfo->fbcon.var.transp.offset); /* 8:8:8:8 */
702 break; 708 break;
703 } 709 }
704 return 0; 710 return 0;
705} 711}
706 712
707static void matroxfb_init_fix(WPMINFO2) 713static void matroxfb_init_fix(struct matrox_fb_info *minfo)
708{ 714{
709 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix; 715 struct fb_fix_screeninfo *fix = &minfo->fbcon.fix;
710 DBG(__func__) 716 DBG(__func__)
711 717
712 strcpy(fix->id,"MATROX"); 718 strcpy(fix->id,"MATROX");
@@ -714,20 +720,20 @@ static void matroxfb_init_fix(WPMINFO2)
714 fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */ 720 fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */
715 fix->ypanstep = 1; 721 fix->ypanstep = 1;
716 fix->ywrapstep = 0; 722 fix->ywrapstep = 0;
717 fix->mmio_start = ACCESS_FBINFO(mmio.base); 723 fix->mmio_start = minfo->mmio.base;
718 fix->mmio_len = ACCESS_FBINFO(mmio.len); 724 fix->mmio_len = minfo->mmio.len;
719 fix->accel = ACCESS_FBINFO(devflags.accelerator); 725 fix->accel = minfo->devflags.accelerator;
720} 726}
721 727
722static void matroxfb_update_fix(WPMINFO2) 728static void matroxfb_update_fix(struct matrox_fb_info *minfo)
723{ 729{
724 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix; 730 struct fb_fix_screeninfo *fix = &minfo->fbcon.fix;
725 DBG(__func__) 731 DBG(__func__)
726 732
727 mutex_lock(&ACCESS_FBINFO(fbcon).mm_lock); 733 mutex_lock(&minfo->fbcon.mm_lock);
728 fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes); 734 fix->smem_start = minfo->video.base + minfo->curr.ydstorg.bytes;
729 fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes); 735 fix->smem_len = minfo->video.len_usable - minfo->curr.ydstorg.bytes;
730 mutex_unlock(&ACCESS_FBINFO(fbcon).mm_lock); 736 mutex_unlock(&minfo->fbcon.mm_lock);
731} 737}
732 738
733static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 739static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -736,12 +742,12 @@ static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *inf
736 int visual; 742 int visual;
737 int cmap_len; 743 int cmap_len;
738 unsigned int ydstorg; 744 unsigned int ydstorg;
739 MINFO_FROM_INFO(info); 745 struct matrox_fb_info *minfo = info2minfo(info);
740 746
741 if (ACCESS_FBINFO(dead)) { 747 if (minfo->dead) {
742 return -ENXIO; 748 return -ENXIO;
743 } 749 }
744 if ((err = matroxfb_decode_var(PMINFO var, &visual, &cmap_len, &ydstorg)) != 0) 750 if ((err = matroxfb_decode_var(minfo, var, &visual, &cmap_len, &ydstorg)) != 0)
745 return err; 751 return err;
746 return 0; 752 return 0;
747} 753}
@@ -753,35 +759,35 @@ static int matroxfb_set_par(struct fb_info *info)
753 int cmap_len; 759 int cmap_len;
754 unsigned int ydstorg; 760 unsigned int ydstorg;
755 struct fb_var_screeninfo *var; 761 struct fb_var_screeninfo *var;
756 MINFO_FROM_INFO(info); 762 struct matrox_fb_info *minfo = info2minfo(info);
757 763
758 DBG(__func__) 764 DBG(__func__)
759 765
760 if (ACCESS_FBINFO(dead)) { 766 if (minfo->dead) {
761 return -ENXIO; 767 return -ENXIO;
762 } 768 }
763 769
764 var = &info->var; 770 var = &info->var;
765 if ((err = matroxfb_decode_var(PMINFO var, &visual, &cmap_len, &ydstorg)) != 0) 771 if ((err = matroxfb_decode_var(minfo, var, &visual, &cmap_len, &ydstorg)) != 0)
766 return err; 772 return err;
767 ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase)) + ydstorg; 773 minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase) + ydstorg;
768 matroxfb_update_fix(PMINFO2); 774 matroxfb_update_fix(minfo);
769 ACCESS_FBINFO(fbcon).fix.visual = visual; 775 minfo->fbcon.fix.visual = visual;
770 ACCESS_FBINFO(fbcon).fix.type = FB_TYPE_PACKED_PIXELS; 776 minfo->fbcon.fix.type = FB_TYPE_PACKED_PIXELS;
771 ACCESS_FBINFO(fbcon).fix.type_aux = 0; 777 minfo->fbcon.fix.type_aux = 0;
772 ACCESS_FBINFO(fbcon).fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3; 778 minfo->fbcon.fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3;
773 { 779 {
774 unsigned int pos; 780 unsigned int pos;
775 781
776 ACCESS_FBINFO(curr.cmap_len) = cmap_len; 782 minfo->curr.cmap_len = cmap_len;
777 ydstorg += ACCESS_FBINFO(devflags.ydstorg); 783 ydstorg += minfo->devflags.ydstorg;
778 ACCESS_FBINFO(curr.ydstorg.bytes) = ydstorg; 784 minfo->curr.ydstorg.bytes = ydstorg;
779 ACCESS_FBINFO(curr.ydstorg.chunks) = ydstorg >> (isInterleave(MINFO)?3:2); 785 minfo->curr.ydstorg.chunks = ydstorg >> (isInterleave(minfo) ? 3 : 2);
780 if (var->bits_per_pixel == 4) 786 if (var->bits_per_pixel == 4)
781 ACCESS_FBINFO(curr.ydstorg.pixels) = ydstorg; 787 minfo->curr.ydstorg.pixels = ydstorg;
782 else 788 else
783 ACCESS_FBINFO(curr.ydstorg.pixels) = (ydstorg * 8) / var->bits_per_pixel; 789 minfo->curr.ydstorg.pixels = (ydstorg * 8) / var->bits_per_pixel;
784 ACCESS_FBINFO(curr.final_bppShift) = matroxfb_get_final_bppShift(PMINFO var->bits_per_pixel); 790 minfo->curr.final_bppShift = matroxfb_get_final_bppShift(minfo, var->bits_per_pixel);
785 { struct my_timming mt; 791 { struct my_timming mt;
786 struct matrox_hw_state* hw; 792 struct matrox_hw_state* hw;
787 int out; 793 int out;
@@ -797,54 +803,55 @@ static int matroxfb_set_par(struct fb_info *info)
797 default: mt.delay = 31 + 8; break; 803 default: mt.delay = 31 + 8; break;
798 } 804 }
799 805
800 hw = &ACCESS_FBINFO(hw); 806 hw = &minfo->hw;
801 807
802 down_read(&ACCESS_FBINFO(altout).lock); 808 down_read(&minfo->altout.lock);
803 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { 809 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) {
804 if (ACCESS_FBINFO(outputs[out]).src == MATROXFB_SRC_CRTC1 && 810 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 &&
805 ACCESS_FBINFO(outputs[out]).output->compute) { 811 minfo->outputs[out].output->compute) {
806 ACCESS_FBINFO(outputs[out]).output->compute(ACCESS_FBINFO(outputs[out]).data, &mt); 812 minfo->outputs[out].output->compute(minfo->outputs[out].data, &mt);
807 } 813 }
808 } 814 }
809 up_read(&ACCESS_FBINFO(altout).lock); 815 up_read(&minfo->altout.lock);
810 ACCESS_FBINFO(crtc1).pixclock = mt.pixclock; 816 minfo->crtc1.pixclock = mt.pixclock;
811 ACCESS_FBINFO(crtc1).mnp = mt.mnp; 817 minfo->crtc1.mnp = mt.mnp;
812 ACCESS_FBINFO(hw_switch->init(PMINFO &mt)); 818 minfo->hw_switch->init(minfo, &mt);
813 pos = (var->yoffset * var->xres_virtual + var->xoffset) * ACCESS_FBINFO(curr.final_bppShift) / 32; 819 pos = (var->yoffset * var->xres_virtual + var->xoffset) * minfo->curr.final_bppShift / 32;
814 pos += ACCESS_FBINFO(curr.ydstorg.chunks); 820 pos += minfo->curr.ydstorg.chunks;
815 821
816 hw->CRTC[0x0D] = pos & 0xFF; 822 hw->CRTC[0x0D] = pos & 0xFF;
817 hw->CRTC[0x0C] = (pos & 0xFF00) >> 8; 823 hw->CRTC[0x0C] = (pos & 0xFF00) >> 8;
818 hw->CRTCEXT[0] = (hw->CRTCEXT[0] & 0xF0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40); 824 hw->CRTCEXT[0] = (hw->CRTCEXT[0] & 0xF0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40);
819 hw->CRTCEXT[8] = pos >> 21; 825 hw->CRTCEXT[8] = pos >> 21;
820 ACCESS_FBINFO(hw_switch->restore(PMINFO2)); 826 minfo->hw_switch->restore(minfo);
821 update_crtc2(PMINFO pos); 827 update_crtc2(minfo, pos);
822 down_read(&ACCESS_FBINFO(altout).lock); 828 down_read(&minfo->altout.lock);
823 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { 829 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) {
824 if (ACCESS_FBINFO(outputs[out]).src == MATROXFB_SRC_CRTC1 && 830 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 &&
825 ACCESS_FBINFO(outputs[out]).output->program) { 831 minfo->outputs[out].output->program) {
826 ACCESS_FBINFO(outputs[out]).output->program(ACCESS_FBINFO(outputs[out]).data); 832 minfo->outputs[out].output->program(minfo->outputs[out].data);
827 } 833 }
828 } 834 }
829 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) { 835 for (out = 0; out < MATROXFB_MAX_OUTPUTS; out++) {
830 if (ACCESS_FBINFO(outputs[out]).src == MATROXFB_SRC_CRTC1 && 836 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 &&
831 ACCESS_FBINFO(outputs[out]).output->start) { 837 minfo->outputs[out].output->start) {
832 ACCESS_FBINFO(outputs[out]).output->start(ACCESS_FBINFO(outputs[out]).data); 838 minfo->outputs[out].output->start(minfo->outputs[out].data);
833 } 839 }
834 } 840 }
835 up_read(&ACCESS_FBINFO(altout).lock); 841 up_read(&minfo->altout.lock);
836 matrox_cfbX_init(PMINFO2); 842 matrox_cfbX_init(minfo);
837 } 843 }
838 } 844 }
839 ACCESS_FBINFO(initialized) = 1; 845 minfo->initialized = 1;
840 return 0; 846 return 0;
841} 847}
842 848
843static int matroxfb_get_vblank(WPMINFO struct fb_vblank *vblank) 849static int matroxfb_get_vblank(struct matrox_fb_info *minfo,
850 struct fb_vblank *vblank)
844{ 851{
845 unsigned int sts1; 852 unsigned int sts1;
846 853
847 matroxfb_enable_irq(PMINFO 0); 854 matroxfb_enable_irq(minfo, 0);
848 memset(vblank, 0, sizeof(*vblank)); 855 memset(vblank, 0, sizeof(*vblank));
849 vblank->flags = FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VSYNC | 856 vblank->flags = FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VSYNC |
850 FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_HBLANK; 857 FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_HBLANK;
@@ -857,13 +864,13 @@ static int matroxfb_get_vblank(WPMINFO struct fb_vblank *vblank)
857 vblank->flags |= FB_VBLANK_HBLANKING; 864 vblank->flags |= FB_VBLANK_HBLANKING;
858 if (sts1 & 8) 865 if (sts1 & 8)
859 vblank->flags |= FB_VBLANK_VSYNCING; 866 vblank->flags |= FB_VBLANK_VSYNCING;
860 if (vblank->vcount >= ACCESS_FBINFO(fbcon).var.yres) 867 if (vblank->vcount >= minfo->fbcon.var.yres)
861 vblank->flags |= FB_VBLANK_VBLANKING; 868 vblank->flags |= FB_VBLANK_VBLANKING;
862 if (test_bit(0, &ACCESS_FBINFO(irq_flags))) { 869 if (test_bit(0, &minfo->irq_flags)) {
863 vblank->flags |= FB_VBLANK_HAVE_COUNT; 870 vblank->flags |= FB_VBLANK_HAVE_COUNT;
864 /* Only one writer, aligned int value... 871 /* Only one writer, aligned int value...
865 it should work without lock and without atomic_t */ 872 it should work without lock and without atomic_t */
866 vblank->count = ACCESS_FBINFO(crtc1).vsync.cnt; 873 vblank->count = minfo->crtc1.vsync.cnt;
867 } 874 }
868 return 0; 875 return 0;
869} 876}
@@ -876,11 +883,11 @@ static int matroxfb_ioctl(struct fb_info *info,
876 unsigned int cmd, unsigned long arg) 883 unsigned int cmd, unsigned long arg)
877{ 884{
878 void __user *argp = (void __user *)arg; 885 void __user *argp = (void __user *)arg;
879 MINFO_FROM_INFO(info); 886 struct matrox_fb_info *minfo = info2minfo(info);
880 887
881 DBG(__func__) 888 DBG(__func__)
882 889
883 if (ACCESS_FBINFO(dead)) { 890 if (minfo->dead) {
884 return -ENXIO; 891 return -ENXIO;
885 } 892 }
886 893
@@ -890,7 +897,7 @@ static int matroxfb_ioctl(struct fb_info *info,
890 struct fb_vblank vblank; 897 struct fb_vblank vblank;
891 int err; 898 int err;
892 899
893 err = matroxfb_get_vblank(PMINFO &vblank); 900 err = matroxfb_get_vblank(minfo, &vblank);
894 if (err) 901 if (err)
895 return err; 902 return err;
896 if (copy_to_user(argp, &vblank, sizeof(vblank))) 903 if (copy_to_user(argp, &vblank, sizeof(vblank)))
@@ -904,7 +911,7 @@ static int matroxfb_ioctl(struct fb_info *info,
904 if (get_user(crt, (u_int32_t __user *)arg)) 911 if (get_user(crt, (u_int32_t __user *)arg))
905 return -EFAULT; 912 return -EFAULT;
906 913
907 return matroxfb_wait_for_sync(PMINFO crt); 914 return matroxfb_wait_for_sync(minfo, crt);
908 } 915 }
909 case MATROXFB_SET_OUTPUT_MODE: 916 case MATROXFB_SET_OUTPUT_MODE:
910 { 917 {
@@ -916,8 +923,8 @@ static int matroxfb_ioctl(struct fb_info *info,
916 return -EFAULT; 923 return -EFAULT;
917 if (mom.output >= MATROXFB_MAX_OUTPUTS) 924 if (mom.output >= MATROXFB_MAX_OUTPUTS)
918 return -ENXIO; 925 return -ENXIO;
919 down_read(&ACCESS_FBINFO(altout.lock)); 926 down_read(&minfo->altout.lock);
920 oproc = ACCESS_FBINFO(outputs[mom.output]).output; 927 oproc = minfo->outputs[mom.output].output;
921 if (!oproc) { 928 if (!oproc) {
922 val = -ENXIO; 929 val = -ENXIO;
923 } else if (!oproc->verifymode) { 930 } else if (!oproc->verifymode) {
@@ -927,18 +934,18 @@ static int matroxfb_ioctl(struct fb_info *info,
927 val = -EINVAL; 934 val = -EINVAL;
928 } 935 }
929 } else { 936 } else {
930 val = oproc->verifymode(ACCESS_FBINFO(outputs[mom.output]).data, mom.mode); 937 val = oproc->verifymode(minfo->outputs[mom.output].data, mom.mode);
931 } 938 }
932 if (!val) { 939 if (!val) {
933 if (ACCESS_FBINFO(outputs[mom.output]).mode != mom.mode) { 940 if (minfo->outputs[mom.output].mode != mom.mode) {
934 ACCESS_FBINFO(outputs[mom.output]).mode = mom.mode; 941 minfo->outputs[mom.output].mode = mom.mode;
935 val = 1; 942 val = 1;
936 } 943 }
937 } 944 }
938 up_read(&ACCESS_FBINFO(altout.lock)); 945 up_read(&minfo->altout.lock);
939 if (val != 1) 946 if (val != 1)
940 return val; 947 return val;
941 switch (ACCESS_FBINFO(outputs[mom.output]).src) { 948 switch (minfo->outputs[mom.output].src) {
942 case MATROXFB_SRC_CRTC1: 949 case MATROXFB_SRC_CRTC1:
943 matroxfb_set_par(info); 950 matroxfb_set_par(info);
944 break; 951 break;
@@ -946,11 +953,11 @@ static int matroxfb_ioctl(struct fb_info *info,
946 { 953 {
947 struct matroxfb_dh_fb_info* crtc2; 954 struct matroxfb_dh_fb_info* crtc2;
948 955
949 down_read(&ACCESS_FBINFO(crtc2.lock)); 956 down_read(&minfo->crtc2.lock);
950 crtc2 = ACCESS_FBINFO(crtc2.info); 957 crtc2 = minfo->crtc2.info;
951 if (crtc2) 958 if (crtc2)
952 crtc2->fbcon.fbops->fb_set_par(&crtc2->fbcon); 959 crtc2->fbcon.fbops->fb_set_par(&crtc2->fbcon);
953 up_read(&ACCESS_FBINFO(crtc2.lock)); 960 up_read(&minfo->crtc2.lock);
954 } 961 }
955 break; 962 break;
956 } 963 }
@@ -966,15 +973,15 @@ static int matroxfb_ioctl(struct fb_info *info,
966 return -EFAULT; 973 return -EFAULT;
967 if (mom.output >= MATROXFB_MAX_OUTPUTS) 974 if (mom.output >= MATROXFB_MAX_OUTPUTS)
968 return -ENXIO; 975 return -ENXIO;
969 down_read(&ACCESS_FBINFO(altout.lock)); 976 down_read(&minfo->altout.lock);
970 oproc = ACCESS_FBINFO(outputs[mom.output]).output; 977 oproc = minfo->outputs[mom.output].output;
971 if (!oproc) { 978 if (!oproc) {
972 val = -ENXIO; 979 val = -ENXIO;
973 } else { 980 } else {
974 mom.mode = ACCESS_FBINFO(outputs[mom.output]).mode; 981 mom.mode = minfo->outputs[mom.output].mode;
975 val = 0; 982 val = 0;
976 } 983 }
977 up_read(&ACCESS_FBINFO(altout.lock)); 984 up_read(&minfo->altout.lock);
978 if (val) 985 if (val)
979 return val; 986 return val;
980 if (copy_to_user(argp, &mom, sizeof(mom))) 987 if (copy_to_user(argp, &mom, sizeof(mom)))
@@ -993,9 +1000,9 @@ static int matroxfb_ioctl(struct fb_info *info,
993 if (tmp & (1 << i)) { 1000 if (tmp & (1 << i)) {
994 if (i >= MATROXFB_MAX_OUTPUTS) 1001 if (i >= MATROXFB_MAX_OUTPUTS)
995 return -ENXIO; 1002 return -ENXIO;
996 if (!ACCESS_FBINFO(outputs[i]).output) 1003 if (!minfo->outputs[i].output)
997 return -ENXIO; 1004 return -ENXIO;
998 switch (ACCESS_FBINFO(outputs[i]).src) { 1005 switch (minfo->outputs[i].src) {
999 case MATROXFB_SRC_NONE: 1006 case MATROXFB_SRC_NONE:
1000 case MATROXFB_SRC_CRTC1: 1007 case MATROXFB_SRC_CRTC1:
1001 break; 1008 break;
@@ -1004,12 +1011,12 @@ static int matroxfb_ioctl(struct fb_info *info,
1004 } 1011 }
1005 } 1012 }
1006 } 1013 }
1007 if (ACCESS_FBINFO(devflags.panellink)) { 1014 if (minfo->devflags.panellink) {
1008 if (tmp & MATROXFB_OUTPUT_CONN_DFP) { 1015 if (tmp & MATROXFB_OUTPUT_CONN_DFP) {
1009 if (tmp & MATROXFB_OUTPUT_CONN_SECONDARY) 1016 if (tmp & MATROXFB_OUTPUT_CONN_SECONDARY)
1010 return -EINVAL; 1017 return -EINVAL;
1011 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1018 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
1012 if (ACCESS_FBINFO(outputs[i]).src == MATROXFB_SRC_CRTC2) { 1019 if (minfo->outputs[i].src == MATROXFB_SRC_CRTC2) {
1013 return -EBUSY; 1020 return -EBUSY;
1014 } 1021 }
1015 } 1022 }
@@ -1018,13 +1025,13 @@ static int matroxfb_ioctl(struct fb_info *info,
1018 changes = 0; 1025 changes = 0;
1019 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1026 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
1020 if (tmp & (1 << i)) { 1027 if (tmp & (1 << i)) {
1021 if (ACCESS_FBINFO(outputs[i]).src != MATROXFB_SRC_CRTC1) { 1028 if (minfo->outputs[i].src != MATROXFB_SRC_CRTC1) {
1022 changes = 1; 1029 changes = 1;
1023 ACCESS_FBINFO(outputs[i]).src = MATROXFB_SRC_CRTC1; 1030 minfo->outputs[i].src = MATROXFB_SRC_CRTC1;
1024 } 1031 }
1025 } else if (ACCESS_FBINFO(outputs[i]).src == MATROXFB_SRC_CRTC1) { 1032 } else if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) {
1026 changes = 1; 1033 changes = 1;
1027 ACCESS_FBINFO(outputs[i]).src = MATROXFB_SRC_NONE; 1034 minfo->outputs[i].src = MATROXFB_SRC_NONE;
1028 } 1035 }
1029 } 1036 }
1030 if (!changes) 1037 if (!changes)
@@ -1038,7 +1045,7 @@ static int matroxfb_ioctl(struct fb_info *info,
1038 int i; 1045 int i;
1039 1046
1040 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1047 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
1041 if (ACCESS_FBINFO(outputs[i]).src == MATROXFB_SRC_CRTC1) { 1048 if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) {
1042 conn |= 1 << i; 1049 conn |= 1 << i;
1043 } 1050 }
1044 } 1051 }
@@ -1052,8 +1059,8 @@ static int matroxfb_ioctl(struct fb_info *info,
1052 int i; 1059 int i;
1053 1060
1054 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1061 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
1055 if (ACCESS_FBINFO(outputs[i]).output) { 1062 if (minfo->outputs[i].output) {
1056 switch (ACCESS_FBINFO(outputs[i]).src) { 1063 switch (minfo->outputs[i].src) {
1057 case MATROXFB_SRC_NONE: 1064 case MATROXFB_SRC_NONE:
1058 case MATROXFB_SRC_CRTC1: 1065 case MATROXFB_SRC_CRTC1:
1059 conn |= 1 << i; 1066 conn |= 1 << i;
@@ -1061,7 +1068,7 @@ static int matroxfb_ioctl(struct fb_info *info,
1061 } 1068 }
1062 } 1069 }
1063 } 1070 }
1064 if (ACCESS_FBINFO(devflags.panellink)) { 1071 if (minfo->devflags.panellink) {
1065 if (conn & MATROXFB_OUTPUT_CONN_DFP) 1072 if (conn & MATROXFB_OUTPUT_CONN_DFP)
1066 conn &= ~MATROXFB_OUTPUT_CONN_SECONDARY; 1073 conn &= ~MATROXFB_OUTPUT_CONN_SECONDARY;
1067 if (conn & MATROXFB_OUTPUT_CONN_SECONDARY) 1074 if (conn & MATROXFB_OUTPUT_CONN_SECONDARY)
@@ -1077,7 +1084,7 @@ static int matroxfb_ioctl(struct fb_info *info,
1077 int i; 1084 int i;
1078 1085
1079 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1086 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
1080 if (ACCESS_FBINFO(outputs[i]).output) { 1087 if (minfo->outputs[i].output) {
1081 conn |= 1 << i; 1088 conn |= 1 << i;
1082 } 1089 }
1083 } 1090 }
@@ -1092,7 +1099,7 @@ static int matroxfb_ioctl(struct fb_info *info,
1092 memset(&r, 0, sizeof(r)); 1099 memset(&r, 0, sizeof(r));
1093 strcpy(r.driver, "matroxfb"); 1100 strcpy(r.driver, "matroxfb");
1094 strcpy(r.card, "Matrox"); 1101 strcpy(r.card, "Matrox");
1095 sprintf(r.bus_info, "PCI:%s", pci_name(ACCESS_FBINFO(pcidev))); 1102 sprintf(r.bus_info, "PCI:%s", pci_name(minfo->pcidev));
1096 r.version = KERNEL_VERSION(1,0,0); 1103 r.version = KERNEL_VERSION(1,0,0);
1097 r.capabilities = V4L2_CAP_VIDEO_OUTPUT; 1104 r.capabilities = V4L2_CAP_VIDEO_OUTPUT;
1098 if (copy_to_user(argp, &r, sizeof(r))) 1105 if (copy_to_user(argp, &r, sizeof(r)))
@@ -1108,15 +1115,15 @@ static int matroxfb_ioctl(struct fb_info *info,
1108 if (copy_from_user(&qctrl, argp, sizeof(qctrl))) 1115 if (copy_from_user(&qctrl, argp, sizeof(qctrl)))
1109 return -EFAULT; 1116 return -EFAULT;
1110 1117
1111 down_read(&ACCESS_FBINFO(altout).lock); 1118 down_read(&minfo->altout.lock);
1112 if (!ACCESS_FBINFO(outputs[1]).output) { 1119 if (!minfo->outputs[1].output) {
1113 err = -ENXIO; 1120 err = -ENXIO;
1114 } else if (ACCESS_FBINFO(outputs[1]).output->getqueryctrl) { 1121 } else if (minfo->outputs[1].output->getqueryctrl) {
1115 err = ACCESS_FBINFO(outputs[1]).output->getqueryctrl(ACCESS_FBINFO(outputs[1]).data, &qctrl); 1122 err = minfo->outputs[1].output->getqueryctrl(minfo->outputs[1].data, &qctrl);
1116 } else { 1123 } else {
1117 err = -EINVAL; 1124 err = -EINVAL;
1118 } 1125 }
1119 up_read(&ACCESS_FBINFO(altout).lock); 1126 up_read(&minfo->altout.lock);
1120 if (err >= 0 && 1127 if (err >= 0 &&
1121 copy_to_user(argp, &qctrl, sizeof(qctrl))) 1128 copy_to_user(argp, &qctrl, sizeof(qctrl)))
1122 return -EFAULT; 1129 return -EFAULT;
@@ -1130,15 +1137,15 @@ static int matroxfb_ioctl(struct fb_info *info,
1130 if (copy_from_user(&ctrl, argp, sizeof(ctrl))) 1137 if (copy_from_user(&ctrl, argp, sizeof(ctrl)))
1131 return -EFAULT; 1138 return -EFAULT;
1132 1139
1133 down_read(&ACCESS_FBINFO(altout).lock); 1140 down_read(&minfo->altout.lock);
1134 if (!ACCESS_FBINFO(outputs[1]).output) { 1141 if (!minfo->outputs[1].output) {
1135 err = -ENXIO; 1142 err = -ENXIO;
1136 } else if (ACCESS_FBINFO(outputs[1]).output->getctrl) { 1143 } else if (minfo->outputs[1].output->getctrl) {
1137 err = ACCESS_FBINFO(outputs[1]).output->getctrl(ACCESS_FBINFO(outputs[1]).data, &ctrl); 1144 err = minfo->outputs[1].output->getctrl(minfo->outputs[1].data, &ctrl);
1138 } else { 1145 } else {
1139 err = -EINVAL; 1146 err = -EINVAL;
1140 } 1147 }
1141 up_read(&ACCESS_FBINFO(altout).lock); 1148 up_read(&minfo->altout.lock);
1142 if (err >= 0 && 1149 if (err >= 0 &&
1143 copy_to_user(argp, &ctrl, sizeof(ctrl))) 1150 copy_to_user(argp, &ctrl, sizeof(ctrl)))
1144 return -EFAULT; 1151 return -EFAULT;
@@ -1153,15 +1160,15 @@ static int matroxfb_ioctl(struct fb_info *info,
1153 if (copy_from_user(&ctrl, argp, sizeof(ctrl))) 1160 if (copy_from_user(&ctrl, argp, sizeof(ctrl)))
1154 return -EFAULT; 1161 return -EFAULT;
1155 1162
1156 down_read(&ACCESS_FBINFO(altout).lock); 1163 down_read(&minfo->altout.lock);
1157 if (!ACCESS_FBINFO(outputs[1]).output) { 1164 if (!minfo->outputs[1].output) {
1158 err = -ENXIO; 1165 err = -ENXIO;
1159 } else if (ACCESS_FBINFO(outputs[1]).output->setctrl) { 1166 } else if (minfo->outputs[1].output->setctrl) {
1160 err = ACCESS_FBINFO(outputs[1]).output->setctrl(ACCESS_FBINFO(outputs[1]).data, &ctrl); 1167 err = minfo->outputs[1].output->setctrl(minfo->outputs[1].data, &ctrl);
1161 } else { 1168 } else {
1162 err = -EINVAL; 1169 err = -EINVAL;
1163 } 1170 }
1164 up_read(&ACCESS_FBINFO(altout).lock); 1171 up_read(&minfo->altout.lock);
1165 return err; 1172 return err;
1166 } 1173 }
1167 } 1174 }
@@ -1175,11 +1182,11 @@ static int matroxfb_blank(int blank, struct fb_info *info)
1175 int seq; 1182 int seq;
1176 int crtc; 1183 int crtc;
1177 CRITFLAGS 1184 CRITFLAGS
1178 MINFO_FROM_INFO(info); 1185 struct matrox_fb_info *minfo = info2minfo(info);
1179 1186
1180 DBG(__func__) 1187 DBG(__func__)
1181 1188
1182 if (ACCESS_FBINFO(dead)) 1189 if (minfo->dead)
1183 return 1; 1190 return 1;
1184 1191
1185 switch (blank) { 1192 switch (blank) {
@@ -1281,7 +1288,9 @@ static char outputs[8]; /* "matrox:outputs:xxx" */
1281static char videomode[64]; /* "matrox:mode:xxxxx" or "matrox:xxxxx" */ 1288static char videomode[64]; /* "matrox:mode:xxxxx" or "matrox:xxxxx" */
1282#endif 1289#endif
1283 1290
1284static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSize){ 1291static int matroxfb_getmemory(struct matrox_fb_info *minfo,
1292 unsigned int maxSize, unsigned int *realSize)
1293{
1285 vaddr_t vm; 1294 vaddr_t vm;
1286 unsigned int offs; 1295 unsigned int offs;
1287 unsigned int offs2; 1296 unsigned int offs2;
@@ -1291,7 +1300,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1291 1300
1292 DBG(__func__) 1301 DBG(__func__)
1293 1302
1294 vm = ACCESS_FBINFO(video.vbase); 1303 vm = minfo->video.vbase;
1295 maxSize &= ~0x1FFFFF; /* must be X*2MB (really it must be 2 or X*4MB) */ 1304 maxSize &= ~0x1FFFFF; /* must be X*2MB (really it must be 2 or X*4MB) */
1296 /* at least 2MB */ 1305 /* at least 2MB */
1297 if (maxSize < 0x0200000) return 0; 1306 if (maxSize < 0x0200000) return 0;
@@ -1323,7 +1332,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1323 1332
1324 *realSize = offs - 0x100000; 1333 *realSize = offs - 0x100000;
1325#ifdef CONFIG_FB_MATROX_MILLENIUM 1334#ifdef CONFIG_FB_MATROX_MILLENIUM
1326 ACCESS_FBINFO(interleave) = !(!isMillenium(MINFO) || ((offs - 0x100000) & 0x3FFFFF)); 1335 minfo->interleave = !(!isMillenium(minfo) || ((offs - 0x100000) & 0x3FFFFF));
1327#endif 1336#endif
1328 return 1; 1337 return 1;
1329} 1338}
@@ -1345,13 +1354,9 @@ static struct video_board vbMystique = {0x0800000, 0x0800000, FB_ACCEL_MATROX_M
1345#ifdef CONFIG_FB_MATROX_G 1354#ifdef CONFIG_FB_MATROX_G
1346static struct video_board vbG100 = {0x0800000, 0x0800000, FB_ACCEL_MATROX_MGAG100, &matrox_G100}; 1355static struct video_board vbG100 = {0x0800000, 0x0800000, FB_ACCEL_MATROX_MGAG100, &matrox_G100};
1347static struct video_board vbG200 = {0x1000000, 0x1000000, FB_ACCEL_MATROX_MGAG200, &matrox_G100}; 1356static struct video_board vbG200 = {0x1000000, 0x1000000, FB_ACCEL_MATROX_MGAG200, &matrox_G100};
1348#ifdef CONFIG_FB_MATROX_32MB
1349/* from doc it looks like that accelerator can draw only to low 16MB :-( Direct accesses & displaying are OK for 1357/* from doc it looks like that accelerator can draw only to low 16MB :-( Direct accesses & displaying are OK for
1350 whole 32MB */ 1358 whole 32MB */
1351static struct video_board vbG400 = {0x2000000, 0x1000000, FB_ACCEL_MATROX_MGAG400, &matrox_G100}; 1359static struct video_board vbG400 = {0x2000000, 0x1000000, FB_ACCEL_MATROX_MGAG400, &matrox_G100};
1352#else
1353static struct video_board vbG400 = {0x2000000, 0x1000000, FB_ACCEL_MATROX_MGAG400, &matrox_G100};
1354#endif
1355#endif 1360#endif
1356 1361
1357#define DEVF_VIDEO64BIT 0x0001 1362#define DEVF_VIDEO64BIT 0x0001
@@ -1558,16 +1563,17 @@ static struct fb_videomode defaultmode = {
1558 1563
1559static int hotplug = 0; 1564static int hotplug = 0;
1560 1565
1561static void setDefaultOutputs(WPMINFO2) { 1566static void setDefaultOutputs(struct matrox_fb_info *minfo)
1567{
1562 unsigned int i; 1568 unsigned int i;
1563 const char* ptr; 1569 const char* ptr;
1564 1570
1565 ACCESS_FBINFO(outputs[0]).default_src = MATROXFB_SRC_CRTC1; 1571 minfo->outputs[0].default_src = MATROXFB_SRC_CRTC1;
1566 if (ACCESS_FBINFO(devflags.g450dac)) { 1572 if (minfo->devflags.g450dac) {
1567 ACCESS_FBINFO(outputs[1]).default_src = MATROXFB_SRC_CRTC1; 1573 minfo->outputs[1].default_src = MATROXFB_SRC_CRTC1;
1568 ACCESS_FBINFO(outputs[2]).default_src = MATROXFB_SRC_CRTC1; 1574 minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1;
1569 } else if (dfp) { 1575 } else if (dfp) {
1570 ACCESS_FBINFO(outputs[2]).default_src = MATROXFB_SRC_CRTC1; 1576 minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1;
1571 } 1577 }
1572 ptr = outputs; 1578 ptr = outputs;
1573 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) { 1579 for (i = 0; i < MATROXFB_MAX_OUTPUTS; i++) {
@@ -1577,11 +1583,11 @@ static void setDefaultOutputs(WPMINFO2) {
1577 break; 1583 break;
1578 } 1584 }
1579 if (c == '0') { 1585 if (c == '0') {
1580 ACCESS_FBINFO(outputs[i]).default_src = MATROXFB_SRC_NONE; 1586 minfo->outputs[i].default_src = MATROXFB_SRC_NONE;
1581 } else if (c == '1') { 1587 } else if (c == '1') {
1582 ACCESS_FBINFO(outputs[i]).default_src = MATROXFB_SRC_CRTC1; 1588 minfo->outputs[i].default_src = MATROXFB_SRC_CRTC1;
1583 } else if (c == '2' && ACCESS_FBINFO(devflags.crtc2)) { 1589 } else if (c == '2' && minfo->devflags.crtc2) {
1584 ACCESS_FBINFO(outputs[i]).default_src = MATROXFB_SRC_CRTC2; 1590 minfo->outputs[i].default_src = MATROXFB_SRC_CRTC2;
1585 } else { 1591 } else {
1586 printk(KERN_ERR "matroxfb: Unknown outputs setting\n"); 1592 printk(KERN_ERR "matroxfb: Unknown outputs setting\n");
1587 break; 1593 break;
@@ -1591,7 +1597,8 @@ static void setDefaultOutputs(WPMINFO2) {
1591 outputs[0] = 0; 1597 outputs[0] = 0;
1592} 1598}
1593 1599
1594static int initMatrox2(WPMINFO struct board* b){ 1600static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
1601{
1595 unsigned long ctrlptr_phys = 0; 1602 unsigned long ctrlptr_phys = 0;
1596 unsigned long video_base_phys = 0; 1603 unsigned long video_base_phys = 0;
1597 unsigned int memsize; 1604 unsigned int memsize;
@@ -1607,58 +1614,56 @@ static int initMatrox2(WPMINFO struct board* b){
1607 /* set default values... */ 1614 /* set default values... */
1608 vesafb_defined.accel_flags = FB_ACCELF_TEXT; 1615 vesafb_defined.accel_flags = FB_ACCELF_TEXT;
1609 1616
1610 ACCESS_FBINFO(hw_switch) = b->base->lowlevel; 1617 minfo->hw_switch = b->base->lowlevel;
1611 ACCESS_FBINFO(devflags.accelerator) = b->base->accelID; 1618 minfo->devflags.accelerator = b->base->accelID;
1612 ACCESS_FBINFO(max_pixel_clock) = b->maxclk; 1619 minfo->max_pixel_clock = b->maxclk;
1613 1620
1614 printk(KERN_INFO "matroxfb: Matrox %s detected\n", b->name); 1621 printk(KERN_INFO "matroxfb: Matrox %s detected\n", b->name);
1615 ACCESS_FBINFO(capable.plnwt) = 1; 1622 minfo->capable.plnwt = 1;
1616 ACCESS_FBINFO(chip) = b->chip; 1623 minfo->chip = b->chip;
1617 ACCESS_FBINFO(capable.srcorg) = b->flags & DEVF_SRCORG; 1624 minfo->capable.srcorg = b->flags & DEVF_SRCORG;
1618 ACCESS_FBINFO(devflags.video64bits) = b->flags & DEVF_VIDEO64BIT; 1625 minfo->devflags.video64bits = b->flags & DEVF_VIDEO64BIT;
1619 if (b->flags & DEVF_TEXT4B) { 1626 if (b->flags & DEVF_TEXT4B) {
1620 ACCESS_FBINFO(devflags.vgastep) = 4; 1627 minfo->devflags.vgastep = 4;
1621 ACCESS_FBINFO(devflags.textmode) = 4; 1628 minfo->devflags.textmode = 4;
1622 ACCESS_FBINFO(devflags.text_type_aux) = FB_AUX_TEXT_MGA_STEP16; 1629 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16;
1623 } else if (b->flags & DEVF_TEXT16B) { 1630 } else if (b->flags & DEVF_TEXT16B) {
1624 ACCESS_FBINFO(devflags.vgastep) = 16; 1631 minfo->devflags.vgastep = 16;
1625 ACCESS_FBINFO(devflags.textmode) = 1; 1632 minfo->devflags.textmode = 1;
1626 ACCESS_FBINFO(devflags.text_type_aux) = FB_AUX_TEXT_MGA_STEP16; 1633 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16;
1627 } else { 1634 } else {
1628 ACCESS_FBINFO(devflags.vgastep) = 8; 1635 minfo->devflags.vgastep = 8;
1629 ACCESS_FBINFO(devflags.textmode) = 1; 1636 minfo->devflags.textmode = 1;
1630 ACCESS_FBINFO(devflags.text_type_aux) = FB_AUX_TEXT_MGA_STEP8; 1637 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP8;
1631 } 1638 }
1632#ifdef CONFIG_FB_MATROX_32MB 1639 minfo->devflags.support32MB = (b->flags & DEVF_SUPPORT32MB) != 0;
1633 ACCESS_FBINFO(devflags.support32MB) = (b->flags & DEVF_SUPPORT32MB) != 0; 1640 minfo->devflags.precise_width = !(b->flags & DEVF_ANY_VXRES);
1634#endif 1641 minfo->devflags.crtc2 = (b->flags & DEVF_CRTC2) != 0;
1635 ACCESS_FBINFO(devflags.precise_width) = !(b->flags & DEVF_ANY_VXRES); 1642 minfo->devflags.maven_capable = (b->flags & DEVF_MAVEN_CAPABLE) != 0;
1636 ACCESS_FBINFO(devflags.crtc2) = (b->flags & DEVF_CRTC2) != 0; 1643 minfo->devflags.dualhead = (b->flags & DEVF_DUALHEAD) != 0;
1637 ACCESS_FBINFO(devflags.maven_capable) = (b->flags & DEVF_MAVEN_CAPABLE) != 0; 1644 minfo->devflags.dfp_type = dfp_type;
1638 ACCESS_FBINFO(devflags.dualhead) = (b->flags & DEVF_DUALHEAD) != 0; 1645 minfo->devflags.g450dac = (b->flags & DEVF_G450DAC) != 0;
1639 ACCESS_FBINFO(devflags.dfp_type) = dfp_type; 1646 minfo->devflags.textstep = minfo->devflags.vgastep * minfo->devflags.textmode;
1640 ACCESS_FBINFO(devflags.g450dac) = (b->flags & DEVF_G450DAC) != 0; 1647 minfo->devflags.textvram = 65536 / minfo->devflags.textmode;
1641 ACCESS_FBINFO(devflags.textstep) = ACCESS_FBINFO(devflags.vgastep) * ACCESS_FBINFO(devflags.textmode); 1648 setDefaultOutputs(minfo);
1642 ACCESS_FBINFO(devflags.textvram) = 65536 / ACCESS_FBINFO(devflags.textmode);
1643 setDefaultOutputs(PMINFO2);
1644 if (b->flags & DEVF_PANELLINK_CAPABLE) { 1649 if (b->flags & DEVF_PANELLINK_CAPABLE) {
1645 ACCESS_FBINFO(outputs[2]).data = MINFO; 1650 minfo->outputs[2].data = minfo;
1646 ACCESS_FBINFO(outputs[2]).output = &panellink_output; 1651 minfo->outputs[2].output = &panellink_output;
1647 ACCESS_FBINFO(outputs[2]).src = ACCESS_FBINFO(outputs[2]).default_src; 1652 minfo->outputs[2].src = minfo->outputs[2].default_src;
1648 ACCESS_FBINFO(outputs[2]).mode = MATROXFB_OUTPUT_MODE_MONITOR; 1653 minfo->outputs[2].mode = MATROXFB_OUTPUT_MODE_MONITOR;
1649 ACCESS_FBINFO(devflags.panellink) = 1; 1654 minfo->devflags.panellink = 1;
1650 } 1655 }
1651 1656
1652 if (ACCESS_FBINFO(capable.cross4MB) < 0) 1657 if (minfo->capable.cross4MB < 0)
1653 ACCESS_FBINFO(capable.cross4MB) = b->flags & DEVF_CROSS4MB; 1658 minfo->capable.cross4MB = b->flags & DEVF_CROSS4MB;
1654 if (b->flags & DEVF_SWAPS) { 1659 if (b->flags & DEVF_SWAPS) {
1655 ctrlptr_phys = pci_resource_start(ACCESS_FBINFO(pcidev), 1); 1660 ctrlptr_phys = pci_resource_start(minfo->pcidev, 1);
1656 video_base_phys = pci_resource_start(ACCESS_FBINFO(pcidev), 0); 1661 video_base_phys = pci_resource_start(minfo->pcidev, 0);
1657 ACCESS_FBINFO(devflags.fbResource) = PCI_BASE_ADDRESS_0; 1662 minfo->devflags.fbResource = PCI_BASE_ADDRESS_0;
1658 } else { 1663 } else {
1659 ctrlptr_phys = pci_resource_start(ACCESS_FBINFO(pcidev), 0); 1664 ctrlptr_phys = pci_resource_start(minfo->pcidev, 0);
1660 video_base_phys = pci_resource_start(ACCESS_FBINFO(pcidev), 1); 1665 video_base_phys = pci_resource_start(minfo->pcidev, 1);
1661 ACCESS_FBINFO(devflags.fbResource) = PCI_BASE_ADDRESS_1; 1666 minfo->devflags.fbResource = PCI_BASE_ADDRESS_1;
1662 } 1667 }
1663 err = -EINVAL; 1668 err = -EINVAL;
1664 if (!ctrlptr_phys) { 1669 if (!ctrlptr_phys) {
@@ -1676,7 +1681,7 @@ static int initMatrox2(WPMINFO struct board* b){
1676 if (!request_mem_region(video_base_phys, memsize, "matroxfb FB")) { 1681 if (!request_mem_region(video_base_phys, memsize, "matroxfb FB")) {
1677 goto failCtrlMR; 1682 goto failCtrlMR;
1678 } 1683 }
1679 ACCESS_FBINFO(video.len_maximum) = memsize; 1684 minfo->video.len_maximum = memsize;
1680 /* convert mem (autodetect k, M) */ 1685 /* convert mem (autodetect k, M) */
1681 if (mem < 1024) mem *= 1024; 1686 if (mem < 1024) mem *= 1024;
1682 if (mem < 0x00100000) mem *= 1024; 1687 if (mem < 0x00100000) mem *= 1024;
@@ -1684,14 +1689,14 @@ static int initMatrox2(WPMINFO struct board* b){
1684 if (mem && (mem < memsize)) 1689 if (mem && (mem < memsize))
1685 memsize = mem; 1690 memsize = mem;
1686 err = -ENOMEM; 1691 err = -ENOMEM;
1687 if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, &ACCESS_FBINFO(mmio.vbase))) { 1692 if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, &minfo->mmio.vbase)) {
1688 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys); 1693 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys);
1689 goto failVideoMR; 1694 goto failVideoMR;
1690 } 1695 }
1691 ACCESS_FBINFO(mmio.base) = ctrlptr_phys; 1696 minfo->mmio.base = ctrlptr_phys;
1692 ACCESS_FBINFO(mmio.len) = 16384; 1697 minfo->mmio.len = 16384;
1693 ACCESS_FBINFO(video.base) = video_base_phys; 1698 minfo->video.base = video_base_phys;
1694 if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, &ACCESS_FBINFO(video.vbase))) { 1699 if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, &minfo->video.vbase)) {
1695 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n", 1700 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n",
1696 video_base_phys, memsize); 1701 video_base_phys, memsize);
1697 goto failCtrlIO; 1702 goto failCtrlIO;
@@ -1700,63 +1705,63 @@ static int initMatrox2(WPMINFO struct board* b){
1700 u_int32_t cmd; 1705 u_int32_t cmd;
1701 u_int32_t mga_option; 1706 u_int32_t mga_option;
1702 1707
1703 pci_read_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, &mga_option); 1708 pci_read_config_dword(minfo->pcidev, PCI_OPTION_REG, &mga_option);
1704 pci_read_config_dword(ACCESS_FBINFO(pcidev), PCI_COMMAND, &cmd); 1709 pci_read_config_dword(minfo->pcidev, PCI_COMMAND, &cmd);
1705 mga_option &= 0x7FFFFFFF; /* clear BIG_ENDIAN */ 1710 mga_option &= 0x7FFFFFFF; /* clear BIG_ENDIAN */
1706 mga_option |= MX_OPTION_BSWAP; 1711 mga_option |= MX_OPTION_BSWAP;
1707 /* disable palette snooping */ 1712 /* disable palette snooping */
1708 cmd &= ~PCI_COMMAND_VGA_PALETTE; 1713 cmd &= ~PCI_COMMAND_VGA_PALETTE;
1709 if (pci_dev_present(intel_82437)) { 1714 if (pci_dev_present(intel_82437)) {
1710 if (!(mga_option & 0x20000000) && !ACCESS_FBINFO(devflags.nopciretry)) { 1715 if (!(mga_option & 0x20000000) && !minfo->devflags.nopciretry) {
1711 printk(KERN_WARNING "matroxfb: Disabling PCI retries due to i82437 present\n"); 1716 printk(KERN_WARNING "matroxfb: Disabling PCI retries due to i82437 present\n");
1712 } 1717 }
1713 mga_option |= 0x20000000; 1718 mga_option |= 0x20000000;
1714 ACCESS_FBINFO(devflags.nopciretry) = 1; 1719 minfo->devflags.nopciretry = 1;
1715 } 1720 }
1716 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_COMMAND, cmd); 1721 pci_write_config_dword(minfo->pcidev, PCI_COMMAND, cmd);
1717 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mga_option); 1722 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, mga_option);
1718 ACCESS_FBINFO(hw).MXoptionReg = mga_option; 1723 minfo->hw.MXoptionReg = mga_option;
1719 1724
1720 /* select non-DMA memory for PCI_MGA_DATA, otherwise dump of PCI cfg space can lock PCI bus */ 1725 /* select non-DMA memory for PCI_MGA_DATA, otherwise dump of PCI cfg space can lock PCI bus */
1721 /* maybe preinit() candidate, but it is same... for all devices... at this time... */ 1726 /* maybe preinit() candidate, but it is same... for all devices... at this time... */
1722 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_MGA_INDEX, 0x00003C00); 1727 pci_write_config_dword(minfo->pcidev, PCI_MGA_INDEX, 0x00003C00);
1723 } 1728 }
1724 1729
1725 err = -ENXIO; 1730 err = -ENXIO;
1726 matroxfb_read_pins(PMINFO2); 1731 matroxfb_read_pins(minfo);
1727 if (ACCESS_FBINFO(hw_switch)->preinit(PMINFO2)) { 1732 if (minfo->hw_switch->preinit(minfo)) {
1728 goto failVideoIO; 1733 goto failVideoIO;
1729 } 1734 }
1730 1735
1731 err = -ENOMEM; 1736 err = -ENOMEM;
1732 if (!matroxfb_getmemory(PMINFO memsize, &ACCESS_FBINFO(video.len)) || !ACCESS_FBINFO(video.len)) { 1737 if (!matroxfb_getmemory(minfo, memsize, &minfo->video.len) || !minfo->video.len) {
1733 printk(KERN_ERR "matroxfb: cannot determine memory size\n"); 1738 printk(KERN_ERR "matroxfb: cannot determine memory size\n");
1734 goto failVideoIO; 1739 goto failVideoIO;
1735 } 1740 }
1736 ACCESS_FBINFO(devflags.ydstorg) = 0; 1741 minfo->devflags.ydstorg = 0;
1737 1742
1738 ACCESS_FBINFO(video.base) = video_base_phys; 1743 minfo->video.base = video_base_phys;
1739 ACCESS_FBINFO(video.len_usable) = ACCESS_FBINFO(video.len); 1744 minfo->video.len_usable = minfo->video.len;
1740 if (ACCESS_FBINFO(video.len_usable) > b->base->maxdisplayable) 1745 if (minfo->video.len_usable > b->base->maxdisplayable)
1741 ACCESS_FBINFO(video.len_usable) = b->base->maxdisplayable; 1746 minfo->video.len_usable = b->base->maxdisplayable;
1742#ifdef CONFIG_MTRR 1747#ifdef CONFIG_MTRR
1743 if (mtrr) { 1748 if (mtrr) {
1744 ACCESS_FBINFO(mtrr.vram) = mtrr_add(video_base_phys, ACCESS_FBINFO(video.len), MTRR_TYPE_WRCOMB, 1); 1749 minfo->mtrr.vram = mtrr_add(video_base_phys, minfo->video.len, MTRR_TYPE_WRCOMB, 1);
1745 ACCESS_FBINFO(mtrr.vram_valid) = 1; 1750 minfo->mtrr.vram_valid = 1;
1746 printk(KERN_INFO "matroxfb: MTRR's turned on\n"); 1751 printk(KERN_INFO "matroxfb: MTRR's turned on\n");
1747 } 1752 }
1748#endif /* CONFIG_MTRR */ 1753#endif /* CONFIG_MTRR */
1749 1754
1750 if (!ACCESS_FBINFO(devflags.novga)) 1755 if (!minfo->devflags.novga)
1751 request_region(0x3C0, 32, "matrox"); 1756 request_region(0x3C0, 32, "matrox");
1752 matroxfb_g450_connect(PMINFO2); 1757 matroxfb_g450_connect(minfo);
1753 ACCESS_FBINFO(hw_switch->reset(PMINFO2)); 1758 minfo->hw_switch->reset(minfo);
1754 1759
1755 ACCESS_FBINFO(fbcon.monspecs.hfmin) = 0; 1760 minfo->fbcon.monspecs.hfmin = 0;
1756 ACCESS_FBINFO(fbcon.monspecs.hfmax) = fh; 1761 minfo->fbcon.monspecs.hfmax = fh;
1757 ACCESS_FBINFO(fbcon.monspecs.vfmin) = 0; 1762 minfo->fbcon.monspecs.vfmin = 0;
1758 ACCESS_FBINFO(fbcon.monspecs.vfmax) = fv; 1763 minfo->fbcon.monspecs.vfmax = fv;
1759 ACCESS_FBINFO(fbcon.monspecs.dpms) = 0; /* TBD */ 1764 minfo->fbcon.monspecs.dpms = 0; /* TBD */
1760 1765
1761 /* static settings */ 1766 /* static settings */
1762 vesafb_defined.red = colors[depth-1].red; 1767 vesafb_defined.red = colors[depth-1].red;
@@ -1768,24 +1773,24 @@ static int initMatrox2(WPMINFO struct board* b){
1768 if (noaccel) 1773 if (noaccel)
1769 vesafb_defined.accel_flags &= ~FB_ACCELF_TEXT; 1774 vesafb_defined.accel_flags &= ~FB_ACCELF_TEXT;
1770 1775
1771 ACCESS_FBINFO(fbops) = matroxfb_ops; 1776 minfo->fbops = matroxfb_ops;
1772 ACCESS_FBINFO(fbcon.fbops) = &ACCESS_FBINFO(fbops); 1777 minfo->fbcon.fbops = &minfo->fbops;
1773 ACCESS_FBINFO(fbcon.pseudo_palette) = ACCESS_FBINFO(cmap); 1778 minfo->fbcon.pseudo_palette = minfo->cmap;
1774 /* after __init time we are like module... no logo */ 1779 /* after __init time we are like module... no logo */
1775 ACCESS_FBINFO(fbcon.flags) = hotplug ? FBINFO_FLAG_MODULE : FBINFO_FLAG_DEFAULT; 1780 minfo->fbcon.flags = hotplug ? FBINFO_FLAG_MODULE : FBINFO_FLAG_DEFAULT;
1776 ACCESS_FBINFO(fbcon.flags) |= FBINFO_PARTIAL_PAN_OK | /* Prefer panning for scroll under MC viewer/edit */ 1781 minfo->fbcon.flags |= FBINFO_PARTIAL_PAN_OK | /* Prefer panning for scroll under MC viewer/edit */
1777 FBINFO_HWACCEL_COPYAREA | /* We have hw-assisted bmove */ 1782 FBINFO_HWACCEL_COPYAREA | /* We have hw-assisted bmove */
1778 FBINFO_HWACCEL_FILLRECT | /* And fillrect */ 1783 FBINFO_HWACCEL_FILLRECT | /* And fillrect */
1779 FBINFO_HWACCEL_IMAGEBLIT | /* And imageblit */ 1784 FBINFO_HWACCEL_IMAGEBLIT | /* And imageblit */
1780 FBINFO_HWACCEL_XPAN | /* And we support both horizontal */ 1785 FBINFO_HWACCEL_XPAN | /* And we support both horizontal */
1781 FBINFO_HWACCEL_YPAN; /* And vertical panning */ 1786 FBINFO_HWACCEL_YPAN; /* And vertical panning */
1782 ACCESS_FBINFO(video.len_usable) &= PAGE_MASK; 1787 minfo->video.len_usable &= PAGE_MASK;
1783 fb_alloc_cmap(&ACCESS_FBINFO(fbcon.cmap), 256, 1); 1788 fb_alloc_cmap(&minfo->fbcon.cmap, 256, 1);
1784 1789
1785#ifndef MODULE 1790#ifndef MODULE
1786 /* mode database is marked __init!!! */ 1791 /* mode database is marked __init!!! */
1787 if (!hotplug) { 1792 if (!hotplug) {
1788 fb_find_mode(&vesafb_defined, &ACCESS_FBINFO(fbcon), videomode[0]?videomode:NULL, 1793 fb_find_mode(&vesafb_defined, &minfo->fbcon, videomode[0] ? videomode : NULL,
1789 NULL, 0, &defaultmode, vesafb_defined.bits_per_pixel); 1794 NULL, 0, &defaultmode, vesafb_defined.bits_per_pixel);
1790 } 1795 }
1791#endif /* !MODULE */ 1796#endif /* !MODULE */
@@ -1874,52 +1879,52 @@ static int initMatrox2(WPMINFO struct board* b){
1874 vesafb_defined.yres_virtual = 65536; /* large enough to be INF, but small enough 1879 vesafb_defined.yres_virtual = 65536; /* large enough to be INF, but small enough
1875 to yres_virtual * xres_virtual < 2^32 */ 1880 to yres_virtual * xres_virtual < 2^32 */
1876 } 1881 }
1877 matroxfb_init_fix(PMINFO2); 1882 matroxfb_init_fix(minfo);
1878 ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase)); 1883 minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase);
1879 /* Normalize values (namely yres_virtual) */ 1884 /* Normalize values (namely yres_virtual) */
1880 matroxfb_check_var(&vesafb_defined, &ACCESS_FBINFO(fbcon)); 1885 matroxfb_check_var(&vesafb_defined, &minfo->fbcon);
1881 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over 1886 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over
1882 * vgacon correctly. fbcon_startup will call fb_set_par for us, WITHOUT check_var, 1887 * vgacon correctly. fbcon_startup will call fb_set_par for us, WITHOUT check_var,
1883 * and unfortunately it will do it BEFORE vgacon contents is saved, so it won't work 1888 * and unfortunately it will do it BEFORE vgacon contents is saved, so it won't work
1884 * anyway. But we at least tried... */ 1889 * anyway. But we at least tried... */
1885 ACCESS_FBINFO(fbcon.var) = vesafb_defined; 1890 minfo->fbcon.var = vesafb_defined;
1886 err = -EINVAL; 1891 err = -EINVAL;
1887 1892
1888 printk(KERN_INFO "matroxfb: %dx%dx%dbpp (virtual: %dx%d)\n", 1893 printk(KERN_INFO "matroxfb: %dx%dx%dbpp (virtual: %dx%d)\n",
1889 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, 1894 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel,
1890 vesafb_defined.xres_virtual, vesafb_defined.yres_virtual); 1895 vesafb_defined.xres_virtual, vesafb_defined.yres_virtual);
1891 printk(KERN_INFO "matroxfb: framebuffer at 0x%lX, mapped to 0x%p, size %d\n", 1896 printk(KERN_INFO "matroxfb: framebuffer at 0x%lX, mapped to 0x%p, size %d\n",
1892 ACCESS_FBINFO(video.base), vaddr_va(ACCESS_FBINFO(video.vbase)), ACCESS_FBINFO(video.len)); 1897 minfo->video.base, vaddr_va(minfo->video.vbase), minfo->video.len);
1893 1898
1894/* We do not have to set currcon to 0... register_framebuffer do it for us on first console 1899/* We do not have to set currcon to 0... register_framebuffer do it for us on first console
1895 * and we do not want currcon == 0 for subsequent framebuffers */ 1900 * and we do not want currcon == 0 for subsequent framebuffers */
1896 1901
1897 ACCESS_FBINFO(fbcon).device = &ACCESS_FBINFO(pcidev)->dev; 1902 minfo->fbcon.device = &minfo->pcidev->dev;
1898 if (register_framebuffer(&ACCESS_FBINFO(fbcon)) < 0) { 1903 if (register_framebuffer(&minfo->fbcon) < 0) {
1899 goto failVideoIO; 1904 goto failVideoIO;
1900 } 1905 }
1901 printk("fb%d: %s frame buffer device\n", 1906 printk("fb%d: %s frame buffer device\n",
1902 ACCESS_FBINFO(fbcon.node), ACCESS_FBINFO(fbcon.fix.id)); 1907 minfo->fbcon.node, minfo->fbcon.fix.id);
1903 1908
1904 /* there is no console on this fb... but we have to initialize hardware 1909 /* there is no console on this fb... but we have to initialize hardware
1905 * until someone tells me what is proper thing to do */ 1910 * until someone tells me what is proper thing to do */
1906 if (!ACCESS_FBINFO(initialized)) { 1911 if (!minfo->initialized) {
1907 printk(KERN_INFO "fb%d: initializing hardware\n", 1912 printk(KERN_INFO "fb%d: initializing hardware\n",
1908 ACCESS_FBINFO(fbcon.node)); 1913 minfo->fbcon.node);
1909 /* We have to use FB_ACTIVATE_FORCE, as we had to put vesafb_defined to the fbcon.var 1914 /* We have to use FB_ACTIVATE_FORCE, as we had to put vesafb_defined to the fbcon.var
1910 * already before, so register_framebuffer works correctly. */ 1915 * already before, so register_framebuffer works correctly. */
1911 vesafb_defined.activate |= FB_ACTIVATE_FORCE; 1916 vesafb_defined.activate |= FB_ACTIVATE_FORCE;
1912 fb_set_var(&ACCESS_FBINFO(fbcon), &vesafb_defined); 1917 fb_set_var(&minfo->fbcon, &vesafb_defined);
1913 } 1918 }
1914 1919
1915 return 0; 1920 return 0;
1916failVideoIO:; 1921failVideoIO:;
1917 matroxfb_g450_shutdown(PMINFO2); 1922 matroxfb_g450_shutdown(minfo);
1918 mga_iounmap(ACCESS_FBINFO(video.vbase)); 1923 mga_iounmap(minfo->video.vbase);
1919failCtrlIO:; 1924failCtrlIO:;
1920 mga_iounmap(ACCESS_FBINFO(mmio.vbase)); 1925 mga_iounmap(minfo->mmio.vbase);
1921failVideoMR:; 1926failVideoMR:;
1922 release_mem_region(video_base_phys, ACCESS_FBINFO(video.len_maximum)); 1927 release_mem_region(video_base_phys, minfo->video.len_maximum);
1923failCtrlMR:; 1928failCtrlMR:;
1924 release_mem_region(ctrlptr_phys, 16384); 1929 release_mem_region(ctrlptr_phys, 16384);
1925fail:; 1930fail:;
@@ -1975,7 +1980,7 @@ void matroxfb_unregister_driver(struct matroxfb_driver* drv) {
1975static void matroxfb_register_device(struct matrox_fb_info* minfo) { 1980static void matroxfb_register_device(struct matrox_fb_info* minfo) {
1976 struct matroxfb_driver* drv; 1981 struct matroxfb_driver* drv;
1977 int i = 0; 1982 int i = 0;
1978 list_add(&ACCESS_FBINFO(next_fb), &matroxfb_list); 1983 list_add(&minfo->next_fb, &matroxfb_list);
1979 for (drv = matroxfb_driver_l(matroxfb_driver_list.next); 1984 for (drv = matroxfb_driver_l(matroxfb_driver_list.next);
1980 drv != matroxfb_driver_l(&matroxfb_driver_list); 1985 drv != matroxfb_driver_l(&matroxfb_driver_list);
1981 drv = matroxfb_driver_l(drv->node.next)) { 1986 drv = matroxfb_driver_l(drv->node.next)) {
@@ -1995,7 +2000,7 @@ static void matroxfb_register_device(struct matrox_fb_info* minfo) {
1995static void matroxfb_unregister_device(struct matrox_fb_info* minfo) { 2000static void matroxfb_unregister_device(struct matrox_fb_info* minfo) {
1996 int i; 2001 int i;
1997 2002
1998 list_del(&ACCESS_FBINFO(next_fb)); 2003 list_del(&minfo->next_fb);
1999 for (i = 0; i < minfo->drivers_count; i++) { 2004 for (i = 0; i < minfo->drivers_count; i++) {
2000 struct matroxfb_driver* drv = minfo->drivers[i]; 2005 struct matroxfb_driver* drv = minfo->drivers[i];
2001 2006
@@ -2011,9 +2016,6 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2011 struct matrox_fb_info* minfo; 2016 struct matrox_fb_info* minfo;
2012 int err; 2017 int err;
2013 u_int32_t cmd; 2018 u_int32_t cmd;
2014#ifndef CONFIG_FB_MATROX_MULTIHEAD
2015 static int registered = 0;
2016#endif
2017 DBG(__func__) 2019 DBG(__func__)
2018 2020
2019 svid = pdev->subsystem_vendor; 2021 svid = pdev->subsystem_vendor;
@@ -2037,68 +2039,57 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2037 return -1; 2039 return -1;
2038 } 2040 }
2039 2041
2040#ifdef CONFIG_FB_MATROX_MULTIHEAD
2041 minfo = kmalloc(sizeof(*minfo), GFP_KERNEL); 2042 minfo = kmalloc(sizeof(*minfo), GFP_KERNEL);
2042 if (!minfo) 2043 if (!minfo)
2043 return -1; 2044 return -1;
2044#else 2045 memset(minfo, 0, sizeof(*minfo));
2045 if (registered) /* singlehead driver... */
2046 return -1;
2047 minfo = &matroxfb_global_mxinfo;
2048#endif
2049 memset(MINFO, 0, sizeof(*MINFO));
2050 2046
2051 ACCESS_FBINFO(pcidev) = pdev; 2047 minfo->pcidev = pdev;
2052 ACCESS_FBINFO(dead) = 0; 2048 minfo->dead = 0;
2053 ACCESS_FBINFO(usecount) = 0; 2049 minfo->usecount = 0;
2054 ACCESS_FBINFO(userusecount) = 0; 2050 minfo->userusecount = 0;
2055 2051
2056 pci_set_drvdata(pdev, MINFO); 2052 pci_set_drvdata(pdev, minfo);
2057 /* DEVFLAGS */ 2053 /* DEVFLAGS */
2058 ACCESS_FBINFO(devflags.memtype) = memtype; 2054 minfo->devflags.memtype = memtype;
2059 if (memtype != -1) 2055 if (memtype != -1)
2060 noinit = 0; 2056 noinit = 0;
2061 if (cmd & PCI_COMMAND_MEMORY) { 2057 if (cmd & PCI_COMMAND_MEMORY) {
2062 ACCESS_FBINFO(devflags.novga) = novga; 2058 minfo->devflags.novga = novga;
2063 ACCESS_FBINFO(devflags.nobios) = nobios; 2059 minfo->devflags.nobios = nobios;
2064 ACCESS_FBINFO(devflags.noinit) = noinit; 2060 minfo->devflags.noinit = noinit;
2065 /* subsequent heads always needs initialization and must not enable BIOS */ 2061 /* subsequent heads always needs initialization and must not enable BIOS */
2066 novga = 1; 2062 novga = 1;
2067 nobios = 1; 2063 nobios = 1;
2068 noinit = 0; 2064 noinit = 0;
2069 } else { 2065 } else {
2070 ACCESS_FBINFO(devflags.novga) = 1; 2066 minfo->devflags.novga = 1;
2071 ACCESS_FBINFO(devflags.nobios) = 1; 2067 minfo->devflags.nobios = 1;
2072 ACCESS_FBINFO(devflags.noinit) = 0; 2068 minfo->devflags.noinit = 0;
2073 } 2069 }
2074 2070
2075 ACCESS_FBINFO(devflags.nopciretry) = no_pci_retry; 2071 minfo->devflags.nopciretry = no_pci_retry;
2076 ACCESS_FBINFO(devflags.mga_24bpp_fix) = inv24; 2072 minfo->devflags.mga_24bpp_fix = inv24;
2077 ACCESS_FBINFO(devflags.precise_width) = option_precise_width; 2073 minfo->devflags.precise_width = option_precise_width;
2078 ACCESS_FBINFO(devflags.sgram) = sgram; 2074 minfo->devflags.sgram = sgram;
2079 ACCESS_FBINFO(capable.cross4MB) = cross4MB; 2075 minfo->capable.cross4MB = cross4MB;
2080 2076
2081 spin_lock_init(&ACCESS_FBINFO(lock.DAC)); 2077 spin_lock_init(&minfo->lock.DAC);
2082 spin_lock_init(&ACCESS_FBINFO(lock.accel)); 2078 spin_lock_init(&minfo->lock.accel);
2083 init_rwsem(&ACCESS_FBINFO(crtc2.lock)); 2079 init_rwsem(&minfo->crtc2.lock);
2084 init_rwsem(&ACCESS_FBINFO(altout.lock)); 2080 init_rwsem(&minfo->altout.lock);
2085 mutex_init(&ACCESS_FBINFO(fbcon).mm_lock); 2081 mutex_init(&minfo->fbcon.mm_lock);
2086 ACCESS_FBINFO(irq_flags) = 0; 2082 minfo->irq_flags = 0;
2087 init_waitqueue_head(&ACCESS_FBINFO(crtc1.vsync.wait)); 2083 init_waitqueue_head(&minfo->crtc1.vsync.wait);
2088 init_waitqueue_head(&ACCESS_FBINFO(crtc2.vsync.wait)); 2084 init_waitqueue_head(&minfo->crtc2.vsync.wait);
2089 ACCESS_FBINFO(crtc1.panpos) = -1; 2085 minfo->crtc1.panpos = -1;
2090 2086
2091 err = initMatrox2(PMINFO b); 2087 err = initMatrox2(minfo, b);
2092 if (!err) { 2088 if (!err) {
2093#ifndef CONFIG_FB_MATROX_MULTIHEAD 2089 matroxfb_register_device(minfo);
2094 registered = 1;
2095#endif
2096 matroxfb_register_device(MINFO);
2097 return 0; 2090 return 0;
2098 } 2091 }
2099#ifdef CONFIG_FB_MATROX_MULTIHEAD
2100 kfree(minfo); 2092 kfree(minfo);
2101#endif
2102 return -1; 2093 return -1;
2103} 2094}
2104 2095
@@ -2106,7 +2097,7 @@ static void pci_remove_matrox(struct pci_dev* pdev) {
2106 struct matrox_fb_info* minfo; 2097 struct matrox_fb_info* minfo;
2107 2098
2108 minfo = pci_get_drvdata(pdev); 2099 minfo = pci_get_drvdata(pdev);
2109 matroxfb_remove(PMINFO 1); 2100 matroxfb_remove(minfo, 1);
2110} 2101}
2111 2102
2112static struct pci_device_id matroxfb_devices[] = { 2103static struct pci_device_id matroxfb_devices[] = {
@@ -2510,13 +2501,8 @@ module_param(inv24, int, 0);
2510MODULE_PARM_DESC(inv24, "Inverts clock polarity for 24bpp and loop frequency > 100MHz (default=do not invert polarity)"); 2501MODULE_PARM_DESC(inv24, "Inverts clock polarity for 24bpp and loop frequency > 100MHz (default=do not invert polarity)");
2511module_param(inverse, int, 0); 2502module_param(inverse, int, 0);
2512MODULE_PARM_DESC(inverse, "Inverse (0 or 1) (default=0)"); 2503MODULE_PARM_DESC(inverse, "Inverse (0 or 1) (default=0)");
2513#ifdef CONFIG_FB_MATROX_MULTIHEAD
2514module_param(dev, int, 0); 2504module_param(dev, int, 0);
2515MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=all working)"); 2505MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=all working)");
2516#else
2517module_param(dev, int, 0);
2518MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=first working)");
2519#endif
2520module_param(vesa, int, 0); 2506module_param(vesa, int, 0);
2521MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)"); 2507MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)");
2522module_param(xres, int, 0); 2508module_param(xres, int, 0);