summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2002-10-03 22:09:04 +0000
committerKeith Packard <keithp@keithp.com>2002-10-03 22:09:04 +0000
commita80e1e5aed07cb57151408b0481f18e2ffb7f146 (patch)
tree5a670e58c4cf9489b36ff0dcf10a71221258d1da
parent238a2ec201a52d59a46540ddd419d8d6f6bf8daa (diff)
Update kdrive servers to support reflection
-rw-r--r--hw/kdrive/fbdev/fbdev.c121
-rw-r--r--hw/kdrive/fbdev/fbdev.h4
-rw-r--r--hw/kdrive/mach64/mach64video.c50
-rw-r--r--hw/kdrive/src/kdrive.c114
-rw-r--r--hw/kdrive/src/kdrive.h19
-rw-r--r--hw/kdrive/src/kinput.c38
-rw-r--r--hw/kdrive/vesa/vesa.c102
-rw-r--r--hw/kdrive/vesa/vesa.h4
8 files changed, 239 insertions, 213 deletions
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 6b943f906..b5499f4e9 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.28 2001/07/24 19:06:03 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.29 2002/09/29 23:39:46 keithp Exp $ */
#include "fbdev.h"
@@ -186,7 +186,7 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
break;
}
screen->rate = 72;
- scrpriv->rotation = screen->rotation;
+ scrpriv->randr = screen->randr;
#ifdef FAKE24_ON_16
if (screen->fb[0].depth == 24 && screen->fb[0].bitsPerPixel == 24 &&
@@ -348,43 +348,36 @@ fbdevLayerCreate (ScreenPtr pScreen)
int kind;
KdMouseMatrix m;
- switch (scrpriv->rotation) {
- case 0:
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
- scrpriv->shadow = FALSE;
- m.matrix[0][0] = 1; m.matrix[0][1] = 0; m.matrix[0][2] = 0;
- m.matrix[1][0] = 0; m.matrix[1][1] = 1; m.matrix[1][2] = 0;
- break;
- case 90:
- pScreen->width = screen->height;
- pScreen->height = screen->width;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
+#ifdef FAKE24_ON_16
+ if (fake24)
+ {
+ scrpriv->randr = RR_Rotate_0;
scrpriv->shadow = TRUE;
- m.matrix[0][0] = 0; m.matrix[0][1] = -1; m.matrix[0][2] = screen->height - 1;
- m.matrix[1][0] = 1; m.matrix[1][1] = 0; m.matrix[1][2] = 0;
- break;
- case 180:
+ }
+ else
+#endif /* FAKE24_ON_16 */
+ {
+ if (scrpriv->randr != RR_Rotate_0)
+ scrpriv->shadow = TRUE;
+ else
+ scrpriv->shadow = FALSE;
+ }
+
+ KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
+
+ if (m.matrix[0][0])
+ {
pScreen->width = screen->width;
pScreen->height = screen->height;
pScreen->mmWidth = screen->width_mm;
pScreen->mmHeight = screen->height_mm;
- scrpriv->shadow = TRUE;
- m.matrix[0][0] = -1; m.matrix[0][1] = 0; m.matrix[0][2] = screen->width - 1;
- m.matrix[1][0] = 0; m.matrix[1][1] = -1; m.matrix[1][2] = screen->height - 1;
- break;
- case 270:
+ }
+ else
+ {
pScreen->width = screen->height;
pScreen->height = screen->width;
pScreen->mmWidth = screen->height_mm;
pScreen->mmHeight = screen->width_mm;
- scrpriv->shadow = TRUE;
- m.matrix[0][0] = 0; m.matrix[0][1] = 1; m.matrix[0][2] = 0;
- m.matrix[1][0] = -1; m.matrix[1][1] = 0; m.matrix[1][2] = screen->width - 1;
- break;
}
KdSetMouseMatrix (&m);
@@ -400,7 +393,7 @@ fbdevLayerCreate (ScreenPtr pScreen)
else
#endif /* FAKE24_ON_16 */
{
- if (scrpriv->rotation)
+ if (scrpriv->randr)
update = shadowUpdateRotatePacked;
else
update = shadowUpdatePacked;
@@ -419,7 +412,7 @@ fbdevLayerCreate (ScreenPtr pScreen)
}
return LayerCreate (pScreen, kind, screen->fb[0].depth,
- pPixmap, update, window, scrpriv->rotation, 0);
+ pPixmap, update, window, scrpriv->randr, 0);
}
@@ -432,11 +425,10 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
KdScreenInfo *screen = pScreenPriv->screen;
FbdevScrPriv *scrpriv = screen->driver;
RRScreenSizePtr pSize;
- Rotation rotateKind;
- int rotation;
+ Rotation randr;
int n;
- *rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270;
+ *rotations = RR_Rotate_All|RR_Reflect_All;
for (n = 0; n < pScreen->numDepths; n++)
if (pScreen->allowedDepths[n].numVids)
@@ -450,27 +442,9 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
screen->width_mm,
screen->height_mm);
- rotation = scrpriv->rotation - screen->rotation;
- if (rotation < 0)
- rotation += 360;
-
- switch (rotation)
- {
- case 0:
- rotateKind = RR_Rotate_0;
- break;
- case 90:
- rotateKind = RR_Rotate_90;
- break;
- case 180:
- rotateKind = RR_Rotate_180;
- break;
- case 270:
- rotateKind = RR_Rotate_270;
- break;
- }
-
- RRSetCurrentConfig (pScreen, rotateKind, pSize);
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, pSize);
return TRUE;
}
@@ -499,42 +473,27 @@ fbdevLayerRemove (WindowPtr pWin, pointer value)
}
fbdevRandRSetConfig (ScreenPtr pScreen,
- Rotation rotateKind,
+ Rotation randr,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
FbdevPriv *priv = pScreenPriv->card->driver;
FbdevScrPriv *scrpriv = screen->driver;
- int rotation;
+ int rotate;
+ int reflect;
Bool wasEnabled = pScreenPriv->enabled;
/*
* The only thing that can change is rotation
*/
- switch (rotateKind)
- {
- case RR_Rotate_0:
- rotation = screen->rotation;
- break;
- case RR_Rotate_90:
- rotation = screen->rotation + 90;
- break;
- case RR_Rotate_180:
- rotation = screen->rotation + 180;
- break;
- case RR_Rotate_270:
- rotation = screen->rotation + 270;
- break;
- }
- if (rotation >= 360)
- rotation -= 360;
+ randr = KdAddRotation (randr, screen->randr);
- if (scrpriv->rotation != rotation)
+ if (scrpriv->randr != randr)
{
LayerPtr pNewLayer;
int kind;
- int oldrotation = scrpriv->rotation;
+ int oldrandr = scrpriv->randr;
int oldshadow = scrpriv->shadow;
int oldwidth = pScreen->width;
int oldheight = pScreen->height;
@@ -543,18 +502,18 @@ fbdevRandRSetConfig (ScreenPtr pScreen,
if (wasEnabled)
KdDisableScreen (pScreen);
- scrpriv->rotation = rotation;
+ scrpriv->randr = randr;
pNewLayer = fbdevLayerCreate (pScreen);
if (!pNewLayer)
{
scrpriv->shadow = oldshadow;
- scrpriv->rotation = oldrotation;
+ scrpriv->randr = oldrandr;
}
if (WalkTree (pScreen, fbdevLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING)
{
WalkTree (pScreen, fbdevLayerRemove, (pointer) pNewLayer);
LayerDestroy (pScreen, pNewLayer);
- scrpriv->rotation = oldrotation;
+ scrpriv->randr = oldrandr;
scrpriv->shadow = oldshadow;
pScreen->width = oldwidth;
pScreen->height = oldheight;
@@ -565,7 +524,7 @@ fbdevRandRSetConfig (ScreenPtr pScreen,
WalkTree (pScreen, fbdevLayerRemove, (pointer) scrpriv->pLayer);
LayerDestroy (pScreen, scrpriv->pLayer);
scrpriv->pLayer = pNewLayer;
- KdSetSubpixelOrder (pScreen, scrpriv->rotation);
+ KdSetSubpixelOrder (pScreen, scrpriv->randr);
if (wasEnabled)
KdEnableScreen (pScreen);
}
diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h
index 330f43720..c821bc140 100644
--- a/hw/kdrive/fbdev/fbdev.h
+++ b/hw/kdrive/fbdev/fbdev.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/fbdev/fbdev.h,v 1.10 2001/05/29 17:47:55 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.11 2001/06/03 21:52:45 keithp Exp $ */
#ifndef _FBDEV_H_
#define _FBDEV_H_
@@ -48,7 +48,7 @@ typedef struct _fbdevPriv {
} FbdevPriv;
typedef struct _fbdevScrPriv {
- int rotation;
+ Rotation randr;
Bool shadow;
LayerPtr pLayer;
} FbdevScrPriv;
diff --git a/hw/kdrive/mach64/mach64video.c b/hw/kdrive/mach64/mach64video.c
index 545d0cb5f..ccf73d50e 100644
--- a/hw/kdrive/mach64/mach64video.c
+++ b/hw/kdrive/mach64/mach64video.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/mach64video.c,v 1.6 2001/07/24 19:06:03 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.7 2001/08/09 09:08:55 keithp Exp $ */
#include "mach64.h"
#include "Xv.h"
@@ -148,7 +148,7 @@ mach64QueryBestSize(KdScreenInfo *screen,
static void
mach64CopyPackedData(KdScreenInfo *screen,
unsigned char *buf,
- int rotate,
+ int randr,
int srcPitch,
int dstPitch,
int srcW,
@@ -168,24 +168,24 @@ mach64CopyPackedData(KdScreenInfo *screen,
int srcDown, srcRight, srcNext;
int p;
- switch (rotate) {
- case 0:
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
src = buf;
srcDown = srcPitch;
srcRight = 2;
break;
- case 90:
- src = src + (srcH - 1) * 2;
+ case RR_Rotate_90:
+ src = buf + (srcH - 1) * 2;
srcDown = -2;
srcRight = srcPitch;
break;
- case 180:
- src = src + srcPitch * (srcH - 1) + (srcW - 1) * 2;
+ case RR_Rotate_180:
+ src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2;
srcDown = -srcPitch;
srcRight = -2;
break;
- case 270:
- src = src + srcPitch * (srcW - 1);
+ case RR_Rotate_270:
+ src = buf + srcPitch * (srcW - 1);
srcDown = 2;
srcRight = -srcPitch;
break;
@@ -505,7 +505,7 @@ mach64DisplayVideo(KdScreenInfo *screen,
int xscaleInt, xscaleFract, yscaleInt, yscaleFract;
int xscaleIntUV = 0, xscaleFractUV = 0;
int yscaleIntUV = 0, yscaleFractUV = 0;
- int rotate = mach64s->vesa.rotate;
+ int randr = mach64s->vesa.randr;
int HORZ_INC, VERT_INC;
CARD32 SCALER_IN;
CARD32 OVERLAY_SCALE_CNTL;
@@ -622,7 +622,7 @@ mach64PutImage(KdScreenInfo *screen,
Reg *reg = mach64c->reg;
MediaReg *media = mach64c->media_reg;
INT32 x1, x2, y1, y2;
- int rotate = mach64s->vesa.rotate;
+ int randr = mach64s->vesa.randr;
int srcPitch, srcPitch2, dstPitch;
int top, left, npixels, nlines, size;
BoxRec dstBox;
@@ -651,29 +651,27 @@ mach64PutImage(KdScreenInfo *screen,
if (!media)
return BadAlloc;
- switch (rotate) {
- case 0:
- case 180:
+ if (randr & (RR_Rotate_0|RR_Rotate_180))
+ {
dst_width = width;
dst_height = height;
rot_src_w = src_w;
rot_src_h = src_h;
rot_drw_w = drw_w;
rot_drw_h = drw_h;
- break;
- case 90:
- case 270:
+ }
+ else
+ {
dst_width = height;
dst_height = width;
rot_src_w = src_h;
rot_src_h = src_w;
rot_drw_w = drw_h;
rot_drw_h = drw_w;
- break;
}
- switch (rotate) {
- case 0:
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
dst_x1 = dstBox.x1;
dst_y1 = dstBox.y1;
dst_x2 = dstBox.x2;
@@ -683,7 +681,7 @@ mach64PutImage(KdScreenInfo *screen,
rot_x2 = x2;
rot_y2 = y2;
break;
- case 90:
+ case RR_Rotate_90:
dst_x1 = dstBox.y1;
dst_y1 = screen->height - dstBox.x2;
dst_x2 = dstBox.y2;
@@ -694,7 +692,7 @@ mach64PutImage(KdScreenInfo *screen,
rot_x2 = y2;
rot_y2 = (src_w << 16) - x1;
break;
- case 180:
+ case RR_Rotate_180:
dst_x1 = screen->width - dstBox.x2;
dst_y1 = screen->height - dstBox.y2;
dst_x2 = screen->width - dstBox.x1;
@@ -704,7 +702,7 @@ mach64PutImage(KdScreenInfo *screen,
rot_x2 = (src_w << 16) - x1;
rot_y2 = (src_h << 16) - y1;
break;
- case 270:
+ case RR_Rotate_270:
dst_x1 = screen->width - dstBox.y2;
dst_y1 = dstBox.x1;
dst_x2 = screen->width - dstBox.y1;
@@ -764,7 +762,7 @@ mach64PutImage(KdScreenInfo *screen,
case FOURCC_I420:
top &= ~1;
nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
- mach64CopyPlanarData(screen, buf, rotate,
+ mach64CopyPlanarData(screen, buf, randr,
srcPitch, srcPitch2, dstPitch,
rot_src_w, rot_src_h, height,
top, left, nlines, npixels, id);
@@ -773,7 +771,7 @@ mach64PutImage(KdScreenInfo *screen,
case FOURCC_YUY2:
default:
nlines = ((rot_y2 + 0xffff) >> 16) - top;
- mach64CopyPackedData(screen, buf, rotate,
+ mach64CopyPackedData(screen, buf, randr,
srcPitch, dstPitch,
rot_src_w, rot_src_h,
top, left, nlines,
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index e7fabd96c..5eba38823 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.25 2002/09/26 02:56:48 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.26 2002/09/29 23:39:46 keithp Exp $
*
* Copyright © 1999 Keith Packard
*
@@ -28,6 +28,9 @@
#endif
#include <mivalidate.h>
#include <dixstruct.h>
+#ifdef RANDR
+#include <randrstr.h>
+#endif
#ifdef XV
#include "kxv.h"
@@ -365,6 +368,28 @@ KdParseFindNext (char *cur, char *delim, char *save, char *last)
return cur;
}
+Rotation
+KdAddRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
+Rotation
+KdSubRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
void
KdParseScreen (KdScreenInfo *screen,
char *arg)
@@ -379,7 +404,7 @@ KdParseScreen (KdScreenInfo *screen,
screen->dumb = kdDumbDriver;
screen->softCursor = kdSoftCursor;
screen->origin = kdOrigin;
- screen->rotation = 0;
+ screen->randr = RR_Rotate_0;
screen->width = 0;
screen->height = 0;
screen->width_mm = 0;
@@ -395,7 +420,7 @@ KdParseScreen (KdScreenInfo *screen,
for (i = 0; i < 2; i++)
{
- arg = KdParseFindNext (arg, "x/@", save, &delim);
+ arg = KdParseFindNext (arg, "x/@XY", save, &delim);
if (!save[0])
return;
@@ -404,7 +429,7 @@ KdParseScreen (KdScreenInfo *screen,
if (delim == '/')
{
- arg = KdParseFindNext (arg, "x@", save, &delim);
+ arg = KdParseFindNext (arg, "x@XY", save, &delim);
if (!save[0])
return;
mm = atoi(save);
@@ -420,7 +445,7 @@ KdParseScreen (KdScreenInfo *screen,
screen->height = pixels;
screen->height_mm = mm;
}
- if (delim != 'x' && delim != '@')
+ if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
return;
}
@@ -432,22 +457,33 @@ KdParseScreen (KdScreenInfo *screen,
if (delim == '@')
{
- arg = KdParseFindNext (arg, "x", save, &delim);
+ arg = KdParseFindNext (arg, "xXY", save, &delim);
if (save[0])
{
- screen->rotation = atoi (save);
- if (screen->rotation < 45)
- screen->rotation = 0;
- else if (screen->rotation < 135)
- screen->rotation = 90;
- else if (screen->rotation < 225)
- screen->rotation = 180;
- else if (screen->rotation < 315)
- screen->rotation = 270;
+ int rotate = atoi (save);
+ if (rotate < 45)
+ screen->randr = RR_Rotate_0;
+ else if (rotate < 135)
+ screen->randr = RR_Rotate_90;
+ else if (rotate < 225)
+ screen->randr = RR_Rotate_180;
+ else if (rotate < 315)
+ screen->randr = RR_Rotate_270;
else
- screen->rotation = 0;
+ screen->randr = RR_Rotate_0;
}
}
+ if (delim == 'X')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_X;
+ }
+
+ if (delim == 'Y')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_Y;
+ }
fb = 0;
while (fb < KD_MAX_FB)
@@ -857,22 +893,33 @@ KdCreateWindow (WindowPtr pWin)
}
void
-KdSetSubpixelOrder (ScreenPtr pScreen, int rotation)
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
int subpixel_order = screen->subpixel_order;
- int subpixel_dir;
+ Rotation subpixel_dir;
int i;
- struct {
- int subpixel_order;
- int direction;
+ static struct {
+ int subpixel_order;
+ Rotation direction;
} orders[] = {
- { SubPixelHorizontalRGB, 0 },
- { SubPixelHorizontalBGR, 180 },
- { SubPixelVerticalRGB, 270 },
- { SubPixelVerticalBGR, 90 },
+ { SubPixelHorizontalRGB, RR_Rotate_0 },
+ { SubPixelHorizontalBGR, RR_Rotate_180 },
+ { SubPixelVerticalRGB, RR_Rotate_270 },
+ { SubPixelVerticalBGR, RR_Rotate_90 },
+ };
+
+ static struct {
+ int bit;
+ int normal;
+ int reflect;
+ } reflects[] = {
+ { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR },
+ { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB },
};
/* map subpixel to direction */
@@ -881,16 +928,23 @@ KdSetSubpixelOrder (ScreenPtr pScreen, int rotation)
break;
if (i < 4)
{
- subpixel_dir = orders[i].direction;
- /* add rotation */
- subpixel_dir += rotation;
+ subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction);
+
/* map back to subpixel order */
for (i = 0; i < 4; i++)
- if (orders[i].direction == subpixel_dir)
+ if (orders[i].direction & subpixel_dir)
{
subpixel_order = orders[i].subpixel_order;
break;
}
+ /* reflect */
+ for (i = 0; i < 4; i++)
+ if ((randr & reflects[i].bit) &&
+ reflects[i].normal == subpixel_order)
+ {
+ subpixel_order = reflects[i].reflect;
+ break;
+ }
}
PictureSetSubpixelOrder (pScreen, subpixel_order);
}
@@ -1066,7 +1120,7 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
- KdSetSubpixelOrder (pScreen, screen->rotation);
+ KdSetSubpixelOrder (pScreen, screen->randr);
/*
* Enable the hardware
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 5a4db18b0..b33b710ed 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.22 2002/08/02 16:15:02 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.23 2002/09/29 23:39:46 keithp Exp $ */
#include <stdio.h>
#include "X.h"
@@ -42,6 +42,7 @@
#include "fb.h"
#include "fboverlay.h"
#include "shadow.h"
+#include "randrstr.h"
extern WindowPtr *WindowTable;
@@ -97,12 +98,15 @@ typedef struct _KdFrameBuffer {
void *closure;
} KdFrameBuffer;
+#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
+#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
+
typedef struct _KdScreenInfo {
struct _KdScreenInfo *next;
KdCardInfo *card;
ScreenPtr pScreen;
void *driver;
- int rotation;
+ Rotation randr; /* rotation and reflection */
int width;
int height;
int rate;
@@ -514,6 +518,12 @@ KdResume (void);
void
KdProcessSwitch (void);
+Rotation
+KdAddRotation (Rotation a, Rotation b);
+
+Rotation
+KdSubRotation (Rotation a, Rotation b);
+
void
KdParseScreen (KdScreenInfo *screen,
char *arg);
@@ -563,7 +573,7 @@ KdInitOutput (ScreenInfo *pScreenInfo,
int argc, char **argv);
void
-KdSetSubpixelOrder (ScreenPtr pScreen, int rotation);
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
/* kinfo.c */
KdCardInfo *
@@ -629,6 +639,9 @@ void
KdSetMouseMatrix (KdMouseMatrix *matrix);
void
+KdComputeMouseMatrix (KdMouseMatrix *matrix, Rotation randr, int width, int height);
+
+void
KdBlockHandler (int screen,
pointer blockData,
pointer timeout,
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index f6eef0dca..773ca8a42 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.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/kinput.c,v 1.21 2001/09/29 04:16:38 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.24 2002/08/15 18:07:57 keithp Exp $ */
#include "kdrive.h"
#include "inputstr.h"
@@ -369,6 +369,42 @@ KdSetMouseMatrix (KdMouseMatrix *matrix)
kdMouseMatrix = *matrix;
}
+void
+KdComputeMouseMatrix (KdMouseMatrix *m, Rotation randr, int width, int height)
+{
+ int x_dir = 1, y_dir = 1;
+ int i, j;
+ int size[2];
+
+ size[0] = width; size[1] = height;
+ if (randr & RR_Reflect_X)
+ x_dir = -1;
+ if (randr & RR_Reflect_Y)
+ y_dir = -1;
+ switch (randr & (RR_Rotate_All)) {
+ case RR_Rotate_0:
+ m->matrix[0][0] = x_dir; m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0; m->matrix[1][1] = y_dir;
+ break;
+ case RR_Rotate_90:
+ m->matrix[0][0] = 0; m->matrix[0][1] = -y_dir;
+ m->matrix[1][0] = x_dir; m->matrix[1][1] = 0;
+ break;
+ case RR_Rotate_180:
+ m->matrix[0][0] = -x_dir; m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0; m->matrix[1][1] = -y_dir;
+ break;
+ case RR_Rotate_270:
+ m->matrix[0][0] = 0; m->matrix[0][1] = y_dir;
+ m->matrix[1][0] = -x_dir; m->matrix[1][1] = 0;
+ break;
+ }
+ for (i = 0; i < 2; i++)
+ for (j = 0 ; j < 2; j++)
+ if (m->matrix[i][j] < 0)
+ m->matrix[i][3] = size[j] - 1;
+}
+
static void
KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
{
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index 3fcc9a2e3..5ed2acd38 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.18 2001/09/14 19:25:17 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.19 2002/09/29 23:39:47 keithp Exp $ */
#include "vesa.h"
#ifdef RANDR
@@ -401,7 +401,7 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
vesaReportMode (&pscr->mode);
}
- pscr->rotate = screen->rotation;
+ pscr->randr = screen->randr;
pscr->shadow = vesa_shadow;
pscr->origDepth = screen->fb[0].depth;
pscr->layerKind = LAYER_FB;
@@ -409,6 +409,7 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
/*
* Compute visual support for the selected depth
*/
+
switch (pscr->mode.MemoryModel) {
case MEMORY_DIRECT:
/* TrueColor or DirectColor */
@@ -748,50 +749,31 @@ vesaConfigureScreen (ScreenPtr pScreen)
if (pscr->mapping == VESA_PLANAR || pscr->mapping == VESA_MONO)
{
pscr->shadow = TRUE;
- pscr->rotate = 0;
- m.matrix[0][0] = 1; m.matrix[0][1] = 0; m.matrix[0][2] = 0;
- m.matrix[1][0] = 0; m.matrix[1][1] = 1; m.matrix[1][2] = 0;
+ pscr->randr = RR_Rotate_0;
}
- else switch (pscr->rotate) {
- case 0:
- pScreen->width = pscr->mode.XResolution;
- pScreen->height = pscr->mode.YResolution;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
- if (pscr->mapping == VESA_WINDOWED)
- pscr->shadow = TRUE;
- else
- pscr->shadow = vesa_shadow;
- m.matrix[0][0] = 1; m.matrix[0][1] = 0; m.matrix[0][2] = 0;
- m.matrix[1][0] = 0; m.matrix[1][1] = 1; m.matrix[1][2] = 0;
- break;
- case 90:
- pScreen->width = pscr->mode.YResolution;
- pScreen->height = pscr->mode.XResolution;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
+ else if (pscr->mapping == VESA_WINDOWED)
pscr->shadow = TRUE;
- m.matrix[0][0] = 0; m.matrix[0][1] = -1; m.matrix[0][2] = pscr->mode.YResolution - 1;
- m.matrix[1][0] = 1; m.matrix[1][1] = 0; m.matrix[1][2] = 0;
- break;
- case 180:
+ else if (pscr->randr != RR_Rotate_0)
+ pscr->shadow = TRUE;
+ else
+ pscr->shadow = vesa_shadow;
+
+ KdComputeMouseMatrix (&m, pscr->randr,
+ pscr->mode.XResolution, pscr->mode.YResolution);
+
+ if (m.matrix[0][0])
+ {
pScreen->width = pscr->mode.XResolution;
pScreen->height = pscr->mode.YResolution;
pScreen->mmWidth = screen->width_mm;
pScreen->mmHeight = screen->height_mm;
- pscr->shadow = TRUE;
- m.matrix[0][0] = -1; m.matrix[0][1] = 0; m.matrix[0][2] = pscr->mode.XResolution - 1;
- m.matrix[1][0] = 0; m.matrix[1][1] = -1; m.matrix[1][2] = pscr->mode.YResolution - 1;
- break;
- case 270:
+ }
+ else
+ {
pScreen->width = pscr->mode.YResolution;
pScreen->height = pscr->mode.XResolution;
pScreen->mmWidth = screen->height_mm;
pScreen->mmHeight = screen->width_mm;
- pscr->shadow = TRUE;
- m.matrix[0][0] = 0; m.matrix[0][1] = 1; m.matrix[0][2] = 0;
- m.matrix[1][0] = -1; m.matrix[1][1] = 0; m.matrix[1][2] = pscr->mode.XResolution - 1;
- break;
}
KdSetMouseMatrix (&m);
}
@@ -811,7 +793,7 @@ vesaLayerCreate (ScreenPtr pScreen)
if (pscr->shadow)
{
- if (pscr->rotate)
+ if (pscr->randr != RR_Rotate_0)
update = shadowUpdateRotatePacked;
else
update = shadowUpdatePacked;
@@ -855,7 +837,7 @@ vesaLayerCreate (ScreenPtr pScreen)
pScreen->width, pScreen->height, screen->fb[0].depth);
return LayerCreate (pScreen, kind, screen->fb[0].depth,
- pPixmap, update, window, pscr->rotate, 0);
+ pPixmap, update, window, pscr->randr, 0);
}
Bool
@@ -929,7 +911,7 @@ vesaMapFramebuffer (KdScreenInfo *screen)
ErrorF ("\tStatic color bpp %d depth %d\n",
bpp, depth);
}
- pscr->rotate = 0;
+ pscr->randr = RR_Rotate_0;
break;
default:
return 0;
@@ -941,7 +923,8 @@ vesaMapFramebuffer (KdScreenInfo *screen)
case 32:
break;
default:
- pscr->rotate = 0;
+ pscr->randr = RR_Rotate_0;
+ break;
}
screen->width = pscr->mode.XResolution;
@@ -1012,7 +995,8 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
int n;
RRScreenSizePtr pSize;
- *rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270;
+ *rotations = (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270|
+ RR_Reflect_X|RR_Reflect_Y);
/*
* Get mode information from BIOS -- every time in case
* something changes, like an external monitor is plugged in
@@ -1044,7 +1028,7 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
mode->BlueFieldPosition == pscr->mode.BlueFieldPosition)
{
int width, height, width_mm, height_mm;
- if (screen->rotation == 0 || screen->rotation == 180)
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
{
width = mode->XResolution;
height = mode->YResolution;
@@ -1064,17 +1048,8 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
if (mode->XResolution == screen->width &&
mode->YResolution == screen->height)
{
- int rotate = pscr->rotate - screen->rotation;
- int rot;
- if (rotate < 0)
- rotate += 360;
- switch (rotate) {
- case 0: rot = RR_Rotate_0; break;
- case 90: rot = RR_Rotate_90; break;
- case 180: rot = RR_Rotate_180; break;
- case 270: rot = RR_Rotate_270; break;
- }
- RRSetCurrentConfig (pScreen, rot, pSize);
+ int randr = KdSubRotation (pscr->randr, screen->randr);
+ RRSetCurrentConfig (pScreen, randr, pSize);
}
}
}
@@ -1107,7 +1082,7 @@ vesaLayerRemove (WindowPtr pWin, pointer value)
Bool
vesaRandRSetConfig (ScreenPtr pScreen,
- Rotation rotation,
+ Rotation randr,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
@@ -1126,7 +1101,7 @@ vesaRandRSetConfig (ScreenPtr pScreen,
LayerPtr pNewLayer;
int newwidth, newheight;
- if (screen->rotation == 0 || screen->rotation == 180)
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
{
newwidth = pSize->width;
newheight = pSize->height;
@@ -1182,17 +1157,8 @@ vesaRandRSetConfig (ScreenPtr pScreen,
*/
pscr->mode = *mode;
- switch (rotation) {
- case RR_Rotate_0: pscr->rotate = 0; break;
- case RR_Rotate_90: pscr->rotate = 90; break;
- case RR_Rotate_180: pscr->rotate = 180; break;
- case RR_Rotate_270: pscr->rotate = 270; break;
- }
-
- pscr->rotate += screen->rotation;
- if (pscr->rotate >= 360)
- pscr->rotate -= 360;
-
+ pscr->randr = KdAddRotation (screen->randr, randr);
+
/*
* Can't rotate some formats
*/
@@ -1202,7 +1168,7 @@ vesaRandRSetConfig (ScreenPtr pScreen,
case 32:
break;
default:
- if (pscr->rotate)
+ if (pscr->randr)
goto bail2;
break;
}
@@ -1256,7 +1222,7 @@ vesaRandRSetConfig (ScreenPtr pScreen,
pscr->pLayer = pNewLayer;
/* set the subpixel order */
- KdSetSubpixelOrder (pScreen, pscr->rotate);
+ KdSetSubpixelOrder (pScreen, pscr->randr);
if (wasEnabled)
KdEnableScreen (pScreen);
diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h
index bab436fab..ceac5911a 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.12 2001/09/05 07:12:42 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.13 2002/09/29 23:39:47 keithp Exp $ */
#ifndef _VESA_H_
#define _VESA_H_
@@ -95,7 +95,7 @@ typedef struct _VesaCardPriv {
typedef struct _VesaScreenPriv {
VesaModeRec mode;
Bool shadow;
- int rotate;
+ Rotation randr;
int mapping;
int origDepth;
int layerKind;