aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-03-22 10:29:25 +0000
committermarha <marha@users.sourceforge.net>2010-03-22 10:29:25 +0000
commitac80633ce275edddaa3e4fa2ae0c048ed00f7d74 (patch)
tree7d4ceffed59f2782533d3485c075f605ab1b9c61 /xorg-server/hw/xfree86
parent6fc6cb8c935fab174e4582909c1cb4f12bd598bf (diff)
downloadvcxsrv-ac80633ce275edddaa3e4fa2ae0c048ed00f7d74.tar.gz
vcxsrv-ac80633ce275edddaa3e4fa2ae0c048ed00f7d74.tar.bz2
vcxsrv-ac80633ce275edddaa3e4fa2ae0c048ed00f7d74.zip
svn merge -c505 ^/branches/released .
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r--xorg-server/hw/xfree86/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/common/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c26
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.c2337
-rw-r--r--xorg-server/hw/xfree86/ddc/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/dixmods/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/doc/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/doc/devel/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/doc/man/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/doc/sgml/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/dri/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/dri2/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c1872
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2ext.c2
-rw-r--r--xorg-server/hw/xfree86/exa/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/i2c/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/int10/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/loader/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/loader/sdksyms.c3
-rw-r--r--xorg-server/hw/xfree86/modes/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c22
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.h26
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Cursors.c4
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c14
-rw-r--r--xorg-server/hw/xfree86/os-support/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/misc/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/os-support/sysv/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/parser/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/ramdac/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86Cursor.c6
-rw-r--r--xorg-server/hw/xfree86/shadowfb/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/utils/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/utils/cvt/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/utils/gtf/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/vbe/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/vgahw/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/x86emu/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/x86emu/sys.c236
-rw-r--r--xorg-server/hw/xfree86/xaa/Makefile.in3
-rw-r--r--xorg-server/hw/xfree86/xf8_16bpp/Makefile.in3
49 files changed, 2362 insertions, 2299 deletions
diff --git a/xorg-server/hw/xfree86/Makefile.in b/xorg-server/hw/xfree86/Makefile.in
index f403408f3..ca37434b7 100644
--- a/xorg-server/hw/xfree86/Makefile.in
+++ b/xorg-server/hw/xfree86/Makefile.in
@@ -184,6 +184,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -315,6 +316,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/common/Makefile.in b/xorg-server/hw/xfree86/common/Makefile.in
index 12341f396..1ca3ada76 100644
--- a/xorg-server/hw/xfree86/common/Makefile.in
+++ b/xorg-server/hw/xfree86/common/Makefile.in
@@ -176,6 +176,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -307,6 +308,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 132e8bc37..718a07860 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -1286,14 +1286,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
}
- if (!foundPointer) {
- if (!xf86Info.allowEmptyInput) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
- return FALSE;
- } else {
- xf86Msg(X_INFO, "Cannot locate a core pointer device.\n");
- }
+ if (!foundPointer && !xf86Info.allowEmptyInput) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+ return FALSE;
}
/*
@@ -1430,14 +1426,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
}
- if (!foundKeyboard) {
- if (!xf86Info.allowEmptyInput) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
- return FALSE;
- } else {
- xf86Msg(X_INFO, "Cannot locate a core keyboard device.\n");
- }
+ if (!foundKeyboard && !xf86Info.allowEmptyInput) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+ return FALSE;
}
if (pointerMsg) {
@@ -1511,7 +1503,7 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
irp = (XF86ConfInputrefPtr)irp->list.next;
}
DebugF("Found %d input devices in the layout section %s\n",
- count, layout.lay_identifier);
+ count, layout->lay_identifier);
indp = xnfcalloc((count + 1), sizeof(IDevPtr));
indp[count] = NULL;
irp = layout->lay_input_lst;
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index d74d90bdd..67bf08bbf 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -612,7 +612,7 @@ configureDDCMonitorSection (int screennum)
len = 0;
}
if ((ptr->mon_comment =
- realloc(ptr->mon_comment, len+strlen(displaySize_string)))) {
+ realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
strcpy(ptr->mon_comment + len, displaySize_string);
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index 4cab8b3eb..f60d96e7d 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -1,1170 +1,1167 @@
-/*
- * Copyright (c) 1998-2001 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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#if defined(_XOPEN_SOURCE) || defined(sun) && defined(__SVR4)
-#include <math.h>
-#else
-#define _XOPEN_SOURCE /* to get prototype for pow on some systems */
-#include <math.h>
-#undef _XOPEN_SOURCE
-#endif
-
-#include <X11/X.h>
-#include "misc.h"
-#include <X11/Xproto.h>
-#include "colormapst.h"
-#include "scrnintstr.h"
-
-#include "resource.h"
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86str.h"
-#include "micmap.h"
-#include "xf86Crtc.h"
-
-#ifdef XFreeXDGA
-#include <X11/extensions/xf86dgaproto.h>
-#include "dgaproc.h"
-#endif
-
-#include "xf86cmap.h"
-
-#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
- ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
-#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
- ((pScreen)->field = wrapper)
-
-#define LOAD_PALETTE(pmap, index) \
- ((pmap == miInstalledMaps[index]) && \
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
- xf86Screens[index]->vtSema || pScreenPriv->isDGAmode))
-
-
-typedef struct _CMapLink {
- ColormapPtr cmap;
- struct _CMapLink *next;
-} CMapLink, *CMapLinkPtr;
-
-typedef struct {
- ScrnInfoPtr pScrn;
- CloseScreenProcPtr CloseScreen;
- CreateColormapProcPtr CreateColormap;
- DestroyColormapProcPtr DestroyColormap;
- InstallColormapProcPtr InstallColormap;
- StoreColorsProcPtr StoreColors;
- Bool (*EnterVT)(int, int);
- Bool (*SwitchMode)(int, DisplayModePtr, int);
- int (*SetDGAMode)(int, int, DGADevicePtr);
- xf86ChangeGammaProc *ChangeGamma;
- int maxColors;
- int sigRGBbits;
- int gammaElements;
- LOCO *gamma;
- int *PreAllocIndices;
- CMapLinkPtr maps;
- unsigned int flags;
- Bool isDGAmode;
-} CMapScreenRec, *CMapScreenPtr;
-
-typedef struct {
- int numColors;
- LOCO *colors;
- Bool recalculate;
- int overscan;
-} CMapColormapRec, *CMapColormapPtr;
-
-static int CMapScreenKeyIndex;
-static DevPrivateKey CMapScreenKey;
-static int CMapColormapKeyIndex;
-static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex;
-
-static void CMapInstallColormap(ColormapPtr);
-static void CMapStoreColors(ColormapPtr, int, xColorItem *);
-static Bool CMapCloseScreen (int, ScreenPtr);
-static Bool CMapCreateColormap (ColormapPtr);
-static void CMapDestroyColormap (ColormapPtr);
-
-static Bool CMapEnterVT(int, int);
-static Bool CMapSwitchMode(int, DisplayModePtr, int);
-#ifdef XFreeXDGA
-static int CMapSetDGAMode(int, int, DGADevicePtr);
-#endif
-static int CMapChangeGamma(int, Gamma);
-
-static void ComputeGamma(CMapScreenPtr);
-static Bool CMapAllocateColormapPrivate(ColormapPtr);
-static void CMapRefreshColors(ColormapPtr, int, int*);
-static void CMapSetOverscan(ColormapPtr, int, int *);
-static void CMapReinstallMap(ColormapPtr);
-static void CMapUnwrapScreen(ScreenPtr pScreen);
-
-
-
-Bool xf86HandleColormaps(
- ScreenPtr pScreen,
- int maxColors,
- int sigRGBbits,
- xf86LoadPaletteProc *loadPalette,
- xf86SetOverscanProc *setOverscan,
- unsigned int flags
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- ColormapPtr pDefMap = NULL;
- CMapScreenPtr pScreenPriv;
- LOCO *gamma;
- int *indices;
- int elements;
-
- /* If we support a better colormap system, then pretend we succeeded. */
- if (xf86_crtc_supports_gamma(pScrn))
- return TRUE;
-
- if(!maxColors || !sigRGBbits || !loadPalette)
- return FALSE;
-
- CMapScreenKey = &CMapScreenKeyIndex;
-
- elements = 1 << sigRGBbits;
-
- if(!(gamma = xalloc(elements * sizeof(LOCO))))
- return FALSE;
-
- if(!(indices = xalloc(maxColors * sizeof(int)))) {
- xfree(gamma);
- return FALSE;
- }
-
- if(!(pScreenPriv = xalloc(sizeof(CMapScreenRec)))) {
- xfree(gamma);
- xfree(indices);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
-
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreenPriv->CreateColormap = pScreen->CreateColormap;
- pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
- pScreenPriv->InstallColormap = pScreen->InstallColormap;
- pScreenPriv->StoreColors = pScreen->StoreColors;
- pScreen->CloseScreen = CMapCloseScreen;
- pScreen->CreateColormap = CMapCreateColormap;
- pScreen->DestroyColormap = CMapDestroyColormap;
- pScreen->InstallColormap = CMapInstallColormap;
- pScreen->StoreColors = CMapStoreColors;
-
- pScreenPriv->pScrn = pScrn;
- pScrn->LoadPalette = loadPalette;
- pScrn->SetOverscan = setOverscan;
- pScreenPriv->maxColors = maxColors;
- pScreenPriv->sigRGBbits = sigRGBbits;
- pScreenPriv->gammaElements = elements;
- pScreenPriv->gamma = gamma;
- pScreenPriv->PreAllocIndices = indices;
- pScreenPriv->maps = NULL;
- pScreenPriv->flags = flags;
- pScreenPriv->isDGAmode = FALSE;
-
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScreenPriv->SwitchMode = pScrn->SwitchMode;
- pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
- pScreenPriv->ChangeGamma = pScrn->ChangeGamma;
-
- if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
- pScrn->EnterVT = CMapEnterVT;
- if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
- pScrn->SwitchMode = CMapSwitchMode;
- }
-#ifdef XFreeXDGA
- pScrn->SetDGAMode = CMapSetDGAMode;
-#endif
- pScrn->ChangeGamma = CMapChangeGamma;
-
- ComputeGamma(pScreenPriv);
-
- /* get the default map */
- dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
- RT_COLORMAP, serverClient, DixInstallAccess);
-
- if(!CMapAllocateColormapPrivate(pDefMap)) {
- CMapUnwrapScreen(pScreen);
- return FALSE;
- }
-
- /* Force the initial map to be loaded */
- miInstalledMaps[pScreen->myNum] = NULL;
- CMapInstallColormap(pDefMap);
- return TRUE;
-}
-
-
-/**** Screen functions ****/
-
-
-static Bool
-CMapCloseScreen (int i, ScreenPtr pScreen)
-{
- CMapUnwrapScreen(pScreen);
-
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static Bool
-CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
-{
- if (pVisual->nplanes > 16)
- return TRUE;
- return ((1 << pVisual->nplanes) > pScreenPriv->maxColors);
-}
-
-static Bool
-CMapAllocateColormapPrivate(ColormapPtr pmap)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pmap->pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv;
- CMapLinkPtr pLink;
- int numColors;
- LOCO *colors;
-
- if (CMapColormapUseMax(pmap->pVisual, pScreenPriv))
- numColors = pmap->pVisual->ColormapEntries;
- else
- numColors = 1 << pmap->pVisual->nplanes;
-
- if(!(colors = xalloc(numColors * sizeof(LOCO))))
- return FALSE;
-
- if(!(pColPriv = xalloc(sizeof(CMapColormapRec)))) {
- xfree(colors);
- return FALSE;
- }
-
- dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
-
- pColPriv->numColors = numColors;
- pColPriv->colors = colors;
- pColPriv->recalculate = TRUE;
- pColPriv->overscan = -1;
-
- /* add map to list */
- pLink = xalloc(sizeof(CMapLink));
- if(pLink) {
- pLink->cmap = pmap;
- pLink->next = pScreenPriv->maps;
- pScreenPriv->maps = pLink;
- }
-
- return TRUE;
-}
-
-static Bool
-CMapCreateColormap (ColormapPtr pmap)
-{
- ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- Bool ret = FALSE;
-
- pScreen->CreateColormap = pScreenPriv->CreateColormap;
- if((*pScreen->CreateColormap)(pmap)) {
- if(CMapAllocateColormapPrivate(pmap))
- ret = TRUE;
- }
- pScreen->CreateColormap = CMapCreateColormap;
-
- return ret;
-}
-
-static void
-CMapDestroyColormap (ColormapPtr cmap)
-{
- ScreenPtr pScreen = cmap->pScreen;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &cmap->devPrivates, CMapColormapKey);
- CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
-
- if(pColPriv) {
- if(pColPriv->colors) xfree(pColPriv->colors);
- xfree(pColPriv);
- }
-
- /* remove map from list */
- while(pLink) {
- if(pLink->cmap == cmap) {
- if(prevLink)
- prevLink->next = pLink->next;
- else
- pScreenPriv->maps = pLink->next;
- xfree(pLink);
- break;
- }
- prevLink = pLink;
- pLink = pLink->next;
- }
-
- if(pScreenPriv->DestroyColormap) {
- pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- (*pScreen->DestroyColormap)(cmap);
- pScreen->DestroyColormap = CMapDestroyColormap;
- }
-}
-
-
-
-static void
-CMapStoreColors(
- ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs
-){
- ScreenPtr pScreen = pmap->pScreen;
- VisualPtr pVisual = pmap->pVisual;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- int *indices = pScreenPriv->PreAllocIndices;
- int num = ndef;
-
- /* At the moment this isn't necessary since there's nobody below us */
- pScreen->StoreColors = pScreenPriv->StoreColors;
- (*pScreen->StoreColors)(pmap, ndef, pdefs);
- pScreen->StoreColors = CMapStoreColors;
-
- /* should never get here for these */
- if( (pVisual->class == TrueColor) ||
- (pVisual->class == StaticColor) ||
- (pVisual->class == StaticGray))
- return;
-
- if(pVisual->class == DirectColor) {
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &pmap->devPrivates, CMapColormapKey);
- int i;
-
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- int index;
-
- num = 0;
- while(ndef--) {
- if(pdefs[ndef].flags & DoRed) {
- index = (pdefs[ndef].pixel & pVisual->redMask) >>
- pVisual->offsetRed;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- if(pdefs[ndef].flags & DoGreen) {
- index = (pdefs[ndef].pixel & pVisual->greenMask) >>
- pVisual->offsetGreen;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- if(pdefs[ndef].flags & DoBlue) {
- index = (pdefs[ndef].pixel & pVisual->blueMask) >>
- pVisual->offsetBlue;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- }
-
- } else {
- /* not really as overkill as it seems */
- num = pColPriv->numColors;
- for(i = 0; i < pColPriv->numColors; i++)
- indices[i] = i;
- }
- } else {
- while(ndef--)
- indices[ndef] = pdefs[ndef].pixel;
- }
-
- CMapRefreshColors(pmap, num, indices);
-}
-
-
-static void
-CMapInstallColormap(ColormapPtr pmap)
-{
- ScreenPtr pScreen = pmap->pScreen;
- int index = pScreen->myNum;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- if (pmap == miInstalledMaps[index])
- return;
-
- pScreen->InstallColormap = pScreenPriv->InstallColormap;
- (*pScreen->InstallColormap)(pmap);
- pScreen->InstallColormap = CMapInstallColormap;
-
- /* Important. We let the lower layers, namely DGA,
- overwrite the choice of Colormap to install */
- if (miInstalledMaps[index])
- pmap = miInstalledMaps[index];
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pmap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pmap->pVisual, pScreenPriv))
- return;
-
- if(LOAD_PALETTE(pmap, index))
- CMapReinstallMap(pmap);
-}
-
-
-/**** ScrnInfoRec functions ****/
-
-static Bool
-CMapEnterVT(int index, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- if((*pScreenPriv->EnterVT)(index, flags)) {
- if(miInstalledMaps[index])
- CMapReinstallMap(miInstalledMaps[index]);
- return TRUE;
- }
- return FALSE;
-}
-
-
-static Bool
-CMapSwitchMode(int index, DisplayModePtr mode, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
- if(miInstalledMaps[index])
- CMapReinstallMap(miInstalledMaps[index]);
- return TRUE;
- }
- return FALSE;
-}
-
-#ifdef XFreeXDGA
-static int
-CMapSetDGAMode(int index, int num, DGADevicePtr dev)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- int ret;
-
- ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
-
- pScreenPriv->isDGAmode = DGAActive(index);
-
- if(!pScreenPriv->isDGAmode && miInstalledMaps[index]
- && xf86Screens[pScreen->myNum]->vtSema)
- CMapReinstallMap(miInstalledMaps[index]);
-
- return ret;
-}
-#endif
-
-
-/**** Utilities ****/
-
-static void
-CMapReinstallMap(ColormapPtr pmap)
-{
- 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;
-
- while(i--)
- indices[i] = i;
-
- if(cmapPriv->recalculate)
- CMapRefreshColors(pmap, cmapPriv->numColors, indices);
- else {
- (*pScrn->LoadPalette)(pScrn, cmapPriv->numColors,
- indices, cmapPriv->colors, pmap->pVisual);
- if (pScrn->SetOverscan) {
-#ifdef DEBUGOVERSCAN
- ErrorF("SetOverscan() called from CMapReinstallMap\n");
-#endif
- pScrn->SetOverscan(pScrn, cmapPriv->overscan);
- }
- }
-
- cmapPriv->recalculate = FALSE;
-}
-
-
-static void
-CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
-{
- 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;
- LOCO *gamma, *colors;
- EntryPtr entry;
- int reds, greens, blues, maxValue, index, shift;
-
- numColors = pColPriv->numColors;
- shift = 16 - pScreenPriv->sigRGBbits;
- maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
- gamma = pScreenPriv->gamma;
- colors = pColPriv->colors;
-
- reds = pVisual->redMask >> pVisual->offsetRed;
- greens = pVisual->greenMask >> pVisual->offsetGreen;
- blues = pVisual->blueMask >> pVisual->offsetBlue;
-
- switch(pVisual->class) {
- case StaticGray:
- for(i = 0; i < numColors; i++) {
- index = (i+1) * maxValue / numColors;
- colors[i].red = gamma[index].red;
- colors[i].green = gamma[index].green;
- colors[i].blue = gamma[index].blue;
- }
- break;
- case TrueColor:
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- for(i = 0; i <= reds; i++)
- colors[i].red = gamma[i * maxValue / reds].red;
- for(i = 0; i <= greens; i++)
- colors[i].green = gamma[i * maxValue / greens].green;
- for(i = 0; i <= blues; i++)
- colors[i].blue = gamma[i * maxValue / blues].blue;
- break;
- }
- for(i = 0; i < numColors; i++) {
- colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) *
- maxValue / reds].red;
- colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) *
- maxValue / greens].green;
- colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) *
- maxValue / blues].blue;
- }
- break;
- case StaticColor:
- case PseudoColor:
- case GrayScale:
- for(i = 0; i < defs; i++) {
- index = indices[i];
- entry = (EntryPtr)&pmap->red[index];
-
- if(entry->fShared) {
- colors[index].red =
- gamma[entry->co.shco.red->color >> shift].red;
- colors[index].green =
- gamma[entry->co.shco.green->color >> shift].green;
- colors[index].blue =
- gamma[entry->co.shco.blue->color >> shift].blue;
- } else {
- colors[index].red =
- gamma[entry->co.local.red >> shift].red;
- colors[index].green =
- gamma[entry->co.local.green >> shift].green;
- colors[index].blue =
- gamma[entry->co.local.blue >> shift].blue;
- }
- }
- break;
- case DirectColor:
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- for(i = 0; i < defs; i++) {
- index = indices[i];
- if(index <= reds)
- colors[index].red =
- gamma[pmap->red[index].co.local.red >> shift].red;
- if(index <= greens)
- colors[index].green =
- gamma[pmap->green[index].co.local.green >> shift].green;
- if(index <= blues)
- colors[index].blue =
- gamma[pmap->blue[index].co.local.blue >> shift].blue;
-
- }
- break;
- }
- for(i = 0; i < defs; i++) {
- index = indices[i];
-
- colors[index].red = gamma[pmap->red[
- (index >> pVisual->offsetRed) & reds
- ].co.local.red >> shift].red;
- colors[index].green = gamma[pmap->green[
- (index >> pVisual->offsetGreen) & greens
- ].co.local.green >> shift].green;
- colors[index].blue = gamma[pmap->blue[
- (index >> pVisual->offsetBlue) & blues
- ].co.local.blue >> shift].blue;
- }
- break;
- }
-
-
- if(LOAD_PALETTE(pmap, pmap->pScreen->myNum))
- (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices,
- colors, pmap->pVisual);
-
- if (pScrn->SetOverscan)
- CMapSetOverscan(pmap, defs, indices);
-
-}
-
-static Bool
-CMapCompareColors(LOCO *color1, LOCO *color2)
-{
- /* return TRUE if the color1 is "closer" to black than color2 */
-#ifdef DEBUGOVERSCAN
- ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n",
- color1->red, color1->green, color1->blue,
- color2->red, color2->green, color2->blue,
- color1->red + color1->green + color1->blue,
- color2->red + color2->green + color2->blue);
-#endif
- return (color1->red + color1->green + color1->blue <
- color2->red + color2->green + color2->blue);
-}
-
-static void
-CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
-{
- 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;
- LOCO *colors;
- int index;
- Bool newOverscan = FALSE;
- int overscan, tmpOverscan;
-
- colors = pColPriv->colors;
- overscan = pColPriv->overscan;
-
- /*
- * Search for a new overscan index in the following cases:
- *
- * - The index hasn't yet been initialised.  In this case search
- * for an index that is black or a close match to black.
- *
- * - The colour of the old index is changed. In this case search
- * all indices for a black or close match to black.
- *
- * - The colour of the old index wasn't black. In this case only
- * search the indices that were changed for a better match to black.
- */
-
- switch (pVisual->class) {
- case StaticGray:
- case TrueColor:
- /* Should only come here once. Initialise the overscan index to 0 */
- overscan = 0;
- newOverscan = TRUE;
- break;
- case StaticColor:
- /*
- * Only come here once, but search for the overscan in the same way
- * as for the other cases.
- */
- case DirectColor:
- case PseudoColor:
- case GrayScale:
- if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) {
- /* Uninitialised */
- newOverscan = TRUE;
- } else {
- /* Check if the overscan was changed */
- for (i = 0; i < defs; i++) {
- index = indices[i];
- if (index == overscan) {
- newOverscan = TRUE;
- break;
- }
- }
- }
- if (newOverscan) {
- /* The overscan is either uninitialised or it has been changed */
-
- if (overscan < 0 || overscan > pScreenPriv->maxColors - 1)
- tmpOverscan = pScreenPriv->maxColors - 1;
- else
- tmpOverscan = overscan;
-
- /* search all entries for a close match to black */
- for (i = pScreenPriv->maxColors - 1; i >= 0; i--) {
- if (colors[i].red == 0 && colors[i].green == 0 &&
- colors[i].blue == 0) {
- overscan = i;
-#ifdef DEBUGOVERSCAN
- ErrorF("Black found at index 0x%02x\n", i);
-#endif
- break;
- } else {
-#ifdef DEBUGOVERSCAN
- ErrorF("0x%02x: ", i);
-#endif
- if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) {
- tmpOverscan = i;
-#ifdef DEBUGOVERSCAN
- ErrorF("possible \"Black\" at index 0x%02x\n", i);
-#endif
- }
- }
- }
- if (i < 0)
- overscan = tmpOverscan;
- } else {
- /* Check of the old overscan wasn't black */
- if (colors[overscan].red != 0 || colors[overscan].green != 0 ||
- colors[overscan].blue != 0) {
- int oldOverscan = tmpOverscan = overscan;
- /* See of there is now a better match */
- for (i = 0; i < defs; i++) {
- index = indices[i];
- if (colors[index].red == 0 && colors[index].green == 0 &&
- colors[index].blue == 0) {
- overscan = index;
-#ifdef DEBUGOVERSCAN
- ErrorF("Black found at index 0x%02x\n", index);
-#endif
- break;
- } else {
-#ifdef DEBUGOVERSCAN
- ErrorF("0x%02x: ", index);
-#endif
- if (CMapCompareColors(&colors[index],
- &colors[tmpOverscan])) {
- tmpOverscan = index;
-#ifdef DEBUGOVERSCAN
- ErrorF("possible \"Black\" at index 0x%02x\n",
- index);
-#endif
- }
- }
- }
- if (i == defs)
- overscan = tmpOverscan;
- if (overscan != oldOverscan)
- newOverscan = TRUE;
- }
- }
- break;
- }
- if (newOverscan) {
- pColPriv->overscan = overscan;
- if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) {
-#ifdef DEBUGOVERSCAN
- ErrorF("SetOverscan() called from CmapSetOverscan\n");
-#endif
- pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
- }
- }
-}
-
-static void
-CMapUnwrapScreen(ScreenPtr pScreen)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- pScreen->CreateColormap = pScreenPriv->CreateColormap;
- pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- pScreen->InstallColormap = pScreenPriv->InstallColormap;
- pScreen->StoreColors = pScreenPriv->StoreColors;
-
- pScrn->EnterVT = pScreenPriv->EnterVT;
- pScrn->SwitchMode = pScreenPriv->SwitchMode;
- pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
- pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
-
- xfree(pScreenPriv->gamma);
- xfree(pScreenPriv->PreAllocIndices);
- xfree(pScreenPriv);
-}
-
-
-static void
-ComputeGamma(CMapScreenPtr priv)
-{
- int elements = priv->gammaElements - 1;
- double RedGamma, GreenGamma, BlueGamma;
- int i;
-
-#ifndef DONT_CHECK_GAMMA
- /* This check is to catch drivers that are not initialising pScrn->gamma */
- if (priv->pScrn->gamma.red < GAMMA_MIN ||
- priv->pScrn->gamma.red > GAMMA_MAX ||
- priv->pScrn->gamma.green < GAMMA_MIN ||
- priv->pScrn->gamma.green > GAMMA_MAX ||
- priv->pScrn->gamma.blue < GAMMA_MIN ||
- priv->pScrn->gamma.blue > GAMMA_MAX) {
-
- xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
- "The %s driver didn't call xf86SetGamma() to initialise\n"
- "\tthe gamma values.\n", priv->pScrn->driverName);
- xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
- "PLEASE FIX THE `%s' DRIVER!\n", priv->pScrn->driverName);
- priv->pScrn->gamma.red = 1.0;
- priv->pScrn->gamma.green = 1.0;
- priv->pScrn->gamma.blue = 1.0;
- }
-#endif
-
- RedGamma = 1.0 / (double)priv->pScrn->gamma.red;
- GreenGamma = 1.0 / (double)priv->pScrn->gamma.green;
- BlueGamma = 1.0 / (double)priv->pScrn->gamma.blue;
-
- for(i = 0; i <= elements; i++) {
- if(RedGamma == 1.0)
- priv->gamma[i].red = i;
- else
- priv->gamma[i].red = (CARD16)(pow((double)i/(double)elements,
- RedGamma) * (double)elements + 0.5);
-
- if(GreenGamma == 1.0)
- priv->gamma[i].green = i;
- else
- priv->gamma[i].green = (CARD16)(pow((double)i/(double)elements,
- GreenGamma) * (double)elements + 0.5);
-
- if(BlueGamma == 1.0)
- priv->gamma[i].blue = i;
- else
- priv->gamma[i].blue = (CARD16)(pow((double)i/(double)elements,
- BlueGamma) * (double)elements + 0.5);
- }
-}
-
-
-int
-CMapChangeGamma(
- int index,
- Gamma gamma
-){
- int ret = Success;
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = pScrn->pScreen;
- CMapColormapPtr pColPriv;
- CMapScreenPtr pScreenPriv;
- CMapLinkPtr pLink;
-
- /* Is this sufficient checking ? */
- if(CMapScreenKey == NULL)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
- gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
- gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
- return BadValue;
-
- pScrn->gamma.red = gamma.red;
- pScrn->gamma.green = gamma.green;
- pScrn->gamma.blue = gamma.blue;
-
- ComputeGamma(pScreenPriv);
-
- /* mark all colormaps on this screen */
- pLink = pScreenPriv->maps;
- while(pLink) {
- pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
- CMapColormapKey);
- pColPriv->recalculate = TRUE;
- pLink = pLink->next;
- }
-
- if(miInstalledMaps[pScreen->myNum] &&
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
- pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pMap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
-
- /* if the current map doesn't have a palette look
- for another map to change the gamma on. */
-
- pLink = pScreenPriv->maps;
- while(pLink) {
- if(pLink->cmap->pVisual->class == PseudoColor)
- break;
- pLink = pLink->next;
- }
-
- if(pLink) {
- /* need to trick CMapRefreshColors() into thinking
- this is the currently installed map */
- miInstalledMaps[pScreen->myNum] = pLink->cmap;
- CMapReinstallMap(pLink->cmap);
- miInstalledMaps[pScreen->myNum] = pMap;
- }
- } else
- CMapReinstallMap(pMap);
- }
-
- pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
- if (pScrn->ChangeGamma)
- ret = pScrn->ChangeGamma(index, gamma);
- pScrn->ChangeGamma = CMapChangeGamma;
-
- return ret;
-}
-
-
-static void
-ComputeGammaRamp (
- CMapScreenPtr priv,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- int elements = priv->gammaElements;
- LOCO *entry = priv->gamma;
- int shift = 16 - priv->sigRGBbits;
-
- while(elements--) {
- entry->red = *(red++) >> shift;
- entry->green = *(green++) >> shift;
- entry->blue = *(blue++) >> shift;
- entry++;
- }
-}
-
-int
-xf86ChangeGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapColormapPtr pColPriv;
- CMapScreenPtr pScreenPriv;
- CMapLinkPtr pLink;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
-
- if (crtc) {
- if (crtc->gammaSize != size)
- return BadValue;
-
- RRCrtcGammaSet(crtc, red, green, blue);
-
- return Success;
- }
- }
-
- if(CMapScreenKey == NULL)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if(pScreenPriv->gammaElements != size)
- return BadValue;
-
- ComputeGammaRamp(pScreenPriv, red, green, blue);
-
- /* mark all colormaps on this screen */
- pLink = pScreenPriv->maps;
- while(pLink) {
- pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
- CMapColormapKey);
- pColPriv->recalculate = TRUE;
- pLink = pLink->next;
- }
-
- if(miInstalledMaps[pScreen->myNum] &&
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
- pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pMap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
-
- /* if the current map doesn't have a palette look
- for another map to change the gamma on. */
-
- pLink = pScreenPriv->maps;
- while(pLink) {
- if(pLink->cmap->pVisual->class == PseudoColor)
- break;
- pLink = pLink->next;
- }
-
- if(pLink) {
- /* need to trick CMapRefreshColors() into thinking
- this is the currently installed map */
- miInstalledMaps[pScreen->myNum] = pLink->cmap;
- CMapReinstallMap(pLink->cmap);
- miInstalledMaps[pScreen->myNum] = pMap;
- }
- } else
- CMapReinstallMap(pMap);
- }
-
- return Success;
-}
-
-int
-xf86GetGammaRampSize(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapScreenPtr pScreenPriv;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
-
- if (crtc)
- return crtc->gammaSize;
- }
-
- if(CMapScreenKey == NULL) return 0;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv) return 0;
-
- return pScreenPriv->gammaElements;
-}
-
-int
-xf86GetGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapScreenPtr pScreenPriv;
- LOCO *entry;
- int shift, sigbits;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
-
- if (crtc) {
- if (crtc->gammaSize < size)
- return BadValue;
-
- if (!RRCrtcGammaGet(crtc))
- return BadImplementation;
-
- memcpy(red, crtc->gammaRed, size * sizeof(*red));
- memcpy(green, crtc->gammaGreen, size * sizeof(*green));
- memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
-
- return Success;
- }
- }
-
- if(CMapScreenKey == NULL)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if(size > pScreenPriv->gammaElements)
- return BadValue;
-
- entry = pScreenPriv->gamma;
- sigbits = pScreenPriv->sigRGBbits;
-
- while(size--) {
- *red = entry->red << (16 - sigbits);
- *green = entry->green << (16 - sigbits);
- *blue = entry->blue << (16 - sigbits);
- shift = sigbits;
- while(shift < 16) {
- *red |= *red >> shift;
- *green |= *green >> shift;
- *blue |= *blue >> shift;
- shift += sigbits;
- }
- red++; green++; blue++;
- entry++;
- }
-
- return Success;
-}
-
-int
-xf86ChangeGamma(
- ScreenPtr pScreen,
- Gamma gamma
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if(pScrn->ChangeGamma)
- return (*pScrn->ChangeGamma)(pScreen->myNum, gamma);
-
- return BadImplementation;
-}
+/*
+ * Copyright (c) 1998-2001 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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(sun) && defined(__SVR4)
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for pow on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include <X11/Xproto.h>
+#include "colormapst.h"
+#include "scrnintstr.h"
+
+#include "resource.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86str.h"
+#include "micmap.h"
+#include "xf86Crtc.h"
+
+#ifdef XFreeXDGA
+#include <X11/extensions/xf86dgaproto.h>
+#include "dgaproc.h"
+#endif
+
+#include "xf86cmap.h"
+
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
+ ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+#define LOAD_PALETTE(pmap, index) \
+ ((pmap == miInstalledMaps[index]) && \
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
+ xf86Screens[index]->vtSema || pScreenPriv->isDGAmode))
+
+
+typedef struct _CMapLink {
+ ColormapPtr cmap;
+ struct _CMapLink *next;
+} CMapLink, *CMapLinkPtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ CloseScreenProcPtr CloseScreen;
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+ Bool (*EnterVT)(int, int);
+ Bool (*SwitchMode)(int, DisplayModePtr, int);
+ int (*SetDGAMode)(int, int, DGADevicePtr);
+ xf86ChangeGammaProc *ChangeGamma;
+ int maxColors;
+ int sigRGBbits;
+ int gammaElements;
+ LOCO *gamma;
+ int *PreAllocIndices;
+ CMapLinkPtr maps;
+ unsigned int flags;
+ Bool isDGAmode;
+} CMapScreenRec, *CMapScreenPtr;
+
+typedef struct {
+ int numColors;
+ LOCO *colors;
+ Bool recalculate;
+ int overscan;
+} CMapColormapRec, *CMapColormapPtr;
+
+static int CMapScreenKeyIndex;
+static DevPrivateKey CMapScreenKey;
+static int CMapColormapKeyIndex;
+static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex;
+
+static void CMapInstallColormap(ColormapPtr);
+static void CMapStoreColors(ColormapPtr, int, xColorItem *);
+static Bool CMapCloseScreen (int, ScreenPtr);
+static Bool CMapCreateColormap (ColormapPtr);
+static void CMapDestroyColormap (ColormapPtr);
+
+static Bool CMapEnterVT(int, int);
+static Bool CMapSwitchMode(int, DisplayModePtr, int);
+#ifdef XFreeXDGA
+static int CMapSetDGAMode(int, int, DGADevicePtr);
+#endif
+static int CMapChangeGamma(int, Gamma);
+
+static void ComputeGamma(CMapScreenPtr);
+static Bool CMapAllocateColormapPrivate(ColormapPtr);
+static void CMapRefreshColors(ColormapPtr, int, int*);
+static void CMapSetOverscan(ColormapPtr, int, int *);
+static void CMapReinstallMap(ColormapPtr);
+static void CMapUnwrapScreen(ScreenPtr pScreen);
+
+
+
+Bool xf86HandleColormaps(
+ ScreenPtr pScreen,
+ int maxColors,
+ int sigRGBbits,
+ xf86LoadPaletteProc *loadPalette,
+ xf86SetOverscanProc *setOverscan,
+ unsigned int flags
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ColormapPtr pDefMap = NULL;
+ CMapScreenPtr pScreenPriv;
+ LOCO *gamma;
+ int *indices;
+ int elements;
+
+ /* If we support a better colormap system, then pretend we succeeded. */
+ if (xf86_crtc_supports_gamma(pScrn))
+ return TRUE;
+
+ if(!maxColors || !sigRGBbits || !loadPalette)
+ return FALSE;
+
+ CMapScreenKey = &CMapScreenKeyIndex;
+
+ elements = 1 << sigRGBbits;
+
+ if(!(gamma = xalloc(elements * sizeof(LOCO))))
+ return FALSE;
+
+ if(!(indices = xalloc(maxColors * sizeof(int)))) {
+ xfree(gamma);
+ return FALSE;
+ }
+
+ if(!(pScreenPriv = xalloc(sizeof(CMapScreenRec)))) {
+ xfree(gamma);
+ xfree(indices);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->CreateColormap = pScreen->CreateColormap;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreenPriv->StoreColors = pScreen->StoreColors;
+ pScreen->CloseScreen = CMapCloseScreen;
+ pScreen->CreateColormap = CMapCreateColormap;
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ pScreen->InstallColormap = CMapInstallColormap;
+ pScreen->StoreColors = CMapStoreColors;
+
+ pScreenPriv->pScrn = pScrn;
+ pScrn->LoadPalette = loadPalette;
+ pScrn->SetOverscan = setOverscan;
+ pScreenPriv->maxColors = maxColors;
+ pScreenPriv->sigRGBbits = sigRGBbits;
+ pScreenPriv->gammaElements = elements;
+ pScreenPriv->gamma = gamma;
+ pScreenPriv->PreAllocIndices = indices;
+ pScreenPriv->maps = NULL;
+ pScreenPriv->flags = flags;
+ pScreenPriv->isDGAmode = FALSE;
+
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScreenPriv->SwitchMode = pScrn->SwitchMode;
+ pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+ pScreenPriv->ChangeGamma = pScrn->ChangeGamma;
+
+ if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
+ pScrn->EnterVT = CMapEnterVT;
+ if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
+ pScrn->SwitchMode = CMapSwitchMode;
+ }
+#ifdef XFreeXDGA
+ pScrn->SetDGAMode = CMapSetDGAMode;
+#endif
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ ComputeGamma(pScreenPriv);
+
+ /* get the default map */
+ dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixInstallAccess);
+
+ if(!CMapAllocateColormapPrivate(pDefMap)) {
+ CMapUnwrapScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Force the initial map to be loaded */
+ miInstalledMaps[pScreen->myNum] = NULL;
+ CMapInstallColormap(pDefMap);
+ return TRUE;
+}
+
+
+/**** Screen functions ****/
+
+
+static Bool
+CMapCloseScreen (int i, ScreenPtr pScreen)
+{
+ CMapUnwrapScreen(pScreen);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static Bool
+CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
+{
+ if (pVisual->nplanes > 16)
+ return TRUE;
+ return ((1 << pVisual->nplanes) > pScreenPriv->maxColors);
+}
+
+static Bool
+CMapAllocateColormapPrivate(ColormapPtr pmap)
+{
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv;
+ CMapLinkPtr pLink;
+ int numColors;
+ LOCO *colors;
+
+ if (CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ numColors = pmap->pVisual->ColormapEntries;
+ else
+ numColors = 1 << pmap->pVisual->nplanes;
+
+ if(!(colors = xalloc(numColors * sizeof(LOCO))))
+ return FALSE;
+
+ if(!(pColPriv = xalloc(sizeof(CMapColormapRec)))) {
+ xfree(colors);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
+
+ pColPriv->numColors = numColors;
+ pColPriv->colors = colors;
+ pColPriv->recalculate = TRUE;
+ pColPriv->overscan = -1;
+
+ /* add map to list */
+ pLink = xalloc(sizeof(CMapLink));
+ if(pLink) {
+ pLink->cmap = pmap;
+ pLink->next = pScreenPriv->maps;
+ pScreenPriv->maps = pLink;
+ }
+
+ return TRUE;
+}
+
+static Bool
+CMapCreateColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ Bool ret = FALSE;
+
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ if((*pScreen->CreateColormap)(pmap)) {
+ if(CMapAllocateColormapPrivate(pmap))
+ ret = TRUE;
+ }
+ pScreen->CreateColormap = CMapCreateColormap;
+
+ return ret;
+}
+
+static void
+CMapDestroyColormap (ColormapPtr cmap)
+{
+ ScreenPtr pScreen = cmap->pScreen;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &cmap->devPrivates, CMapColormapKey);
+ CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
+
+ if(pColPriv) {
+ if(pColPriv->colors) xfree(pColPriv->colors);
+ xfree(pColPriv);
+ }
+
+ /* remove map from list */
+ while(pLink) {
+ if(pLink->cmap == cmap) {
+ if(prevLink)
+ prevLink->next = pLink->next;
+ else
+ pScreenPriv->maps = pLink->next;
+ xfree(pLink);
+ break;
+ }
+ prevLink = pLink;
+ pLink = pLink->next;
+ }
+
+ if(pScreenPriv->DestroyColormap) {
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ (*pScreen->DestroyColormap)(cmap);
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ }
+}
+
+
+
+static void
+CMapStoreColors(
+ ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs
+){
+ ScreenPtr pScreen = pmap->pScreen;
+ VisualPtr pVisual = pmap->pVisual;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ int *indices = pScreenPriv->PreAllocIndices;
+ int num = ndef;
+
+ /* At the moment this isn't necessary since there's nobody below us */
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+ (*pScreen->StoreColors)(pmap, ndef, pdefs);
+ pScreen->StoreColors = CMapStoreColors;
+
+ /* should never get here for these */
+ if( (pVisual->class == TrueColor) ||
+ (pVisual->class == StaticColor) ||
+ (pVisual->class == StaticGray))
+ return;
+
+ if(pVisual->class == DirectColor) {
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
+ int i;
+
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ int index;
+
+ num = 0;
+ while(ndef--) {
+ if(pdefs[ndef].flags & DoRed) {
+ index = (pdefs[ndef].pixel & pVisual->redMask) >>
+ pVisual->offsetRed;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ if(pdefs[ndef].flags & DoGreen) {
+ index = (pdefs[ndef].pixel & pVisual->greenMask) >>
+ pVisual->offsetGreen;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ if(pdefs[ndef].flags & DoBlue) {
+ index = (pdefs[ndef].pixel & pVisual->blueMask) >>
+ pVisual->offsetBlue;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ }
+
+ } else {
+ /* not really as overkill as it seems */
+ num = pColPriv->numColors;
+ for(i = 0; i < pColPriv->numColors; i++)
+ indices[i] = i;
+ }
+ } else {
+ while(ndef--)
+ indices[ndef] = pdefs[ndef].pixel;
+ }
+
+ CMapRefreshColors(pmap, num, indices);
+}
+
+
+static void
+CMapInstallColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ int index = pScreen->myNum;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+
+ if (pmap == miInstalledMaps[index])
+ return;
+
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ (*pScreen->InstallColormap)(pmap);
+ pScreen->InstallColormap = CMapInstallColormap;
+
+ /* Important. We let the lower layers, namely DGA,
+ overwrite the choice of Colormap to install */
+ if (miInstalledMaps[index])
+ pmap = miInstalledMaps[index];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pmap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ return;
+
+ if(LOAD_PALETTE(pmap, index))
+ CMapReinstallMap(pmap);
+}
+
+
+/**** ScrnInfoRec functions ****/
+
+static Bool
+CMapEnterVT(int index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+
+ if((*pScreenPriv->EnterVT)(index, flags)) {
+ if(miInstalledMaps[index])
+ CMapReinstallMap(miInstalledMaps[index]);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+static Bool
+CMapSwitchMode(int index, DisplayModePtr mode, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+
+ if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
+ if(miInstalledMaps[index])
+ CMapReinstallMap(miInstalledMaps[index]);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#ifdef XFreeXDGA
+static int
+CMapSetDGAMode(int index, int num, DGADevicePtr dev)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ int ret;
+
+ ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
+
+ pScreenPriv->isDGAmode = DGAActive(index);
+
+ if(!pScreenPriv->isDGAmode && miInstalledMaps[index]
+ && xf86Screens[pScreen->myNum]->vtSema)
+ CMapReinstallMap(miInstalledMaps[index]);
+
+ return ret;
+}
+#endif
+
+
+/**** Utilities ****/
+
+static void
+CMapReinstallMap(ColormapPtr pmap)
+{
+ 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;
+
+ while(i--)
+ indices[i] = i;
+
+ if(cmapPriv->recalculate)
+ CMapRefreshColors(pmap, cmapPriv->numColors, indices);
+ else {
+ (*pScrn->LoadPalette)(pScrn, cmapPriv->numColors,
+ indices, cmapPriv->colors, pmap->pVisual);
+ if (pScrn->SetOverscan) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CMapReinstallMap\n");
+#endif
+ pScrn->SetOverscan(pScrn, cmapPriv->overscan);
+ }
+ }
+
+ cmapPriv->recalculate = FALSE;
+}
+
+
+static void
+CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
+{
+ 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;
+ LOCO *gamma, *colors;
+ EntryPtr entry;
+ int reds, greens, blues, maxValue, index, shift;
+
+ numColors = pColPriv->numColors;
+ shift = 16 - pScreenPriv->sigRGBbits;
+ maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
+ gamma = pScreenPriv->gamma;
+ colors = pColPriv->colors;
+
+ reds = pVisual->redMask >> pVisual->offsetRed;
+ greens = pVisual->greenMask >> pVisual->offsetGreen;
+ blues = pVisual->blueMask >> pVisual->offsetBlue;
+
+ switch(pVisual->class) {
+ case StaticGray:
+ for(i = 0; i < numColors; i++) {
+ index = (i+1) * maxValue / numColors;
+ colors[i].red = gamma[index].red;
+ colors[i].green = gamma[index].green;
+ colors[i].blue = gamma[index].blue;
+ }
+ break;
+ case TrueColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for(i = 0; i <= reds; i++)
+ colors[i].red = gamma[i * maxValue / reds].red;
+ for(i = 0; i <= greens; i++)
+ colors[i].green = gamma[i * maxValue / greens].green;
+ for(i = 0; i <= blues; i++)
+ colors[i].blue = gamma[i * maxValue / blues].blue;
+ break;
+ }
+ for(i = 0; i < numColors; i++) {
+ colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) *
+ maxValue / reds].red;
+ colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) *
+ maxValue / greens].green;
+ colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) *
+ maxValue / blues].blue;
+ }
+ break;
+ case StaticColor:
+ case PseudoColor:
+ case GrayScale:
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+ entry = (EntryPtr)&pmap->red[index];
+
+ if(entry->fShared) {
+ colors[index].red =
+ gamma[entry->co.shco.red->color >> shift].red;
+ colors[index].green =
+ gamma[entry->co.shco.green->color >> shift].green;
+ colors[index].blue =
+ gamma[entry->co.shco.blue->color >> shift].blue;
+ } else {
+ colors[index].red =
+ gamma[entry->co.local.red >> shift].red;
+ colors[index].green =
+ gamma[entry->co.local.green >> shift].green;
+ colors[index].blue =
+ gamma[entry->co.local.blue >> shift].blue;
+ }
+ }
+ break;
+ case DirectColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+ if(index <= reds)
+ colors[index].red =
+ gamma[pmap->red[index].co.local.red >> shift].red;
+ if(index <= greens)
+ colors[index].green =
+ gamma[pmap->green[index].co.local.green >> shift].green;
+ if(index <= blues)
+ colors[index].blue =
+ gamma[pmap->blue[index].co.local.blue >> shift].blue;
+
+ }
+ break;
+ }
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+
+ colors[index].red = gamma[pmap->red[
+ (index >> pVisual->offsetRed) & reds
+ ].co.local.red >> shift].red;
+ colors[index].green = gamma[pmap->green[
+ (index >> pVisual->offsetGreen) & greens
+ ].co.local.green >> shift].green;
+ colors[index].blue = gamma[pmap->blue[
+ (index >> pVisual->offsetBlue) & blues
+ ].co.local.blue >> shift].blue;
+ }
+ break;
+ }
+
+
+ if(LOAD_PALETTE(pmap, pmap->pScreen->myNum))
+ (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices,
+ colors, pmap->pVisual);
+
+ if (pScrn->SetOverscan)
+ CMapSetOverscan(pmap, defs, indices);
+
+}
+
+static Bool
+CMapCompareColors(LOCO *color1, LOCO *color2)
+{
+ /* return TRUE if the color1 is "closer" to black than color2 */
+#ifdef DEBUGOVERSCAN
+ ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n",
+ color1->red, color1->green, color1->blue,
+ color2->red, color2->green, color2->blue,
+ color1->red + color1->green + color1->blue,
+ color2->red + color2->green + color2->blue);
+#endif
+ return (color1->red + color1->green + color1->blue <
+ color2->red + color2->green + color2->blue);
+}
+
+static void
+CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
+{
+ 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;
+ LOCO *colors;
+ int index;
+ Bool newOverscan = FALSE;
+ int overscan, tmpOverscan;
+
+ colors = pColPriv->colors;
+ overscan = pColPriv->overscan;
+
+ /*
+ * Search for a new overscan index in the following cases:
+ *
+ * - The index hasn't yet been initialised.  In this case search
+ * for an index that is black or a close match to black.
+ *
+ * - The colour of the old index is changed. In this case search
+ * all indices for a black or close match to black.
+ *
+ * - The colour of the old index wasn't black. In this case only
+ * search the indices that were changed for a better match to black.
+ */
+
+ switch (pVisual->class) {
+ case StaticGray:
+ case TrueColor:
+ /* Should only come here once. Initialise the overscan index to 0 */
+ overscan = 0;
+ newOverscan = TRUE;
+ break;
+ case StaticColor:
+ /*
+ * Only come here once, but search for the overscan in the same way
+ * as for the other cases.
+ */
+ case DirectColor:
+ case PseudoColor:
+ case GrayScale:
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) {
+ /* Uninitialised */
+ newOverscan = TRUE;
+ } else {
+ /* Check if the overscan was changed */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (index == overscan) {
+ newOverscan = TRUE;
+ break;
+ }
+ }
+ }
+ if (newOverscan) {
+ /* The overscan is either uninitialised or it has been changed */
+
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1)
+ tmpOverscan = pScreenPriv->maxColors - 1;
+ else
+ tmpOverscan = overscan;
+
+ /* search all entries for a close match to black */
+ for (i = pScreenPriv->maxColors - 1; i >= 0; i--) {
+ if (colors[i].red == 0 && colors[i].green == 0 &&
+ colors[i].blue == 0) {
+ overscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", i);
+#endif
+ break;
+ } else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", i);
+#endif
+ if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) {
+ tmpOverscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n", i);
+#endif
+ }
+ }
+ }
+ if (i < 0)
+ overscan = tmpOverscan;
+ } else {
+ /* Check of the old overscan wasn't black */
+ if (colors[overscan].red != 0 || colors[overscan].green != 0 ||
+ colors[overscan].blue != 0) {
+ int oldOverscan = tmpOverscan = overscan;
+ /* See of there is now a better match */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (colors[index].red == 0 && colors[index].green == 0 &&
+ colors[index].blue == 0) {
+ overscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", index);
+#endif
+ break;
+ } else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", index);
+#endif
+ if (CMapCompareColors(&colors[index],
+ &colors[tmpOverscan])) {
+ tmpOverscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n",
+ index);
+#endif
+ }
+ }
+ }
+ if (i == defs)
+ overscan = tmpOverscan;
+ if (overscan != oldOverscan)
+ newOverscan = TRUE;
+ }
+ }
+ break;
+ }
+ if (newOverscan) {
+ pColPriv->overscan = overscan;
+ if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CmapSetOverscan\n");
+#endif
+ pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
+ }
+ }
+}
+
+static void
+CMapUnwrapScreen(ScreenPtr pScreen)
+{
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ pScrn->SwitchMode = pScreenPriv->SwitchMode;
+ pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
+
+ xfree(pScreenPriv->gamma);
+ xfree(pScreenPriv->PreAllocIndices);
+ xfree(pScreenPriv);
+}
+
+
+static void
+ComputeGamma(CMapScreenPtr priv)
+{
+ int elements = priv->gammaElements - 1;
+ double RedGamma, GreenGamma, BlueGamma;
+ int i;
+
+#ifndef DONT_CHECK_GAMMA
+ /* This check is to catch drivers that are not initialising pScrn->gamma */
+ if (priv->pScrn->gamma.red < GAMMA_MIN ||
+ priv->pScrn->gamma.red > GAMMA_MAX ||
+ priv->pScrn->gamma.green < GAMMA_MIN ||
+ priv->pScrn->gamma.green > GAMMA_MAX ||
+ priv->pScrn->gamma.blue < GAMMA_MIN ||
+ priv->pScrn->gamma.blue > GAMMA_MAX) {
+
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "The %s driver didn't call xf86SetGamma() to initialise\n"
+ "\tthe gamma values.\n", priv->pScrn->driverName);
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "PLEASE FIX THE `%s' DRIVER!\n", priv->pScrn->driverName);
+ priv->pScrn->gamma.red = 1.0;
+ priv->pScrn->gamma.green = 1.0;
+ priv->pScrn->gamma.blue = 1.0;
+ }
+#endif
+
+ RedGamma = 1.0 / (double)priv->pScrn->gamma.red;
+ GreenGamma = 1.0 / (double)priv->pScrn->gamma.green;
+ BlueGamma = 1.0 / (double)priv->pScrn->gamma.blue;
+
+ for(i = 0; i <= elements; i++) {
+ if(RedGamma == 1.0)
+ priv->gamma[i].red = i;
+ else
+ priv->gamma[i].red = (CARD16)(pow((double)i/(double)elements,
+ RedGamma) * (double)elements + 0.5);
+
+ if(GreenGamma == 1.0)
+ priv->gamma[i].green = i;
+ else
+ priv->gamma[i].green = (CARD16)(pow((double)i/(double)elements,
+ GreenGamma) * (double)elements + 0.5);
+
+ if(BlueGamma == 1.0)
+ priv->gamma[i].blue = i;
+ else
+ priv->gamma[i].blue = (CARD16)(pow((double)i/(double)elements,
+ BlueGamma) * (double)elements + 0.5);
+ }
+}
+
+
+int
+CMapChangeGamma(
+ int index,
+ Gamma gamma
+){
+ int ret = Success;
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ /* Is this sufficient checking ? */
+ if(CMapScreenKey == NULL)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
+ gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
+ gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
+ return BadValue;
+
+ pScrn->gamma.red = gamma.red;
+ pScrn->gamma.green = gamma.green;
+ pScrn->gamma.blue = gamma.blue;
+
+ ComputeGamma(pScreenPriv);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if(miInstalledMaps[pScreen->myNum] &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ if(pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if(pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ CMapReinstallMap(pLink->cmap);
+ miInstalledMaps[pScreen->myNum] = pMap;
+ }
+ } else
+ CMapReinstallMap(pMap);
+ }
+
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
+ if (pScrn->ChangeGamma)
+ ret = pScrn->ChangeGamma(index, gamma);
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ return ret;
+}
+
+
+static void
+ComputeGammaRamp (
+ CMapScreenPtr priv,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ int elements = priv->gammaElements;
+ LOCO *entry = priv->gamma;
+ int shift = 16 - priv->sigRGBbits;
+
+ while(elements--) {
+ entry->red = *(red++) >> shift;
+ entry->green = *(green++) >> shift;
+ entry->blue = *(blue++) >> shift;
+ entry++;
+ }
+}
+
+int
+xf86ChangeGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc) {
+ if (crtc->gammaSize != size)
+ return BadValue;
+
+ RRCrtcGammaSet(crtc, red, green, blue);
+
+ return Success;
+ }
+ }
+
+ if(CMapScreenKey == NULL)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if(pScreenPriv->gammaElements != size)
+ return BadValue;
+
+ ComputeGammaRamp(pScreenPriv, red, green, blue);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if(miInstalledMaps[pScreen->myNum] &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ if(pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if(pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ CMapReinstallMap(pLink->cmap);
+ miInstalledMaps[pScreen->myNum] = pMap;
+ }
+ } else
+ CMapReinstallMap(pMap);
+ }
+
+ return Success;
+}
+
+int
+xf86GetGammaRampSize(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapScreenPtr pScreenPriv;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc)
+ return crtc->gammaSize;
+ }
+
+ if(CMapScreenKey == NULL) return 0;
+
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if(!pScreenPriv) return 0;
+
+ return pScreenPriv->gammaElements;
+}
+
+int
+xf86GetGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapScreenPtr pScreenPriv;
+ LOCO *entry;
+ int shift, sigbits;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc) {
+ if (crtc->gammaSize < size)
+ return BadValue;
+
+ if (!RRCrtcGammaGet(crtc))
+ return BadImplementation;
+
+ memcpy(red, crtc->gammaRed, size * sizeof(*red));
+ memcpy(green, crtc->gammaGreen, size * sizeof(*green));
+ memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
+
+ return Success;
+ }
+ }
+
+ if(CMapScreenKey == NULL)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if(size > pScreenPriv->gammaElements)
+ return BadValue;
+
+ entry = pScreenPriv->gamma;
+ sigbits = pScreenPriv->sigRGBbits;
+
+ while(size--) {
+ *red = entry->red << (16 - sigbits);
+ *green = entry->green << (16 - sigbits);
+ *blue = entry->blue << (16 - sigbits);
+ shift = sigbits;
+ while(shift < 16) {
+ *red |= *red >> shift;
+ *green |= *green >> shift;
+ *blue |= *blue >> shift;
+ shift += sigbits;
+ }
+ red++; green++; blue++;
+ entry++;
+ }
+
+ return Success;
+}
+
+int
+xf86ChangeGamma(
+ ScreenPtr pScreen,
+ Gamma gamma
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if(pScrn->ChangeGamma)
+ return (*pScrn->ChangeGamma)(pScreen->myNum, gamma);
+
+ return BadImplementation;
+}
diff --git a/xorg-server/hw/xfree86/ddc/Makefile.in b/xorg-server/hw/xfree86/ddc/Makefile.in
index 4db870280..63f59d0bb 100644
--- a/xorg-server/hw/xfree86/ddc/Makefile.in
+++ b/xorg-server/hw/xfree86/ddc/Makefile.in
@@ -150,6 +150,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -281,6 +282,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.in b/xorg-server/hw/xfree86/dixmods/Makefile.in
index 5b0de7102..5eac39515 100644
--- a/xorg-server/hw/xfree86/dixmods/Makefile.in
+++ b/xorg-server/hw/xfree86/dixmods/Makefile.in
@@ -238,6 +238,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -369,6 +370,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in
index 7ebcb66c5..a5817f798 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in
+++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in
@@ -158,6 +158,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -289,6 +290,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/doc/Makefile.in b/xorg-server/hw/xfree86/doc/Makefile.in
index fba837fca..02ed9da6b 100644
--- a/xorg-server/hw/xfree86/doc/Makefile.in
+++ b/xorg-server/hw/xfree86/doc/Makefile.in
@@ -138,6 +138,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -269,6 +270,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/doc/devel/Makefile.in b/xorg-server/hw/xfree86/doc/devel/Makefile.in
index 754c3f2d5..65790fba5 100644
--- a/xorg-server/hw/xfree86/doc/devel/Makefile.in
+++ b/xorg-server/hw/xfree86/doc/devel/Makefile.in
@@ -101,6 +101,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -232,6 +233,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/doc/man/Makefile.in b/xorg-server/hw/xfree86/doc/man/Makefile.in
index 61bb2cc5a..c8b984c06 100644
--- a/xorg-server/hw/xfree86/doc/man/Makefile.in
+++ b/xorg-server/hw/xfree86/doc/man/Makefile.in
@@ -127,6 +127,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -258,6 +259,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/doc/sgml/Makefile.in b/xorg-server/hw/xfree86/doc/sgml/Makefile.in
index 8f2b24e3f..41e45d7ca 100644
--- a/xorg-server/hw/xfree86/doc/sgml/Makefile.in
+++ b/xorg-server/hw/xfree86/doc/sgml/Makefile.in
@@ -121,6 +121,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -252,6 +253,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/dri/Makefile.in b/xorg-server/hw/xfree86/dri/Makefile.in
index 592bb760c..ecabb043c 100644
--- a/xorg-server/hw/xfree86/dri/Makefile.in
+++ b/xorg-server/hw/xfree86/dri/Makefile.in
@@ -153,6 +153,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -284,6 +285,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/dri2/Makefile.in b/xorg-server/hw/xfree86/dri2/Makefile.in
index ea77660c5..0e46951e8 100644
--- a/xorg-server/hw/xfree86/dri2/Makefile.in
+++ b/xorg-server/hw/xfree86/dri2/Makefile.in
@@ -152,6 +152,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -283,6 +284,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 787544c20..48618e1a5 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -1,934 +1,938 @@
-/*
- * Copyright © 2007, 2008 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 <errno.h>
-#include <xf86drm.h>
-#include "xf86Module.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "dixstruct.h"
-#include "dri2.h"
-#include "xf86VGAarbiter.h"
-
-#include "xf86.h"
-
-static int dri2ScreenPrivateKeyIndex;
-static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
-static int dri2WindowPrivateKeyIndex;
-static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
-static int dri2PixmapPrivateKeyIndex;
-static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
-
-typedef struct _DRI2Drawable {
- unsigned int refCount;
- int width;
- int height;
- DRI2BufferPtr *buffers;
- int bufferCount;
- unsigned int swapsPending;
- ClientPtr blockedClient;
- int swap_interval;
- CARD64 swap_count;
- CARD64 target_sbc; /* -1 means no SBC wait outstanding */
- CARD64 last_swap_target; /* most recently queued swap target */
- int swap_limit; /* for N-buffering */
-} DRI2DrawableRec, *DRI2DrawablePtr;
-
-typedef struct _DRI2Screen *DRI2ScreenPtr;
-
-typedef struct _DRI2Screen {
- unsigned int numDrivers;
- const char **driverNames;
- const char *deviceName;
- int fd;
- unsigned int lastSequence;
-
- DRI2CreateBufferProcPtr CreateBuffer;
- DRI2DestroyBufferProcPtr DestroyBuffer;
- DRI2CopyRegionProcPtr CopyRegion;
- DRI2ScheduleSwapProcPtr ScheduleSwap;
- DRI2GetMSCProcPtr GetMSC;
- DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-
- HandleExposuresProcPtr HandleExposures;
-} DRI2ScreenRec;
-
-static DRI2ScreenPtr
-DRI2GetScreen(ScreenPtr pScreen)
-{
- return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
-}
-
-static DRI2DrawablePtr
-DRI2GetDrawable(DrawablePtr pDraw)
-{
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- if (!pDraw)
- return NULL;
-
- if (pDraw->type == DRAWABLE_WINDOW)
- {
- pWin = (WindowPtr) pDraw;
- return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
- }
- else
- {
- pPixmap = (PixmapPtr) pDraw;
- return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
- }
-}
-
-int
-DRI2CreateDrawable(DrawablePtr pDraw)
-{
- WindowPtr pWin;
- PixmapPtr pPixmap;
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv != NULL)
- {
- pPriv->refCount++;
- return Success;
- }
-
- pPriv = xalloc(sizeof *pPriv);
- if (pPriv == NULL)
- return BadAlloc;
-
- pPriv->refCount = 1;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- pPriv->buffers = NULL;
- pPriv->bufferCount = 0;
- pPriv->swapsPending = 0;
- pPriv->blockedClient = NULL;
- pPriv->swap_count = 0;
- pPriv->target_sbc = -1;
- pPriv->swap_interval = 1;
- pPriv->last_swap_target = -1;
- pPriv->swap_limit = 1; /* default to double buffering */
-
- if (pDraw->type == DRAWABLE_WINDOW)
- {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
- }
- else
- {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
- }
-
- return Success;
-}
-
-static void
-DRI2FreeDrawable(DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- xfree(pPriv);
-
- if (pDraw->type == DRAWABLE_WINDOW)
- {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
- }
- else
- {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
- }
-}
-
-static int
-find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
-{
- int i;
-
- if (pPriv->buffers == NULL) {
- return -1;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if ((pPriv->buffers[i] != NULL)
- && (pPriv->buffers[i]->attachment == attachment)) {
- return i;
- }
- }
-
- return -1;
-}
-
-static DRI2BufferPtr
-allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
- DRI2DrawablePtr pPriv,
- unsigned int attachment, unsigned int format,
- int dimensions_match)
-{
- DRI2BufferPtr buffer;
- int old_buf;
-
- old_buf = find_attachment(pPriv, attachment);
-
- if ((old_buf < 0)
- || !dimensions_match
- || (pPriv->buffers[old_buf]->format != format)) {
- buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
- } else {
- buffer = pPriv->buffers[old_buf];
- pPriv->buffers[old_buf] = NULL;
- }
-
- return buffer;
-}
-
-static DRI2BufferPtr *
-do_get_buffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count,
- int has_format)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2BufferPtr *buffers;
- int need_real_front = 0;
- int need_fake_front = 0;
- int have_fake_front = 0;
- int front_format = 0;
- int dimensions_match;
- int i;
-
- if (!pPriv) {
- *width = pDraw->width;
- *height = pDraw->height;
- *out_count = 0;
- return NULL;
- }
-
- dimensions_match = (pDraw->width == pPriv->width)
- && (pDraw->height == pPriv->height);
-
- buffers = xalloc((count + 1) * sizeof(buffers[0]));
-
- for (i = 0; i < count; i++) {
- const unsigned attachment = *(attachments++);
- const unsigned format = (has_format) ? *(attachments++) : 0;
-
- buffers[i] = allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
- format, dimensions_match);
-
- /* If the drawable is a window and the front-buffer is requested,
- * silently add the fake front-buffer to the list of requested
- * attachments. The counting logic in the loop accounts for the case
- * where the client requests both the fake and real front-buffer.
- */
- if (attachment == DRI2BufferBackLeft) {
- need_real_front++;
- front_format = format;
- }
-
- if (attachment == DRI2BufferFrontLeft) {
- need_real_front--;
- front_format = format;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- need_fake_front++;
- }
- }
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- if (attachment == DRI2BufferFakeFrontLeft) {
- need_fake_front--;
- have_fake_front = 1;
- }
- }
- }
-
- if (need_real_front > 0) {
- buffers[i++] = allocate_or_reuse_buffer(pDraw, ds, pPriv,
- DRI2BufferFrontLeft,
- front_format, dimensions_match);
- }
-
- if (need_fake_front > 0) {
- buffers[i++] = allocate_or_reuse_buffer(pDraw, ds, pPriv,
- DRI2BufferFakeFrontLeft,
- front_format, dimensions_match);
- have_fake_front = 1;
- }
-
- *out_count = i;
-
-
- if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i] != NULL) {
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
- }
- }
-
- xfree(pPriv->buffers);
- }
-
- pPriv->buffers = buffers;
- pPriv->bufferCount = *out_count;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- *width = pPriv->width;
- *height = pPriv->height;
-
-
- /* If the client is getting a fake front-buffer, pre-fill it with the
- * contents of the real front-buffer. This ensures correct operation of
- * applications that call glXWaitX before calling glDrawBuffer.
- */
- if (have_fake_front) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pPriv->width;
- box.y2 = pPriv->height;
- REGION_INIT(pDraw->pScreen, &region, &box, 0);
-
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
- }
-
- return pPriv->buffers;
-}
-
-DRI2BufferPtr *
-DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, FALSE);
-}
-
-DRI2BufferPtr *
-DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, TRUE);
-}
-
-/*
- * In the direct rendered case, we throttle the clients that have more
- * than their share of outstanding swaps (and thus busy buffers) when a
- * new GetBuffers request is received. In the AIGLX case, we allow the
- * client to get the new buffers, but throttle when the next GLX request
- * comes in (see __glXDRIcontextWait()).
- */
-Bool
-DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return FALSE;
-
- /* Throttle to swap limit */
- if ((pPriv->swapsPending >= pPriv->swap_limit) &&
- !pPriv->blockedClient) {
- ResetCurrentRequest(client);
- client->sequence--;
- IgnoreClient(client);
- pPriv->blockedClient = client;
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- if (pPriv->blockedClient == NULL) {
- IgnoreClient(client);
- pPriv->blockedClient = client;
- }
-}
-
-int
-DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
- unsigned int dest, unsigned int src)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer, pSrcBuffer;
- int i;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- pDestBuffer = NULL;
- pSrcBuffer = NULL;
- for (i = 0; i < pPriv->bufferCount; i++)
- {
- if (pPriv->buffers[i]->attachment == dest)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == src)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL)
- return BadValue;
-
- (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
-
- return Success;
-}
-
-/* Can this drawable be page flipped? */
-Bool
-DRI2CanFlip(DrawablePtr pDraw)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- WindowPtr pWin, pRoot;
- PixmapPtr pWinPixmap, pRootPixmap;
-
- if (pDraw->type == DRAWABLE_PIXMAP)
- return TRUE;
-
- pRoot = WindowTable[pScreen->myNum];
- pRootPixmap = pScreen->GetWindowPixmap(pRoot);
-
- pWin = (WindowPtr) pDraw;
- pWinPixmap = pScreen->GetWindowPixmap(pWin);
- if (pRootPixmap != pWinPixmap)
- return FALSE;
- if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize))
- return FALSE;
-
- return TRUE;
-}
-
-/* Can we do a pixmap exchange instead of a blit? */
-Bool
-DRI2CanExchange(DrawablePtr pDraw)
-{
- return FALSE;
-}
-
-void
-DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
-
- if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
-
- pPriv->blockedClient = NULL;
-}
-
-static void
-DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- /*
- * Swap completed. Either wake up an SBC waiter or a client that was
- * blocked due to GLX activity during a swap.
- */
- if (pPriv->target_sbc != -1 &&
- pPriv->target_sbc >= pPriv->swap_count) {
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
- pPriv->target_sbc = -1;
-
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- } else if (pPriv->target_sbc == -1) {
- if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- }
-}
-
-void
-DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec, int type,
- DRI2SwapEventPtr swap_complete, void *swap_data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
- CARD64 ust = 0;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- if (pPriv->refCount == 0) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable refcount\n", __func__);
- DRI2FreeDrawable(pDraw);
- return;
- }
-
- ust = ((CARD64)tv_sec * 1000000) + tv_usec;
- if (swap_complete)
- swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
-
- pPriv->swapsPending--;
- pPriv->swap_count++;
-
- DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
-}
-
-Bool
-DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- /* If we're currently waiting for a swap on this drawable, reset
- * the request and suspend the client. We only support one
- * blocked client per drawable. */
- if ((pPriv->swapsPending) &&
- pPriv->blockedClient == NULL) {
- ResetCurrentRequest(client);
- client->sequence--;
- DRI2BlockClient(client, pDrawable);
- return TRUE;
- }
-
- return FALSE;
-}
-
-int
-DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
- DRI2SwapEventPtr func, void *data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
- CARD64 ust;
- int ret, i;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: drawable has no back or front?\n", __func__);
- return BadDrawable;
- }
-
- /* Old DDX, just blit */
- if (!ds->ScheduleSwap) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- REGION_INIT(pScreen, &region, &box, 0);
-
- pPriv->swapsPending++;
-
- (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
- DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
- func, data);
- return Success;
- }
-
- /*
- * In the simple glXSwapBuffers case, all params will be 0, and we just
- * need to schedule a swap for the last swap target + the swap interval.
- * If the last swap target hasn't been set yet, call into the driver
- * to get the current count.
- */
- if (target_msc == 0 && divisor == 0 && remainder == 0 &&
- pPriv->last_swap_target < 0) {
- ret = (*ds->GetMSC)(pDraw, &ust, &target_msc);
- if (!ret) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: driver failed to return current MSC\n",
- __func__);
- return BadDrawable;
- }
- }
-
- /* First swap needs to initialize last_swap_target */
- if (pPriv->last_swap_target < 0)
- pPriv->last_swap_target = target_msc;
-
- /*
- * Swap target for this swap is last swap target + swap interval since
- * we have to account for the current swap count, interval, and the
- * number of pending swaps.
- */
- *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
-
- ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
- swap_target, divisor, remainder, func, data);
- if (!ret) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: driver failed to schedule swap\n", __func__);
- return BadDrawable;
- }
-
- pPriv->swapsPending++;
- pPriv->last_swap_target = *swap_target;
-
- return Success;
-}
-
-void
-DRI2SwapInterval(DrawablePtr pDrawable, int interval)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- /* fixme: check against arbitrary max? */
-
- pPriv->swap_interval = interval;
-}
-
-int
-DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- if (!ds->GetMSC) {
- *ust = 0;
- *msc = 0;
- *sbc = pPriv->swap_count;
- return Success;
- }
-
- /*
- * Spec needs to be updated to include unmapped or redirected
- * drawables
- */
-
- ret = (*ds->GetMSC)(pDraw, ust, msc);
- if (!ret)
- return BadDrawable;
-
- *sbc = pPriv->swap_count;
-
- return Success;
-}
-
-int
-DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- /* Old DDX just completes immediately */
- if (!ds->ScheduleWaitMSC) {
- DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
-
- return Success;
- }
-
- ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
- if (!ret)
- return BadDrawable;
-
- return Success;
-}
-
-int
-DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
- CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- if (pPriv->swap_count >= target_sbc)
- return Success;
-
- pPriv->target_sbc = target_sbc;
- DRI2BlockClient(client, pDraw);
-
- return Success;
-}
-
-void
-DRI2DestroyDrawable(DrawablePtr pDraw)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- pPriv->refCount--;
- if (pPriv->refCount > 0)
- return;
-
- if (pPriv->buffers != NULL) {
- int i;
-
- for (i = 0; i < pPriv->bufferCount; i++)
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
-
- xfree(pPriv->buffers);
- }
-
- /* If the window is destroyed while we have a swap pending, don't
- * actually free the priv yet. We'll need it in the DRI2SwapComplete()
- * callback and we'll free it there once we're done. */
- if (!pPriv->swapsPending)
- DRI2FreeDrawable(pDraw);
-}
-
-Bool
-DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
- const char **driverName, const char **deviceName)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- if (ds == NULL || driverType >= ds->numDrivers ||
- !ds->driverNames[driverType])
- return FALSE;
-
- *fd = ds->fd;
- *driverName = ds->driverNames[driverType];
- *deviceName = ds->deviceName;
-
- return TRUE;
-}
-
-Bool
-DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- if (ds == NULL || drmAuthMagic(ds->fd, magic))
- return FALSE;
-
- return TRUE;
-}
-
-Bool
-DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
-{
- DRI2ScreenPtr ds;
- const char* driverTypeNames[] = {
- "DRI", /* DRI2DriverDRI */
- "VDPAU", /* DRI2DriverVDPAU */
- };
- unsigned int i;
-
- if (info->version < 3)
- return FALSE;
-
- if (!xf86VGAarbiterAllowDRI(pScreen)) {
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
- return FALSE;
- }
-
- ds = xcalloc(1, sizeof *ds);
- if (!ds)
- return FALSE;
-
- ds->fd = info->fd;
- ds->deviceName = info->deviceName;
-
- ds->CreateBuffer = info->CreateBuffer;
- ds->DestroyBuffer = info->DestroyBuffer;
- ds->CopyRegion = info->CopyRegion;
-
- if (info->version >= 4) {
- ds->ScheduleSwap = info->ScheduleSwap;
- ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
- ds->GetMSC = info->GetMSC;
- }
-
- if (info->version == 3 || info->numDrivers == 0) {
- /* Driver too old: use the old-style driverName field */
- ds->numDrivers = 1;
- ds->driverNames = xalloc(sizeof(*ds->driverNames));
- if (!ds->driverNames) {
- xfree(ds);
- return FALSE;
- }
- ds->driverNames[0] = info->driverName;
- } else {
- ds->numDrivers = info->numDrivers;
- ds->driverNames = xalloc(info->numDrivers * sizeof(*ds->driverNames));
- if (!ds->driverNames) {
- xfree(ds);
- return FALSE;
- }
- memcpy(ds->driverNames, info->driverNames,
- info->numDrivers * sizeof(*ds->driverNames));
- }
-
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
-
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
- for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
- if (i < ds->numDrivers && ds->driverNames[i]) {
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
- driverTypeNames[i], ds->driverNames[i]);
- }
- }
-
- return TRUE;
-}
-
-void
-DRI2CloseScreen(ScreenPtr pScreen)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- xfree(ds->driverNames);
- xfree(ds);
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
-}
-
-extern ExtensionModule dri2ExtensionModule;
-
-static pointer
-DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- static Bool setupDone = FALSE;
-
- if (!setupDone)
- {
- setupDone = TRUE;
- LoadExtension(&dri2ExtensionModule, FALSE);
- }
- else
- {
- if (errmaj)
- *errmaj = LDR_ONCEONLY;
- }
-
- return (pointer) 1;
-}
-
-static XF86ModuleVersionInfo DRI2VersRec =
-{
- "dri2",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 2, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- { 0, 0, 0, 0 }
-};
-
-_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
-
-void
-DRI2Version(int *major, int *minor)
-{
- if (major != NULL)
- *major = DRI2VersRec.majorversion;
-
- if (minor != NULL)
- *minor = DRI2VersRec.minorversion;
-}
+/*
+ * Copyright © 2007, 2008 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 <errno.h>
+#include <xf86drm.h>
+#include "xf86Module.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "dri2.h"
+#include "xf86VGAarbiter.h"
+
+#include "xf86.h"
+
+static int dri2ScreenPrivateKeyIndex;
+static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
+static int dri2WindowPrivateKeyIndex;
+static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
+static int dri2PixmapPrivateKeyIndex;
+static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
+
+typedef struct _DRI2Drawable {
+ unsigned int refCount;
+ int width;
+ int height;
+ DRI2BufferPtr *buffers;
+ int bufferCount;
+ unsigned int swapsPending;
+ ClientPtr blockedClient;
+ int swap_interval;
+ CARD64 swap_count;
+ CARD64 target_sbc; /* -1 means no SBC wait outstanding */
+ CARD64 last_swap_target; /* most recently queued swap target */
+ int swap_limit; /* for N-buffering */
+} DRI2DrawableRec, *DRI2DrawablePtr;
+
+typedef struct _DRI2Screen *DRI2ScreenPtr;
+
+typedef struct _DRI2Screen {
+ unsigned int numDrivers;
+ const char **driverNames;
+ const char *deviceName;
+ int fd;
+ unsigned int lastSequence;
+
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+
+ HandleExposuresProcPtr HandleExposures;
+} DRI2ScreenRec;
+
+static DRI2ScreenPtr
+DRI2GetScreen(ScreenPtr pScreen)
+{
+ return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
+}
+
+static DRI2DrawablePtr
+DRI2GetDrawable(DrawablePtr pDraw)
+{
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ if (!pDraw)
+ return NULL;
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ {
+ pWin = (WindowPtr) pDraw;
+ return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+ }
+ else
+ {
+ pPixmap = (PixmapPtr) pDraw;
+ return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ }
+}
+
+int
+DRI2CreateDrawable(DrawablePtr pDraw)
+{
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv != NULL)
+ {
+ pPriv->refCount++;
+ return Success;
+ }
+
+ pPriv = xalloc(sizeof *pPriv);
+ if (pPriv == NULL)
+ return BadAlloc;
+
+ pPriv->refCount = 1;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ pPriv->buffers = NULL;
+ pPriv->bufferCount = 0;
+ pPriv->swapsPending = 0;
+ pPriv->blockedClient = NULL;
+ pPriv->swap_count = 0;
+ pPriv->target_sbc = -1;
+ pPriv->swap_interval = 1;
+ pPriv->last_swap_target = -1;
+ pPriv->swap_limit = 1; /* default to double buffering */
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+ }
+ else
+ {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+ }
+
+ return Success;
+}
+
+static void
+DRI2FreeDrawable(DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ xfree(pPriv);
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
+ }
+ else
+ {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
+ }
+}
+
+static int
+find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
+{
+ int i;
+
+ if (pPriv->buffers == NULL) {
+ return -1;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if ((pPriv->buffers[i] != NULL)
+ && (pPriv->buffers[i]->attachment == attachment)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static Bool
+allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
+ DRI2DrawablePtr pPriv,
+ unsigned int attachment, unsigned int format,
+ int dimensions_match, DRI2BufferPtr *buffer)
+{
+ int old_buf = find_attachment(pPriv, attachment);
+
+ if ((old_buf < 0)
+ || !dimensions_match
+ || (pPriv->buffers[old_buf]->format != format)) {
+ *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
+ return TRUE;
+
+ } else {
+ *buffer = pPriv->buffers[old_buf];
+ pPriv->buffers[old_buf] = NULL;
+ return FALSE;
+ }
+}
+
+static DRI2BufferPtr *
+do_get_buffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count,
+ int has_format)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2BufferPtr *buffers;
+ int need_real_front = 0;
+ int need_fake_front = 0;
+ int have_fake_front = 0;
+ int front_format = 0;
+ int dimensions_match;
+ int buffers_changed = 0;
+ int i;
+
+ if (!pPriv) {
+ *width = pDraw->width;
+ *height = pDraw->height;
+ *out_count = 0;
+ return NULL;
+ }
+
+ dimensions_match = (pDraw->width == pPriv->width)
+ && (pDraw->height == pPriv->height);
+
+ buffers = xalloc((count + 1) * sizeof(buffers[0]));
+
+ for (i = 0; i < count; i++) {
+ const unsigned attachment = *(attachments++);
+ const unsigned format = (has_format) ? *(attachments++) : 0;
+
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
+ format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ /* If the drawable is a window and the front-buffer is requested,
+ * silently add the fake front-buffer to the list of requested
+ * attachments. The counting logic in the loop accounts for the case
+ * where the client requests both the fake and real front-buffer.
+ */
+ if (attachment == DRI2BufferBackLeft) {
+ need_real_front++;
+ front_format = format;
+ }
+
+ if (attachment == DRI2BufferFrontLeft) {
+ need_real_front--;
+ front_format = format;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ need_fake_front++;
+ }
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ if (attachment == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ have_fake_front = 1;
+ }
+ }
+ }
+
+ if (need_real_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i++]))
+ buffers_changed = 1;
+ }
+
+ if (need_fake_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i++]))
+ buffers_changed = 1;
+
+ have_fake_front = 1;
+ }
+
+ *out_count = i;
+
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i] != NULL) {
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+ }
+ }
+
+ xfree(pPriv->buffers);
+ }
+
+ pPriv->buffers = buffers;
+ pPriv->bufferCount = *out_count;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ *width = pPriv->width;
+ *height = pPriv->height;
+
+
+ /* If the client is getting a fake front-buffer, pre-fill it with the
+ * contents of the real front-buffer. This ensures correct operation of
+ * applications that call glXWaitX before calling glDrawBuffer.
+ */
+ if (have_fake_front && buffers_changed) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pPriv->width;
+ box.y2 = pPriv->height;
+ REGION_INIT(pDraw->pScreen, &region, &box, 0);
+
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+ }
+
+ return pPriv->buffers;
+}
+
+DRI2BufferPtr *
+DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, FALSE);
+}
+
+DRI2BufferPtr *
+DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, TRUE);
+}
+
+/*
+ * In the direct rendered case, we throttle the clients that have more
+ * than their share of outstanding swaps (and thus busy buffers) when a
+ * new GetBuffers request is received. In the AIGLX case, we allow the
+ * client to get the new buffers, but throttle when the next GLX request
+ * comes in (see __glXDRIcontextWait()).
+ */
+Bool
+DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return FALSE;
+
+ /* Throttle to swap limit */
+ if ((pPriv->swapsPending >= pPriv->swap_limit) &&
+ !pPriv->blockedClient) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ if (pPriv->blockedClient == NULL) {
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ }
+}
+
+int
+DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
+ unsigned int dest, unsigned int src)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ pDestBuffer = NULL;
+ pSrcBuffer = NULL;
+ for (i = 0; i < pPriv->bufferCount; i++)
+ {
+ if (pPriv->buffers[i]->attachment == dest)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == src)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL)
+ return BadValue;
+
+ (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
+
+ return Success;
+}
+
+/* Can this drawable be page flipped? */
+Bool
+DRI2CanFlip(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ WindowPtr pWin, pRoot;
+ PixmapPtr pWinPixmap, pRootPixmap;
+
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ return TRUE;
+
+ pRoot = WindowTable[pScreen->myNum];
+ pRootPixmap = pScreen->GetWindowPixmap(pRoot);
+
+ pWin = (WindowPtr) pDraw;
+ pWinPixmap = pScreen->GetWindowPixmap(pWin);
+ if (pRootPixmap != pWinPixmap)
+ return FALSE;
+ if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Can we do a pixmap exchange instead of a blit? */
+Bool
+DRI2CanExchange(DrawablePtr pDraw)
+{
+ return FALSE;
+}
+
+void
+DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+
+ if (pPriv->blockedClient)
+ AttendClient(pPriv->blockedClient);
+
+ pPriv->blockedClient = NULL;
+}
+
+static void
+DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /*
+ * Swap completed. Either wake up an SBC waiter or a client that was
+ * blocked due to GLX activity during a swap.
+ */
+ if (pPriv->target_sbc != -1 &&
+ pPriv->target_sbc >= pPriv->swap_count) {
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+ pPriv->target_sbc = -1;
+
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ } else if (pPriv->target_sbc == -1) {
+ if (pPriv->blockedClient)
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
+}
+
+void
+DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete, void *swap_data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+ CARD64 ust = 0;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ if (pPriv->refCount == 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable refcount\n", __func__);
+ DRI2FreeDrawable(pDraw);
+ return;
+ }
+
+ ust = ((CARD64)tv_sec * 1000000) + tv_usec;
+ if (swap_complete)
+ swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
+
+ pPriv->swapsPending--;
+ pPriv->swap_count++;
+
+ DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+}
+
+Bool
+DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ /* If we're currently waiting for a swap on this drawable, reset
+ * the request and suspend the client. We only support one
+ * blocked client per drawable. */
+ if ((pPriv->swapsPending) &&
+ pPriv->blockedClient == NULL) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ DRI2BlockClient(client, pDrawable);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int
+DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
+ DRI2SwapEventPtr func, void *data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
+ CARD64 ust;
+ int ret, i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: drawable has no back or front?\n", __func__);
+ return BadDrawable;
+ }
+
+ /* Old DDX, just blit */
+ if (!ds->ScheduleSwap) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ REGION_INIT(pScreen, &region, &box, 0);
+
+ pPriv->swapsPending++;
+
+ (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
+ func, data);
+ return Success;
+ }
+
+ /*
+ * In the simple glXSwapBuffers case, all params will be 0, and we just
+ * need to schedule a swap for the last swap target + the swap interval.
+ * If the last swap target hasn't been set yet, call into the driver
+ * to get the current count.
+ */
+ if (target_msc == 0 && divisor == 0 && remainder == 0 &&
+ pPriv->last_swap_target < 0) {
+ ret = (*ds->GetMSC)(pDraw, &ust, &target_msc);
+ if (!ret) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: driver failed to return current MSC\n",
+ __func__);
+ return BadDrawable;
+ }
+ }
+
+ /* First swap needs to initialize last_swap_target */
+ if (pPriv->last_swap_target < 0)
+ pPriv->last_swap_target = target_msc;
+
+ /*
+ * Swap target for this swap is last swap target + swap interval since
+ * we have to account for the current swap count, interval, and the
+ * number of pending swaps.
+ */
+ *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+
+ ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
+ swap_target, divisor, remainder, func, data);
+ if (!ret) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: driver failed to schedule swap\n", __func__);
+ return BadDrawable;
+ }
+
+ pPriv->swapsPending++;
+ pPriv->last_swap_target = *swap_target;
+
+ return Success;
+}
+
+void
+DRI2SwapInterval(DrawablePtr pDrawable, int interval)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ /* fixme: check against arbitrary max? */
+
+ pPriv->swap_interval = interval;
+}
+
+int
+DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ if (!ds->GetMSC) {
+ *ust = 0;
+ *msc = 0;
+ *sbc = pPriv->swap_count;
+ return Success;
+ }
+
+ /*
+ * Spec needs to be updated to include unmapped or redirected
+ * drawables
+ */
+
+ ret = (*ds->GetMSC)(pDraw, ust, msc);
+ if (!ret)
+ return BadDrawable;
+
+ *sbc = pPriv->swap_count;
+
+ return Success;
+}
+
+int
+DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* Old DDX just completes immediately */
+ if (!ds->ScheduleWaitMSC) {
+ DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
+
+ return Success;
+ }
+
+ ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
+ if (!ret)
+ return BadDrawable;
+
+ return Success;
+}
+
+int
+DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
+ CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ if (pPriv->swap_count >= target_sbc)
+ return Success;
+
+ pPriv->target_sbc = target_sbc;
+ DRI2BlockClient(client, pDraw);
+
+ return Success;
+}
+
+void
+DRI2DestroyDrawable(DrawablePtr pDraw)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ pPriv->refCount--;
+ if (pPriv->refCount > 0)
+ return;
+
+ if (pPriv->buffers != NULL) {
+ int i;
+
+ for (i = 0; i < pPriv->bufferCount; i++)
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+
+ xfree(pPriv->buffers);
+ }
+
+ /* If the window is destroyed while we have a swap pending, don't
+ * actually free the priv yet. We'll need it in the DRI2SwapComplete()
+ * callback and we'll free it there once we're done. */
+ if (!pPriv->swapsPending)
+ DRI2FreeDrawable(pDraw);
+}
+
+Bool
+DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
+ const char **driverName, const char **deviceName)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || driverType >= ds->numDrivers ||
+ !ds->driverNames[driverType])
+ return FALSE;
+
+ *fd = ds->fd;
+ *driverName = ds->driverNames[driverType];
+ *deviceName = ds->deviceName;
+
+ return TRUE;
+}
+
+Bool
+DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || drmAuthMagic(ds->fd, magic))
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+ DRI2ScreenPtr ds;
+ const char* driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
+ };
+ unsigned int i;
+
+ if (info->version < 3)
+ return FALSE;
+
+ if (!xf86VGAarbiterAllowDRI(pScreen)) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
+ return FALSE;
+ }
+
+ ds = xcalloc(1, sizeof *ds);
+ if (!ds)
+ return FALSE;
+
+ ds->fd = info->fd;
+ ds->deviceName = info->deviceName;
+
+ ds->CreateBuffer = info->CreateBuffer;
+ ds->DestroyBuffer = info->DestroyBuffer;
+ ds->CopyRegion = info->CopyRegion;
+
+ if (info->version >= 4) {
+ ds->ScheduleSwap = info->ScheduleSwap;
+ ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
+ ds->GetMSC = info->GetMSC;
+ }
+
+ if (info->version == 3 || info->numDrivers == 0) {
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = xalloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames) {
+ xfree(ds);
+ return FALSE;
+ }
+ ds->driverNames[0] = info->driverName;
+ } else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = xalloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames) {
+ xfree(ds);
+ return FALSE;
+ }
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
+ for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
+ }
+
+ return TRUE;
+}
+
+void
+DRI2CloseScreen(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ xfree(ds->driverNames);
+ xfree(ds);
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
+}
+
+extern ExtensionModule dri2ExtensionModule;
+
+static pointer
+DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+ LoadExtension(&dri2ExtensionModule, FALSE);
+ }
+ else
+ {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ }
+
+ return (pointer) 1;
+}
+
+static XF86ModuleVersionInfo DRI2VersRec =
+{
+ "dri2",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 2, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ { 0, 0, 0, 0 }
+};
+
+_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
+
+void
+DRI2Version(int *major, int *minor)
+{
+ if (major != NULL)
+ *major = DRI2VersRec.majorversion;
+
+ if (minor != NULL)
+ *minor = DRI2VersRec.minorversion;
+}
diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c
index 3e6b03e4e..bd92fd304 100644
--- a/xorg-server/hw/xfree86/dri2/dri2ext.c
+++ b/xorg-server/hw/xfree86/dri2/dri2ext.c
@@ -353,10 +353,12 @@ DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc,
CARD64 sbc)
{
xDRI2BufferSwapComplete event;
+ DrawablePtr pDrawable = data;
event.type = DRI2EventBase + DRI2_BufferSwapComplete;
event.sequenceNumber = client->sequence;
event.event_type = type;
+ event.drawable = pDrawable->id;
event.ust_hi = (CARD64)ust >> 32;
event.ust_lo = ust & 0xffffffff;
event.msc_hi = (CARD64)msc >> 32;
diff --git a/xorg-server/hw/xfree86/exa/Makefile.in b/xorg-server/hw/xfree86/exa/Makefile.in
index b3eb780d4..22c176a08 100644
--- a/xorg-server/hw/xfree86/exa/Makefile.in
+++ b/xorg-server/hw/xfree86/exa/Makefile.in
@@ -156,6 +156,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -287,6 +288,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.in b/xorg-server/hw/xfree86/fbdevhw/Makefile.in
index 3ededbb5c..207d083b7 100644
--- a/xorg-server/hw/xfree86/fbdevhw/Makefile.in
+++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.in
@@ -161,6 +161,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -292,6 +293,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/i2c/Makefile.in b/xorg-server/hw/xfree86/i2c/Makefile.in
index 9b93a76e2..2850c0f42 100644
--- a/xorg-server/hw/xfree86/i2c/Makefile.in
+++ b/xorg-server/hw/xfree86/i2c/Makefile.in
@@ -202,6 +202,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -333,6 +334,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/int10/Makefile.in b/xorg-server/hw/xfree86/int10/Makefile.in
index 51c81e1e1..04a42eebc 100644
--- a/xorg-server/hw/xfree86/int10/Makefile.in
+++ b/xorg-server/hw/xfree86/int10/Makefile.in
@@ -166,6 +166,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -297,6 +298,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/loader/Makefile.in b/xorg-server/hw/xfree86/loader/Makefile.in
index 807676bf4..37726d5dc 100644
--- a/xorg-server/hw/xfree86/loader/Makefile.in
+++ b/xorg-server/hw/xfree86/loader/Makefile.in
@@ -126,6 +126,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -257,6 +258,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/loader/sdksyms.c b/xorg-server/hw/xfree86/loader/sdksyms.c
index 66eb840cf..ade24a12d 100644
--- a/xorg-server/hw/xfree86/loader/sdksyms.c
+++ b/xorg-server/hw/xfree86/loader/sdksyms.c
@@ -390,6 +390,7 @@ _X_HIDDEN void *xorg_symbols[] = {
(void *) &OsVendorInit,
(void *) &OsBlockSignals,
(void *) &OsReleaseSignals,
+ (void *) &OsAbort,
(void *) &System,
(void *) &Popen,
(void *) &Pclose,
@@ -593,6 +594,7 @@ _X_HIDDEN void *xorg_symbols[] = {
(void *) &LegalModifier,
(void *) &ProcessInputEvents,
(void *) &InitInput,
+ (void *) &CloseInput,
(void *) &GetMaximumEventsNum,
(void *) &GetEventList,
(void *) &InitEventList,
@@ -1660,6 +1662,7 @@ _X_HIDDEN void *xorg_symbols[] = {
(void *) &xf86QueryLargestOffscreenArea,
(void *) &xf86QueryLargestOffscreenLinear,
(void *) &inputInfo,
+ (void *) &syncEvents,
(void *) &CloseInputDevice,
(void *) &AddOtherInputDevices,
(void *) &OpenInputDevice,
diff --git a/xorg-server/hw/xfree86/modes/Makefile.in b/xorg-server/hw/xfree86/modes/Makefile.in
index 62ce86e1c..ad64acf56 100644
--- a/xorg-server/hw/xfree86/modes/Makefile.in
+++ b/xorg-server/hw/xfree86/modes/Makefile.in
@@ -156,6 +156,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -287,6 +288,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index 9b1ff280b..860e520ad 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -1495,12 +1495,16 @@ GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
mon->vrefresh[0].lo = 58.0;
}
+enum det_monrec_source {
+ sync_config, sync_edid, sync_default
+};
+
struct det_monrec_parameter {
MonRec *mon_rec;
int *max_clock;
Bool set_hsync;
Bool set_vrefresh;
- enum { sync_config, sync_edid, sync_default } *sync_source;
+ enum det_monrec_source *sync_source;
};
static void handle_detailed_monrec(struct detailed_monitor_section *det_mon,
@@ -1563,7 +1567,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
Bool add_default_modes = TRUE;
Bool debug_modes = config->debug_modes ||
xf86Initialising;
- enum { sync_config, sync_edid, sync_default } sync_source = sync_default;
+ enum det_monrec_source sync_source = sync_default;
while (output->probed_modes != NULL)
xf86DeleteMode(&output->probed_modes, output->probed_modes);
@@ -2591,8 +2595,8 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
if (!crtc->enabled)
continue;
- if (config->output[config->compat_output]->crtc == crtc)
- output = config->output[config->compat_output];
+ if (xf86CompatOutput(scrn) && xf86CompatCrtc(scrn) == crtc)
+ output = xf86CompatOutput(scrn);
else
{
for (o = 0; o < config->num_output; o++)
@@ -2712,14 +2716,16 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
Bool ok = TRUE;
- xf86OutputPtr compat_output = config->output[config->compat_output];
- DisplayModePtr compat_mode;
+ xf86OutputPtr compat_output;
+ DisplayModePtr compat_mode = NULL;
int c;
/*
* Let the compat output drive the final mode selection
*/
- compat_mode = xf86OutputFindClosestMode (compat_output, desired);
+ compat_output = xf86CompatOutput(pScrn);
+ if (compat_output)
+ compat_mode = xf86OutputFindClosestMode (compat_output, desired);
if (compat_mode)
desired = compat_mode;
@@ -2943,7 +2949,7 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
}
/* Set the DDC properties for the 'compat' output */
- if (output == config->output[config->compat_output])
+ if (output == xf86CompatOutput(scrn))
xf86SetDDCproperties(scrn, edid_mon);
#ifdef RANDR_12_INTERFACE
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index 9baa956a3..68a968cc2 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -689,6 +689,32 @@ extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
+static _X_INLINE xf86OutputPtr
+xf86CompatOutput(ScrnInfoPtr pScrn)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ return config->output[config->compat_output];
+}
+
+static _X_INLINE xf86CrtcPtr
+xf86CompatCrtc(ScrnInfoPtr pScrn)
+{
+ xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+ if (!compat_output)
+ return NULL;
+ return compat_output->crtc;
+}
+
+static _X_INLINE RRCrtcPtr
+xf86CompatRRCrtc(ScrnInfoPtr pScrn)
+{
+ xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
+ if (!compat_crtc)
+ return NULL;
+ return compat_crtc->randr_crtc;
+}
+
+
/*
* Initialize xf86CrtcConfig structure
*/
diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c
index 385848b7a..e2e174e59 100644
--- a/xorg-server/hw/xfree86/modes/xf86Cursors.c
+++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c
@@ -461,11 +461,11 @@ xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ ++cursor->refcnt;
if (xf86_config->cursor)
FreeCursor (xf86_config->cursor, None);
xf86_config->cursor = cursor;
- ++cursor->refcnt;
-
+
if (cursor->bits->width > cursor_info->MaxWidth ||
cursor->bits->height> cursor_info->MaxHeight)
return FALSE;
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index 1fc63c4dc..7ba09b6fe 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -805,9 +805,10 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
}
else
{
- xf86OutputPtr output = config->output[config->compat_output];
+ xf86OutputPtr output = xf86CompatOutput(pScrn);
- if (output->conf_monitor &&
+ if (output &&
+ output->conf_monitor &&
(output->conf_monitor->mon_width > 0 &&
output->conf_monitor->mon_height > 0))
{
@@ -1719,10 +1720,13 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
{
CARD16 *points, *red, *green, *blue;
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
- int size = max(0, crtc->gammaSize);
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+ int size;
+ if (!crtc)
+ return Success;
+
+ size = max(0, crtc->gammaSize);
if (!size)
return Success;
diff --git a/xorg-server/hw/xfree86/os-support/Makefile.in b/xorg-server/hw/xfree86/os-support/Makefile.in
index fa650625b..7899c0909 100644
--- a/xorg-server/hw/xfree86/os-support/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/Makefile.in
@@ -187,6 +187,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -318,6 +319,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.in b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in
index 74bf6456c..f218ed9ea 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in
@@ -150,6 +150,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -281,6 +282,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/bus/Makefile.in b/xorg-server/hw/xfree86/os-support/bus/Makefile.in
index baad9df02..b81101e36 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/bus/Makefile.in
@@ -158,6 +158,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -289,6 +290,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/hurd/Makefile.in b/xorg-server/hw/xfree86/os-support/hurd/Makefile.in
index 06d32f0ab..fe16508f3 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/hurd/Makefile.in
@@ -126,6 +126,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -257,6 +258,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.in b/xorg-server/hw/xfree86/os-support/linux/Makefile.in
index 8758a6eea..446af9ba4 100644
--- a/xorg-server/hw/xfree86/os-support/linux/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.in
@@ -151,6 +151,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -282,6 +283,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/misc/Makefile.in b/xorg-server/hw/xfree86/os-support/misc/Makefile.in
index 31c246b36..106cf4b96 100644
--- a/xorg-server/hw/xfree86/os-support/misc/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/misc/Makefile.in
@@ -124,6 +124,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -255,6 +256,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/sco/Makefile.in b/xorg-server/hw/xfree86/os-support/sco/Makefile.in
index ef97c1e13..85304ea42 100644
--- a/xorg-server/hw/xfree86/os-support/sco/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/sco/Makefile.in
@@ -98,6 +98,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -229,6 +230,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/solaris/Makefile.in b/xorg-server/hw/xfree86/os-support/solaris/Makefile.in
index 03946bcb1..d895b0f3c 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/solaris/Makefile.in
@@ -173,6 +173,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -304,6 +305,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/os-support/sysv/Makefile.in b/xorg-server/hw/xfree86/os-support/sysv/Makefile.in
index a5e8a1bf9..58c3e40d8 100644
--- a/xorg-server/hw/xfree86/os-support/sysv/Makefile.in
+++ b/xorg-server/hw/xfree86/os-support/sysv/Makefile.in
@@ -98,6 +98,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -229,6 +230,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/parser/Makefile.in b/xorg-server/hw/xfree86/parser/Makefile.in
index 1b31c622d..e4a5e8aa4 100644
--- a/xorg-server/hw/xfree86/parser/Makefile.in
+++ b/xorg-server/hw/xfree86/parser/Makefile.in
@@ -182,6 +182,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -313,6 +314,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/ramdac/Makefile.in b/xorg-server/hw/xfree86/ramdac/Makefile.in
index a1b5a3c37..c3e8e893a 100644
--- a/xorg-server/hw/xfree86/ramdac/Makefile.in
+++ b/xorg-server/hw/xfree86/ramdac/Makefile.in
@@ -150,6 +150,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -281,6 +282,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
index 6b71f4677..7f23d9ef3 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
@@ -129,6 +129,9 @@ xf86CursorCloseScreen(int i, ScreenPtr pScreen)
if (ScreenPriv->isUp && pScrn->vtSema)
xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
+
pScreen->CloseScreen = ScreenPriv->CloseScreen;
pScreen->QueryBestSize = ScreenPriv->QueryBestSize;
pScreen->RecolorCursor = ScreenPriv->RecolorCursor;
@@ -317,6 +320,9 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
if (pDev == inputInfo.pointer ||
(!IsMaster(pDev) && pDev->u.master == inputInfo.pointer))
{
+ pCurs->refcnt++;
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
ScreenPriv->CurrentCursor = pCurs;
ScreenPriv->x = x;
ScreenPriv->y = y;
diff --git a/xorg-server/hw/xfree86/shadowfb/Makefile.in b/xorg-server/hw/xfree86/shadowfb/Makefile.in
index 1bdd31c55..5bae8c586 100644
--- a/xorg-server/hw/xfree86/shadowfb/Makefile.in
+++ b/xorg-server/hw/xfree86/shadowfb/Makefile.in
@@ -153,6 +153,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -284,6 +285,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/utils/Makefile.in b/xorg-server/hw/xfree86/utils/Makefile.in
index d882aed24..714adea6e 100644
--- a/xorg-server/hw/xfree86/utils/Makefile.in
+++ b/xorg-server/hw/xfree86/utils/Makefile.in
@@ -138,6 +138,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -269,6 +270,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/utils/cvt/Makefile.in b/xorg-server/hw/xfree86/utils/cvt/Makefile.in
index 8a865b245..e270da0d2 100644
--- a/xorg-server/hw/xfree86/utils/cvt/Makefile.in
+++ b/xorg-server/hw/xfree86/utils/cvt/Makefile.in
@@ -180,6 +180,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -311,6 +312,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/utils/gtf/Makefile.in b/xorg-server/hw/xfree86/utils/gtf/Makefile.in
index 24fba799b..0d92df052 100644
--- a/xorg-server/hw/xfree86/utils/gtf/Makefile.in
+++ b/xorg-server/hw/xfree86/utils/gtf/Makefile.in
@@ -179,6 +179,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -310,6 +311,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = sed
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/vbe/Makefile.in b/xorg-server/hw/xfree86/vbe/Makefile.in
index 74c500562..02ff89807 100644
--- a/xorg-server/hw/xfree86/vbe/Makefile.in
+++ b/xorg-server/hw/xfree86/vbe/Makefile.in
@@ -152,6 +152,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -283,6 +284,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/vgahw/Makefile.in b/xorg-server/hw/xfree86/vgahw/Makefile.in
index e6d74eb33..06c88aef6 100644
--- a/xorg-server/hw/xfree86/vgahw/Makefile.in
+++ b/xorg-server/hw/xfree86/vgahw/Makefile.in
@@ -152,6 +152,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -283,6 +284,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/x86emu/Makefile.in b/xorg-server/hw/xfree86/x86emu/Makefile.in
index b05b1539e..776232047 100644
--- a/xorg-server/hw/xfree86/x86emu/Makefile.in
+++ b/xorg-server/hw/xfree86/x86emu/Makefile.in
@@ -126,6 +126,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -257,6 +258,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/x86emu/sys.c b/xorg-server/hw/xfree86/x86emu/sys.c
index e15fb0931..602b0bbee 100644
--- a/xorg-server/hw/xfree86/x86emu/sys.c
+++ b/xorg-server/hw/xfree86/x86emu/sys.c
@@ -48,168 +48,104 @@
#ifndef NO_SYS_HEADERS
#include <string.h>
#endif
-/*------------------------- Global Variables ------------------------------*/
-X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
-X86EMU_intrFuncs _X86EMU_intrTab[256];
+# ifndef NO_INLINE
+# ifdef __GNUC__
-/*----------------------------- Implementation ----------------------------*/
-#if defined(__alpha__) || defined(__alpha)
-/* to cope with broken egcs-1.1.2 :-(((( */
-
-#define ALPHA_UALOADS
-/*
- * inline functions to do unaligned accesses
- * from linux/include/asm-alpha/unaligned.h
- */
-
-/*
- * EGCS 1.1 knows about arbitrary unaligned loads. Define some
- * packed structures to talk about such things with.
- */
-
-#if defined(__GNUC__)
-struct __una_u64 { unsigned long x __attribute__((packed)); };
-struct __una_u32 { unsigned int x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-#endif
+/* Define some packed structures to use with unaligned accesses */
+
+struct __una_u64 { u64 x __attribute__((packed)); };
+struct __una_u32 { u32 x __attribute__((packed)); };
+struct __una_u16 { u16 x __attribute__((packed)); };
-static __inline__ unsigned long ldq_u(unsigned long * r11)
+/* Elemental unaligned loads */
+
+static __inline__ u64 ldq_u(u64 *p)
{
-#if defined(__GNUC__)
- const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
return ptr->x;
-#else
- unsigned long r1,r2;
- __asm__("ldq_u %0,%3\n\t"
- "ldq_u %1,%4\n\t"
- "extql %0,%2,%0\n\t"
- "extqh %1,%2,%1"
- :"=&r" (r1), "=&r" (r2)
- :"r" (r11),
- "m" (*r11),
- "m" (*(const unsigned long *)(7+(char *) r11)));
- return r1 | r2;
-#endif
}
-static __inline__ unsigned long ldl_u(unsigned int * r11)
+static __inline__ u32 ldl_u(u32 *p)
{
-#if defined(__GNUC__)
- const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
return ptr->x;
-#else
- unsigned long r1,r2;
- __asm__("ldq_u %0,%3\n\t"
- "ldq_u %1,%4\n\t"
- "extll %0,%2,%0\n\t"
- "extlh %1,%2,%1"
- :"=&r" (r1), "=&r" (r2)
- :"r" (r11),
- "m" (*r11),
- "m" (*(const unsigned long *)(3+(char *) r11)));
- return r1 | r2;
-#endif
}
-static __inline__ unsigned long ldw_u(unsigned short * r11)
+static __inline__ u16 ldw_u(u16 *p)
{
-#if defined(__GNUC__)
- const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
return ptr->x;
-#else
- unsigned long r1,r2;
- __asm__("ldq_u %0,%3\n\t"
- "ldq_u %1,%4\n\t"
- "extwl %0,%2,%0\n\t"
- "extwh %1,%2,%1"
- :"=&r" (r1), "=&r" (r2)
- :"r" (r11),
- "m" (*r11),
- "m" (*(const unsigned long *)(1+(char *) r11)));
- return r1 | r2;
-#endif
}
-/*
- * Elemental unaligned stores
- */
+/* Elemental unaligned stores */
-static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
+static __inline__ void stq_u(u64 val, u64 *p)
{
-#if defined(__GNUC__)
- struct __una_u64 *ptr = (struct __una_u64 *) r11;
- ptr->x = r5;
-#else
- unsigned long r1,r2,r3,r4;
-
- __asm__("ldq_u %3,%1\n\t"
- "ldq_u %2,%0\n\t"
- "insqh %6,%7,%5\n\t"
- "insql %6,%7,%4\n\t"
- "mskqh %3,%7,%3\n\t"
- "mskql %2,%7,%2\n\t"
- "bis %3,%5,%3\n\t"
- "bis %2,%4,%2\n\t"
- "stq_u %3,%1\n\t"
- "stq_u %2,%0"
- :"=m" (*r11),
- "=m" (*(unsigned long *)(7+(char *) r11)),
- "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
- :"r" (r5), "r" (r11));
-#endif
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+ ptr->x = val;
}
-static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
+static __inline__ void stl_u(u32 val, u32 *p)
{
-#if defined(__GNUC__)
- struct __una_u32 *ptr = (struct __una_u32 *) r11;
- ptr->x = r5;
-#else
- unsigned long r1,r2,r3,r4;
-
- __asm__("ldq_u %3,%1\n\t"
- "ldq_u %2,%0\n\t"
- "inslh %6,%7,%5\n\t"
- "insll %6,%7,%4\n\t"
- "msklh %3,%7,%3\n\t"
- "mskll %2,%7,%2\n\t"
- "bis %3,%5,%3\n\t"
- "bis %2,%4,%2\n\t"
- "stq_u %3,%1\n\t"
- "stq_u %2,%0"
- :"=m" (*r11),
- "=m" (*(unsigned long *)(3+(char *) r11)),
- "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
- :"r" (r5), "r" (r11));
-#endif
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
}
-static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
+static __inline__ void stw_u(u16 val, u16 *p)
{
-#if defined(__GNUC__)
- struct __una_u16 *ptr = (struct __una_u16 *) r11;
- ptr->x = r5;
-#else
- unsigned long r1,r2,r3,r4;
-
- __asm__("ldq_u %3,%1\n\t"
- "ldq_u %2,%0\n\t"
- "inswh %6,%7,%5\n\t"
- "inswl %6,%7,%4\n\t"
- "mskwh %3,%7,%3\n\t"
- "mskwl %2,%7,%2\n\t"
- "bis %3,%5,%3\n\t"
- "bis %2,%4,%2\n\t"
- "stq_u %3,%1\n\t"
- "stq_u %2,%0"
- :"=m" (*r11),
- "=m" (*(unsigned long *)(1+(char *) r11)),
- "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
- :"r" (r5), "r" (r11));
-#endif
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+}
+# else /* !__GNUC__ */
+
+static __inline__ u64 ldq_u(u64 *p)
+{
+ u64 ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-#endif
+
+static __inline__ u32 ldl_u(u32 *p)
+{
+ u32 ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ u16 ldw_u(u16 *p)
+{
+ u16 ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ void stq_u(u64 val, u64 *p)
+{
+ u64 tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stl_u(u32 val, u32 *p)
+{
+ u32 tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stw_u(u16 val, u16 *p)
+{
+ u16 tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+# endif /* __GNUC__ */
+# endif /* NO_INLINE */
+/*------------------------- Global Variables ------------------------------*/
+
+X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
+X86EMU_intrFuncs _X86EMU_intrTab[256];
+
+/*----------------------------- Implementation ----------------------------*/
/****************************************************************************
PARAMETERS:
@@ -262,13 +198,7 @@ u16 X86API rdw(
}
else
#endif
-#if defined(ALPHA_UALOADS)
val = ldw_u((u16*)(M.mem_base + addr));
-#elif defined(IA64_UALOADS)
- val = uldw((u16*)(M.mem_base + addr));
-#else
- val = *(u16*)(M.mem_base + addr);
-#endif
DB( if (DEBUG_MEM_TRACE())
printk("%#08x 2 -> %#x\n", addr, val);)
return val;
@@ -301,13 +231,7 @@ u32 X86API rdl(
}
else
#endif
-#if defined(ALPHA_UALOADS)
val = ldl_u((u32*)(M.mem_base + addr));
-#elif defined(IA64_UALOADS)
- val = uldl((u32*)(M.mem_base + addr));
-#else
- val = *(u32*)(M.mem_base + addr);
-#endif
DB( if (DEBUG_MEM_TRACE())
printk("%#08x 4 -> %#x\n", addr, val);)
return val;
@@ -359,13 +283,7 @@ DB( if (DEBUG_MEM_TRACE())
}
else
#endif
-#if defined(ALPHA_UALOADS)
stw_u(val,(u16*)(M.mem_base + addr));
-#elif defined(IA64_UALOADS)
- ustw(val,(u16*)(M.mem_base + addr));
-#else
- *(u16*)(M.mem_base + addr) = val;
-#endif
}
/****************************************************************************
@@ -395,13 +313,7 @@ DB( if (DEBUG_MEM_TRACE())
}
else
#endif
-#if defined(ALPHA_UALOADS)
stl_u(val,(u32*)(M.mem_base + addr));
-#elif defined(IA64_UALOADS)
- ustl(val,(u32*)(M.mem_base + addr));
-#else
- *(u32*)(M.mem_base + addr) = val;
-#endif
}
/****************************************************************************
diff --git a/xorg-server/hw/xfree86/xaa/Makefile.in b/xorg-server/hw/xfree86/xaa/Makefile.in
index 3f628e5dc..9728388dd 100644
--- a/xorg-server/hw/xfree86/xaa/Makefile.in
+++ b/xorg-server/hw/xfree86/xaa/Makefile.in
@@ -172,6 +172,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -303,6 +304,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
diff --git a/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in
index 237259c90..9912be485 100644
--- a/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in
+++ b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in
@@ -153,6 +153,7 @@ DARWIN_LIBS = @DARWIN_LIBS@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -284,6 +285,8 @@ RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@