📄 atipreinit.c
字号:
/* * ATIPreInit -- * * This function is only called once per screen at the start of the first * server generation. */_X_EXPORT BoolATIPreInit( ScrnInfoPtr pScreenInfo, int flags){# define BIOS_SIZE 0x00010000U /* 64kB */ CARD8 BIOS[BIOS_SIZE];# define BIOSByte(_n) ((CARD8)(BIOS[_n]))# define BIOSWord(_n) ((CARD16)(BIOS[_n] | \ (BIOS[(_n) + 1] << 8)))# define BIOSLong(_n) ((CARD32)(BIOS[_n] | \ (BIOS[(_n) + 1] << 8) | \ (BIOS[(_n) + 2] << 16) | \ (BIOS[(_n) + 3] << 24))) unsigned int BIOSSize = 0; unsigned int ROMTable = 0, ClockTable = 0, FrequencyTable = 0; unsigned int LCDTable = 0, LCDPanelInfo = 0, VideoTable = 0; unsigned int HardwareTable = 0; char Buffer[128], *Message; ATIPtr pATI; GDevPtr pGDev; EntityInfoPtr pEntity; resPtr pResources; pciVideoPtr pVideo; DisplayModePtr pMode; unsigned long Block0Base; CARD32 IOValue; int i, j, AcceleratorVideoRAM = 0, ServerVideoRAM; int Numerator, Denominator; int MinX, MinY; ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0}; int DefaultmaxClock = 0; int minPitch, maxPitch = 0xFFU, maxHeight = 0; int ApertureSize = 0x00010000U; int ModeType = M_T_BUILTIN; LookupModeFlags Strategy = LOOKUP_CLOSEST_CLOCK; int DefaultDepth;# define pATIHW (&pATI->OldHW)#ifndef AVOID_CPIO xf86Int10InfoPtr pInt10Info = NULL; vbeInfoPtr pVBE; pointer pInt10Module, pDDCModule = NULL, pVBEModule = NULL; int VGAVideoRAM = 0; resRange Resources[2] = {{0, 0, 0}, _END};#endif /* AVOID_CPIO */ if (pScreenInfo->numEntities != 1) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Logic error: Number of attached entities not 1.\n"); return FALSE; } pATI = ATIPTR(pScreenInfo); if (pATI->iEntity != pScreenInfo->entityList[0]) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Logic error: Entity mismatch.\n"); return FALSE; } /* Register resources */ pEntity = xf86GetEntityInfo(pATI->iEntity); pGDev = pEntity->device; pResources = pEntity->resources; xfree(pEntity); if (!pResources) pResources = xf86RegisterResources(pATI->iEntity, NULL, pATI->SharedAccelerator ? ResShared : ResExclusive); if (pResources) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Unable to register the following bus resources:\n"); xf86PrintResList(0, pResources); xf86FreeResList(pResources); return FALSE; } ConfiguredMonitor = NULL; (void)memset(BIOS, 0, SizeOf(BIOS)); if (!(flags & PROBE_DETECT)) { xf86DrvMsg(pScreenInfo->scrnIndex, pATI->Chipset ? X_CONFIG : X_DEFAULT, "Chipset: \"%s\".\n", ATIChipsetNames[pATI->Chipset]); /* Promote chipset specification */ switch (pATI->Chipset) {#ifndef AVOID_CPIO case ATI_CHIPSET_IBMVGA: if (pATI->Adapter == ATI_ADAPTER_VGA) break; /* XXX */ /* Fall through */ case ATI_CHIPSET_VGAWONDER: pATI->Chipset = ATI_CHIPSET_ATIVGA; break; case ATI_CHIPSET_IBM8514: if (pATI->Adapter == ATI_ADAPTER_8514A) break; /* XXX */ /* Fall through */ case ATI_CHIPSET_MACH8: case ATI_CHIPSET_MACH32:#endif /* AVOID_CPIO */ case ATI_CHIPSET_MACH64: case ATI_CHIPSET_RAGE128: case ATI_CHIPSET_RADEON: pATI->Chipset = ATI_CHIPSET_ATI; break; default: break; } /* Set monitor */ pScreenInfo->monitor = pScreenInfo->confScreen->monitor; /* Set depth, bpp, etc. */ if ((pATI->Chipset != ATI_CHIPSET_ATI) || (pATI->Chip < ATI_CHIP_264CT)) { i = NoDepth24Support; /* No support for >8bpp either */ DefaultDepth = 8; } else { i = Support24bppFb | Support32bppFb; DefaultDepth = 0; } if (!xf86SetDepthBpp(pScreenInfo, DefaultDepth, 0, 0, i)) return FALSE; for (j = 0; ; j++) { static const CARD8 AllowedDepthBpp[][2] = {#ifndef AVOID_CPIO { 1, 1}, { 4, 4}, { 4, 8},#endif /* AVOID_CPIO */ { 8, 8}, {15, 16}, {16, 16}, {24, 24}, {24, 32} }; if (j < NumberOf(AllowedDepthBpp)) { if (pScreenInfo->depth > AllowedDepthBpp[j][0]) continue; if (pScreenInfo->depth == AllowedDepthBpp[j][0]) { if (pScreenInfo->bitsPerPixel > AllowedDepthBpp[j][1]) continue; if (pScreenInfo->bitsPerPixel == AllowedDepthBpp[j][1]) break; } } xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Driver does not support depth %d at fbbpp %d.\n", pScreenInfo->depth, pScreenInfo->bitsPerPixel); return FALSE; } xf86PrintDepthBpp(pScreenInfo); if ((i == NoDepth24Support) && (pScreenInfo->depth > 8)) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Depth %d is not supported through this adapter.\n", pScreenInfo->depth); return FALSE; } /* Pick up XF86Config options */ ATIProcessOptions(pScreenInfo, pATI); }#ifdef AVOID_CPIO else /* if (flags & PROBE_DETECT) */ { return TRUE; }#else /* AVOID_CPIO */#ifdef TV_OUT pATI->pVBE = NULL; pATI->pInt10 = NULL;#endif /* TV_OUT */ /* * If there is an ix86-style BIOS, ensure its initialisation entry point * has been executed, and retrieve DDC and VBE information from it. */ if (!(pInt10Module = ATILoadModule(pScreenInfo, "int10", ATIint10Symbols))) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unable to load int10 module.\n"); } else if (!(pInt10Info = xf86InitInt10(pATI->iEntity))) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unable to initialise int10 interface.\n"); } else { if (!(pDDCModule = ATILoadModule(pScreenInfo, "ddc", ATIddcSymbols))) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unable to load ddc module.\n"); } else if (!(pVBEModule = ATILoadModule(pScreenInfo, "vbe", ATIvbeSymbols))) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unable to load vbe module.\n"); } else { if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) { ConfiguredMonitor = vbeDoEDID(pVBE, pDDCModule);#ifdef TV_OUT pATI->pInt10 = pInt10Info; pATI->pVBE = pVBE; pVBE = NULL;#else vbeFree(pVBE);#endif /* TV_OUT */ }#ifndef TV_OUT xf86UnloadSubModule(pVBEModule);#endif /* TV_OUT */ } if (!(flags & PROBE_DETECT)) { /* Validate, then make a private copy of, the initialised BIOS */ CARD8 *pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4); if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || !pBIOS[2]) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unable to correctly retrieve adapter BIOS.\n"); } else { BIOSSize = pBIOS[2] << 9; if (BIOSSize > BIOS_SIZE) BIOSSize = BIOS_SIZE; (void)memcpy(BIOS, pBIOS, BIOSSize); } } }#ifndef TV_OUT /* De-activate int10 */ xf86FreeInt10(pInt10Info); xf86UnloadSubModule(pInt10Module);#else pInt10Info = NULL;#endif /* TV_OUT */ if (flags & PROBE_DETECT) { xf86UnloadSubModule(pDDCModule); return TRUE; } if (ConfiguredMonitor) { xf86PrintEDID(ConfiguredMonitor); xf86SetDDCproperties(pScreenInfo, ConfiguredMonitor); } /* DDC module is no longer needed at this point */ xf86UnloadSubModule(pDDCModule);#endif /* AVOID_CPIO */ pATI->Block0Base = 0; /* Might no longer be valid */ if ((pVideo = pATI->PCIInfo)) { if (pATI->CPIODecoding == BLOCK_IO) pATI->CPIOBase = pVideo->ioBase[1]; /* Set MMIO address from PCI configuration space, if available */ if ((pATI->Block0Base = pVideo->memBase[2])) { if (pATI->Block0Base >= (CARD32)(-1 << pVideo->size[2])) pATI->Block0Base = 0; else pATI->Block0Base += 0x0400U; } }#ifdef AVOID_CPIO pScreenInfo->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT | RAC_CURSOR;#else /* AVOID_CPIO */ pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT | RAC_CURSOR; pScreenInfo->racMemFlags = RAC_FB | RAC_CURSOR;#endif /* AVOID_CPIO */ /* Deal with ChipID & ChipRev overrides */ if (pGDev->chipID >= 0) { ATIChipType Chip; Chip = ATIChipID(pGDev->chipID, (pGDev->chipRev < 0) ? pATI->ChipRev : pGDev->chipRev); if (Chip != pATI->Chip) { pATI->Chip = Chip; pATI->ChipType = pGDev->chipID; if (pGDev->chipRev < 0) { xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Driver messages reflect ChipID 0x%04X override.\n", pATI->ChipType); } else { pATI->ChipRev = pGDev->chipRev; pATI->ChipVersion = GetBits(pATI->ChipRev, GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV)); pATI->ChipFoundry = GetBits(pATI->ChipRev, GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); pATI->ChipRevision = GetBits(pATI->ChipRev, GetBits(CFG_CHIP_REVISION, CFG_CHIP_REV)); xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Driver messages reflect ChipID 0x%04X and ChipRev 0x%02X" " overrides.\n", pATI->ChipType, pATI->ChipRev); } } } /* Finish private area initialisation */ pATI->DAC = ATI_DAC_GENERIC;#ifndef AVOID_CPIO pATI->NewHW.SetBank = ATIx8800SetBank; pATI->BankInfo.SetSourceBank = ATIx8800SetRead; pATI->BankInfo.SetDestinationBank = ATIx8800SetWrite;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -