Make r128 work on PPC without fbdev https://bugs.freedesktop.org/show_bug.cgi?id=2089 VGAAccess patch. To test PPC users should set "UseFBDev" to false and "VGAAccess" to false. Description from https://bugs.freedesktop.org/show_bug.cgi?id=2064 of the Radeon version: This patch adds the "VGAAccess" option (defaults to NO on PPC and YES on others) that disables all legacy VGA stuffs in the driver, since they are causing various issues on non-x86 machines. Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h:1.3 xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h:1.3 Wed Jun 16 09:43:58 2004 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h Fri Dec 17 19:19:32 2004 @@ -401,6 +401,8 @@ I2CBusPtr pI2CBus; CARD32 DDCReg; + Bool VGAAccess; + } R128InfoRec, *R128InfoPtr; #define R128WaitForFifo(pScrn, entries) \ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man:1.2 xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man:1.2 Fri Apr 23 19:26:46 2004 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man Fri Dec 17 19:19:32 2004 @@ -123,6 +123,17 @@ .BI "Option \*qShowCache\*q \*q" boolean \*q Enable or disable viewing offscreen cache memory. A development debug option. Default: off. +.TP +.BI "Option \*qVGAAccess\*q \*q" boolean \*q +Tell the driver if it can do legacy VGA IOs to the card. This is +necessary for properly resuming consoles when in VGA text mode, but +shouldn't be if the console is using radeonfb or some other graphic +mode driver. Some platforms like PowerPC have issues with those, and they aren't +necessary unless you have a real text mode in console. The default is +.B off +on PowerPC and +.B on +on other architectures. .SH "SEE ALSO" __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c:1.14 xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c:1.15 --- xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c:1.14 Sat Dec 4 22:34:54 2004 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c Fri Dec 17 19:19:32 2004 @@ -137,7 +137,8 @@ OPTION_PROG_FP_REGS, OPTION_FBDEV, OPTION_VIDEO_KEY, - OPTION_SHOW_CACHE + OPTION_SHOW_CACHE, + OPTION_VGA_ACCESS } R128Opts; static const OptionInfoRec R128Options[] = { @@ -164,6 +165,7 @@ { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, { OPTION_SHOW_CACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_VGA_ACCESS, "VGAAccess", OPTV_BOOLEAN, {0}, TRUE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -1875,13 +1877,6 @@ return TRUE; } - if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - xf86LoaderReqSymLists(vgahwSymbols, NULL); - if (!vgaHWGetHWRec(pScrn)) { - R128FreeRec(pScrn); - return FALSE; - } - info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); info->PciTag = pciTag(info->PciInfo->bus, info->PciInfo->device, @@ -1908,6 +1903,33 @@ memcpy(info->Options, R128Options, sizeof(R128Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, info->Options); + /* By default, don't do VGA IOs on ppc */ +#ifdef __powerpc__ + info->VGAAccess = FALSE; +#else + info->VGAAccess = TRUE; +#endif + + xf86GetOptValBool(info->Options, OPTION_VGA_ACCESS, &info->VGAAccess); + if (info->VGAAccess) { + if (!xf86LoadSubModule(pScrn, "vgahw")) + info->VGAAccess = FALSE; + else { + xf86LoaderReqSymLists(vgahwSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) + info->VGAAccess = FALSE; + } + if (!info->VGAAccess) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Loading VGA module failed," + " trying to run without it\n"); + } else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VGAAccess option set to FALSE," + " VGA module load skipped\n"); + if (info->VGAAccess) + vgaHWGetIOBase(VGAHWPTR(pScrn)); + + + if (!R128PreInitWeight(pScrn)) goto fail; if(xf86GetOptValInteger(info->Options, OPTION_VIDEO_KEY, &(info->videoKey))) { @@ -1996,7 +2018,8 @@ if (pInt10) xf86FreeInt10(pInt10); - vgaHWFreeHWRec(pScrn); + if (info->VGAAccess) + vgaHWFreeHWRec(pScrn); R128FreeRec(pScrn); return FALSE; } @@ -2809,16 +2832,30 @@ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128SavePtr save = &info->SavedReg; - vgaHWPtr hwp = VGAHWPTR(pScrn); R128TRACE(("R128Save\n")); if (info->FBDev) { fbdevHWSave(pScrn); return; } - vgaHWUnlock(hwp); - vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ - vgaHWLock(hwp); + + if (info->VGAAccess) { + vgaHWPtr hwp = VGAHWPTR(pScrn); + + vgaHWUnlock(hwp); +#if defined(__powerpc__) + /* temporary hack to prevent crashing on PowerMacs when trying to + * read VGA fonts and colormap, will find a better solution + * in the future. TODO: Check if there's actually some VGA stuff + * setup in the card at all !! + */ + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_MODE); /* Save mode only */ +#else + /* Save mode * & fonts & cmap */ + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS); +#endif + vgaHWLock(hwp); + } R128SaveMode(pScrn, save); @@ -2835,7 +2872,6 @@ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128SavePtr restore = &info->SavedReg; - vgaHWPtr hwp = VGAHWPTR(pScrn); R128TRACE(("R128Restore\n")); if (info->FBDev) { @@ -2851,9 +2887,19 @@ OUTREG(R128_DP_DATATYPE, restore->dp_datatype); R128RestoreMode(pScrn, restore); - vgaHWUnlock(hwp); - vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); - vgaHWLock(hwp); + if (info->VGAAccess) { + vgaHWPtr hwp = VGAHWPTR(pScrn); + vgaHWUnlock(hwp); +#if defined(__powerpc__) + /* Temporary hack to prevent crashing on PowerMacs when trying to + * write VGA fonts, will find a better solution in the future + */ + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE ); +#else + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); +#endif + vgaHWLock(hwp); + } R128WaitForVerticalSync(pScrn); R128Unblank(pScrn); @@ -3586,9 +3632,10 @@ void R128FreeScreen(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); R128TRACE(("R128FreeScreen\n")); - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + if (info->VGAAccess && xf86LoaderCheckSymbol("vgaHWFreeHWRec")) vgaHWFreeHWRec(pScrn); R128FreeRec(pScrn); }