2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1995 Kaleb S. KEITHLEY
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
2015-09-16 13:10:19 -06:00
|
|
|
IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
|
2006-11-26 11:13:41 -07:00
|
|
|
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.
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
Except as contained in this notice, the name of Kaleb S. KEITHLEY
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use
|
2006-11-26 11:13:41 -07:00
|
|
|
or other dealings in this Software without prior written authorization
|
|
|
|
from Kaleb S. KEITHLEY
|
|
|
|
|
|
|
|
*/
|
|
|
|
/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
#ifdef XF86VIDMODE
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
2016-05-29 06:02:34 -06:00
|
|
|
#include <X11/extensions/xf86vmproto.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "misc.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "servermd.h"
|
|
|
|
#include "swaprep.h"
|
2016-05-29 06:02:34 -06:00
|
|
|
#include "vidmodestr.h"
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "globals.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int VidModeErrorBase;
|
2016-05-29 06:02:34 -06:00
|
|
|
static int VidModeAllowNonLocal;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static DevPrivateKeyRec VidModeClientPrivateKeyRec;
|
2010-12-05 08:36:02 -07:00
|
|
|
#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static DevPrivateKeyRec VidModePrivateKeyRec;
|
|
|
|
#define VidModePrivateKey (&VidModePrivateKeyRec)
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* This holds the client's version information */
|
|
|
|
typedef struct {
|
2012-06-10 07:21:05 -06:00
|
|
|
int major;
|
|
|
|
int minor;
|
2006-11-26 11:13:41 -07:00
|
|
|
} VidModePrivRec, *VidModePrivPtr;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#define VM_GETPRIV(c) ((VidModePrivPtr) \
|
|
|
|
dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey))
|
|
|
|
#define VM_SETPRIV(c,p) \
|
|
|
|
dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2016-05-29 06:02:34 -06:00
|
|
|
#define DEBUG_P(x) DebugF(x"\n")
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
#define DEBUG_P(x) /**/
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static DisplayModePtr
|
|
|
|
VidModeCreateMode(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
mode = malloc(sizeof(DisplayModeRec));
|
|
|
|
if (mode != NULL) {
|
|
|
|
mode->name = "";
|
|
|
|
mode->VScan = 1; /* divides refresh rate. default = 1 */
|
|
|
|
mode->Private = NULL;
|
|
|
|
mode->next = mode;
|
|
|
|
mode->prev = mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static void
|
|
|
|
VidModeCopyMode(DisplayModePtr modefrom, DisplayModePtr modeto)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
memcpy(modeto, modefrom, sizeof(DisplayModeRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static int
|
|
|
|
VidModeGetModeValue(DisplayModePtr mode, int valtyp)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
int ret = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
switch (valtyp) {
|
|
|
|
case VIDMODE_H_DISPLAY:
|
|
|
|
ret = mode->HDisplay;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SYNCSTART:
|
|
|
|
ret = mode->HSyncStart;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SYNCEND:
|
|
|
|
ret = mode->HSyncEnd;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_TOTAL:
|
|
|
|
ret = mode->HTotal;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SKEW:
|
|
|
|
ret = mode->HSkew;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_DISPLAY:
|
|
|
|
ret = mode->VDisplay;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_SYNCSTART:
|
|
|
|
ret = mode->VSyncStart;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_SYNCEND:
|
|
|
|
ret = mode->VSyncEnd;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_TOTAL:
|
|
|
|
ret = mode->VTotal;
|
|
|
|
break;
|
|
|
|
case VIDMODE_FLAGS:
|
|
|
|
ret = mode->Flags;
|
|
|
|
break;
|
|
|
|
case VIDMODE_CLOCK:
|
|
|
|
ret = mode->Clock;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static void
|
|
|
|
VidModeSetModeValue(DisplayModePtr mode, int valtyp, int val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
switch (valtyp) {
|
|
|
|
case VIDMODE_H_DISPLAY:
|
|
|
|
mode->HDisplay = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SYNCSTART:
|
|
|
|
mode->HSyncStart = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SYNCEND:
|
|
|
|
mode->HSyncEnd = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_TOTAL:
|
|
|
|
mode->HTotal = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_H_SKEW:
|
|
|
|
mode->HSkew = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_DISPLAY:
|
|
|
|
mode->VDisplay = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_SYNCSTART:
|
|
|
|
mode->VSyncStart = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_SYNCEND:
|
|
|
|
mode->VSyncEnd = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_V_TOTAL:
|
|
|
|
mode->VTotal = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_FLAGS:
|
|
|
|
mode->Flags = val;
|
|
|
|
break;
|
|
|
|
case VIDMODE_CLOCK:
|
|
|
|
mode->Clock = val;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ClientMajorVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
VidModePrivPtr pPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pPriv = VM_GETPRIV(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pPriv)
|
2016-05-29 06:02:34 -06:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return pPriv->major;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeQueryVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86VidModeQueryVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION,
|
|
|
|
.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeQueryVersion");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.majorVersion);
|
|
|
|
swaps(&rep.minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetModeLineReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86VidModeGetModeLineReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence
|
|
|
|
};
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeGetModeline");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
|
|
|
|
SIZEOF(xGenericReply));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) -
|
|
|
|
SIZEOF(xGenericReply));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetCurrentModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
rep.dotclock = dotClock;
|
|
|
|
rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
|
|
|
|
rep.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
|
|
|
|
rep.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
|
|
|
|
rep.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
|
|
|
|
rep.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
|
|
|
|
rep.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
|
|
|
|
rep.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
|
|
|
|
rep.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
|
|
|
|
rep.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
|
|
|
|
rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("GetModeLine - scrn: %d clock: %ld\n",
|
|
|
|
stuff->screen, (unsigned long) rep.dotclock);
|
|
|
|
DebugF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
rep.hdisplay, rep.hsyncstart, rep.hsyncend, rep.htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
rep.vdisplay, rep.vsyncstart, rep.vsyncend,
|
|
|
|
rep.vtotal, (unsigned long) rep.flags);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
2015-09-16 13:10:19 -06:00
|
|
|
* Older servers sometimes had server privates that the VidMode
|
2006-11-26 11:13:41 -07:00
|
|
|
* extention made available. So to be compatiable pretend that
|
|
|
|
* there are no server privates to pass to the client
|
|
|
|
*/
|
|
|
|
rep.privsize = 0;
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.dotclock);
|
|
|
|
swaps(&rep.hdisplay);
|
|
|
|
swaps(&rep.hsyncstart);
|
|
|
|
swaps(&rep.hsyncend);
|
|
|
|
swaps(&rep.htotal);
|
|
|
|
swaps(&rep.hskew);
|
|
|
|
swaps(&rep.vdisplay);
|
|
|
|
swaps(&rep.vsyncstart);
|
|
|
|
swaps(&rep.vsyncend);
|
|
|
|
swaps(&rep.vtotal);
|
|
|
|
swapl(&rep.flags);
|
|
|
|
swapl(&rep.privsize);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (ver < 2) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86OldVidModeGetModeLineReply oldrep = {
|
|
|
|
.type = rep.type,
|
|
|
|
.sequenceNumber = rep.sequenceNumber,
|
|
|
|
.length = rep.length,
|
|
|
|
.dotclock = rep.dotclock,
|
|
|
|
.hdisplay = rep.hdisplay,
|
|
|
|
.hsyncstart = rep.hsyncstart,
|
|
|
|
.hsyncend = rep.hsyncend,
|
|
|
|
.htotal = rep.htotal,
|
|
|
|
.vdisplay = rep.vdisplay,
|
|
|
|
.vsyncstart = rep.vsyncstart,
|
|
|
|
.vsyncend = rep.vsyncend,
|
|
|
|
.vtotal = rep.vtotal,
|
|
|
|
.flags = rep.flags,
|
|
|
|
.privsize = rep.privsize
|
|
|
|
};
|
|
|
|
WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), &oldrep);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetAllModeLines(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetAllModeLinesReq);
|
|
|
|
xXF86VidModeGetAllModeLinesReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int modecount, dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeGetAllModelines");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
ver = ClientMajorVersion(client);
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
modecount = pVidMode->GetNumOfModes(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (modecount < 1)
|
2012-06-10 07:21:05 -06:00
|
|
|
return VidModeErrorBase + XF86VidModeExtensionDisabled;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetFirstModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeGetAllModeLinesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
|
|
|
|
SIZEOF(xGenericReply),
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.modecount = modecount
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length += modecount * sizeof(xXF86VidModeModeInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
rep.length >>= 2;
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.modecount);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
do {
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86VidModeModeInfo mdinf = {
|
|
|
|
.dotclock = dotClock,
|
|
|
|
.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
|
|
|
|
.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
|
|
|
|
.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
|
|
|
|
.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL),
|
|
|
|
.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW),
|
|
|
|
.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
|
|
|
|
.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
|
|
|
|
.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
|
|
|
|
.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
|
|
|
|
.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS),
|
|
|
|
.privsize = 0
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&mdinf.dotclock);
|
|
|
|
swaps(&mdinf.hdisplay);
|
|
|
|
swaps(&mdinf.hsyncstart);
|
|
|
|
swaps(&mdinf.hsyncend);
|
|
|
|
swaps(&mdinf.htotal);
|
|
|
|
swapl(&mdinf.hskew);
|
|
|
|
swaps(&mdinf.vdisplay);
|
|
|
|
swaps(&mdinf.vsyncstart);
|
|
|
|
swaps(&mdinf.vsyncend);
|
|
|
|
swaps(&mdinf.vtotal);
|
|
|
|
swapl(&mdinf.flags);
|
|
|
|
swapl(&mdinf.privsize);
|
|
|
|
}
|
|
|
|
if (ver < 2) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86OldVidModeModeInfo oldmdinf = {
|
|
|
|
.dotclock = mdinf.dotclock,
|
|
|
|
.hdisplay = mdinf.hdisplay,
|
|
|
|
.hsyncstart = mdinf.hsyncstart,
|
|
|
|
.hsyncend = mdinf.hsyncend,
|
|
|
|
.htotal = mdinf.htotal,
|
|
|
|
.vdisplay = mdinf.vdisplay,
|
|
|
|
.vsyncstart = mdinf.vsyncstart,
|
|
|
|
.vsyncend = mdinf.vsyncend,
|
|
|
|
.vtotal = mdinf.vtotal,
|
|
|
|
.flags = mdinf.flags,
|
|
|
|
.privsize = mdinf.privsize
|
|
|
|
};
|
|
|
|
WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), &oldmdinf);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeModeInfo), &mdinf);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
} while (pVidMode->GetNextModeline(pScreen, &mode, &dotClock));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MODEMATCH(mode,stuff) \
|
|
|
|
(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \
|
|
|
|
&& VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeAddModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeAddModeLineReq);
|
|
|
|
xXF86OldVidModeAddModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeAddModeLineReq newstuff;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int len;
|
|
|
|
int dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeAddModeline");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
2017-10-14 03:24:30 -06:00
|
|
|
|
|
|
|
if (ver < 2) {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* convert from old format */
|
|
|
|
stuff = &newstuff;
|
|
|
|
stuff->length = oldstuff->length;
|
|
|
|
stuff->screen = oldstuff->screen;
|
|
|
|
stuff->dotclock = oldstuff->dotclock;
|
|
|
|
stuff->hdisplay = oldstuff->hdisplay;
|
|
|
|
stuff->hsyncstart = oldstuff->hsyncstart;
|
|
|
|
stuff->hsyncend = oldstuff->hsyncend;
|
|
|
|
stuff->htotal = oldstuff->htotal;
|
|
|
|
stuff->hskew = 0;
|
|
|
|
stuff->vdisplay = oldstuff->vdisplay;
|
|
|
|
stuff->vsyncstart = oldstuff->vsyncstart;
|
|
|
|
stuff->vsyncend = oldstuff->vsyncend;
|
|
|
|
stuff->vtotal = oldstuff->vtotal;
|
|
|
|
stuff->flags = oldstuff->flags;
|
|
|
|
stuff->privsize = oldstuff->privsize;
|
|
|
|
stuff->after_dotclock = oldstuff->after_dotclock;
|
|
|
|
stuff->after_hdisplay = oldstuff->after_hdisplay;
|
|
|
|
stuff->after_hsyncstart = oldstuff->after_hsyncstart;
|
|
|
|
stuff->after_hsyncend = oldstuff->after_hsyncend;
|
|
|
|
stuff->after_htotal = oldstuff->after_htotal;
|
|
|
|
stuff->after_hskew = 0;
|
|
|
|
stuff->after_vdisplay = oldstuff->after_vdisplay;
|
|
|
|
stuff->after_vsyncstart = oldstuff->after_vsyncstart;
|
|
|
|
stuff->after_vsyncend = oldstuff->after_vsyncend;
|
|
|
|
stuff->after_vtotal = oldstuff->after_vtotal;
|
|
|
|
stuff->after_flags = oldstuff->after_flags;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("AddModeLine - scrn: %d clock: %ld\n",
|
|
|
|
(int) stuff->screen, (unsigned long) stuff->dotclock);
|
|
|
|
DebugF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
stuff->hdisplay, stuff->hsyncstart,
|
|
|
|
stuff->hsyncend, stuff->htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
|
|
|
|
stuff->vtotal, (unsigned long) stuff->flags);
|
|
|
|
DebugF(" after - scrn: %d clock: %ld\n",
|
|
|
|
(int) stuff->screen, (unsigned long) stuff->after_dotclock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
stuff->after_hdisplay, stuff->after_hsyncstart,
|
|
|
|
stuff->after_hsyncend, stuff->after_htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->after_vdisplay, stuff->after_vsyncstart,
|
|
|
|
stuff->after_vsyncend, stuff->after_vtotal,
|
|
|
|
(unsigned long) stuff->after_flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (len != stuff->privsize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->hsyncstart < stuff->hdisplay ||
|
|
|
|
stuff->hsyncend < stuff->hsyncstart ||
|
|
|
|
stuff->htotal < stuff->hsyncend ||
|
|
|
|
stuff->vsyncstart < stuff->vdisplay ||
|
|
|
|
stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
|
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
if (stuff->after_hsyncstart < stuff->after_hdisplay ||
|
|
|
|
stuff->after_hsyncend < stuff->after_hsyncstart ||
|
|
|
|
stuff->after_htotal < stuff->after_hsyncend ||
|
|
|
|
stuff->after_vsyncstart < stuff->after_vdisplay ||
|
|
|
|
stuff->after_vsyncend < stuff->after_vsyncstart ||
|
|
|
|
stuff->after_vtotal < stuff->after_vsyncend)
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool found = FALSE;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (pVidMode->GetFirstModeline(pScreen, &mode, &dotClock)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
do {
|
2016-05-29 06:02:34 -06:00
|
|
|
if ((pVidMode->GetDotClock(pScreen, stuff->dotclock)
|
2012-06-10 07:21:05 -06:00
|
|
|
== dotClock) && MODEMATCH(mode, stuff)) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
} while (pVidMode->GetNextModeline(pScreen, &mode, &dotClock));
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mode = VidModeCreateMode();
|
|
|
|
if (mode == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_CLOCK, stuff->dotclock);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
|
|
|
|
|
|
|
|
if (stuff->privsize)
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("AddModeLine - Privates in request have been ignored\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Check that the mode is consistent with the monitor specs */
|
2016-05-29 06:02:34 -06:00
|
|
|
switch (pVidMode->CheckModeForMonitor(pScreen, mode)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case MODE_OK:
|
|
|
|
break;
|
|
|
|
case MODE_HSYNC:
|
|
|
|
case MODE_H_ILLEGAL:
|
|
|
|
free(mode);
|
|
|
|
return VidModeErrorBase + XF86VidModeBadHTimings;
|
|
|
|
case MODE_VSYNC:
|
|
|
|
case MODE_V_ILLEGAL:
|
|
|
|
free(mode);
|
|
|
|
return VidModeErrorBase + XF86VidModeBadVTimings;
|
|
|
|
default:
|
|
|
|
free(mode);
|
|
|
|
return VidModeErrorBase + XF86VidModeModeUnsuitable;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that the driver is happy with the mode */
|
2016-05-29 06:02:34 -06:00
|
|
|
if (pVidMode->CheckModeForDriver(pScreen, mode) != MODE_OK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mode);
|
|
|
|
return VidModeErrorBase + XF86VidModeModeUnsuitable;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode->SetCrtcForMode(pScreen, mode);
|
|
|
|
|
|
|
|
pVidMode->AddModeline(pScreen, mode);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("AddModeLine - Succeeded\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeDeleteModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeDeleteModeLineReq);
|
|
|
|
xXF86OldVidModeDeleteModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeDeleteModeLineReq newstuff;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int len, dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeDeleteModeline");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
2017-10-14 03:24:30 -06:00
|
|
|
|
|
|
|
if (ver < 2) {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* convert from old format */
|
|
|
|
stuff = &newstuff;
|
|
|
|
stuff->length = oldstuff->length;
|
|
|
|
stuff->screen = oldstuff->screen;
|
|
|
|
stuff->dotclock = oldstuff->dotclock;
|
|
|
|
stuff->hdisplay = oldstuff->hdisplay;
|
|
|
|
stuff->hsyncstart = oldstuff->hsyncstart;
|
|
|
|
stuff->hsyncend = oldstuff->hsyncend;
|
|
|
|
stuff->htotal = oldstuff->htotal;
|
|
|
|
stuff->hskew = 0;
|
|
|
|
stuff->vdisplay = oldstuff->vdisplay;
|
|
|
|
stuff->vsyncstart = oldstuff->vsyncstart;
|
|
|
|
stuff->vsyncend = oldstuff->vsyncend;
|
|
|
|
stuff->vtotal = oldstuff->vtotal;
|
|
|
|
stuff->flags = oldstuff->flags;
|
|
|
|
stuff->privsize = oldstuff->privsize;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("DeleteModeLine - scrn: %d clock: %ld\n",
|
|
|
|
(int) stuff->screen, (unsigned long) stuff->dotclock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
stuff->hdisplay, stuff->hsyncstart,
|
|
|
|
stuff->hsyncend, stuff->htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
|
|
|
|
(unsigned long) stuff->flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (len != stuff->privsize) {
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
|
|
|
|
"len = %d, length = %d\n",
|
|
|
|
(unsigned long) client->req_len,
|
|
|
|
(int) sizeof(xXF86VidModeDeleteModeLineReq) >> 2,
|
|
|
|
(unsigned long) stuff->privsize, len, stuff->length);
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
if (!pVidMode->GetCurrentModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("Checking against clock: %d (%d)\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_FLAGS));
|
|
|
|
|
|
|
|
if ((pVidMode->GetDotClock(pScreen, stuff->dotclock) == dotClock) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
MODEMATCH(mode, stuff))
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetFirstModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
do {
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("Checking against clock: %d (%d)\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_FLAGS));
|
|
|
|
|
|
|
|
if ((pVidMode->GetDotClock(pScreen, stuff->dotclock) == dotClock) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
MODEMATCH(mode, stuff)) {
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode->DeleteModeline(pScreen, mode);
|
|
|
|
DebugF("DeleteModeLine - Succeeded\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
} while (pVidMode->GetNextModeline(pScreen, &mode, &dotClock));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeModModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeModModeLineReq);
|
|
|
|
xXF86OldVidModeModModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeModModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeModModeLineReq newstuff;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode, modetmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
int len, dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeModModeline");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
2017-10-14 03:24:30 -06:00
|
|
|
|
|
|
|
if (ver < 2) {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ver < 2) {
|
|
|
|
/* convert from old format */
|
|
|
|
stuff = &newstuff;
|
|
|
|
stuff->length = oldstuff->length;
|
|
|
|
stuff->screen = oldstuff->screen;
|
|
|
|
stuff->hdisplay = oldstuff->hdisplay;
|
|
|
|
stuff->hsyncstart = oldstuff->hsyncstart;
|
|
|
|
stuff->hsyncend = oldstuff->hsyncend;
|
|
|
|
stuff->htotal = oldstuff->htotal;
|
|
|
|
stuff->hskew = 0;
|
|
|
|
stuff->vdisplay = oldstuff->vdisplay;
|
|
|
|
stuff->vsyncstart = oldstuff->vsyncstart;
|
|
|
|
stuff->vsyncend = oldstuff->vsyncend;
|
|
|
|
stuff->vtotal = oldstuff->vtotal;
|
|
|
|
stuff->flags = oldstuff->flags;
|
|
|
|
stuff->privsize = oldstuff->privsize;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
(int) stuff->screen, stuff->hdisplay, stuff->hsyncstart,
|
|
|
|
stuff->hsyncend, stuff->htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
|
|
|
|
stuff->vtotal, (unsigned long) stuff->flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (len != stuff->privsize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->hsyncstart < stuff->hdisplay ||
|
|
|
|
stuff->hsyncend < stuff->hsyncstart ||
|
|
|
|
stuff->htotal < stuff->hsyncend ||
|
|
|
|
stuff->vsyncstart < stuff->vdisplay ||
|
|
|
|
stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetCurrentModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
modetmp = VidModeCreateMode();
|
|
|
|
VidModeCopyMode(mode, modetmp);
|
|
|
|
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
|
|
|
|
|
|
|
|
if (stuff->privsize)
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("ModModeLine - Privates in request have been ignored\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Check that the mode is consistent with the monitor specs */
|
2016-05-29 06:02:34 -06:00
|
|
|
switch (pVidMode->CheckModeForMonitor(pScreen, modetmp)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case MODE_OK:
|
|
|
|
break;
|
|
|
|
case MODE_HSYNC:
|
|
|
|
case MODE_H_ILLEGAL:
|
|
|
|
free(modetmp);
|
|
|
|
return VidModeErrorBase + XF86VidModeBadHTimings;
|
|
|
|
case MODE_VSYNC:
|
|
|
|
case MODE_V_ILLEGAL:
|
|
|
|
free(modetmp);
|
|
|
|
return VidModeErrorBase + XF86VidModeBadVTimings;
|
|
|
|
default:
|
|
|
|
free(modetmp);
|
|
|
|
return VidModeErrorBase + XF86VidModeModeUnsuitable;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that the driver is happy with the mode */
|
2016-05-29 06:02:34 -06:00
|
|
|
if (pVidMode->CheckModeForDriver(pScreen, modetmp) != MODE_OK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(modetmp);
|
|
|
|
return VidModeErrorBase + XF86VidModeModeUnsuitable;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(modetmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
|
|
|
|
VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode->SetCrtcForMode(pScreen, mode);
|
|
|
|
pVidMode->SwitchMode(pScreen, mode);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("ModModeLine - Succeeded\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeValidateModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeValidateModeLineReq);
|
|
|
|
xXF86OldVidModeValidateModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeValidateModeLineReq newstuff;
|
|
|
|
xXF86VidModeValidateModeLineReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode, modetmp = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
int len, status, dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeValidateModeline");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
2017-10-14 03:24:30 -06:00
|
|
|
|
|
|
|
if (ver < 2) {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
|
|
|
|
len = client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* convert from old format */
|
|
|
|
stuff = &newstuff;
|
|
|
|
stuff->length = oldstuff->length;
|
|
|
|
stuff->screen = oldstuff->screen;
|
|
|
|
stuff->dotclock = oldstuff->dotclock;
|
|
|
|
stuff->hdisplay = oldstuff->hdisplay;
|
|
|
|
stuff->hsyncstart = oldstuff->hsyncstart;
|
|
|
|
stuff->hsyncend = oldstuff->hsyncend;
|
|
|
|
stuff->htotal = oldstuff->htotal;
|
|
|
|
stuff->hskew = 0;
|
|
|
|
stuff->vdisplay = oldstuff->vdisplay;
|
|
|
|
stuff->vsyncstart = oldstuff->vsyncstart;
|
|
|
|
stuff->vsyncend = oldstuff->vsyncend;
|
|
|
|
stuff->vtotal = oldstuff->vtotal;
|
|
|
|
stuff->flags = oldstuff->flags;
|
|
|
|
stuff->privsize = oldstuff->privsize;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
|
|
|
|
DebugF("ValidateModeLine - scrn: %d clock: %ld\n",
|
|
|
|
(int) stuff->screen, (unsigned long) stuff->dotclock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
stuff->hdisplay, stuff->hsyncstart,
|
|
|
|
stuff->hsyncend, stuff->htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
|
|
|
|
(unsigned long) stuff->flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (len != stuff->privsize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
status = MODE_OK;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->hsyncstart < stuff->hdisplay ||
|
|
|
|
stuff->hsyncend < stuff->hsyncstart ||
|
|
|
|
stuff->htotal < stuff->hsyncend ||
|
|
|
|
stuff->vsyncstart < stuff->vdisplay ||
|
|
|
|
stuff->vsyncend < stuff->vsyncstart ||
|
|
|
|
stuff->vtotal < stuff->vsyncend) {
|
|
|
|
status = MODE_BAD;
|
|
|
|
goto status_reply;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
if (!pVidMode->GetCurrentModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
modetmp = VidModeCreateMode();
|
|
|
|
VidModeCopyMode(mode, modetmp);
|
|
|
|
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
|
2006-11-26 11:13:41 -07:00
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
|
|
|
|
VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
|
|
|
|
if (stuff->privsize)
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("ValidateModeLine - Privates in request have been ignored\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Check that the mode is consistent with the monitor specs */
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status =
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode->CheckModeForMonitor(pScreen, modetmp)) != MODE_OK)
|
2012-06-10 07:21:05 -06:00
|
|
|
goto status_reply;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Check that the driver is happy with the mode */
|
2016-05-29 06:02:34 -06:00
|
|
|
status = pVidMode->CheckModeForDriver(pScreen, modetmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status_reply:
|
2010-12-05 08:36:02 -07:00
|
|
|
free(modetmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeValidateModeLineReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
|
|
|
|
- SIZEOF(xGenericReply)),
|
|
|
|
.status = status
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.status);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), &rep);
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("ValidateModeLine - Succeeded (status = %d)\n", status);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSwitchMode(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSwitchModeReq);
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeSwitchMode");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
pVidMode->ZoomViewport(pScreen, (short) stuff->zoom);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSwitchToMode(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSwitchToModeReq);
|
|
|
|
xXF86OldVidModeSwitchToModeReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeSwitchToModeReq newstuff;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int len, dotClock;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeSwitchToMode");
|
|
|
|
|
|
|
|
ver = ClientMajorVersion(client);
|
2017-10-14 03:24:30 -06:00
|
|
|
|
|
|
|
if (ver < 2) {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
|
|
|
|
len =
|
|
|
|
client->req_len -
|
|
|
|
bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* convert from old format */
|
|
|
|
stuff = &newstuff;
|
|
|
|
stuff->length = oldstuff->length;
|
|
|
|
stuff->screen = oldstuff->screen;
|
|
|
|
stuff->dotclock = oldstuff->dotclock;
|
|
|
|
stuff->hdisplay = oldstuff->hdisplay;
|
|
|
|
stuff->hsyncstart = oldstuff->hsyncstart;
|
|
|
|
stuff->hsyncend = oldstuff->hsyncend;
|
|
|
|
stuff->htotal = oldstuff->htotal;
|
|
|
|
stuff->hskew = 0;
|
|
|
|
stuff->vdisplay = oldstuff->vdisplay;
|
|
|
|
stuff->vsyncstart = oldstuff->vsyncstart;
|
|
|
|
stuff->vsyncend = oldstuff->vsyncend;
|
|
|
|
stuff->vtotal = oldstuff->vtotal;
|
|
|
|
stuff->flags = oldstuff->flags;
|
|
|
|
stuff->privsize = oldstuff->privsize;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
|
|
|
|
DebugF("SwitchToMode - scrn: %d clock: %ld\n",
|
|
|
|
(int) stuff->screen, (unsigned long) stuff->dotclock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
stuff->hdisplay, stuff->hsyncstart,
|
|
|
|
stuff->hsyncend, stuff->htotal);
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
|
|
|
|
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
|
|
|
|
(unsigned long) stuff->flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (len != stuff->privsize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetCurrentModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if ((pVidMode->GetDotClock(pScreen, stuff->dotclock) == dotClock)
|
2012-06-10 07:21:05 -06:00
|
|
|
&& MODEMATCH(mode, stuff))
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetFirstModeline(pScreen, &mode, &dotClock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
do {
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("Checking against clock: %d (%d)\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
|
|
|
|
DebugF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
|
|
|
|
DebugF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
|
|
|
|
VidModeGetModeValue(mode, VIDMODE_FLAGS));
|
|
|
|
|
|
|
|
if ((pVidMode->GetDotClock(pScreen, stuff->dotclock) == dotClock) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
MODEMATCH(mode, stuff)) {
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->SwitchMode(pScreen, mode))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DebugF("SwitchToMode - Succeeded\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
} while (pVidMode->GetNextModeline(pScreen, &mode, &dotClock));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeLockModeSwitch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeLockModeSwitchReq);
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeLockModeSwitch");
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->LockZoom(pScreen, (short) stuff->lock))
|
2012-06-10 07:21:05 -06:00
|
|
|
return VidModeErrorBase + XF86VidModeZoomLocked;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetMonitor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetMonitorReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86VidModeGetMonitorReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
CARD32 *hsyncdata, *vsyncdata;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
int i, nHsync, nVrefresh;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
DEBUG_P("XF86VidModeGetMonitor");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
nHsync = pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_NHSYNC, 0).i;
|
|
|
|
nVrefresh = pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_NVREFRESH, 0).i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if ((char *) (pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_VENDOR, 0)).ptr)
|
|
|
|
rep.vendorLength = strlen((char *) (pVidMode->GetMonitorValue(pScreen,
|
|
|
|
VIDMODE_MON_VENDOR,
|
|
|
|
0)).ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.vendorLength = 0;
|
2016-05-29 06:02:34 -06:00
|
|
|
if ((char *) (pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_MODEL, 0)).ptr)
|
|
|
|
rep.modelLength = strlen((char *) (pVidMode->GetMonitorValue(pScreen,
|
|
|
|
VIDMODE_MON_MODEL,
|
|
|
|
0)).ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.modelLength = 0;
|
|
|
|
rep.length =
|
|
|
|
bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) -
|
|
|
|
SIZEOF(xGenericReply) + (nHsync +
|
|
|
|
nVrefresh) * sizeof(CARD32) +
|
|
|
|
pad_to_int32(rep.vendorLength) +
|
|
|
|
pad_to_int32(rep.modelLength));
|
2006-11-26 11:13:41 -07:00
|
|
|
rep.nhsync = nHsync;
|
|
|
|
rep.nvsync = nVrefresh;
|
2016-05-29 06:02:34 -06:00
|
|
|
hsyncdata = xallocarray(nHsync, sizeof(CARD32));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!hsyncdata) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
vsyncdata = xallocarray(nVrefresh, sizeof(CARD32));
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!vsyncdata) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(hsyncdata);
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nHsync; i++) {
|
2016-05-29 06:02:34 -06:00
|
|
|
hsyncdata[i] = (unsigned short) (pVidMode->GetMonitorValue(pScreen,
|
|
|
|
VIDMODE_MON_HSYNC_LO,
|
|
|
|
i)).f |
|
2012-06-10 07:21:05 -06:00
|
|
|
(unsigned
|
2016-05-29 06:02:34 -06:00
|
|
|
short) (pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_HSYNC_HI,
|
|
|
|
i)).f << 16;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
for (i = 0; i < nVrefresh; i++) {
|
2016-05-29 06:02:34 -06:00
|
|
|
vsyncdata[i] = (unsigned short) (pVidMode->GetMonitorValue(pScreen,
|
|
|
|
VIDMODE_MON_VREFRESH_LO,
|
|
|
|
i)).f |
|
2012-06-10 07:21:05 -06:00
|
|
|
(unsigned
|
2016-05-29 06:02:34 -06:00
|
|
|
short) (pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_VREFRESH_HI,
|
|
|
|
i)).f << 16;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), hsyncdata);
|
|
|
|
WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), vsyncdata);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (rep.vendorLength)
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, rep.vendorLength,
|
2016-05-29 06:02:34 -06:00
|
|
|
(pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_VENDOR, 0)).ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (rep.modelLength)
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, rep.modelLength,
|
2016-05-29 06:02:34 -06:00
|
|
|
(pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_MODEL, 0)).ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(hsyncdata);
|
|
|
|
free(vsyncdata);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetViewPort(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetViewPortReq);
|
|
|
|
xXF86VidModeGetViewPortReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2012-06-10 07:21:05 -06:00
|
|
|
int x, y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeGetViewPort");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode->GetViewPort(pScreen, &x, &y);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
rep = (xXF86VidModeGetViewPortReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.x = x,
|
|
|
|
.y = y
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.x);
|
|
|
|
swapl(&rep.y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSetViewPort(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetViewPortReq);
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeSetViewPort");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->SetViewPort(pScreen, stuff->x, stuff->y))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetDotClocks(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetDotClocksReq);
|
|
|
|
xXF86VidModeGetDotClocksReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2012-06-10 07:21:05 -06:00
|
|
|
int n;
|
2006-11-26 11:13:41 -07:00
|
|
|
int numClocks;
|
|
|
|
CARD32 dotclock;
|
|
|
|
int *Clocks = NULL;
|
|
|
|
Bool ClockProg;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeGetDotClocks");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
numClocks = pVidMode->GetNumOfClocks(pScreen, &ClockProg);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeGetDotClocksReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
|
|
|
|
- SIZEOF(xGenericReply) + numClocks),
|
|
|
|
.clocks = numClocks,
|
|
|
|
.maxclocks = MAXCLOCKS,
|
|
|
|
.flags = 0
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!ClockProg) {
|
2013-06-07 11:28:45 -06:00
|
|
|
Clocks = calloc(numClocks, sizeof(int));
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!Clocks)
|
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetClocks(pScreen, Clocks)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(Clocks);
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (ClockProg) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.flags |= CLKFLAG_PROGRAMABLE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.clocks);
|
|
|
|
swapl(&rep.maxclocks);
|
|
|
|
swapl(&rep.flags);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!ClockProg) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (n = 0; n < numClocks; n++) {
|
2017-12-08 08:01:59 -07:00
|
|
|
dotclock = Clocks[n];
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
WriteSwappedDataToClient(client, 4, (char *) &dotclock);
|
|
|
|
}
|
|
|
|
else {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, 4, &dotclock);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(Clocks);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSetGamma(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetGammaReq);
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeSetGamma");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->SetGamma(pScreen, ((float) stuff->red) / 10000.,
|
2012-06-10 07:21:05 -06:00
|
|
|
((float) stuff->green) / 10000.,
|
|
|
|
((float) stuff->blue) / 10000.))
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetGamma(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetGammaReq);
|
|
|
|
xXF86VidModeGetGammaReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
float red, green, blue;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeGetGamma");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetGamma(pScreen, &red, &green, &blue))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeGetGammaReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.red = (CARD32) (red * 10000.),
|
|
|
|
.green = (CARD32) (green * 10000.),
|
|
|
|
.blue = (CARD32) (blue * 10000.)
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.red);
|
|
|
|
swapl(&rep.green);
|
|
|
|
swapl(&rep.blue);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSetGammaRamp(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
CARD16 *r, *g, *b;
|
|
|
|
int length;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeSetGammaRampReq);
|
2017-10-14 03:24:30 -06:00
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
if (stuff->size != pVidMode->GetGammaRampSize(pScreen))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
length = (stuff->size + 1) & ~1;
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
r = (CARD16 *) &stuff[1];
|
2006-11-26 11:13:41 -07:00
|
|
|
g = r + length;
|
|
|
|
b = g + length;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->SetGammaRamp(pScreen, stuff->size, r, g, b))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetGammaRamp(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
CARD16 *ramp = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
int length;
|
2010-07-27 13:02:24 -06:00
|
|
|
size_t ramplen = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
xXF86VidModeGetGammaRampReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeGetGammaRampReq);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (stuff->size != pVidMode->GetGammaRampSize(pScreen))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
length = (stuff->size + 1) & ~1;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->size) {
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!(ramp = xallocarray(length, 3 * sizeof(CARD16))))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2016-05-29 06:02:34 -06:00
|
|
|
ramplen = length * 3 * sizeof(CARD16);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!pVidMode->GetGammaRamp(pScreen, stuff->size,
|
2012-06-10 07:21:05 -06:00
|
|
|
ramp, ramp + length, ramp + (length * 2))) {
|
|
|
|
free(ramp);
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeGetGammaRampReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = (length >> 1) * 3,
|
|
|
|
.size = stuff->size
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.size);
|
|
|
|
SwapShorts((short *) ramp, length * 3);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->size) {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, ramplen, ramp);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(ramp);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetGammaRampSize(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXF86VidModeGetGammaRampSizeReply rep;
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VidModePtr pVidMode;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeGetGammaRampSizeReq);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
|
|
|
pVidMode = VidModeGetPtr(pScreen);
|
|
|
|
if (pVidMode == NULL)
|
|
|
|
return BadImplementation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXF86VidModeGetGammaRampSizeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
2016-05-29 06:02:34 -06:00
|
|
|
.size = pVidMode->GetGammaRampSize(pScreen)
|
2013-06-07 11:28:45 -06:00
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.size);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeGetPermissions(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xXF86VidModeGetPermissionsReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.permissions = XF86VM_READ_PERMISSION
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeGetPermissionsReq);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->screen >= screenInfo.numScreens)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (VidModeAllowNonLocal || client->local) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.permissions |= XF86VM_WRITE_PERMISSION;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.permissions);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeSetClientVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetClientVersionReq);
|
|
|
|
|
|
|
|
VidModePrivPtr pPriv;
|
|
|
|
|
|
|
|
DEBUG_P("XF86VidModeSetClientVersion");
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if ((pPriv = VM_GETPRIV(client)) == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pPriv = malloc(sizeof(VidModePrivRec));
|
|
|
|
if (!pPriv)
|
|
|
|
return BadAlloc;
|
|
|
|
VM_SETPRIV(client, pPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pPriv->major = stuff->major;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pPriv->minor = stuff->minor;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-29 06:02:34 -06:00
|
|
|
ProcVidModeDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeQueryVersion:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeQueryVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetMonitor:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetMonitor(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetAllModeLines:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetAllModeLines(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeValidateModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeValidateModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetViewPort:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetViewPort(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetDotClocks:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetDotClocks(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeSetClientVersion:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetClientVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGamma:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGamma(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGammaRamp:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGammaRamp(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGammaRampSize:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGammaRampSize(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetPermissions:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetPermissions(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2016-05-29 06:02:34 -06:00
|
|
|
if (VidModeAllowNonLocal || client->local) {
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
|
|
|
case X_XF86VidModeAddModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeAddModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeDeleteModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeDeleteModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeModModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeModModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSwitchMode:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSwitchMode(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSwitchToMode:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSwitchToMode(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeLockModeSwitch:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeLockModeSwitch(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetViewPort:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetViewPort(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetGamma:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetGamma(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetGammaRamp:
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetGammaRamp(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
return BadRequest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return VidModeErrorBase + XF86VidModeClientNotLocal;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeQueryVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeQueryVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeQueryVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetModeLineReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetAllModeLines(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetAllModeLinesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetAllModeLines(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeAddModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXF86OldVidModeAddModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
int ver;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeAddModeLineReq);
|
|
|
|
ver = ClientMajorVersion(client);
|
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&oldstuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
|
|
|
|
swapl(&oldstuff->screen);
|
|
|
|
swaps(&oldstuff->hdisplay);
|
|
|
|
swaps(&oldstuff->hsyncstart);
|
|
|
|
swaps(&oldstuff->hsyncend);
|
|
|
|
swaps(&oldstuff->htotal);
|
|
|
|
swaps(&oldstuff->vdisplay);
|
|
|
|
swaps(&oldstuff->vsyncstart);
|
|
|
|
swaps(&oldstuff->vsyncend);
|
|
|
|
swaps(&oldstuff->vtotal);
|
|
|
|
swapl(&oldstuff->flags);
|
|
|
|
swapl(&oldstuff->privsize);
|
|
|
|
SwapRestL(oldstuff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
swaps(&stuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
|
|
|
|
swapl(&stuff->screen);
|
|
|
|
swaps(&stuff->hdisplay);
|
|
|
|
swaps(&stuff->hsyncstart);
|
|
|
|
swaps(&stuff->hsyncend);
|
|
|
|
swaps(&stuff->htotal);
|
|
|
|
swaps(&stuff->hskew);
|
|
|
|
swaps(&stuff->vdisplay);
|
|
|
|
swaps(&stuff->vsyncstart);
|
|
|
|
swaps(&stuff->vsyncend);
|
|
|
|
swaps(&stuff->vtotal);
|
|
|
|
swapl(&stuff->flags);
|
|
|
|
swapl(&stuff->privsize);
|
|
|
|
SwapRestL(stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeAddModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeDeleteModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXF86OldVidModeDeleteModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
int ver;
|
|
|
|
|
|
|
|
REQUEST(xXF86VidModeDeleteModeLineReq);
|
|
|
|
ver = ClientMajorVersion(client);
|
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&oldstuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
|
|
|
|
swapl(&oldstuff->screen);
|
|
|
|
swaps(&oldstuff->hdisplay);
|
|
|
|
swaps(&oldstuff->hsyncstart);
|
|
|
|
swaps(&oldstuff->hsyncend);
|
|
|
|
swaps(&oldstuff->htotal);
|
|
|
|
swaps(&oldstuff->vdisplay);
|
|
|
|
swaps(&oldstuff->vsyncstart);
|
|
|
|
swaps(&oldstuff->vsyncend);
|
|
|
|
swaps(&oldstuff->vtotal);
|
|
|
|
swapl(&oldstuff->flags);
|
|
|
|
swapl(&oldstuff->privsize);
|
|
|
|
SwapRestL(oldstuff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
swaps(&stuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
|
|
|
|
swapl(&stuff->screen);
|
|
|
|
swaps(&stuff->hdisplay);
|
|
|
|
swaps(&stuff->hsyncstart);
|
|
|
|
swaps(&stuff->hsyncend);
|
|
|
|
swaps(&stuff->htotal);
|
|
|
|
swaps(&stuff->hskew);
|
|
|
|
swaps(&stuff->vdisplay);
|
|
|
|
swaps(&stuff->vsyncstart);
|
|
|
|
swaps(&stuff->vsyncend);
|
|
|
|
swaps(&stuff->vtotal);
|
|
|
|
swapl(&stuff->flags);
|
|
|
|
swapl(&stuff->privsize);
|
|
|
|
SwapRestL(stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeDeleteModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeModModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXF86OldVidModeModModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeModModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
int ver;
|
|
|
|
|
|
|
|
REQUEST(xXF86VidModeModModeLineReq);
|
|
|
|
ver = ClientMajorVersion(client);
|
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&oldstuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
|
|
|
|
swapl(&oldstuff->screen);
|
|
|
|
swaps(&oldstuff->hdisplay);
|
|
|
|
swaps(&oldstuff->hsyncstart);
|
|
|
|
swaps(&oldstuff->hsyncend);
|
|
|
|
swaps(&oldstuff->htotal);
|
|
|
|
swaps(&oldstuff->vdisplay);
|
|
|
|
swaps(&oldstuff->vsyncstart);
|
|
|
|
swaps(&oldstuff->vsyncend);
|
|
|
|
swaps(&oldstuff->vtotal);
|
|
|
|
swapl(&oldstuff->flags);
|
|
|
|
swapl(&oldstuff->privsize);
|
|
|
|
SwapRestL(oldstuff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
swaps(&stuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
|
|
|
|
swapl(&stuff->screen);
|
|
|
|
swaps(&stuff->hdisplay);
|
|
|
|
swaps(&stuff->hsyncstart);
|
|
|
|
swaps(&stuff->hsyncend);
|
|
|
|
swaps(&stuff->htotal);
|
|
|
|
swaps(&stuff->hskew);
|
|
|
|
swaps(&stuff->vdisplay);
|
|
|
|
swaps(&stuff->vsyncstart);
|
|
|
|
swaps(&stuff->vsyncend);
|
|
|
|
swaps(&stuff->vtotal);
|
|
|
|
swapl(&stuff->flags);
|
|
|
|
swapl(&stuff->privsize);
|
|
|
|
SwapRestL(stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeModModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeValidateModeLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXF86OldVidModeValidateModeLineReq *oldstuff =
|
2012-06-10 07:21:05 -06:00
|
|
|
(xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
int ver;
|
|
|
|
|
|
|
|
REQUEST(xXF86VidModeValidateModeLineReq);
|
|
|
|
ver = ClientMajorVersion(client);
|
|
|
|
if (ver < 2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&oldstuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
|
|
|
|
swapl(&oldstuff->screen);
|
|
|
|
swaps(&oldstuff->hdisplay);
|
|
|
|
swaps(&oldstuff->hsyncstart);
|
|
|
|
swaps(&oldstuff->hsyncend);
|
|
|
|
swaps(&oldstuff->htotal);
|
|
|
|
swaps(&oldstuff->vdisplay);
|
|
|
|
swaps(&oldstuff->vsyncstart);
|
|
|
|
swaps(&oldstuff->vsyncend);
|
|
|
|
swaps(&oldstuff->vtotal);
|
|
|
|
swapl(&oldstuff->flags);
|
|
|
|
swapl(&oldstuff->privsize);
|
|
|
|
SwapRestL(oldstuff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
swaps(&stuff->length);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
|
|
|
|
swapl(&stuff->screen);
|
|
|
|
swaps(&stuff->hdisplay);
|
|
|
|
swaps(&stuff->hsyncstart);
|
|
|
|
swaps(&stuff->hsyncend);
|
|
|
|
swaps(&stuff->htotal);
|
|
|
|
swaps(&stuff->hskew);
|
|
|
|
swaps(&stuff->vdisplay);
|
|
|
|
swaps(&stuff->vsyncstart);
|
|
|
|
swaps(&stuff->vsyncend);
|
|
|
|
swaps(&stuff->vtotal);
|
|
|
|
swapl(&stuff->flags);
|
|
|
|
swapl(&stuff->privsize);
|
|
|
|
SwapRestL(stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeValidateModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSwitchMode(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSwitchModeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
|
|
|
swaps(&stuff->zoom);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSwitchMode(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSwitchToMode(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSwitchToModeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSwitchToMode(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeLockModeSwitch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeLockModeSwitchReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
|
|
|
swaps(&stuff->lock);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeLockModeSwitch(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetMonitor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetMonitorReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetMonitor(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetViewPort(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetViewPortReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetViewPort(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSetViewPort(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetViewPortReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
|
|
|
swapl(&stuff->x);
|
|
|
|
swapl(&stuff->y);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetViewPort(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetDotClocks(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetDotClocksReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetDotClocks(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSetClientVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetClientVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->major);
|
|
|
|
swaps(&stuff->minor);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetClientVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSetGamma(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeSetGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
|
|
|
swapl(&stuff->red);
|
|
|
|
swapl(&stuff->green);
|
|
|
|
swapl(&stuff->blue);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetGamma(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetGamma(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGamma(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeSetGammaRamp(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int length;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeSetGammaRampReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->size);
|
|
|
|
swaps(&stuff->screen);
|
2006-11-26 11:13:41 -07:00
|
|
|
length = ((stuff->size + 1) & ~1) * 6;
|
|
|
|
REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
|
2009-09-06 13:44:18 -06:00
|
|
|
SwapRestS(stuff);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeSetGammaRamp(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetGammaRamp(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86VidModeGetGammaRampReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->size);
|
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGammaRamp(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetGammaRampSize(ClientPtr client)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeGetGammaRampSizeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetGammaRampSize(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeGetPermissions(ClientPtr client)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xXF86VidModeGetPermissionsReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->screen);
|
2016-05-29 06:02:34 -06:00
|
|
|
return ProcVidModeGetPermissions(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2016-05-29 06:02:34 -06:00
|
|
|
SProcVidModeDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeQueryVersion:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeQueryVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetMonitor:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetMonitor(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetAllModeLines:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetAllModeLines(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetViewPort:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetViewPort(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeValidateModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeValidateModeLine(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetDotClocks:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetDotClocks(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeSetClientVersion:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSetClientVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGamma:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetGamma(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGammaRamp:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetGammaRamp(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetGammaRampSize:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetGammaRampSize(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XF86VidModeGetPermissions:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeGetPermissions(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2016-05-29 06:02:34 -06:00
|
|
|
if (VidModeAllowNonLocal || client->local) {
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
|
|
|
case X_XF86VidModeAddModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeAddModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeDeleteModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeDeleteModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeModModeLine:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeModModeLine(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSwitchMode:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSwitchMode(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSwitchToMode:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSwitchToMode(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeLockModeSwitch:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeLockModeSwitch(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetViewPort:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSetViewPort(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetGamma:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSetGamma(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
case X_XF86VidModeSetGammaRamp:
|
2016-05-29 06:02:34 -06:00
|
|
|
return SProcVidModeSetGammaRamp(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
return BadRequest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return VidModeErrorBase + XF86VidModeClientNotLocal;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
void
|
2016-05-29 06:02:34 -06:00
|
|
|
VidModeAddExtension(Bool allow_non_local)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExtensionEntry *extEntry;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
DEBUG_P("VidModeAddExtension");
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!dixRegisterPrivateKey(VidModeClientPrivateKey, PRIVATE_CLIENT, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if ((extEntry = AddExtension(XF86VIDMODENAME,
|
|
|
|
XF86VidModeNumberEvents,
|
|
|
|
XF86VidModeNumberErrors,
|
|
|
|
ProcVidModeDispatch,
|
|
|
|
SProcVidModeDispatch,
|
|
|
|
NULL, StandardMinorOpcode))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
VidModeErrorBase = extEntry->errorBase;
|
2016-05-29 06:02:34 -06:00
|
|
|
VidModeAllowNonLocal = allow_non_local;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
|
|
|
|
VidModePtr VidModeGetPtr(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return (VidModePtr) (dixLookupPrivate(&pScreen->devPrivates, VidModePrivateKey));
|
|
|
|
}
|
|
|
|
|
|
|
|
VidModePtr VidModeInit(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
if (!dixRegisterPrivateKey(VidModePrivateKey, PRIVATE_SCREEN, sizeof(VidModeRec)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return VidModeGetPtr(pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* XF86VIDMODE */
|