📄 radeon_dri.c
字号:
info->pLibDRMVersion = drmGetLibVersion(info->drmFD); if (info->pLibDRMVersion == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] RADEONDRIGetVersion failed because libDRM is really " "way to old to even get a version number out of it.\n" "[dri] Disabling DRI.\n"); return FALSE; } if (info->pLibDRMVersion->version_major != 1 || info->pLibDRMVersion->version_minor < 2) { /* incompatible drm library version */ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] RADEONDRIGetVersion failed because of a " "version mismatch.\n" "[dri] libdrm.a module version is %d.%d.%d but " "version 1.2.x is needed.\n" "[dri] Disabling DRI.\n", info->pLibDRMVersion->version_major, info->pLibDRMVersion->version_minor, info->pLibDRMVersion->version_patchlevel); drmFreeVersion(info->pLibDRMVersion); info->pLibDRMVersion = NULL; return FALSE; } /* Create a bus Id */ if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) { busId = DRICreatePCIBusID(info->PciInfo); } else { busId = xalloc(64); sprintf(busId, "PCI:%d:%d:%d", info->PciInfo->bus, info->PciInfo->device, info->PciInfo->func); } /* Low level DRM open */ fd = drmOpen(RADEON_DRIVER_NAME, busId); xfree(busId); if (fd < 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] RADEONDRIGetVersion failed to open the DRM\n" "[dri] Disabling DRI.\n"); return FALSE; } /* Get DRM version & close DRM */ info->pKernelDRMVersion = drmGetVersion(fd); drmClose(fd); if (info->pKernelDRMVersion == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] RADEONDRIGetVersion failed to get the DRM version\n" "[dri] Disabling DRI.\n"); return FALSE; } /* Now check if we qualify */ if (info->ChipFamily >= CHIP_FAMILY_R300) { req_minor = 17; req_patch = 0; } else if (info->IsIGP) { req_minor = 10; req_patch = 0; } else { /* Many problems have been reported with 1.7 in the 2.4 kernel */ req_minor = 8; req_patch = 0; } /* We don't, bummer ! */ if (info->pKernelDRMVersion->version_major != 1 || info->pKernelDRMVersion->version_minor < req_minor || (info->pKernelDRMVersion->version_minor == req_minor && info->pKernelDRMVersion->version_patchlevel < req_patch)) { /* Incompatible drm version */ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] RADEONDRIGetVersion failed because of a version " "mismatch.\n" "[dri] radeon.o kernel module version is %d.%d.%d " "but version 1.%d.%d or newer is needed.\n" "[dri] Disabling DRI.\n", info->pKernelDRMVersion->version_major, info->pKernelDRMVersion->version_minor, info->pKernelDRMVersion->version_patchlevel, req_minor, req_patch); drmFreeVersion(info->pKernelDRMVersion); info->pKernelDRMVersion = NULL; return FALSE; } return TRUE;}/* Initialize the screen-specific data structures for the DRI and the * Radeon. This is the main entry point to the device-specific * initialization code. It calls device-independent DRI functions to * create the DRI data structures and initialize the DRI state. */Bool RADEONDRIScreenInit(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn); DRIInfoPtr pDRIInfo; RADEONDRIPtr pRADEONDRI; info->DRICloseScreen = NULL; switch (info->CurrentLayout.pixel_code) { case 8: case 15: case 24: /* These modes are not supported (yet). */ xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] RADEONInitVisualConfigs failed " "(depth %d not supported). " "Disabling DRI.\n", info->CurrentLayout.pixel_code); return FALSE; /* Only 16 and 32 color depths are supports currently. */ case 16: case 32: break; } radeon_drm_page_size = getpagesize(); /* Create the DRI data structure, and fill it in before calling the * DRIScreenInit(). */ if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; info->pDRIInfo = pDRIInfo; pDRIInfo->drmDriverName = RADEON_DRIVER_NAME; if ( (info->ChipFamily >= CHIP_FAMILY_R300) ) { pDRIInfo->clientDriverName = R300_DRIVER_NAME; } else if ( info->ChipFamily >= CHIP_FAMILY_R200 ) pDRIInfo->clientDriverName = R200_DRIVER_NAME; else pDRIInfo->clientDriverName = RADEON_DRIVER_NAME; if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) { pDRIInfo->busIdString = DRICreatePCIBusID(info->PciInfo); } else { pDRIInfo->busIdString = xalloc(64); sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", info->PciInfo->bus, info->PciInfo->device, info->PciInfo->func); } pDRIInfo->ddxDriverMajorVersion = info->allowColorTiling ? RADEON_VERSION_MAJOR_TILED : RADEON_VERSION_MAJOR; pDRIInfo->ddxDriverMinorVersion = RADEON_VERSION_MINOR; pDRIInfo->ddxDriverPatchVersion = RADEON_VERSION_PATCH; pDRIInfo->frameBufferPhysicalAddress = (void *)info->LinearAddr; pDRIInfo->frameBufferSize = info->FbMapSize - info->FbSecureSize; pDRIInfo->frameBufferStride = (pScrn->displayWidth * info->CurrentLayout.pixel_bytes); pDRIInfo->ddxDrawableTableEntry = RADEON_MAX_DRAWABLES; pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES < RADEON_MAX_DRAWABLES ? SAREA_MAX_DRAWABLES : RADEON_MAX_DRAWABLES); /* kill DRIAdjustFrame. We adjust sarea frame info ourselves to work correctly with pageflip + mergedfb/color tiling */ pDRIInfo->wrap.AdjustFrame = NULL;#ifdef PER_CONTEXT_SAREA /* This is only here for testing per-context SAREAs. When used, the magic number below would be properly defined in a header file. */ info->perctx_sarea_size = 64 * 1024;#endif#ifdef NOT_DONE /* FIXME: Need to extend DRI protocol to pass this size back to * client for SAREA mapping that includes a device private record */ pDRIInfo->SAREASize = ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ /* + shared memory device private rec */#else /* For now the mapping works by using a fixed size defined * in the SAREA header */ if (sizeof(XF86DRISAREARec)+sizeof(RADEONSAREAPriv) > SAREA_MAX) { ErrorF("Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX;#endif if (!(pRADEONDRI = (RADEONDRIPtr)xcalloc(sizeof(RADEONDRIRec),1))) { DRIDestroyInfoRec(info->pDRIInfo); info->pDRIInfo = NULL; return FALSE; } pDRIInfo->devPrivate = pRADEONDRI; pDRIInfo->devPrivateSize = sizeof(RADEONDRIRec); pDRIInfo->contextSize = sizeof(RADEONDRIContextRec); pDRIInfo->CreateContext = RADEONCreateContext; pDRIInfo->DestroyContext = RADEONDestroyContext; pDRIInfo->SwapContext = RADEONDRISwapContext; pDRIInfo->InitBuffers = RADEONDRIInitBuffers; pDRIInfo->MoveBuffers = RADEONDRIMoveBuffers; pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; pDRIInfo->TransitionTo2d = RADEONDRITransitionTo2d; pDRIInfo->TransitionTo3d = RADEONDRITransitionTo3d; pDRIInfo->TransitionSingleToMulti3D = RADEONDRITransitionSingleToMulti3d; pDRIInfo->TransitionMultiToSingle3D = RADEONDRITransitionMultiToSingle3d; pDRIInfo->createDummyCtx = TRUE; pDRIInfo->createDummyCtxPriv = FALSE; if (!DRIScreenInit(pScreen, pDRIInfo, &info->drmFD)) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] DRIScreenInit failed. Disabling DRI.\n"); xfree(pDRIInfo->devPrivate); pDRIInfo->devPrivate = NULL; DRIDestroyInfoRec(pDRIInfo); pDRIInfo = NULL; return FALSE; } /* Initialize AGP */ if (info->cardType==CARD_AGP && !RADEONDRIAgpInit(info, pScreen)) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP failed to initialize. Disabling the DRI.\n" ); xf86DrvMsg(pScreen->myNum, X_INFO, "[agp] You may want to make sure the agpgart kernel " "module\nis loaded before the radeon kernel module.\n"); RADEONDRICloseScreen(pScreen); return FALSE; } /* Initialize PCI */ if ((info->cardType!=CARD_AGP) && !RADEONDRIPciInit(info, pScreen)) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[pci] PCI failed to initialize. Disabling the DRI.\n" ); RADEONDRICloseScreen(pScreen); return FALSE; } /* DRIScreenInit doesn't add all the * common mappings. Add additional * mappings here. */ if (!RADEONDRIMapInit(info, pScreen)) { RADEONDRICloseScreen(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 (!RADEONInitVisualConfigs(pScreen)) { RADEONDRICloseScreen(pScreen); return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] Visual configs initialized\n"); return TRUE;}static Bool RADEONDRIDoCloseScreen(int scrnIndex, ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn); RADEONDRICloseScreen(pScreen); pScreen->CloseScreen = info->DRICloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen);}/* Finish initializing the device-dependent DRI state, and call * DRIFinishScreenInit() to complete the device-independent DRI * initialization. */Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn); RADEONSAREAPrivPtr pSAREAPriv; RADEONDRIPtr pRADEONDRI; 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)) { RADEONDRICloseScreen(pScreen); return FALSE; } /* Initialize the kernel data structures */ if (!RADEONDRIKernelInit(info, pScreen)) { RADEONDRICloseScreen(pScreen); return FALSE; } /* Initialize the vertex buffers list */ if (!RADEONDRIBufInit(info, pScreen)) { RADEONDRICloseScreen(pScreen); return FALSE; } /* Initialize IRQ */ RADEONDRIIrqInit(info, pScreen); /* Initialize kernel GART memory manager */ RADEONDRIGartHeapInit(info, pScreen); /* Initialize and start the CP if required */ RADEONDRICPInit(pScrn); /* Initialize the SAREA private data structure */ pSAREAPriv = (RADEONSAREAPrivPtr)DRIGetSAREAPrivate(pScreen); memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); pRADEONDRI = (RADEONDRIPtr)info->pDRIInfo->devPrivate; pRADEONDRI->deviceID = info->Chipset; pRADEONDRI->width = pScrn->virtualX; pRADEONDRI->height = pScrn->virtualY; pRADEONDRI->depth = pScrn->depth; pRADEONDRI->bpp = pScrn->bitsPerPixel; pRADEONDRI->IsPCI = (info->cardType!=CARD_AGP); pRADEONDRI->AGPMode = info->agpMode; pRADEONDRI->frontOffset = info->frontOffset; pRADEONDRI->frontPitch = info->frontPitch; pRADEONDRI->backOffset = info->backOffset; pRADEONDRI->backPitch = info->backPitch; pRADEONDRI->depthOffset = info->depthOffset; pRADEONDRI->depthPitch = info->depthPitch; pRADEONDRI->textureOffset = info->textureOffset; pRADEONDRI->textureSize = info->textureSize; pRADEONDRI->log2TexGran = info->log2TexGran; pRADEONDRI->registerHandle = info->registerHandle; pRADEONDRI->registerSize = info->registerSize; pRADEONDRI->statusHandle = info->ringReadPtrHandle; pRADEONDRI->statusSize = info->ringReadMapSize; pRADEONDRI->gartTexHandle = info->gartTexHandle; pRADEONDRI->gartTexMapSize = info->gartTexMapSize; pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran; pRADEONDRI->gartTexOffset = info->gartTexStart; pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);#ifdef PER_CONTEXT_SAREA /* Set per-context SAREA size */ pRADEONDRI->perctx_sarea_size = info->perctx_sarea_size;#endif info->directRenderingInited = TRUE; /* Wrap CloseScreen */ info->DRICloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = RADEONDRIDoCloseScreen; return TRUE;}void RADEONDRIInitPageFlip(ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn);#ifdef USE_XAA /* Have shadowfb run only while there is 3d active. This must happen late, * after XAAInit has been called */ if (!info->useEXA) { if (!ShadowFBInit( pScreen, RADEONDRIRefreshArea )) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ShadowFB init failed, Page Flipping disabled\n"); info->allowPageFlip = 0; } else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB initialized for Page Flipping\n"); } else#endif /* USE_XAA */ { info->allowPageFlip = 0; }}/** * This function will attempt to get the Radeon hardware back into shape * after a resume from disc. * * Charl P. Botha <http://cpbotha.net>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -