summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2001-06-04 09:45:42 +0000
committerKeith Packard <keithp@keithp.com>2001-06-04 09:45:42 +0000
commit7fcf46356ba70563f036f535e60667727db442ae (patch)
treea41d16fd99af940ba74e1566c33165aad8312c6c
parent54e66d92db917923e33e018e628a7629d6705507 (diff)
Allow for hardware acceleration under RandR with Layer. Hardware/Software
cursor switching still busted
-rw-r--r--hw/kdrive/mach64/mach64.c40
-rw-r--r--hw/kdrive/mach64/mach64.h8
-rw-r--r--hw/kdrive/mach64/mach64draw.c30
-rw-r--r--hw/kdrive/src/kaa.c10
-rw-r--r--hw/kdrive/src/kasync.c8
-rw-r--r--hw/kdrive/src/kdrive.c15
-rw-r--r--hw/kdrive/src/kdrive.h15
-rw-r--r--hw/kdrive/trident/trident.c11
-rw-r--r--hw/kdrive/vesa/vesa.c680
-rw-r--r--hw/kdrive/vesa/vesa.h14
-rw-r--r--hw/kdrive/vesa/vesainit.c4
11 files changed, 544 insertions, 291 deletions
diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c
index 7abbf7bf5..90f26e44e 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.16 2001/03/21 16:43:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.1 2001/06/03 18:48:19 keithp Exp $ */
#include "mach64.h"
#include <sys/io.h>
@@ -108,6 +108,42 @@ mach64InitScreen (ScreenPtr pScreen)
return vesaInitScreen (pScreen);
}
+#ifdef RANDR
+mach64RandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ RRScreenSizePtr pSize,
+ RRVisualGroupPtr pVisualGroup)
+{
+ KdScreenPriv(pScreen);
+
+ KdCheckSync (pScreen);
+
+ if (!vesaRandRSetConfig (pScreen, rotation, pSize, pVisualGroup))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+mach64RandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ pScrPriv->rrSetConfig = mach64RandRSetConfig;
+}
+#endif
+
+Bool
+mach64FinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = vesaFinishInitScreen (pScreen);
+#ifdef RANDR
+ mach64RandRInit (pScreen);
+#endif
+ return ret;
+}
+
CARD32
mach64ReadLCD (Reg *reg, int id)
{
@@ -328,4 +364,6 @@ KdCardFuncs mach64Funcs = {
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
+
+ mach64FinishInitScreen, /* finishInitScreen */
};
diff --git a/hw/kdrive/mach64/mach64.h b/hw/kdrive/mach64/mach64.h
index 2f0c376e3..a912e2a50 100644
--- a/hw/kdrive/mach64/mach64.h
+++ b/hw/kdrive/mach64/mach64.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/mach64/mach64.h,v 1.9 2000/11/29 08:42:25 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.h,v 1.1 2001/06/03 18:48:19 keithp Exp $ */
#ifndef _MACH64_H_
#define _MACH64_H_
@@ -482,9 +482,15 @@ void
mach64WriteLCD (Reg *reg, int id, CARD32 data);
Bool
+mach64DrawSetup (ScreenPtr pScreen);
+
+Bool
mach64DrawInit (ScreenPtr pScreen);
void
+mach64DrawReinit (ScreenPtr pScreen);
+
+void
mach64DrawEnable (ScreenPtr pScreen);
void
diff --git a/hw/kdrive/mach64/mach64draw.c b/hw/kdrive/mach64/mach64draw.c
index e248dabdd..5371e95b1 100644
--- a/hw/kdrive/mach64/mach64draw.c
+++ b/hw/kdrive/mach64/mach64draw.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/mach64/mach64draw.c,v 1.9 2001/05/30 15:36:25 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.1 2001/06/03 18:48:19 keithp Exp $ */
#include "mach64.h"
#include "mach64draw.h"
@@ -227,6 +227,20 @@ KaaScreenPrivRec mach64Kaa = {
mach64DoneCopy,
};
+Bool
+mach64DrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+
+ if (pScreenPriv->screen->fb[0].depth == 4)
+ return FALSE;
+
+ if (!kaaDrawInit (pScreen, &mach64Kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
#define PIX_FORMAT_MONO 0
#define PIX_FORMAT_PSEUDO_8 2
#define PIX_FORMAT_TRUE_1555 3
@@ -238,7 +252,8 @@ KaaScreenPrivRec mach64Kaa = {
#define PIX_FORMAT_YUV_444 0xe
#define PIX_FORMAT_TRUE_4444 0xf
-mach64DrawInit (ScreenPtr pScreen)
+void
+mach64DrawEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
@@ -266,7 +281,7 @@ mach64DrawInit (ScreenPtr pScreen)
SET_DP_DST_PIX_WIDTH = PIX_FORMAT_MONO;
break;
case 4:
- return FALSE;
+ FatalError ("mach64 can't accelerate 4bpp");
break;
case 8:
DP_PIX_WIDTH = ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */
@@ -355,9 +370,6 @@ mach64DrawInit (ScreenPtr pScreen)
break;
}
- if (!kaaDrawInit (pScreen, &mach64Kaa))
- return FALSE;
-
mach64s->DP_PIX_WIDTH = DP_PIX_WIDTH;
DST1_PITCH = (pScreenPriv->screen->fb[0].pixelStride) >> 3;
if (mach64s->bpp24)
@@ -380,12 +392,6 @@ mach64DrawInit (ScreenPtr pScreen)
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0);
- return TRUE;
-}
-
-void
-mach64DrawEnable (ScreenPtr pScreen)
-{
KdMarkSync (pScreen);
}
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index 28164abf3..85a006152 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/programs/Xserver/hw/kdrive/kaa.c,v 1.2 2001/05/30 15:36:25 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kaa.c,v 1.3 2001/06/03 18:48:19 keithp Exp $
*
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -503,9 +503,8 @@ kaaCreateGC (GCPtr pGC)
if (!fbCreateGC (pGC))
return FALSE;
- if (pGC->depth != 1)
- pGC->funcs = &kaaGCFuncs;
-
+ pGC->funcs = &kaaGCFuncs;
+
return TRUE;
}
@@ -556,8 +555,11 @@ kaaFillRegionSolid (DrawablePtr pDrawable,
KdMarkSync(pDrawable->pScreen);
}
else
+ {
+ KdCheckSync (pDrawable->pScreen);
fbFillRegionSolid (pDrawable, pRegion, 0,
fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+ }
}
void
diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c
index 3dd86b851..04542ba8d 100644
--- a/hw/kdrive/src/kasync.c
+++ b/hw/kdrive/src/kasync.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/kasync.c,v 1.7 2000/09/22 06:25:29 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kasync.c,v 1.8 2001/03/30 02:15:19 keithp Exp $ */
#include "kdrive.h"
@@ -60,7 +60,8 @@ RegionPtr
KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty)
{
- KdCheckSync (pSrc->pScreen);
+ if (pSrc->type == DRAWABLE_WINDOW || pDst->type == DRAWABLE_WINDOW)
+ KdCheckSync (pSrc->pScreen);
return fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
}
@@ -69,7 +70,8 @@ KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty,
unsigned long bitPlane)
{
- KdCheckSync (pSrc->pScreen);
+ if (pSrc->type == DRAWABLE_WINDOW || pDst->type == DRAWABLE_WINDOW)
+ KdCheckSync (pSrc->pScreen);
return fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
bitPlane);
}
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 35c2fc7a2..74d84c4a0 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.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/kdrive.c,v 1.14 2001/05/26 01:25:41 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.15 2001/05/29 04:54:10 keithp Exp $ */
#include "kdrive.h"
#ifdef PSEUDO8
@@ -744,8 +744,12 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
*/
if (screen->width_mm)
pScreen->mmWidth = screen->width_mm;
+ else
+ screen->width_mm = pScreen->mmWidth;
if (screen->height_mm)
pScreen->mmHeight = screen->height_mm;
+ else
+ screen->height_mm = pScreen->mmHeight;
/*
* Plug in our own block/wakeup handlers.
@@ -758,11 +762,6 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
if (!fbPictureInit (pScreen, 0, 0))
return FALSE;
#endif
-#ifdef RANDR
- if (!miRandRInit (pScreen))
- return FALSE;
-#endif
-
if (card->cfuncs->initScreen)
if (!(*card->cfuncs->initScreen) (pScreen))
return FALSE;
@@ -775,6 +774,10 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
(void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
#endif
+ if (card->cfuncs->finishInitScreen)
+ if (!(*card->cfuncs->finishInitScreen) (pScreen))
+ return FALSE;
+
#if 0
fbInitValidateTree (pScreen);
#endif
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 13385d248..0070daf6a 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.12 2000/12/08 22:59:37 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.14 2001/05/29 04:54:10 keithp Exp $ */
#include <stdio.h>
#include "X.h"
@@ -140,6 +140,8 @@ typedef struct _KdCardFuncs {
void (*getColors) (ScreenPtr, int, int, xColorItem *);
void (*putColors) (ScreenPtr, int, int, xColorItem *);
+
+ Bool (*finishInitScreen) (ScreenPtr pScreen);
} KdCardFuncs;
#define KD_MAX_PSEUDO_DEPTH 8
@@ -291,6 +293,17 @@ extern KdOsFuncs *kdOsFuncs;
#define KdMarkSync(s) (KdGetScreenPriv(s)->card->needSync = TRUE)
+/* kaa.c */
+Bool
+kaaDrawInit (ScreenPtr pScreen,
+ KaaScreenPrivPtr pScreenPriv);
+
+void
+kaaWrapGC (GCPtr pGC);
+
+void
+kaaUnwrapGC (GCPtr pGC);
+
/* kasync.c */
void
KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
diff --git a/hw/kdrive/trident/trident.c b/hw/kdrive/trident/trident.c
index 065548bdd..124757cdb 100644
--- a/hw/kdrive/trident/trident.c
+++ b/hw/kdrive/trident/trident.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/trident/trident.c,v 1.16 2001/03/21 16:43:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.17 2001/06/03 18:48:19 keithp Exp $ */
#include "trident.h"
#include <sys/io.h>
@@ -155,6 +155,14 @@ tridentInitScreen (ScreenPtr pScreen)
#endif
}
+Bool
+tridentFinishInitScreen (ScreenPtr pScreen)
+{
+#ifdef VESA
+ return vesaFinishInitScreen (pScreen);
+#endif
+}
+
CARD8
tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index)
{
@@ -598,4 +606,5 @@ KdCardFuncs tridentFuncs = {
fbdevGetColors, /* getColors */
fbdevPutColors, /* putColors */
#endif
+ tridentFinishInitScreen /* finishInitScreen */
};
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index c00859181..d4ef6eac8 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.11 2001/05/29 04:54:12 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.12 2001/06/03 21:52:46 keithp Exp $ */
#include "vesa.h"
#ifdef RANDR
@@ -37,8 +37,8 @@ Bool vesa_verbose = FALSE;
#define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver)
#define ScreenRotated(scr) (VesaPriv(scr)->rotate == 90 || VesaPriv(scr)->rotate == 270)
-#define vesaWidth(scr,vmib) (ScreenRotated(scr) ? vmib->YResolution : vmib->XResolution)
-#define vesaHeight(scr,vmib) (ScreenRotated(scr) ? vmib->XResolution : vmib->YResolution)
+#define vesaWidth(scr,vmib) (ScreenRotated(scr) ? (vmib)->YResolution : (vmib)->XResolution)
+#define vesaHeight(scr,vmib) (ScreenRotated(scr) ? (vmib)->XResolution : (vmib)->YResolution)
static Bool
vesaModeSupportable (VesaModePtr mode, Bool complain)
@@ -370,8 +370,6 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
VesaCardPrivPtr priv = screen->card->driver;
VesaModePtr mode;
Pixel allbits;
- int depth;
- int bpp, fbbpp;
screen->driver = pscr;
@@ -406,29 +404,11 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
pscr->rotate = screen->rotation;
pscr->shadow = vesa_shadow;
pscr->origDepth = screen->fb[0].depth;
+ pscr->layerKind = LAYER_FB;
- if (vesa_linear_fb)
- pscr->mapping = VESA_LINEAR;
- else
- pscr->mapping = VESA_WINDOWED;
-
- depth = vesaDepth (&pscr->mode);
- bpp = pscr->mode.BitsPerPixel;
-
- if (bpp > 24)
- bpp = 32;
- else if (bpp > 16)
- bpp = 24;
- else if (bpp > 8)
- bpp = 16;
- else if (bpp > 4)
- bpp = 8;
- else if (bpp > 1)
- bpp = 4;
- else
- bpp = 1;
- fbbpp = bpp;
-
+ /*
+ * Compute visual support for the selected depth
+ */
switch (pscr->mode.MemoryModel) {
case MEMORY_DIRECT:
/* TrueColor or DirectColor */
@@ -439,19 +419,6 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
FbStipMask(pscr->mode.GreenFieldPosition, pscr->mode.GreenMaskSize);
screen->fb[0].blueMask =
FbStipMask(pscr->mode.BlueFieldPosition, pscr->mode.BlueMaskSize);
- allbits =
- screen->fb[0].redMask |
- screen->fb[0].greenMask |
- screen->fb[0].blueMask;
- depth = 32;
- while (depth && !(allbits & (1 << (depth - 1))))
- depth--;
- if (vesa_verbose)
- ErrorF ("\tTrue Color bpp %d depth %d red 0x%x green 0x%x blue 0x%x\n",
- bpp, depth,
- screen->fb[0].redMask,
- screen->fb[0].greenMask,
- screen->fb[0].blueMask);
break;
case MEMORY_PSEUDO:
/* PseudoColor */
@@ -464,9 +431,6 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
screen->fb[0].blueMask = 0x00;
screen->fb[0].greenMask = 0x00;
screen->fb[0].redMask = 0x00;
- if (vesa_verbose)
- ErrorF ("\tPseudo Color bpp %d depth %d\n",
- bpp, depth);
break;
case MEMORY_PLANAR:
/* 4 plane planar */
@@ -477,94 +441,15 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
screen->fb[0].blueMask = 0x00;
screen->fb[0].greenMask = 0x00;
screen->fb[0].redMask = 0x00;
- if (bpp == 4)
- {
- bpp = screen->fb[0].bitsPerPixel;
- if (bpp != 8)
- bpp = 4;
- depth = bpp;
- }
- if (bpp == 1)
- {
- pscr->mapping = VESA_MONO;
- if (vesa_verbose)
- ErrorF ("\tMonochrome\n");
- }
- else
- {
- pscr->mapping = VESA_PLANAR;
- if (vesa_verbose)
- ErrorF ("\tStatic color bpp %d depth %d\n",
- bpp, depth);
- }
- pscr->rotate = 0;
break;
default:
ErrorF("Unsupported VESA MemoryModel 0x%02X\n",
pscr->mode.MemoryModel);
return FALSE;
}
-
- switch (fbbpp) {
- case 8:
- case 16:
- case 32:
- break;
- default:
- pscr->rotate = 0;
- }
-
- screen->width = vesaWidth(screen, mode);
- screen->height = vesaHeight(screen, mode);
- screen->fb[0].depth = depth;
- screen->fb[0].bitsPerPixel = bpp;
- screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
- screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / fbbpp);
-
- if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR))
- pscr->mapping = VESA_WINDOWED;
-
- if (pscr->rotate)
- pscr->shadow = TRUE;
-
- switch (pscr->mapping) {
- case VESA_MONO:
- pscr->shadow = TRUE;
- /* fall through */
- case VESA_LINEAR:
- if (pscr->mode.vbe)
- pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
- pscr->mode.mode,
- &pscr->fb_size);
- else
- pscr->fb = VgaMapFramebuffer (priv->vi,
- pscr->mode.mode,
- &pscr->fb_size);
- break;
- case VESA_WINDOWED:
- pscr->fb = NULL;
- pscr->shadow = TRUE;
- break;
- case VESA_PLANAR:
- pscr->fb = NULL;
- pscr->shadow = TRUE;
- break;
- }
-
screen->rate = 72;
- screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
- if (pscr->rotate)
- screen->softCursor = TRUE;
-
- if (pscr->shadow)
- return KdShadowScreenInit (screen);
-
- if (vesa_verbose)
- ErrorF ("Mode selected %dx%dx%d\n",
- screen->width, screen->height, screen->fb[0].depth);
-
- return TRUE;
+ return vesaMapFramebuffer (screen);
}
Bool
@@ -850,6 +735,248 @@ vesaCreateColormap16 (ColormapPtr pmap)
return TRUE;
}
+LayerPtr
+vesaLayerCreate (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ LayerPtr pLayer;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+ PixmapPtr pPixmap;
+ int kind;
+
+ if (pscr->shadow)
+ {
+ switch (pscr->mapping) {
+ case VESA_LINEAR:
+ update = shadowUpdatePacked;
+ window = vesaWindowLinear;
+ break;
+ case VESA_WINDOWED:
+ update = shadowUpdatePacked;
+ window = vesaWindowWindowed;
+ break;
+ case VESA_PLANAR:
+ pScreen->CreateColormap = vesaCreateColormap16;
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
+ update = shadowUpdatePlanar4x8;
+ else
+ update = shadowUpdatePlanar4;
+ window = vesaWindowPlanar;
+ pscr->rotate = 0;
+ break;
+ case VESA_MONO:
+ update = vesaUpdateMono;
+ if (pscr->mode.mode < 8)
+ window = vesaWindowCga;
+ else
+ window = vesaWindowLinear;
+ pscr->rotate = 0;
+ break;
+ }
+ switch (pscr->rotate) {
+ case 90:
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ update = shadowUpdateRotate8_90; break;
+ case 16:
+ update = shadowUpdateRotate16_90; break;
+ case 32:
+ update = shadowUpdateRotate32_90; break;
+ }
+ break;
+ case 180:
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ update = shadowUpdateRotate8_180; break;
+ case 16:
+ update = shadowUpdateRotate16_180; break;
+ case 32:
+ update = shadowUpdateRotate32_180; break;
+ }
+ break;
+ case 270:
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ update = shadowUpdateRotate8_270; break;
+ case 16:
+ update = shadowUpdateRotate16_270; break;
+ case 32:
+ update = shadowUpdateRotate32_270; break;
+ }
+ break;
+ }
+
+ kind = LAYER_SHADOW;
+ pPixmap = 0;
+ }
+ else
+ {
+ kind = pscr->layerKind;
+ pPixmap = LAYER_SCREEN_PIXMAP;
+ update = 0;
+ window = 0;
+ }
+
+ if (vesa_verbose)
+ ErrorF ("Mode selected %dx%dx%d\n",
+ screen->width, screen->height, screen->fb[0].depth);
+
+ return LayerCreate (pScreen, kind, screen->fb[0].depth,
+ pPixmap, update, window, 0);
+}
+
+Bool
+vesaMapFramebuffer (KdScreenInfo *screen)
+{
+ VesaCardPrivPtr priv = screen->card->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
+ int depth, bpp, fbbpp;
+ Pixel allbits;
+
+ if (vesa_linear_fb)
+ pscr->mapping = VESA_LINEAR;
+ else
+ pscr->mapping = VESA_WINDOWED;
+
+ depth = vesaDepth (&pscr->mode);
+ bpp = pscr->mode.BitsPerPixel;
+
+ if (bpp > 24)
+ bpp = 32;
+ else if (bpp > 16)
+ bpp = 24;
+ else if (bpp > 8)
+ bpp = 16;
+ else if (bpp > 4)
+ bpp = 8;
+ else if (bpp > 1)
+ bpp = 4;
+ else
+ bpp = 1;
+ fbbpp = bpp;
+
+ switch (pscr->mode.MemoryModel) {
+ case MEMORY_DIRECT:
+ allbits = (screen->fb[0].redMask |
+ screen->fb[0].greenMask |
+ screen->fb[0].blueMask);
+ depth = 32;
+ while (depth && !(allbits & (1 << (depth - 1))))
+ depth--;
+ if (vesa_verbose)
+ ErrorF ("\tTrue Color red 0x%x green 0x%x blue 0x%x\n",
+ bpp, depth,
+ screen->fb[0].redMask,
+ screen->fb[0].greenMask,
+ screen->fb[0].blueMask);
+ break;
+ case MEMORY_PSEUDO:
+ if (vesa_verbose)
+ ErrorF ("\tPseudo Color bpp %d depth %d\n",
+ bpp, depth);
+ break;
+ case MEMORY_PLANAR:
+ if (bpp == 4)
+ {
+ bpp = screen->fb[0].bitsPerPixel;
+ if (bpp != 8)
+ bpp = 4;
+ depth = bpp;
+ }
+ if (bpp == 1)
+ {
+ pscr->mapping = VESA_MONO;
+ if (vesa_verbose)
+ ErrorF ("\tMonochrome\n");
+ }
+ else
+ {
+ pscr->mapping = VESA_PLANAR;
+ if (vesa_verbose)
+ ErrorF ("\tStatic color bpp %d depth %d\n",
+ bpp, depth);
+ }
+ pscr->rotate = 0;
+ break;
+ default:
+ return 0;
+ }
+
+ switch (fbbpp) {
+ case 8:
+ case 16:
+ case 32:
+ break;
+ default:
+ pscr->rotate = 0;
+ }
+
+ screen->width = vesaWidth(screen, &pscr->mode);
+ screen->height = vesaHeight(screen, &pscr->mode);
+ screen->fb[0].depth = depth;
+ screen->fb[0].bitsPerPixel = bpp;
+ screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
+ screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / fbbpp);
+
+ if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR))
+ pscr->mapping = VESA_WINDOWED;
+
+ pscr->shadow = vesa_shadow;
+
+ if (pscr->rotate)
+ pscr->shadow = TRUE;
+
+ if (pscr->rotate)
+ screen->softCursor = TRUE;
+
+ switch (pscr->mapping) {
+ case VESA_MONO:
+ pscr->shadow = TRUE;
+ /* fall through */
+ case VESA_LINEAR:
+ if (pscr->mode.vbe)
+ pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
+ pscr->mode.mode,
+ &pscr->fb_size);
+ else
+ pscr->fb = VgaMapFramebuffer (priv->vi,
+ pscr->mode.mode,
+ &pscr->fb_size);
+ if (!pscr->fb)
+ return FALSE;
+ break;
+ case VESA_WINDOWED:
+ pscr->fb = NULL;
+ pscr->shadow = TRUE;
+ break;
+ case VESA_PLANAR:
+ pscr->fb = NULL;
+ pscr->shadow = TRUE;
+ break;
+ }
+ screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
+ return TRUE;
+}
+
+void
+vesaUnmapFramebuffer (KdScreenInfo *screen)
+{
+ VesaCardPrivPtr priv = screen->card->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
+
+ if (pscr->fb)
+ {
+ if (pscr->mode.vbe)
+ VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, pscr->fb);
+ else
+ VgaUnmapFramebuffer (priv->vi);
+ }
+}
+
#ifdef RANDR
Bool
vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
@@ -939,8 +1066,8 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
pSize = RRRegisterSize (pScreen,
mode->XResolution,
mode->YResolution,
- pScreen->mmWidth,
- pScreen->mmHeight,
+ screen->width_mm,
+ screen->height_mm,
pGroupOfVisualGroup);
if (mode->XResolution == pScreen->width &&
mode->YResolution == pScreen->height)
@@ -951,6 +1078,30 @@ vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
}
}
}
+ return TRUE;
+}
+
+int
+vesaLayerAdd (WindowPtr pWin, pointer value)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLayer = (LayerPtr) value;
+
+ if (!LayerWindowAdd (pScreen, pLayer, pWin))
+ return WT_STOPWALKING;
+
+ return WT_WALKCHILDREN;
+}
+
+int
+vesaLayerRemove (WindowPtr pWin, pointer value)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLayer = (LayerPtr) value;
+
+ LayerWindowRemove (pScreen, pLayer, pWin);
+
+ return WT_WALKCHILDREN;
}
Bool
@@ -966,7 +1117,13 @@ vesaRandRSetConfig (ScreenPtr pScreen,
VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
int n;
Bool wasEnabled = pScreenPriv->enabled;
- Bool ret;
+ Bool ret = FALSE;
+ VesaScreenPrivRec oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ LayerPtr pNewLayer;
for (n = 0; n < priv->nmode; n++)
{
@@ -990,87 +1147,144 @@ vesaRandRSetConfig (ScreenPtr pScreen,
}
}
if (n == priv->nmode)
- return FALSE;
+ goto bail0;
if (wasEnabled)
KdDisableScreen (pScreen);
ret = vesaSetMode (pScreen, mode);
- if (ret)
+
+ if (!ret)
+ goto bail1;
+
+ oldscr = *pscr;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+
+ /*
+ * Set new configuration
+ */
+
+ 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;
+ }
+
+ /*
+ * Can't rotate some formats
+ */
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ case 16:
+ case 32:
+ break;
+ default:
+ if (pscr->rotate)
+ goto bail2;
+ break;
+ }
+
+ pScreen->width = screen->width = vesaWidth(screen, mode);
+ pScreen->height = screen->height = vesaHeight(screen, mode);
+
+ if (rotation & (RR_Rotate_90|RR_Rotate_270))
{
- pscr->mode = *mode;
- switch (screen->fb[0].bitsPerPixel) {
- case 8:
- case 16:
- case 32:
- 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;
- }
- break;
- default:
- pscr->rotate = 0;
- break;
- }
- screen->width = vesaWidth(screen, mode);
- screen->height = vesaHeight(screen, mode);
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- if (rotation == 90 || rotation == 270)
- {
- pScreen->mmWidth = pSize->mmHeight;
- pScreen->mmHeight = pSize->mmWidth;
- }
- else
- {
- pScreen->mmWidth = pSize->mmWidth;
- pScreen->mmHeight = pSize->mmHeight;
- }
+ pScreen->mmWidth = pSize->mmHeight;
+ pScreen->mmHeight = pSize->mmWidth;
+ }
+ else
+ {
+ pScreen->mmWidth = pSize->mmWidth;
+ pScreen->mmHeight = pSize->mmHeight;
+ }
+
+ vesaUnmapFramebuffer (screen);
+ if (!vesaMapFramebuffer (screen))
+ goto bail3;
+
#if 0
- /*
- * XXX can't switch depths yet
- */
- screen->fb[0].depth = depth;
- screen->fb[0].bitsPerPixel = bpp;
+ /*
+ * XXX can't switch depths yet
+ */
+ screen->fb[0].depth = depth;
+ screen->fb[0].bitsPerPixel = bpp;
#endif
- screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
- screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / screen->fb[0].bitsPerPixel);
+ screen->fb[0].byteStride = mode->BytesPerScanLine;
+ screen->fb[0].pixelStride = ((mode->BytesPerScanLine * 8) / screen->fb[0].bitsPerPixel);
+ if (!pscr->shadow)
+ {
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
- screen->width,
- screen->height,
+ pScreen->width,
+ pScreen->height,
screen->fb[0].depth,
screen->fb[0].bitsPerPixel,
screen->fb[0].byteStride,
screen->fb[0].frameBuffer);
}
- else
- (void) vesaSetMode (pScreen, &pscr->mode);
+ pNewLayer = vesaLayerCreate (pScreen);
+ if (!pNewLayer)
+ goto bail4;
+
+ if (WalkTree (pScreen, vesaLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING)
+ goto bail5;
+
+ WalkTree (pScreen, vesaLayerRemove, (pointer) pscr->pLayer);
+ LayerDestroy (pScreen, pscr->pLayer);
+
+ pscr->pLayer = pNewLayer;
+
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+bail5:
+ WalkTree (pScreen, vesaLayerRemove, (pointer) pNewLayer);
+ LayerDestroy (pScreen, pNewLayer);
+bail4:
+ vesaUnmapFramebuffer (screen);
+ *pscr = oldscr;
+ (void) vesaMapFramebuffer (screen);
+
+bail3:
+ pScreen->width = screen->width = oldwidth;
+ pScreen->height = screen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+bail2:
+ *pscr = oldscr;
+
+ (void) vesaSetMode (pScreen, &pscr->mode);
+
+bail1:
if (wasEnabled)
KdEnableScreen (pScreen);
- return ret;
+bail0:
+
+ return FALSE;
}
-void
+Bool
vesaRandRInit (ScreenPtr pScreen)
{
- rrScrPriv(pScreen);
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
- if (!pScrPriv)
- return;
+ pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = vesaRandRGetInfo;
pScrPriv->rrSetConfig = vesaRandRSetConfig;
+ return TRUE;
}
#endif
@@ -1079,76 +1293,31 @@ vesaInitScreen(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
- ShadowUpdateProc update;
- ShadowWindowProc window;
+ if (!LayerStartInit (pScreen))
+ return FALSE;
+
+ return TRUE;
+}
- if (pscr->shadow)
- {
- switch (pscr->mapping) {
- case VESA_LINEAR:
- update = shadowUpdatePacked;
- window = vesaWindowLinear;
- break;
- case VESA_WINDOWED:
- update = shadowUpdatePacked;
- window = vesaWindowWindowed;
- break;
- case VESA_PLANAR:
- pScreen->CreateColormap = vesaCreateColormap16;
- if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
- update = shadowUpdatePlanar4x8;
- else
- update = shadowUpdatePlanar4;
- window = vesaWindowPlanar;
- pscr->rotate = 0;
- break;
- case VESA_MONO:
- update = vesaUpdateMono;
- if (pscr->mode.mode < 8)
- window = vesaWindowCga;
- else
- window = vesaWindowLinear;
- pscr->rotate = 0;
- break;
- }
- switch (pscr->rotate) {
- case 90:
- switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
- case 8:
- update = shadowUpdateRotate8_90; break;
- case 16:
- update = shadowUpdateRotate16_90; break;
- case 32:
- update = shadowUpdateRotate32_90; break;
- }
- break;
- case 180:
- switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
- case 8:
- update = shadowUpdateRotate8_180; break;
- case 16:
- update = shadowUpdateRotate16_180; break;
- case 32:
- update = shadowUpdateRotate32_180; break;
- }
- break;
- case 270:
- switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
- case 8:
- update = shadowUpdateRotate8_270; break;
- case 16:
- update = shadowUpdateRotate16_270; break;
- case 32:
- update = shadowUpdateRotate32_270; break;
- }
- break;
- }
-
- return KdShadowInitScreen (pScreen, update, window);
- }
+Bool
+vesaFinishInitScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+
+ pscr->layerKind = LayerNewKind (pScreen);
+
+ if (!LayerFinishInit (pScreen))
+ return FALSE;
+
+ pscr->pLayer = vesaLayerCreate (pScreen);
+ if (!pscr->pLayer)
+ return FALSE;
+
#ifdef RANDR
- vesaRandRInit (pScreen);
+ if (!vesaRandRInit (pScreen))
+ return FALSE;
#endif
return TRUE;
@@ -1352,16 +1521,7 @@ vesaScreenFini(KdScreenInfo *screen)
VesaScreenPrivPtr pscr = screen->driver;
VesaCardPrivPtr priv = screen->card->driver;
- if (pscr->fb)
- {
- if (pscr->mode.vbe)
- VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, pscr->fb);
- else
- VgaUnmapFramebuffer (priv->vi);
- }
-
- if (pscr->shadow)
- KdShadowScreenFini (screen);
+ vesaUnmapFramebuffer (screen);
screen->fb[0].depth = pscr->origDepth;
}
diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h
index d20c103eb..6d555fb02 100644
--- a/hw/kdrive/vesa/vesa.h
+++ b/hw/kdrive/vesa/vesa.h
@@ -19,13 +19,17 @@ 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.8 2001/05/26 01:25:42 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.9 2001/05/29 04:54:13 keithp Exp $ */
#ifndef _VESA_H_
#define _VESA_H_
#include "kdrive.h"
+#include "layer.h"
#include "vm86.h"
+#ifdef RANDR
+#include "randrstr.h"
+#endif
#define VESA_TEXT_SAVE (64*1024)
@@ -93,8 +97,10 @@ typedef struct _VesaScreenPriv {
int rotate;
int mapping;
int origDepth;
+ int layerKind;
void *fb;
int fb_size;
+ LayerPtr pLayer;
} VesaScreenPrivRec, *VesaScreenPrivPtr;
extern int vesa_video_mode;
@@ -118,10 +124,16 @@ vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr);
Bool
vesaScreenInit(KdScreenInfo *screen);
+LayerPtr
+vesaLayerCreate (ScreenPtr pScreen);
+
Bool
vesaInitScreen(ScreenPtr pScreen);
Bool
+vesaFinishInitScreen(ScreenPtr pScreen);
+
+Bool
vesaEnable(ScreenPtr pScreen);
void
diff --git a/hw/kdrive/vesa/vesainit.c b/hw/kdrive/vesa/vesainit.c
index c6a88810c..3019e4f12 100644
--- a/hw/kdrive/vesa/vesainit.c
+++ b/hw/kdrive/vesa/vesainit.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/vesainit.c,v 1.4 2000/10/20 00:19:50 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.5 2000/12/08 21:40:29 keithp Exp $ */
#include "vesa.h"
@@ -49,6 +49,8 @@ const KdCardFuncs vesaFuncs = {
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
+
+ vesaFinishInitScreen, /* finishInitScreen */
};
void