Add support for on-the-fly screen rotation when supported by hardware (Aron

Plattner).
This commit is contained in:
Egbert Eich 2004-07-30 21:53:09 +00:00
parent 4baf002941
commit d3c98fed2c
4 changed files with 42 additions and 10 deletions

View File

@ -222,7 +222,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
if (mode == pScr->currentMode)
return TRUE;
if (mode->HDisplay > pScreen->width || mode->VDisplay > pScreen->height)
if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
return FALSE;
pCursorScreen = miPointerCurrentScreen();

View File

@ -902,6 +902,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86Screens[i]->DPMSSet = NULL;
xf86Screens[i]->LoadPalette = NULL;
xf86Screens[i]->SetOverscan = NULL;
xf86Screens[i]->RRGetInfo = NULL;
xf86Screens[i]->RRSetConfig = NULL;
scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
if (scr_index == i) {
/*

View File

@ -1,4 +1,4 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.2 2004/04/23 19:20:32 eich Exp $ */
/*
* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $
*
@ -38,6 +38,7 @@ typedef struct _xf86RandRInfo {
CloseScreenProcPtr CloseScreen;
int virtualX;
int virtualY;
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
static int xf86RandRIndex;
@ -77,8 +78,8 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
return FALSE;
RRRegisterRate (pScreen, pSize, refresh);
if (mode == scrp->currentMode &&
mode->HDisplay == pScreen->width && mode->VDisplay == pScreen->height)
RRSetCurrentConfig (pScreen, RR_Rotate_0, refresh, pSize);
mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
if (mode->next == scrp->modes)
break;
}
@ -93,12 +94,17 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
if (!pSize)
return FALSE;
RRRegisterRate (pScreen, pSize, refresh0);
if (pScreen->width == randrp->virtualX &&
pScreen->height == randrp->virtualY)
if (scrp->virtualX == randrp->virtualX &&
scrp->virtualY == randrp->virtualY)
{
RRSetCurrentConfig (pScreen, RR_Rotate_0, refresh0, pSize);
RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
}
}
/* If there is driver support for randr, let it set our supported rotations */
if(scrp->RRGetInfo)
return (*scrp->RRGetInfo)(scrp, rotations);
return TRUE;
}
@ -125,8 +131,17 @@ xf86RandRSetMode (ScreenPtr pScreen,
scrp->virtualX = mode->HDisplay;
scrp->virtualY = mode->VDisplay;
}
pScreen->width = scrp->virtualX;
pScreen->height = scrp->virtualY;
if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
{
/* If the screen is rotated 90 or 270 degrees, swap the sizes. */
pScreen->width = scrp->virtualY;
pScreen->height = scrp->virtualX;
}
else
{
pScreen->width = scrp->virtualX;
pScreen->height = scrp->virtualY;
}
if (!xf86SwitchMode (pScreen, mode))
{
scrp->virtualX = pScreen->width = oldWidth;
@ -160,6 +175,8 @@ xf86RandRSetConfig (ScreenPtr pScreen,
int px, py;
Bool useVirtual = FALSE;
randrp->rotation = rotation;
miPointerPosition (&px, &py);
for (mode = scrp->modes; ; mode = mode->next)
{
@ -179,6 +196,12 @@ xf86RandRSetConfig (ScreenPtr pScreen,
return FALSE;
}
}
/* Have the driver do its thing. */
if (scrp->RRSetConfig &&
!(*scrp->RRSetConfig)(scrp, rotation, rate, pSize->width, pSize->height))
return FALSE;
if (!xf86RandRSetMode (pScreen, mode, useVirtual))
return FALSE;
/*
@ -189,6 +212,7 @@ xf86RandRSetConfig (ScreenPtr pScreen,
if (px < pSize->width && py < pSize->height)
(*pScreen->SetCursorPosition) (pScreen, px, py, FALSE);
}
return TRUE;
}
@ -277,6 +301,8 @@ xf86RandRInit (ScreenPtr pScreen)
randrp->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86RandRCloseScreen;
randrp->rotation = RR_Rotate_0;
pScreen->devPrivates[xf86RandRIndex].ptr = randrp;
return TRUE;
}

View File

@ -476,7 +476,7 @@ typedef struct _confdrirec {
/* These values should be adjusted when new fields are added to ScrnInfoRec */
#define NUM_RESERVED_INTS 16
#define NUM_RESERVED_POINTERS 15
#define NUM_RESERVED_FUNCS 12
#define NUM_RESERVED_FUNCS 10
typedef pointer (*funcPointer)(void);
@ -767,6 +767,8 @@ typedef int xf86HandleMessageProc (int, const char*, const char*, char**);
typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
typedef Bool xf86RRGetInfoProc (ScrnInfoPtr, unsigned short *);
typedef Bool xf86RRSetConfigProc (ScrnInfoPtr, int, int, int, int);
/*
* ScrnInfoRec
@ -921,6 +923,8 @@ typedef struct _ScrnInfoRec {
xf86DPMSSetProc *DPMSSet;
xf86LoadPaletteProc *LoadPalette;
xf86SetOverscanProc *SetOverscan;
xf86RRGetInfoProc *RRGetInfo;
xf86RRSetConfigProc *RRSetConfig;
/*
* This can be used when the minor ABI version is incremented.