summaryrefslogtreecommitdiff
path: root/driver/xf86-video-geode/src/gx_randr.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2012-12-16 23:04:19 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2012-12-16 23:04:19 +0000
commite04fd7d8357e76c4d3ddbf872029a5db170c2487 (patch)
tree3cb5381b211255409a68a427a6e0284c67fc04bb /driver/xf86-video-geode/src/gx_randr.c
parent2b459fdd6e5cca9c9094bae17f2165fe21175db1 (diff)
Update to xf86-video-geode 2.11.14
Diffstat (limited to 'driver/xf86-video-geode/src/gx_randr.c')
-rw-r--r--driver/xf86-video-geode/src/gx_randr.c246
1 files changed, 124 insertions, 122 deletions
diff --git a/driver/xf86-video-geode/src/gx_randr.c b/driver/xf86-video-geode/src/gx_randr.c
index d0ddba8c6..c0ca3b978 100644
--- a/driver/xf86-video-geode/src/gx_randr.c
+++ b/driver/xf86-video-geode/src/gx_randr.c
@@ -48,16 +48,15 @@
static int GXRandRGeneration;
-typedef struct _GXRandRInfo
-{
+typedef struct _GXRandRInfo {
int virtualX;
int virtualY;
int mmWidth;
int mmHeight;
int maxX;
int maxY;
- Rotation rotation; /* current mode */
- Rotation supported_rotations; /* driver supported */
+ Rotation rotation; /* current mode */
+ Rotation supported_rotations; /* driver supported */
} XF86RandRInfoRec, *XF86RandRInfoPtr;
#if HAS_DEVPRIVATEKEYREC
@@ -81,10 +80,9 @@ static int
GXRandRModeRefresh(DisplayModePtr mode)
{
if (mode->VRefresh)
- return (int)(mode->VRefresh + 0.5);
+ return (int) (mode->VRefresh + 0.5);
else
- return (int)(mode->Clock * 1000.0 / mode->HTotal / mode->VTotal +
- 0.5);
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
}
static Bool
@@ -100,59 +98,59 @@ GXRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
*rotations = pRandr->supported_rotations;
if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
}
for (mode = pScrni->modes;; mode = mode->next) {
- int refresh = GXRandRModeRefresh(mode);
-
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
-
- if (mode == pScrni->modes)
- refresh0 = refresh;
-
- pSize = RRRegisterSize(pScreen,
- mode->HDisplay, mode->VDisplay,
- pRandr->mmWidth, pRandr->mmHeight);
- if (!pSize)
- return FALSE;
-
- RRRegisterRate(pScreen, pSize, refresh);
-
- if (mode == pScrni->currentMode &&
- mode->HDisplay == pScrni->virtualX
- && mode->VDisplay == pScrni->virtualY)
- RRSetCurrentConfig(pScreen, pRandr->rotation, refresh, pSize);
- if (mode->next == pScrni->modes)
- break;
+ int refresh = GXRandRModeRefresh(mode);
+
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+
+ if (mode == pScrni->modes)
+ refresh0 = refresh;
+
+ pSize = RRRegisterSize(pScreen,
+ mode->HDisplay, mode->VDisplay,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
+
+ RRRegisterRate(pScreen, pSize, refresh);
+
+ if (mode == pScrni->currentMode &&
+ mode->HDisplay == pScrni->virtualX
+ && mode->VDisplay == pScrni->virtualY)
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh, pSize);
+ if (mode->next == pScrni->modes)
+ break;
}
if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
if (pScrni->currentMode->HDisplay != pScrni->virtualX ||
- pScrni->currentMode->VDisplay != pScrni->virtualY) {
-
- mode = pScrni->modes;
- pSize = RRRegisterSize(pScreen,
- pRandr->virtualX, pRandr->virtualY,
- pRandr->mmWidth, pRandr->mmHeight);
- if (!pSize)
- return FALSE;
-
- RRRegisterRate(pScreen, pSize, refresh0);
- if (pScrni->virtualX == pRandr->virtualX &&
- pScrni->virtualY == pRandr->virtualY) {
- RRSetCurrentConfig(pScreen, pRandr->rotation, refresh0, pSize);
- }
+ pScrni->currentMode->VDisplay != pScrni->virtualY) {
+
+ mode = pScrni->modes;
+ pSize = RRRegisterSize(pScreen,
+ pRandr->virtualX, pRandr->virtualY,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
+
+ RRRegisterRate(pScreen, pSize, refresh0);
+ if (pScrni->virtualX == pRandr->virtualX &&
+ pScrni->virtualY == pRandr->virtualY) {
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh0, pSize);
+ }
}
return TRUE;
@@ -160,7 +158,7 @@ GXRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
static Bool
GXRandRSetMode(ScreenPtr pScreen,
- DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight)
+ DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight)
{
ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
@@ -169,6 +167,7 @@ GXRandRSetMode(ScreenPtr pScreen,
int oldHeight = pScreen->height;
int oldmmWidth = pScreen->mmWidth;
int oldmmHeight = pScreen->mmHeight;
+
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 8
WindowPtr pRoot = WindowTable[pScreen->myNum];
#else
@@ -176,45 +175,49 @@ GXRandRSetMode(ScreenPtr pScreen,
#endif
DisplayModePtr currentMode = NULL;
Bool ret = TRUE;
+
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0)
PixmapPtr pspix = NULL;
- #endif
+#endif
if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ (*pScrni->
+ EnableDisableFBAccess) (XF86_ENABLEDISABLEFB_ARG(pScrni, FALSE));
if (useVirtual) {
- pScrni->virtualX = pRandr->virtualX;
- pScrni->virtualY = pRandr->virtualY;
- } else {
- pScrni->virtualX = mode->HDisplay;
- pScrni->virtualY = mode->VDisplay;
+ pScrni->virtualX = pRandr->virtualX;
+ pScrni->virtualY = pRandr->virtualY;
+ }
+ else {
+ pScrni->virtualX = mode->HDisplay;
+ pScrni->virtualY = mode->VDisplay;
}
if (pRandr->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- pScreen->width = pScrni->virtualY;
- pScreen->height = pScrni->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
- } else {
- pScreen->width = pScrni->virtualX;
- pScreen->height = pScrni->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
+ pScreen->width = pScrni->virtualY;
+ pScreen->height = pScrni->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ }
+ else {
+ pScreen->width = pScrni->virtualX;
+ pScreen->height = pScrni->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
}
if (pScrni->currentMode == mode) {
- currentMode = pScrni->currentMode;
- pScrni->currentMode = NULL;
+ currentMode = pScrni->currentMode;
+ pScrni->currentMode = NULL;
}
if (!xf86SwitchMode(pScreen, mode)) {
- ret = FALSE;
- pScrni->virtualX = pScreen->width = oldWidth;
- pScrni->virtualY = pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- pScrni->currentMode = currentMode;
+ ret = FALSE;
+ pScrni->virtualX = pScreen->width = oldWidth;
+ pScrni->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ pScrni->currentMode = currentMode;
}
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0)
@@ -225,7 +228,7 @@ GXRandRSetMode(ScreenPtr pScreen,
*/
pspix = (*pScreen->GetScreenPixmap) (pScreen);
if (pspix->devPrivate.ptr)
- pScrni->pixmapPrivate = pspix->devPrivate;
+ pScrni->pixmapPrivate = pspix->devPrivate;
#endif
xf86ReconfigureLayout();
@@ -234,14 +237,15 @@ GXRandRSetMode(ScreenPtr pScreen,
xf86SetViewport(pScreen, 0, 0);
if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*pScrni->
+ EnableDisableFBAccess) (XF86_ENABLEDISABLEFB_ARG(pScrni, TRUE));
return ret;
}
Bool
GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
- int rate, RRScreenSizePtr pSize)
+ int rate, RRScreenSizePtr pSize)
{
ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
@@ -255,8 +259,8 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
pRandr->rotation = rotation;
if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
}
/* FIXME: we don't have a new video ABI yet */
@@ -267,40 +271,40 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
#endif
for (mode = pScrni->modes;; mode = mode->next) {
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || GXRandRModeRefresh(mode) == rate))
- break;
- if (mode->next == pScrni->modes) {
- if (pSize->width == pRandr->virtualX &&
- pSize->height == pRandr->virtualY) {
- mode = pScrni->modes;
- useVirtual = TRUE;
- break;
- }
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
- }
- return FALSE;
- }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || GXRandRModeRefresh(mode) == rate))
+ break;
+ if (mode->next == pScrni->modes) {
+ if (pSize->width == pRandr->virtualX &&
+ pSize->height == pRandr->virtualY) {
+ mode = pScrni->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
+ }
+ return FALSE;
+ }
}
if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
if (!GXRandRSetMode(pScreen, mode, useVirtual, pSize->mmWidth,
- pSize->mmHeight)) {
- pRandr->rotation = oldRotation;
- return FALSE;
+ pSize->mmHeight)) {
+ pRandr->rotation = oldRotation;
+ return FALSE;
}
/* FIXME: we don't have a new video ABI yet */
@@ -310,19 +314,17 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
if (pScreen == miPointerCurrentScreen())
#endif
{
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
- xf86SetViewport(pScreen, px, py);
+ xf86SetViewport(pScreen, px, py);
/* FIXME: we don't have a new video ABI yet */
- (*pScreen->SetCursorPosition) (
+ (*pScreen->SetCursorPosition) (
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
- inputInfo.pointer,
+ inputInfo.pointer,
#endif
- pScreen,
- px, py,
- FALSE);
+ pScreen, px, py, FALSE);
}
return TRUE;
@@ -343,23 +345,23 @@ GXRandRInit(ScreenPtr pScreen, int rotation)
rrScrPrivPtr rp;
if (GXRandRGeneration != serverGeneration) {
- GXRandRGeneration = serverGeneration;
+ GXRandRGeneration = serverGeneration;
}
#if OLD_VIDEODRV_INTERFACE
GXRandRIndex = AllocateScreenPrivateIndex();
#endif
#if HAS_DIXREGISTERPRIVATEKEY
if (!dixRegisterPrivateKey(&GXRandRIndex, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
#endif
pRandr = calloc(1, sizeof(XF86RandRInfoRec));
if (pRandr == NULL)
- return FALSE;
+ return FALSE;
if (!RRScreenInit(pScreen)) {
- free(pRandr);
- return FALSE;
+ free(pRandr);
+ return FALSE;
}
rp = rrGetScrPriv(pScreen);