📄 r128_driver.c
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c,v 1.88 2004/01/29 02:51:17 dawes Exp $ *//* * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, * Precision Insight, Inc., Cedar Park, Texas, and * VA Linux Systems Inc., Fremont, California. * * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation on the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial * portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */#ifdef HAVE_CONFIG_H#include "config.h"#endif/* * Authors: * Rickard E. Faith <faith@valinux.com> * Kevin E. Martin <martin@valinux.com> * Gareth Hughes <gareth@valinux.com> * * Credits: * * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for * providing source code to their 3.3.x Rage 128 driver. Portions of * this file are based on the initialization code for that driver. * * References: * * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April * 1999. * * RAGE 128 Software Development Manual (Technical Reference Manual P/N * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. * * This server does not yet support these XFree86 4.0 features: * DDC1 & DDC2 * shadowfb * overlay planes * * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. * * Dualhead support - Alex Deucher <agd5f@yahoo.com> */#include <string.h>#include <stdio.h> /* Driver data structures */#include "r128.h"#include "r128_probe.h"#include "r128_reg.h"#include "r128_version.h"#ifdef XF86DRI#define _XF86DRI_SERVER_#include "r128_dri.h"#include "r128_common.h"#include "r128_sarea.h"#endif#include "fb.h" /* colormap initialization */#include "micmap.h" /* X and server generic header files */#include "xf86.h"#include "xf86_OSproc.h"#include "xf86RAC.h"#include "xf86Resources.h"#include "xf86cmap.h"#include "xf86xv.h"#include "vbe.h" /* fbdevhw & vgahw */#ifdef WITH_VGAHW#include "vgaHW.h"#endif#include "fbdevhw.h"#include "dixstruct.h" /* DPMS support. */#define DPMS_SERVER#include <X11/extensions/dpms.h>#include "atipciids.h"#include "r128_chipset.h"#ifndef MAX#define MAX(a,b) ((a)>(b)?(a):(b))#endif#define USE_CRT_ONLY 0 /* Forward definitions for driver functions */static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen);static Bool R128SaveScreen(ScreenPtr pScreen, int mode);static void R128Save(ScrnInfoPtr pScrn);static void R128Restore(ScrnInfoPtr pScrn);static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);static void R128DisplayPowerManagementSetLCD(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);typedef enum { OPTION_NOACCEL, OPTION_SW_CURSOR, OPTION_DAC_6BIT, OPTION_DAC_8BIT,#ifdef XF86DRI OPTION_XV_DMA, OPTION_IS_PCI, OPTION_CCE_PIO, OPTION_NO_SECURITY, OPTION_USEC_TIMEOUT, OPTION_AGP_MODE, OPTION_AGP_SIZE, OPTION_RING_SIZE, OPTION_BUFFER_SIZE, OPTION_PAGE_FLIP,#endif#if USE_CRT_ONLY /* FIXME: Disable CRTOnly until it is tested */ OPTION_CRT,#endif OPTION_DISPLAY, OPTION_PANEL_WIDTH, OPTION_PANEL_HEIGHT, OPTION_PROG_FP_REGS, OPTION_FBDEV, OPTION_VIDEO_KEY, OPTION_SHOW_CACHE, OPTION_VGA_ACCESS} R128Opts;static const OptionInfoRec R128Options[] = { { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE },#ifdef XF86DRI { OPTION_XV_DMA, "DMAForXv", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE }, { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, { OPTION_BUFFER_SIZE, "BufferSize", OPTV_INTEGER, {0}, FALSE }, { OPTION_PAGE_FLIP, "EnablePageFlip", OPTV_BOOLEAN, {0}, FALSE },#endif { OPTION_DISPLAY, "Display", OPTV_STRING, {0}, FALSE }, { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, { OPTION_PROG_FP_REGS, "ProgramFPRegs", OPTV_BOOLEAN, {0}, FALSE }, { 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 }};_X_EXPORT const OptionInfoRec *R128OptionsWeak(void) { return R128Options; }R128RAMRec R128RAM[] = { /* Memory Specifications From RAGE 128 Software Development Manual (Technical Reference Manual P/N SDK-G04000 Rev 0.01), page 3-21. */ { 4, 4, 3, 3, 1, 3, 1, 16, 12, "128-bit SDR SGRAM 1:1" }, { 4, 8, 3, 3, 1, 3, 1, 17, 13, "64-bit SDR SGRAM 1:1" }, { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SGRAM 2:1" }, { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SGRAM" },};#ifdef WITH_VGAHWstatic const char *vgahwSymbols[] = { "vgaHWFreeHWRec", "vgaHWGetHWRec", "vgaHWGetIndex", "vgaHWLock", "vgaHWRestore", "vgaHWSave", "vgaHWUnlock", NULL};#endifstatic const char *fbdevHWSymbols[] = { "fbdevHWInit", "fbdevHWUseBuildinMode", "fbdevHWGetLineLength", "fbdevHWGetVidmem", "fbdevHWDPMSSet", "fbdevHWDPMSSetWeak", /* colormap */ "fbdevHWLoadPalette", "fbdevHWLoadPaletteWeak", /* ScrnInfo hooks */ "fbdevHWAdjustFrame", "fbdevHWAdjustFrameWeak", "fbdevHWEnterVT", "fbdevHWLeaveVT", "fbdevHWModeInit", "fbdevHWRestore", "fbdevHWSave", "fbdevHWSwitchMode", "fbdevHWSwitchModeWeak", "fbdevHWValidModeWeak", "fbdevHWMapMMIO", "fbdevHWMapVidmem", "fbdevHWUnmapMMIO", "fbdevHWUnmapVidmem", NULL};static const char *ddcSymbols[] = { "xf86PrintEDID", "xf86DoEDID_DDC1", "xf86DoEDID_DDC2", NULL};static const char *i2cSymbols[] = { "xf86CreateI2CBusRec", "xf86I2CBusInit", NULL};static const char *fbSymbols[] = { "fbPictureInit", "fbScreenInit", NULL};static const char *xaaSymbols[] = { "XAACreateInfoRec", "XAADestroyInfoRec", "XAAInit", NULL};static const char *ramdacSymbols[] = { "xf86CreateCursorInfoRec", "xf86DestroyCursorInfoRec", "xf86InitCursor", NULL};#ifdef XF86DRIstatic const char *drmSymbols[] = { "drmAddBufs", "drmAddMap", "drmAgpAcquire", "drmAgpAlloc", "drmAgpBase", "drmAgpBind", "drmAgpDeviceId", "drmAgpEnable", "drmAgpFree", "drmAgpGetMode", "drmAgpRelease", "drmAgpUnbind", "drmAgpVendorId", "drmAvailable", "drmCommandNone", "drmCommandRead", "drmCommandWrite", "drmCommandWriteRead", "drmCtlInstHandler", "drmCtlUninstHandler", "drmFreeBufs", "drmFreeVersion", "drmGetInterruptFromBusID", "drmGetLibVersion", "drmGetVersion", "drmMap", "drmMapBufs", "drmDMA", "drmScatterGatherAlloc", "drmScatterGatherFree", "drmUnmap", "drmUnmapBufs", NULL};static const char *driSymbols[] = { "DRICloseScreen", "DRICreateInfoRec", "DRIDestroyInfoRec", "DRIFinishScreenInit", "DRIGetDeviceInfo", "DRIGetSAREAPrivate", "DRILock", "DRIQueryVersion", "DRIScreenInit", "DRIUnlock", "GlxSetVisualConfigs", "DRICreatePCIBusID", NULL};static const char *driShadowFBSymbols[] = { "ShadowFBInit", NULL};#endifstatic const char *vbeSymbols[] = { "VBEInit", "vbeDoEDID", "vbeFree", NULL};static const char *int10Symbols[] = { "xf86InitInt10", "xf86FreeInt10", "xf86int10Addr", NULL};void R128LoaderRefSymLists(void){ /* * Tell the loader about symbols from other modules that this module might * refer to. */ xf86LoaderRefSymLists(#ifdef WITH_VGAHW vgahwSymbols,#endif fbSymbols, xaaSymbols, ramdacSymbols,#ifdef XF86DRI drmSymbols, driSymbols, driShadowFBSymbols,#endif fbdevHWSymbols, int10Symbols, vbeSymbols, /* ddcsymbols, */ i2cSymbols, /* shadowSymbols, */ NULL);}#ifdef XFree86LOADERint getR128EntityIndex(void){ int *r128_entity_index = LoaderSymbol("gR128EntityIndex"); if (!r128_entity_index) return -1; else return *r128_entity_index;}#elseextern int gR128EntityIndex;int getR128EntityIndex(void){ return gR128EntityIndex;}#endifR128EntPtr R128EntPriv(ScrnInfoPtr pScrn){ DevUnion *pPriv; R128InfoPtr info = R128PTR(pScrn); pPriv = xf86GetEntityPrivate(info->pEnt->index, getR128EntityIndex()); return pPriv->ptr;}/* Allocate our private R128InfoRec. */static Bool R128GetRec(ScrnInfoPtr pScrn){ if (pScrn->driverPrivate) return TRUE; pScrn->driverPrivate = xnfcalloc(sizeof(R128InfoRec), 1); return TRUE;}/* Free our private R128InfoRec. */static void R128FreeRec(ScrnInfoPtr pScrn){ if (!pScrn || !pScrn->driverPrivate) return; xfree(pScrn->driverPrivate); pScrn->driverPrivate = NULL;}/* Memory map the MMIO region. Used during pre-init and by R128MapMem, below. */static Bool R128MapMMIO(ScrnInfoPtr pScrn){ R128InfoPtr info = R128PTR(pScrn); if (info->FBDev) { info->MMIO = fbdevHWMapMMIO(pScrn); } else { info->MMIO = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, info->PciTag, info->MMIOAddr, R128_MMIOSIZE); } if (!info->MMIO) return FALSE; return TRUE;}/* Unmap the MMIO region. Used during pre-init and by R128UnmapMem, below. */static Bool R128UnmapMMIO(ScrnInfoPtr pScrn){ R128InfoPtr info = R128PTR(pScrn);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -