2006-09-17 08:21:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2006 Keith Packard
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "randrstr.h"
|
|
|
|
|
2007-02-16 05:13:15 +01:00
|
|
|
static CARD16
|
2012-03-21 20:55:09 +01:00
|
|
|
RR10CurrentSizeID(ScreenPtr pScreen);
|
2007-02-16 05:13:15 +01:00
|
|
|
|
2006-09-17 08:21:37 +02:00
|
|
|
/*
|
|
|
|
* Edit connection information block so that new clients
|
|
|
|
* see the current screen size on connect
|
|
|
|
*/
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
RREditConnectionInfo(ScreenPtr pScreen)
|
2006-09-17 08:21:37 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xConnSetup *connSetup;
|
|
|
|
char *vendor;
|
|
|
|
xPixmapFormat *formats;
|
|
|
|
xWindowRoot *root;
|
|
|
|
xDepth *depth;
|
|
|
|
xVisualType *visual;
|
|
|
|
int screen = 0;
|
|
|
|
int d;
|
2006-09-17 08:21:37 +02:00
|
|
|
|
2016-05-13 08:58:58 +02:00
|
|
|
if (ConnectionInfo == NULL)
|
|
|
|
return;
|
|
|
|
|
2006-09-17 08:21:37 +02:00
|
|
|
connSetup = (xConnSetup *) ConnectionInfo;
|
2012-03-21 20:55:09 +01:00
|
|
|
vendor = (char *) connSetup + sizeof(xConnSetup);
|
2006-09-17 08:21:37 +02:00
|
|
|
formats = (xPixmapFormat *) ((char *) vendor +
|
2012-07-10 04:12:44 +02:00
|
|
|
pad_to_int32(connSetup->nbytesVendor));
|
2006-09-17 08:21:37 +02:00
|
|
|
root = (xWindowRoot *) ((char *) formats +
|
2012-03-21 20:55:09 +01:00
|
|
|
sizeof(xPixmapFormat) *
|
|
|
|
screenInfo.numPixmapFormats);
|
|
|
|
while (screen != pScreen->myNum) {
|
|
|
|
depth = (xDepth *) ((char *) root + sizeof(xWindowRoot));
|
|
|
|
for (d = 0; d < root->nDepths; d++) {
|
|
|
|
visual = (xVisualType *) ((char *) depth + sizeof(xDepth));
|
|
|
|
depth = (xDepth *) ((char *) visual +
|
|
|
|
depth->nVisuals * sizeof(xVisualType));
|
|
|
|
}
|
|
|
|
root = (xWindowRoot *) ((char *) depth);
|
|
|
|
screen++;
|
2006-09-17 08:21:37 +02:00
|
|
|
}
|
|
|
|
root->pixWidth = pScreen->width;
|
|
|
|
root->pixHeight = pScreen->height;
|
|
|
|
root->mmWidth = pScreen->mmWidth;
|
|
|
|
root->mmHeight = pScreen->mmHeight;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
RRSendConfigNotify(ScreenPtr pScreen)
|
2006-09-17 08:21:37 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
WindowPtr pWin = pScreen->root;
|
2012-07-10 04:12:44 +02:00
|
|
|
xEvent event = {
|
|
|
|
.u.configureNotify.window = pWin->drawable.id,
|
|
|
|
.u.configureNotify.aboveSibling = None,
|
|
|
|
.u.configureNotify.x = 0,
|
|
|
|
.u.configureNotify.y = 0,
|
2006-09-17 08:21:37 +02:00
|
|
|
|
|
|
|
/* XXX xinerama stuff ? */
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2012-07-10 04:12:44 +02:00
|
|
|
.u.configureNotify.width = pWin->drawable.width,
|
|
|
|
.u.configureNotify.height = pWin->drawable.height,
|
|
|
|
.u.configureNotify.borderWidth = wBorderWidth(pWin),
|
|
|
|
.u.configureNotify.override = pWin->overrideRedirect
|
|
|
|
};
|
|
|
|
event.u.u.type = ConfigureNotify;
|
2006-09-17 08:21:37 +02:00
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
|
2006-09-17 08:21:37 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
rrScrPriv(pScreen);
|
|
|
|
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
|
|
|
|
WindowPtr pRoot = pScreen->root;
|
|
|
|
|
2012-07-10 04:12:44 +02:00
|
|
|
xRRScreenChangeNotifyEvent se = {
|
|
|
|
.type = RRScreenChangeNotify + RREventBase,
|
|
|
|
.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0),
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
|
|
|
|
.root = pRoot->drawable.id,
|
|
|
|
.window = pWin->drawable.id,
|
|
|
|
.subpixelOrder = PictureGetSubpixelOrder(pScreen),
|
2006-09-17 08:21:37 +02:00
|
|
|
|
2012-07-10 04:12:44 +02:00
|
|
|
.sizeID = RR10CurrentSizeID(pScreen)
|
|
|
|
};
|
2007-04-04 00:47:01 +02:00
|
|
|
|
|
|
|
if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
se.widthInPixels = pScreen->height;
|
|
|
|
se.heightInPixels = pScreen->width;
|
|
|
|
se.widthInMillimeters = pScreen->mmHeight;
|
|
|
|
se.heightInMillimeters = pScreen->mmWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
se.widthInPixels = pScreen->width;
|
|
|
|
se.heightInPixels = pScreen->height;
|
|
|
|
se.widthInMillimeters = pScreen->mmWidth;
|
|
|
|
se.heightInMillimeters = pScreen->mmHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &se);
|
2006-09-17 08:21:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the extension that the screen size has been changed.
|
|
|
|
* The driver is responsible for calling this whenever it has changed
|
|
|
|
* the size of the screen
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
RRScreenSizeNotify(ScreenPtr pScreen)
|
2006-09-17 08:21:37 +02:00
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
/*
|
|
|
|
* Deliver ConfigureNotify events when root changes
|
|
|
|
* pixel size
|
|
|
|
*/
|
|
|
|
if (pScrPriv->width == pScreen->width &&
|
2012-03-21 20:55:09 +01:00
|
|
|
pScrPriv->height == pScreen->height &&
|
|
|
|
pScrPriv->mmWidth == pScreen->mmWidth &&
|
|
|
|
pScrPriv->mmHeight == pScreen->mmHeight)
|
|
|
|
return;
|
|
|
|
|
2006-09-17 08:21:37 +02:00
|
|
|
pScrPriv->width = pScreen->width;
|
|
|
|
pScrPriv->height = pScreen->height;
|
2006-12-22 08:50:39 +01:00
|
|
|
pScrPriv->mmWidth = pScreen->mmWidth;
|
|
|
|
pScrPriv->mmHeight = pScreen->mmHeight;
|
2013-01-09 05:23:57 +01:00
|
|
|
RRSetChanged(pScreen);
|
2006-10-25 18:48:23 +02:00
|
|
|
/* pScrPriv->sizeChanged = TRUE; */
|
2006-09-17 08:21:37 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
RRTellChanged(pScreen);
|
|
|
|
RRSendConfigNotify(pScreen);
|
|
|
|
RREditConnectionInfo(pScreen);
|
|
|
|
|
|
|
|
RRPointerScreenConfigured(pScreen);
|
2006-09-17 08:21:37 +02:00
|
|
|
/*
|
|
|
|
* Fix pointer bounds and location
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenRestructured(pScreen);
|
2006-09-17 08:21:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request that the screen be resized
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
RRScreenSizeSet(ScreenPtr pScreen,
|
|
|
|
CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
|
2006-09-17 08:21:37 +02:00
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
|
|
|
#if RANDR_12_INTERFACE
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pScrPriv->rrScreenSetSize) {
|
|
|
|
return (*pScrPriv->rrScreenSetSize) (pScreen,
|
|
|
|
width, height, mmWidth, mmHeight);
|
2006-09-17 08:21:37 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if RANDR_10_INTERFACE
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pScrPriv->rrSetConfig) {
|
|
|
|
return TRUE; /* can't set size separately */
|
2006-09-17 08:21:37 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
/*
|
|
|
|
* Retrieve valid screen size range
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRGetScreenSizeRange(ClientPtr client)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetScreenSizeRangeReq);
|
2012-03-21 20:55:09 +01:00
|
|
|
xRRGetScreenSizeRangeReply rep;
|
|
|
|
WindowPtr pWin;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
int rc;
|
|
|
|
|
2012-06-29 22:33:58 +02:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
|
2009-08-16 06:06:10 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRGetScreenSizeRangeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.pad = 0,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (pScrPriv) {
|
|
|
|
if (!RRGetInfo(pScreen, FALSE))
|
|
|
|
return BadAlloc;
|
|
|
|
rep.minWidth = pScrPriv->minWidth;
|
|
|
|
rep.minHeight = pScrPriv->minHeight;
|
|
|
|
rep.maxWidth = pScrPriv->maxWidth;
|
|
|
|
rep.maxHeight = pScrPriv->maxHeight;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
rep.maxWidth = rep.minWidth = pScreen->width;
|
|
|
|
rep.maxHeight = rep.minHeight = pScreen->height;
|
|
|
|
}
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.minWidth);
|
|
|
|
swaps(&rep.minHeight);
|
|
|
|
swaps(&rep.maxWidth);
|
|
|
|
swaps(&rep.maxHeight);
|
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), &rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRSetScreenSize(ClientPtr client)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetScreenSizeReq);
|
2012-03-21 20:55:09 +01:00
|
|
|
WindowPtr pWin;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
int i, rc;
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
|
2009-08-16 06:06:10 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-06-22 03:45:18 +02:00
|
|
|
if (!pScrPriv)
|
|
|
|
return BadMatch;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) {
|
|
|
|
client->errorValue = stuff->width;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (stuff->height < pScrPriv->minHeight ||
|
|
|
|
pScrPriv->maxHeight < stuff->height) {
|
|
|
|
client->errorValue = stuff->height;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
|
|
|
RRModePtr mode = crtc->mode;
|
|
|
|
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 22:51:56 +01:00
|
|
|
if (!RRCrtcIsLeased(crtc) && mode) {
|
2012-03-21 20:55:09 +01:00
|
|
|
int source_width = mode->mode.width;
|
|
|
|
int source_height = mode->mode.height;
|
|
|
|
Rotation rotation = crtc->rotation;
|
|
|
|
|
2018-01-09 03:44:25 +01:00
|
|
|
if (rotation & (RR_Rotate_90 | RR_Rotate_270)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
source_width = mode->mode.height;
|
|
|
|
source_height = mode->mode.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (crtc->x + source_width > stuff->width ||
|
|
|
|
crtc->y + source_height > stuff->height)
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) {
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (!RRScreenSizeSet(pScreen,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->widthInMillimeters,
|
|
|
|
stuff->heightInMillimeters)) {
|
|
|
|
return BadMatch;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-05-24 16:47:22 +02:00
|
|
|
|
|
|
|
#define update_totals(gpuscreen, pScrPriv) do { \
|
|
|
|
total_crtcs += pScrPriv->numCrtcs; \
|
|
|
|
total_outputs += pScrPriv->numOutputs; \
|
|
|
|
modes = RRModesForScreen(gpuscreen, &num_modes); \
|
|
|
|
if (!modes) \
|
|
|
|
return BadAlloc; \
|
|
|
|
for (j = 0; j < num_modes; j++) \
|
|
|
|
total_name_len += modes[j]->mode.nameLength; \
|
|
|
|
total_modes += num_modes; \
|
|
|
|
free(modes); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
static inline void swap_modeinfos(xRRModeInfo *modeinfos, int i)
|
|
|
|
{
|
|
|
|
swapl(&modeinfos[i].id);
|
|
|
|
swaps(&modeinfos[i].width);
|
|
|
|
swaps(&modeinfos[i].height);
|
|
|
|
swapl(&modeinfos[i].dotClock);
|
|
|
|
swaps(&modeinfos[i].hSyncStart);
|
|
|
|
swaps(&modeinfos[i].hSyncEnd);
|
|
|
|
swaps(&modeinfos[i].hTotal);
|
|
|
|
swaps(&modeinfos[i].hSkew);
|
|
|
|
swaps(&modeinfos[i].vSyncStart);
|
|
|
|
swaps(&modeinfos[i].vSyncEnd);
|
|
|
|
swaps(&modeinfos[i].vTotal);
|
|
|
|
swaps(&modeinfos[i].nameLength);
|
|
|
|
swapl(&modeinfos[i].modeFlags);
|
|
|
|
}
|
|
|
|
|
2015-01-07 00:19:27 +01:00
|
|
|
#define update_arrays(gpuscreen, pScrPriv, primary_crtc, has_primary) do { \
|
2012-05-24 16:47:22 +02:00
|
|
|
for (j = 0; j < pScrPriv->numCrtcs; j++) { \
|
2015-01-07 00:19:27 +01:00
|
|
|
if (has_primary && \
|
|
|
|
primary_crtc == pScrPriv->crtcs[j]) { \
|
|
|
|
has_primary = 0; \
|
|
|
|
continue; \
|
|
|
|
}\
|
2012-05-24 16:47:22 +02:00
|
|
|
crtcs[crtc_count] = pScrPriv->crtcs[j]->id; \
|
|
|
|
if (client->swapped) \
|
|
|
|
swapl(&crtcs[crtc_count]); \
|
|
|
|
crtc_count++; \
|
|
|
|
} \
|
|
|
|
for (j = 0; j < pScrPriv->numOutputs; j++) { \
|
|
|
|
outputs[output_count] = pScrPriv->outputs[j]->id; \
|
|
|
|
if (client->swapped) \
|
|
|
|
swapl(&outputs[output_count]); \
|
|
|
|
output_count++; \
|
|
|
|
} \
|
|
|
|
{ \
|
|
|
|
RRModePtr mode; \
|
|
|
|
modes = RRModesForScreen(gpuscreen, &num_modes); \
|
|
|
|
for (j = 0; j < num_modes; j++) { \
|
|
|
|
mode = modes[j]; \
|
|
|
|
modeinfos[mode_count] = mode->mode; \
|
|
|
|
if (client->swapped) { \
|
|
|
|
swap_modeinfos(modeinfos, mode_count); \
|
|
|
|
} \
|
|
|
|
memcpy(names, mode->name, mode->mode.nameLength); \
|
|
|
|
names += mode->mode.nameLength; \
|
|
|
|
mode_count++; \
|
|
|
|
} \
|
|
|
|
free(modes); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int
|
|
|
|
rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
int total_crtcs, total_outputs, total_modes, total_name_len;
|
|
|
|
int crtc_count, output_count, mode_count;
|
|
|
|
ScreenPtr iter;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
int num_modes;
|
|
|
|
RRModePtr *modes;
|
|
|
|
xRRGetScreenResourcesReply rep;
|
|
|
|
unsigned long extraLen;
|
|
|
|
CARD8 *extra;
|
|
|
|
RRCrtc *crtcs;
|
2015-01-07 00:19:27 +01:00
|
|
|
RRCrtcPtr primary_crtc = NULL;
|
2012-05-24 16:47:22 +02:00
|
|
|
RROutput *outputs;
|
|
|
|
xRRModeInfo *modeinfos;
|
|
|
|
CARD8 *names;
|
2015-01-07 00:19:27 +01:00
|
|
|
int has_primary = 0;
|
2012-05-24 16:47:22 +02:00
|
|
|
|
2020-07-05 23:00:50 +02:00
|
|
|
/* we need to iterate all the GPU primarys and all their output secondarys */
|
2012-05-24 16:47:22 +02:00
|
|
|
total_crtcs = 0;
|
|
|
|
total_outputs = 0;
|
|
|
|
total_modes = 0;
|
|
|
|
total_name_len = 0;
|
|
|
|
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
|
|
|
if (query && pScrPriv)
|
|
|
|
if (!RRGetInfo(pScreen, query))
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
update_totals(pScreen, pScrPriv);
|
|
|
|
|
2020-07-05 23:00:50 +02:00
|
|
|
xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) {
|
|
|
|
if (!iter->is_output_secondary)
|
xrandrprovider: Do not use separate lists for unbound / source / offload slaves
A single provider can be both a offload and source slave at the same time,
the use of seperate lists breaks in this case e.g. :
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 0 name:modesetting
xrandr --setprovideroutputsource 1 0x7b
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 1 name:modesetting
xrandr --setprovideroffloadsink 1 0x7b
xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Provider 2: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Not good. The problem is that the provider with id 0x46 now is on both
the output_slave_list and the offload_slave_list of the master screen.
This commit fixes this by unifying all 3 lists into a single slaves list.
Note that this does change the struct _Screen definition, so this is an ABI
break. I do not expect any of the drivers to actually use the removed / changed
fields so a recompile should suffice.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-05-13 15:58:10 +02:00
|
|
|
continue;
|
|
|
|
|
2012-05-24 16:47:22 +02:00
|
|
|
pScrPriv = rrGetScrPriv(iter);
|
|
|
|
|
|
|
|
if (query)
|
|
|
|
if (!RRGetInfo(iter, query))
|
|
|
|
return BadAlloc;
|
|
|
|
update_totals(iter, pScrPriv);
|
|
|
|
}
|
|
|
|
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-07-14 19:45:29 +02:00
|
|
|
rep = (xRRGetScreenResourcesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
|
|
|
|
.nCrtcs = total_crtcs,
|
|
|
|
.nOutputs = total_outputs,
|
|
|
|
.nModes = total_modes,
|
|
|
|
.nbytesNames = total_name_len
|
|
|
|
};
|
2012-05-24 16:47:22 +02:00
|
|
|
|
2015-03-19 13:22:18 +01:00
|
|
|
rep.length = (total_crtcs + total_outputs +
|
|
|
|
total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
|
|
|
|
bytes_to_int32(total_name_len));
|
2012-05-24 16:47:22 +02:00
|
|
|
|
|
|
|
extraLen = rep.length << 2;
|
|
|
|
if (extraLen) {
|
|
|
|
extra = malloc(extraLen);
|
|
|
|
if (!extra) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
extra = NULL;
|
|
|
|
|
|
|
|
crtcs = (RRCrtc *)extra;
|
|
|
|
outputs = (RROutput *)(crtcs + total_crtcs);
|
|
|
|
modeinfos = (xRRModeInfo *)(outputs + total_outputs);
|
|
|
|
names = (CARD8 *)(modeinfos + total_modes);
|
|
|
|
|
|
|
|
crtc_count = 0;
|
|
|
|
output_count = 0;
|
|
|
|
mode_count = 0;
|
|
|
|
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2015-01-07 00:19:27 +01:00
|
|
|
if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) {
|
|
|
|
has_primary = 1;
|
|
|
|
primary_crtc = pScrPriv->primaryOutput->crtc;
|
|
|
|
crtcs[0] = pScrPriv->primaryOutput->crtc->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&crtcs[0]);
|
|
|
|
crtc_count = 1;
|
|
|
|
}
|
|
|
|
update_arrays(pScreen, pScrPriv, primary_crtc, has_primary);
|
2012-05-24 16:47:22 +02:00
|
|
|
|
2020-07-05 23:00:50 +02:00
|
|
|
xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) {
|
|
|
|
if (!iter->is_output_secondary)
|
xrandrprovider: Do not use separate lists for unbound / source / offload slaves
A single provider can be both a offload and source slave at the same time,
the use of seperate lists breaks in this case e.g. :
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 0 name:modesetting
xrandr --setprovideroutputsource 1 0x7b
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 1 name:modesetting
xrandr --setprovideroffloadsink 1 0x7b
xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Provider 2: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Not good. The problem is that the provider with id 0x46 now is on both
the output_slave_list and the offload_slave_list of the master screen.
This commit fixes this by unifying all 3 lists into a single slaves list.
Note that this does change the struct _Screen definition, so this is an ABI
break. I do not expect any of the drivers to actually use the removed / changed
fields so a recompile should suffice.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-05-13 15:58:10 +02:00
|
|
|
continue;
|
|
|
|
|
2012-05-24 16:47:22 +02:00
|
|
|
pScrPriv = rrGetScrPriv(iter);
|
|
|
|
|
2015-01-07 00:19:27 +01:00
|
|
|
update_arrays(iter, pScrPriv, primary_crtc, has_primary);
|
2012-05-24 16:47:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(bytes_to_int32((char *) names - (char *) extra) == rep.length);
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.timestamp);
|
|
|
|
swapl(&rep.configTimestamp);
|
|
|
|
swaps(&rep.nCrtcs);
|
|
|
|
swaps(&rep.nOutputs);
|
|
|
|
swaps(&rep.nModes);
|
|
|
|
swaps(&rep.nbytesNames);
|
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xRRGetScreenResourcesReply), &rep);
|
2012-05-24 16:47:22 +02:00
|
|
|
if (extraLen) {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, extraLen, extra);
|
2012-05-24 16:47:22 +02:00
|
|
|
free(extra);
|
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2008-11-27 00:49:02 +01:00
|
|
|
static int
|
|
|
|
rrGetScreenResources(ClientPtr client, Bool query)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetScreenResourcesReq);
|
2012-03-21 20:55:09 +01:00
|
|
|
xRRGetScreenResourcesReply rep;
|
|
|
|
WindowPtr pWin;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
CARD8 *extra;
|
|
|
|
unsigned long extraLen;
|
|
|
|
int i, rc, has_primary = 0;
|
|
|
|
RRCrtc *crtcs;
|
|
|
|
RROutput *outputs;
|
|
|
|
xRRModeInfo *modeinfos;
|
|
|
|
CARD8 *names;
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
|
2009-08-16 06:06:10 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-11-27 00:49:02 +01:00
|
|
|
if (query && pScrPriv)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!RRGetInfo(pScreen, query))
|
|
|
|
return BadAlloc;
|
|
|
|
|
2020-07-05 23:00:50 +02:00
|
|
|
if (pScreen->output_secondarys)
|
2012-05-24 16:47:22 +02:00
|
|
|
return rrGetMultiScreenResources(client, query, pScreen);
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pScrPriv) {
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRGetScreenResourcesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.timestamp = currentTime.milliseconds,
|
|
|
|
.configTimestamp = currentTime.milliseconds,
|
|
|
|
.nCrtcs = 0,
|
|
|
|
.nOutputs = 0,
|
|
|
|
.nModes = 0,
|
|
|
|
.nbytesNames = 0
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
extra = NULL;
|
|
|
|
extraLen = 0;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
RRModePtr *modes;
|
|
|
|
int num_modes;
|
|
|
|
|
|
|
|
modes = RRModesForScreen(pScreen, &num_modes);
|
|
|
|
if (!modes)
|
|
|
|
return BadAlloc;
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRGetScreenResourcesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
|
|
|
|
.nCrtcs = pScrPriv->numCrtcs,
|
|
|
|
.nOutputs = pScrPriv->numOutputs,
|
|
|
|
.nModes = num_modes,
|
|
|
|
.nbytesNames = 0
|
|
|
|
};
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
for (i = 0; i < num_modes; i++)
|
|
|
|
rep.nbytesNames += modes[i]->mode.nameLength;
|
|
|
|
|
|
|
|
rep.length = (pScrPriv->numCrtcs +
|
|
|
|
pScrPriv->numOutputs +
|
|
|
|
num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
|
|
|
|
bytes_to_int32(rep.nbytesNames));
|
|
|
|
|
|
|
|
extraLen = rep.length << 2;
|
|
|
|
if (extraLen) {
|
2017-11-09 10:21:19 +01:00
|
|
|
extra = calloc(1, extraLen);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!extra) {
|
|
|
|
free(modes);
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
extra = NULL;
|
|
|
|
|
|
|
|
crtcs = (RRCrtc *) extra;
|
|
|
|
outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
|
|
|
|
modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
|
|
|
|
names = (CARD8 *) (modeinfos + num_modes);
|
|
|
|
|
|
|
|
if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) {
|
|
|
|
has_primary = 1;
|
|
|
|
crtcs[0] = pScrPriv->primaryOutput->crtc->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&crtcs[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
if (has_primary &&
|
|
|
|
pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) {
|
|
|
|
has_primary = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&crtcs[i + has_primary]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++) {
|
|
|
|
outputs[i] = pScrPriv->outputs[i]->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&outputs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_modes; i++) {
|
|
|
|
RRModePtr mode = modes[i];
|
|
|
|
|
|
|
|
modeinfos[i] = mode->mode;
|
|
|
|
if (client->swapped) {
|
|
|
|
swapl(&modeinfos[i].id);
|
|
|
|
swaps(&modeinfos[i].width);
|
|
|
|
swaps(&modeinfos[i].height);
|
|
|
|
swapl(&modeinfos[i].dotClock);
|
|
|
|
swaps(&modeinfos[i].hSyncStart);
|
|
|
|
swaps(&modeinfos[i].hSyncEnd);
|
|
|
|
swaps(&modeinfos[i].hTotal);
|
|
|
|
swaps(&modeinfos[i].hSkew);
|
|
|
|
swaps(&modeinfos[i].vSyncStart);
|
|
|
|
swaps(&modeinfos[i].vSyncEnd);
|
|
|
|
swaps(&modeinfos[i].vTotal);
|
|
|
|
swaps(&modeinfos[i].nameLength);
|
|
|
|
swapl(&modeinfos[i].modeFlags);
|
|
|
|
}
|
|
|
|
memcpy(names, mode->name, mode->mode.nameLength);
|
|
|
|
names += mode->mode.nameLength;
|
|
|
|
}
|
2010-05-05 20:44:06 +02:00
|
|
|
free(modes);
|
2012-03-21 20:55:09 +01:00
|
|
|
assert(bytes_to_int32((char *) names - (char *) extra) == rep.length);
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.timestamp);
|
|
|
|
swapl(&rep.configTimestamp);
|
|
|
|
swaps(&rep.nCrtcs);
|
|
|
|
swaps(&rep.nOutputs);
|
|
|
|
swaps(&rep.nModes);
|
|
|
|
swaps(&rep.nbytesNames);
|
|
|
|
}
|
|
|
|
WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *) &rep);
|
|
|
|
if (extraLen) {
|
|
|
|
WriteToClient(client, extraLen, (char *) extra);
|
|
|
|
free(extra);
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRGetScreenResources(ClientPtr client)
|
2008-11-27 00:49:02 +01:00
|
|
|
{
|
|
|
|
return rrGetScreenResources(client, TRUE);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRGetScreenResourcesCurrent(ClientPtr client)
|
2008-11-27 00:49:02 +01:00
|
|
|
{
|
|
|
|
return rrGetScreenResources(client, FALSE);
|
|
|
|
}
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
typedef struct _RR10Data {
|
|
|
|
RRScreenSizePtr sizes;
|
2012-03-21 20:55:09 +01:00
|
|
|
int nsize;
|
|
|
|
int nrefresh;
|
|
|
|
int size;
|
|
|
|
CARD16 refresh;
|
2006-09-20 07:48:54 +02:00
|
|
|
} RR10DataRec, *RR10DataPtr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert 1.2 monitor data into 1.0 screen data
|
|
|
|
*/
|
|
|
|
static RR10DataPtr
|
2012-03-21 20:55:09 +01:00
|
|
|
RR10GetData(ScreenPtr pScreen, RROutputPtr output)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
RR10DataPtr data;
|
2006-09-20 07:48:54 +02:00
|
|
|
RRScreenSizePtr size;
|
2012-03-21 20:55:09 +01:00
|
|
|
int nmode = output->numModes + output->numUserModes;
|
|
|
|
int o, os, l, r;
|
2006-09-20 07:48:54 +02:00
|
|
|
RRScreenRatePtr refresh;
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD16 vRefresh;
|
|
|
|
RRModePtr mode;
|
|
|
|
Bool *used;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
/* Make sure there is plenty of space for any combination */
|
2012-03-21 20:55:09 +01:00
|
|
|
data = malloc(sizeof(RR10DataRec) +
|
|
|
|
sizeof(RRScreenSize) * nmode +
|
|
|
|
sizeof(RRScreenRate) * nmode + sizeof(Bool) * nmode);
|
2006-09-20 07:48:54 +02:00
|
|
|
if (!data)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2006-09-20 07:48:54 +02:00
|
|
|
size = (RRScreenSizePtr) (data + 1);
|
|
|
|
refresh = (RRScreenRatePtr) (size + nmode);
|
2006-12-13 09:58:54 +01:00
|
|
|
used = (Bool *) (refresh + nmode);
|
2012-03-21 20:55:09 +01:00
|
|
|
memset(used, '\0', sizeof(Bool) * nmode);
|
2006-09-20 07:48:54 +02:00
|
|
|
data->sizes = size;
|
|
|
|
data->nsize = 0;
|
|
|
|
data->nrefresh = 0;
|
|
|
|
data->size = 0;
|
|
|
|
data->refresh = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-12-13 09:58:54 +01:00
|
|
|
/*
|
|
|
|
* find modes not yet listed
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (o = 0; o < output->numModes + output->numUserModes; o++) {
|
|
|
|
if (used[o])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (o < output->numModes)
|
|
|
|
mode = output->modes[o];
|
|
|
|
else
|
|
|
|
mode = output->userModes[o - output->numModes];
|
|
|
|
|
|
|
|
l = data->nsize;
|
|
|
|
size[l].id = data->nsize;
|
|
|
|
size[l].width = mode->mode.width;
|
|
|
|
size[l].height = mode->mode.height;
|
|
|
|
if (output->mmWidth && output->mmHeight) {
|
|
|
|
size[l].mmWidth = output->mmWidth;
|
|
|
|
size[l].mmHeight = output->mmHeight;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
size[l].mmWidth = pScreen->mmWidth;
|
|
|
|
size[l].mmHeight = pScreen->mmHeight;
|
|
|
|
}
|
|
|
|
size[l].nRates = 0;
|
|
|
|
size[l].pRates = &refresh[data->nrefresh];
|
|
|
|
data->nsize++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find all modes with matching size
|
|
|
|
*/
|
|
|
|
for (os = o; os < output->numModes + output->numUserModes; os++) {
|
|
|
|
if (os < output->numModes)
|
|
|
|
mode = output->modes[os];
|
|
|
|
else
|
|
|
|
mode = output->userModes[os - output->numModes];
|
|
|
|
if (mode->mode.width == size[l].width &&
|
|
|
|
mode->mode.height == size[l].height) {
|
|
|
|
vRefresh = RRVerticalRefresh(&mode->mode);
|
|
|
|
used[os] = TRUE;
|
|
|
|
|
|
|
|
for (r = 0; r < size[l].nRates; r++)
|
|
|
|
if (vRefresh == size[l].pRates[r].rate)
|
|
|
|
break;
|
|
|
|
if (r == size[l].nRates) {
|
|
|
|
size[l].pRates[r].rate = vRefresh;
|
|
|
|
size[l].pRates[r].mode = mode;
|
|
|
|
size[l].nRates++;
|
|
|
|
data->nrefresh++;
|
|
|
|
}
|
|
|
|
if (mode == output->crtc->mode) {
|
|
|
|
data->size = l;
|
|
|
|
data->refresh = vRefresh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRGetScreenInfo(ClientPtr client)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetScreenInfoReq);
|
2012-03-21 20:55:09 +01:00
|
|
|
xRRGetScreenInfoReply rep;
|
|
|
|
WindowPtr pWin;
|
|
|
|
int rc;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
CARD8 *extra;
|
|
|
|
unsigned long extraLen;
|
|
|
|
RROutputPtr output;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
|
2009-08-16 06:06:10 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
if (pScrPriv)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!RRGetInfo(pScreen, TRUE))
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
output = RRFirstOutput(pScreen);
|
|
|
|
|
|
|
|
if (!pScrPriv || !output) {
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRGetScreenInfoReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.setOfRotations = RR_Rotate_0,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.root = pWin->drawable.pScreen->root->drawable.id,
|
|
|
|
.timestamp = currentTime.milliseconds,
|
|
|
|
.configTimestamp = currentTime.milliseconds,
|
|
|
|
.nSizes = 0,
|
|
|
|
.sizeID = 0,
|
|
|
|
.rotation = RR_Rotate_0,
|
|
|
|
.rate = 0,
|
|
|
|
.nrateEnts = 0
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
extra = 0;
|
|
|
|
extraLen = 0;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
int i, j;
|
|
|
|
xScreenSizes *size;
|
|
|
|
CARD16 *rates;
|
|
|
|
CARD8 *data8;
|
|
|
|
Bool has_rate = RRClientKnowsRates(client);
|
|
|
|
RR10DataPtr pData;
|
|
|
|
RRScreenSizePtr pSize;
|
|
|
|
|
|
|
|
pData = RR10GetData(pScreen, output);
|
|
|
|
if (!pData)
|
|
|
|
return BadAlloc;
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRGetScreenInfoReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.setOfRotations = output->crtc->rotations,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.root = pWin->drawable.pScreen->root->drawable.id,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
|
|
|
|
.rotation = output->crtc->rotation,
|
|
|
|
.nSizes = pData->nsize,
|
|
|
|
.nrateEnts = pData->nrefresh + pData->nsize,
|
|
|
|
.sizeID = pData->size,
|
|
|
|
.rate = pData->refresh
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
extraLen = rep.nSizes * sizeof(xScreenSizes);
|
|
|
|
if (has_rate)
|
|
|
|
extraLen += rep.nrateEnts * sizeof(CARD16);
|
|
|
|
|
|
|
|
if (extraLen) {
|
|
|
|
extra = (CARD8 *) malloc(extraLen);
|
|
|
|
if (!extra) {
|
|
|
|
free(pData);
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
extra = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First comes the size information
|
|
|
|
*/
|
|
|
|
size = (xScreenSizes *) extra;
|
|
|
|
rates = (CARD16 *) (size + rep.nSizes);
|
|
|
|
for (i = 0; i < pData->nsize; i++) {
|
|
|
|
pSize = &pData->sizes[i];
|
|
|
|
size->widthInPixels = pSize->width;
|
|
|
|
size->heightInPixels = pSize->height;
|
|
|
|
size->widthInMillimeters = pSize->mmWidth;
|
|
|
|
size->heightInMillimeters = pSize->mmHeight;
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&size->widthInPixels);
|
|
|
|
swaps(&size->heightInPixels);
|
|
|
|
swaps(&size->widthInMillimeters);
|
|
|
|
swaps(&size->heightInMillimeters);
|
|
|
|
}
|
|
|
|
size++;
|
|
|
|
if (has_rate) {
|
|
|
|
*rates = pSize->nRates;
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(rates);
|
|
|
|
}
|
|
|
|
rates++;
|
|
|
|
for (j = 0; j < pSize->nRates; j++) {
|
|
|
|
*rates = pSize->pRates[j].rate;
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(rates);
|
|
|
|
}
|
|
|
|
rates++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pData);
|
2006-09-20 07:48:54 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
data8 = (CARD8 *) rates;
|
|
|
|
|
|
|
|
if (data8 - (CARD8 *) extra != extraLen)
|
|
|
|
FatalError("RRGetScreenInfo bad extra len %ld != %ld\n",
|
|
|
|
(unsigned long) (data8 - (CARD8 *) extra), extraLen);
|
|
|
|
rep.length = bytes_to_int32(extraLen);
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.timestamp);
|
2012-07-10 04:12:42 +02:00
|
|
|
swapl(&rep.configTimestamp);
|
2012-03-21 20:55:09 +01:00
|
|
|
swaps(&rep.rotation);
|
|
|
|
swaps(&rep.nSizes);
|
|
|
|
swaps(&rep.sizeID);
|
|
|
|
swaps(&rep.rate);
|
|
|
|
swaps(&rep.nrateEnts);
|
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xRRGetScreenInfoReply), &rep);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (extraLen) {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, extraLen, extra);
|
2012-03-21 20:55:09 +01:00
|
|
|
free(extra);
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcRRSetScreenConfig(ClientPtr client)
|
2006-09-20 07:48:54 +02:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetScreenConfigReq);
|
|
|
|
xRRSetScreenConfigReply rep;
|
2012-03-21 20:55:09 +01:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int rc;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
TimeStamp time;
|
|
|
|
int i;
|
|
|
|
Rotation rotation;
|
|
|
|
int rate;
|
|
|
|
Bool has_rate;
|
2012-07-10 04:12:42 +02:00
|
|
|
CARD8 status;
|
2012-03-21 20:55:09 +01:00
|
|
|
RROutputPtr output;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
RRModePtr mode;
|
|
|
|
RR10DataPtr pData = NULL;
|
|
|
|
RRScreenSizePtr pSize;
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
if (RRClientKnowsRates(client)) {
|
|
|
|
REQUEST_SIZE_MATCH(xRRSetScreenConfigReq);
|
|
|
|
has_rate = TRUE;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq);
|
|
|
|
has_rate = FALSE;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-12-14 23:53:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
|
2011-02-23 20:17:42 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2006-09-20 07:48:54 +02:00
|
|
|
|
|
|
|
pScreen = pDraw->pScreen;
|
|
|
|
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
time = ClientTimeToServerTime(stuff->timestamp);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (!pScrPriv) {
|
|
|
|
time = currentTime;
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigFailed;
|
2012-03-21 20:55:09 +01:00
|
|
|
goto sendReply;
|
|
|
|
}
|
|
|
|
if (!RRGetInfo(pScreen, FALSE))
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
output = RRFirstOutput(pScreen);
|
|
|
|
if (!output) {
|
|
|
|
time = currentTime;
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigFailed;
|
2012-03-21 20:55:09 +01:00
|
|
|
goto sendReply;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2007-08-01 01:33:37 +02:00
|
|
|
|
|
|
|
crtc = output->crtc;
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
/*
|
2007-09-01 06:36:37 +02:00
|
|
|
* If the client's config timestamp is not the same as the last config
|
2006-09-20 07:48:54 +02:00
|
|
|
* timestamp, then the config information isn't up-to-date and
|
2007-09-01 06:36:37 +02:00
|
|
|
* can't even be validated.
|
|
|
|
*
|
|
|
|
* Note that the client only knows about the milliseconds part of the
|
|
|
|
* timestamp, so using CompareTimeStamps here would cause randr to suddenly
|
|
|
|
* stop working after several hours have passed (freedesktop bug #6502).
|
2006-09-20 07:48:54 +02:00
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds) {
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigInvalidConfigTime;
|
2012-03-21 20:55:09 +01:00
|
|
|
goto sendReply;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
pData = RR10GetData(pScreen, output);
|
2006-09-20 07:48:54 +02:00
|
|
|
if (!pData)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
if (stuff->sizeID >= pData->nsize) {
|
|
|
|
/*
|
|
|
|
* Invalid size ID
|
|
|
|
*/
|
|
|
|
client->errorValue = stuff->sizeID;
|
|
|
|
free(pData);
|
|
|
|
return BadValue;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
pSize = &pData->sizes[stuff->sizeID];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
/*
|
|
|
|
* Validate requested rotation
|
|
|
|
*/
|
|
|
|
rotation = (Rotation) stuff->rotation;
|
|
|
|
|
|
|
|
/* test the rotation bits only! */
|
|
|
|
switch (rotation & 0xf) {
|
|
|
|
case RR_Rotate_0:
|
|
|
|
case RR_Rotate_90:
|
|
|
|
case RR_Rotate_180:
|
|
|
|
case RR_Rotate_270:
|
2012-03-21 20:55:09 +01:00
|
|
|
break;
|
2006-09-20 07:48:54 +02:00
|
|
|
default:
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
* Invalid rotation
|
|
|
|
*/
|
|
|
|
client->errorValue = stuff->rotation;
|
|
|
|
free(pData);
|
|
|
|
return BadValue;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((~crtc->rotations) & rotation) {
|
|
|
|
/*
|
|
|
|
* requested rotation or reflection not supported by screen
|
|
|
|
*/
|
|
|
|
client->errorValue = stuff->rotation;
|
|
|
|
free(pData);
|
|
|
|
return BadMatch;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate requested refresh
|
|
|
|
*/
|
|
|
|
if (has_rate)
|
2012-03-21 20:55:09 +01:00
|
|
|
rate = (int) stuff->rate;
|
2006-09-20 07:48:54 +02:00
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
rate = 0;
|
|
|
|
|
|
|
|
if (rate) {
|
|
|
|
for (i = 0; i < pSize->nRates; i++) {
|
|
|
|
if (pSize->pRates[i].rate == rate)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == pSize->nRates) {
|
|
|
|
/*
|
|
|
|
* Invalid rate
|
|
|
|
*/
|
|
|
|
client->errorValue = rate;
|
|
|
|
free(pData);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
mode = pSize->pRates[i].mode;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
mode = pSize->pRates[0].mode;
|
|
|
|
|
2006-09-20 07:48:54 +02:00
|
|
|
/*
|
|
|
|
* Make sure the requested set-time is not older than
|
|
|
|
* the last set-time
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (CompareTimeStamps(time, pScrPriv->lastSetTime) < 0) {
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigInvalidTime;
|
2012-03-21 20:55:09 +01:00
|
|
|
goto sendReply;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
2006-10-14 02:34:53 +02:00
|
|
|
/*
|
|
|
|
* If the screen size is changing, adjust all of the other outputs
|
|
|
|
* to fit the new size, mirroring as much as possible
|
|
|
|
*/
|
2007-04-09 23:29:46 +02:00
|
|
|
width = mode->mode.width;
|
|
|
|
height = mode->mode.height;
|
2010-12-17 15:09:35 +01:00
|
|
|
if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = width;
|
|
|
|
free(pData);
|
|
|
|
return BadValue;
|
2010-12-17 15:09:35 +01:00
|
|
|
}
|
|
|
|
if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = height;
|
|
|
|
free(pData);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rotation & (RR_Rotate_90 | RR_Rotate_270)) {
|
|
|
|
width = mode->mode.height;
|
|
|
|
height = mode->mode.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width != pScreen->width || height != pScreen->height) {
|
|
|
|
int c;
|
|
|
|
|
|
|
|
for (c = 0; c < pScrPriv->numCrtcs; c++) {
|
|
|
|
if (!RRCrtcSet(pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
|
|
|
|
0, NULL)) {
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigFailed;
|
2012-03-21 20:55:09 +01:00
|
|
|
/* XXX recover from failure */
|
|
|
|
goto sendReply;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!RRScreenSizeSet(pScreen, width, height,
|
|
|
|
pScreen->mmWidth, pScreen->mmHeight)) {
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigFailed;
|
2012-03-21 20:55:09 +01:00
|
|
|
/* XXX recover from failure */
|
|
|
|
goto sendReply;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RRCrtcSet(crtc, mode, 0, 0, stuff->rotation, 1, &output))
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigFailed;
|
2009-05-28 23:43:27 +02:00
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
pScrPriv->lastSetTime = time;
|
2012-07-10 04:12:42 +02:00
|
|
|
status = RRSetConfigSuccess;
|
2009-05-28 23:43:27 +02:00
|
|
|
}
|
2006-12-13 09:58:54 +01:00
|
|
|
|
2006-10-14 02:34:53 +02:00
|
|
|
/*
|
|
|
|
* XXX Configure other crtcs to mirror as much as possible
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
sendReply:
|
|
|
|
|
2010-06-06 10:28:30 +02:00
|
|
|
free(pData);
|
2006-09-20 07:48:54 +02:00
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xRRSetScreenConfigReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.status = status,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
|
|
|
|
.newTimestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds,
|
|
|
|
.root = pDraw->pScreen->root->drawable.id,
|
|
|
|
/* .subpixelOrder = ?? */
|
|
|
|
};
|
2006-09-20 07:48:54 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.newTimestamp);
|
|
|
|
swapl(&rep.newConfigTimestamp);
|
|
|
|
swapl(&rep.root);
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xRRSetScreenConfigReply), &rep);
|
2006-09-20 07:48:54 +02:00
|
|
|
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2006-09-20 07:48:54 +02:00
|
|
|
}
|
|
|
|
|
2007-02-16 05:13:15 +01:00
|
|
|
static CARD16
|
2012-03-21 20:55:09 +01:00
|
|
|
RR10CurrentSizeID(ScreenPtr pScreen)
|
2007-02-16 05:13:15 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD16 sizeID = 0xffff;
|
|
|
|
RROutputPtr output = RRFirstOutput(pScreen);
|
|
|
|
|
|
|
|
if (output) {
|
|
|
|
RR10DataPtr data = RR10GetData(pScreen, output);
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < data->nsize; i++)
|
|
|
|
if (data->sizes[i].width == pScreen->width &&
|
|
|
|
data->sizes[i].height == pScreen->height) {
|
|
|
|
sizeID = (CARD16) i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free(data);
|
|
|
|
}
|
2007-02-16 05:13:15 +01:00
|
|
|
}
|
|
|
|
return sizeID;
|
|
|
|
}
|