📄 r128_dri.c
字号:
version->version_minor, version->version_patchlevel); drmFreeVersion(version); R128DRICloseScreen(pScreen); return FALSE; } drmFreeVersion(version); } /* Check the r128 DRM version */ version = drmGetVersion(info->drmFD); if (version) { if (version->version_major != 2 || version->version_minor < 2) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] R128DRIScreenInit failed because of a version mismatch.\n" "[dri] r128.o kernel module version is %d.%d.%d but version 2.2 or greater is needed.\n" "[dri] Disabling the DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); drmFreeVersion(version); R128DRICloseScreen(pScreen); return FALSE; } info->drmMinor = version->version_minor; drmFreeVersion(version); } /* Initialize AGP */ if (!info->IsPCI && !R128DRIAgpInit(info, pScreen)) { info->IsPCI = TRUE; xf86DrvMsg(pScreen->myNum, X_WARNING, "[agp] AGP failed to initialize -- falling back to PCI mode.\n"); xf86DrvMsg(pScreen->myNum, X_WARNING, "[agp] Make sure you have the agpgart kernel module loaded.\n"); } /* Initialize PCIGART */ if (info->IsPCI && !R128DRIPciInit(info, pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } /* DRIScreenInit doesn't add all the common mappings. Add additional mappings here. */ if (!R128DRIMapInit(info, pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } /* DRIScreenInit adds the frame buffer map, but we need it as well */ { void *scratch_ptr; int scratch_int; DRIGetDeviceInfo(pScreen, &info->fbHandle, &scratch_int, &scratch_int, &scratch_int, &scratch_int, &scratch_ptr); } /* FIXME: When are these mappings unmapped? */ if (!R128InitVisualConfigs(pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] Visual configs initialized\n"); return TRUE;}/* Finish initializing the device-dependent DRI state, and call DRIFinishScreenInit() to complete the device-independent DRI initialization. */Bool R128DRIFinishScreenInit(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; R128InfoPtr info = R128PTR(pScrn); R128SAREAPrivPtr pSAREAPriv; R128DRIPtr pR128DRI; info->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; /* info->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ /* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit because *DRIKernelInit requires that the hardware lock is held by the X server, and the first time the hardware lock is grabbed is in DRIFinishScreenInit. */ if (!DRIFinishScreenInit(pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } /* Initialize the kernel data structures */ if (!R128DRIKernelInit(info, pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } /* Initialize the vertex buffers list */ if (!R128DRIBufInit(info, pScreen)) { R128DRICloseScreen(pScreen); return FALSE; } /* Initialize IRQ */ R128DRIIrqInit(info, pScreen); /* Initialize and start the CCE if required */ R128DRICCEInit(pScrn); pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); pR128DRI = (R128DRIPtr)info->pDRIInfo->devPrivate; pR128DRI->deviceID = info->Chipset; pR128DRI->width = pScrn->virtualX; pR128DRI->height = pScrn->virtualY; pR128DRI->depth = pScrn->depth; pR128DRI->bpp = pScrn->bitsPerPixel; pR128DRI->IsPCI = info->IsPCI; pR128DRI->AGPMode = info->agpMode; pR128DRI->frontOffset = info->frontOffset; pR128DRI->frontPitch = info->frontPitch; pR128DRI->backOffset = info->backOffset; pR128DRI->backPitch = info->backPitch; pR128DRI->depthOffset = info->depthOffset; pR128DRI->depthPitch = info->depthPitch; pR128DRI->spanOffset = info->spanOffset; pR128DRI->textureOffset = info->textureOffset; pR128DRI->textureSize = info->textureSize; pR128DRI->log2TexGran = info->log2TexGran; pR128DRI->registerHandle = info->registerHandle; pR128DRI->registerSize = info->registerSize; pR128DRI->agpTexHandle = info->agpTexHandle; pR128DRI->agpTexMapSize = info->agpTexMapSize; pR128DRI->log2AGPTexGran = info->log2AGPTexGran; pR128DRI->agpTexOffset = info->agpTexStart; pR128DRI->sarea_priv_offset = sizeof(XF86DRISAREARec); /* Have shadowfb run only while there is 3d active. */ if (info->allowPageFlip && info->drmMinor >= 5 ) { ShadowFBInit( pScreen, R128DRIRefreshArea ); } else if (info->allowPageFlip) { xf86DrvMsg(pScreen->myNum, X_WARNING, "[dri] Kernel module version 2.5.0 or newer is required for pageflipping.\n"); info->allowPageFlip = 0; } return TRUE;}/* The screen is being closed, so clean up any state and free any resources used by the DRI. */void R128DRICloseScreen(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; R128InfoPtr info = R128PTR(pScrn); drmR128Init drmInfo; /* Stop the CCE if it is still in use */ if (info->directRenderingEnabled) { R128CCE_STOP(pScrn, info); } if (info->irq) { drmCtlUninstHandler(info->drmFD); info->irq = 0; info->gen_int_cntl = 0; } /* De-allocate vertex buffers */ if (info->buffers) { drmUnmapBufs(info->buffers); info->buffers = NULL; } /* De-allocate all kernel resources */ memset(&drmInfo, 0, sizeof(drmR128Init)); drmInfo.func = DRM_R128_CLEANUP_CCE; drmCommandWrite(info->drmFD, DRM_R128_INIT, &drmInfo, sizeof(drmR128Init)); /* De-allocate all AGP resources */ if (info->agpTex) { drmUnmap(info->agpTex, info->agpTexMapSize); info->agpTex = NULL; } if (info->buf) { drmUnmap(info->buf, info->bufMapSize); info->buf = NULL; } if (info->ringReadPtr) { drmUnmap(info->ringReadPtr, info->ringReadMapSize); info->ringReadPtr = NULL; } if (info->ring) { drmUnmap(info->ring, info->ringMapSize); info->ring = NULL; } if (info->agpMemHandle != DRM_AGP_NO_HANDLE) { drmAgpUnbind(info->drmFD, info->agpMemHandle); drmAgpFree(info->drmFD, info->agpMemHandle); info->agpMemHandle = DRM_AGP_NO_HANDLE; drmAgpRelease(info->drmFD); } if (info->pciMemHandle) { drmScatterGatherFree(info->drmFD, info->pciMemHandle); info->pciMemHandle = 0; } /* De-allocate all DRI resources */ DRICloseScreen(pScreen); /* De-allocate all DRI data structures */ if (info->pDRIInfo) { if (info->pDRIInfo->devPrivate) { xfree(info->pDRIInfo->devPrivate); info->pDRIInfo->devPrivate = NULL; } DRIDestroyInfoRec(info->pDRIInfo); info->pDRIInfo = NULL; } if (info->pVisualConfigs) { xfree(info->pVisualConfigs); info->pVisualConfigs = NULL; } if (info->pVisualConfigsPriv) { xfree(info->pVisualConfigsPriv); info->pVisualConfigsPriv = NULL; }}/* Use callbacks from dri.c to support pageflipping mode for a single * 3d context without need for any specific full-screen extension. *//* Use the shadowfb module to maintain a list of dirty rectangles. * These are blitted to the back buffer to keep both buffers clean * during page-flipping when the 3d application isn't fullscreen. * * Unlike most use of the shadowfb code, both buffers are in video memory. * * An alternative to this would be to organize for all on-screen drawing * operations to be duplicated for the two buffers. That might be * faster, but seems like a lot more work... */static void R128DRIRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox){ R128InfoPtr info = R128PTR(pScrn); int i; R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScrn->pScreen); /* Don't want to do this when no 3d is active and pages are * right-way-round */ if (!pSAREAPriv->pfAllowPageFlip && pSAREAPriv->pfCurrentPage == 0) return; (*info->accel->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, (CARD32)(-1), -1); for (i = 0 ; i < num ; i++, pbox++) { int xa = max(pbox->x1, 0), xb = min(pbox->x2, pScrn->virtualX-1); int ya = max(pbox->y1, 0), yb = min(pbox->y2, pScrn->virtualY-1); if (xa <= xb && ya <= yb) { (*info->accel->SubsequentScreenToScreenCopy)(pScrn, xa, ya, xa + info->backX, ya + info->backY, xb - xa + 1, yb - ya + 1); } }}static void R128EnablePageFlip(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; R128InfoPtr info = R128PTR(pScrn); R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen); if (info->allowPageFlip) { /* Duplicate the frontbuffer to the backbuffer */ (*info->accel->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, (CARD32)(-1), -1); (*info->accel->SubsequentScreenToScreenCopy)(pScrn, 0, 0, info->backX, info->backY, pScrn->virtualX, pScrn->virtualY); pSAREAPriv->pfAllowPageFlip = 1; }}static void R128DisablePageFlip(ScreenPtr pScreen){ /* Tell the clients not to pageflip. How? * -- Field in sarea, plus bumping the window counters. * -- DRM needs to cope with Front-to-Back swapbuffers. */ R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen); pSAREAPriv->pfAllowPageFlip = 0;}static void R128DRITransitionSingleToMulti3d(ScreenPtr pScreen){ R128DisablePageFlip(pScreen);}static void R128DRITransitionMultiToSingle3d(ScreenPtr pScreen){ /* Let the remaining 3d app start page flipping again */ R128EnablePageFlip(pScreen);}static void R128DRITransitionTo3d(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; R128InfoPtr info = R128PTR(pScrn); R128EnablePageFlip(pScreen); info->have3DWindows = 1; if (info->cursor_start) xf86ForceHWCursor(pScreen, TRUE);}static void R128DRITransitionTo2d(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; R128InfoPtr info = R128PTR(pScrn); R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen); /* Try flipping back to the front page if necessary */ if (pSAREAPriv->pfCurrentPage == 1) drmCommandNone(info->drmFD, DRM_R128_FLIP); /* Shut down shadowing if we've made it back to the front page */ if (pSAREAPriv->pfCurrentPage == 0) { R128DisablePageFlip(pScreen); } else { xf86DrvMsg(pScreen->myNum, X_WARNING, "[dri] R128DRITransitionTo2d: " "kernel failed to unflip buffers.\n"); } info->have3DWindows = 0; if (info->cursor_start) xf86ForceHWCursor(pScreen, FALSE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -