aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/matrox/matroxfb_DAC1064.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-09-22 19:47:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:57 -0400
commit316b4d644caceb2cf7432d8a27e45b88f57ef2a0 (patch)
tree3c1815b8a4a8e4e5999e657a26e5cea222d02dcd /drivers/video/matrox/matroxfb_DAC1064.c
parentfc2d10ddfc8989e82f74d2a38c7d6bfa45bcaba9 (diff)
matroxfb: get rid of unneeded macros WPMINFO and friends
With multihead support always enabled, these macros are no longer needed and make the code harder to read. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Petr Vandrovec <vandrove@vc.cvut.cz> Cc: Krzysztof Helt <krzysztof.h1@poczta.fm> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/matrox/matroxfb_DAC1064.c')
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c248
1 files changed, 139 insertions, 109 deletions
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 7662a2862898..88466a04bab2 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -33,7 +33,11 @@
33#define DAC1064_OPT_MDIV2 0x00 33#define DAC1064_OPT_MDIV2 0x00
34#define DAC1064_OPT_RESERVED 0x10 34#define DAC1064_OPT_RESERVED 0x10
35 35
36static void DAC1064_calcclock(CPMINFO unsigned int freq, unsigned int fmax, unsigned int* in, unsigned int* feed, unsigned int* post) { 36static void DAC1064_calcclock(const struct matrox_fb_info *minfo,
37 unsigned int freq, unsigned int fmax,
38 unsigned int *in, unsigned int *feed,
39 unsigned int *post)
40{
37 unsigned int fvco; 41 unsigned int fvco;
38 unsigned int p; 42 unsigned int p;
39 43
@@ -41,7 +45,7 @@ static void DAC1064_calcclock(CPMINFO unsigned int freq, unsigned int fmax, unsi
41 45
42 /* only for devices older than G450 */ 46 /* only for devices older than G450 */
43 47
44 fvco = PLL_calcclock(PMINFO freq, fmax, in, feed, &p); 48 fvco = PLL_calcclock(minfo, freq, fmax, in, feed, &p);
45 49
46 p = (1 << p) - 1; 50 p = (1 << p) - 1;
47 if (fvco <= 100000) 51 if (fvco <= 100000)
@@ -80,18 +84,21 @@ static const unsigned char MGA1064_DAC[] = {
80 0x00, 84 0x00,
81 0x00, 0x00, 0xFF, 0xFF}; 85 0x00, 0x00, 0xFF, 0xFF};
82 86
83static void DAC1064_setpclk(WPMINFO unsigned long fout) { 87static void DAC1064_setpclk(struct matrox_fb_info *minfo, unsigned long fout)
88{
84 unsigned int m, n, p; 89 unsigned int m, n, p;
85 90
86 DBG(__func__) 91 DBG(__func__)
87 92
88 DAC1064_calcclock(PMINFO fout, minfo->max_pixel_clock, &m, &n, &p); 93 DAC1064_calcclock(minfo, fout, minfo->max_pixel_clock, &m, &n, &p);
89 minfo->hw.DACclk[0] = m; 94 minfo->hw.DACclk[0] = m;
90 minfo->hw.DACclk[1] = n; 95 minfo->hw.DACclk[1] = n;
91 minfo->hw.DACclk[2] = p; 96 minfo->hw.DACclk[2] = p;
92} 97}
93 98
94static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) { 99static void DAC1064_setmclk(struct matrox_fb_info *minfo, int oscinfo,
100 unsigned long fmem)
101{
95 u_int32_t mx; 102 u_int32_t mx;
96 struct matrox_hw_state *hw = &minfo->hw; 103 struct matrox_hw_state *hw = &minfo->hw;
97 104
@@ -99,9 +106,9 @@ static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) {
99 106
100 if (minfo->devflags.noinit) { 107 if (minfo->devflags.noinit) {
101 /* read MCLK and give up... */ 108 /* read MCLK and give up... */
102 hw->DACclk[3] = inDAC1064(PMINFO DAC1064_XSYSPLLM); 109 hw->DACclk[3] = inDAC1064(minfo, DAC1064_XSYSPLLM);
103 hw->DACclk[4] = inDAC1064(PMINFO DAC1064_XSYSPLLN); 110 hw->DACclk[4] = inDAC1064(minfo, DAC1064_XSYSPLLN);
104 hw->DACclk[5] = inDAC1064(PMINFO DAC1064_XSYSPLLP); 111 hw->DACclk[5] = inDAC1064(minfo, DAC1064_XSYSPLLP);
105 return; 112 return;
106 } 113 }
107 mx = hw->MXoptionReg | 0x00000004; 114 mx = hw->MXoptionReg | 0x00000004;
@@ -131,12 +138,12 @@ static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) {
131 perfect... */ 138 perfect... */
132 /* (bit 2 of PCI_OPTION_REG must be 0... and bits 0,1 must not 139 /* (bit 2 of PCI_OPTION_REG must be 0... and bits 0,1 must not
133 select PLL... because of PLL can be stopped at this time) */ 140 select PLL... because of PLL can be stopped at this time) */
134 DAC1064_calcclock(PMINFO fmem, minfo->max_pixel_clock, &m, &n, &p); 141 DAC1064_calcclock(minfo, fmem, minfo->max_pixel_clock, &m, &n, &p);
135 outDAC1064(PMINFO DAC1064_XSYSPLLM, hw->DACclk[3] = m); 142 outDAC1064(minfo, DAC1064_XSYSPLLM, hw->DACclk[3] = m);
136 outDAC1064(PMINFO DAC1064_XSYSPLLN, hw->DACclk[4] = n); 143 outDAC1064(minfo, DAC1064_XSYSPLLN, hw->DACclk[4] = n);
137 outDAC1064(PMINFO DAC1064_XSYSPLLP, hw->DACclk[5] = p); 144 outDAC1064(minfo, DAC1064_XSYSPLLP, hw->DACclk[5] = p);
138 for (clk = 65536; clk; --clk) { 145 for (clk = 65536; clk; --clk) {
139 if (inDAC1064(PMINFO DAC1064_XSYSPLLSTAT) & 0x40) 146 if (inDAC1064(minfo, DAC1064_XSYSPLLSTAT) & 0x40)
140 break; 147 break;
141 } 148 }
142 if (!clk) 149 if (!clk)
@@ -154,7 +161,8 @@ static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) {
154} 161}
155 162
156#ifdef CONFIG_FB_MATROX_G 163#ifdef CONFIG_FB_MATROX_G
157static void g450_set_plls(WPMINFO2) { 164static void g450_set_plls(struct matrox_fb_info *minfo)
165{
158 u_int32_t c2_ctl; 166 u_int32_t c2_ctl;
159 unsigned int pxc; 167 unsigned int pxc;
160 struct matrox_hw_state *hw = &minfo->hw; 168 struct matrox_hw_state *hw = &minfo->hw;
@@ -184,16 +192,16 @@ static void g450_set_plls(WPMINFO2) {
184 c2_ctl |= 0x0006; /* Use video PLL */ 192 c2_ctl |= 0x0006; /* Use video PLL */
185 hw->DACreg[POS1064_XPWRCTRL] |= 0x02; 193 hw->DACreg[POS1064_XPWRCTRL] |= 0x02;
186 194
187 outDAC1064(PMINFO M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]); 195 outDAC1064(minfo, M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]);
188 matroxfb_g450_setpll_cond(PMINFO videomnp, M_VIDEO_PLL); 196 matroxfb_g450_setpll_cond(minfo, videomnp, M_VIDEO_PLL);
189 } 197 }
190 198
191 hw->DACreg[POS1064_XPIXCLKCTRL] &= ~M1064_XPIXCLKCTRL_PLL_UP; 199 hw->DACreg[POS1064_XPIXCLKCTRL] &= ~M1064_XPIXCLKCTRL_PLL_UP;
192 if (pixelmnp >= 0) { 200 if (pixelmnp >= 0) {
193 hw->DACreg[POS1064_XPIXCLKCTRL] |= M1064_XPIXCLKCTRL_PLL_UP; 201 hw->DACreg[POS1064_XPIXCLKCTRL] |= M1064_XPIXCLKCTRL_PLL_UP;
194 202
195 outDAC1064(PMINFO M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]); 203 outDAC1064(minfo, M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]);
196 matroxfb_g450_setpll_cond(PMINFO pixelmnp, M_PIXEL_PLL_C); 204 matroxfb_g450_setpll_cond(minfo, pixelmnp, M_PIXEL_PLL_C);
197 } 205 }
198 if (c2_ctl != hw->crtc2.ctl) { 206 if (c2_ctl != hw->crtc2.ctl) {
199 hw->crtc2.ctl = c2_ctl; 207 hw->crtc2.ctl = c2_ctl;
@@ -245,7 +253,8 @@ static void g450_set_plls(WPMINFO2) {
245} 253}
246#endif 254#endif
247 255
248void DAC1064_global_init(WPMINFO2) { 256void DAC1064_global_init(struct matrox_fb_info *minfo)
257{
249 struct matrox_hw_state *hw = &minfo->hw; 258 struct matrox_hw_state *hw = &minfo->hw;
250 259
251 hw->DACreg[POS1064_XMISCCTRL] &= M1064_XMISCCTRL_DAC_WIDTHMASK; 260 hw->DACreg[POS1064_XMISCCTRL] &= M1064_XMISCCTRL_DAC_WIDTHMASK;
@@ -299,7 +308,7 @@ void DAC1064_global_init(WPMINFO2) {
299 break; 308 break;
300 } 309 }
301 /* Now set timming related variables... */ 310 /* Now set timming related variables... */
302 g450_set_plls(PMINFO2); 311 g450_set_plls(minfo);
303 } else 312 } else
304#endif 313#endif
305 { 314 {
@@ -318,24 +327,26 @@ void DAC1064_global_init(WPMINFO2) {
318 } 327 }
319} 328}
320 329
321void DAC1064_global_restore(WPMINFO2) { 330void DAC1064_global_restore(struct matrox_fb_info *minfo)
331{
322 struct matrox_hw_state *hw = &minfo->hw; 332 struct matrox_hw_state *hw = &minfo->hw;
323 333
324 outDAC1064(PMINFO M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]); 334 outDAC1064(minfo, M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]);
325 outDAC1064(PMINFO M1064_XMISCCTRL, hw->DACreg[POS1064_XMISCCTRL]); 335 outDAC1064(minfo, M1064_XMISCCTRL, hw->DACreg[POS1064_XMISCCTRL]);
326 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) { 336 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) {
327 outDAC1064(PMINFO 0x20, 0x04); 337 outDAC1064(minfo, 0x20, 0x04);
328 outDAC1064(PMINFO 0x1F, minfo->devflags.dfp_type); 338 outDAC1064(minfo, 0x1F, minfo->devflags.dfp_type);
329 if (minfo->devflags.g450dac) { 339 if (minfo->devflags.g450dac) {
330 outDAC1064(PMINFO M1064_XSYNCCTRL, 0xCC); 340 outDAC1064(minfo, M1064_XSYNCCTRL, 0xCC);
331 outDAC1064(PMINFO M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]); 341 outDAC1064(minfo, M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]);
332 outDAC1064(PMINFO M1064_XPANMODE, hw->DACreg[POS1064_XPANMODE]); 342 outDAC1064(minfo, M1064_XPANMODE, hw->DACreg[POS1064_XPANMODE]);
333 outDAC1064(PMINFO M1064_XOUTPUTCONN, hw->DACreg[POS1064_XOUTPUTCONN]); 343 outDAC1064(minfo, M1064_XOUTPUTCONN, hw->DACreg[POS1064_XOUTPUTCONN]);
334 } 344 }
335 } 345 }
336} 346}
337 347
338static int DAC1064_init_1(WPMINFO struct my_timming* m) { 348static int DAC1064_init_1(struct matrox_fb_info *minfo, struct my_timming *m)
349{
339 struct matrox_hw_state *hw = &minfo->hw; 350 struct matrox_hw_state *hw = &minfo->hw;
340 351
341 DBG(__func__) 352 DBG(__func__)
@@ -367,11 +378,12 @@ static int DAC1064_init_1(WPMINFO struct my_timming* m) {
367 hw->DACreg[POS1064_XCURADDL] = 0; 378 hw->DACreg[POS1064_XCURADDL] = 0;
368 hw->DACreg[POS1064_XCURADDH] = 0; 379 hw->DACreg[POS1064_XCURADDH] = 0;
369 380
370 DAC1064_global_init(PMINFO2); 381 DAC1064_global_init(minfo);
371 return 0; 382 return 0;
372} 383}
373 384
374static int DAC1064_init_2(WPMINFO struct my_timming* m) { 385static int DAC1064_init_2(struct matrox_fb_info *minfo, struct my_timming *m)
386{
375 struct matrox_hw_state *hw = &minfo->hw; 387 struct matrox_hw_state *hw = &minfo->hw;
376 388
377 DBG(__func__) 389 DBG(__func__)
@@ -413,7 +425,8 @@ static int DAC1064_init_2(WPMINFO struct my_timming* m) {
413 return 0; 425 return 0;
414} 426}
415 427
416static void DAC1064_restore_1(WPMINFO2) { 428static void DAC1064_restore_1(struct matrox_fb_info *minfo)
429{
417 struct matrox_hw_state *hw = &minfo->hw; 430 struct matrox_hw_state *hw = &minfo->hw;
418 431
419 CRITFLAGS 432 CRITFLAGS
@@ -422,28 +435,29 @@ static void DAC1064_restore_1(WPMINFO2) {
422 435
423 CRITBEGIN 436 CRITBEGIN
424 437
425 if ((inDAC1064(PMINFO DAC1064_XSYSPLLM) != hw->DACclk[3]) || 438 if ((inDAC1064(minfo, DAC1064_XSYSPLLM) != hw->DACclk[3]) ||
426 (inDAC1064(PMINFO DAC1064_XSYSPLLN) != hw->DACclk[4]) || 439 (inDAC1064(minfo, DAC1064_XSYSPLLN) != hw->DACclk[4]) ||
427 (inDAC1064(PMINFO DAC1064_XSYSPLLP) != hw->DACclk[5])) { 440 (inDAC1064(minfo, DAC1064_XSYSPLLP) != hw->DACclk[5])) {
428 outDAC1064(PMINFO DAC1064_XSYSPLLM, hw->DACclk[3]); 441 outDAC1064(minfo, DAC1064_XSYSPLLM, hw->DACclk[3]);
429 outDAC1064(PMINFO DAC1064_XSYSPLLN, hw->DACclk[4]); 442 outDAC1064(minfo, DAC1064_XSYSPLLN, hw->DACclk[4]);
430 outDAC1064(PMINFO DAC1064_XSYSPLLP, hw->DACclk[5]); 443 outDAC1064(minfo, DAC1064_XSYSPLLP, hw->DACclk[5]);
431 } 444 }
432 { 445 {
433 unsigned int i; 446 unsigned int i;
434 447
435 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) { 448 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) {
436 if ((i != POS1064_XPIXCLKCTRL) && (i != POS1064_XMISCCTRL)) 449 if ((i != POS1064_XPIXCLKCTRL) && (i != POS1064_XMISCCTRL))
437 outDAC1064(PMINFO MGA1064_DAC_regs[i], hw->DACreg[i]); 450 outDAC1064(minfo, MGA1064_DAC_regs[i], hw->DACreg[i]);
438 } 451 }
439 } 452 }
440 453
441 DAC1064_global_restore(PMINFO2); 454 DAC1064_global_restore(minfo);
442 455
443 CRITEND 456 CRITEND
444}; 457};
445 458
446static void DAC1064_restore_2(WPMINFO2) { 459static void DAC1064_restore_2(struct matrox_fb_info *minfo)
460{
447#ifdef DEBUG 461#ifdef DEBUG
448 unsigned int i; 462 unsigned int i;
449#endif 463#endif
@@ -470,14 +484,14 @@ static int m1064_compute(void* out, struct my_timming* m) {
470 int tmout; 484 int tmout;
471 CRITFLAGS 485 CRITFLAGS
472 486
473 DAC1064_setpclk(PMINFO m->pixclock); 487 DAC1064_setpclk(minfo, m->pixclock);
474 488
475 CRITBEGIN 489 CRITBEGIN
476 490
477 for (i = 0; i < 3; i++) 491 for (i = 0; i < 3; i++)
478 outDAC1064(PMINFO M1064_XPIXPLLCM + i, minfo->hw.DACclk[i]); 492 outDAC1064(minfo, M1064_XPIXPLLCM + i, minfo->hw.DACclk[i]);
479 for (tmout = 500000; tmout; tmout--) { 493 for (tmout = 500000; tmout; tmout--) {
480 if (inDAC1064(PMINFO M1064_XPIXPLLSTAT) & 0x40) 494 if (inDAC1064(minfo, M1064_XPIXPLLSTAT) & 0x40)
481 break; 495 break;
482 udelay(10); 496 udelay(10);
483 }; 497 };
@@ -500,9 +514,9 @@ static struct matrox_altout m1064 = {
500static int g450_compute(void* out, struct my_timming* m) { 514static int g450_compute(void* out, struct my_timming* m) {
501#define minfo ((struct matrox_fb_info*)out) 515#define minfo ((struct matrox_fb_info*)out)
502 if (m->mnp < 0) { 516 if (m->mnp < 0) {
503 m->mnp = matroxfb_g450_setclk(PMINFO m->pixclock, (m->crtc == MATROXFB_SRC_CRTC1) ? M_PIXEL_PLL_C : M_VIDEO_PLL); 517 m->mnp = matroxfb_g450_setclk(minfo, m->pixclock, (m->crtc == MATROXFB_SRC_CRTC1) ? M_PIXEL_PLL_C : M_VIDEO_PLL);
504 if (m->mnp >= 0) { 518 if (m->mnp >= 0) {
505 m->pixclock = g450_mnp2f(PMINFO m->mnp); 519 m->pixclock = g450_mnp2f(minfo, m->mnp);
506 } 520 }
507 } 521 }
508#undef minfo 522#undef minfo
@@ -518,13 +532,14 @@ static struct matrox_altout g450out = {
518#endif /* NEED_DAC1064 */ 532#endif /* NEED_DAC1064 */
519 533
520#ifdef CONFIG_FB_MATROX_MYSTIQUE 534#ifdef CONFIG_FB_MATROX_MYSTIQUE
521static int MGA1064_init(WPMINFO struct my_timming* m) { 535static int MGA1064_init(struct matrox_fb_info *minfo, struct my_timming *m)
536{
522 struct matrox_hw_state *hw = &minfo->hw; 537 struct matrox_hw_state *hw = &minfo->hw;
523 538
524 DBG(__func__) 539 DBG(__func__)
525 540
526 if (DAC1064_init_1(PMINFO m)) return 1; 541 if (DAC1064_init_1(minfo, m)) return 1;
527 if (matroxfb_vgaHWinit(PMINFO m)) return 1; 542 if (matroxfb_vgaHWinit(minfo, m)) return 1;
528 543
529 hw->MiscOutReg = 0xCB; 544 hw->MiscOutReg = 0xCB;
530 if (m->sync & FB_SYNC_HOR_HIGH_ACT) 545 if (m->sync & FB_SYNC_HOR_HIGH_ACT)
@@ -534,20 +549,21 @@ static int MGA1064_init(WPMINFO struct my_timming* m) {
534 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */ 549 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
535 hw->CRTCEXT[3] |= 0x40; 550 hw->CRTCEXT[3] |= 0x40;
536 551
537 if (DAC1064_init_2(PMINFO m)) return 1; 552 if (DAC1064_init_2(minfo, m)) return 1;
538 return 0; 553 return 0;
539} 554}
540#endif 555#endif
541 556
542#ifdef CONFIG_FB_MATROX_G 557#ifdef CONFIG_FB_MATROX_G
543static int MGAG100_init(WPMINFO struct my_timming* m) { 558static int MGAG100_init(struct matrox_fb_info *minfo, struct my_timming *m)
559{
544 struct matrox_hw_state *hw = &minfo->hw; 560 struct matrox_hw_state *hw = &minfo->hw;
545 561
546 DBG(__func__) 562 DBG(__func__)
547 563
548 if (DAC1064_init_1(PMINFO m)) return 1; 564 if (DAC1064_init_1(minfo, m)) return 1;
549 hw->MXoptionReg &= ~0x2000; 565 hw->MXoptionReg &= ~0x2000;
550 if (matroxfb_vgaHWinit(PMINFO m)) return 1; 566 if (matroxfb_vgaHWinit(minfo, m)) return 1;
551 567
552 hw->MiscOutReg = 0xEF; 568 hw->MiscOutReg = 0xEF;
553 if (m->sync & FB_SYNC_HOR_HIGH_ACT) 569 if (m->sync & FB_SYNC_HOR_HIGH_ACT)
@@ -557,13 +573,14 @@ static int MGAG100_init(WPMINFO struct my_timming* m) {
557 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */ 573 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
558 hw->CRTCEXT[3] |= 0x40; 574 hw->CRTCEXT[3] |= 0x40;
559 575
560 if (DAC1064_init_2(PMINFO m)) return 1; 576 if (DAC1064_init_2(minfo, m)) return 1;
561 return 0; 577 return 0;
562} 578}
563#endif /* G */ 579#endif /* G */
564 580
565#ifdef CONFIG_FB_MATROX_MYSTIQUE 581#ifdef CONFIG_FB_MATROX_MYSTIQUE
566static void MGA1064_ramdac_init(WPMINFO2) { 582static void MGA1064_ramdac_init(struct matrox_fb_info *minfo)
583{
567 584
568 DBG(__func__) 585 DBG(__func__)
569 586
@@ -577,7 +594,7 @@ static void MGA1064_ramdac_init(WPMINFO2) {
577 minfo->features.pll.post_shift_max = 3; 594 minfo->features.pll.post_shift_max = 3;
578 minfo->features.DAC1064.xvrefctrl = DAC1064_XVREFCTRL_EXTERNAL; 595 minfo->features.DAC1064.xvrefctrl = DAC1064_XVREFCTRL_EXTERNAL;
579 /* maybe cmdline MCLK= ?, doc says gclk=44MHz, mclk=66MHz... it was 55/83 with old values */ 596 /* maybe cmdline MCLK= ?, doc says gclk=44MHz, mclk=66MHz... it was 55/83 with old values */
580 DAC1064_setmclk(PMINFO DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PLL, 133333); 597 DAC1064_setmclk(minfo, DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PLL, 133333);
581} 598}
582#endif 599#endif
583 600
@@ -589,23 +606,25 @@ static int x7AF4 = 0x10; /* flags, maybe 0x10 = SDRAM, 0x00 = SGRAM??? */
589static int def50 = 0; /* reg50, & 0x0F, & 0x3000 (only 0x0000, 0x1000, 0x2000 (0x3000 disallowed and treated as 0) */ 606static int def50 = 0; /* reg50, & 0x0F, & 0x3000 (only 0x0000, 0x1000, 0x2000 (0x3000 disallowed and treated as 0) */
590#endif 607#endif
591 608
592static void MGAG100_progPixClock(CPMINFO int flags, int m, int n, int p) { 609static void MGAG100_progPixClock(const struct matrox_fb_info *minfo, int flags,
610 int m, int n, int p)
611{
593 int reg; 612 int reg;
594 int selClk; 613 int selClk;
595 int clk; 614 int clk;
596 615
597 DBG(__func__) 616 DBG(__func__)
598 617
599 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) | M1064_XPIXCLKCTRL_DIS | 618 outDAC1064(minfo, M1064_XPIXCLKCTRL, inDAC1064(minfo, M1064_XPIXCLKCTRL) | M1064_XPIXCLKCTRL_DIS |
600 M1064_XPIXCLKCTRL_PLL_UP); 619 M1064_XPIXCLKCTRL_PLL_UP);
601 switch (flags & 3) { 620 switch (flags & 3) {
602 case 0: reg = M1064_XPIXPLLAM; break; 621 case 0: reg = M1064_XPIXPLLAM; break;
603 case 1: reg = M1064_XPIXPLLBM; break; 622 case 1: reg = M1064_XPIXPLLBM; break;
604 default: reg = M1064_XPIXPLLCM; break; 623 default: reg = M1064_XPIXPLLCM; break;
605 } 624 }
606 outDAC1064(PMINFO reg++, m); 625 outDAC1064(minfo, reg++, m);
607 outDAC1064(PMINFO reg++, n); 626 outDAC1064(minfo, reg++, n);
608 outDAC1064(PMINFO reg, p); 627 outDAC1064(minfo, reg, p);
609 selClk = mga_inb(M_MISC_REG_READ) & ~0xC; 628 selClk = mga_inb(M_MISC_REG_READ) & ~0xC;
610 /* there should be flags & 0x03 & case 0/1/else */ 629 /* there should be flags & 0x03 & case 0/1/else */
611 /* and we should first select source and after that we should wait for PLL */ 630 /* and we should first select source and after that we should wait for PLL */
@@ -617,34 +636,37 @@ static void MGAG100_progPixClock(CPMINFO int flags, int m, int n, int p) {
617 } 636 }
618 mga_outb(M_MISC_REG, selClk); 637 mga_outb(M_MISC_REG, selClk);
619 for (clk = 500000; clk; clk--) { 638 for (clk = 500000; clk; clk--) {
620 if (inDAC1064(PMINFO M1064_XPIXPLLSTAT) & 0x40) 639 if (inDAC1064(minfo, M1064_XPIXPLLSTAT) & 0x40)
621 break; 640 break;
622 udelay(10); 641 udelay(10);
623 }; 642 };
624 if (!clk) 643 if (!clk)
625 printk(KERN_ERR "matroxfb: Pixel PLL%c not locked after usual time\n", (reg-M1064_XPIXPLLAM-2)/4 + 'A'); 644 printk(KERN_ERR "matroxfb: Pixel PLL%c not locked after usual time\n", (reg-M1064_XPIXPLLAM-2)/4 + 'A');
626 selClk = inDAC1064(PMINFO M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_SRC_MASK; 645 selClk = inDAC1064(minfo, M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_SRC_MASK;
627 switch (flags & 0x0C) { 646 switch (flags & 0x0C) {
628 case 0x00: selClk |= M1064_XPIXCLKCTRL_SRC_PCI; break; 647 case 0x00: selClk |= M1064_XPIXCLKCTRL_SRC_PCI; break;
629 case 0x04: selClk |= M1064_XPIXCLKCTRL_SRC_PLL; break; 648 case 0x04: selClk |= M1064_XPIXCLKCTRL_SRC_PLL; break;
630 default: selClk |= M1064_XPIXCLKCTRL_SRC_EXT; break; 649 default: selClk |= M1064_XPIXCLKCTRL_SRC_EXT; break;
631 } 650 }
632 outDAC1064(PMINFO M1064_XPIXCLKCTRL, selClk); 651 outDAC1064(minfo, M1064_XPIXCLKCTRL, selClk);
633 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_DIS); 652 outDAC1064(minfo, M1064_XPIXCLKCTRL, inDAC1064(minfo, M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_DIS);
634} 653}
635 654
636static void MGAG100_setPixClock(CPMINFO int flags, int freq) { 655static void MGAG100_setPixClock(const struct matrox_fb_info *minfo, int flags,
656 int freq)
657{
637 unsigned int m, n, p; 658 unsigned int m, n, p;
638 659
639 DBG(__func__) 660 DBG(__func__)
640 661
641 DAC1064_calcclock(PMINFO freq, minfo->max_pixel_clock, &m, &n, &p); 662 DAC1064_calcclock(minfo, freq, minfo->max_pixel_clock, &m, &n, &p);
642 MGAG100_progPixClock(PMINFO flags, m, n, p); 663 MGAG100_progPixClock(minfo, flags, m, n, p);
643} 664}
644#endif 665#endif
645 666
646#ifdef CONFIG_FB_MATROX_MYSTIQUE 667#ifdef CONFIG_FB_MATROX_MYSTIQUE
647static int MGA1064_preinit(WPMINFO2) { 668static int MGA1064_preinit(struct matrox_fb_info *minfo)
669{
648 static const int vxres_mystique[] = { 512, 640, 768, 800, 832, 960, 670 static const int vxres_mystique[] = { 512, 640, 768, 800, 832, 960,
649 1024, 1152, 1280, 1600, 1664, 1920, 671 1024, 1152, 1280, 1600, 1664, 1920,
650 2048, 0}; 672 2048, 0};
@@ -681,16 +703,18 @@ static int MGA1064_preinit(WPMINFO2) {
681 return 0; 703 return 0;
682} 704}
683 705
684static void MGA1064_reset(WPMINFO2) { 706static void MGA1064_reset(struct matrox_fb_info *minfo)
707{
685 708
686 DBG(__func__); 709 DBG(__func__);
687 710
688 MGA1064_ramdac_init(PMINFO2); 711 MGA1064_ramdac_init(minfo);
689} 712}
690#endif 713#endif
691 714
692#ifdef CONFIG_FB_MATROX_G 715#ifdef CONFIG_FB_MATROX_G
693static void g450_mclk_init(WPMINFO2) { 716static void g450_mclk_init(struct matrox_fb_info *minfo)
717{
694 /* switch all clocks to PCI source */ 718 /* switch all clocks to PCI source */
695 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg | 4); 719 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg | 4);
696 pci_write_config_dword(minfo->pcidev, PCI_OPTION3_REG, minfo->values.reg.opt3 & ~0x00300C03); 720 pci_write_config_dword(minfo->pcidev, PCI_OPTION3_REG, minfo->values.reg.opt3 & ~0x00300C03);
@@ -699,17 +723,17 @@ static void g450_mclk_init(WPMINFO2) {
699 if (((minfo->values.reg.opt3 & 0x000003) == 0x000003) || 723 if (((minfo->values.reg.opt3 & 0x000003) == 0x000003) ||
700 ((minfo->values.reg.opt3 & 0x000C00) == 0x000C00) || 724 ((minfo->values.reg.opt3 & 0x000C00) == 0x000C00) ||
701 ((minfo->values.reg.opt3 & 0x300000) == 0x300000)) { 725 ((minfo->values.reg.opt3 & 0x300000) == 0x300000)) {
702 matroxfb_g450_setclk(PMINFO minfo->values.pll.video, M_VIDEO_PLL); 726 matroxfb_g450_setclk(minfo, minfo->values.pll.video, M_VIDEO_PLL);
703 } else { 727 } else {
704 unsigned long flags; 728 unsigned long flags;
705 unsigned int pwr; 729 unsigned int pwr;
706 730
707 matroxfb_DAC_lock_irqsave(flags); 731 matroxfb_DAC_lock_irqsave(flags);
708 pwr = inDAC1064(PMINFO M1064_XPWRCTRL) & ~0x02; 732 pwr = inDAC1064(minfo, M1064_XPWRCTRL) & ~0x02;
709 outDAC1064(PMINFO M1064_XPWRCTRL, pwr); 733 outDAC1064(minfo, M1064_XPWRCTRL, pwr);
710 matroxfb_DAC_unlock_irqrestore(flags); 734 matroxfb_DAC_unlock_irqrestore(flags);
711 } 735 }
712 matroxfb_g450_setclk(PMINFO minfo->values.pll.system, M_SYSTEM_PLL); 736 matroxfb_g450_setclk(minfo, minfo->values.pll.system, M_SYSTEM_PLL);
713 737
714 /* switch clocks to their real PLL source(s) */ 738 /* switch clocks to their real PLL source(s) */
715 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg | 4); 739 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg | 4);
@@ -718,7 +742,8 @@ static void g450_mclk_init(WPMINFO2) {
718 742
719} 743}
720 744
721static void g450_memory_init(WPMINFO2) { 745static void g450_memory_init(struct matrox_fb_info *minfo)
746{
722 /* disable memory refresh */ 747 /* disable memory refresh */
723 minfo->hw.MXoptionReg &= ~0x001F8000; 748 minfo->hw.MXoptionReg &= ~0x001F8000;
724 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg); 749 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg);
@@ -760,7 +785,8 @@ static void g450_memory_init(WPMINFO2) {
760 785
761} 786}
762 787
763static void g450_preinit(WPMINFO2) { 788static void g450_preinit(struct matrox_fb_info *minfo)
789{
764 u_int32_t c2ctl; 790 u_int32_t c2ctl;
765 u_int8_t curctl; 791 u_int8_t curctl;
766 u_int8_t c1ctl; 792 u_int8_t c1ctl;
@@ -783,24 +809,24 @@ static void g450_preinit(WPMINFO2) {
783 c2ctl = mga_inl(M_C2CTL); 809 c2ctl = mga_inl(M_C2CTL);
784 mga_outl(M_C2CTL, c2ctl & ~1); 810 mga_outl(M_C2CTL, c2ctl & ~1);
785 /* stop cursor */ 811 /* stop cursor */
786 curctl = inDAC1064(PMINFO M1064_XCURCTRL); 812 curctl = inDAC1064(minfo, M1064_XCURCTRL);
787 outDAC1064(PMINFO M1064_XCURCTRL, 0); 813 outDAC1064(minfo, M1064_XCURCTRL, 0);
788 /* stop crtc1 */ 814 /* stop crtc1 */
789 c1ctl = mga_readr(M_SEQ_INDEX, 1); 815 c1ctl = mga_readr(M_SEQ_INDEX, 1);
790 mga_setr(M_SEQ_INDEX, 1, c1ctl | 0x20); 816 mga_setr(M_SEQ_INDEX, 1, c1ctl | 0x20);
791 817
792 g450_mclk_init(PMINFO2); 818 g450_mclk_init(minfo);
793 g450_memory_init(PMINFO2); 819 g450_memory_init(minfo);
794 820
795 /* set legacy VGA clock sources for DOSEmu or VMware... */ 821 /* set legacy VGA clock sources for DOSEmu or VMware... */
796 matroxfb_g450_setclk(PMINFO 25175, M_PIXEL_PLL_A); 822 matroxfb_g450_setclk(minfo, 25175, M_PIXEL_PLL_A);
797 matroxfb_g450_setclk(PMINFO 28322, M_PIXEL_PLL_B); 823 matroxfb_g450_setclk(minfo, 28322, M_PIXEL_PLL_B);
798 824
799 /* restore crtc1 */ 825 /* restore crtc1 */
800 mga_setr(M_SEQ_INDEX, 1, c1ctl); 826 mga_setr(M_SEQ_INDEX, 1, c1ctl);
801 827
802 /* restore cursor */ 828 /* restore cursor */
803 outDAC1064(PMINFO M1064_XCURCTRL, curctl); 829 outDAC1064(minfo, M1064_XCURCTRL, curctl);
804 830
805 /* restore crtc2 */ 831 /* restore crtc2 */
806 mga_outl(M_C2CTL, c2ctl); 832 mga_outl(M_C2CTL, c2ctl);
@@ -808,7 +834,8 @@ static void g450_preinit(WPMINFO2) {
808 return; 834 return;
809} 835}
810 836
811static int MGAG100_preinit(WPMINFO2) { 837static int MGAG100_preinit(struct matrox_fb_info *minfo)
838{
812 static const int vxres_g100[] = { 512, 640, 768, 800, 832, 960, 839 static const int vxres_g100[] = { 512, 640, 768, 800, 832, 960,
813 1024, 1152, 1280, 1600, 1664, 1920, 840 1024, 1152, 1280, 1600, 1664, 1920,
814 2048, 0}; 841 2048, 0};
@@ -862,7 +889,7 @@ static int MGAG100_preinit(WPMINFO2) {
862 if (minfo->devflags.noinit) 889 if (minfo->devflags.noinit)
863 return 0; 890 return 0;
864 if (minfo->devflags.g450dac) { 891 if (minfo->devflags.g450dac) {
865 g450_preinit(PMINFO2); 892 g450_preinit(minfo);
866 return 0; 893 return 0;
867 } 894 }
868 hw->MXoptionReg &= 0xC0000100; 895 hw->MXoptionReg &= 0xC0000100;
@@ -874,7 +901,7 @@ static int MGAG100_preinit(WPMINFO2) {
874 if (minfo->devflags.nopciretry) 901 if (minfo->devflags.nopciretry)
875 hw->MXoptionReg |= 0x20000000; 902 hw->MXoptionReg |= 0x20000000;
876 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, hw->MXoptionReg); 903 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, hw->MXoptionReg);
877 DAC1064_setmclk(PMINFO DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PCI, 133333); 904 DAC1064_setmclk(minfo, DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PCI, 133333);
878 905
879 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG100) { 906 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG100) {
880 pci_read_config_dword(minfo->pcidev, PCI_OPTION2_REG, &reg50); 907 pci_read_config_dword(minfo->pcidev, PCI_OPTION2_REG, &reg50);
@@ -952,7 +979,8 @@ static int MGAG100_preinit(WPMINFO2) {
952 return 0; 979 return 0;
953} 980}
954 981
955static void MGAG100_reset(WPMINFO2) { 982static void MGAG100_reset(struct matrox_fb_info *minfo)
983{
956 u_int8_t b; 984 u_int8_t b;
957 struct matrox_hw_state *hw = &minfo->hw; 985 struct matrox_hw_state *hw = &minfo->hw;
958 986
@@ -981,35 +1009,36 @@ static void MGAG100_reset(WPMINFO2) {
981 } 1009 }
982 if (minfo->devflags.g450dac) { 1010 if (minfo->devflags.g450dac) {
983 /* either leave MCLK as is... or they were set in preinit */ 1011 /* either leave MCLK as is... or they were set in preinit */
984 hw->DACclk[3] = inDAC1064(PMINFO DAC1064_XSYSPLLM); 1012 hw->DACclk[3] = inDAC1064(minfo, DAC1064_XSYSPLLM);
985 hw->DACclk[4] = inDAC1064(PMINFO DAC1064_XSYSPLLN); 1013 hw->DACclk[4] = inDAC1064(minfo, DAC1064_XSYSPLLN);
986 hw->DACclk[5] = inDAC1064(PMINFO DAC1064_XSYSPLLP); 1014 hw->DACclk[5] = inDAC1064(minfo, DAC1064_XSYSPLLP);
987 } else { 1015 } else {
988 DAC1064_setmclk(PMINFO DAC1064_OPT_RESERVED | DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV1 | DAC1064_OPT_SCLK_PLL, 133333); 1016 DAC1064_setmclk(minfo, DAC1064_OPT_RESERVED | DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV1 | DAC1064_OPT_SCLK_PLL, 133333);
989 } 1017 }
990 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) { 1018 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) {
991 if (minfo->devflags.dfp_type == -1) { 1019 if (minfo->devflags.dfp_type == -1) {
992 minfo->devflags.dfp_type = inDAC1064(PMINFO 0x1F); 1020 minfo->devflags.dfp_type = inDAC1064(minfo, 0x1F);
993 } 1021 }
994 } 1022 }
995 if (minfo->devflags.noinit) 1023 if (minfo->devflags.noinit)
996 return; 1024 return;
997 if (minfo->devflags.g450dac) { 1025 if (minfo->devflags.g450dac) {
998 } else { 1026 } else {
999 MGAG100_setPixClock(PMINFO 4, 25175); 1027 MGAG100_setPixClock(minfo, 4, 25175);
1000 MGAG100_setPixClock(PMINFO 5, 28322); 1028 MGAG100_setPixClock(minfo, 5, 28322);
1001 if (x7AF4 & 0x10) { 1029 if (x7AF4 & 0x10) {
1002 b = inDAC1064(PMINFO M1064_XGENIODATA) & ~1; 1030 b = inDAC1064(minfo, M1064_XGENIODATA) & ~1;
1003 outDAC1064(PMINFO M1064_XGENIODATA, b); 1031 outDAC1064(minfo, M1064_XGENIODATA, b);
1004 b = inDAC1064(PMINFO M1064_XGENIOCTRL) | 1; 1032 b = inDAC1064(minfo, M1064_XGENIOCTRL) | 1;
1005 outDAC1064(PMINFO M1064_XGENIOCTRL, b); 1033 outDAC1064(minfo, M1064_XGENIOCTRL, b);
1006 } 1034 }
1007 } 1035 }
1008} 1036}
1009#endif 1037#endif
1010 1038
1011#ifdef CONFIG_FB_MATROX_MYSTIQUE 1039#ifdef CONFIG_FB_MATROX_MYSTIQUE
1012static void MGA1064_restore(WPMINFO2) { 1040static void MGA1064_restore(struct matrox_fb_info *minfo)
1041{
1013 int i; 1042 int i;
1014 struct matrox_hw_state *hw = &minfo->hw; 1043 struct matrox_hw_state *hw = &minfo->hw;
1015 1044
@@ -1025,17 +1054,18 @@ static void MGA1064_restore(WPMINFO2) {
1025 1054
1026 CRITEND 1055 CRITEND
1027 1056
1028 DAC1064_restore_1(PMINFO2); 1057 DAC1064_restore_1(minfo);
1029 matroxfb_vgaHWrestore(PMINFO2); 1058 matroxfb_vgaHWrestore(minfo);
1030 minfo->crtc1.panpos = -1; 1059 minfo->crtc1.panpos = -1;
1031 for (i = 0; i < 6; i++) 1060 for (i = 0; i < 6; i++)
1032 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]); 1061 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]);
1033 DAC1064_restore_2(PMINFO2); 1062 DAC1064_restore_2(minfo);
1034} 1063}
1035#endif 1064#endif
1036 1065
1037#ifdef CONFIG_FB_MATROX_G 1066#ifdef CONFIG_FB_MATROX_G
1038static void MGAG100_restore(WPMINFO2) { 1067static void MGAG100_restore(struct matrox_fb_info *minfo)
1068{
1039 int i; 1069 int i;
1040 struct matrox_hw_state *hw = &minfo->hw; 1070 struct matrox_hw_state *hw = &minfo->hw;
1041 1071
@@ -1048,8 +1078,8 @@ static void MGAG100_restore(WPMINFO2) {
1048 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, hw->MXoptionReg); 1078 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, hw->MXoptionReg);
1049 CRITEND 1079 CRITEND
1050 1080
1051 DAC1064_restore_1(PMINFO2); 1081 DAC1064_restore_1(minfo);
1052 matroxfb_vgaHWrestore(PMINFO2); 1082 matroxfb_vgaHWrestore(minfo);
1053#ifdef CONFIG_FB_MATROX_32MB 1083#ifdef CONFIG_FB_MATROX_32MB
1054 if (minfo->devflags.support32MB) 1084 if (minfo->devflags.support32MB)
1055 mga_setr(M_EXTVGA_INDEX, 8, hw->CRTCEXT[8]); 1085 mga_setr(M_EXTVGA_INDEX, 8, hw->CRTCEXT[8]);
@@ -1057,7 +1087,7 @@ static void MGAG100_restore(WPMINFO2) {
1057 minfo->crtc1.panpos = -1; 1087 minfo->crtc1.panpos = -1;
1058 for (i = 0; i < 6; i++) 1088 for (i = 0; i < 6; i++)
1059 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]); 1089 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]);
1060 DAC1064_restore_2(PMINFO2); 1090 DAC1064_restore_2(minfo);
1061} 1091}
1062#endif 1092#endif
1063 1093