From 238a2ec201a52d59a46540ddd419d8d6f6bf8daa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 29 Sep 2002 23:39:47 +0000 Subject: [PATCH] Update RandR to 1.0 (library version 2.0) --- hw/kdrive/fbdev/fbdev.c | 44 +++++-------------------------- hw/kdrive/mach64/mach64.c | 7 +++-- hw/kdrive/src/kdrive.c | 47 ++++++++++++++++++++++++++++++--- hw/kdrive/src/kdrive.h | 6 ++++- hw/kdrive/vesa/vesa.c | 55 +++++---------------------------------- hw/kdrive/vesa/vesa.h | 4 +-- 6 files changed, 66 insertions(+), 97 deletions(-) diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c index b5e2df9f9..6b943f906 100644 --- a/hw/kdrive/fbdev/fbdev.c +++ b/hw/kdrive/fbdev/fbdev.c @@ -21,7 +21,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.27 2001/07/20 19:35:29 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.28 2001/07/24 19:06:03 keithp Exp $ */ #include "fbdev.h" @@ -417,6 +417,7 @@ fbdevLayerCreate (ScreenPtr pScreen) update = 0; window = 0; } + return LayerCreate (pScreen, kind, screen->fb[0].depth, pPixmap, update, window, scrpriv->rotation, 0); } @@ -430,8 +431,6 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) FbdevPriv *priv = pScreenPriv->card->driver; KdScreenInfo *screen = pScreenPriv->screen; FbdevScrPriv *scrpriv = screen->driver; - RRVisualGroupPtr pVisualGroup; - RRGroupOfVisualGroupPtr pGroupOfVisualGroup; RRScreenSizePtr pSize; Rotation rotateKind; int rotation; @@ -445,42 +444,11 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) if (n == pScreen->numDepths) return FALSE; - pVisualGroup = RRCreateVisualGroup (pScreen); - if (!pVisualGroup) - return FALSE; - if (!RRAddDepthToVisualGroup (pScreen, - pVisualGroup, - &pScreen->allowedDepths[n])) - { - RRDestroyVisualGroup (pScreen, pVisualGroup); - return FALSE; - } - - pVisualGroup = RRRegisterVisualGroup (pScreen, pVisualGroup); - if (!pVisualGroup) - return FALSE; - - pGroupOfVisualGroup = RRCreateGroupOfVisualGroup (pScreen); - - if (!RRAddVisualGroupToGroupOfVisualGroup (pScreen, - pGroupOfVisualGroup, - pVisualGroup)) - { - RRDestroyGroupOfVisualGroup (pScreen, pGroupOfVisualGroup); - /* pVisualGroup left until screen closed */ - return FALSE; - } - - pGroupOfVisualGroup = RRRegisterGroupOfVisualGroup (pScreen, pGroupOfVisualGroup); - if (!pGroupOfVisualGroup) - return FALSE; - pSize = RRRegisterSize (pScreen, screen->width, screen->height, screen->width_mm, - screen->height_mm, - pGroupOfVisualGroup); + screen->height_mm); rotation = scrpriv->rotation - screen->rotation; if (rotation < 0) @@ -502,7 +470,7 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) break; } - RRSetCurrentConfig (pScreen, rotateKind, pSize, pVisualGroup); + RRSetCurrentConfig (pScreen, rotateKind, pSize); return TRUE; } @@ -532,8 +500,7 @@ fbdevLayerRemove (WindowPtr pWin, pointer value) fbdevRandRSetConfig (ScreenPtr pScreen, Rotation rotateKind, - RRScreenSizePtr pSize, - RRVisualGroupPtr pVisualGroup) + RRScreenSizePtr pSize) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; @@ -598,6 +565,7 @@ fbdevRandRSetConfig (ScreenPtr pScreen, WalkTree (pScreen, fbdevLayerRemove, (pointer) scrpriv->pLayer); LayerDestroy (pScreen, scrpriv->pLayer); scrpriv->pLayer = pNewLayer; + KdSetSubpixelOrder (pScreen, scrpriv->rotation); if (wasEnabled) KdEnableScreen (pScreen); } diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c index 6e49465c0..c78718330 100644 --- a/hw/kdrive/mach64/mach64.c +++ b/hw/kdrive/mach64/mach64.c @@ -19,7 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.7 2001/07/24 19:06:03 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.8 2001/07/24 21:26:17 keithp Exp $ */ #include "mach64.h" #include @@ -123,14 +123,13 @@ mach64InitScreen (ScreenPtr pScreen) #ifdef RANDR mach64RandRSetConfig (ScreenPtr pScreen, Rotation rotation, - RRScreenSizePtr pSize, - RRVisualGroupPtr pVisualGroup) + RRScreenSizePtr pSize) { KdScreenPriv(pScreen); KdCheckSync (pScreen); - if (!vesaRandRSetConfig (pScreen, rotation, pSize, pVisualGroup)) + if (!vesaRandRSetConfig (pScreen, rotation, pSize)) return FALSE; return TRUE; diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index e068fd18b..e7fabd96c 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.21tsi Exp $ + * $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.25 2002/09/26 02:56:48 keithp Exp $ * * Copyright © 1999 Keith Packard * @@ -384,6 +384,7 @@ KdParseScreen (KdScreenInfo *screen, screen->height = 0; screen->width_mm = 0; screen->height_mm = 0; + screen->subpixel_order = kdSubpixelOrder; screen->rate = 0; for (fb = 0; fb < KD_MAX_FB; fb++) screen->fb[fb].depth = 0; @@ -427,7 +428,8 @@ KdParseScreen (KdScreenInfo *screen, kdOrigin.y = 0; kdDumbDriver = FALSE; kdSoftCursor = FALSE; - + kdSubpixelOrder = SubPixelUnknown; + if (delim == '@') { arg = KdParseFindNext (arg, "x", save, &delim); @@ -854,6 +856,45 @@ KdCreateWindow (WindowPtr pWin) return fbCreateWindow (pWin); } +void +KdSetSubpixelOrder (ScreenPtr pScreen, int rotation) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + int subpixel_order = screen->subpixel_order; + int subpixel_dir; + int i; + + struct { + int subpixel_order; + int direction; + } orders[] = { + { SubPixelHorizontalRGB, 0 }, + { SubPixelHorizontalBGR, 180 }, + { SubPixelVerticalRGB, 270 }, + { SubPixelVerticalBGR, 90 }, + }; + + /* map subpixel to direction */ + for (i = 0; i < 4; i++) + if (orders[i].subpixel_order == subpixel_order) + break; + if (i < 4) + { + subpixel_dir = orders[i].direction; + /* add rotation */ + subpixel_dir += rotation; + /* map back to subpixel order */ + for (i = 0; i < 4; i++) + if (orders[i].direction == subpixel_dir) + { + subpixel_order = orders[i].subpixel_order; + break; + } + } + PictureSetSubpixelOrder (pScreen, subpixel_order); +} + /* Pass through AddScreen, which doesn't take any closure */ static KdScreenInfo *kdCurrentScreen; @@ -1025,7 +1066,7 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) return FALSE; } - PictureSetSubpixelOrder (pScreen, kdSubpixelOrder); + KdSetSubpixelOrder (pScreen, screen->rotation); /* * Enable the hardware diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h index d2f0d47d5..5a4db18b0 100644 --- a/hw/kdrive/src/kdrive.h +++ b/hw/kdrive/src/kdrive.h @@ -21,7 +21,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.21 2001/10/12 06:33:07 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.22 2002/08/02 16:15:02 keithp Exp $ */ #include #include "X.h" @@ -108,6 +108,7 @@ typedef struct _KdScreenInfo { int rate; int width_mm; int height_mm; + int subpixel_order; Bool dumb; Bool softCursor; int mynum; @@ -561,6 +562,9 @@ void KdInitOutput (ScreenInfo *pScreenInfo, int argc, char **argv); +void +KdSetSubpixelOrder (ScreenPtr pScreen, int rotation); + /* kinfo.c */ KdCardInfo * KdCardInfoAdd (KdCardFuncs *funcs, diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c index 85e44d535..3fcc9a2e3 100644 --- a/hw/kdrive/vesa/vesa.c +++ b/hw/kdrive/vesa/vesa.c @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.17 2001/09/05 07:12:42 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.18 2001/09/14 19:25:17 keithp Exp $ */ #include "vesa.h" #ifdef RANDR @@ -1010,8 +1010,6 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; int nmode; int n; - RRVisualGroupPtr pVisualGroup; - RRGroupOfVisualGroupPtr pGroupOfVisualGroup; RRScreenSizePtr pSize; *rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270; @@ -1026,46 +1024,6 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) xfree (priv->modes); priv->modes = modes; priv->nmode = nmode; - /* - * XXX Create a single set of visual sets that has all of the visuals - * for the root depth - */ - for (n = 0; n < pScreen->numDepths; n++) - if (pScreen->allowedDepths[n].numVids) - break; - if (n == pScreen->numDepths) - return FALSE; - - pVisualGroup = RRCreateVisualGroup (pScreen); - if (!pVisualGroup) - return FALSE; - - if (!RRAddDepthToVisualGroup (pScreen, - pVisualGroup, - &pScreen->allowedDepths[n])) - { - RRDestroyVisualGroup (pScreen, pVisualGroup); - return FALSE; - } - pVisualGroup = RRRegisterVisualGroup (pScreen, pVisualGroup); - if (!pVisualGroup) - return FALSE; - - pGroupOfVisualGroup = RRCreateGroupOfVisualGroup (pScreen); - - if (!RRAddVisualGroupToGroupOfVisualGroup (pScreen, - pGroupOfVisualGroup, - pVisualGroup)) - { - RRDestroyGroupOfVisualGroup (pScreen, pGroupOfVisualGroup); - /* pVisualGroup left until screen closed */ - return FALSE; - } - - pGroupOfVisualGroup = RRRegisterGroupOfVisualGroup (pScreen, pGroupOfVisualGroup); - if (!pGroupOfVisualGroup) - return FALSE; - for (n = 0; n < nmode; n++) { mode = &priv->modes[n]; @@ -1102,8 +1060,7 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) } pSize = RRRegisterSize (pScreen, width, height, - width_mm, height_mm, - pGroupOfVisualGroup); + width_mm, height_mm); if (mode->XResolution == screen->width && mode->YResolution == screen->height) { @@ -1117,8 +1074,7 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) case 180: rot = RR_Rotate_180; break; case 270: rot = RR_Rotate_270; break; } - RRSetCurrentConfig (pScreen, rot, pSize, - pVisualGroup); + RRSetCurrentConfig (pScreen, rot, pSize); } } } @@ -1152,8 +1108,7 @@ vesaLayerRemove (WindowPtr pWin, pointer value) Bool vesaRandRSetConfig (ScreenPtr pScreen, Rotation rotation, - RRScreenSizePtr pSize, - RRVisualGroupPtr pVisualGroup) + RRScreenSizePtr pSize) { KdScreenPriv(pScreen); VesaModePtr mode; @@ -1300,6 +1255,8 @@ vesaRandRSetConfig (ScreenPtr pScreen, pscr->pLayer = pNewLayer; + /* set the subpixel order */ + KdSetSubpixelOrder (pScreen, pscr->rotate); if (wasEnabled) KdEnableScreen (pScreen); diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h index fc8f7fa19..bab436fab 100644 --- a/hw/kdrive/vesa/vesa.h +++ b/hw/kdrive/vesa/vesa.h @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.11 2001/07/20 19:35:30 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.12 2001/09/05 07:12:42 keithp Exp $ */ #ifndef _VESA_H_ #define _VESA_H_ @@ -165,4 +165,4 @@ vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); int vesaProcessArgument (int argc, char **argv, int i); -#endif _VESA_H_ +#endif /* _VESA_H_ */