3 * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200, G400 and G450.
5 * (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
7 * Portions Copyright (c) 2001 Matrox Graphics Inc.
9 * Version: 1.65 2002/08/14
11 * See matroxfb_base.c for contributors.
15 /* make checkconfig does not walk through include tree :-( */
16 #include <linux/config.h>
18 #include "matroxfb_DAC1064.h"
19 #include "matroxfb_misc.h"
20 #include "matroxfb_accel.h"
22 #include <linux/matroxfb.h>
25 #define outDAC1064 matroxfb_DAC_out
26 #define inDAC1064 matroxfb_DAC_in
28 #define DAC1064_OPT_SCLK_PCI 0x00
29 #define DAC1064_OPT_SCLK_PLL 0x01
30 #define DAC1064_OPT_SCLK_EXT 0x02
31 #define DAC1064_OPT_SCLK_MASK 0x03
32 #define DAC1064_OPT_GDIV1 0x04 /* maybe it is GDIV2 on G100 ?! */
33 #define DAC1064_OPT_GDIV3 0x00
34 #define DAC1064_OPT_MDIV1 0x08
35 #define DAC1064_OPT_MDIV2 0x00
36 #define DAC1064_OPT_RESERVED 0x10
38 static void DAC1064_calcclock(CPMINFO unsigned int freq, unsigned int fmax, unsigned int* in, unsigned int* feed, unsigned int* post) {
44 /* only for devices older than G450 */
46 fvco = PLL_calcclock(PMINFO freq, fmax, in, feed, &p);
51 else if (fvco <= 140000)
53 else if (fvco <= 180000)
60 /* they must be in POS order */
61 static const unsigned char MGA1064_DAC_regs[] = {
62 M1064_XCURADDL, M1064_XCURADDH, M1064_XCURCTRL,
63 M1064_XCURCOL0RED, M1064_XCURCOL0GREEN, M1064_XCURCOL0BLUE,
64 M1064_XCURCOL1RED, M1064_XCURCOL1GREEN, M1064_XCURCOL1BLUE,
65 M1064_XCURCOL2RED, M1064_XCURCOL2GREEN, M1064_XCURCOL2BLUE,
66 DAC1064_XVREFCTRL, M1064_XMULCTRL, M1064_XPIXCLKCTRL, M1064_XGENCTRL,
68 M1064_XGENIOCTRL, M1064_XGENIODATA, M1064_XZOOMCTRL, M1064_XSENSETEST,
70 M1064_XCOLKEYMASKL, M1064_XCOLKEYMASKH, M1064_XCOLKEYL, M1064_XCOLKEYH };
72 static const unsigned char MGA1064_DAC[] = {
73 0x00, 0x00, M1064_XCURCTRL_DIS,
74 0x00, 0x00, 0x00, /* black */
75 0xFF, 0xFF, 0xFF, /* white */
76 0xFF, 0x00, 0x00, /* red */
78 M1064_XPIXCLKCTRL_PLL_UP | M1064_XPIXCLKCTRL_EN | M1064_XPIXCLKCTRL_SRC_PLL,
79 M1064_XGENCTRL_VS_0 | M1064_XGENCTRL_ALPHA_DIS | M1064_XGENCTRL_BLACK_0IRE | M1064_XGENCTRL_NO_SYNC_ON_GREEN,
80 M1064_XMISCCTRL_DAC_8BIT,
81 0x00, 0x00, M1064_XZOOMCTRL_1, M1064_XSENSETEST_BCOMP | M1064_XSENSETEST_GCOMP | M1064_XSENSETEST_RCOMP | M1064_XSENSETEST_PDOWN,
83 0x00, 0x00, 0xFF, 0xFF};
85 static void DAC1064_setpclk(WPMINFO unsigned long fout) {
90 DAC1064_calcclock(PMINFO fout, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p);
91 ACCESS_FBINFO(hw).DACclk[0] = m;
92 ACCESS_FBINFO(hw).DACclk[1] = n;
93 ACCESS_FBINFO(hw).DACclk[2] = p;
96 static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) {
98 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
102 if (ACCESS_FBINFO(devflags.noinit)) {
103 /* read MCLK and give up... */
104 hw->DACclk[3] = inDAC1064(PMINFO DAC1064_XSYSPLLM);
105 hw->DACclk[4] = inDAC1064(PMINFO DAC1064_XSYSPLLN);
106 hw->DACclk[5] = inDAC1064(PMINFO DAC1064_XSYSPLLP);
109 mx = hw->MXoptionReg | 0x00000004;
110 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mx);
112 if (oscinfo & DAC1064_OPT_GDIV1)
114 if (oscinfo & DAC1064_OPT_MDIV1)
116 if (oscinfo & DAC1064_OPT_RESERVED)
118 if ((oscinfo & DAC1064_OPT_SCLK_MASK) == DAC1064_OPT_SCLK_PLL) {
119 /* select PCI clock until we have setup oscilator... */
121 unsigned int m, n, p;
123 /* powerup system PLL, select PCI clock */
125 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mx);
127 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mx);
129 /* !!! you must not access device if MCLK is not running !!!
130 Doing so cause immediate PCI lockup :-( Maybe they should
131 generate ABORT or I/O (parity...) error and Linux should
132 recover from this... (kill driver/process). But world is not
134 /* (bit 2 of PCI_OPTION_REG must be 0... and bits 0,1 must not
135 select PLL... because of PLL can be stopped at this time) */
136 DAC1064_calcclock(PMINFO fmem, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p);
137 outDAC1064(PMINFO DAC1064_XSYSPLLM, hw->DACclk[3] = m);
138 outDAC1064(PMINFO DAC1064_XSYSPLLN, hw->DACclk[4] = n);
139 outDAC1064(PMINFO DAC1064_XSYSPLLP, hw->DACclk[5] = p);
140 for (clk = 65536; clk; --clk) {
141 if (inDAC1064(PMINFO DAC1064_XSYSPLLSTAT) & 0x40)
145 printk(KERN_ERR "matroxfb: aiee, SYSPLL not locked\n");
149 /* select specified system clock source */
150 mx |= oscinfo & DAC1064_OPT_SCLK_MASK;
152 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mx);
154 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, mx);
155 hw->MXoptionReg = mx;
158 #ifdef CONFIG_FB_MATROX_G
159 static void g450_set_plls(WPMINFO2) {
162 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
166 c2_ctl = hw->crtc2.ctl & ~0x4007; /* Clear PLL + enable for CRTC2 */
167 c2_ctl |= 0x0001; /* Enable CRTC2 */
168 hw->DACreg[POS1064_XPWRCTRL] &= ~0x02; /* Stop VIDEO PLL */
169 pixelmnp = ACCESS_FBINFO(crtc1).mnp;
170 videomnp = ACCESS_FBINFO(crtc2).mnp;
172 c2_ctl &= ~0x0001; /* Disable CRTC2 */
173 hw->DACreg[POS1064_XPWRCTRL] &= ~0x10; /* Powerdown CRTC2 */
174 } else if (ACCESS_FBINFO(crtc2).pixclock == ACCESS_FBINFO(features).pll.ref_freq) {
175 c2_ctl |= 0x4002; /* Use reference directly */
176 } else if (videomnp == pixelmnp) {
177 c2_ctl |= 0x0004; /* Use pixel PLL */
179 if (0 == ((videomnp ^ pixelmnp) & 0xFFFFFF00)) {
180 /* PIXEL and VIDEO PLL must not use same frequency. We modify N
181 of PIXEL PLL in such case because of VIDEO PLL may be source
182 of TVO clocks, and chroma subcarrier is derived from its
184 pixelmnp += 0x000100;
186 c2_ctl |= 0x0006; /* Use video PLL */
187 hw->DACreg[POS1064_XPWRCTRL] |= 0x02;
189 outDAC1064(PMINFO M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]);
190 matroxfb_g450_setpll_cond(PMINFO videomnp, M_VIDEO_PLL);
193 hw->DACreg[POS1064_XPIXCLKCTRL] &= ~M1064_XPIXCLKCTRL_PLL_UP;
195 hw->DACreg[POS1064_XPIXCLKCTRL] |= M1064_XPIXCLKCTRL_PLL_UP;
197 outDAC1064(PMINFO M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]);
198 matroxfb_g450_setpll_cond(PMINFO pixelmnp, M_PIXEL_PLL_C);
200 if (c2_ctl != hw->crtc2.ctl) {
201 hw->crtc2.ctl = c2_ctl;
202 mga_outl(0x3C10, c2_ctl);
205 pxc = ACCESS_FBINFO(crtc1).pixclock;
206 if (pxc == 0 || ACCESS_FBINFO(outputs[2]).src == MATROXFB_SRC_CRTC2) {
207 pxc = ACCESS_FBINFO(crtc2).pixclock;
209 if (ACCESS_FBINFO(chip) == MGA_G550) {
211 hw->DACreg[POS1064_XPANMODE] = 0x00; /* 0-50 */
212 } else if (pxc < 55000) {
213 hw->DACreg[POS1064_XPANMODE] = 0x08; /* 34-62 */
214 } else if (pxc < 70000) {
215 hw->DACreg[POS1064_XPANMODE] = 0x10; /* 42-78 */
216 } else if (pxc < 85000) {
217 hw->DACreg[POS1064_XPANMODE] = 0x18; /* 62-92 */
218 } else if (pxc < 100000) {
219 hw->DACreg[POS1064_XPANMODE] = 0x20; /* 74-108 */
220 } else if (pxc < 115000) {
221 hw->DACreg[POS1064_XPANMODE] = 0x28; /* 94-122 */
222 } else if (pxc < 125000) {
223 hw->DACreg[POS1064_XPANMODE] = 0x30; /* 108-132 */
225 hw->DACreg[POS1064_XPANMODE] = 0x38; /* 120-168 */
230 hw->DACreg[POS1064_XPANMODE] = 0x00; /* 0-54 */
231 } else if (pxc < 65000) {
232 hw->DACreg[POS1064_XPANMODE] = 0x08; /* 38-70 */
233 } else if (pxc < 85000) {
234 hw->DACreg[POS1064_XPANMODE] = 0x10; /* 56-96 */
235 } else if (pxc < 105000) {
236 hw->DACreg[POS1064_XPANMODE] = 0x18; /* 80-114 */
237 } else if (pxc < 135000) {
238 hw->DACreg[POS1064_XPANMODE] = 0x20; /* 102-144 */
239 } else if (pxc < 160000) {
240 hw->DACreg[POS1064_XPANMODE] = 0x28; /* 132-166 */
241 } else if (pxc < 175000) {
242 hw->DACreg[POS1064_XPANMODE] = 0x30; /* 154-182 */
244 hw->DACreg[POS1064_XPANMODE] = 0x38; /* 170-204 */
250 void DAC1064_global_init(WPMINFO2) {
251 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
253 hw->DACreg[POS1064_XMISCCTRL] &= M1064_XMISCCTRL_DAC_WIDTHMASK;
254 hw->DACreg[POS1064_XMISCCTRL] |= M1064_XMISCCTRL_LUT_EN;
255 hw->DACreg[POS1064_XPIXCLKCTRL] = M1064_XPIXCLKCTRL_PLL_UP | M1064_XPIXCLKCTRL_EN | M1064_XPIXCLKCTRL_SRC_PLL;
256 #ifdef CONFIG_FB_MATROX_G
257 if (ACCESS_FBINFO(devflags.g450dac)) {
258 hw->DACreg[POS1064_XPWRCTRL] = 0x1F; /* powerup everything */
259 hw->DACreg[POS1064_XOUTPUTCONN] = 0x00; /* disable outputs */
260 hw->DACreg[POS1064_XMISCCTRL] |= M1064_XMISCCTRL_DAC_EN;
261 switch (ACCESS_FBINFO(outputs[0]).src) {
262 case MATROXFB_SRC_CRTC1:
263 case MATROXFB_SRC_CRTC2:
264 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x01; /* enable output; CRTC1/2 selection is in CRTC2 ctl */
266 case MATROXFB_SRC_NONE:
267 hw->DACreg[POS1064_XMISCCTRL] &= ~M1064_XMISCCTRL_DAC_EN;
270 switch (ACCESS_FBINFO(outputs[1]).src) {
271 case MATROXFB_SRC_CRTC1:
272 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x04;
274 case MATROXFB_SRC_CRTC2:
275 if (ACCESS_FBINFO(outputs[1]).mode == MATROXFB_OUTPUT_MODE_MONITOR) {
276 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x08;
278 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x0C;
281 case MATROXFB_SRC_NONE:
282 hw->DACreg[POS1064_XPWRCTRL] &= ~0x01; /* Poweroff DAC2 */
285 switch (ACCESS_FBINFO(outputs[2]).src) {
286 case MATROXFB_SRC_CRTC1:
287 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x20;
289 case MATROXFB_SRC_CRTC2:
290 hw->DACreg[POS1064_XOUTPUTCONN] |= 0x40;
292 case MATROXFB_SRC_NONE:
294 /* HELP! If we boot without DFP connected to DVI, we can
295 poweroff TMDS. But if we boot with DFP connected,
296 TMDS generated clocks are used instead of ALL pixclocks
297 available... If someone knows which register
298 handles it, please reveal this secret to me... */
299 hw->DACreg[POS1064_XPWRCTRL] &= ~0x04; /* Poweroff TMDS */
303 /* Now set timming related variables... */
304 g450_set_plls(PMINFO2);
308 if (ACCESS_FBINFO(outputs[1]).src == MATROXFB_SRC_CRTC1) {
309 hw->DACreg[POS1064_XPIXCLKCTRL] = M1064_XPIXCLKCTRL_PLL_UP | M1064_XPIXCLKCTRL_EN | M1064_XPIXCLKCTRL_SRC_EXT;
310 hw->DACreg[POS1064_XMISCCTRL] |= GX00_XMISCCTRL_MFC_MAFC | G400_XMISCCTRL_VDO_MAFC12;
311 } else if (ACCESS_FBINFO(outputs[1]).src == MATROXFB_SRC_CRTC2) {
312 hw->DACreg[POS1064_XMISCCTRL] |= GX00_XMISCCTRL_MFC_MAFC | G400_XMISCCTRL_VDO_C2_MAFC12;
313 } else if (ACCESS_FBINFO(outputs[2]).src == MATROXFB_SRC_CRTC1)
314 hw->DACreg[POS1064_XMISCCTRL] |= GX00_XMISCCTRL_MFC_PANELLINK | G400_XMISCCTRL_VDO_MAFC12;
316 hw->DACreg[POS1064_XMISCCTRL] |= GX00_XMISCCTRL_MFC_DIS;
318 if (ACCESS_FBINFO(outputs[0]).src != MATROXFB_SRC_NONE)
319 hw->DACreg[POS1064_XMISCCTRL] |= M1064_XMISCCTRL_DAC_EN;
323 void DAC1064_global_restore(WPMINFO2) {
324 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
326 outDAC1064(PMINFO M1064_XPIXCLKCTRL, hw->DACreg[POS1064_XPIXCLKCTRL]);
327 outDAC1064(PMINFO M1064_XMISCCTRL, hw->DACreg[POS1064_XMISCCTRL]);
328 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG400) {
329 outDAC1064(PMINFO 0x20, 0x04);
330 outDAC1064(PMINFO 0x1F, ACCESS_FBINFO(devflags.dfp_type));
331 if (ACCESS_FBINFO(devflags.g450dac)) {
332 outDAC1064(PMINFO M1064_XSYNCCTRL, 0xCC);
333 outDAC1064(PMINFO M1064_XPWRCTRL, hw->DACreg[POS1064_XPWRCTRL]);
334 outDAC1064(PMINFO M1064_XPANMODE, hw->DACreg[POS1064_XPANMODE]);
335 outDAC1064(PMINFO M1064_XOUTPUTCONN, hw->DACreg[POS1064_XOUTPUTCONN]);
340 static int DAC1064_init_1(WPMINFO struct my_timming* m) {
341 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
345 memcpy(hw->DACreg, MGA1064_DAC, sizeof(MGA1064_DAC_regs));
346 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
347 /* case 4: not supported by MGA1064 DAC */
349 hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_8BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
352 if (ACCESS_FBINFO(fbcon).var.green.length == 5)
353 hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_15BPP_1BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
355 hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_16BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
358 hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_24BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
361 hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_32BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
364 return 1; /* unsupported depth */
366 hw->DACreg[POS1064_XVREFCTRL] = ACCESS_FBINFO(features.DAC1064.xvrefctrl);
367 hw->DACreg[POS1064_XGENCTRL] &= ~M1064_XGENCTRL_SYNC_ON_GREEN_MASK;
368 hw->DACreg[POS1064_XGENCTRL] |= (m->sync & FB_SYNC_ON_GREEN)?M1064_XGENCTRL_SYNC_ON_GREEN:M1064_XGENCTRL_NO_SYNC_ON_GREEN;
369 hw->DACreg[POS1064_XCURADDL] = 0;
370 hw->DACreg[POS1064_XCURADDH] = 0;
372 DAC1064_global_init(PMINFO2);
376 static int DAC1064_init_2(WPMINFO struct my_timming* m) {
377 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
381 if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 16) { /* 256 entries */
384 for (i = 0; i < 256; i++) {
385 hw->DACpal[i * 3 + 0] = i;
386 hw->DACpal[i * 3 + 1] = i;
387 hw->DACpal[i * 3 + 2] = i;
389 } else if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 8) {
390 if (ACCESS_FBINFO(fbcon).var.green.length == 5) { /* 0..31, 128..159 */
393 for (i = 0; i < 32; i++) {
395 hw->DACpal[i * 3 + 0] = i << 3;
396 hw->DACpal[i * 3 + 1] = i << 3;
397 hw->DACpal[i * 3 + 2] = i << 3;
399 hw->DACpal[(i + 128) * 3 + 0] = i << 3;
400 hw->DACpal[(i + 128) * 3 + 1] = i << 3;
401 hw->DACpal[(i + 128) * 3 + 2] = i << 3;
406 for (i = 0; i < 64; i++) { /* 0..63 */
407 hw->DACpal[i * 3 + 0] = i << 3;
408 hw->DACpal[i * 3 + 1] = i << 2;
409 hw->DACpal[i * 3 + 2] = i << 3;
413 memset(hw->DACpal, 0, 768);
418 static void DAC1064_restore_1(WPMINFO2) {
419 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
427 if ((inDAC1064(PMINFO DAC1064_XSYSPLLM) != hw->DACclk[3]) ||
428 (inDAC1064(PMINFO DAC1064_XSYSPLLN) != hw->DACclk[4]) ||
429 (inDAC1064(PMINFO DAC1064_XSYSPLLP) != hw->DACclk[5])) {
430 outDAC1064(PMINFO DAC1064_XSYSPLLM, hw->DACclk[3]);
431 outDAC1064(PMINFO DAC1064_XSYSPLLN, hw->DACclk[4]);
432 outDAC1064(PMINFO DAC1064_XSYSPLLP, hw->DACclk[5]);
437 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) {
438 if ((i != POS1064_XPIXCLKCTRL) && (i != POS1064_XMISCCTRL))
439 outDAC1064(PMINFO MGA1064_DAC_regs[i], hw->DACreg[i]);
443 DAC1064_global_restore(PMINFO2);
448 static void DAC1064_restore_2(WPMINFO2) {
456 dprintk(KERN_DEBUG "DAC1064regs ");
457 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) {
458 dprintk("R%02X=%02X ", MGA1064_DAC_regs[i], ACCESS_FBINFO(hw).DACreg[i]);
459 if ((i & 0x7) == 0x7) dprintk("\n" KERN_DEBUG "continuing... ");
461 dprintk("\n" KERN_DEBUG "DAC1064clk ");
462 for (i = 0; i < 6; i++)
463 dprintk("C%02X=%02X ", i, ACCESS_FBINFO(hw).DACclk[i]);
468 static int m1064_compute(void* out, struct my_timming* m) {
469 #define minfo ((struct matrox_fb_info*)out)
475 DAC1064_setpclk(PMINFO m->pixclock);
479 for (i = 0; i < 3; i++)
480 outDAC1064(PMINFO M1064_XPIXPLLCM + i, ACCESS_FBINFO(hw).DACclk[i]);
481 for (tmout = 500000; tmout; tmout--) {
482 if (inDAC1064(PMINFO M1064_XPIXPLLSTAT) & 0x40)
490 printk(KERN_ERR "matroxfb: Pixel PLL not locked after 5 secs\n");
496 static struct matrox_altout m1064 = {
497 .name = "Primary output",
498 .compute = m1064_compute,
501 #ifdef CONFIG_FB_MATROX_G
502 static int g450_compute(void* out, struct my_timming* m) {
503 #define minfo ((struct matrox_fb_info*)out)
505 m->mnp = matroxfb_g450_setclk(PMINFO m->pixclock, (m->crtc == MATROXFB_SRC_CRTC1) ? M_PIXEL_PLL_C : M_VIDEO_PLL);
507 m->pixclock = g450_mnp2f(PMINFO m->mnp);
514 static struct matrox_altout g450out = {
515 .name = "Primary output",
516 .compute = g450_compute,
520 #endif /* NEED_DAC1064 */
522 #ifdef CONFIG_FB_MATROX_MYSTIQUE
523 static int MGA1064_init(WPMINFO struct my_timming* m) {
524 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
528 if (DAC1064_init_1(PMINFO m)) return 1;
529 if (matroxfb_vgaHWinit(PMINFO m)) return 1;
531 hw->MiscOutReg = 0xCB;
532 if (m->sync & FB_SYNC_HOR_HIGH_ACT)
533 hw->MiscOutReg &= ~0x40;
534 if (m->sync & FB_SYNC_VERT_HIGH_ACT)
535 hw->MiscOutReg &= ~0x80;
536 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
537 hw->CRTCEXT[3] |= 0x40;
539 if (DAC1064_init_2(PMINFO m)) return 1;
544 #ifdef CONFIG_FB_MATROX_G
545 static int MGAG100_init(WPMINFO struct my_timming* m) {
546 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
550 if (DAC1064_init_1(PMINFO m)) return 1;
551 hw->MXoptionReg &= ~0x2000;
552 if (matroxfb_vgaHWinit(PMINFO m)) return 1;
554 hw->MiscOutReg = 0xEF;
555 if (m->sync & FB_SYNC_HOR_HIGH_ACT)
556 hw->MiscOutReg &= ~0x40;
557 if (m->sync & FB_SYNC_VERT_HIGH_ACT)
558 hw->MiscOutReg &= ~0x80;
559 if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
560 hw->CRTCEXT[3] |= 0x40;
562 if (DAC1064_init_2(PMINFO m)) return 1;
567 #ifdef CONFIG_FB_MATROX_MYSTIQUE
568 static void MGA1064_ramdac_init(WPMINFO2) {
572 /* ACCESS_FBINFO(features.DAC1064.vco_freq_min) = 120000; */
573 ACCESS_FBINFO(features.pll.vco_freq_min) = 62000;
574 ACCESS_FBINFO(features.pll.ref_freq) = 14318;
575 ACCESS_FBINFO(features.pll.feed_div_min) = 100;
576 ACCESS_FBINFO(features.pll.feed_div_max) = 127;
577 ACCESS_FBINFO(features.pll.in_div_min) = 1;
578 ACCESS_FBINFO(features.pll.in_div_max) = 31;
579 ACCESS_FBINFO(features.pll.post_shift_max) = 3;
580 ACCESS_FBINFO(features.DAC1064.xvrefctrl) = DAC1064_XVREFCTRL_EXTERNAL;
581 /* maybe cmdline MCLK= ?, doc says gclk=44MHz, mclk=66MHz... it was 55/83 with old values */
582 DAC1064_setmclk(PMINFO DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PLL, 133333);
586 #ifdef CONFIG_FB_MATROX_G
588 static int x7AF4 = 0x10; /* flags, maybe 0x10 = SDRAM, 0x00 = SGRAM??? */
589 /* G100 wants 0x10, G200 SGRAM does not care... */
591 static int def50 = 0; /* reg50, & 0x0F, & 0x3000 (only 0x0000, 0x1000, 0x2000 (0x3000 disallowed and treated as 0) */
594 static void MGAG100_progPixClock(CPMINFO int flags, int m, int n, int p) {
601 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) | M1064_XPIXCLKCTRL_DIS |
602 M1064_XPIXCLKCTRL_PLL_UP);
604 case 0: reg = M1064_XPIXPLLAM; break;
605 case 1: reg = M1064_XPIXPLLBM; break;
606 default: reg = M1064_XPIXPLLCM; break;
608 outDAC1064(PMINFO reg++, m);
609 outDAC1064(PMINFO reg++, n);
610 outDAC1064(PMINFO reg, p);
611 selClk = mga_inb(M_MISC_REG_READ) & ~0xC;
612 /* there should be flags & 0x03 & case 0/1/else */
613 /* and we should first select source and after that we should wait for PLL */
614 /* and we are waiting for PLL with oscilator disabled... Is it right? */
615 switch (flags & 0x03) {
617 case 0x01: selClk |= 4; break;
618 default: selClk |= 0x0C; break;
620 mga_outb(M_MISC_REG, selClk);
621 for (clk = 500000; clk; clk--) {
622 if (inDAC1064(PMINFO M1064_XPIXPLLSTAT) & 0x40)
627 printk(KERN_ERR "matroxfb: Pixel PLL%c not locked after usual time\n", (reg-M1064_XPIXPLLAM-2)/4 + 'A');
628 selClk = inDAC1064(PMINFO M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_SRC_MASK;
629 switch (flags & 0x0C) {
630 case 0x00: selClk |= M1064_XPIXCLKCTRL_SRC_PCI; break;
631 case 0x04: selClk |= M1064_XPIXCLKCTRL_SRC_PLL; break;
632 default: selClk |= M1064_XPIXCLKCTRL_SRC_EXT; break;
634 outDAC1064(PMINFO M1064_XPIXCLKCTRL, selClk);
635 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) & ~M1064_XPIXCLKCTRL_DIS);
638 static void MGAG100_setPixClock(CPMINFO int flags, int freq) {
639 unsigned int m, n, p;
643 DAC1064_calcclock(PMINFO freq, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p);
644 MGAG100_progPixClock(PMINFO flags, m, n, p);
648 #ifdef CONFIG_FB_MATROX_MYSTIQUE
649 static int MGA1064_preinit(WPMINFO2) {
650 static const int vxres_mystique[] = { 512, 640, 768, 800, 832, 960,
651 1024, 1152, 1280, 1600, 1664, 1920,
653 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
657 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */
658 ACCESS_FBINFO(capable.text) = 1;
659 ACCESS_FBINFO(capable.vxres) = vxres_mystique;
661 ACCESS_FBINFO(outputs[0]).output = &m1064;
662 ACCESS_FBINFO(outputs[0]).src = ACCESS_FBINFO(outputs[0]).default_src;
663 ACCESS_FBINFO(outputs[0]).data = MINFO;
664 ACCESS_FBINFO(outputs[0]).mode = MATROXFB_OUTPUT_MODE_MONITOR;
666 if (ACCESS_FBINFO(devflags.noinit))
667 return 0; /* do not modify settings */
668 hw->MXoptionReg &= 0xC0000100;
669 hw->MXoptionReg |= 0x00094E20;
670 if (ACCESS_FBINFO(devflags.novga))
671 hw->MXoptionReg &= ~0x00000100;
672 if (ACCESS_FBINFO(devflags.nobios))
673 hw->MXoptionReg &= ~0x40000000;
674 if (ACCESS_FBINFO(devflags.nopciretry))
675 hw->MXoptionReg |= 0x20000000;
676 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
677 mga_setr(M_SEQ_INDEX, 0x01, 0x20);
678 mga_outl(M_CTLWTST, 0x00000000);
680 mga_outl(M_MACCESS, 0x00008000);
682 mga_outl(M_MACCESS, 0x0000C000);
686 static void MGA1064_reset(WPMINFO2) {
690 MGA1064_ramdac_init(PMINFO2);
694 #ifdef CONFIG_FB_MATROX_G
695 static void g450_mclk_init(WPMINFO2) {
696 /* switch all clocks to PCI source */
697 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg | 4);
698 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION3_REG, ACCESS_FBINFO(values).reg.opt3 & ~0x00300C03);
699 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
701 if (((ACCESS_FBINFO(values).reg.opt3 & 0x000003) == 0x000003) ||
702 ((ACCESS_FBINFO(values).reg.opt3 & 0x000C00) == 0x000C00) ||
703 ((ACCESS_FBINFO(values).reg.opt3 & 0x300000) == 0x300000)) {
704 matroxfb_g450_setclk(PMINFO ACCESS_FBINFO(values.pll.video), M_VIDEO_PLL);
709 matroxfb_DAC_lock_irqsave(flags);
710 pwr = inDAC1064(PMINFO M1064_XPWRCTRL) & ~0x02;
711 outDAC1064(PMINFO M1064_XPWRCTRL, pwr);
712 matroxfb_DAC_unlock_irqrestore(flags);
714 matroxfb_g450_setclk(PMINFO ACCESS_FBINFO(values.pll.system), M_SYSTEM_PLL);
716 /* switch clocks to their real PLL source(s) */
717 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg | 4);
718 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION3_REG, ACCESS_FBINFO(values).reg.opt3);
719 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
723 static void g450_memory_init(WPMINFO2) {
724 /* disable memory refresh */
725 ACCESS_FBINFO(hw).MXoptionReg &= ~0x001F8000;
726 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
728 /* set memory interface parameters */
729 ACCESS_FBINFO(hw).MXoptionReg &= ~0x00207E00;
730 ACCESS_FBINFO(hw).MXoptionReg |= 0x00207E00 & ACCESS_FBINFO(values).reg.opt;
731 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
732 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, ACCESS_FBINFO(values).reg.opt2);
734 mga_outl(M_CTLWTST, ACCESS_FBINFO(values).reg.mctlwtst);
736 /* first set up memory interface with disabled memory interface clocks */
737 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_MEMMISC_REG, ACCESS_FBINFO(values).reg.memmisc & ~0x80000000U);
738 mga_outl(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk);
739 mga_outl(M_MACCESS, ACCESS_FBINFO(values).reg.maccess);
740 /* start memory clocks */
741 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_MEMMISC_REG, ACCESS_FBINFO(values).reg.memmisc | 0x80000000U);
745 if (ACCESS_FBINFO(values).memory.ddr && (!ACCESS_FBINFO(values).memory.emrswen || !ACCESS_FBINFO(values).memory.dll)) {
746 mga_outl(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk & ~0x1000);
748 mga_outl(M_MACCESS, ACCESS_FBINFO(values).reg.maccess | 0x8000);
752 ACCESS_FBINFO(hw).MXoptionReg |= 0x001F8000 & ACCESS_FBINFO(values).reg.opt;
753 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
755 /* value is written to memory chips only if old != new */
756 mga_outl(M_PLNWT, 0);
757 mga_outl(M_PLNWT, ~0);
759 if (ACCESS_FBINFO(values).reg.mctlwtst != ACCESS_FBINFO(values).reg.mctlwtst_core) {
760 mga_outl(M_CTLWTST, ACCESS_FBINFO(values).reg.mctlwtst_core);
765 static void g450_preinit(WPMINFO2) {
770 /* ACCESS_FBINFO(hw).MXoptionReg = minfo->values.reg.opt; */
771 ACCESS_FBINFO(hw).MXoptionReg &= 0xC0000100;
772 ACCESS_FBINFO(hw).MXoptionReg |= 0x00000020;
773 if (ACCESS_FBINFO(devflags.novga))
774 ACCESS_FBINFO(hw).MXoptionReg &= ~0x00000100;
775 if (ACCESS_FBINFO(devflags.nobios))
776 ACCESS_FBINFO(hw).MXoptionReg &= ~0x40000000;
777 if (ACCESS_FBINFO(devflags.nopciretry))
778 ACCESS_FBINFO(hw).MXoptionReg |= 0x20000000;
779 ACCESS_FBINFO(hw).MXoptionReg |= ACCESS_FBINFO(values).reg.opt & 0x03400040;
780 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, ACCESS_FBINFO(hw).MXoptionReg);
782 /* Init system clocks */
785 c2ctl = mga_inl(M_C2CTL);
786 mga_outl(M_C2CTL, c2ctl & ~1);
788 curctl = inDAC1064(PMINFO M1064_XCURCTRL);
789 outDAC1064(PMINFO M1064_XCURCTRL, 0);
791 c1ctl = mga_readr(M_SEQ_INDEX, 1);
792 mga_setr(M_SEQ_INDEX, 1, c1ctl | 0x20);
794 g450_mclk_init(PMINFO2);
795 g450_memory_init(PMINFO2);
797 /* set legacy VGA clock sources for DOSEmu or VMware... */
798 matroxfb_g450_setclk(PMINFO 25175, M_PIXEL_PLL_A);
799 matroxfb_g450_setclk(PMINFO 28322, M_PIXEL_PLL_B);
802 mga_setr(M_SEQ_INDEX, 1, c1ctl);
805 outDAC1064(PMINFO M1064_XCURCTRL, curctl);
808 mga_outl(M_C2CTL, c2ctl);
813 static int MGAG100_preinit(WPMINFO2) {
814 static const int vxres_g100[] = { 512, 640, 768, 800, 832, 960,
815 1024, 1152, 1280, 1600, 1664, 1920,
817 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
826 /* there are some instabilities if in_div > 19 && vco < 61000 */
827 if (ACCESS_FBINFO(devflags.g450dac)) {
828 ACCESS_FBINFO(features.pll.vco_freq_min) = 130000; /* my sample: >118 */
830 ACCESS_FBINFO(features.pll.vco_freq_min) = 62000;
832 if (!ACCESS_FBINFO(features.pll.ref_freq)) {
833 ACCESS_FBINFO(features.pll.ref_freq) = 27000;
835 ACCESS_FBINFO(features.pll.feed_div_min) = 7;
836 ACCESS_FBINFO(features.pll.feed_div_max) = 127;
837 ACCESS_FBINFO(features.pll.in_div_min) = 1;
838 ACCESS_FBINFO(features.pll.in_div_max) = 31;
839 ACCESS_FBINFO(features.pll.post_shift_max) = 3;
840 ACCESS_FBINFO(features.DAC1064.xvrefctrl) = DAC1064_XVREFCTRL_G100_DEFAULT;
841 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */
842 ACCESS_FBINFO(capable.text) = 1;
843 ACCESS_FBINFO(capable.vxres) = vxres_g100;
844 ACCESS_FBINFO(capable.plnwt) = ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG100
845 ? ACCESS_FBINFO(devflags.sgram) : 1;
847 #ifdef CONFIG_FB_MATROX_G
848 if (ACCESS_FBINFO(devflags.g450dac)) {
849 ACCESS_FBINFO(outputs[0]).output = &g450out;
853 ACCESS_FBINFO(outputs[0]).output = &m1064;
855 ACCESS_FBINFO(outputs[0]).src = ACCESS_FBINFO(outputs[0]).default_src;
856 ACCESS_FBINFO(outputs[0]).data = MINFO;
857 ACCESS_FBINFO(outputs[0]).mode = MATROXFB_OUTPUT_MODE_MONITOR;
859 if (ACCESS_FBINFO(devflags.g450dac)) {
860 /* we must do this always, BIOS does not do it for us
861 and accelerator dies without it */
864 if (ACCESS_FBINFO(devflags.noinit))
866 if (ACCESS_FBINFO(devflags.g450dac)) {
867 g450_preinit(PMINFO2);
870 hw->MXoptionReg &= 0xC0000100;
871 hw->MXoptionReg |= 0x00000020;
872 if (ACCESS_FBINFO(devflags.novga))
873 hw->MXoptionReg &= ~0x00000100;
874 if (ACCESS_FBINFO(devflags.nobios))
875 hw->MXoptionReg &= ~0x40000000;
876 if (ACCESS_FBINFO(devflags.nopciretry))
877 hw->MXoptionReg |= 0x20000000;
878 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
879 DAC1064_setmclk(PMINFO DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PCI, 133333);
881 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG100) {
882 pci_read_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, ®50);
884 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, reg50);
886 hw->MXoptionReg |= 0x1080;
887 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
888 mga_outl(M_CTLWTST, ACCESS_FBINFO(values).reg.mctlwtst);
890 mga_outb(0x1C05, 0x00);
891 mga_outb(0x1C05, 0x80);
893 mga_outb(0x1C05, 0x40);
894 mga_outb(0x1C05, 0xC0);
898 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, reg50);
899 /* it should help with G100 */
900 mga_outb(M_GRAPHICS_INDEX, 6);
901 mga_outb(M_GRAPHICS_DATA, (mga_inb(M_GRAPHICS_DATA) & 3) | 4);
902 mga_setr(M_EXTVGA_INDEX, 0x03, 0x81);
903 mga_setr(M_EXTVGA_INDEX, 0x04, 0x00);
904 mga_writeb(ACCESS_FBINFO(video.vbase), 0x0000, 0xAA);
905 mga_writeb(ACCESS_FBINFO(video.vbase), 0x0800, 0x55);
906 mga_writeb(ACCESS_FBINFO(video.vbase), 0x4000, 0x55);
908 if (mga_readb(ACCESS_FBINFO(video.vbase), 0x0000) != 0xAA) {
909 hw->MXoptionReg &= ~0x1000;
912 hw->MXoptionReg |= 0x00078020;
913 } else if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG200) {
914 pci_read_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, ®50);
916 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, reg50);
918 if (ACCESS_FBINFO(devflags.memtype) == -1)
919 hw->MXoptionReg |= ACCESS_FBINFO(values).reg.opt & 0x1C00;
921 hw->MXoptionReg |= (ACCESS_FBINFO(devflags.memtype) & 7) << 10;
922 if (ACCESS_FBINFO(devflags.sgram))
923 hw->MXoptionReg |= 0x4000;
924 mga_outl(M_CTLWTST, ACCESS_FBINFO(values).reg.mctlwtst);
925 mga_outl(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk);
927 mga_outl(M_MACCESS, 0x00000000);
928 mga_outl(M_MACCESS, 0x00008000);
930 mga_outw(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk);
931 hw->MXoptionReg |= 0x00078020;
933 pci_read_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, ®50);
934 reg50 &= ~0x00000100;
936 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION2_REG, reg50);
938 if (ACCESS_FBINFO(devflags.memtype) == -1)
939 hw->MXoptionReg |= ACCESS_FBINFO(values).reg.opt & 0x1C00;
941 hw->MXoptionReg |= (ACCESS_FBINFO(devflags.memtype) & 7) << 10;
942 if (ACCESS_FBINFO(devflags.sgram))
943 hw->MXoptionReg |= 0x4000;
944 mga_outl(M_CTLWTST, ACCESS_FBINFO(values).reg.mctlwtst);
945 mga_outl(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk);
947 mga_outl(M_MACCESS, 0x00000000);
948 mga_outl(M_MACCESS, 0x00008000);
950 mga_outl(M_MEMRDBK, ACCESS_FBINFO(values).reg.memrdbk);
951 hw->MXoptionReg |= 0x00040020;
953 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
957 static void MGAG100_reset(WPMINFO2) {
959 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
964 #ifdef G100_BROKEN_IBM_82351
967 find 1014/22 (IBM/82351); /* if found and bridging Matrox, do some strange stuff */
968 pci_read_config_byte(ibm, PCI_SECONDARY_BUS, &b);
969 if (b == ACCESS_FBINFO(pcidev)->bus->number) {
970 pci_write_config_byte(ibm, PCI_COMMAND+1, 0); /* disable back-to-back & SERR */
971 pci_write_config_byte(ibm, 0x41, 0xF4); /* ??? */
972 pci_write_config_byte(ibm, PCI_IO_BASE, 0xF0); /* ??? */
973 pci_write_config_byte(ibm, PCI_IO_LIMIT, 0x00); /* ??? */
976 if (!ACCESS_FBINFO(devflags.noinit)) {
978 hw->MXoptionReg |= 0x40; /* FIXME... */
979 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
981 mga_setr(M_EXTVGA_INDEX, 0x06, 0x00);
984 if (ACCESS_FBINFO(devflags.g450dac)) {
985 /* either leave MCLK as is... or they were set in preinit */
986 hw->DACclk[3] = inDAC1064(PMINFO DAC1064_XSYSPLLM);
987 hw->DACclk[4] = inDAC1064(PMINFO DAC1064_XSYSPLLN);
988 hw->DACclk[5] = inDAC1064(PMINFO DAC1064_XSYSPLLP);
990 DAC1064_setmclk(PMINFO DAC1064_OPT_RESERVED | DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV1 | DAC1064_OPT_SCLK_PLL, 133333);
992 if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG400) {
993 if (ACCESS_FBINFO(devflags.dfp_type) == -1) {
994 ACCESS_FBINFO(devflags.dfp_type) = inDAC1064(PMINFO 0x1F);
997 if (ACCESS_FBINFO(devflags.noinit))
999 if (ACCESS_FBINFO(devflags.g450dac)) {
1001 MGAG100_setPixClock(PMINFO 4, 25175);
1002 MGAG100_setPixClock(PMINFO 5, 28322);
1004 b = inDAC1064(PMINFO M1064_XGENIODATA) & ~1;
1005 outDAC1064(PMINFO M1064_XGENIODATA, b);
1006 b = inDAC1064(PMINFO M1064_XGENIOCTRL) | 1;
1007 outDAC1064(PMINFO M1064_XGENIOCTRL, b);
1013 #ifdef CONFIG_FB_MATROX_MYSTIQUE
1014 static void MGA1064_restore(WPMINFO2) {
1016 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
1024 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
1025 mga_outb(M_IEN, 0x00);
1026 mga_outb(M_CACHEFLUSH, 0x00);
1030 DAC1064_restore_1(PMINFO2);
1031 matroxfb_vgaHWrestore(PMINFO2);
1032 ACCESS_FBINFO(crtc1.panpos) = -1;
1033 for (i = 0; i < 6; i++)
1034 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]);
1035 DAC1064_restore_2(PMINFO2);
1039 #ifdef CONFIG_FB_MATROX_G
1040 static void MGAG100_restore(WPMINFO2) {
1042 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
1050 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
1053 DAC1064_restore_1(PMINFO2);
1054 matroxfb_vgaHWrestore(PMINFO2);
1055 #ifdef CONFIG_FB_MATROX_32MB
1056 if (ACCESS_FBINFO(devflags.support32MB))
1057 mga_setr(M_EXTVGA_INDEX, 8, hw->CRTCEXT[8]);
1059 ACCESS_FBINFO(crtc1.panpos) = -1;
1060 for (i = 0; i < 6; i++)
1061 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]);
1062 DAC1064_restore_2(PMINFO2);
1066 #ifdef CONFIG_FB_MATROX_MYSTIQUE
1067 struct matrox_switch matrox_mystique = {
1068 MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
1070 EXPORT_SYMBOL(matrox_mystique);
1073 #ifdef CONFIG_FB_MATROX_G
1074 struct matrox_switch matrox_G100 = {
1075 MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
1077 EXPORT_SYMBOL(matrox_G100);
1081 EXPORT_SYMBOL(DAC1064_global_init);
1082 EXPORT_SYMBOL(DAC1064_global_restore);
1084 MODULE_LICENSE("GPL");