diff options
author | Alan Hourihane <alanh@tungstengraphics.com> | 2008-02-27 17:30:21 +0000 |
---|---|---|
committer | Alan Hourihane <alanh@tungstengraphics.com> | 2008-02-27 17:30:21 +0000 |
commit | 8689f7e348671f65e4b8c425ea4674fa33fc2900 (patch) | |
tree | 55e6d0af861c23466263508d6935b05e305c4d9d /hw/xfree86 | |
parent | 06a58f2d5363e13069315beac8934cca1aab54db (diff) | |
parent | 41aea6194bd29ab34cc166b3fd90eee64299ddf8 (diff) |
Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into glucose-2
Conflicts:
hw/xfree86/Makefile.am
hw/xfree86/dri/dri.c
hw/xfree86/dri/dristruct.h
hw/xgl/glx/xglx.c
hw/xgl/xglscreen.c
render/picture.c
Diffstat (limited to 'hw/xfree86')
124 files changed, 2204 insertions, 1983 deletions
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index 4c46d5e69..7200dc7f5 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -8,6 +8,10 @@ if GLUCOSE GLUCOSE_DIR=glucose endif +if DRI2 +DRI2_SUBDIR = dri2 +endif + if XF86UTILS XF86UTILS_SUBDIR = utils endif @@ -25,12 +29,21 @@ DOC_SUBDIR = doc SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support parser rac \ ramdac shadowfb vbe vgahw xaa $(MFB_SUBDIR) $(CFB_SUBDIR) \ xf8_16bpp loader dixmods exa modes \ +<<<<<<< HEAD:hw/xfree86/Makefile.am $(DRI_SUBDIR) $(XF86UTILS_SUBDIR) $(DOC_SUBDIR) $(GLUCOSE_DIR) +======= + $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) $(DOC_SUBDIR) +>>>>>>> 41aea6194bd29ab34cc166b3fd90eee64299ddf8:hw/xfree86/Makefile.am DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ parser rac ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp \ +<<<<<<< HEAD:hw/xfree86/Makefile.am xf8_16bpp xf8_32bpp loader dixmods dri exa modes \ utils doc glucose +======= + xf8_16bpp xf8_32bpp loader dixmods dri dri2 exa modes \ + utils doc +>>>>>>> 41aea6194bd29ab34cc166b3fd90eee64299ddf8:hw/xfree86/Makefile.am bin_PROGRAMS = Xorg diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am index 5499b694e..4f0a2d6b3 100644 --- a/hw/xfree86/common/Makefile.am +++ b/hw/xfree86/common/Makefile.am @@ -31,7 +31,7 @@ BUILT_SOURCES = xf86DefModeSet.c AM_LDFLAGS = -r libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \ xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c \ - xf86DoProbe.c xf86DoScanPci.c xf86Events.c \ + xf86DoProbe.c xf86Events.c \ xf86Globals.c xf86AutoConfig.c \ xf86MiscExt.c xf86Option.c \ xf86VidMode.c xf86fbman.c xf86cmap.c \ @@ -85,9 +85,8 @@ EXTRA_DIST = \ xf86Version.h \ xorgVersion.h \ xf86Date.h \ - xf86DefModes.c \ $(MODEDEFSOURCES) \ - modeline2c.pl \ + modeline2c.awk \ $(DISTKBDSOURCES) if LNXACPI diff --git a/hw/xfree86/common/modeline2c.awk b/hw/xfree86/common/modeline2c.awk index 7a893300c..d4b9649c8 100644 --- a/hw/xfree86/common/modeline2c.awk +++ b/hw/xfree86/common/modeline2c.awk @@ -29,7 +29,7 @@ # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# Usage: modeline2c.awk < modefile > xf86DefModes.c +# Usage: modeline2c.awk < modefile > xf86DefModeSet.c # BEGIN { diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 064107428..4b3e10463 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -57,9 +57,9 @@ /* General parameters */ extern int xf86DoConfigure; extern Bool xf86DoConfigurePass1; -extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */ -extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */ -extern int xf86PixmapIndex; +extern DevPrivateKey xf86ScreenKey; +extern DevPrivateKey xf86CreateRootWindowKey; +extern DevPrivateKey xf86PixmapKey; extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ extern const unsigned char byte_reversed[256]; extern ScrnInfoPtr xf86CurrentScreen; @@ -72,8 +72,8 @@ extern Bool sbusSlotClaimed; extern confDRIRec xf86ConfigDRI; extern Bool xf86inSuspend; -#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr)) - +#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \ + xf86ScreenKey)) #define XF86FLIP_PIXELS() \ do { \ if (xf86GetFlipPixels()) { \ @@ -337,8 +337,9 @@ int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, pointer value); Bool xf86IsUnblank(int mode); -void xf86AddModuleInfo(ModuleInfoPtr info, pointer module); -void xf86DeleteModuleInfo(int idx); +_X_DEPRECATED void xf86AddModuleInfo(pointer info, pointer module); +_X_DEPRECATED void xf86DeleteModuleInfo(int idx); +void xf86getsecs(long *, long *); /* xf86Debug.c */ #ifdef BUILDDEBUG diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c index c6e197216..da6c3f38d 100644 --- a/hw/xfree86/common/xf86AutoConfig.c +++ b/hw/xfree86/common/xf86AutoConfig.c @@ -184,7 +184,7 @@ videoPtrToDriverName(struct pci_device *dev) case 0x3d3d: return "glint"; case 0x1023: return "trident"; case 0x100c: return "tseng"; - case 0x1106: return "via"; + case 0x1106: return "openchrome"; case 0x15ad: return "vmware"; default: break; } diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 599f7a46e..f7ffac85e 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -290,8 +290,10 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) if (entityIndex == -1) return; if (xf86Entities[entityIndex]->inUse && - !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) - FatalError("Requested Entity already in use!\n"); + !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) { + ErrorF("Requested Entity already in use!\n"); + return; + } pScrn->numEntities++; pScrn->entityList = xnfrealloc(pScrn->entityList, diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 622c31850..605c6b347 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -733,7 +733,6 @@ typedef enum { FLAG_DISABLEMODINDEV, FLAG_MODINDEVALLOWNONLOCAL, FLAG_ALLOWMOUSEOPENFAIL, - FLAG_VTINIT, FLAG_VTSYSREQ, FLAG_XKBDISABLE, FLAG_PCIPROBE1, @@ -785,8 +784,6 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE }, { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN, {0}, FALSE }, - { FLAG_VTINIT, "VTInit", OPTV_STRING, - {0}, FALSE }, { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN, {0}, FALSE }, { FLAG_XKBDISABLE, "XkbDisable", OPTV_BOOLEAN, @@ -977,8 +974,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) #endif } - xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT); - if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1)) xf86Info.pciFlags = PCIProbe1; if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2)) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 85d4b2ea0..0daf1de44 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -49,8 +49,7 @@ #include "mi.h" -static unsigned long DGAGeneration = 0; -static int DGAScreenIndex = -1; +static DevPrivateKey DGAScreenKey = NULL; static int mieq_installed = 0; static Bool DGACloseScreen(int i, ScreenPtr pScreen); @@ -68,8 +67,8 @@ DGACopyModeInfo( _X_EXPORT int *XDGAEventBase = NULL; -#define DGA_GET_SCREEN_PRIV(pScreen) \ - ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr)) +#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey)) typedef struct _FakedVisualList{ @@ -116,11 +115,7 @@ DGAInit( if(!modes || num <= 0) return FALSE; - if(DGAGeneration != serverGeneration) { - if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - DGAGeneration = serverGeneration; - } + DGAScreenKey = &DGAScreenKey; if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec)))) return FALSE; @@ -148,7 +143,7 @@ DGAInit( modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; #endif - pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = DGACloseScreen; pScreenPriv->DestroyColormap = pScreen->DestroyColormap; @@ -176,7 +171,7 @@ DGAReInitModes( int i; /* No DGA? Ignore call (but don't make it look like it failed) */ - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return TRUE; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); @@ -350,7 +345,7 @@ xf86SetDGAMode( DGAModePtr pMode = NULL; /* First check if DGAInit was successful on this screen */ - if (DGAScreenIndex < 0) + if (DGAScreenKey == NULL) return BadValue; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); if (!pScreenPriv) @@ -485,7 +480,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) DGAModePtr pMode; PixmapPtr pPix; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -535,11 +530,12 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) _X_EXPORT Bool DGAAvailable(int index) { - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; - if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]-> - devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM)) + if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate( + &screenInfo.screens[index]->devPrivates, + xf86ScreenKey))->scrnIndex, MEM)) return FALSE; if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) @@ -553,7 +549,7 @@ DGAActive(int index) { DGAScreenPtr pScreenPriv; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -574,7 +570,7 @@ DGAShutdown() ScrnInfoPtr pScrn; int i; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return; for(i = 0; i < screenInfo.numScreens; i++) { @@ -904,7 +900,7 @@ DGAVTSwitch(void) /* Alternatively, this could send events to DGA clients */ - if(DGAScreenIndex >= 0) { + if(DGAScreenKey) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); if(pScreenPriv && pScreenPriv->current) @@ -921,7 +917,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down) DGAScreenPtr pScreenPriv; dgaEvent de; - if(DGAScreenIndex < 0) /* no DGA */ + if(DGAScreenKey == NULL) /* no DGA */ return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -945,7 +941,7 @@ DGAStealMotionEvent(int index, int dx, int dy) DGAScreenPtr pScreenPriv; dgaEvent de; - if(DGAScreenIndex < 0) /* no DGA */ + if(DGAScreenKey == NULL) /* no DGA */ return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -980,7 +976,7 @@ DGAStealButtonEvent(int index, int button, int is_down) DGAScreenPtr pScreenPriv; dgaEvent de; - if (DGAScreenIndex < 0) + if (DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -1006,7 +1002,7 @@ Bool DGAIsDgaEvent (xEvent *e) { int coreEquiv; - if (DGAScreenIndex < 0 || XDGAEventBase == 0) + if (DGAScreenKey == NULL || XDGAEventBase == 0) return FALSE; coreEquiv = e->u.u.type - *XDGAEventBase; if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify) @@ -1275,7 +1271,7 @@ DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents) int coreEquiv; /* no DGA */ - if (DGAScreenIndex < 0 || XDGAEventBase == 0) + if (DGAScreenKey == NULL || XDGAEventBase == 0) return; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c index 3aa83e882..4fb901aae 100644 --- a/hw/xfree86/common/xf86DPMS.c +++ b/hw/xfree86/common/xf86DPMS.c @@ -47,8 +47,7 @@ #ifdef DPMSExtension -static int DPMSGeneration = 0; -static int DPMSIndex = -1; +static DevPrivateKey DPMSKey = NULL; static Bool DPMSClose(int i, ScreenPtr pScreen); static int DPMSCount = 0; #endif @@ -61,19 +60,17 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; DPMSPtr pDPMS; pointer DPMSOpt; + MessageType enabled_from = X_INFO; - if (serverGeneration != DPMSGeneration) { - if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - DPMSGeneration = serverGeneration; - } + DPMSKey = &DPMSKey; if (DPMSDisabledSwitch) DPMSEnabled = FALSE; - if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1))) + if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey, + xcalloc(sizeof(DPMSRec), 1))) return FALSE; - pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); pScrn->DPMSSet = set; pDPMS->Flags = flags; DPMSOpt = xf86FindOption(pScrn->options, "dpms"); @@ -82,8 +79,8 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) = xf86SetBoolOption(pScrn->options, "dpms", FALSE)) && !DPMSDisabledSwitch) DPMSEnabled = TRUE; + enabled_from = X_CONFIG; xf86MarkOptionUsed(DPMSOpt); - xf86DrvMsg(pScreen->myNum, X_CONFIG, "DPMS enabled\n"); } else if (DPMSEnabledSwitch) { if (!DPMSDisabledSwitch) DPMSEnabled = TRUE; @@ -92,6 +89,8 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) else { pDPMS->Enabled = defaultDPMSEnabled; } + if (pDPMS->Enabled) + xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n"); pDPMS->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = DPMSClose; DPMSCount++; @@ -110,10 +109,10 @@ DPMSClose(int i, ScreenPtr pScreen) DPMSPtr pDPMS; /* This shouldn't happen */ - if (DPMSIndex < 0) + if (DPMSKey == NULL) return FALSE; - pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); /* This shouldn't happen */ if (!pDPMS) @@ -132,9 +131,9 @@ DPMSClose(int i, ScreenPtr pScreen) } xfree((pointer)pDPMS); - pScreen->devPrivates[DPMSIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL); if (--DPMSCount == 0) - DPMSIndex = -1; + DPMSKey = NULL; return pScreen->CloseScreen(i, pScreen); } @@ -144,30 +143,35 @@ DPMSClose(int i, ScreenPtr pScreen) * Device dependent DPMS mode setting hook. This is called whenever * the DPMS mode is to be changed. */ -_X_EXPORT void -DPMSSet(int level) +_X_EXPORT int +DPMSSet(ClientPtr client, int level) { - int i; + int rc, i; DPMSPtr pDPMS; ScrnInfoPtr pScrn; DPMSPowerLevel = level; - if (DPMSIndex < 0) - return; + if (DPMSKey == NULL) + return Success; - if (level != DPMSModeOn) - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverActive); + if (level != DPMSModeOn) { + rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (rc != Success) + return rc; + } /* For each screen, set the DPMS level */ for (i = 0; i < xf86NumScreens; i++) { pScrn = xf86Screens[i]; - pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) { xf86EnableAccess(pScrn); pScrn->DPMSSet(pScrn, level, 0); } } + return Success; } @@ -182,14 +186,15 @@ DPMSSupported(void) DPMSPtr pDPMS; ScrnInfoPtr pScrn; - if (DPMSIndex < 0) { + if (DPMSKey == NULL) { return FALSE; } /* For each screen, check if DPMS is supported */ for (i = 0; i < xf86NumScreens; i++) { pScrn = xf86Screens[i]; - pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); if (pDPMS && pScrn->DPMSSet) return TRUE; } diff --git a/hw/xfree86/common/xf86DefModes.c b/hw/xfree86/common/xf86DefModes.c deleted file mode 100644 index bdb64fe8e..000000000 --- a/hw/xfree86/common/xf86DefModes.c +++ /dev/null @@ -1,155 +0,0 @@ -/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at - * modeline2c.pl */ - -/* - * Copyright 1999-2003 by The XFree86 Project, Inc. - * - * Author: Dirk Hohndel <hohndel@XFree86.Org> - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86Config.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include "globals.h" - -#define MODEPREFIX(name) NULL, NULL, name, MODE_OK, M_T_DEFAULT -#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 - -DisplayModeRec xf86DefaultModes [] = { -/* 640x350 @ 85Hz (VESA) hsync: 37.9kHz */ - {MODEPREFIX("640x350"),31500, 640,672,736,832,0, 350,382,385,445,0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("320x175"),15750, 320,336,368,416,0, 175,191,192,222,0, V_PHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 640x400 @ 85Hz (VESA) hsync: 37.9kHz */ - {MODEPREFIX("640x400"),31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("320x200"),15750, 320,336,368,416,0, 200,200,202,222,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 720x400 @ 85Hz (VESA) hsync: 37.9kHz */ - {MODEPREFIX("720x400"),35500, 720,756,828,936,0, 400,401,404,446,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("360x200"),17750, 360,378,414,468,0, 200,200,202,223,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */ - {MODEPREFIX("640x480"),25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("320x240"),12600, 320,328,376,400,0, 240,245,246,262,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */ - {MODEPREFIX("640x480"),31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("320x240"),15750, 320,332,352,416,0, 240,244,245,260,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */ - {MODEPREFIX("640x480"),31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("320x240"),15750, 320,328,360,420,0, 240,240,242,250,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */ - {MODEPREFIX("640x480"),36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("320x240"),18000, 320,348,376,416,0, 240,240,242,254,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */ - {MODEPREFIX("800x600"),36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("400x300"),18000, 400,412,448,512,0, 300,300,301,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */ - {MODEPREFIX("800x600"),40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("400x300"),20000, 400,420,484,528,0, 300,300,302,314,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */ - {MODEPREFIX("800x600"),50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("400x300"),25000, 400,428,488,520,0, 300,318,321,333,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */ - {MODEPREFIX("800x600"),49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("400x300"),24750, 400,408,448,528,0, 300,300,302,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */ - {MODEPREFIX("800x600"),56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("400x300"),28150, 400,416,448,524,0, 300,300,302,315,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */ - {MODEPREFIX("1024x768"),44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, - {MODEPREFIX("512x384"),22450, 512,516,604,632,0, 384,384,388,408,0, V_PHSYNC | V_PVSYNC | V_INTERLACE | V_DBLSCAN, MODESUFFIX}, -/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */ - {MODEPREFIX("1024x768"),65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("512x384"),32500, 512,524,592,672,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */ - {MODEPREFIX("1024x768"),75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("512x384"),37500, 512,524,592,664,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */ - {MODEPREFIX("1024x768"),78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("512x384"),39400, 512,520,568,656,0, 384,384,386,400,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */ - {MODEPREFIX("1024x768"),94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("512x384"),47250, 512,536,584,688,0, 384,384,386,404,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */ - {MODEPREFIX("1152x864"),108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("576x432"),54000, 576,608,672,800,0, 432,432,434,450,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1280x960 @ 60Hz (VESA) hsync: 60.0kHz */ - {MODEPREFIX("1280x960"),108000, 1280,1376,1488,1800,0, 960,961,964,1000,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("640x480"),54000, 640,688,744,900,0, 480,480,482,500,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1280x960 @ 85Hz (VESA) hsync: 85.9kHz */ - {MODEPREFIX("1280x960"),148500, 1280,1344,1504,1728,0, 960,961,964,1011,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("640x480"),74250, 640,672,752,864,0, 480,480,482,505,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz */ - {MODEPREFIX("1280x1024"),108000, 1280,1328,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("640x512"),54000, 640,664,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz */ - {MODEPREFIX("1280x1024"),135000, 1280,1296,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("640x512"),67500, 640,648,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz */ - {MODEPREFIX("1280x1024"),157500, 1280,1344,1504,1728,0, 1024,1025,1028,1072,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("640x512"),78750, 640,672,752,864,0, 512,512,514,536,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz */ - {MODEPREFIX("1600x1200"),162000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("800x600"),81000, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz */ - {MODEPREFIX("1600x1200"),175500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("800x600"),87750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz */ - {MODEPREFIX("1600x1200"),189000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("800x600"),94500, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz */ - {MODEPREFIX("1600x1200"),202500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("800x600"),101250, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz */ - {MODEPREFIX("1600x1200"),229500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("800x600"),114750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz */ - {MODEPREFIX("1792x1344"),204800, 1792,1920,2120,2448,0, 1344,1345,1348,1394,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("896x672"),102400, 896,960,1060,1224,0, 672,672,674,697,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz */ - {MODEPREFIX("1792x1344"),261000, 1792,1888,2104,2456,0, 1344,1345,1348,1417,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("896x672"),130500, 896,944,1052,1228,0, 672,672,674,708,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz */ - {MODEPREFIX("1856x1392"),218300, 1856,1952,2176,2528,0, 1392,1393,1396,1439,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("928x696"),109150, 928,976,1088,1264,0, 696,696,698,719,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz */ - {MODEPREFIX("1856x1392"),288000, 1856,1984,2208,2560,0, 1392,1393,1396,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("928x696"),144000, 928,992,1104,1280,0, 696,696,698,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz */ - {MODEPREFIX("1920x1440"),234000, 1920,2048,2256,2600,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("960x720"),117000, 960,1024,1128,1300,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz */ - {MODEPREFIX("1920x1440"),297000, 1920,2064,2288,2640,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("960x720"),148500, 960,1032,1144,1320,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz */ - {MODEPREFIX("832x624"),57284, 832,864,928,1152,0, 624,625,628,667,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("416x312"),28642, 416,432,464,576,0, 312,312,314,333,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1152x768 @ 54.8Hz (Titanium PowerBook) hsync: 44.2kHz */ - {MODEPREFIX("1152x768"),64995, 1152,1178,1314,1472,0, 768,771,777,806,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("576x384"),32497, 576,589,657,736,0, 384,385,388,403,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz */ - {MODEPREFIX("1400x1050"),122000, 1400,1488,1640,1880,0, 1050,1052,1064,1082,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("700x525"),61000, 700,744,820,940,0, 525,526,532,541,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz */ - {MODEPREFIX("1400x1050"),155800, 1400,1464,1784,1912,0, 1050,1052,1064,1090,0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("700x525"),77900, 700,732,892,956,0, 525,526,532,545,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1600x1024 @ 60Hz (SGI 1600SW) hsync: 64.0kHz */ - {MODEPREFIX("1600x1024"),106910, 1600,1620,1640,1670,0, 1024,1027,1030,1067,0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, - {MODEPREFIX("800x512"),53455, 800,810,820,835,0, 512,513,515,533,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz */ - {MODEPREFIX("1920x1440"),341350, 1920,2072,2288,2656,0, 1440,1441,1444,1512,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("960x720"),170675, 960,1036,1144,1328,0, 720,720,722,756,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz */ - {MODEPREFIX("2048x1536"),266950, 2048,2200,2424,2800,0, 1536,1537,1540,1589,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("1024x768"),133475, 1024,1100,1212,1400,0, 768,768,770,794,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz */ - {MODEPREFIX("2048x1536"),340480, 2048,2216,2440,2832,0, 1536,1537,1540,1603,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("1024x768"),170240, 1024,1108,1220,1416,0, 768,768,770,801,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, -/* 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz */ - {MODEPREFIX("2048x1536"),388040, 2048,2216,2440,2832,0, 1536,1537,1540,1612,0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, - {MODEPREFIX("1024x768"),194020, 1024,1108,1220,1416,0, 768,768,770,806,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX}, - {MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX} -}; diff --git a/hw/xfree86/common/xf86DoScanPci.c b/hw/xfree86/common/xf86DoScanPci.c deleted file mode 100644 index 51892f041..000000000 --- a/hw/xfree86/common/xf86DoScanPci.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1999-2002 by The XFree86 Project, Inc. - * - * 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 - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* - * Finish setting up the server. - * Call the functions from the scanpci module. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <ctype.h> -#include <stdlib.h> -#include <X11/X.h> -#include <X11/Xmd.h> -#include <pciaccess.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Pci.h" -#include "Pci.h" -#include "xf86_OSproc.h" - -static void ScanPciDisplayPCICardInfo(void); - -void -ScanPciDisplayPCICardInfo(void) -{ - struct pci_id_match match; - struct pci_device_iterator *iter; - const struct pci_device *dev; - - xf86EnableIO(); - - if (! xf86scanpci()) { - xf86MsgVerb(X_NONE, 0, "No PCI info available\n"); - return; - } - xf86MsgVerb(X_NONE, 0, - "Probing for PCI devices (Bus:Device:Function)\n\n"); - - iter = pci_id_match_iterator_create(NULL); - while ((dev = pci_device_next(iter)) != NULL) { - const char *svendorname = NULL, *subsysname = NULL; - const char *vendorname = NULL, *devicename = NULL; - - - xf86MsgVerb(X_NONE, 0, "(%d:%d:%d) ", - PCI_MAKE_BUS(dev->domain, dev->bus), dev->dev, dev->func); - - /* - * Lookup as much as we can about the device. - */ - match.vendor_id = dev->vendor_id; - match.device_id = dev->device_id; - match.subvendor_id = (dev->subvendor_id != 0) - ? dev->subvendor_id : PCI_MATCH_ANY; - match.subdevice_id = (dev->subdevice_id != 0) - ? dev->subdevice_id : PCI_MATCH_ANY; - match.device_class = 0; - match.device_class_mask = 0; - - pci_get_strings(& match, & vendorname, & devicename, - & svendorname, & subsysname); - - if ((dev->subvendor_id != 0) || (dev->subdevice_id != 0)) { - xf86MsgVerb(X_NONE, 0, "%s %s (0x%04x / 0x%04x) using ", - (svendorname == NULL) ? "unknown vendor" : svendorname, - (subsysname == NULL) ? "unknown card" : subsysname, - dev->subvendor_id, dev->subdevice_id); - } - - xf86MsgVerb(X_NONE, 0, "%s %s (0x%04x / 0x%04x)\n", - (vendorname == NULL) ? "unknown vendor" : vendorname, - (devicename == NULL) ? "unknown chip" : devicename, - dev->vendor_id, dev->device_id); - } - - pci_iterator_destroy(iter); -} - - -void DoScanPci(int argc, char **argv, int i) -{ - int j,skip,globalVerbose; - - /* - * first we need to finish setup of the OS so that we can call other - * functions in the server - */ - OsInit(); - - /* - * The old verbosity processing that was here isn't useful anymore, but - * for compatibility purposes, ignore verbosity changes after the -scanpci - * flag. - */ - globalVerbose = xf86Verbose; - - /* - * next we process the arguments that are remaining on the command line, - * so that things like the module path can be set there - */ - for ( j = i+1; j < argc; j++ ) { - if ((skip = ddxProcessArgument(argc, argv, j))) - j += (skip - 1); - } - - /* - * Was the verbosity level increased? If so, set it back. - */ - if (xf86Verbose > globalVerbose) - xf86SetVerbosity(globalVerbose); - - ScanPciDisplayPCICardInfo(); - - /* - * That's it; we really should clean things up, but a simple - * exit seems to be all we need. - */ - exit(0); -} diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index e88fc3b3e..2b7cb121d 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -857,7 +857,7 @@ xf86VTSwitch() #endif #ifdef DPMSExtension if (DPMSPowerLevel != DPMSModeOn) - DPMSSet(DPMSModeOn); + DPMSSet(serverClient, DPMSModeOn); #endif for (i = 0; i < xf86NumScreens; i++) { if (!(dispatchException & DE_TERMINATE)) @@ -906,7 +906,7 @@ xf86VTSwitch() (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } } - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { @@ -970,7 +970,7 @@ xf86VTSwitch() } /* Turn screen saver off when switching back */ - SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset); + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index b3969b102..0dc42c66b 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -46,10 +46,12 @@ /* Globals that video drivers may access */ -_X_EXPORT int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */ -int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */ +/* Index into pScreen.devPrivates */ +DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey; +/* Index of ScrnInfo in pScreen.devPrivates */ +_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey; +_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey; _X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ -_X_EXPORT int xf86PixmapIndex = 0; _X_EXPORT const unsigned char byte_reversed[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, @@ -95,7 +97,6 @@ InputInfoPtr xf86InputDevs = NULL; xf86InfoRec xf86Info = { -1, /* consoleFd */ -1, /* vtno */ - NULL, /* vtinit */ FALSE, /* vtSysreq */ SKWhenNeeded, /* ddxSpecialKeys */ NULL, /* pMouse */ @@ -152,8 +153,6 @@ DriverPtr *xf86DriverList = NULL; int xf86NumDrivers = 0; InputDriverPtr *xf86InputDriverList = NULL; int xf86NumInputDrivers = 0; -ModuleInfoPtr *xf86ModuleInfoList = NULL; -int xf86NumModuleInfos = 0; int xf86NumScreens = 0; const char *xf86VisualNames[] = { diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index d37875c35..0d2471aa1 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 1997-2003 by The XFree86 Project, Inc. * @@ -170,37 +169,17 @@ xf86LookupInput(const char *name) return NULL; } +/* ABI stubs of despair */ _X_EXPORT void -xf86AddModuleInfo(ModuleInfoPtr info, pointer module) +xf86AddModuleInfo(pointer info, pointer module) { - /* Don't add null entries */ - if (!module) - return; - - if (xf86ModuleInfoList == NULL) - xf86NumModuleInfos = 0; - - xf86NumModuleInfos++; - xf86ModuleInfoList = xnfrealloc(xf86ModuleInfoList, - xf86NumModuleInfos * sizeof(ModuleInfoPtr)); - xf86ModuleInfoList[xf86NumModuleInfos - 1] = xnfalloc(sizeof(ModuleInfoRec)); - *xf86ModuleInfoList[xf86NumModuleInfos - 1] = *info; - xf86ModuleInfoList[xf86NumModuleInfos - 1]->module = module; - xf86ModuleInfoList[xf86NumModuleInfos - 1]->refCount = 0; } _X_EXPORT void xf86DeleteModuleInfo(int idx) { - if (xf86ModuleInfoList[idx]) { - if (xf86ModuleInfoList[idx]->module) - UnloadModule(xf86ModuleInfoList[idx]->module); - xfree(xf86ModuleInfoList[idx]); - xf86ModuleInfoList[idx] = NULL; - } } - /* Allocate a new ScrnInfoRec in xf86Screens */ _X_EXPORT ScrnInfoPtr @@ -1374,7 +1353,7 @@ xf86ErrorF(const char *format, ...) void xf86LogInit() { - char *lf; + char *lf = NULL; #define LOGSUFFIX ".log" #define LOGOLDSUFFIX ".old" @@ -1398,6 +1377,8 @@ xf86LogInit() #undef LOGSUFFIX #undef LOGOLDSUFFIX + + free(lf); } void @@ -2957,3 +2938,17 @@ xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start, { return GetMotionHistory(pDev, buff, start, stop, pScreen); } + +_X_EXPORT void +xf86getsecs(long * secs, long * usecs) +{ + struct timeval tv; + + X_GETTIMEOFDAY(&tv); + if (secs) + *secs = tv.tv_sec; + if (usecs) + *usecs= tv.tv_usec; + + return; +} diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index c72fe30e8..d1603c081 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -102,7 +102,6 @@ static void xf86PrintBanner(void); static void xf86PrintMarkers(void); static void xf86PrintDefaultModulePath(void); static void xf86PrintDefaultLibraryPath(void); -static void xf86RunVtInit(void); static Bool probe_devices_from_device_sections(DriverPtr drvp); static Bool add_matching_devices_to_configure_list(DriverPtr drvp); @@ -139,8 +138,8 @@ xf86CreateRootWindow(WindowPtr pWin) int err = Success; ScreenPtr pScreen = pWin->drawable.pScreen; RootWinPropPtr pProp; - CreateWindowProcPtr CreateWindow = - (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr); + CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr) + dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey); #ifdef DEBUG ErrorF("xf86CreateRootWindow(%p)\n", pWin); @@ -156,7 +155,7 @@ xf86CreateRootWindow(WindowPtr pWin) /* Unhook this function ... */ pScreen->CreateWindow = CreateWindow; - pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL); /* ... and call the previous CreateWindow fuction, if any */ if (NULL!=pScreen->CreateWindow) { @@ -199,13 +198,6 @@ xf86CreateRootWindow(WindowPtr pWin) } -/* - * InitOutput -- - * Initialize screenInfo for all actually accessible framebuffers. - * That includes vt-manager setup, querying all possible devices and - * collecting the pixmap formats. - */ - static void PostConfigInit(void) { @@ -238,9 +230,6 @@ PostConfigInit(void) xf86OSPMClose = xf86OSPMOpen(); #endif - /* Run an external VT Init program if specified in the config file */ - xf86RunVtInit(); - /* Do this after XF86Config is read (it's normally in OsInit()) */ OsInitColors(); } @@ -471,12 +460,16 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) return foundScreen; } - +/* + * InitOutput -- + * Initialize screenInfo for all actually accessible framebuffers. + * That includes vt-manager setup, querying all possible devices and + * collecting the pixmap formats. + */ void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) { int i, j, k, scr_index; - static unsigned long generation = 0; char **modulelist; pointer *optionlist; screenLayoutPtr layout; @@ -487,14 +480,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) xf86Initialising = TRUE; - /* Do this early? */ - if (generation != serverGeneration) { - xf86ScreenIndex = AllocateScreenPrivateIndex(); - xf86CreateRootWindowIndex = AllocateScreenPrivateIndex(); - xf86PixmapIndex = AllocatePixmapPrivateIndex(); - generation = serverGeneration; - } - if (serverGeneration == 1) { pScreenInfo->numScreens = 0; @@ -1070,8 +1055,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) * Hook in our ScrnInfoRec, and initialise some other pScreen * fields. */ - screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr - = (pointer)xf86Screens[i]; + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86ScreenKey, xf86Screens[i]); xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; /* The driver should set this, but make sure it is set anyway */ xf86Screens[i]->vtSema = TRUE; @@ -1087,8 +1072,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) i, xf86Screens[i]->pScreen->CreateWindow ); #endif - screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr - = (void*)(xf86Screens[i]->pScreen->CreateWindow); + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86CreateRootWindowKey, + xf86Screens[i]->pScreen->CreateWindow); xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; #ifdef RENDER @@ -1143,12 +1129,6 @@ InitInput(argc, argv) for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { /* Replace obsolete keyboard driver with kbd */ if (!xf86NameCmp((*pDev)->driver, "keyboard")) { - xf86MsgVerb(X_WARNING, 0, - "*** WARNING the legacy keyboard driver \"%s\" has been removed\n", - (*pDev)->driver); - xf86MsgVerb(X_WARNING, 0, - "*** Using the new \"kbd\" driver for \"%s\".\n", - (*pDev)->identifier); strcpy((*pDev)->driver, "kbd"); } @@ -1307,7 +1287,7 @@ AbortDDX() */ #ifdef DPMSExtension /* Turn screens back on */ if (DPMSPowerLevel != DPMSModeOn) - DPMSSet(DPMSModeOn); + DPMSSet(serverClient, DPMSModeOn); #endif if (xf86Screens) { if (xf86Screens[0]->vtSema) @@ -1574,15 +1554,6 @@ ddxProcessArgument(int argc, char **argv, int i) xf86sFlag = TRUE; return 0; } - if (!strcmp(argv[i], "-bpp")) - { - ErrorF("The -bpp option is no longer supported.\n" - "\tUse -depth to set the color depth, and use -fbbpp if you really\n" - "\tneed to force a non-default framebuffer (hardware) pixel format.\n"); - if (++i >= argc) - return 1; - return 2; - } if (!strcmp(argv[i], "-pixmap24")) { xf86Pix24 = Pix24Use24; @@ -1695,10 +1666,6 @@ ddxProcessArgument(int argc, char **argv, int i) return 1; } #endif - if (!strcmp(argv[i], "-scanpci")) - { - DoScanPci(argc, argv, i); - } if (!strcmp(argv[i], "-probe")) { xf86DoProbe = TRUE; @@ -1761,7 +1728,6 @@ ddxUseMsg() ErrorF("-config file specify a configuration file, relative to the\n"); ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); ErrorF("-probeonly probe for devices, then exit\n"); - ErrorF("-scanpci execute the scanpci module and exit\n"); ErrorF("-verbose [n] verbose startup messages\n"); ErrorF("-logverbose [n] verbose log messages\n"); ErrorF("-quiet minimal startup messages\n"); @@ -1938,44 +1904,6 @@ xf86PrintDefaultLibraryPath(void) ErrorF("%s\n", DEFAULT_LIBRARY_PATH); } -static void -xf86RunVtInit(void) -{ - int i; - - /* - * If VTInit was set, run that program with consoleFd as stdin and stdout - */ - - if (xf86Info.vtinit) { - switch(fork()) { - case -1: - FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno)); - break; - case 0: /* child */ - if (setuid(getuid()) == -1) { - xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n", - strerror(errno)); - exit(255); - } - /* set stdin, stdout to the consoleFd */ - for (i = 0; i < 2; i++) { - if (xf86Info.consoleFd != i) { - close(i); - dup(xf86Info.consoleFd); - } - } - execl("/bin/sh", "sh", "-c", xf86Info.vtinit, (void *)NULL); - xf86Msg(X_WARNING, "exec of /bin/sh failed for VTInit (%s)\n", - strerror(errno)); - exit(255); - break; - default: /* parent */ - wait(NULL); - } - } -} - /* * xf86LoadModules iterates over a list that is being passed in. */ diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c index c1b9c60fc..40c196a3e 100644 --- a/hw/xfree86/common/xf86MiscExt.c +++ b/hw/xfree86/common/xf86MiscExt.c @@ -548,6 +548,10 @@ MiscExtPassMessage(int scrnIndex, const char *msgtype, const char *msgval, { ScrnInfoPtr pScr = xf86Screens[scrnIndex]; + /* should check this in the protocol, but xf86NumScreens isn't exported */ + if (scrnIndex >= xf86NumScreens) + return BadValue; + if (*pScr->HandleMessage == NULL) return BadImplementation; return (*pScr->HandleMessage)(scrnIndex, msgtype, msgval, retstr); diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index 7fcce10b1..fb899a1e4 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -183,6 +183,8 @@ xf86ModeStatusToString(ModeStatus status) return "all modes must have the same resolution"; case MODE_NO_REDUCED: return "monitor doesn't support reduced blanking"; + case MODE_BANDWIDTH: + return "mode requires too much memory bandwidth"; case MODE_BAD: return "unknown reason"; case MODE_ERROR: @@ -368,52 +370,6 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp, return MODE_OK; } -#if 0 -/** Calculates the horizontal sync rate of a mode */ -_X_EXPORT double -xf86ModeHSync(DisplayModePtr mode) -{ - double hsync = 0.0; - - if (mode->HSync > 0.0) - hsync = mode->HSync; - else if (mode->HTotal > 0) - hsync = (float)mode->Clock / (float)mode->HTotal; - - return hsync; -} - -/** Calculates the vertical refresh rate of a mode */ -_X_EXPORT double -xf86ModeVRefresh(DisplayModePtr mode) -{ - double refresh = 0.0; - - if (mode->VRefresh > 0.0) - refresh = mode->VRefresh; - else if (mode->HTotal > 0 && mode->VTotal > 0) { - refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal; - if (mode->Flags & V_INTERLACE) - refresh *= 2.0; - if (mode->Flags & V_DBLSCAN) - refresh /= 2.0; - if (mode->VScan > 1) - refresh /= (float)(mode->VScan); - } - return refresh; -} - -/** Sets a default mode name of <width>x<height> on a mode. */ -_X_EXPORT void -xf86SetModeDefaultName(DisplayModePtr mode) -{ - if (mode->name != NULL) - xfree(mode->name); - - mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); -} -#endif - /* * xf86LookupMode * @@ -1259,20 +1215,40 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy) { float aspect = 0.0; MonPtr mon = scrp->monitor; + xf86MonPtr DDC; int x = 0, y = 0; DisplayModePtr mode; if (!mon) return 0; + DDC = mon->DDC; + + if (DDC && DDC->ver.revision >= 4) { + /* For 1.4, we might actually get native pixel format. How novel. */ + if (PREFERRED_TIMING_MODE(DDC->features.msc)) { + for (mode = modes; mode; mode = mode->next) { + if (mode->type & (M_T_DRIVER | M_T_PREFERRED)) { + x = mode->HDisplay; + y = mode->VDisplay; + goto found; + } + } + } + /* + * Even if we don't, we might get aspect ratio from extra CVT info + * or from the monitor size fields. TODO. + */ + } /* - * technically this triggers if _either_ is zero, which is not what EDID - * says, but if only one is zero this is best effort. also we don't - * know that all projectors are 4:3, but we certainly suspect it. + * Technically this triggers if either is zero. That wasn't legal + * before EDID 1.4, but right now we'll get that wrong. TODO. */ - if (!mon->widthmm || !mon->heightmm) - aspect = 4.0/3.0; - else - aspect = (float)mon->widthmm / (float)mon->heightmm; + if (!aspect) { + if (!mon->widthmm || !mon->heightmm) + aspect = 4.0/3.0; + else + aspect = (float)mon->widthmm / (float)mon->heightmm; + } /* find the largest M_T_DRIVER mode with that aspect ratio */ for (mode = modes; mode; mode = mode->next) { @@ -1296,6 +1272,7 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy) return 0; } +found: *vx = x; *vy = y; diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index 852e51f43..240155ca7 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -83,9 +83,9 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 3) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(3, 0) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(4, 0) #define ABI_XINPUT_VERSION SET_ABI_VERSION(2, 0) -#define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 3) +#define ABI_EXTENSION_VERSION SET_ABI_VERSION(1, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 5) #define MODINFOSTRING1 0xef23fdc5 diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c index a6bcc3421..7c8320dee 100644 --- a/hw/xfree86/common/xf86PM.c +++ b/hw/xfree86/common/xf86PM.c @@ -116,7 +116,7 @@ resume(pmEvent event, Bool undo) if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { EnableDevice(pInfo->dev); diff --git a/hw/xfree86/common/xf86PciInfo.h b/hw/xfree86/common/xf86PciInfo.h index 0630cfa82..356c7db4d 100644 --- a/hw/xfree86/common/xf86PciInfo.h +++ b/hw/xfree86/common/xf86PciInfo.h @@ -40,9 +40,8 @@ * or for non-video devices unless they're needed by a driver or elsewhere. * A comprehensive set of PCI vendor, device and subsystem data is * auto-generated from the ../etc/pci.ids file using the pciids2c.pl script, - * and is used in both the scanpci module and the scanpci utility. Don't - * modify the pci.ids file. If new/corrected entries are required, add them - * to ../etc/extrapci.ids. + * and is used in scanpci utility. Don't modify the pci.ids file. If + * new/corrected entries are required, add them to ../etc/extrapci.ids. */ #ifndef _XF86_PCIINFO_H diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h index 4723f5aba..fb9ecaea8 100644 --- a/hw/xfree86/common/xf86Priv.h +++ b/hw/xfree86/common/xf86Priv.h @@ -1,4 +1,3 @@ - /* * Copyright (c) 1997-2002 by The XFree86 Project, Inc. * @@ -97,8 +96,6 @@ extern Bool xf86SupportedMouseTypes[]; extern int xf86NumMouseTypes; extern DriverPtr *xf86DriverList; -extern ModuleInfoPtr *xf86ModuleInfoList; -extern int xf86NumModuleInfos; extern int xf86NumDrivers; extern Bool xf86Resetting; extern Bool xf86Initialising; @@ -158,10 +155,6 @@ Bool xf86PathIsSafe(const char *path); extern DisplayModeRec xf86DefaultModes []; -/* xf86DoScanPci.c */ - -void DoScanPci(int argc, char **argv, int i); - /* xf86DoProbe.c */ void DoProbe(void); void DoConfigure(void); diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index 92a6305a0..d97ca440e 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -75,7 +75,6 @@ typedef enum { typedef struct { int consoleFd; int vtno; - char * vtinit; Bool vtSysreq; SpecialKeysInDDX ddxSpecialKeys; diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 288d72193..4432ad96b 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -45,10 +45,9 @@ typedef struct _xf86RandRInfo { Rotation rotation; } XF86RandRInfoRec, *XF86RandRInfoPtr; -static int xf86RandRIndex = -1; -static int xf86RandRGeneration; +static DevPrivateKey xf86RandRKey = NULL; -#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr) +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey)) static int xf86RandRModeRefresh (DisplayModePtr mode) @@ -338,14 +337,14 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen) scrp->currentMode = scrp->modes; pScreen->CloseScreen = randrp->CloseScreen; xfree (randrp); - pScreen->devPrivates[xf86RandRIndex].ptr = 0; + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL); return (*pScreen->CloseScreen) (index, pScreen); } _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen) { - if (xf86RandRIndex == -1) + if (xf86RandRKey == NULL) return RR_Rotate_0; return XF86RANDRINFO(pScreen)->rotation; @@ -359,7 +358,7 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, { XF86RandRInfoPtr randrp; - if (xf86RandRIndex == -1) + if (xf86RandRKey == NULL) return FALSE; randrp = XF86RANDRINFO(pScreen); @@ -401,11 +400,8 @@ xf86RandRInit (ScreenPtr pScreen) if (!noPanoramiXExtension) return TRUE; #endif - if (xf86RandRGeneration != serverGeneration) - { - xf86RandRIndex = AllocateScreenPrivateIndex(); - xf86RandRGeneration = serverGeneration; - } + + xf86RandRKey = &xf86RandRKey; randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) @@ -433,7 +429,7 @@ xf86RandRInit (ScreenPtr pScreen) randrp->rotation = RR_Rotate_0; - pScreen->devPrivates[xf86RandRIndex].ptr = randrp; + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp); return TRUE; } diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c index 16a4d824c..38d605c88 100644 --- a/hw/xfree86/common/xf86VidMode.c +++ b/hw/xfree86/common/xf86VidMode.c @@ -47,12 +47,11 @@ #include "vidmodeproc.h" #include "xf86cmap.h" -static int VidModeGeneration = 0; -static int VidModeIndex = -1; +static DevPrivateKey VidModeKey = NULL; static int VidModeCount = 0; static Bool VidModeClose(int i, ScreenPtr pScreen); -#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr) +#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey)) #endif @@ -73,15 +72,10 @@ VidModeExtensionInit(ScreenPtr pScreen) return FALSE; } - if (serverGeneration != VidModeGeneration) { - if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) { - DEBUG_P("AllocateScreenPrivateIndex() failed"); - return FALSE; - } - VidModeGeneration = serverGeneration; - } + VidModeKey = &VidModeKey; - if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) { + if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey, + xcalloc(sizeof(VidModeRec), 1))) { DEBUG_P("xcalloc failed"); return FALSE; } @@ -114,10 +108,9 @@ VidModeClose(int i, ScreenPtr pScreen) pScreen->CloseScreen = pVidMode->CloseScreen; if (--VidModeCount == 0) { - if (pScreen->devPrivates[VidModeIndex].ptr) - xfree(pScreen->devPrivates[VidModeIndex].ptr); - pScreen->devPrivates[VidModeIndex].ptr = NULL; - VidModeIndex = -1; + xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey)); + dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL); + VidModeKey = NULL; } return pScreen->CloseScreen(i, pScreen); } @@ -128,8 +121,8 @@ VidModeAvailable(int scrnIndex) ScrnInfoPtr pScrn; VidModePtr pVidMode; - if (VidModeIndex < 0) { - DEBUG_P("VidModeIndex < 0"); + if (VidModeKey == NULL) { + DEBUG_P("VidModeKey == NULL"); return FALSE; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index b939fb763..eafc0e9a0 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -77,7 +77,6 @@ #define EXTENSION_PROC_ARGS void * #include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ #include "windowstr.h" /* screenIsSaved */ @@ -116,7 +115,7 @@ _X_EXPORT void xf86ProcessCommonOptions(LocalDevicePtr local, pointer list) { - if (xf86SetBoolOption(list, "AlwaysCore", 0) || + if (!xf86SetBoolOption(list, "AlwaysCore", 1) || !xf86SetBoolOption(list, "SendCoreEvents", 1) || !xf86SetBoolOption(list, "CorePointer", 1) || !xf86SetBoolOption(list, "CoreKeyboard", 1)) { @@ -134,6 +133,11 @@ xf86ProcessCommonOptions(LocalDevicePtr local, /* Backwards compatibility. */ local->history_size = GetMotionHistorySize(); + /* Preallocate xEvent store */ + if (!xf86Events) + xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); + if (!xf86Events) + FatalError("Couldn't allocate event store\n"); } /*********************************************************************** @@ -462,6 +466,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev) * convenient functions to post events */ +#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */ + _X_EXPORT void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute, @@ -471,17 +477,12 @@ xf86PostMotionEvent(DeviceIntPtr device, { va_list var; int i = 0; - static int *valuators = NULL; - static int n_valuators = 0; - - if (num_valuators > n_valuators) { - xfree (valuators); - valuators = NULL; - } + static int valuators[MAX_VALUATORS]; - if (!valuators) { - valuators = xcalloc(sizeof(int), num_valuators); - n_valuators = num_valuators; + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; } va_start(var, num_valuators); @@ -506,6 +507,12 @@ xf86PostMotionEventP(DeviceIntPtr device, int index; int flags = 0; + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + if (is_absolute) flags = POINTER_ABSOLUTE; else @@ -530,9 +537,7 @@ xf86PostMotionEventP(DeviceIntPtr device, #endif if (!xf86Events) - xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!xf86Events) - FatalError("Couldn't allocate event store\n"); + FatalError("Didn't allocate event store\n"); nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, flags, first_valuator, num_valuators, @@ -556,9 +561,15 @@ xf86PostProximityEvent(DeviceIntPtr device, ...) { va_list var; - int i, nevents, *valuators = NULL; + int i, nevents; + int valuators[MAX_VALUATORS]; - valuators = xcalloc(sizeof(int), num_valuators); + + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } va_start(var, num_valuators); for (i = 0; i < num_valuators; i++) @@ -566,9 +577,7 @@ xf86PostProximityEvent(DeviceIntPtr device, va_end(var); if (!xf86Events) - xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!xf86Events) - FatalError("Couldn't allocate event store\n"); + FatalError("Didn't allocate event store\n"); nevents = GetProximityEvents(xf86Events, device, is_in ? ProximityIn : ProximityOut, @@ -576,7 +585,6 @@ xf86PostProximityEvent(DeviceIntPtr device, for (i = 0; i < nevents; i++) mieqEnqueue(device, xf86Events + i); - xfree(valuators); } _X_EXPORT void @@ -589,7 +597,7 @@ xf86PostButtonEvent(DeviceIntPtr device, ...) { va_list var; - int *valuators = NULL; + int valuators[MAX_VALUATORS]; int i = 0, nevents = 0; int index; @@ -600,18 +608,19 @@ xf86PostButtonEvent(DeviceIntPtr device, return; } #endif + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } - valuators = xcalloc(sizeof(int), num_valuators); - va_start(var, num_valuators); for (i = 0; i < num_valuators; i++) valuators[i] = va_arg(var, int); va_end(var); if (!xf86Events) - xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!xf86Events) - FatalError("Couldn't allocate event store\n"); + FatalError("Didn't allocate event store\n"); nevents = GetPointerEvents(xf86Events, device, is_down ? ButtonPress : ButtonRelease, button, @@ -621,8 +630,6 @@ xf86PostButtonEvent(DeviceIntPtr device, for (i = 0; i < nevents; i++) mieqEnqueue(device, xf86Events + i); - - xfree(valuators); } _X_EXPORT void @@ -635,20 +642,24 @@ xf86PostKeyEvent(DeviceIntPtr device, ...) { va_list var; - int i = 0, nevents = 0, *valuators = NULL; + int i = 0, nevents = 0; + static int valuators[MAX_VALUATORS]; /* instil confidence in the user */ DebugF("this function has never been tested properly. if things go quite " "badly south after this message, then xf86PostKeyEvent is " "broken.\n"); + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + if (!xf86Events) - xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!xf86Events) - FatalError("Couldn't allocate event store\n"); + FatalError("Didn't allocate event store\n"); if (is_absolute) { - valuators = xcalloc(sizeof(int), num_valuators); va_start(var, num_valuators); for (i = 0; i < num_valuators; i++) valuators[i] = va_arg(var, int); @@ -658,7 +669,6 @@ xf86PostKeyEvent(DeviceIntPtr device, is_down ? KeyPress : KeyRelease, key_code, first_valuator, num_valuators, valuators); - xfree(valuators); } else { nevents = GetKeyboardEvents(xf86Events, device, @@ -687,9 +697,7 @@ xf86PostKeyboardEvent(DeviceIntPtr device, #endif if (!xf86Events) - xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!xf86Events) - FatalError("Couldn't allocate event store\n"); + FatalError("Didn't allocate event store\n"); nevents = GetKeyboardEvents(xf86Events, device, is_down ? KeyPress : KeyRelease, key_code); diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index ea6a26dcd..764647ee4 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -60,7 +60,7 @@ #include "xf86cmap.h" #define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ - ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field) + ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field) #define SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) @@ -102,9 +102,8 @@ typedef struct { int overscan; } CMapColormapRec, *CMapColormapPtr; -static unsigned long CMapGeneration = 0; -static int CMapScreenIndex = -1; -static int CMapColormapIndex = -1; +static DevPrivateKey CMapScreenKey = NULL; +static DevPrivateKey CMapColormapKey = &CMapColormapKey; static void CMapInstallColormap(ColormapPtr); static void CMapStoreColors(ColormapPtr, int, xColorItem *); @@ -119,7 +118,6 @@ static int CMapChangeGamma(int, Gamma); static void ComputeGamma(CMapScreenPtr); static Bool CMapAllocateColormapPrivate(ColormapPtr); -static Bool CMapInitDefMap(ColormapPtr,int); static void CMapRefreshColors(ColormapPtr, int, int*); static void CMapSetOverscan(ColormapPtr, int, int *); static void CMapReinstallMap(ColormapPtr); @@ -145,13 +143,7 @@ _X_EXPORT Bool xf86HandleColormaps( if(!maxColors || !sigRGBbits || !loadPalette) return FALSE; - if(CMapGeneration != serverGeneration) { - if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((CMapColormapIndex = AllocateColormapPrivateIndex( - CMapInitDefMap)) < 0)) - return FALSE; - CMapGeneration = serverGeneration; - } + CMapScreenKey = &CMapScreenKey; elements = 1 << sigRGBbits; @@ -169,7 +161,7 @@ _X_EXPORT Bool xf86HandleColormaps( return FALSE; } - pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CreateColormap = pScreen->CreateColormap; @@ -225,12 +217,6 @@ _X_EXPORT Bool xf86HandleColormaps( return TRUE; } -static Bool -CMapInitDefMap(ColormapPtr cmap, int index) -{ - return TRUE; -} - /**** Screen functions ****/ @@ -254,8 +240,8 @@ CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv) static Bool CMapAllocateColormapPrivate(ColormapPtr pmap) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); CMapColormapPtr pColPriv; CMapLinkPtr pLink; int numColors; @@ -274,7 +260,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap) return FALSE; } - pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv; + dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv); pColPriv->numColors = numColors; pColPriv->colors = colors; @@ -296,8 +282,8 @@ static Bool CMapCreateColormap (ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); Bool ret = FALSE; pScreen->CreateColormap = pScreenPriv->CreateColormap; @@ -314,10 +300,10 @@ static void CMapDestroyColormap (ColormapPtr cmap) { ScreenPtr pScreen = cmap->pScreen; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &cmap->devPrivates, CMapColormapKey); CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps; if(pColPriv) { @@ -356,8 +342,8 @@ CMapStoreColors( ){ ScreenPtr pScreen = pmap->pScreen; VisualPtr pVisual = pmap->pVisual; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); int *indices = pScreenPriv->PreAllocIndices; int num = ndef; @@ -373,8 +359,8 @@ CMapStoreColors( return; if(pVisual->class == DirectColor) { - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); int i; if (CMapColormapUseMax(pVisual, pScreenPriv)) { @@ -431,8 +417,8 @@ CMapInstallColormap(ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; int index = pScreen->myNum; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if (pmap == miInstalledMaps[index]) return; @@ -462,8 +448,8 @@ static Bool CMapEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->EnterVT)(index, flags)) { if(miInstalledMaps[index]) @@ -478,8 +464,8 @@ static Bool CMapSwitchMode(int index, DisplayModePtr mode, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->SwitchMode)(index, mode, flags)) { if(miInstalledMaps[index]) @@ -494,8 +480,8 @@ static int CMapSetDGAMode(int index, int num, DGADevicePtr dev) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); int ret; ret = (*pScreenPriv->SetDGAMode)(index, num, dev); @@ -516,10 +502,10 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev) static void CMapReinstallMap(ColormapPtr pmap) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr cmapPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; int i = cmapPriv->numColors; int *indices = pScreenPriv->PreAllocIndices; @@ -547,10 +533,10 @@ CMapReinstallMap(ColormapPtr pmap) static void CMapRefreshColors(ColormapPtr pmap, int defs, int* indices) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); VisualPtr pVisual = pmap->pVisual; ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; int numColors, i; @@ -681,10 +667,10 @@ CMapCompareColors(LOCO *color1, LOCO *color2) static void CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; VisualPtr pVisual = pmap->pVisual; int i; @@ -819,8 +805,8 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) static void CMapUnwrapScreen(ScreenPtr pScreen) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; pScreen->CloseScreen = pScreenPriv->CloseScreen; @@ -904,10 +890,11 @@ CMapChangeGamma( CMapLinkPtr pLink; /* Is this sufficient checking ? */ - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; @@ -925,8 +912,8 @@ CMapChangeGamma( /* mark all colormaps on this screen */ pLink = pScreenPriv->maps; while(pLink) { - pColPriv = - (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr; + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); pColPriv->recalculate = TRUE; pLink = pLink->next; } @@ -997,10 +984,11 @@ xf86ChangeGammaRamp( CMapScreenPtr pScreenPriv; CMapLinkPtr pLink; - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; @@ -1012,8 +1000,8 @@ xf86ChangeGammaRamp( /* mark all colormaps on this screen */ pLink = pScreenPriv->maps; while(pLink) { - pColPriv = - (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr; + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); pColPriv->recalculate = TRUE; pLink = pLink->next; } @@ -1056,9 +1044,10 @@ xf86GetGammaRampSize(ScreenPtr pScreen) { CMapScreenPtr pScreenPriv; - if(CMapScreenIndex == -1) return 0; + if(CMapScreenKey == NULL) return 0; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return 0; return pScreenPriv->gammaElements; @@ -1076,10 +1065,11 @@ xf86GetGammaRamp( LOCO *entry; int shift, sigbits; - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c index 537d53d7d..9fd2e6c70 100644 --- a/hw/xfree86/common/xf86fbman.c +++ b/hw/xfree86/common/xf86fbman.c @@ -42,21 +42,15 @@ #define DEBUG */ -static int xf86FBMangerIndex = -1; -static unsigned long xf86ManagerGeneration = 0; +static DevPrivateKey xf86FBManagerKey = NULL; _X_EXPORT Bool xf86RegisterOffscreenManager( ScreenPtr pScreen, FBManagerFuncsPtr funcs ){ - if(xf86ManagerGeneration != serverGeneration) { - if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86ManagerGeneration = serverGeneration; - } - - pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs; + xf86FBManagerKey = &xf86FBManagerKey; + dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs); return TRUE; } @@ -65,9 +59,9 @@ _X_EXPORT Bool xf86RegisterOffscreenManager( _X_EXPORT Bool xf86FBManagerRunning(ScreenPtr pScreen) { - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!pScreen->devPrivates[xf86FBMangerIndex].ptr) + if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey)) return FALSE; return TRUE; @@ -81,9 +75,10 @@ xf86RegisterFreeBoxCallback( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv); @@ -101,9 +96,10 @@ xf86AllocateOffscreenArea( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; return (*funcs->AllocateOffscreenArea)( @@ -122,9 +118,10 @@ xf86AllocateOffscreenLinear( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; return (*funcs->AllocateOffscreenLinear)( @@ -139,10 +136,10 @@ xf86FreeOffscreenArea(FBAreaPtr area) if(!area) return; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return; - if(!(funcs = - (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &area->pScreen->devPrivates, xf86FBManagerKey))) return; (*funcs->FreeOffscreenArea)(area); @@ -158,10 +155,10 @@ xf86FreeOffscreenLinear(FBLinearPtr linear) if(!linear) return; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return; - if(!(funcs = - (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &linear->pScreen->devPrivates, xf86FBManagerKey))) return; (*funcs->FreeOffscreenLinear)(linear); @@ -179,10 +176,10 @@ xf86ResizeOffscreenArea( if(!resize) return FALSE; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = - (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) return FALSE; return (*funcs->ResizeOffscreenArea)(resize, w, h); @@ -197,10 +194,10 @@ xf86ResizeOffscreenLinear( if(!resize) return FALSE; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = - (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) return FALSE; return (*funcs->ResizeOffscreenLinear)(resize, size); @@ -220,9 +217,10 @@ xf86QueryLargestOffscreenArea( *w = 0; *h = 0; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->QueryLargestOffscreenArea)( @@ -240,9 +238,10 @@ xf86QueryLargestOffscreenLinear( *size = 0; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->QueryLargestOffscreenLinear)( @@ -255,9 +254,10 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) { FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->PurgeOffscreenAreas)(pScreen); @@ -269,8 +269,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) \************************************************************/ -static unsigned long xf86FBGeneration = 0; -static int xf86FBScreenIndex = -1; +static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey; typedef struct _FBLink { FBArea area; @@ -320,8 +319,8 @@ localRegisterFreeBoxCallback( FreeBoxCallbackProcPtr *newCallbacks; DevUnion *newPrivates; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback, sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1)); @@ -446,8 +445,8 @@ localAllocateOffscreenArea( FBManagerPtr offman; FBAreaPtr area = NULL; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData))) SendCallFreeBoxCallbacks(offman); @@ -464,8 +463,8 @@ localFreeOffscreenArea(FBAreaPtr area) ScreenPtr pScreen; pScreen = area->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->UsedAreas; if(!pLink) return; @@ -505,8 +504,8 @@ localResizeOffscreenArea( FBLinkPtr pLink, newLink, pLinkPrev = NULL; pScreen = resize->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); /* find this link */ if(!(pLink = offman->UsedAreas)) return FALSE; @@ -625,8 +624,8 @@ localQueryLargestOffscreenArea( if((preferences < 0) || (preferences > 3)) return FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); if(severity < 0) severity = 0; if(severity > 2) severity = 2; @@ -731,8 +730,8 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen) RegionRec FreedRegion; Bool anyUsed = FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->UsedAreas; if(!pLink) return TRUE; @@ -780,8 +779,8 @@ LinearRemoveCBWrapper(FBAreaPtr area) FBLinearLinkPtr pLink, pLinkPrev = NULL; ScreenPtr pScreen = area->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return; @@ -911,7 +910,8 @@ localAllocateOffscreenLinear( BoxPtr extents; int w, h, pitch; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); /* Try to allocate from linear memory first...... */ #ifdef DEBUG @@ -991,8 +991,8 @@ localFreeOffscreenLinear(FBLinearPtr linear) FBLinearLinkPtr pLink, pLinkPrev = NULL; ScreenPtr pScreen = linear->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return; @@ -1049,8 +1049,8 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length) FBLinearLinkPtr pLink; ScreenPtr pScreen = resize->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return FALSE; @@ -1099,7 +1099,8 @@ localQueryLargestOffscreenLinear( int priority ) { - FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); FBLinearLinkPtr pLink; FBLinearLinkPtr pLinkRet; @@ -1130,7 +1131,8 @@ localQueryLargestOffscreenLinear( FBManagerPtr offman; BoxPtr extents; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); if((extents->x2 - extents->x1) == w) *size = w * h; @@ -1162,9 +1164,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) { FBLinkPtr pLink, tmp; FBLinearLinkPtr pLinearLink, tmp2; - FBManagerPtr offman = - (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr; - + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pScreen->CloseScreen = offman->CloseScreen; @@ -1188,7 +1189,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) xfree(offman->FreeBoxesUpdateCallback); xfree(offman->devPrivates); xfree(offman); - pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL); return (*pScreen->CloseScreen) (i, pScreen); } @@ -1332,19 +1333,13 @@ xf86InitFBManagerRegion( if(REGION_NIL(FullRegion)) return FALSE; - if(xf86FBGeneration != serverGeneration) { - if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86FBGeneration = serverGeneration; - } - if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) return FALSE; offman = xalloc(sizeof(FBManager)); if(!offman) return FALSE; - pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman; + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman); offman->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86FBCloseScreen; @@ -1380,11 +1375,11 @@ xf86InitFBManagerLinear( return FALSE; /* we expect people to have called the Area setup first for pixmap cache */ - if (!pScreen->devPrivates[xf86FBScreenIndex].ptr) + if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey)) return FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); offman->LinearAreas = xalloc(sizeof(FBLinearLink)); if (!offman->LinearAreas) return FALSE; @@ -1424,13 +1419,14 @@ xf86AllocateLinearOffscreenArea ( BoxPtr extents; int w, h; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); w = extents->x2 - extents->x1; diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 13e13e980..d5ae75b3a 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -107,127 +107,6 @@ xf86FormatPciBusNumber(int busnum, char *buffer) sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); } -static void -FindPCIVideoInfo(void) -{ - int i = 0, k; - int num = 0; - struct pci_device *info; - struct pci_device_iterator *iter; - - - if (!xf86scanpci()) { - xf86PciVideoInfo = NULL; - return; - } - - iter = pci_slot_match_iterator_create(& xf86IsolateDevice); - while ((info = pci_device_next(iter)) != NULL) { - if (PCIINFOCLASSES(info->device_class)) { - num++; - xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, - (sizeof(struct pci_device *) - * (num + 1))); - xf86PciVideoInfo[num] = NULL; - xf86PciVideoInfo[num - 1] = info; - - pci_device_probe(info); - info->user_data = 0; - } - } - - - /* If we haven't found a primary device try a different heuristic */ - if (primaryBus.type == BUS_NONE && num) { - for (i = 0; i < num; i++) { - uint16_t command; - - info = xf86PciVideoInfo[i]; - pci_device_cfg_read_u16(info, & command, 4); - - if ((command & PCI_CMD_MEM_ENABLE) - && ((num == 1) || IS_VGA(info->device_class))) { - if (primaryBus.type == BUS_NONE) { - primaryBus.type = BUS_PCI; - primaryBus.id.pci = info; - } else { - xf86Msg(X_NOTICE, - "More than one possible primary device found\n"); - primaryBus.type ^= (BusType)(-1); - } - } - } - } - - /* Print a summary of the video devices found */ - for (k = 0; k < num; k++) { - const char *vendorname = NULL, *chipname = NULL; - const char *prim = " "; - Bool memdone = FALSE, iodone = FALSE; - - - info = xf86PciVideoInfo[k]; - - vendorname = pci_device_get_vendor_name( info ); - chipname = pci_device_get_device_name( info ); - - if ((!vendorname || !chipname) && - !PCIALWAYSPRINTCLASSES(info->device_class)) - continue; - - if (xf86IsPrimaryPci(info)) - prim = "*"; - - xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, - info->bus, info->dev, info->func ); - - if (vendorname) - xf86ErrorF("%s ", vendorname); - else - xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); - - if (chipname) - xf86ErrorF("%s ", chipname); - else - xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); - - xf86ErrorF("rev %d", info->revision); - - for (i = 0; i < 6; i++) { - struct pci_mem_region * r = & info->regions[i]; - - if ( r->size && ! r->is_IO ) { - if (!memdone) { - xf86ErrorF(", Mem @ "); - memdone = TRUE; - } else - xf86ErrorF(", "); - xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); - } - } - - for (i = 0; i < 6; i++) { - struct pci_mem_region * r = & info->regions[i]; - - if ( r->size && r->is_IO ) { - if (!iodone) { - xf86ErrorF(", I/O @ "); - iodone = TRUE; - } else - xf86ErrorF(", "); - xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); - } - } - - if ( info->rom_size ) { - xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); - } - - xf86ErrorF("\n"); - } -} - - /* * IO enable/disable related routines for PCI */ @@ -401,10 +280,10 @@ savePciState( struct pci_device * dev, pciSavePtr ptr ) } /* move to OS layer */ +#if 0 static void restorePciState( struct pci_device * dev, pciSavePtr ptr) { -#if 0 int i; /* disable card before setting anything */ @@ -419,8 +298,8 @@ restorePciState( struct pci_device * dev, pciSavePtr ptr) } pci_device_cfg_write_u32(dev, ptr->command, PCI_CMD_STAT_REG); -#endif } +#endif /* move to OS layer */ static void @@ -470,7 +349,121 @@ restorePciBusState(BusAccPtr ptr) void xf86PciProbe(void) { - FindPCIVideoInfo(); + int i = 0, k; + int num = 0; + struct pci_device *info; + struct pci_device_iterator *iter; + + + if (!xf86scanpci()) { + xf86PciVideoInfo = NULL; + return; + } + + iter = pci_slot_match_iterator_create(& xf86IsolateDevice); + while ((info = pci_device_next(iter)) != NULL) { + if (PCIINFOCLASSES(info->device_class)) { + num++; + xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, + (sizeof(struct pci_device *) + * (num + 1))); + xf86PciVideoInfo[num] = NULL; + xf86PciVideoInfo[num - 1] = info; + + pci_device_probe(info); + info->user_data = 0; + } + } + + + /* If we haven't found a primary device try a different heuristic */ + if (primaryBus.type == BUS_NONE && num) { + for (i = 0; i < num; i++) { + uint16_t command; + + info = xf86PciVideoInfo[i]; + pci_device_cfg_read_u16(info, & command, 4); + + if ((command & PCI_CMD_MEM_ENABLE) + && ((num == 1) || IS_VGA(info->device_class))) { + if (primaryBus.type == BUS_NONE) { + primaryBus.type = BUS_PCI; + primaryBus.id.pci = info; + } else { + xf86Msg(X_NOTICE, + "More than one possible primary device found\n"); + primaryBus.type ^= (BusType)(-1); + } + } + } + } + + /* Print a summary of the video devices found */ + for (k = 0; k < num; k++) { + const char *vendorname = NULL, *chipname = NULL; + const char *prim = " "; + Bool memdone = FALSE, iodone = FALSE; + + + info = xf86PciVideoInfo[k]; + + vendorname = pci_device_get_vendor_name( info ); + chipname = pci_device_get_device_name( info ); + + if ((!vendorname || !chipname) && + !PCIALWAYSPRINTCLASSES(info->device_class)) + continue; + + if (xf86IsPrimaryPci(info)) + prim = "*"; + + xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, + info->bus, info->dev, info->func ); + + if (vendorname) + xf86ErrorF("%s ", vendorname); + else + xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); + + if (chipname) + xf86ErrorF("%s ", chipname); + else + xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); + + xf86ErrorF("rev %d", info->revision); + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && ! r->is_IO ) { + if (!memdone) { + xf86ErrorF(", Mem @ "); + memdone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && r->is_IO ) { + if (!iodone) { + xf86ErrorF(", I/O @ "); + iodone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + if ( info->rom_size ) { + xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); + } + + xf86ErrorF("\n"); + } } void diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c index af2cd4a4c..63d1cb31c 100644 --- a/hw/xfree86/common/xf86sbusBus.c +++ b/hw/xfree86/common/xf86sbusBus.c @@ -602,8 +602,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp) pScrn->virtualY = psdp->height; } -static int sbusPaletteIndex = -1; -static unsigned long sbusPaletteGeneration = 0; +static DevPrivateKey sbusPaletteKey = &sbusPaletteKey; typedef struct _sbusCmap { sbusDevicePtr psdp; CloseScreenProcPtr CloseScreen; @@ -613,7 +612,8 @@ typedef struct _sbusCmap { unsigned char origBlue[16]; } sbusCmapRec, *sbusCmapPtr; -#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr)) +#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey)) static void xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, @@ -673,13 +673,8 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) struct fbcmap fbcmap; unsigned char data[2]; - if(sbusPaletteGeneration != serverGeneration) { - if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - sbusPaletteGeneration = serverGeneration; - } cmap = xnfcalloc(1, sizeof(sbusCmapRec)); - pScreen->devPrivates[sbusPaletteIndex].ptr = cmap; + dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap); cmap->psdp = psdp; fbcmap.index = 0; fbcmap.count = 16; diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index af98b4fd5..fc94284cb 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -125,6 +125,7 @@ typedef enum { MODE_ONE_HEIGHT, /* only one height is supported */ MODE_ONE_SIZE, /* only one resolution is supported */ MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ + MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ MODE_BAD = -2, /* unspecified reason */ MODE_ERROR = -1 /* error condition */ } ModeStatus; @@ -347,7 +348,7 @@ typedef struct _DriverRec { * functions to configuration tools, the Xserver, or any other * application/module interested in such information. */ -typedef struct _ModuleInfoRec { +_X_DEPRECATED typedef struct _ModuleInfoRec { int moduleVersion; char * moduleName; pointer module; diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index eac0d7e2c..7483e20d2 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -110,23 +110,22 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags); static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int); -static int XF86XVWindowIndex = -1; -int XF86XvScreenIndex = -1; -static unsigned long XF86XVGeneration = 0; +static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey; +DevPrivateKey XF86XvScreenKey; static unsigned long PortResource = 0; -int (*XvGetScreenIndexProc)(void) = NULL; +DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL; unsigned long (*XvGetRTPortProc)(void) = NULL; int (*XvScreenInitProc)(ScreenPtr) = NULL; #define GET_XV_SCREEN(pScreen) \ - ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr)) + ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey)) #define GET_XF86XV_SCREEN(pScreen) \ - ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) + ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) #define GET_XF86XV_WINDOW(pWin) \ - ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr)) + ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey)) static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL; static int NumGenDrivers = 0; @@ -233,21 +232,12 @@ xf86XVScreenInit( XvScreenPtr pxvs; if(num <= 0 || - !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc) - return FALSE; - - if(XF86XVGeneration != serverGeneration) { - if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - XF86XVGeneration = serverGeneration; - } - - if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0)) + !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc) return FALSE; if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; - XF86XvScreenIndex = (*XvGetScreenIndexProc)(); + XF86XvScreenKey = (*XvGetScreenKeyProc)(); PortResource = (*XvGetRTPortProc)(); pxvs = GET_XV_SCREEN(pScreen); @@ -977,7 +967,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) memset(winPriv, 0, sizeof(XF86XVWindowRec)); winPriv->PortRec = portPriv; winPriv->next = PrivRoot; - pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv); } portPriv->pDraw = (DrawablePtr)pWin; @@ -998,8 +988,8 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) if(prevPriv) prevPriv->next = winPriv->next; else - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)winPriv->next; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + winPriv->next); xfree(winPriv); break; } @@ -1037,7 +1027,7 @@ xf86XVDestroyWindow(WindowPtr pWin) xfree(tmp); } - pWin->devPrivates[XF86XVWindowIndex].ptr = NULL; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL); pScreen->DestroyWindow = ScreenPriv->DestroyWindow; ret = (*pScreen->DestroyWindow)(pWin); @@ -1094,8 +1084,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) pPriv->pDraw = NULL; if(!pPrev) - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)(WinPriv->next); + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); else pPrev->next = WinPriv->next; tmp = WinPriv; @@ -1146,8 +1136,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) pPriv->pDraw = NULL; if(!pPrev) - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)(WinPriv->next); + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); else pPrev->next = WinPriv->next; tmp = WinPriv; @@ -1844,7 +1834,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) int status; pval[0] = key; pval[1] = IncludeInferiors; - pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status); + pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status, + (XID)0, serverClient); if(!pGC) return; ValidateGC(pDraw, pGC); if (pPriv) pPriv->pGC = pGC; diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c index f8ff0bed4..05267a240 100644 --- a/hw/xfree86/common/xf86xvmc.c +++ b/hw/xfree86/common/xf86xvmc.c @@ -56,11 +56,10 @@ typedef struct { XvMCAdaptorPtr dixinfo; } xf86XvMCScreenRec, *xf86XvMCScreenPtr; -static unsigned long XF86XvMCGeneration = 0; -static int XF86XvMCScreenIndex = -1; +static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey; -#define XF86XVMC_GET_PRIVATE(pScreen) \ - (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr) +#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey) static int @@ -164,19 +163,12 @@ _X_EXPORT Bool xf86XvMCScreenInit( { XvMCAdaptorPtr pAdapt; xf86XvMCScreenPtr pScreenPriv; - XvScreenPtr pxvs = - (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr); - + XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + XF86XvScreenKey); int i, j; if(!XvMCScreenInitProc) return FALSE; - if(XF86XvMCGeneration != serverGeneration) { - if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - XF86XvMCGeneration = serverGeneration; - } - if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors))) return FALSE; @@ -185,7 +177,7 @@ _X_EXPORT Bool xf86XvMCScreenInit( return FALSE; } - pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86XvMCCloseScreen; diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index e716c9c6a..4200dac80 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -30,10 +30,11 @@ #define _XF86XVPRIV_H_ #include "xf86xv.h" +#include "privates.h" /*** These are DDX layer privates ***/ -extern int XF86XvScreenIndex; +extern DevPrivateKey XF86XvScreenKey; typedef struct { DestroyWindowProcPtr DestroyWindow; diff --git a/hw/xfree86/ddc/edid.h b/hw/xfree86/ddc/edid.h index 4487273cd..2496e19e6 100644 --- a/hw/xfree86/ddc/edid.h +++ b/hw/xfree86/ddc/edid.h @@ -1,5 +1,5 @@ - -/* edid.h: defines to parse an EDID block +/* + * edid.h: defines to parse an EDID block * * This file contains all information to interpret a standard EDIC block * transmitted by a display device via DDC (Display Data Channel). So far @@ -125,7 +125,11 @@ #define SYNC _SYNC(GET(D_INPUT)) #define _DFP(x) (x & 0x01) #define DFP _DFP(GET(D_INPUT)) -#define _GAMMA(x) (x == 0xff ? 1.0 : ((x + 100.0)/100.0)) +#define _BPC(x) ((x & 0x70) >> 4) +#define BPC _BPC(GET(D_INPUT)) +#define _DIGITAL_INTERFACE(x) (x & 0x0F) +#define DIGITAL_INTERFACE _DIGITAL_INTERFACE(GET(D_INPUT)) +#define _GAMMA(x) (x == 0xff ? 0.0 : ((x + 100.0)/100.0)) #define GAMMA _GAMMA(GET(D_GAMMA)) #define HSIZE_MAX GET(D_HSIZE) #define VSIZE_MAX GET(D_VSIZE) @@ -241,14 +245,18 @@ #define SERIAL_NUMBER 0xFF #define ASCII_STR 0xFE #define MONITOR_RANGES 0xFD +#define _MIN_V_OFFSET(x) ((!!(x[4] & 0x01)) * 255) +#define _MAX_V_OFFSET(x) ((!!(x[4] & 0x02)) * 255) +#define _MIN_H_OFFSET(x) ((!!(x[4] & 0x04)) * 255) +#define _MAX_H_OFFSET(x) ((!!(x[4] & 0x08)) * 255) #define _MIN_V(x) x[5] -#define MIN_V _MIN_V(c) +#define MIN_V (_MIN_V(c) + _MIN_V_OFFSET(c)) #define _MAX_V(x) x[6] -#define MAX_V _MAX_V(c) +#define MAX_V (_MAX_V(c) + _MAX_V_OFFSET(c)) #define _MIN_H(x) x[7] -#define MIN_H _MIN_H(c) +#define MIN_H (_MIN_H(c) + _MIN_H_OFFSET(c)) #define _MAX_H(x) x[8] -#define MAX_H _MAX_H(c) +#define MAX_H (_MAX_H(c) + _MAX_H_OFFSET(c)) #define _MAX_CLOCK(x) x[9] #define MAX_CLOCK _MAX_CLOCK(c) #define _HAVE_2ND_GTF(x) (x[10] == 0x02) @@ -282,6 +290,9 @@ #define _WHITE_GAMMA2(x) _GAMMA(x[14]) #define WHITE_GAMMA2 _WHITE_GAMMA2(c) #define ADD_STD_TIMINGS 0xFA +#define COLOR_MANAGEMENT_DATA 0xF9 +#define CVT_3BYTE_DATA 0xF8 +#define ADD_EST_TIMINGS 0xF7 #define ADD_DUMMY 0x10 #define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN)) @@ -315,11 +326,15 @@ #define DPMS_SUSPEND(x) (x & 0x02) #define DPMS_OFF(x) (x & 0x01) -/* display type */ +/* display type, analog */ #define DISP_MONO 0 #define DISP_RGB 1 #define DISP_MULTCOLOR 2 +/* display color encodings, digital */ +#define DISP_YCRCB444 0x01 +#define DISP_YCRCB422 0x02 + /* Msc stuff EDID Ver > 1.1 */ #define STD_COLOR_SPACE(x) (x & 0x4) #define PREFERRED_TIMING_MODE(x) (x & 0x2) @@ -357,6 +372,9 @@ struct disp_features { unsigned int input_setup:1; unsigned int input_sync:5; unsigned int input_dfp:1; + unsigned int input_bpc:3; + unsigned int input_interface:4; + /* 15 bit hole */ int hsize; int vsize; float gamma; @@ -414,8 +432,13 @@ struct detailed_timings { #define DS_RANGES 0xFD #define DS_WHITE_P 0xFB #define DS_STD_TIMINGS 0xFA +#define DS_CMD 0xF9 +#define DS_CVT 0xF8 +#define DS_EST_III 0xF7 #define DS_DUMMY 0x10 #define DS_UNKOWN 0x100 /* type is an int */ +#define DS_VENDOR 0x101 +#define DS_VENDOR_MAX 0x110 struct monitor_ranges { int min_v; @@ -437,17 +460,33 @@ struct whitePoints{ float white_gamma; }; +struct cvt_timings { + int width; + int height; + int rate; + int rates; +}; + +/* + * Be careful when adding new sections; this structure can't grow, it's + * embedded in the middle of xf86Monitor which is ABI. Sizes below are + * in bytes, for ILP32 systems. If all else fails just copy the section + * literally like serial and friends. + */ struct detailed_monitor_section { int type; union { - struct detailed_timings d_timings; + struct detailed_timings d_timings; /* 56 */ Uchar serial[13]; Uchar ascii_data[13]; Uchar name[13]; - struct monitor_ranges ranges; - struct std_timings std_t[5]; - struct whitePoints wp[2]; - } section; + struct monitor_ranges ranges; /* 40 */ + struct std_timings std_t[5]; /* 80 */ + struct whitePoints wp[2]; /* 32 */ + /* color management data */ + struct cvt_timings cvt[4]; /* 64 */ + /* established timings III */ + } section; /* max: 80 */ }; typedef struct { diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c index 7b4b2b9ec..14b0fd73a 100644 --- a/hw/xfree86/ddc/interpret_edid.c +++ b/hw/xfree86/ddc/interpret_edid.c @@ -1,8 +1,28 @@ - -/* interpret_edid.c: interpret a primary EDID block - * +/* * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE> + * Copyright 2007 Red Hat, Inc. + * + * 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, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * them 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 MERCHANTIBILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + * + * interpret_edid.c: interpret a primary EDID block */ + #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> #endif @@ -128,8 +148,12 @@ get_display_section(Uchar *c, struct disp_features *r, r->input_voltage = INPUT_VOLTAGE; r->input_setup = SETUP; r->input_sync = SYNC; - } else if (v->version > 1 || v->revision > 2) + } else if (v->revision == 2 || v->revision == 3) { r->input_dfp = DFP; + } else if (v->revision >= 4) { + r->input_bpc = BPC; + r->input_interface = DIGITAL_INTERFACE; + } r->hsize = HSIZE_MAX; r->vsize = VSIZE_MAX; r->gamma = GAMMA; @@ -155,6 +179,34 @@ get_established_timing_section(Uchar *c, struct established_timings *r) } static void +get_cvt_timing_section(Uchar *c, struct cvt_timings *r) +{ + int i; + + for (i = 0; i < 4; i++) { + if (c[0] && c[1] && c[2]) { + r[i].height = (c[0] + ((c[1] & 0xF0) << 8) + 1) * 2; + switch (c[1] & 0xc0) { + case 0x00: r[i].width = r[i].height * 4 / 3; break; + case 0x40: r[i].width = r[i].height * 16 / 9; break; + case 0x80: r[i].width = r[i].height * 16 / 10; break; + case 0xc0: r[i].width = r[i].height * 15 / 9; break; + } + switch (c[2] & 0x60) { + case 0x00: r[i].rate = 50; break; + case 0x20: r[i].rate = 60; break; + case 0x40: r[i].rate = 75; break; + case 0x60: r[i].rate = 85; break; + } + r[i].rates = c[2] & 0x1f; + } else { + return; + } + c += 3; + } +} + +static void get_std_timing_section(Uchar *c, struct std_timings *r, struct edid_version *v) { @@ -207,6 +259,16 @@ get_dt_md_section(Uchar *c, struct edid_version *ver, det_mon[i].type = DS_STD_TIMINGS; get_dst_timing_section(c,det_mon[i].section.std_t, ver); break; + case COLOR_MANAGEMENT_DATA: + det_mon[i].type = DS_CMD; + break; + case CVT_3BYTE_DATA: + det_mon[i].type = DS_CVT; + get_cvt_timing_section(c, det_mon[i].section.cvt); + break; + case ADD_EST_TIMINGS: + det_mon[i].type = DS_EST_III; + break; case ADD_DUMMY: det_mon[i].type = DS_DUMMY; break; @@ -214,6 +276,9 @@ get_dt_md_section(Uchar *c, struct edid_version *ver, det_mon[i].type = DS_UNKOWN; break; } + if (c[3] <= 0x0F) { + det_mon[i].type = DS_VENDOR + c[3]; + } } else { det_mon[i].type = DT; get_detailed_timing_section(c,&det_mon[i].section.d_timings); @@ -304,13 +369,16 @@ get_detailed_timing_section(Uchar *c, struct detailed_timings *r) r->misc = MISC; } -#define MAX_EDID_MINOR 3 +#define MAX_EDID_MINOR 4 static Bool validate_version(int scrnIndex, struct edid_version *r) { - if (r->version != 1) + if (r->version != 1) { + xf86DrvMsg(scrnIndex, X_ERROR, "Unknown EDID version %d\n", + r->version); return FALSE; + } if (r->revision > MAX_EDID_MINOR) xf86DrvMsg(scrnIndex, X_WARNING, diff --git a/hw/xfree86/ddc/print_edid.c b/hw/xfree86/ddc/print_edid.c index 30b607d4f..d9f18fa9f 100644 --- a/hw/xfree86/ddc/print_edid.c +++ b/hw/xfree86/ddc/print_edid.c @@ -1,8 +1,28 @@ - -/* print_edid.c: print out all information retrieved from display device - * +/* * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE> + * Copyright 2007 Red Hat, Inc. + * + * 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, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * them 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 MERCHANTIBILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + * + * print_edid.c: print out all information retrieved from display device */ + #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> #endif @@ -11,53 +31,9 @@ #include "xf86.h" #include "xf86_OSproc.h" #include "xf86DDC.h" +#include "edid.h" -static void print_vendor(int scrnIndex, struct vendor *); -static void print_version(int scrnIndex, struct edid_version *); -static void print_display(int scrnIndex, struct disp_features *, - struct edid_version *); -static void print_established_timings(int scrnIndex, - struct established_timings *); -static void print_std_timings(int scrnIndex, struct std_timings *); -static void print_detailed_monitor_section(int scrnIndex, - struct detailed_monitor_section *); -static void print_detailed_timings(int scrnIndex, struct detailed_timings *); - -static void print_input_features(int scrnIndex, struct disp_features *); -static void print_dpms_features(int scrnIndex, struct disp_features *, - struct edid_version *v); -static void print_whitepoint(int scrnIndex, struct disp_features *); -static void print_number_sections(int scrnIndex, int); - #define EDID_WIDTH 16 - -xf86MonPtr -xf86PrintEDID(xf86MonPtr m) -{ - CARD16 i, j; - char buf[EDID_WIDTH * 2 + 1]; - - if (!(m)) return NULL; - - print_vendor(m->scrnIndex,&m->vendor); - print_version(m->scrnIndex,&m->ver); - print_display(m->scrnIndex,&m->features, &m->ver); - print_established_timings(m->scrnIndex,&m->timings1); - print_std_timings(m->scrnIndex,m->timings2); - print_detailed_monitor_section(m->scrnIndex,m->det_mon); - print_number_sections(m->scrnIndex,m->no_sections); - - xf86DrvMsg(m->scrnIndex, X_INFO, "EDID (in hex):\n"); - - for (i = 0; i < 128; i += j) { - for (j = 0; j < EDID_WIDTH; ++j) { - sprintf(&buf[j * 2], "%02x", m->rawData[i + j]); - } - xf86DrvMsg(m->scrnIndex, X_INFO, "\t%s\n", buf); - } - - return m; -} static void print_vendor(int scrnIndex, struct vendor *c) @@ -66,7 +42,7 @@ print_vendor(int scrnIndex, struct vendor *c) (char *)&c->name, c->prod_id, c->serial); xf86DrvMsg(scrnIndex, X_INFO, "Year: %u Week: %u\n", c->year, c->week); } - + static void print_version(int scrnIndex, struct edid_version *c) { @@ -74,32 +50,38 @@ print_version(int scrnIndex, struct edid_version *c) c->revision); } -static void -print_display(int scrnIndex, struct disp_features *disp, - struct edid_version *version) -{ - print_input_features(scrnIndex,disp); - xf86DrvMsg(scrnIndex,X_INFO,"Max H-Image Size [cm]: "); - if (disp->hsize) - xf86ErrorF("horiz.: %i ",disp->hsize); - else - xf86ErrorF("H-Size may change, "); - if (disp->vsize) - xf86ErrorF("vert.: %i\n",disp->vsize); - else - xf86ErrorF("V-Size may change\n"); - xf86DrvMsg(scrnIndex,X_INFO,"Gamma: %.2f\n", disp->gamma); - print_dpms_features(scrnIndex,disp,version); - print_whitepoint(scrnIndex,disp); -} - +static const char *digital_interfaces[] = { + "undefined", + "DVI", + "HDMI-a", + "HDMI-b", + "MDDI", + "DisplayPort", + "unknown" +}; + static void -print_input_features(int scrnIndex, struct disp_features *c) +print_input_features(int scrnIndex, struct disp_features *c, + struct edid_version *v) { if (DIGITAL(c->input_type)) { - xf86DrvMsg(scrnIndex,X_INFO,"Digital Display Input\n"); - if (DFP1(c->input_dfp)) - xf86DrvMsg(scrnIndex,X_INFO,"DFP 1.x compatible TMDS\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Digital Display Input\n"); + if (v->revision == 2 || v->revision == 3) { + if (DFP1(c->input_dfp)) + xf86DrvMsg(scrnIndex, X_INFO, "DFP 1.x compatible TMDS\n"); + } else if (v->revision >= 4) { + int interface = c->input_interface; + int bpc = c->input_bpc; + if (interface > 6) + interface = 6; /* unknown */ + if (bpc == 0 || bpc == 7) + xf86DrvMsg(scrnIndex, X_INFO, "Undefined color depth\n"); + else + xf86DrvMsg(scrnIndex, X_INFO, "%d bits per channel\n", + bpc * 2 + 4); + xf86DrvMsg(scrnIndex, X_INFO, "Digital interface is %s\n", + digital_interfaces[interface]); + } } else { xf86DrvMsg(scrnIndex,X_INFO,"Analog Display Input, "); xf86ErrorF("Input Voltage Level: "); @@ -146,33 +128,53 @@ print_dpms_features(int scrnIndex, struct disp_features *c, if (DPMS_OFF(c->dpms)) xf86ErrorF(" Off"); } else xf86DrvMsg(scrnIndex,X_INFO,"No DPMS capabilities specified"); - switch (c->display_type){ - case DISP_MONO: - xf86ErrorF("; Monochorome/GrayScale Display\n"); - break; - case DISP_RGB: - xf86ErrorF("; RGB/Color Display\n"); - break; - case DISP_MULTCOLOR: - xf86ErrorF("; Non RGB Multicolor Display\n"); - break; - default: - xf86ErrorF("\n"); - break; + if (!c->input_type) { /* analog */ + switch (c->display_type){ + case DISP_MONO: + xf86ErrorF("; Monochorome/GrayScale Display\n"); + break; + case DISP_RGB: + xf86ErrorF("; RGB/Color Display\n"); + break; + case DISP_MULTCOLOR: + xf86ErrorF("; Non RGB Multicolor Display\n"); + break; + default: + xf86ErrorF("\n"); + break; + } + } else { + int enc = c->display_type; + xf86DrvMsg(scrnIndex, X_INFO, "\nSupported color encodings: " + "RGB 4:4:4 %s%s\n", + enc & DISP_YCRCB444 ? "YCrCb 4:4:4 " : "", + enc & DISP_YCRCB422 ? "YCrCb 4:2:2" : ""); } + if (STD_COLOR_SPACE(c->msc)) xf86DrvMsg(scrnIndex,X_INFO, "Default color space is primary color space\n"); - if (PREFERRED_TIMING_MODE(c->msc)) - xf86DrvMsg(scrnIndex,X_INFO, + + if (PREFERRED_TIMING_MODE(c->msc) || v->revision >= 4) { + xf86DrvMsg(scrnIndex, X_INFO, "First detailed timing is preferred mode\n"); - else if (v->version == 1 && v->revision >= 3) + if (v->revision >= 4) + xf86DrvMsg(scrnIndex, X_INFO, + "Preferred mode is native pixel format and refresh rate\n"); + } else if (v->revision == 3) { xf86DrvMsg(scrnIndex,X_INFO, "First detailed timing not preferred " "mode in violation of standard!"); - if (GFT_SUPPORTED(c->msc)) - xf86DrvMsg(scrnIndex,X_INFO, - "GTF timings supported\n"); + } + + if (v->revision >= 4) { + if (GFT_SUPPORTED(c->msc)) { + xf86DrvMsg(scrnIndex, X_INFO, "Display is continuous-frequency\n"); + } + } else { + if (GFT_SUPPORTED(c->msc)) + xf86DrvMsg(scrnIndex, X_INFO, "GTF timings supported\n"); + } } static void @@ -187,7 +189,37 @@ print_whitepoint(int scrnIndex, struct disp_features *disp) xf86ErrorF("whiteX: %.3f whiteY: %.3f\n", disp->whitex,disp->whitey); } - + +static void +print_display(int scrnIndex, struct disp_features *disp, + struct edid_version *v) +{ + print_input_features(scrnIndex, disp, v); + if (disp->hsize && disp->vsize) { + xf86DrvMsg(scrnIndex, X_INFO, "Max Image Size [cm]: "); + xf86ErrorF("horiz.: %i ", disp->hsize); + xf86ErrorF("vert.: %i\n", disp->vsize); + } else if (v->revision >= 4 && (disp->hsize || disp->vsize)) { + if (disp->hsize) + xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (landscape)\n", + (disp->hsize + 99) / 100.0); + if (disp->vsize) + xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (portrait)\n", + 100.0 / (float)(disp->vsize + 99)); + + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Indeterminate output size\n"); + } + + if (!disp->gamma && v->revision >= 1.4) + xf86DrvMsg(scrnIndex, X_INFO, "Gamma defined in extension block\n"); + else + xf86DrvMsg(scrnIndex, X_INFO, "Gamma: %.2f\n", disp->gamma); + + print_dpms_features(scrnIndex, disp, v); + print_whitepoint(scrnIndex, disp); +} + static void print_established_timings(int scrnIndex, struct established_timings *t) { @@ -235,7 +267,68 @@ print_std_timings(int scrnIndex, struct std_timings *t) } } } - + +static void +print_cvt_timings(int si, struct cvt_timings *t) +{ + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + xf86DrvMsg(si, X_INFO, "%dx%d @ %s%s%s%s%s Hz\n", + t[i].width, t[i].height, + t[i].rates & 0x10 ? "50," : "", + t[i].rates & 0x08 ? "60," : "", + t[i].rates & 0x04 ? "75," : "", + t[i].rates & 0x02 ? "85," : "", + t[i].rates & 0x01 ? "60RB" : ""); + } else break; + } +} + +static void +print_detailed_timings(int scrnIndex, struct detailed_timings *t) +{ + + if (t->clock > 15000000) { /* sanity check */ + xf86DrvMsg(scrnIndex,X_INFO,"Supported additional Video Mode:\n"); + xf86DrvMsg(scrnIndex,X_INFO,"clock: %.1f MHz ",t->clock/1000000.0); + xf86ErrorF("Image Size: %i x %i mm\n",t->h_size,t->v_size); + xf86DrvMsg(scrnIndex,X_INFO, + "h_active: %i h_sync: %i h_sync_end %i h_blank_end %i ", + t->h_active, t->h_sync_off + t->h_active, + t->h_sync_off + t->h_sync_width + t->h_active, + t->h_active + t->h_blanking); + xf86ErrorF("h_border: %i\n",t->h_border); + xf86DrvMsg(scrnIndex,X_INFO, + "v_active: %i v_sync: %i v_sync_end %i v_blanking: %i ", + t->v_active, t->v_sync_off + t->v_active, + t->v_sync_off + t->v_sync_width + t->v_active, + t->v_active + t->v_blanking); + xf86ErrorF("v_border: %i\n",t->v_border); + if (IS_STEREO(t->stereo)) { + xf86DrvMsg(scrnIndex,X_INFO,"Stereo: "); + if (IS_RIGHT_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("right channel on sync\n"); + else + xf86ErrorF("left channel on sync\n"); + } else if (IS_LEFT_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("right channel on even line\n"); + else + xf86ErrorF("left channel on evel line\n"); + } + if (IS_4WAY_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("4-way interleaved\n"); + else + xf86ErrorF("side-by-side interleaved"); + } + } + } +} + static void print_detailed_monitor_section(int scrnIndex, struct detailed_monitor_section *m) @@ -290,56 +383,31 @@ print_detailed_monitor_section(int scrnIndex, m[i].section.wp[j].white_y, m[i].section.wp[j].white_gamma); break; + case DS_CMD: + xf86DrvMsg(scrnIndex, X_INFO, + "Color management data: (not decoded)\n"); + break; + case DS_CVT: + xf86DrvMsg(scrnIndex, X_INFO, + "CVT 3-byte-code modes:\n"); + print_cvt_timings(scrnIndex, m[i].section.cvt); + break; + case DS_EST_III: + xf86DrvMsg(scrnIndex, X_INFO, + "Established timings III: (not decoded)\n"); + break; case DS_DUMMY: default: break; } - } -} - -static void -print_detailed_timings(int scrnIndex, struct detailed_timings *t) -{ - - if (t->clock > 15000000) { /* sanity check */ - xf86DrvMsg(scrnIndex,X_INFO,"Supported additional Video Mode:\n"); - xf86DrvMsg(scrnIndex,X_INFO,"clock: %.1f MHz ",t->clock/1000000.0); - xf86ErrorF("Image Size: %i x %i mm\n",t->h_size,t->v_size); - xf86DrvMsg(scrnIndex,X_INFO, - "h_active: %i h_sync: %i h_sync_end %i h_blank_end %i ", - t->h_active, t->h_sync_off + t->h_active, - t->h_sync_off + t->h_sync_width + t->h_active, - t->h_active + t->h_blanking); - xf86ErrorF("h_border: %i\n",t->h_border); - xf86DrvMsg(scrnIndex,X_INFO, - "v_active: %i v_sync: %i v_sync_end %i v_blanking: %i ", - t->v_active, t->v_sync_off + t->v_active, - t->v_sync_off + t->v_sync_width + t->v_active, - t->v_active + t->v_blanking); - xf86ErrorF("v_border: %i\n",t->v_border); - if (IS_STEREO(t->stereo)) { - xf86DrvMsg(scrnIndex,X_INFO,"Stereo: "); - if (IS_RIGHT_STEREO(t->stereo)) { - if (!t->stereo_1) - xf86ErrorF("right channel on sync\n"); - else - xf86ErrorF("left channel on sync\n"); - } else if (IS_LEFT_STEREO(t->stereo)) { - if (!t->stereo_1) - xf86ErrorF("right channel on even line\n"); - else - xf86ErrorF("left channel on evel line\n"); - } - if (IS_4WAY_STEREO(t->stereo)) { - if (!t->stereo_1) - xf86ErrorF("4-way interleaved\n"); - else - xf86ErrorF("side-by-side interleaved"); - } + if (m[i].type >= DS_VENDOR && m[i].type <= DS_VENDOR_MAX) { + xf86DrvMsg(scrnIndex, X_WARNING, + "Unknown vendor-specific block %hx\n", + m[i].type - DS_VENDOR); } } } - + static void print_number_sections(int scrnIndex, int num) { @@ -348,3 +416,30 @@ print_number_sections(int scrnIndex, int num) num); } +xf86MonPtr +xf86PrintEDID(xf86MonPtr m) +{ + CARD16 i, j; + char buf[EDID_WIDTH * 2 + 1]; + + if (!(m)) return NULL; + + print_vendor(m->scrnIndex,&m->vendor); + print_version(m->scrnIndex,&m->ver); + print_display(m->scrnIndex,&m->features, &m->ver); + print_established_timings(m->scrnIndex,&m->timings1); + print_std_timings(m->scrnIndex,m->timings2); + print_detailed_monitor_section(m->scrnIndex,m->det_mon); + print_number_sections(m->scrnIndex,m->no_sections); + + xf86DrvMsg(m->scrnIndex, X_INFO, "EDID (in hex):\n"); + + for (i = 0; i < 128; i += j) { + for (j = 0; j < EDID_WIDTH; ++j) { + sprintf(&buf[j * 2], "%02x", m->rawData[i + j]); + } + xf86DrvMsg(m->scrnIndex, X_INFO, "\t%s\n", buf); + } + + return m; +} diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c index acd700694..d0d892aaf 100644 --- a/hw/xfree86/dixmods/extmod/modinit.c +++ b/hw/xfree86/dixmods/extmod/modinit.c @@ -38,6 +38,15 @@ static MODULESETUPPROTO(extmodSetup); * Array describing extensions to be initialized */ static ExtensionModule extensionModules[] = { +#ifdef XSELINUX + { + SELinuxExtensionInit, + SELINUX_EXTENSION_NAME, + NULL, + NULL, + NULL + }, +#endif #ifdef SHAPE { ShapeExtensionInit, diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h index 41f060b2a..3c2e2022a 100644 --- a/hw/xfree86/dixmods/extmod/modinit.h +++ b/hw/xfree86/dixmods/extmod/modinit.h @@ -125,12 +125,12 @@ extern void ShmRegisterFuncs( ShmFuncsPtr funcs); #endif -#ifdef XACE -extern void XaceExtensionInit(INITARGS); +#ifdef XSELINUX +extern void SELinuxExtensionInit(INITARGS); +#include "xselinux.h" #endif #if 1 -extern void SecurityExtensionSetup(INITARGS); extern void SecurityExtensionInit(INITARGS); #endif diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index fa9530860..295e05e9e 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -62,8 +62,7 @@ unsigned char DGAReqCode = 0; int DGAErrorBase; int DGAEventBase; -static int DGAGeneration = 0; -static int DGAClientPrivateIndex; +static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey; static int DGACallbackRefCount = 0; /* This holds the client's version information */ @@ -72,7 +71,11 @@ typedef struct { int minor; } DGAPrivRec, *DGAPrivPtr; -#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr) +#define DGA_GETPRIV(c) ((DGAPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey)) +#define DGA_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p) + void XFree86DGAExtensionInit(INITARGS) @@ -97,23 +100,6 @@ XFree86DGAExtensionInit(INITARGS) for (i = KeyPress; i <= MotionNotify; i++) SetCriticalEvent (DGAEventBase + i); } - - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (DGAGeneration != serverGeneration) { - DGAClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to - * our DGAPrivRec. - */ - if (!AllocateClientPrivate(DGAClientPrivateIndex, 0)) { - ErrorF("XFree86DGAExtensionInit: AllocateClientPrivate failed\n"); - return; - } - DGAGeneration = serverGeneration; - } } @@ -590,12 +576,12 @@ ProcXDGASetClientVersion(ClientPtr client) DGAPrivPtr pPriv; REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); - if ((pPriv = DGAPRIV(client)) == NULL) { + if ((pPriv = DGA_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(DGAPrivRec)); /* XXX Need to look into freeing this */ if (!pPriv) return BadAlloc; - DGAPRIV(client) = pPriv; + DGA_SETPRIV(client, pPriv); } pPriv->major = stuff->major; pPriv->minor = stuff->minor; diff --git a/hw/xfree86/dixmods/extmod/xf86misc.c b/hw/xfree86/dixmods/extmod/xf86misc.c index 3a6f83eca..8127afdff 100644 --- a/hw/xfree86/dixmods/extmod/xf86misc.c +++ b/hw/xfree86/dixmods/extmod/xf86misc.c @@ -41,8 +41,7 @@ #endif static int miscErrorBase; -static int MiscGeneration = 0; -static int MiscClientPrivateIndex; +static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey; /* This holds the client's version information */ typedef struct { @@ -50,7 +49,10 @@ typedef struct { int minor; } MiscPrivRec, *MiscPrivPtr; -#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr) +#define M_GETPRIV(c) ((MiscPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey)) +#define M_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p) static void XF86MiscResetProc( ExtensionEntry* /* extEntry */ @@ -61,7 +63,7 @@ ClientVersion(ClientPtr client, int *major, int *minor) { MiscPrivPtr pPriv; - pPriv = MPRIV(client); + pPriv = M_GETPRIV(client); if (!pPriv) { if (major) *major = 0; if (minor) *minor = 0; @@ -106,9 +108,9 @@ static unsigned char XF86MiscReqCode = 0; #endif #ifdef DEBUG -# define DEBUG_P(x) ErrorF(x"\n"); +# define DEBUG_P(x) ErrorF x; #else -# define DEBUG_P(x) /**/ +# define DEBUG_P(x) do {} while (0) #endif #define MISCERR(x) (miscErrorBase + x) @@ -118,29 +120,9 @@ XFree86MiscExtensionInit(void) { ExtensionEntry* extEntry; - DEBUG_P("XFree86MiscExtensionInit"); - if (!xf86GetModInDevEnabled()) return; - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (MiscGeneration != serverGeneration) { - MiscClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to our - * MiscPrivRec. - */ - if (!AllocateClientPrivate(MiscClientPrivateIndex, 0)) { - ErrorF("XFree86MiscExtensionInit: " - "AllocateClientPrivate failed\n"); - return; - } - MiscGeneration = serverGeneration; - } - if ( (extEntry = AddExtension(XF86MISCNAME, XF86MiscNumberEvents, @@ -170,8 +152,6 @@ ProcXF86MiscQueryVersion(client) xXF86MiscQueryVersionReply rep; register int n; - DEBUG_P("XF86MiscQueryVersion"); - REQUEST_SIZE_MATCH(xXF86MiscQueryVersionReq); rep.type = X_Reply; rep.length = 0; @@ -205,7 +185,9 @@ ProcXF86MiscSetSaver(client) if (stuff->screen > screenInfo.numScreens) return BadValue; - vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); @@ -233,7 +215,9 @@ ProcXF86MiscGetSaver(client) if (stuff->screen > screenInfo.numScreens) return BadValue; - vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); rep.type = X_Reply; @@ -262,8 +246,7 @@ ProcXF86MiscGetMouseSettings(client) char *devname; pointer mouse; register int n; - - DEBUG_P("XF86MiscGetMouseSettings"); + int devnamelen; REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); rep.type = X_Reply; @@ -281,7 +264,7 @@ ProcXF86MiscGetMouseSettings(client) rep.emulate3timeout = MiscExtGetMouseValue(mouse, MISC_MSE_EM3TIMEOUT); rep.chordmiddle = MiscExtGetMouseValue(mouse, MISC_MSE_CHORDMIDDLE); rep.flags = MiscExtGetMouseValue(mouse, MISC_MSE_FLAGS); - rep.devnamelen = (devname? strlen(devname): 0); + devnamelen = rep.devnamelen = (devname? strlen(devname): 0); rep.length = (sizeof(xXF86MiscGetMouseSettingsReply) - sizeof(xGenericReply) + ((rep.devnamelen+3) & ~3)) >> 2; @@ -301,8 +284,8 @@ ProcXF86MiscGetMouseSettings(client) WriteToClient(client, SIZEOF(xXF86MiscGetMouseSettingsReply), (char *)&rep); MiscExtDestroyStruct(mouse, MISC_POINTER); - if (rep.devnamelen) - WriteToClient(client, rep.devnamelen, devname); + if (devnamelen) + WriteToClient(client, devnamelen, devname); return (client->noClientException); } @@ -314,8 +297,6 @@ ProcXF86MiscGetKbdSettings(client) pointer kbd; register int n; - DEBUG_P("XF86MiscGetKbdSettings"); - REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); rep.type = X_Reply; rep.length = 0; @@ -349,19 +330,17 @@ ProcXF86MiscSetMouseSettings(client) REQUEST(xXF86MiscSetMouseSettingsReq); - DEBUG_P("XF86MiscSetMouseSettings"); - REQUEST_AT_LEAST_SIZE(xXF86MiscSetMouseSettingsReq); ClientVersion(client, &major, &minor); if (xf86GetVerbosity() > 1) { - ErrorF("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n", + DEBUG_P(("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n", (int)stuff->mousetype, (int)stuff->baudrate, - (int)stuff->samplerate, stuff->chordmiddle); - ErrorF(" em3but: %d em3tim: %d res: %d flags: %ld\n", + (int)stuff->samplerate, stuff->chordmiddle)); + DEBUG_P((" em3but: %d em3tim: %d res: %d flags: %ld\n", stuff->emulate3buttons, (int)stuff->emulate3timeout, - (int)stuff->resolution, (unsigned long)stuff->flags); + (int)stuff->resolution, (unsigned long)stuff->flags)); } if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0) @@ -387,7 +366,7 @@ ProcXF86MiscSetMouseSettings(client) return BadAlloc; strncpy(devname,(char*)(&stuff[1]),stuff->devnamelen); if (xf86GetVerbosity() > 1) - ErrorF("SetMouseSettings - device: %s\n",devname); + DEBUG_P(("SetMouseSettings - device: %s\n",devname)); MiscExtSetMouseDevice(mouse, devname); } } @@ -406,12 +385,12 @@ ProcXF86MiscSetMouseSettings(client) case MISC_RET_BADCOMBO: return MISCERR(XF86MiscBadMouseCombo); case MISC_RET_NOMODULE: return MISCERR(XF86MiscNoModule); default: - ErrorF("Unexpected return from MiscExtApply(POINTER) = %d\n", ret); + DEBUG_P(("Unexpected return from MiscExtApply(POINTER) = %d\n", ret)); return BadImplementation; } if (xf86GetVerbosity() > 1) - ErrorF("SetMouseSettings - Succeeded\n"); + DEBUG_P(("SetMouseSettings - Succeeded\n")); return (client->noClientException); } @@ -423,14 +402,12 @@ ProcXF86MiscSetKbdSettings(client) pointer kbd; REQUEST(xXF86MiscSetKbdSettingsReq); - DEBUG_P("XF86MiscSetKbdSettings"); - REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); if (xf86GetVerbosity() > 1) - ErrorF("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n", + DEBUG_P(("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n", (int)stuff->kbdtype, (int)stuff->rate, - (int)stuff->delay, stuff->servnumlock); + (int)stuff->delay, stuff->servnumlock)); if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0) return BadAlloc; @@ -445,12 +422,12 @@ ProcXF86MiscSetKbdSettings(client) case MISC_RET_BADVAL: return BadValue; case MISC_RET_BADKBDTYPE: return MISCERR(XF86MiscBadKbdType); default: - ErrorF("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret); + DEBUG_P(("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret)); return BadImplementation; } if (xf86GetVerbosity() > 1) - ErrorF("SetKbdSettings - Succeeded\n"); + DEBUG_P(("SetKbdSettings - Succeeded\n")); return (client->noClientException); } @@ -462,14 +439,12 @@ ProcXF86MiscSetGrabKeysState(client) xXF86MiscSetGrabKeysStateReply rep; REQUEST(xXF86MiscSetGrabKeysStateReq); - DEBUG_P("XF86MiscSetGrabKeysState"); - REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); if ((status = MiscExtSetGrabKeysState(client, stuff->enable)) == 0) { if (xf86GetVerbosity() > 1) - ErrorF("SetGrabKeysState - %s\n", - stuff->enable ? "enabled" : "disabled"); + DEBUG_P(("SetGrabKeysState - %s\n", + stuff->enable ? "enabled" : "disabled")); } rep.type = X_Reply; @@ -493,18 +468,16 @@ ProcXF86MiscSetClientVersion(ClientPtr client) MiscPrivPtr pPriv; - DEBUG_P("XF86MiscSetClientVersion"); - REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); - if ((pPriv = MPRIV(client)) == NULL) { + if ((pPriv = M_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(MiscPrivRec)); if (!pPriv) return BadAlloc; - MPRIV(client) = pPriv; + M_SETPRIV(client, pPriv); } if (xf86GetVerbosity() > 1) - ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor); + DEBUG_P(("SetClientVersion: %i %i\n",stuff->major,stuff->minor)); pPriv->major = stuff->major; pPriv->minor = stuff->minor; @@ -520,8 +493,7 @@ ProcXF86MiscGetFilePaths(client) const char *modulepath; const char *logfile; register int n; - - DEBUG_P("XF86MiscGetFilePaths"); + int configlen, modulelen, loglen; REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); rep.type = X_Reply; @@ -530,9 +502,9 @@ ProcXF86MiscGetFilePaths(client) if (!MiscExtGetFilePaths(&configfile, &modulepath, &logfile)) return BadValue; - rep.configlen = (configfile? strlen(configfile): 0); - rep.modulelen = (modulepath? strlen(modulepath): 0); - rep.loglen = (logfile? strlen(logfile): 0); + configlen = rep.configlen = (configfile? strlen(configfile): 0); + modulelen = rep.modulelen = (modulepath? strlen(modulepath): 0); + loglen = rep.loglen = (logfile? strlen(logfile): 0); rep.length = (SIZEOF(xXF86MiscGetFilePathsReply) - SIZEOF(xGenericReply) + ((rep.configlen + 3) & ~3) + ((rep.modulelen + 3) & ~3) + @@ -547,12 +519,12 @@ ProcXF86MiscGetFilePaths(client) } WriteToClient(client, SIZEOF(xXF86MiscGetFilePathsReply), (char *)&rep); - if (rep.configlen) - WriteToClient(client, rep.configlen, (char *)configfile); - if (rep.modulelen) - WriteToClient(client, rep.modulelen, (char *)modulepath); - if (rep.loglen) - WriteToClient(client, rep.loglen, (char *)logfile); + if (configlen) + WriteToClient(client, configlen, (char *)configfile); + if (modulelen) + WriteToClient(client, modulelen, (char *)modulepath); + if (loglen) + WriteToClient(client, loglen, (char *)logfile); return (client->noClientException); } @@ -565,11 +537,10 @@ ProcXF86MiscPassMessage(client) char *msgtype, *msgval, *retstr; int retval, size; register int n; + int mesglen; REQUEST(xXF86MiscPassMessageReq); - DEBUG_P("XF86MiscPassMessage"); - REQUEST_AT_LEAST_SIZE(xXF86MiscPassMessageReq); size = (sizeof(xXF86MiscPassMessageReq) + 3) >> 2; size+= (stuff->typelen + 3) >> 2; @@ -601,7 +572,7 @@ ProcXF86MiscPassMessage(client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.mesglen = (retstr? strlen(retstr): 0); + mesglen = rep.mesglen = (retstr? strlen(retstr): 0); rep.length = (SIZEOF(xXF86MiscPassMessageReply) - SIZEOF(xGenericReply) + ((rep.mesglen + 3) & ~3)) >> 2; rep.status = 0; @@ -613,8 +584,8 @@ ProcXF86MiscPassMessage(client) } WriteToClient(client, SIZEOF(xXF86MiscPassMessageReply), (char *)&rep); - if (rep.mesglen) - WriteToClient(client, rep.mesglen, (char *)retstr); + if (mesglen) + WriteToClient(client, mesglen, (char *)retstr); xfree(msgtype); xfree(msgval); diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index 3b054a829..718d40fbd 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -52,8 +52,7 @@ from Kaleb S. KEITHLEY #define DEFAULT_XF86VIDMODE_VERBOSITY 3 static int VidModeErrorBase; -static int VidModeGeneration = 0; -static int VidModeClientPrivateIndex; +static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey; /* This holds the client's version information */ typedef struct { @@ -61,7 +60,10 @@ typedef struct { int minor; } VidModePrivRec, *VidModePrivPtr; -#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr) +#define VM_GETPRIV(c) ((VidModePrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey)) +#define VM_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p) static void XF86VidModeResetProc( ExtensionEntry* /* extEntry */ @@ -145,10 +147,12 @@ typedef struct _XF86VidModeScreenPrivate { Bool hasWindow; } XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; -static int ScreenPrivateIndex; +static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey; -#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr) -#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v); +#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ + dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) +#define SetScreenPrivate(s,v) \ + dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v) #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s) #define New(t) (xalloc (sizeof (t))) @@ -172,7 +176,6 @@ XFree86VidModeExtensionInit(void) #ifdef XF86VIDMODE_EVENTS EventType = CreateNewResourceType(XF86VidModeFreeEvents); - ScreenPrivateIndex = AllocateScreenPrivateIndex (); #endif for(i = 0; i < screenInfo.numScreens; i++) { @@ -187,27 +190,9 @@ XFree86VidModeExtensionInit(void) if (!enabled) return; - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (VidModeGeneration != serverGeneration) { - VidModeClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to our - * VidModePrivRec. - */ - if (!AllocateClientPrivate(VidModeClientPrivateIndex, 0)) { - ErrorF("XFree86VidModeExtensionInit: " - "AllocateClientPrivate failed\n"); - return; - } - VidModeGeneration = serverGeneration; - } - if ( #ifdef XF86VIDMODE_EVENTS - EventType && ScreenPrivateIndex != -1 && + EventType && #endif (extEntry = AddExtension(XF86VIDMODENAME, XF86VidModeNumberEvents, @@ -239,7 +224,7 @@ ClientMajorVersion(ClientPtr client) { VidModePrivPtr pPriv; - pPriv = VMPRIV(client); + pPriv = VM_GETPRIV(client); if (!pPriv) return 0; else @@ -1682,11 +1667,11 @@ ProcXF86VidModeSetClientVersion(ClientPtr client) REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); - if ((pPriv = VMPRIV(client)) == NULL) { + if ((pPriv = VM_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(VidModePrivRec)); if (!pPriv) return BadAlloc; - VMPRIV(client) = pPriv; + VM_SETPRIV(client, pPriv); } pPriv->major = stuff->major; pPriv->minor = stuff->minor; diff --git a/hw/xfree86/dixmods/extmod/xvmod.c b/hw/xfree86/dixmods/extmod/xvmod.c index 7c1450c7a..6b3f1149a 100644 --- a/hw/xfree86/dixmods/extmod/xvmod.c +++ b/hw/xfree86/dixmods/extmod/xvmod.c @@ -16,7 +16,7 @@ void XvRegister() { XvScreenInitProc = XvScreenInit; - XvGetScreenIndexProc = XvGetScreenIndex; + XvGetScreenKeyProc = XvGetScreenKey; XvGetRTPortProc = XvGetRTPort; XvMCScreenInitProc = XvMCScreenInit; } diff --git a/hw/xfree86/dixmods/extmod/xvmodproc.h b/hw/xfree86/dixmods/extmod/xvmodproc.h index 81356a149..b39c915b4 100644 --- a/hw/xfree86/dixmods/extmod/xvmodproc.h +++ b/hw/xfree86/dixmods/extmod/xvmodproc.h @@ -5,7 +5,7 @@ #include "xvmcext.h" -extern int (*XvGetScreenIndexProc)(void); +extern DevPrivateKey (*XvGetScreenKeyProc)(void); extern unsigned long (*XvGetRTPortProc)(void); extern int (*XvScreenInitProc)(ScreenPtr); extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c index 0ff867de0..a1a088629 100644 --- a/hw/xfree86/dixmods/glxmodule.c +++ b/hw/xfree86/dixmods/glxmodule.c @@ -125,6 +125,9 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) provider = LoaderSymbol("__glXDRIProvider"); if (provider) GlxPushProvider(provider); + provider = LoaderSymbol("__glXDRI2Provider"); + if (provider) + GlxPushProvider(provider); } switch (xf86Info.glxVisuals) { diff --git a/hw/xfree86/dixmods/xkbKillSrv.c b/hw/xfree86/dixmods/xkbKillSrv.c index b3399db4a..9074fd390 100644 --- a/hw/xfree86/dixmods/xkbKillSrv.c +++ b/hw/xfree86/dixmods/xkbKillSrv.c @@ -48,6 +48,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. int XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) { - xf86ProcessActionEvent(ACTION_TERMINATE, NULL); + if (dev != inputInfo.keyboard) + xf86ProcessActionEvent(ACTION_TERMINATE, NULL); + return 0; } diff --git a/hw/xfree86/doc/devel/Registry b/hw/xfree86/doc/devel/Registry index d76622157..1fec230e8 100644 --- a/hw/xfree86/doc/devel/Registry +++ b/hw/xfree86/doc/devel/Registry @@ -75,7 +75,6 @@ rendition s3 s3virge savage -scanpci shadow shadowfb siliconmotion diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index c950e326b..405efda55 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -378,13 +378,6 @@ and .B \-ggamma options. .TP 8 -.B \-scanpci -When this option is specified, the -.B __xservername__ -server scans the PCI bus, and prints out some information about each -device that was detected. See also scanpci(__appmansuffix__) -and pcitweak(__appmansuffix__). -.TP 8 .BI \-screen " screen-name" Use the __xconfigfile__(__filemansuffix__) file .B Screen diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre index 3c657d0f0..9f3980879 100644 --- a/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/hw/xfree86/doc/man/xorg.conf.man.pre @@ -493,7 +493,7 @@ extension) to connect from another host. Default: off. .TP 7 .BI "Option \*qDisableModInDev\*q \*q" boolean \*q -This disables the parts of the __xservername__\-Misc extension that can be used to +This disables the parts of the XFree86\-Misc extension that can be used to modify the input device settings dynamically. Default: that functionality is enabled. .TP 7 @@ -507,17 +507,6 @@ This allows the server to start up even if the mouse device can't be opened/initialised. Default: false. .TP 7 -.BI "Option \*qVTInit\*q \*q" command \*q -Runs -.I command -after the VT used by the server has been opened. -The command string is passed to \*q/bin/sh \-c\*q, and is run with the real -user's id with stdin and stdout set to the VT. -The purpose of this option is to allow system dependent VT initialisation -commands to be run. -This option should rarely be needed. -Default: not set. -.TP 7 .BI "Option \*qVTSysReq\*q \*q" boolean \*q enables the SYSV\-style VT switch sequence for non\-SYSV systems which support VT switching. @@ -704,6 +693,20 @@ default. .BI "Option \*qIgnoreABI\*q \*q" boolean \*q Allow modules built for a different, potentially incompatible version of the X server to load. Disabled by default. +.TP 7 +.BI "Option \*qAllowEmptyInput\*q \*q" boolean \*q +If enabled, don't add the standard keyboard and mouse drivers, if there are no +input devices in the config file. Disabled by default. +.TP 7 +.BI "Option \*qAutoAddDevices\*q \*q" boolean \*q +If this option is disabled, then no devices will be added from HAL events. +Enabled by default. +.TP 7 +.BI "Option \*qAutoEnableDevices\*q \*q" boolean \*q +If this option is disabled, then the devices will be added (and the +DevicePresenceNotify event sent), but not enabled, thus leaving policy up +to the client. +Enabled by default. .SH "MODULE SECTION" The .B Module @@ -991,10 +994,8 @@ In multi-head configurations, or when using a secondary graphics card in a single-head configuration, this entry is mandatory. Its main purpose is to make an unambiguous connection between the device section and the hardware it is representing. -This information can usually be found by running the __xservername__ server -with the -.B \-scanpci -command line option. +This information can usually be found by running the pciaccess tool +scanpci. .TP 7 .BI "Screen " number This option is mandatory for cards where a single PCI entity can drive more @@ -1418,24 +1419,24 @@ This optional entry specifies the position of the monitor within the X screen. (RandR 1.2-supporting drivers only) .TP 7 -.BI "Option " "\*qLeftOf\*q " \*qmonitor\*q +.BI "Option " "\*qLeftOf\*q " \*qoutput\*q This optional entry specifies that the monitor should be positioned to the -left of the monitor of the given name. +left of the output (not monitor) of the given name. (RandR 1.2-supporting drivers only) .TP 7 -.BI "Option " "\*qRightOf\*q " \*qmonitor\*q +.BI "Option " "\*qRightOf\*q " \*qoutput\*q This optional entry specifies that the monitor should be positioned to the -right of the monitor of the given name. +right of the output (not monitor) of the given name. (RandR 1.2-supporting drivers only) .TP 7 -.BI "Option " "\*qAbove\*q " \*qmonitor\*q +.BI "Option " "\*qAbove\*q " \*qoutput\*q This optional entry specifies that the monitor should be positioned above the -monitor of the given name. +output (not monitor) of the given name. (RandR 1.2-supporting drivers only) .TP 7 -.BI "Option " "\*qBelow\*q " \*qmonitor\*q +.BI "Option " "\*qBelow\*q " \*qoutput\*q This optional entry specifies that the monitor should be positioned below the -monitor of the given name. +output (not monitor) of the given name. (RandR 1.2-supporting drivers only) .TP 7 .BI "Option " "\*qEnable\*q " \*qbool\*q @@ -2015,7 +2016,7 @@ These both specify that the upper left corner's coordinates are The .B Absolute keyword is optional. -Some older versions of __xservername__ (4.2 and earlier) don't recognise the +Some older versions of XFree86 (4.2 and earlier) don't recognise the .B Absolute keyword, so it's safest to just specify the coordinates without it. .TP 4 @@ -2144,7 +2145,9 @@ The data therein is not used in this release. General: .BR X (__miscmansuffix__), .BR Xserver (__appmansuffix__), -.BR __xservername__ (__appmansuffix__). +.BR __xservername__ (__appmansuffix__), +.BR cvt (__appmansuffix__), +.BR gtf (__appmansuffix__). .PP .B Not all modules or interfaces are available on all platforms. .PP diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index ce75af5bb..9ec48c9b3 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -78,9 +78,9 @@ extern Bool noPanoramiXExtension; #endif static int DRIEntPrivIndex = -1; -static int DRIScreenPrivIndex = -1; -static int DRIWindowPrivIndex = -1; -static int DRIPixmapPrivIndex = -1; +static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey; +static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey; +static DevPrivateKey DRIPixmapPrivKey = &DRIPixmapPrivKey; static unsigned long DRIGeneration = 0; static unsigned int DRIDrawableValidationStamp = 0; @@ -343,20 +343,18 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIEntPriv = DRI_ENT_PRIV(pScrn); - if (DRIGeneration != serverGeneration) { - if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; + DRIScreenPrivKey = &DRIScreenPrivKey; + if (DRIGeneration != serverGeneration) DRIGeneration = serverGeneration; - } pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; - DRIScreenPrivIndex = -1; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + DRIScreenPrivKey = NULL; return FALSE; } - pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv); pDRIPriv->drmFD = pDRIEntPriv->drmFD; pDRIPriv->directRenderingSupport = TRUE; pDRIPriv->pDriverInfo = pDRIInfo; @@ -381,7 +379,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) &pDRIPriv->hSAREA) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n"); @@ -398,7 +396,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmMap failed\n"); @@ -428,7 +426,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, @@ -744,8 +742,8 @@ DRICloseScreen(ScreenPtr pScreen) } xfree(pDRIPriv); - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; - DRIScreenPrivIndex = -1; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + DRIScreenPrivKey = NULL; } } @@ -772,38 +770,13 @@ drmServerInfo DRIDRMServerInfo = { Bool DRIExtensionInit(void) { - int i; - ScreenPtr pScreen; - - if (DRIScreenPrivIndex < 0 || DRIGeneration != serverGeneration) { + if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) { return FALSE; } - /* Allocate a window private index with a zero sized private area for - * each window, then should a window become a DRI window, we'll hang - * a DRIWindowPrivateRec off of this private index. - */ - if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - /* Allocate a pixmap private index with a zero sized private area for - * each pixmap, then should a pixmap become a DRI pixmap, we'll hang - * a DRIPixmapPrivateRec off of this private index. - */ - if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0) - return FALSE; - DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete); DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete); - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0)) - return FALSE; - if (!AllocatePixmapPrivate(pScreen, DRIPixmapPrivIndex, 0)) - return FALSE; - } - RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL); return TRUE; @@ -1278,9 +1251,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList); /* save private off of preallocated index */ - pWin->devPrivates[DRIWindowPrivIndex].ptr = - (pointer)pDRIDrawablePriv; - + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, + pDRIDrawablePriv); pDRIPriv->nrWindows++; if (pDRIDrawablePriv->nrects) @@ -1377,7 +1349,7 @@ DRIDrawablePrivDestroy(WindowPtr pWin) drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable); xfree(pDRIDrawablePriv); - pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); } static Bool diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index f81d17c92..bf1332c4e 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -37,15 +37,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86drm.h" -#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \ - ((DRIWindowPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr))) - -#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \ - ((DRIPixmapPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr))) +#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) +#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey)) typedef struct _DRIDrawablePrivRec { @@ -65,13 +60,12 @@ struct _DRIContextPrivRec void** pContextStore; }; -#define DRI_SCREEN_PRIV(pScreen) \ - ((DRIScreenPrivIndex < 0) ? \ - NULL : \ - ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr))) +#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey)) #define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ - (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr)) + dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ + DRIScreenPrivKey)) #define DRI_ENT_PRIV(pScrn) \ ((DRIEntPrivIndex < 0) ? \ diff --git a/hw/xfree86/dri2/Makefile.am b/hw/xfree86/dri2/Makefile.am new file mode 100644 index 000000000..be3cea48f --- /dev/null +++ b/hw/xfree86/dri2/Makefile.am @@ -0,0 +1,15 @@ +libdri2_la_LTLIBRARIES = libdri2.la +libdri2_la_CFLAGS = \ + -DHAVE_XORG_CONFIG_H \ + -I@MESA_SOURCE@/include \ + @DIX_CFLAGS@ @DRIPROTO_CFLAGS@ @LIBDRM_CFLAGS@ \ + -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/os-support/bus + +libdri2_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ +libdri2_ladir = $(moduledir)/extensions +libdri2_la_SOURCES = \ + dri2.c \ + dri2.h + +sdk_HEADERS = dri2.h diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c new file mode 100644 index 000000000..3bc533ede --- /dev/null +++ b/hw/xfree86/dri2/dri2.c @@ -0,0 +1,456 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <xf86drm.h> +#include "xf86Module.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "dri2.h" +#include <GL/internal/dri_sarea.h> + +#include "xf86.h" + +static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKey; +static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKey; +static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKey; + +typedef struct _DRI2DrawablePriv { + drm_drawable_t drawable; + unsigned int handle; +} DRI2DrawablePrivRec, *DRI2DrawablePrivPtr; + +typedef struct _DRI2Screen { + int fd; + drmBO sareaBO; + void *sarea; + unsigned int sareaSize; + const char *driverName; + int ddxVersionMajor; + int ddxVersionMinor; + int ddxVersionPatch; + + __DRIEventBuffer *buffer; + int locked; + + DRI2GetPixmapHandleProcPtr getPixmapHandle; + DRI2BeginClipNotifyProcPtr beginClipNotify; + DRI2EndClipNotifyProcPtr endClipNotify; + + ClipNotifyProcPtr ClipNotify; + HandleExposuresProcPtr HandleExposures; +} DRI2ScreenRec, *DRI2ScreenPtr; + +static DRI2ScreenPtr +DRI2GetScreen(ScreenPtr pScreen) +{ + return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey); +} + +static void * +DRI2ScreenAllocEvent(DRI2ScreenPtr ds, size_t size) +{ + unsigned int *pad, mask = ds->buffer->size - 1; + size_t pad_size; + void *p; + + if ((ds->buffer->head & mask) + size > ds->buffer->size) { + /* The requested event size would wrap the buffer, so pad to + * the end and allocate the event from the start. */ + pad_size = ds->buffer->size - (ds->buffer->head & mask); + pad = (unsigned int *) + (ds->buffer->data + (ds->buffer->prealloc & mask)); + *pad = DRI2_EVENT_HEADER(DRI2_EVENT_PAD, pad_size); + ds->buffer->prealloc += pad_size; + } + + p = ds->buffer->data + (ds->buffer->prealloc & mask); + ds->buffer->prealloc += size; + + return p; +} + +static void +DRI2ScreenCommitEvents(DRI2ScreenPtr ds) +{ + ds->buffer->head = ds->buffer->prealloc; +} + +static void +DRI2PostDrawableConfig(DrawablePtr pDraw) +{ + ScreenPtr pScreen = pDraw->pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + DRI2DrawablePrivPtr pPriv; + WindowPtr pWin; + PixmapPtr pPixmap; + BoxPtr pBox; + BoxRec pixmapBox; + int nBox; + int i; + __DRIDrawableConfigEvent *e; + size_t size; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + pPriv = dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + + nBox = REGION_NUM_RECTS(&pWin->clipList); + pBox = REGION_RECTS(&pWin->clipList); + + pPixmap = pScreen->GetWindowPixmap(pWin); + } else { + pPixmap = (PixmapPtr) pDraw; + pPriv = dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + + pixmapBox.x1 = 0; + pixmapBox.y1 = 0; + pixmapBox.x2 = pDraw->width; + pixmapBox.y2 = pDraw->height; + nBox = 1; + pBox = &pixmapBox; + } + + if (!pPriv) + return; + + size = sizeof *e + nBox * sizeof e->rects[0]; + + e = DRI2ScreenAllocEvent(ds, size); + e->event_header = DRI2_EVENT_HEADER(DRI2_EVENT_DRAWABLE_CONFIG, size); + e->drawable = pPriv->drawable; + e->x = pDraw->x - pPixmap->screen_x; + e->y = pDraw->y - pPixmap->screen_y; + e->width = pDraw->width; + e->height = pDraw->height; + + e->num_rects = nBox; + for (i = 0; i < nBox; i++) { + e->rects[i].x1 = pBox->x1 - pPixmap->screen_x; + e->rects[i].y1 = pBox->y1 - pPixmap->screen_y; + e->rects[i].x2 = pBox->x2 - pPixmap->screen_x; + e->rects[i].y2 = pBox->y2 - pPixmap->screen_y; + pBox++; + } +} + +static void +DRI2PostBufferAttach(DrawablePtr pDraw) +{ + ScreenPtr pScreen = pDraw->pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + DRI2DrawablePrivPtr pPriv; + WindowPtr pWin; + PixmapPtr pPixmap; + __DRIBufferAttachEvent *e; + size_t size; + unsigned int handle, flags; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + pPixmap = pScreen->GetWindowPixmap(pWin); + pPriv = dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + } else { + pPixmap = (PixmapPtr) pDraw; + pPriv = dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + } + + if (!pPriv) + return; + + size = sizeof *e; + + handle = ds->getPixmapHandle(pPixmap, &flags); + if (handle == 0 || handle == pPriv->handle) + return; + + e = DRI2ScreenAllocEvent(ds, size); + e->event_header = DRI2_EVENT_HEADER(DRI2_EVENT_BUFFER_ATTACH, size); + e->drawable = pPriv->drawable; + e->buffer.attachment = DRI_DRAWABLE_BUFFER_FRONT_LEFT; + e->buffer.handle = handle; + e->buffer.pitch = pPixmap->devKind; + e->buffer.cpp = pPixmap->drawable.bitsPerPixel / 8; + e->buffer.flags = flags; + + pPriv->handle = handle; +} + +static void +DRI2ClipNotify(WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (!ds->locked) { + ds->beginClipNotify(pScreen); + ds->locked = 1; + } + + if (ds->ClipNotify) { + pScreen->ClipNotify = ds->ClipNotify; + pScreen->ClipNotify(pWin, dx, dy); + pScreen->ClipNotify = DRI2ClipNotify; + } + + DRI2PostDrawableConfig(&pWin->drawable); + DRI2PostBufferAttach(&pWin->drawable); +} + +static void +DRI2HandleExposures(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds->HandleExposures) { + pScreen->HandleExposures = ds->HandleExposures; + pScreen->HandleExposures(pWin); + pScreen->HandleExposures = DRI2HandleExposures; + } + + DRI2ScreenCommitEvents(ds); + + if (ds->locked) { + ds->endClipNotify(pScreen); + ds->locked = 0; + } +} + +void +DRI2CloseScreen(ScreenPtr pScreen) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + pScreen->ClipNotify = ds->ClipNotify; + pScreen->HandleExposures = ds->HandleExposures; + + drmBOUnmap(ds->fd, &ds->sareaBO); + drmBOUnreference(ds->fd, &ds->sareaBO); + + xfree(ds); + dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL); +} + +Bool +DRI2CreateDrawable(ScreenPtr pScreen, + DrawablePtr pDraw, drm_drawable_t *pDrmDrawable) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + WindowPtr pWin; + PixmapPtr pPixmap; + DRI2DrawablePrivPtr pPriv; + DevPrivateKey key; + PrivateRec **devPrivates; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + devPrivates = &pWin->devPrivates; + key = dri2WindowPrivateKey; + } else { + pPixmap = (PixmapPtr) pDraw; + devPrivates = &pPixmap->devPrivates; + key = dri2PixmapPrivateKey; + } + + pPriv = dixLookupPrivate(devPrivates, key); + if (pPriv == NULL) { + pPriv = xalloc(sizeof *pPriv); + if (drmCreateDrawable(ds->fd, &pPriv->drawable)) + return FALSE; + + dixSetPrivate(devPrivates, key, pPriv); + } + + *pDrmDrawable = pPriv->drawable; + + DRI2PostDrawableConfig(pDraw); + DRI2PostBufferAttach(pDraw); + DRI2ScreenCommitEvents(ds); + + return TRUE; +} + +void +DRI2DestroyDrawable(ScreenPtr pScreen, DrawablePtr pDraw) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + PixmapPtr pPixmap; + WindowPtr pWin; + DRI2DrawablePrivPtr pPriv; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + pPriv = dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL); + } else { + pPixmap = (PixmapPtr) pDraw; + pPriv = dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL); + } + + if (pPriv == NULL) + return; + + drmDestroyDrawable(ds->fd, pPriv->drawable); + xfree(pPriv); +} + +Bool +DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName, + int *ddxMajor, int *ddxMinor, int *ddxPatch, + unsigned int *sareaHandle) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds == NULL) + return FALSE; + + *fd = ds->fd; + *driverName = ds->driverName; + *ddxMajor = ds->ddxVersionMajor; + *ddxMinor = ds->ddxVersionMinor; + *ddxPatch = ds->ddxVersionPatch; + *sareaHandle = ds->sareaBO.handle; + + return TRUE; +} + +unsigned int +DRI2GetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pPixmap->drawable.pScreen); + + return ds->getPixmapHandle(pPixmap, flags); +} + +static void * +DRI2SetupSAREA(ScreenPtr pScreen, size_t driverSareaSize) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + unsigned long mask; + const size_t event_buffer_size = 32 * 1024; + + ds->sareaSize = + sizeof(*ds->buffer) + event_buffer_size + + driverSareaSize + + sizeof (unsigned int); + + mask = DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MAPPABLE | + DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_SHAREABLE; + + if (drmBOCreate(ds->fd, ds->sareaSize, 1, NULL, mask, 0, &ds->sareaBO)) + return NULL; + + if (drmBOMap(ds->fd, &ds->sareaBO, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &ds->sarea)) { + drmBOUnreference(ds->fd, &ds->sareaBO); + return NULL; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, + "[DRI2] Allocated %d byte SAREA, BO handle 0x%08x\n", + ds->sareaSize, ds->sareaBO.handle); + memset(ds->sarea, 0, ds->sareaSize); + + ds->buffer = ds->sarea; + ds->buffer->block_header = + DRI2_SAREA_BLOCK_HEADER(DRI2_SAREA_BLOCK_EVENT_BUFFER, + sizeof *ds->buffer + event_buffer_size); + ds->buffer->size = event_buffer_size; + + return DRI2_SAREA_BLOCK_NEXT(ds->buffer); +} + +void * +DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) +{ + DRI2ScreenPtr ds; + void *p; + + ds = xalloc(sizeof *ds); + if (!ds) + return NULL; + + ds->fd = info->fd; + ds->driverName = info->driverName; + ds->ddxVersionMajor = info->ddxVersionMajor; + ds->ddxVersionMinor = info->ddxVersionMinor; + ds->ddxVersionPatch = info->ddxVersionPatch; + + ds->getPixmapHandle = info->getPixmapHandle; + ds->beginClipNotify = info->beginClipNotify; + ds->endClipNotify = info->endClipNotify; + + ds->ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = DRI2ClipNotify; + ds->HandleExposures = pScreen->HandleExposures; + pScreen->HandleExposures = DRI2HandleExposures; + + dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds); + + p = DRI2SetupSAREA(pScreen, info->driverSareaSize); + if (p == NULL) { + xfree(ds); + return NULL; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n"); + + return p; +} + +static pointer +DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + return (pointer) 1; +} + +static XF86ModuleVersionInfo DRI2VersRec = +{ + "dri2", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_NONE, + { 0, 0, 0, 0 } +}; + +_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL }; + diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h new file mode 100644 index 000000000..c687a93f6 --- /dev/null +++ b/hw/xfree86/dri2/dri2.h @@ -0,0 +1,80 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifndef _DRI2_H_ +#define _DRI2_H_ + +typedef unsigned int (*DRI2GetPixmapHandleProcPtr)(PixmapPtr p, + unsigned int *flags); +typedef void (*DRI2BeginClipNotifyProcPtr)(ScreenPtr pScreen); +typedef void (*DRI2EndClipNotifyProcPtr)(ScreenPtr pScreen); + +typedef struct { + unsigned int version; /* Version of this struct */ + int fd; + size_t driverSareaSize; + const char *driverName; + int ddxVersionMajor, ddxVersionMinor, ddxVersionPatch; + DRI2GetPixmapHandleProcPtr getPixmapHandle; + DRI2BeginClipNotifyProcPtr beginClipNotify; + DRI2EndClipNotifyProcPtr endClipNotify; +} DRI2InfoRec, *DRI2InfoPtr; + +void *DRI2ScreenInit(ScreenPtr pScreen, + DRI2InfoPtr info); + +void DRI2CloseScreen(ScreenPtr pScreen); + +Bool DRI2Connect(ScreenPtr pScreen, + int *fd, + const char **driverName, + int *ddxMajor, + int *ddxMinor, + int *ddxPatch, + unsigned int *sareaHandle); + +unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap, + unsigned int *flags); + +void DRI2Lock(ScreenPtr pScreen); +void DRI2Unlock(ScreenPtr pScreen); + +Bool DRI2CreateDrawable(ScreenPtr pScreen, + DrawablePtr pDraw, + drm_drawable_t *pDrmDrawable); + +void DRI2DestroyDrawable(ScreenPtr pScreen, + DrawablePtr pDraw); + +void DRI2ExtensionInit(void); + +#endif diff --git a/hw/xfree86/dummylib/Makefile.am b/hw/xfree86/dummylib/Makefile.am index 3e70d25fe..85a1d03dd 100644 --- a/hw/xfree86/dummylib/Makefile.am +++ b/hw/xfree86/dummylib/Makefile.am @@ -1,6 +1,6 @@ # libdummy.a contains just those bits used in the server itself # libdummy-nonserver.a contains additional routines normally found in the -# server for use in building the utilities like scanpci & the config tools +# server for use in building the utilities like config tools noinst_LIBRARIES = libdummy-nonserver.a @@ -13,6 +13,7 @@ STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c endif libdummy_nonserver_a_SOURCES = \ + dixprivates.c \ fatalerror.c \ logvwrite.c \ $(STRL_SRCS) \ @@ -24,7 +25,6 @@ libdummy_nonserver_a_SOURCES = \ xf86drvmsgverb.c \ xf86errorf.c \ xf86errorfverb.c \ - xf86getpagesize.c \ xf86getverb.c \ xf86info.c \ xf86msg.c \ diff --git a/hw/xfree86/dummylib/xf86getpagesize.c b/hw/xfree86/dummylib/dixprivates.c index 8859c7673..40c173a20 100644 --- a/hw/xfree86/dummylib/xf86getpagesize.c +++ b/hw/xfree86/dummylib/dixprivates.c @@ -11,11 +11,9 @@ * Utility functions required by libxf86_os. */ -int xf86getpagesize(void); - -_X_EXPORT int -xf86getpagesize(void) +_X_EXPORT pointer * +dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key) { - return 4096; /* not used */ + return NULL; /* not used */ } diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c index ceead8219..086639cc5 100644 --- a/hw/xfree86/exa/examodule.c +++ b/hw/xfree86/exa/examodule.c @@ -42,8 +42,7 @@ typedef struct _ExaXorgScreenPrivRec { OptionInfoPtr options; } ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr; -static int exaXorgServerGeneration; -static int exaXorgScreenPrivateIndex; +static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKey; typedef enum { EXAOPT_MIGRATION_HEURISTIC, @@ -72,8 +71,8 @@ static Bool exaXorgCloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - ExaXorgScreenPrivPtr pScreenPriv = - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr; + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); pScreen->CloseScreen = pScreenPriv->SavedCloseScreen; @@ -89,8 +88,8 @@ static void exaXorgEnableDisableFBAccess (int index, Bool enable) { ScreenPtr pScreen = screenInfo.screens[index]; - ExaXorgScreenPrivPtr pScreenPriv = - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr; + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); if (!enable) exaEnableDisableFBAccess (index, enable); @@ -114,11 +113,6 @@ exaDDXDriverInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ExaXorgScreenPrivPtr pScreenPriv; - if (exaXorgServerGeneration != serverGeneration) { - exaXorgScreenPrivateIndex = AllocateScreenPrivateIndex(); - exaXorgServerGeneration = serverGeneration; - } - pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec)); if (pScreenPriv == NULL) return; @@ -174,7 +168,7 @@ exaDDXDriverInit(ScreenPtr pScreen) pExaScr->info->DownloadFromScreen = NULL; } - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr = pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv); pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess; @@ -184,8 +178,6 @@ exaDDXDriverInit(ScreenPtr pScreen) } -static MODULESETUPPROTO(exaSetup); - /*ARGSUSED*/ static const OptionInfoRec * EXAAvailableOptions(void *unused) @@ -207,26 +199,4 @@ static XF86ModuleVersionInfo exaVersRec = {0,0,0,0} }; -_X_EXPORT XF86ModuleData exaModuleData = { &exaVersRec, exaSetup, NULL }; - -static ModuleInfoRec EXA = { - 1, - "EXA", - NULL, - 0, - EXAAvailableOptions, -}; - -/*ARGSUSED*/ -static pointer -exaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) -{ - static Bool Initialised = FALSE; - - if (!Initialised) { - Initialised = TRUE; - xf86AddModuleInfo(&EXA, Module); - } - - return (pointer)TRUE; -} +_X_EXPORT XF86ModuleData exaModuleData = { &exaVersRec, NULL, NULL }; diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 5d06b05c7..49c7d271b 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -63,7 +63,9 @@ #include "globals.h" #include "os.h" #include "osdep.h" +#include "privates.h" #include "resource.h" +#include "registry.h" #include "servermd.h" #include "scrnintstr.h" #include "windowstr.h" @@ -113,6 +115,16 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(QueryColors) /* cursor.c */ SYMFUNC(FreeCursor) + /* deprecated.c */ + SYMFUNC(LookupClient) + SYMFUNC(LookupDrawable) + SYMFUNC(LookupWindow) + SYMFUNC(SecurityLookupDrawable) + SYMFUNC(SecurityLookupWindow) + SYMFUNC(LookupIDByType) + SYMFUNC(LookupIDByClass) + SYMFUNC(SecurityLookupIDByClass) + SYMFUNC(SecurityLookupIDByType) /* devices.c */ SYMFUNC(Ones) SYMFUNC(InitButtonClassDeviceStruct) @@ -128,8 +140,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(InitKeyboardDeviceStruct) SYMFUNC(SendMappingNotify) SYMFUNC(InitPointerDeviceStruct) - SYMFUNC(LookupKeyboardDevice) - SYMFUNC(LookupPointerDevice) /* dispatch.c */ SYMFUNC(SetInputCheck) SYMFUNC(SendErrorToClient) @@ -159,13 +169,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(dixLookupWindow) SYMFUNC(dixLookupClient) SYMFUNC(dixLookupGC) - /* following are deprecated */ - SYMFUNC(LookupClient) - SYMFUNC(LookupDrawable) - SYMFUNC(LookupWindow) - SYMFUNC(SecurityLookupDrawable) - SYMFUNC(SecurityLookupWindow) - /* end deprecated */ SYMFUNC(NoopDDA) SYMFUNC(QueueWorkProc) SYMFUNC(RegisterBlockAndWakeupHandlers) @@ -191,11 +194,11 @@ _X_HIDDEN void *dixLookupTab[] = { #endif /* property.c */ SYMFUNC(ChangeWindowProperty) + SYMFUNC(dixChangeWindowProperty) /* extension.c */ SYMFUNC(AddExtension) SYMFUNC(AddExtensionAlias) SYMFUNC(CheckExtension) - SYMFUNC(DeclareExtensionSecurity) SYMFUNC(MinorOpcodeOfRequest) SYMFUNC(StandardMinorOpcode) #ifdef XEVIE @@ -234,7 +237,7 @@ _X_HIDDEN void *dixLookupTab[] = { #ifdef XV /* XXX These are exported from the DDX, not DIX. */ SYMVAR(XvScreenInitProc) - SYMVAR(XvGetScreenIndexProc) + SYMVAR(XvGetScreenKeyProc) SYMVAR(XvGetRTPortProc) SYMVAR(XvMCScreenInitProc) #endif @@ -259,42 +262,38 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(GetScratchPixmapHeader) SYMFUNC(FreeScratchPixmapHeader) /* privates.c */ - SYMFUNC(AllocateExtensionPrivate) - SYMFUNC(AllocateExtensionPrivateIndex) - SYMFUNC(AllocateClientPrivate) - SYMFUNC(AllocateClientPrivateIndex) - SYMFUNC(AllocateGCPrivate) - SYMFUNC(AllocateGCPrivateIndex) - SYMFUNC(AllocateWindowPrivate) - SYMFUNC(AllocateWindowPrivateIndex) - SYMFUNC(AllocateScreenPrivateIndex) - SYMFUNC(AllocateColormapPrivateIndex) - SYMFUNC(AllocateDevicePrivateIndex) - SYMFUNC(AllocateDevicePrivate) - SYMFUNC(AllocatePixmapPrivateIndex) - SYMFUNC(AllocatePixmapPrivate) + SYMFUNC(dixRequestPrivate) + SYMFUNC(dixRegisterPrivateInitFunc) + SYMFUNC(dixRegisterPrivateDeleteFunc) + SYMFUNC(dixAllocatePrivate) + SYMFUNC(dixFreePrivates) + SYMFUNC(dixRegisterPrivateOffset) + SYMFUNC(dixLookupPrivateOffset) /* resource.c */ SYMFUNC(AddResource) SYMFUNC(ChangeResourceValue) SYMFUNC(CreateNewResourceClass) SYMFUNC(CreateNewResourceType) + SYMFUNC(dixLookupResource) SYMFUNC(FakeClientID) SYMFUNC(FreeResource) SYMFUNC(FreeResourceByType) SYMFUNC(GetXIDList) SYMFUNC(GetXIDRange) - SYMFUNC(LookupIDByType) - SYMFUNC(LookupIDByClass) SYMFUNC(LegalNewID) - SYMFUNC(SecurityLookupIDByClass) - SYMFUNC(SecurityLookupIDByType) SYMFUNC(FindClientResourcesByType) SYMFUNC(FindAllClientResources) SYMVAR(lastResourceType) SYMVAR(TypeMask) -#ifdef RES + SYMVAR(ResourceStateCallback) + /* registry.c */ +#ifdef XREGISTRY SYMFUNC(RegisterResourceName) - SYMVAR(ResourceNames) + SYMFUNC(LookupMajorName) + SYMFUNC(LookupRequestName) + SYMFUNC(LookupEventName) + SYMFUNC(LookupErrorName) + SYMFUNC(LookupResourceName) #endif /* swaprep.c */ SYMFUNC(CopySwap32Write) @@ -322,6 +321,7 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(NotClippedByChildren) SYMFUNC(ResizeChildrenWinSize) SYMFUNC(SaveScreens) + SYMFUNC(dixSaveScreens) SYMFUNC(SendVisibilityNotify) SYMFUNC(SetWinSize) SYMFUNC(SetBorderSize) @@ -512,7 +512,7 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(PictureTransformPoint3d) SYMFUNC(PictureGetSubpixelOrder) SYMFUNC(PictureSetSubpixelOrder) - SYMVAR(PictureScreenPrivateIndex) + SYMVAR(PictureScreenPrivateKey) /* mipict.c */ SYMFUNC(miPictureInit) SYMFUNC(miComputeCompositeRegion) diff --git a/hw/xfree86/loader/dlloader.c b/hw/xfree86/loader/dlloader.c index 2afdef789..4caefd071 100644 --- a/hw/xfree86/loader/dlloader.c +++ b/hw/xfree86/loader/dlloader.c @@ -71,15 +71,9 @@ #define DLSYM_PREFIX "" #endif -typedef struct { - int handle; - void *dlhandle; - int flags; -} DLModuleRec, *DLModulePtr; - /* Hooray, yet another open coded linked list! FIXME */ typedef struct DLModuleList { - DLModulePtr module; + void *module; struct DLModuleList *next; } DLModuleList; @@ -88,19 +82,22 @@ static DLModuleList *dlModuleList = NULL; static void * DLFindSymbolLocal(pointer module, const char *name) { - DLModulePtr dlfile = module; void *p; char *n; static const char symPrefix[] = DLSYM_PREFIX; - n = malloc(strlen(symPrefix) + strlen(name) + 1); - if (strlen(symPrefix)) + if (strlen(symPrefix)) { + n = malloc(strlen(symPrefix) + strlen(name) + 1); sprintf(n, "%s%s", symPrefix, name); - else - sprintf(n, "%s", name); - p = dlsym(dlfile->dlhandle, n); - free(n); + } else { + n = name; + } + + p = dlsym(module, n); + + if (strlen(symPrefix)) + free(n); return p; } @@ -127,7 +124,7 @@ DLFindSymbol(const char *name) global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL); if (global_scope) - return dlsym(global_scope, name); + return DLFindSymbolLocal(global_scope, name); return NULL; } @@ -135,23 +132,17 @@ DLFindSymbol(const char *name) void * DLLoadModule(loaderPtr modrec, int flags) { - DLModulePtr dlfile; + void * dlfile; DLModuleList *l; int dlopen_flags; - if ((dlfile = calloc(1, sizeof(DLModuleRec))) == NULL) { - ErrorF("Unable to allocate DLModuleRec\n"); - return NULL; - } - dlfile->handle = modrec->handle; if (flags & LD_FLAG_GLOBAL) dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL; else dlopen_flags = DLOPEN_LAZY; - dlfile->dlhandle = dlopen(modrec->name, dlopen_flags); - if (dlfile->dlhandle == NULL) { + dlfile = dlopen(modrec->name, dlopen_flags); + if (dlfile == NULL) { ErrorF("dlopen: %s\n", dlerror()); - free(dlfile); return NULL; } @@ -166,7 +157,6 @@ DLLoadModule(loaderPtr modrec, int flags) void DLUnloadModule(void *modptr) { - DLModulePtr dlfile = (DLModulePtr) modptr; DLModuleList *l, *p; /* remove it from dlModuleList. */ @@ -185,6 +175,5 @@ DLUnloadModule(void *modptr) p = l; } } - dlclose(dlfile->dlhandle); - free(modptr); + dlclose(modptr); } diff --git a/hw/xfree86/loader/extsym.c b/hw/xfree86/loader/extsym.c index e09e9c084..1bdff9482 100644 --- a/hw/xfree86/loader/extsym.c +++ b/hw/xfree86/loader/extsym.c @@ -44,7 +44,6 @@ extern RESTYPE ShmSegType, ShmPixType; extern Bool noPanoramiXExtension; extern int PanoramiXNumScreens; extern PanoramiXData *panoramiXdataPtr; -extern XID *PanoramiXVisualTable; extern unsigned long XRT_WINDOW; extern unsigned long XRT_PIXMAP; extern unsigned long XRT_GC; @@ -69,7 +68,6 @@ _X_HIDDEN void *extLookupTab[] = { SYMFUNC(XineramaDeleteResource) SYMVAR(PanoramiXNumScreens) SYMVAR(panoramiXdataPtr) - SYMVAR(PanoramiXVisualTable) SYMVAR(XRT_WINDOW) SYMVAR(XRT_PIXMAP) SYMVAR(XRT_GC) diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h index b71ad4590..9c73db3a6 100644 --- a/hw/xfree86/loader/loaderProcs.h +++ b/hw/xfree86/loader/loaderProcs.h @@ -62,17 +62,11 @@ typedef struct module_desc { struct module_desc *child; struct module_desc *sib; struct module_desc *parent; - struct module_desc *demand_next; char *name; - char *filename; - char *identifier; - XID client_id; - int in_use; int handle; ModuleSetupProc SetupProc; ModuleTearDownProc TearDownProc; void *TearDownData; /* returned from SetupProc */ - const char *path; const XF86ModuleVersionInfo *VersionInfo; } ModuleDesc, *ModuleDescPtr; diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 1b5c717fd..7f3bbe49c 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -177,6 +177,7 @@ InitPathList(const char *path) } if (list) list[n] = NULL; + xfree(fullpath); return list; } @@ -786,12 +787,7 @@ NewModuleDesc(const char *name) mdp->child = NULL; mdp->sib = NULL; mdp->parent = NULL; - mdp->demand_next = NULL; mdp->name = xstrdup(name); - mdp->filename = NULL; - mdp->identifier = NULL; - mdp->client_id = 0; - mdp->in_use = 0; mdp->handle = -1; mdp->SetupProc = NULL; mdp->TearDownProc = NULL; @@ -816,15 +812,10 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) if (LoaderHandleOpen(mod->handle) == -1) return NULL; - ret->filename = xstrdup(mod->filename); - ret->identifier = mod->identifier; - ret->client_id = mod->client_id; - ret->in_use = mod->in_use; ret->handle = mod->handle; ret->SetupProc = mod->SetupProc; ret->TearDownProc = mod->TearDownProc; ret->TearDownData = NULL; - ret->path = mod->path; ret->child = DuplicateModule(mod->child, ret); ret->sib = DuplicateModule(mod->sib, parent); ret->parent = parent; @@ -859,12 +850,12 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, char *m = NULL; const char **cim; - xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module); + xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"\n", module); for (cim = compiled_in_modules; *cim; cim++) if (!strcmp (module, *cim)) { - xf86MsgVerb(X_INFO, 0, "Module \"%s\" already built-in\n", module); + xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", module); return (ModuleDescPtr) 1; } @@ -943,8 +934,6 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, if (ret->handle < 0) goto LoadModule_fail; - ret->filename = xstrdup(found); - /* drop any explicit suffix from the module name */ p = strchr(name, '.'); if (p) @@ -998,7 +987,6 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, ret->SetupProc = setup; if (teardown) ret->TearDownProc = teardown; - ret->path = path; ret->VersionInfo = vers; } else { /* No initdata is OK for external modules */ @@ -1120,7 +1108,6 @@ UnloadModuleOrDriver(ModuleDescPtr mod) if (mod->sib) UnloadModuleOrDriver(mod->sib); TestFree(mod->name); - TestFree(mod->filename); xfree(mod); #ifdef __alpha__ istream_mem_barrier(); @@ -1145,7 +1132,6 @@ UnloadSubModule(ModuleDescPtr mod) UnloadModuleOrDriver(mod->child); TestFree(mod->name); - TestFree(mod->filename); xfree(mod); } @@ -1156,12 +1142,6 @@ FreeModuleDesc(ModuleDescPtr head) if (head == (ModuleDescPtr) 1) return; - /* - * only free it if it's not marked as in use. In use means that it may - * be unloaded someday, and UnloadModule will free it - */ - if (head->in_use) - return; if (head->child) FreeModuleDesc(head->child); sibs = head; diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c index 025983b09..aa712c03a 100644 --- a/hw/xfree86/loader/misym.c +++ b/hw/xfree86/loader/misym.c @@ -200,9 +200,9 @@ _X_HIDDEN void *miLookupTab[] = { SYMFUNC(miOverlaySetRootClip) SYMVAR(miEmptyBox) SYMVAR(miEmptyData) - SYMVAR(miZeroLineScreenIndex) + SYMVAR(miZeroLineScreenKey) SYMVAR(miSpritePointerFuncs) - SYMVAR(miPointerScreenIndex) + SYMVAR(miPointerScreenKey) SYMVAR(miInstalledMaps) SYMVAR(miInitVisualsProc) #ifdef DAMAGE diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 050b873fb..754e9c06b 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -479,8 +479,6 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86IsScreenPrimary) SYMFUNC(xf86RegisterRootWindowProperty) SYMFUNC(xf86IsUnblank) - SYMFUNC(xf86AddModuleInfo) - SYMFUNC(xf86DeleteModuleInfo) #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) /* xf86sbusBus.c */ @@ -906,8 +904,8 @@ _X_HIDDEN void *xfree86LookupTab[] = { #endif /* General variables (from xf86.h) */ - SYMVAR(xf86ScreenIndex) - SYMVAR(xf86PixmapIndex) + SYMVAR(xf86ScreenKey) + SYMVAR(xf86PixmapKey) SYMVAR(xf86Screens) SYMVAR(byte_reversed) SYMVAR(xf86inSuspend) diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am index 1f82068b3..6ee85757a 100644 --- a/hw/xfree86/modes/Makefile.am +++ b/hw/xfree86/modes/Makefile.am @@ -16,7 +16,7 @@ libxf86modes_a_SOURCES = \ INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ - -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac \ -I$(srcdir)/../dixmods/extmod diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index fc80f5202..266e08195 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -236,6 +236,9 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int saved_x, saved_y; Rotation saved_rotation; + if (crtc->funcs->set_mode_major) + return crtc->funcs->set_mode_major(crtc, mode, rotation, x, y); + crtc->enabled = xf86CrtcInUse (crtc); if (!crtc->enabled) @@ -1362,8 +1365,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) if (sync_source == sync_default) sync_source = sync_edid; } - if (ranges->max_clock > max_clock) - max_clock = ranges->max_clock; + if (ranges->max_clock * 1000 > max_clock) + max_clock = ranges->max_clock * 1000; } } } @@ -1410,9 +1413,12 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) /* * Check default modes against monitor max clock */ - if (max_clock) + if (max_clock) { xf86ValidateModesClocks(scrn, default_modes, &min_clock, &max_clock, 1); + xf86ValidateModesClocks(scrn, output_modes, + &min_clock, &max_clock, 1); + } output->probed_modes = NULL; output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes); @@ -2186,14 +2192,18 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) xf86MonPtr mon; mon = xf86DoEDID_DDC2 (scrn->scrnIndex, pDDCBus); - xf86DDCApplyQuirks (scrn->scrnIndex, pDDCBus); + if (mon) + xf86DDCApplyQuirks (scrn->scrnIndex, mon); return mon; } -static char *_xf86ConnectorNames[] = { "None", "VGA", "DVI-I", "DVI-D", - "DVI-A", "Composite", "S-Video", - "Component", "LFP", "Proprietary" }; +static char *_xf86ConnectorNames[] = { + "None", "VGA", "DVI-I", "DVI-D", + "DVI-A", "Composite", "S-Video", + "Component", "LFP", "Proprietary", + "HDMI", "DisplayPort", + }; _X_EXPORT char * xf86ConnectorGetName(xf86ConnectorType connector) { diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index f312b30cb..cc045b229 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -61,7 +61,9 @@ typedef enum _xf86ConnectorType { XF86ConnectorSvideo, XF86ConnectorComponent, XF86ConnectorLFP, - XF86ConnectorProprietary + XF86ConnectorProprietary, + XF86ConnectorHDMI, + XF86ConnectorDisplayPort, } xf86ConnectorType; typedef enum _xf86OutputStatus { @@ -204,6 +206,13 @@ typedef struct _xf86CrtcFuncs { */ void (*destroy) (xf86CrtcPtr crtc); + + /** + * Less fine-grained mode setting entry point for kernel modesetting + */ + Bool + (*set_mode_major)(xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, int x, int y); } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; struct _xf86Crtc { diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index b5101642b..5a4d0f6fa 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -226,7 +226,8 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); CursorPtr cursor = xf86_config->cursor; int c; - CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL; + CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates, + screen) : NULL; /* Save ARGB versions of these colors */ xf86_config->cursor_fg = (CARD32) fg | 0xff000000; @@ -399,7 +400,7 @@ xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src) int flags = cursor_info->Flags; cursor_image = xf86_config->cursor_image; - memset(cursor_image, 0, cursor_info->MaxWidth * stride); + memset(cursor_image, 0, cursor_info->MaxHeight * stride); for (y = 0; y < cursor_info->MaxHeight; y++) for (x = 0; x < cursor_info->MaxWidth; x++) @@ -612,7 +613,7 @@ xf86_reload_cursors (ScreenPtr screen) else #endif (*cursor_info->LoadCursorImage)(cursor_info->pScrn, - cursor->devPriv[screen->myNum]); + dixLookupPrivate(&cursor->devPrivates, screen)); (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); (*cursor_info->ShowCursor)(cursor_info->pScrn); diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index 777ef7e44..b865727ef 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -66,6 +66,8 @@ typedef enum { DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE = 1 << 5, /* Monitor forgot to set the first detailed is preferred bit. */ DDC_QUIRK_FIRST_DETAILED_PREFERRED = 1 << 6, + /* use +hsync +vsync for detailed mode */ + DDC_QUIRK_DETAILED_SYNC_PP = 1 << 7, } ddc_quirk_t; static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) @@ -160,6 +162,15 @@ static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC) return FALSE; } +static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #12439: Samsung SyncMaster 205BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 541) + return TRUE; + return FALSE; +} + typedef struct { Bool (*detect) (int scrnIndex, xf86MonPtr DDC); ddc_quirk_t quirk; @@ -195,6 +206,10 @@ static const ddc_quirk_map_t ddc_quirks[] = { quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED, "First detailed timing was not marked as preferred." }, + { + quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP, + "Use +hsync +vsync for detailed timing." + }, { NULL, DDC_QUIRK_NONE, "No known quirks" @@ -328,6 +343,12 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; Mode->VTotal = timing->v_active + timing->v_blanking; + /* perform basic check on the detail timing */ + if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { + xfree(Mode); + return NULL; + } + xf86SetModeDefaultName(Mode); /* We ignore h/v_size and h/v_border for now. */ @@ -335,19 +356,53 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, if (timing->interlaced) Mode->Flags |= V_INTERLACE; - if (timing->misc & 0x02) - Mode->Flags |= V_PVSYNC; - else - Mode->Flags |= V_NVSYNC; - - if (timing->misc & 0x01) - Mode->Flags |= V_PHSYNC; - else - Mode->Flags |= V_NHSYNC; + if (quirks & DDC_QUIRK_DETAILED_SYNC_PP) + Mode->Flags |= V_PVSYNC | V_PHSYNC; + else { + if (timing->misc & 0x02) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + } return Mode; } +static DisplayModePtr +DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) +{ + DisplayModePtr modes = NULL; + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + if (t[i].rates & 0x10) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 50, 0, 0)); + if (t[i].rates & 0x08) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 0, 0)); + if (t[i].rates & 0x04) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 75, 0, 0)); + if (t[i].rates & 0x02) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 85, 0, 0)); + if (t[i].rates & 0x01) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 1, 0)); + } else break; + } + + return modes; +} + + /* * */ @@ -498,6 +553,8 @@ xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE); preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + if (DDC->ver.revision >= 4) + preferred = TRUE; if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED) preferred = TRUE; if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75)) @@ -521,6 +578,10 @@ xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) quirks); Modes = xf86ModesAdd(Modes, Mode); break; + case DS_CVT: + Mode = DDCModesFromCVT(scrnIndex, det_mon->section.cvt); + Modes = xf86ModesAdd(Modes, Mode); + break; default: break; } diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 3879b9103..3d222cc73 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -38,12 +38,14 @@ extern XF86ConfigPtr xf86configptr; -/** - * @file this file contains symbols from xf86Mode.c and friends that are static - * there but we still want to use. We need to come up with better API here. +/* + * This is the version number where we epoched. These files get copied + * into drivers that want to use this setup infrastructure on pre-1.3 + * servers, so when that happens they need to define these symbols + * themselves. However, _in_ the server, we basically always define them now. */ - #if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) + /** * Calculates the horizontal sync rate of a mode. * @@ -116,6 +118,24 @@ xf86ModeHeight (DisplayModePtr mode, Rotation rotation) } } +/** Calculates the memory bandwidth (in MiB/sec) of a mode. */ +_X_EXPORT unsigned int +xf86ModeBandwidth(DisplayModePtr mode, int depth) +{ + float a_active, a_total, active_percent, pixels_per_second; + int bytes_per_pixel = (depth + 7) / 8; + + if (!mode->HTotal || !mode->VTotal || !mode->Clock) + return 0; + + a_active = mode->HDisplay * mode->VDisplay; + a_total = mode->HTotal * mode->VTotal; + active_percent = a_active / a_total; + pixels_per_second = active_percent * mode->Clock * 1000.0; + + return (unsigned int)(pixels_per_second * bytes_per_pixel / (1024 * 1024)); +} + /** Sets a default mode name of <width>x<height> on a mode. */ _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode) @@ -319,12 +339,10 @@ xf86PrintModeline(int scrnIndex,DisplayModePtr mode) /** * Marks as bad any modes with unsupported flags. * - * \param modeList doubly-linked or circular list of modes. + * \param modeList doubly-linked list of modes. * \param flags flags supported by the driver. * * \bug only V_INTERLACE and V_DBLSCAN are supported. Is that enough? - * - * This is not in xf86Modes.c, but would be part of the proposed new API. */ _X_EXPORT void xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, @@ -343,9 +361,7 @@ xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, /** * Marks as bad any modes extending beyond the given max X, Y, or pitch. * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. + * \param modeList doubly-linked list of modes. */ _X_EXPORT void xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, @@ -372,9 +388,7 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, * Marks as bad any modes that aren't supported by the given monitor's * hsync and vrefresh ranges. * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. + * \param modeList doubly-linked list of modes. */ _X_EXPORT void xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, @@ -416,12 +430,10 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, /** * Marks as bad any modes extending beyond outside of the given clock ranges. * - * \param modeList doubly-linked or circular list of modes. + * \param modeList doubly-linked list of modes. * \param min pointer to minimums of clock ranges * \param max pointer to maximums of clock ranges * \param n_ranges number of ranges. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. */ _X_EXPORT void xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, @@ -454,9 +466,7 @@ xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, * * MODE_BAD is used as the rejection flag, for lack of a better flag. * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. + * \param modeList doubly-linked list of modes. */ _X_EXPORT void xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList) @@ -484,13 +494,30 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList) /** + * Marks as bad any modes exceeding the given bandwidth. + * + * \param modeList doubly-linked list of modes. + * \param bandwidth bandwidth in MHz. + * \param depth color depth. + */ +_X_EXPORT void +xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, + unsigned int bandwidth, int depth) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (xf86ModeBandwidth(mode, depth) > bandwidth) + mode->status = MODE_BANDWIDTH; + } +} + +/** * Frees any modes from the list with a status other than MODE_OK. * * \param modeList pointer to a doubly-linked or circular list of modes. * \param verbose determines whether the reason for mode invalidation is * printed. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. */ _X_EXPORT void xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h index 3722d25a0..9ad5ee653 100644 --- a/hw/xfree86/modes/xf86Modes.h +++ b/hw/xfree86/modes/xf86Modes.h @@ -42,6 +42,7 @@ double xf86ModeHSync(DisplayModePtr mode); double xf86ModeVRefresh(DisplayModePtr mode); +unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth); int xf86ModeWidth (DisplayModePtr mode, Rotation rotation); @@ -79,6 +80,10 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, MonPtr mon); void +xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, + unsigned int bandwidth, int depth); + +void xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, Bool verbose); diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index bb7f94581..e2668fbbc 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -59,11 +59,11 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen); static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); #endif -static int xf86RandR12Index = -1; -static int xf86RandR12Generation; +static int xf86RandR12Generation; +static DevPrivateKey xf86RandR12Key; -#define XF86RANDRINFO(p) \ - ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ + dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) static int xf86RandR12ModeRefresh (DisplayModePtr mode) @@ -340,7 +340,7 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); Bool ret = FALSE; - if (xf86RandR12Index != -1) { + if (xf86RandR12Key) { if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; @@ -368,7 +368,7 @@ finish: if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE - if ((xf86RandR12Index != -1) && WindowTable[pScreen->myNum] && ret) + if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; @@ -468,7 +468,7 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) mmHeight); } - if (xf86RandR12Index == -1) + if (xf86RandR12Key == NULL) return TRUE; if (randrp->virtualX == -1 || randrp->virtualY == -1) @@ -496,11 +496,11 @@ xf86RandR12Init (ScreenPtr pScreen) if (!noPanoramiXExtension) return TRUE; #endif + if (xf86RandR12Generation != serverGeneration) - { - xf86RandR12Index = AllocateScreenPrivateIndex(); xf86RandR12Generation = serverGeneration; - } + + xf86RandR12Key = &xf86RandR12Key; randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) @@ -526,7 +526,7 @@ xf86RandR12Init (ScreenPtr pScreen) randrp->maxX = randrp->maxY = 0; - pScreen->devPrivates[xf86RandR12Index].ptr = randrp; + dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp); #if RANDR_12_INTERFACE if (!xf86RandR12Init12 (pScreen)) @@ -545,7 +545,7 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); #endif - if (xf86RandR12Index == -1) + if (xf86RandR12Key == NULL) return; randrp = XF86RANDRINFO(pScreen); @@ -1076,7 +1076,7 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - if (xf86RandR12Index == -1) + if (xf86RandR12Key == NULL) return TRUE; for (c = 0; c < config->num_crtc; c++) @@ -1099,7 +1099,7 @@ xf86RandR12TellChanged (ScreenPtr pScreen) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int c; - if (xf86RandR12Index == -1) + if (xf86RandR12Key == NULL) return; xf86RandR12SetInfo12 (pScreen); diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 380478f7f..e2d6295b9 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -494,7 +494,8 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) { ScrnInfoPtr pScrn = crtc->scrn; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; + /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */ + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; PictTransform crtc_to_fb, fb_to_crtc; PictureTransformIdentity (&crtc_to_fb); @@ -579,9 +580,9 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) } else { - PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, crtc->x, crtc->y); + PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, F(crtc->x), F(crtc->y)); PictureTransformIsInverse ("offset", &crtc_to_fb, &fb_to_crtc); - + /* * these are the size of the shadow pixmap, which * matches the mode, not the pre-rotated copy in the diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c index a1b19d0f6..523c4488e 100644 --- a/hw/xfree86/os-support/bsd/alpha_video.c +++ b/hw/xfree86/os-support/bsd/alpha_video.c @@ -368,7 +368,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, return(-1); } - psize = xf86getpagesize(); + psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c index b556563d3..23948b5d6 100644 --- a/hw/xfree86/os-support/bsd/arm_video.c +++ b/hw/xfree86/os-support/bsd/arm_video.c @@ -246,7 +246,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, return(-1); } - psize = xf86getpagesize(); + psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); diff --git a/hw/xfree86/os-support/bsd/bsd_apm.c b/hw/xfree86/os-support/bsd/bsd_apm.c index 61779875c..43eda7421 100644 --- a/hw/xfree86/os-support/bsd/bsd_apm.c +++ b/hw/xfree86/os-support/bsd/bsd_apm.c @@ -66,7 +66,7 @@ bsdPMGetEventFromOS(int fd, pmEvent *events, int num) if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) { if (errno != EAGAIN) { xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT" - " errno = %d\n", errno); + " %s\n", strerror(errno)); } break; } diff --git a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c index b0171e2c3..b37070c37 100644 --- a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c +++ b/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c @@ -102,7 +102,7 @@ bsdPMGetEventFromOS(int kq, pmEvent *events, int num) break; } else if (result < 0) { xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns" - " errno = %d\n", errno); + " %s\n", strerror(errno)); break; } events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data)); diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index e7db6c10e..0dcff6631 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -301,7 +301,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, return(-1); } - psize = xf86getpagesize(); + psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); @@ -602,7 +602,7 @@ cleanMTRR() #ifdef DEBUG ErrorF("Clean for (0x%lx,0x%lx)\n", (unsigned long)mrd[i].mr_base, - (unsigned long)rd[i].mr_len); + (unsigned long)mrd[i].mr_len); #endif if (mrd[i].mr_flags & MDF_FIXACTIVE) { mro.mo_arg[0] = MEMRANGE_SET_UPDATE; diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index a34ed99d0..064533c77 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -1,65 +1,4 @@ /* - * Pci.c - New server PCI access functions - * - * The XFree86 server PCI access functions have been reimplemented as a - * framework that allows each supported platform/OS to have their own - * platform/OS specific pci driver. - * - * All of the public PCI access functions exported to the other parts of - * the server are declared in Pci.h and defined herein. These include: - * pciInit() - Initialize PCI access functions - * pciReadLong() - Read a 32 bit value from a device's cfg space - * pciReadWord() - Read a 16 bit value from a device's cfg space - * pciReadByte() - Read an 8 bit value from a device's cfg space - * pciWriteLong() - Write a 32 bit value to a device's cfg space - * pciWriteWord() - Write a 16 bit value to a device's cfg space - * pciWriteByte() - Write an 8 bit value to a device's cfg space - * pciSetBitsLong() - Write a 32 bit value against a mask - * pciSetBitsByte() - Write an 8 bit value against a mask - * pciTag() - Return tag for a given PCI bus, device, & - * function - * pciBusAddrToHostAddr() - Convert a PCI address to a host address - * xf86scanpci() - Return info about all PCI devices - * xf86MapDomainMemory() - Like xf86MapPciMem() but can handle - * domain/host address translation - * xf86MapLegacyIO() - Maps PCI I/O spaces - * - * The actual PCI backend driver is selected by the pciInit() function - * (see below) using either compile time definitions, run-time checks, - * or both. - * - * Certain generic functions are provided that make the implementation - * of certain well behaved platforms (e.g. those supporting PCI config - * mechanism 1 or some thing close to it) very easy. - * - * Less well behaved platforms/OS's can roll their own functions. - * - * To add support for another platform/OS, add a call to fooPciInit() within - * pciInit() below under the correct compile time definition or run-time - * conditional. - * - * The fooPciInit() procedure must do three things: - * 1) Initialize the pciBusTable[] for all primary PCI buses including - * the per domain PCI access functions (readLong, writeLong, - * addrBusToHost, and addrHostToBus). - * - * 2) Add entries to pciBusTable[] for configured secondary buses. This - * step may be skipped if a platform is using the generic findFirst/ - * findNext functions because these procedures will automatically - * discover and add secondary buses dynamically. - * - * 3) Overide default settings for global PCI access functions if - * required. These include pciFindFirstFP, pciFindNextFP, - * Of course, if you choose not to use one of the generic - * functions, you will need to provide a platform specifc replacement. - * - * Gary Barton - * Concurrent Computer Corporation - * garyb@gate.net - * - */ - -/* * Copyright 1998 by Concurrent Computer Corporation * * Permission to use, copy, modify, distribute, and sell this software @@ -197,14 +136,6 @@ #include <pciaccess.h> -#if 0 -#include <stdio.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#endif - #define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */ #define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */ @@ -217,35 +148,11 @@ _X_EXPORT int pciNumBuses = 0; /* Actual number of PCI buses */ int pciMaxBusNum = MAX_PCI_BUSES; -/* - * pciInit - choose correct platform/OS specific PCI init routine - */ -static void -pciInit(void) -{ - static int pciInitialized = 0; - - if (!pciInitialized) { - pciInitialized = 1; - - /* XXX */ -#if defined(DEBUGPCI) - if (DEBUGPCI >= xf86Verbose) { - xf86Verbose = DEBUGPCI; - } -#endif - - ARCH_PCI_INIT(); - } -} - _X_EXPORT ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr) { int bus = PCI_BUS_FROM_TAG(tag); - pciInit(); - if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] && pciBusInfo[bus]->funcs->pciAddrBusToHost) return (*pciBusInfo[bus]->funcs->pciAddrBusToHost)(tag, type, addr); @@ -268,21 +175,19 @@ pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS addr) _X_EXPORT Bool xf86scanpci(void) { - static Bool done = FALSE; - static Bool success = FALSE; + Bool success = FALSE; - /* - * if we haven't found PCI devices checking for pci_devp may - * result in an endless recursion if platform/OS specific PCI - * bus probing code calls this function from with in it. - */ - if (done) - return success; + success = (pci_system_init() == 0); - done = TRUE; + /* XXX */ +#if defined(DEBUGPCI) + if (DEBUGPCI >= xf86Verbose) { + xf86Verbose = DEBUGPCI; + } +#endif - success = (pci_system_init() == 0); - pciInit(); + /* choose correct platform/OS specific PCI init routine */ + ARCH_PCI_INIT(); return success; } diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c index c864e3385..ff257a8c7 100644 --- a/hw/xfree86/os-support/bus/Sbus.c +++ b/hw/xfree86/os-support/bus/Sbus.c @@ -559,7 +559,7 @@ _X_EXPORT pointer xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size) { pointer ret; - unsigned long pagemask = xf86getpagesize() - 1; + unsigned long pagemask = getpagesize() - 1; unsigned long off = offset & ~pagemask; unsigned long len = ((offset + size + pagemask) & ~pagemask) - off; @@ -585,7 +585,7 @@ xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size) _X_EXPORT void xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size) { - unsigned long mask = xf86getpagesize() - 1; + unsigned long mask = getpagesize() - 1; unsigned long base = (unsigned long)addr & ~mask; unsigned long len = (((unsigned long)addr + size + mask) & ~mask) - base; diff --git a/hw/xfree86/os-support/bus/sparcPci.c b/hw/xfree86/os-support/bus/sparcPci.c index 6f7113f15..2d8039c29 100644 --- a/hw/xfree86/os-support/bus/sparcPci.c +++ b/hw/xfree86/os-support/bus/sparcPci.c @@ -270,7 +270,7 @@ sparcPciInit(void) } sparcPromInit(); - pagemask = xf86getpagesize() - 1; + pagemask = getpagesize() - 1; for (node = promGetChild(promRootNode); node; diff --git a/hw/xfree86/os-support/bus/zx1PCI.c b/hw/xfree86/os-support/bus/zx1PCI.c index 561fbd9f7..d78e0c434 100644 --- a/hw/xfree86/os-support/bus/zx1PCI.c +++ b/hw/xfree86/os-support/bus/zx1PCI.c @@ -469,7 +469,7 @@ void xf86PreScanZX1(void) { resRange range; - unsigned long mapSize = xf86getpagesize(); + unsigned long mapSize = getpagesize(); unsigned long tmp, base, ioaaddr; unsigned long flagsd, based, lastd, maskd, routed; unsigned long flags0, base0, last0, mask0, route0; diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c index 8e6ae8d36..04763ada7 100644 --- a/hw/xfree86/os-support/hurd/hurd_video.c +++ b/hw/xfree86/os-support/hurd/hurd_video.c @@ -126,7 +126,7 @@ extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); Bool xf86EnableIO() { - if (ioperm(0, 0xffff, 1)) { + if (ioperm(0, 0x10000, 1)) { FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno)); return FALSE; } @@ -138,7 +138,7 @@ xf86EnableIO() void xf86DisableIO() { - ioperm(0,0xffff,0); + ioperm(0,0x10000,0); return; } diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c index 53818f2dc..8eedfa49f 100644 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ b/hw/xfree86/os-support/linux/lnx_pci.c @@ -25,8 +25,6 @@ #define PCIADDR_FMT "%lx" #endif -int lnxPciInit(void); - struct pci_dev { unsigned int domain; unsigned int bus; @@ -139,14 +137,6 @@ static struct pci_dev *xf86OSLinuxGetPciDevs(void) { return ret; } -/* not to be confused with linuxPciInit (i.e. ARCH_PCI_INIT), found in - * os-support/bus/linuxPci.c. */ -int lnxPciInit(void) { - if (!xf86OSLinuxPCIDevs) - xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs(); - return xf86OSLinuxNumPciDevs; -} - /* Query the kvirt address (64bit) of a BAR range from size for a given TAG */ unsigned long xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c index ad2b66f74..1bd2d575f 100644 --- a/hw/xfree86/os-support/linux/lnx_video.c +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -142,17 +142,8 @@ mtrr_open(int verbosity) /* Only report absence of /proc/mtrr once. */ static Bool warned = FALSE; - char **fn; - static char *mtrr_files[] = { - "/dev/cpu/mtrr", /* Possible future name */ - "/proc/mtrr", /* Current name */ - NULL - }; - if (mtrr_fd == MTRR_FD_UNOPENED) { - /* So open it. */ - for (fn = mtrr_files; mtrr_fd < 0 && *fn; fn++) - mtrr_fd = open(*fn, O_WRONLY); + mtrr_fd = open("/proc/mtrr", O_WRONLY); if (mtrr_fd < 0) mtrr_fd = MTRR_FD_PROBLEM; diff --git a/hw/xfree86/os-support/shared/bios_mmap.c b/hw/xfree86/os-support/shared/bios_mmap.c index 51d429948..8bac87ebe 100644 --- a/hw/xfree86/os-support/shared/bios_mmap.c +++ b/hw/xfree86/os-support/shared/bios_mmap.c @@ -137,7 +137,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, return(-1); } - psize = xf86getpagesize(); + psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c index a9657fd55..7decc900f 100644 --- a/hw/xfree86/os-support/solaris/sun_apm.c +++ b/hw/xfree86/os-support/solaris/sun_apm.c @@ -149,7 +149,7 @@ sunPMGetEventFromOS(int fd, pmEvent *events, int num) if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) { if (errno != EAGAIN) { xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT" - " errno = %d\n", errno); + " %s\n", strerror(errno)); } break; } @@ -178,7 +178,7 @@ sunPMConfirmEventToOs(int fd, pmEvent event) return PM_CONTINUE; else { xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND" - " errno = %d\n", errno); + " %s\n", strerror(errno)); return PM_FAILED; } case XF86_APM_STANDBY_RESUME: @@ -191,7 +191,7 @@ sunPMConfirmEventToOs(int fd, pmEvent event) return PM_CONTINUE; else { xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME" - " errno = %d\n", errno); + " %s\n", strerror(errno)); return PM_FAILED; } default: diff --git a/hw/xfree86/os-support/solaris/sun_bios.c b/hw/xfree86/os-support/solaris/sun_bios.c index 1fae9759c..a27a5a5a7 100644 --- a/hw/xfree86/os-support/solaris/sun_bios.c +++ b/hw/xfree86/os-support/solaris/sun_bios.c @@ -62,7 +62,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, * * Use /dev/xsvc for everything. */ - psize = xf86getpagesize(); + psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c index aa509d08b..a5955ef2c 100644 --- a/hw/xfree86/os-support/solaris/sun_mouse.c +++ b/hw/xfree86/os-support/solaris/sun_mouse.c @@ -121,8 +121,11 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse); static void vuidMouseAdjustFrame(int index, int x, int y, int flags); static int vuidMouseGeneration = 0; -static int vuidMouseScreenIndex; -#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr) +static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey; +#define vuidMouseGetScreenPrivate(s) ( \ + dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey)) +#define vuidMouseSetScreenPrivate(s,p) \ + dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, (void *) p) #endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ static inline @@ -455,7 +458,7 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags) ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = pScrn->pScreen; xf86AdjustFrameProc *wrappedAdjustFrame - = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen); + = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen); VuidMsePtr m; if(wrappedAdjustFrame) { @@ -496,15 +499,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what) case DEVICE_INIT: #ifdef HAVE_ABSOLUTE_MOUSE_SCALING if (vuidMouseGeneration != serverGeneration) { - if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) { for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - vuidMouseScreenPrivate(pScreen) - = (pointer) pScrn->AdjustFrame; + vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame); pScrn->AdjustFrame = vuidMouseAdjustFrame; } - } vuidMouseGeneration = serverGeneration; } #endif diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h index 786dac145..6e4fdeab5 100644 --- a/hw/xfree86/parser/xf86tokens.h +++ b/hw/xfree86/parser/xf86tokens.h @@ -208,7 +208,6 @@ typedef enum { XKBVARIANT, XKBOPTIONS, /* The next two have become ServerFlags options */ - VTINIT, VTSYSREQ, /* Obsolete keyboard tokens */ SERVERNUM, diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c index 0d41599b1..8985f38b0 100644 --- a/hw/xfree86/rac/xf86RAC.c +++ b/hw/xfree86/rac/xf86RAC.c @@ -39,9 +39,8 @@ pScreen->x = y;} #define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x -#define SCREEN_PROLOG(x) \ - pScreen->x = \ - ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->x +#define SCREEN_PROLOG(x) pScreen->x = ((RACScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->x #define SCREEN_EPILOG(x,y) pScreen->x = y; #define WRAP_PICT_COND(x,y,cond) if (ps)\ @@ -50,9 +49,8 @@ ps->x = y;} #define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;} -#define PICTURE_PROLOGUE(field) \ - ps->field = \ - ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->field +#define PICTURE_PROLOGUE(field) ps->field = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->field #define PICTURE_EPILOGUE(field, wrap) \ ps->field = wrap @@ -65,9 +63,9 @@ #define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x #define SPRITE_PROLOG miPointerScreenPtr PointPriv = \ -(miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;\ - RACScreenPtr pScreenPriv = \ -((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr);\ + (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); \ + RACScreenPtr pScreenPriv = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey));\ PointPriv->spriteFuncs = pScreenPriv->miSprite; #define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\ PointPriv->spriteFuncs = &RACSpriteFuncs; @@ -82,7 +80,7 @@ (x)->ops = &RACGCOps;\ (x)->funcs = &RACGCFuncs; #define GC_UNWRAP(x)\ - RACGCPtr pGCPriv = (RACGCPtr) (x)->devPrivates[RACGCIndex].ptr;\ + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&(x)->devPrivates, RACGCKey);\ (x)->ops = pGCPriv->wrapOps;\ (x)->funcs = pGCPriv->wrapFuncs; @@ -252,9 +250,8 @@ static miPointerSpriteFuncRec RACSpriteFuncs = { RACSpriteMoveCursor }; -static int RACScreenIndex = -1; -static int RACGCIndex = -1; -static unsigned long RACGeneration = 0; +static DevPrivateKey RACScreenKey = &RACScreenKey; +static DevPrivateKey RACGCKey = &RACGCKey; Bool @@ -268,24 +265,17 @@ xf86RACInit(ScreenPtr pScreen, unsigned int flag) #endif pScrn = xf86Screens[pScreen->myNum]; - PointPriv = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr; - + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); DPRINT_S("RACInit",pScreen->myNum); - if (RACGeneration != serverGeneration) { - if ( ((RACScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((RACGCIndex = AllocateGCPrivateIndex()) < 0)) - return FALSE; - - RACGeneration = serverGeneration; - } - if (!AllocateGCPrivate(pScreen, RACGCIndex, sizeof(RACGCRec))) + if (!dixRequestPrivate(RACGCKey, sizeof(RACGCRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(RACScreenRec)))) return FALSE; - pScreen->devPrivates[RACScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, RACScreenKey, pScreenPriv); WRAP_SCREEN(CloseScreen, RACCloseScreen); WRAP_SCREEN(SaveScreen, RACSaveScreen); @@ -322,10 +312,10 @@ static Bool RACCloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; - miPointerScreenPtr PointPriv - = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif @@ -581,8 +571,8 @@ static void RACAdjustFrame(int index, int x, int y, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACAdjustFrame",index); xf86EnableAccess(xf86Screens[index]); @@ -594,8 +584,8 @@ static Bool RACSwitchMode(int index, DisplayModePtr mode, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACSwitchMode",index); xf86EnableAccess(xf86Screens[index]); @@ -607,8 +597,8 @@ static Bool RACEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACEnterVT",index); xf86EnableAccess(xf86Screens[index]); @@ -620,8 +610,8 @@ static void RACLeaveVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACLeaveVT",index); xf86EnableAccess(xf86Screens[index]); @@ -633,8 +623,8 @@ static void RACFreeScreen(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACFreeScreen",index); xf86EnableAccess(xf86Screens[index]); @@ -646,7 +636,7 @@ static Bool RACCreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - RACGCPtr pGCPriv = (RACGCPtr) (pGC)->devPrivates[RACGCIndex].ptr; + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&pGC->devPrivates, RACGCKey); Bool ret; DPRINT_S("RACCreateGC",pScreen->myNum); diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 457807698..5b1ce5e1f 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -8,8 +8,7 @@ #include "colormapst.h" #include "cursorstr.h" -int xf86CursorScreenIndex = -1; -static unsigned long xf86CursorGeneration = 0; +DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey; /* sprite functions */ @@ -48,12 +47,6 @@ xf86InitCursor( xf86CursorScreenPtr ScreenPriv; miPointerScreenPtr PointPriv; - if (xf86CursorGeneration != serverGeneration) { - if ((xf86CursorScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86CursorGeneration = serverGeneration; - } - if (!xf86InitHardwareCursor(pScreen, infoPtr)) return FALSE; @@ -61,7 +54,7 @@ xf86InitCursor( if (!ScreenPriv) return FALSE; - pScreen->devPrivates[xf86CursorScreenIndex].ptr = ScreenPriv; + dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv); ScreenPriv->SWCursor = TRUE; ScreenPriv->isUp = FALSE; @@ -84,7 +77,7 @@ xf86InitCursor( ScreenPriv->PalettedCursor = TRUE; } - PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr; + PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); ScreenPriv->showTransparent = PointPriv->showTransparent; if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) @@ -113,10 +106,10 @@ static Bool xf86CursorCloseScreen(int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - miPointerScreenPtr PointPriv = - pScreen->devPrivates[miPointerScreenIndex].ptr; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (ScreenPriv->isUp && pScrn->vtSema) xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); @@ -146,8 +139,8 @@ xf86CursorQueryBestSize( unsigned short *height, ScreenPtr pScreen) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (class == CursorShape) { if(*width > ScreenPriv->CursorInfoPtr->MaxWidth) @@ -161,8 +154,8 @@ xf86CursorQueryBestSize( static void xf86CursorInstallColormap(ColormapPtr pMap) { - xf86CursorScreenPtr ScreenPriv = - pMap->pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pMap->pScreen->devPrivates, xf86CursorScreenKey); ScreenPriv->pInstalledMap = pMap; @@ -175,8 +168,8 @@ xf86CursorRecolorCursor( CursorPtr pCurs, Bool displayed) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (!displayed) return; @@ -195,8 +188,8 @@ xf86CursorEnableDisableFBAccess( Bool enable) { ScreenPtr pScreen = screenInfo.screens[index]; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (!enable && ScreenPriv->CurrentCursor != NullCursor) { CursorPtr currentCursor = ScreenPriv->CurrentCursor; @@ -226,10 +219,10 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags) { Bool ret; ScreenPtr pScreen = screenInfo.screens[index]; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; - miPointerScreenPtr PointPriv = - pScreen->devPrivates[miPointerScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); if (ScreenPriv->isUp) { xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); @@ -254,11 +247,11 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags) static Bool xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) - pCurs->devPriv[pScreen->myNum] = NULL; + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs); } @@ -266,12 +259,12 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) static Bool xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) { - xfree(pCurs->devPriv[pScreen->myNum]); - pCurs->devPriv[pScreen->myNum] = NULL; + xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen)); + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); } return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs); @@ -280,8 +273,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) static void xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; miPointerScreenPtr PointPriv; @@ -306,8 +299,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) ScreenPriv->HotX = pCurs->bits->xhot; ScreenPriv->HotY = pCurs->bits->yhot; - PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr; - + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || (( #ifdef ARGB_CURSOR pCurs->bits->argb && infoPtr->UseHWCursorARGB && @@ -351,8 +344,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) static void xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); ScreenPriv->x = x; ScreenPriv->y = y; @@ -369,8 +362,8 @@ xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y) void xf86ForceHWCursor (ScreenPtr pScreen, Bool on) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (on) { diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h index 472e2b06b..f82be2edc 100644 --- a/hw/xfree86/ramdac/xf86CursorPriv.h +++ b/hw/xfree86/ramdac/xf86CursorPriv.h @@ -45,6 +45,6 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); CARD32 xf86ReverseBitOrder(CARD32 data); -extern int xf86CursorScreenIndex; +extern DevPrivateKey xf86CursorScreenKey; #endif /* _XF86CURSORPRIV_H */ diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c index 91caea047..d10e283d7 100644 --- a/hw/xfree86/ramdac/xf86HWCurs.c +++ b/hw/xfree86/ramdac/xf86HWCurs.c @@ -113,8 +113,8 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr) void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; unsigned char *bits; @@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) return; } - bits = pCurs->devPriv[pScreen->myNum]; + bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen); x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY; @@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) #endif if (!bits) { bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs); - pCurs->devPriv[pScreen->myNum] = bits; + dixSetPrivate(&pCurs->devPrivates, pScreen, bits); } if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) @@ -157,8 +157,8 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) void xf86SetTransparentCursor(ScreenPtr pScreen) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; if (!ScreenPriv->transparentData) @@ -178,8 +178,8 @@ xf86SetTransparentCursor(ScreenPtr pScreen) void xf86MoveCursor(ScreenPtr pScreen, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; @@ -191,8 +191,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y) void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; #ifdef ARGB_CURSOR diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c index 52fdcbef6..74beefb67 100644 --- a/hw/xfree86/shadowfb/shadow.c +++ b/hw/xfree86/shadowfb/shadow.c @@ -94,14 +94,13 @@ typedef struct { } ShadowGCRec, *ShadowGCPtr; -static int ShadowScreenIndex = -1; -static int ShadowGCIndex = -1; -static unsigned long ShadowGeneration = 0; +static DevPrivateKey ShadowScreenKey = &ShadowScreenKey; +static DevPrivateKey ShadowGCKey = &ShadowGCKey; #define GET_SCREEN_PRIVATE(pScreen) \ - (ShadowScreenPtr)((pScreen)->devPrivates[ShadowScreenIndex].ptr) + (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey) #define GET_GC_PRIVATE(pGC) \ - (ShadowGCPtr)((pGC)->devPrivates[ShadowGCIndex].ptr) + (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey); #define SHADOW_GC_FUNC_PROLOGUE(pGC)\ ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\ @@ -172,20 +171,13 @@ ShadowFBInit2 ( if(!preRefreshArea && !postRefreshArea) return FALSE; - if (ShadowGeneration != serverGeneration) { - if(((ShadowScreenIndex = AllocateScreenPrivateIndex ()) < 0) || - ((ShadowGCIndex = AllocateGCPrivateIndex()) < 0)) - return FALSE; - ShadowGeneration = serverGeneration; - } - - if(!AllocateGCPrivate(pScreen, ShadowGCIndex, sizeof(ShadowGCRec))) + if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec))) return FALSE; if(!(pPriv = (ShadowScreenPtr)xalloc(sizeof(ShadowScreenRec)))) return FALSE; - pScreen->devPrivates[ShadowScreenIndex].ptr = (pointer)pPriv; + dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv); pPriv->pScrn = pScrn; pPriv->preRefresh = preRefreshArea; diff --git a/hw/xfree86/utils/ioport/ioport.c b/hw/xfree86/utils/ioport/ioport.c index 32213642e..737043462 100644 --- a/hw/xfree86/utils/ioport/ioport.c +++ b/hw/xfree86/utils/ioport/ioport.c @@ -489,4 +489,3 @@ main(argc, argv) return (0); } -#include "xf86getpagesize.c" diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c index 06559bbd5..8af1727cc 100644 --- a/hw/xfree86/vbe/vbe.c +++ b/hw/xfree86/vbe/vbe.c @@ -1019,7 +1019,7 @@ VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) /* Input: AX := 4F0Bh VBE Get Pixel Clock - BL := 01h Get Pixel Clock + BL := 00h Get Pixel Clock ECX := pixel clock in units of Hz DX := mode number @@ -1030,7 +1030,7 @@ VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x4f0b; - pVbe->pInt10->bx = 0x01; + pVbe->pInt10->bx = 0x00; pVbe->pInt10->cx = clock; pVbe->pInt10->dx = mode; xf86ExecX86int10(pVbe->pInt10); diff --git a/hw/xfree86/x86emu/ops2.c b/hw/xfree86/x86emu/ops2.c index 8c6c53539..324de8ad8 100644 --- a/hw/xfree86/x86emu/ops2.c +++ b/hw/xfree86/x86emu/ops2.c @@ -328,6 +328,20 @@ static void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2)) } /**************************************************************************** +REMARKS: CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output +Handles opcode 0x0f,0xa2 +****************************************************************************/ +static void x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("CPUID\n"); + TRACE_AND_STEP(); + cpuid(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** REMARKS: Handles opcode 0x0f,0xa3 ****************************************************************************/ @@ -2734,7 +2748,7 @@ void (*x86emu_optab2[256])(u8) = /* 0xa0 */ x86emuOp2_push_FS, /* 0xa1 */ x86emuOp2_pop_FS, -/* 0xa2 */ x86emuOp2_illegal_op, +/* 0xa2 */ x86emuOp2_cpuid, /* 0xa3 */ x86emuOp2_bt_R, /* 0xa4 */ x86emuOp2_shld_IMM, /* 0xa5 */ x86emuOp2_shld_CL, diff --git a/hw/xfree86/x86emu/prim_ops.c b/hw/xfree86/x86emu/prim_ops.c index b9e7257ca..b42cdc0a5 100644 --- a/hw/xfree86/x86emu/prim_ops.c +++ b/hw/xfree86/x86emu/prim_ops.c @@ -102,6 +102,12 @@ #define PRIM_OPS_NO_REDEFINE_ASM #include "x86emu/x86emui.h" +#if defined(__GNUC__) +# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) +# include "x86emu/prim_x86_gcc.h" +# endif +#endif + /*------------------------- Global Variables ------------------------------*/ static u32 x86emu_parity_tab[8] = @@ -2654,3 +2660,63 @@ DB( if (CHECK_SP_ACCESS()) return res; } +/**************************************************************************** +REMARKS: +CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output +****************************************************************************/ +void cpuid (void) +{ + u32 feature = M.x86.R_EAX; + +#ifdef X86EMU_HAS_HW_CPUID + /* If the platform allows it, we will base our values on the real + * results from the CPUID instruction. We limit support to the + * first two features, and the results of those are sanitized. + */ + if (feature <= 1) + hw_cpuid(&M.x86.R_EAX, &M.x86.R_EBX, &M.x86.R_ECX, &M.x86.R_EDX); +#endif + + switch (feature) { + case 0: + /* Regardless if we have real data from the hardware, the emulator + * will only support upto feature 1, which we set in register EAX. + * Registers EBX:EDX:ECX contain a string identifying the CPU. + */ + M.x86.R_EAX = 1; +#ifndef X86EMU_HAS_HW_CPUID + /* EBX:EDX:ECX = "GenuineIntel" */ + M.x86.R_EBX = 0x756e6547; + M.x86.R_EDX = 0x49656e69; + M.x86.R_ECX = 0x6c65746e; +#endif + break; + case 1: +#ifndef X86EMU_HAS_HW_CPUID + /* If we don't have x86 compatible hardware, we return values from an + * Intel 486dx4; which was one of the first processors to have CPUID. + */ + M.x86.R_EAX = 0x00000480; + M.x86.R_EBX = 0x00000000; + M.x86.R_ECX = 0x00000000; + M.x86.R_EDX = 0x00000002; /* VME */ +#else + /* In the case that we have hardware CPUID instruction, we make sure + * that the features reported are limited to TSC and VME. + */ + M.x86.R_EDX &= 0x00000012; +#endif + break; + default: + /* Finally, we don't support any additional features. Most CPUs + * return all zeros when queried for invalid or unsupported feature + * numbers. + */ + M.x86.R_EAX = 0; + M.x86.R_EBX = 0; + M.x86.R_ECX = 0; + M.x86.R_EDX = 0; + break; + } +} + diff --git a/hw/xfree86/x86emu/x86emu/prim_ops.h b/hw/xfree86/x86emu/x86emu/prim_ops.h index bea8357e4..6ac2a29f6 100644 --- a/hw/xfree86/x86emu/x86emu/prim_ops.h +++ b/hw/xfree86/x86emu/x86emu/prim_ops.h @@ -133,6 +133,7 @@ void push_word (u16 w); void push_long (u32 w); u16 pop_word (void); u32 pop_long (void); +void cpuid (void); #ifdef __cplusplus } /* End of "C" linkage for C++ */ diff --git a/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h b/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h new file mode 100644 index 000000000..af61e2023 --- /dev/null +++ b/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h @@ -0,0 +1,79 @@ +/**************************************************************************** +* +* Inline helpers for x86emu +* +* Copyright (C) 2008 Bart Trojanowski, Symbio Technologies, LLC +* +* ======================================================================== +* +* Permission to use, copy, modify, distribute, and sell this software and +* its documentation for any purpose is hereby granted without fee, +* provided that the above copyright notice appear in all copies and that +* both that copyright notice and this permission notice appear in +* supporting documentation, and that the name of the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +* PERFORMANCE OF THIS SOFTWARE. +* +* ======================================================================== +* +* Language: GNU C +* Environment: GCC on i386 or x86-64 +* Developer: Bart Trojanowski +* +* Description: This file defines a few x86 macros that can be used by the +* emulator to execute native instructions. +* +* For PIC vs non-PIC code refer to: +* http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well +* +****************************************************************************/ +#ifndef __X86EMU_PRIM_X86_GCC_H +#define __X86EMU_PRIM_X86_GCC_H + +#include "x86emu/types.h" + +#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)) +#error This file is intended to be used by gcc on i386 or x86-64 system +#endif + +#if defined(__PIC__) && defined(__i386__) + +#define X86EMU_HAS_HW_CPUID 1 +static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d) +{ + __asm__ __volatile__ ("pushl %%ebx \n\t" + "cpuid \n\t" + "movl %%ebx, %1 \n\t" + "popl %%ebx \n\t" + : "=a" (*a), "=r" (*b), + "=c" (*c), "=d" (*d) + : "a" (*a), "c" (*c) + : "cc"); +} + +#else // ! (__PIC__ && __i386__) + +#define x86EMU_HAS_HW_CPUID 1 +static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d) +{ + __asm__ __volatile__ ("cpuid" + : "=a" (*a), "=b" (*b), + "=c" (*c), "=d" (*d) + : "a" (*a), "c" (*c) + : "cc"); +} + +#endif // __PIC__ && __i386__ + + +#endif // __X86EMU_PRIM_X86_GCC_H diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c index 1a4732baa..63233e05d 100644 --- a/hw/xfree86/xaa/xaaDashLine.c +++ b/hw/xfree86/xaa/xaaDashLine.c @@ -35,7 +35,8 @@ XAAPolyLinesDashed( #endif ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c index b3dc83ada..e6083d529 100644 --- a/hw/xfree86/xaa/xaaGC.c +++ b/hw/xfree86/xaa/xaaGC.c @@ -38,7 +38,8 @@ Bool XAACreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); Bool ret; XAA_SCREEN_PROLOGUE(pScreen,CreateGC); diff --git a/hw/xfree86/xaa/xaaGCmisc.c b/hw/xfree86/xaa/xaaGCmisc.c index a7a3f4081..5823cc064 100644 --- a/hw/xfree86/xaa/xaaGCmisc.c +++ b/hw/xfree86/xaa/xaaGCmisc.c @@ -305,7 +305,8 @@ XAAValidatePolylines( DrawablePtr pDraw ) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); if(pGC->lineStyle == LineSolid) changes &= ~GCDashList; if(!changes) return; diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c index 196569278..892cbcfc3 100644 --- a/hw/xfree86/xaa/xaaInit.c +++ b/hw/xfree86/xaa/xaaInit.c @@ -39,22 +39,20 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); static void XAAEnableDisableFBAccess (int index, Bool enable); static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); -static int XAAScreenIndex = -1; -static int XAAGCIndex = -1; -static int XAAPixmapIndex = -1; +static DevPrivateKey XAAScreenKey = &XAAScreenKey; +static DevPrivateKey XAAGCKey = &XAAGCKey; +static DevPrivateKey XAAPixmapKey = &XAAPixmapKey; -static unsigned long XAAGeneration = 0; - -int XAAGetScreenIndex(void) { - return XAAScreenIndex; +DevPrivateKey XAAGetScreenKey(void) { + return XAAScreenKey; } -int XAAGetGCIndex(void) { - return XAAGCIndex; +DevPrivateKey XAAGetGCKey(void) { + return XAAGCKey; } -int XAAGetPixmapIndex(void) { - return XAAPixmapIndex; +DevPrivateKey XAAGetPixmapKey(void) { + return XAAPixmapKey; } /* temp kludge */ @@ -104,25 +102,16 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) if (!infoRec) return TRUE; - if (XAAGeneration != serverGeneration) { - if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) || - ((XAAPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) - return FALSE; - - XAAGeneration = serverGeneration; - } - - if (!AllocateGCPrivate(pScreen, XAAGCIndex, sizeof(XAAGCRec))) + if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec))) return FALSE; - if (!AllocatePixmapPrivate(pScreen, XAAPixmapIndex, sizeof(XAAPixmapRec))) + if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec)))) return FALSE; - pScreen->devPrivates[XAAScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv); if(!xf86FBManagerRunning(pScreen)) infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); @@ -219,7 +208,7 @@ XAACloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); pScrn->EnterVT = pScreenPriv->EnterVT; pScrn->LeaveVT = pScreenPriv->LeaveVT; @@ -516,7 +505,7 @@ XAAEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); return((*pScreenPriv->EnterVT)(index, flags)); } @@ -526,7 +515,7 @@ XAALeaveVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; if(infoRec->NeedToSync) { @@ -549,7 +538,7 @@ XAASetDGAMode(int index, int num, DGADevicePtr devRet) ScreenPtr pScreen = screenInfo.screens[index]; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); int ret; if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */ @@ -611,7 +600,7 @@ XAAEnableDisableFBAccess (int index, Bool enable) ScreenPtr pScreen = screenInfo.screens[index]; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); if(!enable) { if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps)) diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c index fe0b70a14..1b7c15487 100644 --- a/hw/xfree86/xaa/xaaInitAccel.c +++ b/hw/xfree86/xaa/xaaInitAccel.c @@ -93,8 +93,6 @@ static const OptionInfoRec XAAOptions[] = { OPTV_NONE, {0}, FALSE } }; -static MODULESETUPPROTO(xaaSetup); - static XF86ModuleVersionInfo xaaVersRec = { "xaa", @@ -109,29 +107,7 @@ static XF86ModuleVersionInfo xaaVersRec = {0,0,0,0} }; -_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, xaaSetup, NULL }; - -ModuleInfoRec XAA = { - 1, - "XAA", - NULL, - 0, - XAAAvailableOptions, -}; - -/*ARGSUSED*/ -static pointer -xaaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) -{ - static Bool Initialised = FALSE; - - if (!Initialised) { - Initialised = TRUE; - xf86AddModuleInfo(&XAA, Module); - } - - return (pointer)TRUE; -} +_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL }; /*ARGSUSED*/ static const OptionInfoRec * diff --git a/hw/xfree86/xaa/xaaLineMisc.c b/hw/xfree86/xaa/xaaLineMisc.c index 537b08b97..cefb59a8e 100644 --- a/hw/xfree86/xaa/xaaLineMisc.c +++ b/hw/xfree86/xaa/xaaLineMisc.c @@ -64,7 +64,8 @@ void XAAComputeDash(GCPtr pGC) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE; int PatternLength = 0; unsigned char* DashPtr = (unsigned char*)pGC->dash; diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c index 47599d7d3..64ca998ee 100644 --- a/hw/xfree86/xaa/xaaOverlayDF.c +++ b/hw/xfree86/xaa/xaaOverlayDF.c @@ -151,11 +151,10 @@ typedef struct { int (*TiledFillChooser)(GCPtr); } XAAOverlayRec, *XAAOverlayPtr; -static int XAAOverlayIndex = -1; -static unsigned long XAAOverlayGeneration = 0; +static DevPrivateKey XAAOverlayKey = &XAAOverlayKey; #define GET_OVERLAY_PRIV(pScreen) \ - ((XAAOverlayPtr)((pScreen)->devPrivates[XAAOverlayIndex].ptr)) + (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey) #define SWITCH_DEPTH(d) \ if(pOverPriv->currentDepth != d) { \ @@ -173,18 +172,10 @@ XAAInitDualFramebufferOverlay( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAOverlayPtr pOverPriv; - if (XAAOverlayGeneration != serverGeneration) { - if((XAAOverlayIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - - XAAOverlayGeneration = serverGeneration; - } - - if(!(pOverPriv = xalloc(sizeof(XAAOverlayRec)))) return FALSE; - pScreen->devPrivates[XAAOverlayIndex].ptr = (pointer)pOverPriv; + dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv); pOverPriv->pScrn = pScrn; pOverPriv->callback = callback; diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c index 02c556b33..443bda628 100644 --- a/hw/xfree86/xaa/xaaStateChange.c +++ b/hw/xfree86/xaa/xaaStateChange.c @@ -274,18 +274,17 @@ typedef struct _XAAStateWrapRec { #endif } XAAStateWrapRec, *XAAStateWrapPtr; -static int XAAStateIndex = -1; -static unsigned long XAAStateGeneration = 0; +static DevPrivateKey XAAStateKey = &XAAStateKey; /* Wrap functions start here */ #define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pGC->pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey) #define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey) #define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pScrn->pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey) #define STATE_CHECK_SP(pStatePriv) {\ ScrnInfoPtr pScrn = pStatePriv->pScrn;\ @@ -1504,12 +1503,8 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec) XAAStateWrapPtr pStatePriv; int i = 0; - if (XAAStateGeneration != serverGeneration) { - if((XAAStateIndex = AllocateScreenPrivateIndex()) < 0) return FALSE; - XAAStateGeneration = serverGeneration; - } if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE; - pScreen->devPrivates[XAAStateIndex].ptr = (pointer)pStatePriv; + dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv); pStatePriv->RestoreAccelState = infoRec->RestoreAccelState; pStatePriv->pScrn = pScrn; diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c index b0176f03f..5d6ea05cf 100644 --- a/hw/xfree86/xaa/xaaWrapper.c +++ b/hw/xfree86/xaa/xaaWrapper.c @@ -86,10 +86,8 @@ typedef struct { int depth; } xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr; -#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \ - (xaaWrapperScrPrivateIndex != -1) \ - ? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\ - : NULL)) +#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr) \ + dixLookupPrivate(&(s)->devPrivates, xaaWrapperScrPrivateKey)) #define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s) #define wrap(priv,real,mem,func) {\ @@ -127,13 +125,12 @@ typedef struct _xaaWrapperGCPriv { } xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr; #define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \ - (pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr) + dixLookupPrivate(&(pGC)->devPrivates, xaaWrapperGCPrivateKey)) #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC) -static int xaaWrapperScrPrivateIndex = -1; -static int xaaWrapperGCPrivateIndex = -1; -static int xaaWrapperGeneration = -1; +static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKey; +static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKey; static Bool xaaWrapperCreateScreenResources(ScreenPtr pScreen) @@ -274,18 +271,8 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif - if (xaaWrapperGeneration != serverGeneration) { - xaaWrapperScrPrivateIndex = AllocateScreenPrivateIndex (); - if (xaaWrapperScrPrivateIndex == -1) - return FALSE; - xaaWrapperGCPrivateIndex = AllocateGCPrivateIndex (); - if (xaaWrapperGCPrivateIndex == -1) - return FALSE; - xaaWrapperGeneration = serverGeneration; - } - if (!AllocateGCPrivate (pScreen, xaaWrapperGCPrivateIndex, - sizeof (xaaWrapperGCPrivRec))) + if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec))) return FALSE; pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec)); @@ -335,7 +322,7 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f } #endif pScrPriv->depth = depth; - pScreen->devPrivates[xaaWrapperScrPrivateIndex].ptr = (pointer) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv); *func = XAASync; @@ -486,8 +473,8 @@ xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, void XAASync(ScreenPtr pScreen) { - XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAGetScreenIndex()].ptr; + XAAScreenPtr pScreenPriv = (XAAScreenPtr) + dixLookupPrivate(&pScreen->devPrivates, XAAGetScreenKey()); XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; if(infoRec->NeedToSync) { diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h index 686cc876d..e25b9df52 100644 --- a/hw/xfree86/xaa/xaalocal.h +++ b/hw/xfree86/xaa/xaalocal.h @@ -1629,9 +1629,9 @@ XAAGetPixelFromRGBA ( extern GCOps XAAFallbackOps; extern GCOps *XAAGetFallbackOps(void); extern GCFuncs XAAGCFuncs; -extern int XAAGetScreenIndex(void); -extern int XAAGetGCIndex(void); -extern int XAAGetPixmapIndex(void); +extern DevPrivateKey XAAGetScreenKey(void); +extern DevPrivateKey XAAGetGCKey(void); +extern DevPrivateKey XAAGetPixmapKey(void); extern unsigned int XAAShiftMasks[32]; @@ -1640,28 +1640,28 @@ extern unsigned int byte_expand3[256], byte_reversed_expand3[256]; CARD32 XAAReverseBitOrder(CARD32 data); #define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\ - (pScreen)->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()) #define GET_XAASCREENPTR_FROM_GC(pGC)\ - (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()) #define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\ - (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()) #define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\ - ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_GC(pGC)\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\ -((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\ -((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define XAA_GET_PIXMAP_PRIVATE(pix)\ - (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr) + (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey()) #define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h index 32c17a60c..38c97d70b 100644 --- a/hw/xfree86/xaa/xaawrap.h +++ b/hw/xfree86/xaa/xaawrap.h @@ -1,14 +1,14 @@ #define XAA_SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) #define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) #define XAA_GC_FUNC_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ (pGC)->funcs = pGCPriv->wrapFuncs;\ if(pGCPriv->flags)\ (pGC)->ops = pGCPriv->wrapOps @@ -24,13 +24,13 @@ #define XAA_GC_OP_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ pGC->ops = pGCPriv->wrapOps #define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ GCFuncs *oldFuncs = pGC->funcs;\ if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -44,7 +44,7 @@ #define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -64,7 +64,7 @@ #ifdef RENDER #define XAA_RENDER_PROLOGUE(pScreen,field)\ (GetPictureScreen(pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) #define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ (GetPictureScreen(pScreen)->field = wrapper) @@ -74,7 +74,7 @@ #define SYNC_CHECK(pGC) {\ XAAInfoRecPtr infoRec =\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec;\ +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ if(infoRec->NeedToSync) {\ (*infoRec->Sync)(infoRec->pScrn);\ infoRec->NeedToSync = FALSE;\ diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c index d5b5372f5..89aeadd2b 100644 --- a/hw/xfree86/xf4bpp/mfbfillarc.c +++ b/hw/xfree86/xf4bpp/mfbfillarc.c @@ -253,7 +253,8 @@ xf4bppPolyFillArcSolid mfbPrivGC *priv; int rop; - priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; + priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); rop = priv->rop; if ((rop == RROP_NOP) || !(pGC->planemask & 1)) #else diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c index 73e7ce064..4f9561161 100644 --- a/hw/xfree86/xf4bpp/mfbimggblt.c +++ b/hw/xfree86/xf4bpp/mfbimggblt.c @@ -149,7 +149,8 @@ xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; + pPrivGC = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */ oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */ oldalu = pPrivGC->colorRrop.alu; /* GJA */ diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c index c7a8c4d56..61fc7b184 100644 --- a/hw/xfree86/xf4bpp/mfbzerarc.c +++ b/hw/xfree86/xf4bpp/mfbzerarc.c @@ -108,7 +108,8 @@ v16ZeroArcSS int pmask; register int *paddr; - if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop == + if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()))->rop == RROP_BLACK) pixel = 0; else diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c index e95696260..df7856a35 100644 --- a/hw/xfree86/xf4bpp/ppcArea.c +++ b/hw/xfree86/xf4bpp/ppcArea.c @@ -49,7 +49,7 @@ int alu ; unsigned long int fg, bg, pm ; int xSrc, ySrc ; PixmapPtr pPixmap ; -ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; +ppcPrivGC *pPrivGC = dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ; diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c index 674a38b78..7ef312d39 100644 --- a/hw/xfree86/xf4bpp/ppcGC.c +++ b/hw/xfree86/xf4bpp/ppcGC.c @@ -182,7 +182,7 @@ register GCPtr pGC ; * a pointer to a ppcPrivGC in its slot. */ *pPriv = vgaPrototypeGCPriv; - (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) = (pointer) pPriv; + dixSetPrivate(&pGC->devPrivates, mfbGetGCPrivateKey(), pPriv); /* Set the vgaGCOps */ *pOps = vgaGCOps; @@ -202,7 +202,7 @@ xf4bppDestroyGC( pGC ) if ( pGC->freeCompClip && pGC->pCompositeClip ) REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); if(pGC->ops->devPrivate.val) xfree( pGC->ops ); - xfree( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; + xfree(dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey())); return ; } @@ -213,7 +213,7 @@ ppcChangePixmapGC register Mask changes ) { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ @@ -291,8 +291,8 @@ xf4bppValidateGC( pGC, changes, pDrawable ) register ppcPrivGCPtr devPriv ; WindowPtr pWin ; - devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; - + devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); if ( pDrawable->type != devPriv->lastDrawableType ) { devPriv->lastDrawableType = pDrawable->type ; xf4bppChangeGCtype( pGC, devPriv ) ; diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c index dfc648660..9fd29efce 100644 --- a/hw/xfree86/xf4bpp/ppcPixFS.c +++ b/hw/xfree86/xf4bpp/ppcPixFS.c @@ -124,7 +124,7 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()))->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand(pGC->pCompositeClip) ; @@ -142,8 +142,8 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; for ( ; n-- ; ppt++, pwidth++ ) { @@ -258,14 +258,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; pTile = pGC->stipple ; tlwidth = pTile->devKind ; @@ -356,15 +356,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->stipple ; @@ -459,14 +459,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; /* the following code is for 8 bits per pixel addressable memory only */ - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->tile.pixmap ; tileWidth = pTile->drawable.width ; diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c index 73524c3fc..d04aacf82 100644 --- a/hw/xfree86/xf4bpp/ppcPixmap.c +++ b/hw/xfree86/xf4bpp/ppcPixmap.c @@ -139,6 +139,7 @@ xf4bppCopyPixmap(pSrc) pDst = xalloc(sizeof(PixmapRec) + size); if (!pDst) return NullPixmap; + pDst->devPrivates = NULL; pDst->drawable = pSrc->drawable; pDst->drawable.id = 0; pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER; diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c index 1d6905563..c61fd6d26 100644 --- a/hw/xfree86/xf4bpp/ppcPolyPnt.c +++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c @@ -102,7 +102,7 @@ if ( pDrawable->type == DRAWABLE_PIXMAP ) { return ; } -devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; +devPriv = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); if ( ( alu = devPriv->colorRrop.alu ) == GXnoop ) return ; diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c index 78001d793..1522afd9e 100644 --- a/hw/xfree86/xf4bpp/ppcWinFS.c +++ b/hw/xfree86/xf4bpp/ppcWinFS.c @@ -96,7 +96,7 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand( pGC->pCompositeClip ) ; @@ -114,8 +114,8 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; for ( ; n-- ; ppt++, pwidth++ ) if ( *pwidth ) @@ -163,14 +163,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -215,15 +215,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -260,7 +260,7 @@ int fSorted ; TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, @@ -268,7 +268,7 @@ int fSorted ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; for ( ; n-- ; ppt++, pwidth++ ) xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm, diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c index 5a8604090..6495e5638 100644 --- a/hw/xfree86/xf4bpp/vgaGC.c +++ b/hw/xfree86/xf4bpp/vgaGC.c @@ -107,7 +107,7 @@ xf4bppChangeWindowGC( pGC, changes ) register GC *pGC ; register Mask changes ; { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h index e14096568..6e985da20 100644 --- a/hw/xfree86/xf8_32bpp/cfb8_32.h +++ b/hw/xfree86/xf8_32bpp/cfb8_32.h @@ -22,10 +22,8 @@ typedef struct { } cfb8_32ScreenRec, *cfb8_32ScreenPtr; -extern int cfb8_32GCPrivateIndex; /* XXX */ -extern int cfb8_32GetGCPrivateIndex(void); -extern int cfb8_32ScreenPrivateIndex; /* XXX */ -extern int cfb8_32GetScreenPrivateIndex(void); +extern DevPrivateKey cfb8_32GetGCPrivateKey(void); +extern DevPrivateKey cfb8_32GetScreenPrivateKey(void); RegionPtr cfb8_32CopyArea( @@ -182,11 +180,11 @@ cfb8_32ChangeWindowAttributes( ); -#define CFB8_32_GET_GC_PRIVATE(pGC)\ - (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GetGCPrivateIndex()].ptr) +#define CFB8_32_GET_GC_PRIVATE(pGC) ((cfb8_32GCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, cfb8_32GetGCPrivateKey())) -#define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\ - (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32GetScreenPrivateIndex()].ptr) +#define CFB8_32_GET_SCREEN_PRIVATE(pScreen) ((cfb8_32ScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, cfb8_32GetScreenPrivateKey())) Bool xf86Overlay8Plus32Init (ScreenPtr pScreen); diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c index 5e2657f2b..c3432b803 100644 --- a/hw/xfree86/xf8_32bpp/cfbscrinit.c +++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c @@ -31,38 +31,37 @@ /* CAUTION: We require that cfb8 and cfb32 were NOT compiled with CFB_NEED_SCREEN_PRIVATE */ -int cfb8_32GCPrivateIndex; -int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; } -int cfb8_32ScreenPrivateIndex; -int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex; } -static unsigned long cfb8_32Generation = 0; +static DevPrivateKey cfb8_32GCPrivateKey = &cfb8_32GCPrivateKey; +DevPrivateKey cfb8_32GetGCPrivateKey(void) +{ + return cfb8_32GCPrivateKey; +} + +static DevPrivateKey cfb8_32ScreenPrivateKey = &cfb8_32ScreenPrivateKey; +DevPrivateKey cfb8_32GetScreenPrivateKey(void) +{ + return cfb8_32ScreenPrivateKey; +} static Bool cfb8_32AllocatePrivates(ScreenPtr pScreen) { cfb8_32ScreenPtr pScreenPriv; - if(cfb8_32Generation != serverGeneration) { - if(((cfb8_32GCPrivateIndex = AllocateGCPrivateIndex()) < 0) || - ((cfb8_32ScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0)) - return FALSE; - cfb8_32Generation = serverGeneration; - } - if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec)))) return FALSE; - pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, pScreenPriv); /* All cfb will have the same GC and Window private indicies */ - if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex)) + if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey)) return FALSE; - if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC))) + if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC))) return FALSE; - if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec))) + if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec))) return FALSE; return TRUE; @@ -160,7 +159,7 @@ cfb8_32CloseScreen (int i, ScreenPtr pScreen) xfree(pScreenPriv->visualData); xfree((pointer) pScreenPriv); - pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, NULL); return(cfb32CloseScreen(i, pScreen)); } diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c index 47b2b52db..c63b3cfd1 100644 --- a/hw/xfree86/xf8_32bpp/xf86overlay.c +++ b/hw/xfree86/xf8_32bpp/xf86overlay.c @@ -177,23 +177,22 @@ typedef struct { } OverlayPixmapRec, *OverlayPixmapPtr; -static int OverlayScreenIndex = -1; -static int OverlayGCIndex = -1; -static int OverlayPixmapIndex = -1; -static unsigned long OverlayGeneration = 0; +static DevPrivateKey OverlayScreenKey = &OverlayScreenKey; +static DevPrivateKey OverlayGCKey = &OverlayGCKey; +static DevPrivateKey OverlayPixmapKey = &OverlayPixmapKey; /** Macros **/ #define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap) -#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \ - (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr) +#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) ((OverlayPixmapPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, OverlayPixmapKey)) -#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \ - (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr) +#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) ((OverlayScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, OverlayScreenKey)) -#define OVERLAY_GET_GC_PRIVATE(pGC) \ - (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr) +#define OVERLAY_GET_GC_PRIVATE(pGC) ((OverlayGCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, OverlayGCKey)) #define OVERLAY_GC_FUNC_PROLOGUE(pGC)\ OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ @@ -255,26 +254,16 @@ xf86Overlay8Plus32Init (ScreenPtr pScreen) { OverlayScreenPtr pScreenPriv; - if(OverlayGeneration != serverGeneration) { - if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) || - ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) - return FALSE; - - OverlayGeneration = serverGeneration; - } - - if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec))) + if (!dixRequestPrivate(OverlayGCKey, sizeof(OverlayGCRec))) return FALSE; - if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex, - sizeof(OverlayPixmapRec))) + if (!dixRequestPrivate(OverlayPixmapKey, sizeof(OverlayPixmapRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec)))) return FALSE; - pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, OverlayScreenKey, pScreenPriv); pScreenPriv->CreateGC = pScreen->CreateGC; pScreenPriv->CloseScreen = pScreen->CloseScreen; |