summaryrefslogtreecommitdiff
path: root/hw/kdrive/src
diff options
context:
space:
mode:
Diffstat (limited to 'hw/kdrive/src')
-rw-r--r--hw/kdrive/src/kasync.c294
-rw-r--r--hw/kdrive/src/kcolor.c18
-rw-r--r--hw/kdrive/src/kcurscol.c92
-rw-r--r--hw/kdrive/src/kdrive.c61
-rw-r--r--hw/kdrive/src/kdrive.h167
-rw-r--r--hw/kdrive/src/kinput.c38
-rw-r--r--hw/kdrive/src/kmap.c8
-rw-r--r--hw/kdrive/src/kmode.c313
-rw-r--r--hw/kdrive/src/vga.c65
-rw-r--r--hw/kdrive/src/vga.h11
10 files changed, 1004 insertions, 63 deletions
diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c
new file mode 100644
index 000000000..2712ee50f
--- /dev/null
+++ b/hw/kdrive/src/kasync.c
@@ -0,0 +1,294 @@
+/*
+ * $Id$
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "kdrive.h"
+
+/*
+ * These functions wrap the low-level fb rendering functions and
+ * synchronize framebuffer/accelerated drawing by stalling until
+ * the accelerator is idle
+ */
+
+void
+KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ KdCheckSync (pDrawable->pScreen);
+ fbFillSpans (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
+}
+
+void
+KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
+{
+ KdCheckSync (pDrawable->pScreen);
+ fbSetSpans (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+}
+
+void
+KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *bits)
+{
+ KdCheckSync (pDrawable->pScreen);
+ fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
+}
+
+RegionPtr
+KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ KdCheckSync (pSrc->pScreen);
+ return fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
+}
+
+RegionPtr
+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);
+ return fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
+ bitPlane);
+}
+
+void
+KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit)
+{
+ KdCheckSync (pDrawable->pScreen);
+ fbPolyPoint (pDrawable, pGC, mode, npt, pptInit);
+}
+
+void
+KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt)
+{
+
+ if (pGC->lineWidth == 0)
+ {
+ KdCheckSync (pDrawable->pScreen);
+ fbZeroLine (pDrawable, pGC, mode, npt, ppt);
+ }
+ else
+ {
+ if (pGC->lineStyle != LineSolid)
+ miWideDash (pDrawable, pGC, mode, npt, ppt);
+ else
+ miWideLine (pDrawable, pGC, mode, npt, ppt);
+ }
+}
+
+#if 0
+void
+KdCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
+ int nsegInit, xSegment *pSegInit)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPolySegment (pDrawable, pGC, nsegInit, pSegInit);
+}
+
+void
+KdCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *prect)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPolyRectangle (pDrawable, pGC, nrects, prect);
+}
+#endif
+
+void
+KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs)
+{
+ if (pGC->lineWidth == 0)
+ {
+ KdCheckSync(pDrawable->pScreen);
+ fbPolyArc (pDrawable, pGC, narcs, pArcs);
+ }
+ else
+ miPolyArc (pDrawable, pGC, narcs, pArcs);
+}
+
+#if 0
+void
+KdCheckFillPolygon (DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbFillPolygon (pDrawable, pGC, mode, count, pPts);
+}
+#endif
+
+void
+KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrect, xRectangle *prect)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPolyFillRect (pDrawable, pGC, nrect, prect);
+}
+
+#if 0
+void
+KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
+}
+#endif
+
+void
+KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+}
+
+void
+KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+}
+
+void
+KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+}
+
+void
+KdCheckGetImage (DrawablePtr pDrawable,
+ int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *d)
+{
+ KdCheckSync(pDrawable->pScreen);
+ fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
+}
+
+void
+KdCheckGetSpans (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pdstStart)
+{
+ if (pDrawable->type != DRAWABLE_PIXMAP)
+ KdCheckSync(pDrawable->pScreen);
+ fbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+}
+
+void
+KdCheckSaveAreas (PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+ KdCheckSync(pWin->drawable.pScreen);
+ fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin);
+}
+
+void
+KdCheckRestoreAreas (PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+ KdCheckSync(pWin->drawable.pScreen);
+ fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin);
+}
+
+void
+KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ KdCheckSync (pWin->drawable.pScreen);
+ fbPaintWindow (pWin, pRegion, what);
+}
+
+void
+KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ KdCheckSync (pWin->drawable.pScreen);
+ fbCopyWindow (pWin, ptOldOrg, prgnSrc);
+}
+
+void
+KdScreenInitAsync (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ pScreen->GetImage = KdCheckGetImage;
+ pScreen->GetSpans = KdCheckGetSpans;
+ pScreen->PaintWindowBackground = KdCheckPaintWindow;
+ pScreen->PaintWindowBorder = KdCheckPaintWindow;
+ pScreen->CopyWindow = KdCheckCopyWindow;
+
+#ifndef FB_OLD_SCREEN
+ pScreen->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas;
+ pScreen->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas;
+#else
+ pScreenPriv->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas;
+ pScreenPriv->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas;
+#endif
+}
+
+/*
+ * Only need to stall for copyarea/copyplane
+ */
+const GCOps kdAsyncPixmapGCOps = {
+ fbFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ KdCheckCopyArea,
+ KdCheckCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ miPolySegment,
+ miPolyRectangle,
+ fbPolyArc,
+ miFillPolygon,
+ fbPolyFillRect,
+ miPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ fbImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
diff --git a/hw/kdrive/src/kcolor.c b/hw/kdrive/src/kcolor.c
index b2ef89e19..56cbd0628 100644
--- a/hw/kdrive/src/kcolor.c
+++ b/hw/kdrive/src/kcolor.c
@@ -21,9 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
-
-/* $XConsortium: oscolor.c,v 1.23 94/04/17 20:27:04 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kcolor.c,v 1.1 1999/11/19 13:53:48 hohndel Exp $ */
#include "kdrive.h"
#include <stdio.h>
@@ -45,7 +43,7 @@ KdToLower (unsigned char a)
}
int
-KdStrCaseCmp (unsigned char *s1, unsigned char *s2, int l2)
+KdStrCaseCmp (const unsigned char *s1, const unsigned char *s2, int l2)
{
unsigned char c1, c2;
@@ -69,12 +67,12 @@ typedef struct _kdNamedColor {
unsigned short red;
unsigned short green;
unsigned short blue;
- unsigned char *name;
+ const unsigned char *name;
} KdNamedColor;
#define C 0x101
-KdNamedColor KdColors[] = {
+const KdNamedColor KdColors[] = {
240*C, 248*C, 255*C, "alice blue",
240*C, 248*C, 255*C, "AliceBlue",
250*C, 235*C, 215*C, "antique white",
@@ -847,10 +845,10 @@ OsLookupColor(int screen,
unsigned short *pgreen,
unsigned short *pblue)
{
- KdNamedColor *c;
- unsigned char *name = (unsigned char *) s_name;
- int low, mid, high;
- int r;
+ const KdNamedColor *c;
+ unsigned char *name = (unsigned char *) s_name;
+ int low, mid, high;
+ int r;
low = 0;
high = NUM_KD_COLORS;
diff --git a/hw/kdrive/src/kcurscol.c b/hw/kdrive/src/kcurscol.c
new file mode 100644
index 000000000..a6882b96d
--- /dev/null
+++ b/hw/kdrive/src/kcurscol.c
@@ -0,0 +1,92 @@
+/*
+ * $Id$
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "kdrive.h"
+#include "cursorstr.h"
+
+static int
+KdComputeCmapShift (unsigned long mask)
+{
+ int shift;
+ unsigned long bit;
+
+ shift = 16;
+ bit = 0x80000000;
+ while (!(mask & bit))
+ {
+ shift--;
+ bit >>= 1;
+ }
+ return shift;
+}
+
+#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
+
+void
+KdAllocateCursorPixels (ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Pixel *source,
+ Pixel *mask)
+{
+ xColorItem sourceColor, maskColor;
+ int r, g, b;
+ KdScreenPriv(pScreen);
+
+ if (pScreenPriv->screen->redMask)
+ {
+
+ r = KdComputeCmapShift (pScreenPriv->screen->redMask);
+ g = KdComputeCmapShift (pScreenPriv->screen->greenMask);
+ b = KdComputeCmapShift (pScreenPriv->screen->blueMask);
+ *source = ((Shift(pCursor->foreRed,r) & pScreenPriv->screen->redMask) |
+ (Shift(pCursor->foreGreen,g) & pScreenPriv->screen->greenMask) |
+ (Shift(pCursor->foreBlue,b) & pScreenPriv->screen->blueMask));
+ *mask = ((Shift(pCursor->backRed,r) & pScreenPriv->screen->redMask) |
+ (Shift(pCursor->backGreen,g) & pScreenPriv->screen->greenMask) |
+ (Shift(pCursor->backBlue,b) & pScreenPriv->screen->blueMask));
+ }
+ else
+ {
+ /*
+ * Set these to an invalid pixel value so that
+ * when the store colors comes through, the cursor
+ * won't get recolored
+ */
+ *source = ~0;
+ *mask = ~0;
+
+ sourceColor.red = pCursor->foreRed;
+ sourceColor.green = pCursor->foreGreen;
+ sourceColor.blue = pCursor->foreBlue;
+ FakeAllocColor(pScreenPriv->pInstalledmap, &sourceColor);
+ maskColor.red = pCursor->backRed;
+ maskColor.green = pCursor->backGreen;
+ maskColor.blue = pCursor->backBlue;
+ FakeAllocColor(pScreenPriv->pInstalledmap, &maskColor);
+ FakeFreeColor(pScreenPriv->pInstalledmap, sourceColor.pixel);
+ FakeFreeColor(pScreenPriv->pInstalledmap, maskColor.pixel);
+ *source = sourceColor.pixel;
+ *mask = maskColor.pixel;
+ }
+}
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index b17fb0fc4..01409b85e 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -21,9 +21,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.1 1999/11/19 13:53:48 hohndel Exp $ */
#include "kdrive.h"
+#ifdef PSEUDO8
+#include "pseudo8/pseudo8.h"
+#endif
#include <mivalidate.h>
#include <dixstruct.h>
@@ -41,8 +44,6 @@ Bool kdDisableZaphod;
Bool kdEnabled;
Bool kdSwitchPending;
-void (*restoreHardware)(void);
-
/*
* Carry arguments from InitOutput through driver initialization
* to KdScreenInit
@@ -54,6 +55,7 @@ extern WindowPtr *WindowTable;
void
KdSetRootClip (ScreenPtr pScreen, BOOL enable)
{
+#ifndef FB_OLD_SCREEN
WindowPtr pWin = WindowTable[pScreen->myNum];
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
@@ -173,6 +175,7 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable)
}
if (pWin->realized)
WindowsRestructured ();
+#endif /* !FB_OLD_SCREEN */
}
void
@@ -182,7 +185,9 @@ KdDisableScreen (ScreenPtr pScreen)
if (!pScreenPriv->enabled)
return;
- KdSetRootClip (pScreen, FALSE);
+ KdCheckSync (pScreen);
+ if (!pScreenPriv->closed)
+ KdSetRootClip (pScreen, FALSE);
KdDisableColormap (pScreen);
if (!pScreenPriv->screen->dumb)
(*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
@@ -332,7 +337,7 @@ Bool kdDumbDriver;
Bool kdSoftCursor;
int
-ddxProcessArgument (int argc, char **argv, int i)
+KdProcessArgument (int argc, char **argv, int i)
{
KdCardInfo *card;
KdScreenInfo *screen;
@@ -398,7 +403,11 @@ ddxProcessArgument (int argc, char **argv, int i)
}
if (!strcmp (argv[i], "-standalone"))
return 1;
+#ifdef PSEUDO8
+ return p8ProcessArgument (argc, argv, i);
+#else
return 0;
+#endif
}
/*
@@ -443,6 +452,7 @@ KdCloseScreen (int index, ScreenPtr pScreen)
KdCardInfo *card = pScreenPriv->card;
Bool ret;
+ pScreenPriv->closed = TRUE;
pScreen->CloseScreen = pScreenPriv->CloseScreen;
ret = (*pScreen->CloseScreen) (index, pScreen);
@@ -529,6 +539,7 @@ KdSaveScreen (ScreenPtr pScreen, int on)
Bool
KdCreateWindow (WindowPtr pWin)
{
+#ifndef PHOENIX
if (!pWin->parent)
{
KdScreenPriv(pWin->drawable.pScreen);
@@ -539,6 +550,7 @@ KdCreateWindow (WindowPtr pWin)
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
}
+#endif
return TRUE;
}
@@ -588,9 +600,13 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->SaveScreen = KdSaveScreen;
pScreen->CreateWindow = KdCreateWindow;
- if (!screen->dumb && card->cfuncs->initAccel)
- if (!(*card->cfuncs->initAccel) (pScreen))
- screen->dumb = TRUE;
+#ifdef FB_OLD_SCREEN
+ pScreenPriv->BackingStoreFuncs.SaveAreas = fbSaveAreas;
+ pScreenPriv->BackingStoreFuncs.RestoreAreas = fbSaveAreas;
+ pScreenPriv->BackingStoreFuncs.SetClipmaskRgn = 0;
+ pScreenPriv->BackingStoreFuncs.GetImagePixmap = 0;
+ pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0;
+#endif
if (!fbFinishScreenInit (pScreen,
screen->frameBuffer,
@@ -609,6 +625,24 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->BlockHandler = KdBlockHandler;
pScreen->WakeupHandler = KdWakeupHandler;
+ if (card->cfuncs->initScreen)
+ if (!(*card->cfuncs->initScreen) (pScreen))
+ return FALSE;
+
+ if (!screen->dumb && card->cfuncs->initAccel)
+ if (!(*card->cfuncs->initAccel) (pScreen))
+ screen->dumb = TRUE;
+
+#ifdef PSEUDO8
+ (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
+#endif
+
+ pScreen->backingStoreSupport = Always;
+#ifdef FB_OLD_SCREEN
+ miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs);
+#else
+ miInitializeBackingStore (pScreen);
+#endif
/*
* Wrap CloseScreen, the order now is:
* KdCloseScreen
@@ -683,17 +717,13 @@ Bool
KdSetPixmapFormats (ScreenInfo *pScreenInfo)
{
CARD8 depthToBpp[33]; /* depth -> bpp map */
- CARD8 bppToDepth[33]; /* bpp -> depth map */
KdCardInfo *card;
KdScreenInfo *screen;
int i;
PixmapFormatRec *format;
for (i = 1; i <= 32; i++)
- {
depthToBpp[i] = 0;
- bppToDepth[i] = 0;
- }
/*
* Generate mappings between bitsPerPixel and depth,
@@ -709,8 +739,6 @@ KdSetPixmapFormats (ScreenInfo *pScreenInfo)
depthToBpp[screen->depth] = screen->bitsPerPixel;
else if (depthToBpp[screen->depth] != screen->bitsPerPixel)
return FALSE;
- if (!bppToDepth[screen->bitsPerPixel])
- bppToDepth[screen->bitsPerPixel] = screen->depth;
}
}
@@ -718,11 +746,8 @@ KdSetPixmapFormats (ScreenInfo *pScreenInfo)
* Fill in additional formats
*/
for (i = 0; i < NUM_KD_BPP; i++)
- if (!bppToDepth[kdBpp[i]] && !depthToBpp[kdBpp[i]])
- {
- bppToDepth[kdBpp[i]] = kdBpp[i];
+ if (!depthToBpp[kdBpp[i]])
depthToBpp[kdBpp[i]] = kdBpp[i];
- }
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 50601d690..3352259d8 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: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.1 1999/11/19 13:53:48 hohndel Exp $ */
#include <stdio.h>
#include "X.h"
@@ -67,6 +67,7 @@ typedef struct _KdCardInfo {
struct _KdScreenInfo *screenList;
int selected;
struct _KdCardInfo *next;
+ Bool needSync;
} KdCardInfo;
extern KdCardInfo *kdCardInfo;
@@ -98,6 +99,7 @@ typedef struct _KdScreenInfo {
typedef struct _KdCardFuncs {
Bool (*cardinit) (KdCardInfo *); /* detect and map device */
Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
+ Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
void (*preserve) (KdCardInfo *); /* save graphics card state */
void (*enable) (ScreenPtr); /* set up for rendering */
Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
@@ -114,6 +116,7 @@ typedef struct _KdCardFuncs {
Bool (*initAccel) (ScreenPtr);
void (*enableAccel) (ScreenPtr);
+ void (*syncAccel) (ScreenPtr);
void (*disableAccel) (ScreenPtr);
void (*finiAccel) (ScreenPtr);
@@ -129,6 +132,7 @@ typedef struct {
KdCardInfo *card;
Bool enabled;
+ Bool closed;
int bytesPerPixel;
int dpmsState;
@@ -137,6 +141,9 @@ typedef struct {
xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
CloseScreenProcPtr CloseScreen;
+#ifdef FB_OLD_SCREEN
+ miBSFuncRec BackingStoreFuncs;
+#endif
} KdPrivScreenRec, *KdPrivScreenPtr;
typedef struct _KdMouseFuncs {
@@ -163,6 +170,32 @@ typedef struct _KdOsFuncs {
void (*Fini) (void);
} KdOsFuncs;
+typedef enum _KdSyncPolarity {
+ KdSyncNegative, KdSyncPositive
+} KdSyncPolarity;
+
+typedef struct _KdMonitorTiming {
+ /* label */
+ int horizontal;
+ int vertical;
+ int rate;
+ /* pixel clock */
+ int clock; /* in KHz */
+ /* horizontal timing */
+ int hfp; /* front porch */
+ int hbp; /* back porch */
+ int hblank; /* blanking */
+ KdSyncPolarity hpol; /* polarity */
+ /* vertical timing */
+ int vfp; /* front porch */
+ int vbp; /* back porch */
+ int vblank; /* blanking */
+ KdSyncPolarity vpol; /* polarity */
+} KdMonitorTiming;
+
+extern const KdMonitorTiming kdMonitorTimings[];
+extern const int kdNumMonitorTimings;
+
/*
* This is the only completely portable way to
* compute this info.
@@ -190,6 +223,114 @@ extern KdOsFuncs *kdOsFuncs;
(pointer) v)
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
+#define KdCheckSync(s) { \
+ KdScreenPriv(s); \
+ KdCardInfo *card = pScreenPriv->card; \
+ if (card->needSync) { \
+ card->needSync = FALSE; \
+ (*card->cfuncs->syncAccel) (s); \
+ } \
+}
+
+#define KdMarkSync(s) (KdGetScreenPriv(s)->card->needSync = TRUE)
+
+/* kasync.c */
+void
+KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+
+void
+KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
+
+void
+KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *bits);
+
+RegionPtr
+KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty);
+
+RegionPtr
+KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane);
+
+void
+KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit);
+
+void
+KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt);
+
+#define KdCheckPolySegment miPolySegment
+#define KdCheckPolyRectangle miPolyRectangle
+
+void
+KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs);
+
+#define KdCheckFillPolygon miFillPolygon
+
+void
+KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrect, xRectangle *prect);
+
+#define KdCheckPolyFillArc miPolyFillArc
+
+void
+KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+
+void
+KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+
+void
+KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y);
+
+void
+KdCheckGetImage (DrawablePtr pDrawable,
+ int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *d);
+
+void
+KdCheckGetSpans (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pdstStart);
+
+void
+KdCheckSaveAreas (PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin);
+
+void
+KdCheckRestoreAreas (PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin);
+
+void
+KdScreenInitAsync (ScreenPtr pScreen);
+
+void
+KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
+
+extern const GCOps kdAsyncPixmapGCOps;
+
/* knoop.c */
extern GCOps kdNoopOps;
@@ -215,6 +356,13 @@ KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
void
KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
+/* kcurscol.c */
+void
+KdAllocateCursorPixels (ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Pixel *source,
+ Pixel *mask);
+
/* kdrive.c */
extern miPointerScreenFuncRec kdPointerScreenFuncs;
@@ -347,6 +495,10 @@ extern KdMouseFuncs Ps2MouseFuncs;
extern KdKeyboardFuncs LinuxKeyboardFuncs;
extern KdOsFuncs LinuxFuncs;
+extern KdMouseFuncs VxWorksMouseFuncs;
+extern KdKeyboardFuncs VxWorksKeyboardFuncs;
+extern KdOsFuncs VxWorksFuncs;
+
/* kmap.c */
void *
KdMapDevice (CARD32 addr, CARD32 size);
@@ -354,9 +506,22 @@ KdMapDevice (CARD32 addr, CARD32 size);
void
KdUnmapDevice (void *addr, CARD32 size);
+/* kmode.c */
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
/* ktest.c */
Bool
KdFrameBufferValid (CARD8 *base, int size);
int
KdFrameBufferSize (CARD8 *base, int max);
+
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 27207ac1e..3fee89ee3 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: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.1 1999/11/19 13:53:49 hohndel Exp $ */
#include "kdrive.h"
#include "inputstr.h"
@@ -134,10 +134,9 @@ KdAddFd (int fd)
flags |= FASYNC|NOBLOCK;
fcntl (fd, F_SETFL, flags);
AddEnabledDevice (fd);
+ memset (&act, '\0', sizeof act);
act.sa_handler = KdSigio;
sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- act.sa_restorer = 0;
sigaction (SIGIO, &act, 0);
sigemptyset (&set);
sigprocmask (SIG_SETMASK, &set, 0);
@@ -156,10 +155,9 @@ KdRemoveFd (int fd)
fcntl (fd, F_SETFL, flags);
if (kdnFds == 0)
{
+ memset (&act, '\0', sizeof act);
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- act.sa_restorer = 0;
sigaction (SIGIO, &act, 0);
}
}
@@ -320,8 +318,8 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
extern KeybdCtrl defaultKeyboardControl;
-void
-InitAutoRepeats (void)
+static void
+KdInitAutoRepeats (void)
{
int key_code;
unsigned char mask;
@@ -341,8 +339,8 @@ InitAutoRepeats (void)
}
}
-void
-InitModMap (void)
+static void
+KdInitModMap (void)
{
int key_code;
int row;
@@ -412,8 +410,8 @@ KdInitInput(KdMouseFuncs *pMouseFuncs,
kdLeds = 0;
kdBellPitch = 1000;
kdBellDuration = 200;
- InitModMap ();
- InitAutoRepeats ();
+ KdInitModMap ();
+ KdInitAutoRepeats ();
KdResetInputMachine ();
pPointer = AddInputDevice(KdMouseProc, TRUE);
pKeyboard = AddInputDevice(KdKeybdProc, TRUE);
@@ -421,6 +419,13 @@ KdInitInput(KdMouseFuncs *pMouseFuncs,
RegisterKeyboardDevice(pKeyboard);
miRegisterPointerDevice(screenInfo.screens[0], pPointer);
mieqInit(&pKeyboard->public, &pPointer->public);
+#ifdef XINPUT
+ {
+ static long zero1, zero2;
+
+ SetExtInputCheck (&zero1, &zero2);
+ }
+#endif
}
/*
@@ -1095,7 +1100,7 @@ KdEnqueueKeyboardEvent(unsigned char scan_code,
#define Press(b) SetButton(b+1,ButtonPress,"Down")
#define Release(b) SetButton(b+1,ButtonRelease,"Up")
-unsigned char ButtonState = 0;
+static unsigned char kdButtonState = 0;
/*
* kdEnqueueMouseEvent
@@ -1146,7 +1151,7 @@ KdEnqueueMouseEvent(unsigned long flags, int x, int y)
buttons = flags;
- if ((ButtonState & KD_BUTTON_1) ^ (buttons & KD_BUTTON_1))
+ if ((kdButtonState & KD_BUTTON_1) ^ (buttons & KD_BUTTON_1))
{
if (buttons & KD_BUTTON_1)
{
@@ -1157,7 +1162,7 @@ KdEnqueueMouseEvent(unsigned long flags, int x, int y)
Release(0);
}
}
- if ((ButtonState & KD_BUTTON_2) ^ (buttons & KD_BUTTON_2))
+ if ((kdButtonState & KD_BUTTON_2) ^ (buttons & KD_BUTTON_2))
{
if (buttons & KD_BUTTON_2)
{
@@ -1168,7 +1173,7 @@ KdEnqueueMouseEvent(unsigned long flags, int x, int y)
Release(1);
}
}
- if ((ButtonState & KD_BUTTON_3) ^ (buttons & KD_BUTTON_3))
+ if ((kdButtonState & KD_BUTTON_3) ^ (buttons & KD_BUTTON_3))
{
if (buttons & KD_BUTTON_3)
{
@@ -1179,7 +1184,7 @@ KdEnqueueMouseEvent(unsigned long flags, int x, int y)
Release(2);
}
}
- ButtonState = buttons;
+ kdButtonState = buttons;
}
void
@@ -1328,4 +1333,3 @@ ProcessInputEvents ()
KdProcessSwitch ();
KdCheckLock ();
}
-
diff --git a/hw/kdrive/src/kmap.c b/hw/kdrive/src/kmap.c
index fdd0f36d6..782657997 100644
--- a/hw/kdrive/src/kmap.c
+++ b/hw/kdrive/src/kmap.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kmap.c,v 1.1 1999/11/19 13:53:50 hohndel Exp $ */
#include "kdrive.h"
@@ -70,6 +70,9 @@ KdMapDevice (CARD32 addr, CARD32 size)
strerror (errno));
return a;
#endif
+#ifdef VXWORKS
+ return (void *) addr;
+#endif
}
void
@@ -82,5 +85,8 @@ KdUnmapDevice (void *addr, CARD32 size)
#ifdef linux
munmap (addr, size);
#endif
+#ifdef VXWORKS
+ ;
+#endif
}
diff --git a/hw/kdrive/src/kmode.c b/hw/kdrive/src/kmode.c
new file mode 100644
index 000000000..61d7a2fdf
--- /dev/null
+++ b/hw/kdrive/src/kmode.c
@@ -0,0 +1,313 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#include "kdrive.h"
+
+const KdMonitorTiming kdMonitorTimings[] = {
+ /* H V Hz KHz */
+ /* FP BP BLANK POLARITY */
+ /* Other VESA modes */
+ { 640, 350, 85, 31500, /* VESA */
+ 32, 96, 192, KdSyncPositive, /* 37.861 */
+ 32, 60, 95, KdSyncNegative, /* 85.080 */
+ },
+ { 640, 400, 85, 31500, /* VESA */
+ 32, 96, 192, KdSyncNegative, /* 37.861 */
+ 1, 41, 45, KdSyncPositive, /* 85.080 */
+ },
+ { 720, 400, 85, 35500, /* VESA */
+ 36, 108, 216, KdSyncNegative, /* 37.927 */
+ 1, 42, 46, KdSyncPositive, /* 85.039 */
+ },
+
+ /* 640x480 modes */
+ { 640, 480, 85, 36000, /* VESA */
+ 56, 80, 192, KdSyncNegative, /* 43.269 */
+ 1, 25, 29, KdSyncNegative, /* 85.008 */
+ },
+ { 640, 480, 75, 31500, /* VESA */
+ 16, 120, 200, KdSyncNegative, /* 37.500 */
+ 1, 16, 20, KdSyncNegative, /* 75.000 */
+ },
+ { 640, 480, 72, 31500, /* VESA */
+ 16, 120, 176, KdSyncNegative, /* 37.861 */
+ 1, 20, 24, KdSyncNegative, /* 72.809 */
+ },
+ { 640, 480, 60, 25175, /* VESA */
+ 8, 40, 144, KdSyncNegative, /* 31.469 */
+ 2, 25, 29, KdSyncNegative, /* 59.940 */
+ },
+
+ /* 800x600 modes */
+ { 800, 600, 85, 56250, /* VESA */
+ 32, 152, 248, KdSyncPositive, /* 53.674 */
+ 1, 27, 31, KdSyncPositive, /* 85.061 */
+ },
+ { 800, 600, 75, 49500, /* VESA */
+ 16, 160, 256, KdSyncPositive, /* 46.875 */
+ 1, 21, 25, KdSyncPositive, /* 75.000 */
+ },
+ /* DEFAULT */
+#define MONITOR_TIMING_DEFAULT 9
+ { 800, 600, 72, 50000, /* VESA */
+ 56, 64, 240, KdSyncPositive, /* 48.077 */
+ 37, 23, 66, KdSyncPositive, /* 72.188 */
+ },
+ { 800, 600, 60, 40000, /* VESA */
+ 40, 88, 256, KdSyncPositive, /* 37.879 */
+ 1, 23, 28, KdSyncPositive, /* 60.317 */
+ },
+ { 800, 600, 56, 36000, /* VESA */
+ 24, 128, 224, KdSyncPositive, /* 35.156 */
+ 1, 22, 25, KdSyncPositive, /* 56.250 */
+ },
+
+ /* 1024x768 modes */
+ { 1024, 768, 85, 94500, /* VESA */
+ 48, 208, 352, KdSyncPositive, /* 68.677 */
+ 1, 36, 40, KdSyncPositive, /* 84.997 */
+ },
+ { 1024, 768, 75, 78750, /* VESA */
+ 16, 176, 288, KdSyncPositive, /* 60.023 */
+ 1, 28, 32, KdSyncPositive, /* 75.029 */
+ },
+ { 1024, 768, 70, 75000, /* VESA */
+ 24, 144, 304, KdSyncNegative, /* 56.476 */
+ 3, 29, 38, KdSyncNegative, /* 70.069 */
+ },
+ { 1024, 768, 60, 65000, /* VESA */
+ 24, 160, 320, KdSyncNegative, /* 48.363 */
+ 3, 29, 38, KdSyncNegative, /* 60.004 */
+ },
+
+ /* 1152x864 mode */
+ { 1152, 864, 75, 108000, /* VESA */
+ 64, 256, 448, KdSyncPositive, /* 67.500 */
+ 1, 32, 36, KdSyncPositive, /* 75.000 */
+ },
+
+ /* 1152x900 modes */
+ { 1152, 900, 85, 122500, /* ADDED */
+ 48, 208, 384, KdSyncPositive, /* 79.753 */
+ 1, 32, 38, KdSyncPositive, /* 85.024 */
+ },
+ { 1152, 900, 75, 108250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 70.475 */
+ 1, 32, 38, KdSyncPositive, /* 75.133 */
+ },
+ { 1152, 900, 70, 100250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 65.267 */
+ 2, 32, 38, KdSyncPositive, /* 69.581 */
+ },
+ { 1152, 900, 66, 95000, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 61.849 */
+ 1, 32, 38, KdSyncPositive, /* 65.937 */
+ },
+
+ /* 1280x960 modes */
+ { 1280, 960, 85, 148500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 85.938 */
+ 1, 47, 51, KdSyncPositive, /* 85.002 */
+ },
+ { 1280, 960, 60, 108000, /* VESA */
+ 96, 312, 520, KdSyncPositive, /* 60.000 */
+ 1, 36, 40, KdSyncPositive, /* 60.000 */
+ },
+
+ /* 1280x1024 modes */
+ { 1280, 1024, 85, 157500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 91.146 */
+ 1, 44, 48, KdSyncPositive, /* 85.024 */
+ },
+ { 1280, 1024, 75, 135000, /* VESA */
+ 16, 248, 408, KdSyncPositive, /* 79.976 */
+ 1, 38, 42, KdSyncPositive, /* 75.025 */
+ },
+ { 1280, 1024, 60, 108000, /* VESA */
+ 48, 248, 408, KdSyncPositive, /* 63.981 */
+ 1, 38, 42, KdSyncPositive, /* 60.020 */
+ },
+
+ /* 1600x1200 modes */
+ { 1600, 1200, 85, 229500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 106.250 */
+ 1, 46, 50, KdSyncPositive, /* 85.000 */
+ },
+ { 1600, 1200, 75, 202500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 93.750 */
+ 1, 46, 50, KdSyncPositive, /* 75.000 */
+ },
+ { 1600, 1200, 70, 189000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 87.500 */
+ 1, 46, 50, KdSyncPositive, /* 70.000 */
+ },
+ { 1600, 1200, 65, 175500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 81.250 */
+ 1, 46, 50, KdSyncPositive, /* 65.000 */
+ },
+ { 1600, 1200, 60, 162000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 75.000 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
+
+ /* 1792x1344 modes */
+ { 1792, 1344, 85, 301500, /* ADDED */
+ 96, 352, 672, KdSyncNegative, /* 122.362 */
+ 1, 92, 96, KdSyncPositive, /* 84.974 */
+ },
+ { 1792, 1344, 75, 261000, /* VESA */
+ 96, 352, 664, KdSyncNegative, /* 106.270 */
+ 1, 69, 73, KdSyncPositive, /* 74.997 */
+ },
+ { 1792, 1344, 60, 204750, /* VESA */
+ 128, 328, 656, KdSyncNegative, /* 83.640 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
+
+#if 0
+ { 1800, 1012, 75 },
+ { 1906, 1072, 68 },
+#endif
+
+ /* 1856x1392 modes */
+ { 1856, 1392, 85, 330500, /* ADDED */
+ 160, 352, 736, KdSyncNegative, /* 127.508 */
+ 1, 104, 108, KdSyncPositive, /* 85.001 */
+ },
+ { 1856, 1392, 75, 288000, /* VESA */
+ 128, 352, 704, KdSyncNegative, /* 112.500 */
+ 1, 104, 108, KdSyncPositive, /* 75.000 */
+ },
+ { 1856, 1392, 60, 218250, /* VESA */
+ 96, 352, 672, KdSyncNegative, /* 86.333 */
+ 1, 43, 47, KdSyncPositive, /* 59.995 */
+ },
+
+ /* 1920x1440 modes */
+ { 1920, 1440, 85, 341750, /* ADDED */
+ 160, 352, 760, KdSyncNegative, /* 127.512 */
+ 1, 56, 60, KdSyncPositive, /* 85.012 */
+ },
+ { 1920, 1440, 75, 297000, /* VESA */
+ 144, 352, 720, KdSyncNegative, /* 112.500 */
+ 1, 56, 60, KdSyncPositive, /* 75.000 */
+ },
+ { 1920, 1440, 60, 234000, /* VESA */
+ 128, 244, 680, KdSyncNegative, /* 90.000 */
+ 1, 56, 60, KdSyncPositive, /* 60.000 */
+ },
+};
+
+#define NUM_MONITOR_TIMINGS (sizeof kdMonitorTimings/sizeof kdMonitorTimings[0])
+
+const int kdNumMonitorTimings = NUM_MONITOR_TIMINGS;
+
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *))
+{
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
+ {
+ if ((*supported) (screen, t) &&
+ t->horizontal == screen->width &&
+ t->vertical == screen->height &&
+ (!screen->rate || t->rate <= screen->rate))
+ {
+ return t;
+ }
+ }
+ return &kdMonitorTimings[MONITOR_TIMING_DEFAULT];
+}
+
+static const KdMonitorTiming *
+kdFindPrevSize (const KdMonitorTiming *old)
+{
+ const KdMonitorTiming *new, *prev;
+
+ if (old == kdMonitorTimings)
+ return 0;
+ new = old;
+ /*
+ * Search for the previous size
+ */
+ while (new != kdMonitorTimings)
+ {
+ new--;
+ if (new->horizontal != old->horizontal &&
+ new->vertical != old->vertical)
+ {
+ break;
+ }
+ }
+ /*
+ * Match the refresh rate (<=)
+ */
+ while (new != kdMonitorTimings)
+ {
+ prev = new - 1;
+ if (prev->horizontal == new->horizontal &&
+ prev->vertical == new->vertical &&
+ prev->rate > old->rate)
+ {
+ break;
+ }
+ new--;
+ }
+ return new;
+}
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *))
+{
+ const KdMonitorTiming *t, *new;
+
+ while (!(*usable) (screen))
+ {
+ /*
+ * Fix requested depth and geometry until it works
+ */
+ if (screen->depth > 16)
+ screen->depth = 16;
+ else if (screen->depth > 8)
+ screen->depth = 8;
+ else
+ {
+ t = kdFindPrevSize (KdFindMode (screen, supported));
+ if (!t)
+ return FALSE;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+ screen->rate = t->rate;
+ }
+ }
+ return TRUE;
+}
diff --git a/hw/kdrive/src/vga.c b/hw/kdrive/src/vga.c
index 0e0c53878..41fb38089 100644
--- a/hw/kdrive/src/vga.c
+++ b/hw/kdrive/src/vga.c
@@ -21,22 +21,37 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.c,v 1.1 1999/11/19 13:53:51 hohndel Exp $ */
#include "vga.h"
#include <stdio.h>
#ifdef linux
-#define extern
+#define extern static
#include <asm/io.h>
#undef extern
#define _VgaInb(r) inb(r)
#define _VgaOutb(v,r) outb(v,r)
+#define _VgaByteAddr(a) ((VGAVOL8 *) (a))
+#define _VgaBytePort(a) (a)
#endif
-#if 0
+#ifdef VXWORKS
+#define _VgaInb(r) 0
+#define _VgaOutb(v,r) 0
+
+#define _VgaByteAddr(a) ((VGAVOL8 *) ((VGA32) (a) ^ 3))
+#define _VgaBytePort(a) 0
+
+#undef stderr
+#define stderr stdout
+
+#endif
+
+#undef VGA_DEBUG_REGISTERS
+#ifdef VGA_DEBUG_REGISTERS
#define VGA_DEBUG(a) fprintf a
#else
#define VGA_DEBUG(a)
@@ -55,26 +70,37 @@ VgaOutb (VGA8 v, VGA16 r)
}
VGA8
+VgaReadMemb (VGA32 addr)
+{
+ return *_VgaByteAddr(addr);
+}
+
+void
+VgaWriteMemb (VGA8 v, VGA32 addr)
+{
+ *_VgaByteAddr(addr) = v;
+}
+
+VGA8
VgaFetch (VgaCard *card, VGA16 reg)
{
VgaMap map;
- VGAVOL8 *mem;
VGA8 value;
(*card->map) (card, reg, &map, VGAFALSE);
switch (map.access) {
case VgaAccessMem:
- mem = (VGAVOL8 *) map.port;
- value = *mem;
+ value = VgaReadMemb (map.port);
+ VGA_DEBUG ((stderr, "%08x -> %2x\n", map.port, value));
break;
case VgaAccessIo:
value = _VgaInb (map.port);
VGA_DEBUG ((stderr, "%4x -> %2x\n", map.port, value));
break;
case VgaAccessIndMem:
- mem = (VGAVOL8 *) map.port;
- mem[map.addr] = map.index;
- value = mem[map.value];
+ VgaWriteMemb (map.index, map.port + map.addr);
+ value = VgaReadMemb (map.port + map.value);
+ VGA_DEBUG ((stderr, "%4x/%2x -> %2x\n", map.port, map.index, value));
break;
case VgaAccessIndIo:
_VgaOutb (map.index, map.port + map.addr);
@@ -93,23 +119,22 @@ void
VgaStore (VgaCard *card, VGA16 reg, VGA8 value)
{
VgaMap map;
- VGAVOL8 *mem;
map.value = value;
(*card->map) (card, reg, &map, VGATRUE);
switch (map.access) {
case VgaAccessMem:
- mem = (VGAVOL8 *) map.port;
- *mem = value;
+ VGA_DEBUG ((stderr, "%8x <- %2x\n", map.port, value));
+ VgaWriteMemb (map.value, map.port);
break;
case VgaAccessIo:
VGA_DEBUG ((stderr, "%4x <- %2x\n", map.port, value));
_VgaOutb (value, map.port);
break;
case VgaAccessIndMem:
- mem = (VGAVOL8 *) map.port;
- mem[map.addr] = map.index;
- mem[map.value] = value;
+ VgaWriteMemb (map.index, map.port + map.addr);
+ VgaWriteMemb (value, map.port + map.value);
+ VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value));
break;
case VgaAccessIndIo:
VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value));
@@ -168,6 +193,16 @@ VgaFinish (VgaCard *card)
}
void
+VgaInvalidate (VgaCard *card)
+{
+ VGA16 id;
+
+ for (id = 0; id < card->max; id++)
+ card->values[id].flags &= ~VGA_VALUE_VALID;
+}
+
+
+void
_VgaSync (VgaCard *card, VGA16 id)
{
if (!(card->values[id].flags & VGA_VALUE_VALID))
diff --git a/hw/kdrive/src/vga.h b/hw/kdrive/src/vga.h
index b254152cb..a044e5f5d 100644
--- a/hw/kdrive/src/vga.h
+++ b/hw/kdrive/src/vga.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.h,v 1.1 1999/11/19 13:53:51 hohndel Exp $ */
#ifndef _VGA_H_
#define _VGA_H_
@@ -93,6 +93,12 @@ VgaInb (VGA16 r);
void
VgaOutb (VGA8 v, VGA16 r);
+VGA8
+VgaReadMemb (VGA32 addr);
+
+void
+VgaWriteMemb (VGA8 v, VGA32 addr);
+
void
VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value);
@@ -115,6 +121,9 @@ void
VgaPreserve (VgaCard *card);
void
+VgaInvalidate (VgaCard *card);
+
+void
VgaRestore (VgaCard *card);
VGA8