1 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga.h Sat Jan 12 00:42:57 2002
2 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h Sun Apr 14 15:07:08 2002
8 } MGARegRec, *MGARegPtr;
10 /* For programming the second CRTC */
12 void (*GetQuiescence)(ScrnInfoPtr pScrn);
18 XF86VideoAdaptorPtr adaptor;
19 + Bool DualHeadEnabled;
24 void MGACRTC2GetDisplayStart(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo, CARD32 base, CARD32 ulX, CARD32 ulY);
26 double MGAG450SetPLLFreq(ScrnInfoPtr pScrn, long f_out);
28 +double MGAG450SetPLLFreq(ScrnInfoPtr pScrn, long f_out);
29 +long MGAG450SavePLLFreq(ScrnInfoPtr pScrn);
30 void MGAprintDac(ScrnInfoPtr pScrn);
33 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga.man Tue Dec 18 05:52:32 2001
34 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.man Sun Apr 14 15:07:08 2002
36 8, 15, 16, 24, and an 8+24 overlay mode. All
37 visual types are supported for depth 8, and both TrueColor and DirectColor
38 visuals are supported for the other depths except 8+24 mode which supports
39 -PseudoColor, GrayScale and TrueColor. Multi-head configurations
40 +PseudoColor, GrayScale and TrueColor. Multi-card configurations
41 are supported. XVideo is supported on G200 and newer systems, with
45 +or video overlay. The second head of dual-head cards is supported for
46 +the G450 and G550. Support for the second head on G400 cards requires
47 +a binary-only "mga_hal" module that is available from Matrox
48 +<http://www.matrox.com>. That module also provides various other enhancements.
49 .SH SUPPORTED HARDWARE
53 Millennium G200 and Mystique G200
60 .SH CONFIGURATION DETAILS
61 Please refer to XF86Config(__filemansuffix__) for general configuration
62 details. This section only covers configuration details specific to this
66 "mga2064w", "mga1064sg", "mga2164w", "mga2164w agp", "mgag100", "mgag200",
67 -"mgag200 pci" "mgag400".
68 +"mgag200 pci", "mgag400", "mgag550".
71 +The G450 is Chipset "mgag400" with ChipRev 0x80.
73 The driver will auto-detect the amount of video memory present for all
74 chips except the Millennium II. In the Millennium II case it defaults
75 to 4096\ kBytes. When using a Millennium II, the actual amount of video
78 .BI "Option \*qNoAccel\*q \*q" boolean \*q
79 Disable or enable acceleration. Default: acceleration is enabled.
81 +.BI "Option \*qNoHal\*q \*q" boolean \*q
82 +Disable or enable loading the "mga_hal" module. Default: the module is
83 +loaded when available and when using hardware that it supports.
85 .BI "Option \*qOverclockMem\*q"
86 Set clocks to values used by some commercial X-Servers (G100, G200 and G400
87 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_dacG.c Sat Jan 12 00:42:57 2002
88 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c Sun Apr 14 15:07:08 2002
93 - MGAG450SetPLLFreq(pScrn, f_out);
95 + pReg->Clock = f_out;
99 /* Do the calculations for m, n, p and s */
101 pReg->DacRegs[i] = initDAC[i];
106 switch(pMga->Chipset)
108 case PCI_CHIP_MGA1064:
110 OUTREG(MGAREG_ZORG, 0);
113 - MGAGSetPCLK(pScrn, mode->Clock);
114 + MGAGSetPCLK(pScrn, mode->Clock);
117 /* This disables the VGA memory aperture */
124 MGAGRestorePalette(ScrnInfoPtr pScrn, unsigned char* pntr)
129 outMGAdreg(MGA1064_WADR_PAL, 0x00);
131 - outMGAdreg(MGA1064_COL_PAL, *(pntr++));
133 + outMGAdreg(MGA1064_COL_PAL, *(pntr++));
140 outMGAdreg(MGA1064_RADR_PAL, 0x00);
142 - *(pntr++) = inMGAdreg(MGA1064_COL_PAL);
144 + *(pntr++) = inMGAdreg(MGA1064_COL_PAL);
149 MGAPtr pMga = MGAPTR(pScrn);
153 + * Pixel Clock needs to be restored regardless if we use
154 + * HALLib or not. HALlib doesn't do a good job restoring
155 + * VESA modes. MATROX: hint, hint.
157 + if (MGAISGx50(pMga) && mgaReg->Clock) {
159 + * With HALlib program only when restoring to console!
160 + * To test this we check for Clock == 0.
162 + MGAG450SetPLLFreq(pScrn, mgaReg->Clock);
165 if(!pMga->SecondCrtc) {
169 * Code is needed to get things back to bank zero.
177 + * Work around another bug in HALlib: it doesn't restore the
178 + * DAC width register correctly. MATROX: hint, hint.
181 + outMGAdac(MGA1064_MUL_CTL,mgaReg->DacRegs[0]);
182 + outMGAdac(MGA1064_MISC_CTL,mgaReg->DacRegs[1]);
183 + if (!MGAISGx50(pMga)) {
184 + outMGAdac(MGA1064_PIX_PLLC_M,mgaReg->DacRegs[2]);
185 + outMGAdac(MGA1064_PIX_PLLC_N,mgaReg->DacRegs[3]);
186 + outMGAdac(MGA1064_PIX_PLLC_P,mgaReg->DacRegs[4]);
190 /* restore CRTCEXT regs */
191 for (i = 0; i < 6; i++)
192 OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i);
195 vgaHWRestore(pScrn, vgaReg,
196 VGA_SR_MODE | (restoreFonts ? VGA_SR_FONTS : 0));
197 - MGAGRestorePalette(pScrn, vgaReg->DAC);
198 + MGAGRestorePalette(pScrn, vgaReg->DAC);
201 * this is needed to properly restore start address
203 for (i=0; i<6; i++) ErrorF(" %02X", mgaReg->ExtVga[i]);
212 MGAPtr pMga = MGAPTR(pScrn);
215 + * Pixel Clock needs to be restored regardless if we use
216 + * HALLib or not. HALlib doesn't do a good job restoring
217 + * VESA modes (s.o.). MATROX: hint, hint.
219 + if (MGAISGx50(pMga)) {
220 + mgaReg->Clock = MGAG450SavePLLFreq(pScrn);
223 if(pMga->SecondCrtc == TRUE) {
224 for(i = 0x80; i < 0xa0; i++)
225 mgaReg->dac2[i-0x80] = inMGAdac(i);
228 vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0));
229 MGAGSavePalette(pScrn, vgaReg->DAC);
231 + * Work around another bug in HALlib: it doesn't restore the
232 + * DAC width register correctly.
237 + * Work around another bug in HALlib: it doesn't restore the
238 + * DAC width register correctly (s.o.). MATROX: hint, hint.
241 + if (mgaReg->DacRegs == NULL) {
242 + mgaReg->DacRegs = xnfcalloc(MGAISGx50(pMga) ? 2 : 5, 1);
244 + mgaReg->DacRegs[0] = inMGAdac(MGA1064_MUL_CTL);
245 + mgaReg->DacRegs[1] = inMGAdac(MGA1064_MISC_CTL);
246 + if (!MGAISGx50(pMga)) {
247 + mgaReg->DacRegs[2] = inMGAdac(MGA1064_PIX_PLLC_M);
248 + mgaReg->DacRegs[3] = inMGAdac(MGA1064_PIX_PLLC_N);
249 + mgaReg->DacRegs[4] = inMGAdac(MGA1064_PIX_PLLC_P);
255 * The port I/O code necessary to read in the extended registers.
256 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_dri.c Wed Sep 26 21:59:17 2001
257 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c Sun Apr 14 15:07:08 2002
258 @@ -571,11 +571,14 @@
259 MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo;
261 unsigned int vendor, device;
265 + if(pMga->agpSize < 12)pMga->agpSize = 12;
266 + if(pMga->agpSize > 64)pMga->agpSize = 64; /* cap */
268 /* FIXME: Make these configurable...
270 - pMGADRIServer->agp.size = 12 * 1024 * 1024;
271 + pMGADRIServer->agp.size = pMga->agpSize * 1024 * 1024;
273 pMGADRIServer->warp.offset = 0;
274 pMGADRIServer->warp.size = MGA_WARP_UCODE_SIZE;
276 pMGADRIServer->primary.size);
277 pMGADRIServer->buffers.size = MGA_NUM_BUFFERS * MGA_BUFFER_SIZE;
280 + pMGADRIServer->agpTextures.offset = (pMGADRIServer->buffers.offset +
281 + pMGADRIServer->buffers.size);
283 + pMGADRIServer->agpTextures.size = pMGADRIServer->agp.size -
284 + pMGADRIServer->agpTextures.offset;
286 if ( drmAgpAcquire( pMga->drmFD ) < 0 ) {
287 xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not available\n" );
290 "[drm] Added %d %d byte DMA buffers\n",
291 count, MGA_BUFFER_SIZE );
293 + i = mylog2(pMGADRIServer->agpTextures.size / MGA_NR_TEX_REGIONS);
294 + if(i < MGA_LOG_MIN_TEX_REGION_SIZE)
295 + i = MGA_LOG_MIN_TEX_REGION_SIZE;
296 + pMGADRIServer->agpTextures.size = (pMGADRIServer->agpTextures.size >> i) << i;
298 + if ( drmAddMap( pMga->drmFD,
299 + pMGADRIServer->agpTextures.offset,
300 + pMGADRIServer->agpTextures.size,
302 + &pMGADRIServer->agpTextures.handle ) < 0 ) {
303 + xf86DrvMsg( pScreen->myNum, X_ERROR,
304 + "[agp] Could not add agpTexture mapping\n" );
307 +/* should i map it ? */
308 + xf86DrvMsg( pScreen->myNum, X_INFO,
309 + "[agp] agpTexture handle = 0x%08lx\n",
310 + pMGADRIServer->agpTextures.handle );
311 + xf86DrvMsg( pScreen->myNum, X_INFO,
312 + "[agp] agpTexture size: %d kb\n", pMGADRIServer->agpTextures.size/1024 );
315 xf86EnablePciBusMaster( pMga->PciInfo, TRUE );
319 init.primary_offset = pMGADRIServer->primary.handle;
320 init.buffers_offset = pMGADRIServer->buffers.handle;
322 + init.texture_offset[1] = pMGADRIServer->agpTextures.handle;
323 + init.texture_size[1] = pMGADRIServer->agpTextures.size;
325 ret = drmMGAInitDMA( pMga->drmFD, &init );
327 xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
328 @@ -1192,6 +1227,14 @@
329 pMGADRI->logTextureGranularity = i;
330 pMGADRI->textureSize = (pMGADRI->textureSize >> i) << i; /* truncate */
332 + i = mylog2( pMGADRIServer->agpTextures.size / MGA_NR_TEX_REGIONS );
333 + if ( i < MGA_LOG_MIN_TEX_REGION_SIZE )
334 + i = MGA_LOG_MIN_TEX_REGION_SIZE;
336 + pMGADRI->logAgpTextureGranularity = i;
337 + pMGADRI->agpTextureOffset = (unsigned int)pMGADRIServer->agpTextures.handle;
338 + pMGADRI->agpTextureSize = (unsigned int)pMGADRIServer->agpTextures.size;
340 pMGADRI->registers.handle = pMGADRIServer->registers.handle;
341 pMGADRI->registers.size = pMGADRIServer->registers.size;
342 pMGADRI->status.handle = pMGADRIServer->status.handle;
343 @@ -1233,6 +1276,11 @@
344 if ( pMGADRIServer->warp.map ) {
345 drmUnmap( pMGADRIServer->warp.map, pMGADRIServer->warp.size );
346 pMGADRIServer->warp.map = NULL;
349 + if ( pMGADRIServer->agpTextures.map ) {
350 + drmUnmap( pMGADRIServer->agpTextures.map, pMGADRIServer->agpTextures.size );
351 + pMGADRIServer->agpTextures.map = NULL;
354 if ( pMGADRIServer->agp.handle ) {
355 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_driver.c Tue Jan 8 06:50:11 2002
356 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c Sun Apr 14 15:36:52 2002
366 { OPTION_CRTC2RAM, "Crtc2Ram", OPTV_INTEGER, {0}, FALSE },
367 { OPTION_INT10, "Int10", OPTV_BOOLEAN, {0}, FALSE },
368 { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE },
369 + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE },
370 { OPTION_DIGITAL, "DigitalScreen",OPTV_BOOLEAN, {0}, FALSE },
371 { OPTION_TV, "TV", OPTV_BOOLEAN, {0}, FALSE },
372 { OPTION_TVSTANDARD, "TVStandard", OPTV_ANYSTR, {0}, FALSE },
373 @@ -1299,28 +1301,122 @@
374 pScrn->monitor = pScrn->confScreen->monitor;
377 - * In case of DualHead, we need to determine if we are the 'master' head or the 'slave'
378 - * head. In order to do that, at the end of the first initialisation, PrimInit is set as
379 - * DONE to the shared entity. So that the second initialisation knows that something has
380 - * been done before it. This always assume that the first device initialised is the master
381 + * Set the Chipset and ChipRev, allowing config file entries to
384 + if (pMga->device->chipset && *pMga->device->chipset) {
385 + pScrn->chipset = pMga->device->chipset;
386 + pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset);
388 + } else if (pMga->device->chipID >= 0) {
389 + pMga->Chipset = pMga->device->chipID;
390 + pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
392 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
396 + pMga->Chipset = pMga->PciInfo->chipType;
397 + pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
399 + if (pMga->device->chipRev >= 0) {
400 + pMga->ChipRev = pMga->device->chipRev;
401 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
404 + pMga->ChipRev = pMga->PciInfo->chipRev;
408 + * This shouldn't happen because such problems should be caught in
409 + * MGAProbe(), but check it just in case.
411 + if (pScrn->chipset == NULL) {
412 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
413 + "ChipID 0x%04X is not recognised\n", pMga->Chipset);
416 + if (pMga->Chipset < 0) {
417 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
418 + "Chipset \"%s\" is not recognised\n", pScrn->chipset);
422 + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"", pScrn->chipset);
423 + if ((pMga->Chipset == PCI_CHIP_MGAG400) &&
424 + (pMga->ChipRev >= 0x80))
425 + xf86ErrorF(" (G450)\n");
427 + xf86ErrorF(" (G400)\n");
430 + if (HAL_CHIPSETS) {
431 + Bool loadHal = TRUE;
434 + if (xf86FindOption(pMga->device->options, "NoHal")) {
435 + loadHal = !xf86SetBoolOption(pMga->device->options,
436 + "NoHal", !loadHal);
438 + } else if (xf86FindOption(pMga->device->options, "Hal")) {
439 + loadHal = xf86SetBoolOption(pMga->device->options,
443 + if (loadHal && xf86LoadSubModule(pScrn, "mga_hal")) {
444 + xf86LoaderReqSymLists(halSymbols, NULL);
445 + xf86DrvMsg(pScrn->scrnIndex, from,"Matrox HAL module used\n");
446 + pMga->HALLoaded = TRUE;
448 + xf86DrvMsg(pScrn->scrnIndex, from, "Matrox HAL module not loaded "
449 + "- using builtin mode setup instead\n");
450 + pMga->HALLoaded = FALSE;
455 + pMga->DualHeadEnabled = FALSE;
456 + if (xf86IsEntityShared(pScrn->entityList[0])) {/* dual-head mode requested*/
458 + if (pMga->HALLoaded || !MGA_DH_NEEDS_HAL(pMga)) {
460 + if (!MGA_DH_NEEDS_HAL(pMga)) {
462 + pMga->DualHeadEnabled = TRUE;
463 + } else if (xf86IsPrimInitDone(pScrn->entityList[0])) {
464 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
465 + "This card requires the \"mga_hal\" module for dual-head operation\n"
466 + "\tIt can be found at the Matrox web site <http://www.matrox.com>\n");
471 + * In case of DualHead, we need to determine if we are the 'master' head
472 + * or the 'slave' head. In order to do that, at the end of the first
473 + * initialisation, PrimInit is set as DONE to the shared entity. So that
474 + * the second initialisation knows that something has been done before it.
475 + * This always assume that the first device initialised is the master
476 * head, and the second the slave.
479 if (xf86IsEntityShared(pScrn->entityList[0])) { /* dual-head mode */
481 if (!xf86IsPrimInitDone(pScrn->entityList[0])) { /* Is it the first initialisation? */
483 pMga->SecondCrtc = FALSE;
484 pMga->HWCursor = TRUE;
485 pMgaEnt->pScrn_1 = pScrn;
488 + } else if (pMga->DualHeadEnabled) {
490 pMga->SecondCrtc = TRUE;
491 pMga->HWCursor = FALSE;
492 pMgaEnt->pScrn_2 = pScrn;
493 pScrn->AdjustFrame = MGAAdjustFrameCrtc2;
500 + if (pMga->DualHeadEnabled) {
502 pMga->GetQuiescence = MGAGetQuiescenceShared;
504 @@ -1421,65 +1517,6 @@
505 if (pScrn->depth == 8)
509 - * Set the Chipset and ChipRev, allowing config file entries to
512 - if (pMga->device->chipset && *pMga->device->chipset) {
513 - pScrn->chipset = pMga->device->chipset;
514 - pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset);
516 - } else if (pMga->device->chipID >= 0) {
517 - pMga->Chipset = pMga->device->chipID;
518 - pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
520 - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
524 - pMga->Chipset = pMga->PciInfo->chipType;
525 - pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
527 - if (pMga->device->chipRev >= 0) {
528 - pMga->ChipRev = pMga->device->chipRev;
529 - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
532 - pMga->ChipRev = pMga->PciInfo->chipRev;
536 - if (HAL_CHIPSETS) {
537 - if (!xf86ReturnOptValBool(pMga->Options, OPTION_NOHAL, FALSE)
538 - && xf86LoadSubModule(pScrn, "mga_hal")) {
539 - xf86LoaderReqSymLists(halSymbols, NULL);
540 - xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Matrox HAL module used\n");
541 - pMga->HALLoaded = TRUE;
543 - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Matrox HAL module not loaded "
544 - "- using builtin mode setup instead\n");
545 - pMga->HALLoaded = FALSE;
551 - * This shouldn't happen because such problems should be caught in
552 - * MGAProbe(), but check it just in case.
554 - if (pScrn->chipset == NULL) {
555 - xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
556 - "ChipID 0x%04X is not recognised\n", pMga->Chipset);
559 - if (pMga->Chipset < 0) {
560 - xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
561 - "Chipset \"%s\" is not recognised\n", pScrn->chipset);
565 - xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
569 pMga->agpMode = MGA_DEFAULT_AGP_MODE;
570 @@ -1494,6 +1531,12 @@
574 + if (xf86GetOptValInteger(pMga->Options,
575 + OPTION_AGP_SIZE, &(pMga->agpSize))) {
577 + xf86DrvMsg(pScrn->scrnIndex, from, "Using %d MB of AGP memory\n",
581 xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP %dx mode\n",
583 @@ -1812,7 +1855,7 @@
584 pScrn->videoRam = MGACountRam(pScrn);
587 - if(xf86IsEntityShared(pScrn->entityList[0])) {
588 + if (pMga->DualHeadEnabled) {
589 /* This takes gives either half or 8 meg to the second head
590 * whichever is less. */
591 if(pMga->SecondCrtc == FALSE) {
592 @@ -2073,6 +2116,17 @@
593 pMga->pClientStruct->pMga = (MGAPtr) pMga;
597 + * For some reason the MGAOPM_DMA_BLIT bit needs to be set
598 + * on G200 before opening the HALlib. I don't know why.
599 + * MATROX: hint, hint.
601 + /*if (pMga->Chipset == PCI_CHIP_MGAG200 ||
602 + pMga->Chipset == PCI_CHIP_MGAG200_PCI) */{
604 + opmode = INREG(MGAREG_OPMODE);
605 + OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | opmode);
607 MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
609 pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
610 @@ -2101,7 +2155,7 @@
613 /* copy the board handles */
614 - if (xf86IsEntityShared(pScrn->entityList[0])) {
615 + if (pMga->DualHeadEnabled) {
616 pMgaEnt->pClientStruct = pMga->pClientStruct;
617 pMgaEnt->pBoard = pMga->pBoard;
618 pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
619 @@ -2182,7 +2236,11 @@
620 * Can we trust HALlib to set the memory configuration
621 * registers correctly?
624 else if ((pMga->softbooted || pMga->Primary /*|| pMga->HALLoaded*/ ) &&
626 + else if ((pMga->softbooted || pMga->Primary) &&
628 (pMga->Chipset != PCI_CHIP_MGA2064) &&
629 (pMga->Chipset != PCI_CHIP_MGA2164) &&
630 (pMga->Chipset != PCI_CHIP_MGA2164_AGP)) {
631 @@ -2264,7 +2322,7 @@
633 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n",
635 - if(xf86IsEntityShared(pScrn->entityList[0])) {
636 + if(pMga->DualHeadEnabled) {
637 if(pMga->SecondCrtc == FALSE) {
638 pMga->FbUsableSize = pMgaEnt->masterFbMapSize;
639 /* Allocate HW cursor buffer at the end of video ram */
640 @@ -2368,7 +2426,7 @@
641 /* This needs to only happen after this board has completed preinit
644 - if(xf86IsEntityShared(pScrn->entityList[0])) {
645 + if(pMga->DualHeadEnabled) {
646 /* Entity is shared make sure refcount == 2 */
647 /* If ref count is 2 then reset it to 0 */
648 if(pMgaEnt->refCount == 2) {
649 @@ -2630,6 +2688,7 @@
651 MGAPtr pMga = MGAPTR(pScrn);
655 Bool digital1 = FALSE;
656 Bool digital2 = FALSE;
657 @@ -2736,7 +2795,7 @@
661 - /* getting around bugs in the HAL lib. MATROX: hint, hint */
662 + /* getting around bugs in the HAL lib. MATROX: hint, hint. */
664 switch (pMga->Chipset) {
665 case PCI_CHIP_MGA1064:
666 @@ -2745,7 +2804,8 @@
667 case PCI_CHIP_MGAG200:
668 case PCI_CHIP_MGAG200_PCI:
669 case PCI_CHIP_MGAG400:
670 - if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
671 + case PCI_CHIP_MGAG550:
672 + if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
673 outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW,
674 pMga->FbCursorOffset >> 10);
675 outMGAdac(MGA1064_CURSOR_BASE_ADR_HI,
676 @@ -2769,6 +2829,7 @@
679 MGAStormEngineInit(pScrn);
681 vgaHWProtect(pScrn, FALSE);
684 @@ -2840,7 +2901,6 @@
686 if (pScrn->pScreen != NULL)
689 if(pMga->SecondCrtc) {
690 MGARestoreSecondCrtc(pScrn);
692 @@ -2930,7 +2990,7 @@
693 || (pMga->Chipset == PCI_CHIP_MGAG100_PCI))
694 MGAG100BlackMagic(pMga);
696 - if (xf86IsEntityShared(pScrn->entityList[0])) {
697 + if (pMga->DualHeadEnabled) {
699 pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
700 pMgaEnt = pPriv->ptr;
701 @@ -2988,7 +3048,7 @@
704 /* There is a problem in the HALlib: set soft reset bit */
705 - /* MATROX: hint, hint */
706 + /* MATROX: hint, hint. */
707 if (!pMga->Primary && !pMga->FBDev &&
708 (pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SG) ) {
709 OUTREG(MGAREG_Reset, 1);
710 @@ -3040,7 +3100,6 @@
711 if (!MGAModeInit(pScrn, pScrn->currentMode))
715 /* Darken the screen for aesthetic reasons and set the viewport */
716 if (pMga->SecondCrtc == TRUE) {
717 MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON);
718 @@ -3290,7 +3349,7 @@
720 xf86DrvMsg(pScrn->scrnIndex, driFrom, "Direct rendering disabled\n");
722 - if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE)
723 + if (pMga->DualHeadEnabled && pMga->SecondCrtc == FALSE)
724 pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled;
725 pMga->haveQuiescense = 1;
727 @@ -3318,7 +3377,7 @@
729 MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
731 - return MGAModeInit(xf86Screens[scrnIndex], mode);
732 + return MGAModeInit(xf86Screens[scrnIndex], mode);
736 @@ -3513,6 +3572,7 @@
737 vgaHWPtr hwp = VGAHWPTR(pScrn);
738 MGAPtr pMga = MGAPTR(pScrn);
739 MGAEntPtr pMgaEnt = NULL;
742 MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); );
744 @@ -3534,7 +3594,7 @@
748 - if (xf86IsEntityShared(pScrn->entityList[0])) {
749 + if (pMga->DualHeadEnabled) {
751 pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
752 pMgaEnt = pPriv->ptr;
753 @@ -3543,7 +3603,7 @@
757 - if(xf86IsEntityShared(pScrn->entityList[0])) {
758 + if(pMga->DualHeadEnabled) {
759 if(pMgaEnt->refCount == 0) {
760 /* Both boards have closed there screen */
761 MGACloseLibrary(pMga->pBoard);
762 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_g450pll.c Sat Jan 12 00:42:57 2002
763 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_g450pll.c Sun Apr 14 15:07:08 2002
768 +static CARD32 G450ReadMNP(ScrnInfoPtr pScrn)
770 + MGAPtr pMga = MGAPTR(pScrn);
774 + pReg = &pMga->ModeReg;
776 + if (!pMga->SecondCrtc) {
777 + ret = (CARD8)inMGAdac(MGA1064_PIX_PLLC_M) << 16;
778 + ret |= (CARD8)inMGAdac(MGA1064_PIX_PLLC_N) << 8;
779 + ret |= (CARD8)inMGAdac(MGA1064_PIX_PLLC_P);
781 + ret = (CARD8)inMGAdac(MGA1064_VID_PLL_M) << 16;
782 + ret |= (CARD8)inMGAdac(MGA1064_VID_PLL_N) << 8;
783 + ret |= (CARD8)inMGAdac(MGA1064_VID_PLL_P);
789 static CARD32 G450CompareMNP(ScrnInfoPtr pScrn, CARD32 ulFout, CARD32 ulMNP1,
790 CARD32 ulMNP2, long *pulResult)
793 MGAPtr pMga = MGAPTR(pScrn);
796 + xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Restoring PLLClk = %d\n",f_out);
798 G450FindFirstPLLParam(pScrn, f_out, &ulMNP);
799 ulMNPTable[0] = ulMNP;
800 G450FindNextPLLParam(pScrn, f_out, &ulMNP);
808 +MGAG450SavePLLFreq(ScrnInfoPtr pScrn)
810 + CARD32 ulMNP = G450ReadMNP(pScrn);
814 + G450CalculVCO(pScrn, ulMNP, &freq);
815 + ucP = (CARD8)(ulMNP & 0x03);
816 + G450ApplyPFactor(pScrn, ucP, &freq);
819 + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Saved PLLClk = %d\n",freq);
823 diff -urN XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_macros.h XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h
824 --- XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga.orig/mga_macros.h Wed Sep 26 21:59:17 2001
825 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h Sun Apr 14 15:07:08 2002
828 #define MGAISGx50(x) ( (((x)->Chipset == PCI_CHIP_MGAG400) && ((x)->ChipRev >= 0x80)) || \
829 ((x)->Chipset == PCI_CHIP_MGAG550) )
831 +#define MGA_DH_NEEDS_HAL(x) (((x)->Chipset == PCI_CHIP_MGAG400) && \
832 + ((x)->ChipRev < 0x80))
834 #endif /* _MGA_MACROS_H_ */