📄 r128_driver.c
字号:
R128MapMem(pScrn); info->BIOSDisplay = R128_BIOS_DISPLAY_FP; /* validate if DFP really connected. */ if(!R128GetDFPInfo(pScrn)) { info->isDFP = FALSE; info->BIOSDisplay = R128_BIOS_DISPLAY_CRT; } else if(!info->isPro2) { /* RageProII doesn't support rmx, we can't use native-mode stretching for other non-native modes. It will rely on whatever VESA modes monitor can support. */ modesFound = R128ValidateFPModes(pScrn); if(modesFound < 1) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid mode found for this DFP/LCD\n"); R128UnmapMem(pScrn); return FALSE; } } R128UnmapMem(pScrn); } if(!info->isDFP || info->isPro2) { /* Get mode information */ pScrn->progClock = TRUE; clockRanges = xnfcalloc(sizeof(*clockRanges), 1); clockRanges->next = NULL; clockRanges->minClock = info->pll.min_pll_freq; clockRanges->maxClock = info->pll.max_pll_freq * 10; clockRanges->clockIndex = -1; if (info->HasPanelRegs || info->isDFP) { clockRanges->interlaceAllowed = FALSE; clockRanges->doubleScanAllowed = FALSE; } else { clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; } if(pScrn->monitor->DDC) { /*if we still don't know sync range yet, let's try EDID. Note that, since we can have dual heads, the Xconfigurator may not be able to probe both monitors correctly through vbe probe function (R128ProbeDDC). Here we provide an additional way to auto-detect sync ranges if they haven't been added to XF86Config manually. **/ if(pScrn->monitor->nHsync <= 0) R128SetSyncRangeFromEdid(pScrn, 1); if(pScrn->monitor->nVrefresh <= 0) R128SetSyncRangeFromEdid(pScrn, 0); } modesFound = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, NULL, /* linePitches */ 8 * 64, /* minPitch */ 8 * 1024, /* maxPitch *//* * ATI docs say pitchInc must be 8 * 64, but this doesn't permit a pitch of * 800 bytes, which is known to work on the Rage128 LF on clamshell iBooks */ 8 * 32, /* pitchInc */ 128, /* minHeight */ 2048, /* maxHeight */ pScrn->display->virtualX, pScrn->display->virtualY, info->FbMapSize, LOOKUP_BEST_REFRESH); if (modesFound < 1 && info->FBDev) { fbdevHWUseBuildinMode(pScrn); pScrn->displayWidth = fbdevHWGetLineLength(pScrn)/(pScrn->bitsPerPixel/8); modesFound = 1; } if (modesFound == -1) return FALSE; xf86PruneDriverModes(pScrn); if (!modesFound || !pScrn->modes) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); return FALSE; } xf86SetCrtcForModes(pScrn, 0); } /* Set DPI */ pScrn->currentMode = pScrn->modes; xf86PrintModes(pScrn); xf86SetDpi(pScrn, 0, 0); /* Get ScreenInit function */ if (!xf86LoadSubModule(pScrn, "fb")) return FALSE; xf86LoaderReqSymLists(fbSymbols, NULL); info->CurrentLayout.displayWidth = pScrn->displayWidth; info->CurrentLayout.mode = pScrn->currentMode; return TRUE;}/* This is called by R128PreInit to initialize the hardware cursor. */static Bool R128PreInitCursor(ScrnInfoPtr pScrn){ R128InfoPtr info = R128PTR(pScrn); if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) { if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; xf86LoaderReqSymLists(ramdacSymbols, NULL); } return TRUE;}/* This is called by R128PreInit to initialize hardware acceleration. */static Bool R128PreInitAccel(ScrnInfoPtr pScrn){ R128InfoPtr info = R128PTR(pScrn); if (!xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE)) { if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; xf86LoaderReqSymLists(xaaSymbols, NULL); } return TRUE;}static Bool R128PreInitInt10(ScrnInfoPtr pScrn, xf86Int10InfoPtr *ppInt10){ R128InfoPtr info = R128PTR(pScrn);#if 1 && !defined(__alpha__) /* int10 is broken on some Alphas */ if (xf86LoadSubModule(pScrn, "int10")) { xf86LoaderReqSymLists(int10Symbols, NULL); xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); *ppInt10 = xf86InitInt10(info->pEnt->index); }#endif return TRUE;}#ifdef XF86DRIstatic Bool R128PreInitDRI(ScrnInfoPtr pScrn){ R128InfoPtr info = R128PTR(pScrn); if (xf86ReturnOptValBool(info->Options, OPTION_CCE_PIO, FALSE)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CCE into PIO mode\n"); info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; } else { info->CCEMode = R128_DEFAULT_CCE_BM_MODE; } if (xf86ReturnOptValBool(info->Options, OPTION_NO_SECURITY, FALSE)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "WARNING!!! CCE Security checks disabled!!! **********\n"); info->CCESecure = FALSE; } else { info->CCESecure = TRUE; } info->agpMode = R128_DEFAULT_AGP_MODE; info->agpSize = R128_DEFAULT_AGP_SIZE; info->ringSize = R128_DEFAULT_RING_SIZE; info->bufSize = R128_DEFAULT_BUFFER_SIZE; info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; if (!info->IsPCI) { if (xf86GetOptValInteger(info->Options, OPTION_AGP_MODE, &(info->agpMode))) { if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Illegal AGP Mode: %d\n", info->agpMode); return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using AGP %dx mode\n", info->agpMode); } if (xf86GetOptValInteger(info->Options, OPTION_AGP_SIZE, (int *)&(info->agpSize))) { switch (info->agpSize) { case 4: case 8: case 16: case 32: case 64: case 128: case 256: break; default: xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Illegal AGP size: %d MB\n", info->agpSize); return FALSE; } } if (xf86GetOptValInteger(info->Options, OPTION_RING_SIZE, &(info->ringSize))) { if (info->ringSize < 1 || info->ringSize >= (int)info->agpSize) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Illegal ring buffer size: %d MB\n", info->ringSize); return FALSE; } } if (xf86GetOptValInteger(info->Options, OPTION_BUFFER_SIZE, &(info->bufSize))) { if (info->bufSize < 1 || info->bufSize >= (int)info->agpSize) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Illegal vertex/indirect buffers size: %d MB\n", info->bufSize); return FALSE; } if (info->bufSize > 2) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Illegal vertex/indirect buffers size: %d MB\n", info->bufSize); xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Clamping vertex/indirect buffers size to 2 MB\n"); info->bufSize = 2; } } if (info->ringSize + info->bufSize + info->agpTexSize > (int)info->agpSize) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Buffers are too big for requested AGP space\n"); return FALSE; } info->agpTexSize = info->agpSize - (info->ringSize + info->bufSize); } if (xf86GetOptValInteger(info->Options, OPTION_USEC_TIMEOUT, &(info->CCEusecTimeout))) { /* This option checked by the R128 DRM kernel module */ } if (!xf86LoadSubModule(pScrn, "shadowfb")) { info->allowPageFlip = 0; xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't load shadowfb module:\n"); } else { xf86LoaderReqSymLists(driShadowFBSymbols, NULL); info->allowPageFlip = xf86ReturnOptValBool(info->Options, OPTION_PAGE_FLIP, FALSE); } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Page flipping %sabled\n", info->allowPageFlip ? "en" : "dis"); return TRUE;}#endifstatic voidR128ProbeDDC(ScrnInfoPtr pScrn, int indx){ vbeInfoPtr pVbe; if (xf86LoadSubModule(pScrn, "vbe")) { pVbe = VBEInit(NULL,indx); ConfiguredMonitor = vbeDoEDID(pVbe, NULL); vbeFree(pVbe); }}/* R128PreInit is called once at server startup. */_X_EXPORT Bool R128PreInit(ScrnInfoPtr pScrn, int flags){ R128InfoPtr info; xf86Int10InfoPtr pInt10 = NULL; R128TRACE(("R128PreInit\n")); if (pScrn->numEntities != 1) return FALSE; if (!R128GetRec(pScrn)) return FALSE; info = R128PTR(pScrn); info->IsSecondary = FALSE; info->IsPrimary = FALSE; info->SwitchingMode = FALSE; info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (info->pEnt->location.type != BUS_PCI) goto fail; if(xf86IsEntityShared(pScrn->entityList[0])) { if(xf86IsPrimInitDone(pScrn->entityList[0])) { DevUnion* pPriv; R128EntPtr pR128Ent; info->IsSecondary = TRUE; pPriv = xf86GetEntityPrivate(pScrn->entityList[0], getR128EntityIndex()); pR128Ent = pPriv->ptr; if(pR128Ent->BypassSecondary) return FALSE; pR128Ent->pSecondaryScrn = pScrn; } else { DevUnion* pPriv; R128EntPtr pR128Ent; info->IsPrimary = TRUE; xf86SetPrimInitDone(pScrn->entityList[0]); pPriv = xf86GetEntityPrivate(pScrn->entityList[0], getR128EntityIndex()); pR128Ent = pPriv->ptr; pR128Ent->pPrimaryScrn = pScrn; pR128Ent->IsDRIEnabled = FALSE; pR128Ent->BypassSecondary = FALSE; pR128Ent->HasSecondary = FALSE; pR128Ent->RestorePrimary = FALSE; pR128Ent->IsSecondaryRestored = FALSE; } } if (flags & PROBE_DETECT) { R128ProbeDDC(pScrn, info->pEnt->index); return TRUE; } info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); info->PciTag = pciTag(info->PciInfo->bus, info->PciInfo->device, info->PciInfo->func); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PCI bus %d card %d func %d\n", info->PciInfo->bus, info->PciInfo->device, info->PciInfo->func); if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; if (xf86SetOperatingState(resVga, info->pEnt->index, ResUnusedOpr)) goto fail; pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT | RAC_CURSOR; pScrn->monitor = pScrn->confScreen->monitor; if (!R128PreInitVisual(pScrn)) goto fail; /* We can't do this until we have a pScrn->display. */ xf86CollectOptions(pScrn, NULL); if (!(info->Options = xalloc(sizeof(R128Options)))) goto fail; memcpy(info->Options, R128Options, sizeof(R128Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, info->Options); /* By default, don't do VGA IOs on ppc */#if defined(__powerpc__) || !defined(WITH_VGAHW) info->VGAAccess = FALSE;#else info->VGAAccess = TRUE;#endif#ifdef WITH_VGAHW 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));#else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VGAHW support not compiled, VGA " "module load skipped\n");#endif if (!R128PreInitWeight(pScrn)) goto fail; if(xf86GetOptValInteger(info->Options, OPTION_VIDEO_KEY, &(info->videoKey))) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", info->videoKey); } else { info->videoKey = 0x1E; } if (xf86ReturnOptValBool(info->Options, OPTION_SHOW_CACHE, FALSE)) { info->showCache = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShowCache enabled\n"); }#ifdef __powerpc__ if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, TRUE))#else if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, FALSE))#endif { info->FBDev = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using framebuffer device\n"); } if (info->FBDev) { /* check for linux framebuffer device */ if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; xf86LoaderReqSymLists(fbdevHWSymbols, NULL); if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; pScrn->SwitchMode = fbdevHWSwitchModeWeak(); pScrn->AdjustFrame = fbdevHWAdjustFrameWeak(); pScrn->ValidMode = fbdevHWValidModeWeak(); } if (!info->FBDev) if (!R128PreInitInt10(pScrn, &pInt10)) goto fail; if (!R128PreInitConfig(pScrn)) goto fail; if (!R128GetBIOSParameters(pScrn, pInt10)) goto fail; if (!R128GetPLLParameters(pScrn)) goto fail; /* Don't fail on this one */ R128PreInitDDC(pScrn, pInt10); if (!R128PreInitGamma(pScrn)) goto fail; if (!R128PreInitModes(pScrn)) goto fail; if (!R128PreInitCursor(pScrn)) goto fail; if (!R128PreInitAccel(pScrn)) goto fail;#ifdef XF86
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -