From d95c758630f4aacec339a7ec80d2c4a9d7de1e4a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 1 Jul 2006 19:46:38 -0700 Subject: [PATCH 001/109] Preliminary RandR 1.2 work --- randr/mirandr.c | 85 +++++++------- randr/randr.c | 289 ++++++++++++++++++++++++++++++----------------- randr/randrstr.h | 179 ++++++++++++++++++++--------- 3 files changed, 357 insertions(+), 196 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 0954028d1..7bef02d29 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -1,36 +1,36 @@ /* - * - * Copyright © 2000, Compaq Computer Corporation, - * Copyright © 2002, Hewlett Packard, Inc. + * Copyright © 2000 Compaq Computer Corporation + * Copyright © 2002 Hewlett-Packard Company + * Copyright © 2006 Intel Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Compaq or HP not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. HP makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. * - * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. * - * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. + * Author: Jim Gettys, Hewlett-Packard Company, Inc. + * Keith Packard, Intel Corporation */ - #ifdef HAVE_DIX_CONFIG_H #include #endif #include "scrnintstr.h" #include "mi.h" -#include #include "randrstr.h" #include @@ -48,26 +48,35 @@ miRRGetInfo (ScreenPtr pScreen, Rotation *rotations) { int i; Bool setConfig = FALSE; + RRMonitorPtr pMonitor; - *rotations = RR_Rotate_0; + pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); for (i = 0; i < pScreen->numDepths; i++) { if (pScreen->allowedDepths[i].numVids) { - RRScreenSizePtr pSize; + xRRMonitorMode rrMode; + RRModePtr pMode; + char name[64]; - pSize = RRRegisterSize (pScreen, - pScreen->width, - pScreen->height, - pScreen->mmWidth, - pScreen->mmHeight); - if (!pSize) - return FALSE; - if (!setConfig) - { - RRSetCurrentConfig (pScreen, RR_Rotate_0, 0, pSize); - setConfig = TRUE; - } + sprintf (name, "%dx%d", pScreen->width, pScreen->height); + memset (&rrMode, '\0', sizeof (rrMode)); + rrMode.width = pScreen->width; + rrMode.height = pScreen->height; + rrMode.widthInMillimeters = pScreen->mmWidth; + rrMode.heightInMillimeters = pScreen->mmHeight; + pMonitor = RRRegisterMonitor (pScreen, RR_Rotate_0); + pMode = RRRegisterMode (pMonitor, + &rrMode, + name, + strlen (name)); + if (!pMode) + return FALSE; + if (!setConfig) + { + RRSetCurrentMode (pMonitor, pMode, 0, 0, RR_Rotate_0); + setConfig = TRUE; + } } } return TRUE; @@ -78,10 +87,10 @@ miRRGetInfo (ScreenPtr pScreen, Rotation *rotations) * different here */ Bool -miRRSetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) +miRRSetMode (ScreenPtr pScreen, + int monitor, + RRModePtr pMode, + Rotation rotation) { return TRUE; } @@ -96,6 +105,6 @@ miRandRInit (ScreenPtr pScreen) return FALSE; rp = rrGetScrPriv(pScreen); rp->rrGetInfo = miRRGetInfo; - rp->rrSetConfig = miRRSetConfig; + rp->rrSetMode = miRRSetMode; return TRUE; } diff --git a/randr/randr.c b/randr/randr.c index 946aad31d..1a9624a24 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -1,29 +1,30 @@ /* - * - * Copyright © 2000, Compaq Computer Corporation, - * Copyright © 2002, Hewlett Packard, Inc. + * Copyright © 2000 Compaq Computer Corporation + * Copyright © 2002 Hewlett-Packard Company + * Copyright © 2006 Intel Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Compaq or HP not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. HP makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. * - * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. * - * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. + * Author: Jim Gettys, Hewlett-Packard Company, Inc. + * Keith Packard, Intel Corporation */ - #define NEED_REPLIES #define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H @@ -159,10 +160,21 @@ static Bool RRCloseScreen (int i, ScreenPtr pScreen) { rrScrPriv(pScreen); + RRMonitorPtr pMonitor; unwrap (pScrPriv, pScreen, CloseScreen); - if (pScrPriv->pSizes) - xfree (pScrPriv->pSizes); + while (pMonitor = pScrPriv->pMonitors) + { + RRModePtr pMode; + + pScrPriv->pMonitors = pMonitor->next; + while (pMode = pMonitor->pModes) + { + pMonitor->pModes = pMode->next; + xfree (pMode); + } + xfree (pMonitor); + } xfree (pScrPriv); RRNScreens -= 1; /* ok, one fewer screen with RandR running */ return (*pScreen->CloseScreen) (i, pScreen); @@ -187,6 +199,25 @@ SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from, cpswaps(from->subpixelOrder, to->subpixelOrder); } +static void +SRRMonitorChangeNotifyEvent(xRRMonitorChangeNotifyEvent *from, + xRRMonitorChangeNotifyEvent *to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->configTimestamp, to->configTimestamp); + cpswapl(from->root, to->root); + cpswapl(from->window, to->window); + cpswaps(from->monitor, to->monitor); + cpswaps(from->modeID, to->modeID); + cpswaps(from->rotation, to->rotation); + cpswaps(from->subpixelOrder, to->subpixelOrder); + cpswaps(from->x, to->x); + cpswaps(from->y, to->y); +} + Bool RRScreenInit(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; @@ -207,8 +238,12 @@ Bool RRScreenInit(ScreenPtr pScreen) /* * Calling function best set these function vectors */ - pScrPriv->rrSetConfig = 0; + pScrPriv->rrSetMode = 0; pScrPriv->rrGetInfo = 0; +#ifdef RANDR_SCREEN_INTERFACE + pScrPriv->rrSetConfig = 0; +#endif + /* * This value doesn't really matter -- any client must call * GetScreenInfo before reading it which will automatically update @@ -219,14 +254,7 @@ Bool RRScreenInit(ScreenPtr pScreen) wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen); - pScrPriv->rotations = RR_Rotate_0; - - pScrPriv->nSizes = 0; - pScrPriv->nSizesInUse = 0; - pScrPriv->pSizes = 0; - - pScrPriv->rotation = RR_Rotate_0; - pScrPriv->size = -1; + pScrPriv->pMonitors = NULL; RRNScreens += 1; /* keep count of screens that implement randr */ return TRUE; @@ -318,55 +346,96 @@ TellChanged (WindowPtr pWin, pointer value) RREventPtr *pHead, pRREvent; ClientPtr client; xRRScreenChangeNotifyEvent se; + xRRMonitorChangeNotifyEvent me; ScreenPtr pScreen = pWin->drawable.pScreen; rrScrPriv(pScreen); - RRScreenSizePtr pSize; + RRMonitorPtr pMonitor = pScrPriv->pMonitors; + RRModePtr pMode; WindowPtr pRoot = WindowTable[pScreen->myNum]; + int i; pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, EventType); if (!pHead) return WT_WALKCHILDREN; - se.type = RRScreenChangeNotify + RREventBase; - se.rotation = (CARD8) pScrPriv->rotation; - se.timestamp = pScrPriv->lastSetTime.milliseconds; - se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - se.root = pRoot->drawable.id; - se.window = pWin->drawable.id; -#ifdef RENDER - se.subpixelOrder = PictureGetSubpixelOrder (pScreen); -#else - se.subpixelOrder = SubPixelUnknown; -#endif - if (pScrPriv->size >= 0) - { - pSize = &pScrPriv->pSizes[pScrPriv->size]; - se.sizeID = pSize->id; - se.widthInPixels = pSize->width; - se.heightInPixels = pSize->height; - se.widthInMillimeters = pSize->mmWidth; - se.heightInMillimeters = pSize->mmHeight; - } - else - { - /* - * This "shouldn't happen", but a broken DDX can - * forget to set the current configuration on GetInfo - */ - se.sizeID = 0xffff; - se.widthInPixels = 0; - se.heightInPixels = 0; - se.widthInMillimeters = 0; - se.heightInMillimeters = 0; - } for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { client = pRREvent->client; if (client == serverClient || client->clientGone) continue; - se.sequenceNumber = client->sequence; - if(pRREvent->mask & RRScreenChangeNotifyMask) - WriteEventsToClient (client, 1, (xEvent *) &se); + + if (pRREvent->mask & RRMonitorChangeNotifyMask)) + { + me.type = RRNotify + RREventBase; + me.subCode = RRNotify_MonitorChange; + me.timestamp = pScrPriv->lastSetTime.milliseconds; + me.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + me.root = pRoot->drawable.id; + me.window = pWin->drawable.id; +#ifdef RENDER + me.subpixelOrder = PictureGetSubpixelOrder (pScreen); +#else + me.subpixelOrder = SubPixelUnknown; +#endif + for (i = 0; i < pScrPriv->nMonitors; i++) + { + pMonitor = &pScrPriv->pMonitors[i]; + me.monitor = i; + if (pMonitor->mode >= 0) { + me.modeID = pMonitor->pMode[pMonitor->mode].id; + me.rotation = pMonitor->rotation; + me.x = pMonitor->x; + me.y = pMonitor->y; + } else { + me.modeID = 0xffff; + me.rotation = RR_Rotate_0; + me.x = 0; + me.y = 0; + } + WriteEventsToClient (client, 1, (xEvent *) &me); + } + } + if ((pRREvent->mask & RRScreenChangeNotifyMask) && + pScrPriv->nMonitors > 0) + { + se.type = RRScreenChangeNotify + RREventBase; + se.rotation = (CARD8) pScrPriv->rotation; + se.timestamp = pScrPriv->lastSetTime.milliseconds; + se.sequenceNumber = client->sequence; + se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + se.root = pRoot->drawable.id; + se.window = pWin->drawable.id; +#ifdef RENDER + se.subpixelOrder = PictureGetSubpixelOrder (pScreen); +#else + se.subpixelOrder = SubPixelUnknown; +#endif + + pMonitor = &pScrPriv->pMonitors[0]; + se.sequenceNumber = client->sequence; + if (pMonitor->mode >= 0) + { + pMode = &pMonitor->pModes[pMonitor->mode]; + se.sizeID = pMode->id; + se.widthInPixels = pMode->width; + se.heightInPixels = pMode->height; + se.widthInMillimeters = pMode->mmWidth; + se.heightInMillimeters = pMode->mmHeight; + } + else + { + /* + * This "shouldn't happen", but a broken DDX can + * forget to set the current configuration on GetInfo + */ + se.sizeID = 0xffff; + se.widthInPixels = 0; + se.heightInPixels = 0; + se.widthInMillimeters = 0; + se.heightInMillimeters = 0; + } + WriteEventsToClient (client, 1, (xEvent *) &se); + } } return WT_WALKCHILDREN; } @@ -375,59 +444,66 @@ static Bool RRGetInfo (ScreenPtr pScreen) { rrScrPriv (pScreen); - int i, j, k, l; + int m, s, n; Bool changed; Rotation rotations; - RRScreenSizePtr pSize; - RRScreenRatePtr pRate; + RRMonitorPtr pMonitor; + RRModePtr pMode; - for (i = 0; i < pScrPriv->nSizes; i++) + for (m = 0; m < pScrPriv->nMonitors; m++) { - pSize = &pScrPriv->pSizes[i]; - pSize->oldReferenced = pSize->referenced; - pSize->referenced = FALSE; - for (k = 0; k < pSize->nRates; k++) + pMonitor = &pScrPriv->pMonitors[m]; + pMonitor->oldReferenced = pMonitor->referenced; + pMonitor->referenced = FALSE; + for (s = 0; s < pMonitor->nModes; s++) { - pRate = &pSize->pRates[k]; - pRate->oldReferenced = pRate->referenced; - pRate->referenced = FALSE; + pMode = &pSize->pModes[s]; + pMode->oldReferenced = pMode->referenced; + pMode->referenced = FALSE; } } - if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) - return FALSE; - changed = FALSE; - /* - * Check whether anything changed and simultaneously generate - * the protocol id values for the objects - */ - if (rotations != pScrPriv->rotations) - { - pScrPriv->rotations = rotations; - changed = TRUE; - } - - j = 0; - for (i = 0; i < pScrPriv->nSizes; i++) - { - pSize = &pScrPriv->pSizes[i]; - if (pSize->oldReferenced != pSize->referenced) - changed = TRUE; - if (pSize->referenced) - pSize->id = j++; - l = 0; - for (k = 0; k < pSize->nRates; k++) + rotations = 0; + if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) + return FALSE; + + /* Old GetInfo clients return rotations here */ + if (rotations && pScrPriv->nMonitors) { + /* + * Check whether anything changed and simultaneously generate + * the protocol id values for the objects + */ + if (rotations != pScrPriv->pMonitors[i].rotations) { - pRate = &pSize->pRates[k]; - if (pRate->oldReferenced != pRate->referenced) - changed = TRUE; - if (pRate->referenced) - l++; + pScrPriv->pMonitors[i].rotations = rotations; + changed = TRUE; } - pSize->nRatesInUse = l; } - pScrPriv->nSizesInUse = j; + + n = 0; + for (m = 0; m < pScrPriv->nMonitors; m++) + { + int modeid = 0; + + pMonitor = &pScrPriv->pMonitors[m]; + if (pMonitor->oldReferenced != pMonitor->referenced) + changed = TRUE; + if (pMonitor->referenced) + { + for (s = 0; s < pMonitor->nModes; s++) + { + pMode = &pMonitor->pModes[s]; + if (pMode->oldReferenced != pMode->referenced) + changed = TRUE; + if (pMode->referenced) + pMode->id = modeid++; + } + n++; + } + pMonitor->nModesInUse = modeid; + } + pScrPriv->nMonitorsInUse = n; if (changed) { UpdateCurrentTime (); @@ -1241,6 +1317,7 @@ RRRegisterSize (ScreenPtr pScreen, if (!pScrPriv) return 0; + tmp.id = -1; tmp.width = width; tmp.height= height; tmp.mmWidth = mmWidth; diff --git a/randr/randrstr.h b/randr/randrstr.h index 27ab61abb..07c6c3798 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -1,24 +1,28 @@ /* - * * Copyright © 2000 Compaq Computer Corporation + * Copyright © 2002 Hewlett-Packard Company + * Copyright © 2006 Intel Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Compaq not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Compaq makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. * - * COMPAQ DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL COMPAQ BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Author: Jim Gettys, Hewlett-Packard Company, Inc. + * Keith Packard, Intel Corporation */ #ifdef HAVE_DIX_CONFIG_H @@ -28,56 +32,83 @@ #ifndef _RANDRSTR_H_ #define _RANDRSTR_H_ -#include +#include -typedef struct _rrScreenRate { - int rate; - Bool referenced; - Bool oldReferenced; -} RRScreenRate, *RRScreenRatePtr; - -typedef struct _rrScreenSize { +typedef struct _rrMode { + struct _rrMode *next; int id; - short width, height; - short mmWidth, mmHeight; - RRScreenRatePtr pRates; - int nRates; - int nRatesInUse; Bool referenced; Bool oldReferenced; -} RRScreenSize, *RRScreenSizePtr; + xRRMonitorMode mode; +} RRMode, *RRModePtr; + +typedef struct _rrMonitor { + struct _rrMonitor *next; + ScreenPtr pScreen; + RRModePtr pModes; + void *identifier; /* made unique by DDX */ + Bool referenced; + + /* + * Current state + */ + int mode; + int x, y; + Rotation rotation; +} RRMonitor, *RRMonitorPtr; + +typedef Bool (*RRSetScreenSizeProcPtr) (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 widthInMM, + CARD32 heightInMM); + +typedef Bool (*RRSetModeProcPtr) (ScreenPtr pScreen, + int monitor, + RRModePtr pMode, + int x, + int y, + Rotation rotation); + +typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); +typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); + + +#ifdef RANDR_SCREEN_INTERFACE + +typedef void *RRScreenSizePtr; typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize); -typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); -typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); +#endif + typedef struct _rrScrPriv { - RRSetConfigProcPtr rrSetConfig; + RRSetModeProcPtr rrSetMode; RRGetInfoProcPtr rrGetInfo; + RRCloseScreenProcPtr CloseScreen; TimeStamp lastSetTime; /* last changed by client */ TimeStamp lastConfigTime; /* possible configs changed */ - RRCloseScreenProcPtr CloseScreen; + /* + * monitor data + */ + RRMonitorPtr pMonitors; + +#ifdef RANDR_SCREEN_INTERFACE /* * Configuration information */ Rotation rotations; - int nSizes; - int nSizesInUse; - RRScreenSizePtr pSizes; + RRSetConfigProcPtr rrSetConfig; - /* - * Current state - */ Rotation rotation; - int size; - int rate; +#endif } rrScrPrivRec, *rrScrPrivPtr; extern int rrPrivIndex; @@ -90,6 +121,60 @@ extern int rrPrivIndex; void RRExtensionInit (void); +/* + * Then, register a monitor with the screen + */ + +RRMonitorPtr +RRRegisterMonitor (ScreenPtr pScreen, + void *identifier, + Rotation rotations); + +/* + * Next, register the list of modes with the monitor + */ + +RRModePtr +RRRegisterMode (RRMonitorPtr pMonitor, + xRRMonitorMode *pMode, + char *name, + int nameLength); + +/* + * Finally, set the current configuration of each monitor + */ + +void +RRSetCurrentMode (RRMonitorPtr pMonitor, + RRModePtr pMode, + Rotation rotation); + +Bool RRScreenInit(ScreenPtr pScreen); + +Rotation +RRGetRotation (ScreenPtr pScreen); + +Bool +miRandRInit (ScreenPtr pScreen); + +Bool +miRRGetInfo (ScreenPtr pScreen, Rotation *rotations); + +Bool +miRRGetScreenInfo (ScreenPtr pScreen); + +Bool +miRRSetMode (ScreenPtr pScreen, + int monitor, + RRModePtr pMode, + Rotation rotation); + +#ifdef RANDR_SCREEN_INTERFACE +/* + * This is the old interface, deprecated but left + * around for compatibility + */ + /* * Then, register the specific size with the screen */ @@ -105,6 +190,9 @@ Bool RRRegisterRate (ScreenPtr pScreen, RRScreenSizePtr pSize, int rate); +Bool RRRegisterRotation (ScreenPtr pScreen, + Rotation rotation); + /* * Finally, set the current configuration of the screen */ @@ -115,30 +203,17 @@ RRSetCurrentConfig (ScreenPtr pScreen, int rate, RRScreenSizePtr pSize); -Bool RRScreenInit(ScreenPtr pScreen); - -Rotation -RRGetRotation (ScreenPtr pScreen); - int RRSetScreenConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize); -Bool -miRandRInit (ScreenPtr pScreen); - -Bool -miRRGetInfo (ScreenPtr pScreen, Rotation *rotations); - Bool miRRSetConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr size); -Bool -miRRGetScreenInfo (ScreenPtr pScreen); - +#endif #endif /* _RANDRSTR_H_ */ From cab3a0145f2483fe43b5db5f5dd2076db9757fe5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 17 Jul 2006 01:21:11 -0400 Subject: [PATCH 002/109] RandR: New data structure, old API. At least it compiles now --- randr/mirandr.c | 8 +- randr/randr.c | 699 +++++++++++++++++++++++++++++++++++------------ randr/randrstr.h | 51 +++- 3 files changed, 571 insertions(+), 187 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 7bef02d29..e15213327 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -65,11 +65,11 @@ miRRGetInfo (ScreenPtr pScreen, Rotation *rotations) rrMode.height = pScreen->height; rrMode.widthInMillimeters = pScreen->mmWidth; rrMode.heightInMillimeters = pScreen->mmHeight; - pMonitor = RRRegisterMonitor (pScreen, RR_Rotate_0); + rrMode.nameLength = strlen (name); + pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); pMode = RRRegisterMode (pMonitor, &rrMode, - name, - strlen (name)); + name); if (!pMode) return FALSE; if (!setConfig) @@ -90,6 +90,8 @@ Bool miRRSetMode (ScreenPtr pScreen, int monitor, RRModePtr pMode, + int x, + int y, Rotation rotation) { return TRUE; diff --git a/randr/randr.c b/randr/randr.c index 1a9624a24..4a5cd4e1d 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -163,12 +163,12 @@ RRCloseScreen (int i, ScreenPtr pScreen) RRMonitorPtr pMonitor; unwrap (pScrPriv, pScreen, CloseScreen); - while (pMonitor = pScrPriv->pMonitors) + while ((pMonitor = pScrPriv->pMonitors)) { RRModePtr pMode; pScrPriv->pMonitors = pMonitor->next; - while (pMode = pMonitor->pModes) + while ((pMode = pMonitor->pModes)) { pMonitor->pModes = pMode->next; xfree (pMode); @@ -218,6 +218,20 @@ SRRMonitorChangeNotifyEvent(xRRMonitorChangeNotifyEvent *from, cpswaps(from->y, to->y); } +static void +SRRNotifyEvent (xEvent *from, + xEvent *to) +{ + switch (from->u.u.detail) { + case RRNotify_MonitorChange: + SRRMonitorChangeNotifyEvent ((xRRMonitorChangeNotifyEvent *) from, + (xRRMonitorChangeNotifyEvent *) to); + break; + default: + break; + } +} + Bool RRScreenInit(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; @@ -336,6 +350,8 @@ RRExtensionInit (void) RREventBase = extEntry->eventBase; EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr) SRRScreenChangeNotifyEvent; + EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr) + SRRNotifyEvent; return; } @@ -349,8 +365,8 @@ TellChanged (WindowPtr pWin, pointer value) xRRMonitorChangeNotifyEvent me; ScreenPtr pScreen = pWin->drawable.pScreen; rrScrPriv(pScreen); - RRMonitorPtr pMonitor = pScrPriv->pMonitors; RRModePtr pMode; + RRMonitorPtr pMonitor; WindowPtr pRoot = WindowTable[pScreen->myNum]; int i; @@ -364,7 +380,7 @@ TellChanged (WindowPtr pWin, pointer value) if (client == serverClient || client->clientGone) continue; - if (pRREvent->mask & RRMonitorChangeNotifyMask)) + if (pRREvent->mask & RRMonitorChangeNotifyMask) { me.type = RRNotify + RREventBase; me.subCode = RRNotify_MonitorChange; @@ -377,12 +393,13 @@ TellChanged (WindowPtr pWin, pointer value) #else me.subpixelOrder = SubPixelUnknown; #endif - for (i = 0; i < pScrPriv->nMonitors; i++) + for (pMonitor = pScrPriv->pMonitors, i = 0; + pMonitor; + pMonitor = pMonitor->next, i++) { - pMonitor = &pScrPriv->pMonitors[i]; me.monitor = i; - if (pMonitor->mode >= 0) { - me.modeID = pMonitor->pMode[pMonitor->mode].id; + if (pMonitor->pMode) { + me.modeID = pMonitor->pMode->id; me.rotation = pMonitor->rotation; me.x = pMonitor->x; me.y = pMonitor->y; @@ -396,10 +413,10 @@ TellChanged (WindowPtr pWin, pointer value) } } if ((pRREvent->mask & RRScreenChangeNotifyMask) && - pScrPriv->nMonitors > 0) + (pMonitor = pScrPriv->pMonitors)) { se.type = RRScreenChangeNotify + RREventBase; - se.rotation = (CARD8) pScrPriv->rotation; + se.rotation = (CARD8) pMonitor->rotation; se.timestamp = pScrPriv->lastSetTime.milliseconds; se.sequenceNumber = client->sequence; se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; @@ -413,14 +430,14 @@ TellChanged (WindowPtr pWin, pointer value) pMonitor = &pScrPriv->pMonitors[0]; se.sequenceNumber = client->sequence; - if (pMonitor->mode >= 0) + if (pMonitor->pMode) { - pMode = &pMonitor->pModes[pMonitor->mode]; + pMode = pMonitor->pMode; se.sizeID = pMode->id; - se.widthInPixels = pMode->width; - se.heightInPixels = pMode->height; - se.widthInMillimeters = pMode->mmWidth; - se.heightInMillimeters = pMode->mmHeight; + se.widthInPixels = pMode->mode.width; + se.heightInPixels = pMode->mode.height; + se.widthInMillimeters = pMode->mode.widthInMillimeters; + se.heightInMillimeters = pMode->mode.heightInMillimeters; } else { @@ -440,70 +457,107 @@ TellChanged (WindowPtr pWin, pointer value) return WT_WALKCHILDREN; } +static void +RRFreeMode (RRModePtr pMode) +{ + xfree (pMode); +} + +static void +RRFreeModes (RRModePtr pHead) +{ + RRModePtr pMode; + while ((pMode = pHead)) + { + pHead = pMode->next; + RRFreeMode (pMode); + } +} + +static void +RRFreeMonitor (RRMonitorPtr pMonitor) +{ + RRFreeModes (pMonitor->pModes); + xfree (pMonitor); +} + + static Bool RRGetInfo (ScreenPtr pScreen) { rrScrPriv (pScreen); - int m, s, n; Bool changed; Rotation rotations; - RRMonitorPtr pMonitor; - RRModePtr pMode; + RRMonitorPtr pMonitor, *pPrevMon; + RRModePtr pMode, *pPrevMode; + int monitorid; - for (m = 0; m < pScrPriv->nMonitors; m++) + for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) { - pMonitor = &pScrPriv->pMonitors[m]; - pMonitor->oldReferenced = pMonitor->referenced; + pMonitor->oldReferenced = TRUE; pMonitor->referenced = FALSE; - for (s = 0; s < pMonitor->nModes; s++) + pMonitor->pMode = NULL; + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) { - pMode = &pSize->pModes[s]; - pMode->oldReferenced = pMode->referenced; + pMode->oldReferenced = TRUE; pMode->referenced = FALSE; } } - changed = FALSE; - rotations = 0; if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) return FALSE; + + changed = FALSE; /* Old GetInfo clients return rotations here */ - if (rotations && pScrPriv->nMonitors) { + if (rotations && pScrPriv->pMonitors) { /* * Check whether anything changed and simultaneously generate * the protocol id values for the objects */ - if (rotations != pScrPriv->pMonitors[i].rotations) + if (rotations != pScrPriv->pMonitors->rotations) { - pScrPriv->pMonitors[i].rotations = rotations; + pScrPriv->pMonitors->rotations = rotations; changed = TRUE; } } - n = 0; - for (m = 0; m < pScrPriv->nMonitors; m++) + /* + * Walk monitor and mode lists looking for updates + */ + monitorid = 0; + for (pPrevMon = &pScrPriv->pMonitors; (pMonitor = *pPrevMon);) { int modeid = 0; - pMonitor = &pScrPriv->pMonitors[m]; - if (pMonitor->oldReferenced != pMonitor->referenced) - changed = TRUE; if (pMonitor->referenced) { - for (s = 0; s < pMonitor->nModes; s++) + pMonitor->id = monitorid++; + if (!pMonitor->oldReferenced) + changed = TRUE; + for (pPrevMode = &pMonitor->pModes; (pMode = *pPrevMode);) { - pMode = &pMonitor->pModes[s]; - if (pMode->oldReferenced != pMode->referenced) - changed = TRUE; if (pMode->referenced) + { pMode->id = modeid++; + if (!pMode->oldReferenced) + changed = TRUE; + } + else + { + *pPrevMode = pMode->next; + changed = TRUE; + RRFreeMode (pMode); + } } - n++; } - pMonitor->nModesInUse = modeid; + else + { + *pPrevMon = pMonitor->next; + changed = TRUE; + RRFreeMonitor (pMonitor); + } } - pScrPriv->nMonitorsInUse = n; if (changed) { UpdateCurrentTime (); @@ -548,6 +602,10 @@ ProcRRQueryVersion (ClientPtr client) rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; + /* + * Report the current version; the current + * spec says they're all compatible after 1.0 + */ rep.majorVersion = RANDR_MAJOR; rep.minorVersion = RANDR_MINOR; if (client->swapped) { @@ -604,6 +662,100 @@ RREditConnectionInfo (ScreenPtr pScreen) root->mmHeight = pScreen->mmHeight; } +static int +RRNumModes (RRMonitorPtr pMonitor) +{ + int n = 0; + RRModePtr pMode; + + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + n++; + return n; +} + +typedef struct _RR10Data { + RRScreenSizePtr sizes; + int nsize; + int nrefresh; + int size; + CARD16 refresh; +} RR10DataRec, *RR10DataPtr; + +static CARD16 +RRVerticalRefresh (xRRMonitorMode *mode) +{ + CARD32 refresh; + if (!mode->hTotal || !mode->vTotal) + return 0; + refresh = mode->dotClock / (mode->hTotal * mode->vTotal); + if (refresh > 0xffff) + refresh = 0xffff; + return (CARD16) refresh; +} + +/* + * Convert 1.2 monitor data into 1.0 screen data + */ +static RR10DataPtr +RR10GetData (ScreenPtr pScreen, RRMonitorPtr pMonitor) +{ + RR10DataPtr data; + RRScreenSizePtr size; + int nmode = RRNumModes (pMonitor); + int i; + int j; + RRRefreshPtr refresh; + CARD16 vRefresh; + RRModePtr pMode; + + /* Make sure there is plenty of space for any combination */ + data = malloc (sizeof (RR10DataRec) + + sizeof (RRScreenSizeRec) * nmode + + sizeof (RRRefreshRec) * nmode); + if (!data) + return NULL; + size = (RRScreenSizePtr) (data + 1); + refresh = (RRRefreshPtr) (size + nmode); + data->nsize = 0; + data->nrefresh = 0; + data->size = 0; + data->refresh = 0; + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + { + for (i = 0; i < data->nsize; i++) + if (pMode->mode.width == size[i].width && + pMode->mode.height == size[i].height) + break; + if (i == data->nsize) + { + size[i].width = pMode->mode.width; + size[i].height = pMode->mode.height; + size[i].mmWidth = pMode->mode.widthInMillimeters; + size[i].mmHeight = pMode->mode.heightInMillimeters; + size[i].nrefresh = 0; + size[i].refresh = &refresh[data->nrefresh]; + data->nsize++; + } + vRefresh = RRVerticalRefresh (&pMode->mode); + for (j = 0; j < size[i].nrefresh; j++) + if (vRefresh == size[i].refresh[j].refresh) + break; + if (j == size[i].nrefresh) + { + size[i].refresh[j].refresh = vRefresh; + size[i].refresh[j].pMode = pMode; + size[i].nrefresh++; + data->nrefresh++; + } + if (pMode == pMonitor->pMode) + { + data->size = i; + data->refresh = vRefresh; + } + } + return data; +} + static int ProcRRGetScreenInfo (ClientPtr client) { @@ -626,7 +778,11 @@ ProcRRGetScreenInfo (ClientPtr client) pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); rep.pad = 0; - if (!pScrPriv) + + if (pScrPriv) + RRGetInfo (pScreen); + + if (!pScrPriv && !pScrPriv->pMonitors) { rep.type = X_Reply; rep.setOfRotations = RR_Rotate_0;; @@ -645,94 +801,82 @@ ProcRRGetScreenInfo (ClientPtr client) } else { + RRMonitorPtr pMonitor = pScrPriv->pMonitors; int i, j; xScreenSizes *size; CARD16 *rates; CARD8 *data8; Bool has_rate = RRClientKnowsRates (client); + RR10DataPtr pData; + RRScreenSizePtr pSize; - RRGetInfo (pScreen); - + pData = RR10GetData (pScreen, pMonitor); + if (!pData) + return BadAlloc; + rep.type = X_Reply; - rep.setOfRotations = pScrPriv->rotations; + rep.setOfRotations = pMonitor->rotations; rep.sequenceNumber = client->sequence; rep.length = 0; rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = pScrPriv->rotation; - rep.nSizes = pScrPriv->nSizesInUse; - rep.rate = pScrPriv->rate; - rep.nrateEnts = 0; - if (has_rate) - { - for (i = 0; i < pScrPriv->nSizes; i++) - { - RRScreenSizePtr pSize = &pScrPriv->pSizes[i]; - if (pSize->referenced) - { - rep.nrateEnts += (1 + pSize->nRatesInUse); - } - } - } - - if (pScrPriv->size >= 0) - rep.sizeID = pScrPriv->pSizes[pScrPriv->size].id; - else - return BadImplementation; + rep.rotation = pMonitor->rotation; + rep.nSizes = pData->nsize; + rep.nrateEnts = pData->nrefresh; + rep.sizeID = pData->size; + rep.rate = pData->refresh; extraLen = (rep.nSizes * sizeof (xScreenSizes) + rep.nrateEnts * sizeof (CARD16)); extra = (CARD8 *) xalloc (extraLen); if (!extra) + { + xfree (pData); return BadAlloc; + } /* * First comes the size information */ size = (xScreenSizes *) extra; rates = (CARD16 *) (size + rep.nSizes); - for (i = 0; i < pScrPriv->nSizes; i++) + for (i = 0; i < pData->nsize; i++) { - RRScreenSizePtr pSize = &pScrPriv->pSizes[i]; - if (pSize->referenced) + pSize = &pData->sizes[i]; + size->widthInPixels = pSize->width; + size->heightInPixels = pSize->height; + size->widthInMillimeters = pSize->mmWidth; + size->heightInMillimeters = pSize->mmHeight; + if (client->swapped) { - size->widthInPixels = pSize->width; - size->heightInPixels = pSize->height; - size->widthInMillimeters = pSize->mmWidth; - size->heightInMillimeters = pSize->mmHeight; + swaps (&size->widthInPixels, n); + swaps (&size->heightInPixels, n); + swaps (&size->widthInMillimeters, n); + swaps (&size->heightInMillimeters, n); + } + size++; + if (has_rate) + { + *rates = pSize->nrefresh; if (client->swapped) { - swaps (&size->widthInPixels, n); - swaps (&size->heightInPixels, n); - swaps (&size->widthInMillimeters, n); - swaps (&size->heightInMillimeters, n); + swaps (rates, n); } - size++; - if (has_rate) + rates++; + for (j = 0; j < pSize->nrefresh; j++) { - *rates = pSize->nRatesInUse; + *rates = pSize->refresh[j].refresh; if (client->swapped) { swaps (rates, n); } rates++; - for (j = 0; j < pSize->nRates; j++) - { - RRScreenRatePtr pRate = &pSize->pRates[j]; - if (pRate->referenced) - { - *rates = pRate->rate; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - } - } } } } + xfree (pData); + data8 = (CARD8 *) rates; if (data8 - (CARD8 *) extra != extraLen) @@ -770,13 +914,16 @@ ProcRRSetScreenConfig (ClientPtr client) rrScrPrivPtr pScrPriv; TimeStamp configTime; TimeStamp time; - RRScreenSizePtr pSize; int i; Rotation rotation; int rate; short oldWidth, oldHeight; Bool has_rate; - + RRMonitorPtr pMonitor; + RRModePtr pMode; + RR10DataPtr pData = NULL; + RRScreenSizePtr pSize; + UpdateCurrentTime (); if (RRClientKnowsRates (client)) @@ -812,6 +959,14 @@ ProcRRSetScreenConfig (ClientPtr client) if (!RRGetInfo (pScreen)) return BadAlloc; + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + /* * if the client's config timestamp is not the same as the last config * timestamp, then the config information isn't up-to-date and @@ -823,26 +978,20 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - /* - * Search for the requested size - */ - pSize = 0; - for (i = 0; i < pScrPriv->nSizes; i++) - { - pSize = &pScrPriv->pSizes[i]; - if (pSize->referenced && pSize->id == stuff->sizeID) - { - break; - } - } - if (i == pScrPriv->nSizes) + pData = RR10GetData (pScreen, pMonitor); + if (!pData) + return BadAlloc; + + if (stuff->sizeID >= pData->nsize) { /* * Invalid size ID */ client->errorValue = stuff->sizeID; + xfree (pData); return BadValue; } + pSize = &pData->sizes[stuff->sizeID]; /* * Validate requested rotation @@ -861,15 +1010,17 @@ ProcRRSetScreenConfig (ClientPtr client) * Invalid rotation */ client->errorValue = stuff->rotation; + xfree (pData); return BadValue; } - if ((~pScrPriv->rotations) & rotation) + if ((~pMonitor->rotations) & rotation) { /* * requested rotation or reflection not supported by screen */ client->errorValue = stuff->rotation; + xfree (pData); return BadMatch; } @@ -883,21 +1034,24 @@ ProcRRSetScreenConfig (ClientPtr client) if (rate) { - for (i = 0; i < pSize->nRates; i++) + for (i = 0; i < pSize->nrefresh; i++) { - RRScreenRatePtr pRate = &pSize->pRates[i]; - if (pRate->referenced && pRate->rate == rate) + if (pSize->refresh[i].refresh == rate) break; } - if (i == pSize->nRates) + if (i == pSize->nrefresh) { /* * Invalid rate */ client->errorValue = rate; + xfree (pData); return BadValue; } + pMode = pSize->refresh[i].pMode; } + else + pMode = pSize->refresh[0].pMode; /* * Make sure the requested set-time is not older than @@ -912,9 +1066,51 @@ ProcRRSetScreenConfig (ClientPtr client) /* * call out to ddx routine to effect the change */ - if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, - pSize)) + if (pScrPriv->rrSetScreenSize && pScrPriv->rrSetMode) { + xScreenSizes oldSize; + if (!(*pScrPriv->rrSetMode) (pScreen, 0, NULL, 0, 0, RR_Rotate_0)) + goto fail; + oldSize.widthInPixels = pScreen->width; + oldSize.heightInPixels = pScreen->width; + oldSize.widthInMillimeters = pScreen->mmWidth; + oldSize.heightInMillimeters = pScreen->mmHeight; + if (!(*pScrPriv->rrSetScreenSize) (pScreen, + pMode->mode.width, + pMode->mode.height, + pMode->mode.widthInMillimeters, + pMode->mode.heightInMillimeters)) + { + (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, + pMonitor->x, pMonitor->y, + pMonitor->rotation); + goto fail; + } + if (!(*pScrPriv->rrSetMode) (pScreen, 0, pMode, 0, 0, rotation)) + { + (void) (*pScrPriv->rrSetScreenSize) (pScreen, + oldSize.widthInPixels, + oldSize.heightInPixels, + oldSize.widthInMillimeters, + oldSize.heightInMillimeters); + (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, + pMonitor->x, pMonitor->y, + pMonitor->rotation); + goto fail; + } + } +#ifdef RANDR_SCREEN_INTERFACE + else if (pScrPriv->rrSetConfig) + { + if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, pSize)) + { + goto fail; + } + } +#endif + else + { +fail: ; /* * unknown DDX failure, report to client */ @@ -925,7 +1121,7 @@ ProcRRSetScreenConfig (ClientPtr client) /* * set current extension configuration pointers */ - RRSetCurrentConfig (pScreen, rotation, rate, pSize); + RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); /* * Deliver ScreenChangeNotify events whenever @@ -954,6 +1150,9 @@ ProcRRSetScreenConfig (ClientPtr client) sendReply: + if (pData) + xfree (pData); + rep.type = X_Reply; /* rep.status has already been filled in */ rep.length = 0; @@ -1055,7 +1254,7 @@ RRSetScreenConfig (ScreenPtr pScreen, /* * set current extension configuration pointers */ - RRSetCurrentConfig (pScreen, rotation, rate, pSize); + RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); /* * Deliver ScreenChangeNotify events whenever @@ -1075,7 +1274,6 @@ RRSetScreenConfig (ScreenPtr pScreen, * Fix pointer bounds and location */ ScreenRestructured (pScreen); - return Success; } @@ -1286,22 +1484,114 @@ SProcRRDispatch (ClientPtr client) } } - -static Bool -RRScreenSizeMatches (RRScreenSizePtr a, - RRScreenSizePtr b) +/* + * Register a monitor for a screen. identifier is a unique identifier + * for the monitors of a particular screen. + */ +RRMonitorPtr +RRRegisterMonitor (ScreenPtr pScreen, + void *identifier, + Rotation rotations) { - if (a->width != b->width) - return FALSE; - if (a->height != b->height) - return FALSE; - if (a->mmWidth != b->mmWidth) - return FALSE; - if (a->mmHeight != b->mmHeight) - return FALSE; - return TRUE; + rrScrPriv (pScreen); + RRMonitorPtr pMonitor, *pPrev, *pInsert; + + pInsert = NULL; + for (pPrev = &pScrPriv->pMonitors; (pMonitor = *pPrev); + pPrev = &(pMonitor)->next) + { + if (pMonitor->identifier == identifier) + { + pMonitor->referenced = TRUE; + return pMonitor; + } + if (!pMonitor->referenced) + pInsert = pPrev; + } + if (!pInsert) + pInsert = pPrev; + + /* + * New monitor, add before the first unreferenced monitor + */ + pMonitor = xalloc (sizeof (RRMonitor)); + if (!pMonitor) + return NULL; + pMonitor->pScreen = pScreen; + pMonitor->pModes = NULL; + pMonitor->identifier = identifier; + pMonitor->referenced = TRUE; + pMonitor->oldReferenced = FALSE; + pMonitor->rotations = RR_Rotate_0; + + pMonitor->pMode = NULL; + pMonitor->x = 0; + pMonitor->y = 0; + pMonitor->rotation = RR_Rotate_0; + pMonitor->next = *pInsert; + *pInsert = pMonitor; + return pMonitor; } +/* + * Register a mode for a monitor + */ + +RRModePtr +RRRegisterMode (RRMonitorPtr pMonitor, + xRRMonitorMode *pModeline, + char *name) +{ + RRModePtr pMode, *pPrev, *pInsert = NULL; + + /* + * Find existing mode with same modeline and name + */ + for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &(pMode->next)) + { + if (!memcmp (&pMode->mode, pModeline, sizeof (xRRMonitorMode)) && + pMode->mode.nameLength == pModeline->nameLength && + !memcmp (RRModeName(pMode), name, pModeline->nameLength)) + { + pMode->referenced = TRUE; + return pMode; + } + if (!pMode->referenced) + pInsert = pPrev; + } + + if (!pInsert) + pInsert = pPrev; + + /* + * Create a new mode, inserting before the first unreferenced mode + */ + pMode = xalloc (sizeof (RRMode) + pModeline->nameLength + 1); + pMode->referenced = TRUE; + pMode->oldReferenced = FALSE; + pMode->mode = *pModeline; + memcpy (RRModeName (pMode), name, pModeline->nameLength); + RRModeName(pMode)[pModeline->nameLength] = '\0'; + pMode->next = *pInsert; + *pInsert = pMode; + return pMode; +} + +void +RRSetCurrentMode (RRMonitorPtr pMonitor, + RRModePtr pMode, + int x, + int y, + Rotation rotation) +{ + pMonitor->pMode = pMode; + pMonitor->x = x; + pMonitor->y = y; + pMonitor->rotation = rotation; +} + +#ifdef RANDR_SCREEN_INTERFACE + RRScreenSizePtr RRRegisterSize (ScreenPtr pScreen, short width, @@ -1310,36 +1600,45 @@ RRRegisterSize (ScreenPtr pScreen, short mmHeight) { rrScrPriv (pScreen); - int i; - RRScreenSize tmp; - RRScreenSizePtr pNew; + xRRMonitorMode tmp; + RRMonitorPtr pMonitor; + RRModePtr pMode, *pPrev; + char name[100]; if (!pScrPriv) - return 0; + return NULL; + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + return NULL; - tmp.id = -1; + for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &(pMode->next)) + if (pMode->mode.width == width && + pMode->mode.height == height && + pMode->mode.widthInMillimeters == mmWidth && + pMode->mode.heightInMillimeters == mmHeight) + { + pMode->referenced =TRUE; + return (void *) pMode; + } + memset (&tmp, '\0', sizeof (xRRMonitorMode)); + memset (name, '\0', sizeof (name)); + sprintf (name, "%dx%d", width, height); tmp.width = width; tmp.height= height; - tmp.mmWidth = mmWidth; - tmp.mmHeight = mmHeight; - tmp.pRates = 0; - tmp.nRates = 0; - tmp.nRatesInUse = 0; - tmp.referenced = TRUE; - tmp.oldReferenced = FALSE; - for (i = 0; i < pScrPriv->nSizes; i++) - if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i])) - { - pScrPriv->pSizes[i].referenced = TRUE; - return &pScrPriv->pSizes[i]; - } - pNew = xrealloc (pScrPriv->pSizes, - (pScrPriv->nSizes + 1) * sizeof (RRScreenSize)); - if (!pNew) - return 0; - pNew[pScrPriv->nSizes++] = tmp; - pScrPriv->pSizes = pNew; - return &pNew[pScrPriv->nSizes-1]; + tmp.widthInMillimeters = mmWidth; + tmp.heightInMillimeters = mmHeight; + tmp.nameLength = strlen (name) + 10; /* leave space for refresh */ + pMode = RRRegisterMode (pMonitor, &tmp, name); + return (void *) pMode; +} + +static Bool +RRModesMatchSize (RRModePtr a, RRModePtr b) +{ + return (a->mode.width == a->mode.width && + a->mode.height == b->mode.height && + a->mode.widthInMillimeters == b->mode.widthInMillimeters && + a->mode.heightInMillimeters == b->mode.heightInMillimeters); } Bool RRRegisterRate (ScreenPtr pScreen, @@ -1347,31 +1646,61 @@ Bool RRRegisterRate (ScreenPtr pScreen, int rate) { rrScrPriv(pScreen); - int i; - RRScreenRatePtr pNew, pRate; + RRMonitorPtr pMonitor; + RRModePtr pSizeMode = (RRModePtr) pSize; + RRModePtr pMode, *pPrev; + CARD16 width = pSizeMode->mode.width; + CARD16 height = pSizeMode->mode.height; + char name[100]; + xRRMonitorMode modeLine; if (!pScrPriv) return FALSE; - for (i = 0; i < pSize->nRates; i++) + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + return FALSE; + + for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &pMode->next) { - pRate = &pSize->pRates[i]; - if (pRate->rate == rate) + if (RRModesMatchSize (pMode, pSizeMode)) { - pRate->referenced = TRUE; - return TRUE; + if (pMode->mode.dotClock == 0) + { + /* + * First refresh for this size; reprogram this mode + * with the right refresh. + */ + pMode->mode.hSyncStart = width; + pMode->mode.hSyncEnd = width; + pMode->mode.hTotal = width; + pMode->mode.hSkew = 0; + pMode->mode.vSyncStart = height; + pMode->mode.vSyncEnd = height; + pMode->mode.vTotal = height; + pMode->mode.dotClock = width * height * rate; + sprintf ((char *) (pMode + 1), "%dx%d@%d", width, height, rate); + pMode->mode.modeFlags = 0; + pMode->mode.nameLength = strlen ((char *) (pMode + 1)); + pMode->referenced = TRUE; + return TRUE; + } + else if (rate == RRVerticalRefresh (&pMode->mode)) + { + pMode->referenced = TRUE; + return TRUE; + } } } - - pNew = xrealloc (pSize->pRates, - (pSize->nRates + 1) * sizeof (RRScreenRate)); - if (!pNew) + + sprintf (name, "%dx%d@%d", pSizeMode->mode.width, pSizeMode->mode.height, + rate); + modeLine = pSizeMode->mode; + modeLine.dotClock = rate * modeLine.vTotal * modeLine.hTotal; + modeLine.nameLength = strlen (name); + pMode = RRRegisterMode (pMonitor, &modeLine, name); + if (!pMode) return FALSE; - pRate = &pNew[pSize->nRates++]; - pRate->rate = rate; - pRate->referenced = TRUE; - pRate->oldReferenced = FALSE; - pSize->pRates = pNew; return TRUE; } @@ -1379,11 +1708,15 @@ Rotation RRGetRotation(ScreenPtr pScreen) { rrScrPriv (pScreen); + RRMonitorPtr pMonitor; if (!pScrPriv) return RR_Rotate_0; - return pScrPriv->rotation; + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + return RR_Rotate_0; + return pMonitor->rotation; } void @@ -1393,11 +1726,25 @@ RRSetCurrentConfig (ScreenPtr pScreen, RRScreenSizePtr pSize) { rrScrPriv (pScreen); + RRMonitorPtr pMonitor; + RRModePtr pMode; + RRModePtr pSizeMode = (RRModePtr) pSize; if (!pScrPriv) return; + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + return; - pScrPriv->rotation = rotation; - pScrPriv->size = pSize - pScrPriv->pSizes; - pScrPriv->rate = rate; + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + { + if (RRModesMatchSize (pMode, pSizeMode) && + RRVerticalRefresh (&pMode->mode) == rate) + break; + } + if (!pMode) + return; + + RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); } +#endif diff --git a/randr/randrstr.h b/randr/randrstr.h index 07c6c3798..3610274cc 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -34,11 +34,19 @@ #include +#define RANDR_SCREEN_INTERFACE 1 + +/* + * Modeline for a monitor. Name follows directly after this struct + */ + +#define RRModeName(pMode) ((char *) (pMode + 1)) + typedef struct _rrMode { struct _rrMode *next; - int id; Bool referenced; Bool oldReferenced; + int id; xRRMonitorMode mode; } RRMode, *RRModePtr; @@ -47,12 +55,15 @@ typedef struct _rrMonitor { ScreenPtr pScreen; RRModePtr pModes; void *identifier; /* made unique by DDX */ + int id; /* index in list of monitors */ Bool referenced; + Bool oldReferenced; + Rotation rotations; /* * Current state */ - int mode; + RRModePtr pMode; int x, y; Rotation rotation; } RRMonitor, *RRMonitorPtr; @@ -76,7 +87,18 @@ typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); #ifdef RANDR_SCREEN_INTERFACE -typedef void *RRScreenSizePtr; +typedef struct _rrRefresh { + CARD16 refresh; + RRModePtr pMode; +} RRRefreshRec, *RRRefreshPtr; + +typedef struct _rrScreenSize { + int id; + short width, height; + short mmWidth, mmHeight; + int nrefresh; + RRRefreshPtr refresh; +} RRScreenSizeRec, *RRScreenSizePtr; typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, Rotation rotation, @@ -87,12 +109,23 @@ typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, typedef struct _rrScrPriv { - RRSetModeProcPtr rrSetMode; + /* + * 'public' part of the structure; DDXen fill this in + * as they initialize + */ +#ifdef RANDR_SCREEN_INTERFACE + RRSetConfigProcPtr rrSetConfig; +#endif RRGetInfoProcPtr rrGetInfo; - RRCloseScreenProcPtr CloseScreen; + RRSetScreenSizeProcPtr rrSetScreenSize; + RRSetModeProcPtr rrSetMode; + /* + * Private part of the structure; not considered part of the ABI + */ TimeStamp lastSetTime; /* last changed by client */ TimeStamp lastConfigTime; /* possible configs changed */ + RRCloseScreenProcPtr CloseScreen; /* * monitor data @@ -105,7 +138,6 @@ typedef struct _rrScrPriv { */ Rotation rotations; - RRSetConfigProcPtr rrSetConfig; Rotation rotation; #endif @@ -137,8 +169,7 @@ RRRegisterMonitor (ScreenPtr pScreen, RRModePtr RRRegisterMode (RRMonitorPtr pMonitor, xRRMonitorMode *pMode, - char *name, - int nameLength); + char *name); /* * Finally, set the current configuration of each monitor @@ -147,6 +178,8 @@ RRRegisterMode (RRMonitorPtr pMonitor, void RRSetCurrentMode (RRMonitorPtr pMonitor, RRModePtr pMode, + int x, + int y, Rotation rotation); Bool RRScreenInit(ScreenPtr pScreen); @@ -167,6 +200,8 @@ Bool miRRSetMode (ScreenPtr pScreen, int monitor, RRModePtr pMode, + int x, + int y, Rotation rotation); #ifdef RANDR_SCREEN_INTERFACE From 8dec74321d916f204f8182f1b93a65defbe50e78 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 17 Jul 2006 14:43:07 -0400 Subject: [PATCH 003/109] Successful legacy RandR API/Protocol emulation for query. These changes clean up minor errors to make it possible to list the available modes for a monitor using legacy APIs in both the X server DDX and RandR protocol. Setting modes is untested, so it probably doesn't work. --- randr/randr.c | 331 +++++++++++++++++++++++++++----------------------- 1 file changed, 178 insertions(+), 153 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 4a5cd4e1d..58d8f177f 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -542,6 +542,7 @@ RRGetInfo (ScreenPtr pScreen) pMode->id = modeid++; if (!pMode->oldReferenced) changed = TRUE; + pPrevMode = &pMode->next; } else { @@ -550,6 +551,7 @@ RRGetInfo (ScreenPtr pScreen) RRFreeMode (pMode); } } + pPrevMon = &pMonitor->next; } else { @@ -716,6 +718,7 @@ RR10GetData (ScreenPtr pScreen, RRMonitorPtr pMonitor) return NULL; size = (RRScreenSizePtr) (data + 1); refresh = (RRRefreshPtr) (size + nmode); + data->sizes = size; data->nsize = 0; data->nrefresh = 0; data->size = 0; @@ -728,6 +731,7 @@ RR10GetData (ScreenPtr pScreen, RRMonitorPtr pMonitor) break; if (i == data->nsize) { + size[i].id = i; size[i].width = pMode->mode.width; size[i].height = pMode->mode.height; size[i].mmWidth = pMode->mode.widthInMillimeters; @@ -823,7 +827,7 @@ ProcRRGetScreenInfo (ClientPtr client) rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; rep.rotation = pMonitor->rotation; rep.nSizes = pData->nsize; - rep.nrateEnts = pData->nrefresh; + rep.nrateEnts = pData->nrefresh + pData->nsize; rep.sizeID = pData->size; rep.rate = pData->refresh; @@ -903,6 +907,97 @@ ProcRRGetScreenInfo (ClientPtr client) return (client->noClientException); } +static int +RRMonitorSetMode (ScreenPtr pScreen, RRMonitorPtr pMonitor, + RRModePtr pMode, int x, int y, Rotation rotation, + TimeStamp time) +{ + rrScrPriv(pScreen); + short oldWidth, oldHeight; + + oldWidth = pScreen->width; + oldHeight = pScreen->height; + + /* + * call out to ddx routine to effect the change + */ + if (pScrPriv->rrSetScreenSize && pScrPriv->rrSetMode) + { + xScreenSizes oldSize; + if (!(*pScrPriv->rrSetMode) (pScreen, 0, NULL, 0, 0, RR_Rotate_0)) + return RRSetConfigFailed; + oldSize.widthInPixels = pScreen->width; + oldSize.heightInPixels = pScreen->width; + oldSize.widthInMillimeters = pScreen->mmWidth; + oldSize.heightInMillimeters = pScreen->mmHeight; + if (!(*pScrPriv->rrSetScreenSize) (pScreen, + pMode->mode.width, + pMode->mode.height, + pMode->mode.widthInMillimeters, + pMode->mode.heightInMillimeters)) + { + (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, + pMonitor->x, pMonitor->y, + pMonitor->rotation); + return RRSetConfigFailed; + } + if (!(*pScrPriv->rrSetMode) (pScreen, 0, pMode, 0, 0, rotation)) + { + (void) (*pScrPriv->rrSetScreenSize) (pScreen, + oldSize.widthInPixels, + oldSize.heightInPixels, + oldSize.widthInMillimeters, + oldSize.heightInMillimeters); + (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, + pMonitor->x, pMonitor->y, + pMonitor->rotation); + return RRSetConfigFailed; + } + } +#ifdef RANDR_SCREEN_INTERFACE + else if (pScrPriv->rrSetConfig) + { + int rate = RRVerticalRefresh (&pMode->mode); + RRScreenSizeRec size; + + size.width = pMode->mode.width; + size.height = pMode->mode.height; + size.mmWidth = pMode->mode.widthInMillimeters; + size.mmHeight = pMode->mode.heightInMillimeters; + if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, &size)) + return RRSetConfigFailed; + } +#endif + else + return RRSetConfigFailed; + + /* + * set current extension configuration pointers + */ + RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); + + /* + * Deliver ScreenChangeNotify events whenever + * the configuration is updated + */ + WalkTree (pScreen, TellChanged, (pointer) pScreen); + + /* + * Deliver ConfigureNotify events when root changes + * pixel size + */ + if (oldWidth != pScreen->width || oldHeight != pScreen->height) + RRSendConfigNotify (pScreen); + RREditConnectionInfo (pScreen); + + /* + * Fix pointer bounds and location + */ + ScreenRestructured (pScreen); + pScrPriv->lastSetTime = time; + return RRSetConfigSuccess; +} + static int ProcRRSetScreenConfig (ClientPtr client) { @@ -917,7 +1012,6 @@ ProcRRSetScreenConfig (ClientPtr client) int i; Rotation rotation; int rate; - short oldWidth, oldHeight; Bool has_rate; RRMonitorPtr pMonitor; RRModePtr pMode; @@ -947,9 +1041,6 @@ ProcRRSetScreenConfig (ClientPtr client) time = ClientTimeToServerTime(stuff->timestamp); configTime = ClientTimeToServerTime(stuff->configTimestamp); - oldWidth = pScreen->width; - oldHeight = pScreen->height; - if (!pScrPriv) { time = currentTime; @@ -1063,90 +1154,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - /* - * call out to ddx routine to effect the change - */ - if (pScrPriv->rrSetScreenSize && pScrPriv->rrSetMode) - { - xScreenSizes oldSize; - if (!(*pScrPriv->rrSetMode) (pScreen, 0, NULL, 0, 0, RR_Rotate_0)) - goto fail; - oldSize.widthInPixels = pScreen->width; - oldSize.heightInPixels = pScreen->width; - oldSize.widthInMillimeters = pScreen->mmWidth; - oldSize.heightInMillimeters = pScreen->mmHeight; - if (!(*pScrPriv->rrSetScreenSize) (pScreen, - pMode->mode.width, - pMode->mode.height, - pMode->mode.widthInMillimeters, - pMode->mode.heightInMillimeters)) - { - (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, - pMonitor->x, pMonitor->y, - pMonitor->rotation); - goto fail; - } - if (!(*pScrPriv->rrSetMode) (pScreen, 0, pMode, 0, 0, rotation)) - { - (void) (*pScrPriv->rrSetScreenSize) (pScreen, - oldSize.widthInPixels, - oldSize.heightInPixels, - oldSize.widthInMillimeters, - oldSize.heightInMillimeters); - (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, - pMonitor->x, pMonitor->y, - pMonitor->rotation); - goto fail; - } - } -#ifdef RANDR_SCREEN_INTERFACE - else if (pScrPriv->rrSetConfig) - { - if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, pSize)) - { - goto fail; - } - } -#endif - else - { -fail: ; - /* - * unknown DDX failure, report to client - */ - rep.status = RRSetConfigFailed; - goto sendReply; - } - - /* - * set current extension configuration pointers - */ - RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); - - /* - * Deliver ScreenChangeNotify events whenever - * the configuration is updated - */ - WalkTree (pScreen, TellChanged, (pointer) pScreen); - - /* - * Deliver ConfigureNotify events when root changes - * pixel size - */ - if (oldWidth != pScreen->width || oldHeight != pScreen->height) - RRSendConfigNotify (pScreen); - RREditConnectionInfo (pScreen); - - /* - * Fix pointer bounds and location - */ - ScreenRestructured (pScreen); - pScrPriv->lastSetTime = time; - - /* - * Report Success - */ - rep.status = RRSetConfigSuccess; + rep.status = RRMonitorSetMode (pScreen, pMonitor, pMode, 0, 0, rotation, time); sendReply: @@ -1182,11 +1190,20 @@ RRSetScreenConfig (ScreenPtr pScreen, RRScreenSizePtr pSize) { rrScrPrivPtr pScrPriv; - int i; + RRMonitorPtr pMonitor; short oldWidth, oldHeight; + RRModePtr pMode; + int status; pScrPriv = rrGetScrPriv(pScreen); + if (!pScrPriv) + return BadImplementation; + + pMonitor = pScrPriv->pMonitors; + if (!pMonitor) + return BadImplementation; + oldWidth = pScreen->width; oldHeight = pScreen->height; @@ -1219,61 +1236,24 @@ RRSetScreenConfig (ScreenPtr pScreen, return BadMatch; } - /* - * Validate requested refresh - */ - if (rate) + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) { - for (i = 0; i < pSize->nRates; i++) + if (pMode->mode.width == pSize->width && + pMode->mode.height == pSize->height && + pMode->mode.widthInMillimeters == pSize->mmWidth && + pMode->mode.heightInMillimeters == pSize->mmHeight && + (RRVerticalRefresh (&pMode->mode) == rate || rate == 0)) { - RRScreenRatePtr pRate = &pSize->pRates[i]; - if (pRate->referenced && pRate->rate == rate) - break; - } - if (i == pSize->nRates) - { - /* - * Invalid rate - */ - return BadValue; + break; } } - - /* - * call out to ddx routine to effect the change - */ - if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, - pSize)) - { - /* - * unknown DDX failure, report to client - */ - return BadImplementation; - } + if (!pMode) + return BadValue; - /* - * set current extension configuration pointers - */ - RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); - - /* - * Deliver ScreenChangeNotify events whenever - * the configuration is updated - */ - WalkTree (pScreen, TellChanged, (pointer) pScreen); - - /* - * Deliver ConfigureNotify events when root changes - * pixel size - */ - if (oldWidth != pScreen->width || oldHeight != pScreen->height) - RRSendConfigNotify (pScreen); - RREditConnectionInfo (pScreen); - - /* - * Fix pointer bounds and location - */ - ScreenRestructured (pScreen); + status = RRMonitorSetMode (pScreen, pMonitor, pMode, 0, 0, + rotation, currentTime); + if (status != RRSetConfigSuccess) + return BadImplementation; return Success; } @@ -1387,23 +1367,63 @@ ProcRRSelectInput (ClientPtr client) } +static int ProcRRGetScreenSizeRange (ClientPtr pClient) +{ + return BadImplementation; +} + +static int ProcRRSetScreenSize (ClientPtr pClient) +{ + return BadImplementation; +} + +static int ProcRRGetMonitorInfo (ClientPtr pClient) +{ + return BadImplementation; +} + +static int ProcRRAddMonitorMode (ClientPtr pClient) +{ + return BadImplementation; +} + +static int ProcRRDeleteMonitorMode (ClientPtr pClient) +{ + return BadImplementation; +} + +static int ProcRRSetMonitorConfig (ClientPtr pClient) +{ + return BadImplementation; +} + +int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { + ProcRRQueryVersion, /* 0 */ +/* we skip 1 to make old clients fail pretty immediately */ + NULL, /* 1 ProcRandrOldGetScreenInfo */ +/* V1.0 apps share the same set screen config request id */ + ProcRRSetScreenConfig, /* 2 */ + NULL, /* 3 ProcRandrOldScreenChangeSelectInput */ +/* 3 used to be ScreenChangeSelectInput; deprecated */ + ProcRRSelectInput, /* 4 */ + ProcRRGetScreenInfo, /* 5 */ +/* V1.2 additions */ + ProcRRGetScreenSizeRange, /* 6 */ + ProcRRSetScreenSize, /* 7 */ + ProcRRGetMonitorInfo, /* 8 */ + ProcRRAddMonitorMode, /* 9 */ + ProcRRDeleteMonitorMode, /* 10 */ + ProcRRSetMonitorConfig, /* 11 */ +}; + + static int ProcRRDispatch (ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_RRQueryVersion: - return ProcRRQueryVersion(client); - case X_RRSetScreenConfig: - return ProcRRSetScreenConfig(client); - case X_RRSelectInput: - return ProcRRSelectInput(client); - case X_RRGetScreenInfo: - return ProcRRGetScreenInfo(client); - default: + if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data]) return BadRequest; - } + return (*ProcRandrVector[stuff->data]) (client); } static int @@ -1609,7 +1629,12 @@ RRRegisterSize (ScreenPtr pScreen, return NULL; pMonitor = pScrPriv->pMonitors; if (!pMonitor) - return NULL; + { + pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); + if (!pMonitor) + return NULL; + } + pMonitor->referenced = TRUE; for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &(pMode->next)) if (pMode->mode.width == width && From d17fb9672e238a089e463ac74cc4cd3325b67e1f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 16 Sep 2006 21:44:42 -0700 Subject: [PATCH 004/109] Start moving to new randr 1.2 definition --- randr/mirandr.c | 123 +++-- randr/randr.c | 1352 +++++++++++++++++++++++++++++----------------- randr/randrstr.h | 235 +++++--- 3 files changed, 1078 insertions(+), 632 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index e15213327..5aea38d60 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -34,6 +34,29 @@ #include "randrstr.h" #include +Bool +miRRGetInfo (ScreenPtr pScreen, Rotation *rotations) +{ + return TRUE; +} + +/* + * Any hardware that can actually change anything will need something + * different here + */ +Bool +miRRCrtcSet (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutput, + RROutputPtr *outputs) +{ + return TRUE; +} + /* * This function assumes that only a single depth can be * displayed at a time, but that all visuals of that depth @@ -43,70 +66,52 @@ * XXX what to do here.... */ -Bool -miRRGetInfo (ScreenPtr pScreen, Rotation *rotations) -{ - int i; - Bool setConfig = FALSE; - RRMonitorPtr pMonitor; - - pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); - for (i = 0; i < pScreen->numDepths; i++) - { - if (pScreen->allowedDepths[i].numVids) - { - xRRMonitorMode rrMode; - RRModePtr pMode; - char name[64]; - - sprintf (name, "%dx%d", pScreen->width, pScreen->height); - memset (&rrMode, '\0', sizeof (rrMode)); - rrMode.width = pScreen->width; - rrMode.height = pScreen->height; - rrMode.widthInMillimeters = pScreen->mmWidth; - rrMode.heightInMillimeters = pScreen->mmHeight; - rrMode.nameLength = strlen (name); - pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); - pMode = RRRegisterMode (pMonitor, - &rrMode, - name); - if (!pMode) - return FALSE; - if (!setConfig) - { - RRSetCurrentMode (pMonitor, pMode, 0, 0, RR_Rotate_0); - setConfig = TRUE; - } - } - } - return TRUE; -} - -/* - * Any hardware that can actually change anything will need something - * different here - */ -Bool -miRRSetMode (ScreenPtr pScreen, - int monitor, - RRModePtr pMode, - int x, - int y, - Rotation rotation) -{ - return TRUE; -} - - Bool miRandRInit (ScreenPtr pScreen) { - rrScrPrivPtr rp; + rrScrPrivPtr pScrPriv; + RRModePtr mode; + RRCrtcPtr crtc; + RROutputPtr output; + xRRModeInfo modeInfo; + char name[64]; if (!RRScreenInit (pScreen)) return FALSE; - rp = rrGetScrPriv(pScreen); - rp->rrGetInfo = miRRGetInfo; - rp->rrSetMode = miRRSetMode; + pScrPriv = rrGetScrPriv(pScreen); + pScrPriv->rrGetInfo = miRRGetInfo; + pScrPriv->rrCrtcSet = miRRCrtcSet; + + RRScreenSetSizeRange (pScreen, + pScreen->width, pScreen->height, + pScreen->width, pScreen->height); + + sprintf (name, "%dx%d", pScreen->width, pScreen->height); + memset (&modeInfo, '\0', sizeof (modeInfo)); + modeInfo.width = pScreen->width; + modeInfo.height = pScreen->height; + modeInfo.mmWidth = pScreen->mmWidth; + modeInfo.mmHeight = pScreen->mmHeight; + modeInfo.nameLength = strlen (name); + + mode = RRModeGet (pScreen, &modeInfo, name); + if (!mode) + return FALSE; + + crtc = RRCrtcCreate (pScreen, NULL); + if (!crtc) + return FALSE; + + output = RROutputCreate (pScreen, "screen", 6, NULL); + if (!output) + return FALSE; + if (!RROutputSet (output, + NULL, 0, /* clones */ + &mode, 1, /* modes */ + &crtc, 1, /* crtcs */ + RR_Connected)) + return FALSE; + if (!RRCrtcSet (crtc, mode, 0, 0, RR_Rotate_0, 1, &output)) + return FALSE; return TRUE; } diff --git a/randr/randr.c b/randr/randr.c index 58d8f177f..e34b82c2f 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -60,6 +60,8 @@ int RRGeneration; int RRNScreens; +static RESTYPE ModeType, CrtcType, OutputType; + static int ProcRRQueryVersion (ClientPtr pClient); static int ProcRRDispatch (ClientPtr pClient); static int SProcRRDispatch (ClientPtr pClient); @@ -160,21 +162,16 @@ static Bool RRCloseScreen (int i, ScreenPtr pScreen) { rrScrPriv(pScreen); - RRMonitorPtr pMonitor; + int j; unwrap (pScrPriv, pScreen, CloseScreen); - while ((pMonitor = pScrPriv->pMonitors)) - { - RRModePtr pMode; - - pScrPriv->pMonitors = pMonitor->next; - while ((pMode = pMonitor->pModes)) - { - pMonitor->pModes = pMode->next; - xfree (pMode); - } - xfree (pMonitor); - } + for (j = pScrPriv->numCrtcs - 1; j >= 0; j--) + RRCrtcDestroy (pScrPriv->crtcs[j]); + for (j = pScrPriv->numOutputs - 1; j >= 0; j--) + RROutputDestroy (pScrPriv->outputs[j]); + for (j = pScrPriv->numModes - 1; j >= 0; j--) + RRModeDestroy (pScrPriv->modes[j]); + xfree (pScrPriv); RRNScreens -= 1; /* ok, one fewer screen with RandR running */ return (*pScreen->CloseScreen) (i, pScreen); @@ -199,6 +196,7 @@ SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from, cpswaps(from->subpixelOrder, to->subpixelOrder); } +#if 0 static void SRRMonitorChangeNotifyEvent(xRRMonitorChangeNotifyEvent *from, xRRMonitorChangeNotifyEvent *to) @@ -217,30 +215,68 @@ SRRMonitorChangeNotifyEvent(xRRMonitorChangeNotifyEvent *from, cpswaps(from->x, to->x); cpswaps(from->y, to->y); } +#endif static void SRRNotifyEvent (xEvent *from, xEvent *to) { switch (from->u.u.detail) { +#if 0 case RRNotify_MonitorChange: SRRMonitorChangeNotifyEvent ((xRRMonitorChangeNotifyEvent *) from, (xRRMonitorChangeNotifyEvent *) to); break; +#endif default: break; } } +static int +RRModeDestroyResource (pointer value, XID pid) +{ + RRModeDestroy ((RRModePtr) value); + return 1; +} + +static int +RRCrtcDestroyResource (pointer value, XID pid) +{ + RRCrtcDestroy ((RRCrtcPtr) value); + return 1; +} + +static int +RROutputDestroyResource (pointer value, XID pid) +{ + RROutputDestroy ((RROutputPtr) value); + return 1; +} + Bool RRScreenInit(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; if (RRGeneration != serverGeneration) { + ModeType = CreateNewResourceType (RRModeDestroyResource); + if (!ModeType) + return FALSE; + CrtcType = CreateNewResourceType (RRCrtcDestroyResource); + if (!ModeType) + return FALSE; + OutputType = CreateNewResourceType (RROutputDestroyResource); + if (!ModeType) + return FALSE; if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0) return FALSE; RRGeneration = serverGeneration; +#ifdef XResExtension + RegisterResourceName (ModeType, "MODE"); + RegisterResourceName (CrtcType, "CRTC"); + RegisterResourceName (OutputType, "OUTPUT"); +#endif } pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec)); @@ -252,10 +288,14 @@ Bool RRScreenInit(ScreenPtr pScreen) /* * Calling function best set these function vectors */ - pScrPriv->rrSetMode = 0; + pScrPriv->rrCrtcSet = 0; pScrPriv->rrGetInfo = 0; + pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width; + pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; #ifdef RANDR_SCREEN_INTERFACE pScrPriv->rrSetConfig = 0; + pScrPriv->reqWidth = pScreen->width; + pScrPriv->reqHeight = pScreen->height; #endif /* @@ -268,7 +308,12 @@ Bool RRScreenInit(ScreenPtr pScreen) wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen); - pScrPriv->pMonitors = NULL; + pScrPriv->numModes = 0; + pScrPriv->modes = NULL; + pScrPriv->numOutputs = 0; + pScrPriv->outputs = NULL; + pScrPriv->numCrtcs = 0; + pScrPriv->crtcs = NULL; RRNScreens += 1; /* keep count of screens that implement randr */ return TRUE; @@ -356,18 +401,77 @@ RRExtensionInit (void) return; } +static void +DeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + xRRScreenChangeNotifyEvent se; + RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; + RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL; + RRModePtr mode = crtc ? crtc->mode : NULL; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + int i; + + se.type = RRScreenChangeNotify + RREventBase; + se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); + se.timestamp = pScrPriv->lastSetTime.milliseconds; + se.sequenceNumber = client->sequence; + se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + se.root = pRoot->drawable.id; + se.window = pWin->drawable.id; +#ifdef RENDER + se.subpixelOrder = PictureGetSubpixelOrder (pScreen); +#else + se.subpixelOrder = SubPixelUnknown; +#endif + + se.sequenceNumber = client->sequence; + if (mode) + { + se.sizeID = -1; + for (i = 0; i < output->numModes; i++) + if (mode == output->modes[i]) + { + se.sizeID = i; + break; + } + se.widthInPixels = mode->mode.width; + se.heightInPixels = mode->mode.height; + se.widthInMillimeters = mode->mode.mmWidth; + se.heightInMillimeters = mode->mode.mmHeight; + } + else + { + /* + * This "shouldn't happen", but a broken DDX can + * forget to set the current configuration on GetInfo + */ + se.sizeID = 0xffff; + se.widthInPixels = 0; + se.heightInPixels = 0; + se.widthInMillimeters = 0; + se.heightInMillimeters = 0; + } + WriteEventsToClient (client, 1, (xEvent *) &se); +} + +static void +DeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) +{ +} + +static void +DeliverOutputEvent (ClientPtr client, WindowPtr pWin, RROutputPtr output) +{ +} + static int TellChanged (WindowPtr pWin, pointer value) { RREventPtr *pHead, pRREvent; ClientPtr client; - xRRScreenChangeNotifyEvent se; - xRRMonitorChangeNotifyEvent me; ScreenPtr pScreen = pWin->drawable.pScreen; rrScrPriv(pScreen); - RRModePtr pMode; - RRMonitorPtr pMonitor; - WindowPtr pRoot = WindowTable[pScreen->myNum]; int i; pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, EventType); @@ -380,192 +484,245 @@ TellChanged (WindowPtr pWin, pointer value) if (client == serverClient || client->clientGone) continue; - if (pRREvent->mask & RRMonitorChangeNotifyMask) + if (pRREvent->mask & RRScreenChangeNotifyMask) + DeliverScreenEvent (client, pWin, pScreen); + + if (pRREvent->mask & RRCrtcChangeNotifyMask) { - me.type = RRNotify + RREventBase; - me.subCode = RRNotify_MonitorChange; - me.timestamp = pScrPriv->lastSetTime.milliseconds; - me.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - me.root = pRoot->drawable.id; - me.window = pWin->drawable.id; -#ifdef RENDER - me.subpixelOrder = PictureGetSubpixelOrder (pScreen); -#else - me.subpixelOrder = SubPixelUnknown; -#endif - for (pMonitor = pScrPriv->pMonitors, i = 0; - pMonitor; - pMonitor = pMonitor->next, i++) + for (i = 0; i < pScrPriv->numCrtcs; i++) { - me.monitor = i; - if (pMonitor->pMode) { - me.modeID = pMonitor->pMode->id; - me.rotation = pMonitor->rotation; - me.x = pMonitor->x; - me.y = pMonitor->y; - } else { - me.modeID = 0xffff; - me.rotation = RR_Rotate_0; - me.x = 0; - me.y = 0; - } - WriteEventsToClient (client, 1, (xEvent *) &me); + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + if (crtc->changed) + DeliverCrtcEvent (client, pWin, crtc); } } - if ((pRREvent->mask & RRScreenChangeNotifyMask) && - (pMonitor = pScrPriv->pMonitors)) + + if (pRREvent->mask & RROutputChangeNotifyMask) { - se.type = RRScreenChangeNotify + RREventBase; - se.rotation = (CARD8) pMonitor->rotation; - se.timestamp = pScrPriv->lastSetTime.milliseconds; - se.sequenceNumber = client->sequence; - se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - se.root = pRoot->drawable.id; - se.window = pWin->drawable.id; -#ifdef RENDER - se.subpixelOrder = PictureGetSubpixelOrder (pScreen); -#else - se.subpixelOrder = SubPixelUnknown; -#endif - - pMonitor = &pScrPriv->pMonitors[0]; - se.sequenceNumber = client->sequence; - if (pMonitor->pMode) + for (i = 0; i < pScrPriv->numOutputs; i++) { - pMode = pMonitor->pMode; - se.sizeID = pMode->id; - se.widthInPixels = pMode->mode.width; - se.heightInPixels = pMode->mode.height; - se.widthInMillimeters = pMode->mode.widthInMillimeters; - se.heightInMillimeters = pMode->mode.heightInMillimeters; + RROutputPtr output = pScrPriv->outputs[i]; + if (output->changed) + DeliverOutputEvent (client, pWin, output); } - else - { - /* - * This "shouldn't happen", but a broken DDX can - * forget to set the current configuration on GetInfo - */ - se.sizeID = 0xffff; - se.widthInPixels = 0; - se.heightInPixels = 0; - se.widthInMillimeters = 0; - se.heightInMillimeters = 0; - } - WriteEventsToClient (client, 1, (xEvent *) &se); } } return WT_WALKCHILDREN; } -static void -RRFreeMode (RRModePtr pMode) +void +RRTellChanged (ScreenPtr pScreen) { - xfree (pMode); -} - -static void -RRFreeModes (RRModePtr pHead) -{ - RRModePtr pMode; - while ((pMode = pHead)) + rrScrPriv (pScreen); + int i; + + if (pScrPriv->changed) { - pHead = pMode->next; - RRFreeMode (pMode); + UpdateCurrentTime (); + pScrPriv->lastConfigTime = currentTime; + WalkTree (pScreen, TellChanged, (pointer) pScreen); + pScrPriv->changed = FALSE; + for (i = 0; i < pScrPriv->numOutputs; i++) + pScrPriv->outputs[i]->changed = FALSE; + for (i = 0; i < pScrPriv->numCrtcs; i++) + pScrPriv->crtcs[i]->changed = FALSE; } } -static void -RRFreeMonitor (RRMonitorPtr pMonitor) +RRModePtr +RRModeGet (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + char *name) { - RRFreeModes (pMonitor->pModes); - xfree (pMonitor); + rrScrPriv (pScreen); + int i; + RRModePtr mode; + + for (i = 0; i < pScrPriv->numModes; i++) + { + mode = pScrPriv->modes[i]; + if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) && + !memcmp (name, mode->name, modeInfo->nameLength)) + { + ++mode->refcnt; + return mode; + } + } + mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1); + mode->refcnt = 1; + mode->mode = *modeInfo; + mode->name = (char *) (mode + 1); + memcpy (mode->name, name, modeInfo->nameLength); + mode->name[modeInfo->nameLength] = '\0'; + mode->id = FakeClientID(0); + if (!AddResource (mode->id, ModeType, (pointer) mode)) + return NULL; + ++mode->refcnt; + pScrPriv->changed = TRUE; + return mode; } +void +RRModeDestroy (RRModePtr mode) +{ + if (--mode->refcnt > 0) + return; + xfree (mode); +} + +/* + * Return the first output which is connected to an active CRTC + * Used in emulating 1.0 behaviour + */ +static RROutputPtr +RRFirstOutput (ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + RROutputPtr output; + int i, j; + + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + for (j = 0; j < pScrPriv->numOutputs; j++) + { + output = pScrPriv->outputs[j]; + if (output->crtc == crtc) + return output; + } + } + return NULL; +} + +#ifdef RANDR_SCREEN_INTERFACE + +static Bool +RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) +{ + xRRModeInfo modeInfo; + char name[100]; + RRModePtr mode; + int i; + RRModePtr *modes; + + memset (&modeInfo, '\0', sizeof (modeInfo)); + sprintf (name, "%dx%d", size->width, size->height); + + modeInfo.width = size->width; + modeInfo.height = size->height; + modeInfo.mmWidth = size->mmWidth; + modeInfo.mmHeight = size->mmHeight; + modeInfo.hTotal = size->width; + modeInfo.vTotal = size->height; + modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->width * + (CARD32) refresh); + modeInfo.nameLength = strlen (name); + mode = RRModeGet (output->pScreen, &modeInfo, name); + if (!mode) + return FALSE; + for (i = 0; i < output->numModes; i++) + if (output->modes[i] == mode) + return TRUE; + + if (output->numModes) + modes = xrealloc (output->modes, + (output->numModes + 1) * sizeof (RRModePtr)); + else + modes = xalloc (sizeof (RRModePtr)); + if (!modes) + return FALSE; + modes[output->numModes++] = mode; + output->modes = modes; + output->changed = TRUE; + return TRUE; +} + +static void +RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) +{ + rrScrPriv(pScreen); + RROutputPtr output = RRFirstOutput (pScreen); + RRCrtcPtr crtc; + int i; + CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; + CARD16 maxWidth = 0, maxHeight = 0; + + if (!output) + return; + crtc = output->crtc; + + /* check rotations */ + if (rotations != crtc->rotations) + { + crtc->rotations = rotations; + crtc->changed = TRUE; + pScrPriv->changed = TRUE; + } + + /* regenerate mode list */ + for (i = 0; i < pScrPriv->nSizes; i++) + { + RRScreenSizePtr size = &pScrPriv->pSizes[i]; + int r; + + if (size->nRates) + for (r = 0; r < size->nRates; r++) + RROldModeAdd (output, size, size->pRates[r].rate); + else + RROldModeAdd (output, size, 0); + } + + /* find size bounds */ + for (i = 0; i < output->numModes; i++) + { + RRModePtr mode = output->modes[i]; + CARD16 width = mode->mode.width; + CARD16 height = mode->mode.height; + + if (width < minWidth) minWidth = width; + if (width > maxWidth) maxWidth = width; + if (height < minHeight) minHeight = height; + if (height > maxHeight) maxHeight = height; + } + + if (minWidth != pScrPriv->minWidth) { + pScrPriv->minWidth = minWidth; pScrPriv->changed = TRUE; + } + if (maxWidth != pScrPriv->maxWidth) { + pScrPriv->maxWidth = maxWidth; pScrPriv->changed = TRUE; + } + if (minHeight != pScrPriv->minHeight) { + pScrPriv->minHeight = minHeight; pScrPriv->changed = TRUE; + } + if (maxHeight != pScrPriv->maxHeight) { + pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE; + } +} +#endif static Bool RRGetInfo (ScreenPtr pScreen) { rrScrPriv (pScreen); - Bool changed; Rotation rotations; - RRMonitorPtr pMonitor, *pPrevMon; - RRModePtr pMode, *pPrevMode; - int monitorid; + int i; - for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) - { - pMonitor->oldReferenced = TRUE; - pMonitor->referenced = FALSE; - pMonitor->pMode = NULL; - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - pMode->oldReferenced = TRUE; - pMode->referenced = FALSE; - } - } + for (i = 0; i < pScrPriv->numOutputs; i++) + pScrPriv->outputs[i]->changed = FALSE; + for (i = 0; i < pScrPriv->numCrtcs; i++) + pScrPriv->crtcs[i]->changed = FALSE; + rotations = 0; + pScrPriv->changed = FALSE; + if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) return FALSE; - changed = FALSE; - - /* Old GetInfo clients return rotations here */ - if (rotations && pScrPriv->pMonitors) { - /* - * Check whether anything changed and simultaneously generate - * the protocol id values for the objects - */ - if (rotations != pScrPriv->pMonitors->rotations) - { - pScrPriv->pMonitors->rotations = rotations; - changed = TRUE; - } - } - - /* - * Walk monitor and mode lists looking for updates - */ - monitorid = 0; - for (pPrevMon = &pScrPriv->pMonitors; (pMonitor = *pPrevMon);) - { - int modeid = 0; - - if (pMonitor->referenced) - { - pMonitor->id = monitorid++; - if (!pMonitor->oldReferenced) - changed = TRUE; - for (pPrevMode = &pMonitor->pModes; (pMode = *pPrevMode);) - { - if (pMode->referenced) - { - pMode->id = modeid++; - if (!pMode->oldReferenced) - changed = TRUE; - pPrevMode = &pMode->next; - } - else - { - *pPrevMode = pMode->next; - changed = TRUE; - RRFreeMode (pMode); - } - } - pPrevMon = &pMonitor->next; - } - else - { - *pPrevMon = pMonitor->next; - changed = TRUE; - RRFreeMonitor (pMonitor); - } - } - if (changed) - { - UpdateCurrentTime (); - pScrPriv->lastConfigTime = currentTime; - WalkTree (pScreen, TellChanged, (pointer) pScreen); - } +#if RANDR_SCREEN_INTERFACE + if (pScrPriv->nSizes) + RRScanOldConfig (pScreen, rotations); +#endif + RRTellChanged (pScreen); return TRUE; } @@ -664,17 +821,6 @@ RREditConnectionInfo (ScreenPtr pScreen) root->mmHeight = pScreen->mmHeight; } -static int -RRNumModes (RRMonitorPtr pMonitor) -{ - int n = 0; - RRModePtr pMode; - - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - n++; - return n; -} - typedef struct _RR10Data { RRScreenSizePtr sizes; int nsize; @@ -684,7 +830,7 @@ typedef struct _RR10Data { } RR10DataRec, *RR10DataPtr; static CARD16 -RRVerticalRefresh (xRRMonitorMode *mode) +RRVerticalRefresh (xRRModeInfo *mode) { CARD32 refresh; if (!mode->hTotal || !mode->vTotal) @@ -699,61 +845,61 @@ RRVerticalRefresh (xRRMonitorMode *mode) * Convert 1.2 monitor data into 1.0 screen data */ static RR10DataPtr -RR10GetData (ScreenPtr pScreen, RRMonitorPtr pMonitor) +RR10GetData (ScreenPtr pScreen, RROutputPtr output) { RR10DataPtr data; RRScreenSizePtr size; - int nmode = RRNumModes (pMonitor); - int i; - int j; - RRRefreshPtr refresh; + int nmode = output->numModes; + int i, j, k; + RRScreenRatePtr refresh; CARD16 vRefresh; - RRModePtr pMode; + RRModePtr mode; /* Make sure there is plenty of space for any combination */ data = malloc (sizeof (RR10DataRec) + - sizeof (RRScreenSizeRec) * nmode + - sizeof (RRRefreshRec) * nmode); + sizeof (RRScreenSize) * nmode + + sizeof (RRScreenRate) * nmode); if (!data) return NULL; size = (RRScreenSizePtr) (data + 1); - refresh = (RRRefreshPtr) (size + nmode); + refresh = (RRScreenRatePtr) (size + nmode); data->sizes = size; data->nsize = 0; data->nrefresh = 0; data->size = 0; data->refresh = 0; - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + for (i = 0; i < output->numModes; i++) { - for (i = 0; i < data->nsize; i++) - if (pMode->mode.width == size[i].width && - pMode->mode.height == size[i].height) + mode = output->modes[i]; + for (j = 0; j < data->nsize; j++) + if (mode->mode.width == size[j].width && + mode->mode.height == size[j].height) break; - if (i == data->nsize) + if (j == data->nsize) { - size[i].id = i; - size[i].width = pMode->mode.width; - size[i].height = pMode->mode.height; - size[i].mmWidth = pMode->mode.widthInMillimeters; - size[i].mmHeight = pMode->mode.heightInMillimeters; - size[i].nrefresh = 0; - size[i].refresh = &refresh[data->nrefresh]; + size[j].id = j; + size[j].width = mode->mode.width; + size[j].height = mode->mode.height; + size[j].mmWidth = mode->mode.mmWidth; + size[j].mmHeight = mode->mode.mmHeight; + size[j].nRates = 0; + size[j].pRates = &refresh[data->nrefresh]; data->nsize++; } - vRefresh = RRVerticalRefresh (&pMode->mode); - for (j = 0; j < size[i].nrefresh; j++) - if (vRefresh == size[i].refresh[j].refresh) + vRefresh = RRVerticalRefresh (&mode->mode); + for (k = 0; k < size[j].nRates; k++) + if (vRefresh == size[j].pRates[k].rate) break; - if (j == size[i].nrefresh) + if (k == size[j].nRates) { - size[i].refresh[j].refresh = vRefresh; - size[i].refresh[j].pMode = pMode; - size[i].nrefresh++; + size[j].pRates[k].rate = vRefresh; + size[j].pRates[k].mode = mode; + size[j].nRates++; data->nrefresh++; } - if (pMode == pMonitor->pMode) + if (mode == output->crtc->mode) { - data->size = i; + data->size = j; data->refresh = vRefresh; } } @@ -771,6 +917,7 @@ ProcRRGetScreenInfo (ClientPtr client) rrScrPrivPtr pScrPriv; CARD8 *extra; unsigned long extraLen; + RROutputPtr output; REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, @@ -786,7 +933,9 @@ ProcRRGetScreenInfo (ClientPtr client) if (pScrPriv) RRGetInfo (pScreen); - if (!pScrPriv && !pScrPriv->pMonitors) + output = RRFirstOutput (pScreen); + + if (!pScrPriv || !output) { rep.type = X_Reply; rep.setOfRotations = RR_Rotate_0;; @@ -805,7 +954,6 @@ ProcRRGetScreenInfo (ClientPtr client) } else { - RRMonitorPtr pMonitor = pScrPriv->pMonitors; int i, j; xScreenSizes *size; CARD16 *rates; @@ -814,18 +962,18 @@ ProcRRGetScreenInfo (ClientPtr client) RR10DataPtr pData; RRScreenSizePtr pSize; - pData = RR10GetData (pScreen, pMonitor); + pData = RR10GetData (pScreen, output); if (!pData) return BadAlloc; rep.type = X_Reply; - rep.setOfRotations = pMonitor->rotations; + rep.setOfRotations = output->crtc->rotations; rep.sequenceNumber = client->sequence; rep.length = 0; rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = pMonitor->rotation; + rep.rotation = output->crtc->rotation; rep.nSizes = pData->nsize; rep.nrateEnts = pData->nrefresh + pData->nsize; rep.sizeID = pData->size; @@ -862,15 +1010,15 @@ ProcRRGetScreenInfo (ClientPtr client) size++; if (has_rate) { - *rates = pSize->nrefresh; + *rates = pSize->nRates; if (client->swapped) { swaps (rates, n); } rates++; - for (j = 0; j < pSize->nrefresh; j++) + for (j = 0; j < pSize->nRates; j++) { - *rates = pSize->refresh[j].refresh; + *rates = pSize->pRates[j].rate; if (client->swapped) { swaps (rates, n); @@ -907,6 +1055,7 @@ ProcRRGetScreenInfo (ClientPtr client) return (client->noClientException); } +#if 0 static int RRMonitorSetMode (ScreenPtr pScreen, RRMonitorPtr pMonitor, RRModePtr pMode, int x, int y, Rotation rotation, @@ -997,6 +1146,7 @@ RRMonitorSetMode (ScreenPtr pScreen, RRMonitorPtr pMonitor, pScrPriv->lastSetTime = time; return RRSetConfigSuccess; } +#endif static int ProcRRSetScreenConfig (ClientPtr client) @@ -1013,8 +1163,8 @@ ProcRRSetScreenConfig (ClientPtr client) Rotation rotation; int rate; Bool has_rate; - RRMonitorPtr pMonitor; - RRModePtr pMode; + RROutputPtr output; + RRModePtr mode; RR10DataPtr pData = NULL; RRScreenSizePtr pSize; @@ -1050,8 +1200,8 @@ ProcRRSetScreenConfig (ClientPtr client) if (!RRGetInfo (pScreen)) return BadAlloc; - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) + output = RRFirstOutput (pScreen); + if (!output) { time = currentTime; rep.status = RRSetConfigFailed; @@ -1069,7 +1219,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - pData = RR10GetData (pScreen, pMonitor); + pData = RR10GetData (pScreen, output); if (!pData) return BadAlloc; @@ -1105,7 +1255,7 @@ ProcRRSetScreenConfig (ClientPtr client) return BadValue; } - if ((~pMonitor->rotations) & rotation) + if ((~output->crtc->rotations) & rotation) { /* * requested rotation or reflection not supported by screen @@ -1125,12 +1275,12 @@ ProcRRSetScreenConfig (ClientPtr client) if (rate) { - for (i = 0; i < pSize->nrefresh; i++) + for (i = 0; i < pSize->nRates; i++) { - if (pSize->refresh[i].refresh == rate) + if (pSize->pRates[i].rate == rate) break; } - if (i == pSize->nrefresh) + if (i == pSize->nRates) { /* * Invalid rate @@ -1139,10 +1289,10 @@ ProcRRSetScreenConfig (ClientPtr client) xfree (pData); return BadValue; } - pMode = pSize->refresh[i].pMode; + mode = pSize->pRates[i].mode; } else - pMode = pSize->refresh[0].pMode; + mode = pSize->pRates[0].mode; /* * Make sure the requested set-time is not older than @@ -1154,7 +1304,8 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - rep.status = RRMonitorSetMode (pScreen, pMonitor, pMode, 0, 0, rotation, time); + rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, + 1, &output); sendReply: @@ -1183,6 +1334,7 @@ sendReply: return (client->noClientException); } +#if 0 int RRSetScreenConfig (ScreenPtr pScreen, Rotation rotation, @@ -1252,10 +1404,42 @@ RRSetScreenConfig (ScreenPtr pScreen, status = RRMonitorSetMode (pScreen, pMonitor, pMode, 0, 0, rotation, currentTime); + if (status != RRSetConfigSuccess) return BadImplementation; return Success; } +#endif + +static Bool +RRSetScreenSize (ScreenPtr pScreen, + CARD16 width, CARD16 height, + CARD16 widthInMillimeters, CARD16 heightInMillimeters) +{ + rrScrPriv(pScreen); + + if (pScrPriv->rrScreenSetSize) + { + return (*pScrPriv->rrScreenSetSize) (pScreen, width, height, + widthInMillimeters, + heightInMillimeters); + } +#ifdef RANDR_SCREEN_INTERFACE + else + { + /* Pend the size change until we get the set mode request. + * Yes, this is 'illegal', but the best we can do until + * drivers are updated + */ + pScrPriv->reqWidth = width; + pScrPriv->reqHeight = height; + pScreen->mmWidth = widthInMillimeters; + pScreen->mmHeight = heightInMillimeters; + return TRUE; + } +#endif + return FALSE; +} static int ProcRRSelectInput (ClientPtr client) @@ -1264,7 +1448,7 @@ ProcRRSelectInput (ClientPtr client) rrClientPriv(client); RRTimesPtr pTimes; WindowPtr pWin; - RREventPtr pRREvent, pNewRREvent, *pHead; + RREventPtr pRREvent, *pHead; XID clientResource; REQUEST_SIZE_MATCH(xRRSelectInputReq); @@ -1275,58 +1459,64 @@ ProcRRSelectInput (ClientPtr client) pWin->drawable.id, EventType, SecurityWriteAccess); - if (stuff->enable & (RRScreenChangeNotifyMask)) + if (stuff->enable & (RRScreenChangeNotifyMask| + RRCrtcChangeNotifyMask| + RROutputChangeNotifyMask)) { ScreenPtr pScreen = pWin->drawable.pScreen; rrScrPriv (pScreen); + pRREvent = NULL; if (pHead) { /* check for existing entry. */ for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) if (pRREvent->client == client) - return Success; + break; } - /* build the entry */ - pNewRREvent = (RREventPtr) xalloc (sizeof (RREventRec)); - if (!pNewRREvent) - return BadAlloc; - pNewRREvent->next = 0; - pNewRREvent->client = client; - pNewRREvent->window = pWin; - pNewRREvent->mask = stuff->enable; - /* - * add a resource that will be deleted when - * the client goes away - */ - clientResource = FakeClientID (client->index); - pNewRREvent->clientResource = clientResource; - if (!AddResource (clientResource, ClientType, (pointer)pNewRREvent)) - return BadAlloc; - /* - * create a resource to contain a pointer to the list - * of clients selecting input. This must be indirect as - * the list may be arbitrarily rearranged which cannot be - * done through the resource database. - */ - if (!pHead) + if (!pRREvent) { - pHead = (RREventPtr *) xalloc (sizeof (RREventPtr)); - if (!pHead || - !AddResource (pWin->drawable.id, EventType, (pointer)pHead)) - { - FreeResource (clientResource, RT_NONE); + /* build the entry */ + pRREvent = (RREventPtr) xalloc (sizeof (RREventRec)); + if (!pRREvent) return BadAlloc; + pRREvent->next = 0; + pRREvent->client = client; + pRREvent->window = pWin; + pRREvent->mask = stuff->enable; + /* + * add a resource that will be deleted when + * the client goes away + */ + clientResource = FakeClientID (client->index); + pRREvent->clientResource = clientResource; + if (!AddResource (clientResource, ClientType, (pointer)pRREvent)) + return BadAlloc; + /* + * create a resource to contain a pointer to the list + * of clients selecting input. This must be indirect as + * the list may be arbitrarily rearranged which cannot be + * done through the resource database. + */ + if (!pHead) + { + pHead = (RREventPtr *) xalloc (sizeof (RREventPtr)); + if (!pHead || + !AddResource (pWin->drawable.id, EventType, (pointer)pHead)) + { + FreeResource (clientResource, RT_NONE); + return BadAlloc; + } + *pHead = 0; } - *pHead = 0; + pRREvent->next = *pHead; + *pHead = pRREvent; } - pNewRREvent->next = *pHead; - *pHead = pNewRREvent; /* * Now see if the client needs an event */ - if (pScrPriv) + if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask)) { pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; if (CompareTimeStamps (pTimes->setTime, @@ -1334,15 +1524,15 @@ ProcRRSelectInput (ClientPtr client) CompareTimeStamps (pTimes->configTime, pScrPriv->lastConfigTime) != 0) { - TellChanged (pWin, (pointer) pScreen); + DeliverScreenEvent (client, pWin, pScreen); } } } - else if (stuff->enable == xFalse) + else if (stuff->enable == 0) { /* delete the interest */ if (pHead) { - pNewRREvent = 0; + RREventPtr pNewRREvent = 0; for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { if (pRREvent->client == client) break; @@ -1366,36 +1556,340 @@ ProcRRSelectInput (ClientPtr client) return Success; } +/* + * Retrieve valid screen size range + */ +static int ProcRRGetScreenSizeRange (ClientPtr client) +{ + REQUEST(xRRGetScreenSizeRangeReq); + xRRGetScreenSizeRangeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); -static int ProcRRGetScreenSizeRange (ClientPtr pClient) + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.pad = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + if (pScrPriv) + { + RRGetInfo (pScreen); + rep.minWidth = pScrPriv->minWidth; + rep.minHeight = pScrPriv->minHeight; + rep.maxWidth = pScrPriv->maxWidth; + rep.maxHeight = pScrPriv->maxHeight; + } + else + { + rep.maxWidth = rep.minWidth = pScreen->width; + rep.maxHeight = rep.minHeight = pScreen->height; + } + if (client->swapped) + { + int n; + + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.minWidth, n); + swaps(&rep.minHeight, n); + swaps(&rep.maxWidth, n); + swaps(&rep.maxHeight, n); + } + WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); + return (client->noClientException); +} + +static int ProcRRSetScreenSize (ClientPtr client) +{ + REQUEST(xRRSetScreenSizeReq); + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + int i; + + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) + { + client->errorValue = stuff->width; + return BadValue; + } + if (stuff->height < pScrPriv->minHeight || + pScrPriv->maxHeight < stuff->height) + { + client->errorValue = stuff->height; + return BadValue; + } + for (i = 0; i < pScrPriv->numCrtcs; i++) { + crtc = pScrPriv->crtcs[i]; + if (crtc->mode && + (crtc->x + crtc->mode->mode.width > stuff->width || + crtc->y + crtc->mode->mode.height > stuff->height)) + return BadMatch; + } + if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) + { + client->errorValue = 0; + return BadValue; + } + if (!RRSetScreenSize (pScreen, + stuff->width, stuff->height, + stuff->widthInMillimeters, + stuff->heightInMillimeters)) + { + return BadMatch; + } + return Success; +} + +#if 0 +static int ProcRRGetMonitorInfo (ClientPtr client) +{ + REQUEST(xRRGetMonitorInfoReq); + xRRGetMonitorInfoReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRMonitorPtr pMonitor; + RRModePtr pMode; + int extraLen; + CARD8 *extra; + xRRMonitorInfo *monitor; + xRRMonitorMode *mode; + CARD8 *names; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.type = X_Reply; + rep.pad = 0; + rep.sequenceNumber = client->sequence; + rep.numMonitors = 0; + rep.numModes = 0; + rep.sizeNames = 0; + if (!pScrPriv) + { + extraLen = 0; + extra = NULL; + } + else + { + int i, m, b; + for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) + { + rep.numMonitors++; + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + { + rep.numModes++; + rep.sizeNames += (1 + pMode->mode.nameLength); + } + } + extraLen = (rep.numMonitors * sizeof (xRRMonitorInfo) + + rep.numModes * sizeof (xRRMonitorMode) + + rep.sizeNames + 3) & ~3; + extra = (CARD8 *) xalloc (extraLen); + if (!extra) + return BadAlloc; + monitor = (xRRMonitorInfo *) extra; + mode = (xRRMonitorMode *) (monitor + rep.numMonitors); + names = (CARD8 *) (mode + rep.numModes); + i = 0; + m = 0; + b = 0; + for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) + { + monitor[i].timestamp = pScrPriv->lastSetTime; + monitor[i].configTimestamp = pScrPriv->lastConfigTime; + monitor[i].x = pMonitor->x; + monitor[i].y = pMonitor->y; + monitor[i].rotation = pMonitor->rotation; + monitor[i].mode = pMonitor->pMode->id; + monitor[i].defaultMode = 0; /* XXX */ + monitor[i].rotations = pMonitor->rotations; + monitor[i].firstMode = m; + monitor[i].numModes = 0; + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + { + monitor[i].numModes++; + mode[m] = pMode->mode; + names[b] = pMode->mode.nameLength; + b++; + memcpy (names + b, (char *) (pMode + 1), + pMode->mode.nameLength); + b += pMode->mode.nameLength; + m++; + } + i++; + } + if ((char *) (names + ((b + 3) & ~3)) != (char *) extra + extraLen) + FatalError ("RRGetMonitorInfo length mismatch\n"); + } + rep.length = extraLen >> 2; + + WriteToClient(client, sizeof(xRRGetMonitorInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + + if (extra) + xfree (extra); + return (client->noClientException); +} + +static int ProcRRAddMonitorMode (ClientPtr client) { return BadImplementation; } -static int ProcRRSetScreenSize (ClientPtr pClient) +static int ProcRRDeleteMonitorMode (ClientPtr client) { return BadImplementation; } -static int ProcRRGetMonitorInfo (ClientPtr pClient) +static int ProcRRSetMonitorConfig (ClientPtr client) { - return BadImplementation; -} + REQUEST(xRRSetMonitorConfigReq); + xRRSetMonitorConfigReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRMonitorPtr pMonitor; + RRModePtr pMode; + TimeStamp configTime; + TimeStamp time; + Rotation rotation; + + REQUEST_SIZE_MATCH(xRRSetScreenConfigReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); -static int ProcRRAddMonitorMode (ClientPtr pClient) -{ - return BadImplementation; -} + if (!pWin) + return BadWindow; -static int ProcRRDeleteMonitorMode (ClientPtr pClient) -{ - return BadImplementation; -} + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + time = ClientTimeToServerTime(stuff->timestamp); + configTime = ClientTimeToServerTime(stuff->configTimestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo (pScreen)) + return BadAlloc; + + /* + * if the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated + */ + if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) + { + if (pMonitor->id == stuff->monitorIndex) + break; + } + if (!pMonitor) + { + client->errorValue = stuff->monitorIndex; + return BadValue; + } + + for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) + { + if (pMode->id == stuff->modeIndex) + break; + } + if (!pMode) + { + client->errorValue = stuff->modeIndex; + return BadValue; + } + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; -static int ProcRRSetMonitorConfig (ClientPtr pClient) -{ - return BadImplementation; + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + return BadValue; + } + + if ((~pMonitor->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + return BadMatch; + } + + if (stuff->x + pMode->mode.width > pScreen->width) + { + client->errorValue = stufff + stuff->y + pMode->mode.height > pScreen + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + rep.status = RRMonitorSetMode (pScreen, pMonitor, + pMode, stuff->x, stuff->y, rotation, time); + + return client->noClientException; } +#endif int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { ProcRRQueryVersion, /* 0 */ @@ -1408,12 +1902,14 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { ProcRRSelectInput, /* 4 */ ProcRRGetScreenInfo, /* 5 */ /* V1.2 additions */ +#if 0 ProcRRGetScreenSizeRange, /* 6 */ ProcRRSetScreenSize, /* 7 */ ProcRRGetMonitorInfo, /* 8 */ ProcRRAddMonitorMode, /* 9 */ ProcRRDeleteMonitorMode, /* 10 */ ProcRRSetMonitorConfig, /* 11 */ +#endif }; @@ -1505,113 +2001,42 @@ SProcRRDispatch (ClientPtr client) } /* - * Register a monitor for a screen. identifier is a unique identifier - * for the monitors of a particular screen. + * Register the range of sizes for the screen */ -RRMonitorPtr -RRRegisterMonitor (ScreenPtr pScreen, - void *identifier, - Rotation rotations) +void +RRScreenSetSizeRange (ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, + CARD16 maxWidth, + CARD16 maxHeight) { rrScrPriv (pScreen); - RRMonitorPtr pMonitor, *pPrev, *pInsert; - pInsert = NULL; - for (pPrev = &pScrPriv->pMonitors; (pMonitor = *pPrev); - pPrev = &(pMonitor)->next) - { - if (pMonitor->identifier == identifier) - { - pMonitor->referenced = TRUE; - return pMonitor; - } - if (!pMonitor->referenced) - pInsert = pPrev; - } - if (!pInsert) - pInsert = pPrev; - - /* - * New monitor, add before the first unreferenced monitor - */ - pMonitor = xalloc (sizeof (RRMonitor)); - if (!pMonitor) - return NULL; - pMonitor->pScreen = pScreen; - pMonitor->pModes = NULL; - pMonitor->identifier = identifier; - pMonitor->referenced = TRUE; - pMonitor->oldReferenced = FALSE; - pMonitor->rotations = RR_Rotate_0; - - pMonitor->pMode = NULL; - pMonitor->x = 0; - pMonitor->y = 0; - pMonitor->rotation = RR_Rotate_0; - pMonitor->next = *pInsert; - *pInsert = pMonitor; - return pMonitor; -} - -/* - * Register a mode for a monitor - */ - -RRModePtr -RRRegisterMode (RRMonitorPtr pMonitor, - xRRMonitorMode *pModeline, - char *name) -{ - RRModePtr pMode, *pPrev, *pInsert = NULL; - - /* - * Find existing mode with same modeline and name - */ - for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &(pMode->next)) - { - if (!memcmp (&pMode->mode, pModeline, sizeof (xRRMonitorMode)) && - pMode->mode.nameLength == pModeline->nameLength && - !memcmp (RRModeName(pMode), name, pModeline->nameLength)) - { - pMode->referenced = TRUE; - return pMode; - } - if (!pMode->referenced) - pInsert = pPrev; - } - - if (!pInsert) - pInsert = pPrev; - - /* - * Create a new mode, inserting before the first unreferenced mode - */ - pMode = xalloc (sizeof (RRMode) + pModeline->nameLength + 1); - pMode->referenced = TRUE; - pMode->oldReferenced = FALSE; - pMode->mode = *pModeline; - memcpy (RRModeName (pMode), name, pModeline->nameLength); - RRModeName(pMode)[pModeline->nameLength] = '\0'; - pMode->next = *pInsert; - *pInsert = pMode; - return pMode; -} - -void -RRSetCurrentMode (RRMonitorPtr pMonitor, - RRModePtr pMode, - int x, - int y, - Rotation rotation) -{ - pMonitor->pMode = pMode; - pMonitor->x = x; - pMonitor->y = y; - pMonitor->rotation = rotation; + if (!pScrPriv) + return; + pScrPriv->minWidth = minWidth; + pScrPriv->minHeight = minHeight; + pScrPriv->maxWidth = maxWidth; + pScrPriv->maxHeight = maxHeight; } #ifdef RANDR_SCREEN_INTERFACE +static Bool +RRScreenSizeMatches (RRScreenSizePtr a, + RRScreenSizePtr b) +{ + if (a->width != b->width) + return FALSE; + if (a->height != b->height) + return FALSE; + if (a->mmWidth != b->mmWidth) + return FALSE; + if (a->mmHeight != b->mmHeight) + return FALSE; + return TRUE; +} + RRScreenSizePtr RRRegisterSize (ScreenPtr pScreen, short width, @@ -1620,50 +2045,29 @@ RRRegisterSize (ScreenPtr pScreen, short mmHeight) { rrScrPriv (pScreen); - xRRMonitorMode tmp; - RRMonitorPtr pMonitor; - RRModePtr pMode, *pPrev; - char name[100]; + int i; + RRScreenSize tmp; + RRScreenSizePtr pNew; if (!pScrPriv) - return NULL; - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) - { - pMonitor = RRRegisterMonitor (pScreen, NULL, RR_Rotate_0); - if (!pMonitor) - return NULL; - } - pMonitor->referenced = TRUE; + return 0; - for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &(pMode->next)) - if (pMode->mode.width == width && - pMode->mode.height == height && - pMode->mode.widthInMillimeters == mmWidth && - pMode->mode.heightInMillimeters == mmHeight) - { - pMode->referenced =TRUE; - return (void *) pMode; - } - memset (&tmp, '\0', sizeof (xRRMonitorMode)); - memset (name, '\0', sizeof (name)); - sprintf (name, "%dx%d", width, height); tmp.width = width; tmp.height= height; - tmp.widthInMillimeters = mmWidth; - tmp.heightInMillimeters = mmHeight; - tmp.nameLength = strlen (name) + 10; /* leave space for refresh */ - pMode = RRRegisterMode (pMonitor, &tmp, name); - return (void *) pMode; -} - -static Bool -RRModesMatchSize (RRModePtr a, RRModePtr b) -{ - return (a->mode.width == a->mode.width && - a->mode.height == b->mode.height && - a->mode.widthInMillimeters == b->mode.widthInMillimeters && - a->mode.heightInMillimeters == b->mode.heightInMillimeters); + tmp.mmWidth = mmWidth; + tmp.mmHeight = mmHeight; + tmp.pRates = 0; + tmp.nRates = 0; + for (i = 0; i < pScrPriv->nSizes; i++) + if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i])) + return &pScrPriv->pSizes[i]; + pNew = xrealloc (pScrPriv->pSizes, + (pScrPriv->nSizes + 1) * sizeof (RRScreenSize)); + if (!pNew) + return 0; + pNew[pScrPriv->nSizes++] = tmp; + pScrPriv->pSizes = pNew; + return &pNew[pScrPriv->nSizes-1]; } Bool RRRegisterRate (ScreenPtr pScreen, @@ -1671,77 +2075,35 @@ Bool RRRegisterRate (ScreenPtr pScreen, int rate) { rrScrPriv(pScreen); - RRMonitorPtr pMonitor; - RRModePtr pSizeMode = (RRModePtr) pSize; - RRModePtr pMode, *pPrev; - CARD16 width = pSizeMode->mode.width; - CARD16 height = pSizeMode->mode.height; - char name[100]; - xRRMonitorMode modeLine; + int i; + RRScreenRatePtr pNew, pRate; if (!pScrPriv) return FALSE; - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) - return FALSE; + for (i = 0; i < pSize->nRates; i++) + if (pSize->pRates[i].rate == rate) + return TRUE; - for (pPrev = &pMonitor->pModes; (pMode = *pPrev); pPrev = &pMode->next) - { - if (RRModesMatchSize (pMode, pSizeMode)) - { - if (pMode->mode.dotClock == 0) - { - /* - * First refresh for this size; reprogram this mode - * with the right refresh. - */ - pMode->mode.hSyncStart = width; - pMode->mode.hSyncEnd = width; - pMode->mode.hTotal = width; - pMode->mode.hSkew = 0; - pMode->mode.vSyncStart = height; - pMode->mode.vSyncEnd = height; - pMode->mode.vTotal = height; - pMode->mode.dotClock = width * height * rate; - sprintf ((char *) (pMode + 1), "%dx%d@%d", width, height, rate); - pMode->mode.modeFlags = 0; - pMode->mode.nameLength = strlen ((char *) (pMode + 1)); - pMode->referenced = TRUE; - return TRUE; - } - else if (rate == RRVerticalRefresh (&pMode->mode)) - { - pMode->referenced = TRUE; - return TRUE; - } - } - } - - sprintf (name, "%dx%d@%d", pSizeMode->mode.width, pSizeMode->mode.height, - rate); - modeLine = pSizeMode->mode; - modeLine.dotClock = rate * modeLine.vTotal * modeLine.hTotal; - modeLine.nameLength = strlen (name); - pMode = RRRegisterMode (pMonitor, &modeLine, name); - if (!pMode) + pNew = xrealloc (pSize->pRates, + (pSize->nRates + 1) * sizeof (RRScreenRate)); + if (!pNew) return FALSE; + pRate = &pNew[pSize->nRates++]; + pRate->rate = rate; + pSize->pRates = pNew; return TRUE; } Rotation RRGetRotation(ScreenPtr pScreen) { - rrScrPriv (pScreen); - RRMonitorPtr pMonitor; + RROutputPtr output = RRFirstOutput (pScreen); - if (!pScrPriv) + if (!output) return RR_Rotate_0; - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) - return RR_Rotate_0; - return pMonitor->rotation; + return output->crtc->rotation; } void @@ -1751,25 +2113,11 @@ RRSetCurrentConfig (ScreenPtr pScreen, RRScreenSizePtr pSize) { rrScrPriv (pScreen); - RRMonitorPtr pMonitor; - RRModePtr pMode; - RRModePtr pSizeMode = (RRModePtr) pSize; if (!pScrPriv) return; - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) - return; - - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - if (RRModesMatchSize (pMode, pSizeMode) && - RRVerticalRefresh (&pMode->mode) == rate) - break; - } - if (!pMode) - return; - - RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); + pScrPriv->size = pSize - pScrPriv->pSizes; + pScrPriv->rotation = rotation; + pScrPriv->rate = rate; } #endif diff --git a/randr/randrstr.h b/randr/randrstr.h index 3610274cc..16945231a 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -34,71 +34,94 @@ #include +/* required for ABI compatibility for now */ #define RANDR_SCREEN_INTERFACE 1 +typedef XID RRMode; +typedef XID RROutput; +typedef XID RRCrtc; + /* * Modeline for a monitor. Name follows directly after this struct */ #define RRModeName(pMode) ((char *) (pMode + 1)) +typedef struct _rrMode RRModeRec, *RRModePtr; +typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; +typedef struct _rrOutput RROutputRec, *RROutputPtr; -typedef struct _rrMode { - struct _rrMode *next; - Bool referenced; - Bool oldReferenced; - int id; - xRRMonitorMode mode; -} RRMode, *RRModePtr; +struct _rrMode { + RRMode id; + int refcnt; + xRRModeInfo mode; + char *name; +}; -typedef struct _rrMonitor { - struct _rrMonitor *next; +struct _rrCrtc { + RRCrtc id; ScreenPtr pScreen; - RRModePtr pModes; - void *identifier; /* made unique by DDX */ - int id; /* index in list of monitors */ - Bool referenced; - Bool oldReferenced; - Rotation rotations; - - /* - * Current state - */ - RRModePtr pMode; + RRModePtr mode; int x, y; Rotation rotation; -} RRMonitor, *RRMonitorPtr; + Rotation rotations; + int numPossibleOutputs; + RROutputPtr *possibleOutputs; + Bool changed; + void *devPrivate; +}; -typedef Bool (*RRSetScreenSizeProcPtr) (ScreenPtr pScreen, +struct _rrOutput { + RROutput id; + ScreenPtr pScreen; + char *name; + int nameLength; + CARD8 connection; + CARD8 subpixelOrder; + RRCrtcPtr crtc; + int numCrtcs; + RRCrtcPtr *crtcs; + int numClones; + RROutputPtr *outputs; + int numModes; + RRModePtr *modes; + Bool changed; + void *devPrivate; +}; + +typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 widthInMM, CARD32 heightInMM); -typedef Bool (*RRSetModeProcPtr) (ScreenPtr pScreen, - int monitor, - RRModePtr pMode, +typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, int x, int y, - Rotation rotation); + Rotation rotation, + int numOutput, + RROutputPtr *outputs); typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); - -#ifdef RANDR_SCREEN_INTERFACE - +/* These are for 1.0 compatibility */ + typedef struct _rrRefresh { - CARD16 refresh; - RRModePtr pMode; -} RRRefreshRec, *RRRefreshPtr; + CARD16 rate; + RRModePtr mode; +} RRScreenRate, *RRScreenRatePtr; typedef struct _rrScreenSize { int id; short width, height; short mmWidth, mmHeight; - int nrefresh; - RRRefreshPtr refresh; -} RRScreenSizeRec, *RRScreenSizePtr; + int nRates; + RRScreenRatePtr pRates; +} RRScreenSize, *RRScreenSizePtr; + +#ifdef RANDR_SCREEN_INTERFACE typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, Rotation rotation, @@ -117,8 +140,8 @@ typedef struct _rrScrPriv { RRSetConfigProcPtr rrSetConfig; #endif RRGetInfoProcPtr rrGetInfo; - RRSetScreenSizeProcPtr rrSetScreenSize; - RRSetModeProcPtr rrSetMode; + RRScreenSetSizeProcPtr rrScreenSetSize; + RRCrtcSetProcPtr rrCrtcSet; /* * Private part of the structure; not considered part of the ABI @@ -126,20 +149,34 @@ typedef struct _rrScrPriv { TimeStamp lastSetTime; /* last changed by client */ TimeStamp lastConfigTime; /* possible configs changed */ RRCloseScreenProcPtr CloseScreen; + Bool changed; + CARD16 minWidth, minHeight; + CARD16 maxWidth, maxHeight; - /* - * monitor data - */ - RRMonitorPtr pMonitors; + /* modes, outputs and crtcs */ + int numModes; + RRModePtr *modes; + + int numOutputs; + RROutputPtr *outputs; + + int numCrtcs; + RRCrtcPtr *crtcs; #ifdef RANDR_SCREEN_INTERFACE /* * Configuration information */ Rotation rotations; + CARD16 reqWidth, reqHeight; - + int nSizes; + RRScreenSizePtr pSizes; + + RRScreenSizePtr pSize; Rotation rotation; + int rate; + int size; #endif } rrScrPrivRec, *rrScrPrivPtr; @@ -154,33 +191,91 @@ void RRExtensionInit (void); /* - * Then, register a monitor with the screen + * Set the range of sizes for the screen */ - -RRMonitorPtr -RRRegisterMonitor (ScreenPtr pScreen, - void *identifier, - Rotation rotations); +void +RRScreenSetSizeRange (ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, + CARD16 maxWidth, + CARD16 maxHeight); /* - * Next, register the list of modes with the monitor + * Create a CRTC + */ +RRCrtcPtr +RRCrtcCreate (ScreenPtr pScreen, + void *devPrivate); + + +/* + * Use this value for any num parameter to indicate that + * the related data are unchanged + */ +#define RR_NUM_UNCHANGED -1 + +/* + * Notify the extension that the Crtc has been reconfigured + */ +Bool +RRCrtcSet (RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutput, + RROutputPtr *outputs); + +/* + * Destroy a Crtc at shutdown + */ +void +RRCrtcDestroy (RRCrtcPtr crtc); + +/* + * Find, and if necessary, create a mode */ RRModePtr -RRRegisterMode (RRMonitorPtr pMonitor, - xRRMonitorMode *pMode, - char *name); +RRModeGet (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + char *name); /* - * Finally, set the current configuration of each monitor + * Destroy a mode. */ void -RRSetCurrentMode (RRMonitorPtr pMonitor, - RRModePtr pMode, - int x, - int y, - Rotation rotation); +RRModeDestroy (RRModePtr mode); + +/* + * Create an output + */ + +RROutputPtr +RROutputCreate (ScreenPtr pScreen, + char *name, + int nameLength, + void *devPrivate); + +/* + * Notify extension that output parameters have been changed + */ +Bool +RROutputSet (RROutputPtr output, + RROutputPtr *clones, + int numClones, + RRModePtr *modes, + int numModes, + RRCrtcPtr *crtcs, + int numCrtcs, + CARD8 connection); + +void +RROutputDestroy (RROutputPtr output); + +void +RRTellChanged (ScreenPtr pScreen); Bool RRScreenInit(ScreenPtr pScreen); @@ -197,12 +292,14 @@ Bool miRRGetScreenInfo (ScreenPtr pScreen); Bool -miRRSetMode (ScreenPtr pScreen, - int monitor, - RRModePtr pMode, +miRRCrtcSet (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, int x, int y, - Rotation rotation); + Rotation rotation, + int numOutput, + RROutputPtr *outputs); #ifdef RANDR_SCREEN_INTERFACE /* @@ -225,9 +322,6 @@ Bool RRRegisterRate (ScreenPtr pScreen, RRScreenSizePtr pSize, int rate); -Bool RRRegisterRotation (ScreenPtr pScreen, - Rotation rotation); - /* * Finally, set the current configuration of the screen */ @@ -238,17 +332,16 @@ RRSetCurrentConfig (ScreenPtr pScreen, int rate, RRScreenSizePtr pSize); +Bool RRScreenInit (ScreenPtr pScreen); + +Rotation +RRGetRotation (ScreenPtr pScreen); + int RRSetScreenConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize); -Bool -miRRSetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr size); - #endif #endif /* _RANDRSTR_H_ */ From 3e745745fecef1cb59e53bde52ded311b51e1dac Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 16 Sep 2006 23:21:37 -0700 Subject: [PATCH 005/109] Split RandR implementation into separate files. RandR is getting too big to live in one file; split into one file per object type (crtc, mode, screen), leaving the rest of the code in randr.c. Code is slowly approaching the point where it will drop-in as a replacement for the old 1.0 implementation. --- randr/Makefile.am | 6 +- randr/mirandr.c | 7 +- randr/randr.c | 419 ++++++++-------------------------------------- randr/randrstr.h | 273 ++++++++++++++++++++---------- randr/rrcrtc.c | 238 ++++++++++++++++++++++++++ randr/rrmode.c | 85 ++++++++++ randr/rroutput.c | 56 +++++++ randr/rrscreen.c | 205 +++++++++++++++++++++++ 8 files changed, 852 insertions(+), 437 deletions(-) create mode 100644 randr/rrcrtc.c create mode 100644 randr/rrmode.c create mode 100644 randr/rroutput.c create mode 100644 randr/rrscreen.c diff --git a/randr/Makefile.am b/randr/Makefile.am index bd30aed8a..868786ecb 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -9,4 +9,8 @@ endif librandr_la_SOURCES = \ mirandr.c \ randr.c \ - randrstr.h + randrstr.h \ + rrcrtc.c \ + rrmode.c \ + rroutput.c \ + rrscreen.c diff --git a/randr/mirandr.c b/randr/mirandr.c index 5aea38d60..a57a157ca 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -70,16 +70,19 @@ Bool miRandRInit (ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; +#if RANDR_12_INTERFACE RRModePtr mode; RRCrtcPtr crtc; RROutputPtr output; xRRModeInfo modeInfo; char name[64]; +#endif if (!RRScreenInit (pScreen)) return FALSE; pScrPriv = rrGetScrPriv(pScreen); pScrPriv->rrGetInfo = miRRGetInfo; +#if RANDR_12_INTERFACE pScrPriv->rrCrtcSet = miRRCrtcSet; RRScreenSetSizeRange (pScreen, @@ -111,7 +114,7 @@ miRandRInit (ScreenPtr pScreen) &crtc, 1, /* crtcs */ RR_Connected)) return FALSE; - if (!RRCrtcSet (crtc, mode, 0, 0, RR_Rotate_0, 1, &output)) - return FALSE; + RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output); +#endif return TRUE; } diff --git a/randr/randr.c b/randr/randr.c index e34b82c2f..2305b6094 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -31,25 +31,7 @@ #include #endif -#include -#include -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "resource.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "extnsionst.h" -#include "servermd.h" -#include -#include #include "randrstr.h" -#ifdef RENDER -#include /* we share subpixel order information */ -#include "picturestr.h" -#endif -#include /* From render.h */ #ifndef SubPixelUnknown @@ -60,8 +42,6 @@ int RRGeneration; int RRNScreens; -static RESTYPE ModeType, CrtcType, OutputType; - static int ProcRRQueryVersion (ClientPtr pClient); static int ProcRRDispatch (ClientPtr pClient); static int SProcRRDispatch (ClientPtr pClient); @@ -80,7 +60,7 @@ static int SProcRRQueryVersion (ClientPtr pClient); static CARD8 RRReqCode; static int RRErrBase; #endif -static int RREventBase; +int RREventBase; static RESTYPE ClientType, EventType; /* resource types for event masks */ static int RRClientPrivateIndex; @@ -233,50 +213,21 @@ SRRNotifyEvent (xEvent *from, } } -static int -RRModeDestroyResource (pointer value, XID pid) -{ - RRModeDestroy ((RRModePtr) value); - return 1; -} - -static int -RRCrtcDestroyResource (pointer value, XID pid) -{ - RRCrtcDestroy ((RRCrtcPtr) value); - return 1; -} - -static int -RROutputDestroyResource (pointer value, XID pid) -{ - RROutputDestroy ((RROutputPtr) value); - return 1; -} - Bool RRScreenInit(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; if (RRGeneration != serverGeneration) { - ModeType = CreateNewResourceType (RRModeDestroyResource); - if (!ModeType) + if (!RRModeInit ()) return FALSE; - CrtcType = CreateNewResourceType (RRCrtcDestroyResource); - if (!ModeType) + if (!RRCrtcInit ()) return FALSE; - OutputType = CreateNewResourceType (RROutputDestroyResource); - if (!ModeType) + if (!RROutputInit ()) return FALSE; if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0) return FALSE; RRGeneration = serverGeneration; -#ifdef XResExtension - RegisterResourceName (ModeType, "MODE"); - RegisterResourceName (CrtcType, "CRTC"); - RegisterResourceName (OutputType, "OUTPUT"); -#endif } pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec)); @@ -288,14 +239,23 @@ Bool RRScreenInit(ScreenPtr pScreen) /* * Calling function best set these function vectors */ - pScrPriv->rrCrtcSet = 0; pScrPriv->rrGetInfo = 0; pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width; pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; -#ifdef RANDR_SCREEN_INTERFACE + +#if RANDR_12_INTERFACE + pScrPriv->rrCrtcSet = 0; +#endif +#if RANDR_10_INTERFACE pScrPriv->rrSetConfig = 0; + pScrPriv->rotations = RR_Rotate_0; pScrPriv->reqWidth = pScreen->width; pScrPriv->reqHeight = pScreen->height; + pScrPriv->nSizes = 0; + pScrPriv->pSizes = NULL; + pScrPriv->rotation = RR_Rotate_0; + pScrPriv->rate = 0; + pScrPriv->size = 0; #endif /* @@ -400,61 +360,6 @@ RRExtensionInit (void) return; } - -static void -DeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - xRRScreenChangeNotifyEvent se; - RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; - RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL; - RRModePtr mode = crtc ? crtc->mode : NULL; - WindowPtr pRoot = WindowTable[pScreen->myNum]; - int i; - - se.type = RRScreenChangeNotify + RREventBase; - se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); - se.timestamp = pScrPriv->lastSetTime.milliseconds; - se.sequenceNumber = client->sequence; - se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - se.root = pRoot->drawable.id; - se.window = pWin->drawable.id; -#ifdef RENDER - se.subpixelOrder = PictureGetSubpixelOrder (pScreen); -#else - se.subpixelOrder = SubPixelUnknown; -#endif - - se.sequenceNumber = client->sequence; - if (mode) - { - se.sizeID = -1; - for (i = 0; i < output->numModes; i++) - if (mode == output->modes[i]) - { - se.sizeID = i; - break; - } - se.widthInPixels = mode->mode.width; - se.heightInPixels = mode->mode.height; - se.widthInMillimeters = mode->mode.mmWidth; - se.heightInMillimeters = mode->mode.mmHeight; - } - else - { - /* - * This "shouldn't happen", but a broken DDX can - * forget to set the current configuration on GetInfo - */ - se.sizeID = 0xffff; - se.widthInPixels = 0; - se.heightInPixels = 0; - se.widthInMillimeters = 0; - se.heightInMillimeters = 0; - } - WriteEventsToClient (client, 1, (xEvent *) &se); -} - static void DeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) { @@ -485,7 +390,7 @@ TellChanged (WindowPtr pWin, pointer value) continue; if (pRREvent->mask & RRScreenChangeNotifyMask) - DeliverScreenEvent (client, pWin, pScreen); + RRDeliverScreenEvent (client, pWin, pScreen); if (pRREvent->mask & RRCrtcChangeNotifyMask) { @@ -529,47 +434,6 @@ RRTellChanged (ScreenPtr pScreen) } } -RRModePtr -RRModeGet (ScreenPtr pScreen, - xRRModeInfo *modeInfo, - char *name) -{ - rrScrPriv (pScreen); - int i; - RRModePtr mode; - - for (i = 0; i < pScrPriv->numModes; i++) - { - mode = pScrPriv->modes[i]; - if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) && - !memcmp (name, mode->name, modeInfo->nameLength)) - { - ++mode->refcnt; - return mode; - } - } - mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1); - mode->refcnt = 1; - mode->mode = *modeInfo; - mode->name = (char *) (mode + 1); - memcpy (mode->name, name, modeInfo->nameLength); - mode->name[modeInfo->nameLength] = '\0'; - mode->id = FakeClientID(0); - if (!AddResource (mode->id, ModeType, (pointer) mode)) - return NULL; - ++mode->refcnt; - pScrPriv->changed = TRUE; - return mode; -} - -void -RRModeDestroy (RRModePtr mode) -{ - if (--mode->refcnt > 0) - return; - xfree (mode); -} - /* * Return the first output which is connected to an active CRTC * Used in emulating 1.0 behaviour @@ -594,11 +458,13 @@ RRFirstOutput (ScreenPtr pScreen) return NULL; } -#ifdef RANDR_SCREEN_INTERFACE +#ifdef RANDR_10_INTERFACE -static Bool +static RRModePtr RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) { + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); xRRModeInfo modeInfo; char name[100]; RRModePtr mode; @@ -617,12 +483,15 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->width * (CARD32) refresh); modeInfo.nameLength = strlen (name); - mode = RRModeGet (output->pScreen, &modeInfo, name); + mode = RRModeGet (pScreen, &modeInfo, name); if (!mode) - return FALSE; + return NULL; for (i = 0; i < output->numModes; i++) if (output->modes[i] == mode) - return TRUE; + { + RRModeDestroy (mode); + return mode; + } if (output->numModes) modes = xrealloc (output->modes, @@ -630,11 +499,16 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) else modes = xalloc (sizeof (RRModePtr)); if (!modes) - return FALSE; + { + RRModeDestroy (mode); + FreeResource (mode->id, 0); + return NULL; + } modes[output->numModes++] = mode; output->modes = modes; output->changed = TRUE; - return TRUE; + pScrPriv->changed = TRUE; + return mode; } static void @@ -643,6 +517,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) rrScrPriv(pScreen); RROutputPtr output = RRFirstOutput (pScreen); RRCrtcPtr crtc; + RRModePtr mode, newMode = NULL; int i; CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; CARD16 maxWidth = 0, maxHeight = 0; @@ -666,11 +541,29 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) int r; if (size->nRates) + { for (r = 0; r < size->nRates; r++) - RROldModeAdd (output, size, size->pRates[r].rate); + { + mode = RROldModeAdd (output, size, size->pRates[r].rate); + if (i == pScrPriv->size && + size->pRates[r].rate == pScrPriv->rate) + { + newMode = mode; + } + } + xfree (size->pRates); + } else - RROldModeAdd (output, size, 0); + { + mode = RROldModeAdd (output, size, 0); + if (i == pScrPriv->size) + newMode = mode; + } } + if (pScrPriv->nSizes) + xfree (pScrPriv->pSizes); + pScrPriv->pSizes = NULL; + pScrPriv->nSizes = 0; /* find size bounds */ for (i = 0; i < output->numModes; i++) @@ -697,9 +590,17 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) if (maxHeight != pScrPriv->maxHeight) { pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE; } + + /* notice current mode */ + if (newMode) + RRCrtcSet (output->crtc, newMode, 0, 0, pScrPriv->rotation, + 1, &output); } #endif +/* + * Poll the driver for changed information + */ static Bool RRGetInfo (ScreenPtr pScreen) { @@ -718,7 +619,7 @@ RRGetInfo (ScreenPtr pScreen) if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) return FALSE; -#if RANDR_SCREEN_INTERFACE +#if RANDR_10_INTERFACE if (pScrPriv->nSizes) RRScanOldConfig (pScreen, rotations); #endif @@ -726,27 +627,6 @@ RRGetInfo (ScreenPtr pScreen) return TRUE; } -static void -RRSendConfigNotify (ScreenPtr pScreen) -{ - WindowPtr pWin = WindowTable[pScreen->myNum]; - xEvent event; - - event.u.u.type = ConfigureNotify; - event.u.configureNotify.window = pWin->drawable.id; - event.u.configureNotify.aboveSibling = None; - event.u.configureNotify.x = 0; - event.u.configureNotify.y = 0; - - /* XXX xinerama stuff ? */ - - event.u.configureNotify.width = pWin->drawable.width; - event.u.configureNotify.height = pWin->drawable.height; - event.u.configureNotify.borderWidth = wBorderWidth (pWin); - event.u.configureNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); -} - static int ProcRRQueryVersion (ClientPtr client) { @@ -777,50 +657,6 @@ ProcRRQueryVersion (ClientPtr client) return (client->noClientException); } - -extern char *ConnectionInfo; - -static int padlength[4] = {0, 3, 2, 1}; - -static void -RREditConnectionInfo (ScreenPtr pScreen) -{ - xConnSetup *connSetup; - char *vendor; - xPixmapFormat *formats; - xWindowRoot *root; - xDepth *depth; - xVisualType *visual; - int screen = 0; - int d; - - connSetup = (xConnSetup *) ConnectionInfo; - vendor = (char *) connSetup + sizeof (xConnSetup); - formats = (xPixmapFormat *) ((char *) vendor + - connSetup->nbytesVendor + - padlength[connSetup->nbytesVendor & 3]); - root = (xWindowRoot *) ((char *) formats + - sizeof (xPixmapFormat) * screenInfo.numPixmapFormats); - while (screen != pScreen->myNum) - { - depth = (xDepth *) ((char *) root + - sizeof (xWindowRoot)); - for (d = 0; d < root->nDepths; d++) - { - visual = (xVisualType *) ((char *) depth + - sizeof (xDepth)); - depth = (xDepth *) ((char *) visual + - depth->nVisuals * sizeof (xVisualType)); - } - root = (xWindowRoot *) ((char *) depth); - screen++; - } - root->pixWidth = pScreen->width; - root->pixHeight = pScreen->height; - root->mmWidth = pScreen->mmWidth; - root->mmHeight = pScreen->mmHeight; -} - typedef struct _RR10Data { RRScreenSizePtr sizes; int nsize; @@ -829,7 +665,7 @@ typedef struct _RR10Data { CARD16 refresh; } RR10DataRec, *RR10DataPtr; -static CARD16 +CARD16 RRVerticalRefresh (xRRModeInfo *mode) { CARD32 refresh; @@ -1056,94 +892,6 @@ ProcRRGetScreenInfo (ClientPtr client) } #if 0 -static int -RRMonitorSetMode (ScreenPtr pScreen, RRMonitorPtr pMonitor, - RRModePtr pMode, int x, int y, Rotation rotation, - TimeStamp time) -{ - rrScrPriv(pScreen); - short oldWidth, oldHeight; - - oldWidth = pScreen->width; - oldHeight = pScreen->height; - - /* - * call out to ddx routine to effect the change - */ - if (pScrPriv->rrSetScreenSize && pScrPriv->rrSetMode) - { - xScreenSizes oldSize; - if (!(*pScrPriv->rrSetMode) (pScreen, 0, NULL, 0, 0, RR_Rotate_0)) - return RRSetConfigFailed; - oldSize.widthInPixels = pScreen->width; - oldSize.heightInPixels = pScreen->width; - oldSize.widthInMillimeters = pScreen->mmWidth; - oldSize.heightInMillimeters = pScreen->mmHeight; - if (!(*pScrPriv->rrSetScreenSize) (pScreen, - pMode->mode.width, - pMode->mode.height, - pMode->mode.widthInMillimeters, - pMode->mode.heightInMillimeters)) - { - (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, - pMonitor->x, pMonitor->y, - pMonitor->rotation); - return RRSetConfigFailed; - } - if (!(*pScrPriv->rrSetMode) (pScreen, 0, pMode, 0, 0, rotation)) - { - (void) (*pScrPriv->rrSetScreenSize) (pScreen, - oldSize.widthInPixels, - oldSize.heightInPixels, - oldSize.widthInMillimeters, - oldSize.heightInMillimeters); - (void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode, - pMonitor->x, pMonitor->y, - pMonitor->rotation); - return RRSetConfigFailed; - } - } -#ifdef RANDR_SCREEN_INTERFACE - else if (pScrPriv->rrSetConfig) - { - int rate = RRVerticalRefresh (&pMode->mode); - RRScreenSizeRec size; - - size.width = pMode->mode.width; - size.height = pMode->mode.height; - size.mmWidth = pMode->mode.widthInMillimeters; - size.mmHeight = pMode->mode.heightInMillimeters; - if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, &size)) - return RRSetConfigFailed; - } -#endif - else - return RRSetConfigFailed; - - /* - * set current extension configuration pointers - */ - RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation); - - /* - * Deliver ScreenChangeNotify events whenever - * the configuration is updated - */ - WalkTree (pScreen, TellChanged, (pointer) pScreen); - - /* - * Deliver ConfigureNotify events when root changes - * pixel size - */ - if (oldWidth != pScreen->width || oldHeight != pScreen->height) - RRSendConfigNotify (pScreen); - RREditConnectionInfo (pScreen); - - /* - * Fix pointer bounds and location - */ - ScreenRestructured (pScreen); - pScrPriv->lastSetTime = time; return RRSetConfigSuccess; } #endif @@ -1411,36 +1159,6 @@ RRSetScreenConfig (ScreenPtr pScreen, } #endif -static Bool -RRSetScreenSize (ScreenPtr pScreen, - CARD16 width, CARD16 height, - CARD16 widthInMillimeters, CARD16 heightInMillimeters) -{ - rrScrPriv(pScreen); - - if (pScrPriv->rrScreenSetSize) - { - return (*pScrPriv->rrScreenSetSize) (pScreen, width, height, - widthInMillimeters, - heightInMillimeters); - } -#ifdef RANDR_SCREEN_INTERFACE - else - { - /* Pend the size change until we get the set mode request. - * Yes, this is 'illegal', but the best we can do until - * drivers are updated - */ - pScrPriv->reqWidth = width; - pScrPriv->reqHeight = height; - pScreen->mmWidth = widthInMillimeters; - pScreen->mmHeight = heightInMillimeters; - return TRUE; - } -#endif - return FALSE; -} - static int ProcRRSelectInput (ClientPtr client) { @@ -1524,7 +1242,7 @@ ProcRRSelectInput (ClientPtr client) CompareTimeStamps (pTimes->configTime, pScrPriv->lastConfigTime) != 0) { - DeliverScreenEvent (client, pWin, pScreen); + RRDeliverScreenEvent (client, pWin, pScreen); } } } @@ -1651,7 +1369,7 @@ static int ProcRRSetScreenSize (ClientPtr client) client->errorValue = 0; return BadValue; } - if (!RRSetScreenSize (pScreen, + if (!RRScreenSizeSet (pScreen, stuff->width, stuff->height, stuff->widthInMillimeters, stuff->heightInMillimeters)) @@ -2000,6 +1718,7 @@ SProcRRDispatch (ClientPtr client) } } +#if RANDR_12_INTERFACE /* * Register the range of sizes for the screen */ @@ -2019,8 +1738,9 @@ RRScreenSetSizeRange (ScreenPtr pScreen, pScrPriv->maxWidth = maxWidth; pScrPriv->maxHeight = maxHeight; } +#endif -#ifdef RANDR_SCREEN_INTERFACE +#ifdef RANDR_10_INTERFACE static Bool RRScreenSizeMatches (RRScreenSizePtr a, @@ -2052,6 +1772,7 @@ RRRegisterSize (ScreenPtr pScreen, if (!pScrPriv) return 0; + tmp.id = 0; tmp.width = width; tmp.height= height; tmp.mmWidth = mmWidth; diff --git a/randr/randrstr.h b/randr/randrstr.h index 16945231a..f323660d9 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -32,15 +32,35 @@ #ifndef _RANDRSTR_H_ #define _RANDRSTR_H_ +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "resource.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "servermd.h" +#include #include +#ifdef RENDER +#include /* we share subpixel order information */ +#include "picturestr.h" +#endif +#include /* required for ABI compatibility for now */ -#define RANDR_SCREEN_INTERFACE 1 +#define RANDR_10_INTERFACE 1 +/* #define RANDR_12_INTERFACE 1 */ typedef XID RRMode; typedef XID RROutput; typedef XID RRCrtc; +extern int RREventBase; + /* * Modeline for a monitor. Name follows directly after this struct */ @@ -64,9 +84,9 @@ struct _rrCrtc { int x, y; Rotation rotation; Rotation rotations; - int numPossibleOutputs; - RROutputPtr *possibleOutputs; Bool changed; + int numOutputs; + RROutputPtr *outputs; void *devPrivate; }; @@ -88,11 +108,12 @@ struct _rrOutput { void *devPrivate; }; -typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, +#if RANDR_12_INTERFACE +typedef Bool (*RRScreentSizeSetProcPtr) (ScreenPtr pScreen, CARD16 width, CARD16 height, - CARD32 widthInMM, - CARD32 heightInMM); + CARD32 mmWidth, + CARD32 mmHeight); typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc, @@ -100,8 +121,9 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, int x, int y, Rotation rotation, - int numOutput, + int numOutputs, RROutputPtr *outputs); +#endif typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); @@ -121,7 +143,7 @@ typedef struct _rrScreenSize { RRScreenRatePtr pRates; } RRScreenSize, *RRScreenSizePtr; -#ifdef RANDR_SCREEN_INTERFACE +#ifdef RANDR_10_INTERFACE typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, Rotation rotation, @@ -136,12 +158,14 @@ typedef struct _rrScrPriv { * 'public' part of the structure; DDXen fill this in * as they initialize */ -#ifdef RANDR_SCREEN_INTERFACE +#if RANDR_10_INTERFACE RRSetConfigProcPtr rrSetConfig; #endif RRGetInfoProcPtr rrGetInfo; - RRScreenSetSizeProcPtr rrScreenSetSize; +#if RANDR_12_INTERFACE + RRScreenSetSizeProcPtr rrScreenSizeSet; RRCrtcSetProcPtr rrCrtcSet; +#endif /* * Private part of the structure; not considered part of the ABI @@ -152,6 +176,7 @@ typedef struct _rrScrPriv { Bool changed; CARD16 minWidth, minHeight; CARD16 maxWidth, maxHeight; + CARD16 width, height; /* last known screen size */ /* modes, outputs and crtcs */ int numModes; @@ -163,7 +188,7 @@ typedef struct _rrScrPriv { int numCrtcs; RRCrtcPtr *crtcs; -#ifdef RANDR_SCREEN_INTERFACE +#ifdef RANDR_10_INTERFACE /* * Configuration information */ @@ -173,7 +198,6 @@ typedef struct _rrScrPriv { int nSizes; RRScreenSizePtr pSizes; - RRScreenSizePtr pSize; Rotation rotation; int rate; int size; @@ -190,6 +214,7 @@ extern int rrPrivIndex; void RRExtensionInit (void); +#ifdef RANDR_12_INTERFACE /* * Set the range of sizes for the screen */ @@ -199,89 +224,34 @@ RRScreenSetSizeRange (ScreenPtr pScreen, CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight); +#endif +/* rrscreen.c */ /* - * Create a CRTC + * Notify the extension that the screen size has been changed. + * The driver is responsible for calling this whenever it has changed + * the size of the screen */ -RRCrtcPtr -RRCrtcCreate (ScreenPtr pScreen, - void *devPrivate); - +void +RRScreenSizeNotify (ScreenPtr pScreen); /* - * Use this value for any num parameter to indicate that - * the related data are unchanged - */ -#define RR_NUM_UNCHANGED -1 - -/* - * Notify the extension that the Crtc has been reconfigured + * Request that the screen be resized */ Bool -RRCrtcSet (RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - int numOutput, - RROutputPtr *outputs); +RRScreenSizeSet (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, + CARD32 mmHeight); /* - * Destroy a Crtc at shutdown + * Deliver a ScreenNotify event */ void -RRCrtcDestroy (RRCrtcPtr crtc); - -/* - * Find, and if necessary, create a mode - */ - -RRModePtr -RRModeGet (ScreenPtr pScreen, - xRRModeInfo *modeInfo, - char *name); - -/* - * Destroy a mode. - */ - -void -RRModeDestroy (RRModePtr mode); - -/* - * Create an output - */ - -RROutputPtr -RROutputCreate (ScreenPtr pScreen, - char *name, - int nameLength, - void *devPrivate); - -/* - * Notify extension that output parameters have been changed - */ -Bool -RROutputSet (RROutputPtr output, - RROutputPtr *clones, - int numClones, - RRModePtr *modes, - int numModes, - RRCrtcPtr *crtcs, - int numCrtcs, - CARD8 connection); - -void -RROutputDestroy (RROutputPtr output); - -void -RRTellChanged (ScreenPtr pScreen); - -Bool RRScreenInit(ScreenPtr pScreen); - -Rotation -RRGetRotation (ScreenPtr pScreen); - +RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen); + +/* mirandr.c */ Bool miRandRInit (ScreenPtr pScreen); @@ -301,7 +271,22 @@ miRRCrtcSet (ScreenPtr pScreen, int numOutput, RROutputPtr *outputs); -#ifdef RANDR_SCREEN_INTERFACE +/* randr.c */ +/* + * Send all pending events + */ +void +RRTellChanged (ScreenPtr pScreen); + +Bool RRScreenInit(ScreenPtr pScreen); + +Rotation +RRGetRotation (ScreenPtr pScreen); + +CARD16 +RRVerticalRefresh (xRRModeInfo *mode); + +#ifdef RANDR_10_INTERFACE /* * This is the old interface, deprecated but left * around for compatibility @@ -344,4 +329,122 @@ RRSetScreenConfig (ScreenPtr pScreen, RRScreenSizePtr pSize); #endif + +/* rrcrtc.c */ +/* + * Create a CRTC + */ +RRCrtcPtr +RRCrtcCreate (ScreenPtr pScreen, + void *devPrivate); + + +/* + * Use this value for any num parameter to indicate that + * the related data are unchanged + */ +#define RR_NUM_UNCHANGED -1 + +/* + * Notify the extension that the Crtc has been reconfigured, + * the driver calls this whenever it has updated the mode + */ +Bool +RRCrtcNotify (RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutput, + RROutputPtr *outputs); + +/* + * Request that the Crtc be reconfigured + */ +Bool +RRCrtcSet (RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutput, + RROutputPtr *outputs); + +/* + * Destroy a Crtc at shutdown + */ +void +RRCrtcDestroy (RRCrtcPtr crtc); + +/* + * Initialize crtc type + */ +Bool +RRCrtcInit (void); + +/* rrmode.c */ +/* + * Find, and if necessary, create a mode + */ + +RRModePtr +RRModeGet (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + char *name); + +/* + * Destroy a mode. + */ + +void +RRModeDestroy (RRModePtr mode); + +/* + * Initialize mode type + */ +Bool +RRModeInit (void); + +/* rroutput.c */ +/* + * Create an output + */ + +RROutputPtr +RROutputCreate (ScreenPtr pScreen, + char *name, + int nameLength, + void *devPrivate); + +/* + * Notify extension that output parameters have been changed + */ +Bool +RROutputSetClones (RROutputPtr output, + RROutputPtr *clones, + int numClones); + +Bool +RROutputSetModes (RROutputPtr output, + RRModePtr *modes, + int numModes); + +Bool +RROutputSetCrtcs (RROutputPtr output, + RRCrtcPtr *crtcs, + int numCrtcs); + +Bool +RROutputSetConnection (RROutputPtr output, + CARD8 connection); + +void +RROutputDestroy (RROutputPtr output); + +/* + * Initialize output type + */ +Bool +RROutputInit (void); + #endif /* _RANDRSTR_H_ */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c new file mode 100644 index 000000000..cc5b24d50 --- /dev/null +++ b/randr/rrcrtc.c @@ -0,0 +1,238 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +static RESTYPE CrtcType; + +/* + * Create a CRTC + */ +RRCrtcPtr +RRCrtcCreate (ScreenPtr pScreen, + void *devPrivate) +{ + rrScrPriv (pScreen); + RRCrtcPtr crtc; + RRCrtcPtr *crtcs; + + crtc = xalloc (sizeof (RRCrtcRec)); + if (!crtc) + return NULL; + if (pScrPriv->numCrtcs) + crtcs = xrealloc (pScrPriv->crtcs, + (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); + else + crtcs = xalloc (sizeof (RRCrtcPtr)); + if (!crtcs) + { + xfree (crtc); + return NULL; + } + crtc->id = FakeClientID (0); + crtc->pScreen = pScreen; + crtc->mode = NULL; + crtc->x = 0; + crtc->y = 0; + crtc->rotation = RR_Rotate_0; + crtc->rotations = RR_Rotate_0; + crtc->outputs = NULL; + crtc->numOutputs = 0; + crtc->changed = TRUE; + crtc->devPrivate = devPrivate; + pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; + return crtc; +} + +/* + * Notify the extension that the Crtc has been reconfigured, + * the driver calls this whenever it has updated the mode + */ +Bool +RRCrtcNotify (RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutputs, + RROutputPtr *outputs) +{ + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); + int i, j; + int prevNumOutputs = crtc->numOutputs; + + if (numOutputs != prevNumOutputs) + { + RROutputPtr *outputs; + + if (crtc->numOutputs) + outputs = xrealloc (crtc->outputs, + numOutputs * sizeof (RROutputPtr)); + else + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!outputs) + return FALSE; + crtc->outputs = outputs; + } + for (i = 0; i < numOutputs; i++) + { + for (j = 0; j < crtc->numOutputs; j++) + if (outputs[i] == crtc->outputs[j]) + break; + if (j != crtc->numOutputs) + { + outputs[i]->changed = TRUE; + crtc->changed = TRUE; + } + } + for (j = 0; j < crtc->numOutputs; j++) + { + for (i = 0; i < numOutputs; i++) + if (outputs[i] == crtc->outputs[j]) + break; + if (i != numOutputs) + { + crtc->outputs[j]->changed = TRUE; + crtc->changed = TRUE; + } + } + if (mode != crtc->mode) + { + if (crtc->mode) + RRModeDestroy (crtc->mode); + crtc->mode = mode; + mode->refcnt++; + crtc->changed = TRUE; + } + if (x != crtc->x) + { + crtc->x = x; + crtc->changed = TRUE; + } + if (y != crtc->y) + { + crtc->y = y; + crtc->changed = TRUE; + } + if (rotation != crtc->rotation) + { + crtc->rotation = rotation; + crtc->changed = TRUE; + } + if (crtc->changed) + pScrPriv->changed = TRUE; + return TRUE; +} + +/* + * Request that the Crtc be reconfigured + */ +Bool +RRCrtcSet (RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutputs, + RROutputPtr *outputs) +{ + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); + +#if RANDR_12_INTERFACE + if (pScrPriv->rrCrtcSet) + { + return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, + rotation, numOutputs, outputs); + } +#endif +#if RANDR_10_INTERFACE + if (pScrPriv->rrSetConfig) + { + RRScreenSize size; + RRScreenRate rate; + Bool ret; + + size.width = mode->mode.width; + size.height = mode->mode.height; + size.mmWidth = mode->mode.mmWidth; + size.mmHeight = mode->mode.mmHeight; + size.nRates = 1; + rate.rate = RRVerticalRefresh (&mode->mode); + size.pRates = &rate; + ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); + /* + * Old 1.0 interface tied screen size to mode size + */ + if (ret) + RRScreenSizeNotify (pScreen); + return ret; + } +#endif + return FALSE; +} + +/* + * Destroy a Crtc at shutdown + */ +void +RRCrtcDestroy (RRCrtcPtr crtc) +{ + FreeResource (crtc->id, 0); +} + +static int +RRCrtcDestroyResource (pointer value, XID pid) +{ + RRCrtcPtr crtc = (RRCrtcPtr) value; + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); + int i; + + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + if (pScrPriv->crtcs[i] == crtc) + { + memmove (pScrPriv->crtcs, pScrPriv->crtcs + 1, + (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); + --pScrPriv->numCrtcs; + } + } + free (value); + return 1; +} + +/* + * Initialize crtc type + */ +Bool +RRCrtcInit (void) +{ + CrtcType = CreateNewResourceType (RRCrtcDestroyResource); + if (!CrtcType) + return FALSE; +#ifdef XResExtension + RegisterResourceName (CrtcType, "CRTC"); +#endif + return TRUE; +} diff --git a/randr/rrmode.c b/randr/rrmode.c new file mode 100644 index 000000000..1eb53c388 --- /dev/null +++ b/randr/rrmode.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +static RESTYPE ModeType; + +RRModePtr +RRModeGet (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + char *name) +{ + rrScrPriv (pScreen); + int i; + RRModePtr mode; + + for (i = 0; i < pScrPriv->numModes; i++) + { + mode = pScrPriv->modes[i]; + if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) && + !memcmp (name, mode->name, modeInfo->nameLength)) + { + ++mode->refcnt; + return mode; + } + } + mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1); + mode->refcnt = 1; + mode->mode = *modeInfo; + mode->name = (char *) (mode + 1); + memcpy (mode->name, name, modeInfo->nameLength); + mode->name[modeInfo->nameLength] = '\0'; + mode->id = FakeClientID(0); + if (!AddResource (mode->id, ModeType, (pointer) mode)) + return NULL; + ++mode->refcnt; + pScrPriv->changed = TRUE; + return mode; +} + +void +RRModeDestroy (RRModePtr mode) +{ + if (--mode->refcnt > 0) + return; + xfree (mode); +} + +static int +RRModeDestroyResource (pointer value, XID pid) +{ + RRModeDestroy ((RRModePtr) value); + return 1; +} + +Bool +RRModeInit (void) +{ + ModeType = CreateNewResourceType (RRModeDestroyResource); + if (!ModeType) + return FALSE; +#ifdef XResExtension + RegisterResourceName (ModeType, "MODE"); +#endif + return TRUE; +} diff --git a/randr/rroutput.c b/randr/rroutput.c new file mode 100644 index 000000000..c7e7995fc --- /dev/null +++ b/randr/rroutput.c @@ -0,0 +1,56 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +static RESTYPE OutputType; + +/* + * Destroy a Output at shutdown + */ +void +RROutputDestroy (RROutputPtr crtc) +{ + FreeResource (crtc->id, 0); +} + +static int +RROutputDestroyResource (pointer value, XID pid) +{ + free (value); + return 1; +} + +/* + * Initialize crtc type + */ +Bool +RROutputInit (void) +{ + OutputType = CreateNewResourceType (RROutputDestroyResource); + if (!OutputType) + return FALSE; +#ifdef XResExtension + RegisterResourceName (OutputType, "OUTPUT"); +#endif + return TRUE; +} diff --git a/randr/rrscreen.c b/randr/rrscreen.c new file mode 100644 index 000000000..47ba12d39 --- /dev/null +++ b/randr/rrscreen.c @@ -0,0 +1,205 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +extern char *ConnectionInfo; + +static int padlength[4] = {0, 3, 2, 1}; + +/* + * Edit connection information block so that new clients + * see the current screen size on connect + */ +static void +RREditConnectionInfo (ScreenPtr pScreen) +{ + xConnSetup *connSetup; + char *vendor; + xPixmapFormat *formats; + xWindowRoot *root; + xDepth *depth; + xVisualType *visual; + int screen = 0; + int d; + + connSetup = (xConnSetup *) ConnectionInfo; + vendor = (char *) connSetup + sizeof (xConnSetup); + formats = (xPixmapFormat *) ((char *) vendor + + connSetup->nbytesVendor + + padlength[connSetup->nbytesVendor & 3]); + root = (xWindowRoot *) ((char *) formats + + sizeof (xPixmapFormat) * screenInfo.numPixmapFormats); + while (screen != pScreen->myNum) + { + depth = (xDepth *) ((char *) root + + sizeof (xWindowRoot)); + for (d = 0; d < root->nDepths; d++) + { + visual = (xVisualType *) ((char *) depth + + sizeof (xDepth)); + depth = (xDepth *) ((char *) visual + + depth->nVisuals * sizeof (xVisualType)); + } + root = (xWindowRoot *) ((char *) depth); + screen++; + } + root->pixWidth = pScreen->width; + root->pixHeight = pScreen->height; + root->mmWidth = pScreen->mmWidth; + root->mmHeight = pScreen->mmHeight; +} + +static void +RRSendConfigNotify (ScreenPtr pScreen) +{ + WindowPtr pWin = WindowTable[pScreen->myNum]; + xEvent event; + + event.u.u.type = ConfigureNotify; + event.u.configureNotify.window = pWin->drawable.id; + event.u.configureNotify.aboveSibling = None; + event.u.configureNotify.x = 0; + event.u.configureNotify.y = 0; + + /* XXX xinerama stuff ? */ + + event.u.configureNotify.width = pWin->drawable.width; + event.u.configureNotify.height = pWin->drawable.height; + event.u.configureNotify.borderWidth = wBorderWidth (pWin); + event.u.configureNotify.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, NullWindow); +} + +void +RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + xRRScreenChangeNotifyEvent se; + RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; + RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL; + RRModePtr mode = crtc ? crtc->mode : NULL; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + int i; + + se.type = RRScreenChangeNotify + RREventBase; + se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); + se.timestamp = pScrPriv->lastSetTime.milliseconds; + se.sequenceNumber = client->sequence; + se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + se.root = pRoot->drawable.id; + se.window = pWin->drawable.id; +#ifdef RENDER + se.subpixelOrder = PictureGetSubpixelOrder (pScreen); +#else + se.subpixelOrder = SubPixelUnknown; +#endif + + se.sequenceNumber = client->sequence; + if (mode) + { + se.sizeID = -1; + for (i = 0; i < output->numModes; i++) + if (mode == output->modes[i]) + { + se.sizeID = i; + break; + } + se.widthInPixels = mode->mode.width; + se.heightInPixels = mode->mode.height; + se.widthInMillimeters = mode->mode.mmWidth; + se.heightInMillimeters = mode->mode.mmHeight; + } + else + { + /* + * This "shouldn't happen", but a broken DDX can + * forget to set the current configuration on GetInfo + */ + se.sizeID = 0xffff; + se.widthInPixels = 0; + se.heightInPixels = 0; + se.widthInMillimeters = 0; + se.heightInMillimeters = 0; + } + WriteEventsToClient (client, 1, (xEvent *) &se); +} + +/* + * Notify the extension that the screen size has been changed. + * The driver is responsible for calling this whenever it has changed + * the size of the screen + */ +void +RRScreenSizeNotify (ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + /* + * Deliver ConfigureNotify events when root changes + * pixel size + */ + if (pScrPriv->width == pScreen->width && + pScrPriv->height == pScreen->height) + return; + + pScrPriv->width = pScreen->width; + pScrPriv->height = pScreen->height; + pScrPriv->changed = TRUE; + + RRSendConfigNotify (pScreen); + RREditConnectionInfo (pScreen); + + /* + * Fix pointer bounds and location + */ + ScreenRestructured (pScreen); +} + +/* + * Request that the screen be resized + */ +Bool +RRScreenSizeSet (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, + CARD32 mmHeight) +{ + rrScrPriv(pScreen); + +#if RANDR_12_INTERFACE + if (pScrPriv->rrScreenSizeSet) + { + return (*pScrPriv->rrScreenSizeSet) (pScreen, + width, height, + mmWidth, mmHeight); + } +#endif +#if RANDR_10_INTERFACE + if (pScrPriv->rrSetConfig) + { + return TRUE; /* can't set size separately */ + } +#endif + return FALSE; +} + From bf07893947cfca945598e194ed416fda6162b11c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 17 Sep 2006 23:03:23 -0700 Subject: [PATCH 006/109] Split out RandR dispatch code from randr.c to rr*dispatch.c. More disassembly to ease ongoing development. --- randr/Makefile.am | 4 +- randr/randr.c | 1100 ++----------------------------------------- randr/randrstr.h | 69 ++- randr/rrcrtc.c | 15 +- randr/rrdispatch.c | 1034 ++++++++++++++++++++++++++++++++++++++++ randr/rrmode.c | 10 +- randr/rroutput.c | 148 +++++- randr/rrsdispatch.c | 282 +++++++++++ 8 files changed, 1575 insertions(+), 1087 deletions(-) create mode 100644 randr/rrdispatch.c create mode 100644 randr/rrsdispatch.c diff --git a/randr/Makefile.am b/randr/Makefile.am index 868786ecb..0a735574e 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -11,6 +11,8 @@ librandr_la_SOURCES = \ randr.c \ randrstr.h \ rrcrtc.c \ + rrdispatch.c \ rrmode.c \ rroutput.c \ - rrscreen.c + rrscreen.c \ + rrsdispatch.c diff --git a/randr/randr.c b/randr/randr.c index 2305b6094..63d471ce0 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -42,10 +42,8 @@ int RRGeneration; int RRNScreens; -static int ProcRRQueryVersion (ClientPtr pClient); static int ProcRRDispatch (ClientPtr pClient); static int SProcRRDispatch (ClientPtr pClient); -static int SProcRRQueryVersion (ClientPtr pClient); #define wrap(priv,real,mem,func) {\ priv->mem = real->mem; \ @@ -56,57 +54,13 @@ static int SProcRRQueryVersion (ClientPtr pClient); real->mem = priv->mem; \ } -#if 0 -static CARD8 RRReqCode; -static int RRErrBase; -#endif int RREventBase; -static RESTYPE ClientType, EventType; /* resource types for event masks */ -static int RRClientPrivateIndex; - -typedef struct _RRTimes { - TimeStamp setTime; - TimeStamp configTime; -} RRTimesRec, *RRTimesPtr; - -typedef struct _RRClient { - int major_version; - int minor_version; -/* RRTimesRec times[0]; */ -} RRClientRec, *RRClientPtr; - -/* - * each window has a list of clients requesting - * RRNotify events. Each client has a resource - * for each window it selects RRNotify input for, - * this resource is used to delete the RRNotifyRec - * entry from the per-window queue. - */ - -typedef struct _RREvent *RREventPtr; - -typedef struct _RREvent { - RREventPtr next; - ClientPtr client; - WindowPtr window; - XID clientResource; - int mask; -} RREventRec; +int RRErrorBase; +RESTYPE RRClientType, RREventType; /* resource types for event masks */ +int RRClientPrivateIndex; int rrPrivIndex = -1; -#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr) -#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient) - -static Bool -RRClientKnowsRates (ClientPtr pClient) -{ - rrClientPriv(pClient); - - return (pRRClient->major_version > 1 || - (pRRClient->major_version == 1 && pRRClient->minor_version >= 1)); -} - static void RRClientCallback (CallbackListPtr *list, pointer closure, @@ -289,7 +243,7 @@ RRFreeClient (pointer data, XID id) pRREvent = (RREventPtr) data; pWin = pRREvent->window; - pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, EventType); + pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, RREventType); if (pHead) { pPrev = 0; for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next) @@ -315,7 +269,7 @@ RRFreeEvents (pointer data, XID id) pHead = (RREventPtr *) data; for (pCur = *pHead; pCur; pCur = pNext) { pNext = pCur->next; - FreeResource (pCur->clientResource, ClientType); + FreeResource (pCur->clientResource, RRClientType); xfree ((pointer) pCur); } xfree ((pointer) pHead); @@ -337,38 +291,26 @@ RRExtensionInit (void) if (!AddCallback (&ClientStateCallback, RRClientCallback, 0)) return; - ClientType = CreateNewResourceType(RRFreeClient); - if (!ClientType) + RRClientType = CreateNewResourceType(RRFreeClient); + if (!RRClientType) return; - EventType = CreateNewResourceType(RRFreeEvents); - if (!EventType) + RREventType = CreateNewResourceType(RRFreeEvents); + if (!RREventType) return; extEntry = AddExtension (RANDR_NAME, RRNumberEvents, RRNumberErrors, ProcRRDispatch, SProcRRDispatch, RRResetProc, StandardMinorOpcode); if (!extEntry) return; -#if 0 - RRReqCode = (CARD8) extEntry->base; - RRErrBase = extEntry->errorBase; -#endif + RRErrorBase = extEntry->errorBase; RREventBase = extEntry->eventBase; EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr) - SRRScreenChangeNotifyEvent; + SRRScreenChangeNotifyEvent; EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr) SRRNotifyEvent; return; } -static void -DeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) -{ -} - -static void -DeliverOutputEvent (ClientPtr client, WindowPtr pWin, RROutputPtr output) -{ -} static int TellChanged (WindowPtr pWin, pointer value) @@ -379,7 +321,7 @@ TellChanged (WindowPtr pWin, pointer value) rrScrPriv(pScreen); int i; - pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, EventType); + pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, RREventType); if (!pHead) return WT_WALKCHILDREN; @@ -398,7 +340,7 @@ TellChanged (WindowPtr pWin, pointer value) { RRCrtcPtr crtc = pScrPriv->crtcs[i]; if (crtc->changed) - DeliverCrtcEvent (client, pWin, crtc); + RRDeliverCrtcEvent (client, pWin, crtc); } } @@ -408,7 +350,7 @@ TellChanged (WindowPtr pWin, pointer value) { RROutputPtr output = pScrPriv->outputs[i]; if (output->changed) - DeliverOutputEvent (client, pWin, output); + RRDeliverOutputEvent (client, pWin, output); } } } @@ -438,7 +380,7 @@ RRTellChanged (ScreenPtr pScreen) * Return the first output which is connected to an active CRTC * Used in emulating 1.0 behaviour */ -static RROutputPtr +RROutputPtr RRFirstOutput (ScreenPtr pScreen) { rrScrPriv(pScreen); @@ -459,7 +401,6 @@ RRFirstOutput (ScreenPtr pScreen) } #ifdef RANDR_10_INTERFACE - static RRModePtr RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) { @@ -515,13 +456,31 @@ static void RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) { rrScrPriv(pScreen); - RROutputPtr output = RRFirstOutput (pScreen); + RROutputPtr output; RRCrtcPtr crtc; RRModePtr mode, newMode = NULL; int i; CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; CARD16 maxWidth = 0, maxHeight = 0; + /* + * First time through, create a crtc and output and hook + * them together + */ + if (pScrPriv->numOutputs == 0 && + pScrPriv->numCrtcs == 0) + { + crtc = RRCrtcCreate (pScreen, NULL); + if (!crtc) + return; + output = RROutputCreate (pScreen, "default", 7, NULL); + if (!output) + return; + RROutputSetCrtcs (output, &crtc, 1); + RROutputSetConnection (output, RR_Connected); + } + + output = RRFirstOutput (pScreen); if (!output) return; crtc = output->crtc; @@ -601,7 +560,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) /* * Poll the driver for changed information */ -static Bool +Bool RRGetInfo (ScreenPtr pScreen) { rrScrPriv (pScreen); @@ -627,44 +586,6 @@ RRGetInfo (ScreenPtr pScreen) return TRUE; } -static int -ProcRRQueryVersion (ClientPtr client) -{ - xRRQueryVersionReply rep; - register int n; - REQUEST(xRRQueryVersionReq); - rrClientPriv(client); - - REQUEST_SIZE_MATCH(xRRQueryVersionReq); - pRRClient->major_version = stuff->majorVersion; - pRRClient->minor_version = stuff->minorVersion; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - /* - * Report the current version; the current - * spec says they're all compatible after 1.0 - */ - rep.majorVersion = RANDR_MAJOR; - rep.minorVersion = RANDR_MINOR; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.majorVersion, n); - swapl(&rep.minorVersion, n); - } - WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep); - return (client->noClientException); -} - -typedef struct _RR10Data { - RRScreenSizePtr sizes; - int nsize; - int nrefresh; - int size; - CARD16 refresh; -} RR10DataRec, *RR10DataPtr; - CARD16 RRVerticalRefresh (xRRModeInfo *mode) { @@ -677,411 +598,6 @@ RRVerticalRefresh (xRRModeInfo *mode) return (CARD16) refresh; } -/* - * Convert 1.2 monitor data into 1.0 screen data - */ -static RR10DataPtr -RR10GetData (ScreenPtr pScreen, RROutputPtr output) -{ - RR10DataPtr data; - RRScreenSizePtr size; - int nmode = output->numModes; - int i, j, k; - RRScreenRatePtr refresh; - CARD16 vRefresh; - RRModePtr mode; - - /* Make sure there is plenty of space for any combination */ - data = malloc (sizeof (RR10DataRec) + - sizeof (RRScreenSize) * nmode + - sizeof (RRScreenRate) * nmode); - if (!data) - return NULL; - size = (RRScreenSizePtr) (data + 1); - refresh = (RRScreenRatePtr) (size + nmode); - data->sizes = size; - data->nsize = 0; - data->nrefresh = 0; - data->size = 0; - data->refresh = 0; - for (i = 0; i < output->numModes; i++) - { - mode = output->modes[i]; - for (j = 0; j < data->nsize; j++) - if (mode->mode.width == size[j].width && - mode->mode.height == size[j].height) - break; - if (j == data->nsize) - { - size[j].id = j; - size[j].width = mode->mode.width; - size[j].height = mode->mode.height; - size[j].mmWidth = mode->mode.mmWidth; - size[j].mmHeight = mode->mode.mmHeight; - size[j].nRates = 0; - size[j].pRates = &refresh[data->nrefresh]; - data->nsize++; - } - vRefresh = RRVerticalRefresh (&mode->mode); - for (k = 0; k < size[j].nRates; k++) - if (vRefresh == size[j].pRates[k].rate) - break; - if (k == size[j].nRates) - { - size[j].pRates[k].rate = vRefresh; - size[j].pRates[k].mode = mode; - size[j].nRates++; - data->nrefresh++; - } - if (mode == output->crtc->mode) - { - data->size = j; - data->refresh = vRefresh; - } - } - return data; -} - -static int -ProcRRGetScreenInfo (ClientPtr client) -{ - REQUEST(xRRGetScreenInfoReq); - xRRGetScreenInfoReply rep; - WindowPtr pWin; - int n; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - RROutputPtr output; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - - if (pScrPriv) - RRGetInfo (pScreen); - - output = RRFirstOutput (pScreen); - - if (!pScrPriv || !output) - { - rep.type = X_Reply; - rep.setOfRotations = RR_Rotate_0;; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nSizes = 0; - rep.sizeID = 0; - rep.rotation = RR_Rotate_0; - rep.rate = 0; - rep.nrateEnts = 0; - extra = 0; - extraLen = 0; - } - else - { - int i, j; - xScreenSizes *size; - CARD16 *rates; - CARD8 *data8; - Bool has_rate = RRClientKnowsRates (client); - RR10DataPtr pData; - RRScreenSizePtr pSize; - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - rep.type = X_Reply; - rep.setOfRotations = output->crtc->rotations; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = output->crtc->rotation; - rep.nSizes = pData->nsize; - rep.nrateEnts = pData->nrefresh + pData->nsize; - rep.sizeID = pData->size; - rep.rate = pData->refresh; - - extraLen = (rep.nSizes * sizeof (xScreenSizes) + - rep.nrateEnts * sizeof (CARD16)); - - extra = (CARD8 *) xalloc (extraLen); - if (!extra) - { - xfree (pData); - return BadAlloc; - } - /* - * First comes the size information - */ - size = (xScreenSizes *) extra; - rates = (CARD16 *) (size + rep.nSizes); - for (i = 0; i < pData->nsize; i++) - { - pSize = &pData->sizes[i]; - size->widthInPixels = pSize->width; - size->heightInPixels = pSize->height; - size->widthInMillimeters = pSize->mmWidth; - size->heightInMillimeters = pSize->mmHeight; - if (client->swapped) - { - swaps (&size->widthInPixels, n); - swaps (&size->heightInPixels, n); - swaps (&size->widthInMillimeters, n); - swaps (&size->heightInMillimeters, n); - } - size++; - if (has_rate) - { - *rates = pSize->nRates; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - for (j = 0; j < pSize->nRates; j++) - { - *rates = pSize->pRates[j].rate; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - } - } - } - xfree (pData); - - data8 = (CARD8 *) rates; - - if (data8 - (CARD8 *) extra != extraLen) - FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", - (unsigned long)(data8 - (CARD8 *) extra), extraLen); - rep.length = (extraLen + 3) >> 2; - } - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swaps(&rep.rotation, n); - swaps(&rep.nSizes, n); - swaps(&rep.sizeID, n); - swaps(&rep.rate, n); - swaps(&rep.nrateEnts, n); - } - WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); - } - return (client->noClientException); -} - -#if 0 - return RRSetConfigSuccess; -} -#endif - -static int -ProcRRSetScreenConfig (ClientPtr client) -{ - REQUEST(xRRSetScreenConfigReq); - xRRSetScreenConfigReply rep; - DrawablePtr pDraw; - int n; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - TimeStamp configTime; - TimeStamp time; - int i; - Rotation rotation; - int rate; - Bool has_rate; - RROutputPtr output; - RRModePtr mode; - RR10DataPtr pData = NULL; - RRScreenSizePtr pSize; - - UpdateCurrentTime (); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - has_rate = TRUE; - } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - has_rate = FALSE; - } - - SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, - SecurityWriteAccess); - - pScreen = pDraw->pScreen; - - pScrPriv = rrGetScrPriv(pScreen); - - time = ClientTimeToServerTime(stuff->timestamp); - configTime = ClientTimeToServerTime(stuff->configTimestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - if (!output) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - - /* - * if the client's config timestamp is not the same as the last config - * timestamp, then the config information isn't up-to-date and - * can't even be validated - */ - if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; - } - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - if (stuff->sizeID >= pData->nsize) - { - /* - * Invalid size ID - */ - client->errorValue = stuff->sizeID; - xfree (pData); - return BadValue; - } - pSize = &pData->sizes[stuff->sizeID]; - - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - xfree (pData); - return BadValue; - } - - if ((~output->crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - xfree (pData); - return BadMatch; - } - - /* - * Validate requested refresh - */ - if (has_rate) - rate = (int) stuff->rate; - else - rate = 0; - - if (rate) - { - for (i = 0; i < pSize->nRates; i++) - { - if (pSize->pRates[i].rate == rate) - break; - } - if (i == pSize->nRates) - { - /* - * Invalid rate - */ - client->errorValue = rate; - xfree (pData); - return BadValue; - } - mode = pSize->pRates[i].mode; - } - else - mode = pSize->pRates[0].mode; - - /* - * Make sure the requested set-time is not older than - * the last set-time - */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; - } - - rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, - 1, &output); - -sendReply: - - if (pData) - xfree (pData); - - rep.type = X_Reply; - /* rep.status has already been filled in */ - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; - rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; - - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); - swapl(&rep.newConfigTimestamp, n); - swapl(&rep.root, n); - } - WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); - - return (client->noClientException); -} - #if 0 int RRSetScreenConfig (ScreenPtr pScreen, @@ -1159,478 +675,6 @@ RRSetScreenConfig (ScreenPtr pScreen, } #endif -static int -ProcRRSelectInput (ClientPtr client) -{ - REQUEST(xRRSelectInputReq); - rrClientPriv(client); - RRTimesPtr pTimes; - WindowPtr pWin; - RREventPtr pRREvent, *pHead; - XID clientResource; - - REQUEST_SIZE_MATCH(xRRSelectInputReq); - pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess); - if (!pWin) - return BadWindow; - pHead = (RREventPtr *)SecurityLookupIDByType(client, - pWin->drawable.id, EventType, - SecurityWriteAccess); - - if (stuff->enable & (RRScreenChangeNotifyMask| - RRCrtcChangeNotifyMask| - RROutputChangeNotifyMask)) - { - ScreenPtr pScreen = pWin->drawable.pScreen; - rrScrPriv (pScreen); - - pRREvent = NULL; - if (pHead) - { - /* check for existing entry. */ - for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) - if (pRREvent->client == client) - break; - } - - if (!pRREvent) - { - /* build the entry */ - pRREvent = (RREventPtr) xalloc (sizeof (RREventRec)); - if (!pRREvent) - return BadAlloc; - pRREvent->next = 0; - pRREvent->client = client; - pRREvent->window = pWin; - pRREvent->mask = stuff->enable; - /* - * add a resource that will be deleted when - * the client goes away - */ - clientResource = FakeClientID (client->index); - pRREvent->clientResource = clientResource; - if (!AddResource (clientResource, ClientType, (pointer)pRREvent)) - return BadAlloc; - /* - * create a resource to contain a pointer to the list - * of clients selecting input. This must be indirect as - * the list may be arbitrarily rearranged which cannot be - * done through the resource database. - */ - if (!pHead) - { - pHead = (RREventPtr *) xalloc (sizeof (RREventPtr)); - if (!pHead || - !AddResource (pWin->drawable.id, EventType, (pointer)pHead)) - { - FreeResource (clientResource, RT_NONE); - return BadAlloc; - } - *pHead = 0; - } - pRREvent->next = *pHead; - *pHead = pRREvent; - } - /* - * Now see if the client needs an event - */ - if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask)) - { - pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; - if (CompareTimeStamps (pTimes->setTime, - pScrPriv->lastSetTime) != 0 || - CompareTimeStamps (pTimes->configTime, - pScrPriv->lastConfigTime) != 0) - { - RRDeliverScreenEvent (client, pWin, pScreen); - } - } - } - else if (stuff->enable == 0) - { - /* delete the interest */ - if (pHead) { - RREventPtr pNewRREvent = 0; - for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { - if (pRREvent->client == client) - break; - pNewRREvent = pRREvent; - } - if (pRREvent) { - FreeResource (pRREvent->clientResource, ClientType); - if (pNewRREvent) - pNewRREvent->next = pRREvent->next; - else - *pHead = pRREvent->next; - xfree (pRREvent); - } - } - } - else - { - client->errorValue = stuff->enable; - return BadValue; - } - return Success; -} - -/* - * Retrieve valid screen size range - */ -static int ProcRRGetScreenSizeRange (ClientPtr client) -{ - REQUEST(xRRGetScreenSizeRangeReq); - xRRGetScreenSizeRangeReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - rep.type = X_Reply; - rep.pad = 0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - if (pScrPriv) - { - RRGetInfo (pScreen); - rep.minWidth = pScrPriv->minWidth; - rep.minHeight = pScrPriv->minHeight; - rep.maxWidth = pScrPriv->maxWidth; - rep.maxHeight = pScrPriv->maxHeight; - } - else - { - rep.maxWidth = rep.minWidth = pScreen->width; - rep.maxHeight = rep.minHeight = pScreen->height; - } - if (client->swapped) - { - int n; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.minWidth, n); - swaps(&rep.minHeight, n); - swaps(&rep.maxWidth, n); - swaps(&rep.maxHeight, n); - } - WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); - return (client->noClientException); -} - -static int ProcRRSetScreenSize (ClientPtr client) -{ - REQUEST(xRRSetScreenSizeReq); - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtcPtr crtc; - int i; - - REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) - { - client->errorValue = stuff->width; - return BadValue; - } - if (stuff->height < pScrPriv->minHeight || - pScrPriv->maxHeight < stuff->height) - { - client->errorValue = stuff->height; - return BadValue; - } - for (i = 0; i < pScrPriv->numCrtcs; i++) { - crtc = pScrPriv->crtcs[i]; - if (crtc->mode && - (crtc->x + crtc->mode->mode.width > stuff->width || - crtc->y + crtc->mode->mode.height > stuff->height)) - return BadMatch; - } - if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) - { - client->errorValue = 0; - return BadValue; - } - if (!RRScreenSizeSet (pScreen, - stuff->width, stuff->height, - stuff->widthInMillimeters, - stuff->heightInMillimeters)) - { - return BadMatch; - } - return Success; -} - -#if 0 -static int ProcRRGetMonitorInfo (ClientPtr client) -{ - REQUEST(xRRGetMonitorInfoReq); - xRRGetMonitorInfoReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRMonitorPtr pMonitor; - RRModePtr pMode; - int extraLen; - CARD8 *extra; - xRRMonitorInfo *monitor; - xRRMonitorMode *mode; - CARD8 *names; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.type = X_Reply; - rep.pad = 0; - rep.sequenceNumber = client->sequence; - rep.numMonitors = 0; - rep.numModes = 0; - rep.sizeNames = 0; - if (!pScrPriv) - { - extraLen = 0; - extra = NULL; - } - else - { - int i, m, b; - for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) - { - rep.numMonitors++; - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - rep.numModes++; - rep.sizeNames += (1 + pMode->mode.nameLength); - } - } - extraLen = (rep.numMonitors * sizeof (xRRMonitorInfo) + - rep.numModes * sizeof (xRRMonitorMode) + - rep.sizeNames + 3) & ~3; - extra = (CARD8 *) xalloc (extraLen); - if (!extra) - return BadAlloc; - monitor = (xRRMonitorInfo *) extra; - mode = (xRRMonitorMode *) (monitor + rep.numMonitors); - names = (CARD8 *) (mode + rep.numModes); - i = 0; - m = 0; - b = 0; - for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) - { - monitor[i].timestamp = pScrPriv->lastSetTime; - monitor[i].configTimestamp = pScrPriv->lastConfigTime; - monitor[i].x = pMonitor->x; - monitor[i].y = pMonitor->y; - monitor[i].rotation = pMonitor->rotation; - monitor[i].mode = pMonitor->pMode->id; - monitor[i].defaultMode = 0; /* XXX */ - monitor[i].rotations = pMonitor->rotations; - monitor[i].firstMode = m; - monitor[i].numModes = 0; - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - monitor[i].numModes++; - mode[m] = pMode->mode; - names[b] = pMode->mode.nameLength; - b++; - memcpy (names + b, (char *) (pMode + 1), - pMode->mode.nameLength); - b += pMode->mode.nameLength; - m++; - } - i++; - } - if ((char *) (names + ((b + 3) & ~3)) != (char *) extra + extraLen) - FatalError ("RRGetMonitorInfo length mismatch\n"); - } - rep.length = extraLen >> 2; - - WriteToClient(client, sizeof(xRRGetMonitorInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); - } - - if (extra) - xfree (extra); - return (client->noClientException); -} - -static int ProcRRAddMonitorMode (ClientPtr client) -{ - return BadImplementation; -} - -static int ProcRRDeleteMonitorMode (ClientPtr client) -{ - return BadImplementation; -} - -static int ProcRRSetMonitorConfig (ClientPtr client) -{ - REQUEST(xRRSetMonitorConfigReq); - xRRSetMonitorConfigReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRMonitorPtr pMonitor; - RRModePtr pMode; - TimeStamp configTime; - TimeStamp time; - Rotation rotation; - - REQUEST_SIZE_MATCH(xRRSetScreenConfigReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - time = ClientTimeToServerTime(stuff->timestamp); - configTime = ClientTimeToServerTime(stuff->configTimestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen)) - return BadAlloc; - - /* - * if the client's config timestamp is not the same as the last config - * timestamp, then the config information isn't up-to-date and - * can't even be validated - */ - if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; - } - - for (pMonitor = pScrPriv->pMonitors; pMonitor; pMonitor = pMonitor->next) - { - if (pMonitor->id == stuff->monitorIndex) - break; - } - if (!pMonitor) - { - client->errorValue = stuff->monitorIndex; - return BadValue; - } - - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - if (pMode->id == stuff->modeIndex) - break; - } - if (!pMode) - { - client->errorValue = stuff->modeIndex; - return BadValue; - } - - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - return BadValue; - } - - if ((~pMonitor->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - return BadMatch; - } - - if (stuff->x + pMode->mode.width > pScreen->width) - { - client->errorValue = stufff - stuff->y + pMode->mode.height > pScreen - /* - * Make sure the requested set-time is not older than - * the last set-time - */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; - } - - rep.status = RRMonitorSetMode (pScreen, pMonitor, - pMode, stuff->x, stuff->y, rotation, time); - - return client->noClientException; -} -#endif - -int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { - ProcRRQueryVersion, /* 0 */ -/* we skip 1 to make old clients fail pretty immediately */ - NULL, /* 1 ProcRandrOldGetScreenInfo */ -/* V1.0 apps share the same set screen config request id */ - ProcRRSetScreenConfig, /* 2 */ - NULL, /* 3 ProcRandrOldScreenChangeSelectInput */ -/* 3 used to be ScreenChangeSelectInput; deprecated */ - ProcRRSelectInput, /* 4 */ - ProcRRGetScreenInfo, /* 5 */ -/* V1.2 additions */ -#if 0 - ProcRRGetScreenSizeRange, /* 6 */ - ProcRRSetScreenSize, /* 7 */ - ProcRRGetMonitorInfo, /* 8 */ - ProcRRAddMonitorMode, /* 9 */ - ProcRRDeleteMonitorMode, /* 10 */ - ProcRRSetMonitorConfig, /* 11 */ -#endif -}; - - static int ProcRRDispatch (ClientPtr client) { @@ -1640,82 +684,13 @@ ProcRRDispatch (ClientPtr client) return (*ProcRandrVector[stuff->data]) (client); } -static int -SProcRRQueryVersion (ClientPtr client) -{ - register int n; - REQUEST(xRRQueryVersionReq); - - swaps(&stuff->length, n); - swapl(&stuff->majorVersion, n); - swapl(&stuff->minorVersion, n); - return ProcRRQueryVersion(client); -} - -static int -SProcRRGetScreenInfo (ClientPtr client) -{ - register int n; - REQUEST(xRRGetScreenInfoReq); - - swaps(&stuff->length, n); - swapl(&stuff->window, n); - return ProcRRGetScreenInfo(client); -} - -static int -SProcRRSetScreenConfig (ClientPtr client) -{ - register int n; - REQUEST(xRRSetScreenConfigReq); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - swaps (&stuff->rate, n); - } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - } - - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - swapl(&stuff->timestamp, n); - swaps(&stuff->sizeID, n); - swaps(&stuff->rotation, n); - return ProcRRSetScreenConfig(client); -} - -static int -SProcRRSelectInput (ClientPtr client) -{ - register int n; - REQUEST(xRRSelectInputReq); - - swaps(&stuff->length, n); - swapl(&stuff->window, n); - return ProcRRSelectInput(client); -} - - static int SProcRRDispatch (ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_RRQueryVersion: - return SProcRRQueryVersion(client); - case X_RRSetScreenConfig: - return SProcRRSetScreenConfig(client); - case X_RRSelectInput: - return SProcRRSelectInput(client); - case X_RRGetScreenInfo: - return SProcRRGetScreenInfo(client); - default: + if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data]) return BadRequest; - } + return (*SProcRandrVector[stuff->data]) (client); } #if RANDR_12_INTERFACE @@ -1741,7 +716,6 @@ RRScreenSetSizeRange (ScreenPtr pScreen, #endif #ifdef RANDR_10_INTERFACE - static Bool RRScreenSizeMatches (RRScreenSizePtr a, RRScreenSizePtr b) diff --git a/randr/randrstr.h b/randr/randrstr.h index f323660d9..33461570f 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -59,8 +59,11 @@ typedef XID RRMode; typedef XID RROutput; typedef XID RRCrtc; -extern int RREventBase; +extern int RREventBase, RRErrorBase; +extern int (*ProcRandrVector[RRNumberRequests])(ClientPtr); +extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr); + /* * Modeline for a monitor. Name follows directly after this struct */ @@ -101,7 +104,7 @@ struct _rrOutput { int numCrtcs; RRCrtcPtr *crtcs; int numClones; - RROutputPtr *outputs; + RROutputPtr *clones; int numModes; RRModePtr *modes; Bool changed; @@ -210,6 +213,42 @@ extern int rrPrivIndex; #define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr) #define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p)) +/* + * each window has a list of clients requesting + * RRNotify events. Each client has a resource + * for each window it selects RRNotify input for, + * this resource is used to delete the RRNotifyRec + * entry from the per-window queue. + */ + +typedef struct _RREvent *RREventPtr; + +typedef struct _RREvent { + RREventPtr next; + ClientPtr client; + WindowPtr window; + XID clientResource; + int mask; +} RREventRec; + +typedef struct _RRTimes { + TimeStamp setTime; + TimeStamp configTime; +} RRTimesRec, *RRTimesPtr; + +typedef struct _RRClient { + int major_version; + int minor_version; +/* RRTimesRec times[0]; */ +} RRClientRec, *RRClientPtr; + +extern RESTYPE RRClientType, RREventType; /* resource types for event masks */ +extern int RRClientPrivateIndex; +extern RESTYPE RRCrtcType, RRModeType, RROutputType; + +#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr) +#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient) + /* Initialize the extension */ void RRExtensionInit (void); @@ -278,8 +317,17 @@ miRRCrtcSet (ScreenPtr pScreen, void RRTellChanged (ScreenPtr pScreen); +/* + * Poll the driver for changed information + */ +Bool +RRGetInfo (ScreenPtr pScreen); + Bool RRScreenInit(ScreenPtr pScreen); +RROutputPtr +RRFirstOutput (ScreenPtr pScreen); + Rotation RRGetRotation (ScreenPtr pScreen); @@ -338,13 +386,6 @@ RRCrtcPtr RRCrtcCreate (ScreenPtr pScreen, void *devPrivate); - -/* - * Use this value for any num parameter to indicate that - * the related data are unchanged - */ -#define RR_NUM_UNCHANGED -1 - /* * Notify the extension that the Crtc has been reconfigured, * the driver calls this whenever it has updated the mode @@ -358,6 +399,9 @@ RRCrtcNotify (RRCrtcPtr crtc, int numOutput, RROutputPtr *outputs); +void +RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc); + /* * Request that the Crtc be reconfigured */ @@ -382,6 +426,10 @@ RRCrtcDestroy (RRCrtcPtr crtc); Bool RRCrtcInit (void); +/* rrdispatch.c */ +Bool +RRClientKnowsRates (ClientPtr pClient); + /* rrmode.c */ /* * Find, and if necessary, create a mode @@ -438,6 +486,9 @@ Bool RROutputSetConnection (RROutputPtr output, CARD8 connection); +void +RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); + void RROutputDestroy (RROutputPtr output); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index cc5b24d50..d343c3a57 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -22,7 +22,7 @@ #include "randrstr.h" -static RESTYPE CrtcType; +RESTYPE RRCrtcType; /* * Create a CRTC @@ -144,6 +144,12 @@ RRCrtcNotify (RRCrtcPtr crtc, return TRUE; } +void +RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) +{ + +} + /* * Request that the Crtc be reconfigured */ @@ -216,6 +222,7 @@ RRCrtcDestroyResource (pointer value, XID pid) memmove (pScrPriv->crtcs, pScrPriv->crtcs + 1, (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); --pScrPriv->numCrtcs; + break; } } free (value); @@ -228,11 +235,11 @@ RRCrtcDestroyResource (pointer value, XID pid) Bool RRCrtcInit (void) { - CrtcType = CreateNewResourceType (RRCrtcDestroyResource); - if (!CrtcType) + RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource); + if (!RRCrtcType) return FALSE; #ifdef XResExtension - RegisterResourceName (CrtcType, "CRTC"); + RegisterResourceName (RRCrtcType, "CRTC"); #endif return TRUE; } diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c new file mode 100644 index 000000000..acf629832 --- /dev/null +++ b/randr/rrdispatch.c @@ -0,0 +1,1034 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +Bool +RRClientKnowsRates (ClientPtr pClient) +{ + rrClientPriv(pClient); + + return (pRRClient->major_version > 1 || + (pRRClient->major_version == 1 && pRRClient->minor_version >= 1)); +} + +typedef struct _RR10Data { + RRScreenSizePtr sizes; + int nsize; + int nrefresh; + int size; + CARD16 refresh; +} RR10DataRec, *RR10DataPtr; + +/* + * Convert 1.2 monitor data into 1.0 screen data + */ +static RR10DataPtr +RR10GetData (ScreenPtr pScreen, RROutputPtr output) +{ + RR10DataPtr data; + RRScreenSizePtr size; + int nmode = output->numModes; + int i, j, k; + RRScreenRatePtr refresh; + CARD16 vRefresh; + RRModePtr mode; + + /* Make sure there is plenty of space for any combination */ + data = malloc (sizeof (RR10DataRec) + + sizeof (RRScreenSize) * nmode + + sizeof (RRScreenRate) * nmode); + if (!data) + return NULL; + size = (RRScreenSizePtr) (data + 1); + refresh = (RRScreenRatePtr) (size + nmode); + data->sizes = size; + data->nsize = 0; + data->nrefresh = 0; + data->size = 0; + data->refresh = 0; + for (i = 0; i < output->numModes; i++) + { + mode = output->modes[i]; + for (j = 0; j < data->nsize; j++) + if (mode->mode.width == size[j].width && + mode->mode.height == size[j].height) + break; + if (j == data->nsize) + { + size[j].id = j; + size[j].width = mode->mode.width; + size[j].height = mode->mode.height; + size[j].mmWidth = mode->mode.mmWidth; + size[j].mmHeight = mode->mode.mmHeight; + size[j].nRates = 0; + size[j].pRates = &refresh[data->nrefresh]; + data->nsize++; + } + vRefresh = RRVerticalRefresh (&mode->mode); + for (k = 0; k < size[j].nRates; k++) + if (vRefresh == size[j].pRates[k].rate) + break; + if (k == size[j].nRates) + { + size[j].pRates[k].rate = vRefresh; + size[j].pRates[k].mode = mode; + size[j].nRates++; + data->nrefresh++; + } + if (mode == output->crtc->mode) + { + data->size = j; + data->refresh = vRefresh; + } + } + return data; +} + +static int +ProcRRQueryVersion (ClientPtr client) +{ + xRRQueryVersionReply rep; + register int n; + REQUEST(xRRQueryVersionReq); + rrClientPriv(client); + + REQUEST_SIZE_MATCH(xRRQueryVersionReq); + pRRClient->major_version = stuff->majorVersion; + pRRClient->minor_version = stuff->minorVersion; + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + /* + * Report the current version; the current + * spec says they're all compatible after 1.0 + */ + rep.majorVersion = RANDR_MAJOR; + rep.minorVersion = RANDR_MINOR; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.majorVersion, n); + swapl(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcRRGetScreenInfo (ClientPtr client) +{ + REQUEST(xRRGetScreenInfoReq); + xRRGetScreenInfoReply rep; + WindowPtr pWin; + int n; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (pScrPriv) + RRGetInfo (pScreen); + + output = RRFirstOutput (pScreen); + + if (!pScrPriv || !output) + { + rep.type = X_Reply; + rep.setOfRotations = RR_Rotate_0;; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nSizes = 0; + rep.sizeID = 0; + rep.rotation = RR_Rotate_0; + rep.rate = 0; + rep.nrateEnts = 0; + extra = 0; + extraLen = 0; + } + else + { + int i, j; + xScreenSizes *size; + CARD16 *rates; + CARD8 *data8; + Bool has_rate = RRClientKnowsRates (client); + RR10DataPtr pData; + RRScreenSizePtr pSize; + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + rep.type = X_Reply; + rep.setOfRotations = output->crtc->rotations; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.rotation = output->crtc->rotation; + rep.nSizes = pData->nsize; + rep.nrateEnts = pData->nrefresh + pData->nsize; + rep.sizeID = pData->size; + rep.rate = pData->refresh; + + extraLen = (rep.nSizes * sizeof (xScreenSizes) + + rep.nrateEnts * sizeof (CARD16)); + + extra = (CARD8 *) xalloc (extraLen); + if (!extra) + { + xfree (pData); + return BadAlloc; + } + /* + * First comes the size information + */ + size = (xScreenSizes *) extra; + rates = (CARD16 *) (size + rep.nSizes); + for (i = 0; i < pData->nsize; i++) + { + pSize = &pData->sizes[i]; + size->widthInPixels = pSize->width; + size->heightInPixels = pSize->height; + size->widthInMillimeters = pSize->mmWidth; + size->heightInMillimeters = pSize->mmHeight; + if (client->swapped) + { + swaps (&size->widthInPixels, n); + swaps (&size->heightInPixels, n); + swaps (&size->widthInMillimeters, n); + swaps (&size->heightInMillimeters, n); + } + size++; + if (has_rate) + { + *rates = pSize->nRates; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + for (j = 0; j < pSize->nRates; j++) + { + *rates = pSize->pRates[j].rate; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + } + } + } + xfree (pData); + + data8 = (CARD8 *) rates; + + if (data8 - (CARD8 *) extra != extraLen) + FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", + (unsigned long)(data8 - (CARD8 *) extra), extraLen); + rep.length = (extraLen + 3) >> 2; + } + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swaps(&rep.rotation, n); + swaps(&rep.nSizes, n); + swaps(&rep.sizeID, n); + swaps(&rep.rate, n); + swaps(&rep.nrateEnts, n); + } + WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + return (client->noClientException); +} + +static int +ProcRRSetScreenConfig (ClientPtr client) +{ + REQUEST(xRRSetScreenConfigReq); + xRRSetScreenConfigReply rep; + DrawablePtr pDraw; + int n; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + TimeStamp configTime; + TimeStamp time; + int i; + Rotation rotation; + int rate; + Bool has_rate; + RROutputPtr output; + RRModePtr mode; + RR10DataPtr pData = NULL; + RRScreenSizePtr pSize; + + UpdateCurrentTime (); + + if (RRClientKnowsRates (client)) + { + REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); + has_rate = TRUE; + } + else + { + REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); + has_rate = FALSE; + } + + SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, + SecurityWriteAccess); + + pScreen = pDraw->pScreen; + + pScrPriv = rrGetScrPriv(pScreen); + + time = ClientTimeToServerTime(stuff->timestamp); + configTime = ClientTimeToServerTime(stuff->configTimestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo (pScreen)) + return BadAlloc; + + output = RRFirstOutput (pScreen); + if (!output) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + + /* + * if the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated + */ + if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + if (stuff->sizeID >= pData->nsize) + { + /* + * Invalid size ID + */ + client->errorValue = stuff->sizeID; + xfree (pData); + return BadValue; + } + pSize = &pData->sizes[stuff->sizeID]; + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + xfree (pData); + return BadValue; + } + + if ((~output->crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + xfree (pData); + return BadMatch; + } + + /* + * Validate requested refresh + */ + if (has_rate) + rate = (int) stuff->rate; + else + rate = 0; + + if (rate) + { + for (i = 0; i < pSize->nRates; i++) + { + if (pSize->pRates[i].rate == rate) + break; + } + if (i == pSize->nRates) + { + /* + * Invalid rate + */ + client->errorValue = rate; + xfree (pData); + return BadValue; + } + mode = pSize->pRates[i].mode; + } + else + mode = pSize->pRates[0].mode; + + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, + 1, &output); + +sendReply: + + if (pData) + xfree (pData); + + rep.type = X_Reply; + /* rep.status has already been filled in */ + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; + rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; + + if (client->swapped) + { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.newTimestamp, n); + swapl(&rep.newConfigTimestamp, n); + swapl(&rep.root, n); + } + WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); + + return (client->noClientException); +} + +static int +ProcRRSelectInput (ClientPtr client) +{ + REQUEST(xRRSelectInputReq); + rrClientPriv(client); + RRTimesPtr pTimes; + WindowPtr pWin; + RREventPtr pRREvent, *pHead; + XID clientResource; + + REQUEST_SIZE_MATCH(xRRSelectInputReq); + pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess); + if (!pWin) + return BadWindow; + pHead = (RREventPtr *)SecurityLookupIDByType(client, + pWin->drawable.id, RREventType, + SecurityWriteAccess); + + if (stuff->enable & (RRScreenChangeNotifyMask| + RRCrtcChangeNotifyMask| + RROutputChangeNotifyMask)) + { + ScreenPtr pScreen = pWin->drawable.pScreen; + rrScrPriv (pScreen); + + pRREvent = NULL; + if (pHead) + { + /* check for existing entry. */ + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) + if (pRREvent->client == client) + break; + } + + if (!pRREvent) + { + /* build the entry */ + pRREvent = (RREventPtr) xalloc (sizeof (RREventRec)); + if (!pRREvent) + return BadAlloc; + pRREvent->next = 0; + pRREvent->client = client; + pRREvent->window = pWin; + pRREvent->mask = stuff->enable; + /* + * add a resource that will be deleted when + * the client goes away + */ + clientResource = FakeClientID (client->index); + pRREvent->clientResource = clientResource; + if (!AddResource (clientResource, RRClientType, (pointer)pRREvent)) + return BadAlloc; + /* + * create a resource to contain a pointer to the list + * of clients selecting input. This must be indirect as + * the list may be arbitrarily rearranged which cannot be + * done through the resource database. + */ + if (!pHead) + { + pHead = (RREventPtr *) xalloc (sizeof (RREventPtr)); + if (!pHead || + !AddResource (pWin->drawable.id, RREventType, (pointer)pHead)) + { + FreeResource (clientResource, RT_NONE); + return BadAlloc; + } + *pHead = 0; + } + pRREvent->next = *pHead; + *pHead = pRREvent; + } + /* + * Now see if the client needs an event + */ + if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask)) + { + pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; + if (CompareTimeStamps (pTimes->setTime, + pScrPriv->lastSetTime) != 0 || + CompareTimeStamps (pTimes->configTime, + pScrPriv->lastConfigTime) != 0) + { + RRDeliverScreenEvent (client, pWin, pScreen); + } + } + } + else if (stuff->enable == 0) + { + /* delete the interest */ + if (pHead) { + RREventPtr pNewRREvent = 0; + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { + if (pRREvent->client == client) + break; + pNewRREvent = pRREvent; + } + if (pRREvent) { + FreeResource (pRREvent->clientResource, RRClientType); + if (pNewRREvent) + pNewRREvent->next = pRREvent->next; + else + *pHead = pRREvent->next; + xfree (pRREvent); + } + } + } + else + { + client->errorValue = stuff->enable; + return BadValue; + } + return Success; +} + +/* + * Retrieve valid screen size range + */ +static int +ProcRRGetScreenSizeRange (ClientPtr client) +{ + REQUEST(xRRGetScreenSizeRangeReq); + xRRGetScreenSizeRangeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.pad = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + if (pScrPriv) + { + RRGetInfo (pScreen); + rep.minWidth = pScrPriv->minWidth; + rep.minHeight = pScrPriv->minHeight; + rep.maxWidth = pScrPriv->maxWidth; + rep.maxHeight = pScrPriv->maxHeight; + } + else + { + rep.maxWidth = rep.minWidth = pScreen->width; + rep.maxHeight = rep.minHeight = pScreen->height; + } + if (client->swapped) + { + int n; + + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.minWidth, n); + swaps(&rep.minHeight, n); + swaps(&rep.maxWidth, n); + swaps(&rep.maxHeight, n); + } + WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); + return (client->noClientException); +} + +static int ProcRRSetScreenSize (ClientPtr client) +{ + REQUEST(xRRSetScreenSizeReq); + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + int i; + + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) + { + client->errorValue = stuff->width; + return BadValue; + } + if (stuff->height < pScrPriv->minHeight || + pScrPriv->maxHeight < stuff->height) + { + client->errorValue = stuff->height; + return BadValue; + } + for (i = 0; i < pScrPriv->numCrtcs; i++) { + crtc = pScrPriv->crtcs[i]; + if (crtc->mode && + (crtc->x + crtc->mode->mode.width > stuff->width || + crtc->y + crtc->mode->mode.height > stuff->height)) + return BadMatch; + } + if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) + { + client->errorValue = 0; + return BadValue; + } + if (!RRScreenSizeSet (pScreen, + stuff->width, stuff->height, + stuff->widthInMillimeters, + stuff->heightInMillimeters)) + { + return BadMatch; + } + return Success; +} + +static int +ProcRRGetScreenResources (ClientPtr client) +{ + REQUEST(xRRGetScreenResourcesReq); + + REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRGetOutputInfo (ClientPtr client) +{ + REQUEST(xRRGetOutputInfoReq);; + + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRListOutputProperties (ClientPtr client) +{ + REQUEST(xRRListOutputPropertiesReq); + + REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRChangeOutputProperty (ClientPtr client) +{ + REQUEST(xRRChangeOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRDeleteOutputProperty (ClientPtr client) +{ + REQUEST(xRRDeleteOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRGetOutputProperty (ClientPtr client) +{ + REQUEST(xRRGetOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRCreateMode (ClientPtr client) +{ + REQUEST(xRRCreateModeReq); + + REQUEST_SIZE_MATCH(xRRCreateModeReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRDestroyMode (ClientPtr client) +{ + REQUEST(xRRDestroyModeReq); + + REQUEST_SIZE_MATCH(xRRDestroyModeReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRAddOutputMode (ClientPtr client) +{ + REQUEST(xRRAddOutputModeReq); + + REQUEST_SIZE_MATCH(xRRAddOutputModeReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRDeleteOutputMode (ClientPtr client) +{ + REQUEST(xRRDeleteOutputModeReq); + + REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRGetCrtcInfo (ClientPtr client) +{ + REQUEST(xRRGetCrtcInfoReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRSetCrtcConfig (ClientPtr client) +{ + REQUEST(xRRSetCrtcConfigReq); + xRRSetCrtcConfigReply rep; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + RRModePtr mode; + int numOutputs; + RROutputPtr *outputs = NULL; + RROutput *outputIds; + TimeStamp configTime; + TimeStamp time; + Rotation rotation; + int i, j; + + REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); + numOutputs = stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2); + + crtc = LookupIDByType (stuff->crtc, RRCrtcType); + if (!crtc) + { + client->errorValue = stuff->crtc; + return RRErrorBase + BadCrtc; + } + if (stuff->mode == None) + { + mode = NULL; + if (numOutputs > 0) + return BadMatch; + } + else + { + mode = LookupIDByType (stuff->mode, RRModeType); + if (!mode) + { + client->errorValue = stuff->mode; + return RRErrorBase + BadMode; + } + if (numOutputs == 0) + return BadMatch; + } + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!outputs) + return BadAlloc; + + outputIds = (RROutput *) (stuff + 1); + for (i = 0; i < numOutputs; i++) + { + outputs[i] = LookupIDByType (outputIds[i], RROutputType); + if (!outputs[i]) + { + client->errorValue = outputIds[i]; + return RRErrorBase + BadOutput; + } + /* validate crtc for this output */ + for (j = 0; j < outputs[i]->numCrtcs; j++) + if (outputs[i]->crtcs[j] == crtc) + break; + if (j == outputs[j]->numCrtcs) + return BadMatch; + /* validate mode for this output */ + for (j = 0; j < outputs[i]->numModes; j++) + if (outputs[i]->modes[j] == mode) + break; + if (j == outputs[j]->numModes) + return BadMatch; + } + + pScreen = crtc->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + time = ClientTimeToServerTime(stuff->timestamp); + configTime = ClientTimeToServerTime(stuff->configTimestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo (pScreen)) + return BadAlloc; + + /* + * if the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated + */ + if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + return BadValue; + } + + if ((~crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + return BadMatch; + } + + if (stuff->x + mode->mode.width > pScreen->width) + { + client->errorValue = stuff->x; + return BadValue; + } + + if (stuff->y + mode->mode.height > pScreen->height) + { + client->errorValue = stuff->y; + return BadValue; + } + + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + rep.status = RRCrtcSet (crtc, mode, stuff->x, stuff->y, + rotation, numOutputs, outputs); + +sendReply: + if (outputs) + xfree (outputs); + + rep.type = X_Reply; + /* rep.status has already been filled in */ + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.newTimestamp = pScrPriv->lastConfigTime.milliseconds; + + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.newTimestamp, n); + } + WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep); + + return client->noClientException; +} + +static int +ProcRRGetCrtcGammaSize (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaSizeReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRGetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); + (void) stuff; + return BadImplementation; +} + +static int +ProcRRSetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRSetCrtcGammaReq); + + REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); + (void) stuff; + return BadImplementation; +} + +int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { + ProcRRQueryVersion, /* 0 */ +/* we skip 1 to make old clients fail pretty immediately */ + NULL, /* 1 ProcRandrOldGetScreenInfo */ +/* V1.0 apps share the same set screen config request id */ + ProcRRSetScreenConfig, /* 2 */ + NULL, /* 3 ProcRandrOldScreenChangeSelectInput */ +/* 3 used to be ScreenChangeSelectInput; deprecated */ + ProcRRSelectInput, /* 4 */ + ProcRRGetScreenInfo, /* 5 */ +/* V1.2 additions */ + ProcRRGetScreenSizeRange, /* 6 */ + ProcRRSetScreenSize, /* 7 */ + ProcRRGetScreenResources, /* 8 */ + ProcRRGetOutputInfo, /* 9 */ + ProcRRListOutputProperties, /* 10 */ + ProcRRChangeOutputProperty, /* 11 */ + ProcRRDeleteOutputProperty, /* 12 */ + ProcRRGetOutputProperty, /* 13 */ + ProcRRCreateMode, /* 14 */ + ProcRRDestroyMode, /* 15 */ + ProcRRAddOutputMode, /* 16 */ + ProcRRDeleteOutputMode, /* 17 */ + ProcRRGetCrtcInfo, /* 18 */ + ProcRRSetCrtcConfig, /* 19 */ + ProcRRGetCrtcGammaSize, /* 20 */ + ProcRRGetCrtcGamma, /* 21 */ + ProcRRSetCrtcGamma, /* 22 */ +}; + diff --git a/randr/rrmode.c b/randr/rrmode.c index 1eb53c388..3a9d55671 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -22,7 +22,7 @@ #include "randrstr.h" -static RESTYPE ModeType; +RESTYPE RRModeType; RRModePtr RRModeGet (ScreenPtr pScreen, @@ -50,7 +50,7 @@ RRModeGet (ScreenPtr pScreen, memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; mode->id = FakeClientID(0); - if (!AddResource (mode->id, ModeType, (pointer) mode)) + if (!AddResource (mode->id, RRModeType, (pointer) mode)) return NULL; ++mode->refcnt; pScrPriv->changed = TRUE; @@ -75,11 +75,11 @@ RRModeDestroyResource (pointer value, XID pid) Bool RRModeInit (void) { - ModeType = CreateNewResourceType (RRModeDestroyResource); - if (!ModeType) + RRModeType = CreateNewResourceType (RRModeDestroyResource); + if (!RRModeType) return FALSE; #ifdef XResExtension - RegisterResourceName (ModeType, "MODE"); + RegisterResourceName (RRModeType, "MODE"); #endif return TRUE; } diff --git a/randr/rroutput.c b/randr/rroutput.c index c7e7995fc..6b67f1997 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -22,7 +22,124 @@ #include "randrstr.h" -static RESTYPE OutputType; +RESTYPE RROutputType; + +/* + * Create an output + */ + +RROutputPtr +RROutputCreate (ScreenPtr pScreen, + char *name, + int nameLength, + void *devPrivate) +{ + rrScrPriv (pScreen); + RROutputPtr output; + RROutputPtr *outputs; + + output = xalloc (sizeof (RROutputRec) + nameLength + 1); + if (!output) + return NULL; + if (pScrPriv->numOutputs) + outputs = xrealloc (pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + else + outputs = xalloc (sizeof (RROutputPtr)); + if (!outputs) + { + xfree (output); + return NULL; + } + output->id = FakeClientID (0); + output->pScreen = pScreen; + output->name = (char *) (output + 1); + output->nameLength = nameLength; + memcpy (output->name, name, nameLength); + output->connection = RR_UnknownConnection; + output->subpixelOrder = SubPixelUnknown; + output->crtc = NULL; + output->numCrtcs = 0; + output->crtcs = NULL; + output->numClones = 0; + output->clones = NULL; + output->numModes = 0; + output->modes = NULL; + output->changed = TRUE; + output->devPrivate = devPrivate; + pScrPriv->outputs[pScrPriv->numOutputs++] = output; + return output; +} + +/* + * Notify extension that output parameters have been changed + */ +Bool +RROutputSetClones (RROutputPtr output, + RROutputPtr *clones, + int numClones) +{ + RROutputPtr *newClones; + + newClones = xalloc (numClones * sizeof (RROutputPtr)); + if (!newClones) + return FALSE; + if (output->clones) + xfree (output->clones); + memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); + output->clones = newClones; + output->numClones = numClones; + return TRUE; +} + +Bool +RROutputSetModes (RROutputPtr output, + RRModePtr *modes, + int numModes) +{ + RRModePtr *newModes; + + newModes = xalloc (numModes * sizeof (RRModePtr)); + if (!newModes) + return FALSE; + if (output->modes) + xfree (output->modes); + memcpy (newModes, modes, numModes * sizeof (RRModePtr)); + output->modes = newModes; + output->numModes = numModes; + return TRUE; +} + +Bool +RROutputSetCrtcs (RROutputPtr output, + RRCrtcPtr *crtcs, + int numCrtcs) +{ + RRCrtcPtr *newCrtcs; + + newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr)); + if (!newCrtcs) + return FALSE; + if (output->crtcs) + xfree (output->crtcs); + memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); + output->crtcs = newCrtcs; + output->numCrtcs = numCrtcs; + return TRUE; +} + +Bool +RROutputSetConnection (RROutputPtr output, + CARD8 connection) +{ + output->connection = connection; + return TRUE; +} + +void +RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) +{ +} /* * Destroy a Output at shutdown @@ -36,7 +153,28 @@ RROutputDestroy (RROutputPtr crtc) static int RROutputDestroyResource (pointer value, XID pid) { - free (value); + RROutputPtr output = (RROutputPtr) value; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); + int i; + + for (i = 0; i < pScrPriv->numOutputs; i++) + { + if (pScrPriv->outputs[i] == output) + { + memmove (pScrPriv->outputs, pScrPriv->outputs + 1, + (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr)); + --pScrPriv->numOutputs; + break; + } + } + if (output->modes) + xfree (output->modes); + if (output->crtcs) + xfree (output->crtcs); + if (output->clones) + xfree (output->clones); + xfree (output); return 1; } @@ -46,11 +184,11 @@ RROutputDestroyResource (pointer value, XID pid) Bool RROutputInit (void) { - OutputType = CreateNewResourceType (RROutputDestroyResource); - if (!OutputType) + RROutputType = CreateNewResourceType (RROutputDestroyResource); + if (!RROutputType) return FALSE; #ifdef XResExtension - RegisterResourceName (OutputType, "OUTPUT"); + RegisterResourceName (RROutputType, "OUTPUT"); #endif return TRUE; } diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c new file mode 100644 index 000000000..bf81f8bdb --- /dev/null +++ b/randr/rrsdispatch.c @@ -0,0 +1,282 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +static int +SProcRRQueryVersion (ClientPtr client) +{ + register int n; + REQUEST(xRRQueryVersionReq); + + swaps(&stuff->length, n); + swapl(&stuff->majorVersion, n); + swapl(&stuff->minorVersion, n); + return (*ProcRandrVector[stuff->randrReqType]) (client); +} + +static int +SProcRRGetScreenInfo (ClientPtr client) +{ + register int n; + REQUEST(xRRGetScreenInfoReq); + + swaps(&stuff->length, n); + swapl(&stuff->window, n); + return (*ProcRandrVector[stuff->randrReqType]) (client); +} + +static int +SProcRRSetScreenConfig (ClientPtr client) +{ + register int n; + REQUEST(xRRSetScreenConfigReq); + + if (RRClientKnowsRates (client)) + { + REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); + swaps (&stuff->rate, n); + } + else + { + REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); + } + + swaps(&stuff->length, n); + swapl(&stuff->drawable, n); + swapl(&stuff->timestamp, n); + swaps(&stuff->sizeID, n); + swaps(&stuff->rotation, n); + return (*ProcRandrVector[stuff->randrReqType]) (client); +} + +static int +SProcRRSelectInput (ClientPtr client) +{ + register int n; + REQUEST(xRRSelectInputReq); + + swaps(&stuff->length, n); + swapl(&stuff->window, n); + return (*ProcRandrVector[stuff->randrReqType]) (client); +} + +static int +SProcRRGetScreenSizeRange (ClientPtr client) +{ + REQUEST(xRRGetScreenSizeRangeReq); + + REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRSetScreenSize (ClientPtr client) +{ + REQUEST(xRRSetScreenSizeReq); + + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetScreenResources (ClientPtr client) +{ + REQUEST(xRRGetScreenResourcesReq); + + REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetOutputInfo (ClientPtr client) +{ + REQUEST(xRRGetOutputInfoReq);; + + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRListOutputProperties (ClientPtr client) +{ + REQUEST(xRRListOutputPropertiesReq); + + REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRChangeOutputProperty (ClientPtr client) +{ + REQUEST(xRRChangeOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRDeleteOutputProperty (ClientPtr client) +{ + REQUEST(xRRDeleteOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetOutputProperty (ClientPtr client) +{ + REQUEST(xRRGetOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRCreateMode (ClientPtr client) +{ + REQUEST(xRRCreateModeReq); + + REQUEST_SIZE_MATCH(xRRCreateModeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRDestroyMode (ClientPtr client) +{ + REQUEST(xRRDestroyModeReq); + + REQUEST_SIZE_MATCH(xRRDestroyModeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRAddOutputMode (ClientPtr client) +{ + REQUEST(xRRAddOutputModeReq); + + REQUEST_SIZE_MATCH(xRRAddOutputModeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRDeleteOutputMode (ClientPtr client) +{ + REQUEST(xRRDeleteOutputModeReq); + + REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetCrtcInfo (ClientPtr client) +{ + REQUEST(xRRGetCrtcInfoReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRSetCrtcConfig (ClientPtr client) +{ + REQUEST(xRRSetCrtcConfigReq); + + REQUEST_SIZE_MATCH(xRRSetCrtcConfigReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetCrtcGammaSize (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaSizeReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRGetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaReq); + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRSetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRSetCrtcGammaReq); + + REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); + (void) stuff; + return BadImplementation; +} + +int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = { + SProcRRQueryVersion, /* 0 */ +/* we skip 1 to make old clients fail pretty immediately */ + NULL, /* 1 SProcRandrOldGetScreenInfo */ +/* V1.0 apps share the same set screen config request id */ + SProcRRSetScreenConfig, /* 2 */ + NULL, /* 3 SProcRandrOldScreenChangeSelectInput */ +/* 3 used to be ScreenChangeSelectInput; deprecated */ + SProcRRSelectInput, /* 4 */ + SProcRRGetScreenInfo, /* 5 */ +/* V1.2 additions */ + SProcRRGetScreenSizeRange, /* 6 */ + SProcRRSetScreenSize, /* 7 */ + SProcRRGetScreenResources, /* 8 */ + SProcRRGetOutputInfo, /* 9 */ + SProcRRListOutputProperties,/* 10 */ + SProcRRChangeOutputProperty,/* 11 */ + SProcRRDeleteOutputProperty,/* 12 */ + SProcRRGetOutputProperty, /* 13 */ + SProcRRCreateMode, /* 14 */ + SProcRRDestroyMode, /* 15 */ + SProcRRAddOutputMode, /* 16 */ + SProcRRDeleteOutputMode, /* 17 */ + SProcRRGetCrtcInfo, /* 18 */ + SProcRRSetCrtcConfig, /* 19 */ + SProcRRGetCrtcGammaSize, /* 20 */ + SProcRRGetCrtcGamma, /* 21 */ + SProcRRSetCrtcGamma, /* 22 */ +}; + From 2be1ac15aee592782d7693b8de2c3815478a094e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 18 Sep 2006 12:11:18 -0700 Subject: [PATCH 007/109] Remove smashing of CFLAGS from server build. CFLAGS is a user variable, extracted from the environment at configure time and settable by the user at build time. We must not override this variable. --- configure.ac | 6 ++---- hw/xfree86/common/Makefile.am | 2 +- hw/xfree86/ddc/Makefile.am | 2 +- hw/xfree86/dixmods/extmod/Makefile.am | 2 +- hw/xfree86/dri/Makefile.am | 2 +- hw/xfree86/dummylib/Makefile.am | 2 +- hw/xfree86/exa/Makefile.am | 2 +- hw/xfree86/fbdevhw/Makefile.am | 2 +- hw/xfree86/i2c/Makefile.am | 2 +- hw/xfree86/int10/Makefile.am | 6 +++--- hw/xfree86/loader/Makefile.am | 2 +- hw/xfree86/os-support/Makefile.am | 2 ++ hw/xfree86/parser/Makefile.am | 2 +- hw/xfree86/rac/Makefile.am | 2 +- hw/xfree86/ramdac/Makefile.am | 2 +- hw/xfree86/scanpci/Makefile.am | 2 +- hw/xfree86/shadowfb/Makefile.am | 2 +- hw/xfree86/vbe/Makefile.am | 2 +- hw/xfree86/vgahw/Makefile.am | 2 +- hw/xfree86/x86emu/Makefile.am | 2 +- hw/xfree86/xaa/Makefile.am | 2 +- hw/xfree86/xf4bpp/Makefile.am | 2 +- hw/xfree86/xf8_16bpp/Makefile.am | 2 +- hw/xfree86/xf8_32bpp/Makefile.am | 2 +- 24 files changed, 28 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index 798c8f0da..d1afa784e 100644 --- a/configure.ac +++ b/configure.ac @@ -1605,13 +1605,11 @@ AM_CONDITIONAL(BUILD_KBD_MODE, [test x$BUILD_KBD_MODE = xyes]) AM_CONDITIONAL(BSD_KBD_MODE, [test x$KBD_MODE_TYPE = xbsd]) AM_CONDITIONAL(SUN_KBD_MODE, [test x$KBD_MODE_TYPE = xsun]) -CFLAGS="$XSERVER_CFLAGS $CFLAGS" -AC_SUBST([CFLAGS]) - BUILD_DATE="$(date +'%Y%m%d')" AC_SUBST([BUILD_DATE]) -DIX_CFLAGS="-DHAVE_DIX_CONFIG_H" +DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS" + AC_SUBST([DIX_CFLAGS]) AC_SUBST([libdir exec_prefix prefix]) diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am index d983ee9cc..08a3a877d 100644 --- a/hw/xfree86/common/Makefile.am +++ b/hw/xfree86/common/Makefile.am @@ -103,4 +103,4 @@ if LNXACPI XORG_CFLAGS += -DHAVE_ACPI endif -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am index 7cfff4763..aff8cd3b7 100644 --- a/hw/xfree86/ddc/Makefile.am +++ b/hw/xfree86/ddc/Makefile.am @@ -8,6 +8,6 @@ libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) EXTRA_DIST = ddcPriv.h DDC.HOWTO diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am index 229d4e592..9f6c4081b 100644 --- a/hw/xfree86/dixmods/extmod/Makefile.am +++ b/hw/xfree86/dixmods/extmod/Makefile.am @@ -11,7 +11,7 @@ if XV XV_SRCS = xvmod.c xvmodproc.h endif -AM_CFLAGS = @XORG_CFLAGS@ +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ INCLUDES = @XORG_INCS@ \ -I$(top_srcdir)/afb \ -I$(top_srcdir)/mfb \ diff --git a/hw/xfree86/dri/Makefile.am b/hw/xfree86/dri/Makefile.am index e711846b2..bc7124bc1 100644 --- a/hw/xfree86/dri/Makefile.am +++ b/hw/xfree86/dri/Makefile.am @@ -10,7 +10,7 @@ libdri_la_CFLAGS = -I$(top_srcdir)/hw/xfree86/common \ \ \ \ - @DRIPROTO_CFLAGS@ \ + @DIX_CFLAGS@ @DRIPROTO_CFLAGS@ \ @LIBDRM_CFLAGS@ \ @GL_CFLAGS@ libdri_la_LDFLAGS = -module -avoid-version diff --git a/hw/xfree86/dummylib/Makefile.am b/hw/xfree86/dummylib/Makefile.am index d89ee59a8..6299a1ff7 100644 --- a/hw/xfree86/dummylib/Makefile.am +++ b/hw/xfree86/dummylib/Makefile.am @@ -6,7 +6,7 @@ noinst_LIBRARIES = libdummy-nonserver.a INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) if NEED_STRLCAT STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c diff --git a/hw/xfree86/exa/Makefile.am b/hw/xfree86/exa/Makefile.am index 31682c425..9eb2e1797 100644 --- a/hw/xfree86/exa/Makefile.am +++ b/hw/xfree86/exa/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = \ -I$(srcdir)/../../../exa \ -I$(srcdir)/../../../miext/cw -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) libexa_la_SOURCES = \ examodule.c diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am index 10de50e83..6a4a6e4e6 100644 --- a/hw/xfree86/fbdevhw/Makefile.am +++ b/hw/xfree86/fbdevhw/Makefile.am @@ -11,7 +11,7 @@ endif INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) sdk_HEADERS = fbdevhw.h diff --git a/hw/xfree86/i2c/Makefile.am b/hw/xfree86/i2c/Makefile.am index cbf4f6571..e73fcaeb8 100644 --- a/hw/xfree86/i2c/Makefile.am +++ b/hw/xfree86/i2c/Makefile.am @@ -15,7 +15,7 @@ libi2c_la_SOURCES = xf86i2c.c xf86i2cmodule.c INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) sdk_HEADERS = xf86i2c.h bt829.h fi1236.h msp3430.h tda8425.h tda9850.h tda9885.h uda1380.h i2c_def.h diff --git a/hw/xfree86/int10/Makefile.am b/hw/xfree86/int10/Makefile.am index c059070ec..868954fd4 100644 --- a/hw/xfree86/int10/Makefile.am +++ b/hw/xfree86/int10/Makefile.am @@ -14,7 +14,7 @@ COMMON_SOURCES = \ xf86int10module.c if INT10_VM86 -AM_CFLAGS = -D_PC -D_VM86_LINUX $(XORG_CFLAGS) $(EXTRA_CFLAGS) +AM_CFLAGS = -D_PC -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) INCLUDES = $(XORG_INCS) libint10_la_SOURCES = \ $(COMMON_SOURCES) \ @@ -23,7 +23,7 @@ libint10_la_SOURCES = \ endif if INT10_X86EMU -AM_CFLAGS = -D_X86EMU -DNO_SYS_HEADERS -D_PC $(XORG_CFLAGS) $(EXTRA_CFLAGS) +AM_CFLAGS = -D_X86EMU -DNO_SYS_HEADERS -D_PC $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu libint10_la_SOURCES = \ $(COMMON_SOURCES) \ @@ -33,7 +33,7 @@ libint10_la_SOURCES = \ endif if INT10_STUB -AM_CFLAGS = -D_PC -D_VM86_LINUX $(XORG_CFLAGS) $(EXTRA_CFLAGS) +AM_CFLAGS = -D_PC -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) libint10_la_SOURCES = stub.c xf86int10module.c endif diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am index 030672389..206600214 100644 --- a/hw/xfree86/loader/Makefile.am +++ b/hw/xfree86/loader/Makefile.am @@ -5,7 +5,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ -I$(srcdir)/../ddc -I$(srcdir)/../i2c #AM_LDFLAGS = -r -AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS) +AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS) if XORG_LOADER_SPARC SPARC_SOURCES = SparcMulDiv.S diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am index e64703a53..58b0e95c2 100644 --- a/hw/xfree86/os-support/Makefile.am +++ b/hw/xfree86/os-support/Makefile.am @@ -19,6 +19,8 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ bus/libbus.la \ misc/libmisc.la +AM_CFLAGS = $(DIX_CFLAGS) + xorgos.c: touch $@ diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am index 46ef79060..a9491a18a 100644 --- a/hw/xfree86/parser/Makefile.am +++ b/hw/xfree86/parser/Makefile.am @@ -26,7 +26,7 @@ libxf86config_a_SOURCES = \ DRI.c \ Extensions.c -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) EXTRA_DIST = \ Configint.h \ diff --git a/hw/xfree86/rac/Makefile.am b/hw/xfree86/rac/Makefile.am index 2d8d87975..b25068271 100644 --- a/hw/xfree86/rac/Makefile.am +++ b/hw/xfree86/rac/Makefile.am @@ -5,4 +5,4 @@ sdk_HEADERS = xf86RAC.h INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/ramdac/Makefile.am b/hw/xfree86/ramdac/Makefile.am index c9afdad60..8d944455f 100644 --- a/hw/xfree86/ramdac/Makefile.am +++ b/hw/xfree86/ramdac/Makefile.am @@ -13,7 +13,7 @@ EXTRA_DIST = BTPriv.h IBMPriv.h TIPriv.h xf86CursorPriv.h xf86RamDacPriv.h \ CURSOR.NOTES AM_CFLAGS = -DXAAReverseBitOrder=xf86ReverseBitOrder -DRAMDAC_MODULE \ - $(XORG_CFLAGS) + $(DIX_CFLAGS) $(XORG_CFLAGS) INCLUDES = $(XORG_INCS) xf86BitOrder.c: diff --git a/hw/xfree86/scanpci/Makefile.am b/hw/xfree86/scanpci/Makefile.am index 7e5671aa1..d4d9da222 100644 --- a/hw/xfree86/scanpci/Makefile.am +++ b/hw/xfree86/scanpci/Makefile.am @@ -8,7 +8,7 @@ libscanpci_la_SOURCES = xf86ScanPci.c INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) BUILT_SOURCES = xf86PciIds.h diff --git a/hw/xfree86/shadowfb/Makefile.am b/hw/xfree86/shadowfb/Makefile.am index cb5ebb14a..02d2dd4ea 100644 --- a/hw/xfree86/shadowfb/Makefile.am +++ b/hw/xfree86/shadowfb/Makefile.am @@ -6,4 +6,4 @@ sdk_HEADERS = shadowfb.h INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/vbe/Makefile.am b/hw/xfree86/vbe/Makefile.am index 02fdb4837..85c6fd82a 100644 --- a/hw/xfree86/vbe/Makefile.am +++ b/hw/xfree86/vbe/Makefile.am @@ -4,7 +4,7 @@ libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c sdk_HEADERS = vbe.h vbeModes.h -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ -I$(srcdir)/../int10 diff --git a/hw/xfree86/vgahw/Makefile.am b/hw/xfree86/vgahw/Makefile.am index 2aa27fa41..f48e46a11 100644 --- a/hw/xfree86/vgahw/Makefile.am +++ b/hw/xfree86/vgahw/Makefile.am @@ -2,7 +2,7 @@ module_LTLIBRARIES = libvgahw.la libvgahw_la_LDFLAGS = -avoid-version libvgahw_la_SOURCES = vgaHW.c vgaHWmodule.c INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) sdk_HEADERS = vgaHW.h diff --git a/hw/xfree86/x86emu/Makefile.am b/hw/xfree86/x86emu/Makefile.am index 5959c867a..9f9c87f4f 100644 --- a/hw/xfree86/x86emu/Makefile.am +++ b/hw/xfree86/x86emu/Makefile.am @@ -11,7 +11,7 @@ libx86emu_a_SOURCES = debug.c \ INCLUDES = -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) EXTRA_DIST = validate.c \ x86emu/debug.h \ diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am index 23b7e16b1..5d529b118 100644 --- a/hw/xfree86/xaa/Makefile.am +++ b/hw/xfree86/xaa/Makefile.am @@ -68,4 +68,4 @@ EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \ INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/xf4bpp/Makefile.am b/hw/xfree86/xf4bpp/Makefile.am index 7cb4ac235..9af336446 100644 --- a/hw/xfree86/xf4bpp/Makefile.am +++ b/hw/xfree86/xf4bpp/Makefile.am @@ -59,4 +59,4 @@ mfbseg.c: INCLUDES = $(XORG_INCS) -I$(srcdir)/../xf1bpp -I$(top_srcdir)/mfb -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/xf8_16bpp/Makefile.am b/hw/xfree86/xf8_16bpp/Makefile.am index 5b30f45ed..3c5b8c93d 100644 --- a/hw/xfree86/xf8_16bpp/Makefile.am +++ b/hw/xfree86/xf8_16bpp/Makefile.am @@ -4,7 +4,7 @@ sdk_HEADERS = cfb8_16.h INCLUDES = $(XORG_INCS) -I$(top_srcdir)/fb -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) libxf8_16bpp_la_LDFLAGS = -avoid-version diff --git a/hw/xfree86/xf8_32bpp/Makefile.am b/hw/xfree86/xf8_32bpp/Makefile.am index 3050b81d1..bbcd10f94 100644 --- a/hw/xfree86/xf8_32bpp/Makefile.am +++ b/hw/xfree86/xf8_32bpp/Makefile.am @@ -4,7 +4,7 @@ sdk_HEADERS = cfb8_32.h INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) libxf8_32bpp_la_LDFLAGS = -avoid-version From afe5e9483b352ed06075ed68a6ffa50799194e2d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 18 Sep 2006 12:18:22 -0700 Subject: [PATCH 008/109] RandR working with old clients and old API. --- randr/randr.c | 5 +++-- randr/randrstr.h | 3 +++ randr/rrcrtc.c | 16 ++++++++++++++++ randr/rrdispatch.c | 6 +++--- randr/rrmode.c | 19 +++++++++++++++++++ randr/rroutput.c | 18 ++++++++++++++++++ 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 63d471ce0..926e32f1c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -477,6 +477,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) if (!output) return; RROutputSetCrtcs (output, &crtc, 1); + RROutputSetCrtc (output, crtc); RROutputSetConnection (output, RR_Connected); } @@ -552,8 +553,8 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) /* notice current mode */ if (newMode) - RRCrtcSet (output->crtc, newMode, 0, 0, pScrPriv->rotation, - 1, &output); + RRCrtcNotify (output->crtc, newMode, 0, 0, pScrPriv->rotation, + 1, &output); } #endif diff --git a/randr/randrstr.h b/randr/randrstr.h index 33461570f..a7f91b79a 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -482,6 +482,9 @@ RROutputSetCrtcs (RROutputPtr output, RRCrtcPtr *crtcs, int numCrtcs); +void +RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc); + Bool RROutputSetConnection (RROutputPtr output, CARD8 connection); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index d343c3a57..d1328e7ba 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -59,7 +59,13 @@ RRCrtcCreate (ScreenPtr pScreen, crtc->numOutputs = 0; crtc->changed = TRUE; crtc->devPrivate = devPrivate; + + if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) + return NULL; + + pScrPriv->crtcs = crtcs; pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; + pScrPriv->changed = TRUE; return crtc; } @@ -165,6 +171,16 @@ RRCrtcSet (RRCrtcPtr crtc, ScreenPtr pScreen = crtc->pScreen; rrScrPriv(pScreen); + /* See if nothing changed */ + if (crtc->mode == mode && + crtc->x == x && + crtc->y == y && + crtc->rotation == rotation && + crtc->numOutputs == numOutputs && + !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr))) + { + return TRUE; + } #if RANDR_12_INTERFACE if (pScrPriv->rrCrtcSet) { diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index acf629832..279acfdee 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -824,7 +824,7 @@ ProcRRSetCrtcConfig (ClientPtr client) if (!crtc) { client->errorValue = stuff->crtc; - return RRErrorBase + BadCrtc; + return RRErrorBase + BadRRCrtc; } if (stuff->mode == None) { @@ -838,7 +838,7 @@ ProcRRSetCrtcConfig (ClientPtr client) if (!mode) { client->errorValue = stuff->mode; - return RRErrorBase + BadMode; + return RRErrorBase + BadRRMode; } if (numOutputs == 0) return BadMatch; @@ -854,7 +854,7 @@ ProcRRSetCrtcConfig (ClientPtr client) if (!outputs[i]) { client->errorValue = outputIds[i]; - return RRErrorBase + BadOutput; + return RRErrorBase + BadRROutput; } /* validate crtc for this output */ for (j = 0; j < outputs[i]->numCrtcs; j++) diff --git a/randr/rrmode.c b/randr/rrmode.c index 3a9d55671..52585d967 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -32,6 +32,7 @@ RRModeGet (ScreenPtr pScreen, rrScrPriv (pScreen); int i; RRModePtr mode; + RRModePtr *modes; for (i = 0; i < pScrPriv->numModes; i++) { @@ -43,16 +44,34 @@ RRModeGet (ScreenPtr pScreen, return mode; } } + mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1); + if (!mode) + return NULL; mode->refcnt = 1; mode->mode = *modeInfo; mode->name = (char *) (mode + 1); memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; + + if (pScrPriv->numModes) + modes = xrealloc (pScrPriv->modes, + (pScrPriv->numModes + 1) * sizeof (RRModePtr)); + else + modes = xalloc (sizeof (RRModePtr)); + + if (!modes) + { + xfree (mode); + return NULL; + } + mode->id = FakeClientID(0); if (!AddResource (mode->id, RRModeType, (pointer) mode)) return NULL; ++mode->refcnt; + pScrPriv->modes = modes; + pScrPriv->modes[pScrPriv->numModes++] = mode; pScrPriv->changed = TRUE; return mode; } diff --git a/randr/rroutput.c b/randr/rroutput.c index 6b67f1997..ba5bcb451 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -56,6 +56,7 @@ RROutputCreate (ScreenPtr pScreen, output->name = (char *) (output + 1); output->nameLength = nameLength; memcpy (output->name, name, nameLength); + output->name[nameLength] = '\0'; output->connection = RR_UnknownConnection; output->subpixelOrder = SubPixelUnknown; output->crtc = NULL; @@ -67,7 +68,13 @@ RROutputCreate (ScreenPtr pScreen, output->modes = NULL; output->changed = TRUE; output->devPrivate = devPrivate; + + if (!AddResource (output->id, RROutputType, (pointer) output)) + return NULL; + + pScrPriv->outputs = outputs; pScrPriv->outputs[pScrPriv->numOutputs++] = output; + pScrPriv->changed = TRUE; return output; } @@ -89,6 +96,7 @@ RROutputSetClones (RROutputPtr output, memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); output->clones = newClones; output->numClones = numClones; + output->changed = TRUE; return TRUE; } @@ -107,6 +115,7 @@ RROutputSetModes (RROutputPtr output, memcpy (newModes, modes, numModes * sizeof (RRModePtr)); output->modes = newModes; output->numModes = numModes; + output->changed = TRUE; return TRUE; } @@ -125,14 +134,23 @@ RROutputSetCrtcs (RROutputPtr output, memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; + output->changed = TRUE; return TRUE; } +void +RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) +{ + output->crtc = crtc; + output->changed = TRUE; +} + Bool RROutputSetConnection (RROutputPtr output, CARD8 connection) { output->connection = connection; + output->changed = TRUE; return TRUE; } From 07112adb0802d28488de5a495aa61bb3cfc280b6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 Sep 2006 00:46:27 -0700 Subject: [PATCH 009/109] RRGetScreenResources and RRGetOutputInfo are working now. Removed separate id field in RRModeRec. Pull screen subpixel order from Render extension. Implement RGetScreenResources and RRGetOutputInfo --- randr/randr.c | 5 +- randr/randrstr.h | 5 +- randr/rrdispatch.c | 217 ++++++++++++++++++++++++++++++++++++++++++++- randr/rrmode.c | 5 +- randr/rroutput.c | 9 ++ 5 files changed, 233 insertions(+), 8 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 926e32f1c..beddb50b0 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -442,7 +442,7 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) if (!modes) { RRModeDestroy (mode); - FreeResource (mode->id, 0); + FreeResource (mode->mode.id, 0); return NULL; } modes[output->numModes++] = mode; @@ -479,6 +479,9 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) RROutputSetCrtcs (output, &crtc, 1); RROutputSetCrtc (output, crtc); RROutputSetConnection (output, RR_Connected); +#ifdef RENDER + RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen)); +#endif } output = RRFirstOutput (pScreen); diff --git a/randr/randrstr.h b/randr/randrstr.h index a7f91b79a..682ebbfed 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -74,7 +74,6 @@ typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; typedef struct _rrOutput RROutputRec, *RROutputPtr; struct _rrMode { - RRMode id; int refcnt; xRRModeInfo mode; char *name; @@ -489,6 +488,10 @@ Bool RROutputSetConnection (RROutputPtr output, CARD8 connection); +Bool +RROutputSetSubpixelOrder (RROutputPtr output, + int subpixelOrder); + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 279acfdee..aca0e542a 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -694,20 +694,229 @@ static int ProcRRGetScreenResources (ClientPtr client) { REQUEST(xRRGetScreenResourcesReq); + xRRGetScreenResourcesReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + int i; + RRCrtc *crtcs; + RROutput *outputs; + xRRModeInfo *modeinfos; + CARD8 *names; + int n; REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); - (void) stuff; - return BadImplementation; + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (pScrPriv) + RRGetInfo (pScreen); + + if (!pScrPriv) + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = 0; + rep.nOutputs = 0; + rep.nModes = 0; + rep.nbytesNames = 0; + extra = NULL; + extraLen = 0; + } + else + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = pScrPriv->numCrtcs; + rep.nOutputs = pScrPriv->numOutputs; + rep.nModes = pScrPriv->numModes;; + rep.nbytesNames = 0; + + for (i = 0; i < pScrPriv->numModes; i++) + rep.nbytesNames += pScrPriv->modes[i]->mode.nameLength; + + rep.length = (pScrPriv->numCrtcs + + pScrPriv->numOutputs + + pScrPriv->numModes * 10 + + ((rep.nbytesNames + 3) >> 2)); + + extraLen = rep.length << 2; + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + + crtcs = (RRCrtc *) extra; + outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); + modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); + names = (CARD8 *) (modeinfos + pScrPriv->numModes); + + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + crtcs[i] = pScrPriv->crtcs[i]->id; + if (client->swapped) + swapl (&crtcs[i], n); + } + + for (i = 0; i < pScrPriv->numOutputs; i++) + { + outputs[i] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl (&outputs[i], n); + } + + for (i = 0; i < pScrPriv->numModes; i++) + { + modeinfos[i] = pScrPriv->modes[i]->mode; + if (client->swapped) + { + swapl (&modeinfos[i].id, n); + swaps (&modeinfos[i].width, n); + swaps (&modeinfos[i].height, n); + swapl (&modeinfos[i].mmWidth, n); + swapl (&modeinfos[i].mmHeight, n); + swapl (&modeinfos[i].dotClock, n); + swaps (&modeinfos[i].hSyncStart, n); + swaps (&modeinfos[i].hSyncEnd, n); + swaps (&modeinfos[i].hTotal, n); + swaps (&modeinfos[i].hSkew, n); + swaps (&modeinfos[i].vSyncStart, n); + swaps (&modeinfos[i].vSyncEnd, n); + swaps (&modeinfos[i].vTotal, n); + swaps (&modeinfos[i].nameLength, n); + swapl (&modeinfos[i].modeFlags, n); + } + memcpy (names, pScrPriv->modes[i]->name, + pScrPriv->modes[i]->mode.nameLength); + names += pScrPriv->modes[i]->mode.nameLength; + } + assert ((names + 3 >> 3) == rep.length); + } + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.configTimestamp, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nOutputs, n); + swaps(&rep.nModes, n); + swaps(&rep.nbytesNames, n); + } + WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + return client->noClientException; } static int ProcRRGetOutputInfo (ClientPtr client) { REQUEST(xRRGetOutputInfoReq);; + xRRGetOutputInfoReply rep; + RROutputPtr output; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtc *crtcs; + RRMode *modes; + RROutput *clones; + char *name; + int i, n; REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - (void) stuff; - return BadImplementation; + output = (RROutputPtr)SecurityLookupIDByType(client, stuff->output, + RROutputType, + SecurityReadAccess); + + if (!output) + return RRErrorBase + BadRROutput; + + pScreen = output->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.crtc = output->crtc ? output->crtc->id : None; + rep.connection = output->connection; + rep.subpixelOrder = output->subpixelOrder; + rep.nCrtcs = output->numCrtcs; + rep.nModes = output->numModes; + rep.nClones = output->numClones; + rep.nameLength = output->nameLength; + + rep.length = (output->numCrtcs + + output->numModes + + output->numClones + + ((rep.nameLength + 3) >> 2)); + + extraLen = rep.length << 2; + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + + crtcs = (RRCrtc *) extra; + modes = (RRMode *) (crtcs + output->numCrtcs); + clones = (RROutput *) (modes + output->numModes); + name = (char *) (clones + output->numClones); + + for (i = 0; i < output->numCrtcs; i++) + { + crtcs[i] = output->crtcs[i]->id; + if (client->swapped) + swapl (&crtcs[i], n); + } + for (i = 0; i < output->numModes; i++) + { + modes[i] = output->modes[i]->mode.id; + if (client->swapped) + swapl (&modes[i], n); + } + for (i = 0; i < output->numClones; i++) + { + clones[i] = output->clones[i]->id; + if (client->swapped) + swapl (&clones[i], n); + } + memcpy (name, output->name, output->nameLength); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.crtc, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nModes, n); + swaps(&rep.nClones, n); + swaps(&rep.nameLength, n); + } + WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + + return client->noClientException; } static int diff --git a/randr/rrmode.c b/randr/rrmode.c index 52585d967..4e44e7d82 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -37,6 +37,7 @@ RRModeGet (ScreenPtr pScreen, for (i = 0; i < pScrPriv->numModes; i++) { mode = pScrPriv->modes[i]; + modeInfo->id = mode->mode.id; if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) && !memcmp (name, mode->name, modeInfo->nameLength)) { @@ -66,8 +67,8 @@ RRModeGet (ScreenPtr pScreen, return NULL; } - mode->id = FakeClientID(0); - if (!AddResource (mode->id, RRModeType, (pointer) mode)) + mode->mode.id = FakeClientID(0); + if (!AddResource (mode->mode.id, RRModeType, (pointer) mode)) return NULL; ++mode->refcnt; pScrPriv->modes = modes; diff --git a/randr/rroutput.c b/randr/rroutput.c index ba5bcb451..478002300 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -154,6 +154,15 @@ RROutputSetConnection (RROutputPtr output, return TRUE; } +Bool +RROutputSetSubpixelOrder (RROutputPtr output, + int subpixelOrder) +{ + output->subpixelOrder = subpixelOrder; + output->changed = TRUE; + return TRUE; +} + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { From ef1f3248cb5fff0a02c0059f865c4d931eba23a6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 Sep 2006 22:48:54 -0700 Subject: [PATCH 010/109] Split out 1.0-style info and new property routines to their own files. --- randr/Makefile.am | 2 + randr/mirandr.c | 12 +- randr/randr.c | 394 +---------------- randr/randrstr.h | 128 +++++- randr/rrcrtc.c | 461 +++++++++++++++++++- randr/rrdispatch.c | 1035 -------------------------------------------- randr/rrmode.c | 41 ++ randr/rroutput.c | 96 +++- randr/rrscreen.c | 651 ++++++++++++++++++++++++++++ 9 files changed, 1385 insertions(+), 1435 deletions(-) diff --git a/randr/Makefile.am b/randr/Makefile.am index 0a735574e..a28ead0eb 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -12,7 +12,9 @@ librandr_la_SOURCES = \ randrstr.h \ rrcrtc.c \ rrdispatch.c \ + rrinfo.c \ rrmode.c \ rroutput.c \ + rrproperty.c \ rrscreen.c \ rrsdispatch.c diff --git a/randr/mirandr.c b/randr/mirandr.c index a57a157ca..bcc8e0fcd 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -108,11 +108,13 @@ miRandRInit (ScreenPtr pScreen) output = RROutputCreate (pScreen, "screen", 6, NULL); if (!output) return FALSE; - if (!RROutputSet (output, - NULL, 0, /* clones */ - &mode, 1, /* modes */ - &crtc, 1, /* crtcs */ - RR_Connected)) + if (!RROutputSetClones (output, NULL, 0)) + return FALSE; + if (!RROutputSetModes (output, &mode, 1)) + return FALSE; + if (!RROutputSetCrtcs (output, &crtc, 1)) + return FALSE; + if (!RROutputSetConnection (output, RR_Connected)) return FALSE; RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output); #endif diff --git a/randr/randr.c b/randr/randr.c index beddb50b0..5f6ef62e4 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -198,7 +198,9 @@ Bool RRScreenInit(ScreenPtr pScreen) pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; #if RANDR_12_INTERFACE - pScrPriv->rrCrtcSet = 0; + pScrPriv->rrScreenSizeSet = NULL; + pScrPriv->rrCrtcSet = NULL; + pScrPriv->rrCrtcSetGamma = NULL; #endif #if RANDR_10_INTERFACE pScrPriv->rrSetConfig = 0; @@ -400,196 +402,6 @@ RRFirstOutput (ScreenPtr pScreen) return NULL; } -#ifdef RANDR_10_INTERFACE -static RRModePtr -RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) -{ - ScreenPtr pScreen = output->pScreen; - rrScrPriv(pScreen); - xRRModeInfo modeInfo; - char name[100]; - RRModePtr mode; - int i; - RRModePtr *modes; - - memset (&modeInfo, '\0', sizeof (modeInfo)); - sprintf (name, "%dx%d", size->width, size->height); - - modeInfo.width = size->width; - modeInfo.height = size->height; - modeInfo.mmWidth = size->mmWidth; - modeInfo.mmHeight = size->mmHeight; - modeInfo.hTotal = size->width; - modeInfo.vTotal = size->height; - modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->width * - (CARD32) refresh); - modeInfo.nameLength = strlen (name); - mode = RRModeGet (pScreen, &modeInfo, name); - if (!mode) - return NULL; - for (i = 0; i < output->numModes; i++) - if (output->modes[i] == mode) - { - RRModeDestroy (mode); - return mode; - } - - if (output->numModes) - modes = xrealloc (output->modes, - (output->numModes + 1) * sizeof (RRModePtr)); - else - modes = xalloc (sizeof (RRModePtr)); - if (!modes) - { - RRModeDestroy (mode); - FreeResource (mode->mode.id, 0); - return NULL; - } - modes[output->numModes++] = mode; - output->modes = modes; - output->changed = TRUE; - pScrPriv->changed = TRUE; - return mode; -} - -static void -RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) -{ - rrScrPriv(pScreen); - RROutputPtr output; - RRCrtcPtr crtc; - RRModePtr mode, newMode = NULL; - int i; - CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; - CARD16 maxWidth = 0, maxHeight = 0; - - /* - * First time through, create a crtc and output and hook - * them together - */ - if (pScrPriv->numOutputs == 0 && - pScrPriv->numCrtcs == 0) - { - crtc = RRCrtcCreate (pScreen, NULL); - if (!crtc) - return; - output = RROutputCreate (pScreen, "default", 7, NULL); - if (!output) - return; - RROutputSetCrtcs (output, &crtc, 1); - RROutputSetCrtc (output, crtc); - RROutputSetConnection (output, RR_Connected); -#ifdef RENDER - RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen)); -#endif - } - - output = RRFirstOutput (pScreen); - if (!output) - return; - crtc = output->crtc; - - /* check rotations */ - if (rotations != crtc->rotations) - { - crtc->rotations = rotations; - crtc->changed = TRUE; - pScrPriv->changed = TRUE; - } - - /* regenerate mode list */ - for (i = 0; i < pScrPriv->nSizes; i++) - { - RRScreenSizePtr size = &pScrPriv->pSizes[i]; - int r; - - if (size->nRates) - { - for (r = 0; r < size->nRates; r++) - { - mode = RROldModeAdd (output, size, size->pRates[r].rate); - if (i == pScrPriv->size && - size->pRates[r].rate == pScrPriv->rate) - { - newMode = mode; - } - } - xfree (size->pRates); - } - else - { - mode = RROldModeAdd (output, size, 0); - if (i == pScrPriv->size) - newMode = mode; - } - } - if (pScrPriv->nSizes) - xfree (pScrPriv->pSizes); - pScrPriv->pSizes = NULL; - pScrPriv->nSizes = 0; - - /* find size bounds */ - for (i = 0; i < output->numModes; i++) - { - RRModePtr mode = output->modes[i]; - CARD16 width = mode->mode.width; - CARD16 height = mode->mode.height; - - if (width < minWidth) minWidth = width; - if (width > maxWidth) maxWidth = width; - if (height < minHeight) minHeight = height; - if (height > maxHeight) maxHeight = height; - } - - if (minWidth != pScrPriv->minWidth) { - pScrPriv->minWidth = minWidth; pScrPriv->changed = TRUE; - } - if (maxWidth != pScrPriv->maxWidth) { - pScrPriv->maxWidth = maxWidth; pScrPriv->changed = TRUE; - } - if (minHeight != pScrPriv->minHeight) { - pScrPriv->minHeight = minHeight; pScrPriv->changed = TRUE; - } - if (maxHeight != pScrPriv->maxHeight) { - pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE; - } - - /* notice current mode */ - if (newMode) - RRCrtcNotify (output->crtc, newMode, 0, 0, pScrPriv->rotation, - 1, &output); -} -#endif - -/* - * Poll the driver for changed information - */ -Bool -RRGetInfo (ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - Rotation rotations; - int i; - - for (i = 0; i < pScrPriv->numOutputs; i++) - pScrPriv->outputs[i]->changed = FALSE; - for (i = 0; i < pScrPriv->numCrtcs; i++) - pScrPriv->crtcs[i]->changed = FALSE; - - rotations = 0; - pScrPriv->changed = FALSE; - - if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) - return FALSE; - -#if RANDR_10_INTERFACE - if (pScrPriv->nSizes) - RRScanOldConfig (pScreen, rotations); -#endif - RRTellChanged (pScreen); - return TRUE; -} - CARD16 RRVerticalRefresh (xRRModeInfo *mode) { @@ -602,83 +414,6 @@ RRVerticalRefresh (xRRModeInfo *mode) return (CARD16) refresh; } -#if 0 -int -RRSetScreenConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - rrScrPrivPtr pScrPriv; - RRMonitorPtr pMonitor; - short oldWidth, oldHeight; - RRModePtr pMode; - int status; - - pScrPriv = rrGetScrPriv(pScreen); - - if (!pScrPriv) - return BadImplementation; - - pMonitor = pScrPriv->pMonitors; - if (!pMonitor) - return BadImplementation; - - oldWidth = pScreen->width; - oldHeight = pScreen->height; - - if (!RRGetInfo (pScreen)) - return BadAlloc; - - /* - * Validate requested rotation - */ - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - return BadValue; - } - - if ((~pScrPriv->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - return BadMatch; - } - - for (pMode = pMonitor->pModes; pMode; pMode = pMode->next) - { - if (pMode->mode.width == pSize->width && - pMode->mode.height == pSize->height && - pMode->mode.widthInMillimeters == pSize->mmWidth && - pMode->mode.heightInMillimeters == pSize->mmHeight && - (RRVerticalRefresh (&pMode->mode) == rate || rate == 0)) - { - break; - } - } - if (!pMode) - return BadValue; - - status = RRMonitorSetMode (pScreen, pMonitor, pMode, 0, 0, - rotation, currentTime); - - if (status != RRSetConfigSuccess) - return BadImplementation; - return Success; -} -#endif - static int ProcRRDispatch (ClientPtr client) { @@ -697,126 +432,3 @@ SProcRRDispatch (ClientPtr client) return (*SProcRandrVector[stuff->data]) (client); } -#if RANDR_12_INTERFACE -/* - * Register the range of sizes for the screen - */ -void -RRScreenSetSizeRange (ScreenPtr pScreen, - CARD16 minWidth, - CARD16 minHeight, - CARD16 maxWidth, - CARD16 maxHeight) -{ - rrScrPriv (pScreen); - - if (!pScrPriv) - return; - pScrPriv->minWidth = minWidth; - pScrPriv->minHeight = minHeight; - pScrPriv->maxWidth = maxWidth; - pScrPriv->maxHeight = maxHeight; -} -#endif - -#ifdef RANDR_10_INTERFACE -static Bool -RRScreenSizeMatches (RRScreenSizePtr a, - RRScreenSizePtr b) -{ - if (a->width != b->width) - return FALSE; - if (a->height != b->height) - return FALSE; - if (a->mmWidth != b->mmWidth) - return FALSE; - if (a->mmHeight != b->mmHeight) - return FALSE; - return TRUE; -} - -RRScreenSizePtr -RRRegisterSize (ScreenPtr pScreen, - short width, - short height, - short mmWidth, - short mmHeight) -{ - rrScrPriv (pScreen); - int i; - RRScreenSize tmp; - RRScreenSizePtr pNew; - - if (!pScrPriv) - return 0; - - tmp.id = 0; - tmp.width = width; - tmp.height= height; - tmp.mmWidth = mmWidth; - tmp.mmHeight = mmHeight; - tmp.pRates = 0; - tmp.nRates = 0; - for (i = 0; i < pScrPriv->nSizes; i++) - if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i])) - return &pScrPriv->pSizes[i]; - pNew = xrealloc (pScrPriv->pSizes, - (pScrPriv->nSizes + 1) * sizeof (RRScreenSize)); - if (!pNew) - return 0; - pNew[pScrPriv->nSizes++] = tmp; - pScrPriv->pSizes = pNew; - return &pNew[pScrPriv->nSizes-1]; -} - -Bool RRRegisterRate (ScreenPtr pScreen, - RRScreenSizePtr pSize, - int rate) -{ - rrScrPriv(pScreen); - int i; - RRScreenRatePtr pNew, pRate; - - if (!pScrPriv) - return FALSE; - - for (i = 0; i < pSize->nRates; i++) - if (pSize->pRates[i].rate == rate) - return TRUE; - - pNew = xrealloc (pSize->pRates, - (pSize->nRates + 1) * sizeof (RRScreenRate)); - if (!pNew) - return FALSE; - pRate = &pNew[pSize->nRates++]; - pRate->rate = rate; - pSize->pRates = pNew; - return TRUE; -} - -Rotation -RRGetRotation(ScreenPtr pScreen) -{ - RROutputPtr output = RRFirstOutput (pScreen); - - if (!output) - return RR_Rotate_0; - - return output->crtc->rotation; -} - -void -RRSetCurrentConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - rrScrPriv (pScreen); - - if (!pScrPriv) - return; - pScrPriv->size = pSize - pScrPriv->pSizes; - pScrPriv->rotation = rotation; - pScrPriv->rate = rate; -} -#endif diff --git a/randr/randrstr.h b/randr/randrstr.h index 682ebbfed..26c180697 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -53,7 +53,7 @@ /* required for ABI compatibility for now */ #define RANDR_10_INTERFACE 1 -/* #define RANDR_12_INTERFACE 1 */ +#define RANDR_12_INTERFACE 1 typedef XID RRMode; typedef XID RROutput; @@ -89,6 +89,10 @@ struct _rrCrtc { Bool changed; int numOutputs; RROutputPtr *outputs; + int gammaSize; + CARD16 *gammaRed; + CARD16 *gammaBlue; + CARD16 *gammaGreen; void *devPrivate; }; @@ -107,11 +111,12 @@ struct _rrOutput { int numModes; RRModePtr *modes; Bool changed; + PropertyPtr properties; void *devPrivate; }; #if RANDR_12_INTERFACE -typedef Bool (*RRScreentSizeSetProcPtr) (ScreenPtr pScreen, +typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 mmWidth, @@ -125,6 +130,10 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, Rotation rotation, int numOutputs, RROutputPtr *outputs); + +typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, + RRCrtcPtr crtc); + #endif typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); @@ -167,6 +176,7 @@ typedef struct _rrScrPriv { #if RANDR_12_INTERFACE RRScreenSetSizeProcPtr rrScreenSizeSet; RRCrtcSetProcPtr rrCrtcSet; + RRCrtcSetGammaProcPtr rrCrtcSetGamma; #endif /* @@ -245,6 +255,16 @@ extern RESTYPE RRClientType, RREventType; /* resource types for event masks */ extern int RRClientPrivateIndex; extern RESTYPE RRCrtcType, RRModeType, RROutputType; +#define LookupOutput(client,id,a) ((RROutputPtr) \ + (SecurityLookupIDByType (client, id, \ + RROutputType, a))) +#define LookupCrtc(client,id,a) ((RRCrtcPtr) \ + (SecurityLookupIDByType (client, id, \ + RRCrtcType, a))) +#define LookupMode(client,id,a) ((RRModePtr) \ + (SecurityLookupIDByType (client, id, \ + RRModeType, a))) + #define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr) #define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient) @@ -283,6 +303,24 @@ RRScreenSizeSet (ScreenPtr pScreen, CARD32 mmWidth, CARD32 mmHeight); +/* + * screen dispatch + */ +int +ProcRRGetScreenSizeRange (ClientPtr client); + +int +ProcRRSetScreenSize (ClientPtr client); + +int +ProcRRGetScreenResources (ClientPtr client); + +int +ProcRRSetScreenConfig (ClientPtr client); + +int +ProcRRGetScreenInfo (ClientPtr client); + /* * Deliver a ScreenNotify event */ @@ -413,6 +451,33 @@ RRCrtcSet (RRCrtcPtr crtc, int numOutput, RROutputPtr *outputs); +/* + * Request that the Crtc gamma be changed + */ + +Bool +RRCrtcGammaSet (RRCrtcPtr crtc, + CARD16 *red, + CARD16 *green, + CARD16 *blue); + +/* + * Notify the extension that the Crtc gamma has been changed + * The driver calls this whenever it has changed the gamma values + * in the RRCrtcRec + */ + +Bool +RRCrtcGammaNotify (RRCrtcPtr crtc); + +/* + * Set the size of the gamma table at server startup time + */ + +Bool +RRCrtcGammaSetSize (RRCrtcPtr crtc, + int size); + /* * Destroy a Crtc at shutdown */ @@ -425,6 +490,25 @@ RRCrtcDestroy (RRCrtcPtr crtc); Bool RRCrtcInit (void); +/* + * Crtc dispatch + */ + +int +ProcRRGetCrtcInfo (ClientPtr client); + +int +ProcRRSetCrtcConfig (ClientPtr client); + +int +ProcRRGetCrtcGammaSize (ClientPtr client); + +int +ProcRRGetCrtcGamma (ClientPtr client); + +int +ProcRRSetCrtcGamma (ClientPtr client); + /* rrdispatch.c */ Bool RRClientKnowsRates (ClientPtr pClient); @@ -452,6 +536,18 @@ RRModeDestroy (RRModePtr mode); Bool RRModeInit (void); +int +ProcRRCreateMode (ClientPtr client); + +int +ProcRRDestroyMode (ClientPtr client); + +int +ProcRRAddOutputMode (ClientPtr client); + +int +ProcRRDeleteOutputMode (ClientPtr client); + /* rroutput.c */ /* * Create an output @@ -498,10 +594,38 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); void RROutputDestroy (RROutputPtr output); +int +ProcRRGetOutputInfo (ClientPtr client); + /* * Initialize output type */ Bool RROutputInit (void); +/* rrproperty.c */ + +void +RRDeleteAllOutputProperties (RROutputPtr output); + +void +RRDeleteOutputProperty (RROutputPtr output, Atom property); + +int +RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, + int format, int mode, unsigned long len, + pointer value, Bool sendevent); + +int +ProcRRChangeOutputProperty (ClientPtr client); + +int +ProcRRGetOutputProperty (ClientPtr client); + +int +ProcRRListOutputProperties (ClientPtr client); + +int +ProcRRDeleteOutputProperty (ClientPtr client); + #endif /* _RANDRSTR_H_ */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index d1328e7ba..c55e08871 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -21,6 +21,7 @@ */ #include "randrstr.h" +#include "swaprep.h" RESTYPE RRCrtcType; @@ -57,6 +58,8 @@ RRCrtcCreate (ScreenPtr pScreen, crtc->rotations = RR_Rotate_0; crtc->outputs = NULL; crtc->numOutputs = 0; + crtc->gammaSize = 0; + crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL; crtc->changed = TRUE; crtc->devPrivate = devPrivate; @@ -241,10 +244,74 @@ RRCrtcDestroyResource (pointer value, XID pid) break; } } - free (value); + if (crtc->gammaRed) + xfree (crtc->gammaRed); + xfree (value); return 1; } +/* + * Request that the Crtc gamma be changed + */ + +Bool +RRCrtcGammaSet (RRCrtcPtr crtc, + CARD16 *red, + CARD16 *green, + CARD16 *blue) +{ + Bool ret = TRUE; +#if RANDR_12_INTERFACE + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); +#endif + + memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16)); + memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16)); + memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16)); +#if RANDR_12_INTERFACE + if (pScrPriv->rrCrtcSetGamma) + ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc); +#endif + return ret; +} + +/* + * Notify the extension that the Crtc gamma has been changed + * The driver calls this whenever it has changed the gamma values + * in the RRCrtcRec + */ + +Bool +RRCrtcGammaNotify (RRCrtcPtr crtc) +{ + return TRUE; /* not much going on here */ +} + +/* + * Set the size of the gamma table at server startup time + */ + +Bool +RRCrtcGammaSetSize (RRCrtcPtr crtc, + int size) +{ + CARD16 *gamma; + + if (size == crtc->gammaSize) + return TRUE; + gamma = xalloc (size * 3 * sizeof (CARD16)); + if (!gamma) + return FALSE; + if (crtc->gammaRed) + xfree (crtc->gammaRed); + crtc->gammaRed = gamma; + crtc->gammaGreen = gamma + size; + crtc->gammaBlue = gamma + size*2; + crtc->gammaSize = size; + return TRUE; +} + /* * Initialize crtc type */ @@ -259,3 +326,395 @@ RRCrtcInit (void) #endif return TRUE; } + +int +ProcRRGetCrtcInfo (ClientPtr client) +{ + REQUEST(xRRGetCrtcInfoReq);; + xRRGetCrtcInfoReply rep; + RRCrtcPtr crtc; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRModePtr mode; + RROutput *outputs; + RROutput *possible; + int i, j, k, n; + + REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); + crtc = LookupCrtc(client, stuff->crtc, SecurityReadAccess); + + if (!crtc) + return RRErrorBase + BadRRCrtc; + + pScreen = crtc->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + mode = crtc->mode; + + rep.type = X_Reply; + rep.status = RRSetConfigSuccess; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.x = crtc->x; + rep.y = crtc->y; + rep.width = mode ? mode->mode.width : 0; + rep.height = mode ? mode->mode.height : 0; + rep.mode = mode->mode.id; + rep.rotation = crtc->rotation; + rep.rotations = crtc->rotations; + rep.nOutput = crtc->numOutputs; + k = 0; + for (i = 0; i < pScrPriv->numOutputs; i++) + for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) + if (pScrPriv->outputs[i]->crtcs[j] == crtc) + k++; + rep.nPossibleOutput = k; + + rep.length = rep.nOutput + rep.nPossibleOutput; + + extraLen = rep.length << 2; + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + + outputs = (RROutput *) extra; + possible = (RROutput *) (outputs + rep.nOutput); + + for (i = 0; i < crtc->numOutputs; i++) + { + outputs[i] = crtc->outputs[i]->id; + if (client->swapped) + swapl (&outputs[i], n); + } + k = 0; + for (i = 0; i < pScrPriv->numOutputs; i++) + for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) + if (pScrPriv->outputs[i]->crtcs[j] == crtc) + { + possible[k] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl (&possible[k], n); + k++; + } + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swaps(&rep.x, n); + swaps(&rep.y, n); + swaps(&rep.width, n); + swaps(&rep.height, n); + swapl(&rep.mode, n); + swaps(&rep.rotation, n); + swaps(&rep.rotations, n); + swaps(&rep.nOutput, n); + swaps(&rep.nPossibleOutput, n); + } + WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + + return client->noClientException; +} + +int +ProcRRSetCrtcConfig (ClientPtr client) +{ + REQUEST(xRRSetCrtcConfigReq); + xRRSetCrtcConfigReply rep; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + RRModePtr mode; + int numOutputs; + RROutputPtr *outputs = NULL; + RROutput *outputIds; + TimeStamp configTime; + TimeStamp time; + Rotation rotation; + int i, j; + + REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); + numOutputs = stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2); + + crtc = LookupIDByType (stuff->crtc, RRCrtcType); + if (!crtc) + { + client->errorValue = stuff->crtc; + return RRErrorBase + BadRRCrtc; + } + if (stuff->mode == None) + { + mode = NULL; + if (numOutputs > 0) + return BadMatch; + } + else + { + mode = LookupIDByType (stuff->mode, RRModeType); + if (!mode) + { + client->errorValue = stuff->mode; + return RRErrorBase + BadRRMode; + } + if (numOutputs == 0) + return BadMatch; + } + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!outputs) + return BadAlloc; + + outputIds = (RROutput *) (stuff + 1); + for (i = 0; i < numOutputs; i++) + { + outputs[i] = LookupIDByType (outputIds[i], RROutputType); + if (!outputs[i]) + { + client->errorValue = outputIds[i]; + if (outputs) + xfree (outputs); + return RRErrorBase + BadRROutput; + } + /* validate crtc for this output */ + for (j = 0; j < outputs[i]->numCrtcs; j++) + if (outputs[i]->crtcs[j] == crtc) + break; + if (j == outputs[j]->numCrtcs) + { + if (outputs) + xfree (outputs); + return BadMatch; + } + /* validate mode for this output */ + for (j = 0; j < outputs[i]->numModes; j++) + if (outputs[i]->modes[j] == mode) + break; + if (j == outputs[i]->numModes) + { + if (outputs) + xfree (outputs); + return BadMatch; + } + } + + pScreen = crtc->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + if (!RRGetInfo (pScreen)) + { + if (outputs) + xfree (outputs); + return BadAlloc; + } + + time = ClientTimeToServerTime(stuff->timestamp); + configTime = ClientTimeToServerTime(stuff->configTimestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + + /* + * if the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated + */ + if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + if (outputs) + xfree (outputs); + return BadValue; + } + + if ((~crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + if (outputs) + xfree (outputs); + return BadMatch; + } + +#ifdef RANDR_12_INTERFACE + /* + * Check screen size bounds if the DDX provides a 1.2 interface + * for setting screen size. Else, assume the CrtcSet sets + * the size along with the mode + */ + if (pScrPriv->rrScreenSizeSet) + { + if (stuff->x + mode->mode.width > pScreen->width) + { + client->errorValue = stuff->x; + if (outputs) + xfree (outputs); + return BadValue; + } + + if (stuff->y + mode->mode.height > pScreen->height) + { + client->errorValue = stuff->y; + if (outputs) + xfree (outputs); + return BadValue; + } + } +#endif + + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + rep.status = RRCrtcSet (crtc, mode, stuff->x, stuff->y, + rotation, numOutputs, outputs); + +sendReply: + if (outputs) + xfree (outputs); + + rep.type = X_Reply; + /* rep.status has already been filled in */ + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.newTimestamp = pScrPriv->lastConfigTime.milliseconds; + + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.newTimestamp, n); + } + WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep); + + return client->noClientException; +} + +int +ProcRRGetCrtcGammaSize (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaSizeReq); + xRRGetCrtcGammaSizeReply reply; + RRCrtcPtr crtc; + int n; + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); + crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess); + if (!crtc) + return RRErrorBase + BadRRCrtc; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.size = crtc->gammaSize; + if (client->swapped) { + swaps (&reply.sequenceNumber, n); + swapl (&reply.length, n); + swaps (&reply.size, n); + } + WriteToClient (client, sizeof (xRRGetCrtcGammaSizeReply), (char *) &reply); + return client->noClientException; +} + +int +ProcRRGetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRGetCrtcGammaReq); + xRRGetCrtcGammaReply reply; + RRCrtcPtr crtc; + int n; + unsigned long len; + + REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); + crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess); + if (!crtc) + return RRErrorBase + BadRRCrtc; + + len = crtc->gammaSize * 3 * 2; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = (len + 3) >> 2; + reply.size = crtc->gammaSize; + if (client->swapped) { + swaps (&reply.sequenceNumber, n); + swapl (&reply.length, n); + swaps (&reply.size, n); + } + WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply); + if (crtc->gammaSize) + { + client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; + WriteSwappedDataToClient (client, len, (char *) crtc->gammaRed); + } + return client->noClientException; +} + +int +ProcRRSetCrtcGamma (ClientPtr client) +{ + REQUEST(xRRSetCrtcGammaReq); + RRCrtcPtr crtc; + unsigned long len; + CARD16 *red, *green, *blue; + + REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); + crtc = LookupCrtc (client, stuff->crtc, SecurityWriteAccess); + if (!crtc) + return RRErrorBase + BadRRCrtc; + + len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2); + if (len < (stuff->size * 3 + 1) >> 1) + return BadLength; + + if (stuff->size != crtc->gammaSize) + return BadMatch; + + red = (CARD16 *) (stuff + 1); + green = red + crtc->gammaSize; + blue = green + crtc->gammaSize; + + RRCrtcGammaSet (crtc, red, green, blue); + + return Success; +} + diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index aca0e542a..49ba10bc0 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -31,79 +31,6 @@ RRClientKnowsRates (ClientPtr pClient) (pRRClient->major_version == 1 && pRRClient->minor_version >= 1)); } -typedef struct _RR10Data { - RRScreenSizePtr sizes; - int nsize; - int nrefresh; - int size; - CARD16 refresh; -} RR10DataRec, *RR10DataPtr; - -/* - * Convert 1.2 monitor data into 1.0 screen data - */ -static RR10DataPtr -RR10GetData (ScreenPtr pScreen, RROutputPtr output) -{ - RR10DataPtr data; - RRScreenSizePtr size; - int nmode = output->numModes; - int i, j, k; - RRScreenRatePtr refresh; - CARD16 vRefresh; - RRModePtr mode; - - /* Make sure there is plenty of space for any combination */ - data = malloc (sizeof (RR10DataRec) + - sizeof (RRScreenSize) * nmode + - sizeof (RRScreenRate) * nmode); - if (!data) - return NULL; - size = (RRScreenSizePtr) (data + 1); - refresh = (RRScreenRatePtr) (size + nmode); - data->sizes = size; - data->nsize = 0; - data->nrefresh = 0; - data->size = 0; - data->refresh = 0; - for (i = 0; i < output->numModes; i++) - { - mode = output->modes[i]; - for (j = 0; j < data->nsize; j++) - if (mode->mode.width == size[j].width && - mode->mode.height == size[j].height) - break; - if (j == data->nsize) - { - size[j].id = j; - size[j].width = mode->mode.width; - size[j].height = mode->mode.height; - size[j].mmWidth = mode->mode.mmWidth; - size[j].mmHeight = mode->mode.mmHeight; - size[j].nRates = 0; - size[j].pRates = &refresh[data->nrefresh]; - data->nsize++; - } - vRefresh = RRVerticalRefresh (&mode->mode); - for (k = 0; k < size[j].nRates; k++) - if (vRefresh == size[j].pRates[k].rate) - break; - if (k == size[j].nRates) - { - size[j].pRates[k].rate = vRefresh; - size[j].pRates[k].mode = mode; - size[j].nRates++; - data->nrefresh++; - } - if (mode == output->crtc->mode) - { - data->size = j; - data->refresh = vRefresh; - } - } - return data; -} - static int ProcRRQueryVersion (ClientPtr client) { @@ -134,341 +61,6 @@ ProcRRQueryVersion (ClientPtr client) return (client->noClientException); } -static int -ProcRRGetScreenInfo (ClientPtr client) -{ - REQUEST(xRRGetScreenInfoReq); - xRRGetScreenInfoReply rep; - WindowPtr pWin; - int n; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - RROutputPtr output; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - - if (pScrPriv) - RRGetInfo (pScreen); - - output = RRFirstOutput (pScreen); - - if (!pScrPriv || !output) - { - rep.type = X_Reply; - rep.setOfRotations = RR_Rotate_0;; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nSizes = 0; - rep.sizeID = 0; - rep.rotation = RR_Rotate_0; - rep.rate = 0; - rep.nrateEnts = 0; - extra = 0; - extraLen = 0; - } - else - { - int i, j; - xScreenSizes *size; - CARD16 *rates; - CARD8 *data8; - Bool has_rate = RRClientKnowsRates (client); - RR10DataPtr pData; - RRScreenSizePtr pSize; - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - rep.type = X_Reply; - rep.setOfRotations = output->crtc->rotations; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = output->crtc->rotation; - rep.nSizes = pData->nsize; - rep.nrateEnts = pData->nrefresh + pData->nsize; - rep.sizeID = pData->size; - rep.rate = pData->refresh; - - extraLen = (rep.nSizes * sizeof (xScreenSizes) + - rep.nrateEnts * sizeof (CARD16)); - - extra = (CARD8 *) xalloc (extraLen); - if (!extra) - { - xfree (pData); - return BadAlloc; - } - /* - * First comes the size information - */ - size = (xScreenSizes *) extra; - rates = (CARD16 *) (size + rep.nSizes); - for (i = 0; i < pData->nsize; i++) - { - pSize = &pData->sizes[i]; - size->widthInPixels = pSize->width; - size->heightInPixels = pSize->height; - size->widthInMillimeters = pSize->mmWidth; - size->heightInMillimeters = pSize->mmHeight; - if (client->swapped) - { - swaps (&size->widthInPixels, n); - swaps (&size->heightInPixels, n); - swaps (&size->widthInMillimeters, n); - swaps (&size->heightInMillimeters, n); - } - size++; - if (has_rate) - { - *rates = pSize->nRates; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - for (j = 0; j < pSize->nRates; j++) - { - *rates = pSize->pRates[j].rate; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - } - } - } - xfree (pData); - - data8 = (CARD8 *) rates; - - if (data8 - (CARD8 *) extra != extraLen) - FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", - (unsigned long)(data8 - (CARD8 *) extra), extraLen); - rep.length = (extraLen + 3) >> 2; - } - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swaps(&rep.rotation, n); - swaps(&rep.nSizes, n); - swaps(&rep.sizeID, n); - swaps(&rep.rate, n); - swaps(&rep.nrateEnts, n); - } - WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); - } - return (client->noClientException); -} - -static int -ProcRRSetScreenConfig (ClientPtr client) -{ - REQUEST(xRRSetScreenConfigReq); - xRRSetScreenConfigReply rep; - DrawablePtr pDraw; - int n; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - TimeStamp configTime; - TimeStamp time; - int i; - Rotation rotation; - int rate; - Bool has_rate; - RROutputPtr output; - RRModePtr mode; - RR10DataPtr pData = NULL; - RRScreenSizePtr pSize; - - UpdateCurrentTime (); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - has_rate = TRUE; - } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - has_rate = FALSE; - } - - SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, - SecurityWriteAccess); - - pScreen = pDraw->pScreen; - - pScrPriv = rrGetScrPriv(pScreen); - - time = ClientTimeToServerTime(stuff->timestamp); - configTime = ClientTimeToServerTime(stuff->configTimestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - if (!output) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - - /* - * if the client's config timestamp is not the same as the last config - * timestamp, then the config information isn't up-to-date and - * can't even be validated - */ - if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; - } - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - if (stuff->sizeID >= pData->nsize) - { - /* - * Invalid size ID - */ - client->errorValue = stuff->sizeID; - xfree (pData); - return BadValue; - } - pSize = &pData->sizes[stuff->sizeID]; - - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - xfree (pData); - return BadValue; - } - - if ((~output->crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - xfree (pData); - return BadMatch; - } - - /* - * Validate requested refresh - */ - if (has_rate) - rate = (int) stuff->rate; - else - rate = 0; - - if (rate) - { - for (i = 0; i < pSize->nRates; i++) - { - if (pSize->pRates[i].rate == rate) - break; - } - if (i == pSize->nRates) - { - /* - * Invalid rate - */ - client->errorValue = rate; - xfree (pData); - return BadValue; - } - mode = pSize->pRates[i].mode; - } - else - mode = pSize->pRates[0].mode; - - /* - * Make sure the requested set-time is not older than - * the last set-time - */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; - } - - rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, - 1, &output); - -sendReply: - - if (pData) - xfree (pData); - - rep.type = X_Reply; - /* rep.status has already been filled in */ - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; - rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; - - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); - swapl(&rep.newConfigTimestamp, n); - swapl(&rep.root, n); - } - WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); - - return (client->noClientException); -} - static int ProcRRSelectInput (ClientPtr client) { @@ -584,633 +176,6 @@ ProcRRSelectInput (ClientPtr client) return Success; } -/* - * Retrieve valid screen size range - */ -static int -ProcRRGetScreenSizeRange (ClientPtr client) -{ - REQUEST(xRRGetScreenSizeRangeReq); - xRRGetScreenSizeRangeReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - rep.type = X_Reply; - rep.pad = 0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - if (pScrPriv) - { - RRGetInfo (pScreen); - rep.minWidth = pScrPriv->minWidth; - rep.minHeight = pScrPriv->minHeight; - rep.maxWidth = pScrPriv->maxWidth; - rep.maxHeight = pScrPriv->maxHeight; - } - else - { - rep.maxWidth = rep.minWidth = pScreen->width; - rep.maxHeight = rep.minHeight = pScreen->height; - } - if (client->swapped) - { - int n; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.minWidth, n); - swaps(&rep.minHeight, n); - swaps(&rep.maxWidth, n); - swaps(&rep.maxHeight, n); - } - WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); - return (client->noClientException); -} - -static int ProcRRSetScreenSize (ClientPtr client) -{ - REQUEST(xRRSetScreenSizeReq); - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtcPtr crtc; - int i; - - REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) - { - client->errorValue = stuff->width; - return BadValue; - } - if (stuff->height < pScrPriv->minHeight || - pScrPriv->maxHeight < stuff->height) - { - client->errorValue = stuff->height; - return BadValue; - } - for (i = 0; i < pScrPriv->numCrtcs; i++) { - crtc = pScrPriv->crtcs[i]; - if (crtc->mode && - (crtc->x + crtc->mode->mode.width > stuff->width || - crtc->y + crtc->mode->mode.height > stuff->height)) - return BadMatch; - } - if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) - { - client->errorValue = 0; - return BadValue; - } - if (!RRScreenSizeSet (pScreen, - stuff->width, stuff->height, - stuff->widthInMillimeters, - stuff->heightInMillimeters)) - { - return BadMatch; - } - return Success; -} - -static int -ProcRRGetScreenResources (ClientPtr client) -{ - REQUEST(xRRGetScreenResourcesReq); - xRRGetScreenResourcesReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - int i; - RRCrtc *crtcs; - RROutput *outputs; - xRRModeInfo *modeinfos; - CARD8 *names; - int n; - - REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - - if (!pWin) - return BadWindow; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - - if (pScrPriv) - RRGetInfo (pScreen); - - if (!pScrPriv) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nCrtcs = 0; - rep.nOutputs = 0; - rep.nModes = 0; - rep.nbytesNames = 0; - extra = NULL; - extraLen = 0; - } - else - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nCrtcs = pScrPriv->numCrtcs; - rep.nOutputs = pScrPriv->numOutputs; - rep.nModes = pScrPriv->numModes;; - rep.nbytesNames = 0; - - for (i = 0; i < pScrPriv->numModes; i++) - rep.nbytesNames += pScrPriv->modes[i]->mode.nameLength; - - rep.length = (pScrPriv->numCrtcs + - pScrPriv->numOutputs + - pScrPriv->numModes * 10 + - ((rep.nbytesNames + 3) >> 2)); - - extraLen = rep.length << 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; - - crtcs = (RRCrtc *) extra; - outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); - modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); - names = (CARD8 *) (modeinfos + pScrPriv->numModes); - - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - crtcs[i] = pScrPriv->crtcs[i]->id; - if (client->swapped) - swapl (&crtcs[i], n); - } - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - outputs[i] = pScrPriv->outputs[i]->id; - if (client->swapped) - swapl (&outputs[i], n); - } - - for (i = 0; i < pScrPriv->numModes; i++) - { - modeinfos[i] = pScrPriv->modes[i]->mode; - if (client->swapped) - { - swapl (&modeinfos[i].id, n); - swaps (&modeinfos[i].width, n); - swaps (&modeinfos[i].height, n); - swapl (&modeinfos[i].mmWidth, n); - swapl (&modeinfos[i].mmHeight, n); - swapl (&modeinfos[i].dotClock, n); - swaps (&modeinfos[i].hSyncStart, n); - swaps (&modeinfos[i].hSyncEnd, n); - swaps (&modeinfos[i].hTotal, n); - swaps (&modeinfos[i].hSkew, n); - swaps (&modeinfos[i].vSyncStart, n); - swaps (&modeinfos[i].vSyncEnd, n); - swaps (&modeinfos[i].vTotal, n); - swaps (&modeinfos[i].nameLength, n); - swapl (&modeinfos[i].modeFlags, n); - } - memcpy (names, pScrPriv->modes[i]->name, - pScrPriv->modes[i]->mode.nameLength); - names += pScrPriv->modes[i]->mode.nameLength; - } - assert ((names + 3 >> 3) == rep.length); - } - - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swapl(&rep.configTimestamp, n); - swaps(&rep.nCrtcs, n); - swaps(&rep.nOutputs, n); - swaps(&rep.nModes, n); - swaps(&rep.nbytesNames, n); - } - WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); - } - return client->noClientException; -} - -static int -ProcRRGetOutputInfo (ClientPtr client) -{ - REQUEST(xRRGetOutputInfoReq);; - xRRGetOutputInfoReply rep; - RROutputPtr output; - CARD8 *extra; - unsigned long extraLen; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtc *crtcs; - RRMode *modes; - RROutput *clones; - char *name; - int i, n; - - REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - output = (RROutputPtr)SecurityLookupIDByType(client, stuff->output, - RROutputType, - SecurityReadAccess); - - if (!output) - return RRErrorBase + BadRROutput; - - pScreen = output->pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.crtc = output->crtc ? output->crtc->id : None; - rep.connection = output->connection; - rep.subpixelOrder = output->subpixelOrder; - rep.nCrtcs = output->numCrtcs; - rep.nModes = output->numModes; - rep.nClones = output->numClones; - rep.nameLength = output->nameLength; - - rep.length = (output->numCrtcs + - output->numModes + - output->numClones + - ((rep.nameLength + 3) >> 2)); - - extraLen = rep.length << 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; - - crtcs = (RRCrtc *) extra; - modes = (RRMode *) (crtcs + output->numCrtcs); - clones = (RROutput *) (modes + output->numModes); - name = (char *) (clones + output->numClones); - - for (i = 0; i < output->numCrtcs; i++) - { - crtcs[i] = output->crtcs[i]->id; - if (client->swapped) - swapl (&crtcs[i], n); - } - for (i = 0; i < output->numModes; i++) - { - modes[i] = output->modes[i]->mode.id; - if (client->swapped) - swapl (&modes[i], n); - } - for (i = 0; i < output->numClones; i++) - { - clones[i] = output->clones[i]->id; - if (client->swapped) - swapl (&clones[i], n); - } - memcpy (name, output->name, output->nameLength); - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swapl(&rep.crtc, n); - swaps(&rep.nCrtcs, n); - swaps(&rep.nModes, n); - swaps(&rep.nClones, n); - swaps(&rep.nameLength, n); - } - WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); - } - - return client->noClientException; -} - -static int -ProcRRListOutputProperties (ClientPtr client) -{ - REQUEST(xRRListOutputPropertiesReq); - - REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRChangeOutputProperty (ClientPtr client) -{ - REQUEST(xRRChangeOutputPropertyReq); - - REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRDeleteOutputProperty (ClientPtr client) -{ - REQUEST(xRRDeleteOutputPropertyReq); - - REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRGetOutputProperty (ClientPtr client) -{ - REQUEST(xRRGetOutputPropertyReq); - - REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRCreateMode (ClientPtr client) -{ - REQUEST(xRRCreateModeReq); - - REQUEST_SIZE_MATCH(xRRCreateModeReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRDestroyMode (ClientPtr client) -{ - REQUEST(xRRDestroyModeReq); - - REQUEST_SIZE_MATCH(xRRDestroyModeReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRAddOutputMode (ClientPtr client) -{ - REQUEST(xRRAddOutputModeReq); - - REQUEST_SIZE_MATCH(xRRAddOutputModeReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRDeleteOutputMode (ClientPtr client) -{ - REQUEST(xRRDeleteOutputModeReq); - - REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRGetCrtcInfo (ClientPtr client) -{ - REQUEST(xRRGetCrtcInfoReq); - - REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRSetCrtcConfig (ClientPtr client) -{ - REQUEST(xRRSetCrtcConfigReq); - xRRSetCrtcConfigReply rep; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtcPtr crtc; - RRModePtr mode; - int numOutputs; - RROutputPtr *outputs = NULL; - RROutput *outputIds; - TimeStamp configTime; - TimeStamp time; - Rotation rotation; - int i, j; - - REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - numOutputs = stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2); - - crtc = LookupIDByType (stuff->crtc, RRCrtcType); - if (!crtc) - { - client->errorValue = stuff->crtc; - return RRErrorBase + BadRRCrtc; - } - if (stuff->mode == None) - { - mode = NULL; - if (numOutputs > 0) - return BadMatch; - } - else - { - mode = LookupIDByType (stuff->mode, RRModeType); - if (!mode) - { - client->errorValue = stuff->mode; - return RRErrorBase + BadRRMode; - } - if (numOutputs == 0) - return BadMatch; - } - outputs = xalloc (numOutputs * sizeof (RROutputPtr)); - if (!outputs) - return BadAlloc; - - outputIds = (RROutput *) (stuff + 1); - for (i = 0; i < numOutputs; i++) - { - outputs[i] = LookupIDByType (outputIds[i], RROutputType); - if (!outputs[i]) - { - client->errorValue = outputIds[i]; - return RRErrorBase + BadRROutput; - } - /* validate crtc for this output */ - for (j = 0; j < outputs[i]->numCrtcs; j++) - if (outputs[i]->crtcs[j] == crtc) - break; - if (j == outputs[j]->numCrtcs) - return BadMatch; - /* validate mode for this output */ - for (j = 0; j < outputs[i]->numModes; j++) - if (outputs[i]->modes[j] == mode) - break; - if (j == outputs[j]->numModes) - return BadMatch; - } - - pScreen = crtc->pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - time = ClientTimeToServerTime(stuff->timestamp); - configTime = ClientTimeToServerTime(stuff->configTimestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen)) - return BadAlloc; - - /* - * if the client's config timestamp is not the same as the last config - * timestamp, then the config information isn't up-to-date and - * can't even be validated - */ - if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; - } - - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - return BadValue; - } - - if ((~crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - return BadMatch; - } - - if (stuff->x + mode->mode.width > pScreen->width) - { - client->errorValue = stuff->x; - return BadValue; - } - - if (stuff->y + mode->mode.height > pScreen->height) - { - client->errorValue = stuff->y; - return BadValue; - } - - /* - * Make sure the requested set-time is not older than - * the last set-time - */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; - } - - rep.status = RRCrtcSet (crtc, mode, stuff->x, stuff->y, - rotation, numOutputs, outputs); - -sendReply: - if (outputs) - xfree (outputs); - - rep.type = X_Reply; - /* rep.status has already been filled in */ - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.newTimestamp = pScrPriv->lastConfigTime.milliseconds; - - if (client->swapped) - { - int n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); - } - WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep); - - return client->noClientException; -} - -static int -ProcRRGetCrtcGammaSize (ClientPtr client) -{ - REQUEST(xRRGetCrtcGammaSizeReq); - - REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRGetCrtcGamma (ClientPtr client) -{ - REQUEST(xRRGetCrtcGammaReq); - - REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); - (void) stuff; - return BadImplementation; -} - -static int -ProcRRSetCrtcGamma (ClientPtr client) -{ - REQUEST(xRRSetCrtcGammaReq); - - REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); - (void) stuff; - return BadImplementation; -} - int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { ProcRRQueryVersion, /* 0 */ /* we skip 1 to make old clients fail pretty immediately */ diff --git a/randr/rrmode.c b/randr/rrmode.c index 4e44e7d82..ab0ea18d9 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -103,3 +103,44 @@ RRModeInit (void) #endif return TRUE; } + +int +ProcRRCreateMode (ClientPtr client) +{ + REQUEST(xRRCreateModeReq); + + REQUEST_SIZE_MATCH(xRRCreateModeReq); + (void) stuff; + return BadImplementation; +} + +int +ProcRRDestroyMode (ClientPtr client) +{ + REQUEST(xRRDestroyModeReq); + + REQUEST_SIZE_MATCH(xRRDestroyModeReq); + (void) stuff; + return BadImplementation; +} + +int +ProcRRAddOutputMode (ClientPtr client) +{ + REQUEST(xRRAddOutputModeReq); + + REQUEST_SIZE_MATCH(xRRAddOutputModeReq); + (void) stuff; + return BadImplementation; +} + +int +ProcRRDeleteOutputMode (ClientPtr client) +{ + REQUEST(xRRDeleteOutputModeReq); + + REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); + (void) stuff; + return BadImplementation; +} + diff --git a/randr/rroutput.c b/randr/rroutput.c index 478002300..07dabad2e 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -66,6 +66,7 @@ RROutputCreate (ScreenPtr pScreen, output->clones = NULL; output->numModes = 0; output->modes = NULL; + output->properties = NULL; output->changed = TRUE; output->devPrivate = devPrivate; @@ -201,12 +202,13 @@ RROutputDestroyResource (pointer value, XID pid) xfree (output->crtcs); if (output->clones) xfree (output->clones); + RRDeleteAllOutputProperties (output); xfree (output); return 1; } /* - * Initialize crtc type + * Initialize output type */ Bool RROutputInit (void) @@ -219,3 +221,95 @@ RROutputInit (void) #endif return TRUE; } + +int +ProcRRGetOutputInfo (ClientPtr client) +{ + REQUEST(xRRGetOutputInfoReq);; + xRRGetOutputInfoReply rep; + RROutputPtr output; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtc *crtcs; + RRMode *modes; + RROutput *clones; + char *name; + int i, n; + + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); + output = LookupOutput(client, stuff->output, SecurityReadAccess); + + if (!output) + return RRErrorBase + BadRROutput; + + pScreen = output->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.crtc = output->crtc ? output->crtc->id : None; + rep.connection = output->connection; + rep.subpixelOrder = output->subpixelOrder; + rep.nCrtcs = output->numCrtcs; + rep.nModes = output->numModes; + rep.nClones = output->numClones; + rep.nameLength = output->nameLength; + + rep.length = (output->numCrtcs + + output->numModes + + output->numClones + + ((rep.nameLength + 3) >> 2)); + + extraLen = rep.length << 2; + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + + crtcs = (RRCrtc *) extra; + modes = (RRMode *) (crtcs + output->numCrtcs); + clones = (RROutput *) (modes + output->numModes); + name = (char *) (clones + output->numClones); + + for (i = 0; i < output->numCrtcs; i++) + { + crtcs[i] = output->crtcs[i]->id; + if (client->swapped) + swapl (&crtcs[i], n); + } + for (i = 0; i < output->numModes; i++) + { + modes[i] = output->modes[i]->mode.id; + if (client->swapped) + swapl (&modes[i], n); + } + for (i = 0; i < output->numClones; i++) + { + clones[i] = output->clones[i]->id; + if (client->swapped) + swapl (&clones[i], n); + } + memcpy (name, output->name, output->nameLength); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.crtc, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nModes, n); + swaps(&rep.nClones, n); + swaps(&rep.nameLength, n); + } + WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + + return client->noClientException; +} + diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 47ba12d39..58d5152d0 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -203,3 +203,654 @@ RRScreenSizeSet (ScreenPtr pScreen, return FALSE; } +/* + * Retrieve valid screen size range + */ +int +ProcRRGetScreenSizeRange (ClientPtr client) +{ + REQUEST(xRRGetScreenSizeRangeReq); + xRRGetScreenSizeRangeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.pad = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + if (pScrPriv) + { + RRGetInfo (pScreen); + rep.minWidth = pScrPriv->minWidth; + rep.minHeight = pScrPriv->minHeight; + rep.maxWidth = pScrPriv->maxWidth; + rep.maxHeight = pScrPriv->maxHeight; + } + else + { + rep.maxWidth = rep.minWidth = pScreen->width; + rep.maxHeight = rep.minHeight = pScreen->height; + } + if (client->swapped) + { + int n; + + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.minWidth, n); + swaps(&rep.minHeight, n); + swaps(&rep.maxWidth, n); + swaps(&rep.maxHeight, n); + } + WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); + return (client->noClientException); +} + +int +ProcRRSetScreenSize (ClientPtr client) +{ + REQUEST(xRRSetScreenSizeReq); + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + int i; + + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) + { + client->errorValue = stuff->width; + return BadValue; + } + if (stuff->height < pScrPriv->minHeight || + pScrPriv->maxHeight < stuff->height) + { + client->errorValue = stuff->height; + return BadValue; + } + for (i = 0; i < pScrPriv->numCrtcs; i++) { + crtc = pScrPriv->crtcs[i]; + if (crtc->mode && + (crtc->x + crtc->mode->mode.width > stuff->width || + crtc->y + crtc->mode->mode.height > stuff->height)) + return BadMatch; + } + if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) + { + client->errorValue = 0; + return BadValue; + } + if (!RRScreenSizeSet (pScreen, + stuff->width, stuff->height, + stuff->widthInMillimeters, + stuff->heightInMillimeters)) + { + return BadMatch; + } + return Success; +} + +int +ProcRRGetScreenResources (ClientPtr client) +{ + REQUEST(xRRGetScreenResourcesReq); + xRRGetScreenResourcesReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + int i; + RRCrtc *crtcs; + RROutput *outputs; + xRRModeInfo *modeinfos; + CARD8 *names; + int n; + + REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (pScrPriv) + RRGetInfo (pScreen); + + if (!pScrPriv) + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = 0; + rep.nOutputs = 0; + rep.nModes = 0; + rep.nbytesNames = 0; + extra = NULL; + extraLen = 0; + } + else + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = pScrPriv->numCrtcs; + rep.nOutputs = pScrPriv->numOutputs; + rep.nModes = pScrPriv->numModes;; + rep.nbytesNames = 0; + + for (i = 0; i < pScrPriv->numModes; i++) + rep.nbytesNames += pScrPriv->modes[i]->mode.nameLength; + + rep.length = (pScrPriv->numCrtcs + + pScrPriv->numOutputs + + pScrPriv->numModes * 10 + + ((rep.nbytesNames + 3) >> 2)); + + extraLen = rep.length << 2; + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + + crtcs = (RRCrtc *) extra; + outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); + modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); + names = (CARD8 *) (modeinfos + pScrPriv->numModes); + + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + crtcs[i] = pScrPriv->crtcs[i]->id; + if (client->swapped) + swapl (&crtcs[i], n); + } + + for (i = 0; i < pScrPriv->numOutputs; i++) + { + outputs[i] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl (&outputs[i], n); + } + + for (i = 0; i < pScrPriv->numModes; i++) + { + modeinfos[i] = pScrPriv->modes[i]->mode; + if (client->swapped) + { + swapl (&modeinfos[i].id, n); + swaps (&modeinfos[i].width, n); + swaps (&modeinfos[i].height, n); + swapl (&modeinfos[i].mmWidth, n); + swapl (&modeinfos[i].mmHeight, n); + swapl (&modeinfos[i].dotClock, n); + swaps (&modeinfos[i].hSyncStart, n); + swaps (&modeinfos[i].hSyncEnd, n); + swaps (&modeinfos[i].hTotal, n); + swaps (&modeinfos[i].hSkew, n); + swaps (&modeinfos[i].vSyncStart, n); + swaps (&modeinfos[i].vSyncEnd, n); + swaps (&modeinfos[i].vTotal, n); + swaps (&modeinfos[i].nameLength, n); + swapl (&modeinfos[i].modeFlags, n); + } + memcpy (names, pScrPriv->modes[i]->name, + pScrPriv->modes[i]->mode.nameLength); + names += pScrPriv->modes[i]->mode.nameLength; + } + assert ((names + 3 >> 3) == rep.length); + } + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.configTimestamp, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nOutputs, n); + swaps(&rep.nModes, n); + swaps(&rep.nbytesNames, n); + } + WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + return client->noClientException; +} + +typedef struct _RR10Data { + RRScreenSizePtr sizes; + int nsize; + int nrefresh; + int size; + CARD16 refresh; +} RR10DataRec, *RR10DataPtr; + +/* + * Convert 1.2 monitor data into 1.0 screen data + */ +static RR10DataPtr +RR10GetData (ScreenPtr pScreen, RROutputPtr output) +{ + RR10DataPtr data; + RRScreenSizePtr size; + int nmode = output->numModes; + int i, j, k; + RRScreenRatePtr refresh; + CARD16 vRefresh; + RRModePtr mode; + + /* Make sure there is plenty of space for any combination */ + data = malloc (sizeof (RR10DataRec) + + sizeof (RRScreenSize) * nmode + + sizeof (RRScreenRate) * nmode); + if (!data) + return NULL; + size = (RRScreenSizePtr) (data + 1); + refresh = (RRScreenRatePtr) (size + nmode); + data->sizes = size; + data->nsize = 0; + data->nrefresh = 0; + data->size = 0; + data->refresh = 0; + for (i = 0; i < output->numModes; i++) + { + mode = output->modes[i]; + for (j = 0; j < data->nsize; j++) + if (mode->mode.width == size[j].width && + mode->mode.height == size[j].height) + break; + if (j == data->nsize) + { + size[j].id = j; + size[j].width = mode->mode.width; + size[j].height = mode->mode.height; + size[j].mmWidth = mode->mode.mmWidth; + size[j].mmHeight = mode->mode.mmHeight; + size[j].nRates = 0; + size[j].pRates = &refresh[data->nrefresh]; + data->nsize++; + } + vRefresh = RRVerticalRefresh (&mode->mode); + for (k = 0; k < size[j].nRates; k++) + if (vRefresh == size[j].pRates[k].rate) + break; + if (k == size[j].nRates) + { + size[j].pRates[k].rate = vRefresh; + size[j].pRates[k].mode = mode; + size[j].nRates++; + data->nrefresh++; + } + if (mode == output->crtc->mode) + { + data->size = j; + data->refresh = vRefresh; + } + } + return data; +} + +int +ProcRRGetScreenInfo (ClientPtr client) +{ + REQUEST(xRRGetScreenInfoReq); + xRRGetScreenInfoReply rep; + WindowPtr pWin; + int n; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (pScrPriv) + RRGetInfo (pScreen); + + output = RRFirstOutput (pScreen); + + if (!pScrPriv || !output) + { + rep.type = X_Reply; + rep.setOfRotations = RR_Rotate_0;; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nSizes = 0; + rep.sizeID = 0; + rep.rotation = RR_Rotate_0; + rep.rate = 0; + rep.nrateEnts = 0; + extra = 0; + extraLen = 0; + } + else + { + int i, j; + xScreenSizes *size; + CARD16 *rates; + CARD8 *data8; + Bool has_rate = RRClientKnowsRates (client); + RR10DataPtr pData; + RRScreenSizePtr pSize; + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + rep.type = X_Reply; + rep.setOfRotations = output->crtc->rotations; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.rotation = output->crtc->rotation; + rep.nSizes = pData->nsize; + rep.nrateEnts = pData->nrefresh + pData->nsize; + rep.sizeID = pData->size; + rep.rate = pData->refresh; + + extraLen = (rep.nSizes * sizeof (xScreenSizes) + + rep.nrateEnts * sizeof (CARD16)); + + extra = (CARD8 *) xalloc (extraLen); + if (!extra) + { + xfree (pData); + return BadAlloc; + } + /* + * First comes the size information + */ + size = (xScreenSizes *) extra; + rates = (CARD16 *) (size + rep.nSizes); + for (i = 0; i < pData->nsize; i++) + { + pSize = &pData->sizes[i]; + size->widthInPixels = pSize->width; + size->heightInPixels = pSize->height; + size->widthInMillimeters = pSize->mmWidth; + size->heightInMillimeters = pSize->mmHeight; + if (client->swapped) + { + swaps (&size->widthInPixels, n); + swaps (&size->heightInPixels, n); + swaps (&size->widthInMillimeters, n); + swaps (&size->heightInMillimeters, n); + } + size++; + if (has_rate) + { + *rates = pSize->nRates; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + for (j = 0; j < pSize->nRates; j++) + { + *rates = pSize->pRates[j].rate; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + } + } + } + xfree (pData); + + data8 = (CARD8 *) rates; + + if (data8 - (CARD8 *) extra != extraLen) + FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", + (unsigned long)(data8 - (CARD8 *) extra), extraLen); + rep.length = (extraLen + 3) >> 2; + } + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swaps(&rep.rotation, n); + swaps(&rep.nSizes, n); + swaps(&rep.sizeID, n); + swaps(&rep.rate, n); + swaps(&rep.nrateEnts, n); + } + WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + xfree (extra); + } + return (client->noClientException); +} + +int +ProcRRSetScreenConfig (ClientPtr client) +{ + REQUEST(xRRSetScreenConfigReq); + xRRSetScreenConfigReply rep; + DrawablePtr pDraw; + int n; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + TimeStamp configTime; + TimeStamp time; + int i; + Rotation rotation; + int rate; + Bool has_rate; + RROutputPtr output; + RRModePtr mode; + RR10DataPtr pData = NULL; + RRScreenSizePtr pSize; + + UpdateCurrentTime (); + + if (RRClientKnowsRates (client)) + { + REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); + has_rate = TRUE; + } + else + { + REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); + has_rate = FALSE; + } + + SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, + SecurityWriteAccess); + + pScreen = pDraw->pScreen; + + pScrPriv = rrGetScrPriv(pScreen); + + time = ClientTimeToServerTime(stuff->timestamp); + configTime = ClientTimeToServerTime(stuff->configTimestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo (pScreen)) + return BadAlloc; + + output = RRFirstOutput (pScreen); + if (!output) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + + /* + * if the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated + */ + if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + if (stuff->sizeID >= pData->nsize) + { + /* + * Invalid size ID + */ + client->errorValue = stuff->sizeID; + xfree (pData); + return BadValue; + } + pSize = &pData->sizes[stuff->sizeID]; + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + xfree (pData); + return BadValue; + } + + if ((~output->crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + xfree (pData); + return BadMatch; + } + + /* + * Validate requested refresh + */ + if (has_rate) + rate = (int) stuff->rate; + else + rate = 0; + + if (rate) + { + for (i = 0; i < pSize->nRates; i++) + { + if (pSize->pRates[i].rate == rate) + break; + } + if (i == pSize->nRates) + { + /* + * Invalid rate + */ + client->errorValue = rate; + xfree (pData); + return BadValue; + } + mode = pSize->pRates[i].mode; + } + else + mode = pSize->pRates[0].mode; + + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, + 1, &output); + +sendReply: + + if (pData) + xfree (pData); + + rep.type = X_Reply; + /* rep.status has already been filled in */ + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; + rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; + + if (client->swapped) + { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.newTimestamp, n); + swapl(&rep.newConfigTimestamp, n); + swapl(&rep.root, n); + } + WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); + + return (client->noClientException); +} + From d08718d8fd31477e90f13b9e122504c515b46ee0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Sep 2006 12:05:52 -0700 Subject: [PATCH 011/109] Avoid calling xalloc(0). Change rrScreenSizeSet to rrScreenSetSize. --- randr/randr.c | 2 +- randr/randrstr.h | 6 +++--- randr/rrcrtc.c | 56 ++++++++++++++++++++++++++++++++++-------------- randr/rrmode.c | 2 +- randr/rroutput.c | 46 ++++++++++++++++++++++++++++----------- randr/rrscreen.c | 29 +++++++++++++++++-------- 6 files changed, 98 insertions(+), 43 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 5f6ef62e4..5f54dea14 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -198,7 +198,7 @@ Bool RRScreenInit(ScreenPtr pScreen) pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; #if RANDR_12_INTERFACE - pScrPriv->rrScreenSizeSet = NULL; + pScrPriv->rrScreenSetSize = NULL; pScrPriv->rrCrtcSet = NULL; pScrPriv->rrCrtcSetGamma = NULL; #endif diff --git a/randr/randrstr.h b/randr/randrstr.h index 26c180697..80272623c 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -174,7 +174,7 @@ typedef struct _rrScrPriv { #endif RRGetInfoProcPtr rrGetInfo; #if RANDR_12_INTERFACE - RRScreenSetSizeProcPtr rrScreenSizeSet; + RRScreenSetSizeProcPtr rrScreenSetSize; RRCrtcSetProcPtr rrCrtcSet; RRCrtcSetGammaProcPtr rrCrtcSetGamma; #endif @@ -521,7 +521,7 @@ RRClientKnowsRates (ClientPtr pClient); RRModePtr RRModeGet (ScreenPtr pScreen, xRRModeInfo *modeInfo, - char *name); + const char *name); /* * Destroy a mode. @@ -555,7 +555,7 @@ ProcRRDeleteOutputMode (ClientPtr client); RROutputPtr RROutputCreate (ScreenPtr pScreen, - char *name, + const char *name, int nameLength, void *devPrivate); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index c55e08871..90d609ed0 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -94,13 +94,22 @@ RRCrtcNotify (RRCrtcPtr crtc, { RROutputPtr *outputs; - if (crtc->numOutputs) - outputs = xrealloc (crtc->outputs, - numOutputs * sizeof (RROutputPtr)); + if (numOutputs) + { + if (crtc->numOutputs) + outputs = xrealloc (crtc->outputs, + numOutputs * sizeof (RROutputPtr)); + else + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!outputs) + return FALSE; + } else - outputs = xalloc (numOutputs * sizeof (RROutputPtr)); - if (!outputs) - return FALSE; + { + if (crtc->outputs) + xfree (crtc->outputs); + outputs = NULL; + } crtc->outputs = outputs; } for (i = 0; i < numOutputs; i++) @@ -300,9 +309,14 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc, if (size == crtc->gammaSize) return TRUE; - gamma = xalloc (size * 3 * sizeof (CARD16)); - if (!gamma) - return FALSE; + if (size) + { + gamma = xalloc (size * 3 * sizeof (CARD16)); + if (!gamma) + return FALSE; + } + else + gamma = NULL; if (crtc->gammaRed) xfree (crtc->gammaRed); crtc->gammaRed = gamma; @@ -376,9 +390,14 @@ ProcRRGetCrtcInfo (ClientPtr client) rep.length = rep.nOutput + rep.nPossibleOutput; extraLen = rep.length << 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; + if (extraLen) + { + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + } + else + extra = NULL; outputs = (RROutput *) extra; possible = (RROutput *) (outputs + rep.nOutput); @@ -467,9 +486,14 @@ ProcRRSetCrtcConfig (ClientPtr client) if (numOutputs == 0) return BadMatch; } - outputs = xalloc (numOutputs * sizeof (RROutputPtr)); - if (!outputs) - return BadAlloc; + if (numOutputs) + { + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!outputs) + return BadAlloc; + } + else + outputs = NULL; outputIds = (RROutput *) (stuff + 1); for (i = 0; i < numOutputs; i++) @@ -574,7 +598,7 @@ ProcRRSetCrtcConfig (ClientPtr client) * for setting screen size. Else, assume the CrtcSet sets * the size along with the mode */ - if (pScrPriv->rrScreenSizeSet) + if (pScrPriv->rrScreenSetSize) { if (stuff->x + mode->mode.width > pScreen->width) { diff --git a/randr/rrmode.c b/randr/rrmode.c index ab0ea18d9..23ac5305c 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -27,7 +27,7 @@ RESTYPE RRModeType; RRModePtr RRModeGet (ScreenPtr pScreen, xRRModeInfo *modeInfo, - char *name) + const char *name) { rrScrPriv (pScreen); int i; diff --git a/randr/rroutput.c b/randr/rroutput.c index 07dabad2e..3d4c16342 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -30,7 +30,7 @@ RESTYPE RROutputType; RROutputPtr RROutputCreate (ScreenPtr pScreen, - char *name, + const char *name, int nameLength, void *devPrivate) { @@ -89,9 +89,14 @@ RROutputSetClones (RROutputPtr output, { RROutputPtr *newClones; - newClones = xalloc (numClones * sizeof (RROutputPtr)); - if (!newClones) - return FALSE; + if (numClones) + { + newClones = xalloc (numClones * sizeof (RROutputPtr)); + if (!newClones) + return FALSE; + } + else + newClones = NULL; if (output->clones) xfree (output->clones); memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); @@ -108,9 +113,14 @@ RROutputSetModes (RROutputPtr output, { RRModePtr *newModes; - newModes = xalloc (numModes * sizeof (RRModePtr)); - if (!newModes) - return FALSE; + if (numModes) + { + newModes = xalloc (numModes * sizeof (RRModePtr)); + if (!newModes) + return FALSE; + } + else + newModes = NULL; if (output->modes) xfree (output->modes); memcpy (newModes, modes, numModes * sizeof (RRModePtr)); @@ -127,9 +137,14 @@ RROutputSetCrtcs (RROutputPtr output, { RRCrtcPtr *newCrtcs; - newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr)); - if (!newCrtcs) - return FALSE; + if (numCrtcs) + { + newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr)); + if (!newCrtcs) + return FALSE; + } + else + newCrtcs = NULL; if (output->crtcs) xfree (output->crtcs); memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); @@ -265,9 +280,14 @@ ProcRRGetOutputInfo (ClientPtr client) ((rep.nameLength + 3) >> 2)); extraLen = rep.length << 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; + if (extraLen) + { + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + } + else + extra = NULL; crtcs = (RRCrtc *) extra; modes = (RRMode *) (crtcs + output->numCrtcs); diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 58d5152d0..617ae4109 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -187,9 +187,9 @@ RRScreenSizeSet (ScreenPtr pScreen, rrScrPriv(pScreen); #if RANDR_12_INTERFACE - if (pScrPriv->rrScreenSizeSet) + if (pScrPriv->rrScreenSetSize) { - return (*pScrPriv->rrScreenSizeSet) (pScreen, + return (*pScrPriv->rrScreenSetSize) (pScreen, width, height, mmWidth, mmHeight); } @@ -376,9 +376,14 @@ ProcRRGetScreenResources (ClientPtr client) ((rep.nbytesNames + 3) >> 2)); extraLen = rep.length << 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; + if (extraLen) + { + extra = xalloc (extraLen); + if (!extra) + return BadAlloc; + } + else + extra = NULL; crtcs = (RRCrtc *) extra; outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); @@ -595,12 +600,18 @@ ProcRRGetScreenInfo (ClientPtr client) extraLen = (rep.nSizes * sizeof (xScreenSizes) + rep.nrateEnts * sizeof (CARD16)); - extra = (CARD8 *) xalloc (extraLen); - if (!extra) + if (extraLen) { - xfree (pData); - return BadAlloc; + extra = (CARD8 *) xalloc (extraLen); + if (!extra) + { + xfree (pData); + return BadAlloc; + } } + else + extra = NULL; + /* * First comes the size information */ From 9f870e0aa1ada238d6a0cd099996e8c47f6ba1d9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Sep 2006 13:14:53 -0700 Subject: [PATCH 012/109] When setting output state, leave output unchanged when setting to current. --- randr/randrstr.h | 1 + randr/rroutput.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/randr/randrstr.h b/randr/randrstr.h index 80272623c..e459452ff 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -77,6 +77,7 @@ struct _rrMode { int refcnt; xRRModeInfo mode; char *name; + void *devPrivate; }; struct _rrCrtc { diff --git a/randr/rroutput.c b/randr/rroutput.c index 3d4c16342..a4f5a66dd 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -88,7 +88,16 @@ RROutputSetClones (RROutputPtr output, int numClones) { RROutputPtr *newClones; + int i; + if (numClones == output->numClones) + { + for (i = 0; i < numClones; i++) + if (output->clones[i] != clones[i]) + break; + if (i == numClones) + return TRUE; + } if (numClones) { newClones = xalloc (numClones * sizeof (RROutputPtr)); @@ -112,6 +121,20 @@ RROutputSetModes (RROutputPtr output, int numModes) { RRModePtr *newModes; + int i; + + if (numModes == output->numModes) + { + for (i = 0; i < numModes; i++) + if (output->modes[i] != modes[i]) + break; + if (i == numModes) + { + for (i = 0; i < numModes; i++) + RRModeDestroy (modes[i]); + return TRUE; + } + } if (numModes) { @@ -122,7 +145,11 @@ RROutputSetModes (RROutputPtr output, else newModes = NULL; if (output->modes) + { + for (i = 0; i < output->numModes; i++) + RRModeDestroy (output->modes[i]); xfree (output->modes); + } memcpy (newModes, modes, numModes * sizeof (RRModePtr)); output->modes = newModes; output->numModes = numModes; @@ -136,7 +163,16 @@ RROutputSetCrtcs (RROutputPtr output, int numCrtcs) { RRCrtcPtr *newCrtcs; + int i; + if (numCrtcs == output->numCrtcs) + { + for (i = 0; i < numCrtcs; i++) + if (output->crtcs[i] != crtcs[i]) + break; + if (i == numCrtcs) + return TRUE; + } if (numCrtcs) { newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr)); @@ -157,6 +193,8 @@ RROutputSetCrtcs (RROutputPtr output, void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) { + if (output->crtc == crtc) + return TRUE; output->crtc = crtc; output->changed = TRUE; } @@ -165,6 +203,8 @@ Bool RROutputSetConnection (RROutputPtr output, CARD8 connection) { + if (output->connection == connection) + return TRUE; output->connection = connection; output->changed = TRUE; return TRUE; @@ -174,6 +214,9 @@ Bool RROutputSetSubpixelOrder (RROutputPtr output, int subpixelOrder) { + if (output->subpixelOrder == subpixelOrder) + return TRUE; + output->subpixelOrder = subpixelOrder; output->changed = TRUE; return TRUE; From 09f7499851bd2f2eba1e30460c61c7a82ed9e853 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Sep 2006 13:15:20 -0700 Subject: [PATCH 013/109] typo --- randr/rroutput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/rroutput.c b/randr/rroutput.c index a4f5a66dd..90b2b9856 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -194,7 +194,7 @@ void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) { if (output->crtc == crtc) - return TRUE; + return; output->crtc = crtc; output->changed = TRUE; } From bde0a4c12cb393a6d7f1552b067624da1b0502ae Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Sep 2006 19:42:34 -0700 Subject: [PATCH 014/109] RRSetCrtcConfig status fix. RRGetScreenResources timestamp fix. RRSetCrtcConfig was returning the wrong status values. RRGetScreenResources was always returning currentTime. --- randr/rrcrtc.c | 9 +++++++-- randr/rrscreen.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 90d609ed0..dfa9ca6ee 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -628,8 +628,13 @@ ProcRRSetCrtcConfig (ClientPtr client) goto sendReply; } - rep.status = RRCrtcSet (crtc, mode, stuff->x, stuff->y, - rotation, numOutputs, outputs); + if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y, + rotation, numOutputs, outputs)) + { + rep.status = RRSetConfigFailed; + goto sendReply; + } + rep.status = RRSetConfigSuccess; sendReply: if (outputs) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 617ae4109..e59947b36 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -360,8 +360,8 @@ ProcRRGetScreenResources (ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; rep.nCrtcs = pScrPriv->numCrtcs; rep.nOutputs = pScrPriv->numOutputs; rep.nModes = pScrPriv->numModes;; From 219546fd76750f358ffb6738f17b9237c58c15a6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Sep 2006 22:43:05 -0700 Subject: [PATCH 015/109] Steal Xinerama code from SiS driver. Add missing files. Provide a Xinerama implementation when DIX version isn't enabled. This version exposes each crtc as a separate 'screen' and reports the size of that patch. The extension also sends ConfigureNotify events to the root window whenever crtcs change so that applications will re-fetch xinerama information. This actually works for metacity. --- randr/Makefile.am | 3 +- randr/randr.c | 2 +- randr/randrstr.h | 10 ++ randr/rrcrtc.c | 5 + randr/rrinfo.c | 337 +++++++++++++++++++++++++++++++++++ randr/rrproperty.c | 430 +++++++++++++++++++++++++++++++++++++++++++++ randr/rrscreen.c | 2 +- randr/rrxinerama.c | 424 ++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 1210 insertions(+), 3 deletions(-) create mode 100644 randr/rrinfo.c create mode 100644 randr/rrproperty.c create mode 100644 randr/rrxinerama.c diff --git a/randr/Makefile.am b/randr/Makefile.am index a28ead0eb..91c4bc6dd 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -17,4 +17,5 @@ librandr_la_SOURCES = \ rroutput.c \ rrproperty.c \ rrscreen.c \ - rrsdispatch.c + rrsdispatch.c \ + rrxinerama.c diff --git a/randr/randr.c b/randr/randr.c index 5f54dea14..4ea72e505 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -311,7 +311,7 @@ RRExtensionInit (void) EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr) SRRNotifyEvent; - return; + RRXineramaExtensionInit(); } static int diff --git a/randr/randrstr.h b/randr/randrstr.h index e459452ff..0b8c61e1f 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -304,6 +304,12 @@ RRScreenSizeSet (ScreenPtr pScreen, CARD32 mmWidth, CARD32 mmHeight); +/* + * Send ConfigureNotify event to root window when 'something' happens + */ +void +RRSendConfigNotify (ScreenPtr pScreen); + /* * screen dispatch */ @@ -629,4 +635,8 @@ ProcRRListOutputProperties (ClientPtr client); int ProcRRDeleteOutputProperty (ClientPtr client); +/* rrxinerama.c */ +void +RRXineramaExtensionInit(void); + #endif /* _RANDRSTR_H_ */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index dfa9ca6ee..ebb254068 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -111,6 +111,7 @@ RRCrtcNotify (RRCrtcPtr crtc, outputs = NULL; } crtc->outputs = outputs; + crtc->numOutputs = numOutputs; } for (i = 0; i < numOutputs; i++) { @@ -158,7 +159,11 @@ RRCrtcNotify (RRCrtcPtr crtc, crtc->changed = TRUE; } if (crtc->changed) + { + if (!pScrPriv->changed) + RRSendConfigNotify (pScreen); pScrPriv->changed = TRUE; + } return TRUE; } diff --git a/randr/rrinfo.c b/randr/rrinfo.c new file mode 100644 index 000000000..491ac218d --- /dev/null +++ b/randr/rrinfo.c @@ -0,0 +1,337 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +#ifdef RANDR_10_INTERFACE +static RRModePtr +RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) +{ + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); + xRRModeInfo modeInfo; + char name[100]; + RRModePtr mode; + int i; + RRModePtr *modes; + + memset (&modeInfo, '\0', sizeof (modeInfo)); + sprintf (name, "%dx%d", size->width, size->height); + + modeInfo.width = size->width; + modeInfo.height = size->height; + modeInfo.mmWidth = size->mmWidth; + modeInfo.mmHeight = size->mmHeight; + modeInfo.hTotal = size->width; + modeInfo.vTotal = size->height; + modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height * + (CARD32) refresh); + modeInfo.nameLength = strlen (name); + mode = RRModeGet (pScreen, &modeInfo, name); + if (!mode) + return NULL; + for (i = 0; i < output->numModes; i++) + if (output->modes[i] == mode) + { + RRModeDestroy (mode); + return mode; + } + + if (output->numModes) + modes = xrealloc (output->modes, + (output->numModes + 1) * sizeof (RRModePtr)); + else + modes = xalloc (sizeof (RRModePtr)); + if (!modes) + { + RRModeDestroy (mode); + FreeResource (mode->mode.id, 0); + return NULL; + } + modes[output->numModes++] = mode; + output->modes = modes; + output->changed = TRUE; + pScrPriv->changed = TRUE; + return mode; +} + +static void +RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) +{ + rrScrPriv(pScreen); + RROutputPtr output; + RRCrtcPtr crtc; + RRModePtr mode, newMode = NULL; + int i; + CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; + CARD16 maxWidth = 0, maxHeight = 0; + + /* + * First time through, create a crtc and output and hook + * them together + */ + if (pScrPriv->numOutputs == 0 && + pScrPriv->numCrtcs == 0) + { + crtc = RRCrtcCreate (pScreen, NULL); + if (!crtc) + return; + output = RROutputCreate (pScreen, "default", 7, NULL); + if (!output) + return; + RROutputSetCrtcs (output, &crtc, 1); + RROutputSetCrtc (output, crtc); + RROutputSetConnection (output, RR_Connected); +#ifdef RENDER + RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen)); +#endif + } + + output = RRFirstOutput (pScreen); + if (!output) + return; + crtc = output->crtc; + + /* check rotations */ + if (rotations != crtc->rotations) + { + crtc->rotations = rotations; + crtc->changed = TRUE; + pScrPriv->changed = TRUE; + } + + /* regenerate mode list */ + for (i = 0; i < pScrPriv->nSizes; i++) + { + RRScreenSizePtr size = &pScrPriv->pSizes[i]; + int r; + + if (size->nRates) + { + for (r = 0; r < size->nRates; r++) + { + mode = RROldModeAdd (output, size, size->pRates[r].rate); + if (i == pScrPriv->size && + size->pRates[r].rate == pScrPriv->rate) + { + newMode = mode; + } + } + xfree (size->pRates); + } + else + { + mode = RROldModeAdd (output, size, 0); + if (i == pScrPriv->size) + newMode = mode; + } + } + if (pScrPriv->nSizes) + xfree (pScrPriv->pSizes); + pScrPriv->pSizes = NULL; + pScrPriv->nSizes = 0; + + /* find size bounds */ + for (i = 0; i < output->numModes; i++) + { + RRModePtr mode = output->modes[i]; + CARD16 width = mode->mode.width; + CARD16 height = mode->mode.height; + + if (width < minWidth) minWidth = width; + if (width > maxWidth) maxWidth = width; + if (height < minHeight) minHeight = height; + if (height > maxHeight) maxHeight = height; + } + + if (minWidth != pScrPriv->minWidth) { + pScrPriv->minWidth = minWidth; pScrPriv->changed = TRUE; + } + if (maxWidth != pScrPriv->maxWidth) { + pScrPriv->maxWidth = maxWidth; pScrPriv->changed = TRUE; + } + if (minHeight != pScrPriv->minHeight) { + pScrPriv->minHeight = minHeight; pScrPriv->changed = TRUE; + } + if (maxHeight != pScrPriv->maxHeight) { + pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE; + } + + /* notice current mode */ + if (newMode) + RRCrtcNotify (output->crtc, newMode, 0, 0, pScrPriv->rotation, + 1, &output); +} +#endif + +/* + * Poll the driver for changed information + */ +Bool +RRGetInfo (ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + Rotation rotations; + int i; + + for (i = 0; i < pScrPriv->numOutputs; i++) + pScrPriv->outputs[i]->changed = FALSE; + for (i = 0; i < pScrPriv->numCrtcs; i++) + pScrPriv->crtcs[i]->changed = FALSE; + + rotations = 0; + pScrPriv->changed = FALSE; + + if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) + return FALSE; + +#if RANDR_10_INTERFACE + if (pScrPriv->nSizes) + RRScanOldConfig (pScreen, rotations); +#endif + RRTellChanged (pScreen); + return TRUE; +} + +#if RANDR_12_INTERFACE +/* + * Register the range of sizes for the screen + */ +void +RRScreenSetSizeRange (ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, + CARD16 maxWidth, + CARD16 maxHeight) +{ + rrScrPriv (pScreen); + + if (!pScrPriv) + return; + pScrPriv->minWidth = minWidth; + pScrPriv->minHeight = minHeight; + pScrPriv->maxWidth = maxWidth; + pScrPriv->maxHeight = maxHeight; +} +#endif + +#ifdef RANDR_10_INTERFACE +static Bool +RRScreenSizeMatches (RRScreenSizePtr a, + RRScreenSizePtr b) +{ + if (a->width != b->width) + return FALSE; + if (a->height != b->height) + return FALSE; + if (a->mmWidth != b->mmWidth) + return FALSE; + if (a->mmHeight != b->mmHeight) + return FALSE; + return TRUE; +} + +RRScreenSizePtr +RRRegisterSize (ScreenPtr pScreen, + short width, + short height, + short mmWidth, + short mmHeight) +{ + rrScrPriv (pScreen); + int i; + RRScreenSize tmp; + RRScreenSizePtr pNew; + + if (!pScrPriv) + return 0; + + tmp.id = 0; + tmp.width = width; + tmp.height= height; + tmp.mmWidth = mmWidth; + tmp.mmHeight = mmHeight; + tmp.pRates = 0; + tmp.nRates = 0; + for (i = 0; i < pScrPriv->nSizes; i++) + if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i])) + return &pScrPriv->pSizes[i]; + pNew = xrealloc (pScrPriv->pSizes, + (pScrPriv->nSizes + 1) * sizeof (RRScreenSize)); + if (!pNew) + return 0; + pNew[pScrPriv->nSizes++] = tmp; + pScrPriv->pSizes = pNew; + return &pNew[pScrPriv->nSizes-1]; +} + +Bool RRRegisterRate (ScreenPtr pScreen, + RRScreenSizePtr pSize, + int rate) +{ + rrScrPriv(pScreen); + int i; + RRScreenRatePtr pNew, pRate; + + if (!pScrPriv) + return FALSE; + + for (i = 0; i < pSize->nRates; i++) + if (pSize->pRates[i].rate == rate) + return TRUE; + + pNew = xrealloc (pSize->pRates, + (pSize->nRates + 1) * sizeof (RRScreenRate)); + if (!pNew) + return FALSE; + pRate = &pNew[pSize->nRates++]; + pRate->rate = rate; + pSize->pRates = pNew; + return TRUE; +} + +Rotation +RRGetRotation(ScreenPtr pScreen) +{ + RROutputPtr output = RRFirstOutput (pScreen); + + if (!output) + return RR_Rotate_0; + + return output->crtc->rotation; +} + +void +RRSetCurrentConfig (ScreenPtr pScreen, + Rotation rotation, + int rate, + RRScreenSizePtr pSize) +{ + rrScrPriv (pScreen); + + if (!pScrPriv) + return; + pScrPriv->size = pSize - pScrPriv->pSizes; + pScrPriv->rotation = rotation; + pScrPriv->rate = rate; +} +#endif diff --git a/randr/rrproperty.c b/randr/rrproperty.c new file mode 100644 index 000000000..cdafb5c9b --- /dev/null +++ b/randr/rrproperty.c @@ -0,0 +1,430 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" +#include "propertyst.h" +#include "swaprep.h" + +static void +RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask) +{ +} + +void +RRDeleteAllOutputProperties (RROutputPtr output) +{ + PropertyPtr prop, next; + xRROutputPropertyNotifyEvent event; + + for (prop = output->properties; prop; prop = next) + { + next = prop->next; + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyDelete; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); + xfree(prop->data); + xfree(prop); + } +} + +void +RRDeleteOutputProperty (RROutputPtr output, Atom property) +{ + PropertyPtr prop, *prev; + xRROutputPropertyNotifyEvent event; + + for (prev = &output->properties; (prop = *prev); prev = &(prop->next)) + if (prop->propertyName == property) + break; + if (prop) + { + *prev = prop->next; + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyDelete; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); + xfree(prop->data); + xfree(prop); + } +} + +int +RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, + int format, int mode, unsigned long len, + pointer value, Bool sendevent) +{ + PropertyPtr prop; + xRROutputPropertyNotifyEvent event; + int sizeInBytes; + int totalSize; + pointer data; + + sizeInBytes = format >> 3; + totalSize = len * sizeInBytes; + + /* first see if property already exists */ + + for (prop = output->properties; prop; prop = prop->next) + if (prop->propertyName == property) + break; + + if (!prop) /* just add to list */ + { + prop = (PropertyPtr)xalloc(sizeof(PropertyRec)); + if (!prop) + return(BadAlloc); + data = (pointer)xalloc(totalSize); + if (!data && len) + { + xfree(prop); + return(BadAlloc); + } + prop->propertyName = property; + prop->type = type; + prop->format = format; + prop->data = data; + if (len) + memmove((char *)data, (char *)value, totalSize); + prop->size = len; + prop->next = output->properties; + output->properties = prop; + } + else + { + /* To append or prepend to a property the request format and type + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ + + if ((format != prop->format) && (mode != PropModeReplace)) + return(BadMatch); + if ((prop->type != type) && (mode != PropModeReplace)) + return(BadMatch); + if (mode == PropModeReplace) + { + if (totalSize != prop->size * (prop->format >> 3)) + { + data = (pointer)xrealloc(prop->data, totalSize); + if (!data && len) + return(BadAlloc); + prop->data = data; + } + if (len) + memmove((char *)prop->data, (char *)value, totalSize); + prop->size = len; + prop->type = type; + prop->format = format; + } + else if (len == 0) + { + /* do nothing */ + } + else if (mode == PropModeAppend) + { + data = (pointer)xrealloc(prop->data, + sizeInBytes * (len + prop->size)); + if (!data) + return(BadAlloc); + prop->data = data; + memmove(&((char *)data)[prop->size * sizeInBytes], + (char *)value, + totalSize); + prop->size += len; + } + else if (mode == PropModePrepend) + { + data = (pointer)xalloc(sizeInBytes * (len + prop->size)); + if (!data) + return(BadAlloc); + memmove(&((char *)data)[totalSize], (char *)prop->data, + (int)(prop->size * sizeInBytes)); + memmove((char *)data, (char *)value, totalSize); + xfree(prop->data); + prop->data = data; + prop->size += len; + } + } + if (sendevent) + { + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyNewValue; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); + } + return(Success); +} + +int +ProcRRListOutputProperties (ClientPtr client) +{ + REQUEST(xRRListOutputPropertiesReq); + Atom *pAtoms = NULL, *temppAtoms; + xRRListOutputPropertiesReply rep; + int numProps = 0; + RROutputPtr output; + PropertyPtr prop; + + REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); + + output = LookupOutput (client, stuff->output, SecurityReadAccess); + + if (!output) + return RRErrorBase + BadRROutput; + + for (prop = output->properties; prop; prop = prop->next) + numProps++; + if (numProps) + if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom)))) + return(BadAlloc); + + rep.type = X_Reply; + rep.nProperties = numProps; + rep.length = (numProps * sizeof(Atom)) >> 2; + rep.sequenceNumber = client->sequence; + temppAtoms = pAtoms; + for (prop = output->properties; prop; prop = prop->next) + *temppAtoms++ = prop->propertyName; + + WriteReplyToClient(client, sizeof(xRRListOutputPropertiesReply), &rep); + if (numProps) + { + client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); + DEALLOCATE_LOCAL(pAtoms); + } + return(client->noClientException); +} + +int +ProcRRChangeOutputProperty (ClientPtr client) +{ + REQUEST(xRRChangeOutputPropertyReq); + RROutputPtr output; + char format, mode; + unsigned long len; + int sizeInBytes; + int totalSize; + int err; + + REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq); + UpdateCurrentTime(); + format = stuff->format; + mode = stuff->mode; + if ((mode != PropModeReplace) && (mode != PropModeAppend) && + (mode != PropModePrepend)) + { + client->errorValue = mode; + return BadValue; + } + if ((format != 8) && (format != 16) && (format != 32)) + { + client->errorValue = format; + return BadValue; + } + len = stuff->nUnits; + if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2)) + return BadLength; + sizeInBytes = format>>3; + totalSize = len * sizeInBytes; + REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize); + + output = LookupOutput (client, stuff->output, SecurityWriteAccess); + if (!output) + return RRErrorBase + BadRROutput; + + if (!ValidAtom(stuff->property)) + { + client->errorValue = stuff->property; + return(BadAtom); + } + if (!ValidAtom(stuff->type)) + { + client->errorValue = stuff->type; + return(BadAtom); + } + + err = RRChangeOutputProperty(output, stuff->property, + stuff->type, (int)format, + (int)mode, len, (pointer)&stuff[1], TRUE); + if (err != Success) + return err; + else + return client->noClientException; +} + +int +ProcRRDeleteOutputProperty (ClientPtr client) +{ + REQUEST(xRRDeleteOutputPropertyReq); + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); + UpdateCurrentTime(); + output = LookupOutput (client, stuff->output, SecurityWriteAccess); + if (!output) + return RRErrorBase + BadRROutput; + + if (!ValidAtom(stuff->property)) + { + client->errorValue = stuff->property; + return (BadAtom); + } + + + RRDeleteOutputProperty(output, stuff->property); + return client->noClientException; +} + +int +ProcRRGetOutputProperty (ClientPtr client) +{ + REQUEST(xRRGetOutputPropertyReq); + PropertyPtr prop, *prev; + unsigned long n, len, ind; + RROutputPtr output; + xRRGetOutputPropertyReply reply; + + REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); + if (stuff->delete) + UpdateCurrentTime(); + output = LookupOutput (client, stuff->output, + stuff->delete ? SecurityWriteAccess : + SecurityReadAccess); + if (!output) + return RRErrorBase + BadRROutput; + + if (!ValidAtom(stuff->property)) + { + client->errorValue = stuff->property; + return(BadAtom); + } + if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) + { + client->errorValue = stuff->delete; + return(BadValue); + } + if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type)) + { + client->errorValue = stuff->type; + return(BadAtom); + } + + for (prev = &output->properties; (prop = *prev); prev = &prop->next) + if (prop->propertyName == stuff->property) + break; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + if (!prop) + { + reply.nItems = 0; + reply.length = 0; + reply.bytesAfter = 0; + reply.propertyType = None; + reply.format = 0; + WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); + return(client->noClientException); + } + + /* If the request type and actual type don't match. Return the + property information, but not the data. */ + + if (((stuff->type != prop->type) && + (stuff->type != AnyPropertyType)) + ) + { + reply.bytesAfter = prop->size; + reply.format = prop->format; + reply.length = 0; + reply.nItems = 0; + reply.propertyType = prop->type; + WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); + return(client->noClientException); + } + +/* + * Return type, format, value to client + */ + n = (prop->format/8) * prop->size; /* size (bytes) of prop */ + ind = stuff->longOffset << 2; + + /* If longOffset is invalid such that it causes "len" to + be negative, it's a value error. */ + + if (n < ind) + { + client->errorValue = stuff->longOffset; + return BadValue; + } + + len = min(n - ind, 4 * stuff->longLength); + + reply.bytesAfter = n - (ind + len); + reply.format = prop->format; + reply.length = (len + 3) >> 2; + reply.nItems = len / (prop->format / 8 ); + reply.propertyType = prop->type; + + if (stuff->delete && (reply.bytesAfter == 0)) + { + xRROutputPropertyNotifyEvent event; + + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyDelete; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); + } + + WriteReplyToClient(client, sizeof(xGenericReply), &reply); + if (len) + { + switch (reply.format) { + case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break; + case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break; + default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break; + } + WriteSwappedDataToClient(client, len, + (char *)prop->data + ind); + } + + if (stuff->delete && (reply.bytesAfter == 0)) + { /* delete the Property */ + *prev = prop->next; + xfree(prop->data); + xfree(prop); + } + return(client->noClientException); +} + diff --git a/randr/rrscreen.c b/randr/rrscreen.c index e59947b36..e382540b7 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -69,7 +69,7 @@ RREditConnectionInfo (ScreenPtr pScreen) root->mmHeight = pScreen->mmHeight; } -static void +void RRSendConfigNotify (ScreenPtr pScreen) { WindowPtr pWin = WindowTable[pScreen->myNum]; diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c new file mode 100644 index 000000000..31f60cca1 --- /dev/null +++ b/randr/rrxinerama.c @@ -0,0 +1,424 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +/* + * This Xinerama implementation comes from the SiS driver which has + * the following notice: + */ +/* + * SiS driver main code + * + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * - driver entirely rewritten since 2001, only basic structure taken from + * old code (except sis_dri.c, sis_shadow.c, sis_accel.c and parts of + * sis_dga.c; these were mostly taken over; sis_dri.c was changed for + * new versions of the DRI layer) + * + * This notice covers the entire driver code unless indicated otherwise. + * + * Formerly based on code which was + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. + * Written by: + * Alan Hourihane , + * Mike Chapman , + * Juanjo Santamarta , + * Mitani Hiroshi , + * David Thomas . + */ + +#include "randrstr.h" +#include "swaprep.h" +#include + +#define RR_XINERAMA_MAJOR_VERSION 1 +#define RR_XINERAMA_MINOR_VERSION 1 + +/* Xinerama is not multi-screen capable; just report about screen 0 */ +#define RR_XINERAMA_SCREEN 0 + +static int ProcRRXineramaQueryVersion(ClientPtr client); +static int ProcRRXineramaGetState(ClientPtr client); +static int ProcRRXineramaGetScreenCount(ClientPtr client); +static int ProcRRXineramaGetScreenSize(ClientPtr client); +static int ProcRRXineramaIsActive(ClientPtr client); +static int ProcRRXineramaQueryScreens(ClientPtr client); +static int SProcRRXineramaDispatch(ClientPtr client); + +/* Proc */ + +int +ProcRRXineramaQueryVersion(ClientPtr client) +{ + xPanoramiXQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = RR_XINERAMA_MAJOR_VERSION; + rep.minorVersion = RR_XINERAMA_MINOR_VERSION; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +int +ProcRRXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + WindowPtr pWin; + xPanoramiXGetStateReply rep; + register int n; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + Bool active = FALSE; + + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + pWin = LookupWindow(stuff->window, client); + if(!pWin) return BadWindow; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (pScrPriv) + { + /* XXX do we need more than this? */ + active = TRUE; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = active; + if(client->swapped) { + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + swaps (&rep.state, n); + } + WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep); + return client->noClientException; +} + +static Bool +RRXineramaScreenActive (ScreenPtr pScreen) +{ + return rrGetScrPriv(pScreen) != NULL; +} + +static Bool +RRXineramaCrtcActive (RRCrtcPtr crtc) +{ + return crtc->mode != NULL && crtc->numOutputs > 0; +} + +static int +RRXineramaScreenCount (ScreenPtr pScreen) +{ + int i, n; + + n = 0; + if (RRXineramaScreenActive (pScreen)) + { + rrScrPriv(pScreen); + for (i = 0; i < pScrPriv->numCrtcs; i++) + if (RRXineramaCrtcActive (pScrPriv->crtcs[i])) + n++; + } + return n; +} + +int +ProcRRXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + WindowPtr pWin; + xPanoramiXGetScreenCountReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + pWin = LookupWindow(stuff->window, client); + if(!pWin) return BadWindow; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen); + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.ScreenCount, n); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep); + return client->noClientException; +} + +int +ProcRRXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + WindowPtr pWin, pRoot; + ScreenPtr pScreen; + xPanoramiXGetScreenSizeReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + pWin = LookupWindow (stuff->window, client); + if(!pWin) return BadWindow; + + pScreen = pWin->drawable.pScreen; + pRoot = WindowTable[pScreen->myNum]; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.width = pRoot->drawable.width; + rep.height = pRoot->drawable.height; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.width, n); + swaps(&rep.height, n); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep); + return client->noClientException; +} + +int +ProcRRXineramaIsActive(ClientPtr client) +{ + xXineramaIsActiveReply rep; + + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = RRXineramaScreenActive (screenInfo.screens[RR_XINERAMA_SCREEN]); + if(client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.state, n); + } + WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep); + return client->noClientException; +} + +int +ProcRRXineramaQueryScreens(ClientPtr client) +{ + xXineramaQueryScreensReply rep; + ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN]; + + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.number = RRXineramaScreenCount (pScreen); + rep.length = rep.number * sz_XineramaScreenInfo >> 2; + if(client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.number, n); + } + WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep); + + if(rep.number) { + rrScrPriv(pScreen); + xXineramaScreenInfo scratch; + int i; + + for(i = 0; i < pScrPriv->numCrtcs; i++) { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + if (RRXineramaCrtcActive (crtc)) + { + scratch.x_org = crtc->x; + scratch.y_org = crtc->y; + scratch.width = crtc->mode->mode.width; + scratch.height = crtc->mode->mode.height; + if(client->swapped) { + register int n; + swaps(&scratch.x_org, n); + swaps(&scratch.y_org, n); + swaps(&scratch.width, n); + swaps(&scratch.height, n); + } + WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch); + } + } + } + + return client->noClientException; +} + +static int +ProcRRXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return ProcRRXineramaQueryVersion(client); + case X_PanoramiXGetState: + return ProcRRXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return ProcRRXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return ProcRRXineramaGetScreenSize(client); + case X_XineramaIsActive: + return ProcRRXineramaIsActive(client); + case X_XineramaQueryScreens: + return ProcRRXineramaQueryScreens(client); + } + return BadRequest; +} + +/* SProc */ + +static int +SProcRRXineramaQueryVersion (ClientPtr client) +{ + REQUEST(xPanoramiXQueryVersionReq); + register int n; + swaps(&stuff->length,n); + REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + return ProcRRXineramaQueryVersion(client); +} + +static int +SProcRRXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + return ProcRRXineramaGetState(client); +} + +static int +SProcRRXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + return ProcRRXineramaGetScreenCount(client); +} + +static int +SProcRRXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + return ProcRRXineramaGetScreenSize(client); +} + +static int +SProcRRXineramaIsActive(ClientPtr client) +{ + REQUEST(xXineramaIsActiveReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + return ProcRRXineramaIsActive(client); +} + +static int +SProcRRXineramaQueryScreens(ClientPtr client) +{ + REQUEST(xXineramaQueryScreensReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + return ProcRRXineramaQueryScreens(client); +} + +int +SProcRRXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return SProcRRXineramaQueryVersion(client); + case X_PanoramiXGetState: + return SProcRRXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return SProcRRXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return SProcRRXineramaGetScreenSize(client); + case X_XineramaIsActive: + return SProcRRXineramaIsActive(client); + case X_XineramaQueryScreens: + return SProcRRXineramaQueryScreens(client); + } + return BadRequest; +} + +static void +RRXineramaResetProc(ExtensionEntry* extEntry) +{ +} + +void +RRXineramaExtensionInit(void) +{ +#ifdef PANORAMIX + if(!noPanoramiXExtension) + return; +#endif + + (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0, + ProcRRXineramaDispatch, + SProcRRXineramaDispatch, + RRXineramaResetProc, + StandardMinorOpcode); +} From b36fde9257263fa502147df37e8331184c323e14 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 21 Sep 2006 09:52:04 -0700 Subject: [PATCH 016/109] When no mode is specified, don't validate mode-specific parameters. --- randr/rrcrtc.c | 105 +++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index ebb254068..77cba29fa 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -564,64 +564,67 @@ ProcRRSetCrtcConfig (ClientPtr client) goto sendReply; } - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - if (outputs) - xfree (outputs); - return BadValue; - } - - if ((~crtc->rotations) & rotation) + if (mode) { /* - * requested rotation or reflection not supported by screen + * Validate requested rotation */ - client->errorValue = stuff->rotation; - if (outputs) - xfree (outputs); - return BadMatch; - } - + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + if (outputs) + xfree (outputs); + return BadValue; + } + + if ((~crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + if (outputs) + xfree (outputs); + return BadMatch; + } + #ifdef RANDR_12_INTERFACE - /* - * Check screen size bounds if the DDX provides a 1.2 interface - * for setting screen size. Else, assume the CrtcSet sets - * the size along with the mode - */ - if (pScrPriv->rrScreenSetSize) - { - if (stuff->x + mode->mode.width > pScreen->width) + /* + * Check screen size bounds if the DDX provides a 1.2 interface + * for setting screen size. Else, assume the CrtcSet sets + * the size along with the mode + */ + if (pScrPriv->rrScreenSetSize) { - client->errorValue = stuff->x; - if (outputs) - xfree (outputs); - return BadValue; + if (stuff->x + mode->mode.width > pScreen->width) + { + client->errorValue = stuff->x; + if (outputs) + xfree (outputs); + return BadValue; + } + + if (stuff->y + mode->mode.height > pScreen->height) + { + client->errorValue = stuff->y; + if (outputs) + xfree (outputs); + return BadValue; + } } - - if (stuff->y + mode->mode.height > pScreen->height) - { - client->errorValue = stuff->y; - if (outputs) - xfree (outputs); - return BadValue; - } - } #endif + } /* * Make sure the requested set-time is not older than From c4f30c63538e1451f15ed1991439869127d9b148 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 3 Oct 2006 21:06:11 -0700 Subject: [PATCH 017/109] Add mode origins and output options. Fix memmoves in resource free funcs. Output options and mode origins both affected driver ABI. memmove mistakes were causing 'Freeing resource which isn't there' messages. Prune unused non-user defined modes from available list now. --- randr/mirandr.c | 6 ++++- randr/randrstr.h | 28 +++++++++++++++++--- randr/rrcrtc.c | 52 ++++++++++++++++++++---------------- randr/rrinfo.c | 1 + randr/rrmode.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-- randr/rroutput.c | 43 +++++++++++++++++++++++++----- randr/rrscreen.c | 17 ++++++------ 7 files changed, 171 insertions(+), 44 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index bcc8e0fcd..7300cfebe 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -52,7 +52,7 @@ miRRCrtcSet (ScreenPtr pScreen, int y, Rotation rotation, int numOutput, - RROutputPtr *outputs) + RROutputConfigPtr outputs) { return TRUE; } @@ -114,6 +114,10 @@ miRandRInit (ScreenPtr pScreen) return FALSE; if (!RROutputSetCrtcs (output, &crtc, 1)) return FALSE; + if (!RROutputSetPossibleOptions (output, 0)) + return FALSE; + if (!RROutputSetCurrentOptions (output, 0)) + return FALSE; if (!RROutputSetConnection (output, RR_Connected)) return FALSE; RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output); diff --git a/randr/randrstr.h b/randr/randrstr.h index 0b8c61e1f..a4e55890f 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -72,12 +72,14 @@ extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr); typedef struct _rrMode RRModeRec, *RRModePtr; typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; typedef struct _rrOutput RROutputRec, *RROutputPtr; +typedef struct _rrOutputConfig RROutputConfigRec, *RROutputConfigPtr; struct _rrMode { int refcnt; xRRModeInfo mode; char *name; void *devPrivate; + ScreenPtr screen; }; struct _rrCrtc { @@ -105,6 +107,8 @@ struct _rrOutput { CARD8 connection; CARD8 subpixelOrder; RRCrtcPtr crtc; + CARD32 currentOptions; + CARD32 possibleOptions; int numCrtcs; RRCrtcPtr *crtcs; int numClones; @@ -116,6 +120,11 @@ struct _rrOutput { void *devPrivate; }; +struct _rrOutputConfig { + RROutputPtr output; + CARD32 options; +}; + #if RANDR_12_INTERFACE typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, CARD16 width, @@ -130,7 +139,7 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, int y, Rotation rotation, int numOutputs, - RROutputPtr *outputs); + RROutputConfigPtr outputs); typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); @@ -352,7 +361,7 @@ miRRCrtcSet (ScreenPtr pScreen, int y, Rotation rotation, int numOutput, - RROutputPtr *outputs); + RROutputConfigPtr outputs); /* randr.c */ /* @@ -440,7 +449,7 @@ RRCrtcNotify (RRCrtcPtr crtc, int x, int y, Rotation rotation, - int numOutput, + int numOutputs, RROutputPtr *outputs); void @@ -456,7 +465,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y, Rotation rotation, int numOutput, - RROutputPtr *outputs); + RROutputConfigPtr outputs); /* * Request that the Crtc gamma be changed @@ -530,6 +539,9 @@ RRModeGet (ScreenPtr pScreen, xRRModeInfo *modeInfo, const char *name); +void +RRModePruneUnused (ScreenPtr pScreen); + /* * Destroy a mode. */ @@ -584,6 +596,10 @@ RROutputSetCrtcs (RROutputPtr output, RRCrtcPtr *crtcs, int numCrtcs); +Bool +RROutputSetPossibleOptions (RROutputPtr output, + CARD32 possibleOptions); + void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc); @@ -595,6 +611,10 @@ Bool RROutputSetSubpixelOrder (RROutputPtr output, int subpixelOrder); +Bool +RROutputSetCurrentOptions (RROutputPtr output, + CARD32 currentOptions); + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 77cba29fa..3108f1452 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -92,25 +92,25 @@ RRCrtcNotify (RRCrtcPtr crtc, if (numOutputs != prevNumOutputs) { - RROutputPtr *outputs; + RROutputPtr *newoutputs; if (numOutputs) { if (crtc->numOutputs) - outputs = xrealloc (crtc->outputs, + newoutputs = xrealloc (crtc->outputs, numOutputs * sizeof (RROutputPtr)); else - outputs = xalloc (numOutputs * sizeof (RROutputPtr)); - if (!outputs) + newoutputs = xalloc (numOutputs * sizeof (RROutputPtr)); + if (!newoutputs) return FALSE; } else { if (crtc->outputs) xfree (crtc->outputs); - outputs = NULL; + newoutputs = NULL; } - crtc->outputs = outputs; + crtc->outputs = newoutputs; crtc->numOutputs = numOutputs; } for (i = 0; i < numOutputs; i++) @@ -183,7 +183,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y, Rotation rotation, int numOutputs, - RROutputPtr *outputs) + RROutputConfigPtr outputs) { ScreenPtr pScreen = crtc->pScreen; rrScrPriv(pScreen); @@ -252,7 +252,7 @@ RRCrtcDestroyResource (pointer value, XID pid) { if (pScrPriv->crtcs[i] == crtc) { - memmove (pScrPriv->crtcs, pScrPriv->crtcs + 1, + memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); --pScrPriv->numCrtcs; break; @@ -458,15 +458,15 @@ ProcRRSetCrtcConfig (ClientPtr client) RRCrtcPtr crtc; RRModePtr mode; int numOutputs; - RROutputPtr *outputs = NULL; - RROutput *outputIds; + RROutputConfigPtr outputs = NULL; + xRROutputConfig *outputConfigs; TimeStamp configTime; TimeStamp time; Rotation rotation; int i, j; REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - numOutputs = stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2); + numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2)) >> 1; crtc = LookupIDByType (stuff->crtc, RRCrtcType); if (!crtc) @@ -493,39 +493,47 @@ ProcRRSetCrtcConfig (ClientPtr client) } if (numOutputs) { - outputs = xalloc (numOutputs * sizeof (RROutputPtr)); + outputs = xalloc (numOutputs * sizeof (RROutputConfigRec)); if (!outputs) return BadAlloc; } else outputs = NULL; - outputIds = (RROutput *) (stuff + 1); + outputConfigs = (xRROutputConfig *) (stuff + 1); for (i = 0; i < numOutputs; i++) { - outputs[i] = LookupIDByType (outputIds[i], RROutputType); - if (!outputs[i]) + outputs[i].output = LookupIDByType (outputConfigs[i].output, RROutputType); + if (!outputs[i].output) { - client->errorValue = outputIds[i]; + client->errorValue = outputConfigs[i].output; if (outputs) xfree (outputs); return RRErrorBase + BadRROutput; } + outputs[i].options = outputConfigs[i].options; + if (outputs[i].options & ~outputs[i].output->possibleOptions) + { + client->errorValue = outputConfigs[i].options; + if (outputs) + xfree (outputs); + return BadMatch; + } /* validate crtc for this output */ - for (j = 0; j < outputs[i]->numCrtcs; j++) - if (outputs[i]->crtcs[j] == crtc) + for (j = 0; j < outputs[i].output->numCrtcs; j++) + if (outputs[i].output->crtcs[j] == crtc) break; - if (j == outputs[j]->numCrtcs) + if (j == outputs[j].output->numCrtcs) { if (outputs) xfree (outputs); return BadMatch; } /* validate mode for this output */ - for (j = 0; j < outputs[i]->numModes; j++) - if (outputs[i]->modes[j] == mode) + for (j = 0; j < outputs[i].output->numModes; j++) + if (outputs[i].output->modes[j] == mode) break; - if (j == outputs[i]->numModes) + if (j == outputs[i].output->numModes) { if (outputs) xfree (outputs); diff --git a/randr/rrinfo.c b/randr/rrinfo.c index 491ac218d..6fd4ee581 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -208,6 +208,7 @@ RRGetInfo (ScreenPtr pScreen) if (pScrPriv->nSizes) RRScanOldConfig (pScreen, rotations); #endif + RRModePruneUnused (pScreen); RRTellChanged (pScreen); return TRUE; } diff --git a/randr/rrmode.c b/randr/rrmode.c index 23ac5305c..3a6748691 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -24,6 +24,27 @@ RESTYPE RRModeType; +static Bool +RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) +{ + if (a->width != b->width) return FALSE; + if (a->height != b->height) return FALSE; + if (a->mmWidth != b->mmWidth) return FALSE; + if (a->mmHeight != b->mmHeight) return FALSE; + if (a->dotClock != b->dotClock) return FALSE; + if (a->hSyncStart != b->hSyncStart) return FALSE; + if (a->hSyncEnd != b->hSyncEnd) return FALSE; + if (a->hTotal != b->hTotal) return FALSE; + if (a->hSkew != b->hSkew) return FALSE; + if (a->vSyncStart != b->vSyncStart) return FALSE; + if (a->vSyncEnd != b->vSyncEnd) return FALSE; + if (a->vTotal != b->vTotal) return FALSE; + if (a->nameLength != b->nameLength) return FALSE; + if (a->modeFlags != b->modeFlags) return FALSE; + if (a->origin != b->origin) return FALSE; + return TRUE; +} + RRModePtr RRModeGet (ScreenPtr pScreen, xRRModeInfo *modeInfo, @@ -37,8 +58,7 @@ RRModeGet (ScreenPtr pScreen, for (i = 0; i < pScrPriv->numModes; i++) { mode = pScrPriv->modes[i]; - modeInfo->id = mode->mode.id; - if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) && + if (RRModeEqual (&mode->mode, modeInfo) && !memcmp (name, mode->name, modeInfo->nameLength)) { ++mode->refcnt; @@ -54,6 +74,7 @@ RRModeGet (ScreenPtr pScreen, mode->name = (char *) (mode + 1); memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; + mode->screen = pScreen; if (pScrPriv->numModes) modes = xrealloc (pScrPriv->modes, @@ -80,8 +101,31 @@ RRModeGet (ScreenPtr pScreen, void RRModeDestroy (RRModePtr mode) { + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + int m; + if (--mode->refcnt > 0) return; + pScreen = mode->screen; + pScrPriv = rrGetScrPriv (pScreen); + for (m = 0; m < pScrPriv->numModes; m++) + { + if (pScrPriv->modes[m] == mode) + { + memmove (pScrPriv->modes + m, pScrPriv->modes + m + 1, + (pScrPriv->numModes - m - 1) * sizeof (RRModePtr)); + pScrPriv->numModes--; + if (!pScrPriv->numModes) + { + xfree (pScrPriv->modes); + pScrPriv->modes = NULL; + } + pScrPriv->changed = TRUE; + break; + } + } + xfree (mode); } @@ -104,6 +148,26 @@ RRModeInit (void) return TRUE; } +void +RRModePruneUnused (ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + RRModePtr *unused, mode; + int m; + int num = pScrPriv->numModes; + + unused = xalloc (num * sizeof (RRModePtr)); + if (!unused) + return; + memcpy (unused, pScrPriv->modes, num * sizeof (RRModePtr)); + for (m = 0; m < num; m++) { + mode = unused[m]; + if (mode->refcnt == 1 && mode->mode.origin != RRModeOriginUser) + FreeResource (mode->mode.id, 0); + } + xfree (unused); +} + int ProcRRCreateMode (ClientPtr client) { diff --git a/randr/rroutput.c b/randr/rroutput.c index 90b2b9856..b252d7dec 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -60,6 +60,8 @@ RROutputCreate (ScreenPtr pScreen, output->connection = RR_UnknownConnection; output->subpixelOrder = SubPixelUnknown; output->crtc = NULL; + output->currentOptions = 0; + output->possibleOptions = 0; output->numCrtcs = 0; output->crtcs = NULL; output->numClones = 0; @@ -190,6 +192,17 @@ RROutputSetCrtcs (RROutputPtr output, return TRUE; } +Bool +RROutputSetPossibleOptions (RROutputPtr output, + CARD32 possibleOptions) +{ + if (output->possibleOptions == possibleOptions) + return TRUE; + output->possibleOptions = possibleOptions; + output->changed = TRUE; + return TRUE; +} + void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) { @@ -222,6 +235,17 @@ RROutputSetSubpixelOrder (RROutputPtr output, return TRUE; } +Bool +RROutputSetCurrentOptions (RROutputPtr output, + CARD32 currentOptions) +{ + if (output->currentOptions == currentOptions) + return TRUE; + output->currentOptions = currentOptions; + output->changed = TRUE; + return TRUE; +} + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { @@ -248,7 +272,7 @@ RROutputDestroyResource (pointer value, XID pid) { if (pScrPriv->outputs[i] == output) { - memmove (pScrPriv->outputs, pScrPriv->outputs + 1, + memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr)); --pScrPriv->numOutputs; break; @@ -280,6 +304,8 @@ RROutputInit (void) return TRUE; } +#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) + int ProcRRGetOutputInfo (ClientPtr client) { @@ -307,24 +333,27 @@ ProcRRGetOutputInfo (ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.length = 0; + rep.length = OutputInfoExtra >> 2; rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.crtc = output->crtc ? output->crtc->id : None; + rep.currentOptions = output->currentOptions; rep.connection = output->connection; rep.subpixelOrder = output->subpixelOrder; rep.nCrtcs = output->numCrtcs; rep.nModes = output->numModes; rep.nClones = output->numClones; rep.nameLength = output->nameLength; + rep.possibleOptions = output->possibleOptions; + rep.pad1 = 42; - rep.length = (output->numCrtcs + - output->numModes + - output->numClones + - ((rep.nameLength + 3) >> 2)); + extraLen = ((output->numCrtcs + + output->numModes + + output->numClones + + ((rep.nameLength + 3) >> 2)) << 2); - extraLen = rep.length << 2; if (extraLen) { + rep.length += extraLen >> 2; extra = xalloc (extraLen); if (!extra) return BadAlloc; diff --git a/randr/rrscreen.c b/randr/rrscreen.c index e382540b7..7b53f0468 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -372,7 +372,7 @@ ProcRRGetScreenResources (ClientPtr client) rep.length = (pScrPriv->numCrtcs + pScrPriv->numOutputs + - pScrPriv->numModes * 10 + + pScrPriv->numModes * (SIZEOF(xRRModeInfo) >> 2) + ((rep.nbytesNames + 3) >> 2)); extraLen = rep.length << 2; @@ -429,7 +429,7 @@ ProcRRGetScreenResources (ClientPtr client) pScrPriv->modes[i]->mode.nameLength); names += pScrPriv->modes[i]->mode.nameLength; } - assert ((names + 3 >> 3) == rep.length); + assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length); } if (client->swapped) { @@ -694,7 +694,7 @@ ProcRRSetScreenConfig (ClientPtr client) Rotation rotation; int rate; Bool has_rate; - RROutputPtr output; + RROutputConfigRec output; RRModePtr mode; RR10DataPtr pData = NULL; RRScreenSizePtr pSize; @@ -731,13 +731,14 @@ ProcRRSetScreenConfig (ClientPtr client) if (!RRGetInfo (pScreen)) return BadAlloc; - output = RRFirstOutput (pScreen); - if (!output) + output.output = RRFirstOutput (pScreen); + if (!output.output) { time = currentTime; rep.status = RRSetConfigFailed; goto sendReply; } + output.options = output.output->currentOptions; /* * if the client's config timestamp is not the same as the last config @@ -750,7 +751,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - pData = RR10GetData (pScreen, output); + pData = RR10GetData (pScreen, output.output); if (!pData) return BadAlloc; @@ -786,7 +787,7 @@ ProcRRSetScreenConfig (ClientPtr client) return BadValue; } - if ((~output->crtc->rotations) & rotation) + if ((~output.output->crtc->rotations) & rotation) { /* * requested rotation or reflection not supported by screen @@ -835,7 +836,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, + rep.status = RRCrtcSet (output.output->crtc, mode, 0, 0, stuff->rotation, 1, &output); sendReply: From 1178796a4dff5ebf0bd9fb3cacb35be9709b41e5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 Oct 2006 22:31:35 -0700 Subject: [PATCH 018/109] Add preferred modes for each output. Round vrefresh. Deliver crtc events. --- randr/mirandr.c | 2 +- randr/randr.c | 5 +- randr/randrstr.h | 10 +++- randr/rrcrtc.c | 142 +++++++++++++++++++++++++++++++---------------- randr/rrmode.c | 4 +- randr/rroutput.c | 9 ++- 6 files changed, 116 insertions(+), 56 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 7300cfebe..918e55da4 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -110,7 +110,7 @@ miRandRInit (ScreenPtr pScreen) return FALSE; if (!RROutputSetClones (output, NULL, 0)) return FALSE; - if (!RROutputSetModes (output, &mode, 1)) + if (!RROutputSetModes (output, &mode, 1, 0)) return FALSE; if (!RROutputSetCrtcs (output, &crtc, 1)) return FALSE; diff --git a/randr/randr.c b/randr/randr.c index 4ea72e505..35f9a4c80 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -406,9 +406,10 @@ CARD16 RRVerticalRefresh (xRRModeInfo *mode) { CARD32 refresh; - if (!mode->hTotal || !mode->vTotal) + CARD32 dots = mode->hTotal * mode->vTotal; + if (!dots) return 0; - refresh = mode->dotClock / (mode->hTotal * mode->vTotal); + refresh = (mode->dotClock + dots/2) / dots; if (refresh > 0xffff) refresh = 0xffff; return (CARD16) refresh; diff --git a/randr/randrstr.h b/randr/randrstr.h index a4e55890f..6690556b4 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -80,6 +80,7 @@ struct _rrMode { char *name; void *devPrivate; ScreenPtr screen; + Bool userDefined; }; struct _rrCrtc { @@ -114,6 +115,7 @@ struct _rrOutput { int numClones; RROutputPtr *clones; int numModes; + int numPreferred; RRModePtr *modes; Bool changed; PropertyPtr properties; @@ -144,6 +146,10 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); +typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + Atom property); + #endif typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); @@ -187,6 +193,7 @@ typedef struct _rrScrPriv { RRScreenSetSizeProcPtr rrScreenSetSize; RRCrtcSetProcPtr rrCrtcSet; RRCrtcSetGammaProcPtr rrCrtcSetGamma; + RROutputSetPropertyProcPtr rrOutputSetProperty; #endif /* @@ -589,7 +596,8 @@ RROutputSetClones (RROutputPtr output, Bool RROutputSetModes (RROutputPtr output, RRModePtr *modes, - int numModes); + int numModes, + int numPreferred); Bool RROutputSetCrtcs (RROutputPtr output, diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 3108f1452..baefd3a15 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -88,9 +88,41 @@ RRCrtcNotify (RRCrtcPtr crtc, ScreenPtr pScreen = crtc->pScreen; rrScrPriv(pScreen); int i, j; - int prevNumOutputs = crtc->numOutputs; - if (numOutputs != prevNumOutputs) + /* + * Check to see if any of the new outputs were + * not in the old list and mark them as changed + */ + for (i = 0; i < numOutputs; i++) + { + for (j = 0; j < crtc->numOutputs; j++) + if (outputs[i] == crtc->outputs[j]) + break; + if (j == crtc->numOutputs) + { + outputs[i]->changed = TRUE; + crtc->changed = TRUE; + } + } + /* + * Check to see if any of the old outputs are + * not in the new list and mark them as changed + */ + for (j = 0; j < crtc->numOutputs; j++) + { + for (i = 0; i < numOutputs; i++) + if (outputs[i] == crtc->outputs[j]) + break; + if (i == numOutputs) + { + crtc->outputs[j]->changed = TRUE; + crtc->changed = TRUE; + } + } + /* + * Reallocate the crtc output array if necessary + */ + if (numOutputs != crtc->numOutputs) { RROutputPtr *newoutputs; @@ -113,28 +145,13 @@ RRCrtcNotify (RRCrtcPtr crtc, crtc->outputs = newoutputs; crtc->numOutputs = numOutputs; } - for (i = 0; i < numOutputs; i++) - { - for (j = 0; j < crtc->numOutputs; j++) - if (outputs[i] == crtc->outputs[j]) - break; - if (j != crtc->numOutputs) - { - outputs[i]->changed = TRUE; - crtc->changed = TRUE; - } - } - for (j = 0; j < crtc->numOutputs; j++) - { - for (i = 0; i < numOutputs; i++) - if (outputs[i] == crtc->outputs[j]) - break; - if (i != numOutputs) - { - crtc->outputs[j]->changed = TRUE; - crtc->changed = TRUE; - } - } + /* + * Copy the new list of outputs into the crtc + */ + memcpy (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)); + /* + * Update remaining crtc fields + */ if (mode != crtc->mode) { if (crtc->mode) @@ -158,6 +175,9 @@ RRCrtcNotify (RRCrtcPtr crtc, crtc->rotation = rotation; crtc->changed = TRUE; } + /* + * Send events if anything changed + */ if (crtc->changed) { if (!pScrPriv->changed) @@ -170,7 +190,35 @@ RRCrtcNotify (RRCrtcPtr crtc, void RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) { + ScreenPtr pScreen = pWin->drawable.pScreen; + rrScrPriv (pScreen); + xRRCrtcChangeNotifyEvent ce; + RRModePtr mode = crtc->mode; + ce.type = RRNotify + RREventBase; + ce.subCode = RRNotify_CrtcChange; + ce.sequenceNumber = client->sequence; + ce.timestamp = pScrPriv->lastSetTime.milliseconds; + ce.window = pWin->drawable.id; + ce.crtc = crtc->id; + ce.rotation = crtc->rotation; + if (mode) + { + ce.mode = mode->mode.id; + ce.x = crtc->x; + ce.y = crtc->y; + ce.width = mode->mode.width; + ce.height = mode->mode.height; + } + else + { + ce.mode = None; + ce.x = 0; + ce.y = 0; + ce.width = 0; + ce.height = 0; + } + WriteEventsToClient (client, 1, (xEvent *) &ce); } /* @@ -381,7 +429,7 @@ ProcRRGetCrtcInfo (ClientPtr client) rep.y = crtc->y; rep.width = mode ? mode->mode.width : 0; rep.height = mode ? mode->mode.height : 0; - rep.mode = mode->mode.id; + rep.mode = mode ? mode->mode.id : 0; rep.rotation = crtc->rotation; rep.rotations = crtc->rotations; rep.nOutput = crtc->numOutputs; @@ -572,30 +620,30 @@ ProcRRSetCrtcConfig (ClientPtr client) goto sendReply; } + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + if (outputs) + xfree (outputs); + return BadValue; + } + if (mode) { - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - if (outputs) - xfree (outputs); - return BadValue; - } - if ((~crtc->rotations) & rotation) { /* diff --git a/randr/rrmode.c b/randr/rrmode.c index 3a6748691..07cd0c14f 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -41,7 +41,6 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) if (a->vTotal != b->vTotal) return FALSE; if (a->nameLength != b->nameLength) return FALSE; if (a->modeFlags != b->modeFlags) return FALSE; - if (a->origin != b->origin) return FALSE; return TRUE; } @@ -75,6 +74,7 @@ RRModeGet (ScreenPtr pScreen, memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; mode->screen = pScreen; + mode->userDefined = FALSE; if (pScrPriv->numModes) modes = xrealloc (pScrPriv->modes, @@ -162,7 +162,7 @@ RRModePruneUnused (ScreenPtr pScreen) memcpy (unused, pScrPriv->modes, num * sizeof (RRModePtr)); for (m = 0; m < num; m++) { mode = unused[m]; - if (mode->refcnt == 1 && mode->mode.origin != RRModeOriginUser) + if (mode->refcnt == 1 && !mode->userDefined) FreeResource (mode->mode.id, 0); } xfree (unused); diff --git a/randr/rroutput.c b/randr/rroutput.c index b252d7dec..618ef1f80 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -67,6 +67,7 @@ RROutputCreate (ScreenPtr pScreen, output->numClones = 0; output->clones = NULL; output->numModes = 0; + output->numPreferred = 0; output->modes = NULL; output->properties = NULL; output->changed = TRUE; @@ -120,12 +121,13 @@ RROutputSetClones (RROutputPtr output, Bool RROutputSetModes (RROutputPtr output, RRModePtr *modes, - int numModes) + int numModes, + int numPreferred) { RRModePtr *newModes; int i; - if (numModes == output->numModes) + if (numModes == output->numModes && numPreferred == output->numPreferred) { for (i = 0; i < numModes; i++) if (output->modes[i] != modes[i]) @@ -155,6 +157,7 @@ RROutputSetModes (RROutputPtr output, memcpy (newModes, modes, numModes * sizeof (RRModePtr)); output->modes = newModes; output->numModes = numModes; + output->numPreferred = numPreferred; output->changed = TRUE; return TRUE; } @@ -341,10 +344,10 @@ ProcRRGetOutputInfo (ClientPtr client) rep.subpixelOrder = output->subpixelOrder; rep.nCrtcs = output->numCrtcs; rep.nModes = output->numModes; + rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; rep.possibleOptions = output->possibleOptions; - rep.pad1 = 42; extraLen = ((output->numCrtcs + output->numModes + From 054f8cd2675a80b14bc1ce266377fcfee2335cee Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Oct 2006 17:34:53 -0700 Subject: [PATCH 019/109] Limit pointer to valid crtc areas. Add event swapping. Fix change tracking. Add function to keep pointer within valid crtc areas. Finish event delivery and swapping code. Separate configuration from layout changes to send correct events. --- randr/Makefile.am | 1 + randr/mirandr.c | 3 + randr/randr.c | 74 ++++++++++++++++++------ randr/randrstr.h | 104 +++++++++++++++++++++++++++++++++- randr/rrcrtc.c | 53 ++++++++++-------- randr/rroutput.c | 61 ++++++++++++++++---- randr/rrpointer.c | 137 +++++++++++++++++++++++++++++++++++++++++++++ randr/rrproperty.c | 1 + randr/rrscreen.c | 31 ++++++++++ 9 files changed, 416 insertions(+), 49 deletions(-) create mode 100644 randr/rrpointer.c diff --git a/randr/Makefile.am b/randr/Makefile.am index 91c4bc6dd..9bf0e6531 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -15,6 +15,7 @@ librandr_la_SOURCES = \ rrinfo.c \ rrmode.c \ rroutput.c \ + rrpointer.c \ rrproperty.c \ rrscreen.c \ rrsdispatch.c \ diff --git a/randr/mirandr.c b/randr/mirandr.c index 918e55da4..fab0fd1bd 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -84,6 +84,9 @@ miRandRInit (ScreenPtr pScreen) pScrPriv->rrGetInfo = miRRGetInfo; #if RANDR_12_INTERFACE pScrPriv->rrCrtcSet = miRRCrtcSet; + pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma; + pScrPriv->rrOutputSetProperty = miRROutput + RRScreenSetSizeRange (pScreen, pScreen->width, pScreen->height, diff --git a/randr/randr.c b/randr/randr.c index 35f9a4c80..b422efe9d 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -130,38 +130,71 @@ SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from, cpswaps(from->subpixelOrder, to->subpixelOrder); } -#if 0 static void -SRRMonitorChangeNotifyEvent(xRRMonitorChangeNotifyEvent *from, - xRRMonitorChangeNotifyEvent *to) +SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent *from, + xRRCrtcChangeNotifyEvent *to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->window, to->window); + cpswapl(from->crtc, to->crtc); + cpswapl(from->mode, to->mode); + cpswapl(from->window, to->window); + cpswaps(from->rotation, to->rotation); + cpswaps(from->x, to->x); + cpswaps(from->y, to->y); + cpswaps(from->width, to->width); + cpswaps(from->height, to->height); +} + +static void +SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent *from, + xRROutputChangeNotifyEvent *to) { to->type = from->type; to->subCode = from->subCode; cpswaps(from->sequenceNumber, to->sequenceNumber); cpswapl(from->timestamp, to->timestamp); cpswapl(from->configTimestamp, to->configTimestamp); - cpswapl(from->root, to->root); cpswapl(from->window, to->window); - cpswaps(from->monitor, to->monitor); - cpswaps(from->modeID, to->modeID); + cpswapl(from->output, to->output); + cpswapl(from->crtc, to->crtc); + cpswapl(from->mode, to->mode); cpswaps(from->rotation, to->rotation); - cpswaps(from->subpixelOrder, to->subpixelOrder); - cpswaps(from->x, to->x); - cpswaps(from->y, to->y); } -#endif + +static void +SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent *from, + xRROutputPropertyNotifyEvent *to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->window, to->window); + cpswapl(from->output, to->output); + cpswapl(from->atom, to->atom); + cpswapl(from->timestamp, to->timestamp); +} static void SRRNotifyEvent (xEvent *from, xEvent *to) { switch (from->u.u.detail) { -#if 0 - case RRNotify_MonitorChange: - SRRMonitorChangeNotifyEvent ((xRRMonitorChangeNotifyEvent *) from, - (xRRMonitorChangeNotifyEvent *) to); + case RRNotify_CrtcChange: + SRRCrtcChangeNotifyEvent ((xRRCrtcChangeNotifyEvent *) from, + (xRRCrtcChangeNotifyEvent *) to); + break; + case RRNotify_OutputChange: + SRROutputChangeNotifyEvent ((xRROutputChangeNotifyEvent *) from, + (xRROutputChangeNotifyEvent *) to); + break; + case RRNotify_OutputProperty: + SRROutputPropertyNotifyEvent ((xRROutputPropertyNotifyEvent *) from, + (xRROutputPropertyNotifyEvent *) to); break; -#endif default: break; } @@ -359,6 +392,9 @@ TellChanged (WindowPtr pWin, pointer value) return WT_WALKCHILDREN; } +/* + * Something changed; send events and adjust pointer position + */ void RRTellChanged (ScreenPtr pScreen) { @@ -369,12 +405,18 @@ RRTellChanged (ScreenPtr pScreen) { UpdateCurrentTime (); pScrPriv->lastConfigTime = currentTime; - WalkTree (pScreen, TellChanged, (pointer) pScreen); pScrPriv->changed = FALSE; + WalkTree (pScreen, TellChanged, (pointer) pScreen); for (i = 0; i < pScrPriv->numOutputs; i++) pScrPriv->outputs[i]->changed = FALSE; for (i = 0; i < pScrPriv->numCrtcs; i++) pScrPriv->crtcs[i]->changed = FALSE; + if (pScrPriv->layoutChanged) + { + pScrPriv->layoutChanged = FALSE; + RRPointerScreenConfigured (pScreen); + RRSendConfigNotify (pScreen); + } } } diff --git a/randr/randrstr.h b/randr/randrstr.h index 6690556b4..a8a995026 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -202,10 +202,11 @@ typedef struct _rrScrPriv { TimeStamp lastSetTime; /* last changed by client */ TimeStamp lastConfigTime; /* possible configs changed */ RRCloseScreenProcPtr CloseScreen; - Bool changed; + Bool changed; /* some config changed */ CARD16 minWidth, minHeight; CARD16 maxWidth, maxHeight; CARD16 width, height; /* last known screen size */ + Bool layoutChanged; /* screen layout changed */ /* modes, outputs and crtcs */ int numModes; @@ -217,6 +218,9 @@ typedef struct _rrScrPriv { int numCrtcs; RRCrtcPtr *crtcs; + /* Last known pointer position */ + RRCrtcPtr pointerCrtc; + #ifdef RANDR_10_INTERFACE /* * Configuration information @@ -439,6 +443,14 @@ RRSetScreenConfig (ScreenPtr pScreen, #endif /* rrcrtc.c */ + +/* + * Notify the CRTC of some change; layoutChanged indicates that + * some position or size element changed + */ +void +RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged); + /* * Create a CRTC */ @@ -575,6 +587,13 @@ int ProcRRDeleteOutputMode (ClientPtr client); /* rroutput.c */ + +/* + * Notify the output of some change + */ +void +RROutputChanged (RROutputPtr output); + /* * Create an output */ @@ -638,6 +657,13 @@ ProcRRGetOutputInfo (ClientPtr client); Bool RROutputInit (void); +/* rrpointer.c */ +void +RRPointerMoved (ScreenPtr pScreen, int x, int y); + +void +RRPointerScreenConfigured (ScreenPtr pScreen); + /* rrproperty.c */ void @@ -668,3 +694,79 @@ void RRXineramaExtensionInit(void); #endif /* _RANDRSTR_H_ */ + +/* + +randr extension implementation structure + +Query state: + ProcRRGetScreenInfo/ProcRRGetScreenResources + RRGetInfo + + • Request configuration from driver, either 1.0 or 1.2 style + • These functions only record state changes, all + other actions are pended until RRTellChanged is called + + ->rrGetInfo + 1.0: + RRRegisterSize + RRRegisterRate + RRSetCurrentConfig + 1.2: + RRScreenSetSizeRange + RROutputSetCrtcs + RROutputSetCrtc + RROutputSetPossibleOptions + RRSetCurrentOptions + RRModeGet + RROutputSetModes + RROutputSetConnection + RROutputSetSubpixelOrder + RROutputSetClones + RRCrtcNotify + + • Must delay scanning configuration until after ->rrGetInfo returns + because some drivers will call SetCurrentConfig in the middle + of the ->rrGetInfo operation. + + 1.0: + + • Scan old configuration, mirror to new structures + + RRScanOldConfig + RRCrtcCreate + RROutputCreate + RROutputSetCrtcs + RROutputSetCrtc + RROutputSetConnection + RROutputSetSubpixelOrder + RROldModeAdd • This adds modes one-at-a-time + RRModeGet + RRCrtcNotify + + • send events, reset pointer if necessary + + RRTellChanged + WalkTree (sending events) + + • when layout has changed: + RRPointerScreenConfigured + RRSendConfigNotify + +Asynchronous state setting (1.2 only) + When setting state asynchronously, the driver invokes the + ->rrGetInfo function and then calls RRTellChanged to flush + the changes to the clients and reset pointer if necessary + +Set state + + ProcRRSetScreenConfig + RRCrtcSet + 1.2: + ->rrCrtcSet + RRCrtcNotify + 1.0: + ->rrSetConfig + RRCrtcNotify + RRTellChanged + */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index baefd3a15..c662899a4 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -25,6 +25,24 @@ RESTYPE RRCrtcType; +/* + * Notify the CRTC of some change + */ +void +RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) +{ + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); + + crtc->changed = TRUE; + pScrPriv->changed = TRUE; + /* + * Send ConfigureNotify on any layout change + */ + if (layoutChanged) + pScrPriv->layoutChanged = TRUE; +} + /* * Create a CRTC */ @@ -60,7 +78,7 @@ RRCrtcCreate (ScreenPtr pScreen, crtc->numOutputs = 0; crtc->gammaSize = 0; crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL; - crtc->changed = TRUE; + crtc->changed = FALSE; crtc->devPrivate = devPrivate; if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) @@ -68,7 +86,8 @@ RRCrtcCreate (ScreenPtr pScreen, pScrPriv->crtcs = crtcs; pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; - pScrPriv->changed = TRUE; + + RRCrtcChanged (crtc, TRUE); return crtc; } @@ -85,8 +104,6 @@ RRCrtcNotify (RRCrtcPtr crtc, int numOutputs, RROutputPtr *outputs) { - ScreenPtr pScreen = crtc->pScreen; - rrScrPriv(pScreen); int i, j; /* @@ -100,8 +117,8 @@ RRCrtcNotify (RRCrtcPtr crtc, break; if (j == crtc->numOutputs) { - outputs[i]->changed = TRUE; - crtc->changed = TRUE; + RROutputChanged (outputs[i]); + RRCrtcChanged (crtc, FALSE); } } /* @@ -115,8 +132,8 @@ RRCrtcNotify (RRCrtcPtr crtc, break; if (i == numOutputs) { - crtc->outputs[j]->changed = TRUE; - crtc->changed = TRUE; + RROutputChanged (crtc->outputs[j]); + RRCrtcChanged (crtc, FALSE); } } /* @@ -158,31 +175,22 @@ RRCrtcNotify (RRCrtcPtr crtc, RRModeDestroy (crtc->mode); crtc->mode = mode; mode->refcnt++; - crtc->changed = TRUE; + RRCrtcChanged (crtc, TRUE); } if (x != crtc->x) { crtc->x = x; - crtc->changed = TRUE; + RRCrtcChanged (crtc, TRUE); } if (y != crtc->y) { crtc->y = y; - crtc->changed = TRUE; + RRCrtcChanged (crtc, TRUE); } if (rotation != crtc->rotation) { crtc->rotation = rotation; - crtc->changed = TRUE; - } - /* - * Send events if anything changed - */ - if (crtc->changed) - { - if (!pScrPriv->changed) - RRSendConfigNotify (pScreen); - pScrPriv->changed = TRUE; + RRCrtcChanged (crtc, TRUE); } return TRUE; } @@ -272,10 +280,11 @@ RRCrtcSet (RRCrtcPtr crtc, * Old 1.0 interface tied screen size to mode size */ if (ret) - RRScreenSizeNotify (pScreen); + RRCrtcNotify (crtc, mode, x, y, rotation, return ret; } #endif + RRTellChanged (pScreen); return FALSE; } diff --git a/randr/rroutput.c b/randr/rroutput.c index 618ef1f80..fc84ec1e6 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -24,6 +24,19 @@ RESTYPE RROutputType; +/* + * Notify the output of some change + */ +void +RROutputChanged (RROutputPtr output) +{ + ScreenPtr pScreen = output->pScreen; + rrScrPriv (pScreen); + + output->changed = TRUE; + pScrPriv->changed = TRUE; +} + /* * Create an output */ @@ -70,7 +83,7 @@ RROutputCreate (ScreenPtr pScreen, output->numPreferred = 0; output->modes = NULL; output->properties = NULL; - output->changed = TRUE; + output->changed = FALSE; output->devPrivate = devPrivate; if (!AddResource (output->id, RROutputType, (pointer) output)) @@ -78,7 +91,7 @@ RROutputCreate (ScreenPtr pScreen, pScrPriv->outputs = outputs; pScrPriv->outputs[pScrPriv->numOutputs++] = output; - pScrPriv->changed = TRUE; + RROutputChanged (output); return output; } @@ -114,7 +127,7 @@ RROutputSetClones (RROutputPtr output, memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); output->clones = newClones; output->numClones = numClones; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -158,7 +171,7 @@ RROutputSetModes (RROutputPtr output, output->modes = newModes; output->numModes = numModes; output->numPreferred = numPreferred; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -191,7 +204,7 @@ RROutputSetCrtcs (RROutputPtr output, memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -202,7 +215,7 @@ RROutputSetPossibleOptions (RROutputPtr output, if (output->possibleOptions == possibleOptions) return TRUE; output->possibleOptions = possibleOptions; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -212,7 +225,7 @@ RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) if (output->crtc == crtc) return; output->crtc = crtc; - output->changed = TRUE; + RROutputChanged (output); } Bool @@ -222,7 +235,7 @@ RROutputSetConnection (RROutputPtr output, if (output->connection == connection) return TRUE; output->connection = connection; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -234,7 +247,7 @@ RROutputSetSubpixelOrder (RROutputPtr output, return TRUE; output->subpixelOrder = subpixelOrder; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } @@ -245,13 +258,41 @@ RROutputSetCurrentOptions (RROutputPtr output, if (output->currentOptions == currentOptions) return TRUE; output->currentOptions = currentOptions; - output->changed = TRUE; + RROutputChanged (output); return TRUE; } void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { + ScreenPtr pScreen = pWin->drawable.pScreen; + rrScrPriv (pScreen); + xRROutputChangeNotifyEvent oe; + RRCrtcPtr crtc = output->crtc; + RRModePtr mode = crtc ? crtc->mode : 0; + + oe.type = RRNotify + RREventBase; + oe.subCode = RRNotify_OutputChange; + oe.sequenceNumber = client->sequence; + oe.timestamp = pScrPriv->lastSetTime.milliseconds; + oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + oe.window = pWin->drawable.id; + oe.output = output->id; + if (crtc) + { + oe.crtc = crtc->id; + oe.mode = mode ? mode->mode.id : None; + oe.rotation = crtc->rotation; + } + else + { + oe.crtc = None; + oe.mode = None; + oe.rotation = RR_Rotate_0; + } + oe.connection = output->connection; + oe.subpixelOrder = output->subpixelOrder; + WriteEventsToClient (client, 1, (xEvent *) &oe); } /* diff --git a/randr/rrpointer.c b/randr/rrpointer.c new file mode 100644 index 000000000..7ba0460f5 --- /dev/null +++ b/randr/rrpointer.c @@ -0,0 +1,137 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +/* + * When the pointer moves, check to see if the specified position is outside + * any of theavailable CRTCs and move it to a 'sensible' place if so, where + * sensible is the closest monitor to the departing edge. + * + * Returns whether the position was adjusted + */ + +static Bool +RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y) +{ + RRModePtr mode = crtc->mode; + + if (!mode) + return FALSE; + if (crtc->x <= x && x < crtc->x + mode->mode.width && + crtc->y <= y && y < crtc->y + mode->mode.height) + return TRUE; + return FALSE; +} + +/* + * Find the CRTC nearest the specified position, ignoring 'skip' + */ +static void +RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip) +{ + rrScrPriv (pScreen); + int c; + RRCrtcPtr nearest = NULL; + int best = 0; + int best_dx = 0, best_dy = 0; + + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + RRModePtr mode = crtc->mode; + int dx, dy; + int dist; + + if (!mode) + continue; + if (crtc == skip) + continue; + if (x < crtc->x) + dx = crtc->x - x; + else if (x > crtc->x + mode->mode.width) + dx = x - (crtc->x + mode->mode.width); + else + dx = 0; + if (y < crtc->y) + dy = crtc->y - x; + else if (y > crtc->y + mode->mode.height) + dy = y - (crtc->y + mode->mode.height); + else + dy = 0; + dist = dx + dy; + if (!nearest || dist < best) + { + nearest = crtc; + best_dx = dx; + best_dy = dy; + } + } + if (best_dx || best_dy) + (*pScreen->SetCursorPosition) (pScreen, x + best_dx, y + best_dy, TRUE); + pScrPriv->pointerCrtc = nearest; +} + +void +RRPointerMoved (ScreenPtr pScreen, int x, int y) +{ + rrScrPriv (pScreen); + RRCrtcPtr pointerCrtc = pScrPriv->pointerCrtc;; + int c; + + /* Check last known CRTC */ + if (pointerCrtc && RRCrtcContainsPosition (pointerCrtc, x, y)) + return; + + /* Check all CRTCs */ + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + + if (RRCrtcContainsPosition (crtc, x, y)) + { + /* Remember containing CRTC */ + pScrPriv->pointerCrtc = crtc; + return; + } + } + + /* None contain pointer, find nearest */ + RRPointerToNearestCrtc (pScreen, x, y, pointerCrtc); +} + +/* + * When the screen is reconfigured, move the pointer to the nearest + * CRTC + */ +void +RRPointerScreenConfigured (ScreenPtr pScreen) +{ + WindowPtr pRoot = GetCurrentRootWindow (); + ScreenPtr pCurrentScreen = pRoot ? pRoot->drawable.pScreen : NULL; + int x, y; + + if (pScreen != pCurrentScreen) + return FALSE; + GetSpritePosition (&x, &y); + RRPointerToNearestCrtc (pScreen, x, y, NULL); +} diff --git a/randr/rrproperty.c b/randr/rrproperty.c index cdafb5c9b..44f1f0ace 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -27,6 +27,7 @@ static void RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask) { + } void diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 7b53f0468..6d38e96b5 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -164,10 +164,13 @@ RRScreenSizeNotify (ScreenPtr pScreen) pScrPriv->width = pScreen->width; pScrPriv->height = pScreen->height; pScrPriv->changed = TRUE; + pScrPriv->sizeChanged = TRUE; + RRTellChanged (pScreen); RRSendConfigNotify (pScreen); RREditConnectionInfo (pScreen); + RRPointerScreenConfigured (pScreen); /* * Fix pointer bounds and location */ @@ -836,9 +839,37 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } + /* + * If the screen size is changing, adjust all of the other outputs + * to fit the new size, mirroring as much as possible + */ + if (mode->mode.width != pScreen->width || + mode->mode.height != pScreen->height) + { + int c; + + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + rep.status = RRCrtcSet (pScrPriv->->crtc, NULL, 0, 0, RR_Rotate_0, + 0, NULL); + if (rep.status != Success) + goto sendReply; + } + if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height, + pScreen->mmWidth, pScreen->mmHeight)) + { + rep.status RRSetConfigFailed; + goto sendReply; + } + } + rep.status = RRCrtcSet (output.output->crtc, mode, 0, 0, stuff->rotation, 1, &output); + /* + * XXX Configure other crtcs to mirror as much as possible + */ + sendReply: if (pData) From e21604914dccece6bc64c69b55512d1f1a969235 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 25 Oct 2006 09:48:23 -0700 Subject: [PATCH 020/109] Merge master back in and clean up some unfinished code (closes 8745) --- randr/mirandr.c | 17 +++++++++++++- randr/randr.c | 54 +++------------------------------------------ randr/rrcrtc.c | 2 +- randr/rrscreen.c | 6 ++--- randr/rrsdispatch.c | 1 + randr/rrxinerama.c | 3 +++ 6 files changed, 27 insertions(+), 56 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index fab0fd1bd..8d79e8a11 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -57,6 +57,21 @@ miRRCrtcSet (ScreenPtr pScreen, return TRUE; } +static Bool +miRRCrtcSetGamma (ScreenPtr pScreen, + RRCrtcPtr crtc) +{ + return TRUE; +} + +static Bool +miRROutputSetProperty (ScreenPtr pScreen, + RROutputPtr output, + Atom property) +{ + return TRUE; +} + /* * This function assumes that only a single depth can be * displayed at a time, but that all visuals of that depth @@ -85,7 +100,7 @@ miRandRInit (ScreenPtr pScreen) #if RANDR_12_INTERFACE pScrPriv->rrCrtcSet = miRRCrtcSet; pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma; - pScrPriv->rrOutputSetProperty = miRROutput + pScrPriv->rrOutputSetProperty = miRROutputSetProperty; RRScreenSetSizeRange (pScreen, diff --git a/randr/randr.c b/randr/randr.c index 5494428fc..7b39e8045 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -42,9 +42,6 @@ int RRGeneration; int RRNScreens; -static int ProcRRDispatch (ClientPtr pClient); -static int SProcRRDispatch (ClientPtr pClient); - #define wrap(priv,real,mem,func) {\ priv->mem = real->mem; \ real->mem = func; \ @@ -54,6 +51,9 @@ static int SProcRRDispatch (ClientPtr pClient); real->mem = priv->mem; \ } +static int ProcRRDispatch (ClientPtr pClient); +static int SProcRRDispatch (ClientPtr pClient); + int RREventBase; int RRErrorBase; RESTYPE RRClientType, RREventType; /* resource types for event masks */ @@ -466,54 +466,6 @@ ProcRRDispatch (ClientPtr client) return (*ProcRandrVector[stuff->data]) (client); } -static int -SProcRRGetScreenInfo (ClientPtr client) -{ - register int n; - REQUEST(xRRGetScreenInfoReq); - - swaps(&stuff->length, n); - swapl(&stuff->window, n); - return ProcRRGetScreenInfo(client); -} - -static int -SProcRRSetScreenConfig (ClientPtr client) -{ - register int n; - REQUEST(xRRSetScreenConfigReq); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - swaps (&stuff->rate, n); - } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - } - - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - swapl(&stuff->timestamp, n); - swaps(&stuff->sizeID, n); - swaps(&stuff->rotation, n); - return ProcRRSetScreenConfig(client); -} - -static int -SProcRRSelectInput (ClientPtr client) -{ - register int n; - REQUEST(xRRSelectInputReq); - - swaps(&stuff->length, n); - swapl(&stuff->window, n); - swaps(&stuff->enable, n); - return ProcRRSelectInput(client); -} - - static int SProcRRDispatch (ClientPtr client) { diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index c662899a4..ee51cc23a 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -280,7 +280,7 @@ RRCrtcSet (RRCrtcPtr crtc, * Old 1.0 interface tied screen size to mode size */ if (ret) - RRCrtcNotify (crtc, mode, x, y, rotation, + RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output); return ret; } #endif diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 6d38e96b5..b4d361846 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -164,7 +164,7 @@ RRScreenSizeNotify (ScreenPtr pScreen) pScrPriv->width = pScreen->width; pScrPriv->height = pScreen->height; pScrPriv->changed = TRUE; - pScrPriv->sizeChanged = TRUE; +/* pScrPriv->sizeChanged = TRUE; */ RRTellChanged (pScreen); RRSendConfigNotify (pScreen); @@ -850,7 +850,7 @@ ProcRRSetScreenConfig (ClientPtr client) for (c = 0; c < pScrPriv->numCrtcs; c++) { - rep.status = RRCrtcSet (pScrPriv->->crtc, NULL, 0, 0, RR_Rotate_0, + rep.status = RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, 0, NULL); if (rep.status != Success) goto sendReply; @@ -858,7 +858,7 @@ ProcRRSetScreenConfig (ClientPtr client) if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height, pScreen->mmWidth, pScreen->mmHeight)) { - rep.status RRSetConfigFailed; + rep.status = RRSetConfigFailed; goto sendReply; } } diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c index bf81f8bdb..67af75306 100644 --- a/randr/rrsdispatch.c +++ b/randr/rrsdispatch.c @@ -77,6 +77,7 @@ SProcRRSelectInput (ClientPtr client) swaps(&stuff->length, n); swapl(&stuff->window, n); + swaps(&stuff->enable, n); return (*ProcRandrVector[stuff->randrReqType]) (client); } diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c index 31f60cca1..a8e4b390b 100644 --- a/randr/rrxinerama.c +++ b/randr/rrxinerama.c @@ -259,6 +259,9 @@ ProcRRXineramaQueryScreens(ClientPtr client) REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + if (RRXineramaScreenActive (pScreen)) + RRGetInfo (pScreen); + rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.number = RRXineramaScreenCount (pScreen); From 4056e6e79a4e37101d298ae29139c83d3816368b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 1 Nov 2006 00:29:46 -0800 Subject: [PATCH 021/109] Move physical size from mode to output. Modes can be shared across different sized monitors this way. Also caught some missing byteswapping and an incorrect return type. --- randr/mirandr.c | 2 -- randr/randrstr.h | 7 +++++++ randr/rrcrtc.c | 12 ++++++++++-- randr/rrinfo.c | 2 -- randr/rrmode.c | 2 -- randr/rroutput.c | 23 +++++++++++++++++++++++ randr/rrpointer.c | 2 +- randr/rrscreen.c | 15 +++++++++------ 8 files changed, 50 insertions(+), 15 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 8d79e8a11..11c299133 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -111,8 +111,6 @@ miRandRInit (ScreenPtr pScreen) memset (&modeInfo, '\0', sizeof (modeInfo)); modeInfo.width = pScreen->width; modeInfo.height = pScreen->height; - modeInfo.mmWidth = pScreen->mmWidth; - modeInfo.mmHeight = pScreen->mmHeight; modeInfo.nameLength = strlen (name); mode = RRModeGet (pScreen, &modeInfo, name); diff --git a/randr/randrstr.h b/randr/randrstr.h index a8a995026..60877a3c1 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -107,6 +107,8 @@ struct _rrOutput { int nameLength; CARD8 connection; CARD8 subpixelOrder; + int mmWidth; + int mmHeight; RRCrtcPtr crtc; CARD32 currentOptions; CARD32 possibleOptions; @@ -642,6 +644,11 @@ Bool RROutputSetCurrentOptions (RROutputPtr output, CARD32 currentOptions); +Bool +RROutputSetPhysicalSize (RROutputPtr output, + int mmWidth, + int mmHeight); + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index ee51cc23a..c40dac129 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -270,8 +270,16 @@ RRCrtcSet (RRCrtcPtr crtc, size.width = mode->mode.width; size.height = mode->mode.height; - size.mmWidth = mode->mode.mmWidth; - size.mmHeight = mode->mode.mmHeight; + if (outputs[0].output->mmWidth && outputs[0].output->mmHeight) + { + size.mmWidth = outputs[0].output->mmWidth; + size.mmHeight = outputs[0].output->mmHeight; + } + else + { + size.mmWidth = pScreen->mmWidth; + size.mmHeight = pScreen->mmHeight; + } size.nRates = 1; rate.rate = RRVerticalRefresh (&mode->mode); size.pRates = &rate; diff --git a/randr/rrinfo.c b/randr/rrinfo.c index 6fd4ee581..e92caadfa 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -39,8 +39,6 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) modeInfo.width = size->width; modeInfo.height = size->height; - modeInfo.mmWidth = size->mmWidth; - modeInfo.mmHeight = size->mmHeight; modeInfo.hTotal = size->width; modeInfo.vTotal = size->height; modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height * diff --git a/randr/rrmode.c b/randr/rrmode.c index 07cd0c14f..fb4b5eb1e 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -29,8 +29,6 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) { if (a->width != b->width) return FALSE; if (a->height != b->height) return FALSE; - if (a->mmWidth != b->mmWidth) return FALSE; - if (a->mmHeight != b->mmHeight) return FALSE; if (a->dotClock != b->dotClock) return FALSE; if (a->hSyncStart != b->hSyncStart) return FALSE; if (a->hSyncEnd != b->hSyncEnd) return FALSE; diff --git a/randr/rroutput.c b/randr/rroutput.c index fc84ec1e6..1f6f33030 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -72,6 +72,8 @@ RROutputCreate (ScreenPtr pScreen, output->name[nameLength] = '\0'; output->connection = RR_UnknownConnection; output->subpixelOrder = SubPixelUnknown; + output->mmWidth = 0; + output->mmHeight = 0; output->crtc = NULL; output->currentOptions = 0; output->possibleOptions = 0; @@ -262,6 +264,20 @@ RROutputSetCurrentOptions (RROutputPtr output, return TRUE; } +Bool +RROutputSetPhysicalSize (RROutputPtr output, + int mmWidth, + int mmHeight) +{ + if (output->mmWidth == mmWidth && output->mmHeight == mmHeight) + return TRUE; + output->mmWidth = mmWidth; + output->mmHeight = mmHeight; + RROutputChanged (output); + return TRUE; +} + + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { @@ -381,6 +397,8 @@ ProcRRGetOutputInfo (ClientPtr client) rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.crtc = output->crtc ? output->crtc->id : None; rep.currentOptions = output->currentOptions; + rep.mmWidth = output->mmWidth; + rep.mmHeight = output->mmHeight; rep.connection = output->connection; rep.subpixelOrder = output->subpixelOrder; rep.nCrtcs = output->numCrtcs; @@ -434,10 +452,15 @@ ProcRRGetOutputInfo (ClientPtr client) swapl(&rep.length, n); swapl(&rep.timestamp, n); swapl(&rep.crtc, n); + swapl(&rep.currentOptions, n); + swapl(&rep.mmWidth, n); + swapl(&rep.mmHeight, n); swaps(&rep.nCrtcs, n); swaps(&rep.nModes, n); swaps(&rep.nClones, n); + swapl(&rep.possibleOptions, n); swaps(&rep.nameLength, n); + swapl(&rep.possibleOptions, n); } WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); if (extraLen) diff --git a/randr/rrpointer.c b/randr/rrpointer.c index 7ba0460f5..c092e494b 100644 --- a/randr/rrpointer.c +++ b/randr/rrpointer.c @@ -131,7 +131,7 @@ RRPointerScreenConfigured (ScreenPtr pScreen) int x, y; if (pScreen != pCurrentScreen) - return FALSE; + return; GetSpritePosition (&x, &y); RRPointerToNearestCrtc (pScreen, x, y, NULL); } diff --git a/randr/rrscreen.c b/randr/rrscreen.c index b4d361846..705e7d78c 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -126,8 +126,8 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) } se.widthInPixels = mode->mode.width; se.heightInPixels = mode->mode.height; - se.widthInMillimeters = mode->mode.mmWidth; - se.heightInMillimeters = mode->mode.mmHeight; + se.widthInMillimeters = pScreen->mmWidth; + se.heightInMillimeters = pScreen->mmHeight; } else { @@ -415,8 +415,6 @@ ProcRRGetScreenResources (ClientPtr client) swapl (&modeinfos[i].id, n); swaps (&modeinfos[i].width, n); swaps (&modeinfos[i].height, n); - swapl (&modeinfos[i].mmWidth, n); - swapl (&modeinfos[i].mmHeight, n); swapl (&modeinfos[i].dotClock, n); swaps (&modeinfos[i].hSyncStart, n); swaps (&modeinfos[i].hSyncEnd, n); @@ -501,8 +499,13 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output) size[j].id = j; size[j].width = mode->mode.width; size[j].height = mode->mode.height; - size[j].mmWidth = mode->mode.mmWidth; - size[j].mmHeight = mode->mode.mmHeight; + if (output->mmWidth && output->mmHeight) { + size[j].mmWidth = output->mmWidth; + size[j].mmHeight = output->mmHeight; + } else { + size[j].mmWidth = pScreen->mmWidth; + size[j].mmHeight = pScreen->mmHeight; + } size[j].nRates = 0; size[j].pRates = &refresh[data->nrefresh]; data->nsize++; From cde8806c2930788ba8076e94651d391e45f3ccdb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 3 Nov 2006 16:36:34 -0800 Subject: [PATCH 022/109] Don't bump the refcnt if the new mode is NULL. --- randr/rrcrtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index c40dac129..76d0b6bf5 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -174,7 +174,8 @@ RRCrtcNotify (RRCrtcPtr crtc, if (crtc->mode) RRModeDestroy (crtc->mode); crtc->mode = mode; - mode->refcnt++; + if (mode != NULL) + mode->refcnt++; RRCrtcChanged (crtc, TRUE); } if (x != crtc->x) From 2db62bce0725ba2d88cbe40fc440b6bda45046f3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 4 Nov 2006 17:40:34 -0800 Subject: [PATCH 023/109] Define fbHasVisualTypes in fb.h as it is exported --- fb/fb.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fb/fb.h b/fb/fb.h index de0b3a8c2..e60507874 100644 --- a/fb/fb.h +++ b/fb/fb.h @@ -1341,6 +1341,9 @@ fbCreateDefColormap(ScreenPtr pScreen); void fbClearVisualTypes(void); +Bool +fbHasVisualTypes (int depth); + Bool fbSetVisualTypes (int depth, int visuals, int bitsPerRGB); From 7ffbe9d232e3a4621a204448d67e434736465cbe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 4 Nov 2006 17:41:09 -0800 Subject: [PATCH 024/109] Add DIX_CFLAGS to hw/vfb/Makefile.am --- hw/vfb/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am index baab5ca22..2a0151f57 100644 --- a/hw/vfb/Makefile.am +++ b/hw/vfb/Makefile.am @@ -21,8 +21,8 @@ Xvfb_LDFLAGS = AM_CFLAGS = -DHAVE_DIX_CONFIG_H \ -DNO_HW_ONLY_EXTS \ -DNO_MODULE_EXTS \ - \ - $(XVFBMODULES_CFLAGS) + $(XVFBMODULES_CFLAGS) \ + $(DIX_CFLAGS) # Man page include $(top_srcdir)/cpprules.in From 8b87ce19741753eafbd99e7093bc3dea8f26e838 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 4 Nov 2006 17:41:25 -0800 Subject: [PATCH 025/109] Allow X server to build against libdrm 2.1 --- configure.ac | 3 +++ hw/xfree86/os-support/drm/xf86drm.c | 2 ++ hw/xfree86/os-support/xf86drm.h | 2 ++ include/dix-config.h.in | 3 +++ 4 files changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 195211cb9..cb194aee6 100644 --- a/configure.ac +++ b/configure.ac @@ -619,6 +619,9 @@ if test "x$DRI" = xyes; then PKG_CHECK_MODULES([DRIPROTO], [xf86driproto]) PKG_CHECK_MODULES([LIBDRM], [libdrm]) PKG_CHECK_MODULES([GL], [glproto >= 1.4.1]) + PKG_CHECK_EXISTS(libdrm >= 2.2.0, + [AC_DEFINE([HAVE_LIBDRM_2_2], 1, + [Has version 2.2 (or newer) of the drm library])]) AC_SUBST(DRIPROTO_CFLAGS) AC_SUBST(LIBDRM_CFLAGS) AC_SUBST(GL_CFLAGS) diff --git a/hw/xfree86/os-support/drm/xf86drm.c b/hw/xfree86/os-support/drm/xf86drm.c index e990e286b..8bcccee2a 100644 --- a/hw/xfree86/os-support/drm/xf86drm.c +++ b/hw/xfree86/os-support/drm/xf86drm.c @@ -2307,6 +2307,7 @@ int drmRemoveSIGIOHandler(int fd) return xf86RemoveSIGIOHandler(fd); } +#if HAVE_LIBDRM_2_2 /* * Valid flags are * DRM_FENCE_FLAG_EMIT @@ -3260,3 +3261,4 @@ int drmMMUnlock(int fd, unsigned memType) return ret; } +#endif /* HAVE_LIBDRM_2_2 */ diff --git a/hw/xfree86/os-support/xf86drm.h b/hw/xfree86/os-support/xf86drm.h index 18e4564d1..1d93f6f90 100644 --- a/hw/xfree86/os-support/xf86drm.h +++ b/hw/xfree86/os-support/xf86drm.h @@ -36,7 +36,9 @@ #define _XF86DRM_H_ #include +#if HAVE_LIBDRM_2_2 #include +#endif /* Defaults, if nothing set in xf86config */ #define DRM_DEV_UID 0 diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 35700e460..84d693f5c 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -127,6 +127,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have version 2.2 (or newer) of the drm library */ +#undef HAVE_LIBDRM_2_2 + /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM From 1dcda4f3c56214464c0b6123fea6daa69aae69fc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 7 Nov 2006 01:29:51 -0800 Subject: [PATCH 026/109] Avoid dereferencing sprite.screen when Xinerama is not running. (#8925) With Xinerama support built into the X server but not in use, sprite.screen is NULL and yet the SyntheticMotion macro would dereference it. Avoid that by just passing sprite.screen to PostSyntheticMotion which can then dereference it when Xinerama is enabled. Also, define PostSyntheticMotion in dixevents.h and include dixevents.h in getevents.c --- dix/events.c | 3 +-- dix/getevents.c | 8 +++++--- include/dixevents.h | 4 ++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dix/events.c b/dix/events.c index 3b1a0aaf4..ce053b347 100644 --- a/dix/events.c +++ b/dix/events.c @@ -327,11 +327,10 @@ static CARD8 criticalEvents[32] = #ifdef PANORAMIX static void ConfineToShape(RegionPtr shape, int *px, int *py); -extern void PostSyntheticMotion(int x, int y, int screenNum, int time); static void PostNewCursor(void); #define SyntheticMotion(x, y) \ - PostSyntheticMotion(x, y, sprite.screen->myNum, \ + PostSyntheticMotion(x, y, sprite.screen, \ syncEvents.playingEvents ? \ syncEvents.time.milliseconds : \ currentTime.milliseconds); diff --git a/dix/getevents.c b/dix/getevents.c index b19a73fa6..1d9502802 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -38,6 +38,7 @@ #include "dixstruct.h" #include "globals.h" +#include "dixevents.h" #include "mipointer.h" @@ -758,7 +759,7 @@ SwitchCorePointer(DeviceIntPtr pDev) * to shift the pointer to get it inside the new bounds. */ void -PostSyntheticMotion(int x, int y, int screenNum, unsigned long time) +PostSyntheticMotion(int x, int y, ScreenPtr pScreen, unsigned long time) { xEvent xE; @@ -767,8 +768,8 @@ PostSyntheticMotion(int x, int y, int screenNum, unsigned long time) will translate from sprite screen to screen 0 upon reentry to the DIX layer. */ if (!noPanoramiXExtension) { - x += panoramiXdataPtr[0].x - panoramiXdataPtr[screenNum].x; - y += panoramiXdataPtr[0].y - panoramiXdataPtr[screenNum].y; + x += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x; + y += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y; } #endif @@ -776,6 +777,7 @@ PostSyntheticMotion(int x, int y, int screenNum, unsigned long time) xE.u.u.type = MotionNotify; xE.u.keyButtonPointer.rootX = x; xE.u.keyButtonPointer.rootY = y; + xE.u.keyButtonPointer.time = time; (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1); } diff --git a/include/dixevents.h b/include/dixevents.h index 2a9458f08..c78fb0e85 100644 --- a/include/dixevents.h +++ b/include/dixevents.h @@ -102,4 +102,8 @@ extern int ProcUngrabButton(ClientPtr /* client */); extern int ProcRecolorCursor(ClientPtr /* client */); +#ifdef PANORAMIX +extern void PostSyntheticMotion(int x, int y, ScreenPtr pScreen, unsigned long time); +#endif + #endif /* DIXEVENTS_H */ From 20e9144c0746943624ff77a61791b8596f3f8458 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 7 Nov 2006 12:49:28 -0800 Subject: [PATCH 027/109] Add $(DIX_CFLAGS) to remaining Makefile.am files --- hw/dmx/config/Makefile.am | 2 +- hw/dmx/glxProxy/Makefile.am | 2 +- hw/dmx/input/Makefile.am | 2 +- hw/xfree86/Makefile.am | 2 +- hw/xfree86/os-support/bsd/Makefile.am | 2 +- hw/xfree86/os-support/bus/Makefile.am | 2 +- hw/xfree86/os-support/hurd/Makefile.am | 2 +- hw/xfree86/os-support/linux/Makefile.am | 2 +- hw/xfree86/os-support/misc/Makefile.am | 2 +- hw/xfree86/os-support/solaris/Makefile.am | 2 +- hw/xgl/Makefile.am | 2 +- hw/xgl/egl/Makefile.am | 2 +- hw/xgl/egl/module/Makefile.am | 1 + hw/xgl/glx/Makefile.am | 2 +- hw/xgl/glx/module/Makefile.am | 2 +- hw/xgl/glxext/Makefile.am | 2 +- hw/xgl/glxext/module/Makefile.am | 2 +- hw/xwin/Makefile.am | 2 +- 18 files changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/dmx/config/Makefile.am b/hw/dmx/config/Makefile.am index fbc7f35a1..c31e04942 100644 --- a/hw/dmx/config/Makefile.am +++ b/hw/dmx/config/Makefile.am @@ -27,7 +27,7 @@ endif AM_YFLAGS = -d AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -I$(top_srcdir)/hw/dmx \ $(GLX_INCS) \ -DHAVE_DMX_CONFIG_H \ diff --git a/hw/dmx/glxProxy/Makefile.am b/hw/dmx/glxProxy/Makefile.am index 2f4a3b708..1fbc8d764 100644 --- a/hw/dmx/glxProxy/Makefile.am +++ b/hw/dmx/glxProxy/Makefile.am @@ -32,7 +32,7 @@ libglxproxy_a_SOURCES = compsize.c \ unpack.h AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -I$(top_srcdir)/hw/dmx \ -I$(top_srcdir)/include \ -I$(top_srcdir)/GL/include \ diff --git a/hw/dmx/input/Makefile.am b/hw/dmx/input/Makefile.am index 326506e77..da8de0546 100644 --- a/hw/dmx/input/Makefile.am +++ b/hw/dmx/input/Makefile.am @@ -60,7 +60,7 @@ GLX_DEFS = @GL_CFLAGS@ GLX_INCS = -I@MESA_SOURCE@/include endif -AM_CFLAGS = \ +AM_CFLAGS = $(DIX_CFLAGS) \ -I$(top_srcdir)/hw/dmx \ -I$(top_srcdir)/hw/xfree86/common \ $(GLX_INCS) \ diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index 72befea19..b373242e8 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -22,7 +22,7 @@ DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ bin_PROGRAMS = Xorg -AM_CFLAGS = @XORG_CFLAGS@ +AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ INCLUDES = @XORG_INCS@ Xorg_SOURCES = xorg.c diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am index e456328df..099240467 100644 --- a/hw/xfree86/os-support/bsd/Makefile.am +++ b/hw/xfree86/os-support/bsd/Makefile.am @@ -50,7 +50,7 @@ ARCH_SOURCES = \ endif # FIXME: NetBSD Aperture defines (configure.ac) -AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) +AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) INCLUDES = $(XORG_INCS) diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index c56f3d717..fba6e5421 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -53,6 +53,6 @@ libbus_la_SOURCES = Pci.c Pci.h $(PCI_SOURCES) $(PLATFORM_PCI_SOURCES) \ INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) EXTRA_DIST = $(sdk_HEADERS) diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am index b80fdde99..731ff083d 100644 --- a/hw/xfree86/os-support/hurd/Makefile.am +++ b/hw/xfree86/os-support/hurd/Makefile.am @@ -12,6 +12,6 @@ libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ $(srcdir)/../shared/kmod_noop.c \ $(srcdir)/../shared/agp_noop.c -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) INCLUDES = $(XORG_INCS) diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am index caf600787..9c4fa4984 100644 --- a/hw/xfree86/os-support/linux/Makefile.am +++ b/hw/xfree86/os-support/linux/Makefile.am @@ -34,7 +34,7 @@ liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \ $(APM_SRCS) \ $(PLATFORM_PCI_SUPPORT) -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(PLATFORM_DEFINES) +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES) INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack diff --git a/hw/xfree86/os-support/misc/Makefile.am b/hw/xfree86/os-support/misc/Makefile.am index 8bec35088..65fbe92b4 100644 --- a/hw/xfree86/os-support/misc/Makefile.am +++ b/hw/xfree86/os-support/misc/Makefile.am @@ -18,6 +18,6 @@ libmisc_la_SOURCES = xf86_Util.c Delay.c $(ARCH_SRCS) INCLUDES = $(XORG_INCS) -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) $(ILHACK_SRCS) diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am index 291c329ea..57ec89e57 100644 --- a/hw/xfree86/os-support/solaris/Makefile.am +++ b/hw/xfree86/os-support/solaris/Makefile.am @@ -30,7 +30,7 @@ nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC) sdk_HEADERS = agpgart.h nodist_sdk_HEADERS = solaris-$(SOLARIS_INOUT_ARCH).il -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) INCLUDES = $(XORG_INCS) diff --git a/hw/xgl/Makefile.am b/hw/xgl/Makefile.am index 48a9825d2..965060cd7 100644 --- a/hw/xgl/Makefile.am +++ b/hw/xgl/Makefile.am @@ -19,7 +19,7 @@ SUBDIRS = \ $(XEGL_SUBDIRS) AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -DHAVE_XGL_CONFIG_H \ -DHAVE_DIX_CONFIG_H \ -I$(top_srcdir)/GL/glx \ diff --git a/hw/xgl/egl/Makefile.am b/hw/xgl/egl/Makefile.am index ded4a15e2..5136e58b1 100644 --- a/hw/xgl/egl/Makefile.am +++ b/hw/xgl/egl/Makefile.am @@ -9,7 +9,7 @@ SUBDIRS = \ $(XGL_MODULE_DIRS) AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -DHAVE_XGL_CONFIG_H \ -DHAVE_DIX_CONFIG_H \ $(XEGLMODULES_CFLAGS) diff --git a/hw/xgl/egl/module/Makefile.am b/hw/xgl/egl/module/Makefile.am index 7ed217322..c84f85c90 100644 --- a/hw/xgl/egl/module/Makefile.am +++ b/hw/xgl/egl/module/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = \ + $(DIX_CFLAGS) \ -I$(srcdir)/.. \ -I$(srcdir)/../.. \ $(XEGLMODULES_CFLAGS) diff --git a/hw/xgl/glx/Makefile.am b/hw/xgl/glx/Makefile.am index 10a831f94..314c02e96 100644 --- a/hw/xgl/glx/Makefile.am +++ b/hw/xgl/glx/Makefile.am @@ -15,7 +15,7 @@ AM_CFLAGS = \ -I$(top_srcdir)/GL/include \ -I@MESA_SOURCE@/include \ -I@MESA_SOURCE@/src/mesa/glapi \ - \ + $(DIX_CFLAGS) \ -DHAVE_XGL_CONFIG_H \ -DHAVE_DIX_CONFIG_H \ $(XGLXMODULES_CFLAGS) diff --git a/hw/xgl/glx/module/Makefile.am b/hw/xgl/glx/module/Makefile.am index 846942a43..bd1c4b08f 100644 --- a/hw/xgl/glx/module/Makefile.am +++ b/hw/xgl/glx/module/Makefile.am @@ -2,7 +2,7 @@ if GLX GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la endif -AM_CFLAGS = \ +AM_CFLAGS = $(DIX_CFLAGS) \ -I$(srcdir)/.. \ -I$(srcdir)/../.. \ $(XGLXMODULES_CFLAGS) diff --git a/hw/xgl/glxext/Makefile.am b/hw/xgl/glxext/Makefile.am index c400f364a..98a9b13c4 100644 --- a/hw/xgl/glxext/Makefile.am +++ b/hw/xgl/glxext/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = module AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -DHAVE_XGL_CONFIG_H \ -DHAVE_DIX_CONFIG_H \ $(XGLMODULES_CFLAGS) \ diff --git a/hw/xgl/glxext/module/Makefile.am b/hw/xgl/glxext/module/Makefile.am index 82c4211d8..4633f7ffa 100644 --- a/hw/xgl/glxext/module/Makefile.am +++ b/hw/xgl/glxext/module/Makefile.am @@ -1,5 +1,5 @@ AM_CFLAGS = \ - \ + $(DIX_CFLAGS) \ -DHAVE_XGL_CONFIG_H \ -DHAVE_DIX_CONFIG_H \ $(XGLMODULES_CFLAGS) \ diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am index dbbcb0545..57e20102e 100644 --- a/hw/xwin/Makefile.am +++ b/hw/xwin/Makefile.am @@ -161,7 +161,7 @@ CLEANFILES = $(BUILT_SOURCES) AM_YFLAGS = -d AM_LFLAGS = -i -AM_CFLAGS = -DHAVE_XWIN_CONFIG_H \ +AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \ $(XWINMODULES_CFLAGS) dist_man1_MANS = XWin.man XWinrc.man From ec77a95a02329a2ee3a94d7de9d2a234aecb9ca0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 8 Nov 2006 21:36:35 -0800 Subject: [PATCH 028/109] Allow RandR objects to be created before the associated ScreenRec. xf86 drivers need to create RandR object in the PreInit stage, before the ScreenRec is allocated. Changing the RandR DIX code to permit this required the addition of functions that later associate the objects with the related screen. An additional change is that modes are now global, and no longer associated with a specific screen. This change actually makes mode management cleaner as there is no more per-screen list of modes to deal with. This changes the RandR 1.2 ABI/API for drivers. --- hw/xfree86/common/Makefile.am | 2 +- randr/mirandr.c | 13 ++- randr/randr.c | 4 - randr/randrstr.h | 36 ++++--- randr/rrcrtc.c | 170 ++++++++++++++++++++-------------- randr/rrinfo.c | 14 ++- randr/rrmode.c | 108 +++++++++++---------- randr/rroutput.c | 46 +++++---- randr/rrscreen.c | 32 +++++-- 9 files changed, 255 insertions(+), 170 deletions(-) diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am index 0e1582e69..35b22f007 100644 --- a/hw/xfree86/common/Makefile.am +++ b/hw/xfree86/common/Makefile.am @@ -51,7 +51,7 @@ sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \ xf86PciInfo.h xf86Priv.h xf86Privstr.h xf86Resources.h \ xf86cmap.h xf86fbman.h xf86str.h $(XISDKINCS) \ $(XVSDKINCS) atKeynames.h xf86Version.h xorgVersion.h \ - xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h + xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h xf86Keymap.h DISTCLEANFILES = xf86Build.h CLEANFILES = $(BUILT_SOURCES) diff --git a/randr/mirandr.c b/randr/mirandr.c index 11c299133..3f56fe42e 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -113,17 +113,24 @@ miRandRInit (ScreenPtr pScreen) modeInfo.height = pScreen->height; modeInfo.nameLength = strlen (name); - mode = RRModeGet (pScreen, &modeInfo, name); + mode = RRModeGet (&modeInfo, name); if (!mode) return FALSE; - crtc = RRCrtcCreate (pScreen, NULL); + crtc = RRCrtcCreate (NULL); if (!crtc) return FALSE; + if (!RRCrtcAttachScreen (crtc, pScreen)) + { + RRCrtcDestroy (crtc); + return FALSE; + } - output = RROutputCreate (pScreen, "screen", 6, NULL); + output = RROutputCreate ("screen", 6, NULL); if (!output) return FALSE; + if (!RROutputAttachScreen (output, pScreen)) + return FALSE; if (!RROutputSetClones (output, NULL, 0)) return FALSE; if (!RROutputSetModes (output, &mode, 1, 0)) diff --git a/randr/randr.c b/randr/randr.c index 7b39e8045..4426c4773 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -103,8 +103,6 @@ RRCloseScreen (int i, ScreenPtr pScreen) RRCrtcDestroy (pScrPriv->crtcs[j]); for (j = pScrPriv->numOutputs - 1; j >= 0; j--) RROutputDestroy (pScrPriv->outputs[j]); - for (j = pScrPriv->numModes - 1; j >= 0; j--) - RRModeDestroy (pScrPriv->modes[j]); xfree (pScrPriv); RRNScreens -= 1; /* ok, one fewer screen with RandR running */ @@ -257,8 +255,6 @@ Bool RRScreenInit(ScreenPtr pScreen) wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen); - pScrPriv->numModes = 0; - pScrPriv->modes = NULL; pScrPriv->numOutputs = 0; pScrPriv->outputs = NULL; pScrPriv->numCrtcs = 0; diff --git a/randr/randrstr.h b/randr/randrstr.h index 60877a3c1..345418b8f 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -79,7 +79,6 @@ struct _rrMode { xRRModeInfo mode; char *name; void *devPrivate; - ScreenPtr screen; Bool userDefined; }; @@ -210,10 +209,6 @@ typedef struct _rrScrPriv { CARD16 width, height; /* last known screen size */ Bool layoutChanged; /* screen layout changed */ - /* modes, outputs and crtcs */ - int numModes; - RRModePtr *modes; - int numOutputs; RROutputPtr *outputs; @@ -457,9 +452,16 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged); * Create a CRTC */ RRCrtcPtr -RRCrtcCreate (ScreenPtr pScreen, - void *devPrivate); +RRCrtcCreate (void *devPrivate); +/* + * Attach a CRTC to a screen. Once done, this cannot be + * undone without destroying the CRTC; it is separate from Create + * only to allow an xf86-based driver to create objects in preinit + */ +Bool +RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen); + /* * Notify the extension that the Crtc has been reconfigured, * the driver calls this whenever it has updated the mode @@ -556,8 +558,7 @@ RRClientKnowsRates (ClientPtr pClient); */ RRModePtr -RRModeGet (ScreenPtr pScreen, - xRRModeInfo *modeInfo, +RRModeGet (xRRModeInfo *modeInfo, const char *name); void @@ -570,6 +571,12 @@ RRModePruneUnused (ScreenPtr pScreen); void RRModeDestroy (RRModePtr mode); +/* + * Return a list of modes that are valid for some output in pScreen + */ +RRModePtr * +RRModesForScreen (ScreenPtr pScreen, int *num_ret); + /* * Initialize mode type */ @@ -601,11 +608,18 @@ RROutputChanged (RROutputPtr output); */ RROutputPtr -RROutputCreate (ScreenPtr pScreen, - const char *name, +RROutputCreate (const char *name, int nameLength, void *devPrivate); +/* + * Attach an output to a screen, again split from creation so + * xf86 DDXen can create randr resources before the ScreenRec + * exists + */ +Bool +RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen); + /* * Notify extension that output parameters have been changed */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 76d0b6bf5..9f7177a34 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -32,43 +32,34 @@ void RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) { ScreenPtr pScreen = crtc->pScreen; - rrScrPriv(pScreen); crtc->changed = TRUE; - pScrPriv->changed = TRUE; - /* - * Send ConfigureNotify on any layout change - */ - if (layoutChanged) - pScrPriv->layoutChanged = TRUE; + if (pScreen) + { + rrScrPriv(pScreen); + + pScrPriv->changed = TRUE; + /* + * Send ConfigureNotify on any layout change + */ + if (layoutChanged) + pScrPriv->layoutChanged = TRUE; + } } /* * Create a CRTC */ RRCrtcPtr -RRCrtcCreate (ScreenPtr pScreen, - void *devPrivate) +RRCrtcCreate (void *devPrivate) { - rrScrPriv (pScreen); RRCrtcPtr crtc; - RRCrtcPtr *crtcs; crtc = xalloc (sizeof (RRCrtcRec)); if (!crtc) return NULL; - if (pScrPriv->numCrtcs) - crtcs = xrealloc (pScrPriv->crtcs, - (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); - else - crtcs = xalloc (sizeof (RRCrtcPtr)); - if (!crtcs) - { - xfree (crtc); - return NULL; - } crtc->id = FakeClientID (0); - crtc->pScreen = pScreen; + crtc->pScreen = NULL; crtc->mode = NULL; crtc->x = 0; crtc->y = 0; @@ -84,11 +75,37 @@ RRCrtcCreate (ScreenPtr pScreen, if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) return NULL; + return crtc; +} + +/* + * Attach a Crtc to a screen. This is done as a separate step + * so that an xf86-based driver can create CRTCs in PreInit + * before the Screen has been created + */ + +Bool +RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + RRCrtcPtr *crtcs; + + /* make space for the crtc pointer */ + if (pScrPriv->numCrtcs) + crtcs = xrealloc (pScrPriv->crtcs, + (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); + else + crtcs = xalloc (sizeof (RRCrtcPtr)); + if (!crtcs) + return FALSE; + + /* attach the screen and crtc together */ + crtc->pScreen = pScreen; pScrPriv->crtcs = crtcs; pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; RRCrtcChanged (crtc, TRUE); - return crtc; + return TRUE; } /* @@ -243,7 +260,6 @@ RRCrtcSet (RRCrtcPtr crtc, RROutputConfigPtr outputs) { ScreenPtr pScreen = crtc->pScreen; - rrScrPriv(pScreen); /* See if nothing changed */ if (crtc->mode == mode && @@ -255,45 +271,49 @@ RRCrtcSet (RRCrtcPtr crtc, { return TRUE; } -#if RANDR_12_INTERFACE - if (pScrPriv->rrCrtcSet) + if (pScreen) { - return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, - rotation, numOutputs, outputs); - } +#if RANDR_12_INTERFACE + rrScrPriv(pScreen); + if (pScrPriv->rrCrtcSet) + { + return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, + rotation, numOutputs, outputs); + } #endif #if RANDR_10_INTERFACE - if (pScrPriv->rrSetConfig) - { - RRScreenSize size; - RRScreenRate rate; - Bool ret; + if (pScrPriv->rrSetConfig) + { + RRScreenSize size; + RRScreenRate rate; + Bool ret; - size.width = mode->mode.width; - size.height = mode->mode.height; - if (outputs[0].output->mmWidth && outputs[0].output->mmHeight) - { - size.mmWidth = outputs[0].output->mmWidth; - size.mmHeight = outputs[0].output->mmHeight; + size.width = mode->mode.width; + size.height = mode->mode.height; + if (outputs[0].output->mmWidth && outputs[0].output->mmHeight) + { + size.mmWidth = outputs[0].output->mmWidth; + size.mmHeight = outputs[0].output->mmHeight; + } + else + { + size.mmWidth = pScreen->mmWidth; + size.mmHeight = pScreen->mmHeight; + } + size.nRates = 1; + rate.rate = RRVerticalRefresh (&mode->mode); + size.pRates = &rate; + ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); + /* + * Old 1.0 interface tied screen size to mode size + */ + if (ret) + RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output); + return ret; } - else - { - size.mmWidth = pScreen->mmWidth; - size.mmHeight = pScreen->mmHeight; - } - size.nRates = 1; - rate.rate = RRVerticalRefresh (&mode->mode); - size.pRates = &rate; - ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); - /* - * Old 1.0 interface tied screen size to mode size - */ - if (ret) - RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output); - return ret; - } #endif - RRTellChanged (pScreen); + RRTellChanged (pScreen); + } return FALSE; } @@ -311,22 +331,26 @@ RRCrtcDestroyResource (pointer value, XID pid) { RRCrtcPtr crtc = (RRCrtcPtr) value; ScreenPtr pScreen = crtc->pScreen; - rrScrPriv(pScreen); - int i; - for (i = 0; i < pScrPriv->numCrtcs; i++) + if (pScreen) { - if (pScrPriv->crtcs[i] == crtc) + rrScrPriv(pScreen); + int i; + + for (i = 0; i < pScrPriv->numCrtcs; i++) { - memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, - (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); - --pScrPriv->numCrtcs; - break; + if (pScrPriv->crtcs[i] == crtc) + { + memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, + (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); + --pScrPriv->numCrtcs; + break; + } } } if (crtc->gammaRed) xfree (crtc->gammaRed); - xfree (value); + xfree (crtc); return 1; } @@ -343,15 +367,18 @@ RRCrtcGammaSet (RRCrtcPtr crtc, Bool ret = TRUE; #if RANDR_12_INTERFACE ScreenPtr pScreen = crtc->pScreen; - rrScrPriv(pScreen); #endif memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16)); memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16)); memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16)); #if RANDR_12_INTERFACE - if (pScrPriv->rrCrtcSetGamma) - ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc); + if (pScreen) + { + rrScrPriv(pScreen); + if (pScrPriv->rrCrtcSetGamma) + ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc); + } #endif return ret; } @@ -433,6 +460,9 @@ ProcRRGetCrtcInfo (ClientPtr client) if (!crtc) return RRErrorBase + BadRRCrtc; + /* All crtcs must be associated with screens before client + * requests are processed + */ pScreen = crtc->pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -589,7 +619,7 @@ ProcRRSetCrtcConfig (ClientPtr client) for (j = 0; j < outputs[i].output->numCrtcs; j++) if (outputs[i].output->crtcs[j] == crtc) break; - if (j == outputs[j].output->numCrtcs) + if (j == outputs[i].output->numCrtcs) { if (outputs) xfree (outputs); diff --git a/randr/rrinfo.c b/randr/rrinfo.c index e92caadfa..244b089f3 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -44,7 +44,7 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height * (CARD32) refresh); modeInfo.nameLength = strlen (name); - mode = RRModeGet (pScreen, &modeInfo, name); + mode = RRModeGet (&modeInfo, name); if (!mode) return NULL; for (i = 0; i < output->numModes; i++) @@ -90,12 +90,19 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) if (pScrPriv->numOutputs == 0 && pScrPriv->numCrtcs == 0) { - crtc = RRCrtcCreate (pScreen, NULL); + crtc = RRCrtcCreate (NULL); if (!crtc) return; - output = RROutputCreate (pScreen, "default", 7, NULL); + if (!RRCrtcAttachScreen (crtc, pScreen)) + { + RRCrtcDestroy (crtc); + return; + } + output = RROutputCreate ("default", 7, NULL); if (!output) return; + if (!RROutputAttachScreen (output, pScreen)) + return; RROutputSetCrtcs (output, &crtc, 1); RROutputSetCrtc (output, crtc); RROutputSetConnection (output, RR_Connected); @@ -206,7 +213,6 @@ RRGetInfo (ScreenPtr pScreen) if (pScrPriv->nSizes) RRScanOldConfig (pScreen, rotations); #endif - RRModePruneUnused (pScreen); RRTellChanged (pScreen); return TRUE; } diff --git a/randr/rrmode.c b/randr/rrmode.c index fb4b5eb1e..3cd9ef273 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -42,19 +42,23 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) return TRUE; } +/* + * Keep a list so it's easy to find modes in the resource database. + */ +static int num_modes; +static RRModePtr *modes; + RRModePtr -RRModeGet (ScreenPtr pScreen, - xRRModeInfo *modeInfo, +RRModeGet (xRRModeInfo *modeInfo, const char *name) { - rrScrPriv (pScreen); int i; RRModePtr mode; - RRModePtr *modes; + RRModePtr *newModes; - for (i = 0; i < pScrPriv->numModes; i++) + for (i = 0; i < num_modes; i++) { - mode = pScrPriv->modes[i]; + mode = modes[i]; if (RRModeEqual (&mode->mode, modeInfo) && !memcmp (name, mode->name, modeInfo->nameLength)) { @@ -71,16 +75,14 @@ RRModeGet (ScreenPtr pScreen, mode->name = (char *) (mode + 1); memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; - mode->screen = pScreen; mode->userDefined = FALSE; - if (pScrPriv->numModes) - modes = xrealloc (pScrPriv->modes, - (pScrPriv->numModes + 1) * sizeof (RRModePtr)); + if (num_modes) + newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr)); else - modes = xalloc (sizeof (RRModePtr)); + newModes = xalloc (sizeof (RRModePtr)); - if (!modes) + if (!newModes) { xfree (mode); return NULL; @@ -89,37 +91,64 @@ RRModeGet (ScreenPtr pScreen, mode->mode.id = FakeClientID(0); if (!AddResource (mode->mode.id, RRModeType, (pointer) mode)) return NULL; + modes = newModes; + modes[num_modes++] = mode; + + /* + * give the caller a reference to this mode + */ ++mode->refcnt; - pScrPriv->modes = modes; - pScrPriv->modes[pScrPriv->numModes++] = mode; - pScrPriv->changed = TRUE; return mode; } +RRModePtr * +RRModesForScreen (ScreenPtr pScreen, int *num_ret) +{ + rrScrPriv(pScreen); + int o; + RRModePtr *screen_modes; + int num_screen_modes = 0; + + screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr)); + + for (o = 0; o < pScrPriv->numOutputs; o++) + { + RROutputPtr output = pScrPriv->outputs[o]; + int m, n; + + for (m = 0; m < output->numModes; m++) + { + RRModePtr mode = output->modes[m]; + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } + } + *num_ret = num_screen_modes; + return screen_modes; +} + void RRModeDestroy (RRModePtr mode) { - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; int m; if (--mode->refcnt > 0) return; - pScreen = mode->screen; - pScrPriv = rrGetScrPriv (pScreen); - for (m = 0; m < pScrPriv->numModes; m++) + for (m = 0; m < num_modes; m++) { - if (pScrPriv->modes[m] == mode) + if (modes[m] == mode) { - memmove (pScrPriv->modes + m, pScrPriv->modes + m + 1, - (pScrPriv->numModes - m - 1) * sizeof (RRModePtr)); - pScrPriv->numModes--; - if (!pScrPriv->numModes) + memmove (modes + m, modes + m + 1, + (num_modes - m - 1) * sizeof (RRModePtr)); + num_modes--; + if (!num_modes) { - xfree (pScrPriv->modes); - pScrPriv->modes = NULL; + xfree (modes); + modes = NULL; } - pScrPriv->changed = TRUE; break; } } @@ -137,6 +166,8 @@ RRModeDestroyResource (pointer value, XID pid) Bool RRModeInit (void) { + assert (num_modes == 0); + assert (modes == NULL); RRModeType = CreateNewResourceType (RRModeDestroyResource); if (!RRModeType) return FALSE; @@ -146,26 +177,6 @@ RRModeInit (void) return TRUE; } -void -RRModePruneUnused (ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - RRModePtr *unused, mode; - int m; - int num = pScrPriv->numModes; - - unused = xalloc (num * sizeof (RRModePtr)); - if (!unused) - return; - memcpy (unused, pScrPriv->modes, num * sizeof (RRModePtr)); - for (m = 0; m < num; m++) { - mode = unused[m]; - if (mode->refcnt == 1 && !mode->userDefined) - FreeResource (mode->mode.id, 0); - } - xfree (unused); -} - int ProcRRCreateMode (ClientPtr client) { @@ -205,4 +216,3 @@ ProcRRDeleteOutputMode (ClientPtr client) (void) stuff; return BadImplementation; } - diff --git a/randr/rroutput.c b/randr/rroutput.c index 1f6f33030..1b0ecab93 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -42,30 +42,17 @@ RROutputChanged (RROutputPtr output) */ RROutputPtr -RROutputCreate (ScreenPtr pScreen, - const char *name, +RROutputCreate (const char *name, int nameLength, void *devPrivate) { - rrScrPriv (pScreen); RROutputPtr output; - RROutputPtr *outputs; output = xalloc (sizeof (RROutputRec) + nameLength + 1); if (!output) return NULL; - if (pScrPriv->numOutputs) - outputs = xrealloc (pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); - else - outputs = xalloc (sizeof (RROutputPtr)); - if (!outputs) - { - xfree (output); - return NULL; - } output->id = FakeClientID (0); - output->pScreen = pScreen; + output->pScreen = NULL; output->name = (char *) (output + 1); output->nameLength = nameLength; memcpy (output->name, name, nameLength); @@ -91,12 +78,35 @@ RROutputCreate (ScreenPtr pScreen, if (!AddResource (output->id, RROutputType, (pointer) output)) return NULL; - pScrPriv->outputs = outputs; - pScrPriv->outputs[pScrPriv->numOutputs++] = output; - RROutputChanged (output); return output; } +/* + * Attach an Output to a screen. This is done as a separate step + * so that an xf86-based driver can create Outputs in PreInit + * before the Screen has been created + */ + +Bool +RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + RROutputPtr *outputs; + + if (pScrPriv->numOutputs) + outputs = xrealloc (pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + else + outputs = xalloc (sizeof (RROutputPtr)); + if (!outputs) + return FALSE; + output->pScreen = pScreen; + pScrPriv->outputs = outputs; + pScrPriv->outputs[pScrPriv->numOutputs++] = output; + RROutputChanged (output); + return TRUE; +} + /* * Notify extension that output parameters have been changed */ diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 705e7d78c..d47e9d60a 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -360,6 +360,13 @@ ProcRRGetScreenResources (ClientPtr client) } else { + RRModePtr *modes; + int num_modes; + + modes = RRModesForScreen (pScreen, &num_modes); + if (!modes) + return BadAlloc; + rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; @@ -367,15 +374,15 @@ ProcRRGetScreenResources (ClientPtr client) rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; rep.nCrtcs = pScrPriv->numCrtcs; rep.nOutputs = pScrPriv->numOutputs; - rep.nModes = pScrPriv->numModes;; + rep.nModes = num_modes; rep.nbytesNames = 0; - for (i = 0; i < pScrPriv->numModes; i++) - rep.nbytesNames += pScrPriv->modes[i]->mode.nameLength; + for (i = 0; i < num_modes; i++) + rep.nbytesNames += modes[i]->mode.nameLength; rep.length = (pScrPriv->numCrtcs + pScrPriv->numOutputs + - pScrPriv->numModes * (SIZEOF(xRRModeInfo) >> 2) + + num_modes * (SIZEOF(xRRModeInfo) >> 2) + ((rep.nbytesNames + 3) >> 2)); extraLen = rep.length << 2; @@ -383,7 +390,10 @@ ProcRRGetScreenResources (ClientPtr client) { extra = xalloc (extraLen); if (!extra) + { + xfree (modes); return BadAlloc; + } } else extra = NULL; @@ -391,7 +401,7 @@ ProcRRGetScreenResources (ClientPtr client) crtcs = (RRCrtc *) extra; outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); - names = (CARD8 *) (modeinfos + pScrPriv->numModes); + names = (CARD8 *) (modeinfos + num_modes); for (i = 0; i < pScrPriv->numCrtcs; i++) { @@ -407,9 +417,10 @@ ProcRRGetScreenResources (ClientPtr client) swapl (&outputs[i], n); } - for (i = 0; i < pScrPriv->numModes; i++) + for (i = 0; i < num_modes; i++) { - modeinfos[i] = pScrPriv->modes[i]->mode; + RRModePtr mode = modes[i]; + modeinfos[i] = mode->mode; if (client->swapped) { swapl (&modeinfos[i].id, n); @@ -426,10 +437,11 @@ ProcRRGetScreenResources (ClientPtr client) swaps (&modeinfos[i].nameLength, n); swapl (&modeinfos[i].modeFlags, n); } - memcpy (names, pScrPriv->modes[i]->name, - pScrPriv->modes[i]->mode.nameLength); - names += pScrPriv->modes[i]->mode.nameLength; + memcpy (names, mode->name, + mode->mode.nameLength); + names += mode->mode.nameLength; } + xfree (modes); assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length); } From 0dee48b8af3e054228aef0d15c1cb1c9e23790cc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 8 Nov 2006 23:17:55 -0800 Subject: [PATCH 029/109] Add RRInit function to create resource types for RR objects. To allow RandR objects to be created before the screen object exists, the resource types must be registered with the resource database. A driver wishing to create RandR objects must call RRInit before doing so. Also, fix a segfault when setting Output data before it is associated with a screen. --- randr/randr.c | 27 +++++++++++++++++++++------ randr/randrstr.h | 2 ++ randr/rroutput.c | 30 ++++++++++++++++++------------ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 4426c4773..147df8c2c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -39,8 +39,7 @@ #endif #define RR_VALIDATE -int RRGeneration; -int RRNScreens; +static int RRNScreens; #define wrap(priv,real,mem,func) {\ priv->mem = real->mem; \ @@ -198,10 +197,10 @@ SRRNotifyEvent (xEvent *from, } } -Bool RRScreenInit(ScreenPtr pScreen) -{ - rrScrPrivPtr pScrPriv; +static int RRGeneration; +Bool RRInit (void) +{ if (RRGeneration != serverGeneration) { if (!RRModeInit ()) @@ -210,9 +209,25 @@ Bool RRScreenInit(ScreenPtr pScreen) return FALSE; if (!RROutputInit ()) return FALSE; + RRGeneration = serverGeneration; + } + return TRUE; +} + +static int RRScreenGeneration; + +Bool RRScreenInit(ScreenPtr pScreen) +{ + rrScrPrivPtr pScrPriv; + + if (!RRInit ()) + return FALSE; + + if (RRScreenGeneration != serverGeneration) + { if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0) return FALSE; - RRGeneration = serverGeneration; + RRScreenGeneration = serverGeneration; } pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec)); diff --git a/randr/randrstr.h b/randr/randrstr.h index 345418b8f..2c3e0e71c 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -384,6 +384,8 @@ RRTellChanged (ScreenPtr pScreen); Bool RRGetInfo (ScreenPtr pScreen); +Bool RRInit (void); + Bool RRScreenInit(ScreenPtr pScreen); RROutputPtr diff --git a/randr/rroutput.c b/randr/rroutput.c index 1b0ecab93..102587b50 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -31,10 +31,13 @@ void RROutputChanged (RROutputPtr output) { ScreenPtr pScreen = output->pScreen; - rrScrPriv (pScreen); - + output->changed = TRUE; - pScrPriv->changed = TRUE; + if (pScreen) + { + rrScrPriv (pScreen); + pScrPriv->changed = TRUE; + } } /* @@ -335,17 +338,21 @@ RROutputDestroyResource (pointer value, XID pid) { RROutputPtr output = (RROutputPtr) value; ScreenPtr pScreen = output->pScreen; - rrScrPriv(pScreen); - int i; - for (i = 0; i < pScrPriv->numOutputs; i++) + if (pScreen) { - if (pScrPriv->outputs[i] == output) + rrScrPriv(pScreen); + int i; + + for (i = 0; i < pScrPriv->numOutputs; i++) { - memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, - (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr)); - --pScrPriv->numOutputs; - break; + if (pScrPriv->outputs[i] == output) + { + memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, + (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr)); + --pScrPriv->numOutputs; + break; + } } } if (output->modes) @@ -481,4 +488,3 @@ ProcRRGetOutputInfo (ClientPtr client) return client->noClientException; } - From 6ff7f2ad6a5e2e769244590578e6809974b5235d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 7 Nov 2006 13:13:53 -0800 Subject: [PATCH 030/109] Fix build on FreeBSD after input-hotplug. (cherry picked from commit 4e6e4baead6c565363abbcd9e06cc685be121596) --- hw/xfree86/os-support/bsd/bsd_bell.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c index 60c2ffc8b..b7a0c486e 100644 --- a/hw/xfree86/os-support/bsd/bsd_bell.c +++ b/hw/xfree86/os-support/bsd/bsd_bell.c @@ -27,10 +27,15 @@ #include #endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) +#include +#endif + #include #include "xf86.h" #include "xf86Priv.h" +#include "xf86_OSlib.h" #ifdef WSCONS_SUPPORT #define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd) From ae3c9ad4abe66784d7ee474455003d2745699286 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Thu, 16 Nov 2006 17:29:06 +0100 Subject: [PATCH 031/109] Bug 9041: Check the return code in xf86MapDomainMemory(). --- hw/xfree86/os-support/bus/linuxPci.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 15fc2b8c7..03388f1ff 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -683,28 +683,28 @@ xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, ADDRESS Base, unsigned long Size) { int domain = xf86GetPciDomain(Tag); - int fd; + int fd = -1; pointer addr; /* * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs * legacy_mem interface is unavailable. */ - if (Base > 1024*1024) - return linuxMapPci(ScreenNum, Flags, Tag, Base, Size, + if (Base >= 1024*1024) + addr = linuxMapPci(ScreenNum, Flags, Tag, Base, Size, PCIIOC_MMAP_IS_MEM); - - if ((fd = linuxOpenLegacy(Tag, "legacy_mem")) < 0) - return linuxMapPci(ScreenNum, Flags, Tag, Base, Size, + else if ((fd = linuxOpenLegacy(Tag, "legacy_mem")) < 0) + addr = linuxMapPci(ScreenNum, Flags, Tag, Base, Size, PCIIOC_MMAP_IS_MEM); + else + addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); - addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); - if (addr == MAP_FAILED) { - close (fd); + if (fd >= 0) + close(fd); + if (addr == NULL || addr == MAP_FAILED) { perror("mmap failure"); FatalError("xf86MapDomainMem(): mmap() failure\n"); } - close(fd); return addr; } From f17e3c34dfd1f1418440bdebf45764e4dbf550f0 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 16 Nov 2006 02:18:03 +0200 Subject: [PATCH 032/109] Fix GL context destruction with AIGLX. The logic for freeing GL contexts introduced by "Fix AIGLX VT switching." is inverted. As it is now, GL context destruction is deferred for glxDRIEnterVT(). --- GL/glx/glxext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c index 11fb7fcaf..1f6c7f376 100644 --- a/GL/glx/glxext.c +++ b/GL/glx/glxext.c @@ -237,7 +237,7 @@ GLboolean __glXFreeContext(__GLXcontext *cx) * __glXDispatch() or as a callback from the resource manager. In * the latter case we need to lift the DRI lock manually. */ - if (glxBlockClients) { + if (!glxBlockClients) { __glXleaveServer(); cx->destroy(cx); __glXenterServer(); From 07b26e690cd9a4fc626132feed0702515cbe5a88 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 16 Nov 2006 09:48:33 -0800 Subject: [PATCH 033/109] Remove RandR output options. RandR output options are now expected to be handled by properties instead. (cherry picked from commit 8b2a7e94a1dc2776ab2cfaaebb309be02502602a) --- randr/mirandr.c | 6 +----- randr/randrstr.h | 24 +++--------------------- randr/rrcrtc.c | 46 +++++++++++++++++++--------------------------- randr/rroutput.c | 29 ----------------------------- randr/rrscreen.c | 13 ++++++------- 5 files changed, 29 insertions(+), 89 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 3f56fe42e..3a99bf9ed 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -52,7 +52,7 @@ miRRCrtcSet (ScreenPtr pScreen, int y, Rotation rotation, int numOutput, - RROutputConfigPtr outputs) + RROutputPtr *outputs) { return TRUE; } @@ -137,10 +137,6 @@ miRandRInit (ScreenPtr pScreen) return FALSE; if (!RROutputSetCrtcs (output, &crtc, 1)) return FALSE; - if (!RROutputSetPossibleOptions (output, 0)) - return FALSE; - if (!RROutputSetCurrentOptions (output, 0)) - return FALSE; if (!RROutputSetConnection (output, RR_Connected)) return FALSE; RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output); diff --git a/randr/randrstr.h b/randr/randrstr.h index 2c3e0e71c..19af9b979 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -72,7 +72,6 @@ extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr); typedef struct _rrMode RRModeRec, *RRModePtr; typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; typedef struct _rrOutput RROutputRec, *RROutputPtr; -typedef struct _rrOutputConfig RROutputConfigRec, *RROutputConfigPtr; struct _rrMode { int refcnt; @@ -109,8 +108,6 @@ struct _rrOutput { int mmWidth; int mmHeight; RRCrtcPtr crtc; - CARD32 currentOptions; - CARD32 possibleOptions; int numCrtcs; RRCrtcPtr *crtcs; int numClones; @@ -123,11 +120,6 @@ struct _rrOutput { void *devPrivate; }; -struct _rrOutputConfig { - RROutputPtr output; - CARD32 options; -}; - #if RANDR_12_INTERFACE typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, CARD16 width, @@ -142,7 +134,7 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, int y, Rotation rotation, int numOutputs, - RROutputConfigPtr outputs); + RROutputPtr *outputs); typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); @@ -369,7 +361,7 @@ miRRCrtcSet (ScreenPtr pScreen, int y, Rotation rotation, int numOutput, - RROutputConfigPtr outputs); + RROutputPtr *outputs); /* randr.c */ /* @@ -490,7 +482,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y, Rotation rotation, int numOutput, - RROutputConfigPtr outputs); + RROutputPtr *outputs); /* * Request that the Crtc gamma be changed @@ -641,10 +633,6 @@ RROutputSetCrtcs (RROutputPtr output, RRCrtcPtr *crtcs, int numCrtcs); -Bool -RROutputSetPossibleOptions (RROutputPtr output, - CARD32 possibleOptions); - void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc); @@ -656,10 +644,6 @@ Bool RROutputSetSubpixelOrder (RROutputPtr output, int subpixelOrder); -Bool -RROutputSetCurrentOptions (RROutputPtr output, - CARD32 currentOptions); - Bool RROutputSetPhysicalSize (RROutputPtr output, int mmWidth, @@ -739,8 +723,6 @@ Query state: RRScreenSetSizeRange RROutputSetCrtcs RROutputSetCrtc - RROutputSetPossibleOptions - RRSetCurrentOptions RRModeGet RROutputSetModes RROutputSetConnection diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 9f7177a34..c945468bf 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -257,7 +257,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y, Rotation rotation, int numOutputs, - RROutputConfigPtr outputs) + RROutputPtr *outputs) { ScreenPtr pScreen = crtc->pScreen; @@ -290,10 +290,10 @@ RRCrtcSet (RRCrtcPtr crtc, size.width = mode->mode.width; size.height = mode->mode.height; - if (outputs[0].output->mmWidth && outputs[0].output->mmHeight) + if (outputs[0]->mmWidth && outputs[0]->mmHeight) { - size.mmWidth = outputs[0].output->mmWidth; - size.mmHeight = outputs[0].output->mmHeight; + size.mmWidth = outputs[0]->mmWidth; + size.mmHeight = outputs[0]->mmHeight; } else { @@ -308,7 +308,7 @@ RRCrtcSet (RRCrtcPtr crtc, * Old 1.0 interface tied screen size to mode size */ if (ret) - RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output); + RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs); return ret; } #endif @@ -554,15 +554,15 @@ ProcRRSetCrtcConfig (ClientPtr client) RRCrtcPtr crtc; RRModePtr mode; int numOutputs; - RROutputConfigPtr outputs = NULL; - xRROutputConfig *outputConfigs; + RROutputPtr *outputs = NULL; + RROutput *outputIds; TimeStamp configTime; TimeStamp time; Rotation rotation; int i, j; REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2)) >> 1; + numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2)); crtc = LookupIDByType (stuff->crtc, RRCrtcType); if (!crtc) @@ -589,47 +589,39 @@ ProcRRSetCrtcConfig (ClientPtr client) } if (numOutputs) { - outputs = xalloc (numOutputs * sizeof (RROutputConfigRec)); + outputs = xalloc (numOutputs * sizeof (RROutputPtr)); if (!outputs) return BadAlloc; } else outputs = NULL; - outputConfigs = (xRROutputConfig *) (stuff + 1); + outputIds = (RROutput *) (stuff + 1); for (i = 0; i < numOutputs; i++) { - outputs[i].output = LookupIDByType (outputConfigs[i].output, RROutputType); - if (!outputs[i].output) + outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType); + if (!outputs[i]) { - client->errorValue = outputConfigs[i].output; + client->errorValue = outputIds[i]; if (outputs) xfree (outputs); return RRErrorBase + BadRROutput; } - outputs[i].options = outputConfigs[i].options; - if (outputs[i].options & ~outputs[i].output->possibleOptions) - { - client->errorValue = outputConfigs[i].options; - if (outputs) - xfree (outputs); - return BadMatch; - } /* validate crtc for this output */ - for (j = 0; j < outputs[i].output->numCrtcs; j++) - if (outputs[i].output->crtcs[j] == crtc) + for (j = 0; j < outputs[i]->numCrtcs; j++) + if (outputs[i]->crtcs[j] == crtc) break; - if (j == outputs[i].output->numCrtcs) + if (j == outputs[i]->numCrtcs) { if (outputs) xfree (outputs); return BadMatch; } /* validate mode for this output */ - for (j = 0; j < outputs[i].output->numModes; j++) - if (outputs[i].output->modes[j] == mode) + for (j = 0; j < outputs[i]->numModes; j++) + if (outputs[i]->modes[j] == mode) break; - if (j == outputs[i].output->numModes) + if (j == outputs[i]->numModes) { if (outputs) xfree (outputs); diff --git a/randr/rroutput.c b/randr/rroutput.c index 102587b50..8b760ec9a 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -65,8 +65,6 @@ RROutputCreate (const char *name, output->mmWidth = 0; output->mmHeight = 0; output->crtc = NULL; - output->currentOptions = 0; - output->possibleOptions = 0; output->numCrtcs = 0; output->crtcs = NULL; output->numClones = 0; @@ -223,17 +221,6 @@ RROutputSetCrtcs (RROutputPtr output, return TRUE; } -Bool -RROutputSetPossibleOptions (RROutputPtr output, - CARD32 possibleOptions) -{ - if (output->possibleOptions == possibleOptions) - return TRUE; - output->possibleOptions = possibleOptions; - RROutputChanged (output); - return TRUE; -} - void RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) { @@ -266,17 +253,6 @@ RROutputSetSubpixelOrder (RROutputPtr output, return TRUE; } -Bool -RROutputSetCurrentOptions (RROutputPtr output, - CARD32 currentOptions) -{ - if (output->currentOptions == currentOptions) - return TRUE; - output->currentOptions = currentOptions; - RROutputChanged (output); - return TRUE; -} - Bool RROutputSetPhysicalSize (RROutputPtr output, int mmWidth, @@ -413,7 +389,6 @@ ProcRRGetOutputInfo (ClientPtr client) rep.length = OutputInfoExtra >> 2; rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.crtc = output->crtc ? output->crtc->id : None; - rep.currentOptions = output->currentOptions; rep.mmWidth = output->mmWidth; rep.mmHeight = output->mmHeight; rep.connection = output->connection; @@ -423,7 +398,6 @@ ProcRRGetOutputInfo (ClientPtr client) rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; - rep.possibleOptions = output->possibleOptions; extraLen = ((output->numCrtcs + output->numModes + @@ -469,15 +443,12 @@ ProcRRGetOutputInfo (ClientPtr client) swapl(&rep.length, n); swapl(&rep.timestamp, n); swapl(&rep.crtc, n); - swapl(&rep.currentOptions, n); swapl(&rep.mmWidth, n); swapl(&rep.mmHeight, n); swaps(&rep.nCrtcs, n); swaps(&rep.nModes, n); swaps(&rep.nClones, n); - swapl(&rep.possibleOptions, n); swaps(&rep.nameLength, n); - swapl(&rep.possibleOptions, n); } WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); if (extraLen) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index d47e9d60a..76c16b010 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -712,7 +712,7 @@ ProcRRSetScreenConfig (ClientPtr client) Rotation rotation; int rate; Bool has_rate; - RROutputConfigRec output; + RROutputPtr output; RRModePtr mode; RR10DataPtr pData = NULL; RRScreenSizePtr pSize; @@ -749,14 +749,13 @@ ProcRRSetScreenConfig (ClientPtr client) if (!RRGetInfo (pScreen)) return BadAlloc; - output.output = RRFirstOutput (pScreen); - if (!output.output) + output = RRFirstOutput (pScreen); + if (!output) { time = currentTime; rep.status = RRSetConfigFailed; goto sendReply; } - output.options = output.output->currentOptions; /* * if the client's config timestamp is not the same as the last config @@ -769,7 +768,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } - pData = RR10GetData (pScreen, output.output); + pData = RR10GetData (pScreen, output); if (!pData) return BadAlloc; @@ -805,7 +804,7 @@ ProcRRSetScreenConfig (ClientPtr client) return BadValue; } - if ((~output.output->crtc->rotations) & rotation) + if ((~output->crtc->rotations) & rotation) { /* * requested rotation or reflection not supported by screen @@ -878,7 +877,7 @@ ProcRRSetScreenConfig (ClientPtr client) } } - rep.status = RRCrtcSet (output.output->crtc, mode, 0, 0, stuff->rotation, + rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, 1, &output); /* From ef47d9c3ba63e9a6243fe5c81ccc60c8246352b4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 16 Nov 2006 13:50:48 -0800 Subject: [PATCH 034/109] Reduce calls to RRGetInfo. RRGetInfo can be expensive. Don't invoke it when quering Xinerama information or setting a new CRTC configuration. (cherry picked from commit b5aa9eb8e6eda36856a075f4b008c33f6c706bad) --- randr/rrcrtc.c | 7 ------- randr/rrxinerama.c | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index c945468bf..b81c390f1 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -632,13 +632,6 @@ ProcRRSetCrtcConfig (ClientPtr client) pScreen = crtc->pScreen; pScrPriv = rrGetScrPriv(pScreen); - if (!RRGetInfo (pScreen)) - { - if (outputs) - xfree (outputs); - return BadAlloc; - } - time = ClientTimeToServerTime(stuff->timestamp); configTime = ClientTimeToServerTime(stuff->configTimestamp); diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c index a8e4b390b..771ed0976 100644 --- a/randr/rrxinerama.c +++ b/randr/rrxinerama.c @@ -260,7 +260,11 @@ ProcRRXineramaQueryScreens(ClientPtr client) REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); if (RRXineramaScreenActive (pScreen)) - RRGetInfo (pScreen); + { + rrScrPriv(pScreen); + if (pScrPriv->numCrtcs == 0 || pScrPriv->numOutputs == 0) + RRGetInfo (pScreen); + } rep.type = X_Reply; rep.sequenceNumber = client->sequence; From e2f6dacc736527790ed8e304698678afc17f71c6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 18 Nov 2006 11:26:55 +1100 Subject: [PATCH 035/109] dri: setup libdrm hooks as early as possible. This is due to radeon doing drm stuff before DRI extension gets initialised --- hw/xfree86/dri/dri.c | 6 ++---- hw/xfree86/dri/drimodule.c | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index a49c63212..5337f9a4a 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -84,7 +84,7 @@ static RESTYPE DRIDrawablePrivResType; static RESTYPE DRIContextPrivResType; static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv); -static drmServerInfo DRIDRMServerInfo; +drmServerInfo DRIDRMServerInfo; /* Wrapper just like xf86DrvMsg, but without the verbosity level checking. @@ -176,8 +176,6 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) else openbusid = NULL; - drmSetServerInfo(&DRIDRMServerInfo); - /* Note that drmOpen will try to load the kernel module, if needed. */ fd = drmOpen(pDRIInfo->drmDriverName, openbusid); if (fd < 0) { @@ -593,7 +591,7 @@ static void dri_drm_get_perms(gid_t *group, mode_t *mode) *mode = xf86ConfigDRI.mode; } -static drmServerInfo DRIDRMServerInfo = { +drmServerInfo DRIDRMServerInfo = { dri_drm_debug_print, xf86LoadKernelModule, dri_drm_get_perms, diff --git a/hw/xfree86/dri/drimodule.c b/hw/xfree86/dri/drimodule.c index b39c22e11..0e3d84eb8 100644 --- a/hw/xfree86/dri/drimodule.c +++ b/hw/xfree86/dri/drimodule.c @@ -39,8 +39,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86Module.h" #include "globals.h" +#include "xf86drm.h" static MODULESETUPPROTO(driSetup); +drmServerInfo DRIDRMServerInfo; + static XF86ModuleVersionInfo VersRec = { "dri", @@ -81,6 +84,9 @@ driSetup(pointer module, pointer opts, int *errmaj, int *errmin) } else { if (errmaj) *errmaj = LDR_ONCEONLY; } + + drmSetServerInfo(&DRIDRMServerInfo); + /* Need a non-NULL return value to indicate success */ return 1; } From c9a5f9d3911c2e6a8f81b0721c9eb914fb7719b5 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Sat, 18 Nov 2006 19:55:42 +0000 Subject: [PATCH 036/109] Shutdown input devices if FatalError occurs during startup. Fixes Xdmx problems when the input device has been initialized and the keyboard map has been destroyed. --- dix/main.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dix/main.c b/dix/main.c index 88d775571..bee5490fd 100644 --- a/dix/main.c +++ b/dix/main.c @@ -414,21 +414,27 @@ main(int argc, char *argv[], char *envp[]) ErrorF("failed to set default font path '%s'", defaultFontPath); } - if (!SetDefaultFont(defaultTextFont)) + if (!SetDefaultFont(defaultTextFont)) { + CloseDownDevices(); FatalError("could not open default font '%s'", defaultTextFont); + } #ifdef NULL_ROOT_CURSOR cm.width = 0; cm.height = 0; cm.xhot = 0; cm.yhot = 0; - if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0))) + if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0))) { + CloseDownDevices(); FatalError("could not create empty root cursor"); + } AddResource(FakeClientID(0), RT_CURSOR, (pointer)rootCursor); #else - if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) + if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) { + CloseDownDevices(); FatalError("could not open default cursor font '%s'", defaultCursorFont); + } #endif #ifdef DPMSExtension /* check all screens, looking for DPMS Capabilities */ @@ -452,13 +458,17 @@ main(int argc, char *argv[], char *envp[]) #ifdef PANORAMIX if (!noPanoramiXExtension) { - if (!PanoramiXCreateConnectionBlock()) + if (!PanoramiXCreateConnectionBlock()) { + CloseDownDevices(); FatalError("could not create connection block info"); + } } else #endif { - if (!CreateConnectionBlock()) + if (!CreateConnectionBlock()) { + CloseDownDevices(); FatalError("could not create connection block info"); + } } Dispatch(); From 33ff4cec5ff7533ec725f71d357c096dfb0acb79 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 21 Nov 2006 21:23:17 +0000 Subject: [PATCH 037/109] Issue CloseDownDevices() in os/log.c and remove from dix/main.c. This ensures that all calls to FatalError() will shutdown the input devices. --- dix/main.c | 5 ----- os/log.c | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dix/main.c b/dix/main.c index bee5490fd..077fdea04 100644 --- a/dix/main.c +++ b/dix/main.c @@ -415,7 +415,6 @@ main(int argc, char *argv[], char *envp[]) defaultFontPath); } if (!SetDefaultFont(defaultTextFont)) { - CloseDownDevices(); FatalError("could not open default font '%s'", defaultTextFont); } #ifdef NULL_ROOT_CURSOR @@ -425,13 +424,11 @@ main(int argc, char *argv[], char *envp[]) cm.yhot = 0; if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0))) { - CloseDownDevices(); FatalError("could not create empty root cursor"); } AddResource(FakeClientID(0), RT_CURSOR, (pointer)rootCursor); #else if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) { - CloseDownDevices(); FatalError("could not open default cursor font '%s'", defaultCursorFont); } @@ -459,14 +456,12 @@ main(int argc, char *argv[], char *envp[]) #ifdef PANORAMIX if (!noPanoramiXExtension) { if (!PanoramiXCreateConnectionBlock()) { - CloseDownDevices(); FatalError("could not create connection block info"); } } else #endif { if (!CreateConnectionBlock()) { - CloseDownDevices(); FatalError("could not create connection block info"); } } diff --git a/os/log.c b/os/log.c index 05e542f08..b1d628c3f 100644 --- a/os/log.c +++ b/os/log.c @@ -89,6 +89,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include /* for malloc() */ #include +#include "input.h" #include "site.h" #include "opaque.h" @@ -404,6 +405,7 @@ void AbortServer(void) { OsCleanup(TRUE); + CloseDownDevices(); AbortDDX(); fflush(stderr); if (CoreDump) From 61863f09d22935406371e92bb75173d55ff9b29f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 22 Nov 2006 09:16:17 -0700 Subject: [PATCH 038/109] Regenerated from Mesa, fixes glMap* protocol problem (bug 8899) --- GL/glx/indirect_table.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GL/glx/indirect_table.c b/GL/glx/indirect_table.c index a6fd3a39a..60d676064 100644 --- a/GL/glx/indirect_table.c +++ b/GL/glx/indirect_table.c @@ -645,7 +645,7 @@ static const void *Render_function_table[400][2] = { /* [ 302] = 4182 */ {__glXDisp_RequestResidentProgramsNV, __glXDispSwap_RequestResidentProgramsNV}, /* [ 303] = 4183 */ {__glXDisp_LoadProgramNV, __glXDispSwap_LoadProgramNV}, /* [ 304] = 4184 */ {__glXDisp_ProgramParameter4fvNV, __glXDispSwap_ProgramParameter4fvNV}, - /* [ 305] = 4185 */ {__glXDisp_ProgramParameter4dvNV, __glXDispSwap_ProgramParameter4dvNV}, + /* [ 305] = 4185 */ {__glXDisp_ProgramEnvParameter4dvARB, __glXDispSwap_ProgramEnvParameter4dvARB}, /* [ 306] = 4186 */ {__glXDisp_ProgramParameters4fvNV, __glXDispSwap_ProgramParameters4fvNV}, /* [ 307] = 4187 */ {__glXDisp_ProgramParameters4dvNV, __glXDispSwap_ProgramParameters4dvNV}, /* [ 308] = 4188 */ {__glXDisp_TrackMatrixNV, __glXDispSwap_TrackMatrixNV}, @@ -886,10 +886,10 @@ static const int_fast16_t Render_size_table[400][2] = { /* [140] = 140 */ { 0, ~0}, /* [141] = 141 */ { 4, ~0}, /* [142] = 142 */ { 8, ~0}, - /* [143] = 143 */ { 40, 20}, - /* [144] = 144 */ { 28, 21}, - /* [145] = 145 */ { 64, 22}, - /* [146] = 146 */ { 44, 23}, + /* [143] = 143 */ { 28, 20}, + /* [144] = 144 */ { 20, 21}, + /* [145] = 145 */ { 48, 22}, + /* [146] = 146 */ { 32, 23}, /* [147] = 147 */ { 24, ~0}, /* [148] = 148 */ { 16, ~0}, /* [149] = 149 */ { 44, ~0}, From 61832cb94c8a4d62cddb92188caeed86519e9d62 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 22 Nov 2006 09:16:43 -0700 Subject: [PATCH 039/109] Regenerated from Mesa w/ latest gl_API.xml file --- GL/glx/indirect_dispatch.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/GL/glx/indirect_dispatch.h b/GL/glx/indirect_dispatch.h index 9bf74ebd1..17a372f91 100644 --- a/GL/glx/indirect_dispatch.h +++ b/GL/glx/indirect_dispatch.h @@ -85,8 +85,6 @@ extern HIDDEN void __glXDisp_EvalCoord2fv(GLbyte * pc); extern HIDDEN void __glXDispSwap_EvalCoord2fv(GLbyte * pc); extern HIDDEN int __glXDisp_DestroyPixmap(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDispSwap_DestroyPixmap(struct __GLXclientStateRec *, GLbyte *); -extern HIDDEN void __glXDisp_ProgramEnvParameter4dvARB(GLbyte * pc); -extern HIDDEN void __glXDispSwap_ProgramEnvParameter4dvARB(GLbyte * pc); extern HIDDEN int __glXDisp_GetMapiv(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDispSwap_GetMapiv(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDisp_SwapBuffers(struct __GLXclientStateRec *, GLbyte *); @@ -123,6 +121,8 @@ extern HIDDEN int __glXDisp_VendorPrivate(struct __GLXclientStateRec *, GLbyte * extern HIDDEN int __glXDispSwap_VendorPrivate(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDisp_CreateGLXPixmapWithConfigSGIX(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(struct __GLXclientStateRec *, GLbyte *); +extern HIDDEN void __glXDisp_VertexAttrib1fvNV(GLbyte * pc); +extern HIDDEN void __glXDispSwap_VertexAttrib1fvNV(GLbyte * pc); extern HIDDEN void __glXDisp_Vertex3iv(GLbyte * pc); extern HIDDEN void __glXDispSwap_Vertex3iv(GLbyte * pc); extern HIDDEN void __glXDisp_CopyConvolutionFilter1D(GLbyte * pc); @@ -279,6 +279,8 @@ extern HIDDEN void __glXDisp_ClearStencil(GLbyte * pc); extern HIDDEN void __glXDispSwap_ClearStencil(GLbyte * pc); extern HIDDEN void __glXDisp_VertexAttrib3dvARB(GLbyte * pc); extern HIDDEN void __glXDispSwap_VertexAttrib3dvARB(GLbyte * pc); +extern HIDDEN void __glXDisp_VertexAttribs4ubvNV(GLbyte * pc); +extern HIDDEN void __glXDispSwap_VertexAttribs4ubvNV(GLbyte * pc); extern HIDDEN void __glXDisp_ConvolutionParameteriv(GLbyte * pc); extern HIDDEN void __glXDispSwap_ConvolutionParameteriv(GLbyte * pc); extern HIDDEN void __glXDisp_RasterPos2fv(GLbyte * pc); @@ -327,6 +329,8 @@ extern HIDDEN int __glXDisp_GetVertexAttribdvNV(struct __GLXclientStateRec *, GL extern HIDDEN int __glXDispSwap_GetVertexAttribdvNV(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN void __glXDisp_Normal3fv(GLbyte * pc); extern HIDDEN void __glXDispSwap_Normal3fv(GLbyte * pc); +extern HIDDEN void __glXDisp_ProgramEnvParameter4dvARB(GLbyte * pc); +extern HIDDEN void __glXDispSwap_ProgramEnvParameter4dvARB(GLbyte * pc); extern HIDDEN void __glXDisp_VertexAttrib4ivARB(GLbyte * pc); extern HIDDEN void __glXDispSwap_VertexAttrib4ivARB(GLbyte * pc); extern HIDDEN void __glXDisp_End(GLbyte * pc); @@ -457,8 +461,6 @@ extern HIDDEN void __glXDisp_BindFramebufferEXT(GLbyte * pc); extern HIDDEN void __glXDispSwap_BindFramebufferEXT(GLbyte * pc); extern HIDDEN void __glXDisp_PushAttrib(GLbyte * pc); extern HIDDEN void __glXDispSwap_PushAttrib(GLbyte * pc); -extern HIDDEN void __glXDisp_VertexAttrib4usvARB(GLbyte * pc); -extern HIDDEN void __glXDispSwap_VertexAttrib4usvARB(GLbyte * pc); extern HIDDEN int __glXDisp_DestroyPbuffer(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDispSwap_DestroyPbuffer(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN void __glXDisp_TexParameteriv(GLbyte * pc); @@ -615,6 +617,8 @@ extern HIDDEN void __glXDisp_PrioritizeTextures(GLbyte * pc); extern HIDDEN void __glXDispSwap_PrioritizeTextures(GLbyte * pc); extern HIDDEN int __glXDisp_PixelStorei(struct __GLXclientStateRec *, GLbyte *); extern HIDDEN int __glXDispSwap_PixelStorei(struct __GLXclientStateRec *, GLbyte *); +extern HIDDEN void __glXDisp_VertexAttrib4usvARB(GLbyte * pc); +extern HIDDEN void __glXDispSwap_VertexAttrib4usvARB(GLbyte * pc); extern HIDDEN void __glXDisp_Color4iv(GLbyte * pc); extern HIDDEN void __glXDispSwap_Color4iv(GLbyte * pc); extern HIDDEN void __glXDisp_EvalCoord2dv(GLbyte * pc); @@ -783,8 +787,6 @@ extern HIDDEN void __glXDisp_VertexAttribs2fvNV(GLbyte * pc); extern HIDDEN void __glXDispSwap_VertexAttribs2fvNV(GLbyte * pc); extern HIDDEN void __glXDisp_Rectiv(GLbyte * pc); extern HIDDEN void __glXDispSwap_Rectiv(GLbyte * pc); -extern HIDDEN void __glXDisp_VertexAttrib1fvNV(GLbyte * pc); -extern HIDDEN void __glXDispSwap_VertexAttrib1fvNV(GLbyte * pc); extern HIDDEN void __glXDisp_SecondaryColor3dvEXT(GLbyte * pc); extern HIDDEN void __glXDispSwap_SecondaryColor3dvEXT(GLbyte * pc); extern HIDDEN void __glXDisp_Vertex2fv(GLbyte * pc); @@ -919,8 +921,6 @@ extern HIDDEN void __glXDisp_DrawBuffersARB(GLbyte * pc); extern HIDDEN void __glXDispSwap_DrawBuffersARB(GLbyte * pc); extern HIDDEN void __glXDisp_LoadName(GLbyte * pc); extern HIDDEN void __glXDispSwap_LoadName(GLbyte * pc); -extern HIDDEN void __glXDisp_VertexAttribs4ubvNV(GLbyte * pc); -extern HIDDEN void __glXDispSwap_VertexAttribs4ubvNV(GLbyte * pc); extern HIDDEN void __glXDisp_CopyTexSubImage1D(GLbyte * pc); extern HIDDEN void __glXDispSwap_CopyTexSubImage1D(GLbyte * pc); extern HIDDEN void __glXDisp_CullFace(GLbyte * pc); From 0a2a6e4070718b90af7ca0e047f028e0cabdfb9d Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Fri, 17 Nov 2006 18:27:23 -0800 Subject: [PATCH 040/109] Add a -showDefaultModulePath option. As discussed on the mailing list, people would rather have an X command-line option to print the module path so installers can know where to put modules, rather than the installers using `pkg-config --variable=moduledir xorg-server`, since some distros choose not to install xorg-server.pc. --- hw/xfree86/common/xf86Init.c | 13 +++++++++++++ hw/xfree86/doc/man/Xorg.man.pre | 3 +++ 2 files changed, 16 insertions(+) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 33351f2c1..5106acfe3 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -100,6 +100,7 @@ static void xf86PrintBanner(void); static void xf86PrintMarkers(void); +static void xf86PrintDefaultModulePath(void); static void xf86RunVtInit(void); #ifdef __UNIXOS2__ @@ -1376,6 +1377,11 @@ ddxProcessArgument(int argc, char **argv, int i) xf86PrintBanner(); exit(0); } + if (!strcmp(argv[i],"-showDefaultModulePath")) + { + xf86PrintDefaultModulePath(); + exit(0); + } /* Notice the -fp flag, but allow it to pass to the dix layer */ if (!strcmp(argv[i], "-fp")) { @@ -1625,6 +1631,7 @@ ddxUseMsg() ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); ErrorF("-version show the server version\n"); + ErrorF("-showDefaultModulePath show the server default module path\n"); /* OS-specific usage */ xf86UseMsg(); ErrorF("\n"); @@ -1747,6 +1754,12 @@ xf86PrintMarkers() LogPrintMarkers(); } +static void +xf86PrintDefaultModulePath(void) +{ + ErrorF("%s\n", DEFAULT_MODULE_PATH); +} + static void xf86RunVtInit(void) { diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index b7fa990bb..580310018 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -426,6 +426,9 @@ Print out the server version, patchlevel, release date, the operating system/platform it was built on, and whether it includes module loader support. .TP 8 +.B \-showDefaultModulePath +Print out the default module path the server was compiled with. +.TP 8 .BI \-config " file" Read the server configuration from .IR file . From 64de3baf85f6df274f71f736016f0848567cd9f6 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 22 Nov 2006 14:46:51 -0800 Subject: [PATCH 041/109] Add a -showDefaultLibPath option. A corollary to the previous change, this option prints $libdir. --- configure.ac | 1 + hw/xfree86/common/xf86Init.c | 13 +++++++++++++ hw/xfree86/doc/man/Xorg.man.pre | 3 +++ include/xorg-config.h.in | 3 +++ 4 files changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac index 2108db4d3..590ab2ad0 100644 --- a/configure.ac +++ b/configure.ac @@ -1383,6 +1383,7 @@ dnl has it in libc), or if libdl is needed to get it. AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file]) AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file]) AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path]) + AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path]) AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location]) AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support]) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 5106acfe3..ff878d59c 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -101,6 +101,7 @@ static void xf86PrintBanner(void); static void xf86PrintMarkers(void); static void xf86PrintDefaultModulePath(void); +static void xf86PrintDefaultLibraryPath(void); static void xf86RunVtInit(void); #ifdef __UNIXOS2__ @@ -1382,6 +1383,11 @@ ddxProcessArgument(int argc, char **argv, int i) xf86PrintDefaultModulePath(); exit(0); } + if (!strcmp(argv[i],"-showDefaultLibPath")) + { + xf86PrintDefaultLibraryPath(); + exit(0); + } /* Notice the -fp flag, but allow it to pass to the dix layer */ if (!strcmp(argv[i], "-fp")) { @@ -1632,6 +1638,7 @@ ddxUseMsg() ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); ErrorF("-version show the server version\n"); ErrorF("-showDefaultModulePath show the server default module path\n"); + ErrorF("-showDefaultLibPath show the server default library path\n"); /* OS-specific usage */ xf86UseMsg(); ErrorF("\n"); @@ -1760,6 +1767,12 @@ xf86PrintDefaultModulePath(void) ErrorF("%s\n", DEFAULT_MODULE_PATH); } +static void +xf86PrintDefaultLibraryPath(void) +{ + ErrorF("%s\n", DEFAULT_LIBRARY_PATH); +} + static void xf86RunVtInit(void) { diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index 580310018..86457321c 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -429,6 +429,9 @@ support. .B \-showDefaultModulePath Print out the default module path the server was compiled with. .TP 8 +.B \-showDefaultLibPath +Print out the path libraries should be installed to. +.TP 8 .BI \-config " file" Read the server configuration from .IR file . diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in index 4a64522a7..b9643a2a4 100644 --- a/include/xorg-config.h.in +++ b/include/xorg-config.h.in @@ -45,6 +45,9 @@ /* Path to loadable modules. */ #undef DEFAULT_MODULE_PATH +/* Path to installed libraries. */ +#undef DEFAULT_LIBRARY_PATH + /* Path to server log file. */ #undef DEFAULT_LOGPREFIX From d6cd0313c7f23f32c9c7dda00ff739e772bf7db3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 27 Nov 2006 14:46:50 -0800 Subject: [PATCH 042/109] Add some mode helper functions from the intel driver. This also removes static from some other functions that had been copied out to at least the intel driver, but perhaps others that were doing mode list handling. --- hw/xfree86/common/xf86.h | 8 +++ hw/xfree86/common/xf86Mode.c | 129 ++++++++++++++++++++++++++++++----- 2 files changed, 119 insertions(+), 18 deletions(-) diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 458750007..57284c151 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -414,6 +414,14 @@ void xf86PruneDriverModes(ScrnInfoPtr scrp); void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags); void xf86PrintModes(ScrnInfoPtr scrp); void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges); +double xf86ModeHSync(DisplayModePtr mode); +double xf86ModeVRefresh(DisplayModePtr mode); +void xf86SetModeDefaultName(DisplayModePtr mode); +void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); +DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList); +Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); +void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); /* xf86Option.c */ diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index cd57e9916..6dccf2493 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -366,8 +366,9 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp, return MODE_OK; } -static double -ModeHSync(DisplayModePtr mode) +/** Calculates the horizontal sync rate of a mode */ +_X_EXPORT double +xf86ModeHSync(DisplayModePtr mode) { double hsync = 0.0; @@ -379,8 +380,9 @@ ModeHSync(DisplayModePtr mode) return hsync; } -static double -ModeVRefresh(DisplayModePtr mode) +/** Calculates the vertical refresh rate of a mode */ +_X_EXPORT double +xf86ModeVRefresh(DisplayModePtr mode) { double refresh = 0.0; @@ -398,6 +400,16 @@ ModeVRefresh(DisplayModePtr mode) return refresh; } +/** Sets a default mode name of x on a mode. */ +_X_EXPORT void +xf86SetModeDefaultName(DisplayModePtr mode) +{ + if (mode->name != NULL) + xfree(mode->name); + + mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); +} + /* * xf86LookupMode * @@ -522,7 +534,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, ModePrivFlags = cp->PrivFlags; break; } - refresh = ModeVRefresh(p); + refresh = xf86ModeVRefresh(p); if (p->Flags & V_INTERLACE) refresh /= INTERLACE_REFRESH_WEIGHT; if (refresh > bestRefresh) { @@ -561,7 +573,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, found = TRUE; if (strategy == LOOKUP_BEST_REFRESH) { - refresh = ModeVRefresh(p); + refresh = xf86ModeVRefresh(p); if (p->Flags & V_INTERLACE) refresh /= INTERLACE_REFRESH_WEIGHT; if (refresh > bestRefresh) { @@ -662,7 +674,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, * Initialises the Crtc parameters for a mode. The initialisation includes * adjustments for interlaced and double scan modes. */ -static void +_X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) { if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN)) @@ -744,6 +756,87 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) } } +/** + * Allocates and returns a copy of pMode, including pointers within pMode. + */ +_X_EXPORT DisplayModePtr +xf86DuplicateMode(DisplayModePtr pMode) +{ + DisplayModePtr pNew; + + pNew = xnfalloc(sizeof(DisplayModeRec)); + *pNew = *pMode; + pNew->next = NULL; + pNew->prev = NULL; + if (pNew->name == NULL) { + xf86SetModeDefaultName(pMode); + } else { + pNew->name = xnfstrdup(pMode->name); + } + + return pNew; +} + +/** + * Duplicates every mode in the given list and returns a pointer to the first + * mode. + * + * \param modeList doubly-linked mode list + */ +_X_EXPORT DisplayModePtr +xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList) +{ + DisplayModePtr first = NULL, last = NULL; + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + DisplayModePtr new; + + new = xf86DuplicateMode(mode); + + /* Insert pNew into modeList */ + if (last) { + last->next = new; + new->prev = last; + } else { + first = new; + new->prev = NULL; + } + new->next = NULL; + last = new; + } + + return first; +} + +/** + * Returns true if the given modes should program to the same timings. + * + * This doesn't use Crtc values, as it might be used on ModeRecs without the + * Crtc values set. So, it's assumed that the other numbers are enough. + */ +_X_EXPORT Bool +xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2) +{ + if (pMode1->Clock == pMode2->Clock && + pMode1->HDisplay == pMode2->HDisplay && + pMode1->HSyncStart == pMode2->HSyncStart && + pMode1->HSyncEnd == pMode2->HSyncEnd && + pMode1->HTotal == pMode2->HTotal && + pMode1->HSkew == pMode2->HSkew && + pMode1->VDisplay == pMode2->VDisplay && + pMode1->VSyncStart == pMode2->VSyncStart && + pMode1->VSyncEnd == pMode2->VSyncEnd && + pMode1->VTotal == pMode2->VTotal && + pMode1->VScan == pMode2->VScan && + pMode1->Flags == pMode2->Flags) + { + return TRUE; + } else { + return FALSE; + } +} + /* * xf86CheckModeForMonitor * @@ -802,7 +895,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor) if (monitor->nHsync > 0) { /* Check hsync against the allowed ranges */ - float hsync = ModeHSync(mode); + float hsync = xf86ModeHSync(mode); for (i = 0; i < monitor->nHsync; i++) if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) && (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE))) @@ -815,7 +908,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor) if (monitor->nVrefresh > 0) { /* Check vrefresh against the allowed ranges */ - float vrefrsh = ModeVRefresh(mode); + float vrefrsh = xf86ModeVRefresh(mode); for (i = 0; i < monitor->nVrefresh; i++) if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) && (vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE))) @@ -1043,8 +1136,8 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, / (mode->CrtcHTotal * mode->CrtcVTotal); } - mode->HSync = ModeHSync(mode); - mode->VRefresh = ModeVRefresh(mode); + mode->HSync = xf86ModeHSync(mode); + mode->VRefresh = xf86ModeVRefresh(mode); /* Assume it is OK */ return MODE_OK; @@ -1683,7 +1776,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, "TargetRefresh", 0.0); if (targetRefresh > 0.0) { for (p = scrp->modePool; p != NULL; p = p->next) { - if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE)) + if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE)) break; } if (!p) @@ -1772,7 +1865,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, * If there is a target refresh rate, skip modes that * don't match up. */ - if (ModeVRefresh(q) < + if (xf86ModeVRefresh(q) < (1.0 - SYNC_TOLERANCE) * targetRefresh) continue; @@ -2068,8 +2161,8 @@ add(char **p, char *new) strcat(*p, new); } -static void -PrintModeline(int scrnIndex,DisplayModePtr mode) +_X_EXPORT void +xf86PrintModeline(int scrnIndex,DisplayModePtr mode) { char tmp[256]; char *flags = xnfcalloc(1, 1); @@ -2124,8 +2217,8 @@ xf86PrintModes(ScrnInfoPtr scrp) do { desc = desc2 = ""; - hsync = ModeHSync(p); - refresh = ModeVRefresh(p); + hsync = xf86ModeHSync(p); + refresh = xf86ModeVRefresh(p); if (p->Flags & V_INTERLACE) { desc = " (I)"; } @@ -2166,7 +2259,7 @@ xf86PrintModes(ScrnInfoPtr scrp) p->SynthClock / 1000.0, hsync, refresh, desc, desc2); } if (hsync != 0 && refresh != 0) - PrintModeline(scrp->scrnIndex,p); + xf86PrintModeline(scrp->scrnIndex,p); p = p->next; } while (p != NULL && p != scrp->modes); } From 16f8f10dc2106bc6253b2d89a1f8efee8d80e2ba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 27 Nov 2006 16:21:31 -0800 Subject: [PATCH 043/109] Move mode handling helpers from ddcProperty.c to xf86Mode.c. --- hw/xfree86/common/xf86.h | 1 + hw/xfree86/common/xf86Mode.c | 24 +++++++++ hw/xfree86/ddc/ddcProperty.c | 99 ++---------------------------------- 3 files changed, 29 insertions(+), 95 deletions(-) diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 41ad08a0e..aa73e7dc0 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -426,6 +426,7 @@ DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList); Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); +DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); /* xf86Option.c */ diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index 5a51be033..3cebac754 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -2178,3 +2178,27 @@ xf86PrintModes(ScrnInfoPtr scrp) p = p->next; } while (p != NULL && p != scrp->modes); } + +/** + * Adds the new mode into the mode list, and returns the new list + * + * \param modes doubly-linked mode list. + */ +_X_EXPORT DisplayModePtr +xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) +{ + if (modes == NULL) + return new; + + if (new) { + DisplayModePtr mode = modes; + + while (mode->next) + mode = mode->next; + + mode->next = new; + new->prev = mode; + } + + return modes; +} diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index a1650bc03..87c91b8ce 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -32,98 +32,6 @@ #include "propertyst.h" #include "xf86DDC.h" -/* - * xf86Mode.c should have a some more DisplayModePtr list handling. - */ -static DisplayModePtr -xf86ModesAdd(DisplayModePtr Modes, DisplayModePtr Additions) -{ - if (!Modes) { - if (Additions) - return Additions; - else - return NULL; - } - - if (Additions) { - DisplayModePtr Mode = Modes; - - while (Mode->next) - Mode = Mode->next; - - Mode->next = Additions; - Additions->prev = Mode; - } - - return Modes; -} - -static DisplayModePtr -xf86ModeCopy(DisplayModePtr Mode) -{ - DisplayModePtr New; - - if (!Mode) - return NULL; - - New = xnfalloc(sizeof(DisplayModeRec)); - - memcpy(New, Mode, sizeof(DisplayModeRec)); - - New->name = xnfalloc(strlen(Mode->name) + 1); - memcpy(New->name, Mode->name, strlen(Mode->name) + 1); - - /* We ignore privates as DDC code doesn't use it currently */ - return New; -} - -/* - * Temporary. - */ -static void -add(char **p, char *new) -{ - *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); - strcat(*p, " "); - strcat(*p, new); -} - -static void -PrintModeline(int scrnIndex,DisplayModePtr mode) -{ - char tmp[256]; - char *flags = xnfcalloc(1, 1); - - if (mode->HSkew) { - snprintf(tmp, 256, "hskew %i", mode->HSkew); - add(&flags, tmp); - } - if (mode->VScan) { - snprintf(tmp, 256, "vscan %i", mode->VScan); - add(&flags, tmp); - } - if (mode->Flags & V_INTERLACE) add(&flags, "interlace"); - if (mode->Flags & V_CSYNC) add(&flags, "composite"); - if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan"); - if (mode->Flags & V_BCAST) add(&flags, "bcast"); - if (mode->Flags & V_PHSYNC) add(&flags, "+hsync"); - if (mode->Flags & V_NHSYNC) add(&flags, "-hsync"); - if (mode->Flags & V_PVSYNC) add(&flags, "+vsync"); - if (mode->Flags & V_NVSYNC) add(&flags, "-vsync"); - if (mode->Flags & V_PCSYNC) add(&flags, "+csync"); - if (mode->Flags & V_NCSYNC) add(&flags, "-csync"); -#if 0 - if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2"); -#endif - xf86DrvMsgVerb(scrnIndex, X_INFO, 3, - "Modeline \"%s\" %6.2f %i %i %i %i %i %i %i %i%s\n", - mode->name, mode->Clock/1000., mode->HDisplay, - mode->HSyncStart, mode->HSyncEnd, mode->HTotal, - mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, - mode->VTotal, flags); - xfree(flags); -} - /* * TODO: * - for those with access to the VESA DMT standard; review please. @@ -159,11 +67,12 @@ DDCModesFromEstablished(int scrnIndex, struct established_timings *timing) ((timing->t_manu & 0x80) << 9); int i; - for (i = 0; i < 17; i++) + for (i = 0; i < 17; i++) { if (bits & (0x01 << i)) { - Mode = xf86ModeCopy(&(DDCEstablishedModes[i])); + Mode = xf86DusplicateMode(&DDCEstablishedModes[i]); Modes = xf86ModesAdd(Modes, Mode); } + } return Modes; } @@ -392,7 +301,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) Mode = Modes; while (Mode) { - PrintModeline(scrnIndex, Mode); + xf86PrintModeline(scrnIndex, Mode); Mode = Mode->next; } From 5dbcd34a0a6c0d10dbfea8fdc9d7dfe7a0261b19 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 27 Nov 2006 16:26:14 -0800 Subject: [PATCH 044/109] Register dependency on new RandR protocol. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e3221edab..db2234f9a 100644 --- a/configure.ac +++ b/configure.ac @@ -545,7 +545,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.la' XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la' dnl Core modules for most extensions, et al. -REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]" +REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]" REQUIRED_LIBS="xfont xau fontenc" if test "x$DBUS" = xauto; then From 834e4b079866594b50be64ae79f3cb2a5baa2070 Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Tue, 28 Nov 2006 18:57:13 +0100 Subject: [PATCH 045/109] Fix potential NULL pointer access in timer code. https://bugzilla.novell.com/show_bug.cgi?id=223718 --- os/WaitFor.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/os/WaitFor.c b/os/WaitFor.c index 6109e3477..ba227a3b6 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -205,15 +205,17 @@ WaitForSomething(int *pClientsReady) if (timeout > 0 && timeout > timers->delta + 250) { /* time has rewound. reset the timers. */ CheckAllTimers(now); - timeout = timers->expires - now; } - if (timeout < 0) - timeout = 0; - waittime.tv_sec = timeout / MILLI_PER_SECOND; - waittime.tv_usec = (timeout % MILLI_PER_SECOND) * - (1000000 / MILLI_PER_SECOND); - wt = &waittime; + if (timers) { + timeout = timers->expires - now; + if (timeout < 0) + timeout = 0; + waittime.tv_sec = timeout / MILLI_PER_SECOND; + waittime.tv_usec = (timeout % MILLI_PER_SECOND) * + (1000000 / MILLI_PER_SECOND); + wt = &waittime; + } } XFD_COPYSET(&AllSockets, &LastSelectMask); #ifdef SMART_SCHEDULE From 38ecc66cd9c61346a46697bbf1d8319f4f6f9800 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 28 Nov 2006 10:06:15 -0800 Subject: [PATCH 046/109] Typo that was missed in testing. --- hw/xfree86/ddc/ddcProperty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index 87c91b8ce..ddf580cd4 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -69,7 +69,7 @@ DDCModesFromEstablished(int scrnIndex, struct established_timings *timing) for (i = 0; i < 17; i++) { if (bits & (0x01 << i)) { - Mode = xf86DusplicateMode(&DDCEstablishedModes[i]); + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); Modes = xf86ModesAdd(Modes, Mode); } } From 05778432dc6e688bc0beff0c20ffd7e27b74888e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 28 Nov 2006 10:07:57 -0800 Subject: [PATCH 047/109] Move code to get a mode list from EDID data from ddcProperty.c to edid_modes.c. --- hw/xfree86/ddc/Makefile.am | 3 +- hw/xfree86/ddc/ddcProperty.c | 292 ------------------------------- hw/xfree86/ddc/edid_modes.c | 328 +++++++++++++++++++++++++++++++++++ 3 files changed, 330 insertions(+), 293 deletions(-) create mode 100644 hw/xfree86/ddc/edid_modes.c diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am index aff8cd3b7..a04b5e8fe 100644 --- a/hw/xfree86/ddc/Makefile.am +++ b/hw/xfree86/ddc/Makefile.am @@ -4,7 +4,8 @@ module_LTLIBRARIES = libddc.la libddc_la_LDFLAGS = -avoid-version libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ - interpret_vdif.c print_vdif.c ddcProperty.c + interpret_vdif.c print_vdif.c ddcProperty.c \ + edid_modes.c INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index ddf580cd4..11b5e26ed 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -32,300 +32,8 @@ #include "propertyst.h" #include "xf86DDC.h" -/* - * TODO: - * - for those with access to the VESA DMT standard; review please. - */ -#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER -#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 -DisplayModeRec DDCEstablishedModes[17] = { - { MODEPREFIX("800x600"), 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ - { MODEPREFIX("800x600"), 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ - { MODEPREFIX("640x480"), 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ - { MODEPREFIX("640x480"), 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ - { MODEPREFIX("640x480"), 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ - { MODEPREFIX("640x480"), 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ - { MODEPREFIX("720x400"), 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ - { MODEPREFIX("720x400"), 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ - { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ - { MODEPREFIX("1024x768"), 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ - { MODEPREFIX("1024x768"), 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ - { MODEPREFIX("1024x768"), 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ - { MODEPREFIX("1024x768"), 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ - { MODEPREFIX("832x624"), 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ - { MODEPREFIX("800x600"), 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ - { MODEPREFIX("800x600"), 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ - { MODEPREFIX("1152x864"), 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ -}; -static DisplayModePtr -DDCModesFromEstablished(int scrnIndex, struct established_timings *timing) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - CARD32 bits = (timing->t1) | (timing->t2 << 8) | - ((timing->t_manu & 0x80) << 9); - int i; - - for (i = 0; i < 17; i++) { - if (bits & (0x01 << i)) { - Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); - Modes = xf86ModesAdd(Modes, Mode); - } - } - - return Modes; -} - -/* - * - */ -static DisplayModePtr -DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - int i; - - for (i = 0; i < STD_TIMINGS; i++) - if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { - Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, - timing[i].refresh, FALSE, FALSE); - Mode->type = M_T_DRIVER; - Modes = xf86ModesAdd(Modes, Mode); - } - - return Modes; -} - -/* - * - */ -static DisplayModePtr -DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, - int preferred) -{ - DisplayModePtr Mode; - - /* We don't do stereo */ - if (timing->stereo) { - xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n", - __func__); - return NULL; - } - - /* We only do seperate sync currently */ - if (timing->sync != 0x03) { - xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate" - " sync.\n", __func__, timing->h_active, timing->v_active); - } - - Mode = xnfalloc(sizeof(DisplayModeRec)); - memset(Mode, 0, sizeof(DisplayModeRec)); - - Mode->name = xnfalloc(10); /* "1234x1234" */ - xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active, - timing->v_active); - - Mode->type = M_T_DRIVER; - if (preferred) - Mode->type |= M_T_PREFERRED; - - Mode->Clock = timing->clock / 1000.0; - - Mode->HDisplay = timing->h_active; - Mode->HSyncStart = timing->h_active + timing->h_sync_off; - Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; - Mode->HTotal = timing->h_active + timing->h_blanking; - - Mode->VDisplay = timing->v_active; - Mode->VSyncStart = timing->v_active + timing->v_sync_off; - Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; - Mode->VTotal = timing->v_active + timing->v_blanking; - - /* We ignore h/v_size and h/v_border for now. */ - - if (timing->interlaced) - Mode->Flags |= V_INTERLACE; - - if (timing->misc & 0x02) - Mode->Flags |= V_PHSYNC; - else - Mode->Flags |= V_NHSYNC; - - if (timing->misc & 0x01) - Mode->Flags |= V_PVSYNC; - else - Mode->Flags |= V_NVSYNC; - - return Mode; -} - -/* - * - */ -static void -DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) -{ - DisplayModePtr Mode = Modes; - - if (!Monitor || !Modes) - return; - - /* set up the ranges for scanning through the modes */ - Monitor->nHsync = 1; - Monitor->hsync[0].lo = 1024.0; - Monitor->hsync[0].hi = 0.0; - - Monitor->nVrefresh = 1; - Monitor->vrefresh[0].lo = 1024.0; - Monitor->vrefresh[0].hi = 0.0; - - while (Mode) { - if (!Mode->HSync) - Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); - - if (!Mode->VRefresh) - Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / - ((float) (Mode->HTotal * Mode->VTotal)); - - if (Mode->HSync < Monitor->hsync[0].lo) - Monitor->hsync[0].lo = Mode->HSync; - - if (Mode->HSync > Monitor->hsync[0].hi) - Monitor->hsync[0].hi = Mode->HSync; - - if (Mode->VRefresh < Monitor->vrefresh[0].lo) - Monitor->vrefresh[0].lo = Mode->VRefresh; - - if (Mode->VRefresh > Monitor->vrefresh[0].hi) - Monitor->vrefresh[0].hi = Mode->VRefresh; - - Mode = Mode->next; - } -} - -/* - * Fill out MonPtr with xf86MonPtr information. - */ -void -xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) -{ - DisplayModePtr Modes = NULL, Mode; - int i, clock; - Bool have_hsync = FALSE, have_vrefresh = FALSE; - int preferred; - - if (!Monitor || !DDC) - return; - - Monitor->DDC = DDC; - - preferred = PREFERRED_TIMING_MODE(DDC->features.msc); - - Monitor->widthmm = 10 * DDC->features.hsize; - Monitor->heightmm = 10 * DDC->features.vsize; - - /* If this is a digital display, then we can use reduced blanking */ - if (DDC->features.input_type) - Monitor->reducedblanking = TRUE; - /* Allow the user to also enable this through config */ - - /* Add established timings */ - Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1); - Modes = xf86ModesAdd(Modes, Mode); - - /* Add standard timings */ - Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2); - Modes = xf86ModesAdd(Modes, Mode); - - /* Skip EDID ranges if they were specified in the config file */ - have_hsync = (Monitor->nHsync != 0); - have_vrefresh = (Monitor->nVrefresh != 0); - - /* Go through the detailed monitor sections */ - for (i = 0; i < DET_TIMINGS; i++) - switch (DDC->det_mon[i].type) { - case DS_RANGES: - if (!have_hsync) { - if (!Monitor->nHsync) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for horizontal sync\n"); - Monitor->hsync[Monitor->nHsync].lo = - DDC->det_mon[i].section.ranges.min_h; - Monitor->hsync[Monitor->nHsync].hi = - DDC->det_mon[i].section.ranges.max_h; - Monitor->nHsync++; - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Using hsync ranges from config file\n"); - } - - if (!have_vrefresh) { - if (!Monitor->nVrefresh) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for vertical refresh\n"); - Monitor->vrefresh[Monitor->nVrefresh].lo = - DDC->det_mon[i].section.ranges.min_v; - Monitor->vrefresh[Monitor->nVrefresh].hi = - DDC->det_mon[i].section.ranges.max_v; - Monitor->nVrefresh++; - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Using vrefresh ranges from config file\n"); - } - - clock = DDC->det_mon[i].section.ranges.max_clock * 1000; - if (clock > Monitor->maxPixClock) - Monitor->maxPixClock = clock; - - break; - case DT: - Mode = DDCModeFromDetailedTiming(scrnIndex, - &DDC->det_mon[i].section.d_timings, - preferred); - preferred = 0; - Modes = xf86ModesAdd(Modes, Mode); - break; - case DS_STD_TIMINGS: - Mode = DDCModesFromStandardTiming(scrnIndex, - DDC->det_mon[i].section.std_t); - Modes = xf86ModesAdd(Modes, Mode); - break; - default: - break; - } - - if (Modes) { - /* Print Modes */ - xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); - - Mode = Modes; - while (Mode) { - xf86PrintModeline(scrnIndex, Mode); - Mode = Mode->next; - } - - /* Do we still need ranges to be filled in? */ - if (!Monitor->nHsync || !Monitor->nVrefresh) - DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); - - /* look for last Mode */ - Mode = Modes; - - while (Mode->next) - Mode = Mode->next; - - /* add to MonPtr */ - if (Monitor->Modes) { - Monitor->Last->next = Modes; - Modes->prev = Monitor->Last; - Monitor->Last = Mode; - } else { - Monitor->Modes = Modes; - Monitor->Last = Mode; - } - } -} #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" #define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA" diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c new file mode 100644 index 000000000..5ce86eebe --- /dev/null +++ b/hw/xfree86/ddc/edid_modes.c @@ -0,0 +1,328 @@ +/* + * Copyright 2006 Luc Verhaegen. + * + * 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, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include +#include "property.h" +#include "propertyst.h" +#include "xf86DDC.h" + +/* + * TODO: + * - for those with access to the VESA DMT standard; review please. + */ +#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER +#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 + +DisplayModeRec DDCEstablishedModes[17] = { + { MODEPREFIX("800x600"), 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX("800x600"), 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX("640x480"), 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX("640x480"), 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX("640x480"), 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ + { MODEPREFIX("640x480"), 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX("720x400"), 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ + { MODEPREFIX("720x400"), 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ + { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX("1024x768"), 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX("1024x768"), 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX("1024x768"), 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX("1024x768"), 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ + { MODEPREFIX("832x624"), 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ + { MODEPREFIX("800x600"), 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX("800x600"), 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX("1152x864"), 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ +}; + +static DisplayModePtr +DDCModesFromEstablished(int scrnIndex, struct established_timings *timing) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + CARD32 bits = (timing->t1) | (timing->t2 << 8) | + ((timing->t_manu & 0x80) << 9); + int i; + + for (i = 0; i < 17; i++) { + if (bits & (0x01 << i)) { + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* + * + */ +static DisplayModePtr +DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + int i; + + for (i = 0; i < STD_TIMINGS; i++) + if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { + Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, + timing[i].refresh, FALSE, FALSE); + Mode->type = M_T_DRIVER; + Modes = xf86ModesAdd(Modes, Mode); + } + + return Modes; +} + +/* + * + */ +static DisplayModePtr +DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, + int preferred) +{ + DisplayModePtr Mode; + + /* We don't do stereo */ + if (timing->stereo) { + xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n", + __func__); + return NULL; + } + + /* We only do seperate sync currently */ + if (timing->sync != 0x03) { + xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate" + " sync.\n", __func__, timing->h_active, timing->v_active); + } + + Mode = xnfalloc(sizeof(DisplayModeRec)); + memset(Mode, 0, sizeof(DisplayModeRec)); + + Mode->name = xnfalloc(10); /* "1234x1234" */ + xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active, + timing->v_active); + + Mode->type = M_T_DRIVER; + if (preferred) + Mode->type |= M_T_PREFERRED; + + Mode->Clock = timing->clock / 1000.0; + + Mode->HDisplay = timing->h_active; + Mode->HSyncStart = timing->h_active + timing->h_sync_off; + Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; + Mode->HTotal = timing->h_active + timing->h_blanking; + + Mode->VDisplay = timing->v_active; + Mode->VSyncStart = timing->v_active + timing->v_sync_off; + Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; + Mode->VTotal = timing->v_active + timing->v_blanking; + + /* We ignore h/v_size and h/v_border for now. */ + + if (timing->interlaced) + Mode->Flags |= V_INTERLACE; + + if (timing->misc & 0x02) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + + return Mode; +} + +/* + * + */ +static void +DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) +{ + DisplayModePtr Mode = Modes; + + if (!Monitor || !Modes) + return; + + /* set up the ranges for scanning through the modes */ + Monitor->nHsync = 1; + Monitor->hsync[0].lo = 1024.0; + Monitor->hsync[0].hi = 0.0; + + Monitor->nVrefresh = 1; + Monitor->vrefresh[0].lo = 1024.0; + Monitor->vrefresh[0].hi = 0.0; + + while (Mode) { + if (!Mode->HSync) + Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); + + if (!Mode->VRefresh) + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + if (Mode->HSync < Monitor->hsync[0].lo) + Monitor->hsync[0].lo = Mode->HSync; + + if (Mode->HSync > Monitor->hsync[0].hi) + Monitor->hsync[0].hi = Mode->HSync; + + if (Mode->VRefresh < Monitor->vrefresh[0].lo) + Monitor->vrefresh[0].lo = Mode->VRefresh; + + if (Mode->VRefresh > Monitor->vrefresh[0].hi) + Monitor->vrefresh[0].hi = Mode->VRefresh; + + Mode = Mode->next; + } +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +void +xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + int i, clock; + Bool have_hsync = FALSE, have_vrefresh = FALSE; + int preferred; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + + /* If this is a digital display, then we can use reduced blanking */ + if (DDC->features.input_type) + Monitor->reducedblanking = TRUE; + /* Allow the user to also enable this through config */ + + /* Add established timings */ + Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add standard timings */ + Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2); + Modes = xf86ModesAdd(Modes, Mode); + + /* Skip EDID ranges if they were specified in the config file */ + have_hsync = (Monitor->nHsync != 0); + have_vrefresh = (Monitor->nVrefresh != 0); + + /* Go through the detailed monitor sections */ + for (i = 0; i < DET_TIMINGS; i++) + switch (DDC->det_mon[i].type) { + case DS_RANGES: + if (!have_hsync) { + if (!Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + Monitor->hsync[Monitor->nHsync].lo = + DDC->det_mon[i].section.ranges.min_h; + Monitor->hsync[Monitor->nHsync].hi = + DDC->det_mon[i].section.ranges.max_h; + Monitor->nHsync++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using hsync ranges from config file\n"); + } + + if (!have_vrefresh) { + if (!Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + Monitor->vrefresh[Monitor->nVrefresh].lo = + DDC->det_mon[i].section.ranges.min_v; + Monitor->vrefresh[Monitor->nVrefresh].hi = + DDC->det_mon[i].section.ranges.max_v; + Monitor->nVrefresh++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using vrefresh ranges from config file\n"); + } + + clock = DDC->det_mon[i].section.ranges.max_clock * 1000; + if (clock > Monitor->maxPixClock) + Monitor->maxPixClock = clock; + + break; + case DT: + Mode = DDCModeFromDetailedTiming(scrnIndex, + &DDC->det_mon[i].section.d_timings, + preferred); + preferred = 0; + Modes = xf86ModesAdd(Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(scrnIndex, + DDC->det_mon[i].section.std_t); + Modes = xf86ModesAdd(Modes, Mode); + break; + default: + break; + } + + if (Modes) { + /* Print Modes */ + xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); + + Mode = Modes; + while (Mode) { + xf86PrintModeline(scrnIndex, Mode); + Mode = Mode->next; + } + + /* Do we still need ranges to be filled in? */ + if (!Monitor->nHsync || !Monitor->nVrefresh) + DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); + + /* look for last Mode */ + Mode = Modes; + + while (Mode->next) + Mode = Mode->next; + + /* add to MonPtr */ + if (Monitor->Modes) { + Monitor->Last->next = Modes; + Modes->prev = Monitor->Last; + Monitor->Last = Mode; + } else { + Monitor->Modes = Modes; + Monitor->Last = Mode; + } + } +} From 4ad0bde661be2af4a17771d66066d49736e85cbe Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 28 Nov 2006 10:12:02 -0800 Subject: [PATCH 048/109] Clean up a bunch of long lines and trailing whitespace. --- hw/xfree86/ddc/edid_modes.c | 48 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c index 5ce86eebe..9e824b1dc 100644 --- a/hw/xfree86/ddc/edid_modes.c +++ b/hw/xfree86/ddc/edid_modes.c @@ -85,14 +85,15 @@ DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing) { DisplayModePtr Modes = NULL, Mode = NULL; int i; - - for (i = 0; i < STD_TIMINGS; i++) + + for (i = 0; i < STD_TIMINGS; i++) { if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, timing[i].refresh, FALSE, FALSE); Mode->type = M_T_DRIVER; Modes = xf86ModesAdd(Modes, Mode); } + } return Modes; } @@ -108,55 +109,56 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, /* We don't do stereo */ if (timing->stereo) { - xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n", - __func__); + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring: We don't handle stereo.\n", __func__); return NULL; } - + /* We only do seperate sync currently */ if (timing->sync != 0x03) { - xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate" + xf86DrvMsg(scrnIndex, X_INFO, + "%s: %dx%d Warning: We only handle seperate" " sync.\n", __func__, timing->h_active, timing->v_active); } - + Mode = xnfalloc(sizeof(DisplayModeRec)); memset(Mode, 0, sizeof(DisplayModeRec)); - + Mode->name = xnfalloc(10); /* "1234x1234" */ xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active, timing->v_active); - + Mode->type = M_T_DRIVER; if (preferred) Mode->type |= M_T_PREFERRED; - + Mode->Clock = timing->clock / 1000.0; - + Mode->HDisplay = timing->h_active; Mode->HSyncStart = timing->h_active + timing->h_sync_off; Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; Mode->HTotal = timing->h_active + timing->h_blanking; - + Mode->VDisplay = timing->v_active; Mode->VSyncStart = timing->v_active + timing->v_sync_off; Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; Mode->VTotal = timing->v_active + timing->v_blanking; - + /* We ignore h/v_size and h/v_border for now. */ - + if (timing->interlaced) Mode->Flags |= V_INTERLACE; - + if (timing->misc & 0x02) Mode->Flags |= V_PHSYNC; else Mode->Flags |= V_NHSYNC; - + if (timing->misc & 0x01) Mode->Flags |= V_PVSYNC; else Mode->Flags |= V_NVSYNC; - + return Mode; } @@ -199,7 +201,7 @@ DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) if (Mode->VRefresh > Monitor->vrefresh[0].hi) Monitor->vrefresh[0].hi = Mode->VRefresh; - + Mode = Mode->next; } } @@ -214,7 +216,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) int i, clock; Bool have_hsync = FALSE, have_vrefresh = FALSE; int preferred; - + if (!Monitor || !DDC) return; @@ -224,9 +226,9 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) Monitor->widthmm = 10 * DDC->features.hsize; Monitor->heightmm = 10 * DDC->features.vsize; - + /* If this is a digital display, then we can use reduced blanking */ - if (DDC->features.input_type) + if (DDC->features.input_type) Monitor->reducedblanking = TRUE; /* Allow the user to also enable this through config */ @@ -280,7 +282,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) break; case DT: - Mode = DDCModeFromDetailedTiming(scrnIndex, + Mode = DDCModeFromDetailedTiming(scrnIndex, &DDC->det_mon[i].section.d_timings, preferred); preferred = 0; @@ -314,7 +316,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) while (Mode->next) Mode = Mode->next; - + /* add to MonPtr */ if (Monitor->Modes) { Monitor->Last->next = Modes; From fbd09443385c533416fa530399d54f130afaf985 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 28 Nov 2006 10:15:51 -0800 Subject: [PATCH 049/109] Replace bad mode name-setting code with xf86SetModeDefaultName(). --- hw/xfree86/ddc/edid_modes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c index 9e824b1dc..25f95ca24 100644 --- a/hw/xfree86/ddc/edid_modes.c +++ b/hw/xfree86/ddc/edid_modes.c @@ -124,10 +124,6 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, Mode = xnfalloc(sizeof(DisplayModeRec)); memset(Mode, 0, sizeof(DisplayModeRec)); - Mode->name = xnfalloc(10); /* "1234x1234" */ - xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active, - timing->v_active); - Mode->type = M_T_DRIVER; if (preferred) Mode->type |= M_T_PREFERRED; @@ -144,6 +140,8 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; Mode->VTotal = timing->v_active + timing->v_blanking; + xf86SetModeDefaultName(Mode); + /* We ignore h/v_size and h/v_border for now. */ if (timing->interlaced) From f62ac3ec39c6593df476985c630e499864c19c72 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 28 Nov 2006 10:31:40 -0800 Subject: [PATCH 050/109] Separate DDC mode list creation from MonPtr creation. This will be used by the intel driver, and likely other RandR 1.2 drivers. --- hw/xfree86/ddc/edid_modes.c | 88 +++++++++++++++++++++++-------------- hw/xfree86/ddc/xf86DDC.h | 2 + 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c index 25f95ca24..cfc8ddc13 100644 --- a/hw/xfree86/ddc/edid_modes.c +++ b/hw/xfree86/ddc/edid_modes.c @@ -204,32 +204,14 @@ DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) } } -/* - * Fill out MonPtr with xf86MonPtr information. - */ -void -xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +DisplayModePtr +xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) { + int preferred, i; DisplayModePtr Modes = NULL, Mode; - int i, clock; - Bool have_hsync = FALSE, have_vrefresh = FALSE; - int preferred; - - if (!Monitor || !DDC) - return; - - Monitor->DDC = DDC; preferred = PREFERRED_TIMING_MODE(DDC->features.msc); - Monitor->widthmm = 10 * DDC->features.hsize; - Monitor->heightmm = 10 * DDC->features.vsize; - - /* If this is a digital display, then we can use reduced blanking */ - if (DDC->features.input_type) - Monitor->reducedblanking = TRUE; - /* Allow the user to also enable this through config */ - /* Add established timings */ Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1); Modes = xf86ModesAdd(Modes, Mode); @@ -238,12 +220,61 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2); Modes = xf86ModesAdd(Modes, Mode); + for (i = 0; i < DET_TIMINGS; i++) { + struct detailed_monitor_section *det_mon = &DDC->det_mon[i]; + + switch (det_mon->type) { + case DT: + Mode = DDCModeFromDetailedTiming(scrnIndex, + &det_mon->section.d_timings, + preferred); + preferred = 0; + Modes = xf86ModesAdd(Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(scrnIndex, + det_mon->section.std_t); + Modes = xf86ModesAdd(Modes, Mode); + break; + default: + break; + } + } + + return Modes; +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +void +xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + int i, clock; + Bool have_hsync = FALSE, have_vrefresh = FALSE; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + + /* If this is a digital display, then we can use reduced blanking */ + if (DDC->features.input_type) + Monitor->reducedblanking = TRUE; + /* Allow the user to also enable this through config */ + + Modes = xf86DDCGetModes(scrnIndex, DDC); + /* Skip EDID ranges if they were specified in the config file */ have_hsync = (Monitor->nHsync != 0); have_vrefresh = (Monitor->nVrefresh != 0); /* Go through the detailed monitor sections */ - for (i = 0; i < DET_TIMINGS; i++) + for (i = 0; i < DET_TIMINGS; i++) { switch (DDC->det_mon[i].type) { case DS_RANGES: if (!have_hsync) { @@ -278,22 +309,11 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) if (clock > Monitor->maxPixClock) Monitor->maxPixClock = clock; - break; - case DT: - Mode = DDCModeFromDetailedTiming(scrnIndex, - &DDC->det_mon[i].section.d_timings, - preferred); - preferred = 0; - Modes = xf86ModesAdd(Modes, Mode); - break; - case DS_STD_TIMINGS: - Mode = DDCModesFromStandardTiming(scrnIndex, - DDC->det_mon[i].section.std_t); - Modes = xf86ModesAdd(Modes, Mode); break; default: break; } + } if (Modes) { /* Print Modes */ diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h index 5def97a81..77994715e 100644 --- a/hw/xfree86/ddc/xf86DDC.h +++ b/hw/xfree86/ddc/xf86DDC.h @@ -59,6 +59,8 @@ extern void xf86print_vdif( xf86vdifPtr v ); +DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); + #endif From 24abce8032940e96bb2ccf9e463a7fff6f36283a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 21 Nov 2006 01:15:26 -0800 Subject: [PATCH 051/109] Change RandR property datatype to include pending/valid values. This patch tracks the protocol changes which introduce more complex semantics for RandR output properties including pending and valid value information. (cherry picked from commit af55c65bea40669fdc038aa34c6a1ec9ecb33e87) --- randr/mirandr.c | 9 +- randr/randrstr.h | 57 ++++++- randr/rrdispatch.c | 26 ++-- randr/rrproperty.c | 370 +++++++++++++++++++++++++++++++++----------- randr/rrsdispatch.c | 46 ++++-- 5 files changed, 384 insertions(+), 124 deletions(-) diff --git a/randr/mirandr.c b/randr/mirandr.c index 3a99bf9ed..0b763e111 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -64,10 +64,11 @@ miRRCrtcSetGamma (ScreenPtr pScreen, return TRUE; } -static Bool -miRROutputSetProperty (ScreenPtr pScreen, - RROutputPtr output, - Atom property) +Bool +miRROutputSetProperty (ScreenPtr pScreen, + RROutputPtr output, + Atom property, + RRPropertyValuePtr value) { return TRUE; } diff --git a/randr/randrstr.h b/randr/randrstr.h index 19af9b979..27ede9226 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -69,9 +69,11 @@ extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr); */ #define RRModeName(pMode) ((char *) (pMode + 1)) -typedef struct _rrMode RRModeRec, *RRModePtr; -typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; -typedef struct _rrOutput RROutputRec, *RROutputPtr; +typedef struct _rrMode RRModeRec, *RRModePtr; +typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr; +typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr; +typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; +typedef struct _rrOutput RROutputRec, *RROutputPtr; struct _rrMode { int refcnt; @@ -81,6 +83,24 @@ struct _rrMode { Bool userDefined; }; +struct _rrPropertyValue { + Atom type; /* ignored by server */ + short format; /* format of data for swapping - 8,16,32 */ + long size; /* size of data in (format/8) bytes */ + pointer data; /* private to client */ +}; + +struct _rrProperty { + RRPropertyPtr next; + ATOM propertyName; + Bool is_pending; + Bool range; + Bool immutable; + int num_valid; + INT32 *valid_values; + RRPropertyValueRec current, pending; +}; + struct _rrCrtc { RRCrtc id; ScreenPtr pScreen; @@ -116,7 +136,7 @@ struct _rrOutput { int numPreferred; RRModePtr *modes; Bool changed; - PropertyPtr properties; + RRPropertyPtr properties; void *devPrivate; }; @@ -139,9 +159,10 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); -typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, - RROutputPtr output, - Atom property); +typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + Atom property, + RRPropertyValuePtr value); #endif @@ -363,6 +384,12 @@ miRRCrtcSet (ScreenPtr pScreen, int numOutput, RROutputPtr *outputs); +Bool +miRROutputSetProperty (ScreenPtr pScreen, + RROutputPtr output, + Atom property, + RRPropertyValuePtr value); + /* randr.c */ /* * Send all pending events @@ -676,6 +703,12 @@ RRPointerScreenConfigured (ScreenPtr pScreen); void RRDeleteAllOutputProperties (RROutputPtr output); +RRPropertyValuePtr +RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending); + +RRPropertyPtr +RRQueryOutputProperty (RROutputPtr output, Atom property); + void RRDeleteOutputProperty (RROutputPtr output, Atom property); @@ -685,6 +718,10 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, pointer value, Bool sendevent); int +RRConfigureOutputProperty (RROutputPtr output, Atom property, + Bool pending, Bool range, Bool immutable, + int num_values, INT32 *values); +int ProcRRChangeOutputProperty (ClientPtr client); int @@ -693,6 +730,12 @@ ProcRRGetOutputProperty (ClientPtr client); int ProcRRListOutputProperties (ClientPtr client); +int +ProcRRQueryOutputProperty (ClientPtr client); + +int +ProcRRConfigureOutputProperty (ClientPtr client); + int ProcRRDeleteOutputProperty (ClientPtr client); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 49ba10bc0..6b61b9cd7 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -192,17 +192,19 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { ProcRRGetScreenResources, /* 8 */ ProcRRGetOutputInfo, /* 9 */ ProcRRListOutputProperties, /* 10 */ - ProcRRChangeOutputProperty, /* 11 */ - ProcRRDeleteOutputProperty, /* 12 */ - ProcRRGetOutputProperty, /* 13 */ - ProcRRCreateMode, /* 14 */ - ProcRRDestroyMode, /* 15 */ - ProcRRAddOutputMode, /* 16 */ - ProcRRDeleteOutputMode, /* 17 */ - ProcRRGetCrtcInfo, /* 18 */ - ProcRRSetCrtcConfig, /* 19 */ - ProcRRGetCrtcGammaSize, /* 20 */ - ProcRRGetCrtcGamma, /* 21 */ - ProcRRSetCrtcGamma, /* 22 */ + ProcRRQueryOutputProperty, /* 11 */ + ProcRRConfigureOutputProperty, /* 12 */ + ProcRRChangeOutputProperty, /* 13 */ + ProcRRDeleteOutputProperty, /* 14 */ + ProcRRGetOutputProperty, /* 15 */ + ProcRRCreateMode, /* 16 */ + ProcRRDestroyMode, /* 17 */ + ProcRRAddOutputMode, /* 18 */ + ProcRRDeleteOutputMode, /* 19 */ + ProcRRGetCrtcInfo, /* 20 */ + ProcRRSetCrtcConfig, /* 21 */ + ProcRRGetCrtcGammaSize, /* 22 */ + ProcRRGetCrtcGamma, /* 23 */ + ProcRRSetCrtcGamma, /* 24 */ }; diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 44f1f0ace..5d4c86565 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -33,7 +33,7 @@ RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask) void RRDeleteAllOutputProperties (RROutputPtr output) { - PropertyPtr prop, next; + RRPropertyPtr prop, next; xRROutputPropertyNotifyEvent event; for (prop = output->properties; prop; prop = next) @@ -46,15 +46,58 @@ RRDeleteAllOutputProperties (RROutputPtr output) event.atom = prop->propertyName; event.timestamp = currentTime.milliseconds; RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); - xfree(prop->data); + if (prop->current.data) + xfree(prop->current.data); + if (prop->pending.data) + xfree(prop->pending.data); xfree(prop); } } +static void +RRInitOutputPropertyValue (RRPropertyValuePtr property_value) +{ + property_value->type = None; + property_value->format = 0; + property_value->size = 0; + property_value->data = NULL; +} + +static RRPropertyPtr +RRCreateOutputProperty (Atom property) +{ + RRPropertyPtr prop; + + prop = (RRPropertyPtr)xalloc(sizeof(PropertyRec)); + if (!prop) + return NULL; + prop->propertyName = property; + prop->is_pending = FALSE; + prop->range = FALSE; + prop->immutable = FALSE; + prop->num_valid = 0; + prop->valid_values = NULL; + RRInitOutputPropertyValue (&prop->current); + RRInitOutputPropertyValue (&prop->pending); + return prop; +} + +static void +RRDestroyOutputProperty (RRPropertyPtr prop) +{ + if (prop->valid_values) + xfree (prop->valid_values); + if (prop->current.data) + xfree(prop->current.data); + if (prop->pending.data) + xfree(prop->pending.data); + xfree(prop); +} + void RRDeleteOutputProperty (RROutputPtr output, Atom property) { - PropertyPtr prop, *prev; + RRPropertyPtr prop, *prev; xRROutputPropertyNotifyEvent event; for (prev = &output->properties; (prop = *prev); prev = &(prop->next)) @@ -70,8 +113,7 @@ RRDeleteOutputProperty (RROutputPtr output, Atom property) event.atom = prop->propertyName; event.timestamp = currentTime.milliseconds; RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask); - xfree(prop->data); - xfree(prop); + RRDestroyOutputProperty (prop); } } @@ -80,96 +122,95 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, int format, int mode, unsigned long len, pointer value, Bool sendevent) { - PropertyPtr prop; + RRPropertyPtr prop; xRROutputPropertyNotifyEvent event; int sizeInBytes; int totalSize; pointer data; + RRPropertyValuePtr prop_value; + Bool add = FALSE; sizeInBytes = format >> 3; totalSize = len * sizeInBytes; /* first see if property already exists */ - - for (prop = output->properties; prop; prop = prop->next) - if (prop->propertyName == property) - break; - + prop = RRQueryOutputProperty (output, property); if (!prop) /* just add to list */ { - prop = (PropertyPtr)xalloc(sizeof(PropertyRec)); + prop = RRCreateOutputProperty (property); if (!prop) return(BadAlloc); - data = (pointer)xalloc(totalSize); - if (!data && len) - { - xfree(prop); - return(BadAlloc); - } - prop->propertyName = property; - prop->type = type; - prop->format = format; - prop->data = data; - if (len) - memmove((char *)data, (char *)value, totalSize); - prop->size = len; - prop->next = output->properties; - output->properties = prop; + add = TRUE; + mode = PropModeReplace; } + if (prop->is_pending) + prop_value = &prop->pending; else - { - /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ + prop_value = &prop->current; + + /* To append or prepend to a property the request format and type + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ - if ((format != prop->format) && (mode != PropModeReplace)) - return(BadMatch); - if ((prop->type != type) && (mode != PropModeReplace)) - return(BadMatch); - if (mode == PropModeReplace) - { - if (totalSize != prop->size * (prop->format >> 3)) - { - data = (pointer)xrealloc(prop->data, totalSize); - if (!data && len) - return(BadAlloc); - prop->data = data; - } - if (len) - memmove((char *)prop->data, (char *)value, totalSize); - prop->size = len; - prop->type = type; - prop->format = format; - } - else if (len == 0) + if ((format != prop_value->format) && (mode != PropModeReplace)) + return(BadMatch); + if ((prop_value->type != type) && (mode != PropModeReplace)) + return(BadMatch); + if (mode == PropModeReplace) + { + if (totalSize != prop_value->size * (prop_value->format >> 3)) { - /* do nothing */ - } - else if (mode == PropModeAppend) - { - data = (pointer)xrealloc(prop->data, - sizeInBytes * (len + prop->size)); - if (!data) + if (prop_value->data) + data = (pointer)xrealloc(prop_value->data, totalSize); + else + data = (pointer)xalloc (totalSize); + if (!data && len) + { + if (add) + RRDestroyOutputProperty (prop); return(BadAlloc); - prop->data = data; - memmove(&((char *)data)[prop->size * sizeInBytes], - (char *)value, - totalSize); - prop->size += len; - } - else if (mode == PropModePrepend) - { - data = (pointer)xalloc(sizeInBytes * (len + prop->size)); - if (!data) - return(BadAlloc); - memmove(&((char *)data)[totalSize], (char *)prop->data, - (int)(prop->size * sizeInBytes)); - memmove((char *)data, (char *)value, totalSize); - xfree(prop->data); - prop->data = data; - prop->size += len; + } + prop_value->data = data; } + if (len) + memmove((char *)prop_value->data, (char *)value, totalSize); + prop_value->size = len; + prop_value->type = type; + prop_value->format = format; + } + else if (len == 0) + { + /* do nothing */ + } + else if (mode == PropModeAppend) + { + data = (pointer)xrealloc(prop_value->data, + sizeInBytes * (len + prop_value->size)); + if (!data) + return(BadAlloc); + prop_value->data = data; + memmove(&((char *)data)[prop_value->size * sizeInBytes], + (char *)value, + totalSize); + prop_value->size += len; + } + else if (mode == PropModePrepend) + { + data = (pointer)xalloc(sizeInBytes * (len + prop_value->size)); + if (!data) + return(BadAlloc); + memmove(&((char *)data)[totalSize], (char *)prop_value->data, + (int)(prop_value->size * sizeInBytes)); + memmove((char *)data, (char *)value, totalSize); + xfree(prop_value->data); + prop_value->data = data; + prop_value->size += len; + } + if (add) + { + prop->next = output->properties; + output->properties = prop; } if (sendevent) { @@ -184,6 +225,81 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, return(Success); } +RRPropertyPtr +RRQueryOutputProperty (RROutputPtr output, Atom property) +{ + RRPropertyPtr prop; + + for (prop = output->properties; prop; prop = prop->next) + if (prop->propertyName == property) + return prop; + return NULL; +} + +RRPropertyValuePtr +RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending) +{ + RRPropertyPtr prop = RRQueryOutputProperty (output, property); + + if (!prop) + return NULL; + if (pending && prop->is_pending) + return &prop->pending; + else + return &prop->current; +} + +int +RRConfigureOutputProperty (RROutputPtr output, Atom property, + Bool pending, Bool range, Bool immutable, + int num_values, INT32 *values) +{ + RRPropertyPtr prop = RRQueryOutputProperty (output, property); + Bool add = FALSE; + INT32 *new_values; + + if (!prop) + { + prop = RRCreateOutputProperty (property); + if (!prop) + return(BadAlloc); + add = TRUE; + } else if (prop->immutable && !immutable) + return(BadAccess); + + /* + * ranges must have even number of values + */ + if (range && (num_values & 1)) + return BadMatch; + + new_values = xalloc (num_values * sizeof (INT32)); + if (!new_values && num_values) + return BadAlloc; + if (num_values) + memcpy (new_values, values, num_values * sizeof (INT32)); + + /* + * Property moving from pending to non-pending + * loses any pending values + */ + if (prop->is_pending && !pending) + { + if (prop->pending.data) + xfree (prop->pending.data); + RRInitOutputPropertyValue (&prop->pending); + } + + prop->is_pending = pending; + prop->range = range; + prop->immutable = immutable; + prop->num_valid = num_values; + if (prop->valid_values) + xfree (prop->valid_values); + prop->valid_values = new_values; + return Success; +} + int ProcRRListOutputProperties (ClientPtr client) { @@ -192,7 +308,7 @@ ProcRRListOutputProperties (ClientPtr client) xRRListOutputPropertiesReply rep; int numProps = 0; RROutputPtr output; - PropertyPtr prop; + RRPropertyPtr prop; REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); @@ -211,6 +327,12 @@ ProcRRListOutputProperties (ClientPtr client) rep.nProperties = numProps; rep.length = (numProps * sizeof(Atom)) >> 2; rep.sequenceNumber = client->sequence; + if (client->swapped) + { + int n; + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + } temppAtoms = pAtoms; for (prop = output->properties; prop; prop = prop->next) *temppAtoms++ = prop->propertyName; @@ -225,6 +347,68 @@ ProcRRListOutputProperties (ClientPtr client) return(client->noClientException); } +int +ProcRRQueryOutputProperty (ClientPtr client) +{ + REQUEST(xRRQueryOutputPropertyReq); + xRRQueryOutputPropertyReply rep; + RROutputPtr output; + RRPropertyPtr prop; + + REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); + + output = LookupOutput (client, stuff->output, SecurityReadAccess); + + if (!output) + return RRErrorBase + BadRROutput; + + prop = RRQueryOutputProperty (output, stuff->property); + if (!prop) + return BadName; + + rep.type = X_Reply; + rep.length = prop->num_valid; + rep.sequenceNumber = client->sequence; + rep.pending = prop->is_pending; + rep.range = prop->range; + rep.immutable = prop->immutable; + if (client->swapped) + { + int n; + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + } + WriteReplyToClient (client, sizeof (xRRQueryOutputPropertyReply), &rep); + if (prop->num_valid) + { + client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32), + prop->valid_values); + } + return(client->noClientException); +} + +int +ProcRRConfigureOutputProperty (ClientPtr client) +{ + REQUEST(xRRConfigureOutputPropertyReq); + RROutputPtr output; + int num_valid; + + REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); + + output = LookupOutput (client, stuff->output, SecurityReadAccess); + + if (!output) + return RRErrorBase + BadRROutput; + + num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2); + return RRConfigureOutputProperty (output, stuff->property, + stuff->pending, stuff->range, + FALSE, num_valid, + (INT32 *) (stuff + 1)); +} + int ProcRRChangeOutputProperty (ClientPtr client) { @@ -309,7 +493,8 @@ int ProcRRGetOutputProperty (ClientPtr client) { REQUEST(xRRGetOutputPropertyReq); - PropertyPtr prop, *prev; + RRPropertyPtr prop, *prev; + RRPropertyValuePtr prop_value; unsigned long n, len, ind; RROutputPtr output; xRRGetOutputPropertyReply reply; @@ -356,18 +541,26 @@ ProcRRGetOutputProperty (ClientPtr client) return(client->noClientException); } + if (prop->immutable && stuff->delete) + return BadAccess; + + if (stuff->pending && prop->is_pending) + prop_value = &prop->pending; + else + prop_value = &prop->current; + /* If the request type and actual type don't match. Return the property information, but not the data. */ - if (((stuff->type != prop->type) && + if (((stuff->type != prop_value->type) && (stuff->type != AnyPropertyType)) ) { - reply.bytesAfter = prop->size; - reply.format = prop->format; + reply.bytesAfter = prop_value->size; + reply.format = prop_value->format; reply.length = 0; reply.nItems = 0; - reply.propertyType = prop->type; + reply.propertyType = prop_value->type; WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); return(client->noClientException); } @@ -375,7 +568,7 @@ ProcRRGetOutputProperty (ClientPtr client) /* * Return type, format, value to client */ - n = (prop->format/8) * prop->size; /* size (bytes) of prop */ + n = (prop_value->format/8) * prop_value->size; /* size (bytes) of prop */ ind = stuff->longOffset << 2; /* If longOffset is invalid such that it causes "len" to @@ -390,10 +583,10 @@ ProcRRGetOutputProperty (ClientPtr client) len = min(n - ind, 4 * stuff->longLength); reply.bytesAfter = n - (ind + len); - reply.format = prop->format; + reply.format = prop_value->format; reply.length = (len + 3) >> 2; - reply.nItems = len / (prop->format / 8 ); - reply.propertyType = prop->type; + reply.nItems = len / (prop_value->format / 8 ); + reply.propertyType = prop_value->type; if (stuff->delete && (reply.bytesAfter == 0)) { @@ -417,14 +610,13 @@ ProcRRGetOutputProperty (ClientPtr client) default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break; } WriteSwappedDataToClient(client, len, - (char *)prop->data + ind); + (char *)prop_value->data + ind); } if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */ *prev = prop->next; - xfree(prop->data); - xfree(prop); + RRDestroyOutputProperty (prop); } return(client->noClientException); } diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c index 67af75306..4a6a6e43f 100644 --- a/randr/rrsdispatch.c +++ b/randr/rrsdispatch.c @@ -131,6 +131,26 @@ SProcRRListOutputProperties (ClientPtr client) return BadImplementation; } +static int +SProcRRQueryOutputProperty (ClientPtr client) +{ + REQUEST(xRRQueryOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + +static int +SProcRRConfigureOutputProperty (ClientPtr client) +{ + REQUEST(xRRConfigureOutputPropertyReq); + + REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); + (void) stuff; + return BadImplementation; +} + static int SProcRRChangeOutputProperty (ClientPtr client) { @@ -267,17 +287,19 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = { SProcRRGetScreenResources, /* 8 */ SProcRRGetOutputInfo, /* 9 */ SProcRRListOutputProperties,/* 10 */ - SProcRRChangeOutputProperty,/* 11 */ - SProcRRDeleteOutputProperty,/* 12 */ - SProcRRGetOutputProperty, /* 13 */ - SProcRRCreateMode, /* 14 */ - SProcRRDestroyMode, /* 15 */ - SProcRRAddOutputMode, /* 16 */ - SProcRRDeleteOutputMode, /* 17 */ - SProcRRGetCrtcInfo, /* 18 */ - SProcRRSetCrtcConfig, /* 19 */ - SProcRRGetCrtcGammaSize, /* 20 */ - SProcRRGetCrtcGamma, /* 21 */ - SProcRRSetCrtcGamma, /* 22 */ + SProcRRQueryOutputProperty, /* 11 */ + SProcRRConfigureOutputProperty, /* 12 */ + SProcRRChangeOutputProperty,/* 13 */ + SProcRRDeleteOutputProperty,/* 14 */ + SProcRRGetOutputProperty, /* 15 */ + SProcRRCreateMode, /* 16 */ + SProcRRDestroyMode, /* 17 */ + SProcRRAddOutputMode, /* 18 */ + SProcRRDeleteOutputMode, /* 19 */ + SProcRRGetCrtcInfo, /* 20 */ + SProcRRSetCrtcConfig, /* 21 */ + SProcRRGetCrtcGammaSize, /* 22 */ + SProcRRGetCrtcGamma, /* 23 */ + SProcRRSetCrtcGamma, /* 24 */ }; From 6245e9dd4719c5dc15ff45d49cf626123794038b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 21 Nov 2006 16:52:28 -0800 Subject: [PATCH 052/109] Allocate correct size for RRPropertyRec (oops). Neglected to change the allocation size from sizeof (PropertyRec) to sizeof (RRPropertyRec). Lots of fun crashes this way. (cherry picked from commit 0626eb8e5c9fa05de6bdc9aa0c654f5148bf7cff) --- randr/rrproperty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 5d4c86565..a47f30671 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -68,9 +68,10 @@ RRCreateOutputProperty (Atom property) { RRPropertyPtr prop; - prop = (RRPropertyPtr)xalloc(sizeof(PropertyRec)); + prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec)); if (!prop) return NULL; + prop->next = NULL; prop->propertyName = property; prop->is_pending = FALSE; prop->range = FALSE; From b0c8558b9d9a9984c0067960392e28f5a7622b29 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 26 Nov 2006 19:31:48 -0800 Subject: [PATCH 053/109] Ensure RandR resource types are registered before resources are created. Now that resources can be created during server initialization, make sure the crtc, output and mode resource types are created before attempting to create associated resources. (cherry picked from commit ec83d674167e7045d5317b179c9998e3172a26dc) --- randr/rrcrtc.c | 2 ++ randr/rrmode.c | 3 +++ randr/rroutput.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index b81c390f1..212352c15 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -55,6 +55,8 @@ RRCrtcCreate (void *devPrivate) { RRCrtcPtr crtc; + if (!RRInit()) + return NULL; crtc = xalloc (sizeof (RRCrtcRec)); if (!crtc) return NULL; diff --git a/randr/rrmode.c b/randr/rrmode.c index 3cd9ef273..a0696e170 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -67,6 +67,9 @@ RRModeGet (xRRModeInfo *modeInfo, } } + if (!RRInit ()) + return NULL; + mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1); if (!mode) return NULL; diff --git a/randr/rroutput.c b/randr/rroutput.c index 8b760ec9a..f38f5826a 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -51,6 +51,8 @@ RROutputCreate (const char *name, { RROutputPtr output; + if (!RRInit()) + return NULL; output = xalloc (sizeof (RROutputRec) + nameLength + 1); if (!output) return NULL; From a6381e69845f58d2b3282992b1f881015190f1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 29 Nov 2006 19:25:09 +0100 Subject: [PATCH 054/109] xfree86 DDX: Delete DDX screens in ddxGiveUp(). This allows video drivers to clean up in the FreeScreen hook things they set up in the PreInit hook. --- hw/xfree86/common/xf86Init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index ff878d59c..68d69c51c 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1119,6 +1119,9 @@ ddxGiveUp() DGAShutdown(); #endif + while (xf86NumScreens) + xf86DeleteScreen(xf86NumScreens - 1, 0); + xf86CloseConsole(); xf86CloseLog(); From ee9bdd3f4a14a42fb0747acc420966f0f669129b Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 29 Nov 2006 12:01:43 -0800 Subject: [PATCH 055/109] Add DIX_CFLAGS to util builds. Fixes a build breakage when $(top_srcdir) != $(top_builddir) because -I$(top_srcdir)/include is missing for the cvt, ioport, pcitweak, and scanpci builds. Signed-off-by: Adam Jackson --- hw/xfree86/utils/cvt/Makefile.am | 2 +- hw/xfree86/utils/ioport/Makefile.am | 2 +- hw/xfree86/utils/pcitweak/Makefile.am | 2 +- hw/xfree86/utils/scanpci/Makefile.am | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/utils/cvt/Makefile.am b/hw/xfree86/utils/cvt/Makefile.am index ff3c1f7bc..365c6cb88 100644 --- a/hw/xfree86/utils/cvt/Makefile.am +++ b/hw/xfree86/utils/cvt/Makefile.am @@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib # gah cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/common/xf86cvt.c -cvt_CFLAGS = $(XORG_CFLAGS) +cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) cvt_LDADD = $(top_builddir)/hw/xfree86/dummylib/libdummy-nonserver.a man1_MANS = cvt.man diff --git a/hw/xfree86/utils/ioport/Makefile.am b/hw/xfree86/utils/ioport/Makefile.am index e96681bbf..1839c9a60 100644 --- a/hw/xfree86/utils/ioport/Makefile.am +++ b/hw/xfree86/utils/ioport/Makefile.am @@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR) -ioport_CFLAGS = $(XORG_CFLAGS) +ioport_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) ioport_LDADD = \ ../../os-support/libxorgos.la \ ../../dummylib/libdummy-nonserver.a \ diff --git a/hw/xfree86/utils/pcitweak/Makefile.am b/hw/xfree86/utils/pcitweak/Makefile.am index 9a565adc8..5c2a6eb56 100644 --- a/hw/xfree86/utils/pcitweak/Makefile.am +++ b/hw/xfree86/utils/pcitweak/Makefile.am @@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR) -pcitweak_CFLAGS = $(XORG_CFLAGS) +pcitweak_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) pcitweak_LDADD = \ ../../os-support/libxorgos.la \ ../../dummylib/libdummy-nonserver.a \ diff --git a/hw/xfree86/utils/scanpci/Makefile.am b/hw/xfree86/utils/scanpci/Makefile.am index f4e2cbb37..6af8eaee5 100644 --- a/hw/xfree86/utils/scanpci/Makefile.am +++ b/hw/xfree86/utils/scanpci/Makefile.am @@ -34,7 +34,7 @@ DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib INCLUDES = $(XORG_INCS) -I$(SCANPCI_SRCDIR) -I$(DUMMYLIB_SRCDIR) -scanpci_CFLAGS = $(XORG_CFLAGS) +scanpci_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) scanpci_LDADD = \ ../../scanpci/libscanpci.la \ ../../os-support/libxorgos.la \ From 8956f63a941bf0a5f157d47b33e6221601a75040 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 30 Nov 2006 19:53:29 -0800 Subject: [PATCH 056/109] Tell automake to STFU about the *.O files automake will not stop whining about the *.O files not being in normal library name format, so just tell automake they are PROGRAMS so it builds them without bitching. --- dix/Makefile.am | 2 +- os/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dix/Makefile.am b/dix/Makefile.am index d0d6e8785..a1f02c1b6 100644 --- a/dix/Makefile.am +++ b/dix/Makefile.am @@ -52,7 +52,7 @@ Xserver-dtrace.h: $(srcdir)/Xserver.d dtrace-dix.o: $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS) $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o -noinst_LIBRARIES = dix.O +noinst_PROGRAMS = dix.O dix.O: dtrace-dix.o $(am_libdix_la_OBJECTS) ld -r -o $@ .libs/*.o diff --git a/os/Makefile.am b/os/Makefile.am index 7381797ab..d8d1405ce 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -56,7 +56,7 @@ if XSERVER_DTRACE dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS) $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o -noinst_LIBRARIES = os.O +noinst_PROGRAMS = os.O os.O: dtrace.o $(am_libos_la_OBJECTS) ld -r -o $@ dtrace.o .libs/*.o From 82912ad7709e8cf4a5f8a9fa6b47f789842a3fe9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 30 Nov 2006 20:13:52 -0800 Subject: [PATCH 057/109] Make solaris version of xf86OSRingBell return void like other OS'es --- hw/xfree86/os-support/solaris/sun_bell.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c index b3a9bfe7e..29ecd7300 100644 --- a/hw/xfree86/os-support/solaris/sun_bell.c +++ b/hw/xfree86/os-support/solaris/sun_bell.c @@ -48,7 +48,7 @@ #define AUDIO_DEVICE "/dev/audio" -_X_EXPORT int +_X_EXPORT void xf86OSRingBell(int loudness, int pitch, int duration) { static short samples[BELL_SAMPLES]; @@ -66,7 +66,7 @@ xf86OSRingBell(int loudness, int pitch, int duration) int audioFD; if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) { - return 0; + return; } lastFreq = 0; @@ -76,7 +76,7 @@ xf86OSRingBell(int loudness, int pitch, int duration) if (audioFD == -1) { xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n", AUDIO_DEVICE, strerror(errno)); - return -1; + return; } freq = pitch; @@ -126,7 +126,7 @@ xf86OSRingBell(int loudness, int pitch, int duration) "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n", AUDIO_DEVICE, strerror(errno)); close(audioFD); - return -1; + return; } iovcnt = 0; @@ -155,7 +155,7 @@ xf86OSRingBell(int loudness, int pitch, int duration) "Bell: writev failed on audio device \"%s\": %s\n", AUDIO_DEVICE, strerror(errno)); close(audioFD); - return -1; + return; } i = iovcnt; } else { @@ -181,5 +181,5 @@ xf86OSRingBell(int loudness, int pitch, int duration) } close(audioFD); - return 0; + return; } From 9423ac134a2a9800787c4978d384827cc4e61fc8 Mon Sep 17 00:00:00 2001 From: Drew Parsons Date: Fri, 1 Dec 2006 15:21:05 +1100 Subject: [PATCH 058/109] GNU/FreeBSD support in GLX: include byteswap.h for FreeBSD systems defining __GLIBC__, as done already for Linux and Hurd (cf. bug #5613). Also includes some more __GNU__ checks on top of those made in commit ade4bf09076d13dbf3549c0a2d987a0afe76d5c1. Thanks Petr Salinger (Debian bug #400869). --- GL/glx/indirect_dispatch_swap.c | 2 +- GL/glx/indirect_program.c | 2 +- GL/glx/indirect_reqsize.c | 2 +- GL/glx/indirect_texture_compression.c | 2 +- GL/glx/indirect_util.c | 2 +- GL/glx/swap_interval.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GL/glx/indirect_dispatch_swap.c b/GL/glx/indirect_dispatch_swap.c index 1d45676b3..136f0d010 100644 --- a/GL/glx/indirect_dispatch_swap.c +++ b/GL/glx/indirect_dispatch_swap.c @@ -28,7 +28,7 @@ #include #include #include -#if defined(__linux__) || defined(__GNU__) +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/indirect_program.c b/GL/glx/indirect_program.c index d0fd3d135..8d5f0e60f 100644 --- a/GL/glx/indirect_program.c +++ b/GL/glx/indirect_program.c @@ -46,7 +46,7 @@ #include "dispatch.h" #include "glapioffsets.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/indirect_reqsize.c b/GL/glx/indirect_reqsize.c index 1c332da79..d3e2bc516 100644 --- a/GL/glx/indirect_reqsize.c +++ b/GL/glx/indirect_reqsize.c @@ -31,7 +31,7 @@ #include "indirect_size.h" #include "indirect_reqsize.h" -#if defined(__linux__) || defined(__GNU__) +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) # include # define SWAP_32(v) do { (v) = bswap_32(v); } while(0) #else diff --git a/GL/glx/indirect_texture_compression.c b/GL/glx/indirect_texture_compression.c index 0c42ea034..35af1d235 100644 --- a/GL/glx/indirect_texture_compression.c +++ b/GL/glx/indirect_texture_compression.c @@ -39,7 +39,7 @@ #include "glthread.h" #include "dispatch.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/indirect_util.c b/GL/glx/indirect_util.c index 2d64f3399..09b7ab87c 100644 --- a/GL/glx/indirect_util.c +++ b/GL/glx/indirect_util.c @@ -28,7 +28,7 @@ #include #include #include -#if defined(__linux__) || defined(__GNU__) +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/swap_interval.c b/GL/glx/swap_interval.c index bcc1c4793..c4137c1aa 100644 --- a/GL/glx/swap_interval.c +++ b/GL/glx/swap_interval.c @@ -40,7 +40,7 @@ #include "dispatch.h" #include "glapioffsets.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) #include #elif defined(__OpenBSD__) #include From 23ba72323af785516db6cbcf6c1b2fa907a8232f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 30 Nov 2006 23:16:42 -0800 Subject: [PATCH 059/109] RandR ListOutputProperties has nAtoms element, not nProperties Earlier RandR 1.2 encoding revisions used 8-bit nProperties field. Final RandR 1.2 spec uses 16-bit nAtoms field instead. (cherry picked from 66b6358a393972946f16394918db2401c51dc5ed commit) --- randr/rrproperty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index a47f30671..13e848340 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -325,9 +325,9 @@ ProcRRListOutputProperties (ClientPtr client) return(BadAlloc); rep.type = X_Reply; - rep.nProperties = numProps; rep.length = (numProps * sizeof(Atom)) >> 2; rep.sequenceNumber = client->sequence; + rep.nAtoms = numProps; if (client->swapped) { int n; From 89b2aa9be81613cb1a06bd535bf50ecf2a00208d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 27 Nov 2006 21:40:24 -0800 Subject: [PATCH 060/109] Destroying RandR crtc or output overwrites memory. RRCrtcDestroyResource and RROutputDestroyResource had matching bugs that would overwrite memory past the end of the storage of the crtc or output arrays. Oops. (cherry picked from 4202b23ed86405a4cebfdcf239df1b023c1d10ca commit) --- randr/rrcrtc.c | 2 +- randr/rroutput.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 212352c15..e8a7b79e1 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -344,7 +344,7 @@ RRCrtcDestroyResource (pointer value, XID pid) if (pScrPriv->crtcs[i] == crtc) { memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, - (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr)); + (pScrPriv->numCrtcs - (i + 1)) * sizeof (RRCrtcPtr)); --pScrPriv->numCrtcs; break; } diff --git a/randr/rroutput.c b/randr/rroutput.c index f38f5826a..430f8bdaa 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -327,7 +327,7 @@ RROutputDestroyResource (pointer value, XID pid) if (pScrPriv->outputs[i] == output) { memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, - (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr)); + (pScrPriv->numOutputs - (i + 1)) * sizeof (RROutputPtr)); --pScrPriv->numOutputs; break; } From a5d6499d666fea4a9988118ddd3a5e4c9cfcc32c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 1 Dec 2006 16:42:37 -0800 Subject: [PATCH 061/109] Fix syntax error in configure check for SYSV_IPC that broke with Sun cc --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index db2234f9a..1aa5455b9 100644 --- a/configure.ac +++ b/configure.ac @@ -174,7 +174,7 @@ AC_CACHE_CHECK([for SYSV IPC], [AC_TRY_LINK([ #include ],[ -int main () { +{ int id; id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R); if (id < 0) return -1; From f44f14fe564d834568a0afefba944223a73ea0f5 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 1 Dec 2006 20:48:15 -0500 Subject: [PATCH 062/109] Define calls away when not building XACE, allowing ifdef's to be removed. --- Xext/xace.h | 26 +++++++++++++---- dix/devices.c | 22 ++++----------- dix/dispatch.c | 41 +++++++-------------------- dix/dixutils.c | 2 -- dix/events.c | 50 ++++++++++++--------------------- dix/extension.c | 17 ++--------- dix/getevents.c | 4 --- dix/property.c | 75 ++++++++++++++++++------------------------------- dix/resource.c | 8 ++---- dix/window.c | 42 +++++++++------------------ os/access.c | 6 ++-- os/connection.c | 6 ++-- 12 files changed, 105 insertions(+), 194 deletions(-) diff --git a/Xext/xace.h b/Xext/xace.h index 6cb4b4f5d..6f998951e 100644 --- a/Xext/xace.h +++ b/Xext/xace.h @@ -20,6 +20,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef _XACE_H #define _XACE_H +/* Hook return codes */ +#define SecurityErrorOperation 0 +#define SecurityAllowOperation 1 +#define SecurityIgnoreOperation 2 + +#ifdef XACE + #define XACE_EXTENSION_NAME "XAccessControlExtension" #define XACE_MAJOR_VERSION 1 #define XACE_MINOR_VERSION 0 @@ -75,11 +82,6 @@ extern int XaceHook( /* From the original Security extension... */ -/* Hook return codes */ -#define SecurityAllowOperation 0 -#define SecurityIgnoreOperation 1 -#define SecurityErrorOperation 2 - /* Proc vectors for untrusted clients, swapped and unswapped versions. * These are the same as the normal proc vectors except that extensions * that haven't declared themselves secure will have ProcBadRequest plugged @@ -100,4 +102,18 @@ extern void XaceCensorImage( char * pBuf ); +#else /* XACE */ + +/* Define calls away when XACE is not being built. */ + +#ifdef __GNUC__ +#define XaceHook(args...) SecurityAllowOperation +#define XaceCensorImage(args...) { ; } +#else +#define XaceHook(...) SecurityAllowOperation +#define XaceCensorImage(...) { ; } +#endif + +#endif /* XACE */ + #endif /* _XACE_H */ diff --git a/dix/devices.c b/dix/devices.c index aa0486219..e6a504954 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -69,9 +69,7 @@ SOFTWARE. #ifdef XKB #include #endif -#ifdef XACE #include "xace.h" -#endif #include "dispatch.h" #include "swaprep.h" @@ -1178,10 +1176,8 @@ DoSetModifierMapping(ClientPtr client, KeyCode *inputMap, } } -#ifdef XACE if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE)) return BadAccess; -#endif /* None of the modifiers (old or new) may be down while we change * the map. */ @@ -1302,14 +1298,12 @@ ProcChangeKeyboardMapping(ClientPtr client) return BadValue; } -#ifdef XACE for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE)) return BadAccess; } } -#endif keysyms.minKeyCode = stuff->firstKeyCode; keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; @@ -1655,7 +1649,6 @@ ProcChangeKeyboardControl (ClientPtr client) if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) return BadLength; -#ifdef XACE for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { @@ -1663,7 +1656,6 @@ ProcChangeKeyboardControl (ClientPtr client) return BadAccess; } } -#endif for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if ((pDev->coreEvents || pDev == inputInfo.keyboard) && @@ -1920,15 +1912,13 @@ ProcQueryKeymap(ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 2; -#ifdef XACE - if (!XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE)) - { - bzero((char *)&rep.map[0], 32); - } + + if (XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE)) + for (i = 0; i<32; i++) + rep.map[i] = down[i]; else -#endif - for (i = 0; i<32; i++) - rep.map[i] = down[i]; + bzero((char *)&rep.map[0], 32); + WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); return Success; } diff --git a/dix/dispatch.c b/dix/dispatch.c index 26cb54445..0a93c3b6e 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -135,9 +135,7 @@ int ProcInitialConnection(); #include "panoramiX.h" #include "panoramiXsrv.h" #endif -#ifdef XACE #include "xace.h" -#endif #ifdef XAPPGROUP #include "appgroup.h" #endif @@ -504,16 +502,11 @@ Dispatch(void) #endif if (result > (maxBigRequestSize << 2)) result = BadLength; - else -#ifdef XACE - { + else { XaceHook(XACE_AUDIT_BEGIN, client); result = (* client->requestVector[MAJOROP])(client); XaceHook(XACE_AUDIT_END, client, result); } -#else - result = (* client->requestVector[MAJOROP])(client); -#endif /* XACE */ #ifdef XSERVER_DTRACE XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP, client->sequence, client->index, result); @@ -1166,14 +1159,11 @@ ProcConvertSelection(register ClientPtr client) i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->selection) i++; - if ((i < NumCurrentSelections) && - (CurrentSelections[i].window != None) -#ifdef XACE - && XaceHook(XACE_RESOURCE_ACCESS, client, - CurrentSelections[i].window, RT_WINDOW, - SecurityReadAccess, CurrentSelections[i].pWin) -#endif - ) + if ((i < NumCurrentSelections) && + (CurrentSelections[i].window != None) && + XaceHook(XACE_RESOURCE_ACCESS, client, + CurrentSelections[i].window, RT_WINDOW, + SecurityReadAccess, CurrentSelections[i].pWin)) { event.u.u.type = SelectionRequest; event.u.selectionRequest.time = stuff->time; @@ -2163,9 +2153,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, Mask plane = 0; char *pBuf; xGetImageReply xgi; -#ifdef XACE RegionPtr pVisibleRegion = NULL; -#endif if ((format != XYPixmap) && (format != ZPixmap)) { @@ -2269,17 +2257,16 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); } -#ifdef XACE if (pDraw->type == DRAWABLE_WINDOW && !XaceHook(XACE_DRAWABLE_ACCESS, client, pDraw)) { pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw); if (pVisibleRegion) { - REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion, -pDraw->x, -pDraw->y); + REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion, + -pDraw->x, -pDraw->y); } } -#endif if (linesPerBuf == 0) { @@ -2299,12 +2286,10 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, format, planemask, (pointer) pBuf); -#ifdef XACE if (pVisibleRegion) XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y + linesDone, width, nlines, format, pBuf); -#endif /* Note that this is NOT a call to WriteSwappedDataToClient, as we do NOT byte swap */ @@ -2340,13 +2325,11 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, format, plane, (pointer)pBuf); -#ifdef XACE if (pVisibleRegion) XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y + linesDone, width, nlines, format, pBuf); -#endif /* Note: NOT a call to WriteSwappedDataToClient, as we do NOT byte swap */ @@ -2368,10 +2351,8 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, } } } -#ifdef XACE if (pVisibleRegion) REGION_DESTROY(pDraw->pScreen, pVisibleRegion); -#endif if (!im_return) DEALLOCATE_LOCAL(pBuf); return (client->noClientException); @@ -3342,13 +3323,11 @@ ProcListHosts(register ClientPtr client) /* REQUEST(xListHostsReq); */ REQUEST_SIZE_MATCH(xListHostsReq); -#ifdef XACE + /* untrusted clients can't list hosts */ if (!XaceHook(XACE_HOSTLIST_ACCESS, client, SecurityReadAccess)) - { return BadAccess; - } -#endif + result = GetHosts(&pdata, &nHosts, &len, &reply.enabled); if (result != Success) return(result); diff --git a/dix/dixutils.c b/dix/dixutils.c index a395d4474..af7e1c8f1 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -95,9 +95,7 @@ Author: Adobe Systems Incorporated #include "scrnintstr.h" #define XK_LATIN1 #include -#ifdef XACE #include "xace.h" -#endif /* * CompareTimeStamps returns -1, 0, or +1 depending on if the first diff --git a/dix/events.c b/dix/events.c index c8da7d62c..7cfe0ad0c 100644 --- a/dix/events.c +++ b/dix/events.c @@ -137,9 +137,7 @@ of the copyright holder. extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #endif -#ifdef XACE #include "xace.h" -#endif #ifdef XSERVER_DTRACE #include @@ -2462,10 +2460,8 @@ CheckPassiveGrabsOnWindow( (grab->confineTo->realized && BorderSizeNotEmpty(grab->confineTo)))) { -#ifdef XACE if (!XaceHook(XACE_DEVICE_ACCESS, wClient(pWin), device, FALSE)) return FALSE; -#endif #ifdef XKB if (!noXkbExtension) { XE_KBPTR.state &= 0x1f00; @@ -2826,9 +2822,7 @@ drawable.id:0; if (deactivateGrab) (*keybd->DeactivateGrab)(keybd); -#ifdef XACE XaceHook(XACE_KEY_AVAIL, xE, keybd, count); -#endif } #ifdef XKB @@ -3252,17 +3246,13 @@ EnterLeaveEvent( if ((type == EnterNotify) && (mask & KeymapStateMask)) { xKeymapEvent ke; - -#ifdef XACE ClientPtr client = grab ? rClient(grab) : clients[CLIENT_ID(pWin->drawable.id)]; - if (!XaceHook(XACE_DEVICE_ACCESS, client, keybd, FALSE)) - { - bzero((char *)&ke.map[0], 31); - } + if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, FALSE)) + memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31); else -#endif - memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31); + bzero((char *)&ke.map[0], 31); + ke.type = KeymapNotify; if (grab) (void)TryClientEvents(rClient(grab), (xEvent *)&ke, 1, mask, @@ -3348,15 +3338,12 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) { xKeymapEvent ke; -#ifdef XACE ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)]; - if (!XaceHook(XACE_DEVICE_ACCESS, client, dev, FALSE)) - { - bzero((char *)&ke.map[0], 31); - } + if (XaceHook(XACE_DEVICE_ACCESS, client, dev, FALSE)) + memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31); else -#endif - memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31); + bzero((char *)&ke.map[0], 31); + ke.type = KeymapNotify; (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1, KeymapStateMask, NullGrab, 0); @@ -3619,10 +3606,10 @@ ProcSetInputFocus(client) REQUEST(xSetInputFocusReq); REQUEST_SIZE_MATCH(xSetInputFocusReq); -#ifdef XACE + if (!XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE)) return Success; -#endif + return SetInputFocus(client, inputInfo.keyboard, stuff->focus, stuff->revertTo, stuff->time, FALSE); } @@ -3884,18 +3871,17 @@ ProcGrabKeyboard(ClientPtr client) int result; REQUEST_SIZE_MATCH(xGrabKeyboardReq); -#ifdef XACE - if (!XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE)) - { + + if (XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE)) + result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode, + stuff->pointerMode, stuff->grabWindow, + stuff->ownerEvents, stuff->time, + KeyPressMask | KeyReleaseMask, &rep.status); + else { result = Success; rep.status = AlreadyGrabbed; } - else -#endif - result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode, - stuff->pointerMode, stuff->grabWindow, - stuff->ownerEvents, stuff->time, - KeyPressMask | KeyReleaseMask, &rep.status); + if (result != Success) return result; rep.type = X_Reply; diff --git a/dix/extension.c b/dix/extension.c index fe779b2be..29cae8676 100644 --- a/dix/extension.c +++ b/dix/extension.c @@ -59,9 +59,7 @@ SOFTWARE. #include "gcstruct.h" #include "scrnintstr.h" #include "dispatch.h" -#ifdef XACE #include "xace.h" -#endif #define EXTENSION_BASE 128 #define EXTENSION_EVENT_BASE 64 @@ -256,11 +254,9 @@ GetExtensionEntry(int major) _X_EXPORT void DeclareExtensionSecurity(char *extname, Bool secure) { -#ifdef XACE int i = FindExtension(extname, strlen(extname)); if (i >= 0) XaceHook(XACE_DECLARE_EXT_SECURE, extensions[i], secure); -#endif } _X_EXPORT unsigned short @@ -336,12 +332,7 @@ ProcQueryExtension(ClientPtr client) else { i = FindExtension((char *)&stuff[1], stuff->nbytes); - if (i < 0 -#ifdef XACE - /* call callbacks to find out whether to show extension */ - || !XaceHook(XACE_EXT_ACCESS, client, extensions[i]) -#endif - ) + if (i < 0 || !XaceHook(XACE_EXT_ACCESS, client, extensions[i])) reply.present = xFalse; else { @@ -376,11 +367,10 @@ ProcListExtensions(ClientPtr client) for (i=0; iname) + 1; reply.nExtensions += 1 + extensions[i]->num_aliases; for (j = extensions[i]->num_aliases; --j >= 0;) @@ -393,10 +383,9 @@ ProcListExtensions(ClientPtr client) for (i=0; iname); memmove(bufptr, extensions[i]->name, len); bufptr += len; diff --git a/dix/getevents.c b/dix/getevents.c index be598bce8..41542625b 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -48,10 +48,6 @@ extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies); #endif -#ifdef XACE -#include "xace.h" -#endif - #ifdef PANORAMIX #include "panoramiX.h" #include "panoramiXsrv.h" diff --git a/dix/property.c b/dix/property.c index da983838f..0946b65e1 100644 --- a/dix/property.c +++ b/dix/property.c @@ -58,9 +58,7 @@ SOFTWARE. #include "dixstruct.h" #include "dispatch.h" #include "swaprep.h" -#ifdef XACE #include "xace.h" -#endif /***************************************************************** * Property Stuff @@ -118,27 +116,19 @@ ProcRotateProperties(ClientPtr client) return(BadAlloc); for (i = 0; i < stuff->nAtoms; i++) { -#ifdef XACE char action = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, atoms[i], SecurityReadAccess|SecurityWriteAccess); -#endif - if (!ValidAtom(atoms[i]) -#ifdef XACE - || (SecurityErrorOperation == action) -#endif - ) - { + + if (!ValidAtom(atoms[i]) || (SecurityErrorOperation == action)) { DEALLOCATE_LOCAL(props); client->errorValue = atoms[i]; return BadAtom; } -#ifdef XACE - if (SecurityIgnoreOperation == action) - { + if (SecurityIgnoreOperation == action) { DEALLOCATE_LOCAL(props); return Success; } -#endif + for (j = i + 1; j < stuff->nAtoms; j++) if (atoms[j] == atoms[i]) { @@ -233,17 +223,15 @@ ProcChangeProperty(ClientPtr client) return(BadAtom); } -#ifdef XACE switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, - SecurityWriteAccess)) + SecurityWriteAccess)) { - case SecurityErrorOperation: - client->errorValue = stuff->property; - return BadAtom; - case SecurityIgnoreOperation: - return Success; + case SecurityErrorOperation: + client->errorValue = stuff->property; + return BadAtom; + case SecurityIgnoreOperation: + return Success; } -#endif err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format, (int)mode, len, (pointer)&stuff[1], TRUE); @@ -460,6 +448,7 @@ ProcGetProperty(ClientPtr client) unsigned long n, len, ind; WindowPtr pWin; xGetPropertyReply reply; + Mask access_mode = SecurityReadAccess; REQUEST(xGetPropertyReq); REQUEST_SIZE_MATCH(xGetPropertyReq); @@ -501,24 +490,18 @@ ProcGetProperty(ClientPtr client) if (!pProp) return NullPropertyReply(client, None, 0, &reply); -#ifdef XACE + if (stuff->delete) + access_mode |= SecurityDestroyAccess; + switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, + access_mode)) { - Mask access_mode = SecurityReadAccess; - - if (stuff->delete) - access_mode |= SecurityDestroyAccess; - switch(XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, - access_mode)) - { - case SecurityErrorOperation: - client->errorValue = stuff->property; - return BadAtom;; - case SecurityIgnoreOperation: - return NullPropertyReply(client, pProp->type, pProp->format, - &reply); - } + case SecurityErrorOperation: + client->errorValue = stuff->property; + return BadAtom;; + case SecurityIgnoreOperation: + return NullPropertyReply(client, pProp->type, pProp->format, &reply); } -#endif + /* If the request type and actual type don't match. Return the property information, but not the data. */ @@ -663,17 +646,15 @@ ProcDeleteProperty(register ClientPtr client) return (BadAtom); } -#ifdef XACE - switch(XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, - SecurityDestroyAccess)) + switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, + SecurityDestroyAccess)) { - case SecurityErrorOperation: - client->errorValue = stuff->property; - return BadAtom;; - case SecurityIgnoreOperation: - return Success; + case SecurityErrorOperation: + client->errorValue = stuff->property; + return BadAtom;; + case SecurityIgnoreOperation: + return Success; } -#endif result = DeleteProperty(pWin, stuff->property); if (client->noClientException != Success) diff --git a/dix/resource.c b/dix/resource.c index efb759e75..c2044601f 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -148,9 +148,7 @@ Equipment Corporation. #include "panoramiX.h" #include "panoramiXsrv.h" #endif -#ifdef XACE #include "xace.h" -#endif #include #ifdef XSERVER_DTRACE @@ -904,11 +902,10 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) break; } } -#ifdef XACE if (retval && client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, mode, retval)) retval = NULL; -#endif + return retval; } @@ -932,11 +929,10 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) break; } } -#ifdef XACE if (retval && client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, mode, retval)) retval = NULL; -#endif + return retval; } diff --git a/dix/window.c b/dix/window.c index f0079e09d..fa6906f2a 100644 --- a/dix/window.c +++ b/dix/window.c @@ -126,9 +126,7 @@ Equipment Corporation. #ifdef XAPPGROUP #include "appgroup.h" #endif -#ifdef XACE #include "xace.h" -#endif /****** * Window stuff for server @@ -531,9 +529,7 @@ InitRootWindow(WindowPtr pWin) /* We SHOULD check for an error value here XXX */ (*pScreen->ChangeWindowAttributes)(pWin, backFlag); -#ifdef XACE XaceHook(XACE_WINDOW_INIT, serverClient, pWin); -#endif MapWindow(pWin, serverClient); } @@ -738,18 +734,16 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, } pWin->borderWidth = bw; -#ifdef XACE + /* can't let untrusted clients have background None windows; * they make it too easy to steal window contents */ - if (!XaceHook(XACE_BACKGRND_ACCESS, client, pWin)) - { + if (XaceHook(XACE_BACKGRND_ACCESS, client, pWin)) + pWin->backgroundState = None; + else { pWin->backgroundState = BackgroundPixel; pWin->background.pixel = 0; } - else -#endif - pWin->backgroundState = None; pWin->borderIsPixel = pParent->borderIsPixel; pWin->border = pParent->border; @@ -769,9 +763,7 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, REGION_NULL(pScreen, &pWin->winSize); REGION_NULL(pScreen, &pWin->borderSize); -#ifdef XACE XaceHook(XACE_WINDOW_INIT, client, pWin); -#endif pHead = RealChildHead(pParent); if (pHead) @@ -1036,24 +1028,18 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt borderRelative = TRUE; if (pixID == None) { -#ifdef XACE /* can't let untrusted clients have background None windows */ - if (XaceHook(XACE_BACKGRND_ACCESS, client, pWin)) - { -#endif - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - if (!pWin->parent) - MakeRootTile(pWin); - else - pWin->backgroundState = None; -#ifdef XACE - } - else - { /* didn't change the background to None, so don't tell ddx */ + if (XaceHook(XACE_BACKGRND_ACCESS, client, pWin)) { + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + if (!pWin->parent) + MakeRootTile(pWin); + else + pWin->backgroundState = None; + } else { + /* didn't change the backgrnd to None, so don't tell ddx */ index2 = 0; } -#endif } else if (pixID == ParentRelative) { @@ -2739,11 +2725,9 @@ MapWindow(register WindowPtr pWin, ClientPtr client) if (pWin->mapped) return(Success); -#ifdef XACE /* general check for permission to map window */ if (!XaceHook(XACE_MAP_ACCESS, client, pWin)) return Success; -#endif pScreen = pWin->drawable.pScreen; if ( (pParent = pWin->parent) ) diff --git a/os/access.c b/os/access.c index cdb17589c..d61edeffc 100644 --- a/os/access.c +++ b/os/access.c @@ -202,9 +202,7 @@ SOFTWARE. #include "dixstruct.h" #include "osdep.h" -#ifdef XACE #include "xace.h" -#endif #ifndef PATH_MAX #ifdef MAXPATHLEN @@ -1528,11 +1526,11 @@ AuthorizedClient(ClientPtr client) { if (!client || defeatAccessControl) return TRUE; -#ifdef XACE + /* untrusted clients can't change host access */ if (!XaceHook(XACE_HOSTLIST_ACCESS, client, SecurityWriteAccess)) return FALSE; -#endif + return LocalClient(client); } diff --git a/os/connection.c b/os/connection.c index 100f1e522..ffe911e45 100644 --- a/os/connection.c +++ b/os/connection.c @@ -148,9 +148,7 @@ extern __const__ int _nfiles; #ifdef XAPPGROUP #include "appgroup.h" #endif -#ifdef XACE #include "xace.h" -#endif #ifdef XCSECURITY #include "securitysrv.h" #endif @@ -750,9 +748,9 @@ ClientAuthorized(ClientPtr client, /* indicate to Xdmcp protocol that we've opened new client */ XdmcpOpenDisplay(priv->fd); #endif /* XDMCP */ -#ifdef XACE + XaceHook(XACE_AUTH_AVAIL, client, auth_id); -#endif + /* At this point, if the client is authorized to change the access control * list, we should getpeername() information, and add the client to * the selfhosts list. It's not really the host machine, but the From ac90ce58ba1da3ed605adf75f4d54c34b578c402 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 1 Dec 2006 21:12:21 -0500 Subject: [PATCH 063/109] Naming change: Security*Operation -> Xace*Operation --- Xext/security.c | 14 +++++++------- Xext/xace.c | 2 +- Xext/xace.h | 10 +++++----- dix/property.c | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Xext/security.c b/Xext/security.c index ac762794a..572f81196 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -1251,7 +1251,7 @@ typedef struct _PropertyAccessRec { } PropertyAccessRec, *PropertyAccessPtr; static PropertyAccessPtr PropertyAccessList = NULL; -static char SecurityDefaultAction = SecurityErrorOperation; +static char SecurityDefaultAction = XaceErrorOperation; static char *SecurityPolicyFile = DEFAULTPOLICYFILE; static ATOM SecurityMaxPropertyName = 0; @@ -1410,9 +1410,9 @@ SecurityParsePropertyAccessRule( { switch (c) { - case 'i': action = SecurityIgnoreOperation; break; - case 'a': action = SecurityAllowOperation; break; - case 'e': action = SecurityErrorOperation; break; + case 'i': action = XaceIgnoreOperation; break; + case 'a': action = XaceAllowOperation; break; + case 'e': action = XaceErrorOperation; break; case 'r': readAction = action; break; case 'w': writeAction = action; break; @@ -1797,7 +1797,7 @@ CALLBACK(SecurityCheckPropertyAccess) * If pacl doesn't apply, something above should have * executed a continue, which will skip the follwing code. */ - action = SecurityAllowOperation; + action = XaceAllowOperation; if (access_mode & SecurityReadAccess) action = max(action, pacl->readAction); if (access_mode & SecurityWriteAccess) @@ -1808,11 +1808,11 @@ CALLBACK(SecurityCheckPropertyAccess) } /* end for each pacl */ } /* end if propertyName <= SecurityMaxPropertyName */ - if (SecurityAllowOperation != action) + if (XaceAllowOperation != action) { /* audit the access violation */ int cid = CLIENT_ID(pWin->drawable.id); int reqtype = ((xReq *)client->requestBuffer)->reqType; - char *actionstr = (SecurityIgnoreOperation == action) ? + char *actionstr = (XaceIgnoreOperation == action) ? "ignored" : "error"; SecurityAudit("client %d attempted request %d with window 0x%x property %s (atom 0x%x) of client %d, %s\n", client->index, reqtype, pWin->drawable.id, diff --git a/Xext/xace.c b/Xext/xace.c index 7f7944a17..6fc5c12ee 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -99,7 +99,7 @@ int XaceHook(int hook, ...) va_arg(ap, WindowPtr), va_arg(ap, Atom), va_arg(ap, Mask), - SecurityAllowOperation /* default allow */ + XaceAllowOperation /* default allow */ }; calldata = &rec; prv = &rec.rval; diff --git a/Xext/xace.h b/Xext/xace.h index 6f998951e..7231b04bc 100644 --- a/Xext/xace.h +++ b/Xext/xace.h @@ -21,9 +21,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _XACE_H /* Hook return codes */ -#define SecurityErrorOperation 0 -#define SecurityAllowOperation 1 -#define SecurityIgnoreOperation 2 +#define XaceErrorOperation 0 +#define XaceAllowOperation 1 +#define XaceIgnoreOperation 2 #ifdef XACE @@ -107,10 +107,10 @@ extern void XaceCensorImage( /* Define calls away when XACE is not being built. */ #ifdef __GNUC__ -#define XaceHook(args...) SecurityAllowOperation +#define XaceHook(args...) XaceAllowOperation #define XaceCensorImage(args...) { ; } #else -#define XaceHook(...) SecurityAllowOperation +#define XaceHook(...) XaceAllowOperation #define XaceCensorImage(...) { ; } #endif diff --git a/dix/property.c b/dix/property.c index 0946b65e1..00d485655 100644 --- a/dix/property.c +++ b/dix/property.c @@ -119,12 +119,12 @@ ProcRotateProperties(ClientPtr client) char action = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, atoms[i], SecurityReadAccess|SecurityWriteAccess); - if (!ValidAtom(atoms[i]) || (SecurityErrorOperation == action)) { + if (!ValidAtom(atoms[i]) || (XaceErrorOperation == action)) { DEALLOCATE_LOCAL(props); client->errorValue = atoms[i]; return BadAtom; } - if (SecurityIgnoreOperation == action) { + if (XaceIgnoreOperation == action) { DEALLOCATE_LOCAL(props); return Success; } @@ -226,10 +226,10 @@ ProcChangeProperty(ClientPtr client) switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, SecurityWriteAccess)) { - case SecurityErrorOperation: + case XaceErrorOperation: client->errorValue = stuff->property; return BadAtom; - case SecurityIgnoreOperation: + case XaceIgnoreOperation: return Success; } @@ -495,10 +495,10 @@ ProcGetProperty(ClientPtr client) switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, access_mode)) { - case SecurityErrorOperation: + case XaceErrorOperation: client->errorValue = stuff->property; return BadAtom;; - case SecurityIgnoreOperation: + case XaceIgnoreOperation: return NullPropertyReply(client, pProp->type, pProp->format, &reply); } @@ -649,10 +649,10 @@ ProcDeleteProperty(register ClientPtr client) switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, SecurityDestroyAccess)) { - case SecurityErrorOperation: + case XaceErrorOperation: client->errorValue = stuff->property; return BadAtom;; - case SecurityIgnoreOperation: + case XaceIgnoreOperation: return Success; } From f9f7d7f3be53c808abb5eaceb7a1abc55744a210 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 4 Dec 2006 13:36:30 -0800 Subject: [PATCH 064/109] Check for __sparc as well as __sparc__ for compatibility with Sun cc (gcc defines __sparc__, Sun cc defines __sparc) --- hw/xfree86/common/compiler.h | 4 ++-- hw/xfree86/common/xf86.h | 2 +- hw/xfree86/common/xf86Bus.c | 8 ++++---- hw/xfree86/common/xf86Bus.h | 2 +- hw/xfree86/common/xf86Configure.c | 8 ++++---- hw/xfree86/loader/xf86sym.c | 2 +- hw/xfree86/utils/xorgcfg/loadmod.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h index a330fadf4..ea995eda1 100644 --- a/hw/xfree86/common/compiler.h +++ b/hw/xfree86/common/compiler.h @@ -118,7 +118,7 @@ extern int ffs(unsigned long); # if defined(NO_INLINE) || defined(DO_PROTOTYPES) # if !defined(__arm__) -# if !defined(__sparc__) && !defined(__arm32__) \ +# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \ && !(defined(__alpha__) && defined(linux)) \ && !(defined(__ia64__) && defined(linux)) \ @@ -1697,7 +1697,7 @@ static __inline__ void ppc_flush_icache(char *addr) : : "r"(addr) : "memory"); } -# elif defined(__sparc__) || defined(sparc) +# elif defined(__sparc__) || defined(sparc) || defined(__sparc) /* * Like powerpc, we provide byteswapping and no byteswapping functions * here with byteswapping as default, drivers that don't need byteswapping diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index aa73e7dc0..169a957d2 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -64,7 +64,7 @@ extern ScrnInfoPtr xf86CurrentScreen; extern Bool pciSlotClaimed; extern Bool isaSlotClaimed; extern Bool fbSlotClaimed; -#ifdef __sparc__ +#if defined(__sparc__) || defined(__sparc) extern Bool sbusSlotClaimed; #endif extern confDRIRec xf86ConfigDRI; diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index e20837851..7617bf78a 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -113,7 +113,7 @@ void xf86BusProbe(void) { xf86PciProbe(); -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) xf86SbusProbe(); #endif } @@ -2373,7 +2373,7 @@ xf86PostProbe(void) if (fbSlotClaimed) { if (pciSlotClaimed || isaSlotClaimed -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) || sbusSlotClaimed #endif ) { @@ -3006,7 +3006,7 @@ xf86FindPrimaryDevice() } -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) +#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) #include "vgaHW.h" #include "compiler.h" #endif @@ -3018,7 +3018,7 @@ static void CheckGenericGA() { /* This needs to be changed for multiple domains */ -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) +#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h index b7d16089c..b638e9026 100644 --- a/hw/xfree86/common/xf86Bus.h +++ b/hw/xfree86/common/xf86Bus.h @@ -40,7 +40,7 @@ #define _XF86_BUS_H #include "xf86pciBus.h" -#ifdef __sparc__ +#if defined(__sparc__) || defined(__sparc) #include "xf86sbusBus.h" #endif diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index f1f173dd8..f71486c9d 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -48,7 +48,7 @@ #include "Configint.h" #include "vbe.h" #include "xf86DDC.h" -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) #include "xf86Bus.h" #include "xf86Sbus.h" #endif @@ -57,7 +57,7 @@ typedef struct _DevToConfig { GDevRec GDev; pciVideoPtr pVideo; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) sbusDevicePtr sVideo; #endif int iDriver; @@ -134,7 +134,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int if (!DevToConfig[i].pVideo) return NULL; break; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: for (i = 0; i < nDevToConfig; i++) if (DevToConfig[i].sVideo && @@ -213,7 +213,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int NewDevice.GDev.identifier = "ISA Adapter"; NewDevice.GDev.busID = "ISA"; break; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: { char *promPath = NULL; NewDevice.sVideo = (sbusDevicePtr) busData; diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 3051dedaf..1cb7dae08 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -499,7 +499,7 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86AddModuleInfo) SYMFUNC(xf86DeleteModuleInfo) -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) /* xf86sbusBus.c */ SYMFUNC(xf86MatchSbusInstances) SYMFUNC(xf86GetSbusInfoForEntity) diff --git a/hw/xfree86/utils/xorgcfg/loadmod.c b/hw/xfree86/utils/xorgcfg/loadmod.c index 598d0c06a..6f83f3509 100644 --- a/hw/xfree86/utils/xorgcfg/loadmod.c +++ b/hw/xfree86/utils/xorgcfg/loadmod.c @@ -181,7 +181,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86memchr) SYMFUNC(xf86memcmp) SYMFUNC(xf86memcpy) -#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__ia64__) || defined (__amd64__) +#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__sparc) || defined(__ia64__) || defined (__amd64__) /* * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle * structure copies. This causes a problem both here and in shared From 3690de9b1b0902d395bc7d071fc05ebc8f75be2b Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Tue, 5 Dec 2006 12:42:12 -0800 Subject: [PATCH 065/109] Bug #9219: Return BadMatch when trying to name the backing pixmap of an unrealized window. Before this change, ProcCompositeNameWindowPixmap would name the screen pixmap if !pWin->realized. --- composite/compext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composite/compext.c b/composite/compext.c index a7ad4e2fd..ec5e1fab9 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -269,7 +269,10 @@ ProcCompositeNameWindowPixmap (ClientPtr client) client->errorValue = stuff->window; return BadWindow; } - + + if (!pWin->realized) + return BadMatch; + LEGAL_NEW_RESOURCE (stuff->pixmap, client); cw = GetCompWindow (pWin); From 724f9cb578086e8483a2d0636dd6eb05d664d31c Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Tue, 5 Dec 2006 13:44:05 -0800 Subject: [PATCH 066/109] Bug #9219: Use pWin->viewable instead of pWin->realized to catch InputOnly windows too. --- composite/compext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite/compext.c b/composite/compext.c index ec5e1fab9..13936fa18 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -270,7 +270,7 @@ ProcCompositeNameWindowPixmap (ClientPtr client) return BadWindow; } - if (!pWin->realized) + if (!pWin->viewable) return BadMatch; LEGAL_NEW_RESOURCE (stuff->pixmap, client); From abe5e079af715713097ab0daad29a3e9f523c398 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 6 Dec 2006 07:58:03 -0800 Subject: [PATCH 067/109] Update pci.ids to 2006-12-06 from pciids.sf.net --- hw/xfree86/scanpci/pci.ids | 85 +++- hw/xfree86/scanpci/xf86PciStdIds.h | 619 +++++++++++++++++++++++++++-- 2 files changed, 647 insertions(+), 57 deletions(-) diff --git a/hw/xfree86/scanpci/pci.ids b/hw/xfree86/scanpci/pci.ids index c6f565370..d48e25c58 100644 --- a/hw/xfree86/scanpci/pci.ids +++ b/hw/xfree86/scanpci/pci.ids @@ -11,7 +11,7 @@ # This file can be distributed under either the GNU General Public License # (version 2 or higher) or the 3-clause BSD License. # -# Daily snapshot on Tue 2006-10-03 01:05:01 +# Daily snapshot on Wed 2006-12-06 02:05:02 # # Vendors, devices and subsystems. Please keep sorted. @@ -3012,20 +3012,22 @@ 2200 QLA2200 64-bit Fibre Channel Adapter 1077 0002 QLA2200 2300 QLA2300 64-bit Fibre Channel Adapter - 2312 QLA2312 Fibre Channel Adapter + 2312 ISP2312-based 2Gb Fibre Channel to PCI-X HBA 103c 0131 2Gb Fibre Channel - Single port [A7538A] 103c 12ba 2Gb Fibre Channel - Dual port [A6826A] - 2322 QLA2322 Fibre Channel Adapter - 2422 QLA2422 Fibre Channel Adapter + 2322 ISP2322-based 2Gb Fibre Channel to PCI-X HBA + 2422 ISP2422-based 4Gb Fibre Channel to PCI-X HBA 103c 12d7 4Gb Fibre Channel [AB379A] 103c 12dd 4Gb Fibre Channel [AB429A] - 2432 QLA2432 Fibre Channel Adapter - 3010 QLA3010 Network Adapter - 3022 QLA3022 Network Adapter - 4010 QLA4010 iSCSI TOE Adapter - 4022 QLA4022 iSCSI TOE Adapter - 6312 QLA6312 Fibre Channel Adapter - 6322 QLA6322 Fibre Channel Adapter + 2432 ISP2432-based 4Gb Fibre Channel to PCI Express HBA + 3022 ISP4022-based Ethernet NIC + 3032 ISP4032-based Ethernet NIC + 4010 ISP4010-based iSCSI TOE HBA + 4022 ISP4022-based iSCSI TOE HBA + 4032 ISP4032-based iSCSI TOE IPv6 HBA + 5432 SP232-based 4Gb Fibre Channel to PCI Express HBA + 6312 SP202-based 2Gb Fibre Channel to PCI-X HBA + 6322 SP212-based 2Gb Fibre Channel to PCI-X HBA 1078 Cyrix Corporation 0000 5510 [Grappa] 0001 PCI Master @@ -10565,7 +10567,9 @@ 16be 1040 V.9X DSP Data Fax Modem 1043 PRO/Wireless LAN 2100 3B Mini PCI Adapter 103c 08b0 tc1100 tablet + 8086 2522 Samsung P30 integrated WLAN 8086 2527 MIM2000/Centrino + 8086 2581 Toshiba Satellite M10 1048 PRO/10GbE LR Server Adapter 8086 a01f PRO/10GbE LR Server Adapter 8086 a11f PRO/10GbE LR Server Adapter @@ -10583,6 +10587,10 @@ 1051 82801EB/ER (ICH5/ICH5R) integrated LAN Controller 1052 PRO/100 VM Network Connection 1053 PRO/100 VM Network Connection + 1054 PRO/100 VE Network Connection + 1055 PRO/100 VM Network Connection + 1056 PRO/100 VE Network Connection + 1057 PRO/100 VE Network Connection 1059 82551QM Ethernet Controller 105b 82546GB Gigabit Ethernet Controller (Copper) 105e 82571EB Gigabit Ethernet Controller @@ -10673,19 +10681,30 @@ 108c 82573E Gigabit Ethernet Controller (Copper) 108e 82573E KCS (Active Management) 108f Active Management Technology - SOL + 1091 PRO/100 VM Network Connection 1092 PRO/100 VE Network Connection + 1093 PRO/100 VM Network Connection + 1094 PRO/100 VE Network Connection + 1095 PRO/100 VE Network Connection 1096 80003ES2LAN Gigabit Ethernet Controller (Copper) 1097 631xESB/632xESB DPT LAN Controller (Fiber) 1098 80003ES2LAN Gigabit Ethernet Controller (Serdes) 1099 82546GB Gigabit Ethernet Controller (Copper) 8086 1099 PRO/1000 GT Quad Port Server Adapter 109a 82573L Gigabit Ethernet Controller + 1179 ff10 PRO/1000 PL 17aa 2001 ThinkPad T60 17aa 207e Thinkpad X60s 8086 109a PRO/1000 PL Network Connection 109b 82546GB PRO/1000 GF Quad Port Server Adapter + 109e 82597EX 10GbE Ethernet Controller + 8086 a01f PRO/10GbE CX4 Server Adapter + 8086 a11f PRO/10GbE CX4 Server Adapter 10a0 82571EB PRO/1000 AT Quad Port Bypass Adapter 10a1 82571EB PRO/1000 AF Quad Port Bypass Adapter + 10a4 82571EB Gigabit Ethernet Controller + 8086 10a4 PRO/1000 PT Quad Port Server Adapter + 8086 11a4 PRO/1000 PT Quad Port Server Adapter 10b0 82573L PRO/1000 PL Network Connection 10b2 82573V PRO/1000 PM Network Connection 10b3 82573E PRO/1000 PM Network Connection @@ -10699,6 +10718,11 @@ 8086 1093 PRO/1000 PT Desktop Adapter 10ba 80003ES2LAN Gigabit Ethernet Controller (Copper) 10bb 80003ES2LAN Gigabit Ethernet Controller (Serdes) + 10bc 82571EB Gigabit Ethernet Controller (Copper) + 8086 10bc PRO/1000 PT Quad Port LP Server Adapter + 8086 11bc PRO/1000 PT Quad Port LP Server Adapter + 10c4 82562GT 10/100 Network Connection + 10c5 82562G 10/100 Network Connection 1107 PRO/1000 MF Server Adapter (LX) 1130 82815 815 Chipset Host Bridge and Memory Controller Hub 1025 1016 Travelmate 612 TX @@ -10946,6 +10970,9 @@ 1a31 82845 845 (Brookdale) Chipset AGP Bridge 1a38 5000 Series Chipset DMA Engine 1a48 PRO/10GbE SR Server Adapter + 1b48 82597EX 10GbE Ethernet Controller + 8086 a01f PRO/10GbE LR Server Adapter + 8086 a11f PRO/10GbE LR Server Adapter 2410 82801AA ISA Bridge (LPC) 2411 82801AA IDE 2412 82801AA USB @@ -10998,6 +11025,7 @@ 147b 0507 TH7II-RAID 8086 4532 D815EEA2 mainboard 2445 82801BA/BAM AC'97 Audio + 0e11 000b Compaq Deskpro EN Audio 0e11 0088 Evo D500 1014 01c6 Netvista A40/A40p 1025 1016 Travelmate 612 TX @@ -11010,6 +11038,7 @@ 104d 80df Vaio PCG-FX403 2448 82801 Mobile PCI Bridge 103c 099c NX6110/NC6120 + 144d c00c P30 notebook 1734 1055 Amilo M1420 2449 82801BA/BAM/CA/CAM Ethernet Controller 0e11 0012 EtherExpress PRO/100 VM @@ -11129,6 +11158,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 1462 5800 845PE Max (MS-6580) 1509 2990 Averatec 5110H laptop 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) @@ -11160,6 +11190,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 1462 5800 845PE Max (MS-6580) 1509 2990 Averatec 5110H 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) @@ -11177,6 +11208,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 1458 a002 GA-8PE667 Ultra 1462 5800 845PE Max (MS-6580) 1734 1005 D1451 (SCENIC N300, i845GV) Sigmatel STAC9750T @@ -11190,6 +11222,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 24c7 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 1014 0267 NetVista A30p 1014 052d Thinkpad R50e model 1634 @@ -11201,6 +11234,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 1462 5800 845PE Max (MS-6580) 1509 2990 Averatec 5110H 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) @@ -11215,6 +11249,7 @@ 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet 1071 8160 MIM2000 + 144d c00c P30 notebook 1734 1055 Amilo M1420 8086 4541 Latitude D400 24cb 82801DB (ICH4) IDE Controller @@ -11225,6 +11260,7 @@ 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) 4c53 1090 Cx9 / Vx9 mainboard 24cc 82801DBM (ICH4-M) LPC Interface Bridge + 144d c00c P30 notebook 1734 1055 Amilo M1420 24cd 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller 1014 0267 NetVista A30p @@ -11240,6 +11276,7 @@ 103c 08b0 tc1100 tablet 1071 8160 MIM2000 1179 ff00 Satellite 2430 + 144d c00c P30 notebook 1462 3981 845PE Max (MS-6580) 1509 1968 Averatec 5110H 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) @@ -11278,6 +11315,7 @@ 1014 02ed xSeries server mainboard 1028 0156 Precision 360 1028 0169 Precision 470 + 103c 12bc d330 uT 1043 80a6 P4P800 Mainboard 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) 1462 7280 865PE Neo2 (MS-6728) @@ -11304,6 +11342,7 @@ 8086 4c43 Desktop Board D865GLC 8086 524c D865PERL mainboard 24d5 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller + 100a 147b Abit IS7-E motherboard 1028 0169 Precision 470 103c 006a NX9500 103c 12bc d330 uT @@ -11427,6 +11466,7 @@ 1734 1004 D1451 Mainboard (SCENIC N300, i845GV) 2570 82865G/PE/P DRAM Controller/Host-Hub Interface 103c 006a NX9500 + 103c 12bc d330 uT 1043 80f2 P5P800-MX Mainboard 1458 2570 GA-8IPE1000 Pro2 motherboard (865PE) 2571 82865G/PE/P PCI to AGP Controller @@ -11533,7 +11573,7 @@ 25e5 5000 Series Chipset PCI Express x4 Port 5 25e6 5000 Series Chipset PCI Express x4 Port 6 25e7 5000 Series Chipset PCI Express x4 Port 7 - 25f0 5000 Series Chipset Error Reporting Registers + 25f0 5000 Series Chipset FSB Registers 25f1 5000 Series Chipset Reserved Registers 25f3 5000 Series Chipset Reserved Registers 25f5 5000 Series Chipset FBD Registers @@ -11554,7 +11594,7 @@ 2609 E8500/E8501 PCI Express x8 Port B 260a E8500/E8501 PCI Express x8 Port A 260c E8500/E8501 IMI Registers - 2610 E8500/E8501 Front Side Bus, Boot, and Interrupt Registers + 2610 E8500/E8501 FSB Registers 2611 E8500/E8501 Address Mapping Registers 2612 E8500/E8501 RAS Registers 2613 E8500/E8501 Reserved Registers @@ -11713,6 +11753,7 @@ 107b 5048 E4500 8086 544e DeskTop Board D945GTP 27b9 82801GBM (ICH7-M) LPC Interface Bridge + 10f7 8338 Panasonic CF-Y5 laptop 17aa 2009 ThinkPad T60/R60 series 27bd 82801GHM (ICH7-M DH) LPC Interface Bridge 27c0 82801GB/GR/GH (ICH7 Family) Serial ATA Storage Controller IDE @@ -11749,9 +11790,12 @@ 27d6 82801G (ICH7 Family) PCI Express Port 4 27d8 82801G (ICH7 Family) High Definition Audio Controller 107b 5048 E4500 + 10f7 8338 Panasonic CF-Y5 laptop + 1179 ff31 Toshiba America Information Systems:AC97 Data Fax SoftModem with SmartCP 152d 0753 Softmodem 17aa 2010 ThinkPad T60/R60 series 27da 82801G (ICH7 Family) SMBus Controller + 10f7 8338 Panasonic CF-Y5 laptop 17aa 200f ThinkPad T60/R60 series 8086 544e DeskTop Board D945GTP 27dc 82801G (ICH7 Family) LAN Controller @@ -11760,6 +11804,7 @@ 27de 82801G (ICH7 Family) AC'97 Audio Controller 27df 82801G (ICH7 Family) IDE Controller 107b 5048 E4500 + 10f7 8338 Panasonic CF-Y5 laptop 17aa 200c Thinkpad R60e model 0657 8086 544e DeskTop Board D945GTP 27e0 82801GR/GH/GHM (ICH7 Family) PCI Express Port 5 @@ -11770,21 +11815,28 @@ 2814 82801HO (ICH8DO) LPC Interface Controller 2815 Mobile LPC Interface Controller 2820 82801H (ICH8 Family) 4 port SATA IDE Controller - 2821 82801HB (ICH8) SATA AHCI Controller + 1462 7235 P965 Neo MS-7235 mainboard + 2821 82801HR/HO/HH (ICH8R/DO/DH) 6 port SATA AHCI Controller 2822 82801HR/HO/HH (ICH8R/DO/DH) SATA RAID Controller - 2824 82801HR/HO/HH (ICH8R/DO/DH) SATA AHCI Controller + 2824 82801HB (ICH8) 4 port SATA AHCI Controller 2825 82801H (ICH8 Family) 2 port SATA IDE Controller + 1462 7235 P965 Neo MS-7235 mainboard 2828 Mobile SATA IDE Controller 2829 Mobile SATA AHCI Controller 282a Mobile SATA RAID Controller 2830 82801H (ICH8 Family) USB UHCI #1 + 1462 7235 P965 Neo MS-7235 mainboard 2831 82801H (ICH8 Family) USB UHCI #2 + 1462 7235 P965 Neo MS-7235 mainboard 2832 82801H (ICH8 Family) USB UHCI #3 2834 82801H (ICH8 Family) USB UHCI #4 + 1462 7235 P965 Neo MS-7235 mainboard 2835 82801H (ICH8 Family) USB UHCI #5 2836 82801H (ICH8 Family) USB2 EHCI #1 + 1462 7235 P965 Neo MS-7235 mainboard 283a 82801H (ICH8 Family) USB2 EHCI #2 283e 82801H (ICH8 Family) SMBus Controller + 1462 7235 P965 Neo MS-7235 mainboard 283f 82801H (ICH8 Family) PCI Express Port 1 2841 82801H (ICH8 Family) PCI Express Port 2 2843 82801H (ICH8 Family) PCI Express Port 3 @@ -11831,12 +11883,15 @@ 2a07 Mobile KT Controller 3092 Integrated RAID 3200 GD31244 PCI-X SATA HBA + 1775 c200 C2K onboard SATA host bus adapter 3340 82855PM Processor to I/O Controller 1025 005a TravelMate 290 103c 088c NC8000 laptop 103c 0890 NC6000 laptop 103c 08b0 tc1100 tablet + 144d c00c P30 notebook 3341 82855PM Processor to AGP Controller + 144d c00c P30 notebook 3500 6311ESB/6321ESB PCI Express Upstream Port 3501 6310ESB PCI Express Upstream Port 3504 6311ESB/6321ESB I/OxAPIC Interrupt Controller diff --git a/hw/xfree86/scanpci/xf86PciStdIds.h b/hw/xfree86/scanpci/xf86PciStdIds.h index d86d686c8..0cf8d4e55 100644 --- a/hw/xfree86/scanpci/xf86PciStdIds.h +++ b/hw/xfree86/scanpci/xf86PciStdIds.h @@ -5712,7 +5712,7 @@ static const char pci_device_1077_2200[] = "QLA2200 64-bit Fibre Channel Adapter static const char pci_subsys_1077_2200_1077_0002[] = "QLA2200"; #endif static const char pci_device_1077_2300[] = "QLA2300 64-bit Fibre Channel Adapter"; -static const char pci_device_1077_2312[] = "QLA2312 Fibre Channel Adapter"; +static const char pci_device_1077_2312[] = "ISP2312-based 2Gb Fibre Channel to PCI-X HBA"; #endif #ifdef INIT_SUBSYS_INFO static const char pci_subsys_1077_2312_103c_0131[] = "2Gb Fibre Channel - Single port [A7538A]"; @@ -5723,8 +5723,8 @@ static const char pci_subsys_1077_2312_103c_0131[] = "2Gb Fibre Channel - Single static const char pci_subsys_1077_2312_103c_12ba[] = "2Gb Fibre Channel - Dual port [A6826A]"; #endif #ifdef VENDOR_INCLUDE_NONVIDEO -static const char pci_device_1077_2322[] = "QLA2322 Fibre Channel Adapter"; -static const char pci_device_1077_2422[] = "QLA2422 Fibre Channel Adapter"; +static const char pci_device_1077_2322[] = "ISP2322-based 2Gb Fibre Channel to PCI-X HBA"; +static const char pci_device_1077_2422[] = "ISP2422-based 4Gb Fibre Channel to PCI-X HBA"; #endif #ifdef INIT_SUBSYS_INFO static const char pci_subsys_1077_2422_103c_12d7[] = "4Gb Fibre Channel [AB379A]"; @@ -5735,13 +5735,15 @@ static const char pci_subsys_1077_2422_103c_12d7[] = "4Gb Fibre Channel [AB379A] static const char pci_subsys_1077_2422_103c_12dd[] = "4Gb Fibre Channel [AB429A]"; #endif #ifdef VENDOR_INCLUDE_NONVIDEO -static const char pci_device_1077_2432[] = "QLA2432 Fibre Channel Adapter"; -static const char pci_device_1077_3010[] = "QLA3010 Network Adapter"; -static const char pci_device_1077_3022[] = "QLA3022 Network Adapter"; -static const char pci_device_1077_4010[] = "QLA4010 iSCSI TOE Adapter"; -static const char pci_device_1077_4022[] = "QLA4022 iSCSI TOE Adapter"; -static const char pci_device_1077_6312[] = "QLA6312 Fibre Channel Adapter"; -static const char pci_device_1077_6322[] = "QLA6322 Fibre Channel Adapter"; +static const char pci_device_1077_2432[] = "ISP2432-based 4Gb Fibre Channel to PCI Express HBA"; +static const char pci_device_1077_3022[] = "ISP4022-based Ethernet NIC"; +static const char pci_device_1077_3032[] = "ISP4032-based Ethernet NIC"; +static const char pci_device_1077_4010[] = "ISP4010-based iSCSI TOE HBA"; +static const char pci_device_1077_4022[] = "ISP4022-based iSCSI TOE HBA"; +static const char pci_device_1077_4032[] = "ISP4032-based iSCSI TOE IPv6 HBA"; +static const char pci_device_1077_5432[] = "SP232-based 4Gb Fibre Channel to PCI Express HBA"; +static const char pci_device_1077_6312[] = "SP202-based 2Gb Fibre Channel to PCI-X HBA"; +static const char pci_device_1077_6322[] = "SP212-based 2Gb Fibre Channel to PCI-X HBA"; #endif static const char pci_vendor_1078[] = "Cyrix Corporation"; static const char pci_device_1078_0000[] = "5510 [Grappa]"; @@ -20449,10 +20451,8 @@ static const char pci_device_19e7_1003[] = "STIX - 2 Port T1/E1 Card"; static const char pci_device_19e7_1004[] = "STIX - 4 Port T1/E1 Card"; static const char pci_device_19e7_1005[] = "STIX - 4 Port FXS Card"; #endif -#ifdef VENDOR_INCLUDE_NONVIDEO static const char pci_vendor_1a03[] = "ASPEED Technology, Inc."; static const char pci_device_1a03_2000[] = "AST2000"; -#endif #ifdef VENDOR_INCLUDE_NONVIDEO static const char pci_vendor_1a08[] = "Sierra semiconductor"; static const char pci_device_1a08_0000[] = "SC15064"; @@ -21670,8 +21670,14 @@ static const char pci_device_8086_1043[] = "PRO/Wireless LAN 2100 3B Mini PCI Ad static const char pci_subsys_8086_1043_103c_08b0[] = "tc1100 tablet"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_1043_8086_2522[] = "Samsung P30 integrated WLAN"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_1043_8086_2527[] = "MIM2000/Centrino"; #endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_1043_8086_2581[] = "Toshiba Satellite M10"; +#endif static const char pci_device_8086_1048[] = "PRO/10GbE LR Server Adapter"; #ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_1048_8086_a01f[] = "PRO/10GbE LR Server Adapter"; @@ -21703,6 +21709,10 @@ static const char pci_subsys_8086_1050_8086_3427[] = "S875WP1-E mainboard"; static const char pci_device_8086_1051[] = "82801EB/ER (ICH5/ICH5R) integrated LAN Controller"; static const char pci_device_8086_1052[] = "PRO/100 VM Network Connection"; static const char pci_device_8086_1053[] = "PRO/100 VM Network Connection"; +static const char pci_device_8086_1054[] = "PRO/100 VE Network Connection"; +static const char pci_device_8086_1055[] = "PRO/100 VM Network Connection"; +static const char pci_device_8086_1056[] = "PRO/100 VE Network Connection"; +static const char pci_device_8086_1057[] = "PRO/100 VE Network Connection"; static const char pci_device_8086_1059[] = "82551QM Ethernet Controller"; static const char pci_device_8086_105b[] = "82546GB Gigabit Ethernet Controller (Copper)"; static const char pci_device_8086_105e[] = "82571EB Gigabit Ethernet Controller"; @@ -21897,7 +21907,11 @@ static const char pci_device_8086_108b[] = "82573V Gigabit Ethernet Controller ( static const char pci_device_8086_108c[] = "82573E Gigabit Ethernet Controller (Copper)"; static const char pci_device_8086_108e[] = "82573E KCS (Active Management)"; static const char pci_device_8086_108f[] = "Active Management Technology - SOL"; +static const char pci_device_8086_1091[] = "PRO/100 VM Network Connection"; static const char pci_device_8086_1092[] = "PRO/100 VE Network Connection"; +static const char pci_device_8086_1093[] = "PRO/100 VM Network Connection"; +static const char pci_device_8086_1094[] = "PRO/100 VE Network Connection"; +static const char pci_device_8086_1095[] = "PRO/100 VE Network Connection"; static const char pci_device_8086_1096[] = "80003ES2LAN Gigabit Ethernet Controller (Copper)"; static const char pci_device_8086_1097[] = "631xESB/632xESB DPT LAN Controller (Fiber)"; static const char pci_device_8086_1098[] = "80003ES2LAN Gigabit Ethernet Controller (Serdes)"; @@ -21907,6 +21921,9 @@ static const char pci_subsys_8086_1099_8086_1099[] = "PRO/1000 GT Quad Port Serv #endif static const char pci_device_8086_109a[] = "82573L Gigabit Ethernet Controller"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_109a_1179_ff10[] = "PRO/1000 PL"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_109a_17aa_2001[] = "ThinkPad T60"; #endif #ifdef INIT_SUBSYS_INFO @@ -21916,8 +21933,22 @@ static const char pci_subsys_8086_109a_17aa_207e[] = "Thinkpad X60s"; static const char pci_subsys_8086_109a_8086_109a[] = "PRO/1000 PL Network Connection"; #endif static const char pci_device_8086_109b[] = "82546GB PRO/1000 GF Quad Port Server Adapter"; +static const char pci_device_8086_109e[] = "82597EX 10GbE Ethernet Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_109e_8086_a01f[] = "PRO/10GbE CX4 Server Adapter"; +#endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_109e_8086_a11f[] = "PRO/10GbE CX4 Server Adapter"; +#endif static const char pci_device_8086_10a0[] = "82571EB PRO/1000 AT Quad Port Bypass Adapter"; static const char pci_device_8086_10a1[] = "82571EB PRO/1000 AF Quad Port Bypass Adapter"; +static const char pci_device_8086_10a4[] = "82571EB Gigabit Ethernet Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_10a4_8086_10a4[] = "PRO/1000 PT Quad Port Server Adapter"; +#endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_10a4_8086_11a4[] = "PRO/1000 PT Quad Port Server Adapter"; +#endif static const char pci_device_8086_10b0[] = "82573L PRO/1000 PL Network Connection"; static const char pci_device_8086_10b2[] = "82573V PRO/1000 PM Network Connection"; static const char pci_device_8086_10b3[] = "82573E PRO/1000 PM Network Connection"; @@ -21941,6 +21972,15 @@ static const char pci_subsys_8086_10b9_8086_1093[] = "PRO/1000 PT Desktop Adapte #endif static const char pci_device_8086_10ba[] = "80003ES2LAN Gigabit Ethernet Controller (Copper)"; static const char pci_device_8086_10bb[] = "80003ES2LAN Gigabit Ethernet Controller (Serdes)"; +static const char pci_device_8086_10bc[] = "82571EB Gigabit Ethernet Controller (Copper)"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_10bc_8086_10bc[] = "PRO/1000 PT Quad Port LP Server Adapter"; +#endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_10bc_8086_11bc[] = "PRO/1000 PT Quad Port LP Server Adapter"; +#endif +static const char pci_device_8086_10c4[] = "82562GT 10/100 Network Connection"; +static const char pci_device_8086_10c5[] = "82562G 10/100 Network Connection"; static const char pci_device_8086_1107[] = "PRO/1000 MF Server Adapter (LX)"; static const char pci_device_8086_1130[] = "82815 815 Chipset Host Bridge and Memory Controller Hub"; #ifdef INIT_SUBSYS_INFO @@ -22587,6 +22627,13 @@ static const char pci_subsys_8086_1a30_1028_010e[] = "Optiplex GX240"; static const char pci_device_8086_1a31[] = "82845 845 (Brookdale) Chipset AGP Bridge"; static const char pci_device_8086_1a38[] = "5000 Series Chipset DMA Engine"; static const char pci_device_8086_1a48[] = "PRO/10GbE SR Server Adapter"; +static const char pci_device_8086_1b48[] = "82597EX 10GbE Ethernet Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_1b48_8086_a01f[] = "PRO/10GbE LR Server Adapter"; +#endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_1b48_8086_a11f[] = "PRO/10GbE LR Server Adapter"; +#endif static const char pci_device_8086_2410[] = "82801AA ISA Bridge (LPC)"; static const char pci_device_8086_2411[] = "82801AA IDE"; static const char pci_device_8086_2412[] = "82801AA USB"; @@ -22706,6 +22753,9 @@ static const char pci_subsys_8086_2444_8086_4532[] = "D815EEA2 mainboard"; #endif static const char pci_device_8086_2445[] = "82801BA/BAM AC'97 Audio"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2445_0e11_000b[] = "Compaq Deskpro EN Audio"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_2445_0e11_0088[] = "Evo D500"; #endif #ifdef INIT_SUBSYS_INFO @@ -22738,6 +22788,9 @@ static const char pci_device_8086_2448[] = "82801 Mobile PCI Bridge"; static const char pci_subsys_8086_2448_103c_099c[] = "NX6110/NC6120"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2448_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_2448_1734_1055[] = "Amilo M1420"; #endif static const char pci_device_8086_2449[] = "82801BA/BAM/CA/CAM Ethernet Controller"; @@ -23045,6 +23098,9 @@ static const char pci_subsys_8086_24c2_103c_08b0[] = "tc1100 tablet"; static const char pci_subsys_8086_24c2_1071_8160[] = "MIM2000"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24c2_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c2_1462_5800[] = "845PE Max (MS-6580)"; #endif #ifdef INIT_SUBSYS_INFO @@ -23134,6 +23190,9 @@ static const char pci_subsys_8086_24c4_103c_08b0[] = "tc1100 tablet"; static const char pci_subsys_8086_24c4_1071_8160[] = "MIM2000"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24c4_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c4_1462_5800[] = "845PE Max (MS-6580)"; #endif #ifdef INIT_SUBSYS_INFO @@ -23183,6 +23242,9 @@ static const char pci_subsys_8086_24c5_103c_08b0[] = "tc1100 tablet"; static const char pci_subsys_8086_24c5_1071_8160[] = "MIM2000"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24c5_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c5_1458_a002[] = "GA-8PE667 Ultra"; #endif #ifdef INIT_SUBSYS_INFO @@ -23219,6 +23281,9 @@ static const char pci_subsys_8086_24c6_103c_08b0[] = "tc1100 tablet"; #ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c6_1071_8160[] = "MIM2000"; #endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24c6_144d_c00c[] = "P30 notebook"; +#endif static const char pci_device_8086_24c7[] = "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3"; #ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c7_1014_0267[] = "NetVista A30p"; @@ -23251,6 +23316,9 @@ static const char pci_subsys_8086_24c7_103c_08b0[] = "tc1100 tablet"; static const char pci_subsys_8086_24c7_1071_8160[] = "MIM2000"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24c7_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24c7_1462_5800[] = "845PE Max (MS-6580)"; #endif #ifdef INIT_SUBSYS_INFO @@ -23291,6 +23359,9 @@ static const char pci_subsys_8086_24ca_103c_08b0[] = "tc1100 tablet"; static const char pci_subsys_8086_24ca_1071_8160[] = "MIM2000"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24ca_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24ca_1734_1055[] = "Amilo M1420"; #endif #ifdef INIT_SUBSYS_INFO @@ -23317,6 +23388,9 @@ static const char pci_subsys_8086_24cb_4c53_1090[] = "Cx9 / Vx9 mainboard"; #endif static const char pci_device_8086_24cc[] = "82801DBM (ICH4-M) LPC Interface Bridge"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24cc_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24cc_1734_1055[] = "Amilo M1420"; #endif static const char pci_device_8086_24cd[] = "82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller"; @@ -23360,6 +23434,9 @@ static const char pci_subsys_8086_24cd_1071_8160[] = "MIM2000"; static const char pci_subsys_8086_24cd_1179_ff00[] = "Satellite 2430"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24cd_144d_c00c[] = "P30 notebook"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24cd_1462_3981[] = "845PE Max (MS-6580)"; #endif #ifdef INIT_SUBSYS_INFO @@ -23466,6 +23543,9 @@ static const char pci_subsys_8086_24d3_1028_0156[] = "Precision 360"; static const char pci_subsys_8086_24d3_1028_0169[] = "Precision 470"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24d3_103c_12bc[] = "d330 uT"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24d3_1043_80a6[] = "P4P800 Mainboard"; #endif #ifdef INIT_SUBSYS_INFO @@ -23540,6 +23620,9 @@ static const char pci_subsys_8086_24d4_8086_524c[] = "D865PERL mainboard"; #endif static const char pci_device_8086_24d5[] = "82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_24d5_100a_147b[] = "Abit IS7-E motherboard"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_24d5_1028_0169[] = "Precision 470"; #endif #ifdef INIT_SUBSYS_INFO @@ -23835,6 +23918,9 @@ static const char pci_device_8086_2570[] = "82865G/PE/P DRAM Controller/Host-Hub static const char pci_subsys_8086_2570_103c_006a[] = "NX9500"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2570_103c_12bc[] = "d330 uT"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_2570_1043_80f2[] = "P5P800-MX Mainboard"; #endif #ifdef INIT_SUBSYS_INFO @@ -24068,7 +24154,7 @@ static const char pci_device_8086_25e4[] = "5000 Series Chipset PCI Express x4 P static const char pci_device_8086_25e5[] = "5000 Series Chipset PCI Express x4 Port 5"; static const char pci_device_8086_25e6[] = "5000 Series Chipset PCI Express x4 Port 6"; static const char pci_device_8086_25e7[] = "5000 Series Chipset PCI Express x4 Port 7"; -static const char pci_device_8086_25f0[] = "5000 Series Chipset Error Reporting Registers"; +static const char pci_device_8086_25f0[] = "5000 Series Chipset FSB Registers"; static const char pci_device_8086_25f1[] = "5000 Series Chipset Reserved Registers"; static const char pci_device_8086_25f3[] = "5000 Series Chipset Reserved Registers"; static const char pci_device_8086_25f5[] = "5000 Series Chipset FBD Registers"; @@ -24089,7 +24175,7 @@ static const char pci_device_8086_2608[] = "E8500/E8501 PCI Express x8 Port C"; static const char pci_device_8086_2609[] = "E8500/E8501 PCI Express x8 Port B"; static const char pci_device_8086_260a[] = "E8500/E8501 PCI Express x8 Port A"; static const char pci_device_8086_260c[] = "E8500/E8501 IMI Registers"; -static const char pci_device_8086_2610[] = "E8500/E8501 Front Side Bus, Boot, and Interrupt Registers"; +static const char pci_device_8086_2610[] = "E8500/E8501 FSB Registers"; static const char pci_device_8086_2611[] = "E8500/E8501 Address Mapping Registers"; static const char pci_device_8086_2612[] = "E8500/E8501 RAS Registers"; static const char pci_device_8086_2613[] = "E8500/E8501 Reserved Registers"; @@ -24400,6 +24486,9 @@ static const char pci_subsys_8086_27b8_8086_544e[] = "DeskTop Board D945GTP"; #endif static const char pci_device_8086_27b9[] = "82801GBM (ICH7-M) LPC Interface Bridge"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_27b9_10f7_8338[] = "Panasonic CF-Y5 laptop"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_27b9_17aa_2009[] = "ThinkPad T60/R60 series"; #endif static const char pci_device_8086_27bd[] = "82801GHM (ICH7-M DH) LPC Interface Bridge"; @@ -24474,6 +24563,12 @@ static const char pci_device_8086_27d8[] = "82801G (ICH7 Family) High Definition static const char pci_subsys_8086_27d8_107b_5048[] = "E4500"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_27d8_10f7_8338[] = "Panasonic CF-Y5 laptop"; +#endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_27d8_1179_ff31[] = "Toshiba America Information Systems:AC97 Data Fax SoftModem with SmartCP"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_27d8_152d_0753[] = "Softmodem"; #endif #ifdef INIT_SUBSYS_INFO @@ -24481,6 +24576,9 @@ static const char pci_subsys_8086_27d8_17aa_2010[] = "ThinkPad T60/R60 series"; #endif static const char pci_device_8086_27da[] = "82801G (ICH7 Family) SMBus Controller"; #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_27da_10f7_8338[] = "Panasonic CF-Y5 laptop"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_27da_17aa_200f[] = "ThinkPad T60/R60 series"; #endif #ifdef INIT_SUBSYS_INFO @@ -24497,6 +24595,9 @@ static const char pci_device_8086_27df[] = "82801G (ICH7 Family) IDE Controller" static const char pci_subsys_8086_27df_107b_5048[] = "E4500"; #endif #ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_27df_10f7_8338[] = "Panasonic CF-Y5 laptop"; +#endif +#ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_27df_17aa_200c[] = "Thinkpad R60e model 0657"; #endif #ifdef INIT_SUBSYS_INFO @@ -24510,21 +24611,42 @@ static const char pci_device_8086_2812[] = "82801HH (ICH8DH) LPC Interface Contr static const char pci_device_8086_2814[] = "82801HO (ICH8DO) LPC Interface Controller"; static const char pci_device_8086_2815[] = "Mobile LPC Interface Controller"; static const char pci_device_8086_2820[] = "82801H (ICH8 Family) 4 port SATA IDE Controller"; -static const char pci_device_8086_2821[] = "82801HB (ICH8) SATA AHCI Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2820_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif +static const char pci_device_8086_2821[] = "82801HR/HO/HH (ICH8R/DO/DH) 6 port SATA AHCI Controller"; static const char pci_device_8086_2822[] = "82801HR/HO/HH (ICH8R/DO/DH) SATA RAID Controller"; -static const char pci_device_8086_2824[] = "82801HR/HO/HH (ICH8R/DO/DH) SATA AHCI Controller"; +static const char pci_device_8086_2824[] = "82801HB (ICH8) 4 port SATA AHCI Controller"; static const char pci_device_8086_2825[] = "82801H (ICH8 Family) 2 port SATA IDE Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2825_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_2828[] = "Mobile SATA IDE Controller"; static const char pci_device_8086_2829[] = "Mobile SATA AHCI Controller"; static const char pci_device_8086_282a[] = "Mobile SATA RAID Controller"; static const char pci_device_8086_2830[] = "82801H (ICH8 Family) USB UHCI #1"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2830_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_2831[] = "82801H (ICH8 Family) USB UHCI #2"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2831_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_2832[] = "82801H (ICH8 Family) USB UHCI #3"; static const char pci_device_8086_2834[] = "82801H (ICH8 Family) USB UHCI #4"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2834_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_2835[] = "82801H (ICH8 Family) USB UHCI #5"; static const char pci_device_8086_2836[] = "82801H (ICH8 Family) USB2 EHCI #1"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_2836_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_283a[] = "82801H (ICH8 Family) USB2 EHCI #2"; static const char pci_device_8086_283e[] = "82801H (ICH8 Family) SMBus Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_283e_1462_7235[] = "P965 Neo MS-7235 mainboard"; +#endif static const char pci_device_8086_283f[] = "82801H (ICH8 Family) PCI Express Port 1"; static const char pci_device_8086_2841[] = "82801H (ICH8 Family) PCI Express Port 2"; static const char pci_device_8086_2843[] = "82801H (ICH8 Family) PCI Express Port 3"; @@ -24571,6 +24693,9 @@ static const char pci_device_8086_2a06[] = "Mobile PT IDER Controller"; static const char pci_device_8086_2a07[] = "Mobile KT Controller"; static const char pci_device_8086_3092[] = "Integrated RAID"; static const char pci_device_8086_3200[] = "GD31244 PCI-X SATA HBA"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_3200_1775_c200[] = "C2K onboard SATA host bus adapter"; +#endif static const char pci_device_8086_3340[] = "82855PM Processor to I/O Controller"; #ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_3340_1025_005a[] = "TravelMate 290"; @@ -24584,7 +24709,13 @@ static const char pci_subsys_8086_3340_103c_0890[] = "NC6000 laptop"; #ifdef INIT_SUBSYS_INFO static const char pci_subsys_8086_3340_103c_08b0[] = "tc1100 tablet"; #endif +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_3340_144d_c00c[] = "P30 notebook"; +#endif static const char pci_device_8086_3341[] = "82855PM Processor to AGP Controller"; +#ifdef INIT_SUBSYS_INFO +static const char pci_subsys_8086_3341_144d_c00c[] = "P30 notebook"; +#endif static const char pci_device_8086_3500[] = "6311ESB/6321ESB PCI Express Upstream Port"; static const char pci_device_8086_3501[] = "6310ESB PCI Express Upstream Port"; static const char pci_device_8086_3504[] = "6311ESB/6321ESB I/OxAPIC Interrupt Controller"; @@ -40853,10 +40984,18 @@ static const pciSubsystemInfo pci_ss_info_8086_1043_103c_08b0 = {0x103c, 0x08b0, pci_subsys_8086_1043_103c_08b0, 0}; #undef pci_ss_info_103c_08b0 #define pci_ss_info_103c_08b0 pci_ss_info_8086_1043_103c_08b0 +static const pciSubsystemInfo pci_ss_info_8086_1043_8086_2522 = + {0x8086, 0x2522, pci_subsys_8086_1043_8086_2522, 0}; +#undef pci_ss_info_8086_2522 +#define pci_ss_info_8086_2522 pci_ss_info_8086_1043_8086_2522 static const pciSubsystemInfo pci_ss_info_8086_1043_8086_2527 = {0x8086, 0x2527, pci_subsys_8086_1043_8086_2527, 0}; #undef pci_ss_info_8086_2527 #define pci_ss_info_8086_2527 pci_ss_info_8086_1043_8086_2527 +static const pciSubsystemInfo pci_ss_info_8086_1043_8086_2581 = + {0x8086, 0x2581, pci_subsys_8086_1043_8086_2581, 0}; +#undef pci_ss_info_8086_2581 +#define pci_ss_info_8086_2581 pci_ss_info_8086_1043_8086_2581 static const pciSubsystemInfo pci_ss_info_8086_1048_8086_a01f = {0x8086, 0xa01f, pci_subsys_8086_1048_8086_a01f, 0}; #undef pci_ss_info_8086_a01f @@ -41097,6 +41236,10 @@ static const pciSubsystemInfo pci_ss_info_8086_1099_8086_1099 = {0x8086, 0x1099, pci_subsys_8086_1099_8086_1099, 0}; #undef pci_ss_info_8086_1099 #define pci_ss_info_8086_1099 pci_ss_info_8086_1099_8086_1099 +static const pciSubsystemInfo pci_ss_info_8086_109a_1179_ff10 = + {0x1179, 0xff10, pci_subsys_8086_109a_1179_ff10, 0}; +#undef pci_ss_info_1179_ff10 +#define pci_ss_info_1179_ff10 pci_ss_info_8086_109a_1179_ff10 static const pciSubsystemInfo pci_ss_info_8086_109a_17aa_2001 = {0x17aa, 0x2001, pci_subsys_8086_109a_17aa_2001, 0}; #undef pci_ss_info_17aa_2001 @@ -41109,6 +41252,22 @@ static const pciSubsystemInfo pci_ss_info_8086_109a_8086_109a = {0x8086, 0x109a, pci_subsys_8086_109a_8086_109a, 0}; #undef pci_ss_info_8086_109a #define pci_ss_info_8086_109a pci_ss_info_8086_109a_8086_109a +static const pciSubsystemInfo pci_ss_info_8086_109e_8086_a01f = + {0x8086, 0xa01f, pci_subsys_8086_109e_8086_a01f, 0}; +#undef pci_ss_info_8086_a01f +#define pci_ss_info_8086_a01f pci_ss_info_8086_109e_8086_a01f +static const pciSubsystemInfo pci_ss_info_8086_109e_8086_a11f = + {0x8086, 0xa11f, pci_subsys_8086_109e_8086_a11f, 0}; +#undef pci_ss_info_8086_a11f +#define pci_ss_info_8086_a11f pci_ss_info_8086_109e_8086_a11f +static const pciSubsystemInfo pci_ss_info_8086_10a4_8086_10a4 = + {0x8086, 0x10a4, pci_subsys_8086_10a4_8086_10a4, 0}; +#undef pci_ss_info_8086_10a4 +#define pci_ss_info_8086_10a4 pci_ss_info_8086_10a4_8086_10a4 +static const pciSubsystemInfo pci_ss_info_8086_10a4_8086_11a4 = + {0x8086, 0x11a4, pci_subsys_8086_10a4_8086_11a4, 0}; +#undef pci_ss_info_8086_11a4 +#define pci_ss_info_8086_11a4 pci_ss_info_8086_10a4_8086_11a4 static const pciSubsystemInfo pci_ss_info_8086_10b5_103c_3109 = {0x103c, 0x3109, pci_subsys_8086_10b5_103c_3109, 0}; #undef pci_ss_info_103c_3109 @@ -41129,6 +41288,14 @@ static const pciSubsystemInfo pci_ss_info_8086_10b9_8086_1093 = {0x8086, 0x1093, pci_subsys_8086_10b9_8086_1093, 0}; #undef pci_ss_info_8086_1093 #define pci_ss_info_8086_1093 pci_ss_info_8086_10b9_8086_1093 +static const pciSubsystemInfo pci_ss_info_8086_10bc_8086_10bc = + {0x8086, 0x10bc, pci_subsys_8086_10bc_8086_10bc, 0}; +#undef pci_ss_info_8086_10bc +#define pci_ss_info_8086_10bc pci_ss_info_8086_10bc_8086_10bc +static const pciSubsystemInfo pci_ss_info_8086_10bc_8086_11bc = + {0x8086, 0x11bc, pci_subsys_8086_10bc_8086_11bc, 0}; +#undef pci_ss_info_8086_11bc +#define pci_ss_info_8086_11bc pci_ss_info_8086_10bc_8086_11bc static const pciSubsystemInfo pci_ss_info_8086_1130_1025_1016 = {0x1025, 0x1016, pci_subsys_8086_1130_1025_1016, 0}; #undef pci_ss_info_1025_1016 @@ -41929,6 +42096,14 @@ static const pciSubsystemInfo pci_ss_info_8086_1a30_1028_010e = {0x1028, 0x010e, pci_subsys_8086_1a30_1028_010e, 0}; #undef pci_ss_info_1028_010e #define pci_ss_info_1028_010e pci_ss_info_8086_1a30_1028_010e +static const pciSubsystemInfo pci_ss_info_8086_1b48_8086_a01f = + {0x8086, 0xa01f, pci_subsys_8086_1b48_8086_a01f, 0}; +#undef pci_ss_info_8086_a01f +#define pci_ss_info_8086_a01f pci_ss_info_8086_1b48_8086_a01f +static const pciSubsystemInfo pci_ss_info_8086_1b48_8086_a11f = + {0x8086, 0xa11f, pci_subsys_8086_1b48_8086_a11f, 0}; +#undef pci_ss_info_8086_a11f +#define pci_ss_info_8086_a11f pci_ss_info_8086_1b48_8086_a11f static const pciSubsystemInfo pci_ss_info_8086_2415_1028_0095 = {0x1028, 0x0095, pci_subsys_8086_2415_1028_0095, 0}; #undef pci_ss_info_1028_0095 @@ -42061,6 +42236,10 @@ static const pciSubsystemInfo pci_ss_info_8086_2444_8086_4532 = {0x8086, 0x4532, pci_subsys_8086_2444_8086_4532, 0}; #undef pci_ss_info_8086_4532 #define pci_ss_info_8086_4532 pci_ss_info_8086_2444_8086_4532 +static const pciSubsystemInfo pci_ss_info_8086_2445_0e11_000b = + {0x0e11, 0x000b, pci_subsys_8086_2445_0e11_000b, 0}; +#undef pci_ss_info_0e11_000b +#define pci_ss_info_0e11_000b pci_ss_info_8086_2445_0e11_000b static const pciSubsystemInfo pci_ss_info_8086_2445_0e11_0088 = {0x0e11, 0x0088, pci_subsys_8086_2445_0e11_0088, 0}; #undef pci_ss_info_0e11_0088 @@ -42101,6 +42280,10 @@ static const pciSubsystemInfo pci_ss_info_8086_2448_103c_099c = {0x103c, 0x099c, pci_subsys_8086_2448_103c_099c, 0}; #undef pci_ss_info_103c_099c #define pci_ss_info_103c_099c pci_ss_info_8086_2448_103c_099c +static const pciSubsystemInfo pci_ss_info_8086_2448_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_2448_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_2448_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_2448_1734_1055 = {0x1734, 0x1055, pci_subsys_8086_2448_1734_1055, 0}; #undef pci_ss_info_1734_1055 @@ -42477,6 +42660,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24c2_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24c2_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24c2_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24c2_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24c2_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24c2_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24c2_1462_5800 = {0x1462, 0x5800, pci_subsys_8086_24c2_1462_5800, 0}; #undef pci_ss_info_1462_5800 @@ -42593,6 +42780,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24c4_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24c4_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24c4_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24c4_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24c4_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24c4_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24c4_1462_5800 = {0x1462, 0x5800, pci_subsys_8086_24c4_1462_5800, 0}; #undef pci_ss_info_1462_5800 @@ -42657,6 +42848,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24c5_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24c5_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24c5_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24c5_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24c5_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24c5_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24c5_1458_a002 = {0x1458, 0xa002, pci_subsys_8086_24c5_1458_a002, 0}; #undef pci_ss_info_1458_a002 @@ -42705,6 +42900,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24c6_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24c6_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24c6_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24c6_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24c6_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24c6_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24c7_1014_0267 = {0x1014, 0x0267, pci_subsys_8086_24c7_1014_0267, 0}; #undef pci_ss_info_1014_0267 @@ -42745,6 +42944,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24c7_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24c7_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24c7_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24c7_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24c7_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24c7_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24c7_1462_5800 = {0x1462, 0x5800, pci_subsys_8086_24c7_1462_5800, 0}; #undef pci_ss_info_1462_5800 @@ -42797,6 +43000,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24ca_1071_8160 = {0x1071, 0x8160, pci_subsys_8086_24ca_1071_8160, 0}; #undef pci_ss_info_1071_8160 #define pci_ss_info_1071_8160 pci_ss_info_8086_24ca_1071_8160 +static const pciSubsystemInfo pci_ss_info_8086_24ca_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24ca_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24ca_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24ca_1734_1055 = {0x1734, 0x1055, pci_subsys_8086_24ca_1734_1055, 0}; #undef pci_ss_info_1734_1055 @@ -42829,6 +43036,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24cb_4c53_1090 = {0x4c53, 0x1090, pci_subsys_8086_24cb_4c53_1090, 0}; #undef pci_ss_info_4c53_1090 #define pci_ss_info_4c53_1090 pci_ss_info_8086_24cb_4c53_1090 +static const pciSubsystemInfo pci_ss_info_8086_24cc_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24cc_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24cc_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24cc_1734_1055 = {0x1734, 0x1055, pci_subsys_8086_24cc_1734_1055, 0}; #undef pci_ss_info_1734_1055 @@ -42885,6 +43096,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24cd_1179_ff00 = {0x1179, 0xff00, pci_subsys_8086_24cd_1179_ff00, 0}; #undef pci_ss_info_1179_ff00 #define pci_ss_info_1179_ff00 pci_ss_info_8086_24cd_1179_ff00 +static const pciSubsystemInfo pci_ss_info_8086_24cd_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_24cd_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_24cd_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_24cd_1462_3981 = {0x1462, 0x3981, pci_subsys_8086_24cd_1462_3981, 0}; #undef pci_ss_info_1462_3981 @@ -43021,6 +43236,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24d3_1028_0169 = {0x1028, 0x0169, pci_subsys_8086_24d3_1028_0169, 0}; #undef pci_ss_info_1028_0169 #define pci_ss_info_1028_0169 pci_ss_info_8086_24d3_1028_0169 +static const pciSubsystemInfo pci_ss_info_8086_24d3_103c_12bc = + {0x103c, 0x12bc, pci_subsys_8086_24d3_103c_12bc, 0}; +#undef pci_ss_info_103c_12bc +#define pci_ss_info_103c_12bc pci_ss_info_8086_24d3_103c_12bc static const pciSubsystemInfo pci_ss_info_8086_24d3_1043_80a6 = {0x1043, 0x80a6, pci_subsys_8086_24d3_1043_80a6, 0}; #undef pci_ss_info_1043_80a6 @@ -43117,6 +43336,10 @@ static const pciSubsystemInfo pci_ss_info_8086_24d4_8086_524c = {0x8086, 0x524c, pci_subsys_8086_24d4_8086_524c, 0}; #undef pci_ss_info_8086_524c #define pci_ss_info_8086_524c pci_ss_info_8086_24d4_8086_524c +static const pciSubsystemInfo pci_ss_info_8086_24d5_100a_147b = + {0x100a, 0x147b, pci_subsys_8086_24d5_100a_147b, 0}; +#undef pci_ss_info_100a_147b +#define pci_ss_info_100a_147b pci_ss_info_8086_24d5_100a_147b static const pciSubsystemInfo pci_ss_info_8086_24d5_1028_0169 = {0x1028, 0x0169, pci_subsys_8086_24d5_1028_0169, 0}; #undef pci_ss_info_1028_0169 @@ -43461,6 +43684,10 @@ static const pciSubsystemInfo pci_ss_info_8086_2570_103c_006a = {0x103c, 0x006a, pci_subsys_8086_2570_103c_006a, 0}; #undef pci_ss_info_103c_006a #define pci_ss_info_103c_006a pci_ss_info_8086_2570_103c_006a +static const pciSubsystemInfo pci_ss_info_8086_2570_103c_12bc = + {0x103c, 0x12bc, pci_subsys_8086_2570_103c_12bc, 0}; +#undef pci_ss_info_103c_12bc +#define pci_ss_info_103c_12bc pci_ss_info_8086_2570_103c_12bc static const pciSubsystemInfo pci_ss_info_8086_2570_1043_80f2 = {0x1043, 0x80f2, pci_subsys_8086_2570_1043_80f2, 0}; #undef pci_ss_info_1043_80f2 @@ -44021,6 +44248,10 @@ static const pciSubsystemInfo pci_ss_info_8086_27b8_8086_544e = {0x8086, 0x544e, pci_subsys_8086_27b8_8086_544e, 0}; #undef pci_ss_info_8086_544e #define pci_ss_info_8086_544e pci_ss_info_8086_27b8_8086_544e +static const pciSubsystemInfo pci_ss_info_8086_27b9_10f7_8338 = + {0x10f7, 0x8338, pci_subsys_8086_27b9_10f7_8338, 0}; +#undef pci_ss_info_10f7_8338 +#define pci_ss_info_10f7_8338 pci_ss_info_8086_27b9_10f7_8338 static const pciSubsystemInfo pci_ss_info_8086_27b9_17aa_2009 = {0x17aa, 0x2009, pci_subsys_8086_27b9_17aa_2009, 0}; #undef pci_ss_info_17aa_2009 @@ -44097,6 +44328,14 @@ static const pciSubsystemInfo pci_ss_info_8086_27d8_107b_5048 = {0x107b, 0x5048, pci_subsys_8086_27d8_107b_5048, 0}; #undef pci_ss_info_107b_5048 #define pci_ss_info_107b_5048 pci_ss_info_8086_27d8_107b_5048 +static const pciSubsystemInfo pci_ss_info_8086_27d8_10f7_8338 = + {0x10f7, 0x8338, pci_subsys_8086_27d8_10f7_8338, 0}; +#undef pci_ss_info_10f7_8338 +#define pci_ss_info_10f7_8338 pci_ss_info_8086_27d8_10f7_8338 +static const pciSubsystemInfo pci_ss_info_8086_27d8_1179_ff31 = + {0x1179, 0xff31, pci_subsys_8086_27d8_1179_ff31, 0}; +#undef pci_ss_info_1179_ff31 +#define pci_ss_info_1179_ff31 pci_ss_info_8086_27d8_1179_ff31 static const pciSubsystemInfo pci_ss_info_8086_27d8_152d_0753 = {0x152d, 0x0753, pci_subsys_8086_27d8_152d_0753, 0}; #undef pci_ss_info_152d_0753 @@ -44105,6 +44344,10 @@ static const pciSubsystemInfo pci_ss_info_8086_27d8_17aa_2010 = {0x17aa, 0x2010, pci_subsys_8086_27d8_17aa_2010, 0}; #undef pci_ss_info_17aa_2010 #define pci_ss_info_17aa_2010 pci_ss_info_8086_27d8_17aa_2010 +static const pciSubsystemInfo pci_ss_info_8086_27da_10f7_8338 = + {0x10f7, 0x8338, pci_subsys_8086_27da_10f7_8338, 0}; +#undef pci_ss_info_10f7_8338 +#define pci_ss_info_10f7_8338 pci_ss_info_8086_27da_10f7_8338 static const pciSubsystemInfo pci_ss_info_8086_27da_17aa_200f = {0x17aa, 0x200f, pci_subsys_8086_27da_17aa_200f, 0}; #undef pci_ss_info_17aa_200f @@ -44121,6 +44364,10 @@ static const pciSubsystemInfo pci_ss_info_8086_27df_107b_5048 = {0x107b, 0x5048, pci_subsys_8086_27df_107b_5048, 0}; #undef pci_ss_info_107b_5048 #define pci_ss_info_107b_5048 pci_ss_info_8086_27df_107b_5048 +static const pciSubsystemInfo pci_ss_info_8086_27df_10f7_8338 = + {0x10f7, 0x8338, pci_subsys_8086_27df_10f7_8338, 0}; +#undef pci_ss_info_10f7_8338 +#define pci_ss_info_10f7_8338 pci_ss_info_8086_27df_10f7_8338 static const pciSubsystemInfo pci_ss_info_8086_27df_17aa_200c = {0x17aa, 0x200c, pci_subsys_8086_27df_17aa_200c, 0}; #undef pci_ss_info_17aa_200c @@ -44129,6 +44376,38 @@ static const pciSubsystemInfo pci_ss_info_8086_27df_8086_544e = {0x8086, 0x544e, pci_subsys_8086_27df_8086_544e, 0}; #undef pci_ss_info_8086_544e #define pci_ss_info_8086_544e pci_ss_info_8086_27df_8086_544e +static const pciSubsystemInfo pci_ss_info_8086_2820_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2820_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2820_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_2825_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2825_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2825_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_2830_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2830_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2830_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_2831_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2831_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2831_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_2834_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2834_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2834_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_2836_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_2836_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_2836_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_283e_1462_7235 = + {0x1462, 0x7235, pci_subsys_8086_283e_1462_7235, 0}; +#undef pci_ss_info_1462_7235 +#define pci_ss_info_1462_7235 pci_ss_info_8086_283e_1462_7235 +static const pciSubsystemInfo pci_ss_info_8086_3200_1775_c200 = + {0x1775, 0xc200, pci_subsys_8086_3200_1775_c200, 0}; +#undef pci_ss_info_1775_c200 +#define pci_ss_info_1775_c200 pci_ss_info_8086_3200_1775_c200 static const pciSubsystemInfo pci_ss_info_8086_3340_1025_005a = {0x1025, 0x005a, pci_subsys_8086_3340_1025_005a, 0}; #undef pci_ss_info_1025_005a @@ -44145,6 +44424,14 @@ static const pciSubsystemInfo pci_ss_info_8086_3340_103c_08b0 = {0x103c, 0x08b0, pci_subsys_8086_3340_103c_08b0, 0}; #undef pci_ss_info_103c_08b0 #define pci_ss_info_103c_08b0 pci_ss_info_8086_3340_103c_08b0 +static const pciSubsystemInfo pci_ss_info_8086_3340_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_3340_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_3340_144d_c00c +static const pciSubsystemInfo pci_ss_info_8086_3341_144d_c00c = + {0x144d, 0xc00c, pci_subsys_8086_3341_144d_c00c, 0}; +#undef pci_ss_info_144d_c00c +#define pci_ss_info_144d_c00c pci_ss_info_8086_3341_144d_c00c static const pciSubsystemInfo pci_ss_info_8086_3575_0e11_0030 = {0x0e11, 0x0030, pci_subsys_8086_3575_0e11_0030, 0}; #undef pci_ss_info_0e11_0030 @@ -48590,10 +48877,12 @@ static const pciSubsystemInfo *pci_ss_list_1077_2422[] = { NULL }; #define pci_ss_list_1077_2432 NULL -#define pci_ss_list_1077_3010 NULL #define pci_ss_list_1077_3022 NULL +#define pci_ss_list_1077_3032 NULL #define pci_ss_list_1077_4010 NULL #define pci_ss_list_1077_4022 NULL +#define pci_ss_list_1077_4032 NULL +#define pci_ss_list_1077_5432 NULL #define pci_ss_list_1077_6312 NULL #define pci_ss_list_1077_6322 NULL #endif @@ -55730,7 +56019,9 @@ static const pciSubsystemInfo *pci_ss_list_8086_1040[] = { }; static const pciSubsystemInfo *pci_ss_list_8086_1043[] = { &pci_ss_info_8086_1043_103c_08b0, + &pci_ss_info_8086_1043_8086_2522, &pci_ss_info_8086_1043_8086_2527, + &pci_ss_info_8086_1043_8086_2581, NULL }; static const pciSubsystemInfo *pci_ss_list_8086_1048[] = { @@ -55754,6 +56045,10 @@ static const pciSubsystemInfo *pci_ss_list_8086_1050[] = { #define pci_ss_list_8086_1051 NULL #define pci_ss_list_8086_1052 NULL #define pci_ss_list_8086_1053 NULL +#define pci_ss_list_8086_1054 NULL +#define pci_ss_list_8086_1055 NULL +#define pci_ss_list_8086_1056 NULL +#define pci_ss_list_8086_1057 NULL #define pci_ss_list_8086_1059 NULL #define pci_ss_list_8086_105b NULL static const pciSubsystemInfo *pci_ss_list_8086_105e[] = { @@ -55874,7 +56169,11 @@ static const pciSubsystemInfo *pci_ss_list_8086_108a[] = { #define pci_ss_list_8086_108c NULL #define pci_ss_list_8086_108e NULL #define pci_ss_list_8086_108f NULL +#define pci_ss_list_8086_1091 NULL #define pci_ss_list_8086_1092 NULL +#define pci_ss_list_8086_1093 NULL +#define pci_ss_list_8086_1094 NULL +#define pci_ss_list_8086_1095 NULL #define pci_ss_list_8086_1096 NULL #define pci_ss_list_8086_1097 NULL #define pci_ss_list_8086_1098 NULL @@ -55883,14 +56182,25 @@ static const pciSubsystemInfo *pci_ss_list_8086_1099[] = { NULL }; static const pciSubsystemInfo *pci_ss_list_8086_109a[] = { + &pci_ss_info_8086_109a_1179_ff10, &pci_ss_info_8086_109a_17aa_2001, &pci_ss_info_8086_109a_17aa_207e, &pci_ss_info_8086_109a_8086_109a, NULL }; #define pci_ss_list_8086_109b NULL +static const pciSubsystemInfo *pci_ss_list_8086_109e[] = { + &pci_ss_info_8086_109e_8086_a01f, + &pci_ss_info_8086_109e_8086_a11f, + NULL +}; #define pci_ss_list_8086_10a0 NULL #define pci_ss_list_8086_10a1 NULL +static const pciSubsystemInfo *pci_ss_list_8086_10a4[] = { + &pci_ss_info_8086_10a4_8086_10a4, + &pci_ss_info_8086_10a4_8086_11a4, + NULL +}; #define pci_ss_list_8086_10b0 NULL #define pci_ss_list_8086_10b2 NULL #define pci_ss_list_8086_10b3 NULL @@ -55908,6 +56218,13 @@ static const pciSubsystemInfo *pci_ss_list_8086_10b9[] = { }; #define pci_ss_list_8086_10ba NULL #define pci_ss_list_8086_10bb NULL +static const pciSubsystemInfo *pci_ss_list_8086_10bc[] = { + &pci_ss_info_8086_10bc_8086_10bc, + &pci_ss_info_8086_10bc_8086_11bc, + NULL +}; +#define pci_ss_list_8086_10c4 NULL +#define pci_ss_list_8086_10c5 NULL #define pci_ss_list_8086_1107 NULL static const pciSubsystemInfo *pci_ss_list_8086_1130[] = { &pci_ss_info_8086_1130_1025_1016, @@ -56176,6 +56493,11 @@ static const pciSubsystemInfo *pci_ss_list_8086_1a30[] = { #define pci_ss_list_8086_1a31 NULL #define pci_ss_list_8086_1a38 NULL #define pci_ss_list_8086_1a48 NULL +static const pciSubsystemInfo *pci_ss_list_8086_1b48[] = { + &pci_ss_info_8086_1b48_8086_a01f, + &pci_ss_info_8086_1b48_8086_a11f, + NULL +}; #define pci_ss_list_8086_2410 NULL #define pci_ss_list_8086_2411 NULL #define pci_ss_list_8086_2412 NULL @@ -56238,6 +56560,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_2444[] = { NULL }; static const pciSubsystemInfo *pci_ss_list_8086_2445[] = { + &pci_ss_info_8086_2445_0e11_000b, &pci_ss_info_8086_2445_0e11_0088, &pci_ss_info_8086_2445_1014_01c6, &pci_ss_info_8086_2445_1025_1016, @@ -56254,6 +56577,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_2446[] = { }; static const pciSubsystemInfo *pci_ss_list_8086_2448[] = { &pci_ss_info_8086_2448_103c_099c, + &pci_ss_info_8086_2448_144d_c00c, &pci_ss_info_8086_2448_1734_1055, NULL }; @@ -56401,6 +56725,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24c2[] = { &pci_ss_info_8086_24c2_103c_0890, &pci_ss_info_8086_24c2_103c_08b0, &pci_ss_info_8086_24c2_1071_8160, + &pci_ss_info_8086_24c2_144d_c00c, &pci_ss_info_8086_24c2_1462_5800, &pci_ss_info_8086_24c2_1509_2990, &pci_ss_info_8086_24c2_1734_1004, @@ -56436,6 +56761,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24c4[] = { &pci_ss_info_8086_24c4_103c_0890, &pci_ss_info_8086_24c4_103c_08b0, &pci_ss_info_8086_24c4_1071_8160, + &pci_ss_info_8086_24c4_144d_c00c, &pci_ss_info_8086_24c4_1462_5800, &pci_ss_info_8086_24c4_1509_2990, &pci_ss_info_8086_24c4_1734_1004, @@ -56455,6 +56781,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24c5[] = { &pci_ss_info_8086_24c5_103c_0890, &pci_ss_info_8086_24c5_103c_08b0, &pci_ss_info_8086_24c5_1071_8160, + &pci_ss_info_8086_24c5_144d_c00c, &pci_ss_info_8086_24c5_1458_a002, &pci_ss_info_8086_24c5_1462_5800, &pci_ss_info_8086_24c5_1734_1005, @@ -56470,6 +56797,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24c6[] = { &pci_ss_info_8086_24c6_103c_0890, &pci_ss_info_8086_24c6_103c_08b0, &pci_ss_info_8086_24c6_1071_8160, + &pci_ss_info_8086_24c6_144d_c00c, NULL }; static const pciSubsystemInfo *pci_ss_list_8086_24c7[] = { @@ -56483,6 +56811,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24c7[] = { &pci_ss_info_8086_24c7_103c_0890, &pci_ss_info_8086_24c7_103c_08b0, &pci_ss_info_8086_24c7_1071_8160, + &pci_ss_info_8086_24c7_144d_c00c, &pci_ss_info_8086_24c7_1462_5800, &pci_ss_info_8086_24c7_1509_2990, &pci_ss_info_8086_24c7_1734_1004, @@ -56499,6 +56828,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24ca[] = { &pci_ss_info_8086_24ca_103c_0890, &pci_ss_info_8086_24ca_103c_08b0, &pci_ss_info_8086_24ca_1071_8160, + &pci_ss_info_8086_24ca_144d_c00c, &pci_ss_info_8086_24ca_1734_1055, &pci_ss_info_8086_24ca_8086_4541, NULL @@ -56513,6 +56843,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24cb[] = { NULL }; static const pciSubsystemInfo *pci_ss_list_8086_24cc[] = { + &pci_ss_info_8086_24cc_144d_c00c, &pci_ss_info_8086_24cc_1734_1055, NULL }; @@ -56530,6 +56861,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24cd[] = { &pci_ss_info_8086_24cd_103c_08b0, &pci_ss_info_8086_24cd_1071_8160, &pci_ss_info_8086_24cd_1179_ff00, + &pci_ss_info_8086_24cd_144d_c00c, &pci_ss_info_8086_24cd_1462_3981, &pci_ss_info_8086_24cd_1509_1968, &pci_ss_info_8086_24cd_1734_1004, @@ -56574,6 +56906,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24d3[] = { &pci_ss_info_8086_24d3_1014_02ed, &pci_ss_info_8086_24d3_1028_0156, &pci_ss_info_8086_24d3_1028_0169, + &pci_ss_info_8086_24d3_103c_12bc, &pci_ss_info_8086_24d3_1043_80a6, &pci_ss_info_8086_24d3_1458_24d2, &pci_ss_info_8086_24d3_1462_7280, @@ -56604,6 +56937,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_24d4[] = { NULL }; static const pciSubsystemInfo *pci_ss_list_8086_24d5[] = { + &pci_ss_info_8086_24d5_100a_147b, &pci_ss_info_8086_24d5_1028_0169, &pci_ss_info_8086_24d5_103c_006a, &pci_ss_info_8086_24d5_103c_12bc, @@ -56757,6 +57091,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_2562[] = { }; static const pciSubsystemInfo *pci_ss_list_8086_2570[] = { &pci_ss_info_8086_2570_103c_006a, + &pci_ss_info_8086_2570_103c_12bc, &pci_ss_info_8086_2570_1043_80f2, &pci_ss_info_8086_2570_1458_2570, NULL @@ -57122,6 +57457,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_27b8[] = { NULL }; static const pciSubsystemInfo *pci_ss_list_8086_27b9[] = { + &pci_ss_info_8086_27b9_10f7_8338, &pci_ss_info_8086_27b9_17aa_2009, NULL }; @@ -57174,11 +57510,14 @@ static const pciSubsystemInfo *pci_ss_list_8086_27cc[] = { #define pci_ss_list_8086_27d6 NULL static const pciSubsystemInfo *pci_ss_list_8086_27d8[] = { &pci_ss_info_8086_27d8_107b_5048, + &pci_ss_info_8086_27d8_10f7_8338, + &pci_ss_info_8086_27d8_1179_ff31, &pci_ss_info_8086_27d8_152d_0753, &pci_ss_info_8086_27d8_17aa_2010, NULL }; static const pciSubsystemInfo *pci_ss_list_8086_27da[] = { + &pci_ss_info_8086_27da_10f7_8338, &pci_ss_info_8086_27da_17aa_200f, &pci_ss_info_8086_27da_8086_544e, NULL @@ -57191,6 +57530,7 @@ static const pciSubsystemInfo *pci_ss_list_8086_27dc[] = { #define pci_ss_list_8086_27de NULL static const pciSubsystemInfo *pci_ss_list_8086_27df[] = { &pci_ss_info_8086_27df_107b_5048, + &pci_ss_info_8086_27df_10f7_8338, &pci_ss_info_8086_27df_17aa_200c, &pci_ss_info_8086_27df_8086_544e, NULL @@ -57202,22 +57542,43 @@ static const pciSubsystemInfo *pci_ss_list_8086_27df[] = { #define pci_ss_list_8086_2812 NULL #define pci_ss_list_8086_2814 NULL #define pci_ss_list_8086_2815 NULL -#define pci_ss_list_8086_2820 NULL +static const pciSubsystemInfo *pci_ss_list_8086_2820[] = { + &pci_ss_info_8086_2820_1462_7235, + NULL +}; #define pci_ss_list_8086_2821 NULL #define pci_ss_list_8086_2822 NULL #define pci_ss_list_8086_2824 NULL -#define pci_ss_list_8086_2825 NULL +static const pciSubsystemInfo *pci_ss_list_8086_2825[] = { + &pci_ss_info_8086_2825_1462_7235, + NULL +}; #define pci_ss_list_8086_2828 NULL #define pci_ss_list_8086_2829 NULL #define pci_ss_list_8086_282a NULL -#define pci_ss_list_8086_2830 NULL -#define pci_ss_list_8086_2831 NULL +static const pciSubsystemInfo *pci_ss_list_8086_2830[] = { + &pci_ss_info_8086_2830_1462_7235, + NULL +}; +static const pciSubsystemInfo *pci_ss_list_8086_2831[] = { + &pci_ss_info_8086_2831_1462_7235, + NULL +}; #define pci_ss_list_8086_2832 NULL -#define pci_ss_list_8086_2834 NULL +static const pciSubsystemInfo *pci_ss_list_8086_2834[] = { + &pci_ss_info_8086_2834_1462_7235, + NULL +}; #define pci_ss_list_8086_2835 NULL -#define pci_ss_list_8086_2836 NULL +static const pciSubsystemInfo *pci_ss_list_8086_2836[] = { + &pci_ss_info_8086_2836_1462_7235, + NULL +}; #define pci_ss_list_8086_283a NULL -#define pci_ss_list_8086_283e NULL +static const pciSubsystemInfo *pci_ss_list_8086_283e[] = { + &pci_ss_info_8086_283e_1462_7235, + NULL +}; #define pci_ss_list_8086_283f NULL #define pci_ss_list_8086_2841 NULL #define pci_ss_list_8086_2843 NULL @@ -57263,15 +57624,22 @@ static const pciSubsystemInfo *pci_ss_list_8086_27df[] = { #define pci_ss_list_8086_2a06 NULL #define pci_ss_list_8086_2a07 NULL #define pci_ss_list_8086_3092 NULL -#define pci_ss_list_8086_3200 NULL +static const pciSubsystemInfo *pci_ss_list_8086_3200[] = { + &pci_ss_info_8086_3200_1775_c200, + NULL +}; static const pciSubsystemInfo *pci_ss_list_8086_3340[] = { &pci_ss_info_8086_3340_1025_005a, &pci_ss_info_8086_3340_103c_088c, &pci_ss_info_8086_3340_103c_0890, &pci_ss_info_8086_3340_103c_08b0, + &pci_ss_info_8086_3340_144d_c00c, + NULL +}; +static const pciSubsystemInfo *pci_ss_list_8086_3341[] = { + &pci_ss_info_8086_3341_144d_c00c, NULL }; -#define pci_ss_list_8086_3341 NULL #define pci_ss_list_8086_3500 NULL #define pci_ss_list_8086_3501 NULL #define pci_ss_list_8086_3504 NULL @@ -58120,6 +58488,7 @@ static const pciSubsystemInfo *pci_ss_list_0925[] = { #define pci_ss_list_0b49 NULL #define pci_ss_list_0ccd NULL static const pciSubsystemInfo *pci_ss_list_0e11[] = { + &pci_ss_info_0e11_000b, &pci_ss_info_0e11_0012, &pci_ss_info_0e11_001e, &pci_ss_info_0e11_0022, @@ -58382,7 +58751,12 @@ static const pciSubsystemInfo *pci_ss_list_1005[] = { #define pci_ss_list_1006 NULL #define pci_ss_list_1007 NULL #define pci_ss_list_1008 NULL -#define pci_ss_list_100a NULL +#ifdef VENDOR_INCLUDE_NONVIDEO +static const pciSubsystemInfo *pci_ss_list_100a[] = { + &pci_ss_info_100a_147b, + NULL +}; +#endif #define pci_ss_list_100b NULL #define pci_ss_list_100c NULL #define pci_ss_list_100d NULL @@ -60499,6 +60873,7 @@ static const pciSubsystemInfo *pci_ss_list_1179[] = { &pci_ss_info_1179_ff00, &pci_ss_info_1179_ff01, &pci_ss_info_1179_ff10, + &pci_ss_info_1179_ff31, NULL }; #endif @@ -62200,6 +62575,7 @@ static const pciSubsystemInfo *pci_ss_list_1462[] = { &pci_ss_info_1462_7030, &pci_ss_info_1462_7100, &pci_ss_info_1462_7207, + &pci_ss_info_1462_7235, &pci_ss_info_1462_7280, &pci_ss_info_1462_728c, &pci_ss_info_1462_7580, @@ -63348,6 +63724,7 @@ static const pciSubsystemInfo *pci_ss_list_1775[] = { &pci_ss_info_1775_10d0, &pci_ss_info_1775_10d1, &pci_ss_info_1775_6003, + &pci_ss_info_1775_c200, &pci_ss_info_1775_ce90, NULL }; @@ -64030,6 +64407,8 @@ static const pciSubsystemInfo *pci_ss_list_8086[] = { &pci_ss_info_8086_1094, &pci_ss_info_8086_1099, &pci_ss_info_8086_109a, + &pci_ss_info_8086_10a4, + &pci_ss_info_8086_10bc, &pci_ss_info_8086_10f0, &pci_ss_info_8086_1107, &pci_ss_info_8086_1109, @@ -64046,6 +64425,8 @@ static const pciSubsystemInfo *pci_ss_list_8086[] = { &pci_ss_info_8086_117a, &pci_ss_info_8086_118a, &pci_ss_info_8086_1199, + &pci_ss_info_8086_11a4, + &pci_ss_info_8086_11bc, &pci_ss_info_8086_125e, &pci_ss_info_8086_125f, &pci_ss_info_8086_1276, @@ -64098,7 +64479,9 @@ static const pciSubsystemInfo *pci_ss_list_8086[] = { &pci_ss_info_8086_2413, &pci_ss_info_8086_24db, &pci_ss_info_8086_2513, + &pci_ss_info_8086_2522, &pci_ss_info_8086_2527, + &pci_ss_info_8086_2581, &pci_ss_info_8086_265c, &pci_ss_info_8086_3000, &pci_ss_info_8086_3001, @@ -79384,19 +79767,19 @@ static const pciDeviceInfo pci_dev_info_1077_2432 = { #endif 0 }; -static const pciDeviceInfo pci_dev_info_1077_3010 = { - 0x3010, pci_device_1077_3010, +static const pciDeviceInfo pci_dev_info_1077_3022 = { + 0x3022, pci_device_1077_3022, #ifdef INIT_SUBSYS_INFO - pci_ss_list_1077_3010, + pci_ss_list_1077_3022, #else NULL, #endif 0 }; -static const pciDeviceInfo pci_dev_info_1077_3022 = { - 0x3022, pci_device_1077_3022, +static const pciDeviceInfo pci_dev_info_1077_3032 = { + 0x3032, pci_device_1077_3032, #ifdef INIT_SUBSYS_INFO - pci_ss_list_1077_3022, + pci_ss_list_1077_3032, #else NULL, #endif @@ -79420,6 +79803,24 @@ static const pciDeviceInfo pci_dev_info_1077_4022 = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_1077_4032 = { + 0x4032, pci_device_1077_4032, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_1077_4032, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_1077_5432 = { + 0x5432, pci_device_1077_5432, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_1077_5432, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_1077_6312 = { 0x6312, pci_device_1077_6312, #ifdef INIT_SUBSYS_INFO @@ -109037,7 +109438,6 @@ static const pciDeviceInfo pci_dev_info_19e7_1005 = { 0 }; #endif -#ifdef VENDOR_INCLUDE_NONVIDEO static const pciDeviceInfo pci_dev_info_1a03_2000 = { 0x2000, pci_device_1a03_2000, #ifdef INIT_SUBSYS_INFO @@ -109047,7 +109447,6 @@ static const pciDeviceInfo pci_dev_info_1a03_2000 = { #endif 0 }; -#endif #ifdef VENDOR_INCLUDE_NONVIDEO static const pciDeviceInfo pci_dev_info_1a08_0000 = { 0x0000, pci_device_1a08_0000, @@ -111843,6 +112242,42 @@ static const pciDeviceInfo pci_dev_info_8086_1053 = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_1054 = { + 0x1054, pci_device_8086_1054, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1054, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_1055 = { + 0x1055, pci_device_8086_1055, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1055, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_1056 = { + 0x1056, pci_device_8086_1056, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1056, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_1057 = { + 0x1057, pci_device_8086_1057, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1057, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_1059 = { 0x1059, pci_device_8086_1059, #ifdef INIT_SUBSYS_INFO @@ -112185,6 +112620,15 @@ static const pciDeviceInfo pci_dev_info_8086_108f = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_1091 = { + 0x1091, pci_device_8086_1091, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1091, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_1092 = { 0x1092, pci_device_8086_1092, #ifdef INIT_SUBSYS_INFO @@ -112194,6 +112638,33 @@ static const pciDeviceInfo pci_dev_info_8086_1092 = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_1093 = { + 0x1093, pci_device_8086_1093, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1093, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_1094 = { + 0x1094, pci_device_8086_1094, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1094, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_1095 = { + 0x1095, pci_device_8086_1095, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1095, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_1096 = { 0x1096, pci_device_8086_1096, #ifdef INIT_SUBSYS_INFO @@ -112248,6 +112719,15 @@ static const pciDeviceInfo pci_dev_info_8086_109b = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_109e = { + 0x109e, pci_device_8086_109e, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_109e, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_10a0 = { 0x10a0, pci_device_8086_10a0, #ifdef INIT_SUBSYS_INFO @@ -112266,6 +112746,15 @@ static const pciDeviceInfo pci_dev_info_8086_10a1 = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_10a4 = { + 0x10a4, pci_device_8086_10a4, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_10a4, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_10b0 = { 0x10b0, pci_device_8086_10b0, #ifdef INIT_SUBSYS_INFO @@ -112338,6 +112827,33 @@ static const pciDeviceInfo pci_dev_info_8086_10bb = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_10bc = { + 0x10bc, pci_device_8086_10bc, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_10bc, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_10c4 = { + 0x10c4, pci_device_8086_10c4, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_10c4, +#else + NULL, +#endif + 0 +}; +static const pciDeviceInfo pci_dev_info_8086_10c5 = { + 0x10c5, pci_device_8086_10c5, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_10c5, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_1107 = { 0x1107, pci_device_8086_1107, #ifdef INIT_SUBSYS_INFO @@ -112752,6 +113268,15 @@ static const pciDeviceInfo pci_dev_info_8086_1a48 = { #endif 0 }; +static const pciDeviceInfo pci_dev_info_8086_1b48 = { + 0x1b48, pci_device_8086_1b48, +#ifdef INIT_SUBSYS_INFO + pci_ss_list_8086_1b48, +#else + NULL, +#endif + 0 +}; static const pciDeviceInfo pci_dev_info_8086_2410 = { 0x2410, pci_device_8086_2410, #ifdef INIT_SUBSYS_INFO @@ -120919,10 +121444,12 @@ static const pciDeviceInfo *pci_dev_list_1077[] = { &pci_dev_info_1077_2322, &pci_dev_info_1077_2422, &pci_dev_info_1077_2432, - &pci_dev_info_1077_3010, &pci_dev_info_1077_3022, + &pci_dev_info_1077_3032, &pci_dev_info_1077_4010, &pci_dev_info_1077_4022, + &pci_dev_info_1077_4032, + &pci_dev_info_1077_5432, &pci_dev_info_1077_6312, &pci_dev_info_1077_6322, NULL @@ -127194,12 +127721,10 @@ static const pciDeviceInfo *pci_dev_list_19e7[] = { NULL }; #endif -#ifdef VENDOR_INCLUDE_NONVIDEO static const pciDeviceInfo *pci_dev_list_1a03[] = { &pci_dev_info_1a03_2000, NULL }; -#endif #ifdef VENDOR_INCLUDE_NONVIDEO static const pciDeviceInfo *pci_dev_list_1a08[] = { &pci_dev_info_1a08_0000, @@ -127727,6 +128252,10 @@ static const pciDeviceInfo *pci_dev_list_8086[] = { &pci_dev_info_8086_1051, &pci_dev_info_8086_1052, &pci_dev_info_8086_1053, + &pci_dev_info_8086_1054, + &pci_dev_info_8086_1055, + &pci_dev_info_8086_1056, + &pci_dev_info_8086_1057, &pci_dev_info_8086_1059, &pci_dev_info_8086_105b, &pci_dev_info_8086_105e, @@ -127765,15 +128294,21 @@ static const pciDeviceInfo *pci_dev_list_8086[] = { &pci_dev_info_8086_108c, &pci_dev_info_8086_108e, &pci_dev_info_8086_108f, + &pci_dev_info_8086_1091, &pci_dev_info_8086_1092, + &pci_dev_info_8086_1093, + &pci_dev_info_8086_1094, + &pci_dev_info_8086_1095, &pci_dev_info_8086_1096, &pci_dev_info_8086_1097, &pci_dev_info_8086_1098, &pci_dev_info_8086_1099, &pci_dev_info_8086_109a, &pci_dev_info_8086_109b, + &pci_dev_info_8086_109e, &pci_dev_info_8086_10a0, &pci_dev_info_8086_10a1, + &pci_dev_info_8086_10a4, &pci_dev_info_8086_10b0, &pci_dev_info_8086_10b2, &pci_dev_info_8086_10b3, @@ -127782,6 +128317,9 @@ static const pciDeviceInfo *pci_dev_list_8086[] = { &pci_dev_info_8086_10b9, &pci_dev_info_8086_10ba, &pci_dev_info_8086_10bb, + &pci_dev_info_8086_10bc, + &pci_dev_info_8086_10c4, + &pci_dev_info_8086_10c5, &pci_dev_info_8086_1107, &pci_dev_info_8086_1130, &pci_dev_info_8086_1131, @@ -127828,6 +128366,7 @@ static const pciDeviceInfo *pci_dev_list_8086[] = { &pci_dev_info_8086_1a31, &pci_dev_info_8086_1a38, &pci_dev_info_8086_1a48, + &pci_dev_info_8086_1b48, &pci_dev_info_8086_2410, &pci_dev_info_8086_2411, &pci_dev_info_8086_2412, @@ -133715,9 +134254,7 @@ static const pciVendorInfo pciVendorInfoList[] = { #ifdef VENDOR_INCLUDE_NONVIDEO {0x19e7, pci_vendor_19e7, pci_dev_list_19e7}, #endif -#ifdef VENDOR_INCLUDE_NONVIDEO {0x1a03, pci_vendor_1a03, pci_dev_list_1a03}, -#endif #ifdef VENDOR_INCLUDE_NONVIDEO {0x1a08, pci_vendor_1a08, pci_dev_list_1a08}, #endif @@ -139176,9 +139713,7 @@ static const pciVendorSubsysInfo pciVendorSubsysInfoList[] = { #ifdef VENDOR_INCLUDE_NONVIDEO {0x19e7, pci_vendor_19e7, pci_ss_list_19e7}, #endif -#ifdef VENDOR_INCLUDE_NONVIDEO {0x1a03, pci_vendor_1a03, pci_ss_list_1a03}, -#endif #ifdef VENDOR_INCLUDE_NONVIDEO {0x1a08, pci_vendor_1a08, pci_ss_list_1a08}, #endif From d17ec01e8395a8f14b75a10c8bf082b3f5a4fb36 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 1 Dec 2006 00:41:41 +0200 Subject: [PATCH 068/109] remove CID support (bug #5553) Remove CID from all our fontpaths. (cherry picked from 69820a10e33e4582c192360996e866007114639d commit) --- configure.ac | 2 +- hw/xfree86/Makefile.am | 1 - hw/xfree86/dixmods/type1mod.c | 15 --------------- hw/xfree86/doc/man/xorg.conf.man.pre | 2 -- hw/xfree86/xorgconf.cpp | 1 - 5 files changed, 1 insertion(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 1aa5455b9..851194c9f 100644 --- a/configure.ac +++ b/configure.ac @@ -391,7 +391,7 @@ AC_ARG_WITH(mesa-source, AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [P AC_ARG_WITH(fontdir, AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]), [ FONTDIR="$withval" ], [ FONTDIR="${libdir}/X11/fonts" ]) -DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/CID/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/" +DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/" AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]), [ FONTPATH="$withval" ], [ FONTPATH="${DEFAULT_FONT_PATH}" ]) diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index b373242e8..0c1306f09 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -93,7 +93,6 @@ CPP_FILES_FLAGS = \ -DMISCFONTPATH="\"$(BASE_FONT_PATH)/misc\"" \ -DT1FONTPATH="\"$(BASE_FONT_PATH)/Type1\"" \ -DTRUETYPEFONTPATH="\"$(BASE_FONT_PATH)/TTF\"" \ - -DCIDFONTPATH="\"$(BASE_FONT_PATH)/CID\"" \ -DDPI75FONTPATH="\"$(BASE_FONT_PATH)/75dpi\"" \ -DDPI100FONTPATH="\"$(BASE_FONT_PATH)/100dpi\"" \ -DMODULEPATH=\"$(DEFAULT_MODULE_PATH)\" diff --git a/hw/xfree86/dixmods/type1mod.c b/hw/xfree86/dixmods/type1mod.c index 48c1d0421..3da53eae5 100644 --- a/hw/xfree86/dixmods/type1mod.c +++ b/hw/xfree86/dixmods/type1mod.c @@ -57,9 +57,6 @@ static XF86ModuleVersionInfo VersRec = _X_EXPORT XF86ModuleData type1ModuleData = { &VersRec, type1Setup, NULL }; extern void Type1RegisterFontFileFunctions(void); -#ifdef BUILDCID -extern void CIDRegisterFontFileFunctions(void); -#endif FontModule type1Module = { Type1RegisterFontFileFunctions, @@ -67,23 +64,11 @@ FontModule type1Module = { NULL }; -#ifdef BUILDCID -FontModule CIDModule = { - CIDRegisterFontFileFunctions, - "CID", - NULL -}; -#endif - static pointer type1Setup(pointer module, pointer opts, int *errmaj, int *errmin) { type1Module.module = module; LoadFont(&type1Module); -#ifdef BUILDCID - CIDModule.module = module; - LoadFont(&CIDModule); -#endif /* Need a non-NULL return */ return (pointer)1; diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre index abf31468a..8d52b2bcf 100644 --- a/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/hw/xfree86/doc/man/xorg.conf.man.pre @@ -311,7 +311,6 @@ font path elements: .I __projectroot__/lib/X11/fonts/misc/ .I __projectroot__/lib/X11/fonts/TTF/ .I __projectroot__/lib/X11/fonts/Type1/ -.I __projectroot__/lib/X11/fonts/CID/ .I __projectroot__/lib/X11/fonts/75dpi/ .I __projectroot__/lib/X11/fonts/100dpi/ .fi @@ -326,7 +325,6 @@ The recommended font path contains the following font path elements: .I __projectroot__/lib/X11/fonts/75dpi/:unscaled .I __projectroot__/lib/X11/fonts/100dpi/:unscaled .I __projectroot__/lib/X11/fonts/Type1/ -.I __projectroot__/lib/X11/fonts/CID/ .I __projectroot__/lib/X11/fonts/Speedo/ .I __projectroot__/lib/X11/fonts/75dpi/ .I __projectroot__/lib/X11/fonts/100dpi/ diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp index 71abe130d..1995045b8 100644 --- a/hw/xfree86/xorgconf.cpp +++ b/hw/xfree86/xorgconf.cpp @@ -56,7 +56,6 @@ XCOMM command (or a combination of both methods) FontPath MISCFONTPATH FontPath T1FONTPATH FontPath TRUETYPEFONTPATH - FontPath CIDFONTPATH FontPath DPI75FONTPATH FontPath DPI100FONTPATH From f2903c12bb4bb0b7c94b96c55af8fa55507f9d7d Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 7 Nov 2006 11:13:32 +0200 Subject: [PATCH 069/109] SyntheticMotion: don't dereference sprite.screen when not using Xinerama (cherry picked from aa052e43c6c293e14f78837e00c6b7581f9713bb commit) --- dix/events.c | 3 ++- hw/kdrive/linux/keyboard.c | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dix/events.c b/dix/events.c index 7cfe0ad0c..0a39dcd9e 100644 --- a/dix/events.c +++ b/dix/events.c @@ -328,7 +328,8 @@ static void ConfineToShape(RegionPtr shape, int *px, int *py); static void PostNewCursor(void); #define SyntheticMotion(x, y) \ - PostSyntheticMotion(x, y, sprite.screen, \ + PostSyntheticMotion(x, y, noPanoramiXExtension ? 0 : \ + sprite.screen->myNum, \ syncEvents.playingEvents ? \ syncEvents.time.milliseconds : \ currentTime.milliseconds); diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c index b7571f66e..ad9907a59 100644 --- a/hw/kdrive/linux/keyboard.c +++ b/hw/kdrive/linux/keyboard.c @@ -745,14 +745,11 @@ LinuxKeyboardEnable (KdKeyboardInfo *ki) cfsetispeed(&nTty, 9600); cfsetospeed(&nTty, 9600); tcsetattr(fd, TCSANOW, &nTty); - /* Our kernel cleverly ignores O_NONBLOCK. Sigh. */ -#if 0 /* * Flush any pending keystrokes */ while ((n = read (fd, buf, sizeof (buf))) > 0) ; -#endif KdRegisterFd (fd, LinuxKeyboardRead, ki); return Success; } From 8884a73a3f4efa8276c5e38b9573201574c4f1f6 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 27 Nov 2006 22:39:56 +0200 Subject: [PATCH 070/109] xfree86/input: re-add support for disabling drag events --- hw/xfree86/common/xf86Xinput.c | 51 ++++++---------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index be3368dff..16e330d43 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -90,16 +90,6 @@ #include "mi.h" -/****************************************************************************** - * debugging macro - *****************************************************************************/ -#ifdef DEBUG -static int debug_level = 0; -#define DBG(lvl, f) {if ((lvl) <= debug_level) f;} -#else -#define DBG(lvl, f) -#endif - xEvent *xf86Events = NULL; static Bool @@ -140,33 +130,6 @@ xf86ProcessCommonOptions(LocalDevicePtr local, } } -void -xf86AlwaysCoreControl(DeviceIntPtr pDev, IntegerCtrl *control) -{ -} - -/*********************************************************************** - * - * xf86XinputFinalizeInit -- - * - * Create and initialize an integer feedback to control the always - * core feature. - * - *********************************************************************** - */ -void -xf86XinputFinalizeInit(DeviceIntPtr dev) -{ - LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; - - if (InitIntegerFeedbackClassDeviceStruct(dev, xf86AlwaysCoreControl) == FALSE) { - ErrorF("Unable to init integer feedback for always core feature\n"); - } else { - local->always_core_feedback = dev->intfeed; - dev->intfeed->ctrl.integer_displayed = (local->flags & XI86_ALWAYS_CORE) ? 1 : 0; - } -} - /*********************************************************************** * * xf86ActivateDevice -- @@ -193,8 +156,6 @@ xf86ActivateDevice(LocalDevicePtr local) dev->public.devicePrivate = (pointer) local; local->dev = dev; - xf86XinputFinalizeInit(dev); - dev->coreEvents = local->flags & XI86_ALWAYS_CORE; RegisterOtherDevice(dev); @@ -435,9 +396,9 @@ xf86PostMotionEvent(DeviceIntPtr device, va_list var; int i = 0, nevents = 0; Bool drag = xf86SendDragEvents(device); - LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate; int *valuators = NULL; int flags = 0; + xEvent *xE = NULL; if (is_absolute) flags = POINTER_ABSOLUTE; @@ -460,8 +421,14 @@ xf86PostMotionEvent(DeviceIntPtr device, flags, first_valuator, num_valuators, valuators); - for (i = 0; i < nevents; i++) - mieqEnqueue(device, xf86Events + i); + for (i = 0; i < nevents; i++) { + xE = xf86Events + i; + /* Don't post core motion events for devices not registered to send + * drag events. */ + if (xE->u.u.type != MotionNotify || drag) { + mieqEnqueue(device, xf86Events + i); + } + } xfree(valuators); } From 99378b58dbc63160382ad9c41f9cb0dd2a24e9d1 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 27 Nov 2006 22:22:33 +0200 Subject: [PATCH 071/109] kdrive/tslib: remove vendor-specific hacks Parts of the KDrive merge accidentally contained a bunch of vendor-specific hacks; sorry. --- hw/kdrive/linux/tslib.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c index 44b4b5413..41b74fabd 100644 --- a/hw/kdrive/linux/tslib.c +++ b/hw/kdrive/linux/tslib.c @@ -75,10 +75,7 @@ TsRead (int fd, void *closure) while (ts_read(private->tsDev, &event, 1) == 1) { if (event.pressure) { - if (event.pressure > pi->dixdev->absolute->button_threshold) - flags = KD_BUTTON_8; - else - flags = KD_BUTTON_1; + flags = KD_BUTTON_1; /* * Here we test for the touch screen driver actually being on the @@ -113,9 +110,8 @@ TsRead (int fd, void *closure) static Status TslibEnable (KdPointerInfo *pi) { - struct TslibPrivate *private = pi->driverPrivate; + struct TslibPrivate *private = pi->driverPrivate; - private->holdThumbEvents = 1; private->raw_event_hook = NULL; private->raw_event_closure = NULL; private->tsDev = ts_open(pi->path, 0); @@ -126,9 +122,6 @@ TslibEnable (KdPointerInfo *pi) close(private->fd); return BadAlloc; } - if (pi->dixdev && pi->dixdev->absolute && - pi->dixdev->absolute->button_threshold == 0) - pi->dixdev->absolute->button_threshold = 115; KdRegisterFd(private->fd, TsRead, pi); @@ -141,12 +134,12 @@ TslibDisable (KdPointerInfo *pi) { struct TslibPrivate *private = pi->driverPrivate; - if (private->fd) { - KdUnregisterFd(pi, private->fd); - close(private->fd); - } + if (private->fd) + KdUnregisterFd(pi, private->fd, TRUE); + if (private->tsDev) ts_close(private->tsDev); + private->fd = 0; private->tsDev = NULL; } @@ -156,7 +149,6 @@ static Status TslibInit (KdPointerInfo *pi) { int fd = 0, i = 0; - char devpath[PATH_MAX], devname[TS_NAME_SIZE]; DIR *inputdir = NULL; struct dirent *inputent = NULL; struct tsdev *tsDev = NULL; From 2f0a800ffdc881cdb3adf84f1ed97bbb63cba34c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 27 Nov 2006 22:22:53 +0200 Subject: [PATCH 072/109] config: move to block/wakeup handler --- config/config.c | 112 ++++++++++++++++++++++++++++-------------------- dix/dispatch.c | 3 -- 2 files changed, 65 insertions(+), 50 deletions(-) diff --git a/config/config.c b/config/config.c index 05757e2c8..9ecdbb43c 100644 --- a/config/config.c +++ b/config/config.c @@ -50,18 +50,27 @@ ret = BadValue; \ goto unwind; } -static DBusConnection *configConnection = NULL; -static int configfd = -1; -static char busobject[32] = { 0 }; -static char busname[64] = { 0 }; +struct config_data { + int fd; + DBusConnection *connection; + char busobject[32]; + char busname[64]; +}; -void -configDispatch() +static struct config_data *configData; + +static void +configWakeupHandler(pointer blockData, int err, pointer pReadMask) { - if (!configConnection) - return; + struct config_data *data = blockData; - dbus_connection_read_write_dispatch(configConnection, 0); + if (data->connection && FD_ISSET(data->fd, (fd_set *) pReadMask)) + dbus_connection_read_write_dispatch(data->connection, 0); +} + +static void +configBlockHandler(pointer data, struct timeval **tv, pointer pReadMask) +{ } static int @@ -249,68 +258,78 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) void configInitialise() { - DBusConnection *bus = NULL; DBusError error; DBusObjectPathVTable vtable = { .message_function = configMessage }; - configConnection = NULL; + if (!configData) + configData = (struct config_data *) xcalloc(sizeof(struct config_data), 1); + if (!configData) + return; dbus_error_init(&error); - bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); - if (!bus || dbus_error_is_set(&error)) { + configData->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + if (!configData->connection || dbus_error_is_set(&error)) { ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name, error.message); dbus_error_free(&error); return; } - if (!dbus_connection_get_unix_fd(bus, &configfd)) { - dbus_connection_unref(bus); + if (!dbus_connection_get_unix_fd(configData->connection, &configData->fd)) { + dbus_connection_unref(configData->connection); ErrorF("[dbus] couldn't get fd for bus\n"); dbus_error_free(&error); - configfd = -1; + configData->fd = -1; return; } - snprintf(busname, sizeof(busname), "org.x.config.display%d", atoi(display)); - if (!dbus_bus_request_name(bus, busname, 0, &error) || - dbus_error_is_set(&error)) { + snprintf(configData->busname, sizeof(configData->busname), + "org.x.config.display%d", atoi(display)); + if (!dbus_bus_request_name(configData->connection, configData->busname, + 0, &error) || dbus_error_is_set(&error)) { ErrorF("[dbus] couldn't take over org.x.config: %s (%s)\n", error.name, error.message); dbus_error_free(&error); - dbus_connection_unref(bus); - configfd = -1; + dbus_connection_unref(configData->connection); + configData->fd = -1; return; } /* blocks until we get a reply. */ - dbus_bus_add_match(bus, MATCH_RULE, &error); + dbus_bus_add_match(configData->connection, MATCH_RULE, &error); if (dbus_error_is_set(&error)) { ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name, error.message); dbus_error_free(&error); - dbus_bus_release_name(bus, busname, &error); - dbus_connection_unref(bus); - configfd = -1; + dbus_bus_release_name(configData->connection, configData->busname, + &error); + dbus_connection_unref(configData->connection); + configData->fd = -1; return; } - snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display)); - if (!dbus_connection_register_object_path(bus, busobject, &vtable, bus)) { + snprintf(configData->busobject, sizeof(configData->busobject), + "/org/x/config/%d", atoi(display)); + if (!dbus_connection_register_object_path(configData->connection, + configData->busobject, &vtable, + configData->connection)) { ErrorF("[dbus] couldn't register object path\n"); - configfd = -1; - dbus_bus_release_name(bus, busname, &error); - dbus_bus_remove_match(bus, MATCH_RULE, &error); - dbus_connection_unref(bus); + configData->fd = -1; + dbus_bus_release_name(configData->connection, configData->busname, + &error); + dbus_bus_remove_match(configData->connection, MATCH_RULE, &error); + dbus_connection_unref(configData->connection); dbus_error_free(&error); return; } - DebugF("[dbus] registered object path %s\n", busobject); + DebugF("[dbus] registered object path %s\n", configData->busobject); dbus_error_free(&error); - configConnection = bus; - AddGeneralSocket(configfd); + AddGeneralSocket(configData->fd); + + RegisterBlockAndWakeupHandlers(configBlockHandler, configWakeupHandler, + configData); } void @@ -318,26 +337,25 @@ configFini() { DBusError error; - if (configConnection) { + if (configData) { dbus_error_init(&error); - dbus_connection_unregister_object_path(configConnection, busobject); - dbus_bus_remove_match(configConnection, MATCH_RULE, &error); - dbus_bus_release_name(configConnection, busname, &error); - dbus_connection_unref(configConnection); - RemoveGeneralSocket(configfd); - configConnection = NULL; - configfd = -1; + dbus_connection_unregister_object_path(configData->connection, + configData->busobject); + dbus_bus_remove_match(configData->connection, MATCH_RULE, &error); + dbus_bus_release_name(configData->connection, configData->busname, + &error); + dbus_connection_unref(configData->connection); + RemoveGeneralSocket(configData->fd); + RemoveBlockAndWakeupHandlers(configBlockHandler, configWakeupHandler, + configData); + xfree(configData); + configData = NULL; dbus_error_free(&error); } } #else /* !HAVE_DBUS */ -void -configDispatch() -{ -} - void configInitialise() { diff --git a/dix/dispatch.c b/dix/dispatch.c index 0a93c3b6e..4c5a9b718 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -426,9 +426,6 @@ Dispatch(void) nready = WaitForSomething(clientReady); - /* this is an enormous hack and NEEDS TO GO AWAY. */ - configDispatch(); - #ifdef SMART_SCHEDULE if (nready && !SmartScheduleDisable) { From 8724af248cd6c93182fecd060fed09a556361080 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sat, 2 Dec 2006 16:20:34 +0200 Subject: [PATCH 073/109] kdrive/mga: fix compiler warning Change a case that only made one test for an if, preventing the compiler warning about all other PICT_* types being unsupported. --- hw/kdrive/mga/g400_composite.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/kdrive/mga/g400_composite.c b/hw/kdrive/mga/g400_composite.c index 671e517fb..da2e8b810 100644 --- a/hw/kdrive/mga/g400_composite.c +++ b/hw/kdrive/mga/g400_composite.c @@ -286,10 +286,8 @@ mgaCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (pMaskPicture->componentAlpha) MGA_FALLBACK(("Component alpha unsupported")); - switch (pDstPicture->format) { - case PICT_a8: + if (pDstPicture->format == PICT_a8) MGA_FALLBACK(("render to A8 unsupported")); - } return TRUE; } From edabf45425f9ed79547f918cc0dfff4c268de386 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sat, 2 Dec 2006 16:37:19 +0200 Subject: [PATCH 074/109] configure.ac: add CONFIG_LIB to Xvfb --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 851194c9f..002be624c 100644 --- a/configure.ac +++ b/configure.ac @@ -1059,7 +1059,7 @@ AC_MSG_RESULT([$XVFB]) AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes]) if test "x$XVFB" = xyes; then - XVFB_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS" + XVFB_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS" AC_SUBST([XVFB_LIBS]) fi From c458a70d650bd62b8f4706f022d1f3f347636db1 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 20:30:44 +0200 Subject: [PATCH 075/109] GetPointerEvents: fix typo Fix typo that resulted in inverted axes when using an absolute positioning device that didn't report y, and thus relied on the previous value. --- dix/getevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/getevents.c b/dix/getevents.c index 41542625b..9c4ed0ece 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -540,7 +540,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, } else { if (pDev->coreEvents) - x = cp->valuator->lasty; + y = cp->valuator->lasty; else y = pDev->valuator->lasty; } From 72e7f2ac6cf0db474d0defa7918f2a3ba76c0e46 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 23:18:52 +0200 Subject: [PATCH 076/109] GetPointerEvents: always send valuator events for MotionNotify Always chase a DeviceMotionNotify event with a DeviceValuator, which is not required in the spec, but will silently break the lib if you don't include. --- dix/getevents.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index 9c4ed0ece..0150d6658 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -484,6 +484,8 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, int num_events = 0, final_valuator = 0; CARD32 ms = 0; deviceKeyButtonPointer *kbp = NULL; + /* Thanks to a broken lib, we _always_ have to chase DeviceMotionNotifies + * with DeviceValuators. */ Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE); DeviceIntPtr cp = inputInfo.pointer; int x = 0, y = 0; @@ -500,15 +502,16 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, else num_events = 1; + if (type == MotionNotify && num_valuators <= 0) { + return 0; + } + /* Do we need to send a DeviceValuator event? */ - if ((num_valuators + first_valuator) > 2 && sendValuators) { + if (sendValuators) { if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS) num_valuators = MAX_VALUATOR_EVENTS * 6; num_events += ((num_valuators - 1) / 6) + 1; } - else if (type == MotionNotify && num_valuators <= 0) { - return 0; - } final_valuator = num_valuators + first_valuator; @@ -614,7 +617,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, kbp->root_y = y; events++; - if (final_valuator > 2 && sendValuators) { + if (sendValuators) { kbp->deviceid |= MORE_EVENTS; clipValuators(pDev, first_valuator, num_valuators, valuators); events = getValuatorEvents(events, pDev, first_valuator, From 0c5dab5c8eaa174f28054b9d20244a709c015210 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 23:21:15 +0200 Subject: [PATCH 077/109] config: move config.h to hotplug.h Also, move configInitialise to after OsInit, since the next commit will make it use a timer. --- dix/dispatch.c | 1 - dix/main.c | 6 +++--- include/Makefile.am | 2 +- include/{config.h => hotplug.h} | 0 4 files changed, 4 insertions(+), 5 deletions(-) rename include/{config.h => hotplug.h} (100%) diff --git a/dix/dispatch.c b/dix/dispatch.c index 4c5a9b718..0a761eb6c 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -130,7 +130,6 @@ int ProcInitialConnection(); #include "dispatch.h" #include "swaprep.h" #include "swapreq.h" -#include "config.h" #ifdef PANORAMIX #include "panoramiX.h" #include "panoramiXsrv.h" diff --git a/dix/main.c b/dix/main.c index 077fdea04..3a77533a5 100644 --- a/dix/main.c +++ b/dix/main.c @@ -98,7 +98,7 @@ Equipment Corporation. #include #include "opaque.h" #include "servermd.h" -#include "config.h" +#include "hotplug.h" #include "site.h" #include "dixfont.h" #include "extnsionst.h" @@ -309,9 +309,9 @@ main(int argc, char *argv[], char *envp[]) DPMSPowerLevel = 0; #endif InitBlockAndWakeupHandlers(); - configInitialise(); /* Perform any operating system dependent initializations you'd like */ - OsInit(); + OsInit(); + configInitialise(); if(serverGeneration == 1) { CreateWellKnownSockets(); diff --git a/include/Makefile.am b/include/Makefile.am index 9f07fa650..4289b818d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -7,7 +7,7 @@ sdk_HEADERS = \ closure.h \ colormap.h \ colormapst.h \ - config.h \ + hotplug.h \ cursor.h \ cursorstr.h \ dix.h \ diff --git a/include/config.h b/include/hotplug.h similarity index 100% rename from include/config.h rename to include/hotplug.h From 4cba1a1ebfbdd7ab489b1b1ffb6656cbe88eb61e Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 23:21:38 +0200 Subject: [PATCH 078/109] config: bus reconnect support Add support for reconnecting to the bus when it restarts. --- config/config.c | 155 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 118 insertions(+), 37 deletions(-) diff --git a/config/config.c b/config/config.c index 9ecdbb43c..66a15fcba 100644 --- a/config/config.c +++ b/config/config.c @@ -36,10 +36,10 @@ /* the above comment lies. there is no better way. */ #include "input.h" #include "inputstr.h" -#include "config.h" +#include "hotplug.h" #include "os.h" -#define MATCH_RULE "type='method_call',interface='org.x.config.input'" +#define CONFIG_MATCH_RULE "type='method_call',interface='org.x.config.input'" #define MALFORMED_MSG "[config] malformed message, dropping" #define MALFORMED_MESSAGE() { DebugF(MALFORMED_MSG "\n"); \ @@ -50,6 +50,9 @@ ret = BadValue; \ goto unwind; } +/* How often to attempt reconnecting when we get booted off the bus. */ +#define RECONNECT_DELAY 10000 /* in ms */ + struct config_data { int fd; DBusConnection *connection; @@ -59,6 +62,8 @@ struct config_data { static struct config_data *configData; +static CARD32 configReconnect(OsTimerPtr timer, CARD32 time, pointer arg); + static void configWakeupHandler(pointer blockData, int err, pointer pReadMask) { @@ -73,6 +78,18 @@ configBlockHandler(pointer data, struct timeval **tv, pointer pReadMask) { } +static void +configTeardown(void) +{ + if (configData) { + RemoveGeneralSocket(configData->fd); + RemoveBlockAndWakeupHandlers(configBlockHandler, configWakeupHandler, + configData); + xfree(configData); + configData = NULL; + } +} + static int configAddDevice(DBusMessage *message, DBusMessageIter *iter, DBusError *error) { @@ -226,23 +243,22 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) ret = configAddDevice(message, &iter, &error); else if (strcmp(dbus_message_get_member(message), "remove") == 0) ret = configRemoveDevice(message, &iter, &error); - } + if (ret != BadDrawable && ret != BadAlloc) { + reply = dbus_message_new_method_return(message); + dbus_message_iter_init_append(reply, &iter); - if (ret != BadDrawable && ret != BadAlloc) { - reply = dbus_message_new_method_return(message); - dbus_message_iter_init_append(reply, &iter); + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret)) { + ErrorF("[config] couldn't append to iterator\n"); + dbus_error_free(&error); + return DBUS_HANDLER_RESULT_HANDLED; + } - if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret)) { - ErrorF("[config] couldn't append to iterator\n"); - dbus_error_free(&error); - return DBUS_HANDLER_RESULT_HANDLED; + if (!dbus_connection_send(bus, reply, NULL)) + ErrorF("[config] failed to send reply\n"); + dbus_connection_flush(bus); + + dbus_message_unref(reply); } - - if (!dbus_connection_send(bus, reply, NULL)) - ErrorF("[config] failed to send reply\n"); - dbus_connection_flush(bus); - - dbus_message_unref(reply); } dbus_error_free(&error); @@ -255,16 +271,40 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) return DBUS_HANDLER_RESULT_HANDLED; } -void -configInitialise() +/** + * This is a filter, which only handles the disconnected signal, which + * doesn't go to the normal message handling function. This takes + * precedence over the message handling function, so have have to be + * careful to ignore anything we don't want to deal with here. + * + * Yes, this is brutally stupid. + */ +static DBusHandlerResult +configFilter(DBusConnection *connection, DBusMessage *message, void *closure) +{ + if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, + "Disconnected")) { + ErrorF("[dbus] disconnected from bus\n"); + TimerSet(NULL, 0, RECONNECT_DELAY, configReconnect, NULL); + configTeardown(); + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static Bool +configSetup(void) { DBusError error; DBusObjectPathVTable vtable = { .message_function = configMessage }; if (!configData) configData = (struct config_data *) xcalloc(sizeof(struct config_data), 1); - if (!configData) - return; + if (!configData) { + ErrorF("[dbus] failed to allocate data struct.\n"); + return FALSE; + } dbus_error_init(&error); configData->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); @@ -272,15 +312,20 @@ configInitialise() ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name, error.message); dbus_error_free(&error); - return; + xfree(configData); + configData = NULL; + return FALSE; } + dbus_connection_set_exit_on_disconnect(configData->connection, FALSE); + if (!dbus_connection_get_unix_fd(configData->connection, &configData->fd)) { dbus_connection_unref(configData->connection); ErrorF("[dbus] couldn't get fd for bus\n"); dbus_error_free(&error); - configData->fd = -1; - return; + xfree(configData); + configData = NULL; + return FALSE; } snprintf(configData->busname, sizeof(configData->busname), @@ -291,12 +336,13 @@ configInitialise() error.name, error.message); dbus_error_free(&error); dbus_connection_unref(configData->connection); - configData->fd = -1; - return; + xfree(configData); + configData = NULL; + return FALSE; } /* blocks until we get a reply. */ - dbus_bus_add_match(configData->connection, MATCH_RULE, &error); + dbus_bus_add_match(configData->connection, CONFIG_MATCH_RULE, &error); if (dbus_error_is_set(&error)) { ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name, error.message); @@ -304,8 +350,25 @@ configInitialise() dbus_bus_release_name(configData->connection, configData->busname, &error); dbus_connection_unref(configData->connection); - configData->fd = -1; - return; + xfree(configData); + configData = NULL; + return FALSE; + } + + if (!dbus_connection_add_filter(configData->connection, configFilter, + configData, NULL)) { + + ErrorF("[dbus] couldn't add signal filter: %s (%s)\n", error.name, + error.message); + dbus_error_free(&error); + dbus_bus_release_name(configData->connection, configData->busname, + &error); + dbus_bus_remove_match(configData->connection, CONFIG_MATCH_RULE, + &error); + dbus_connection_unref(configData->connection); + xfree(configData); + configData = NULL; + return FALSE; } snprintf(configData->busobject, sizeof(configData->busobject), @@ -314,13 +377,15 @@ configInitialise() configData->busobject, &vtable, configData->connection)) { ErrorF("[dbus] couldn't register object path\n"); - configData->fd = -1; dbus_bus_release_name(configData->connection, configData->busname, &error); - dbus_bus_remove_match(configData->connection, MATCH_RULE, &error); + dbus_bus_remove_match(configData->connection, CONFIG_MATCH_RULE, + &error); dbus_connection_unref(configData->connection); dbus_error_free(&error); - return; + xfree(configData); + configData = NULL; + return FALSE; } DebugF("[dbus] registered object path %s\n", configData->busobject); @@ -330,6 +395,23 @@ configInitialise() RegisterBlockAndWakeupHandlers(configBlockHandler, configWakeupHandler, configData); + + return TRUE; +} + +static CARD32 +configReconnect(OsTimerPtr timer, CARD32 time, pointer arg) +{ + if (configSetup()) + return 0; + else + return RECONNECT_DELAY; +} + +void +configInitialise() +{ + TimerSet(NULL, 0, 1, configReconnect, NULL); } void @@ -341,16 +423,15 @@ configFini() dbus_error_init(&error); dbus_connection_unregister_object_path(configData->connection, configData->busobject); - dbus_bus_remove_match(configData->connection, MATCH_RULE, &error); + dbus_connection_remove_filter(configData->connection, configFilter, + configData); + dbus_bus_remove_match(configData->connection, CONFIG_MATCH_RULE, + &error); dbus_bus_release_name(configData->connection, configData->busname, &error); dbus_connection_unref(configData->connection); - RemoveGeneralSocket(configData->fd); - RemoveBlockAndWakeupHandlers(configBlockHandler, configWakeupHandler, - configData); - xfree(configData); - configData = NULL; dbus_error_free(&error); + configTeardown(); } } From 4ea6dfb984063117eef5c2f931205b1c3eb3108b Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 23:24:39 +0200 Subject: [PATCH 079/109] whitespace police --- config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.c b/config/config.c index 66a15fcba..523327d04 100644 --- a/config/config.c +++ b/config/config.c @@ -357,7 +357,7 @@ configSetup(void) if (!dbus_connection_add_filter(configData->connection, configFilter, configData, NULL)) { - + ErrorF("[dbus] couldn't add signal filter: %s (%s)\n", error.name, error.message); dbus_error_free(&error); From 729fca33a417ae3dfb180caf0ea8946ef9eee1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 7 Dec 2006 12:09:18 +0100 Subject: [PATCH 080/109] Revert "xfree86 DDX: Delete DDX screens in ddxGiveUp()." This reverts commit a6381e69845f58d2b3282992b1f881015190f1bc. See https://bugs.freedesktop.org/show_bug.cgi?id=9224 . --- hw/xfree86/common/xf86Init.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 68d69c51c..ff878d59c 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1119,9 +1119,6 @@ ddxGiveUp() DGAShutdown(); #endif - while (xf86NumScreens) - xf86DeleteScreen(xf86NumScreens - 1, 0); - xf86CloseConsole(); xf86CloseLog(); From e59aeac1ff13ea53f44dba1ac7800f37f4532ca1 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 6 Dec 2006 23:44:06 +0200 Subject: [PATCH 081/109] xfree86: remove stray debug line --- hw/xfree86/common/xf86Events.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 5469426f2..05e62f184 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -789,8 +789,6 @@ xf86ReleaseKeys(DeviceIntPtr pDev) xEvent ke; int i = 0, j = 0, nevents = 0; - ErrorF("releasekeys: called on device %s (%d)\n", pDev->name, pDev->id); - if (!pDev || !pDev->key) return; From ec84f72d077eaf2e7768a1f5398f65a5e1714d08 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 8 Dec 2006 21:31:47 +0200 Subject: [PATCH 082/109] XkbCopyKeymap: always initialise map and preserve If we don't have map or preserve in the source map, make sure the destination is initialised to NULL, and freed if it's a valid type. --- xkb/xkbUtils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 321bf2e1b..c9c5ed018 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -1144,6 +1144,11 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) memcpy(dtype->map, stype->map, stype->map_count * sizeof(XkbKTMapEntryRec)); } + else { + if (dtype->map && i < dst->map->num_types) + xfree(dtype->map); + dtype->map = NULL; + } if (stype->preserve) { if (stype->map_count != dtype->map_count && @@ -1168,17 +1173,22 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) memcpy(dtype->preserve, stype->preserve, stype->map_count * sizeof(XkbModsRec)); } + else { + if (dtype->preserve && i < dst->map->num_types) + xfree(dtype->preserve); + dtype->preserve = NULL; + } dtype->map_count = stype->map_count; } else { - if (dtype->map_count) { + if (dtype->map_count && i < dst->map->num_types) { if (dtype->map) xfree(dtype->map); if (dtype->preserve) xfree(dtype->preserve); - dtype->map_count = 0; } + dtype->map_count = 0; dtype->map = NULL; dtype->preserve = NULL; } From f1f8df1889ab656bb57596e2f85408f15f42cd5d Mon Sep 17 00:00:00 2001 From: "Jeremy C. Reed" Date: Fri, 8 Dec 2006 15:51:44 -0600 Subject: [PATCH 083/109] For MANDEFS, also replace __mandir__ for $(mandir) which includes the prefix. Noticed wrong path to man pages on both Ubuntu and on NetBSD with pkgsrc. --- cpprules.in | 1 + hw/xfree86/doc/man/Xorg.man.pre | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cpprules.in b/cpprules.in index 667b13322..4901ea890 100644 --- a/cpprules.in +++ b/cpprules.in @@ -34,6 +34,7 @@ MANDEFS = \ -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ -D__projectroot__=$(prefix) \ -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index b7fa990bb..d91b79641 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -580,7 +580,7 @@ Client error message database. .B __projectroot__/lib/X11/app-defaults/\(** Client resource specifications. .TP 30 -.B __projectroot__/man/man?/\(** +.B __mandir__/man?/\(** Manual pages. .TP 30 .BI /etc/X n .hosts From fb8364bca30fe9268e807b0a9a3ebf875ee1fce2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Sun, 10 Dec 2006 11:24:05 -0500 Subject: [PATCH 084/109] Accept EDID > 1.3 but < 2.0 if we find it, assume it's compatible. --- hw/xfree86/ddc/ddcProperty.c | 3 --- hw/xfree86/ddc/interpret_edid.c | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index 11b5e26ed..13083dd50 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -32,9 +32,6 @@ #include "propertyst.h" #include "xf86DDC.h" - - - #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" #define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA" #define VDIF_ATOM_NAME "XFree86_DDC_VDIF_RAWDATA" diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c index c58bb2fe1..7b4b2b9ec 100644 --- a/hw/xfree86/ddc/interpret_edid.c +++ b/hw/xfree86/ddc/interpret_edid.c @@ -304,16 +304,18 @@ get_detailed_timing_section(Uchar *c, struct detailed_timings *r) r->misc = MISC; } +#define MAX_EDID_MINOR 3 static Bool validate_version(int scrnIndex, struct edid_version *r) { if (r->version != 1) return FALSE; - if (r->revision > 3) { - xf86DrvMsg(scrnIndex, X_ERROR,"EDID Version 1.%i not yet supported\n", - r->revision); - return FALSE; - } + + if (r->revision > MAX_EDID_MINOR) + xf86DrvMsg(scrnIndex, X_WARNING, + "Assuming version 1.%d is compatible with 1.%d\n", + r->revision, MAX_EDID_MINOR); + return TRUE; } From 27d4b84f268ac21601f7f52a7e257f70753396b3 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Mon, 11 Dec 2006 14:50:08 +0000 Subject: [PATCH 085/109] Fix Tooltip from minimized clients Bug #3678 (Colin Harrison) --- hw/xwin/winmultiwindowwindow.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index dc8e38bae..037c881b4 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -982,11 +982,10 @@ winAdjustXWindow (WindowPtr pWin, HWND hwnd) /* * If the Windows window is minimized, its WindowRect has * meaningless values so we don't adjust X window to it. - * Instead we put the X window to the bottom in Z order to - * be obscured by other windows. */ - vlist[0] = Below; - return ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin)); + vlist[0] = 0; + vlist[1] = 0; + return ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin)); } pDraw = &pWin->drawable; From 792e0f71c6a435b2e28f8a4cdcc790f3b982e62c Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Mon, 11 Dec 2006 14:54:49 +0000 Subject: [PATCH 086/109] Fix Xming fails to use xkb bug bug #5049 (Colin Harrison) --- hw/xwin/InitOutput.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index b64eee9c7..996498090 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -694,6 +694,7 @@ winFixupPaths (void) if (sizeof(xkbbasedir) > 0) xkbbasedir[sizeof(xkbbasedir)-1] = 0; XkbBaseDirectory = xkbbasedir; + XkbBinDirectory = xkbbasedir } #endif /* XKB */ #endif /* RELOCATE_PROJECTROOT */ From 81281cb298a5825bc7a2e692375a86199293bbbe Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 12 Dec 2006 11:28:24 +0000 Subject: [PATCH 087/109] Fix bad commit --- hw/xwin/InitOutput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 996498090..39a5eda7f 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -694,7 +694,7 @@ winFixupPaths (void) if (sizeof(xkbbasedir) > 0) xkbbasedir[sizeof(xkbbasedir)-1] = 0; XkbBaseDirectory = xkbbasedir; - XkbBinDirectory = xkbbasedir + XkbBinDirectory = basedir; } #endif /* XKB */ #endif /* RELOCATE_PROJECTROOT */ From b88ad820fac81d0dfd557a384bf0406e8893e7af Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 13 Dec 2006 12:13:11 +0000 Subject: [PATCH 088/109] Set Int10Current->Tag for the linux native int10 module Fixes bug #9296 (cherry picked from 731952c561a3972d09d1315f4fd31466e459ccb9 commit) --- hw/xfree86/int10/generic.c | 2 +- hw/xfree86/os-support/linux/int10/linux.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 46a1179de..d86372780 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -98,7 +98,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); pvp = xf86GetPciInfoForEntity(entityIndex); - if (pvp) pInt->Tag = ((pciConfigPtr)(pvp->thisCard))->tag; + if (pvp) pInt->Tag = pciTag(pvp->bus, pvp->device, pvp->func); /* * we need to map video RAM MMIO as some chipsets map mmio diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c index 6c8b230e7..dd1637a23 100644 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ b/hw/xfree86/os-support/linux/int10/linux.c @@ -90,6 +90,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) legacyVGARec vga; xf86int10BiosLocation bios; Bool videoBiosMapped = FALSE; + pciVideoPtr pvp; if (int10Generation != serverGeneration) { counter = 0; @@ -151,6 +152,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec)); pInt->scrnIndex = screen; pInt->entityIndex = entityIndex; + pvp = xf86GetPciInfoForEntity(entityIndex); + if (pvp) pInt->Tag = pciTag(pvp->bus, pvp->device, pvp->func); if (!xf86Int10ExecSetup(pInt)) goto error0; pInt->mem = &linuxMem; From 6c46645cfc1afda8aeabfe0ed4d9342673b702f1 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 14:45:42 -0500 Subject: [PATCH 089/109] Naming change: Security*Access -> Dix*Access --- Xext/appgroup.c | 4 +- Xext/cup.c | 2 +- Xext/panoramiXprocs.c | 172 ++++++++++++++++---------------- Xext/saver.c | 10 +- Xext/security.c | 12 +-- Xext/shape.c | 22 ++-- Xext/shm.c | 6 +- Xext/sync.c | 16 +-- Xext/xf86bigfont.c | 4 +- Xext/xprint.c | 26 ++--- Xext/xvdisp.c | 30 +++--- damageext/damageext.c | 10 +- dbe/dbe.c | 12 +-- dix/colormap.c | 4 +- dix/cursor.c | 4 +- dix/dispatch.c | 118 +++++++++++----------- dix/dixfonts.c | 8 +- dix/dixutils.c | 6 +- dix/events.c | 38 +++---- dix/gc.c | 8 +- dix/property.c | 20 ++-- dix/resource.c | 4 +- dix/window.c | 10 +- hw/darwin/quartz/applewm.c | 6 +- hw/darwin/quartz/xpr/appledri.c | 4 +- hw/dmx/dmx.c | 12 +-- hw/dmx/dmxpict.c | 24 ++--- hw/dmx/glxProxy/glxcmds.c | 24 ++--- hw/xfree86/dri/xf86dri.c | 6 +- hw/xwin/winclipboardwrappers.c | 2 +- hw/xwin/winwindowswm.c | 6 +- include/dix.h | 10 +- include/resource.h | 9 +- os/access.c | 2 +- randr/rrcrtc.c | 8 +- randr/rrdispatch.c | 4 +- randr/rroutput.c | 2 +- randr/rrproperty.c | 14 +-- randr/rrscreen.c | 10 +- render/picture.c | 4 +- render/render.c | 122 +++++++++++----------- xfixes/cursor.c | 12 +-- xfixes/region.c | 46 ++++----- xfixes/saveset.c | 2 +- xfixes/select.c | 2 +- 45 files changed, 439 insertions(+), 438 deletions(-) diff --git a/Xext/appgroup.c b/Xext/appgroup.c index 650dc0ab8..4f3000569 100644 --- a/Xext/appgroup.c +++ b/Xext/appgroup.c @@ -432,7 +432,7 @@ int ProcXagDestroy( REQUEST_SIZE_MATCH (xXagDestroyReq); pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client, - (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess); + (XID)stuff->app_group, RT_APPGROUP, DixReadAccess); if (!pAppGrp) return XagBadAppGroup; FreeResource ((XID)stuff->app_group, RT_NONE); if (--XagCallbackRefCount == 0) @@ -451,7 +451,7 @@ int ProcXagGetAttr( REQUEST_SIZE_MATCH (xXagGetAttrReq); pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client, - (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess); + (XID)stuff->app_group, RT_APPGROUP, DixReadAccess); if (!pAppGrp) return XagBadAppGroup; rep.type = X_Reply; rep.length = 0; diff --git a/Xext/cup.c b/Xext/cup.c index 10d13bae0..6bfa27837 100644 --- a/Xext/cup.c +++ b/Xext/cup.c @@ -227,7 +227,7 @@ int ProcStoreColors( REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq); pcmp = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int ncolors, n; diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 8bb4c593d..683308425 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -91,7 +91,7 @@ int PanoramiXCreateWindow(ClientPtr client) return BadLength; if (!(parent = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->parent, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->parent, XRT_WINDOW, DixWriteAccess))) return BadWindow; if(stuff->class == CopyFromParent) @@ -105,7 +105,7 @@ int PanoramiXCreateWindow(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -114,7 +114,7 @@ int PanoramiXCreateWindow(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -123,7 +123,7 @@ int PanoramiXCreateWindow(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, SecurityReadAccess))) + client, tmp, XRT_COLORMAP, DixReadAccess))) return BadColor; } } @@ -192,7 +192,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) return BadLength; if (!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->window, XRT_WINDOW, DixWriteAccess))) return BadWindow; if((win->u.win.class == InputOnly) && @@ -204,7 +204,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -213,7 +213,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -222,7 +222,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, SecurityReadAccess))) + client, tmp, XRT_COLORMAP, DixReadAccess))) return BadColor; } } @@ -251,7 +251,7 @@ int PanoramiXDestroyWindow(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityDestroyAccess))) + client, stuff->id, XRT_WINDOW, DixDestroyAccess))) return BadWindow; FOR_NSCREENS_BACKWARD(j) { @@ -276,7 +276,7 @@ int PanoramiXDestroySubwindows(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityDestroyAccess))) + client, stuff->id, XRT_WINDOW, DixDestroyAccess))) return BadWindow; FOR_NSCREENS_BACKWARD(j) { @@ -301,7 +301,7 @@ int PanoramiXChangeSaveSet(ClientPtr client) REQUEST_SIZE_MATCH(xChangeSaveSetReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityReadAccess))) + client, stuff->window, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS_BACKWARD(j) { @@ -325,11 +325,11 @@ int PanoramiXReparentWindow(ClientPtr client) REQUEST_SIZE_MATCH(xReparentWindowReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->window, XRT_WINDOW, DixWriteAccess))) return BadWindow; if(!(parent = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->parent, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->parent, XRT_WINDOW, DixWriteAccess))) return BadWindow; x = stuff->x; @@ -360,7 +360,7 @@ int PanoramiXMapWindow(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + client, stuff->id, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS_FORWARD(j) { @@ -382,7 +382,7 @@ int PanoramiXMapSubwindows(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + client, stuff->id, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS_FORWARD(j) { @@ -404,7 +404,7 @@ int PanoramiXUnmapWindow(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + client, stuff->id, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS_FORWARD(j) { @@ -426,7 +426,7 @@ int PanoramiXUnmapSubwindows(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + client, stuff->id, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS_FORWARD(j) { @@ -457,11 +457,11 @@ int PanoramiXConfigureWindow(ClientPtr client) /* because we need the parent */ if (!(pWin = (WindowPtr)SecurityLookupIDByType( - client, stuff->window, RT_WINDOW, SecurityWriteAccess))) + client, stuff->window, RT_WINDOW, DixWriteAccess))) return BadWindow; if (!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->window, XRT_WINDOW, DixWriteAccess))) return BadWindow; if ((Mask)stuff->mask & CWSibling) { @@ -469,7 +469,7 @@ int PanoramiXConfigureWindow(ClientPtr client) sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { if(!(sib = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_WINDOW, SecurityReadAccess))) + client, tmp, XRT_WINDOW, DixReadAccess))) return BadWindow; } } @@ -514,7 +514,7 @@ int PanoramiXCirculateWindow(ClientPtr client) REQUEST_SIZE_MATCH(xCirculateWindowReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->window, XRT_WINDOW, DixWriteAccess))) return BadWindow; FOR_NSCREENS_FORWARD(j) { @@ -579,11 +579,11 @@ int PanoramiXTranslateCoords(ClientPtr client) REQUEST_SIZE_MATCH(xTranslateCoordsReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, - SecurityReadAccess); + DixReadAccess); if (!pDst) return(BadWindow); rep.type = X_Reply; @@ -655,7 +655,7 @@ int PanoramiXCreatePixmap(ClientPtr client) client->errorValue = stuff->pid; if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixReadAccess))) return BadDrawable; if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) @@ -694,7 +694,7 @@ int PanoramiXFreePixmap(ClientPtr client) client->errorValue = stuff->id; if(!(pix = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_PIXMAP, SecurityDestroyAccess))) + client, stuff->id, XRT_PIXMAP, DixDestroyAccess))) return BadPixmap; FOR_NSCREENS_BACKWARD(j) { @@ -730,14 +730,14 @@ int PanoramiXCreateGC(ClientPtr client) return BadLength; if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixReadAccess))) return BadDrawable; if ((Mask)stuff->mask & GCTile) { tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -745,7 +745,7 @@ int PanoramiXCreateGC(ClientPtr client) stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -753,7 +753,7 @@ int PanoramiXCreateGC(ClientPtr client) clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -805,14 +805,14 @@ int PanoramiXChangeGC(ClientPtr client) return BadLength; if (!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if ((Mask)stuff->mask & GCTile) { tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -820,7 +820,7 @@ int PanoramiXChangeGC(ClientPtr client) stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -828,7 +828,7 @@ int PanoramiXChangeGC(ClientPtr client) clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -859,11 +859,11 @@ int PanoramiXCopyGC(ClientPtr client) REQUEST_SIZE_MATCH(xCopyGCReq); if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->srcGC, XRT_GC, SecurityReadAccess))) + client, stuff->srcGC, XRT_GC, DixReadAccess))) return BadGC; if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dstGC, XRT_GC, SecurityWriteAccess))) + client, stuff->dstGC, XRT_GC, DixWriteAccess))) return BadGC; FOR_NSCREENS(j) { @@ -886,7 +886,7 @@ int PanoramiXSetDashes(ClientPtr client) REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityWriteAccess))) + client, stuff->gc, XRT_GC, DixWriteAccess))) return BadGC; FOR_NSCREENS_BACKWARD(j) { @@ -908,7 +908,7 @@ int PanoramiXSetClipRectangles(ClientPtr client) REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityWriteAccess))) + client, stuff->gc, XRT_GC, DixWriteAccess))) return BadGC; FOR_NSCREENS_BACKWARD(j) { @@ -930,7 +930,7 @@ int PanoramiXFreeGC(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_GC, SecurityDestroyAccess))) + client, stuff->id, XRT_GC, DixDestroyAccess))) return BadGC; FOR_NSCREENS_BACKWARD(j) { @@ -956,7 +956,7 @@ int PanoramiXClearToBackground(ClientPtr client) REQUEST_SIZE_MATCH(xClearAreaReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->window, XRT_WINDOW, DixWriteAccess))) return BadWindow; x = stuff->x; @@ -998,13 +998,13 @@ int PanoramiXCopyArea(ClientPtr client) REQUEST_SIZE_MATCH(xCopyAreaReq); if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess))) + client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess))) return BadDrawable; srcShared = IS_SHARED_PIXMAP(src); if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; dstShared = IS_SHARED_PIXMAP(dst); @@ -1013,7 +1013,7 @@ int PanoramiXCopyArea(ClientPtr client) return (* SavedProcVector[X_CopyArea])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if((dst->type == XRT_WINDOW) && dst->u.win.root) @@ -1082,7 +1082,7 @@ int PanoramiXCopyArea(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; @@ -1146,13 +1146,13 @@ int PanoramiXCopyPlane(ClientPtr client) REQUEST_SIZE_MATCH(xCopyPlaneReq); if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess))) + client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess))) return BadDrawable; srcShared = IS_SHARED_PIXMAP(src); if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; dstShared = IS_SHARED_PIXMAP(dst); @@ -1161,7 +1161,7 @@ int PanoramiXCopyPlane(ClientPtr client) return (* SavedProcVector[X_CopyPlane])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if((dst->type == XRT_WINDOW) && dst->u.win.root) @@ -1188,7 +1188,7 @@ int PanoramiXCopyPlane(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; return (BadMatch); @@ -1246,14 +1246,14 @@ int PanoramiXPolyPoint(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyPointReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyPoint])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1304,14 +1304,14 @@ int PanoramiXPolyLine(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyLineReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyLine])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1362,14 +1362,14 @@ int PanoramiXPolySegment(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolySegmentReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolySegment])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1424,14 +1424,14 @@ int PanoramiXPolyRectangle(ClientPtr client) if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyRectangle])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1484,14 +1484,14 @@ int PanoramiXPolyArc(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyArcReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyArc])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1542,14 +1542,14 @@ int PanoramiXFillPoly(ClientPtr client) REQUEST_AT_LEAST_SIZE(xFillPolyReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_FillPoly])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1601,14 +1601,14 @@ int PanoramiXPolyFillRectangle(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyFillRectangle])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1660,14 +1660,14 @@ int PanoramiXPolyFillArc(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyFillArc])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1718,14 +1718,14 @@ int PanoramiXPutImage(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPutImageReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PutImage])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1769,7 +1769,7 @@ int PanoramiXGetImage(ClientPtr client) } if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(draw->type == XRT_PIXMAP) @@ -1909,14 +1909,14 @@ PanoramiXPolyText8(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyTextReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyText8])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1948,14 +1948,14 @@ PanoramiXPolyText16(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyTextReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyText16])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1987,14 +1987,14 @@ int PanoramiXImageText8(ClientPtr client) REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_ImageText8])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2026,14 +2026,14 @@ int PanoramiXImageText16(ClientPtr client) REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_ImageText16])(client); if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2064,7 +2064,7 @@ int PanoramiXCreateColormap(ClientPtr client) REQUEST_SIZE_MATCH(xCreateColormapReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, SecurityReadAccess))) + client, stuff->window, XRT_WINDOW, DixReadAccess))) return BadWindow; if(!stuff->visual || (stuff->visual > 255)) @@ -2107,7 +2107,7 @@ int PanoramiXFreeColormap(ClientPtr client) client->errorValue = stuff->id; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, SecurityDestroyAccess))) + client, stuff->id, XRT_COLORMAP, DixDestroyAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j) { @@ -2136,7 +2136,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client) if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( client, stuff->srcCmap, XRT_COLORMAP, - SecurityReadAccess | SecurityWriteAccess))) + DixReadAccess | DixWriteAccess))) return BadColor; if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) @@ -2174,7 +2174,7 @@ int PanoramiXInstallColormap(ClientPtr client) client->errorValue = stuff->id; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, SecurityReadAccess))) + client, stuff->id, XRT_COLORMAP, DixReadAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2197,7 +2197,7 @@ int PanoramiXUninstallColormap(ClientPtr client) client->errorValue = stuff->id; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, SecurityReadAccess))) + client, stuff->id, XRT_COLORMAP, DixReadAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j) { @@ -2220,7 +2220,7 @@ int PanoramiXAllocColor(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2243,7 +2243,7 @@ int PanoramiXAllocNamedColor(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2266,7 +2266,7 @@ int PanoramiXAllocColorCells(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2289,7 +2289,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2313,7 +2313,7 @@ int PanoramiXFreeColors(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j) { @@ -2335,7 +2335,7 @@ int PanoramiXStoreColors(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ @@ -2358,7 +2358,7 @@ int PanoramiXStoreNamedColor(ClientPtr client) client->errorValue = stuff->cmap; if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) return BadColor; FOR_NSCREENS_BACKWARD(j){ diff --git a/Xext/saver.c b/Xext/saver.c index 1d223ae53..d6b537a78 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -1279,7 +1279,7 @@ ProcScreenSaverSetAttributes (ClientPtr client) REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); @@ -1291,7 +1291,7 @@ ProcScreenSaverSetAttributes (ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -1301,7 +1301,7 @@ ProcScreenSaverSetAttributes (ClientPtr client) tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, SecurityReadAccess))) + client, tmp, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } } @@ -1311,7 +1311,7 @@ ProcScreenSaverSetAttributes (ClientPtr client) tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, SecurityReadAccess))) + client, tmp, XRT_COLORMAP, DixReadAccess))) return BadColor; } } @@ -1351,7 +1351,7 @@ ProcScreenSaverUnsetAttributes (ClientPtr client) int i; if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; for(i = PanoramiXNumScreens - 1; i > 0; i--) { diff --git a/Xext/security.c b/Xext/security.c index 572f81196..4fbf6f283 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -600,7 +600,7 @@ ProcSecurityRevokeAuthorization( REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client, - stuff->authId, SecurityAuthorizationResType, SecurityDestroyAccess); + stuff->authId, SecurityAuthorizationResType, DixDestroyAccess); if (!pAuth) return SecurityErrorBase + XSecurityBadAuthorization; @@ -966,7 +966,7 @@ CALLBACK(SecurityCheckResourceIDAccess) int cid, reqtype; if (TRUSTLEVEL(client) == XSecurityClientTrusted || - SecurityUnknownAccess == access_mode) + DixUnknownAccess == access_mode) return; /* for compatibility, we have to allow access */ cid = CLIENT_ID(id); @@ -1217,7 +1217,7 @@ CALLBACK(SecurityCheckHostlistAccess) if (TRUSTLEVEL(rec->client) != XSecurityClientTrusted) { rec->rval = FALSE; - if (rec->access_mode == SecurityWriteAccess) + if (rec->access_mode == DixWriteAccess) SecurityAudit("client %d attempted to change host access\n", rec->client->index); else @@ -1798,11 +1798,11 @@ CALLBACK(SecurityCheckPropertyAccess) * executed a continue, which will skip the follwing code. */ action = XaceAllowOperation; - if (access_mode & SecurityReadAccess) + if (access_mode & DixReadAccess) action = max(action, pacl->readAction); - if (access_mode & SecurityWriteAccess) + if (access_mode & DixWriteAccess) action = max(action, pacl->writeAction); - if (access_mode & SecurityDestroyAccess) + if (access_mode & DixDestroyAccess) action = max(action, pacl->destroyAction); break; } /* end for each pacl */ diff --git a/Xext/shape.c b/Xext/shape.c index 4d9d3fb5b..4a798da7c 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -390,7 +390,7 @@ ProcPanoramiXShapeRectangles( REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->dest, XRT_WINDOW, DixWriteAccess))) return BadWindow; FOR_NSCREENS(j) { @@ -422,7 +422,7 @@ ProcShapeMask (client) REQUEST_SIZE_MATCH (xShapeMaskReq); UpdateCurrentTime(); - pWin = SecurityLookupWindow (stuff->dest, client, SecurityWriteAccess); + pWin = SecurityLookupWindow (stuff->dest, client, DixWriteAccess); if (!pWin) return BadWindow; switch (stuff->destKind) { @@ -444,7 +444,7 @@ ProcShapeMask (client) srcRgn = 0; else { pPixmap = (PixmapPtr) SecurityLookupIDByType(client, stuff->src, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if (!pPixmap) return BadPixmap; if (pPixmap->drawable.pScreen != pScreen || @@ -488,12 +488,12 @@ ProcPanoramiXShapeMask( REQUEST_SIZE_MATCH (xShapeMaskReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->dest, XRT_WINDOW, DixWriteAccess))) return BadWindow; if(stuff->src != None) { if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->src, XRT_PIXMAP, SecurityReadAccess))) + client, stuff->src, XRT_PIXMAP, DixReadAccess))) return BadPixmap; } else pmap = NULL; @@ -616,11 +616,11 @@ ProcPanoramiXShapeCombine( REQUEST_AT_LEAST_SIZE (xShapeCombineReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->dest, XRT_WINDOW, DixWriteAccess))) return BadWindow; if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->src, XRT_WINDOW, SecurityReadAccess))) + client, stuff->src, XRT_WINDOW, DixReadAccess))) return BadWindow; FOR_NSCREENS(j) { @@ -688,7 +688,7 @@ ProcPanoramiXShapeOffset( REQUEST_AT_LEAST_SIZE (xShapeOffsetReq); if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + client, stuff->dest, XRT_WINDOW, DixWriteAccess))) return BadWindow; FOR_NSCREENS(j) { @@ -822,11 +822,11 @@ ProcShapeSelectInput (client) XID clientResource; REQUEST_SIZE_MATCH (xShapeSelectInputReq); - pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess); + pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess); if (!pWin) return BadWindow; pHead = (ShapeEventPtr *)SecurityLookupIDByType(client, - pWin->drawable.id, EventType, SecurityWriteAccess); + pWin->drawable.id, EventType, DixWriteAccess); switch (stuff->enable) { case xTrue: if (pHead) { @@ -999,7 +999,7 @@ ProcShapeInputSelected (client) if (!pWin) return BadWindow; pHead = (ShapeEventPtr *) SecurityLookupIDByType(client, - pWin->drawable.id, EventType, SecurityReadAccess); + pWin->drawable.id, EventType, DixReadAccess); enabled = xFalse; if (pHead) { for (pShapeEvent = *pHead; diff --git a/Xext/shm.c b/Xext/shm.c index be79862cb..0c2299a61 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -571,11 +571,11 @@ ProcPanoramiXShmPutImage(register ClientPtr client) REQUEST_SIZE_MATCH(xShmPutImageReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -621,7 +621,7 @@ ProcPanoramiXShmGetImage(ClientPtr client) } if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if (draw->type == XRT_PIXMAP) diff --git a/Xext/sync.c b/Xext/sync.c index 7def85b94..1d899348b 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -436,7 +436,7 @@ SyncInitTrigger(client, pTrigger, counter, changes) if (counter == None) pCounter = NULL; else if (!(pCounter = (SyncCounter *)SecurityLookupIDByType( - client, counter, RTCounter, SecurityReadAccess))) + client, counter, RTCounter, DixReadAccess))) { client->errorValue = counter; return SyncErrorBase + XSyncBadCounter; @@ -1550,7 +1550,7 @@ ProcSyncSetCounter(client) REQUEST_SIZE_MATCH(xSyncSetCounterReq); pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->cid, - RTCounter, SecurityWriteAccess); + RTCounter, DixWriteAccess); if (pCounter == NULL) { client->errorValue = stuff->cid; @@ -1583,7 +1583,7 @@ ProcSyncChangeCounter(client) REQUEST_SIZE_MATCH(xSyncChangeCounterReq); pCounter = (SyncCounter *) SecurityLookupIDByType(client, stuff->cid, - RTCounter, SecurityWriteAccess); + RTCounter, DixWriteAccess); if (pCounter == NULL) { client->errorValue = stuff->cid; @@ -1621,7 +1621,7 @@ ProcSyncDestroyCounter(client) REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter, - RTCounter, SecurityDestroyAccess); + RTCounter, DixDestroyAccess); if (pCounter == NULL) { client->errorValue = stuff->counter; @@ -1767,7 +1767,7 @@ ProcSyncQueryCounter(client) REQUEST_SIZE_MATCH(xSyncQueryCounterReq); pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter, - RTCounter, SecurityReadAccess); + RTCounter, DixReadAccess); if (pCounter == NULL) { client->errorValue = stuff->counter; @@ -1896,7 +1896,7 @@ ProcSyncChangeAlarm(client) REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); if (!(pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, SecurityWriteAccess))) + RTAlarm, DixWriteAccess))) { client->errorValue = stuff->alarm; return SyncErrorBase + XSyncBadAlarm; @@ -1937,7 +1937,7 @@ ProcSyncQueryAlarm(client) REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, SecurityReadAccess); + RTAlarm, DixReadAccess); if (!pAlarm) { client->errorValue = stuff->alarm; @@ -1997,7 +1997,7 @@ ProcSyncDestroyAlarm(client) REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); if (!((SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, SecurityDestroyAccess))) + RTAlarm, DixDestroyAccess))) { client->errorValue = stuff->alarm; return SyncErrorBase + XSyncBadAlarm; diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index bd250569e..44647060a 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -445,11 +445,11 @@ ProcXF86BigfontQueryFont( #endif client->errorValue = stuff->id; /* EITHER font or gc */ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { /* can't use VERIFY_GC because it might return BadGC */ GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->id; return BadFont; /* procotol spec says only error is BadFont */ diff --git a/Xext/xprint.c b/Xext/xprint.c index 29d3262f9..669ad277d 100644 --- a/Xext/xprint.c +++ b/Xext/xprint.c @@ -749,7 +749,7 @@ ProcXpGetPageDimensions(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -811,7 +811,7 @@ ProcXpSetImageResolution(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityWriteAccess)) + DixWriteAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -859,7 +859,7 @@ ProcXpGetImageResolution(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -1068,7 +1068,7 @@ ProcXpSetContext(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityWriteAccess)) + DixWriteAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -1141,7 +1141,7 @@ ProcXpDestroyContext(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityDestroyAccess)) + DixDestroyAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -1167,7 +1167,7 @@ ProcXpGetContextScreen(ClientPtr client) if((pContext =(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) return XpErrorBase+XPBadContext; @@ -1853,7 +1853,7 @@ ProcXpStartPage(ClientPtr client) return XpErrorBase+XPBadSequence; pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum) return BadWindow; @@ -1994,7 +1994,7 @@ ProcXpGetDocumentData(ClientPtr client) if((pContext = (XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityWriteAccess)) + DixWriteAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -2077,7 +2077,7 @@ ProcXpGetAttributes(ClientPtr client) client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -2149,7 +2149,7 @@ ProcXpSetAttributes(ClientPtr client) client, stuff->printContext, RTcontext, - SecurityWriteAccess)) + DixWriteAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -2229,7 +2229,7 @@ ProcXpGetOneAttribute(ClientPtr client) client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -2300,7 +2300,7 @@ ProcXpSelectInput(ClientPtr client) if((pContext=(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityWriteAccess)) + DixWriteAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; @@ -2336,7 +2336,7 @@ ProcXpInputSelected(ClientPtr client) if((pContext=(XpContextPtr)SecurityLookupIDByType(client, stuff->printContext, RTcontext, - SecurityReadAccess)) + DixReadAccess)) == (XpContextPtr)NULL) { client->errorValue = stuff->printContext; diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 0c7a38199..ec2b4f8d7 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -1877,11 +1877,11 @@ XineramaXvStopVideo(ClientPtr client) REQUEST_SIZE_MATCH(xvStopVideoReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; FOR_NSCREENS_BACKWARD(i) { @@ -1905,7 +1905,7 @@ XineramaXvSetPortAttribute(ClientPtr client) REQUEST_SIZE_MATCH(xvSetPortAttributeReq); if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; FOR_NSCREENS_BACKWARD(i) { @@ -1931,15 +1931,15 @@ XineramaXvShmPutImage(ClientPtr client) REQUEST_SIZE_MATCH(xvShmPutImageReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1978,15 +1978,15 @@ XineramaXvPutImage(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutImageReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2023,15 +2023,15 @@ XineramaXvPutVideo(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutVideoReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2068,15 +2068,15 @@ XineramaXvPutStill(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutImageReq); if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) + client, stuff->gc, XRT_GC, DixReadAccess))) return BadGC; if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) + client, stuff->port, XvXRTPort, DixReadAccess))) return _XvBadPort; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; diff --git a/damageext/damageext.c b/damageext/damageext.c index 225f9ecf0..c8f28e953 100755 --- a/damageext/damageext.c +++ b/damageext/damageext.c @@ -179,7 +179,7 @@ ProcDamageCreate (ClientPtr client) REQUEST_SIZE_MATCH(xDamageCreateReq); LEGAL_NEW_RESOURCE(stuff->damage, client); SECURITY_VERIFY_DRAWABLE (pDrawable, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); switch (stuff->level) { case XDamageReportRawRectangles: level = DamageReportRawRegion; @@ -237,7 +237,7 @@ ProcDamageDestroy (ClientPtr client) DamageExtPtr pDamageExt; REQUEST_SIZE_MATCH(xDamageDestroyReq); - VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess); + VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess); FreeResource (stuff->damage, RT_NONE); return (client->noClientException); } @@ -251,9 +251,9 @@ ProcDamageSubtract (ClientPtr client) RegionPtr pParts; REQUEST_SIZE_MATCH(xDamageSubtractReq); - VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess); - VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, SecurityWriteAccess); - VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, SecurityWriteAccess); + VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess); + VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, DixWriteAccess); + VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, DixWriteAccess); if (pDamageExt->level != DamageReportRawRegion) { diff --git a/dbe/dbe.c b/dbe/dbe.c index 5b43dd1bd..649143cf2 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -406,7 +406,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client) /* The window must be valid. */ if (!(pWin = SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess))) + DixWriteAccess))) { return(BadWindow); } @@ -633,9 +633,9 @@ ProcDbeDeallocateBackBufferName(ClientPtr client) /* Buffer name must be valid */ if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client, - stuff->buffer, dbeWindowPrivResType, SecurityDestroyAccess)) || + stuff->buffer, dbeWindowPrivResType, DixDestroyAccess)) || !(SecurityLookupIDByType(client, stuff->buffer, dbeDrawableResType, - SecurityDestroyAccess))) + DixDestroyAccess))) { client->errorValue = stuff->buffer; return(dbeErrorBase + DbeBadBuffer); @@ -730,7 +730,7 @@ ProcDbeSwapBuffers(ClientPtr client) /* Each window must be a valid window - BadWindow. */ if (!(pWin = SecurityLookupWindow(dbeSwapInfo[i].window, client, - SecurityWriteAccess))) + DixWriteAccess))) { DEALLOCATE_LOCAL(swapInfo); return(BadWindow); @@ -890,7 +890,7 @@ ProcDbeGetVisualInfo(ClientPtr client) for (i = 0; i < stuff->n; i++) { if (!(pDrawables[i] = (DrawablePtr)SecurityLookupDrawable( - drawables[i], client, SecurityReadAccess))) + drawables[i], client, DixReadAccess))) { DEALLOCATE_LOCAL(pDrawables); return(BadDrawable); @@ -1047,7 +1047,7 @@ ProcDbeGetBackBufferAttributes(ClientPtr client) REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client, - stuff->buffer, dbeWindowPrivResType, SecurityReadAccess))) + stuff->buffer, dbeWindowPrivResType, DixReadAccess))) { rep.attributes = None; } diff --git a/dix/colormap.c b/dix/colormap.c index b8f2f4af6..a74cb390c 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -903,7 +903,7 @@ AllocColor (ColormapPtr pmap, { ColormapPtr prootmap = (ColormapPtr) SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pmap->class == prootmap->class) FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, @@ -920,7 +920,7 @@ AllocColor (ColormapPtr pmap, { ColormapPtr prootmap = (ColormapPtr) SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pmap->class == prootmap->class) { diff --git a/dix/cursor.c b/dix/cursor.c index b9ede1f76..7071d8345 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -262,9 +262,9 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, GlyphSharePtr pShare; sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT, - SecurityReadAccess); + DixReadAccess); maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!sourcefont) { diff --git a/dix/dispatch.c b/dix/dispatch.c index 0a761eb6c..a3de07fed 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -563,7 +563,7 @@ ProcCreateWindow(ClientPtr client) LEGAL_NEW_RESOURCE(stuff->wid, client); if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - SecurityWriteAccess))) + DixWriteAccess))) return BadWindow; len = client->req_len - (sizeof(xCreateWindowReq) >> 2); if (Ones(stuff->mask) != len) @@ -604,7 +604,7 @@ ProcChangeWindowAttributes(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); @@ -629,7 +629,7 @@ ProcGetWindowAttributes(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); GetWindowAttributes(pWin, client, &wa); @@ -645,7 +645,7 @@ ProcDestroyWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityDestroyAccess); + DixDestroyAccess); if (!pWin) return(BadWindow); if (pWin->parent) @@ -661,7 +661,7 @@ ProcDestroySubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityDestroyAccess); + DixDestroyAccess); if (!pWin) return(BadWindow); DestroySubwindows(pWin, client); @@ -677,7 +677,7 @@ ProcChangeSaveSet(register ClientPtr client) REQUEST_SIZE_MATCH(xChangeSaveSetReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) @@ -706,11 +706,11 @@ ProcReparentWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xReparentWindowReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - SecurityWriteAccess); + DixWriteAccess); if (!pParent) return(BadWindow); if (SAME_SCREENS(pWin->drawable, pParent->drawable)) @@ -740,7 +740,7 @@ ProcMapWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); MapWindow(pWin, client); @@ -756,7 +756,7 @@ ProcMapSubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); MapSubwindows(pWin, client); @@ -772,7 +772,7 @@ ProcUnmapWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); UnmapWindow(pWin, FALSE); @@ -788,7 +788,7 @@ ProcUnmapSubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); UnmapSubwindows(pWin); @@ -805,7 +805,7 @@ ProcConfigureWindow(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); @@ -833,7 +833,7 @@ ProcCirculateWindow(register ClientPtr client) return BadValue; } pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); CirculateWindow(pWin, (int)stuff->direction, client); @@ -847,7 +847,7 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep) REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess); + SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, DixReadAccess); rep->type = X_Reply; rep->length = 0; rep->sequenceNumber = client->sequence; @@ -906,7 +906,7 @@ ProcQueryTree(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); reply.type = X_Reply; @@ -1022,7 +1022,7 @@ ProcSetSelectionOwner(register ClientPtr client) if (stuff->window != None) { pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); } @@ -1141,7 +1141,7 @@ ProcConvertSelection(register ClientPtr client) REQUEST_SIZE_MATCH(xConvertSelectionReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -1159,7 +1159,7 @@ ProcConvertSelection(register ClientPtr client) (CurrentSelections[i].window != None) && XaceHook(XACE_RESOURCE_ACCESS, client, CurrentSelections[i].window, RT_WINDOW, - SecurityReadAccess, CurrentSelections[i].pWin)) + DixReadAccess, CurrentSelections[i].pWin)) { event.u.u.type = SelectionRequest; event.u.selectionRequest.time = stuff->time; @@ -1263,11 +1263,11 @@ ProcTranslateCoords(register ClientPtr client) REQUEST_SIZE_MATCH(xTranslateCoordsReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, - SecurityReadAccess); + DixReadAccess); if (!pDst) return(BadWindow); rep.type = X_Reply; @@ -1358,7 +1358,7 @@ ProcCloseFont(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityDestroyAccess); + DixDestroyAccess); if ( pFont != (FontPtr)NULL) /* id was valid */ { FreeResource(stuff->id, RT_NONE); @@ -1382,12 +1382,12 @@ ProcQueryFont(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { /* can't use VERIFY_GC because it might return BadGC */ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->id; @@ -1443,11 +1443,11 @@ ProcQueryTextExtents(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->fid; @@ -1526,7 +1526,7 @@ ProcCreatePixmap(register ClientPtr client) client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); if (!stuff->width || !stuff->height) { client->errorValue = 0; @@ -1581,7 +1581,7 @@ ProcFreePixmap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, - SecurityDestroyAccess); + DixDestroyAccess); if (pMap) { FreeResource(stuff->id, RT_NONE); @@ -1607,7 +1607,7 @@ ProcCreateGC(register ClientPtr client) client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1629,7 +1629,7 @@ ProcChangeGC(register ClientPtr client) unsigned len; REQUEST_AT_LEAST_SIZE(xChangeGCReq); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); len = client->req_len - (sizeof(xChangeGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1653,8 +1653,8 @@ ProcCopyGC(register ClientPtr client) REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); - SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess); - SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess); + SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, DixReadAccess); + SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, DixWriteAccess); if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); @@ -1681,7 +1681,7 @@ ProcSetDashes(register ClientPtr client) return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, (unsigned char *)&stuff[1]); @@ -1709,7 +1709,7 @@ ProcSetClipRectangles(register ClientPtr client) client->errorValue = stuff->ordering; return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) @@ -1730,7 +1730,7 @@ ProcFreeGC(register ClientPtr client) REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess); + SECURITY_VERIFY_GC(pGC, stuff->id, client, DixDestroyAccess); FreeResource(stuff->id, RT_NONE); return(client->noClientException); } @@ -1743,7 +1743,7 @@ ProcClearToBackground(register ClientPtr client) REQUEST_SIZE_MATCH(xClearAreaReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (pWin->drawable.class == InputOnly) @@ -1777,7 +1777,7 @@ ProcCopyArea(register ClientPtr client) if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; @@ -1817,7 +1817,7 @@ ProcCopyPlane(register ClientPtr client) if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; @@ -2156,7 +2156,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, client->errorValue = format; return(BadValue); } - SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess); + SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, DixReadAccess); if(pDraw->type == DRAWABLE_WINDOW) { if( /* check for being viewable */ @@ -2478,7 +2478,7 @@ ProcCreateColormap(register ClientPtr client) mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -2508,7 +2508,7 @@ ProcFreeColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, - SecurityDestroyAccess); + DixDestroyAccess); if (pmap) { /* Freeing a default colormap is a no-op */ @@ -2536,7 +2536,7 @@ ProcCopyColormapAndFree(register ClientPtr client) mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap, - RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) ) + RT_COLORMAP, DixReadAccess|DixWriteAccess)) ) { result = CopyColormapAndFree(mid, pSrcMap, client->index); if (client->noClientException != Success) @@ -2559,7 +2559,7 @@ ProcInstallColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { (*(pcmp->pScreen->InstallColormap)) (pcmp); @@ -2580,7 +2580,7 @@ ProcUninstallColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { if(pcmp->mid != pcmp->pScreen->defColormap) @@ -2604,7 +2604,7 @@ ProcListInstalledColormaps(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -2639,7 +2639,7 @@ ProcAllocColor (register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorReq); pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pmap) { acr.type = X_Reply; @@ -2679,7 +2679,7 @@ ProcAllocNamedColor (register ClientPtr client) REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int retval; @@ -2731,7 +2731,7 @@ ProcAllocColorCells (register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorCellsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xAllocColorCellsReply accr; @@ -2797,7 +2797,7 @@ ProcAllocColorPlanes(register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorPlanesReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xAllocColorPlanesReply acpr; @@ -2861,7 +2861,7 @@ ProcFreeColors(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xFreeColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int count; @@ -2896,7 +2896,7 @@ ProcStoreColors (ClientPtr client) REQUEST_AT_LEAST_SIZE(xStoreColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int count; @@ -2930,7 +2930,7 @@ ProcStoreNamedColor (register ClientPtr client) REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xColorItem def; @@ -2964,7 +2964,7 @@ ProcQueryColors(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xQueryColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { int count, retval; @@ -3015,7 +3015,7 @@ ProcLookupColor(register ClientPtr client) REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { xLookupColorReply lcr; @@ -3065,9 +3065,9 @@ ProcCreateCursor (register ClientPtr client) LEGAL_NEW_RESOURCE(stuff->cid, client); src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if ( src == (PixmapPtr)NULL) { client->errorValue = stuff->source; @@ -3167,7 +3167,7 @@ ProcFreeCursor (register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id, - RT_CURSOR, SecurityDestroyAccess); + RT_CURSOR, DixDestroyAccess); if (pCursor) { FreeResource(stuff->id, RT_NONE); @@ -3197,7 +3197,7 @@ ProcQueryBestSize (register ClientPtr client) return(BadValue); } SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return (BadMatch); pScreen = pDraw->pScreen; @@ -3321,7 +3321,7 @@ ProcListHosts(register ClientPtr client) REQUEST_SIZE_MATCH(xListHostsReq); /* untrusted clients can't list hosts */ - if (!XaceHook(XACE_HOSTLIST_ACCESS, client, SecurityReadAccess)) + if (!XaceHook(XACE_HOSTLIST_ACCESS, client, DixReadAccess)) return BadAccess; result = GetHosts(&pdata, &nHosts, &len, &reply.enabled); diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 7e2ed5058..d5b42dcf6 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1178,7 +1178,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (c->slept && c->pDraw && c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) + RC_DRAWABLE, DixWriteAccess)) { /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client and avoid further @@ -1208,7 +1208,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) | ((Font)*(c->pElt+2)) << 16 | ((Font)*(c->pElt+1)) << 24; pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { client->errorValue = fid; @@ -1463,7 +1463,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (c->slept && c->pDraw && c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) + RC_DRAWABLE, DixWriteAccess)) { /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ @@ -2016,7 +2016,7 @@ FontPtr find_old_font(XID id) { return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, - SecurityUnknownAccess); + DixUnknownAccess); } Font diff --git a/dix/dixutils.c b/dix/dixutils.c index af7e1c8f1..fca55d99f 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -236,13 +236,13 @@ SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) _X_EXPORT WindowPtr LookupWindow(XID rid, ClientPtr client) { - return SecurityLookupWindow(rid, client, SecurityUnknownAccess); + return SecurityLookupWindow(rid, client, DixUnknownAccess); } _X_EXPORT pointer LookupDrawable(XID rid, ClientPtr client) { - return SecurityLookupDrawable(rid, client, SecurityUnknownAccess); + return SecurityLookupDrawable(rid, client, DixUnknownAccess); } #else /* not XACE */ @@ -293,7 +293,7 @@ _X_EXPORT ClientPtr LookupClient(XID rid, ClientPtr client) { pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY, - SecurityReadAccess); + DixReadAccess); int clientIndex = CLIENT_ID(rid); if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) diff --git a/dix/events.c b/dix/events.c index 0a39dcd9e..c7cf73e46 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2235,7 +2235,7 @@ XineramaWarpPointer(ClientPtr client) if (stuff->dstWid != None) { - dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); + dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); if (!dest) return BadWindow; } @@ -2248,7 +2248,7 @@ XineramaWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, SecurityReadAccess); + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; winX = source->drawable.x; @@ -2315,7 +2315,7 @@ ProcWarpPointer(ClientPtr client) if (stuff->dstWid != None) { - dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); + dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); if (!dest) return BadWindow; } @@ -2328,7 +2328,7 @@ ProcWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, SecurityReadAccess); + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; winX = source->drawable.x; @@ -3551,7 +3551,7 @@ SetInputFocus( else if ((focusID == FollowKeyboard) && followOK) focusWin = inputInfo.keyboard->focus->win; else if (!(focusWin = SecurityLookupWindow(focusID, client, - SecurityReadAccess))) + DixReadAccess))) return BadWindow; else { @@ -3671,7 +3671,7 @@ ProcGrabPointer(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; if (stuff->confineTo == None) @@ -3679,7 +3679,7 @@ ProcGrabPointer(ClientPtr client) else { confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); + DixReadAccess); if (!confineTo) return BadWindow; } @@ -3688,7 +3688,7 @@ ProcGrabPointer(ClientPtr client) else { cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!cursor) { client->errorValue = stuff->cursor; @@ -3762,7 +3762,7 @@ ProcChangeActivePointerGrab(ClientPtr client) else { newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!newCursor) { client->errorValue = stuff->cursor; @@ -3832,7 +3832,7 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev, client->errorValue = ownerEvents; return BadValue; } - pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; time = ClientTimeToServerTime(ctime); @@ -3920,7 +3920,7 @@ ProcQueryPointer(ClientPtr client) DeviceIntPtr mouse = inputInfo.pointer; REQUEST_SIZE_MATCH(xResourceReq); - pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->id, client, DixReadAccess); if (!pWin) return BadWindow; if (mouse->valuator->motionHintWindow) @@ -4087,7 +4087,7 @@ ProcSendEvent(ClientPtr client) } else pWin = SecurityLookupWindow(stuff->destination, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) @@ -4125,7 +4125,7 @@ ProcUngrabKey(ClientPtr client) DeviceIntPtr keybd = inputInfo.keyboard; REQUEST_SIZE_MATCH(xUngrabKeyReq); - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; @@ -4196,7 +4196,7 @@ ProcGrabKey(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; @@ -4248,14 +4248,14 @@ ProcGrabButton(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; if (stuff->confineTo == None) confineTo = NullWindow; else { confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); + DixReadAccess); if (!confineTo) return BadWindow; } @@ -4264,7 +4264,7 @@ ProcGrabButton(ClientPtr client) else { cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!cursor) { client->errorValue = stuff->cursor; @@ -4297,7 +4297,7 @@ ProcUngrabButton(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; tempGrab.resource = client->clientAsMask; @@ -4451,7 +4451,7 @@ ProcRecolorCursor(ClientPtr client) REQUEST_SIZE_MATCH(xRecolorCursorReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityWriteAccess); + RT_CURSOR, DixWriteAccess); if ( !pCursor) { client->errorValue = stuff->cursor; diff --git a/dix/gc.c b/dix/gc.c index ed6bf26db..5106fcda2 100644 --- a/dix/gc.c +++ b/dix/gc.c @@ -271,7 +271,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newpix); pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - newpix, RT_PIXMAP, SecurityReadAccess); + newpix, RT_PIXMAP, DixReadAccess); } if (pPixmap) { @@ -307,7 +307,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newstipple) pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - newstipple, RT_PIXMAP, SecurityReadAccess); + newstipple, RT_PIXMAP, DixReadAccess); } if (pPixmap) { @@ -349,7 +349,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newfont) pFont = (FontPtr)SecurityLookupIDByType(client, newfont, - RT_FONT, SecurityReadAccess); + RT_FONT, DixReadAccess); } if (pFont) { @@ -416,7 +416,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC } else pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - pid, RT_PIXMAP, SecurityReadAccess); + pid, RT_PIXMAP, DixReadAccess); } if (pPixmap) diff --git a/dix/property.c b/dix/property.c index 00d485655..5c1e957a5 100644 --- a/dix/property.c +++ b/dix/property.c @@ -105,7 +105,7 @@ ProcRotateProperties(ClientPtr client) REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2); UpdateCurrentTime(); pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!stuff->nAtoms) @@ -117,7 +117,7 @@ ProcRotateProperties(ClientPtr client) for (i = 0; i < stuff->nAtoms; i++) { char action = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, atoms[i], - SecurityReadAccess|SecurityWriteAccess); + DixReadAccess|DixWriteAccess); if (!ValidAtom(atoms[i]) || (XaceErrorOperation == action)) { DEALLOCATE_LOCAL(props); @@ -209,7 +209,7 @@ ProcChangeProperty(ClientPtr client) REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!ValidAtom(stuff->property)) @@ -224,7 +224,7 @@ ProcChangeProperty(ClientPtr client) } switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, - SecurityWriteAccess)) + DixWriteAccess)) { case XaceErrorOperation: client->errorValue = stuff->property; @@ -448,14 +448,14 @@ ProcGetProperty(ClientPtr client) unsigned long n, len, ind; WindowPtr pWin; xGetPropertyReply reply; - Mask access_mode = SecurityReadAccess; + Mask access_mode = DixReadAccess; REQUEST(xGetPropertyReq); REQUEST_SIZE_MATCH(xGetPropertyReq); if (stuff->delete) UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -491,7 +491,7 @@ ProcGetProperty(ClientPtr client) return NullPropertyReply(client, None, 0, &reply); if (stuff->delete) - access_mode |= SecurityDestroyAccess; + access_mode |= DixDestroyAccess; switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, access_mode)) { @@ -592,7 +592,7 @@ ProcListProperties(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -637,7 +637,7 @@ ProcDeleteProperty(register ClientPtr client) REQUEST_SIZE_MATCH(xDeletePropertyReq); UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!ValidAtom(stuff->property)) @@ -647,7 +647,7 @@ ProcDeleteProperty(register ClientPtr client) } switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, - SecurityDestroyAccess)) + DixDestroyAccess)) { case XaceErrorOperation: client->errorValue = stuff->property; diff --git a/dix/resource.c b/dix/resource.c index c2044601f..4468f4575 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -944,12 +944,12 @@ _X_EXPORT pointer LookupIDByType(XID id, RESTYPE rtype) { return SecurityLookupIDByType(NullClient, id, rtype, - SecurityUnknownAccess); + DixUnknownAccess); } _X_EXPORT pointer LookupIDByClass(XID id, RESTYPE classes) { return SecurityLookupIDByClass(NullClient, id, classes, - SecurityUnknownAccess); + DixUnknownAccess); } diff --git a/dix/window.c b/dix/window.c index fa6906f2a..e33140dd4 100644 --- a/dix/window.c +++ b/dix/window.c @@ -1062,7 +1062,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if (pPixmap != (PixmapPtr) NULL) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || @@ -1123,7 +1123,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if (pPixmap) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || @@ -1333,7 +1333,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt goto PatchUp; } pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (!pCmap) { error = BadColor; @@ -1409,7 +1409,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!pCursor) { error = BadCursor; @@ -2299,7 +2299,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP sibwid = (Window ) *pVlist; pVlist++; pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid, - RT_WINDOW, SecurityReadAccess); + RT_WINDOW, DixReadAccess); if (!pSib) { client->errorValue = sibwid; diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c index 6db036f1b..a9d8b5659 100644 --- a/hw/darwin/quartz/applewm.c +++ b/hw/darwin/quartz/applewm.c @@ -268,7 +268,7 @@ ProcAppleWMSelectInput (client) REQUEST_SIZE_MATCH (xAppleWMSelectInputReq); pHead = (WMEventPtr *)SecurityLookupIDByType(client, - eventResource, EventType, SecurityWriteAccess); + eventResource, EventType, DixWriteAccess); if (stuff->mask != 0) { if (pHead) { /* check for existing entry. */ @@ -491,7 +491,7 @@ ProcAppleWMSetWindowLevel( REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq); if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, SecurityReadAccess))) + client, DixReadAccess))) { return BadValue; } @@ -603,7 +603,7 @@ ProcAppleWMFrameDraw( REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq); if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, SecurityReadAccess))) + client, DixReadAccess))) { return BadValue; } diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c index 6d9bae10f..585d7e1be 100644 --- a/hw/darwin/quartz/xpr/appledri.c +++ b/hw/darwin/quartz/xpr/appledri.c @@ -223,7 +223,7 @@ ProcAppleDRICreateSurface( if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( (Drawable)stuff->drawable, client, - SecurityReadAccess))) { + DixReadAccess))) { return BadValue; } @@ -256,7 +256,7 @@ ProcAppleDRIDestroySurface( if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( (Drawable)stuff->drawable, client, - SecurityReadAccess))) { + DixReadAccess))) { return BadValue; } diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c index 75623e696..02e8b1e7c 100644 --- a/hw/dmx/dmx.c +++ b/hw/dmx/dmx.c @@ -282,12 +282,12 @@ static int ProcDMXForceWindowCreation(ClientPtr client) int i; if (!(win = SecurityLookupIDByType(client, stuff->window, XRT_WINDOW, - SecurityReadAccess))) + DixReadAccess))) return -1; /* BadWindow */ FOR_NSCREENS(i) { if (!(pWin = SecurityLookupWindow(win->info[i].id, client, - SecurityReadAccess))) + DixReadAccess))) return -1; /* BadWindow */ dmxForceWindowCreation(pWin); @@ -297,7 +297,7 @@ static int ProcDMXForceWindowCreation(ClientPtr client) #endif if (!(pWin = SecurityLookupWindow(stuff->window, client, - SecurityReadAccess))) + DixReadAccess))) return -1; /* BadWindow */ dmxForceWindowCreation(pWin); @@ -556,12 +556,12 @@ static int dmxPopulatePanoramiX(ClientPtr client, Window window, DMXWindowAttributesRec attr; if (!(win = SecurityLookupIDByType(client, window, XRT_WINDOW, - SecurityReadAccess))) + DixReadAccess))) return -1; /* BadWindow */ FOR_NSCREENS(i) { if (!(pWin = SecurityLookupWindow(win->info[i].id, client, - SecurityReadAccess))) + DixReadAccess))) return -1; /* BadWindow */ if (dmxGetWindowAttributes(pWin, &attr)) { screens[count] = attr.screen; @@ -587,7 +587,7 @@ static int dmxPopulate(ClientPtr client, Window window, CARD32 *screens, pos, vis); #endif - if (!(pWin = SecurityLookupWindow(window, client, SecurityReadAccess))) + if (!(pWin = SecurityLookupWindow(window, client, DixReadAccess))) return -1; /* BadWindow */ dmxGetWindowAttributes(pWin, &attr); diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c index 9cdd123b9..339692538 100644 --- a/hw/dmx/dmxpict.c +++ b/hw/dmx/dmxpict.c @@ -247,7 +247,7 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client) /* Make sure we handle all errors here!! */ glyphSet = SecurityLookupIDByType(client, stuff->gsid, GlyphSetType, - SecurityDestroyAccess); + DixDestroyAccess); glyphPriv = xalloc(sizeof(dmxGlyphPrivRec)); if (!glyphPriv) return BadAlloc; glyphPriv->glyphSets = NULL; @@ -255,7 +255,7 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client) DMX_SET_GLYPH_PRIV(glyphSet, glyphPriv); pFmt = SecurityLookupIDByType(client, stuff->format, PictFormatType, - SecurityReadAccess); + DixReadAccess); oldErrorHandler = XSetErrorHandler(dmxGlyphErrorHandler); @@ -315,7 +315,7 @@ static int dmxProcRenderFreeGlyphSet(ClientPtr client) REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType, - SecurityDestroyAccess); + DixDestroyAccess); if (glyphSet && glyphSet->refcnt == 1) { dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); @@ -358,7 +358,7 @@ static int dmxProcRenderAddGlyphs(ClientPtr client) int nbytes; glyphSet = SecurityLookupIDByType(client, stuff->glyphset, - GlyphSetType, SecurityReadAccess); + GlyphSetType, DixReadAccess); glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); nglyphs = stuff->nglyphs; @@ -401,7 +401,7 @@ static int dmxProcRenderFreeGlyphs(ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType, - SecurityWriteAccess); + DixWriteAccess); if (glyphSet) { dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); @@ -473,13 +473,13 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client) dmxGlyphPrivPtr glyphPriv; pSrc = SecurityLookupIDByType(client, stuff->src, PictureType, - SecurityReadAccess); + DixReadAccess); pSrcPriv = DMX_GET_PICT_PRIV(pSrc); if (!pSrcPriv->pict) return ret; pDst = SecurityLookupIDByType(client, stuff->dst, PictureType, - SecurityWriteAccess); + DixWriteAccess); pDstPriv = DMX_GET_PICT_PRIV(pDst); if (!pDstPriv->pict) return ret; @@ -496,7 +496,7 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client) if (stuff->maskFormat) pFmt = SecurityLookupIDByType(client, stuff->maskFormat, - PictFormatType, SecurityReadAccess); + PictFormatType, DixReadAccess); else pFmt = NULL; @@ -547,7 +547,7 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client) curElt = elts; glyphSet = SecurityLookupIDByType(client, stuff->glyphset, - GlyphSetType, SecurityReadAccess); + GlyphSetType, DixReadAccess); glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); while (buffer + sizeof(xGlyphElt) < end) { @@ -558,7 +558,7 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client) glyphSet = SecurityLookupIDByType(client, *((CARD32 *)buffer), GlyphSetType, - SecurityReadAccess); + DixReadAccess); glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); buffer += 4; } else { @@ -622,7 +622,7 @@ static int dmxProcRenderSetPictureTransform(ClientPtr client) REQUEST(xRenderSetPictureTransformReq); REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); /* For the following to work with PanoramiX, it assumes that Render @@ -663,7 +663,7 @@ static int dmxProcRenderSetPictureFilter(ClientPtr client) REQUEST(xRenderSetPictureFilterReq); REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); - VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); /* For the following to work with PanoramiX, it assumes that Render diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c index 78cb34eec..20a02a173 100644 --- a/hw/dmx/glxProxy/glxcmds.c +++ b/hw/dmx/glxProxy/glxcmds.c @@ -1105,13 +1105,13 @@ static int MakeCurrent(__GLXclientState *cl, if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) { pXinDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess); } if (pReadDraw && pReadDraw != pDraw && new_reply.readType != GLX_PBUFFER_TYPE) { pXinReadDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pReadDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pReadDraw->id, XRC_DRAWABLE, DixReadAccess); } else { pXinReadDraw = pXinDraw; @@ -1139,7 +1139,7 @@ static int MakeCurrent(__GLXclientState *cl, else if (pXinDraw) { pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id, client, - SecurityReadAccess); + DixReadAccess); } #endif else if (pGlxWindow) { @@ -1197,7 +1197,7 @@ static int MakeCurrent(__GLXclientState *cl, else if (pXinReadDraw) { pReadWin = (WindowPtr)SecurityLookupWindow(pXinReadDraw->info[s].id, client, - SecurityReadAccess); + DixReadAccess); } #endif else if (pGlxReadWindow) { @@ -1768,7 +1768,7 @@ static int CreateGLXPixmap(__GLXclientState *cl, to_screen = screenInfo.numScreens - 1; pXinDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess); } #endif @@ -2014,7 +2014,7 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag) from_screen = 0; to_screen = screenInfo.numScreens - 1; pXinDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess); } #endif @@ -2060,7 +2060,7 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag) else if (pXinDraw) { pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id, client, - SecurityReadAccess); + DixReadAccess); } #endif else if (pGlxWindow) { @@ -3069,7 +3069,7 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) int nReplyBytes; req = (xGLXQueryContextInfoEXTReq *)pc; - ctx = (__GLXcontext *) SecurityLookupIDByType(client, req->context, __glXContextRes, SecurityReadAccess); + ctx = (__GLXcontext *) SecurityLookupIDByType(client, req->context, __glXContextRes, DixReadAccess); if (!ctx) { client->errorValue = req->context; return __glXBadContext; @@ -3353,7 +3353,7 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) #ifdef PANORAMIX if (!noPanoramiXExtension) { pXinDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess); if (!pXinDraw) { client->errorValue = drawId; return __glXBadDrawable; @@ -3361,7 +3361,7 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id, client, - SecurityReadAccess); + DixReadAccess); } #endif @@ -3515,7 +3515,7 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) #ifdef PANORAMIX if (!noPanoramiXExtension) { pXinDraw = (PanoramiXRes *) - SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess); + SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess); if (!pXinDraw) { client->errorValue = drawId; return __glXBadDrawable; @@ -3523,7 +3523,7 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id, client, - SecurityReadAccess); + DixReadAccess); } #endif diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index d14b3d800..03e6725ff 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -401,7 +401,7 @@ ProcXF86DRICreateDrawable( if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( (Drawable)stuff->drawable, client, - SecurityReadAccess))) { + DixReadAccess))) { return BadValue; } @@ -432,7 +432,7 @@ ProcXF86DRIDestroyDrawable( if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( (Drawable)stuff->drawable, client, - SecurityReadAccess))) { + DixReadAccess))) { return BadValue; } @@ -471,7 +471,7 @@ ProcXF86DRIGetDrawableInfo( if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( (Drawable)stuff->drawable, client, - SecurityReadAccess))) { + DixReadAccess))) { return BadValue; } diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index 8801f6c42..e9bcea9a8 100755 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -345,7 +345,7 @@ winProcSetSelectionOwner (ClientPtr client) { /* Grab the Window from the request */ pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWindow) { ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n"); diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index 81a161041..ac92e26df 100755 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -203,7 +203,7 @@ ProcWindowsWMSelectInput (register ClientPtr client) REQUEST_SIZE_MATCH (xWindowsWMSelectInputReq); pHead = (WMEventPtr *)SecurityLookupIDByType(client, eventResource, - EventType, SecurityWriteAccess); + EventType, DixWriteAccess); if (stuff->mask != 0) { if (pHead) @@ -451,7 +451,7 @@ ProcWindowsWMFrameDraw (register ClientPtr client) ErrorF ("ProcWindowsWMFrameDraw\n"); #endif if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, SecurityReadAccess))) + client, DixReadAccess))) { return BadValue; } @@ -546,7 +546,7 @@ ProcWindowsWMFrameSetTitle( REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq); if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, SecurityReadAccess))) + client, DixReadAccess))) { return BadValue; } diff --git a/include/dix.h b/include/dix.h index a5a570a51..2c87a48c3 100644 --- a/include/dix.h +++ b/include/dix.h @@ -122,13 +122,13 @@ SOFTWARE. } #define VERIFY_DRAWABLE(pDraw, did, client)\ - SECURITY_VERIFY_DRAWABLE(pDraw, did, client, SecurityUnknownAccess) + SECURITY_VERIFY_DRAWABLE(pDraw, did, client, DixUnknownAccess) #define VERIFY_GEOMETRABLE(pDraw, did, client)\ - SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, SecurityUnknownAccess) + SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, DixUnknownAccess) #define VERIFY_GC(pGC, rid, client)\ - SECURITY_VERIFY_GC(pGC, rid, client, SecurityUnknownAccess) + SECURITY_VERIFY_GC(pGC, rid, client, DixUnknownAccess) #else /* not XACE */ @@ -239,8 +239,8 @@ SOFTWARE. if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\ (client->lastDrawableID != drawID))\ {\ - SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, SecurityWriteAccess);\ - SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);\ + SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, DixWriteAccess);\ + SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixReadAccess);\ if ((pGC->depth != pDraw->depth) ||\ (pGC->pScreen != pDraw->pScreen))\ return (BadMatch);\ diff --git a/include/resource.h b/include/resource.h index fd0caaeb5..3231e8cd9 100644 --- a/include/resource.h +++ b/include/resource.h @@ -220,10 +220,11 @@ extern pointer LookupClientResourceComplex( * simultaneously. */ -#define SecurityUnknownAccess 0 /* don't know intentions */ -#define SecurityReadAccess (1<<0) /* inspecting the object */ -#define SecurityWriteAccess (1<<1) /* changing the object */ -#define SecurityDestroyAccess (1<<2) /* destroying the object */ +#define DixUnknownAccess 0 /* don't know intentions */ +#define DixReadAccess (1<<0) /* inspecting the object */ +#define DixWriteAccess (1<<1) /* changing the object */ +#define DixReadWriteAccess (DixReadAccess|DixWriteAccess) +#define DixDestroyAccess (1<<2) /* destroying the object */ extern pointer SecurityLookupIDByType( ClientPtr /*client*/, diff --git a/os/access.c b/os/access.c index d61edeffc..db5ca3135 100644 --- a/os/access.c +++ b/os/access.c @@ -1528,7 +1528,7 @@ AuthorizedClient(ClientPtr client) return TRUE; /* untrusted clients can't change host access */ - if (!XaceHook(XACE_HOSTLIST_ACCESS, client, SecurityWriteAccess)) + if (!XaceHook(XACE_HOSTLIST_ACCESS, client, DixWriteAccess)) return FALSE; return LocalClient(client); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index e8a7b79e1..d4c96f680 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -457,7 +457,7 @@ ProcRRGetCrtcInfo (ClientPtr client) int i, j, k, n; REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); - crtc = LookupCrtc(client, stuff->crtc, SecurityReadAccess); + crtc = LookupCrtc(client, stuff->crtc, DixReadAccess); if (!crtc) return RRErrorBase + BadRRCrtc; @@ -766,7 +766,7 @@ ProcRRGetCrtcGammaSize (ClientPtr client) int n; REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); - crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess); + crtc = LookupCrtc (client, stuff->crtc, DixReadAccess); if (!crtc) return RRErrorBase + BadRRCrtc; @@ -793,7 +793,7 @@ ProcRRGetCrtcGamma (ClientPtr client) unsigned long len; REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); - crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess); + crtc = LookupCrtc (client, stuff->crtc, DixReadAccess); if (!crtc) return RRErrorBase + BadRRCrtc; @@ -826,7 +826,7 @@ ProcRRSetCrtcGamma (ClientPtr client) CARD16 *red, *green, *blue; REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); - crtc = LookupCrtc (client, stuff->crtc, SecurityWriteAccess); + crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess); if (!crtc) return RRErrorBase + BadRRCrtc; diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 6b61b9cd7..b1ec68b83 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -72,12 +72,12 @@ ProcRRSelectInput (ClientPtr client) XID clientResource; REQUEST_SIZE_MATCH(xRRSelectInputReq); - pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess); + pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess); if (!pWin) return BadWindow; pHead = (RREventPtr *)SecurityLookupIDByType(client, pWin->drawable.id, RREventType, - SecurityWriteAccess); + DixWriteAccess); if (stuff->enable & (RRScreenChangeNotifyMask| RRCrtcChangeNotifyMask| diff --git a/randr/rroutput.c b/randr/rroutput.c index 430f8bdaa..33c4ba534 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -378,7 +378,7 @@ ProcRRGetOutputInfo (ClientPtr client) int i, n; REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - output = LookupOutput(client, stuff->output, SecurityReadAccess); + output = LookupOutput(client, stuff->output, DixReadAccess); if (!output) return RRErrorBase + BadRROutput; diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 13e848340..56bb39a85 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -313,7 +313,7 @@ ProcRRListOutputProperties (ClientPtr client) REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); - output = LookupOutput (client, stuff->output, SecurityReadAccess); + output = LookupOutput (client, stuff->output, DixReadAccess); if (!output) return RRErrorBase + BadRROutput; @@ -358,7 +358,7 @@ ProcRRQueryOutputProperty (ClientPtr client) REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); - output = LookupOutput (client, stuff->output, SecurityReadAccess); + output = LookupOutput (client, stuff->output, DixReadAccess); if (!output) return RRErrorBase + BadRROutput; @@ -398,7 +398,7 @@ ProcRRConfigureOutputProperty (ClientPtr client) REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); - output = LookupOutput (client, stuff->output, SecurityReadAccess); + output = LookupOutput (client, stuff->output, DixReadAccess); if (!output) return RRErrorBase + BadRROutput; @@ -443,7 +443,7 @@ ProcRRChangeOutputProperty (ClientPtr client) totalSize = len * sizeInBytes; REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize); - output = LookupOutput (client, stuff->output, SecurityWriteAccess); + output = LookupOutput (client, stuff->output, DixWriteAccess); if (!output) return RRErrorBase + BadRROutput; @@ -475,7 +475,7 @@ ProcRRDeleteOutputProperty (ClientPtr client) REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); UpdateCurrentTime(); - output = LookupOutput (client, stuff->output, SecurityWriteAccess); + output = LookupOutput (client, stuff->output, DixWriteAccess); if (!output) return RRErrorBase + BadRROutput; @@ -504,8 +504,8 @@ ProcRRGetOutputProperty (ClientPtr client) if (stuff->delete) UpdateCurrentTime(); output = LookupOutput (client, stuff->output, - stuff->delete ? SecurityWriteAccess : - SecurityReadAccess); + stuff->delete ? DixWriteAccess : + DixReadAccess); if (!output) return RRErrorBase + BadRROutput; diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 76c16b010..b4004a31f 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -220,7 +220,7 @@ ProcRRGetScreenSizeRange (ClientPtr client) REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -273,7 +273,7 @@ ProcRRSetScreenSize (ClientPtr client) REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -332,7 +332,7 @@ ProcRRGetScreenResources (ClientPtr client) REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -557,7 +557,7 @@ ProcRRGetScreenInfo (ClientPtr client) REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -731,7 +731,7 @@ ProcRRSetScreenConfig (ClientPtr client) } SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, - SecurityWriteAccess); + DixWriteAccess); pScreen = pDraw->pScreen; diff --git a/render/picture.c b/render/picture.c index a3443c20e..e7901e873 100644 --- a/render/picture.c +++ b/render/picture.c @@ -1209,7 +1209,7 @@ ChangePicture (PicturePtr pPicture, pAlpha = (PicturePtr) SecurityLookupIDByType(client, pid, PictureType, - SecurityWriteAccess|SecurityReadAccess); + DixWriteAccess|DixReadAccess); if (!pAlpha) { client->errorValue = pid; @@ -1271,7 +1271,7 @@ ChangePicture (PicturePtr pPicture, pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pid, RT_PIXMAP, - SecurityReadAccess); + DixReadAccess); if (!pPixmap) { client->errorValue = pid; diff --git a/render/render.c b/render/render.c index e4d8d6b32..51a3fa69a 100644 --- a/render/render.c +++ b/render/render.c @@ -554,7 +554,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->format, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { @@ -622,11 +622,11 @@ ProcRenderCreatePicture (ClientPtr client) LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, - SecurityWriteAccess); + DixWriteAccess); pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->format, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->format; @@ -660,7 +660,7 @@ ProcRenderChangePicture (ClientPtr client) int len; REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2); @@ -680,7 +680,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) int result; REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pPicture->pDrawable) return BadDrawable; @@ -706,7 +706,7 @@ ProcRenderFreePicture (ClientPtr client) REQUEST_SIZE_MATCH(xRenderFreePictureReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixDestroyAccess, RenderErrBase + BadPicture); FreeResource (stuff->picture, RT_NONE); return(client->noClientException); @@ -736,13 +736,13 @@ ProcRenderComposite (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess, + VERIFY_ALPHA (pMask, stuff->mask, client, DixReadAccess, RenderErrBase + BadPicture); if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || (pMask && pMask->pDrawable && pDst->pDrawable->pScreen != pMask->pDrawable->pScreen)) @@ -782,9 +782,9 @@ ProcRenderTrapezoids (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -795,7 +795,7 @@ ProcRenderTrapezoids (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->maskFormat, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->maskFormat; @@ -829,9 +829,9 @@ ProcRenderTriangles (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -842,7 +842,7 @@ ProcRenderTriangles (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->maskFormat, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->maskFormat; @@ -876,9 +876,9 @@ ProcRenderTriStrip (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -889,7 +889,7 @@ ProcRenderTriStrip (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->maskFormat, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->maskFormat; @@ -923,9 +923,9 @@ ProcRenderTriFan (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -936,7 +936,7 @@ ProcRenderTriFan (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->maskFormat, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->maskFormat; @@ -988,7 +988,7 @@ ProcRenderCreateGlyphSet (ClientPtr client) format = (PictFormatPtr) SecurityLookupIDByType (client, stuff->format, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!format) { client->errorValue = stuff->format; @@ -1036,7 +1036,7 @@ ProcRenderReferenceGlyphSet (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->existing, GlyphSetType, - SecurityWriteAccess); + DixWriteAccess); if (!glyphSet) { client->errorValue = stuff->existing; @@ -1061,7 +1061,7 @@ ProcRenderFreeGlyphSet (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, - SecurityDestroyAccess); + DixDestroyAccess); if (!glyphSet) { client->errorValue = stuff->glyphset; @@ -1095,7 +1095,7 @@ ProcRenderAddGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, - SecurityWriteAccess); + DixWriteAccess); if (!glyphSet) { client->errorValue = stuff->glyphset; @@ -1196,7 +1196,7 @@ ProcRenderFreeGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, - SecurityWriteAccess); + DixWriteAccess); if (!glyphSet) { client->errorValue = stuff->glyphset; @@ -1251,9 +1251,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -1264,7 +1264,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->maskFormat, PictFormatType, - SecurityReadAccess); + DixReadAccess); if (!pFormat) { client->errorValue = stuff->maskFormat; @@ -1277,7 +1277,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, - SecurityReadAccess); + DixReadAccess); if (!glyphSet) { client->errorValue = stuff->glyphset; @@ -1339,7 +1339,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, gs, GlyphSetType, - SecurityReadAccess); + DixReadAccess); if (!glyphSet) { client->errorValue = gs; @@ -1420,7 +1420,7 @@ ProcRenderFillRectangles (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -1486,7 +1486,7 @@ ProcRenderCreateCursor (ClientPtr client) REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); if (!pSrc->pDrawable) return BadDrawable; @@ -1668,7 +1668,7 @@ ProcRenderSetPictureTransform (ClientPtr client) int result; REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform); if (client->noClientException != Success) @@ -1694,7 +1694,7 @@ ProcRenderQueryFilters (ClientPtr client) char *names; REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); - SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, SecurityReadAccess); + SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, DixReadAccess); pScreen = pDrawable->pScreen; nbytesName = 0; @@ -1797,7 +1797,7 @@ ProcRenderSetPictureFilter (ClientPtr client) char *name; REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); name = (char *) (stuff + 1); params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3)); @@ -1831,7 +1831,7 @@ ProcRenderCreateAnimCursor (ClientPtr client) for (i = 0; i < ncursor; i++) { cursors[i] = (CursorPtr)SecurityLookupIDByType(client, elt->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!cursors[i]) { xfree (cursors); @@ -1859,7 +1859,7 @@ ProcRenderAddTraps (ClientPtr client) REQUEST(xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pPicture->pDrawable) return BadDrawable; @@ -2614,7 +2614,7 @@ PanoramiXRenderCreatePicture (ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) return BadDrawable; if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) return BadAlloc; @@ -2656,7 +2656,7 @@ PanoramiXRenderChangePicture (ClientPtr client) REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); FOR_NSCREENS_BACKWARD(j) { @@ -2677,7 +2677,7 @@ PanoramiXRenderSetPictureClipRectangles (ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); FOR_NSCREENS_BACKWARD(j) { @@ -2698,7 +2698,7 @@ PanoramiXRenderSetPictureTransform (ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq); - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); FOR_NSCREENS_BACKWARD(j) { @@ -2719,7 +2719,7 @@ PanoramiXRenderSetPictureFilter (ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); FOR_NSCREENS_BACKWARD(j) { @@ -2742,7 +2742,7 @@ PanoramiXRenderFreePicture (ClientPtr client) client->errorValue = stuff->picture; - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityDestroyAccess, + VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess, RenderErrBase + BadPicture); @@ -2768,11 +2768,11 @@ PanoramiXRenderComposite (ClientPtr client) REQUEST_SIZE_MATCH(xRenderCompositeReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_ALPHA (msk, stuff->mask, client, SecurityReadAccess, + VERIFY_XIN_ALPHA (msk, stuff->mask, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); orig = *stuff; @@ -2816,9 +2816,9 @@ PanoramiXRenderCompositeGlyphs (ClientPtr client) INT16 xSrc, ySrc; REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) + @@ -2859,7 +2859,7 @@ PanoramiXRenderFillRectangles (ClientPtr client) int extra_len; REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); if (extra_len && @@ -2906,9 +2906,9 @@ PanoramiXRenderTrapezoids(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); @@ -2968,9 +2968,9 @@ PanoramiXRenderTriangles(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq); @@ -3026,9 +3026,9 @@ PanoramiXRenderTriStrip(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderTriStripReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq); @@ -3080,9 +3080,9 @@ PanoramiXRenderTriFan(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderTriFanReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq); @@ -3136,7 +3136,7 @@ PanoramiXRenderColorTrapezoids(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq); @@ -3180,7 +3180,7 @@ PanoramiXRenderColorTriangles(ClientPtr client) REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq); @@ -3226,7 +3226,7 @@ PanoramiXRenderAddTraps (ClientPtr client) INT16 x_off, y_off; REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess, + VERIFY_XIN_PICTURE (picture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); if (extra_len && diff --git a/xfixes/cursor.c b/xfixes/cursor.c index c75e74442..21dbcc2cb 100755 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -242,7 +242,7 @@ ProcXFixesSelectCursorInput (ClientPtr client) REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); if (stuff->eventMask & ~CursorAllEvents) @@ -415,7 +415,7 @@ ProcXFixesSetCursorName (ClientPtr client) Atom atom; REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq); - VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityWriteAccess); + VERIFY_CURSOR(pCursor, stuff->cursor, client, DixWriteAccess); tchar = (char *) &stuff[1]; atom = MakeAtom (tchar, stuff->nbytes, TRUE); if (atom == BAD_RESOURCE) @@ -448,7 +448,7 @@ ProcXFixesGetCursorName (ClientPtr client) int len; REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq); - VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityReadAccess); + VERIFY_CURSOR(pCursor, stuff->cursor, client, DixReadAccess); if (pCursor->name) str = NameForAtom (pCursor->name); else @@ -679,8 +679,8 @@ ProcXFixesChangeCursor (ClientPtr client) REQUEST(xXFixesChangeCursorReq); REQUEST_SIZE_MATCH(xXFixesChangeCursorReq); - VERIFY_CURSOR (pSource, stuff->source, client, SecurityReadAccess); - VERIFY_CURSOR (pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_CURSOR (pSource, stuff->source, client, DixReadAccess); + VERIFY_CURSOR (pDestination, stuff->destination, client, DixWriteAccess); ReplaceCursor (pSource, TestForCursor, (pointer) pDestination); return (client->noClientException); @@ -714,7 +714,7 @@ ProcXFixesChangeCursorByName (ClientPtr client) REQUEST(xXFixesChangeCursorByNameReq); REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes); - VERIFY_CURSOR(pSource, stuff->source, client, SecurityReadAccess); + VERIFY_CURSOR(pSource, stuff->source, client, DixReadAccess); tchar = (char *) &stuff[1]; name = MakeAtom (tchar, stuff->nbytes, FALSE); if (name) diff --git a/xfixes/region.c b/xfixes/region.c index 68c701553..a004fc0ca 100755 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -118,7 +118,7 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client) pPixmap = (PixmapPtr) SecurityLookupIDByType (client, stuff->bitmap, RT_PIXMAP, - SecurityReadAccess); + DixReadAccess); if (!pPixmap) { client->errorValue = stuff->bitmap; @@ -225,7 +225,7 @@ ProcXFixesCreateRegionFromGC (ClientPtr client) REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq); LEGAL_NEW_RESOURCE (stuff->region, client); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess); + SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixReadAccess); switch (pGC->clientClipType) { case CT_PIXMAP: @@ -273,7 +273,7 @@ ProcXFixesCreateRegionFromPicture (ClientPtr client) REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq); LEGAL_NEW_RESOURCE (stuff->region, client); - VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityReadAccess, + VERIFY_PICTURE(pPicture, stuff->picture, client, DixReadAccess, RenderErrBase + BadPicture); switch (pPicture->clientClipType) { @@ -321,7 +321,7 @@ ProcXFixesDestroyRegion (ClientPtr client) RegionPtr pRegion; REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq); - VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess); + VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess); FreeResource (stuff->region, RT_NONE); return(client->noClientException); } @@ -346,7 +346,7 @@ ProcXFixesSetRegion (ClientPtr client) REQUEST (xXFixesSetRegionReq); REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq); - VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess); + VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess); things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq); if (things & 4) @@ -384,8 +384,8 @@ ProcXFixesCopyRegion (ClientPtr client) RegionPtr pSource, pDestination; REQUEST (xXFixesCopyRegionReq); - VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess); - VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); + VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); if (!REGION_COPY(pScreen, pDestination, pSource)) return BadAlloc; @@ -414,9 +414,9 @@ ProcXFixesCombineRegion (ClientPtr client) REQUEST (xXFixesCombineRegionReq); REQUEST_SIZE_MATCH (xXFixesCombineRegionReq); - VERIFY_REGION(pSource1, stuff->source1, client, SecurityReadAccess); - VERIFY_REGION(pSource2, stuff->source2, client, SecurityReadAccess); - VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_REGION(pSource1, stuff->source1, client, DixReadAccess); + VERIFY_REGION(pSource2, stuff->source2, client, DixReadAccess); + VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); switch (stuff->xfixesReqType) { case X_XFixesUnionRegion: @@ -461,8 +461,8 @@ ProcXFixesInvertRegion (ClientPtr client) REQUEST(xXFixesInvertRegionReq); REQUEST_SIZE_MATCH(xXFixesInvertRegionReq); - VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess); - VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); + VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); /* Compute bounds, limit to 16 bits */ bounds.x1 = stuff->x; @@ -509,7 +509,7 @@ ProcXFixesTranslateRegion (ClientPtr client) REQUEST(xXFixesTranslateRegionReq); REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq); - VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess); + VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess); REGION_TRANSLATE(pScreen, pRegion, stuff->dx, stuff->dy); return (client->noClientException); @@ -536,8 +536,8 @@ ProcXFixesRegionExtents (ClientPtr client) REQUEST(xXFixesRegionExtentsReq); REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq); - VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess); - VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); + VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); REGION_RESET (0, pDestination, REGION_EXTENTS (0, pSource)); @@ -569,7 +569,7 @@ ProcXFixesFetchRegion (ClientPtr client) REQUEST(xXFixesFetchRegionReq); REQUEST_SIZE_MATCH(xXFixesFetchRegionReq); - VERIFY_REGION(pRegion, stuff->region, client, SecurityReadAccess); + VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess); pExtent = REGION_EXTENTS (0, pRegion); pBox = REGION_RECTS (pRegion); @@ -633,8 +633,8 @@ ProcXFixesSetGCClipRegion (ClientPtr client) REQUEST(xXFixesSetGCClipRegionReq); REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess); - VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, SecurityReadAccess); + SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); + VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, DixReadAccess); if (pRegion) { @@ -685,7 +685,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client) client->errorValue = stuff->dest; return BadWindow; } - VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityWriteAccess); + VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess); pScreen = pWin->drawable.pScreen; switch (stuff->destKind) { case ShapeBounding: @@ -775,11 +775,11 @@ ProcXFixesSetPictureClipRegion (ClientPtr client) REQUEST(xXFixesSetPictureClipRegionReq); REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq); - VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess, + VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); pScreen = pPicture->pDrawable->pScreen; ps = GetPictureScreen (pScreen); - VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityReadAccess); + VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess); return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin, pRegion); @@ -815,8 +815,8 @@ ProcXFixesExpandRegion (ClientPtr client) int i; REQUEST_SIZE_MATCH (xXFixesExpandRegionReq); - VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess); - VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess); + VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); + VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); nBoxes = REGION_NUM_RECTS(pSource); pSrc = REGION_RECTS(pSource); diff --git a/xfixes/saveset.c b/xfixes/saveset.c index 9ebf24584..9ad2627c0 100755 --- a/xfixes/saveset.c +++ b/xfixes/saveset.c @@ -38,7 +38,7 @@ ProcXFixesChangeSaveSet(ClientPtr client) REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) diff --git a/xfixes/select.c b/xfixes/select.c index 4c7a49def..a718715a1 100755 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -196,7 +196,7 @@ ProcXFixesSelectSelectionInput (ClientPtr client) REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); if (stuff->eventMask & ~SelectionAllEvents) From 60cdc592fe042c03ceb5d4c3344acfbbf5d8ae28 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 14:46:03 -0500 Subject: [PATCH 090/109] Add new, combined dix lookup functions. --- dix/dixutils.c | 186 ++++++++++++++++++++----------------- hw/xfree86/loader/dixsym.c | 12 ++- include/dix.h | 67 ++++++------- include/pixmap.h | 10 ++ 4 files changed, 148 insertions(+), 127 deletions(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index fca55d99f..f9980c5a8 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -194,115 +194,129 @@ CompareISOLatin1Lowered(unsigned char *s1, int s1len, return (int) c1 - (int) c2; } -#ifdef XACE - -/* SecurityLookupWindow and SecurityLookupDrawable: - * Look up the window/drawable taking into account the client doing - * the lookup and the type of access desired. Return the window/drawable - * if it exists and the client is allowed access, else return NULL. - * Most Proc* functions should be calling these instead of - * LookupWindow and LookupDrawable, which do no access checks. - * XACE note: need to see if client->lastDrawableID can still be used here. +/* + * dixLookupWindow and dixLookupDrawable: + * Look up the window/drawable taking into account the client doing the + * lookup, the type of drawable desired, and the type of access desired. + * Return Success with *pDraw set if the window/drawable exists and the client + * is allowed access, else return an error code with *pDraw set to NULL. The + * access mask values are defined in resource.h. The type mask values are + * defined in pixmap.h, with zero equivalent to M_DRAWABLE. */ - -_X_EXPORT WindowPtr -SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode) +_X_EXPORT int +dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client, + Mask type, Mask access) { - client->errorValue = rid; - if(rid == INVALID) - return NULL; - return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); -} + DrawablePtr pTmp; + RESTYPE rtype; + *pDraw = NULL; + client->errorValue = id; + if (id == INVALID) + return BadDrawable; -_X_EXPORT pointer -SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) -{ - register DrawablePtr pDraw; + if (id == client->lastDrawableID) { + pTmp = client->lastDrawable; - if(rid == INVALID) - return (pointer) NULL; - pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE, - access_mode); - if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) - return (pointer)pDraw; - return (pointer)NULL; -} + /* an access check is required for cached drawables */ + rtype = (pTmp->type | M_WINDOW) ? RT_WINDOW : RT_PIXMAP; + if (!XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp)) + return BadDrawable; + } else + pTmp = (DrawablePtr)SecurityLookupIDByClass(client, id, RC_DRAWABLE, + access); + if (!pTmp) + return BadDrawable; + if (!((1 << pTmp->type) | (type ? type : M_DRAWABLE))) + return BadMatch; -/* We can't replace the LookupWindow and LookupDrawable functions with - * macros because of compatibility with loadable servers. - */ - -_X_EXPORT WindowPtr -LookupWindow(XID rid, ClientPtr client) -{ - return SecurityLookupWindow(rid, client, DixUnknownAccess); -} - -_X_EXPORT pointer -LookupDrawable(XID rid, ClientPtr client) -{ - return SecurityLookupDrawable(rid, client, DixUnknownAccess); -} - -#else /* not XACE */ - -WindowPtr -LookupWindow(XID rid, ClientPtr client) -{ - WindowPtr pWin; - - client->errorValue = rid; - if(rid == INVALID) - return NULL; - if (client->lastDrawableID == rid) - { - if (client->lastDrawable->type == DRAWABLE_WINDOW) - return ((WindowPtr) client->lastDrawable); - return (WindowPtr) NULL; - } - pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW); - if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) { - client->lastDrawable = (DrawablePtr) pWin; - client->lastDrawableID = rid; + if (pTmp->type | M_DRAWABLE) { + client->lastDrawable = pTmp; + client->lastDrawableID = id; client->lastGCID = INVALID; client->lastGC = (GCPtr)NULL; } - return pWin; + *pDraw = pTmp; + return Success; } - -pointer -LookupDrawable(XID rid, ClientPtr client) +_X_EXPORT int +dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access) { - register DrawablePtr pDraw; - - if(rid == INVALID) - return (pointer) NULL; - if (client->lastDrawableID == rid) - return ((pointer) client->lastDrawable); - pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE); - if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) - return (pointer)pDraw; - return (pointer)NULL; + int rc; + rc = dixLookupDrawable((DrawablePtr*)pWin, id, client, M_WINDOW, access); + return (rc == BadDrawable) ? BadWindow : rc; } -#endif /* XACE */ +_X_EXPORT int +dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access) +{ + GCPtr pTmp = (GCPtr)SecurityLookupIDByType(client, id, RT_GC, access); + if (pTmp) { + *pGC = pTmp; + return Success; + } + client->errorValue = id; + *pGC = NULL; + return BadGC; +} -_X_EXPORT ClientPtr -LookupClient(XID rid, ClientPtr client) +_X_EXPORT int +dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client) { pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY, DixReadAccess); int clientIndex = CLIENT_ID(rid); - if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) - { - return clients[clientIndex]; + if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) { + *pClient = clients[clientIndex]; + return Success; } - return (ClientPtr)NULL; + *pClient = NULL; + return BadValue; } +/* + * These are deprecated compatibility functions and will be removed soon! + * Please use the new dixLookup*() functions above. + */ +_X_EXPORT WindowPtr +SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode) +{ + WindowPtr pWin; + int i = dixLookupWindow(&pWin, id, client, access_mode); + return (i == Success) ? pWin : NULL; +} + +_X_EXPORT WindowPtr +LookupWindow(XID id, ClientPtr client) +{ + return SecurityLookupWindow(id, client, DixUnknownAccess); +} + +_X_EXPORT pointer +SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode) +{ + DrawablePtr pDraw; + int i = dixLookupDrawable(&pDraw, id, client, access_mode, TRUE); + return (i == Success) ? pDraw : NULL; +} + +_X_EXPORT pointer +LookupDrawable(XID id, ClientPtr client) +{ + return SecurityLookupDrawable(id, client, DixUnknownAccess); +} + +_X_EXPORT ClientPtr +LookupClient(XID id, ClientPtr client) +{ + ClientPtr pClient; + int i = dixLookupClient(&pClient, id, client); + return (i == Success) ? pClient : NULL; +} + +/* end deprecated functions */ int AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 27a3093b1..32e0e4f68 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -155,17 +155,21 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(CompareTimeStamps) SYMFUNC(CopyISOLatin1Lowered) SYMFUNC(DeleteCallback) + SYMFUNC(dixLookupDrawable) + SYMFUNC(dixLookupWindow) + SYMFUNC(dixLookupClient) + SYMFUNC(dixLookupGC) + /* following are deprecated */ SYMFUNC(LookupClient) SYMFUNC(LookupDrawable) SYMFUNC(LookupWindow) + SYMFUNC(SecurityLookupDrawable) + SYMFUNC(SecurityLookupWindow) + /* end deprecated */ SYMFUNC(NoopDDA) SYMFUNC(QueueWorkProc) SYMFUNC(RegisterBlockAndWakeupHandlers) SYMFUNC(RemoveBlockAndWakeupHandlers) -#ifdef XACE - SYMFUNC(SecurityLookupDrawable) - SYMFUNC(SecurityLookupWindow) -#endif /* events.c */ SYMFUNC(CheckCursorConfinement) SYMFUNC(DeliverEvents) diff --git a/include/dix.h b/include/dix.h index 2c87a48c3..09d5fef95 100644 --- a/include/dix.h +++ b/include/dix.h @@ -375,47 +375,40 @@ extern int CompareISOLatin1Lowered( unsigned char * /*b*/, int blen); -#ifdef XACE +extern int dixLookupWindow( + WindowPtr *result, + XID id, + ClientPtr client, + Mask access_mode); -extern WindowPtr SecurityLookupWindow( - XID /*rid*/, - ClientPtr /*client*/, - Mask /*access_mode*/); +extern int dixLookupDrawable( + DrawablePtr *result, + XID id, + ClientPtr client, + Mask type_mask, + Mask access_mode); -extern pointer SecurityLookupDrawable( - XID /*rid*/, - ClientPtr /*client*/, - Mask /*access_mode*/); +extern int dixLookupGC( + GCPtr *result, + XID id, + ClientPtr client, + Mask access_mode); -extern WindowPtr LookupWindow( - XID /*rid*/, - ClientPtr /*client*/); +extern int dixLookupClient( + ClientPtr *result, + XID id, + ClientPtr client); -extern pointer LookupDrawable( - XID /*rid*/, - ClientPtr /*client*/); - -#else - -extern WindowPtr LookupWindow( - XID /*rid*/, - ClientPtr /*client*/); - -extern pointer LookupDrawable( - XID /*rid*/, - ClientPtr /*client*/); - -#define SecurityLookupWindow(rid, client, access_mode) \ - LookupWindow(rid, client) - -#define SecurityLookupDrawable(rid, client, access_mode) \ - LookupDrawable(rid, client) - -#endif /* XACE */ - -extern ClientPtr LookupClient( - XID /*rid*/, - ClientPtr /*client*/); +/* + * These are deprecated compatibility functions and will be removed soon! + * Please use the new dixLookup*() functions above. + */ +extern WindowPtr SecurityLookupWindow(XID, ClientPtr, Mask); +extern WindowPtr LookupWindow(XID, ClientPtr); +extern pointer SecurityLookupDrawable(XID, ClientPtr, Mask); +extern pointer LookupDrawable(XID, ClientPtr); +extern ClientPtr LookupClient(XID, ClientPtr); +/* end deprecated functions */ extern void NoopDDA(void); diff --git a/include/pixmap.h b/include/pixmap.h index 3276fadb6..19e682a50 100644 --- a/include/pixmap.h +++ b/include/pixmap.h @@ -58,6 +58,16 @@ SOFTWARE. #define UNDRAWABLE_WINDOW 2 #define DRAWABLE_BUFFER 3 +/* corresponding type masks for dixLookupDrawable() */ +#define M_DRAWABLE_WINDOW (1<<0) +#define M_DRAWABLE_PIXMAP (1<<1) +#define M_UNDRAWABLE_WINDOW (1<<2) +#define M_DRAWABLE_BUFFER (1<<3) +#define M_ANY (-1) +#define M_WINDOW (M_DRAWABLE_WINDOW|M_UNDRAWABLE_WINDOW) +#define M_DRAWABLE (M_DRAWABLE_WINDOW|M_DRAWABLE_PIXMAP|M_DRAWABLE_BUFFER) +#define M_UNDRAWABLE (M_UNDRAWABLE_WINDOW) + /* flags to PaintWindow() */ #define PW_BACKGROUND 0 #define PW_BORDER 1 From ab1886df73b73360fa3bd7ce8e01affc074cbc8d Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 15:42:19 -0500 Subject: [PATCH 091/109] Add new, combined dix lookup functions (tweak). --- dix/dixutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index f9980c5a8..3479ddccf 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -298,7 +298,7 @@ _X_EXPORT pointer SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode) { DrawablePtr pDraw; - int i = dixLookupDrawable(&pDraw, id, client, access_mode, TRUE); + int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode); return (i == Success) ? pDraw : NULL; } From 0cf75e74322e2b6a6efc7acf892e04365fde503b Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 17:27:12 -0500 Subject: [PATCH 092/109] Remove instances of macros LOOKUP_DRAWABLE and VERIFY_DRAWABLE. --- Xext/panoramiXprocs.c | 25 ++++++++++++++++++------- Xext/shm.c | 24 +++++++++++++++++------- Xext/xvdisp.c | 23 ++++++++++------------- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 683308425..77a2384c4 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -1028,10 +1028,14 @@ int PanoramiXCopyArea(ClientPtr client) DrawablePtr pDst; GCPtr pGC; char *data; - int pitch; + int pitch, rc; - FOR_NSCREENS(j) - VERIFY_DRAWABLE(drawables[j], src->info[j].id, client); + FOR_NSCREENS(j) { + rc = dixLookupDrawable(drawables+j, src->info[j].id, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; + } pitch = PixmapBytePad(stuff->width, drawables[0]->depth); if(!(data = xcalloc(1, stuff->height * pitch))) @@ -1754,7 +1758,7 @@ int PanoramiXGetImage(ClientPtr client) xGetImageReply xgi; Bool isRoot; char *pBuf; - int i, x, y, w, h, format; + int i, x, y, w, h, format, rc; Mask plane = 0, planemask; int linesDone, nlines, linesPerBuf; long widthBytesLine, length; @@ -1775,7 +1779,10 @@ int PanoramiXGetImage(ClientPtr client) if(draw->type == XRT_PIXMAP) return (*SavedProcVector[X_GetImage])(client); - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; if(!((WindowPtr)pDraw)->realized) return(BadMatch); @@ -1809,8 +1816,12 @@ int PanoramiXGetImage(ClientPtr client) } drawables[0] = pDraw; - for(i = 1; i < PanoramiXNumScreens; i++) - VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client); + for(i = 1; i < PanoramiXNumScreens; i++) { + rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; + } xgi.visual = wVisual (((WindowPtr) pDraw)); xgi.type = X_Reply; diff --git a/Xext/shm.c b/Xext/shm.c index 0c2299a61..049c746d6 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -606,7 +606,7 @@ ProcPanoramiXShmGetImage(ClientPtr client) DrawablePtr pDraw; xShmGetImageReply xgi; ShmDescPtr shmdesc; - int i, x, y, w, h, format; + int i, x, y, w, h, format, rc; Mask plane = 0, planemask; long lenPer = 0, length, widthBytesLine; Bool isRoot; @@ -627,7 +627,10 @@ ProcPanoramiXShmGetImage(ClientPtr client) if (draw->type == XRT_PIXMAP) return ProcShmGetImage(client); - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); @@ -660,8 +663,12 @@ ProcPanoramiXShmGetImage(ClientPtr client) } drawables[0] = pDraw; - for(i = 1; i < PanoramiXNumScreens; i++) - VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client); + for(i = 1; i < PanoramiXNumScreens; i++) { + rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; + } xgi.visual = wVisual(((WindowPtr)pDraw)); xgi.type = X_Reply; @@ -909,12 +916,12 @@ static int ProcShmGetImage(client) register ClientPtr client; { - register DrawablePtr pDraw; + DrawablePtr pDraw; long lenPer = 0, length; Mask plane = 0; xShmGetImageReply xgi; ShmDescPtr shmdesc; - int n; + int n, rc; REQUEST(xShmGetImageReq); @@ -924,7 +931,10 @@ ProcShmGetImage(client) client->errorValue = stuff->format; return(BadValue); } - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); if (pDraw->type == DRAWABLE_WINDOW) { diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index ec2b4f8d7..d66604471 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -717,15 +717,14 @@ ProcXvGetStill(ClientPtr client) static int ProcXvSelectVideoNotify(ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; + int rc; REQUEST(xvSelectVideoNotifyReq); REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - if(!(pDraw = (DrawablePtr)LOOKUP_DRAWABLE(stuff->drawable, client) )) - { - client->errorValue = stuff->drawable; - return (BadWindow); - } + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixUnknownAccess); + if (rc != Success) + return rc; return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff); @@ -822,8 +821,8 @@ ProcXvUngrabPort(ClientPtr client) static int ProcXvStopVideo(ClientPtr client) { - int status; - register DrawablePtr pDraw; + int status, rc; + DrawablePtr pDraw; XvPortPtr pPort; REQUEST(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq); @@ -840,11 +839,9 @@ ProcXvStopVideo(ClientPtr client) return (status); } - if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) )) - { - client->errorValue = stuff->drawable; - return (BadDrawable); - } + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixUnknownAccess); + if (rc != Success) + return rc; return XVCALL(diStopVideo)(client, pPort, pDraw); From 51b69ff499c05f59cb1e577c4e8abf6f7f283b3e Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 17:53:43 -0500 Subject: [PATCH 093/109] Remove instances of macro SECURITY_VERIFY_DRAWABLE. --- Xext/panoramiXprocs.c | 17 ++++++++++++----- damageext/damageext.c | 8 ++++++-- dix/dispatch.c | 36 ++++++++++++++++++++++++------------ randr/rrscreen.c | 7 ++++--- render/render.c | 19 +++++++++++-------- 5 files changed, 57 insertions(+), 30 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 77a2384c4..2bf94a998 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -1069,6 +1069,7 @@ int PanoramiXCopyArea(ClientPtr client) DrawablePtr pDst = NULL, pSrc = NULL; GCPtr pGC = NULL; RegionPtr pRgn[MAXSCREENS]; + int rc; FOR_NSCREENS_BACKWARD(j) { stuff->dstDrawable = dst->info[j].id; @@ -1085,8 +1086,11 @@ int PanoramiXCopyArea(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { - SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, - DixReadAccess); + rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; @@ -1137,7 +1141,7 @@ int PanoramiXCopyArea(ClientPtr client) int PanoramiXCopyPlane(ClientPtr client) { - int j, srcx, srcy, dstx, dsty; + int j, srcx, srcy, dstx, dsty, rc; PanoramiXRes *gc, *src, *dst; Bool srcIsRoot = FALSE; Bool dstIsRoot = FALSE; @@ -1191,8 +1195,11 @@ int PanoramiXCopyPlane(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { - SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, - DixReadAccess); + rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; return (BadMatch); diff --git a/damageext/damageext.c b/damageext/damageext.c index c8f28e953..6083693a4 100755 --- a/damageext/damageext.c +++ b/damageext/damageext.c @@ -173,13 +173,17 @@ ProcDamageCreate (ClientPtr client) DamageExtPtr pDamageExt; DamageReportLevel level; RegionPtr pRegion; + int rc; REQUEST(xDamageCreateReq); REQUEST_SIZE_MATCH(xDamageCreateReq); LEGAL_NEW_RESOURCE(stuff->damage, client); - SECURITY_VERIFY_DRAWABLE (pDrawable, stuff->drawable, client, - DixReadAccess); + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + switch (stuff->level) { case XDamageReportRawRectangles: level = DamageReportRawRegion; diff --git a/dix/dispatch.c b/dix/dispatch.c index a3de07fed..8134cd5a5 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1597,17 +1597,19 @@ ProcFreePixmap(register ClientPtr client) int ProcCreateGC(register ClientPtr client) { - int error; + int error, rc; GC *pGC; - register DrawablePtr pDraw; + DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); - SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client, - DixReadAccess); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess); + if (rc != Success) + return rc; + len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1766,18 +1768,21 @@ int ProcCopyArea(register ClientPtr client) { register DrawablePtr pDst; - register DrawablePtr pSrc; + DrawablePtr pSrc; register GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; + int rc; REQUEST_SIZE_MATCH(xCopyAreaReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { - SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, + rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, DixReadAccess); + if (rc != Success) + return rc; if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; @@ -1806,18 +1811,22 @@ ProcCopyArea(register ClientPtr client) int ProcCopyPlane(register ClientPtr client) { - register DrawablePtr psrcDraw, pdstDraw; + DrawablePtr psrcDraw, pdstDraw; register GC *pGC; REQUEST(xCopyPlaneReq); RegionPtr pRgn; + int rc; REQUEST_SIZE_MATCH(xCopyPlaneReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { - SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, - DixReadAccess); + rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; @@ -2142,8 +2151,8 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, int x, int y, int width, int height, Mask planemask, xGetImageReply **im_return) { - register DrawablePtr pDraw; - int nlines, linesPerBuf; + DrawablePtr pDraw; + int nlines, linesPerBuf, rc; register int linesDone; long widthBytesLine, length; Mask plane = 0; @@ -2156,7 +2165,10 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, client->errorValue = format; return(BadValue); } - SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, DixReadAccess); + rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess); + if (rc != Success) + return rc; + if(pDraw->type == DRAWABLE_WINDOW) { if( /* check for being viewable */ diff --git a/randr/rrscreen.c b/randr/rrscreen.c index b4004a31f..3b9263bc4 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -703,7 +703,7 @@ ProcRRSetScreenConfig (ClientPtr client) REQUEST(xRRSetScreenConfigReq); xRRSetScreenConfigReply rep; DrawablePtr pDraw; - int n; + int n, rc; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; TimeStamp configTime; @@ -730,8 +730,9 @@ ProcRRSetScreenConfig (ClientPtr client) has_rate = FALSE; } - SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client, - DixWriteAccess); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); + if (rc != Success) + return rc; pScreen = pDraw->pScreen; diff --git a/render/render.c b/render/render.c index 51a3fa69a..126d08daf 100644 --- a/render/render.c +++ b/render/render.c @@ -614,15 +614,17 @@ ProcRenderCreatePicture (ClientPtr client) PicturePtr pPicture; DrawablePtr pDrawable; PictFormatPtr pFormat; - int len; - int error; + int len, error, rc; REQUEST(xRenderCreatePictureReq); REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); LEGAL_NEW_RESOURCE(stuff->pid, client); - SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, - DixWriteAccess); + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixWriteAccess); + if (rc != Success) + return rc; + pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->format, PictFormatType, @@ -1687,14 +1689,15 @@ ProcRenderQueryFilters (ClientPtr client) int nnames; ScreenPtr pScreen; PictureScreenPtr ps; - int i, j; - int len; - int total_bytes; + int i, j, len, total_bytes, rc; INT16 *aliases; char *names; REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); - SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, DixReadAccess); + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; pScreen = pDrawable->pScreen; nbytesName = 0; From 5e334f06a1ef89891f9df2a371e4662340bec26b Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 18:27:09 -0500 Subject: [PATCH 094/109] Remove instances of macros VERIFY_GEOMETRABLE and VERIFY_GC. --- Xext/panoramiXprocs.c | 6 +++++- Xext/shm.c | 18 +++++++++++++----- Xext/xf86bigfont.c | 1 - dix/dispatch.c | 1 - 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 2bf94a998..a193c4188 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -531,10 +531,14 @@ int PanoramiXGetGeometry(ClientPtr client) { xGetGeometryReply rep; DrawablePtr pDraw; + int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - VERIFY_GEOMETRABLE (pDraw, stuff->id, client); + rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/shm.c b/Xext/shm.c index 049c746d6..4e733197c 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -727,7 +727,7 @@ ProcPanoramiXShmCreatePixmap( PixmapPtr pMap = NULL; DrawablePtr pDraw; DepthPtr pDepth; - int i, j, result; + int i, j, result, rc; ShmDescPtr shmdesc; REQUEST(xShmCreatePixmapReq); PanoramiXRes *newPix; @@ -737,7 +737,11 @@ ProcPanoramiXShmCreatePixmap( if (!sharedPixmaps) return BadImplementation; LEGAL_NEW_RESOURCE(stuff->pid, client); - VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixUnknownAccess); + if (rc != Success) + return rc; + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); if (!stuff->width || !stuff->height) { @@ -1052,9 +1056,9 @@ ProcShmCreatePixmap(client) register ClientPtr client; { PixmapPtr pMap; - register DrawablePtr pDraw; + DrawablePtr pDraw; DepthPtr pDepth; - register int i; + register int i, rc; ShmDescPtr shmdesc; REQUEST(xShmCreatePixmapReq); @@ -1063,7 +1067,11 @@ ProcShmCreatePixmap(client) if (!sharedPixmaps) return BadImplementation; LEGAL_NEW_RESOURCE(stuff->pid, client); - VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixUnknownAccess); + if (rc != Success) + return rc; + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); if (!stuff->width || !stuff->height) { diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 44647060a..f50481f78 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -447,7 +447,6 @@ ProcXF86BigfontQueryFont( pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, DixReadAccess); if (!pFont) { - /* can't use VERIFY_GC because it might return BadGC */ GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, DixReadAccess); if (!pGC) { diff --git a/dix/dispatch.c b/dix/dispatch.c index 8134cd5a5..a5a1d0374 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1385,7 +1385,6 @@ ProcQueryFont(register ClientPtr client) DixReadAccess); if (!pFont) { - /* can't use VERIFY_GC because it might return BadGC */ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, DixReadAccess); if (!pGC) From 00f0705b3bb444ac934fc902cd23130f1777eab2 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 19:15:21 -0500 Subject: [PATCH 095/109] Remove instances of macros SECURITY_VERIFY_GEOMETRABLE and SECURITY_VERIFY_GC. --- Xext/shm.c | 4 +- Xext/xvdisp.c | 16 +++--- dix/dispatch.c | 132 +++++++++++++++++++++++++++++------------------- include/dix.h | 13 +++-- xfixes/region.c | 13 +++-- 5 files changed, 108 insertions(+), 70 deletions(-) diff --git a/Xext/shm.c b/Xext/shm.c index 4e733197c..7cfaa6808 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -816,8 +816,8 @@ static int ProcShmPutImage(client) register ClientPtr client; { - register GCPtr pGC; - register DrawablePtr pDraw; + GCPtr pGC; + DrawablePtr pDraw; long length; ShmDescPtr shmdesc; REQUEST(xShmPutImageReq); diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index d66604471..2afb7c687 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -531,9 +531,9 @@ ProcXvQueryEncodings(ClientPtr client) static int ProcXvPutVideo(ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; XvPortPtr pPort; - register GCPtr pGC; + GCPtr pGC; int status; REQUEST(xvPutVideoReq); @@ -577,9 +577,9 @@ ProcXvPutVideo(ClientPtr client) static int ProcXvPutStill(ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; XvPortPtr pPort; - register GCPtr pGC; + GCPtr pGC; int status; REQUEST(xvPutStillReq); @@ -624,9 +624,9 @@ ProcXvPutStill(ClientPtr client) static int ProcXvGetVideo(ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; XvPortPtr pPort; - register GCPtr pGC; + GCPtr pGC; int status; REQUEST(xvGetVideoReq); @@ -671,9 +671,9 @@ ProcXvGetVideo(ClientPtr client) static int ProcXvGetStill(ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; XvPortPtr pPort; - register GCPtr pGC; + GCPtr pGC; int status; REQUEST(xvGetStillReq); diff --git a/dix/dispatch.c b/dix/dispatch.c index a5a1d0374..0421886a0 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -843,11 +843,15 @@ ProcCirculateWindow(register ClientPtr client) int GetGeometry(register ClientPtr client, xGetGeometryReply *rep) { - register DrawablePtr pDraw; + DrawablePtr pDraw; + int rc; REQUEST(xResourceReq); - REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, DixReadAccess); + + rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixReadAccess); + if (rc != Success) + return rc; + rep->type = X_Reply; rep->length = 0; rep->sequenceNumber = client->sequence; @@ -1516,16 +1520,20 @@ int ProcCreatePixmap(register ClientPtr client) { PixmapPtr pMap; - register DrawablePtr pDraw; + DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; - register int i; + register int i, rc; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - DixReadAccess); + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixReadAccess); + if (rc != Success) + return rc; + if (!stuff->width || !stuff->height) { client->errorValue = 0; @@ -1625,12 +1633,15 @@ int ProcChangeGC(register ClientPtr client) { GC *pGC; - REQUEST(xChangeGCReq); int result; unsigned len; - + REQUEST(xChangeGCReq); REQUEST_AT_LEAST_SIZE(xChangeGCReq); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); + + result = dixLookupGC(&pGC, stuff->gc, client, DixWriteAccess); + if (result != Success) + return result; + len = client->req_len - (sizeof(xChangeGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1648,14 +1659,18 @@ ProcChangeGC(register ClientPtr client) int ProcCopyGC(register ClientPtr client) { - register GC *dstGC; - register GC *pGC; + GC *dstGC; + GC *pGC; int result; REQUEST(xCopyGCReq); - REQUEST_SIZE_MATCH(xCopyGCReq); - SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, DixReadAccess); - SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, DixWriteAccess); + + result = dixLookupGC(&pGC, stuff->srcGC, client, DixReadAccess); + if (result != Success) + return result; + result = dixLookupGC(&dstGC, stuff->dstGC, client, DixWriteAccess); + if (result != Success) + return result; if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); @@ -1671,7 +1686,7 @@ ProcCopyGC(register ClientPtr client) int ProcSetDashes(register ClientPtr client) { - register GC *pGC; + GC *pGC; int result; REQUEST(xSetDashesReq); @@ -1682,7 +1697,9 @@ ProcSetDashes(register ClientPtr client) return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); + result = dixLookupGC(&pGC,stuff->gc, client, DixWriteAccess); + if (result != Success) + return result; result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, (unsigned char *)&stuff[1]); @@ -1698,9 +1715,8 @@ ProcSetDashes(register ClientPtr client) int ProcSetClipRectangles(register ClientPtr client) { - int nr; - int result; - register GC *pGC; + int nr, result; + GC *pGC; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); @@ -1710,7 +1726,9 @@ ProcSetClipRectangles(register ClientPtr client) client->errorValue = stuff->ordering; return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); + result = dixLookupGC(&pGC,stuff->gc, client, DixWriteAccess); + if (result != Success) + return result; nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) @@ -1727,11 +1745,15 @@ ProcSetClipRectangles(register ClientPtr client) int ProcFreeGC(register ClientPtr client) { - register GC *pGC; + GC *pGC; + int rc; REQUEST(xResourceReq); - REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GC(pGC, stuff->id, client, DixDestroyAccess); + + rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess); + if (rc != Success) + return rc; + FreeResource(stuff->id, RT_NONE); return(client->noClientException); } @@ -1766,9 +1788,9 @@ ProcClearToBackground(register ClientPtr client) int ProcCopyArea(register ClientPtr client) { - register DrawablePtr pDst; + DrawablePtr pDst; DrawablePtr pSrc; - register GC *pGC; + GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; int rc; @@ -1811,7 +1833,7 @@ int ProcCopyPlane(register ClientPtr client) { DrawablePtr psrcDraw, pdstDraw; - register GC *pGC; + GC *pGC; REQUEST(xCopyPlaneReq); RegionPtr pRgn; int rc; @@ -1862,8 +1884,8 @@ int ProcPolyPoint(register ClientPtr client) { int npoint; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); @@ -1885,8 +1907,8 @@ int ProcPolyLine(register ClientPtr client) { int npoint; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); @@ -1908,8 +1930,8 @@ int ProcPolySegment(register ClientPtr client) { int nsegs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); @@ -1927,8 +1949,8 @@ int ProcPolyRectangle (register ClientPtr client) { int nrects; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); @@ -1947,8 +1969,8 @@ int ProcPolyArc(register ClientPtr client) { int narcs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyArcReq); REQUEST_AT_LEAST_SIZE(xPolyArcReq); @@ -1966,8 +1988,8 @@ int ProcFillPoly(register ClientPtr client) { int things; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xFillPolyReq); REQUEST_AT_LEAST_SIZE(xFillPolyReq); @@ -1997,8 +2019,8 @@ int ProcPolyFillRectangle(register ClientPtr client) { int things; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); @@ -2018,8 +2040,8 @@ int ProcPolyFillArc(register ClientPtr client) { int narcs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); @@ -2090,8 +2112,8 @@ ReformatImage (char *base, int nbytes, int bpp, int order) int ProcPutImage(register ClientPtr client) { - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; long length; /* length of scanline server padded */ long lengthProto; /* length of scanline protocol padded */ char *tmpImage; @@ -2411,8 +2433,8 @@ int ProcImageText8(register ClientPtr client) { int err; - register DrawablePtr pDraw; - register GC *pGC; + DrawablePtr pDraw; + GC *pGC; REQUEST(xImageTextReq); @@ -2441,8 +2463,8 @@ int ProcImageText16(register ClientPtr client) { int err; - register DrawablePtr pDraw; - register GC *pGC; + DrawablePtr pDraw; + GC *pGC; REQUEST(xImageTextReq); @@ -3195,11 +3217,12 @@ int ProcQueryBestSize (register ClientPtr client) { xQueryBestSizeReply reply; - register DrawablePtr pDraw; + DrawablePtr pDraw; ScreenPtr pScreen; + int rc; REQUEST(xQueryBestSizeReq); - REQUEST_SIZE_MATCH(xQueryBestSizeReq); + if ((stuff->class != CursorShape) && (stuff->class != TileShape) && (stuff->class != StippleShape)) @@ -3207,8 +3230,11 @@ ProcQueryBestSize (register ClientPtr client) client->errorValue = stuff->class; return(BadValue); } - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - DixReadAccess); + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixReadAccess); + if (rc != Success) + return rc; if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return (BadMatch); pScreen = pDraw->pScreen; diff --git a/include/dix.h b/include/dix.h index 09d5fef95..7dd321f22 100644 --- a/include/dix.h +++ b/include/dix.h @@ -239,10 +239,15 @@ SOFTWARE. if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\ (client->lastDrawableID != drawID))\ {\ - SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, DixWriteAccess);\ - SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixReadAccess);\ - if ((pGC->depth != pDraw->depth) ||\ - (pGC->pScreen != pDraw->pScreen))\ + int rc;\ + rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\ + DixWriteAccess);\ + if (rc != Success)\ + return rc;\ + rc = dixLookupGC(&(pGC), stuff->gc, client, DixReadAccess);\ + if (rc != Success)\ + return rc;\ + if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\ return (BadMatch);\ client->lastDrawable = pDraw;\ client->lastDrawableID = drawID;\ diff --git a/xfixes/region.c b/xfixes/region.c index a004fc0ca..91e9fc9c1 100755 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -220,12 +220,15 @@ ProcXFixesCreateRegionFromGC (ClientPtr client) { RegionPtr pRegion, pClip; GCPtr pGC; + int rc; REQUEST (xXFixesCreateRegionFromGCReq); REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq); LEGAL_NEW_RESOURCE (stuff->region, client); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixReadAccess); + rc = dixLookupGC(&pGC, stuff->gc, client, DixReadAccess); + if (rc != Success) + return rc; switch (pGC->clientClipType) { case CT_PIXMAP: @@ -630,10 +633,14 @@ ProcXFixesSetGCClipRegion (ClientPtr client) GCPtr pGC; RegionPtr pRegion; XID vals[2]; + int rc; REQUEST(xXFixesSetGCClipRegionReq); - REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); + + rc = dixLookupGC(&pGC, stuff->gc, client, DixWriteAccess); + if (rc != Success) + return rc; + VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, DixReadAccess); if (pRegion) From 9e32bf98bc9ab17a137664d01f59a8f426f7ff3b Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 14 Dec 2006 19:31:58 -0500 Subject: [PATCH 096/109] Remove now-unused macro definitions from dix.h. --- include/dix.h | 101 -------------------------------------------------- 1 file changed, 101 deletions(-) diff --git a/include/dix.h b/include/dix.h index 7dd321f22..baff43f54 100644 --- a/include/dix.h +++ b/include/dix.h @@ -81,107 +81,6 @@ SOFTWARE. return(BadIDChoice);\ } -/* XXX if you are using this macro, you are probably not generating Match - * errors where appropriate */ -#define LOOKUP_DRAWABLE(did, client)\ - ((client->lastDrawableID == did) ? \ - client->lastDrawable : (DrawablePtr)LookupDrawable(did, client)) - -#ifdef XACE - -#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\ - {\ - pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \ - RC_DRAWABLE, mode);\ - if (!pDraw) \ - {\ - client->errorValue = did; \ - return BadDrawable;\ - }\ - if (pDraw->type == UNDRAWABLE_WINDOW)\ - return BadMatch;\ - } - -#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\ - {\ - pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \ - RC_DRAWABLE, mode);\ - if (!pDraw) \ - {\ - client->errorValue = did; \ - return BadDrawable;\ - }\ - } - -#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\ - pGC = (GC *) SecurityLookupIDByType(client, rid, RT_GC, mode);\ - if (!pGC)\ - {\ - client->errorValue = rid;\ - return (BadGC);\ - } - -#define VERIFY_DRAWABLE(pDraw, did, client)\ - SECURITY_VERIFY_DRAWABLE(pDraw, did, client, DixUnknownAccess) - -#define VERIFY_GEOMETRABLE(pDraw, did, client)\ - SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, DixUnknownAccess) - -#define VERIFY_GC(pGC, rid, client)\ - SECURITY_VERIFY_GC(pGC, rid, client, DixUnknownAccess) - -#else /* not XACE */ - -#define VERIFY_DRAWABLE(pDraw, did, client)\ - if (client->lastDrawableID == did)\ - pDraw = client->lastDrawable;\ - else \ - {\ - pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\ - if (!pDraw) \ - {\ - client->errorValue = did; \ - return BadDrawable;\ - }\ - if (pDraw->type == UNDRAWABLE_WINDOW)\ - return BadMatch;\ - } - -#define VERIFY_GEOMETRABLE(pDraw, did, client)\ - if (client->lastDrawableID == did)\ - pDraw = client->lastDrawable;\ - else \ - {\ - pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\ - if (!pDraw) \ - {\ - client->errorValue = did; \ - return BadDrawable;\ - }\ - } - -#define VERIFY_GC(pGC, rid, client)\ - if (client->lastGCID == rid)\ - pGC = client->lastGC;\ - else\ - pGC = (GC *)LookupIDByType(rid, RT_GC);\ - if (!pGC)\ - {\ - client->errorValue = rid;\ - return (BadGC);\ - } - -#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\ - VERIFY_DRAWABLE(pDraw, did, client) - -#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\ - VERIFY_GEOMETRABLE(pDraw, did, client) - -#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\ - VERIFY_GC(pGC, rid, client) - -#endif /* XACE */ - /* * We think that most hardware implementations of DBE will want * LookupID*(dbe_back_buffer_id) to return the window structure that the From d742025f435f3eb7458cf8284d59300bc9a850aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 12 Dec 2006 20:16:49 -0800 Subject: [PATCH 097/109] RandR mode list needs both output and crtc modes. When an output no longer reports the current mode, it must still be included in the list advertised by the X server. Walk the crtcs to ensure it is included. (cherry picked from 78689d0d6630afcbcd3ce5394d12c2564a489f45 commit) --- randr/rrmode.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/randr/rrmode.c b/randr/rrmode.c index a0696e170..261e1b75f 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -108,12 +108,15 @@ RRModePtr * RRModesForScreen (ScreenPtr pScreen, int *num_ret) { rrScrPriv(pScreen); - int o; + int o, c; RRModePtr *screen_modes; int num_screen_modes = 0; screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr)); + /* + * Add modes from all outputs + */ for (o = 0; o < pScrPriv->numOutputs; o++) { RROutputPtr output = pScrPriv->outputs[o]; @@ -129,6 +132,24 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret) screen_modes[num_screen_modes++] = mode; } } + /* + * Add modes from all crtcs. The goal is to + * make sure all available and active modes + * are visible to the client + */ + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + RRModePtr mode = crtc->mode; + int n; + + if (!mode) continue; + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } *num_ret = num_screen_modes; return screen_modes; } From 628c7daeb12713d28e85e6b49fa037a7748dff83 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 12 Dec 2006 22:59:03 -0800 Subject: [PATCH 098/109] RandR: config time updates when hardware config changes. The config time in the RandR protocol reflects when the hardware state has changed. It was getting changed anytime the driver changed the usage of the hardware as well. (cherry picked from 98d18a6578130adb411ca4bcc776fcb7e07f189f commit) --- randr/randr.c | 6 +++++- randr/randrstr.h | 12 +++++++++--- randr/rrcrtc.c | 4 ++-- randr/rrinfo.c | 2 ++ randr/rroutput.c | 20 +++++++++++--------- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 147df8c2c..1470035ca 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -415,7 +415,11 @@ RRTellChanged (ScreenPtr pScreen) if (pScrPriv->changed) { UpdateCurrentTime (); - pScrPriv->lastConfigTime = currentTime; + if (pScrPriv->configChanged) + { + pScrPriv->lastConfigTime = currentTime; + pScrPriv->configChanged = FALSE; + } pScrPriv->changed = FALSE; WalkTree (pScreen, TellChanged, (pointer) pScreen); for (i = 0; i < pScrPriv->numOutputs; i++) diff --git a/randr/randrstr.h b/randr/randrstr.h index 27ede9226..88f7588ae 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -216,11 +216,14 @@ typedef struct _rrScrPriv { TimeStamp lastSetTime; /* last changed by client */ TimeStamp lastConfigTime; /* possible configs changed */ RRCloseScreenProcPtr CloseScreen; + Bool changed; /* some config changed */ + Bool configChanged; /* configuration changed */ + Bool layoutChanged; /* screen layout changed */ + CARD16 minWidth, minHeight; CARD16 maxWidth, maxHeight; CARD16 width, height; /* last known screen size */ - Bool layoutChanged; /* screen layout changed */ int numOutputs; RROutputPtr *outputs; @@ -619,10 +622,13 @@ ProcRRDeleteOutputMode (ClientPtr client); /* rroutput.c */ /* - * Notify the output of some change + * Notify the output of some change. configChanged indicates whether + * any external configuration (mode list, clones, connected status) + * has changed, or whether the change was strictly internal + * (which crtc is in use) */ void -RROutputChanged (RROutputPtr output); +RROutputChanged (RROutputPtr output, Bool configChanged); /* * Create an output diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index d4c96f680..05863a129 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -136,7 +136,7 @@ RRCrtcNotify (RRCrtcPtr crtc, break; if (j == crtc->numOutputs) { - RROutputChanged (outputs[i]); + RROutputChanged (outputs[i], FALSE); RRCrtcChanged (crtc, FALSE); } } @@ -151,7 +151,7 @@ RRCrtcNotify (RRCrtcPtr crtc, break; if (i == numOutputs) { - RROutputChanged (crtc->outputs[j]); + RROutputChanged (crtc->outputs[j], FALSE); RRCrtcChanged (crtc, FALSE); } } diff --git a/randr/rrinfo.c b/randr/rrinfo.c index 244b089f3..85426f654 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -69,6 +69,7 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) output->modes = modes; output->changed = TRUE; pScrPriv->changed = TRUE; + pScrPriv->configChanged = TRUE; return mode; } @@ -205,6 +206,7 @@ RRGetInfo (ScreenPtr pScreen) rotations = 0; pScrPriv->changed = FALSE; + pScrPriv->configChanged = FALSE; if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) return FALSE; diff --git a/randr/rroutput.c b/randr/rroutput.c index 33c4ba534..a66433015 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -28,7 +28,7 @@ RESTYPE RROutputType; * Notify the output of some change */ void -RROutputChanged (RROutputPtr output) +RROutputChanged (RROutputPtr output, Bool configChanged) { ScreenPtr pScreen = output->pScreen; @@ -37,6 +37,8 @@ RROutputChanged (RROutputPtr output) { rrScrPriv (pScreen); pScrPriv->changed = TRUE; + if (configChanged) + pScrPriv->configChanged = TRUE; } } @@ -106,7 +108,7 @@ RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen) output->pScreen = pScreen; pScrPriv->outputs = outputs; pScrPriv->outputs[pScrPriv->numOutputs++] = output; - RROutputChanged (output); + RROutputChanged (output, FALSE); return TRUE; } @@ -142,7 +144,7 @@ RROutputSetClones (RROutputPtr output, memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); output->clones = newClones; output->numClones = numClones; - RROutputChanged (output); + RROutputChanged (output, TRUE); return TRUE; } @@ -186,7 +188,7 @@ RROutputSetModes (RROutputPtr output, output->modes = newModes; output->numModes = numModes; output->numPreferred = numPreferred; - RROutputChanged (output); + RROutputChanged (output, TRUE); return TRUE; } @@ -219,7 +221,7 @@ RROutputSetCrtcs (RROutputPtr output, memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; - RROutputChanged (output); + RROutputChanged (output, TRUE); return TRUE; } @@ -229,7 +231,7 @@ RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc) if (output->crtc == crtc) return; output->crtc = crtc; - RROutputChanged (output); + RROutputChanged (output, FALSE); } Bool @@ -239,7 +241,7 @@ RROutputSetConnection (RROutputPtr output, if (output->connection == connection) return TRUE; output->connection = connection; - RROutputChanged (output); + RROutputChanged (output, TRUE); return TRUE; } @@ -251,7 +253,7 @@ RROutputSetSubpixelOrder (RROutputPtr output, return TRUE; output->subpixelOrder = subpixelOrder; - RROutputChanged (output); + RROutputChanged (output, FALSE); return TRUE; } @@ -264,7 +266,7 @@ RROutputSetPhysicalSize (RROutputPtr output, return TRUE; output->mmWidth = mmWidth; output->mmHeight = mmHeight; - RROutputChanged (output); + RROutputChanged (output, FALSE); return TRUE; } From 6c6901434ab469dd03b79fc98cd4a2b64d339305 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 13 Dec 2006 00:58:54 -0800 Subject: [PATCH 099/109] RandR 1.0 refresh rates unscrambled. SetScreenConfig uses RRCrtcSet right. RandR 1.0 refresh rates were scrambled when working with a 1.2 driver that returned sizes in a mixed order. SetScreenConfig was treating RRCrtcSet as returning an RandR status instead of a Bool. (cherry picked from 6dc711833d7387372012fdff1ce1df3aefa2d234 commit) --- randr/rrscreen.c | 113 +++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 3b9263bc4..37b6a57d9 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -481,62 +481,81 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output) RR10DataPtr data; RRScreenSizePtr size; int nmode = output->numModes; - int i, j, k; + int o, os, l, r; RRScreenRatePtr refresh; CARD16 vRefresh; RRModePtr mode; + Bool *used; /* Make sure there is plenty of space for any combination */ data = malloc (sizeof (RR10DataRec) + sizeof (RRScreenSize) * nmode + - sizeof (RRScreenRate) * nmode); + sizeof (RRScreenRate) * nmode + + sizeof (Bool) * nmode); if (!data) return NULL; size = (RRScreenSizePtr) (data + 1); refresh = (RRScreenRatePtr) (size + nmode); + used = (Bool *) (refresh + nmode); + memset (used, '\0', sizeof (Bool) * nmode); data->sizes = size; data->nsize = 0; data->nrefresh = 0; data->size = 0; data->refresh = 0; - for (i = 0; i < output->numModes; i++) + + /* + * find modes not yet listed + */ + for (o = 0; o < output->numModes; o++) { - mode = output->modes[i]; - for (j = 0; j < data->nsize; j++) - if (mode->mode.width == size[j].width && - mode->mode.height == size[j].height) - break; - if (j == data->nsize) + if (used[o]) continue; + + mode = output->modes[o]; + + l = data->nsize; + size[l].id = data->nsize; + size[l].width = mode->mode.width; + size[l].height = mode->mode.height; + if (output->mmWidth && output->mmHeight) { + size[l].mmWidth = output->mmWidth; + size[l].mmHeight = output->mmHeight; + } else { + size[l].mmWidth = pScreen->mmWidth; + size[l].mmHeight = pScreen->mmHeight; + } + size[l].nRates = 0; + size[l].pRates = &refresh[data->nrefresh]; + data->nsize++; + + /* + * Find all modes with matching size + */ + for (os = o; os < output->numModes; os++) { - size[j].id = j; - size[j].width = mode->mode.width; - size[j].height = mode->mode.height; - if (output->mmWidth && output->mmHeight) { - size[j].mmWidth = output->mmWidth; - size[j].mmHeight = output->mmHeight; - } else { - size[j].mmWidth = pScreen->mmWidth; - size[j].mmHeight = pScreen->mmHeight; + mode = output->modes[os]; + if (mode->mode.width == size[l].width && + mode->mode.height == size[l].height) + { + vRefresh = RRVerticalRefresh (&mode->mode); + used[os] = TRUE; + + for (r = 0; r < size[l].nRates; r++) + if (vRefresh == size[l].pRates[r].rate) + break; + if (r == size[l].nRates) + { + size[l].pRates[r].rate = vRefresh; + size[l].pRates[r].mode = mode; + size[l].nRates++; + data->nrefresh++; + } + if (mode == output->crtc->mode) + { + data->size = l; + data->refresh = vRefresh; + } } - size[j].nRates = 0; - size[j].pRates = &refresh[data->nrefresh]; - data->nsize++; - } - vRefresh = RRVerticalRefresh (&mode->mode); - for (k = 0; k < size[j].nRates; k++) - if (vRefresh == size[j].pRates[k].rate) - break; - if (k == size[j].nRates) - { - size[j].pRates[k].rate = vRefresh; - size[j].pRates[k].mode = mode; - size[j].nRates++; - data->nrefresh++; - } - if (mode == output->crtc->mode) - { - data->size = j; - data->refresh = vRefresh; } } return data; @@ -865,22 +884,28 @@ ProcRRSetScreenConfig (ClientPtr client) for (c = 0; c < pScrPriv->numCrtcs; c++) { - rep.status = RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, - 0, NULL); - if (rep.status != Success) + if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, + 0, NULL)) + { + rep.status = RRSetConfigFailed; + /* XXX recover from failure */ goto sendReply; + } } if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height, pScreen->mmWidth, pScreen->mmHeight)) { rep.status = RRSetConfigFailed; + /* XXX recover from failure */ goto sendReply; } } - - rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, - 1, &output); - + + if (!RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, 1, &output)) + rep.status = RRSetConfigFailed; + else + rep.status = RRSetConfigSuccess; + /* * XXX Configure other crtcs to mirror as much as possible */ From 670bbb87310503fcc17203cecfa6f4f2f5db51d2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 13 Dec 2006 01:21:32 -0800 Subject: [PATCH 100/109] RandR 1.2 rotation code must adjust width/height. Mode lines reflect the monitor mode, not the projected size into the frame buffer. Flip width/height around so that the dimensions are oriented correctly. (cherry picked from 612a8e61803da8db0e305cbb093696b8e4284572 commit) --- randr/rrcrtc.c | 12 ++++++++++-- randr/rrscreen.c | 25 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 05863a129..076742077 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -698,7 +698,15 @@ ProcRRSetCrtcConfig (ClientPtr client) */ if (pScrPriv->rrScreenSetSize) { - if (stuff->x + mode->mode.width > pScreen->width) + int source_width = mode->mode.width; + int source_height = mode->mode.height; + + if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) + { + source_width = mode->mode.height; + source_height = mode->mode.width; + } + if (stuff->x + source_width > pScreen->width) { client->errorValue = stuff->x; if (outputs) @@ -706,7 +714,7 @@ ProcRRSetCrtcConfig (ClientPtr client) return BadValue; } - if (stuff->y + mode->mode.height > pScreen->height) + if (stuff->y + source_height > pScreen->height) { client->errorValue = stuff->y; if (outputs) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 37b6a57d9..f1d8fc5d9 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -268,7 +268,6 @@ ProcRRSetScreenSize (ClientPtr client) WindowPtr pWin; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; - RRCrtcPtr crtc; int i; REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); @@ -291,12 +290,26 @@ ProcRRSetScreenSize (ClientPtr client) client->errorValue = stuff->height; return BadValue; } - for (i = 0; i < pScrPriv->numCrtcs; i++) { - crtc = pScrPriv->crtcs[i]; - if (crtc->mode && - (crtc->x + crtc->mode->mode.width > stuff->width || - crtc->y + crtc->mode->mode.height > stuff->height)) + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + RRModePtr mode = crtc->mode; + if (mode) + { + int source_width = mode->mode.width; + int source_height = mode->mode.height; + Rotation rotation = crtc->rotation; + + if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) + { + source_width = mode->mode.height; + source_height = mode->mode.width; + } + + if (crtc->x + source_width > stuff->width || + crtc->y + source_height > stuff->height) return BadMatch; + } } if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) { From 04c721854fbf1bd6379c165a53fab2bdc09961c0 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 14:11:40 -0500 Subject: [PATCH 101/109] Convert callers of LookupWindow() to dixLookupWindow(). --- Xext/appgroup.c | 8 ++++-- Xext/mbuf.c | 31 ++++++++++---------- Xext/panoramiX.c | 27 ++++++++++-------- Xext/shape.c | 52 ++++++++++++++++++---------------- Xext/xtest.c | 19 ++++++------- Xext/xvdisp.c | 12 +++----- Xi/chgprop.c | 9 +++--- Xi/exevents.c | 22 +++++++------- Xi/getprop.c | 9 +++--- Xi/getselev.c | 8 +++--- Xi/selectev.c | 8 ++---- Xi/ungrdevb.c | 7 +++-- Xi/ungrdevk.c | 7 +++-- composite/compwindow.c | 6 ++-- hw/darwin/quartz/pseudoramiX.c | 27 ++++++++++-------- randr/rrxinerama.c | 21 ++++++++------ 16 files changed, 141 insertions(+), 132 deletions(-) diff --git a/Xext/appgroup.c b/Xext/appgroup.c index 4f3000569..134b172f9 100644 --- a/Xext/appgroup.c +++ b/Xext/appgroup.c @@ -355,13 +355,15 @@ int AttrValidate( AppGroupPtr pAppGrp) { WindowPtr pWin; - int idepth, ivids, found; + int idepth, ivids, found, rc; ScreenPtr pScreen; DepthPtr pDepth; ColormapPtr pColormap; - pWin = LookupWindow (pAppGrp->default_root, client); - /* XXX check that pWin is not NULL */ + rc = dixLookupWindow(&pWin, pAppGrp->default_root, client, + DixUnknownAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root) return BadWindow; diff --git a/Xext/mbuf.c b/Xext/mbuf.c index e0361dda4..43e2cc107 100644 --- a/Xext/mbuf.c +++ b/Xext/mbuf.c @@ -448,16 +448,15 @@ ProcCreateImageBuffers (client) register int n; WindowPtr pWin; XID *ids; - int len, nbuf; - int i; - int err; + int len, nbuf, i, err, rc; REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2); if (len == 0) return BadLength; - if (!(pWin = LookupWindow (stuff->window, client))) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; if (pWin->drawable.class == InputOnly) return BadMatch; switch (stuff->updateAction) @@ -584,10 +583,12 @@ ProcDestroyImageBuffers (client) { REQUEST (xMbufDestroyImageBuffersReq); WindowPtr pWin; + int rc; REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); - if (!(pWin = LookupWindow (stuff->window, client))) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; DestroyImageBuffers (pWin); return Success; } @@ -599,16 +600,16 @@ ProcSetMBufferAttributes (client) REQUEST (xMbufSetMBufferAttributesReq); WindowPtr pWin; MultibuffersPtr pMultibuffers; - int len; + int len, rc; Mask vmask; Mask index2; CARD32 updateHint; XID *vlist; REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadMatch; @@ -655,12 +656,12 @@ ProcGetMBufferAttributes (client) MultibuffersPtr pMultibuffers; XID *ids; xMbufGetMBufferAttributesReply rep; - int i, n; + int i, n, rc; REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadAccess; diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 6b8b5f2f7..85f591356 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -958,12 +958,13 @@ ProcPanoramiXGetState(ClientPtr client) REQUEST(xPanoramiXGetStateReq); WindowPtr pWin; xPanoramiXGetStateReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -984,12 +985,13 @@ ProcPanoramiXGetScreenCount(ClientPtr client) REQUEST(xPanoramiXGetScreenCountReq); WindowPtr pWin; xPanoramiXGetScreenCountReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -1009,12 +1011,13 @@ ProcPanoramiXGetScreenSize(ClientPtr client) REQUEST(xPanoramiXGetScreenSizeReq); WindowPtr pWin; xPanoramiXGetScreenSizeReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/shape.c b/Xext/shape.c index 4a798da7c..58e3a69b3 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -316,16 +316,16 @@ ProcShapeRectangles (client) ScreenPtr pScreen; REQUEST(xShapeRectanglesReq); xRectangle *prects; - int nrects, ctype; + int nrects, ctype, rc; RegionPtr srcRgn; RegionPtr *destRgn; CreateDftPtr createDefault; REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); UpdateCurrentTime(); - pWin = LookupWindow (stuff->dest, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess); + if (rc != Success) + return rc; switch (stuff->destKind) { case ShapeBounding: createDefault = CreateBoundingShape; @@ -526,12 +526,13 @@ ProcShapeCombine (client) CreateDftPtr createDefault; CreateDftPtr createSrc; RegionPtr tmp; + int rc; REQUEST_SIZE_MATCH (xShapeCombineReq); UpdateCurrentTime(); - pDestWin = LookupWindow (stuff->dest, client); - if (!pDestWin) - return BadWindow; + rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixUnknownAccess); + if (rc != Success) + return rc; if (!pDestWin->optional) MakeWindowOptional (pDestWin); switch (stuff->destKind) { @@ -550,9 +551,9 @@ ProcShapeCombine (client) } pScreen = pDestWin->drawable.pScreen; - pSrcWin = LookupWindow (stuff->src, client); - if (!pSrcWin) - return BadWindow; + rc = dixLookupWindow(&pSrcWin, stuff->src, client, DixUnknownAccess); + if (rc != Success) + return rc; switch (stuff->srcKind) { case ShapeBounding: srcRgn = wBoundingShape (pSrcWin); @@ -645,12 +646,13 @@ ProcShapeOffset (client) ScreenPtr pScreen; REQUEST(xShapeOffsetReq); RegionPtr srcRgn; + int rc; REQUEST_SIZE_MATCH (xShapeOffsetReq); UpdateCurrentTime(); - pWin = LookupWindow (stuff->dest, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess); + if (rc != Success) + return rc; switch (stuff->destKind) { case ShapeBounding: srcRgn = wBoundingShape (pWin); @@ -709,13 +711,13 @@ ProcShapeQueryExtents (client) WindowPtr pWin; xShapeQueryExtentsReply rep; BoxRec extents, *pExtents; - register int n; + register int n, rc; RegionPtr region; REQUEST_SIZE_MATCH (xShapeQueryExtentsReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -990,14 +992,14 @@ ProcShapeInputSelected (client) REQUEST(xShapeInputSelectedReq); WindowPtr pWin; ShapeEventPtr pShapeEvent, *pHead; - int enabled; + int enabled, rc; xShapeInputSelectedReply rep; register int n; REQUEST_SIZE_MATCH (xShapeInputSelectedReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; pHead = (ShapeEventPtr *) SecurityLookupIDByType(client, pWin->drawable.id, EventType, DixReadAccess); enabled = xFalse; @@ -1032,14 +1034,14 @@ ProcShapeGetRectangles (client) WindowPtr pWin; xShapeGetRectanglesReply rep; xRectangle *rects; - int nrects, i; + int nrects, i, rc; RegionPtr region; register int n; REQUEST_SIZE_MATCH(xShapeGetRectanglesReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; switch (stuff->kind) { case ShapeBounding: region = wBoundingShape(pWin); diff --git a/Xext/xtest.c b/Xext/xtest.c index 83f8b8cc6..c9b511e69 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -139,12 +139,12 @@ ProcXTestCompareCursor(client) xXTestCompareCursorReply rep; WindowPtr pWin; CursorPtr pCursor; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xXTestCompareCursorReq); - pWin = (WindowPtr)LookupWindow(stuff->window, client); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; if (stuff->cursor == None) pCursor = NullCursor; else if (stuff->cursor == XTestCurrentCursor) @@ -173,12 +173,10 @@ ProcXTestFakeInput(client) register ClientPtr client; { REQUEST(xXTestFakeInputReq); - int nev; - int n; + int nev, n, type, rc; xEvent *ev; DeviceIntPtr dev = NULL; WindowPtr root; - int type; #ifdef XINPUT Bool extension = FALSE; deviceValuator *dv = NULL; @@ -367,9 +365,10 @@ ProcXTestFakeInput(client) root = GetCurrentRootWindow(); else { - root = LookupWindow(ev->u.keyButtonPointer.root, client); - if (!root) - return BadWindow; + rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, client, + DixUnknownAccess); + if (rc != Success) + return rc; if (root->parent) { client->errorValue = ev->u.keyButtonPointer.root; diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 2afb7c687..21d00aa7f 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -373,10 +373,8 @@ ProcXvQueryAdaptors(ClientPtr client) xvFormat format; xvAdaptorInfo ainfo; xvQueryAdaptorsReply rep; - int totalSize; - int na; + int totalSize, na, nf, rc; XvAdaptorPtr pa; - int nf; XvFormatPtr pf; WindowPtr pWin; ScreenPtr pScreen; @@ -385,11 +383,9 @@ ProcXvQueryAdaptors(ClientPtr client) REQUEST(xvQueryAdaptorsReq); REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) )) - { - client->errorValue = stuff->window; - return (BadWindow); - } + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; diff --git a/Xi/chgprop.c b/Xi/chgprop.c index 52c38838d..bab4597b8 100644 --- a/Xi/chgprop.c +++ b/Xi/chgprop.c @@ -106,7 +106,7 @@ SProcXChangeDeviceDontPropagateList(register ClientPtr client) int ProcXChangeDeviceDontPropagateList(register ClientPtr client) { - int i; + int i, rc; WindowPtr pWin; struct tmask tmp[EMASKSIZE]; OtherInputMasks *others; @@ -121,11 +121,10 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client) return Success; } - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/exevents.c b/Xi/exevents.c index 92a5f0599..b7645f443 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -505,6 +505,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin, confineTo; CursorPtr cursor; GrabPtr grab; + int rc; if ((this_device_mode != GrabModeSync) && (this_device_mode != GrabModeAsync)) { @@ -524,15 +525,15 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; if (rconfineTo == None) confineTo = NullWindow; else { - confineTo = LookupWindow(rconfineTo, client); - if (!confineTo) - return BadWindow; + rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess); + if (rc != Success) + return rc; } if (rcursor == None) cursor = NullCursor; @@ -562,6 +563,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin; GrabPtr grab; KeyClassPtr k = dev->key; + int rc; if (k == NULL) return BadMatch; @@ -588,9 +590,9 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; grab = CreateGrab(client->index, dev, pWin, mask, ownerEvents, this_device_mode, other_devices_mode, @@ -810,7 +812,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, } else effectiveFocus = pWin = inputFocus; } else - pWin = LookupWindow(dest, client); + dixLookupWindow(&pWin, dest, client, DixUnknownAccess); if (!pWin) return BadWindow; if ((propagate != xFalse) && (propagate != xTrue)) { diff --git a/Xi/getprop.c b/Xi/getprop.c index 530841032..058c59514 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -100,7 +100,7 @@ int ProcXGetDeviceDontPropagateList(register ClientPtr client) { CARD16 count = 0; - int i; + int i, rc; XEventClass *buf = NULL, *tbuf; WindowPtr pWin; xGetDeviceDontPropagateListReply rep; @@ -115,11 +115,10 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client) rep.length = 0; rep.count = 0; - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/getselev.c b/Xi/getselev.c index a84c33d23..533c66cd7 100644 --- a/Xi/getselev.c +++ b/Xi/getselev.c @@ -98,8 +98,7 @@ SProcXGetSelectedExtensionEvents(register ClientPtr client) int ProcXGetSelectedExtensionEvents(register ClientPtr client) { - int i; - int total_length = 0; + int i, rc, total_length = 0; xGetSelectedExtensionEventsReply rep; WindowPtr pWin; XEventClass *buf = NULL; @@ -118,9 +117,10 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client) rep.this_client_count = 0; rep.all_clients_count = 0; - if (!(pWin = LookupWindow(stuff->window, client))) { + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/selectev.c b/Xi/selectev.c index 7d3ef9d48..8c893ca1e 100644 --- a/Xi/selectev.c +++ b/Xi/selectev.c @@ -170,11 +170,9 @@ ProcXSelectExtensionEvent(register ClientPtr client) return Success; } - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; - SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, - BadWindow); + ret = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (ret != Success) { + SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, ret); return Success; } diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c index 64bb213f5..8db9307ce 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -105,6 +105,7 @@ ProcXUngrabDeviceButton(ClientPtr client) DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; + int rc; REQUEST(xUngrabDeviceButtonReq); REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq); @@ -134,9 +135,9 @@ ProcXUngrabDeviceButton(ClientPtr client) } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); - pWin = LookupWindow(stuff->grabWindow, client); - if (!pWin) { - SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadWindow); + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc); return Success; } diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index 0a6b3b619..ebb83bce7 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -105,6 +105,7 @@ ProcXUngrabDeviceKey(ClientPtr client) DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; + int rc; REQUEST(xUngrabDeviceKeyReq); REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq); @@ -133,9 +134,9 @@ ProcXUngrabDeviceKey(ClientPtr client) } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); - pWin = LookupWindow(stuff->grabWindow, client); - if (!pWin) { - SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow); + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, rc); return Success; } if (((stuff->key > dev->key->curKeySyms.maxKeyCode) || diff --git a/composite/compwindow.c b/composite/compwindow.c index 2c86cdd95..fed642ec6 100644 --- a/composite/compwindow.c +++ b/composite/compwindow.c @@ -93,10 +93,10 @@ typedef struct _compPixmapVisit { static Bool compRepaintBorder (ClientPtr pClient, pointer closure) { - WindowPtr pWindow = LookupWindow ((XID) closure, pClient); + WindowPtr pWindow; + int rc = dixLookupWindow(&pWindow, (XID)closure, pClient,DixUnknownAccess); - if (pWindow) - { + if (rc == Success) { RegionRec exposed; REGION_NULL(pScreen, &exposed); diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index ab57827d3..a003daf43 100644 --- a/hw/darwin/quartz/pseudoramiX.c +++ b/hw/darwin/quartz/pseudoramiX.c @@ -170,12 +170,13 @@ static int ProcPseudoramiXGetState(ClientPtr client) REQUEST(xPanoramiXGetStateReq); WindowPtr pWin; xPanoramiXGetStateReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -196,12 +197,13 @@ static int ProcPseudoramiXGetScreenCount(ClientPtr client) REQUEST(xPanoramiXGetScreenCountReq); WindowPtr pWin; xPanoramiXGetScreenCountReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -222,12 +224,13 @@ static int ProcPseudoramiXGetScreenSize(ClientPtr client) REQUEST(xPanoramiXGetScreenSizeReq); WindowPtr pWin; xPanoramiXGetScreenSizeReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); - pWin = LookupWindow (stuff->window, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c index 771ed0976..8b951455c 100644 --- a/randr/rrxinerama.c +++ b/randr/rrxinerama.c @@ -116,14 +116,15 @@ ProcRRXineramaGetState(ClientPtr client) REQUEST(xPanoramiXGetStateReq); WindowPtr pWin; xPanoramiXGetStateReply rep; - register int n; + register int n, rc; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; Bool active = FALSE; REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - pWin = LookupWindow(stuff->window, client); - if(!pWin) return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if(rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -180,11 +181,12 @@ ProcRRXineramaGetScreenCount(ClientPtr client) REQUEST(xPanoramiXGetScreenCountReq); WindowPtr pWin; xPanoramiXGetScreenCountReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); - pWin = LookupWindow(stuff->window, client); - if(!pWin) return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; rep.type = X_Reply; rep.length = 0; @@ -206,11 +208,12 @@ ProcRRXineramaGetScreenSize(ClientPtr client) WindowPtr pWin, pRoot; ScreenPtr pScreen; xPanoramiXGetScreenSizeReply rep; - register int n; + register int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); - pWin = LookupWindow (stuff->window, client); - if(!pWin) return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pRoot = WindowTable[pScreen->myNum]; From 25d5e0a629f82d95bd71daf9a920a70e095b5188 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 15:50:46 -0500 Subject: [PATCH 102/109] Convert callers of SecurityLookupWindow() to dixLookupWindow(). --- Xext/panoramiXprocs.c | 18 ++- Xext/shape.c | 14 ++- Xext/xprint.c | 7 +- dbe/dbe.c | 16 ++- dix/devices.c | 8 +- dix/dispatch.c | 214 ++++++++++++++++----------------- dix/events.c | 117 +++++++++--------- dix/property.c | 45 +++---- hw/darwin/quartz/applewm.c | 12 +- hw/dmx/dmx.c | 14 +-- hw/dmx/glxProxy/glxcmds.c | 23 ++-- hw/xwin/winclipboardwrappers.c | 8 +- hw/xwin/winwindowswm.c | 19 ++- randr/rrdispatch.c | 7 +- randr/rrscreen.c | 40 +++--- xfixes/cursor.c | 8 +- xfixes/saveset.c | 7 +- xfixes/select.c | 8 +- 18 files changed, 273 insertions(+), 312 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index a193c4188..1c53a1e1a 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -577,19 +577,17 @@ int PanoramiXTranslateCoords(ClientPtr client) { INT16 x, y; REQUEST(xTranslateCoordsReq); - - register WindowPtr pWin, pDst; + int rc; + WindowPtr pWin, pDst; xTranslateCoordsReply rep; REQUEST_SIZE_MATCH(xTranslateCoordsReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, - DixReadAccess); - if (!pWin) - return(BadWindow); - pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, - DixReadAccess); - if (!pDst) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); + if (rc != Success) + return rc; + rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); + if (rc != Success) + return rc; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/shape.c b/Xext/shape.c index 58e3a69b3..928eeee31 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -419,12 +419,13 @@ ProcShapeMask (client) RegionPtr *destRgn; PixmapPtr pPixmap; CreateDftPtr createDefault; + int rc; REQUEST_SIZE_MATCH (xShapeMaskReq); UpdateCurrentTime(); - pWin = SecurityLookupWindow (stuff->dest, client, DixWriteAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->dest, client, DixWriteAccess); + if (rc != Success) + return rc; switch (stuff->destKind) { case ShapeBounding: createDefault = CreateBoundingShape; @@ -822,11 +823,12 @@ ProcShapeSelectInput (client) WindowPtr pWin; ShapeEventPtr pShapeEvent, pNewShapeEvent, *pHead; XID clientResource; + int rc; REQUEST_SIZE_MATCH (xShapeSelectInputReq); - pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; pHead = (ShapeEventPtr *)SecurityLookupIDByType(client, pWin->drawable.id, EventType, DixWriteAccess); switch (stuff->enable) { diff --git a/Xext/xprint.c b/Xext/xprint.c index 669ad277d..d8fc51713 100644 --- a/Xext/xprint.c +++ b/Xext/xprint.c @@ -1852,9 +1852,10 @@ ProcXpStartPage(ClientPtr client) if(pContext->state & PAGE_STARTED) return XpErrorBase+XPBadSequence; - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum) + result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (result != Success) + return result; + if (pWin->drawable.pScreen->myNum != pContext->screenNum) return BadWindow; if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL) diff --git a/dbe/dbe.c b/dbe/dbe.c index 649143cf2..69ddf4f1c 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -405,11 +405,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client) REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq); /* The window must be valid. */ - if (!(pWin = SecurityLookupWindow(stuff->window, client, - DixWriteAccess))) - { - return(BadWindow); - } + status = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (status != Success) + return status; /* The window must be InputOutput. */ if (pWin->drawable.class != InputOutput) @@ -729,11 +727,11 @@ ProcDbeSwapBuffers(ClientPtr client) /* Check all windows to swap. */ /* Each window must be a valid window - BadWindow. */ - if (!(pWin = SecurityLookupWindow(dbeSwapInfo[i].window, client, - DixWriteAccess))) - { + error = dixLookupWindow(&pWin, dbeSwapInfo[i].window, client, + DixWriteAccess); + if (error != Success) { DEALLOCATE_LOCAL(swapInfo); - return(BadWindow); + return error; } /* Each window must be double-buffered - BadMatch. */ diff --git a/dix/devices.c b/dix/devices.c index e6a504954..9f4218414 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1840,16 +1840,16 @@ ProcGetMotionEvents(ClientPtr client) WindowPtr pWin; xTimecoord * coords = (xTimecoord *) NULL; xGetMotionEventsReply rep; - int i, count, xmin, xmax, ymin, ymax; + int i, count, xmin, xmax, ymin, ymax, rc; unsigned long nEvents; DeviceIntPtr mouse = inputInfo.pointer; TimeStamp start, stop; REQUEST(xGetMotionEventsReq); REQUEST_SIZE_MATCH(xGetMotionEventsReq); - pWin = SecurityLookupWindow(stuff->window, client, TRUE); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) + return rc; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); rep.type = X_Reply; diff --git a/dix/dispatch.c b/dix/dispatch.c index 0421886a0..3060a4c39 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -554,17 +554,16 @@ ProcBadRequest(ClientPtr client) int ProcCreateWindow(ClientPtr client) { - register WindowPtr pParent, pWin; + WindowPtr pParent, pWin; REQUEST(xCreateWindowReq); - int result; - int len; + int result, len, rc; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); LEGAL_NEW_RESOURCE(stuff->wid, client); - if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - DixWriteAccess))) - return BadWindow; + rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess); + if (rc != Success) + return rc; len = client->req_len - (sizeof(xCreateWindowReq) >> 2); if (Ones(stuff->mask) != len) return BadLength; @@ -597,16 +596,15 @@ ProcCreateWindow(ClientPtr client) int ProcChangeWindowAttributes(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xChangeWindowAttributesReq); register int result; - int len; + int len, rc; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); if (len != Ones(stuff->valueMask)) return BadLength; @@ -623,15 +621,15 @@ ProcChangeWindowAttributes(register ClientPtr client) int ProcGetWindowAttributes(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); xGetWindowAttributesReply wa; + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return(client->noClientException); @@ -640,14 +638,14 @@ ProcGetWindowAttributes(register ClientPtr client) int ProcDestroyWindow(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixDestroyAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess); + if (rc != Success) + return rc; if (pWin->parent) FreeResource(stuff->id, RT_NONE); return(client->noClientException); @@ -656,14 +654,14 @@ ProcDestroyWindow(register ClientPtr client) int ProcDestroySubwindows(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixDestroyAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess); + if (rc != Success) + return rc; DestroySubwindows(pWin, client); return(client->noClientException); } @@ -671,15 +669,14 @@ ProcDestroySubwindows(register ClientPtr client) int ProcChangeSaveSet(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xChangeSaveSetReq); - register int result; + register int result, rc; REQUEST_SIZE_MATCH(xChangeSaveSetReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) return BadMatch; if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) @@ -700,19 +697,17 @@ ProcChangeSaveSet(register ClientPtr client) int ProcReparentWindow(register ClientPtr client) { - register WindowPtr pWin, pParent; + WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); - register int result; + register int result, rc; REQUEST_SIZE_MATCH(xReparentWindowReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); - pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - DixWriteAccess); - if (!pParent) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; + rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess); + if (rc != Success) + return rc; if (SAME_SCREENS(pWin->drawable, pParent->drawable)) { if ((pWin->backgroundState == ParentRelative) && @@ -735,14 +730,14 @@ ProcReparentWindow(register ClientPtr client) int ProcMapWindow(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; MapWindow(pWin, client); /* update cache to say it is mapped */ return(client->noClientException); @@ -751,14 +746,14 @@ ProcMapWindow(register ClientPtr client) int ProcMapSubwindows(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; MapSubwindows(pWin, client); /* update cache to say it is mapped */ return(client->noClientException); @@ -767,14 +762,14 @@ ProcMapSubwindows(register ClientPtr client) int ProcUnmapWindow(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; UnmapWindow(pWin, FALSE); /* update cache to say it is mapped */ return(client->noClientException); @@ -783,14 +778,14 @@ ProcUnmapWindow(register ClientPtr client) int ProcUnmapSubwindows(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; UnmapSubwindows(pWin); return(client->noClientException); } @@ -798,16 +793,15 @@ ProcUnmapSubwindows(register ClientPtr client) int ProcConfigureWindow(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xConfigureWindowReq); register int result; - int len; + int len, rc; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); if (Ones((Mask)stuff->mask) != len) return BadLength; @@ -822,8 +816,9 @@ ProcConfigureWindow(register ClientPtr client) int ProcCirculateWindow(register ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xCirculateWindowReq); + int rc; REQUEST_SIZE_MATCH(xCirculateWindowReq); if ((stuff->direction != RaiseLowest) && @@ -832,10 +827,9 @@ ProcCirculateWindow(register ClientPtr client) client->errorValue = stuff->direction; return BadValue; } - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; CirculateWindow(pWin, (int)stuff->direction, client); return(client->noClientException); } @@ -903,16 +897,15 @@ int ProcQueryTree(register ClientPtr client) { xQueryTreeReply reply; - int numChildren = 0; - register WindowPtr pChild, pWin, pHead; + int rc, numChildren = 0; + WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *)NULL; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; reply.type = X_Reply; reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; reply.sequenceNumber = client->sequence; @@ -1025,10 +1018,9 @@ ProcSetSelectionOwner(register ClientPtr client) return Success; if (stuff->window != None) { - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + int rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; } else pWin = (WindowPtr)None; @@ -1142,12 +1134,12 @@ ProcConvertSelection(register ClientPtr client) xEvent event; WindowPtr pWin; REQUEST(xConvertSelectionReq); + int rc; REQUEST_SIZE_MATCH(xConvertSelectionReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->requestor, client, DixReadAccess); + if (rc != Success) + return rc; paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target)); if (stuff->property != None) @@ -1262,18 +1254,17 @@ ProcTranslateCoords(register ClientPtr client) { REQUEST(xTranslateCoordsReq); - register WindowPtr pWin, pDst; + WindowPtr pWin, pDst; xTranslateCoordsReply rep; + int rc; REQUEST_SIZE_MATCH(xTranslateCoordsReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, - DixReadAccess); - if (!pWin) - return(BadWindow); - pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, - DixReadAccess); - if (!pDst) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); + if (rc != Success) + return rc; + rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); + if (rc != Success) + return rc; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -1762,13 +1753,13 @@ int ProcClearToBackground(register ClientPtr client) { REQUEST(xClearAreaReq); - register WindowPtr pWin; + WindowPtr pWin; + int rc; REQUEST_SIZE_MATCH(xClearAreaReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; if (pWin->drawable.class == InputOnly) { client->errorValue = stuff->window; @@ -2496,7 +2487,7 @@ ProcCreateColormap(register ClientPtr client) VisualPtr pVisual; ColormapPtr pmap; Colormap mid; - register WindowPtr pWin; + WindowPtr pWin; ScreenPtr pScreen; REQUEST(xCreateColormapReq); int i, result; @@ -2510,10 +2501,9 @@ ProcCreateColormap(register ClientPtr client) } mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (result != Success) + return result; pScreen = pWin->drawable.pScreen; for (i = 0, pVisual = pScreen->visuals; @@ -2631,16 +2621,14 @@ int ProcListInstalledColormaps(register ClientPtr client) { xListInstalledColormapsReply *preply; - int nummaps; + int nummaps, rc; WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixReadAccess); - - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; preply = (xListInstalledColormapsReply *) ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) + diff --git a/dix/events.c b/dix/events.c index c7cf73e46..0053f42d4 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2228,16 +2228,15 @@ static int XineramaWarpPointer(ClientPtr client) { WindowPtr dest = NULL; - int x, y; + int x, y, rc; REQUEST(xWarpPointerReq); - if (stuff->dstWid != None) - { - dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); - if (!dest) - return BadWindow; + if (stuff->dstWid != None) { + rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess); + if (rc != Success) + return rc; } x = sprite.hotPhys.x; y = sprite.hotPhys.y; @@ -2248,8 +2247,9 @@ XineramaWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, DixReadAccess); - if (!source) return BadWindow; + rc = dixLookupWindow(&source, winID, client, DixReadAccess); + if (rc != Success) + return rc; winX = source->drawable.x; winY = source->drawable.y; @@ -2301,7 +2301,7 @@ int ProcWarpPointer(ClientPtr client) { WindowPtr dest = NULL; - int x, y; + int x, y, rc; ScreenPtr newScreen; REQUEST(xWarpPointerReq); @@ -2313,11 +2313,10 @@ ProcWarpPointer(ClientPtr client) return XineramaWarpPointer(client); #endif - if (stuff->dstWid != None) - { - dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); - if (!dest) - return BadWindow; + if (stuff->dstWid != None) { + rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess); + if (rc != Success) + return rc; } x = sprite.hotPhys.x; y = sprite.hotPhys.y; @@ -2328,8 +2327,9 @@ ProcWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, DixReadAccess); - if (!source) return BadWindow; + rc = dixLookupWindow(&source, winID, client, DixReadAccess); + if (rc != Success) + return rc; winX = source->drawable.x; winY = source->drawable.y; @@ -3532,8 +3532,8 @@ SetInputFocus( Bool followOK) { register FocusClassPtr focus; - register WindowPtr focusWin; - int mode; + WindowPtr focusWin; + int mode, rc; TimeStamp time; UpdateCurrentTime(); @@ -3550,14 +3550,12 @@ SetInputFocus( focusWin = (WindowPtr)(long)focusID; else if ((focusID == FollowKeyboard) && followOK) focusWin = inputInfo.keyboard->focus->win; - else if (!(focusWin = SecurityLookupWindow(focusID, client, - DixReadAccess))) - return BadWindow; - else - { + else { + rc = dixLookupWindow(&focusWin, focusID, client, DixReadAccess); + if (rc != Success) + return rc; /* It is a match error to try to set the input focus to an unviewable window. */ - if(!focusWin->realized) return(BadMatch); } @@ -3646,6 +3644,7 @@ ProcGrabPointer(ClientPtr client) CursorPtr cursor, oldCursor; REQUEST(xGrabPointerReq); TimeStamp time; + int rc; REQUEST_SIZE_MATCH(xGrabPointerReq); UpdateCurrentTime(); @@ -3671,17 +3670,17 @@ ProcGrabPointer(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; if (stuff->confineTo == None) confineTo = NullWindow; else { - confineTo = SecurityLookupWindow(stuff->confineTo, client, - DixReadAccess); - if (!confineTo) - return BadWindow; + rc = dixLookupWindow(&confineTo, stuff->confineTo, client, + DixReadAccess); + if (rc != Success) + return rc; } if (stuff->cursor == None) cursor = NullCursor; @@ -3812,9 +3811,10 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev, unsigned this_mode, unsigned other_mode, Window grabWindow, unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status) { - register WindowPtr pWin; + WindowPtr pWin; register GrabPtr grab; TimeStamp time; + int rc; UpdateCurrentTime(); if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync)) @@ -3832,9 +3832,9 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev, client->errorValue = ownerEvents; return BadValue; } - pWin = SecurityLookupWindow(grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; time = ClientTimeToServerTime(ctime); grab = dev->grab; if (grab && !SameClient(grab, client)) @@ -3918,11 +3918,12 @@ ProcQueryPointer(ClientPtr client) WindowPtr pWin, t; REQUEST(xResourceReq); DeviceIntPtr mouse = inputInfo.pointer; + int rc; REQUEST_SIZE_MATCH(xResourceReq); - pWin = SecurityLookupWindow(stuff->id, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); rep.type = X_Reply; @@ -4086,8 +4087,8 @@ ProcSendEvent(ClientPtr client) effectiveFocus = pWin = inputFocus; } else - pWin = SecurityLookupWindow(stuff->destination, client, - DixReadAccess); + dixLookupWindow(&pWin, stuff->destination, client, DixReadAccess); + if (!pWin) return BadWindow; if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) @@ -4123,11 +4124,12 @@ ProcUngrabKey(ClientPtr client) WindowPtr pWin; GrabRec tempGrab; DeviceIntPtr keybd = inputInfo.keyboard; + int rc; REQUEST_SIZE_MATCH(xUngrabKeyReq); - pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) || (stuff->key < keybd->key->curKeySyms.minKeyCode)) @@ -4164,6 +4166,7 @@ ProcGrabKey(ClientPtr client) REQUEST(xGrabKeyReq); GrabPtr grab; DeviceIntPtr keybd = inputInfo.keyboard; + int rc; REQUEST_SIZE_MATCH(xGrabKeyReq); if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse)) @@ -4196,9 +4199,9 @@ ProcGrabKey(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; grab = CreateGrab(client->index, keybd, pWin, (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents, @@ -4218,6 +4221,7 @@ ProcGrabButton(ClientPtr client) REQUEST(xGrabButtonReq); CursorPtr cursor; GrabPtr grab; + int rc; REQUEST_SIZE_MATCH(xGrabButtonReq); if ((stuff->pointerMode != GrabModeSync) && @@ -4248,16 +4252,16 @@ ProcGrabButton(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; if (stuff->confineTo == None) confineTo = NullWindow; else { - confineTo = SecurityLookupWindow(stuff->confineTo, client, - DixReadAccess); - if (!confineTo) - return BadWindow; + rc = dixLookupWindow(&confineTo, stuff->confineTo, client, + DixReadAccess); + if (rc != Success) + return rc; } if (stuff->cursor == None) cursor = NullCursor; @@ -4289,6 +4293,7 @@ ProcUngrabButton(ClientPtr client) REQUEST(xUngrabButtonReq); WindowPtr pWin; GrabRec tempGrab; + int rc; REQUEST_SIZE_MATCH(xUngrabButtonReq); if ((stuff->modifiers != AnyModifier) && @@ -4297,9 +4302,9 @@ ProcUngrabButton(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); + if (rc != Success) + return rc; tempGrab.resource = client->clientAsMask; tempGrab.device = inputInfo.pointer; tempGrab.window = pWin; diff --git a/dix/property.c b/dix/property.c index 5c1e957a5..d40284901 100644 --- a/dix/property.c +++ b/dix/property.c @@ -94,7 +94,7 @@ PrintPropertys(WindowPtr pWin) int ProcRotateProperties(ClientPtr client) { - int i, j, delta; + int i, j, delta, rc; REQUEST(xRotatePropertiesReq); WindowPtr pWin; register Atom * atoms; @@ -104,10 +104,9 @@ ProcRotateProperties(ClientPtr client) REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2); UpdateCurrentTime(); - pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; if (!stuff->nAtoms) return(Success); atoms = (Atom *) & stuff[1]; @@ -181,9 +180,7 @@ ProcChangeProperty(ClientPtr client) WindowPtr pWin; char format, mode; unsigned long len; - int sizeInBytes; - int totalSize; - int err; + int sizeInBytes, totalSize, err; REQUEST(xChangePropertyReq); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); @@ -208,10 +205,9 @@ ProcChangeProperty(ClientPtr client) totalSize = len * sizeInBytes; REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + err = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (err != Success) + return err; if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; @@ -445,7 +441,7 @@ int ProcGetProperty(ClientPtr client) { PropertyPtr pProp, prevProp; - unsigned long n, len, ind; + unsigned long n, len, ind, rc; WindowPtr pWin; xGetPropertyReply reply; Mask access_mode = DixReadAccess; @@ -454,10 +450,9 @@ ProcGetProperty(ClientPtr client) REQUEST_SIZE_MATCH(xGetPropertyReq); if (stuff->delete) UpdateCurrentTime(); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; if (!ValidAtom(stuff->property)) { @@ -585,16 +580,15 @@ ProcListProperties(ClientPtr client) { Atom *pAtoms = NULL, *temppAtoms; xListPropertiesReply xlpr; - int numProps = 0; + int rc, numProps = 0; WindowPtr pWin; PropertyPtr pProp; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess); + if (rc != Success) + return rc; pProp = wUserProps (pWin); while (pProp) @@ -636,10 +630,9 @@ ProcDeleteProperty(register ClientPtr client) REQUEST_SIZE_MATCH(xDeletePropertyReq); UpdateCurrentTime(); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixWriteAccess); - if (!pWin) - return(BadWindow); + result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (result != Success) + return result; if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c index a9d8b5659..224d6c5e0 100644 --- a/hw/darwin/quartz/applewm.c +++ b/hw/darwin/quartz/applewm.c @@ -490,11 +490,9 @@ ProcAppleWMSetWindowLevel( REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq); - if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, DixReadAccess))) - { + if (Success != dixLookupWindow(&pWin, stuff->window, client, + DixReadAccess)) return BadValue; - } if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) { return BadValue; @@ -602,11 +600,9 @@ ProcAppleWMFrameDraw( REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq); - if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, DixReadAccess))) - { + if (Success != dixLookupWindow(&pWin, stuff->window, client, + DixReadAccess)) return BadValue; - } ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih); or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh); diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c index 02e8b1e7c..b7c81ee57 100644 --- a/hw/dmx/dmx.c +++ b/hw/dmx/dmx.c @@ -286,8 +286,8 @@ static int ProcDMXForceWindowCreation(ClientPtr client) return -1; /* BadWindow */ FOR_NSCREENS(i) { - if (!(pWin = SecurityLookupWindow(win->info[i].id, client, - DixReadAccess))) + if (Success != dixLookupWindow(&pWin, win->info[i].id, client, + DixReadAccess)) return -1; /* BadWindow */ dmxForceWindowCreation(pWin); @@ -296,8 +296,8 @@ static int ProcDMXForceWindowCreation(ClientPtr client) } #endif - if (!(pWin = SecurityLookupWindow(stuff->window, client, - DixReadAccess))) + if (Success != dixLookupWindow(&pWin, stuff->window, client, + DixReadAccess)) return -1; /* BadWindow */ dmxForceWindowCreation(pWin); @@ -560,8 +560,8 @@ static int dmxPopulatePanoramiX(ClientPtr client, Window window, return -1; /* BadWindow */ FOR_NSCREENS(i) { - if (!(pWin = SecurityLookupWindow(win->info[i].id, client, - DixReadAccess))) + if (Success != dixLookupWindow(&pWin, win->info[i].id, client, + DixReadAccess)) return -1; /* BadWindow */ if (dmxGetWindowAttributes(pWin, &attr)) { screens[count] = attr.screen; @@ -587,7 +587,7 @@ static int dmxPopulate(ClientPtr client, Window window, CARD32 *screens, pos, vis); #endif - if (!(pWin = SecurityLookupWindow(window, client, DixReadAccess))) + if (Success != dixLookupWindow(&pWin, window, client, DixReadAccess)) return -1; /* BadWindow */ dmxGetWindowAttributes(pWin, &attr); diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c index 20a02a173..aa9d8318c 100644 --- a/hw/dmx/glxProxy/glxcmds.c +++ b/hw/dmx/glxProxy/glxcmds.c @@ -1137,9 +1137,7 @@ static int MakeCurrent(__GLXclientState *cl, } #ifdef PANORAMIX else if (pXinDraw) { - pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id, - client, - DixReadAccess); + dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess); } #endif else if (pGlxWindow) { @@ -1195,9 +1193,8 @@ static int MakeCurrent(__GLXclientState *cl, } #ifdef PANORAMIX else if (pXinReadDraw) { - pReadWin = (WindowPtr)SecurityLookupWindow(pXinReadDraw->info[s].id, - client, - DixReadAccess); + dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client, + DixReadAccess); } #endif else if (pGlxReadWindow) { @@ -2058,9 +2055,7 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag) } #ifdef PANORAMIX else if (pXinDraw) { - pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id, - client, - DixReadAccess); + dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess); } #endif else if (pGlxWindow) { @@ -3359,9 +3354,8 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) return __glXBadDrawable; } - pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id, - client, - DixReadAccess); + dixLookupWindow(&pWin, pXinDraw->info[screen].id, client, + DixReadAccess); } #endif @@ -3521,9 +3515,8 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) return __glXBadDrawable; } - pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id, - client, - DixReadAccess); + dixLookupWindow(&pWin, pXinDraw->info[screen].id, client, + DixReadAccess); } #endif diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index e9bcea9a8..825d3dc70 100755 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -344,13 +344,11 @@ winProcSetSelectionOwner (ClientPtr client) if (None != stuff->window) { /* Grab the Window from the request */ - pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client, - DixReadAccess); - if (!pWindow) - { + int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess); + if (rc != Success) { ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n"); goto winProcSetSelectionOwner_Done; - } + } } /* Now we either have a valid window or None */ diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index ac92e26df..e1994de84 100755 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -441,7 +441,7 @@ ProcWindowsWMFrameDraw (register ClientPtr client) WindowPtr pWin; win32RootlessWindowPtr pRLWinPriv; RECT rcNew; - int nCmdShow; + int nCmdShow, rc; RegionRec newShape; ScreenPtr pScreen; @@ -450,11 +450,9 @@ ProcWindowsWMFrameDraw (register ClientPtr client) #if CYGMULTIWINDOW_DEBUG ErrorF ("ProcWindowsWMFrameDraw\n"); #endif - if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, DixReadAccess))) - { - return BadValue; - } + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; #if CYGMULTIWINDOW_DEBUG ErrorF ("ProcWindowsWMFrameDraw - Window found\n"); #endif @@ -538,6 +536,7 @@ ProcWindowsWMFrameSetTitle( REQUEST(xWindowsWMFrameSetTitleReq); WindowPtr pWin; win32RootlessWindowPtr pRLWinPriv; + int rc; #if CYGMULTIWINDOW_DEBUG ErrorF ("ProcWindowsWMFrameSetTitle\n"); @@ -545,11 +544,9 @@ ProcWindowsWMFrameSetTitle( REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq); - if (!(pWin = SecurityLookupWindow((Drawable)stuff->window, - client, DixReadAccess))) - { - return BadValue; - } + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; #if CYGMULTIWINDOW_DEBUG ErrorF ("ProcWindowsWMFrameSetTitle - Window found\n"); #endif diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index b1ec68b83..7f98965a4 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -70,11 +70,12 @@ ProcRRSelectInput (ClientPtr client) WindowPtr pWin; RREventPtr pRREvent, *pHead; XID clientResource; + int rc; REQUEST_SIZE_MATCH(xRRSelectInputReq); - pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); + if (rc != Success) + return rc; pHead = (RREventPtr *)SecurityLookupIDByType(client, pWin->drawable.id, RREventType, DixWriteAccess); diff --git a/randr/rrscreen.c b/randr/rrscreen.c index f1d8fc5d9..6f7afaf7a 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -217,13 +217,12 @@ ProcRRGetScreenSizeRange (ClientPtr client) WindowPtr pWin; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; + int rc; REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -268,14 +267,12 @@ ProcRRSetScreenSize (ClientPtr client) WindowPtr pWin; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; - int i; + int i, rc; REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -336,19 +333,16 @@ ProcRRGetScreenResources (ClientPtr client) rrScrPrivPtr pScrPriv; CARD8 *extra; unsigned long extraLen; - int i; + int i, n, rc; RRCrtc *crtcs; RROutput *outputs; xRRModeInfo *modeinfos; CARD8 *names; - int n; REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -580,7 +574,7 @@ ProcRRGetScreenInfo (ClientPtr client) REQUEST(xRRGetScreenInfoReq); xRRGetScreenInfoReply rep; WindowPtr pWin; - int n; + int n, rc; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; CARD8 *extra; @@ -588,11 +582,9 @@ ProcRRGetScreenInfo (ClientPtr client) RROutputPtr output; REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 21dbcc2cb..86a512c25 100755 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -239,12 +239,12 @@ ProcXFixesSelectCursorInput (ClientPtr client) { REQUEST (xXFixesSelectCursorInputReq); WindowPtr pWin; + int rc; REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; if (stuff->eventMask & ~CursorAllEvents) { client->errorValue = stuff->eventMask; diff --git a/xfixes/saveset.c b/xfixes/saveset.c index 9ad2627c0..ab75619e8 100755 --- a/xfixes/saveset.c +++ b/xfixes/saveset.c @@ -37,10 +37,9 @@ ProcXFixesChangeSaveSet(ClientPtr client) REQUEST(xXFixesChangeSaveSetReq); REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (result != Success) + return result; if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) return BadMatch; if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete)) diff --git a/xfixes/select.c b/xfixes/select.c index a718715a1..d1c22c552 100755 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -193,12 +193,12 @@ ProcXFixesSelectSelectionInput (ClientPtr client) { REQUEST (xXFixesSelectSelectionInputReq); WindowPtr pWin; + int rc; REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq); - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - DixReadAccess); - if (!pWin) - return(BadWindow); + rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); + if (rc != Success) + return rc; if (stuff->eventMask & ~SelectionAllEvents) { client->errorValue = stuff->eventMask; From 10aabb729d1586db344f9c1abdf1cf45e7ddaa7a Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 16:36:29 -0500 Subject: [PATCH 103/109] Convert callers of LookupDrawable() to dixLookupDrawable(). --- GL/glx/glxcmds.c | 18 +++++----- XTrap/xtrapdi.c | 4 +-- Xext/mbuf.c | 10 +++--- Xext/saver.c | 36 ++++++++++--------- Xext/xprint.c | 7 ++-- hw/dmx/glxProxy/glxcmds.c | 75 ++++++++++++++++++++------------------- 6 files changed, 80 insertions(+), 70 deletions(-) diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index ccdf3fa00..6273edc56 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -441,6 +441,7 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, __GLcontextModes *modes; __GLXdrawable *pGlxDraw; __GLXpixmap *drawPixmap = NULL; + int rc; /* This is the GLX 1.3 case - the client passes in a GLXWindow and * we just return the __GLXdrawable. The first time a GLXPixmap @@ -466,8 +467,8 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, * GLXWindow with the same XID as an X Window, so we wont get any * resource ID clashes. Effectively, the X Window is now also a * GLXWindow. */ - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { if (pDraw->type == DRAWABLE_WINDOW) { VisualID vid = wVisual((WindowPtr)pDraw); @@ -1199,12 +1200,12 @@ static int ValidateCreateDrawable(ClientPtr client, ScreenPtr pScreen; VisualPtr pVisual; __GLXscreen *pGlxScreen; - int i; + int i, rc; LEGAL_NEW_RESOURCE(glxDrawableId, client); - pDraw = (DrawablePtr) LookupDrawable(drawablId, client); - if (!pDraw || pDraw->type != type) { + rc = dixLookupDrawable(&pDraw, drawablId, client, 0, DixUnknownAccess); + if (rc != Success || pDraw->type != type) { client->errorValue = drawablId; return type == DRAWABLE_WINDOW ? BadWindow : BadPixmap; } @@ -2034,10 +2035,11 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc) xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *) pc; XID drawable = req->drawable; int barrier = req->barrier; - DrawablePtr pDraw = (DrawablePtr) LookupDrawable(drawable, client); - int screen; + DrawablePtr pDraw; + int screen, rc; - if (pDraw && (pDraw->type == DRAWABLE_WINDOW)) { + rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixUnknownAccess); + if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) { screen = pDraw->pScreen->myNum; if (__glXSwapBarrierFuncs && __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc) { diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c index c5d640d0b..23d3bde7f 100644 --- a/XTrap/xtrapdi.c +++ b/XTrap/xtrapdi.c @@ -1092,8 +1092,8 @@ int XETrapRequestVector(ClientPtr client) pdata->hdr.client = client->index; /* stuff client index in hdr */ if (BitIsTrue(penv->cur.data_config_flags_data,XETrapWinXY)) { - window_ptr = (WindowPtr) LookupDrawable(stuff->id, client); - if (window_ptr == 0L) + if (Success != dixLookupDrawable(&window_ptr, stuff->id, + client, 0, DixUnknownAccess)) { /* Failed...invalidate the X and Y coordinate data. */ pdata->hdr.win_x = -1L; pdata->hdr.win_y = -1L; diff --git a/Xext/mbuf.c b/Xext/mbuf.c index 43e2cc107..ed352e21b 100644 --- a/Xext/mbuf.c +++ b/Xext/mbuf.c @@ -786,15 +786,15 @@ ProcGetBufferInfo (client) DrawablePtr pDrawable; xMbufGetBufferInfoReply rep; ScreenPtr pScreen; - int i, j, k; - int n; + int i, j, k, n, rc; xMbufBufferInfo *pInfo; int nInfo; DepthPtr pDepth; - pDrawable = (DrawablePtr) LookupDrawable (stuff->drawable, client); - if (!pDrawable) - return BadDrawable; + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; pScreen = pDrawable->pScreen; nInfo = 0; for (i = 0; i < pScreen->numDepths; i++) diff --git a/Xext/saver.c b/Xext/saver.c index d6b537a78..7e3ebf408 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -780,16 +780,17 @@ ProcScreenSaverQueryInfo (client) { REQUEST(xScreenSaverQueryInfoReq); xScreenSaverQueryInfoReply rep; - register int n; + register int n, rc; ScreenSaverStuffPtr pSaver; DrawablePtr pDraw; CARD32 lastInput; ScreenSaverScreenPrivatePtr pPriv; REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq); - pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client); - if (!pDraw) - return BadDrawable; + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; pSaver = &savedScreenInfo[pDraw->pScreen->myNum]; pPriv = GetScreenPrivate (pDraw->pScreen); @@ -852,11 +853,13 @@ ProcScreenSaverSelectInput (client) { REQUEST(xScreenSaverSelectInputReq); DrawablePtr pDraw; + int rc; REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq); - pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client); - if (!pDraw) - return BadDrawable; + rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; if (!setEventMask (pDraw->pScreen, client, stuff->eventMask)) return BadAlloc; return Success; @@ -871,9 +874,7 @@ ScreenSaverSetAttributes (ClientPtr client) ScreenPtr pScreen; ScreenSaverScreenPrivatePtr pPriv = 0; ScreenSaverAttrPtr pAttr = 0; - int ret; - int len; - int class, bw, depth; + int ret, len, class, bw, depth; unsigned long visual; int idepth, ivisual; Bool fOK; @@ -891,9 +892,10 @@ ScreenSaverSetAttributes (ClientPtr client) ColormapPtr pCmap; REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); - pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client); - if (!pDraw) - return BadDrawable; + ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (ret != Success) + return ret; pScreen = pDraw->pScreen; pParent = WindowTable[pScreen->myNum]; @@ -1246,11 +1248,13 @@ ScreenSaverUnsetAttributes (ClientPtr client) REQUEST(xScreenSaverSetAttributesReq); DrawablePtr pDraw; ScreenSaverScreenPrivatePtr pPriv; + int rc; REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq); - pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client); - if (!pDraw) - return BadDrawable; + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (rc != Success) + return rc; pPriv = GetScreenPrivate (pDraw->pScreen); if (pPriv && pPriv->attr && pPriv->attr->client == client) { diff --git a/Xext/xprint.c b/Xext/xprint.c index d8fc51713..4ac13e6d1 100644 --- a/Xext/xprint.c +++ b/Xext/xprint.c @@ -1944,8 +1944,11 @@ ProcXpPutDocumentData(ClientPtr client) if (stuff->drawable) { if (pContext->state & DOC_RAW_STARTED) return BadDrawable; - pDraw = (DrawablePtr)LookupDrawable(stuff->drawable, client); - if (!pDraw || pDraw->pScreen->myNum != pContext->screenNum) + result = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixUnknownAccess); + if (result != Success) + return result; + if (pDraw->pScreen->myNum != pContext->screenNum) return BadDrawable; } else { if (pContext->state & DOC_COOKED_STARTED) diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c index aa9d8318c..6771cf1de 100644 --- a/hw/dmx/glxProxy/glxcmds.c +++ b/hw/dmx/glxProxy/glxcmds.c @@ -430,9 +430,10 @@ int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; __GLXpixmap *pGlxPixmap = NULL; __glXWindow *pGlxWindow = NULL; + int rc; - pDraw = (DrawablePtr) LookupDrawable(req->drawable, client); - if (!pDraw) { + rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixUnknownAccess); + if (rc != Success) { pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable, __glXPixmapRes); if (pGlxPixmap) pDraw = pGlxPixmap->pDraw; @@ -459,9 +460,10 @@ int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw, pMember = NULL; __GLXpixmap *pGlxPixmap = NULL; __glXWindow *pGlxWindow = NULL; + int rc; - pDraw = (DrawablePtr) LookupDrawable(req->drawable, client); - if (!pDraw) { + rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixUnknownAccess); + if (rc != Success) { pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable, __glXPixmapRes); if (pGlxPixmap) pDraw = pGlxPixmap->pDraw; @@ -479,8 +481,9 @@ int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc) } if (req->member != None) { - pMember = (DrawablePtr) LookupDrawable(req->member, client); - if (!pMember) { + rc = dixLookupDrawable(&pMember, req->member, client, 0, + DixUnknownAccess); + if (rc != Success) { pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->member, __glXPixmapRes); if (pGlxPixmap) pMember = pGlxPixmap->pDraw; @@ -734,7 +737,7 @@ static int MakeCurrent(__GLXclientState *cl, #endif int from_screen = 0; int to_screen = 0; - int s; + int s, rc; /* ** If one is None and the other isn't, it's a bad match. @@ -778,8 +781,8 @@ static int MakeCurrent(__GLXclientState *cl, } if (drawId != None) { - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { if (pDraw->type == DRAWABLE_WINDOW) { /* ** Drawable is an X Window. @@ -885,8 +888,8 @@ static int MakeCurrent(__GLXclientState *cl, } if (readId != None && readId != drawId ) { - pReadDraw = (DrawablePtr) LookupDrawable(readId, client); - if (pReadDraw) { + rc = dixLookupDrawable(&pReadDraw, readId, client, 0,DixUnknownAccess); + if (rc == Success) { if (pReadDraw->type == DRAWABLE_WINDOW) { /* ** Drawable is an X Window. @@ -1636,18 +1639,16 @@ static int CreateGLXPixmap(__GLXclientState *cl, __GLXscreenInfo *pGlxScreen; __GLXvisualConfig *pGlxVisual; __GLXFBConfig *pFBConfig; - int i; - int s; + int i, s, rc; int from_screen, to_screen; #ifdef PANORAMIX PanoramiXRes *pXinDraw = NULL; #endif - pDraw = (DrawablePtr) LookupDrawable(pixmapId, client); - if (!pDraw || pDraw->type != DRAWABLE_PIXMAP) { - client->errorValue = pixmapId; - return BadPixmap; - } + rc = dixLookupDrawable(&pDraw, pixmapId, client, M_DRAWABLE_PIXMAP, + DixUnknownAccess); + if (rc != Success) + return rc; /* ** Check if screen of visual matches screen of pixmap. @@ -1778,7 +1779,8 @@ static int CreateGLXPixmap(__GLXclientState *cl, #ifdef PANORAMIX if (pXinDraw) { - pRealDraw = (DrawablePtr) LookupDrawable(pXinDraw->info[s].id,client); + dixLookupDrawable(&pRealDraw, pXinDraw->info[s].id, client, 0, + DixUnknownAccess); } #endif @@ -1944,14 +1946,13 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag) __glXWindow *pGlxWindow = NULL; int from_screen = 0; int to_screen = 0; - int s; + int s, rc; /* ** Check that the GLX drawable is valid. */ - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { - + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { from_screen = to_screen = pDraw->pScreen->myNum; if (pDraw->type == DRAWABLE_WINDOW) { @@ -2099,12 +2100,13 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) __GLXpixmap *pGlxPixmap = NULL; __GLXcontext *glxc = NULL; __glXWindow *pGlxWindow = NULL; + int rc; /* ** Check that the GLX drawable is valid. */ - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { if (pDraw->type != DRAWABLE_WINDOW) { /* ** Drawable is an X pixmap, which is not allowed. @@ -2892,16 +2894,15 @@ int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc) __GLXFBConfig *pGlxFBConfig = NULL; VisualPtr pVisual; VisualID visId; - int i; + int i, rc; /* ** Check if windowId is valid */ - pDraw = (DrawablePtr) LookupDrawable(windowId, client); - if (!pDraw || pDraw->type != DRAWABLE_WINDOW) { - client->errorValue = windowId; - return BadWindow; - } + rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW, + DixUnknownAccess); + if (rc != Success) + return rc; /* ** Check if screen of window matches screen of fbconfig. @@ -3274,7 +3275,7 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) GLXDrawable be_drawable = 0; DrawablePtr pDraw = NULL; Display *dpy; - int screen; + int screen, rc; DMXScreenInfo *dmxScreen; CARD32 *attribs = NULL; int attribs_size; @@ -3283,8 +3284,8 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) #endif if (drawId != None) { - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { if (pDraw->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDraw; be_drawable = 0; @@ -3435,7 +3436,7 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) GLXDrawable be_drawable = 0; DrawablePtr pDraw = NULL; Display *dpy; - int screen; + int screen, rc; DMXScreenInfo *dmxScreen; char *attrbuf; #ifdef PANORAMIX @@ -3444,8 +3445,8 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) #endif if (drawId != None) { - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { + rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess); + if (rc == Success) { if (pDraw->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDraw; be_drawable = 0; From f11dafaafc68f5cff1a1538d9566907786d8ab72 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 16:51:58 -0500 Subject: [PATCH 104/109] Convert callers of SecurityLookupDrawable() to dixLookupDrawable(). --- dbe/dbe.c | 10 +++++----- hw/darwin/quartz/xpr/appledri.c | 22 ++++++++++----------- hw/xfree86/dri/xf86dri.c | 35 +++++++++++++++------------------ 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/dbe/dbe.c b/dbe/dbe.c index 69ddf4f1c..38375f92a 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -865,7 +865,7 @@ ProcDbeGetVisualInfo(ClientPtr client) xDbeGetVisualInfoReply rep; Drawable *drawables; DrawablePtr *pDrawables = NULL; - register int i, j, n; + register int i, j, n, rc; register int count; /* number of visual infos in reply */ register int length; /* length of reply */ ScreenPtr pScreen; @@ -887,11 +887,11 @@ ProcDbeGetVisualInfo(ClientPtr client) for (i = 0; i < stuff->n; i++) { - if (!(pDrawables[i] = (DrawablePtr)SecurityLookupDrawable( - drawables[i], client, DixReadAccess))) - { + rc = dixLookupDrawable(pDrawables+i, drawables[i], client, 0, + DixReadAccess); + if (rc != Success) { DEALLOCATE_LOCAL(pDrawables); - return(BadDrawable); + return rc; } } } diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c index 585d7e1be..dd688cae3 100644 --- a/hw/darwin/quartz/xpr/appledri.c +++ b/hw/darwin/quartz/xpr/appledri.c @@ -213,6 +213,7 @@ ProcAppleDRICreateSurface( DrawablePtr pDrawable; xp_surface_id sid; unsigned int key[2]; + int rc; REQUEST(xAppleDRICreateSurfaceReq); REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq); @@ -220,12 +221,10 @@ ProcAppleDRICreateSurface( rep.length = 0; rep.sequenceNumber = client->sequence; - if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( - (Drawable)stuff->drawable, - client, - DixReadAccess))) { - return BadValue; - } + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; rep.key_0 = rep.key_1 = rep.uid = 0; @@ -252,13 +251,12 @@ ProcAppleDRIDestroySurface( REQUEST(xAppleDRIDestroySurfaceReq); DrawablePtr pDrawable; REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq); + int rc; - if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( - (Drawable)stuff->drawable, - client, - DixReadAccess))) { - return BadValue; - } + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; if (!DRIDestroySurface( screenInfo.screens[stuff->screen], (Drawable)stuff->drawable, diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 03e6725ff..933cd3e18 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -386,6 +386,7 @@ ProcXF86DRICreateDrawable( { xXF86DRICreateDrawableReply rep; DrawablePtr pDrawable; + int rc; REQUEST(xXF86DRICreateDrawableReq); REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq); @@ -398,12 +399,10 @@ ProcXF86DRICreateDrawable( rep.length = 0; rep.sequenceNumber = client->sequence; - if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( - (Drawable)stuff->drawable, - client, - DixReadAccess))) { - return BadValue; - } + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; if (!DRICreateDrawable( screenInfo.screens[stuff->screen], (Drawable)stuff->drawable, @@ -424,17 +423,17 @@ ProcXF86DRIDestroyDrawable( REQUEST(xXF86DRIDestroyDrawableReq); DrawablePtr pDrawable; REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq); + int rc; + if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; } - if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( - (Drawable)stuff->drawable, - client, - DixReadAccess))) { - return BadValue; - } + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen], (Drawable)stuff->drawable, @@ -455,7 +454,7 @@ ProcXF86DRIGetDrawableInfo( int X, Y, W, H; drm_clip_rect_t * pClipRects; drm_clip_rect_t * pBackClipRects; - int backX, backY; + int backX, backY, rc; REQUEST(xXF86DRIGetDrawableInfoReq); REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); @@ -468,12 +467,10 @@ ProcXF86DRIGetDrawableInfo( rep.length = 0; rep.sequenceNumber = client->sequence; - if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable( - (Drawable)stuff->drawable, - client, - DixReadAccess))) { - return BadValue; - } + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen], pDrawable, From ab1d5b0c31a1cfce95ab6b1d06f209f2c44e19ac Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 17:26:58 -0500 Subject: [PATCH 105/109] Convert callers of LookupClient() to dixLookupClient(). --- Xext/appgroup.c | 7 +++++-- Xext/sync.c | 20 ++++++++++++-------- dix/dispatch.c | 12 +++++------- dix/dixutils.c | 5 +++-- include/dix.h | 3 ++- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Xext/appgroup.c b/Xext/appgroup.c index 134b172f9..bb7a73ce1 100644 --- a/Xext/appgroup.c +++ b/Xext/appgroup.c @@ -485,10 +485,13 @@ int ProcXagQuery( ClientPtr pClient; AppGroupPtr pAppGrp; REQUEST (xXagQueryReq); - int n; + int n, rc; REQUEST_SIZE_MATCH (xXagQueryReq); - pClient = LookupClient (stuff->resource, client); + rc = dixLookupClient(&pClient, stuff->resource, client, DixUnknownAccess); + if (rc != Success) + return rc; + for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next) for (n = 0; n < pAppGrp->nclients; n++) if (pAppGrp->clients[n] == pClient) { diff --git a/Xext/sync.c b/Xext/sync.c index 1d899348b..531b48cc1 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -1452,15 +1452,17 @@ ProcSyncSetPriority(client) { REQUEST(xSyncSetPriorityReq); ClientPtr priorityclient; + int rc; REQUEST_SIZE_MATCH(xSyncSetPriorityReq); if (stuff->id == None) priorityclient = client; - else if (!(priorityclient = LookupClient(stuff->id, client))) - { - client->errorValue = stuff->id; - return BadMatch; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixUnknownAccess); + if (rc != Success) + return rc; } if (priorityclient->priority != stuff->priority) @@ -1487,15 +1489,17 @@ ProcSyncGetPriority(client) REQUEST(xSyncGetPriorityReq); xSyncGetPriorityReply rep; ClientPtr priorityclient; + int rc; REQUEST_SIZE_MATCH(xSyncGetPriorityReq); if (stuff->id == None) priorityclient = client; - else if (!(priorityclient = LookupClient(stuff->id, client))) - { - client->errorValue = stuff->id; - return BadMatch; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixUnknownAccess); + if (rc != Success) + return rc; } rep.type = X_Reply; diff --git a/dix/dispatch.c b/dix/dispatch.c index 3060a4c39..51ad07da5 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3388,7 +3388,8 @@ int ProcKillClient(register ClientPtr client) { REQUEST(xResourceReq); - ClientPtr killclient; + ClientPtr killclient; + int rc; REQUEST_SIZE_MATCH(xResourceReq); if (stuff->id == AllTemporary) @@ -3397,8 +3398,8 @@ ProcKillClient(register ClientPtr client) return (client->noClientException); } - if ((killclient = LookupClient(stuff->id, client))) - { + rc = dixLookupClient(&killclient, stuff->id, client, DixDestroyAccess); + if (rc == Success) { CloseDownClient(killclient); /* if an LBX proxy gets killed, isItTimeToYield will be set */ if (isItTimeToYield || (client == killclient)) @@ -3412,10 +3413,7 @@ ProcKillClient(register ClientPtr client) return (client->noClientException); } else - { - client->errorValue = stuff->id; - return (BadValue); - } + return rc; } int diff --git a/dix/dixutils.c b/dix/dixutils.c index 3479ddccf..2859b96e9 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -262,11 +262,12 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access) } _X_EXPORT int -dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client) +dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) { pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY, DixReadAccess); int clientIndex = CLIENT_ID(rid); + client->errorValue = rid; if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) { *pClient = clients[clientIndex]; @@ -312,7 +313,7 @@ _X_EXPORT ClientPtr LookupClient(XID id, ClientPtr client) { ClientPtr pClient; - int i = dixLookupClient(&pClient, id, client); + int i = dixLookupClient(&pClient, id, client, DixUnknownAccess); return (i == Success) ? pClient : NULL; } diff --git a/include/dix.h b/include/dix.h index baff43f54..5c2c5b862 100644 --- a/include/dix.h +++ b/include/dix.h @@ -301,7 +301,8 @@ extern int dixLookupGC( extern int dixLookupClient( ClientPtr *result, XID id, - ClientPtr client); + ClientPtr client, + Mask access_mode); /* * These are deprecated compatibility functions and will be removed soon! From 012807356883128fde58bb2d4f91dd356d6418fc Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 15 Dec 2006 18:27:16 -0500 Subject: [PATCH 106/109] Add loud warnings to deprecated lookup functions. Hopefully this will alert external driver maintainers. --- dix/dixutils.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index 2859b96e9..084d2e4c5 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -281,39 +281,53 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) * These are deprecated compatibility functions and will be removed soon! * Please use the new dixLookup*() functions above. */ -_X_EXPORT WindowPtr +_X_EXPORT _X_DEPRECATED WindowPtr SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode) { WindowPtr pWin; int i = dixLookupWindow(&pWin, id, client, access_mode); + static int warn = 1; + if (warn-- > 0) + ErrorF("Warning: LookupWindow()/SecurityLookupWindow() " + "are deprecated. Please convert your driver/module " + "to use dixLookupWindow().\n"); return (i == Success) ? pWin : NULL; } -_X_EXPORT WindowPtr +_X_EXPORT _X_DEPRECATED WindowPtr LookupWindow(XID id, ClientPtr client) { return SecurityLookupWindow(id, client, DixUnknownAccess); } -_X_EXPORT pointer +_X_EXPORT _X_DEPRECATED pointer SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode) { DrawablePtr pDraw; int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode); + static int warn = 1; + if (warn-- > 0) + ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() " + "are deprecated. Please convert your driver/module " + "to use dixLookupDrawable().\n"); return (i == Success) ? pDraw : NULL; } -_X_EXPORT pointer +_X_EXPORT _X_DEPRECATED pointer LookupDrawable(XID id, ClientPtr client) { return SecurityLookupDrawable(id, client, DixUnknownAccess); } -_X_EXPORT ClientPtr +_X_EXPORT _X_DEPRECATED ClientPtr LookupClient(XID id, ClientPtr client) { ClientPtr pClient; int i = dixLookupClient(&pClient, id, client, DixUnknownAccess); + static int warn = 1; + if (warn-- > 0) + ErrorF("Warning: LookupClient() is deprecated. Please convert your " + "driver/module to use dixLookupClient().\n"); return (i == Success) ? pClient : NULL; } From c92f7bef54fa737766d65fe32c200f405f39228c Mon Sep 17 00:00:00 2001 From: Kevin E Martin Date: Sat, 16 Dec 2006 12:01:49 -0500 Subject: [PATCH 107/109] For Xvfb, Xnest and Xprt, compile fbcmap.c with -DXFree86Server --- hw/vfb/Makefile.am | 1 + hw/xnest/Makefile.am | 1 + hw/xprint/Makefile.am | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am index 2a0151f57..4f711fde7 100644 --- a/hw/vfb/Makefile.am +++ b/hw/vfb/Makefile.am @@ -21,6 +21,7 @@ Xvfb_LDFLAGS = AM_CFLAGS = -DHAVE_DIX_CONFIG_H \ -DNO_HW_ONLY_EXTS \ -DNO_MODULE_EXTS \ + -DXFree86Server \ $(XVFBMODULES_CFLAGS) \ $(DIX_CFLAGS) diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am index d40d122f4..cce1fef94 100644 --- a/hw/xnest/Makefile.am +++ b/hw/xnest/Makefile.am @@ -51,6 +51,7 @@ Xnest_LDFLAGS = AM_CFLAGS = -DHAVE_XNEST_CONFIG_H \ -DNO_HW_ONLY_EXTS \ + -DXFree86Server \ $(DIX_CFLAGS) \ $(XNESTMODULES_CFLAGS) diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am index 27a7e30d1..d4f22d261 100644 --- a/hw/xprint/Makefile.am +++ b/hw/xprint/Makefile.am @@ -5,7 +5,8 @@ bin_PROGRAMS = Xprt Xprt_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAGS@ \ -DXPRINT -DPRINT_ONLY_SERVER -D_XP_PRINT_SERVER_ \ -DXPRINTDIR=\"$(libdir)/X11/xserver\" \ - -DXPRASTERDDX -DXPPCLDDX -DXPMONOPCLDDX -DXPPSDDX + -DXPRASTERDDX -DXPPCLDDX -DXPMONOPCLDDX -DXPPSDDX \ + -DXFree86Server Xprt_LDFLAGS = -L$(top_srcdir) Xprt_LDADD = @XPRINT_LIBS@ ps/libps.la raster/libraster.la \ From a5fcf1e5e7452c9be82f63b6c2be2a25c4109523 Mon Sep 17 00:00:00 2001 From: James Steven Supancic III Date: Sat, 16 Dec 2006 12:02:38 -0500 Subject: [PATCH 108/109] Fix RENDER issues (bug #7555) and implement RENDER add/remove screen support (bug #8485). --- configure.ac | 2 +- hw/dmx/dmxextension.c | 133 +++++++++++++++++++++++++++++++++++++++++- hw/dmx/dmxinit.c | 2 +- hw/dmx/dmxpict.c | 85 ++++++++++++++++----------- hw/dmx/dmxpict.h | 2 + 5 files changed, 188 insertions(+), 36 deletions(-) diff --git a/configure.ac b/configure.ac index 002be624c..491bdd511 100644 --- a/configure.ac +++ b/configure.ac @@ -1007,7 +1007,7 @@ dnl --------------------------------------------------------------------------- dnl DMX DDX AC_MSG_CHECKING([whether to build Xdmx DDX]) -PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no]) +PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no]) if test "x$DMX" = xauto; then DMX="$have_dmx" fi diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index efcaca457..c12973bd5 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -1056,6 +1056,116 @@ static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old) return TRUE; } +#ifdef RENDER +/** Restore Render's picture */ +static void dmxBERestoreRenderPict(pointer value, XID id, pointer n) +{ + PicturePtr pPicture = value; /* The picture */ + DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */ + int scrnNum = (int)n; + + if (pDraw->pScreen->myNum != scrnNum) { + /* Picture not on the screen we are restoring*/ + return; + } + + if (pDraw->type == DRAWABLE_PIXMAP) { + PixmapPtr pPixmap = (PixmapPtr)pDraw; + + /* Create and restore the pixmap drawable */ + dmxBECreatePixmap(pPixmap); + dmxBERestorePixmap(pPixmap); + } + + dmxBECreatePicture(pPicture); +} + +/** Restore Render's glyphs */ +static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n) +{ + GlyphSetPtr glyphSet = value; + int scrnNum = (int)n; + dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum]; + GlyphRefPtr table; + char *images; + Glyph *gids; + XGlyphInfo *glyphs; + char *pos; + int beret; + int len_images = 0; + int i; + int ctr; + + if (glyphPriv->glyphSets[scrnNum]) { + /* Only restore glyphs on the screen we are attaching */ + return; + } + + /* First we must create the glyph set on the backend. */ + if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) { + dmxLog(dmxWarning, + "\tdmxBERestoreRenderGlyph failed to create glyphset!\n"); + return; + } + + /* Now for the complex part, restore the glyph data */ + table = glyphSet->hash.table; + + /* We need to know how much memory to allocate for this part */ + for (i = 0; i < glyphSet->hash.hashSet->size; i++) { + GlyphRefPtr gr = &table[i]; + GlyphPtr gl = gr->glyph; + + if (!gl || gl == DeletedGlyph) continue; + len_images += gl->size - sizeof(gl->info); + } + + /* Now allocate the memory we need */ + images = ALLOCATE_LOCAL(len_images*sizeof(char)); + gids = ALLOCATE_LOCAL(glyphSet->hash.tableEntries*sizeof(Glyph)); + glyphs = ALLOCATE_LOCAL(glyphSet->hash.tableEntries*sizeof(XGlyphInfo)); + + memset(images, 0, len_images * sizeof(char)); + pos = images; + ctr = 0; + + /* Fill the allocated memory with the proper data */ + for (i = 0; i < glyphSet->hash.hashSet->size; i++) { + GlyphRefPtr gr = &table[i]; + GlyphPtr gl = gr->glyph; + + if (!gl || gl == DeletedGlyph) continue; + + /* First lets put the data into gids */ + gids[ctr] = gr->signature; + + /* Next do the glyphs data structures */ + glyphs[ctr].width = gl->info.width; + glyphs[ctr].height = gl->info.height; + glyphs[ctr].x = gl->info.x; + glyphs[ctr].y = gl->info.y; + glyphs[ctr].xOff = gl->info.xOff; + glyphs[ctr].yOff = gl->info.yOff; + + /* Copy the images from the DIX's data into the buffer */ + memcpy(pos, gl+1, gl->size - sizeof(gl->info)); + pos += gl->size - sizeof(gl->info); + ctr++; + } + + /* Now restore the glyph data */ + XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum], + gids,glyphs, glyphSet->hash.tableEntries, images, + len_images); + + /* Clean up */ + DEALLOCATE_LOCAL(len_images); + DEALLOCATE_LOCAL(gids); + DEALLOCATE_LOCAL(glyphs); +} +#endif + /** Reattach previously detached back-end screen. */ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr) { @@ -1174,6 +1284,20 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr) /* Create window hierarchy (top down) */ dmxBECreateWindowTree(idx); +#ifdef RENDER + /* Restore the picture state for RENDER */ + for (i = currentMaxClients; --i >= 0; ) + if (clients[i]) + FindClientResourcesByType(clients[i],PictureType, + dmxBERestoreRenderPict,(pointer)idx); + + /* Restore the glyph state for RENDER */ + for (i = currentMaxClients; --i >= 0; ) + if (clients[i]) + FindClientResourcesByType(clients[i],GlyphSetType, + dmxBERestoreRenderGlyph,(pointer)idx); +#endif + /* Refresh screen by generating exposure events for all windows */ dmxForceExposures(idx); @@ -1362,8 +1486,15 @@ static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type, #ifdef RENDER } else if ((type & TypeMask) == (PictureType & TypeMask)) { PicturePtr pPict = value; - if (pPict->pDrawable->pScreen->myNum == scrnNum) + if (pPict->pDrawable->pScreen->myNum == scrnNum) { + /* Free the pixmaps on the backend if needed */ + if (pPict->pDrawable->type == DRAWABLE_PIXMAP) { + PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable); + dmxBESavePixmap(pPixmap); + dmxBEFreePixmap(pPixmap); + } dmxBEFreePicture((PicturePtr)value); + } } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) { dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value); #endif diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c index 9c5356ed5..1d3689c40 100644 --- a/hw/dmx/dmxinit.c +++ b/hw/dmx/dmxinit.c @@ -624,7 +624,7 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) } /* Make sure that the command-line arguments are sane. */ - if (dmxAddRemoveScreens && (!noRenderExtension || dmxGLXProxy)) { + if (dmxAddRemoveScreens && dmxGLXProxy) { /* Currently it is not possible to support GLX and Render * extensions with dynamic screen addition/removal due to the * state that each extension keeps, which cannot be restored. */ diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c index 339692538..0f1782e51 100644 --- a/hw/dmx/dmxpict.c +++ b/hw/dmx/dmxpict.c @@ -223,6 +223,36 @@ Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet) return FALSE; } +/** Create \a glyphSet on the backend screen number \a idx. */ +int dmxBECreateGlyphSet(int idx, GlyphSetPtr glyphSet) +{ + XRenderPictFormat *pFormat; + DMXScreenInfo *dmxScreen = &dmxScreens[idx]; + dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + PictFormatPtr pFmt = glyphSet->format; + int (*oldErrorHandler)(Display *, XErrorEvent *); + + pFormat = dmxFindFormat(dmxScreen, pFmt); + if (!pFormat) { + return BadMatch; + } + + dmxGlyphLastError = 0; + oldErrorHandler = XSetErrorHandler(dmxGlyphErrorHandler); + + /* Catch when this fails */ + glyphPriv->glyphSets[idx] + = XRenderCreateGlyphSet(dmxScreen->beDisplay, pFormat); + + XSetErrorHandler(oldErrorHandler); + + if (dmxGlyphLastError) { + return dmxGlyphLastError; + } + + return Success; +} + /** Create a Glyph Set on each screen. Save the glyphset ID from each * screen in the Glyph Set's private structure. Fail if the format * requested is not available or if the Glyph Set cannot be created on @@ -235,12 +265,9 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client) ret = dmxSaveRenderVector[stuff->renderReqType](client); if (ret == Success) { - int (*oldErrorHandler)(Display *, XErrorEvent *); GlyphSetPtr glyphSet; dmxGlyphPrivPtr glyphPriv; int i; - PictFormatPtr pFmt; - XRenderPictFormat *pFormat; /* Look up glyphSet that was just created ???? */ /* Store glyphsets from backends in glyphSet->devPrivate ????? */ @@ -254,21 +281,16 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client) MAXSCREENSALLOC_RETURN(glyphPriv->glyphSets, BadAlloc); DMX_SET_GLYPH_PRIV(glyphSet, glyphPriv); - pFmt = SecurityLookupIDByType(client, stuff->format, PictFormatType, - DixReadAccess); - - oldErrorHandler = XSetErrorHandler(dmxGlyphErrorHandler); - for (i = 0; i < dmxNumScreens; i++) { DMXScreenInfo *dmxScreen = &dmxScreens[i]; + int beret; if (!dmxScreen->beDisplay) { glyphPriv->glyphSets[i] = 0; continue; } - pFormat = dmxFindFormat(dmxScreen, pFmt); - if (!pFormat) { + if ((beret = dmxBECreateGlyphSet(i, glyphSet)) != Success) { int j; /* Free the glyph sets we've allocated thus far */ @@ -278,30 +300,9 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client) /* Free the resource created by render */ FreeResource(stuff->gsid, RT_NONE); - ret = BadMatch; - break; - } - - /* Catch when this fails */ - glyphPriv->glyphSets[i] - = XRenderCreateGlyphSet(dmxScreen->beDisplay, pFormat); - - if (dmxGlyphLastError) { - int j; - - /* Free the glyph sets we've allocated thus far */ - for (j = 0; j < i; j++) - dmxBEFreeGlyphSet(screenInfo.screens[j], glyphSet); - - /* Free the resource created by render */ - FreeResource(stuff->gsid, RT_NONE); - - ret = dmxGlyphLastError; - break; + return beret; } } - - XSetErrorHandler(oldErrorHandler); } return ret; @@ -753,6 +754,20 @@ void dmxCreatePictureList(WindowPtr pWindow) } } +/** Create \a pPicture on the backend. */ +int dmxBECreatePicture(PicturePtr pPicture) +{ + dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture); + + /* Create picutre on BE */ + pPictPriv->pict = dmxDoCreatePicture(pPicture); + + /* Flush changes to the backend server */ + dmxValidatePicture(pPicture, (1 << (CPLastBit+1)) - 1); + + return Success; +} + /** Create a picture. This function handles the CreatePicture * unwrapping/wrapping and calls dmxDoCreatePicture to actually create * the picture on the appropriate screen. */ @@ -853,7 +868,11 @@ int dmxChangePictureClip(PicturePtr pPicture, int clipType, /* The clip has already been changed into a region by the mi * routine called above. */ - if (pPicture->clientClip) { + if (clipType == CT_NONE) { + /* Disable clipping, show all */ + XFixesSetPictureClipRegion(dmxScreen->beDisplay, + pPictPriv->pict, 0, 0, None); + } else if (pPicture->clientClip) { RegionPtr pClip = pPicture->clientClip; BoxPtr pBox = REGION_RECTS(pClip); int nBox = REGION_NUM_RECTS(pClip); diff --git a/hw/dmx/dmxpict.h b/hw/dmx/dmxpict.h index 2ca04ed87..fe2a65959 100644 --- a/hw/dmx/dmxpict.h +++ b/hw/dmx/dmxpict.h @@ -112,7 +112,9 @@ extern void dmxTriFan(CARD8 op, INT16 xSrc, INT16 ySrc, int npoint, xPointFixed *points); +extern int dmxBECreateGlyphSet(int idx, GlyphSetPtr glyphSet); extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet); +extern int dmxBECreatePicture(PicturePtr pPicture); extern Bool dmxBEFreePicture(PicturePtr pPicture); extern int dmxPictPrivateIndex; /**< Index for picture private data */ From 1b029fd896b76096905c516925ce0214fe14632c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 18 Dec 2006 14:51:04 -0800 Subject: [PATCH 109/109] Xorg & Xserver man page updates for 1.2 release - Added -extension & +extension to Xserver man page - Changed Xorg synopsis from X11R6 to X11R7 - Clarified Xorg ancestry description - Moved Solaris to free/Open Source OS list - Removed references to MetroLink module loader & getconfig - Converted (1) to (__appmansuffix__) in a few more places - Replaced http://www.freedesktop.org/cvs/ with http://gitweb.freedesktop.org/ --- doc/Xserver.man.pre | 8 +++++ hw/xfree86/doc/man/Xorg.man.pre | 60 ++++++++++++++------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre index d65acde6a..2457edf22 100644 --- a/doc/Xserver.man.pre +++ b/doc/Xserver.man.pre @@ -159,6 +159,14 @@ default state is platform and configuration specific. disables DPMS (display power management services). The default state is platform and configuration specific. .TP 8 +.BI \-extension extensionName +disables named extension. If an unknown extension name is specified, +a list of accepted extension names is printed. +.TP 8 +.BI \+extension extensionName +enables named extension. If an unknown extension name is specified, +a list of accepted extension names is printed. +.TP 8 .B \-f \fIvolume\fP sets feep (bell) volume (allowable range: 0-100). .TP 8 diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index 43f0518d2..c950e326b 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -1,7 +1,7 @@ .\" $XdotOrg: xserver/xorg/hw/xfree86/doc/man/Xorg.man.pre,v 1.3 2005/07/04 18:41:01 ajax Exp $ .TH __xservername__ __appmansuffix__ __vendorversion__ .SH NAME -__xservername__ - X11R6 X server +__xservername__ - X11R7 X server .SH SYNOPSIS .B __xservername__ .RI [\fB:\fP display ] @@ -13,30 +13,26 @@ is a full featured X server that was originally designed for UNIX and UNIX-like operating systems running on Intel x86 hardware. It now runs on a wider range of hardware and OS platforms. .PP -This work was derived from +This work was derived by the X.Org Foundation from the XFree86 Project's .I "XFree86\ 4.4rc2" -by the X.Org Foundation. -The XFree86 4.4rc2 release was originally derived from +release. +The XFree86 release was originally derived from .I "X386\ 1.2" by Thomas Roell which was contributed to X11R5 by Snitily Graphics -Consulting Service. The -.B __xservername__ -server architecture includes -among many other things a loadable module system derived from code -donated by Metro Link, Inc. The current __xservername__ release is compatible -with X11R6.6. +Consulting Service. .SH PLATFORMS .PP .B __xservername__ operates under a wide range of operating systems and hardware platforms. The Intel x86 (IA32) architecture is the most widely supported hardware -platform. Other hardware platforms include Compaq Alpha, Intel IA64, +platform. Other hardware platforms include Compaq Alpha, Intel IA64, AMD64, SPARC and PowerPC. The most widely supported operating systems are the -free/OpenSource UNIX-like systems such as Linux, FreeBSD, NetBSD and -OpenBSD. Commercial UNIX operating systems such as Solaris (x86) and +free/OpenSource UNIX-like systems such as Linux, FreeBSD, NetBSD, +OpenBSD, and Solaris. Commercial UNIX operating systems such as UnixWare are also supported. Other supported operating systems include LynxOS, and GNU Hurd. Darwin and Mac OS X are supported with the -XDarwin(1) X server. Win32/Cygwin is supported with the XWin X server. +XDarwin(__appmansuffix__) X server. Win32/Cygwin is supported with the +XWin(__appmansuffix__) X server. .PP .SH "NETWORK CONNECTIONS" .B __xservername__ @@ -119,13 +115,14 @@ one way, the highest precedence mechanism is used. The list of mechanisms is ordered from highest precedence to lowest. Note that not all parameters can be supplied via all methods. The available command line options and environment variables (and some defaults) are described here and in -the Xserver(1) manual page. Most configuration file parameters, with -their defaults, are described in the __xconfigfile__(__filemansuffix__) manual -page. Driver and module specific configuration parameters are described -in the relevant driver or module manual page. +the Xserver(__appmansuffix__) manual page. Most configuration file +parameters, with their defaults, are described in the +__xconfigfile__(__filemansuffix__) manual page. Driver and module specific +configuration parameters are described in the relevant driver or module +manual page. .PP -In addition to the normal server options described in the Xserver(1) -manual page, +In addition to the normal server options described in the +Xserver(__appmansuffix__) manual page, .B __xservername__ accepts the following command line switches: .TP 8 @@ -385,7 +382,8 @@ options. When this option is specified, the .B __xservername__ server scans the PCI bus, and prints out some information about each -device that was detected. See also scanpci(1) and pcitweak(1). +device that was detected. See also scanpci(__appmansuffix__) +and pcitweak(__appmansuffix__). .TP 8 .BI \-screen " screen-name" Use the __xconfigfile__(__filemansuffix__) file @@ -508,13 +506,12 @@ for its initial setup. Refer to the __xconfigfile__(__filemansuffix__) manual page for information about the format of this file. .PP -Starting with version 4.4, .B __xservername__ has a mechanism for automatically generating a built-in configuration at run-time when no .B __xconfigfile__ file is present. The current version of this automatic configuration -mechanism works in three ways. +mechanism works in two ways. .PP The first is via enhancements that have made many components of the .B __xconfigfile__ @@ -523,14 +520,7 @@ reasonably deduced doesn't need to be specified explicitly, greatly reducing the amount of built-in configuration information that needs to be generated at run-time. .PP -The second is to use an external utility called getconfig(1), when -available, to use meta-configuration information to generate a suitable -configuration for the primary video device. The meta-configuration -information can be updated to allow an existing installation to get the -best out of new hardware or to work around bugs that are found -post-release. -.PP -The third is to have "safe" fallbacks for most configuration information. +The second is to have "safe" fallbacks for most configuration information. This maximises the likelihood that the .B __xservername__ server will start up in some usable configuration even when information @@ -644,7 +634,7 @@ __xservername__ was originally based on XFree86 4.4rc2. That was originally based on \fIX386 1.2\fP by Thomas Roell, which was contributed to the then X Consortium's X11R5 distribution by SGCS. .PP -__xservername__ is released by the X.org Foundation. +__xservername__ is released by the X.Org Foundation. .PP The project that became XFree86 was originally founded in 1992 by David Dawes, Glenn Lai, Jim Tsillas and David Wexelblat. @@ -685,9 +675,9 @@ Orest Zborowski \fIorestz@eskimo.com\fP .RE .PP __xservername__ source is available from the FTP server -\fI\fP, and from the X.org -server \fI\fP. Documentation and other -information can be found from the X.org web site +\fI\fP, and from the X.Org +server \fI\fP. Documentation and other +information can be found from the X.Org web site \fI\fP. .SH LEGAL