summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/kdrive/Imakefile6
-rw-r--r--hw/kdrive/fbdev/fbdev.c10
-rw-r--r--hw/kdrive/fbdev/fbdev.h5
-rw-r--r--hw/kdrive/fbdev/fbinit.c10
-rw-r--r--hw/kdrive/itsy/itsy.c91
-rw-r--r--hw/kdrive/linux/Imakefile16
-rw-r--r--hw/kdrive/linux/keyboard.c439
-rw-r--r--hw/kdrive/linux/linux.c329
-rw-r--r--hw/kdrive/linux/ps2.c131
-rw-r--r--hw/kdrive/savage/s3.c1067
-rw-r--r--hw/kdrive/savage/s3.h128
-rw-r--r--hw/kdrive/savage/s3clock.c4
-rw-r--r--hw/kdrive/savage/s3cmap.c52
-rw-r--r--hw/kdrive/savage/s3curs.c75
-rw-r--r--hw/kdrive/savage/s3draw.c314
-rw-r--r--hw/kdrive/savage/s3draw.h107
-rw-r--r--hw/kdrive/savage/s3gc.c86
-rw-r--r--hw/kdrive/savage/s3reg.c117
-rw-r--r--hw/kdrive/savage/s3reg.h29
-rw-r--r--hw/kdrive/savage/s3stub.c37
-rw-r--r--hw/kdrive/sis530/sis.c4
-rw-r--r--hw/kdrive/sis530/sis.h3
-rw-r--r--hw/kdrive/sis530/sisdraw.c67
-rw-r--r--hw/kdrive/sis530/sisstub.c8
-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
-rw-r--r--hw/kdrive/trident/trident.c10
-rw-r--r--hw/kdrive/trident/trident.h16
-rw-r--r--hw/kdrive/trident/tridentcurs.c31
-rw-r--r--hw/kdrive/trident/tridentdraw.c63
-rw-r--r--hw/kdrive/trident/tridentdraw.h7
-rw-r--r--hw/kdrive/trident/tridentstub.c8
-rw-r--r--hw/kdrive/trio/s3.c500
-rw-r--r--hw/kdrive/trio/s3.h76
-rw-r--r--hw/kdrive/trio/s3clock.c8
-rw-r--r--hw/kdrive/trio/s3curs.c79
-rw-r--r--hw/kdrive/trio/s3stub.c8
-rw-r--r--hw/kdrive/ts300/ts300.c9
-rw-r--r--hw/kdrive/vxworks/Imakefile15
-rw-r--r--hw/kdrive/vxworks/vxkbd.c262
-rw-r--r--hw/kdrive/vxworks/vxmouse.c121
-rw-r--r--hw/kdrive/vxworks/vxworks.c65
50 files changed, 4155 insertions, 1325 deletions
diff --git a/hw/kdrive/Imakefile b/hw/kdrive/Imakefile
index 0becea61a..364897527 100644
--- a/hw/kdrive/Imakefile
+++ b/hw/kdrive/Imakefile
@@ -1,12 +1,12 @@
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/Imakefile,v 1.1 1999/11/19 13:53:47 hohndel Exp $
#include <Server.tmpl>
SRCS = kcmap.c kcolor.c kdrive.c kinfo.c kinput.c kmap.c knoop.c ktest.c \
- ps2.c keyboard.c linux.c vga.c
+ vga.c kasync.c kmode.c kcurscol.c
OBJS = kcmap.o kcolor.o kdrive.o kinfo.o kinput.o kmap.o knoop.o ktest.o \
- ps2.o keyboard.o linux.o vga.o
+ vga.o kasync.o kmode.o kcurscol.o
INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-I../../fb -I../../mi -I../../include -I../../os \
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index c268ae2b1..65506fd0b 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: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.1 1999/11/19 13:53:52 hohndel Exp $ */
#include "fbdev.h"
@@ -125,6 +125,12 @@ fbdevScreenInit (KdScreenInfo *screen)
return TRUE;
}
+Bool
+fbdevInitScreen (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
void
fbdevPreserve (KdCardInfo *card)
{
@@ -151,8 +157,10 @@ fbdevDPMS (ScreenPtr pScreen, int mode)
KdScreenPriv(pScreen);
FbdevPriv *priv = pScreenPriv->card->driver;
+#ifdef FBIOPUT_POWERMODE
if (!ioctl (priv->fd, FBIOPUT_POWERMODE, &mode))
return TRUE;
+#endif
return FALSE;
}
diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h
index 46c8bb2ef..ce07a40df 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: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.1 1999/11/19 13:53:52 hohndel Exp $ */
#ifndef _FBDEV_H_
#define _FBDEV_H_
@@ -50,6 +50,9 @@ fbdevCardInit (KdCardInfo *card);
Bool
fbdevScreenInit (KdScreenInfo *screen);
+Bool
+fbdevInitScreen (ScreenPtr pScreen);
+
void
fbdevPreserve (KdCardInfo *card);
diff --git a/hw/kdrive/fbdev/fbinit.c b/hw/kdrive/fbdev/fbinit.c
index ea1439145..56fc27b5b 100644
--- a/hw/kdrive/fbdev/fbinit.c
+++ b/hw/kdrive/fbdev/fbinit.c
@@ -21,13 +21,14 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.1 1999/11/19 13:53:52 hohndel Exp $ */
#include <fbdev.h>
KdCardFuncs fbdevFuncs = {
fbdevCardInit, /* cardinit */
fbdevScreenInit, /* scrinit */
+ fbdevInitScreen, /* initScreen */
fbdevPreserve, /* preserve */
fbdevEnable, /* enable */
fbdevDPMS, /* dpms */
@@ -44,6 +45,7 @@ KdCardFuncs fbdevFuncs = {
0, /* initAccel */
0, /* enableAccel */
+ 0, /* syncAccel */
0, /* disableAccel */
0, /* finiAccel */
@@ -71,8 +73,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}
diff --git a/hw/kdrive/itsy/itsy.c b/hw/kdrive/itsy/itsy.c
index 68ce60aaa..6da560934 100644
--- a/hw/kdrive/itsy/itsy.c
+++ b/hw/kdrive/itsy/itsy.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/itsy/itsy.c,v 1.1 1999/11/19 13:53:53 hohndel Exp $ */
#include "itsy.h"
@@ -89,6 +89,46 @@ itsyScreenInit (KdScreenInfo *screen)
return TRUE;
}
+static unsigned short itsyIntensity[16] = {
+ 0xffff,
+ 0xffff,
+ 0xedb6,
+ 0xdb6d,
+ 0xc924,
+ 0xb6db,
+ 0xa492,
+ 0x9249,
+ 0x8000,
+ 0x6db6,
+ 0x5b6d,
+ 0x4924,
+ 0x36db,
+ 0x2492,
+ 0x1249,
+ 0x0000,
+};
+
+Bool
+itsyCreateColormap (ColormapPtr pmap)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ {
+ pmap->red[i].co.local.red = itsyIntensity[i];
+ pmap->red[i].co.local.green = itsyIntensity[i];
+ pmap->red[i].co.local.blue = itsyIntensity[i];
+ }
+ return TRUE;
+}
+
+Bool
+itsyInitScreen (ScreenPtr pScreen)
+{
+ pScreen->CreateColormap = itsyCreateColormap;
+ return TRUE;
+}
+
void
itsyPreserve (KdCardInfo *card)
{
@@ -147,49 +187,10 @@ itsyCardFini (KdCardInfo *card)
fprintf (stderr, "itsyFini done\n");
}
-static unsigned short itsyIntensity[16] = {
- 0xffff,
- 0xffff,
- 0xedb6,
- 0xdb6d,
- 0xc924,
- 0xb6db,
- 0xa492,
- 0x9249,
- 0x8000,
- 0x6db6,
- 0x5b6d,
- 0x4924,
- 0x36db,
- 0x2492,
- 0x1249,
- 0x0000,
-};
-
-Bool
-itsyCreateColormap (ColormapPtr pmap)
-{
- int i;
-
- for (i = 0; i < 16; i++)
- {
- pmap->red[i].co.local.red = itsyIntensity[i];
- pmap->red[i].co.local.green = itsyIntensity[i];
- pmap->red[i].co.local.blue = itsyIntensity[i];
- }
- return TRUE;
-}
-
-Bool
-itsySetupScreen (ScreenPtr pScreen)
-{
- pScreen->CreateColormap = itsyCreateColormap;
- return FALSE;
-}
-
KdCardFuncs itsyFuncs = {
itsyCardInit, /* cardinit */
itsyScreenInit, /* scrinit */
+ itsyInitScreen, /* initScreen */
itsyPreserve, /* preserve */
itsyEnable, /* enable */
itsyDPMS, /* dpms */
@@ -204,7 +205,7 @@ KdCardFuncs itsyFuncs = {
0, /* finiCursor */
0, /* recolorCursor */
- itsySetupScreen, /* initAccel */
+ 0, /* initAccel */
0, /* enableAccel */
0, /* disableAccel */
0, /* finiAccel */
@@ -309,3 +310,9 @@ OsVendorInit (void)
{
KdOsInit (&ItsyOsFuncs);
}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ return KdProcessArgument (argc, argv, i);
+}
diff --git a/hw/kdrive/linux/Imakefile b/hw/kdrive/linux/Imakefile
new file mode 100644
index 000000000..0c8927c42
--- /dev/null
+++ b/hw/kdrive/linux/Imakefile
@@ -0,0 +1,16 @@
+XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
+XCOMM $XFree86: $
+#include <Server.tmpl>
+
+SRCS = keyboard.c linux.c ps2.c
+
+OBJS = keyboard.o linux.o ps2.o
+
+INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../../fb -I../../../mi -I../../../include -I../../../os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(linux,$(OBJS))
+
+DependTarget()
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
new file mode 100644
index 000000000..87fc0962e
--- /dev/null
+++ b/hw/kdrive/linux/keyboard.c
@@ -0,0 +1,439 @@
+/*
+ * $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 "kkeymap.h"
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+#include <X11/keysym.h>
+#include <termios.h>
+
+extern int LinuxConsoleFd;
+
+static const KeySym linux_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+};
+
+static unsigned char tbl[KD_MAX_WIDTH] =
+{
+ 0,
+ 1 << KG_SHIFT,
+ (1 << KG_ALT),
+ (1 << KG_ALT) | (1 << KG_SHIFT)
+};
+
+static void
+readKernelMapping()
+{
+ KeySym *k;
+ int i, j;
+ struct kbentry kbe;
+ int minKeyCode, maxKeyCode;
+
+ minKeyCode = NR_KEYS;
+ maxKeyCode = 0;
+ k = kdKeymap;
+ for (i = 0;
+ i < NR_KEYS && (maxKeyCode - minKeyCode + 1) < KD_MAX_LENGTH;
+ ++i)
+ {
+ kbe.kb_index = i;
+
+ for (j = 0; j < KD_MAX_WIDTH; ++j)
+ {
+ unsigned short kval;
+
+ k[j] = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ if (ioctl(LinuxConsoleFd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value))
+ {
+ case KT_LATIN:
+ case KT_LETTER:
+ k[j] = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ k[j] = XK_F1 + kval;
+ else switch (kbe.kb_value)
+ {
+ case K_FIND:
+ k[j] = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ k[j] = XK_Insert;
+ break;
+ case K_REMOVE:
+ k[j] = XK_Delete;
+ break;
+ case K_SELECT:
+ k[j] = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ k[j] = XK_Prior;
+ break;
+ case K_PGDN:
+ k[j] = XK_Next;
+ break;
+ case K_HELP:
+ k[j] = XK_Help;
+ break;
+ case K_DO:
+ k[j] = XK_Execute;
+ break;
+ case K_PAUSE:
+ k[j] = XK_Pause;
+ break;
+ case K_MACRO:
+ k[j] = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value)
+ {
+ case K_ENTER:
+ k[j] = XK_Return;
+ break;
+ case K_BREAK:
+ k[j] = XK_Break;
+ break;
+ case K_CAPS:
+ k[j] = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ k[j] = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ k[j] = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ k[j] = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value)
+ {
+ case K_PPLUS:
+ k[j] = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ k[j] = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ k[j] = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ k[j] = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ k[j] = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ k[j] = XK_KP_Decimal;
+ break;
+ case K_PPLUSMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ default:
+ if (kval <= 9)
+ k[j] = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value)
+ {
+ case K_DGRAVE:
+ k[j] = XK_dead_grave;
+ break;
+ case K_DACUTE:
+ k[j] = XK_dead_acute;
+ break;
+ case K_DCIRCM:
+ k[j] = XK_dead_circumflex;
+ break;
+ case K_DTILDE:
+ k[j] = XK_dead_tilde;
+ break;
+ case K_DDIERE:
+ k[j] = XK_dead_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value)
+ {
+ case K_DOWN:
+ k[j] = XK_Down;
+ break;
+ case K_LEFT:
+ k[j] = XK_Left;
+ break;
+ case K_RIGHT:
+ k[j] = XK_Right;
+ break;
+ case K_UP:
+ k[j] = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value)
+ {
+ case K_ALTGR:
+ k[j] = XK_Alt_R;
+ break;
+ case K_ALT:
+ k[j] = (kbe.kb_index == 0x64 ?
+ XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ k[j] = (kbe.kb_index == 0x61 ?
+ XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ k[j] = XK_Control_L;
+ break;
+ case K_CTRLR:
+ k[j] = XK_Control_R;
+ break;
+ case K_SHIFT:
+ k[j] = (kbe.kb_index == 0x36 ?
+ XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ k[j] = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ k[j] = XK_Shift_R;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /*
+ * KT_ASCII keys accumulate a 3 digit decimal number that gets
+ * emitted when the shift state changes. We can't emulate that.
+ */
+ case KT_ASCII:
+ break;
+
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK)
+ k[j] = XK_Shift_Lock;
+ break;
+
+ default:
+ break;
+ }
+ if (i < minKeyCode)
+ minKeyCode = i;
+ if (i > maxKeyCode)
+ maxKeyCode = i;
+ }
+
+ if (minKeyCode == NR_KEYS)
+ continue;
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] =NoSymbol;
+
+ k += KD_MAX_WIDTH;
+ }
+ kdMinScanCode = minKeyCode;
+ kdMaxScanCode = maxKeyCode;
+}
+
+void
+LinuxKeyboardLoad (void)
+{
+ readKernelMapping ();
+}
+
+static int LinuxKbdTrans;
+static struct termios LinuxTermios;
+
+int
+LinuxKeyboardInit (void)
+{
+ struct termios nTty;
+
+ ioctl (LinuxConsoleFd, KDGKBMODE, &LinuxKbdTrans);
+ tcgetattr (LinuxConsoleFd, &LinuxTermios);
+
+ ioctl(LinuxConsoleFd, KDSKBMODE, K_MEDIUMRAW);
+ nTty = LinuxTermios;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(LinuxConsoleFd, TCSANOW, &nTty);
+ return LinuxConsoleFd;
+}
+
+void
+LinuxKeyboardFini (int fd)
+{
+ ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
+ tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
+}
+
+void
+LinuxKeyboardRead (int fd)
+{
+ unsigned char buf[256], *b;
+ int n;
+
+ while ((n = read (fd, buf, sizeof (buf))) > 0)
+ {
+ b = buf;
+ while (n--)
+ {
+ KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
+ b++;
+ }
+ }
+}
+
+void
+LinuxKeyboardLeds (int leds)
+{
+ ioctl (LinuxConsoleFd, KDSETLED, leds & 7);
+}
+
+void
+LinuxKeyboardBell (int volume, int pitch, int duration)
+{
+ if (volume && pitch)
+ {
+ ioctl(LinuxConsoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ volume / 50) << 16));
+
+ }
+}
+
+KdKeyboardFuncs LinuxKeyboardFuncs = {
+ LinuxKeyboardLoad,
+ LinuxKeyboardInit,
+ LinuxKeyboardRead,
+ LinuxKeyboardLeds,
+ LinuxKeyboardBell,
+ LinuxKeyboardFini,
+ 3,
+};
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
new file mode 100644
index 000000000..68aa686df
--- /dev/null
+++ b/hw/kdrive/linux/linux.c
@@ -0,0 +1,329 @@
+/*
+ * $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 <errno.h>
+#include <signal.h>
+#include <linux/vt.h>
+#include <linux/kd.h>
+#include <sys/stat.h>
+#include <keysym.h>
+
+static int vtno;
+int LinuxConsoleFd;
+static int activeVT;
+static Bool enabled;
+
+void
+LinuxVTRequest (int sig)
+{
+ kdSwitchPending = TRUE;
+}
+
+/* Check before chowning -- this avoids touching the file system */
+void
+LinuxCheckChown (char *file)
+{
+ struct stat st;
+ __uid_t u;
+ __gid_t g;
+
+ if (stat (file, &st) < 0)
+ return;
+ u = getuid ();
+ g = getgid ();
+ if (st.st_uid != u || st.st_gid != g)
+ chown (file, u, g);
+}
+
+int
+LinuxInit ()
+{
+ int i, fd;
+ char vtname[11];
+ struct vt_stat vts;
+ struct stat statb;
+
+ LinuxConsoleFd = -1;
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("LinuxInit: Server must be suid root\n");
+ }
+
+ if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "LinuxInit: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) ||
+ (vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+
+/* ErrorF("(using VT number %d)\n\n", vtno); */
+
+ sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
+
+ if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
+ {
+ FatalError("LinuxInit: Cannot open %s (%s)\n",
+ vtname, strerror(errno));
+ }
+
+ /* change ownership of the vt */
+ LinuxCheckChown (vtname);
+
+ /*
+ * the current VT device we're running on is not "console", we want
+ * to grab all consoles too
+ *
+ * Why is this needed?
+ */
+ LinuxCheckChown ("/dev/tty0");
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0)
+ {
+ activeVT = vts.v_active;
+ }
+
+ return 1;
+}
+
+Bool
+LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr)
+{
+ FILE *f;
+ char line[2048], *l, *end;
+ CARD32 bus, id, mode, addr;
+ int n;
+ CARD32 ven_dev;
+ Bool ret = FALSE;
+ int i;
+
+ ven_dev = (((CARD32) vendor) << 16) | ((CARD32) device);
+ f = fopen ("/proc/bus/pci/devices", "r");
+ if (!f)
+ return FALSE;
+ attr->io = 0;
+ while (fgets (line, sizeof (line)-1, f))
+ {
+ line[sizeof(line)-1] = '\0';
+ l = line;
+ bus = strtoul (l, &end, 16);
+ if (end == l)
+ continue;
+ l = end;
+ id = strtoul (l, &end, 16);
+ if (end == l)
+ continue;
+ l = end;
+ if (id != ven_dev)
+ continue;
+ if (count--)
+ continue;
+ (void) strtoul (l, &end, 16);
+ if (end == l)
+ continue;
+ l = end;
+ n = 0;
+ for (i = 0; i < 6; i++)
+ {
+ addr = strtoul (l, &end, 16);
+ if (end == l)
+ break;
+ if (addr & 1)
+ attr->io = addr & ~0xf;
+ else
+ {
+ if (n == KD_MAX_CARD_ADDRESS)
+ break;
+ attr->address[n++] = addr & ~0xf;
+ }
+ l = end;
+ }
+ while (n > 0)
+ {
+ if (attr->address[n-1] != 0)
+ break;
+ n--;
+ }
+ attr->naddr = n;
+ ret = TRUE;
+ break;
+ }
+ fclose (f);
+ return ret;
+}
+
+void
+LinuxEnable (void)
+{
+ struct sigaction act;
+ struct vt_mode VT;
+
+ if (enabled)
+ return;
+ if (kdSwitchPending)
+ {
+ kdSwitchPending = FALSE;
+ ioctl (LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
+ }
+ /*
+ * now get the VT
+ */
+ if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
+ {
+ ErrorF("LinuxInit: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
+ {
+ ErrorF("LinuxInit: VT_WAITACTIVE failed\n");
+ }
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError ("LinuxInit: VT_GETMODE failed\n");
+ }
+
+ act.sa_handler = LinuxVTRequest;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_restorer = 0;
+ sigaction (SIGUSR1, &act, 0);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("LinuxInit: VT_SETMODE VT_PROCESS failed\n");
+ }
+ if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ enabled = TRUE;
+}
+
+Bool
+LinuxSpecialKey (KeySym sym)
+{
+ struct vt_stat vts;
+ int con;
+
+ if (XK_F1 <= sym && sym <= XK_F12)
+ {
+ con = sym - XK_F1 + 1;
+ ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
+ if (con != vts.v_active && (vts.v_state & (1 << con)))
+ {
+ ioctl (LinuxConsoleFd, VT_ACTIVATE, con);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+LinuxDisable (void)
+{
+ ioctl(LinuxConsoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (kdSwitchPending)
+ {
+ kdSwitchPending = FALSE;
+ ioctl (LinuxConsoleFd, VT_RELDISP, 1);
+ }
+ enabled = FALSE;
+}
+
+void
+LinuxFini (void)
+{
+ struct vt_mode VT;
+ struct vt_stat vts;
+ int fd;
+
+ if (LinuxConsoleFd < 0)
+ return;
+
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
+ /*
+ * Find a legal VT to switch to, either the one we started from
+ * or the lowest active one that isn't ours
+ */
+ if (activeVT < 0 ||
+ activeVT == vts.v_active ||
+ !(vts.v_state & (1 << activeVT)))
+ {
+ for (activeVT = 1; activeVT < 16; activeVT++)
+ if (activeVT != vtno && (vts.v_state & (1 << activeVT)))
+ break;
+ if (activeVT == 16)
+ activeVT = -1;
+ }
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= -1)
+ {
+ ioctl (LinuxConsoleFd, VT_ACTIVATE, activeVT);
+ ioctl (LinuxConsoleFd, VT_WAITACTIVE, activeVT);
+ activeVT = -1;
+ }
+ close(LinuxConsoleFd); /* make the vt-manager happy */
+ fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0);
+ if (fd >= 0)
+ {
+ ioctl (fd, VT_GETSTATE, &vts);
+ if (ioctl (fd, VT_DISALLOCATE, vtno) < 0)
+ fprintf (stderr, "Can't deallocate console %d errno %d\n", vtno, errno);
+ close (fd);
+ }
+ return;
+}
+
+KdOsFuncs LinuxFuncs = {
+ LinuxInit,
+ LinuxEnable,
+ LinuxSpecialKey,
+ LinuxDisable,
+ LinuxFini,
+};
+
+void
+OsVendorInit (void)
+{
+ KdOsInit (&LinuxFuncs);
+}
diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c
new file mode 100644
index 000000000..efb541430
--- /dev/null
+++ b/hw/kdrive/linux/ps2.c
@@ -0,0 +1,131 @@
+/*
+ * $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.
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include "Xpoll.h"
+
+int
+Ps2ReadBytes (int fd, char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len)
+ {
+ n = read (fd, buf, len);
+ if (n > 0)
+ {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select (fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
+ }
+ return tot;
+}
+
+void
+Ps2Read (int ps2Port)
+{
+ unsigned char buf[3 * 200];
+ unsigned char *b;
+ int n;
+ int dx, dy;
+ unsigned long flags;
+
+ while ((n = Ps2ReadBytes (ps2Port, buf, sizeof (buf), 3)) > 0)
+ {
+ b = buf;
+ while (n >= 3)
+ {
+ flags = KD_MOUSE_DELTA;
+ if (b[0] & 4)
+ flags |= KD_BUTTON_2;
+ if (b[0] & 2)
+ flags |= KD_BUTTON_3;
+ if (b[0] & 1)
+ flags |= KD_BUTTON_1;
+
+ dx = b[1];
+ if (b[0] & 0x10)
+ dx -= 256;
+ dy = b[2];
+ if (b[0] & 0x20)
+ dy -= 256;
+ dy = -dy;
+ n -= 3;
+ b += 3;
+ KdEnqueueMouseEvent (flags, dx, dy);
+ }
+ }
+}
+
+char *Ps2Names[] = {
+ "/dev/psaux",
+ "/dev/mouse",
+};
+
+#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0]))
+
+int
+Ps2Init (void)
+{
+ int i;
+ int ps2Port;
+
+ for (i = 0; i < NUM_PS2_NAMES; i++)
+ {
+ ps2Port = open (Ps2Names[i], 0);
+ if (ps2Port >= 0)
+ return ps2Port;
+ }
+}
+
+void
+Ps2Fini (int ps2Port)
+{
+ if (ps2Port >= 0)
+ close (ps2Port);
+}
+
+KdMouseFuncs Ps2MouseFuncs = {
+ Ps2Init,
+ Ps2Read,
+ Ps2Fini
+};
diff --git a/hw/kdrive/savage/s3.c b/hw/kdrive/savage/s3.c
index bf3e2896a..debe5df43 100644
--- a/hw/kdrive/savage/s3.c
+++ b/hw/kdrive/savage/s3.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.1 1999/11/19 13:53:54 hohndel Exp $ */
#include "s3.h"
@@ -30,141 +30,6 @@
#define PACKED_OFFSET (0x8100)
#define IOMAP_OFFSET (0x8000)
-/*
- * Clock synthesis:
- *
- * f_out = f_ref * ((M + 2) / ((N + 2) * (1 << R)))
- *
- * Constraints:
- *
- * 1. 135MHz <= f_ref * ((M + 2) / (N + 2)) <= 270 MHz
- * 2. N >= 1
- *
- * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
- * Horizontal refresh rate = clock / (hsize + hblank)
- */
-
-#define DEFAULT_S3_TIMING 1
-
-S3Timing s3Timings[] = {
- /* FP BP BLANK */
- /* M N R blank bios5 */
- { 640, 480, 60,
- 16, 48, 160, /* horizontal 31.321 KHz */
- 10, 33, 45, /* vertical 59.568 Hz */
- 26, 0, 3, /* pixel 25.057 MHz */
- },
-
- { 800, 600, 85,
- 32, 152, 248, /* horizontal 53.673 KHz */
- 1, 27, 31, /* vertical 85.060 Hz */
- 108, 5, 2, /* pixel 56.249 MHz */
- },
- { 800, 600, 75,
- 16, 160, 256, /* horizontal 46.891 KHz */
- 1, 21, 25, /* vertical 75.025 Hz */
- 81, 4, 2, /* pixel 49.516 MHz */
- },
- { 800, 600, 72,
- 56, 64, 240, /* horizontal 48.186 KHz */
- 37, 23, 66, /* vertical 72.351 Hz */
- 26, 0, 2, /* pixel 50.113 MHz */
- },
- { 800, 600, 60,
- 48, 80, 256,
- 1, 23, 28,
- 0, 0, 0,
- },
- { 1024, 768, 85,
- 48, 208, 352, /* horizontal 68.676 KHz */
- 1, 36, 40, /* vertical 84.996 Hz */
- 64, 3, 1, /* pixel 94.499 MHz */
- },
- { 1024, 768, 75,
- 16, 176, 288, /* horizontal 60.022 KHz */
- 1, 28, 32, /* vertical 75.028 Hz */
- 20, 0, 1, /* pixel 78.749 MHz */
- },
- { 1024, 768, 70,
- 32, 136, 304, /* horizontal 56.604 KHz */
- 2, 30, 38, /* vertical 70.227 Hz */
- 124, 1, 3, /* pixel 75.170 MHz */
- },
- { 1024, 768, 66,
- 24, 144, 304, /* horizontal 53.234 KHz */
- 3, 29, 38, /* vertical 66.047 Hz */
- 77, 6, 1, /* pixel 70.695 MHz */
- },
-
- { 1152, 900, 85,
- 48, 208, 384, /* horizontal 79.900 KHz */
- 1, 32, 38, /* vertical 85.181 Hz */
- 118, 5, 1, /* pixel 122.726 MHz */
- },
- { 1152, 900, 75,
- 32, 208, 384, /* horizontal 70.495 Khz */
- 1, 32, 38, /* vertical 75.154 Hz */
- 119, 6, 1, /* pixel 108.280 MHz */
- },
- { 1152, 900, 70,
- 32, 208, 384, /* horizontal 65.251 KHz */
- 2, 32, 38, /* vertical 69.564 Hz */
- 12, 0, 0, /* pixel 100.226 MHz */
- },
- { 1152, 900, 66,
- 32, 208, 384, /* horizontal 61.817 KHz */
- 1, 32, 38, /* vertical 65.903 Hz */
- 124, 17, 0, /* pixel 94.951 MHz */
- },
- { 1280, 1024, 85,
- 32, 248, 416, /* horizontal 90.561 KHz */
- 1, 40, 45, /* vertical 84.717 Hz */
- 116, 9, 0, /* pixel 153.593 MHz */
- },
- { 1280, 1024, 75,
- 16, 248, 408, /* horizontal 80.255 KHz */
- 1, 38, 42, /* vertical 75.285 Hz */
- 111, 4, 1, /* pixel 134.828 MHz */
- },
- { 1280, 1024, 70,
- 32, 248, 400, /* horizontal 74.573 KHz */
- 0, 36, 39, /* vertical 70.153 Hz */
- 68, 2, 1, /* pixel 125.283 MHz */
- },
- { 1280, 1024, 66,
- 32, 248, 400, /* horizontal 70.007 KHz */
- 0, 36, 39, /* vertical 65.858 Hz */
- 113, 5, 1, /* pixel 117.612 MHz */
- },
- { 1280, 1024, 60,
- 56, 240, 408, /* horizontal 70.007 KHz */
- 1, 38, 42, /* vertical 65.858 Hz */
- 113, 5, 1, /* pixel 117.612 MHz */
- },
- { 1600, 1200, 85,
- 64, 304, 560, /* horizontal 106.059 KHz */
- 1, 46, 50, /* vertical 84.847 Hz */
- 126, 6, 0, /* pixel 229.088 MHz */
- },
- { 1600, 1200, 75,
- 64, 304, 560, /* horizontal 93.748 KHz */
- 1, 46, 50, /* vertical 74.999 Hz */
- 97, 5, 0, /* pixel 202.497 MHz */
- },
- { 1600, 1200, 70,
- 56, 304, 588, /* horizontal 87.524 KHz */
- 1, 46, 50, /* vertical 70.019 Hz */
- 105, 6, 0, /* pixel 191.503 MHz */
- },
- { 1600, 1200, 65,
- 56, 308, 524, /* horizontal 80.050 KHz */
- 1, 38, 42, /* vertical 64.453 Hz */
- 93, 6, 0, /* pixel 170.026 MHz */
- },
-};
-
-#define NUM_S3_TIMINGS (sizeof (s3Timings) / sizeof (s3Timings[0]))
-
static void
_s3SetBlank (S3Ptr s3, S3Vga *s3vga, Bool blank)
{
@@ -173,17 +38,6 @@ _s3SetBlank (S3Ptr s3, S3Vga *s3vga, Bool blank)
s3SetImm(s3vga, s3_screen_off, blank ? 1 : 0);
}
-static void
-_s3SetDepth (S3Ptr s3, S3Vga *s3vga)
-{
- CARD8 save_3c2;
- _s3SetBlank (s3, s3vga, TRUE);
- VgaFlush(&s3vga->card);
- VgaSetImm (&s3vga->card, s3_clock_load_imm, 1);
- VgaSetImm(&s3vga->card, s3_clock_load_imm, 0);
- _s3SetBlank (s3, s3vga, FALSE);
-}
-
Bool
s3CardInit (KdCardInfo *card)
{
@@ -199,6 +53,7 @@ s3CardInit (KdCardInfo *card)
VGA32 save_linear_window_size;
VGA32 save_enable_linear;
VGA32 save_register_lock_2;
+ VGA32 save_misc_output;
s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo));
if (!s3c)
@@ -210,7 +65,13 @@ s3CardInit (KdCardInfo *card)
card->driver = s3c;
- if (card->attr.naddr > 1)
+#ifdef VXWORKS
+ s3c->bios_initialized = 0;
+#else
+ s3c->bios_initialized = 1;
+#endif
+
+ if (card->attr.naddr > 1 && card->attr.address[1])
{
s3FrameBuffer = card->attr.address[1];
s3Registers = card->attr.address[0];
@@ -240,6 +101,21 @@ s3CardInit (KdCardInfo *card)
s3vga = &s3c->s3vga;
s3RegInit (s3vga, (VGAVOL8 *) (registers + IOMAP_OFFSET));
+ if (!s3c->bios_initialized)
+ {
+ volatile CARD32 *wakeup;
+
+ wakeup = (volatile CARD32 *) (registers + 0x8510);
+ ErrorF ("Wakeup S3 chip at 0x%x\n", wakeup);
+ ErrorF ("Wakeup was 0x%x\n", *wakeup);
+ /* wakeup the chip */
+ *(volatile CARD32 *) (registers + 0x8510) = 1;
+ ErrorF ("Wakeup is 0x%x\n", *wakeup);
+ }
+ s3Set (s3vga, s3_io_addr_select, 1);
+ s3Set (s3vga, s3_enable_ram, 1);
+ VgaFlush (&s3vga->card);
+
save_register_lock_2 = s3Get (s3vga, s3_register_lock_2);
s3SetImm (s3vga, s3_register_lock_2, 0xa0);
save_linear_window_size = s3Get (s3vga, s3_linear_window_size);
@@ -292,20 +168,71 @@ bail0:
}
Bool
+s3ModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
+{
+ /* make sure the clock isn't too fast */
+ if (t->clock > S3_MAX_CLOCK * 2)
+ return FALSE;
+ /* width must be a multiple of 16 */
+ if (t->horizontal & 0xf)
+ return FALSE;
+ return TRUE;
+}
+
+Bool
+s3ModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ S3CardInfo *s3c = (S3CardInfo *) card->driver;
+ int screen_size;
+ int pixel_width;
+ int byte_width;
+
+ if (screen->depth >= 24)
+ {
+ screen->depth = 24;
+ screen->bitsPerPixel = 32;
+ }
+ else if (screen->depth >= 16)
+ {
+ screen->depth = 16;
+ screen->bitsPerPixel = 16;
+ }
+ else if (screen->depth >= 15)
+ {
+ screen->depth = 15;
+ screen->bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->depth = 8;
+ screen->bitsPerPixel = 8;
+ }
+
+ byte_width = screen->width * (screen->bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->pixelStride = pixel_width;
+ screen->byteStride = byte_width;
+
+ screen_size = byte_width * screen->height;
+
+ return screen_size <= s3c->memory;
+}
+
+Bool
s3ScreenInit (KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
S3CardInfo *s3c = (S3CardInfo *) card->driver;
S3ScreenInfo *s3s;
- int screen_size;
int memory;
int requested_memory;
int v_total, h_total;
- int byte_width;
- int pixel_width;
int m, n, r;
int i;
- S3Timing *t;
+ const KdMonitorTiming *t;
+ int screen_size;
s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo));
if (!s3s)
@@ -313,6 +240,12 @@ s3ScreenInit (KdScreenInfo *screen)
memset (s3s, '\0', sizeof (S3ScreenInfo));
+#ifdef PHOENIX
+ screen->width = 1152;
+ screen->height = 900;
+ screen->rate = 85;
+ screen->depth = 32;
+#endif
if (!screen->width || !screen->height)
{
screen->width = 800;
@@ -322,113 +255,29 @@ s3ScreenInit (KdScreenInfo *screen)
if (!screen->depth)
screen->depth = 8;
- for (i = 0, t = s3Timings; i < NUM_S3_TIMINGS; i++, t++)
- {
- if (t->horizontal >= screen->width &&
- t->vertical >= screen->height &&
- (!screen->rate || t->rate <= screen->rate))
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
screen->rate = t->rate;
screen->width = t->horizontal;
screen->height = t->vertical;
- s3GetClock (S3ModeClock(t), &m, &n, &r, 511, 127, 4);
+ s3GetClock (t->clock, &m, &n, &r, 511, 127, 4);
#ifdef DEBUG
- fprintf (stderr, "computed %d,%d,%d (%d) provided %d,%d,%d (%d)\n",
- m, n, r, S3_CLOCK(m,n,r),
- t->dac_m, t->dac_n, t->dac_r,
- S3_CLOCK(t->dac_m, t->dac_n, t->dac_r));
+ fprintf (stderr, "computed %d,%d,%d (%d)\n",
+ m, n, r, S3_CLOCK(m,n,r));
#endif
/*
- * Can only operate in pixel-doubled mode at 8 bits per pixel
+ * Can only operate in pixel-doubled mode at 8 or 16 bits per pixel
*/
if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
screen->depth = 16;
- for (;;)
+ if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported))
{
- if (screen->depth >= 24)
- {
- screen->depth = 24;
- screen->bitsPerPixel = 32;
- }
- else if (screen->depth >= 16)
- {
- screen->depth = 16;
- screen->bitsPerPixel = 16;
- }
- else if (screen->depth >= 15)
- {
- screen->depth = 15;
- screen->bitsPerPixel = 16;
- }
- else
- {
- screen->depth = 8;
- screen->bitsPerPixel = 8;
- }
-
- /* Normalize width to supported values */
-
- if (screen->width >= 1600)
- screen->width = 1600;
- else if (screen->width >= 1280)
- screen->width = 1280;
- else if (screen->width >= 1152)
- screen->width = 1152;
- else if (screen->width >= 1024)
- screen->width = 1024;
- else if (screen->width >= 800)
- screen->width = 800;
- else
- screen->width = 640;
-
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
- pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
-
- screen_size = byte_width * screen->height;
-
- if (screen_size <= s3c->memory)
- break;
-
- /*
- * Fix requested depth and geometry until it works
- */
- if (screen->depth > 16)
- screen->depth = 16;
- else if (screen->depth > 8)
- screen->depth = 8;
- else if (screen->width > 1152)
- {
- screen->width = 1152;
- screen->height = 900;
- }
- else if (screen->width > 1024)
- {
- screen->width = 1024;
- screen->height = 768;
- }
- else if (screen->width > 800)
- {
- screen->width = 800;
- screen->height = 600;
- }
- else if (screen->width > 640)
- {
- screen->width = 640;
- screen->height = 480;
- }
- else
- {
- xfree (s3s);
- return FALSE;
- }
+ xfree (s3s);
+ return FALSE;
}
+ screen_size = screen->byteStride * screen->height;
+
memory = s3c->memory - screen_size;
/*
@@ -451,21 +300,21 @@ s3ScreenInit (KdScreenInfo *screen)
* Use remaining memory for off-screen storage, but only use
* one piece (either right or bottom).
*/
- if (memory >= byte_width * S3_TILE_SIZE)
+ if (memory >= screen->byteStride * S3_TILE_SIZE)
{
s3s->offscreen = s3c->frameBuffer + screen_size;
s3s->offscreen_x = 0;
- s3s->offscreen_y = screen_size / byte_width;
- s3s->offscreen_width = pixel_width;
- s3s->offscreen_height = memory / byte_width;
- memory -= s3s->offscreen_height * byte_width;
+ s3s->offscreen_y = screen_size / screen->byteStride;
+ s3s->offscreen_width = screen->pixelStride;
+ s3s->offscreen_height = memory / screen->byteStride;
+ memory -= s3s->offscreen_height * screen->byteStride;
}
- else if (pixel_width - screen->width >= S3_TILE_SIZE)
+ else if (screen->pixelStride - screen->width >= S3_TILE_SIZE)
{
s3s->offscreen = s3c->frameBuffer + screen->width;
s3s->offscreen_x = screen->width;
s3s->offscreen_y = 0;
- s3s->offscreen_width = pixel_width - screen->width;
+ s3s->offscreen_width = screen->pixelStride - screen->width;
s3s->offscreen_height = screen->height;
}
else
@@ -508,6 +357,461 @@ s3ScreenInit (KdScreenInfo *screen)
return TRUE;
}
+typedef struct _biosInit {
+ VGA16 reg;
+ VGA8 value;
+} s3BiosInit;
+
+s3BiosInit s3BiosReg[] = {
+ S3_SR +0x15, 0x23,
+ S3_MISC_OUT, 0x2f,
+ 0xffff, 1,
+ S3_SR +0x15, 0x03,
+
+ S3_SR + 0x0, 0x03,
+ S3_SR + 0x1, 0x00,
+ S3_SR + 0x2, 0x03,
+ S3_SR + 0x3, 0x00,
+ S3_SR + 0x4, 0x02,
+ S3_SR + 0x5, 0x05,
+ S3_SR + 0x6, 0x06,
+ S3_SR + 0x7, 0x07,
+/* S3_SR + 0x8, 0x06, */
+ S3_SR + 0x9, 0x00,
+ S3_SR + 0xa, 0x0a,
+ S3_SR + 0xb, 0x00,
+ S3_SR + 0xc, 0x0c,
+ S3_SR + 0xd, 0x00,
+ S3_SR + 0xe, 0x0e,
+ S3_SR + 0xf, 0x0f,
+
+/* S3_SR +0x10, 0x00, */
+/* S3_SR +0x11, 0x0c, */
+ S3_SR +0x12, 0x01,
+ S3_SR +0x13, 0x52,
+ S3_SR +0x14, 0x00,
+
+/* S3_SR +0x15, 0x03, */
+
+ S3_SR +0x16, 0xc5,
+ S3_SR +0x17, 0xfc,
+ S3_SR +0x18, 0x40,
+ S3_SR +0x19, 0x00,
+ S3_SR +0x1a, 0x01,
+ S3_SR +0x1b, 0x02,
+ S3_SR +0x1c, 0x5d,
+ S3_SR +0x1d, 0x00,
+ S3_SR +0x1e, 0x00,
+ S3_SR +0x1f, 0x00,
+ S3_SR +0x20, 0x20,
+ S3_SR +0x21, 0x21,
+ S3_SR +0x22, 0x22,
+ S3_SR +0x23, 0x23,
+ S3_SR +0x24, 0x24,
+ S3_SR +0x25, 0x25,
+ S3_SR +0x26, 0x26,
+ S3_SR +0x27, 0x04,
+ S3_SR +0x28, 0xff,
+ S3_SR +0x29, 0x00,
+ S3_SR +0x2a, 0x2a,
+ S3_SR +0x2b, 0x2b,
+ S3_SR +0x2c, 0x2c,
+ S3_SR +0x2d, 0x2d,
+ S3_SR +0x2e, 0x2e,
+ S3_SR +0x2f, 0x2f,
+ S3_SR +0x30, 0x00,
+ S3_SR +0x31, 0x06,
+ S3_SR +0x32, 0x41,
+ S3_SR +0x33, 0x67,
+ S3_SR +0x34, 0x00,
+ S3_SR +0x35, 0x00,
+ S3_SR +0x36, 0x01,
+ S3_SR +0x37, 0x52,
+ S3_SR +0x38, 0x5d,
+ S3_SR +0x39, 0x05,
+ S3_SR +0x3a, 0x3a,
+ S3_SR +0x3b, 0x3b,
+ S3_SR +0x3c, 0x3c,
+ S3_SR +0x3d, 0x00,
+ S3_SR +0x3e, 0x3e,
+ S3_SR +0x3f, 0x00,
+ S3_SR +0x40, 0x40,
+ S3_SR +0x41, 0x41,
+ S3_SR +0x42, 0x42,
+ S3_SR +0x43, 0x43,
+ S3_SR +0x44, 0x44,
+ S3_SR +0x45, 0x45,
+ S3_SR +0x46, 0x46,
+ S3_SR +0x47, 0x47,
+ S3_SR +0x48, 0x48,
+ S3_SR +0x49, 0x49,
+ S3_SR +0x4a, 0x4a,
+ S3_SR +0x4b, 0x4b,
+ S3_SR +0x4c, 0x4c,
+ S3_SR +0x4d, 0x4d,
+ S3_SR +0x4e, 0x4e,
+ S3_SR +0x4f, 0x4f,
+ S3_SR +0x50, 0x00,
+ S3_SR +0x51, 0x00,
+ S3_SR +0x52, 0x00,
+ S3_SR +0x53, 0x00,
+ S3_SR +0x54, 0x00,
+ S3_SR +0x55, 0x00,
+ S3_SR +0x56, 0x00,
+ S3_SR +0x57, 0x00,
+ S3_SR +0x58, 0x00,
+ S3_SR +0x59, 0x70,
+ S3_SR +0x5a, 0x38,
+ S3_SR +0x5b, 0x08,
+ S3_SR +0x5c, 0x77,
+ S3_SR +0x5d, 0x77,
+ S3_SR +0x5e, 0x00,
+ S3_SR +0x5f, 0x00,
+ S3_SR +0x60, 0xff,
+ S3_SR +0x61, 0xbf,
+ S3_SR +0x62, 0xff,
+ S3_SR +0x63, 0xff,
+ S3_SR +0x64, 0xf7,
+ S3_SR +0x65, 0xff,
+ S3_SR +0x66, 0xff,
+ S3_SR +0x67, 0xff,
+ S3_SR +0x68, 0xff,
+ S3_SR +0x69, 0xff,
+ S3_SR +0x6a, 0xff,
+ S3_SR +0x6b, 0xff,
+ S3_SR +0x6c, 0xff,
+ S3_SR +0x6d, 0xff,
+ S3_SR +0x6e, 0x9b,
+ S3_SR +0x6f, 0xbf,
+
+ S3_AR + 0x00, 0x00,
+ S3_AR + 0x01, 0x01,
+ S3_AR + 0x02, 0x02,
+ S3_AR + 0x03, 0x03,
+ S3_AR + 0x04, 0x04,
+ S3_AR + 0x05, 0x05,
+ S3_AR + 0x06, 0x06,
+ S3_AR + 0x07, 0x07,
+ S3_AR + 0x08, 0x08,
+ S3_AR + 0x09, 0x09,
+ S3_AR + 0x0a, 0x0a,
+ S3_AR + 0x0b, 0x0b,
+ S3_AR + 0x0c, 0x0c,
+ S3_AR + 0x0d, 0x0d,
+ S3_AR + 0x0e, 0x0e,
+ S3_AR + 0x0f, 0x0f,
+ S3_AR + 0x10, 0x05,
+ S3_AR + 0x11, 0x00,
+ S3_AR + 0x12, 0x0f,
+ S3_AR + 0x13, 0x08,
+ S3_AR + 0x14, 0x00,
+
+ S3_GR + 0x00, 0x00,
+ S3_GR + 0x01, 0x00,
+ S3_GR + 0x02, 0x00,
+ S3_GR + 0x03, 0x00,
+ S3_GR + 0x04, 0x00,
+ S3_GR + 0x05, 0x10,
+ S3_GR + 0x06, 0x0e,
+ S3_GR + 0x07, 0x00,
+
+ S3_CR + 0x00, 0x5f,
+ S3_CR + 0x01, 0x4f,
+ S3_CR + 0x02, 0x50,
+ S3_CR + 0x03, 0x82,
+ S3_CR + 0x04, 0x55,
+ S3_CR + 0x05, 0x81,
+ S3_CR + 0x06, 0xbf,
+ S3_CR + 0x07, 0x1f,
+ S3_CR + 0x08, 0x00,
+ S3_CR + 0x09, 0x4f,
+ S3_CR + 0x0a, 0x0d,
+ S3_CR + 0x0b, 0x0e,
+ S3_CR + 0x0c, 0x00,
+ S3_CR + 0x0d, 0x00,
+ S3_CR + 0x0e, 0x3f,
+ S3_CR + 0x0f, 0xff,
+ S3_CR + 0x10, 0x9c,
+ S3_CR + 0x11, 0x0e,
+ S3_CR + 0x12, 0x8f,
+ S3_CR + 0x13, 0x28,
+ S3_CR + 0x14, 0x1f,
+ S3_CR + 0x15, 0x96,
+ S3_CR + 0x16, 0xb9,
+ S3_CR + 0x17, 0xa3,
+ S3_CR + 0x18, 0xff,
+ S3_CR + 0x19, 0xdf,
+ S3_CR + 0x1a, 0xdf,
+ S3_CR + 0x1b, 0xdf,
+ S3_CR + 0x1c, 0xdf,
+ S3_CR + 0x1d, 0xdf,
+ S3_CR + 0x1e, 0xdf,
+ S3_CR + 0x1f, 0xdf,
+ S3_CR + 0x20, 0xdf,
+ S3_CR + 0x21, 0x00,
+/* S3_CR + 0x22, 0x07, */
+ S3_CR + 0x23, 0x00,
+ S3_CR + 0x24, 0xdf,
+ S3_CR + 0x25, 0xdf,
+ S3_CR + 0x26, 0x00,
+ S3_CR + 0x27, 0xdf,
+ S3_CR + 0x28, 0xdf,
+ S3_CR + 0x29, 0xdf,
+ S3_CR + 0x2a, 0xdf,
+ S3_CR + 0x2b, 0xdf,
+ S3_CR + 0x2c, 0xdf,
+ S3_CR + 0x2d, 0x8a,
+ S3_CR + 0x2e, 0x22,
+ S3_CR + 0x2f, 0x02,
+ S3_CR + 0x30, 0xe1,
+ S3_CR + 0x31, 0x05,
+ S3_CR + 0x32, 0x40,
+ S3_CR + 0x33, 0x08,
+ S3_CR + 0x34, 0x00,
+ S3_CR + 0x35, 0x00,
+ S3_CR + 0x36, 0xbf,
+ S3_CR + 0x37, 0x9b,
+/* S3_CR + 0x38, 0x7b, */
+/* S3_CR + 0x39, 0xb8, */
+ S3_CR + 0x3a, 0x45,
+ S3_CR + 0x3b, 0x5a,
+ S3_CR + 0x3c, 0x10,
+ S3_CR + 0x3d, 0x00,
+ S3_CR + 0x3e, 0xfd,
+ S3_CR + 0x3f, 0x00,
+ S3_CR + 0x40, 0x00,
+ S3_CR + 0x41, 0x92,
+ S3_CR + 0x42, 0xc0,
+ S3_CR + 0x43, 0x68,
+ S3_CR + 0x44, 0xff,
+ S3_CR + 0x45, 0xe8,
+ S3_CR + 0x46, 0xff,
+ S3_CR + 0x47, 0xff,
+ S3_CR + 0x48, 0xf8,
+ S3_CR + 0x49, 0xff,
+ S3_CR + 0x4a, 0xfe,
+ S3_CR + 0x4b, 0xff,
+ S3_CR + 0x4c, 0xff,
+ S3_CR + 0x4d, 0xff,
+ S3_CR + 0x4e, 0xff,
+ S3_CR + 0x4f, 0xff,
+ S3_CR + 0x50, 0x00,
+ S3_CR + 0x51, 0x00,
+ S3_CR + 0x52, 0x00,
+ S3_CR + 0x53, 0x00,
+ S3_CR + 0x54, 0x00,
+ S3_CR + 0x55, 0x00,
+ S3_CR + 0x56, 0x00,
+ S3_CR + 0x57, 0x00,
+#if 0
+ S3_CR + 0x58, 0x00,
+ S3_CR + 0x59, 0xf0,
+#endif
+ S3_CR + 0x5a, 0x00,
+ S3_CR + 0x5b, 0x00,
+#if 0
+ S3_CR + 0x5c, 0x00,
+#endif
+ S3_CR + 0x5d, 0x00,
+ S3_CR + 0x5e, 0x00,
+ S3_CR + 0x5f, 0x00,
+ S3_CR + 0x60, 0x09,
+ S3_CR + 0x61, 0x9d,
+ S3_CR + 0x62, 0xff,
+ S3_CR + 0x63, 0x00,
+ S3_CR + 0x64, 0xfd,
+ S3_CR + 0x65, 0x04,
+ S3_CR + 0x66, 0x88,
+ S3_CR + 0x67, 0x00,
+ S3_CR + 0x68, 0x7f,
+ S3_CR + 0x69, 0x00,
+ S3_CR + 0x6a, 0x00,
+ S3_CR + 0x6b, 0x00,
+ S3_CR + 0x6c, 0x00,
+ S3_CR + 0x6d, 0x11,
+ S3_CR + 0x6e, 0xff,
+ S3_CR + 0x6f, 0xfe,
+
+ S3_CR + 0x70, 0x30,
+ S3_CR + 0x71, 0xc0,
+ S3_CR + 0x72, 0x07,
+ S3_CR + 0x73, 0x1f,
+ S3_CR + 0x74, 0x1f,
+ S3_CR + 0x75, 0x1f,
+ S3_CR + 0x76, 0x0f,
+ S3_CR + 0x77, 0x1f,
+ S3_CR + 0x78, 0x01,
+ S3_CR + 0x79, 0x01,
+ S3_CR + 0x7a, 0x1f,
+ S3_CR + 0x7b, 0x1f,
+ S3_CR + 0x7c, 0x17,
+ S3_CR + 0x7d, 0x17,
+ S3_CR + 0x7e, 0x17,
+ S3_CR + 0x7f, 0xfd,
+ S3_CR + 0x80, 0x00,
+ S3_CR + 0x81, 0x92,
+ S3_CR + 0x82, 0x10,
+ S3_CR + 0x83, 0x07,
+ S3_CR + 0x84, 0x42,
+ S3_CR + 0x85, 0x00,
+ S3_CR + 0x86, 0x00,
+ S3_CR + 0x87, 0x00,
+ S3_CR + 0x88, 0x10,
+ S3_CR + 0x89, 0xfd,
+ S3_CR + 0x8a, 0xfd,
+ S3_CR + 0x8b, 0xfd,
+ S3_CR + 0x8c, 0xfd,
+ S3_CR + 0x8d, 0xfd,
+ S3_CR + 0x8e, 0xfd,
+ S3_CR + 0x8f, 0xfd,
+ S3_CR + 0x90, 0x00,
+ S3_CR + 0x91, 0x4f,
+ S3_CR + 0x92, 0x10,
+ S3_CR + 0x93, 0x00,
+ S3_CR + 0x94, 0xfd,
+ S3_CR + 0x95, 0xfd,
+ S3_CR + 0x96, 0xfd,
+ S3_CR + 0x97, 0xfd,
+ S3_CR + 0x98, 0xfd,
+ S3_CR + 0x99, 0xff,
+ S3_CR + 0x9a, 0xfd,
+ S3_CR + 0x9b, 0xff,
+ S3_CR + 0x9c, 0xfd,
+ S3_CR + 0x9d, 0xfd,
+ S3_CR + 0x9e, 0xfd,
+ S3_CR + 0x9f, 0xff,
+ S3_CR + 0xa0, 0x0f,
+#if 0
+ S3_CR + 0xa1, 0x00,
+ S3_CR + 0xa2, 0x00,
+ S3_CR + 0xa3, 0x00,
+ S3_CR + 0xa4, 0x55,
+#endif
+ S3_CR + 0xa5, 0x09,
+ S3_CR + 0xa6, 0x20,
+#if 0
+ S3_CR + 0xa7, 0x00,
+ S3_CR + 0xa8, 0x00,
+ S3_CR + 0xa9, 0x00,
+ S3_CR + 0xaa, 0x00,
+ S3_CR + 0xab, 0x00,
+ S3_CR + 0xac, 0x00,
+ S3_CR + 0xad, 0x00,
+ S3_CR + 0xae, 0x00,
+ S3_CR + 0xaf, 0x00,
+ S3_CR + 0xb0, 0xff,
+#endif
+ S3_CR + 0xb1, 0x0e,
+#if 0
+ S3_CR + 0xb2, 0x55,
+ S3_CR + 0xb3, 0x00,
+ S3_CR + 0xb4, 0x55,
+ S3_CR + 0xb5, 0x00,
+ S3_CR + 0xb6, 0x00,
+#endif
+ S3_CR + 0xb7, 0x84,
+#if 0
+ S3_CR + 0xb8, 0xff,
+ S3_CR + 0xb9, 0xff,
+ S3_CR + 0xba, 0xff,
+ S3_CR + 0xbb, 0xff,
+ S3_CR + 0xbc, 0xff,
+ S3_CR + 0xbd, 0xff,
+ S3_CR + 0xbe, 0xff,
+ S3_CR + 0xbf, 0xff,
+#endif
+
+ S3_SR +0x15, 0x23,
+ 0xffff, 1,
+ S3_SR +0x15, 0x03,
+ 0xffff, 1,
+};
+
+#define S3_NUM_BIOS_REG (sizeof (s3BiosReg) / sizeof (s3BiosReg[0]))
+
+typedef struct _bios32Init {
+ VGA16 offset;
+ VGA32 value;
+} s3Bios32Init;
+
+s3Bios32Init s3Bios32Reg[] = {
+ 0x8168, 0x00000000,
+ 0x816c, 0x00000001,
+ 0x8170, 0x00000000,
+ 0x8174, 0x00000000,
+ 0x8178, 0x00000000,
+ 0x817c, 0x00000000,
+#if 0
+ 0x8180, 0x00140000,
+ 0x8184, 0x00000000,
+ 0x8188, 0x00000000,
+ 0x8190, 0x00000000,
+ 0x8194, 0x00000000,
+ 0x8198, 0x00000000,
+ 0x819c, 0x00000000,
+ 0x81a0, 0x00000000,
+#endif
+ 0x81c0, 0x00000000,
+ 0x81c4, 0x01fbffff,
+ 0x81c8, 0x00f7ffbf,
+ 0x81cc, 0x00f7ff00,
+ 0x81d0, 0x11ffff7f,
+ 0x81d4, 0x7fffffdf,
+ 0x81d8, 0xfdfff9ff,
+ 0x81e0, 0xfd000000,
+ 0x81e4, 0x00000000,
+ 0x81e8, 0x00000000,
+ 0x81ec, 0x00010000,
+ 0x81f0, 0x07ff057f,
+ 0x81f4, 0x07ff07ff,
+ 0x81f8, 0x00000000,
+ 0x81fc, 0x00000000,
+ 0x8200, 0x00000000,
+ 0x8204, 0x00000000,
+ 0x8208, 0x33000000,
+ 0x820c, 0x7f000000,
+ 0x8210, 0x80000000,
+ 0x8214, 0x00000000,
+ 0x8218, 0xffffffff,
+ 0x8300, 0xff007fef,
+ 0x8304, 0xfffdf7bf,
+ 0x8308, 0xfdfffbff,
+};
+
+#define S3_NUM_BIOS32_REG (sizeof (s3Bios32Reg) / sizeof (s3Bios32Reg[0]))
+
+/*
+ * Initialize the card precisely as the bios does
+ */
+s3DoBiosInit (KdCardInfo *card)
+{
+ S3CardInfo *s3c = card->driver;
+ CARD32 *regs = (CARD32 *) s3c->registers;
+ S3Vga *s3vga = &s3c->s3vga;
+ int r;
+
+ for (r = 0; r < S3_NUM_BIOS_REG; r++)
+ {
+ if (s3BiosReg[r].reg == 0xffff)
+ sleep (s3BiosReg[r].value);
+ else
+ VgaStore (&s3vga->card, s3BiosReg[r].reg, s3BiosReg[r].value);
+ }
+ VgaStore (&s3vga->card, S3_SR+0x10, 0x22);
+ VgaStore (&s3vga->card, S3_SR+0x11, 0x44);
+ VgaStore (&s3vga->card, S3_SR+0x15, 0x01);
+ sleep (1);
+ VgaStore (&s3vga->card, S3_SR+0x15, 0x03);
+ VgaStore (&s3vga->card, S3_CR+0x6f, 0xff);
+ VgaStore (&s3vga->card, S3_CR+0x3f, 0x3f);
+ sleep (1);
+ VgaStore (&s3vga->card, S3_CR+0x3f, 0x00);
+ VgaStore (&s3vga->card, S3_CR+0x6f, 0xfe);
+ VgaInvalidate (&s3vga->card);
+ for (r = 0; r < S3_NUM_BIOS32_REG; r++)
+ regs[s3Bios32Reg[r].offset/4] = s3Bios32Reg[r].value;
+}
+
void
s3Preserve (KdCardInfo *card)
{
@@ -519,6 +823,9 @@ s3Preserve (KdCardInfo *card)
CARD8 *cursor_base;
s3Save (s3vga);
+ if (!s3c->bios_initialized)
+ s3DoBiosInit (card);
+
_s3SetBlank (s3, s3vga, TRUE);
/*
* Preserve the first part of the frame buffer which holds
@@ -535,6 +842,9 @@ s3Preserve (KdCardInfo *card)
save->write_mask = s3->write_mask;
save->fg = s3->fg;
save->bg = s3->bg;
+ save->global_bitmap_1 = s3->global_bitmap_1;
+ save->global_bitmap_2 = s3->global_bitmap_2;
+ save->primary_bitmap_1 = s3->primary_bitmap_1;
_s3SetBlank (s3, s3vga, FALSE);
}
@@ -542,6 +852,8 @@ s3Preserve (KdCardInfo *card)
* Enable the card for rendering. Manipulate the initial settings
* of the card here.
*/
+int s3CpuTimeout, s3AccelTimeout;
+
void
s3Enable (ScreenPtr pScreen)
{
@@ -552,6 +864,7 @@ s3Enable (ScreenPtr pScreen)
s3ScreenInfo (pScreenPriv);
S3Vga *s3vga = &s3c->s3vga;
+ S3Ptr s3 = s3c->s3;
int hactive, hblank, hfp, hbp;
int vactive, vblank, vfp, vbp;
int hsize;
@@ -580,21 +893,14 @@ s3Enable (ScreenPtr pScreen)
int h_blank_extend;
int i;
CARD16 cursor_address;
- S3Timing *t;
+ const KdMonitorTiming *t;
int m, n, r;
Bool clock_double;
+ int cpu_timeout;
+ int accel_timeout;
+ int bytes_per_ms;
- for (i = 0; i < NUM_S3_TIMINGS; i++)
- {
- t = &s3Timings[i];
-
- if (t->horizontal == screen->width &&
- t->vertical == screen->height &&
- t->rate <= screen->rate)
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
hfp = t->hfp;
hbp = t->hbp;
@@ -613,7 +919,7 @@ s3Enable (ScreenPtr pScreen)
fprintf (stderr, "old clock %d, %d, %d\n", m, n, r);
#endif
clock_double = FALSE;
- s3GetClock (S3ModeClock(t), &m, &n, &r, 511, 127, 4);
+ s3GetClock (t->clock, &m, &n, &r, 511, 127, 4);
if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
clock_double = TRUE;
s3Set (s3vga, s3_clock_select, 3);
@@ -621,7 +927,7 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_dclk_n, n);
s3Set (s3vga, s3_dclk_r, r);
#ifdef DEBUG
- fprintf (stderr, "new clock %d, %d, %d\n", m, n, r);
+ fprintf (stderr, "new clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r));
#endif
s3Set (s3vga, s3_select_graphics_mode, 1);
@@ -630,7 +936,13 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_enhanced_memory_mapping, 1);
s3Set (s3vga, s3_enable_sff, 1);
s3Set (s3vga, s3_enable_2d_access, 1);
+ s3Set (s3vga, s3_2bk_cga, 1);
+ s3Set (s3vga, s3_4bk_hga, 1);
+ s3Set (s3vga, s3_v_total_double, 0);
+ s3Set (s3vga, s3_address_16k_wrap, 1);
+ s3Set (s3vga, s3_word_mode, 0);
s3Set (s3vga, s3_byte_mode, 1);
+ s3Set (s3vga, s3_hardware_reset, 1);
s3Set (s3vga, s3_max_scan_line, 0);
s3Set (s3vga, s3_linear_window_size, 3);
s3Set (s3vga, s3_enable_linear, 1);
@@ -639,31 +951,31 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_disable_pci_read_bursts, 0);
s3Set (s3vga, s3_pci_retry_enable, 1);
s3Set (s3vga, s3_enable_256, 1);
-#if 1
- s3Set (s3vga, s3_border_select, 1); /* eliminate white border */
-#else
+/* s3Set (s3vga, s3_border_select, 1); /* eliminate white border */
s3Set (s3vga, s3_border_select, 0); /* eliminate white border */
-#endif
+ s3SetImm (s3vga, s3_lock_palette, 0); /* unlock palette/border regs */
s3Set (s3vga, s3_disable_v_retrace_int, 1);
- s3Set (s3vga, s3_horz_sync_neg, 0);
- s3Set (s3vga, s3_vert_sync_neg, 0);
+ if (t->hpol == KdSyncPositive)
+ s3Set (s3vga, s3_horz_sync_neg, 0);
+ else
+ s3Set (s3vga, s3_horz_sync_neg, 1);
+ if (t->vpol == KdSyncPositive)
+ s3Set (s3vga, s3_vert_sync_neg, 0);
+ else
+ s3Set (s3vga, s3_vert_sync_neg, 1);
s3Set (s3vga, s3_dot_clock_8, 1);
s3Set (s3vga, s3_enable_write_plane, 0xf);
s3Set (s3vga, s3_extended_memory_access, 1);
s3Set (s3vga, s3_sequential_addressing_mode, 1);
s3Set (s3vga, s3_select_chain_4_mode, 1);
-#if 1
s3Set (s3vga, s3_linear_addressing_control, 1);
-#else
- s3Set (s3vga, s3_linear_addressing_control, 0);
-#endif
s3Set (s3vga, s3_enable_8_bit_luts, 1);
s3Set (s3vga, s3_dclk_invert, 0);
s3Set (s3vga, s3_enable_clock_double, 0);
+ s3Set (s3vga, s3_dclk_over_2, 0);
- s3Set (s3vga, s3_cpu_timeout, 0x1f);
s3Set (s3vga, s3_fifo_fetch_timing, 1);
s3Set (s3vga, s3_fifo_drain_delay, 7);
@@ -671,19 +983,27 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_delay_h_enable, 0);
s3Set (s3vga, s3_sdclk_skew, 0);
+ s3Set (s3vga, s3_dac_mask, 0xff);
+
+ s3Set (s3vga, s3_dac_power_saving_disable, 1);
+
+ s3s->manage_border = FALSE;
/*
* Compute character lengths for horizontal timing values
*/
+ hactive = screen->width / 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+ /*
+ * Set pixel size, choose clock doubling mode
+ */
h_blank_start_adjust = 0;
h_blank_end_adjust = 0;
+
switch (screen->bitsPerPixel) {
case 8:
- hactive = screen->width / 8;
- hblank /= 8;
- hfp /= 8;
- hbp /= 8;
h_screen_off = hactive;
- s3Set (s3vga, s3_2d_graphics_engine_timeout, 0x1f);
s3Set (s3vga, s3_pixel_length, 0);
s3Set (s3vga, s3_color_mode, 0);
/*
@@ -696,23 +1016,15 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_dclk_over_2, 1);
s3Set (s3vga, s3_enable_clock_double, 1);
s3Set (s3vga, s3_border_select, 0);
-#if 0
- s3Set (s3vga, s3_delay_blank, 2);
- s3Set (s3vga, s3_delay_h_enable, 2);
- crtc->extended_bios_5 = 2;
-#endif
- h_blank_start_adjust = -1;
- h_blank_end_adjust = 0;
+/* s3Set (s3vga, s3_border_color, pScreen->blackPixel); */
+ h_blank_start_adjust = 4;
+ h_blank_end_adjust = -4;
+ s3s->manage_border = TRUE;
}
break;
case 16:
- hactive = screen->width / 8;
- hblank /= 8;
- hfp /= 8;
- hbp /= 8;
h_screen_off = hactive * 2;
s3Set (s3vga, s3_pixel_length, 1);
- s3Set (s3vga, s3_2d_graphics_engine_timeout, 0x14);
if (clock_double)
{
if (screen->depth == 15)
@@ -722,6 +1034,8 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_dclk_over_2, 1);
s3Set (s3vga, s3_enable_clock_double, 1);
s3Set (s3vga, s3_border_select, 0);
+ h_blank_start_adjust = 4;
+ h_blank_end_adjust = -4;
}
else
{
@@ -735,14 +1049,9 @@ s3Enable (ScreenPtr pScreen)
}
break;
case 32:
- hactive = screen->width / 8;
- hblank /= 8;
- hfp /= 8;
- hbp /= 8;
h_screen_off = hactive * 4;
s3Set (s3vga, s3_pixel_length, 3);
s3Set (s3vga, s3_color_mode, 0xd);
- s3Set (s3vga, s3_2d_graphics_engine_timeout, 0x07);
break;
}
@@ -751,6 +1060,57 @@ s3Enable (ScreenPtr pScreen)
*/
s3Set (s3vga, s3_start_address, 0);
+
+ /*
+ * Set various registers to avoid snow on the screen
+ */
+ bytes_per_ms = t->clock * (screen->bitsPerPixel / 8);
+
+ fprintf (stderr, "bytes_per_ms %d\n", bytes_per_ms);
+ fprintf (stderr, "primary 0x%x master 0x%x command 0x%x lpb 0x%x cpu 0x%x 2d 0x%x\n",
+ s3Get (s3vga, s3_primary_stream_timeout),
+ s3Get (s3vga, s3_master_control_unit_timeout),
+ s3Get (s3vga, s3_command_buffer_timeout),
+ s3Get (s3vga, s3_lpb_timeout),
+ s3Get (s3vga, s3_cpu_timeout),
+ s3Get (s3vga, s3_2d_graphics_engine_timeout));
+
+ /* cpu 2d
+ * 576000
+ * 288000 0x1f 0x19
+
+ */
+ if (s3CpuTimeout)
+ {
+ cpu_timeout = s3CpuTimeout;
+ if (s3AccelTimeout)
+ accel_timeout = s3AccelTimeout;
+ else
+ accel_timeout = s3CpuTimeout;
+ }
+ else if (bytes_per_ms > 400000)
+ {
+ cpu_timeout = 0x10;
+ accel_timeout = 0x7;
+ }
+ else if (bytes_per_ms > 250000)
+ {
+ cpu_timeout = 0x10;
+ accel_timeout = 0x18;
+ }
+ else
+ {
+ cpu_timeout = 0x1f;
+ accel_timeout = 0x1f;
+ }
+
+ s3Set (s3vga, s3_primary_stream_timeout, 0xc0);
+ s3Set (s3vga, s3_master_control_unit_timeout, 0xf);
+ s3Set (s3vga, s3_command_buffer_timeout, 0x1f);
+ s3Set (s3vga, s3_lpb_timeout, 0xf);
+ s3Set (s3vga, s3_2d_graphics_engine_timeout, accel_timeout);
+ s3Set (s3vga, s3_cpu_timeout, cpu_timeout);
+
/*
* Compute horizontal register values from timings
*/
@@ -855,6 +1215,12 @@ s3Enable (ScreenPtr pScreen)
else
s3Set (s3vga, s3_cursor_enable, 0);
+#define MAKE_GBF(bds,be,stride,bpp,tile) (\
+ ((bds) << 0) | \
+ ((be) << 3) | \
+ ((stride) << 4) | \
+ ((bpp) << 16) | \
+ ((tile) << 24))
/*
* Set accelerator
*/
@@ -865,6 +1231,8 @@ s3Enable (ScreenPtr pScreen)
case 1152: s3Set (s3vga, s3_ge_screen_width, 4); break;
case 1280: s3Set (s3vga, s3_ge_screen_width, 3); break;
case 1600: s3Set (s3vga, s3_ge_screen_width, 6); break;
+ default:
+ s3Set (s3vga, s3_ge_screen_width, 7); /* use global bitmap descriptor */
}
#if 0
@@ -877,7 +1245,100 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_hsync_control, 0);
s3Set (s3vga, s3_vsync_control, 0);
- _s3SetDepth (s3c->s3, s3vga);
+ _s3SetBlank (s3, s3vga, TRUE);
+ VgaFlush(&s3vga->card);
+ VgaSetImm (&s3vga->card, s3_clock_load_imm, 1);
+ VgaSetImm(&s3vga->card, s3_clock_load_imm, 0);
+ s3->global_bitmap_1 = 0;
+ s3->global_bitmap_2 = MAKE_GBF (1, /* 64 bit bitmap descriptor size */
+ 0, /* disable BCI */
+ pScreenPriv->screen->pixelStride >> 4,
+ pScreenPriv->screen->bitsPerPixel,
+ 0); /* tile format */
+ _s3SetBlank (s3, s3vga, FALSE);
+#if 1
+ {
+ VGA16 r;
+ static CARD32 streams[][2] = {
+ /* PCI registers */
+ 0x8000, 0x8024,
+ 0x802c, 0x8034,
+ 0x803c, 0x8040,
+#if 0
+ 0x8080, 0x808c, /* AGP */
+#endif
+ 0x80dc, 0x80e0,
+
+ /* 2D registers */
+ 0x8168, 0x8188,
+ 0x8190, 0x81a0,
+ 0x81c0, 0x81d8,
+ 0x81e0, 0x8218,
+ 0x8300, 0x8308,
+ 0x8504, 0x8510,
+
+ /* LPB/VIP registers */
+ 0xff00, 0xff18,
+ 0xff20, 0xff38,
+ 0xff40, 0xff40,
+ 0xff70, 0xff78,
+ 0xff8c, 0xffa0,
+
+#if 0
+ /* 3D registers */
+ 0x48508, 0x48508,
+ 0x48528, 0x48528,
+ 0x48548, 0x48548,
+ 0x48584, 0x485f0,
+#endif
+
+ /* motion compensation registers */
+ 0x48900, 0x48924,
+#if 0
+ 0x48928, 0x48928,
+#endif
+
+ /* Mastered data transfer registers */
+ 0x48a00, 0x48a1c,
+
+ /* configuation/status registers */
+ 0x48c00, 0x48c18,
+ 0x48c20, 0x48c24,
+ 0x48c40, 0x48c50,
+ 0x48c60, 0x48c64,
+
+ 0, 0,
+ };
+#ifdef PHOENIX
+#undef stderr
+#define stderr stdout
+#endif
+ CARD32 *regs = (CARD32 *) s3c->registers;
+ int i;
+ CARD32 reg;
+
+
+ for (r = S3_SR + 0; r < S3_SR + S3_NSR; r++)
+ fprintf (stderr, "SR%02x = %02x\n", r-S3_SR, VgaFetch (&s3vga->card, r));
+ for (r = S3_GR + 0; r < S3_GR + S3_NGR; r++)
+ fprintf (stderr, "GR%02x = %02x\n", r-S3_GR, VgaFetch (&s3vga->card, r));
+ for (r = S3_AR + 0; r < S3_AR + S3_NAR; r++)
+ fprintf (stderr, "AR%02x = %02x\n", r-S3_AR, VgaFetch (&s3vga->card, r));
+ for (r = S3_CR + 0; r < S3_CR + S3_NCR; r++)
+ fprintf (stderr, "CR%02x = %02x\n", r-S3_CR, VgaFetch (&s3vga->card, r));
+ for (r = S3_DAC + 0; r < S3_DAC + S3_NDAC; r++)
+ fprintf (stderr, "DAC%02x = %02x\n", r-S3_DAC, VgaFetch (&s3vga->card, r));
+ fprintf (stderr, "MISC_OUT = %02x\n", VgaFetch (&s3vga->card, S3_MISC_OUT));
+ fprintf (stderr, "INPUT_STATUS = %02x\n", VgaFetch (&s3vga->card, S3_INPUT_STATUS_1));
+
+
+ for (i = 0; streams[i][0]; i++)
+ {
+ for (reg = streams[i][0]; reg <= streams[i][1]; reg += 4)
+ fprintf (stderr, "0x%4x: 0x%08x\n", reg, regs[reg/4]);
+ }
+ }
+#endif
}
void
@@ -895,6 +1356,8 @@ s3Restore (KdCardInfo *card)
CARD8 *cursor_base;
/* graphics engine state */
+ s3->global_bitmap_1 = save->global_bitmap_1;
+ s3->global_bitmap_2 = save->global_bitmap_2;
s3->alt_mix = save->alt_mix;
s3->write_mask = save->write_mask;
s3->fg = save->fg;
@@ -976,6 +1439,7 @@ s3CardFini (KdCardInfo *card)
KdCardFuncs s3Funcs = {
s3CardInit,
s3ScreenInit,
+ 0,
s3Preserve,
s3Enable,
s3DPMS,
@@ -990,6 +1454,7 @@ KdCardFuncs s3Funcs = {
s3RecolorCursor,
s3DrawInit,
s3DrawEnable,
+ s3DrawSync,
s3DrawDisable,
s3DrawFini,
s3GetColors,
diff --git a/hw/kdrive/savage/s3.h b/hw/kdrive/savage/s3.h
index 95a8edddd..2c07210b1 100644
--- a/hw/kdrive/savage/s3.h
+++ b/hw/kdrive/savage/s3.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.1 1999/11/19 13:53:55 hohndel Exp $ */
#ifndef _S3_H_
#define _S3_H_
@@ -30,8 +30,6 @@
#include "kdrive.h"
#include "s3reg.h"
-#define PLATFORM 300
-
/* VESA Approved Register Definitions */
/*
@@ -74,14 +72,42 @@ typedef volatile struct _s3 {
VOL32 alt_mix; /* 8134 */
VOL32 scissors_tl; /* 8138 */
VOL32 scissors_br; /* 813c */
+#if 0
VOL16 pix_cntl; /* 8140 */
VOL16 mult_misc2; /* 8142 */
+#else
+ VOL32 pix_cntl_mult_misc2; /* 8140 */
+#endif
VOL32 mult_misc_read_sel; /* 8144 */
VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */
- VOL8 _pad3[0x19c]; /* 814c */
+ VOL8 _pad3a[0x1c]; /* 814c */
+ VOL32 global_bitmap_1; /* 8168 */
+ VOL32 global_bitmap_2; /* 816c */
+ VOL32 primary_bitmap_1; /* 8170 */
+ VOL32 primary_bitmap_2; /* 8174 */
+ VOL32 secondary_bitmap_1; /* 8178 */
+ VOL32 secondary_bitmap_2; /* 817c */
+ VOL32 primary_stream_control; /* 8180 */
+ VOL32 chroma_key_control; /* 8184 */
+ VOL32 genlocking_control; /* 8188 */
+ VOL8 _pad3b[0x4]; /* 818c */
+ VOL32 secondary_stream_control; /* 8190 */
+ VOL32 chroma_key_upper_bound; /* 8194 */
+ VOL32 secondary_stream_h_scale; /* 8198 */
+ VOL32 color_adjustment; /* 819c */
+ VOL32 blend_control; /* 81a0 */
+ VOL8 _pad3c[0x1c]; /* 81a4 */
+ VOL32 primary_stream_addr_0; /* 81c0 */
+ VOL8 _pad3d[0x124]; /* 81c4 */
+#if 0
VOL16 cur_y; /* 82e8 */
VOL8 _pad4[0xc6]; /* 82ea */
+#else
+ VOL32 cur_y; /* 82e8 */
+ VOL8 _pad4[0xc4]; /* 82ec */
+#endif
+#if 0
VOL8 crt_vga_3b0; /* 83b0 */
VOL8 crt_vga_3b1; /* 83b1 */
VOL8 crt_vga_3b2; /* 83b2 */
@@ -136,6 +162,8 @@ typedef volatile struct _s3 {
VOL8 _pad5[0x124]; /* 83e0 */
VOL16 subsys_status; /* 8504 */
VOL8 _pad6[0x6]; /* 8506 */
+ VOL32 subsys_status; /* 8504 */
+ VOL8 _pad6[0x4]; /* 8508 */
VOL16 adv_control; /* 850c */
VOL8 _pad7[0x1da]; /* 850e */
VOL16 cur_x; /* 86e8 */
@@ -168,10 +196,14 @@ typedef volatile struct _s3 {
VOL8 _pad21[0x3fe]; /* baea */
VOL16 enh_rd_reg_dt; /* bee8 */
VOL8 _pad22[0x23fe]; /* beea */
+#else
+ VOL8 _pad_reg[0x5f38]; /* 83b0 */
+#endif
VOL32 pix_trans; /* e2e8 */
VOL8 _pad23[0x3a974]; /* e2ec */
VOL32 alt_status_0; /* 48c60 */
+ VOL32 alt_status_1; /* 48c64 */
} S3, *S3Ptr;
#define VGA_STATUS_1_DTM 0x01
@@ -221,6 +253,7 @@ typedef volatile struct _s3 {
#define PATTERN_L 0x8000
#define PATTERN_H 0x9000
#define PIX_CNTL 0xa000
+#define CONTROL_MISC2 0xd000
#define PIX_TRANS 0xe2e8
/* Advanced Function Control Regsiter */
@@ -339,8 +372,8 @@ typedef volatile struct _s3 {
#define S3_SAVAGE4_SLOTS 0x0001ffff
#define S3_SAVAGE4_2DI 0x00800000
-#define _s3WaitLoop(mask,value){ \
- int __loop = 100000; \
+#define _s3WaitLoop(s3,mask,value){ \
+ int __loop = 1000000; \
while (((s3)->alt_status_0 & (mask)) != (value)) \
if (--__loop == 0) { \
ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \
@@ -348,11 +381,21 @@ typedef volatile struct _s3 {
} \
}
-#define _s3WaitSlot(s3) _s3WaitLoop(0x1, 0x0)
-#define _s3WaitEmpty(s3) _s3WaitLoop(S3_SAVAGE4_SLOTS, 0)
-#define _s3WaitIdleEmpty(s3) _s3WaitLoop(S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, \
+#define S3_SAVAGE4_ROOM 10
+
+#define _s3WaitSlots(s3,n) { \
+ int __loop = 1000000; \
+ while (((s3)->alt_status_0 & S3_SAVAGE4_SLOTS) >= S3_SAVAGE4_ROOM-(n)) \
+ if (--__loop == 0) { \
+ ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \
+ break; \
+ } \
+}
+
+#define _s3WaitEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS, 0)
+#define _s3WaitIdleEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, \
S3_SAVAGE4_2DI)
-#define _s3WaitIdle(s3) _s3WaitLoop(S3_SAVAGE4_2DI, S3_SAVAGE4_2DI)
+#define _s3WaitIdle(s3) _s3WaitLoop(s3,S3_SAVAGE4_2DI, S3_SAVAGE4_2DI)
typedef struct _s3Cursor {
int width, height;
@@ -376,14 +419,9 @@ typedef struct _s3Patterns {
#define S3_CLOCK_REF 14318 /* KHz */
-#define S3_CLOCK(m,n,r) (S3_CLOCK_REF * ((m) + 2) / (((n) + 2) * (1 << (r))))
+#define S3_CLOCK(m,n,r) ((S3_CLOCK_REF * ((m) + 2)) / (((n) + 2) * (1 << (r))))
-#if PLATFORM == 200
-#define S3_MAX_CLOCK 80000 /* KHz */
-#endif
-#if PLATFORM == 300
-#define S3_MAX_CLOCK 135000 /* KHz */
-#endif
+#define S3_MAX_CLOCK 150000 /* KHz */
typedef struct _s3Timing {
/* label */
@@ -417,6 +455,10 @@ typedef struct _s3Save {
CARD32 write_mask;
CARD32 fg;
CARD32 bg;
+ CARD32 global_bitmap_1;
+ CARD32 global_bitmap_2;
+ CARD32 primary_bitmap_1;
+ CARD32 primary_bitmap_2;
CARD8 text_save[S3_TEXT_SAVE];
} S3Save;
@@ -427,6 +469,8 @@ typedef struct _s3CardInfo {
CARD8 *registers; /* pointer to register map */
S3Vga s3vga;
S3Save save;
+ Bool need_sync;
+ Bool bios_initialized; /* whether the bios has been run */
} S3CardInfo;
typedef struct _s3ScreenInfo {
@@ -438,6 +482,9 @@ typedef struct _s3ScreenInfo {
int offscreen_height; /* height of offscreen area */
S3Cursor cursor;
S3Patterns patterns;
+ Bool manage_border;
+ Bool managing_border;
+ CARD32 border_pixel;
} S3ScreenInfo;
#define getS3CardInfo(kd) ((S3CardInfo *) ((kd)->card->driver))
@@ -460,6 +507,7 @@ void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
Bool s3DrawInit (ScreenPtr pScreen);
void s3DrawEnable (ScreenPtr pScreen);
+void s3DrawSync (ScreenPtr pScreen);
void s3DrawDisable (ScreenPtr pScreen);
void s3DrawFini (ScreenPtr pScreen);
@@ -470,10 +518,6 @@ void S3InitCard (KdCardAttr *attr);
void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
-#define S3ModeClock(t) (((t->horizontal + t->hblank) * \
- (t->vertical + t->vblank) * \
- t->rate) / 1000)
-
extern KdCardFuncs s3Funcs;
/*
@@ -488,26 +532,22 @@ extern KdCardFuncs s3Funcs;
#define DRAW_DEBUG(a)
-#define _s3WaitVRetrace(s3) { \
- VOL8 *_status = &s3->crt_vga_status_1; \
+#define _s3WaitVRetrace(s3vga) { \
int _loop_count; \
- DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitVRetrace 0x%x", *_status)); \
_loop_count = 0; \
- while ((*_status & VGA_STATUS_1_VSY) != 0) S3_RETRACE_LOOP_CHECK; \
+ while (s3GetImm(s3vga, s3_vertical_sync_active) != 0) S3_RETRACE_LOOP_CHECK; \
_loop_count = 0; \
- while ((*_status & VGA_STATUS_1_VSY) == 0) S3_RETRACE_LOOP_CHECK; \
+ while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \
}
/*
* Wait for the begining of the retrace interval
*/
-#define _s3WaitVRetraceEnd(s3) { \
- VOL8 *_status = &s3->crt_vga_status_1; \
+#define _s3WaitVRetraceEnd(s3vga) { \
int _loop_count; \
- DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitVRetraceEnd 0x%x", *_status)); \
_loop_count = 0; \
- while ((*_status & VGA_STATUS_1_VSY) == 0) S3_RETRACE_LOOP_CHECK; \
+ while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \
_loop_count = 0; \
- while ((*_status & VGA_STATUS_1_VSY) != 0) S3_RETRACE_LOOP_CHECK; \
+ while (s3GetImm(s3vga, s3_vertical_sync_active) != 0) S3_RETRACE_LOOP_CHECK; \
}
#define S3_CURSOR_WIDTH 64
@@ -516,30 +556,4 @@ extern KdCardFuncs s3Funcs;
#define S3_TILE_SIZE 8
-/*
- * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order,
- * but it's willing to take them in LSB byte order. These macros
- * flip bits around without flipping bytes. Instead of using a table
- * and burning memory bandwidth, do them in place with the CPU.
- */
-
-/* The MIPS compiler automatically places these constants in registers */
-#define S3InvertBits32(v) { \
- v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
- v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
- v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-#define S3InvertBits16(v) { \
- v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
- v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
- v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
-}
-
-#define S3InvertBits8(v) { \
- v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
- v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
- v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
-}
-
#endif /* _S3_H_ */
diff --git a/hw/kdrive/savage/s3clock.c b/hw/kdrive/savage/s3clock.c
index 457f5c57e..4541362d4 100644
--- a/hw/kdrive/savage/s3clock.c
+++ b/hw/kdrive/savage/s3clock.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3clock.c,v 1.1 1999/11/19 13:53:55 hohndel Exp $ */
#include "s3.h"
@@ -57,7 +57,7 @@ s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
for (R = 0; R <= maxR; R++)
{
f_vco = target * (1 << R);
- if (MIN_VCO <= f_vco && f_vco < MAX_VCO)
+ if (f_vco >= MIN_VCO)
break;
}
diff --git a/hw/kdrive/savage/s3cmap.c b/hw/kdrive/savage/s3cmap.c
index 1c10dfa16..c0fa73e16 100644
--- a/hw/kdrive/savage/s3cmap.c
+++ b/hw/kdrive/savage/s3cmap.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.1 1999/11/19 13:53:55 hohndel Exp $ */
#include "s3.h"
@@ -31,16 +31,14 @@ s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
- S3Ptr s3 = s3c->s3;
- VOL8 *dac_rd_ad = &s3->crt_vga_dac_rd_ad;
- VOL8 *dac_data = &s3->crt_vga_dac_data;
+ S3Vga *s3vga = &s3c->s3vga;
while (ndef--)
{
- *dac_rd_ad = pdefs->pixel;
- pdefs->red = *dac_data << 8;
- pdefs->green = *dac_data << 8;
- pdefs->blue = *dac_data << 8;
+ s3SetImm (s3vga, s3_dac_read_index, pdefs->pixel);
+ pdefs->red = s3GetImm (s3vga, s3_dac_data) << 8;
+ pdefs->green = s3GetImm (s3vga, s3_dac_data) << 8;
+ pdefs->blue = s3GetImm (s3vga, s3_dac_data) << 8;
pdefs++;
}
}
@@ -50,18 +48,40 @@ s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
- S3Ptr s3 = s3c->s3;
- VOL8 *dac_wt_ad = &s3->crt_vga_dac_wt_ad;
- VOL8 *dac_data = &s3->crt_vga_dac_data;
+ s3ScreenInfo(pScreenPriv);
+ S3Vga *s3vga = &s3c->s3vga;
+ Bool hit_border = FALSE;
+ Bool check_border = FALSE;
- _s3WaitVRetrace (s3);
+ _s3WaitVRetrace (s3vga);
+ if (pScreenPriv->enabled && s3s->manage_border && !s3s->managing_border)
+ check_border = TRUE;
while (ndef--)
{
- *dac_wt_ad = pdefs->pixel;
- *dac_data = pdefs->red >> 8;
- *dac_data = pdefs->green >> 8;
- *dac_data = pdefs->blue >> 8;
+ if (check_border && pdefs->pixel == s3s->border_pixel)
+ {
+ if (pdefs->red || pdefs->green || pdefs->blue)
+ hit_border = TRUE;
+ }
+ s3SetImm (s3vga, s3_dac_write_index, pdefs->pixel);
+ s3SetImm (s3vga, s3_dac_data, pdefs->red >> 8);
+ s3SetImm (s3vga, s3_dac_data, pdefs->green >> 8);
+ s3SetImm (s3vga, s3_dac_data, pdefs->blue >> 8);
pdefs++;
}
+ if (hit_border)
+ {
+ xColorItem black;
+
+ black.red = 0;
+ black.green = 0;
+ black.blue = 0;
+ s3s->managing_border = TRUE;
+ FakeAllocColor (pScreenPriv->pInstalledmap,
+ &black);
+ s3s->border_pixel = black.pixel;
+ FakeFreeColor (pScreenPriv->pInstalledmap, s3s->border_pixel);
+/* s3SetImm (&s3c->s3vga, s3_border_color, (VGA8) s3s->border_pixel); */
+ }
}
diff --git a/hw/kdrive/savage/s3curs.c b/hw/kdrive/savage/s3curs.c
index 0fd1397ab..cb4d79cc7 100644
--- a/hw/kdrive/savage/s3curs.c
+++ b/hw/kdrive/savage/s3curs.c
@@ -22,9 +22,10 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3curs.c,v 1.1 1999/11/19 13:53:56 hohndel Exp $ */
#include "s3.h"
+#include "s3draw.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
@@ -94,33 +95,9 @@ s3AllocCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
- xColorItem sourceColor, maskColor;
-
- /*
- * Set these to an invalid pixel value so that
- * when the store colors comes through, the cursor
- * won't get recolored
- */
- pCurPriv->source = ~0;
- pCurPriv->mask = ~0;
- /*
- * XXX S3 bug workaround; s3 chip doesn't use RGB values from
- * the cursor color registers as documented, rather it uses
- * them to index the DAC. This is in the errata though.
- */
- 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);
- pCurPriv->source = sourceColor.pixel;
- pCurPriv->mask = maskColor.pixel;
+ KdAllocateCursorPixels (pScreen, pCursor,
+ &pCurPriv->source, &pCurPriv->mask);
switch (pScreenPriv->screen->bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
@@ -190,8 +167,9 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
CursorBitsPtr bits = pCursor->bits;
int w, h;
unsigned char r[2], g[2], b[2];
- unsigned short *ram, *msk, *mskLine, *src, *srcLine;
- unsigned short and, xor;
+ unsigned long *ram;
+ unsigned long *msk, *mskLine, *src, *srcLine;
+ unsigned long and, xor;
int i, j;
int cursor_address;
int wsrc;
@@ -209,24 +187,24 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
/*
* Stick new image into cursor memory
*/
- ram = (unsigned short *) s3s->cursor_base;
- mskLine = (unsigned short *) bits->mask;
- srcLine = (unsigned short *) bits->source;
+ ram = (unsigned long *) s3s->cursor_base;
+ mskLine = (unsigned long *) bits->mask;
+ srcLine = (unsigned long *) bits->source;
h = bits->height;
if (h > S3_CURSOR_HEIGHT)
h = S3_CURSOR_HEIGHT;
- wsrc = BitmapBytePad(bits->width) / 2; /* words per line */
+ wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */
for (i = 0; i < S3_CURSOR_HEIGHT; i++) {
msk = mskLine;
src = srcLine;
mskLine += wsrc;
srcLine += wsrc;
- for (j = 0; j < S3_CURSOR_WIDTH / 16; j++) {
+ for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) {
- unsigned short m, s;
+ unsigned long m, s;
if (i < h && j < wsrc)
{
@@ -237,14 +215,14 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
}
else
{
- and = 0xffff;
- xor = 0x0000;
+ and = 0xffffffff;
+ xor = 0x00000000;
}
- S3InvertBits16(and);
- *ram++ = and;
- S3InvertBits16(xor);
- *ram++ = xor;
+ S3AdjustBits32(and);
+ S3AdjustBits32(xor);
+ *ram++ = (and & 0xffff) | (xor << 16);
+ *ram++ = (and >> 16) | (xor & 0xffff0000);
}
}
@@ -254,10 +232,11 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
_s3SetCursorColors (pScreen);
/* Enable the cursor */
+ s3SetImm (s3vga, s3_cursor_ms_x11, 0);
s3SetImm (s3vga, s3_cursor_enable, 1);
/* Wait for VRetrace to make sure the position is read */
- _s3WaitVRetrace (s3);
+ _s3WaitVRetrace (s3vga);
/* Move to new position */
_s3MoveCursor (pScreen, x, y);
@@ -285,7 +264,11 @@ s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
if (pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
@@ -382,7 +365,11 @@ s3CursorEnable (ScreenPtr pScreen)
{
if (pCurPriv->pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c
index c57bc2eb5..2d86caaa9 100644
--- a/hw/kdrive/savage/s3draw.c
+++ b/hw/kdrive/savage/s3draw.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.1 1999/11/19 13:53:56 hohndel Exp $ */
#include "s3.h"
#include "s3draw.h"
@@ -69,12 +69,12 @@ short s3alu[16] = {
#define BURST
#ifdef BURST
#define PixTransDeclare VOL32 *pix_trans_base = (VOL32 *) (s3c->registers),\
- *pix_trans = pix_trans_base;
-#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 8192) pix_trans = pix_trans_base;
+ *pix_trans = pix_trans_base
+#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 8192) pix_trans = pix_trans_base
#define PixTransStore(t) *pix_trans++ = (t)
#else
-#define PixTransDeclare VOL32 *pix_trans = &s3->pix_trans;
-#define PixTransStart(n)
+#define PixTransDeclare VOL32 *pix_trans = &s3->pix_trans
+#define PixTransStart(n)
#define PixTransStore(t) *pix_trans = (t)
#endif
@@ -147,14 +147,14 @@ s3CopyNtoN (DrawablePtr pSrcDrawable,
_s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
pbox++;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pSrcDrawable->pScreen);
}
RegionPtr
s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
int srcx, int srcy, int width, int height, int dstx, int dsty)
{
- KdScreenPriv(pDstDrawable->pScreen);
+ SetupS3(pDstDrawable->pScreen);
if (pSrcDrawable->type == DRAWABLE_WINDOW &&
pDstDrawable->type == DRAWABLE_WINDOW)
@@ -163,12 +163,13 @@ s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
srcx, srcy, width, height,
dstx, dsty, s3CopyNtoN, 0, 0);
}
- return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
- srcx, srcy, width, height, dstx, dsty);
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
}
typedef struct _s31toNargs {
unsigned long copyPlaneFG, copyPlaneBG;
+ Bool opaque;
} s31toNargs;
void
@@ -209,7 +210,7 @@ _s3Stipple (S3CardInfo *s3c,
while (nl--)
{
tmp = *psrc++;
- S3InvertBits32(tmp);
+ S3AdjustBits32 (tmp);
PixTransStore (tmp);
}
psrc += widthRest;
@@ -228,7 +229,7 @@ _s3Stipple (S3CardInfo *s3c,
tmp = FbStipLeft(bits, leftShift);
bits = *psrc++;
tmp |= FbStipRight(bits, rightShift);
- S3InvertBits32(tmp);
+ S3AdjustBits32(tmp);
PixTransStore (tmp);
}
psrc += widthRest;
@@ -257,7 +258,7 @@ s3Copy1toN (DrawablePtr pSrcDrawable,
FbStride widthSrc;
int srcBpp;
- if (sourceInvarient (pGC->alu))
+ if (args->opaque && sourceInvarient (pGC->alu))
{
s3FillBoxSolid (pDstDrawable, nbox, pbox,
pGC->bgPixel, pGC->alu, pGC->planemask);
@@ -266,8 +267,16 @@ s3Copy1toN (DrawablePtr pSrcDrawable,
fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp);
- _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask,args->copyPlaneFG,
- args->copyPlaneBG);
+ if (args->opaque)
+ {
+ _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask,args->copyPlaneFG,
+ args->copyPlaneBG);
+ }
+ else
+ {
+ _s3SetTransparentPlaneBlt (s3, pGC->alu,
+ pGC->planemask, args->copyPlaneFG);
+ }
while (nbox--)
{
@@ -281,7 +290,7 @@ s3Copy1toN (DrawablePtr pSrcDrawable,
pbox->x2 - dstx, pbox->y2 - dsty);
pbox++;
}
- _s3WaitIdleEmpty (s3);
+ MarkSyncS3 (pDstDrawable->pScreen);
}
RegionPtr
@@ -289,7 +298,7 @@ s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
int srcx, int srcy, int width, int height,
int dstx, int dsty, unsigned long bitPlane)
{
- KdScreenPriv (pDstDrawable->pScreen);
+ SetupS3 (pDstDrawable->pScreen);
RegionPtr ret;
s31toNargs args;
@@ -298,13 +307,35 @@ s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
{
args.copyPlaneFG = pGC->fgPixel;
args.copyPlaneBG = pGC->bgPixel;
+ args.opaque = TRUE;
return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
srcx, srcy, width, height,
dstx, dsty, s3Copy1toN, bitPlane, &args);
}
- return fbCopyPlane(pSrcDrawable, pDstDrawable, pGC,
- srcx, srcy, width, height,
- dstx, dsty, bitPlane);
+ return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+void
+s3PushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y)
+{
+ SetupS3 (pDrawable->pScreen);
+ s31toNargs args;
+
+ if (pDrawable->type == DRAWABLE_WINDOW && pGC->fillStyle == FillSolid)
+ {
+ args.opaque = FALSE;
+ args.copyPlaneFG = pGC->fgPixel;
+ (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC,
+ 0, 0, w, h, x, y, s3Copy1toN, 1, &args);
+ }
+ else
+ {
+ KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+ }
}
void
@@ -320,7 +351,7 @@ s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
_s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
pBox++;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -363,7 +394,7 @@ s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
pBox->x2-pBox->x1, pBox->y2-pBox->y1);
pBox++;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -438,7 +469,7 @@ s3FillBoxLargeStipple (DrawablePtr pDrawable, GCPtr pGC,
stipY = 0;
}
}
- _s3WaitIdleEmpty (s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
#define NUM_STACK_RECTS 1024
@@ -669,7 +700,7 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
{
s3GCPrivate(pGC);
SetupS3(pDrawable->pScreen);
- int x, y;
+ int x, y, x1, y1, x2, y2;
int width;
/* next three parameters are post-clip */
int nTmp;
@@ -678,60 +709,113 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
BoxPtr extents;
S3PatternCache *cache;
+ RegionPtr pClip = fbGetCompositeClip (pGC);
- nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
- pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
- pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
- if(!pptFree || !pwidthFree)
+ if (REGION_NUM_RECTS(pClip) == 1 &&
+ (pGC->fillStyle == FillSolid || s3Priv->pPattern))
{
- if (pptFree) DEALLOCATE_LOCAL(pptFree);
- if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
- return;
- }
- n = miClipSpans(fbGetCompositeClip(pGC),
- ppt, pwidth, n,
- pptFree, pwidthFree, fSorted);
- pwidth = pwidthFree;
- ppt = pptFree;
- if (pGC->fillStyle == FillSolid)
- {
- _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
+ extents = REGION_RECTS(pClip);
+ x1 = extents->x1;
+ x2 = extents->x2;
+ y1 = extents->y1;
+ y2 = extents->y2;
+ if (pGC->fillStyle == FillSolid)
+ {
+ _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
+ cache = 0;
+ }
+ else
+ {
+ _s3SetPattern (pDrawable->pScreen, pGC->alu, pGC->planemask,
+ s3Priv->pPattern);
+ cache = s3Priv->pPattern->cache;
+ }
while (n--)
{
- x = ppt->x;
y = ppt->y;
- ppt++;
- width = *pwidth++;
- if (width)
+ if (y1 <= y && y < y2)
{
- _s3SolidRect(s3,x,y,width,1);
+ x = ppt->x;
+ width = *pwidth;
+ if (x < x1)
+ {
+ width -= (x1 - x);
+ x = x1;
+ }
+ if (x2 < x + width)
+ width = x2 - x;
+ if (width > 0)
+ {
+ if (cache)
+ {
+ _s3PatRect(s3, cache->x, cache->y, x, y, width, 1);
+ }
+ else
+ {
+ _s3SolidRect(s3,x,y,width,1);
+ }
+ }
}
+ ppt++;
+ pwidth++;
}
}
- else if (s3Priv->pPattern)
+ else
{
- _s3SetPattern (pDrawable->pScreen, pGC->alu, pGC->planemask,
- s3Priv->pPattern);
- cache = s3Priv->pPattern->cache;
- while (n--)
+ nTmp = n * miFindMaxBand(pClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
{
- x = ppt->x;
- y = ppt->y;
- ppt++;
- width = *pwidth++;
- if (width)
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(fbGetCompositeClip(pGC),
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ if (pGC->fillStyle == FillSolid)
+ {
+ _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
+ while (n--)
{
- _s3PatRect(s3, cache->x, cache->y, x, y, width, 1);
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ _s3SolidRect(s3,x,y,width,1);
+ }
}
}
+ else if (s3Priv->pPattern)
+ {
+ _s3SetPattern (pDrawable->pScreen, pGC->alu, pGC->planemask,
+ s3Priv->pPattern);
+ cache = s3Priv->pPattern->cache;
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ _s3PatRect(s3, cache->x, cache->y, x, y, width, 1);
+ }
+ }
+ }
+ else
+ {
+ _s3FillSpanLargeStipple (pDrawable, pGC, n, ppt, pwidth);
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
}
- else
- {
- _s3FillSpanLargeStipple (pDrawable, pGC, n, ppt, pwidth);
- }
- _s3WaitIdleEmpty (s3);
- DEALLOCATE_LOCAL(pptFree);
- DEALLOCATE_LOCAL(pwidthFree);
+ MarkSyncS3 (pDrawable->pScreen);
}
#include "mifillarc.h"
@@ -886,14 +970,14 @@ s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
}
if (set)
{
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDraw->pScreen);
set = FALSE;
}
- miPolyFillArc(pDraw, pGC, 1, parcs);
+ KdCheckPolyFillArc(pDraw, pGC, 1, parcs);
}
if (set)
{
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDraw->pScreen);
set = FALSE;
}
}
@@ -925,7 +1009,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
if (mode == CoordModePrevious)
{
- miFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
+ KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
@@ -949,7 +1033,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
*/
if (c & 0xe000e000)
{
- miFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
+ KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
c = intToY(c);
@@ -979,7 +1063,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
*/
if (c & 0xe000e000)
{
- miFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
+ KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
c = intToY(c);
@@ -1016,7 +1100,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
yFlip++;
if (yFlip != 2)
{
- miFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
+ KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
}
@@ -1141,7 +1225,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
break;
}
_s3ResetClip (s3, pDrawable->pScreen);
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -1171,7 +1255,7 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
int nbox;
int x1, y1, x2, y2;
unsigned char alu;
- Bool locked;
+ Bool set;
PixTransDeclare;
x += pDrawable->x;
@@ -1229,10 +1313,10 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
_s3SolidRect (s3, x1, y1, x2 - x1, y2 - y1);
}
}
+ MarkSyncS3 (pDrawable->pScreen);
}
- _s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel);
ppci = ppciInit;
- locked = TRUE;
+ set = FALSE;
while (nglyph--)
{
pci = *ppci++;
@@ -1247,13 +1331,14 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox))
{
case rgnIN:
+#if 1
lw = h * ((w + 31) >> 5);
if (lw)
{
- if (!locked)
+ if (!set)
{
_s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel);
- locked = TRUE;
+ set = TRUE;
}
_s3PlaneBlt(s3,
x + pci->metrics.leftSideBearing,
@@ -1264,17 +1349,16 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
while (lw--)
{
b = *bits++;
- S3InvertBits32 (b);
+ S3AdjustBits32 (b);
PixTransStore(b);
}
+ MarkSyncS3 (pDrawable->pScreen);
}
break;
+#endif
case rgnPART:
- if (locked)
- {
- _s3WaitIdleEmpty(s3);
- locked = FALSE;
- }
+ set = FALSE;
+ CheckSyncS3 (pDrawable->pScreen);
fbPutXYImage (pDrawable,
pClip,
fbPriv->fg,
@@ -1293,7 +1377,6 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
}
x += pci->metrics.characterWidth;
}
- _s3WaitIdleEmpty(s3);
}
/*
@@ -1422,13 +1505,13 @@ s3PolyGlyphBlt (DrawablePtr pDrawable,
while (lw--)
{
b = *bits++;
- S3InvertBits32 (b);
+ S3AdjustBits32 (b);
PixTransStore(b);
}
}
x += pci->metrics.characterWidth;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -1487,6 +1570,8 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox))
{
+ case rgnIN:
+ break;
case rgnPART:
if (pglyphBase == (pointer) 1)
pglyphBase = 0;
@@ -1510,6 +1595,12 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
_s3SetOpaquePlaneBlt (s3, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel);
}
+#if BITMAP_BIT_ORDER == LSBFirst
+#define SHIFT <<
+#else
+#define SHIFT >>
+#endif
+
#define LoopIt(count, w, loadup, fetch) \
while (nglyph >= count) \
{ \
@@ -1521,7 +1612,7 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
PixTransStart(h); \
while (lwTmp--) { \
tmp = fetch; \
- S3InvertBits32(tmp); \
+ S3AdjustBits32(tmp); \
PixTransStore(tmp); \
} \
}
@@ -1535,9 +1626,9 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
char3 = (unsigned long *) (*ppci++)->bits;
char4 = (unsigned long *) (*ppci++)->bits;,
(*char1++ | ((*char2++ | ((*char3++ | (*char4++
- << widthGlyph))
- << widthGlyph))
- << widthGlyph)))
+ SHIFT widthGlyph))
+ SHIFT widthGlyph))
+ SHIFT widthGlyph)))
}
else if (widthGlyph <= 10)
{
@@ -1546,7 +1637,7 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
char1 = (unsigned long *) (*ppci++)->bits;
char2 = (unsigned long *) (*ppci++)->bits;
char3 = (unsigned long *) (*ppci++)->bits;,
- (*char1++ | ((*char2++ | (*char3++ << widthGlyph)) << widthGlyph)))
+ (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph)))
}
else if (widthGlyph <= 16)
{
@@ -1554,7 +1645,7 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
LoopIt(2, widthGlyphs,
char1 = (unsigned long *) (*ppci++)->bits;
char2 = (unsigned long *) (*ppci++)->bits;,
- (*char1++ | (*char2++ << widthGlyph)))
+ (*char1++ | (*char2++ SHIFT widthGlyph)))
}
lw = h * ((widthGlyph + 31) >> 5);
while (nglyph--)
@@ -1567,11 +1658,11 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
while (lwTmp--)
{
tmp = *char1++;
- S3InvertBits32(tmp);
+ S3AdjustBits32(tmp);
PixTransStore(tmp);
}
}
- _s3WaitIdleEmpty (s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -1583,15 +1674,6 @@ s3PolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
s3ImageTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (pointer) 1);
}
-#define _s3ClipLine(s3,cmd,e1,e2,e,len) {\
- DRAW_DEBUG ((DEBUG_RENDER, "clip line 0x%x 0x%x 0x%x 0x%x 0x%x", cmd,e1,e2,e,len)); \
- _s3CmdWait(s3); \
- _s3SetPcnt (s3, (len), 0); \
- _s3SetStep (s3, e2, e1); \
- _s3SetErr (s3, e); \
- _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \
-}
-
void
_s3Segment (DrawablePtr pDrawable,
GCPtr pGC,
@@ -1750,7 +1832,7 @@ s3Polylines (DrawablePtr pDrawable, GCPtr pGC,
x = nx;
y = ny;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
void
@@ -1781,7 +1863,7 @@ s3PolySegment (DrawablePtr pDrawable, GCPtr pGC,
pSeg->x2 + ox, pSeg->y2 + oy, drawLast);
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDrawable->pScreen);
}
/*
@@ -1939,6 +2021,8 @@ _s3PutPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
cache->y * pScreenPriv->screen->byteStride +
cache->x * pScreenPriv->bytesPerPixel);
+ CheckSyncS3 (pScreen);
+
for (y = 0; y < S3_TILE_SIZE; y++)
{
switch (pScreenPriv->screen->bitsPerPixel) {
@@ -2094,7 +2178,7 @@ s3ChangeWindowAttributes (WindowPtr pWin, Mask mask)
void
s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
{
- KdScreenPriv(pWin->drawable.pScreen);
+ SetupS3(pWin->drawable.pScreen);
s3PatternPtr pPattern;
DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
@@ -2146,7 +2230,7 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
}
break;
}
- fbPaintWindow (pWin, pRegion, what);
+ KdCheckPaintWindow (pWin, pRegion, what);
}
void
@@ -2198,7 +2282,7 @@ s3CopyWindowProc (DrawablePtr pSrcDrawable,
_s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
pbox++;
}
- _s3WaitIdleEmpty(s3);
+ MarkSyncS3 (pDstDrawable->pScreen);
}
void
@@ -2255,6 +2339,10 @@ s3DrawInit (ScreenPtr pScreen)
if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec)))
return FALSE;
/*
+ * Hook up asynchronous drawing
+ */
+ RegisterSync (pScreen);
+ /*
* Replace various fb screen functions
*/
pScreen->CreateGC = s3CreateGC;
@@ -2306,17 +2394,19 @@ s3DrawEnable (ScreenPtr pScreen)
for (c = 0; c < s3s->patterns.ncache; c++)
s3s->patterns.cache[c].id = 0;
- _s3WaitIdleEmpty(s3);
+ _s3WaitIdleEmpty (s3);
_s3SetScissorsTl(s3, 0, 0);
_s3SetScissorsBr(s3, pScreenPriv->screen->width - 1, pScreenPriv->screen->height - 1);
_s3SetSolidFill(s3, pScreen->blackPixel, GXcopy, ~0);
_s3SolidRect (s3, 0, 0, pScreenPriv->screen->width, pScreenPriv->screen->height);
- _s3WaitIdleEmpty (s3);
+ MarkSyncS3 (pScreen);
}
void
s3DrawDisable (ScreenPtr pScreen)
{
+ SetupS3 (pScreen);
+ _s3WaitIdleEmpty (s3);
}
void
@@ -2332,3 +2422,11 @@ s3DrawFini (ScreenPtr pScreen)
s3s->patterns.ncache = 0;
}
}
+
+void
+s3DrawSync (ScreenPtr pScreen)
+{
+ SetupS3(pScreen);
+
+ _s3WaitIdleEmpty(s3c->s3);
+}
diff --git a/hw/kdrive/savage/s3draw.h b/hw/kdrive/savage/s3draw.h
index 14dd1688e..80b1b1150 100644
--- a/hw/kdrive/savage/s3draw.h
+++ b/hw/kdrive/savage/s3draw.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.1 1999/11/19 13:53:56 hohndel Exp $ */
#ifndef _S3DRAW_H_
#define _S3DRAW_H_
@@ -62,9 +62,69 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
s3CardInfo(pScreenPriv); \
S3Ptr s3 = s3c->s3
+#ifdef S3_SYNC_DEBUG
+#define SYNC_DEBUG() fprintf (stderr, "Sync at %s:%d\n", __FILE__,__LINE__)
+#else
+#define SYNC_DEBUG()
+#endif
+
+#define S3_ASYNC
+#ifdef S3_ASYNC
+#define CheckSyncS3(s) KdCheckSync(s)
+#define MarkSyncS3(s) KdMarkSync(s)
+#define RegisterSync(screen) KdScreenInitAsync (screen)
+#else
+#define CheckSyncS3(s3c)
+#define MarkSyncS3(s3c) _s3WaitIdleEmpty(s3c->s3)
+#define RegisterSync(screen)
+#endif
+
#define WIDEN(x) ((unsigned long) (x))
#define MERGE(a,b) ((WIDEN(a) << 16) | WIDEN(b))
+/*
+ * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order,
+ * but it's willing to take them in LSB byte order. These macros
+ * flip bits around without flipping bytes. Instead of using a table
+ * and burning memory bandwidth, do them in place with the CPU.
+ */
+
+/* The MIPS compiler automatically places these constants in registers */
+#define S3InvertBits32(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+#define S3InvertBits16(v) { \
+ v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
+ v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
+ v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
+}
+
+#define S3InvertBits8(v) { \
+ v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
+ v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
+ v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
+}
+
+#define S3ByteSwap32(x) ((x) = (((x) >> 24) | \
+ (((x) >> 8) & 0xff00) | \
+ (((x) << 8) & 0xff0000) | \
+ ((x) << 24)))
+
+#define S3ByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8))
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define S3AdjustBits32(x) S3InvertBits32(x)
+#define S3AdjustBits16(x) S3InvertBits16(x)
+#else
+#define S3AdjustBits32(x) S3ByteSwap32(x)
+#define S3AdjustBits16(x) S3ByteSwap16(x)
+#endif
+
+#define _s3WaitSlot(s3) _s3WaitSlots(s3,1)
+
#define _s3SetFg(s3,_fg) { \
DRAW_DEBUG ((DEBUG_REGISTERS, " fg <- 0x%x", _fg));\
s3->fg = (_fg); \
@@ -87,7 +147,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetPixelControl(s3,_ctl) { \
DRAW_DEBUG((DEBUG_REGISTERS, " pix_cntl <- 0x%x", PIX_CNTL | (_ctl))); \
- s3->pix_cntl = PIX_CNTL | (_ctl); \
+ s3->pix_cntl_mult_misc2 = MERGE (CONTROL_MISC2, PIX_CNTL | (_ctl)); \
}
#define _s3SetFgMix(s3,_mix) { \
@@ -141,11 +201,12 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
DRAW_DEBUG((DEBUG_REGISTERS, " cmd <- 0x%x", _cmd)); \
_s3CmdWait(s3); \
s3->cmd_gp_stat = (_cmd); \
- { CARD32 __junk__; __junk__ = s3->cmd_gp_stat; } \
+ /* { CARD32 __junk__; __junk__ = s3->cmd_gp_stat; } */ \
}
#define _s3SetSolidFill(s3,pix,alu,mask) { \
DRAW_DEBUG((DEBUG_SET,"set fill 0x%x %d 0x%x",pix,alu,mask)); \
+ _s3WaitSlots(s3,4); \
_s3SetFg (s3, pix); \
_s3SetWriteMask(s3,mask); \
_s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL | MIX_SRC); \
@@ -155,7 +216,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SolidRect(s3,x,y,w,h) {\
DRAW_DEBUG((DEBUG_RENDER,"solid rect %d,%d %dx%d",x,y,w,h)); \
- _s3CmdWait(s3); \
+ _s3WaitSlots(s3,3); \
_s3SetCur(s3, x, y); \
_s3SetPcnt (s3, (w)-1, (h)-1); \
_s3SetCmd (s3, CMD_RECT|INC_X|INC_Y|DRAW|WRTDATA); \
@@ -164,15 +225,25 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SolidLine(s3,maj,min,len,cmd) { \
DRAW_DEBUG ((DEBUG_RENDER, "solid line 0x%x 0x%x 0x%x", maj, min, cmd)); \
- _s3CmdWait(s3); \
+ _s3WaitSlots(s3,4); \
_s3SetPcnt(s3, (len), 0); \
_s3SetStep(s3, 2*((min) - (maj)), 2*(min)); \
_s3SetErr(s3, 2*(min) - (maj)); \
_s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \
}
+#define _s3ClipLine(s3,cmd,e1,e2,e,len) {\
+ DRAW_DEBUG ((DEBUG_RENDER, "clip line 0x%x 0x%x 0x%x 0x%x 0x%x", cmd,e1,e2,e,len)); \
+ _s3WaitSlots(s3, 4); \
+ _s3SetPcnt (s3, (len), 0); \
+ _s3SetStep (s3, e2, e1); \
+ _s3SetErr (s3, e); \
+ _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \
+}
+
#define _s3SetTile(s3,alu,mask) { \
DRAW_DEBUG ((DEBUG_SET,"set tile %d 0x%x", alu, mask)); \
+ _s3WaitSlots(s3,3); \
_s3SetWriteMask(s3, mask); \
_s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT|s3alu[alu]); \
_s3SetPixelControl (s3, MIXSEL_FRGDMIX); \
@@ -185,6 +256,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
*/
#define _s3SetStipple(s3,alu,mask,_fg) {\
DRAW_DEBUG ((DEBUG_SET,"set stipple 0x%x %d 0x%x", _fg, alu, mask)); \
+ _s3WaitSlots(s3,5); \
_s3SetFg (s3, _fg); \
_s3SetBg (s3, 0); \
_s3SetWriteMask(s3,mask); \
@@ -195,6 +267,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetOpaqueStipple(s3,alu,mask,_fg,_bg) {\
DRAW_DEBUG ((DEBUG_SET,"set opaque stipple 0x%x 0x%x %d 0x%x", _fg, _bg, alu, mask)); \
+ _s3WaitSlots(s3,5); \
_s3SetFg (s3, _fg); \
_s3SetBg (s3, _bg); \
_s3SetWriteMask(s3,mask); \
@@ -205,7 +278,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3PatRect(s3,px,py,x,y,w,h) {\
DRAW_DEBUG ((DEBUG_RENDER, "pat rect %d,%d %dx%d", x,y,w,h)); \
- _s3CmdWait(s3); \
+ _s3WaitSlots(s3, 4); \
_s3SetCur (s3, px, py); \
_s3SetStep (s3, x, y); \
_s3SetPcnt (s3, (w)-1, (h)-1); \
@@ -215,6 +288,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetBlt(s3,alu,mask) { \
DRAW_DEBUG ((DEBUG_SET,"set blt %d 0x%x", alu, mask)); \
+ _s3WaitSlots(s3,3); \
_s3SetPixelControl (s3, MIXSEL_FRGDMIX); \
_s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT | s3alu[alu]); \
_s3SetWriteMask(s3, mask); \
@@ -224,7 +298,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3Blt(s3,_sx,_sy,_dx,_dy,_w,_h,_dir) { \
DRAW_DEBUG ((DEBUG_RENDER, "blt %d,%d -> %d,%d %dx%d 0x%x", \
_sx,_sy,_dx,_dy,_w,_h,_dir)); \
- _s3CmdWait(s3); \
+ _s3WaitSlots(s3,4); \
_s3SetCur(s3,_sx,_sy); \
_s3SetStep(s3,_dx,_dy); \
_s3SetPcnt(s3,(_w)-1,(_h)-1); \
@@ -235,6 +309,8 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetOpaquePlaneBlt(s3,alu,mask,_fg,_bg) {\
DRAW_DEBUG ((DEBUG_SET,"set opaque plane blt 0x%x 0x%x %d 0x%x", \
_fg, _bg, alu, mask)); \
+ /* _s3WaitSlots(s3, 5); */ \
+ _s3WaitIdleEmpty (s3); \
_s3SetFg(s3,_fg); \
_s3SetBg(s3,_bg); \
_s3SetWriteMask(s3,mask); \
@@ -246,6 +322,8 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetTransparentPlaneBlt(s3,alu,mask,_fg) {\
DRAW_DEBUG ((DEBUG_SET,"set transparent plane blt 0x%x %d 0x%x", \
_fg, alu, mask)); \
+ /*_s3WaitSlots(s3, 4); */ \
+ _s3WaitIdleEmpty (s3); \
_s3SetFg(s3,_fg); \
_s3SetWriteMask(s3,mask); \
_s3SetMix(s3,FSS_FRGDCOL|s3alu[alu], BSS_BKGDCOL|MIX_DST); \
@@ -256,7 +334,8 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
/* Across the plane blt */
#define _s3PlaneBlt(s3,x,y,w,h) {\
DRAW_DEBUG ((DEBUG_RENDER, "plane blt %d,%d %dx%d", x,y,w,h)); \
- _s3CmdWait(s3); \
+ _s3WaitSlots(s3, 4); \
+ _s3SetPixelControl(s3,MIXSEL_EXPPC); \
_s3SetCur(s3, x, y); \
_s3SetPcnt (s3, (w)-1, (h)-1); \
_s3SetCmd (s3, \
@@ -274,7 +353,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3SetClip(s3,pbox) {\
DRAW_DEBUG ((DEBUG_SET, "set clip %dx%d -> %dx%d ", \
pbox->x1, pbox->y1, pbox->x2, pbox->y2)); \
- _s3WaitEmpty(s3); \
+ _s3WaitSlots(s3, 2); \
_s3SetScissorsTl(s3,(pbox)->x1, (pbox)->y1); \
_s3SetScissorsBr(s3,(pbox)->x2 - 1, (pbox)->y2 - 1); \
DRAW_DEBUG((DEBUG_SET," done")); \
@@ -282,7 +361,7 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define _s3ResetClip(s3,pScreen) { \
DRAW_DEBUG ((DEBUG_SET, "reset clip")); \
- _s3WaitEmpty(s3); \
+ _s3WaitSlots(s3, 2); \
_s3SetScissorsTl(s3,0,0); \
_s3SetScissorsBr(s3,pScreen->width - 1, pScreen->height - 1); \
DRAW_DEBUG((DEBUG_SET," done")); \
@@ -298,6 +377,11 @@ s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
int dstx, int dsty, unsigned long bitPlane);
void
+s3PushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y);
+
+void
s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
unsigned long pixel, int alu, unsigned long planemask);
@@ -369,4 +453,7 @@ s3CheckGCFill (GCPtr pGC);
void
s3MoveGCFill (GCPtr pGC);
+void
+s3SyncProc (DrawablePtr pDrawable);
+
#endif
diff --git a/hw/kdrive/savage/s3gc.c b/hw/kdrive/savage/s3gc.c
index 245dfc483..d62db68ae 100644
--- a/hw/kdrive/savage/s3gc.c
+++ b/hw/kdrive/savage/s3gc.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3gc.c,v 1.1 1999/11/19 13:53:56 hohndel Exp $ */
#include "s3.h"
#include "s3draw.h"
@@ -48,17 +48,17 @@
*/
/* TE font, >= 4 pixels wide, one clip rectangle */
-static GCOps s3TEOps1Rect = {
+static const GCOps s3TEOps1Rect = {
s3FillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
s3CopyArea,
s3CopyPlane,
- fbPolyPoint,
+ KdCheckPolyPoint,
s3Polylines,
s3PolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
s3FillPoly1Rect,
s3PolyFillRect,
s3PolyFillArcSolid,
@@ -68,7 +68,7 @@ static GCOps s3TEOps1Rect = {
miImageText16,
s3ImageTEGlyphBlt,
s3PolyTEGlyphBlt,
- fbPushPixels,
+ s3PushPixels,
#ifdef NEED_LINEHELPER
,NULL
#endif
@@ -77,17 +77,17 @@ static GCOps s3TEOps1Rect = {
extern GCOps fbGCOps;
/* Non TE font, one clip rectangle */
-static GCOps s3NonTEOps1Rect = {
+static const GCOps s3NonTEOps1Rect = {
s3FillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
s3CopyArea,
s3CopyPlane,
- fbPolyPoint,
+ KdCheckPolyPoint,
s3Polylines,
s3PolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
s3FillPoly1Rect,
s3PolyFillRect,
s3PolyFillArcSolid,
@@ -97,24 +97,24 @@ static GCOps s3NonTEOps1Rect = {
miImageText16,
s3ImageGlyphBlt,
s3PolyGlyphBlt,
- fbPushPixels
+ s3PushPixels
#ifdef NEED_LINEHELPER
,NULL
#endif
};
/* TE font, != 1 clip rect (including 0) */
-static GCOps s3TEOps = {
+static const GCOps s3TEOps = {
s3FillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
s3CopyArea,
s3CopyPlane,
- fbPolyPoint,
+ KdCheckPolyPoint,
s3Polylines,
s3PolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
miFillPolygon,
s3PolyFillRect,
s3PolyFillArcSolid,
@@ -124,24 +124,24 @@ static GCOps s3TEOps = {
miImageText16,
s3ImageTEGlyphBlt,
s3PolyTEGlyphBlt,
- fbPushPixels
+ s3PushPixels
#ifdef NEED_LINEHELPER
,NULL
#endif
};
/* Non TE font, != 1 clip rect (including 0) */
-static GCOps s3NonTEOps = {
+static const GCOps s3NonTEOps = {
s3FillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
s3CopyArea,
s3CopyPlane,
- fbPolyPoint,
+ KdCheckPolyPoint,
s3Polylines,
s3PolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
miFillPolygon,
s3PolyFillRect,
s3PolyFillArcSolid,
@@ -151,7 +151,7 @@ static GCOps s3NonTEOps = {
miImageText16,
s3ImageGlyphBlt,
s3PolyGlyphBlt,
- fbPushPixels
+ s3PushPixels
#ifdef NEED_LINEHELPER
,NULL
#endif
@@ -169,7 +169,7 @@ s3MatchCommon (DrawablePtr pDraw, GCPtr pGC, FbGCPrivPtr fbPriv)
}
if (pDraw->type != DRAWABLE_WINDOW)
- return (GCOps *) &fbGCOps;
+ return (GCOps *) &kdAsyncPixmapGCOps;
if (pGC->lineWidth != 0)
return 0;
@@ -184,16 +184,16 @@ s3MatchCommon (DrawablePtr pDraw, GCPtr pGC, FbGCPrivPtr fbPriv)
if (TERMINALFONT(pGC->font))
{
if (fbPriv->oneRect)
- return &s3TEOps1Rect;
+ return (GCOps *) &s3TEOps1Rect;
else
- return &s3TEOps;
+ return (GCOps *) &s3TEOps;
}
else
{
if (fbPriv->oneRect)
- return &s3NonTEOps1Rect;
+ return (GCOps *) &s3NonTEOps1Rect;
else
- return &s3NonTEOps;
+ return (GCOps *) &s3NonTEOps;
}
}
return 0;
@@ -283,7 +283,7 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (pGC->ops == &kdNoopOps)
{
- pGC->ops = (GCOps *) &fbGCOps;
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
new_type = TRUE;
}
pGC->ops = miCreateGCOps (pGC->ops);
@@ -295,8 +295,8 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (new_type || (changes & (GCFillStyle|GCTile|GCStipple)))
{
- pGC->ops->FillSpans = fbFillSpans;
- pGC->ops->PolyFillRect = fbPolyFillRect;
+ pGC->ops->FillSpans = KdCheckFillSpans;
+ pGC->ops->PolyFillRect = KdCheckPolyFillRect;
if (s3Priv->type == DRAWABLE_WINDOW &&
(pGC->fillStyle != FillTiled || s3Priv->pPattern))
{
@@ -310,13 +310,9 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (new_type)
{
- pGC->ops->CopyArea = fbCopyArea;
- pGC->ops->CopyPlane = fbCopyPlane;
- if (s3Priv->type == DRAWABLE_WINDOW)
- {
- pGC->ops->CopyArea = s3CopyArea;
- pGC->ops->CopyPlane = s3CopyPlane;
- }
+ pGC->ops->CopyArea = s3CopyArea;
+ pGC->ops->CopyPlane = s3CopyPlane;
+ pGC->ops->PushPixels = s3PushPixels;
}
/*
@@ -324,8 +320,8 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (new_type || (changes & (GCLineStyle|GCLineWidth|GCFillStyle)))
{
- pGC->ops->Polylines = fbPolyLine;
- pGC->ops->PolySegment = fbPolySegment;
+ pGC->ops->Polylines = KdCheckPolylines;
+ pGC->ops->PolySegment = miPolySegment;
if (pGC->lineStyle == LineSolid &&
pGC->lineWidth == 0 &&
pGC->fillStyle == FillSolid &&
@@ -355,7 +351,7 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (new_type || (changes & GCFillStyle))
{
- pGC->ops->PolyFillArc = fbPolyFillArc;
+ pGC->ops->PolyFillArc = miPolyFillArc;
if (s3Priv->type == DRAWABLE_WINDOW &&
pGC->fillStyle == FillSolid)
{
@@ -368,8 +364,8 @@ s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
*/
if (new_type || (changes & (GCFont|GCFillStyle)))
{
- pGC->ops->PolyGlyphBlt = fbPolyGlyphBlt;
- pGC->ops->ImageGlyphBlt = fbImageGlyphBlt;
+ pGC->ops->PolyGlyphBlt = KdCheckPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = KdCheckImageGlyphBlt;
if (s3Priv->type == DRAWABLE_WINDOW && pGC->font)
{
if (pGC->fillStyle == FillSolid)
diff --git a/hw/kdrive/savage/s3reg.c b/hw/kdrive/savage/s3reg.c
index 38ca2e804..4f4ad85b8 100644
--- a/hw/kdrive/savage/s3reg.c
+++ b/hw/kdrive/savage/s3reg.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.c,v 1.1 1999/11/19 13:53:57 hohndel Exp $ */
#include "s3reg.h"
@@ -360,6 +360,16 @@ VgaReg s3_v_blank_end[] = {
VGA_REG_END
};
+VgaReg s3_2bk_cga[] = {
+ CR17, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_4bk_hga[] = {
+ CR17, 1, 1,
+ VGA_REG_END
+};
+
VgaReg s3_v_total_double[] = {
CR17, 2, 1,
VGA_REG_END
@@ -370,11 +380,21 @@ VgaReg s3_word_mode[] = {
VGA_REG_END
};
+VgaReg s3_address_16k_wrap[] = {
+ CR17, 5, 1,
+ VGA_REG_END
+};
+
VgaReg s3_byte_mode[] = {
CR17, 6, 1,
VGA_REG_END
};
+VgaReg s3_hardware_reset[] = {
+ CR17, 7, 1,
+ VGA_REG_END
+};
+
VgaReg s3_line_compare[] = {
CR18, 0, 8,
CR07, 4, 1,
@@ -414,6 +434,11 @@ VgaReg s3_border_select[] = {
VGA_REG_END
};
+VgaReg s3_lock_palette[] = {
+ CR33, 6, 1,
+ VGA_REG_END
+};
+
VgaReg s3_enable_sff[] = {
CR34, 4, 1,
VGA_REG_END
@@ -639,6 +664,11 @@ VgaReg s3_color_mode[] = {
VGA_REG_END
};
+VgaReg s3_primary_stream_timeout[] = {
+ CR71, 0, 8,
+ VGA_REG_END
+};
+
VgaReg s3_master_control_unit_timeout[] = {
CR74, 0, 8,
VGA_REG_END
@@ -674,6 +704,16 @@ VgaReg s3_fifo_fetch_timing[] = {
VGA_REG_END
};
+VgaReg s3_dac_power_up_time[] = {
+ CR86, 0, 7,
+ VGA_REG_END
+};
+
+VgaReg s3_dac_power_saving_disable[] = {
+ CR86, 7, 1,
+ VGA_REG_END
+};
+
VgaReg s3_primary_stream_l1[] = {
CR91, 0, 8,
CR90, 0, 3,
@@ -985,7 +1025,22 @@ VgaReg s3_enable_blinking[] = {
VGA_REG_END
};
-#define AR_LAST AR10
+VgaReg s3_border_color[] = {
+ AR11, 0, 8,
+ VGA_REG_END
+};
+
+#define AR_LAST AR11
+
+VgaReg s3_io_addr_select[] = {
+ S3_MISC_OUT, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_enable_ram[] = {
+ S3_MISC_OUT, 1, 1,
+ VGA_REG_END
+};
VgaReg s3_clock_select[] = {
S3_MISC_OUT, 2, 2,
@@ -1002,13 +1057,43 @@ VgaReg s3_vert_sync_neg[] = {
VGA_REG_END
};
+VgaReg s3_display_mode_inactive[] = {
+ S3_INPUT_STATUS_1, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_vertical_sync_active[] = {
+ S3_INPUT_STATUS_1, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_dac_mask[] = {
+ S3_DAC + 0, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg s3_dac_read_index[] = {
+ S3_DAC + 1, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg s3_dac_write_index[] = {
+ S3_DAC + 2, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg s3_dac_data[] = {
+ S3_DAC + 3, 0, 8,
+ VGA_REG_END
+};
+
VGA8
_s3Inb (VgaCard *card, VGA16 port)
{
VGAVOL8 *reg;
if (card->closure)
- return *(((VGAVOL8 *) card->closure) + port);
+ return VgaReadMemb ((VGA32) card->closure + port);
else
return VgaInb (port);
}
@@ -1016,10 +1101,8 @@ _s3Inb (VgaCard *card, VGA16 port)
void
_s3Outb (VgaCard *card, VGA8 value, VGA16 port)
{
- VGAVOL8 *reg;
-
if (card->closure)
- *(((VGAVOL8 *) card->closure) + port) = value;
+ VgaWriteMemb (value, (VGA32) card->closure + port);
else
VgaOutb (value, port);
}
@@ -1050,14 +1133,19 @@ _s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
map->access = VgaAccessDone;
/* reset AFF to index */
(void) _s3Inb (card, 0x3da);
+ if (reg >= 16)
+ reg |= 0x20;
_s3Outb (card, reg, 0x3c0);
if (write)
_s3Outb (card, map->value, 0x3c0);
else
map->value = _s3Inb (card, 0x3c1);
- /* enable video display again */
- (void) _s3Inb (card, 0x3da);
- _s3Outb (card, 0x20, 0x3c0);
+ if (!(reg & 0x20))
+ {
+ /* enable video display again */
+ (void) _s3Inb (card, 0x3da);
+ _s3Outb (card, 0x20, 0x3c0);
+ }
return;
}
else if (reg < S3_CR + S3_NCR)
@@ -1068,6 +1156,11 @@ _s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
map->value = 1;
map->index = reg - S3_CR;
}
+ else if (reg < S3_DAC + S3_NDAC)
+ {
+ map->access = VgaAccessIo;
+ map->port = 0x3c6 + reg - S3_DAC;
+ }
else switch (reg) {
case S3_MISC_OUT:
map->access = VgaAccessIo;
@@ -1076,6 +1169,10 @@ _s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
else
map->port = 0x3cc;
break;
+ case S3_INPUT_STATUS_1:
+ map->access = VgaAccessIo;
+ map->port = 0x3da;
+ break;
}
if (card->closure)
{
@@ -1115,7 +1212,7 @@ s3Save (S3Vga *s3vga)
s3vga->save_register_lock_1 = s3Get (s3vga, s3_register_lock_1);
s3SetImm (s3vga, s3_register_lock_1, 0x48);
s3vga->save_register_lock_2 = s3Get (s3vga, s3_register_lock_2);
- s3SetImm (s3vga, s3_register_lock_2, 0xa0);
+ s3SetImm (s3vga, s3_register_lock_2, 0xa5);
s3vga->save_unlock_extended_sequencer = s3Get (s3vga, s3_unlock_extended_sequencer);
s3SetImm (s3vga, s3_unlock_extended_sequencer, 0x06);
s3vga->save_lock_horz = s3Get (s3vga, s3_lock_horz);
diff --git a/hw/kdrive/savage/s3reg.h b/hw/kdrive/savage/s3reg.h
index f1ac18d03..6665de454 100644
--- a/hw/kdrive/savage/s3reg.h
+++ b/hw/kdrive/savage/s3reg.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.h,v 1.1 1999/11/19 13:53:57 hohndel Exp $ */
#ifndef _S3REG_H_
#define _S3REG_H_
@@ -37,8 +37,11 @@
#define S3_NAR 0x15
#define S3_CR (S3_AR+S3_NAR)
#define S3_NCR 0xc0
-#define S3_MISC_OUT (S3_CR+S3_NCR)
-#define S3_NREG (S3_MISC_OUT+1)
+#define S3_DAC (S3_CR+S3_NCR)
+#define S3_NDAC 4
+#define S3_MISC_OUT (S3_DAC + S3_NDAC)
+#define S3_INPUT_STATUS_1 (S3_MISC_OUT+1)
+#define S3_NREG (S3_INPUT_STATUS_1+1)
extern VgaReg s3_h_total[];
extern VgaReg s3_h_display_end[];
@@ -63,9 +66,13 @@ extern VgaReg s3_count_by_4_mode[];
extern VgaReg s3_doubleword_mode[];
extern VgaReg s3_v_blank_start[];
extern VgaReg s3_v_blank_end[];
+extern VgaReg s3_2bk_cga[];
+extern VgaReg s3_4bk_hga[];
extern VgaReg s3_v_total_double[];
+extern VgaReg s3_address_16k_wrap[];
extern VgaReg s3_word_mode[];
extern VgaReg s3_byte_mode[];
+extern VgaReg s3_hardware_reset[];
extern VgaReg s3_line_compare[];
extern VgaReg s3_device_id[];
extern VgaReg s3_revision[];
@@ -74,6 +81,7 @@ extern VgaReg s3_enhanced_memory_mapping[];
extern VgaReg s3_enable_sff[];
extern VgaReg s3_lock_dac_writes[];
extern VgaReg s3_border_select[];
+extern VgaReg s3_lock_palette[];
extern VgaReg s3_lock_vert[];
extern VgaReg s3_lock_horz[];
extern VgaReg s3_io_disable[];
@@ -117,6 +125,7 @@ extern VgaReg s3_enable_2d_3d[];
extern VgaReg s3_pci_disconnect_enable[];
extern VgaReg s3_pci_retry_enable[];
extern VgaReg s3_color_mode[];
+extern VgaReg s3_primary_stream_timeout[];
extern VgaReg s3_master_control_unit_timeout[];
extern VgaReg s3_command_buffer_timeout[];
extern VgaReg s3_lpb_timeout[];
@@ -124,6 +133,8 @@ extern VgaReg s3_cpu_timeout[];
extern VgaReg s3_2d_graphics_engine_timeout[];
extern VgaReg s3_fifo_drain_delay[];
extern VgaReg s3_fifo_fetch_timing[];
+extern VgaReg s3_dac_power_up_time[];
+extern VgaReg s3_dac_power_saving_disable[];
extern VgaReg s3_primary_stream_l1[];
extern VgaReg s3_dot_clock_8[];
@@ -161,10 +172,22 @@ extern VgaReg s3_vga_dclk_m2[];
extern VgaReg s3_vga_clk_select[];
extern VgaReg s3_select_graphics_mode[];
extern VgaReg s3_enable_blinking[];
+extern VgaReg s3_border_color[];
+
+extern VgaReg s3_io_addr_select[];
+extern VgaReg s3_enable_ram[];
extern VgaReg s3_clock_select[];
extern VgaReg s3_horz_sync_neg[];
extern VgaReg s3_vert_sync_neg[];
+extern VgaReg s3_display_mode_inactive[];
+extern VgaReg s3_vertical_sync_active[];
+
+extern VgaReg s3_dac_mask[];
+extern VgaReg s3_dac_read_index[];
+extern VgaReg s3_dac_write_index[];
+extern VgaReg s3_dac_data[];
+
#define s3Get(sv,r) VgaGet(&(sv)->card, (r))
#define s3GetImm(sv,r) VgaGetImm(&(sv)->card, (r))
#define s3Set(sv,r,v) VgaSet(&(sv)->card, (r), (v))
diff --git a/hw/kdrive/savage/s3stub.c b/hw/kdrive/savage/s3stub.c
index 59e187984..31929976c 100644
--- a/hw/kdrive/savage/s3stub.c
+++ b/hw/kdrive/savage/s3stub.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3stub.c,v 1.1 1999/11/19 13:53:57 hohndel Exp $ */
#include "s3.h"
@@ -30,6 +30,13 @@ void
InitCard (char *name)
{
KdCardAttr attr;
+#ifdef VXWORKS
+ attr.naddr = 2;
+ attr.io = 0;
+ attr.address[0] = 0xbc000000; /* registers */
+ attr.address[1] = 0xba000000; /* frame buffer */
+ KdCardInfoAdd (&s3Funcs, &attr, 0);
+#else
CARD32 count;
count = 0;
@@ -38,6 +45,7 @@ InitCard (char *name)
KdCardInfoAdd (&s3Funcs, &attr, 0);
count++;
}
+#endif
}
void
@@ -49,12 +57,31 @@ InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput (int argc, char **argv)
{
+#ifdef VXWORKS
+ KdInitInput (&VxWorksMouseFuncs, &VxWorksKeyboardFuncs);
+#endif
+#ifdef linux
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
+#endif
}
-void
-OsVendorInit (void)
+extern int s3CpuTimeout;
+extern int s3AccelTimeout;
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ int ret;
+
+ if (!strcmp (argv[i], "-cpu"))
+ {
+ s3CpuTimeout = strtol(argv[i+1], NULL, 0);
+ return 2;
+ }
+ if (!strcmp (argv[i], "-accel"))
+ {
+ s3AccelTimeout = strtol (argv[i+1], NULL, 0);
+ return 2;
+ }
+ return KdProcessArgument (argc, argv, i);
}
-
diff --git a/hw/kdrive/sis530/sis.c b/hw/kdrive/sis530/sis.c
index e79ce1a4a..b888b0d69 100644
--- a/hw/kdrive/sis530/sis.c
+++ b/hw/kdrive/sis530/sis.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/sis530/sis.c,v 1.1 1999/11/19 13:53:58 hohndel Exp $ */
#include "sis.h"
@@ -932,6 +932,7 @@ sisCardFini (KdCardInfo *card)
KdCardFuncs sisFuncs = {
sisCardInit,
sisScreenInit,
+ 0,
sisPreserve,
sisEnable,
sisDPMS,
@@ -946,6 +947,7 @@ KdCardFuncs sisFuncs = {
0,
sisDrawInit,
sisDrawEnable,
+ sisDrawSync,
sisDrawDisable,
sisDrawFini,
sisGetColors,
diff --git a/hw/kdrive/sis530/sis.h b/hw/kdrive/sis530/sis.h
index 4e19ef62b..a1dc7bab7 100644
--- a/hw/kdrive/sis530/sis.h
+++ b/hw/kdrive/sis530/sis.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/sis530/sis.h,v 1.1 1999/11/19 13:53:58 hohndel Exp $ */
#ifndef _SIS_H_
#define _SIS_H_
@@ -1098,6 +1098,7 @@ void sisRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
Bool sisDrawInit (ScreenPtr pScreen);
void sisDrawEnable (ScreenPtr pScreen);
+void sisDrawSync (ScreenPtr pScreen);
void sisDrawDisable (ScreenPtr pScreen);
void sisDrawFini (ScreenPtr pScreen);
diff --git a/hw/kdrive/sis530/sisdraw.c b/hw/kdrive/sis530/sisdraw.c
index 836f54e79..5abe7d30b 100644
--- a/hw/kdrive/sis530/sisdraw.c
+++ b/hw/kdrive/sis530/sisdraw.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/sis530/sisdraw.c,v 1.1 1999/11/19 13:53:59 hohndel Exp $ */
#include "sis.h"
#include "sisdraw.h"
@@ -292,7 +292,7 @@ sisGlyphBltClipped (DrawablePtr pDrawable,
}
_sisClip (sis, 0, 0,
pScreenPriv->screen->width, pScreenPriv->screen->height);
- _sisWaitIdleEmpty(sis);
+ KdMarkSync (pDrawable->pScreen);
}
Bool
@@ -493,7 +493,7 @@ sisTEGlyphBlt (DrawablePtr pDrawable,
}
if (imageBlt)
sis->u.general.clip_right = pScreenPriv->screen->width;
- _sisWaitIdleEmpty(sis);
+ KdMarkSync (pDrawable->pScreen);
return TRUE;
}
@@ -704,7 +704,7 @@ sisGlyphBlt(DrawablePtr pDrawable,
}
x += pci->metrics.characterWidth;
}
- _sisWaitIdleEmpty(sis);
+ KdMarkSync (pDrawable->pScreen);
return TRUE;
}
/*
@@ -737,7 +737,7 @@ sisPolyGlyphBlt (DrawablePtr pDrawable,
return;
}
}
- fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
}
void
@@ -764,7 +764,7 @@ sisImageGlyphBlt (DrawablePtr pDrawable,
return;
}
}
- fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
}
#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
@@ -896,7 +896,7 @@ sisFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
_sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
pBox++;
}
- _sisWaitIdleEmpty(sis);
+ KdMarkSync (pDrawable->pScreen);
}
void
@@ -913,7 +913,7 @@ sisFillBoxStipple (DrawablePtr pDrawable, GCPtr pGC,
_sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
pBox++;
}
- _sisWaitIdleEmpty (sis);
+ KdMarkSync (pDrawable->pScreen);
}
void
@@ -931,7 +931,7 @@ sisFillBoxTiled (DrawablePtr pDrawable,
_sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
pBox++;
}
- _sisWaitIdleEmpty (sis);
+ KdMarkSync (pDrawable->pScreen);
}
/*
@@ -1003,7 +1003,7 @@ sisCopyNtoN (DrawablePtr pSrcDrawable,
_sisBlt (sis, srcX, srcY, dstX, dstY, w, h, cmd|flags);
pbox++;
}
- _sisWaitIdleEmpty(sis);
+ KdMarkSync (pDstDrawable->pScreen);
}
RegionPtr
@@ -1022,7 +1022,7 @@ sisCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
srcx, srcy, width, height,
dstx, dsty, sisCopyNtoN, 0, 0);
}
- return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
srcx, srcy, width, height, dstx, dsty);
}
@@ -1183,7 +1183,7 @@ sisCopy1toN (DrawablePtr pSrcDrawable,
pbox->x2 - dstx, pbox->y2 - dsty);
pbox++;
}
- _sisWaitIdleEmpty (sis);
+ KdMarkSync (pDstDrawable->pScreen);
}
RegionPtr
@@ -1207,7 +1207,7 @@ sisCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
srcx, srcy, width, height,
dstx, dsty, sisCopy1toN, bitPlane, &args);
}
- return fbCopyPlane(pSrcDrawable, pDstDrawable, pGC,
+ return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC,
srcx, srcy, width, height,
dstx, dsty, bitPlane);
}
@@ -1227,7 +1227,7 @@ sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
if (!sisFillOk (pGC))
{
- fbFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
return;
}
nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
@@ -1269,7 +1269,7 @@ sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
_sisRect(sis,x,y,width,1,cmd);
}
}
- _sisWaitIdleEmpty (sis);
+ KdMarkSync (pDrawable->pScreen);
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
}
@@ -1296,7 +1296,7 @@ sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
if (!sisFillOk (pGC))
{
- fbPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
+ KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
return;
}
prgnClip = fbGetCompositeClip(pGC);
@@ -1450,25 +1450,25 @@ sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
static const GCOps sisOps = {
sisFillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
sisCopyArea,
sisCopyPlane,
- fbPolyPoint,
- fbPolyLine,
- fbPolySegment,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
miFillPolygon,
sisPolyFillRect,
- fbPolyFillArc,
+ KdCheckPolyFillArc,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
sisImageGlyphBlt,
sisPolyGlyphBlt,
- fbPushPixels,
+ KdCheckPushPixels,
#ifdef NEED_LINEHELPER
,NULL
#endif
@@ -1484,7 +1484,7 @@ sisValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
if (pDrawable->type == DRAWABLE_WINDOW)
pGC->ops = (GCOps *) &sisOps;
else
- pGC->ops = (GCOps *) &fbGCOps;
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
}
GCFuncs sisGCFuncs = {
@@ -1506,6 +1506,8 @@ sisCreateGC (GCPtr pGC)
if (pGC->depth != 1)
pGC->funcs = &sisGCFuncs;
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
+
return TRUE;
}
@@ -1601,7 +1603,7 @@ sisPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
}
break;
}
- fbPaintWindow (pWin, pRegion, what);
+ KdCheckPaintWindow (pWin, pRegion, what);
}
Bool
@@ -1611,6 +1613,10 @@ sisDrawInit (ScreenPtr pScreen)
sisScreenInfo(pScreenPriv);
/*
+ * Hook up asynchronous drawing
+ */
+ KdScreenInitAsync (pScreen);
+ /*
* Replace various fb screen functions
*/
pScreen->CreateGC = sisCreateGC;
@@ -1632,7 +1638,6 @@ sisDrawEnable (ScreenPtr pScreen)
base = pScreenPriv->screen->frameBuffer - sisc->frameBuffer;
stride = pScreenPriv->screen->byteStride;
- _sisWaitIdleEmpty(sis);
sis->u.general.dst_base = base;
sis->u.general.dst_pitch = stride;
sis->u.general.dst_height = pScreenPriv->screen->height;
@@ -1642,6 +1647,14 @@ sisDrawEnable (ScreenPtr pScreen)
_sisRect (sis, 0, 0,
pScreenPriv->screen->width, pScreenPriv->screen->height,
cmd);
+ KdMarkSync (pScreen);
+}
+
+void
+sisDrawSync (ScreenPtr pScreen)
+{
+ SetupSis(pScreen);
+
_sisWaitIdleEmpty (sis);
}
diff --git a/hw/kdrive/sis530/sisstub.c b/hw/kdrive/sis530/sisstub.c
index 9c3c30d86..ed32b120b 100644
--- a/hw/kdrive/sis530/sisstub.c
+++ b/hw/kdrive/sis530/sisstub.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisstub.c,v 1.1 1999/11/19 13:54:00 hohndel Exp $ */
#include "sis.h"
@@ -46,8 +46,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}
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
diff --git a/hw/kdrive/trident/trident.c b/hw/kdrive/trident/trident.c
index 384800f78..db8b9ef8f 100644
--- a/hw/kdrive/trident/trident.c
+++ b/hw/kdrive/trident/trident.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/trident/trident.c,v 1.1 1999/11/19 13:54:01 hohndel Exp $ */
#include "trident.h"
#define extern
@@ -86,6 +86,12 @@ tridentScreenInit (KdScreenInfo *screen)
return TRUE;
}
+Bool
+tridentInitScreen (ScreenPtr pScreen)
+{
+ return fbdevInitScreen (pScreen);
+}
+
CARD8
tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index)
{
@@ -255,6 +261,7 @@ tridentCardFini (KdCardInfo *card)
KdCardFuncs tridentFuncs = {
tridentCardInit, /* cardinit */
tridentScreenInit, /* scrinit */
+ tridentInitScreen, /* initScreen */
tridentPreserve, /* preserve */
tridentEnable, /* enable */
tridentDPMS, /* dpms */
@@ -271,6 +278,7 @@ KdCardFuncs tridentFuncs = {
tridentDrawInit, /* initAccel */
tridentDrawEnable, /* enableAccel */
+ tridentDrawSync, /* syncAccel */
tridentDrawDisable, /* disableAccel */
tridentDrawFini, /* finiAccel */
diff --git a/hw/kdrive/trident/trident.h b/hw/kdrive/trident/trident.h
index f726e0701..ea50448ef 100644
--- a/hw/kdrive/trident/trident.h
+++ b/hw/kdrive/trident/trident.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/trident/trident.h,v 1.1 1999/11/19 13:54:01 hohndel Exp $ */
#ifndef _TRIDENT_H_
#define _TRIDENT_H_
@@ -61,13 +61,22 @@ typedef struct _cop {
#define COP_MULTI_TEXTURE_ADVANCED 0x20000000
#define COP_MULTI_MASK 0xf0000000
-
#define COP_DEPTH_8 0x00000000
#define COP_DEPTH_16 0x00000001
#define COP_DEPTH_24_32 0x00000002
#define COP_DEPTH_15 0x00000005
#define COP_DEPTH_DITHER_DISABLE 0x00000008
+
+#define COP_ALPHA_RESULT_ALPHA 0x00100000
+#define COP_ALPHA_DEST_ALPHA 0x00200000
+#define COP_ALPHA_SOURCE_ALPHA 0x00400000
+#define COP_ALPHA_WRITE_ENABLE 0x00800000
+#define COP_ALPHA_TEST_ENABLE 0x01000000
+#define COP_ALPHA_BLEND_ENABLE 0x02000000
+#define COP_ALPHA_DEST_VALUE 0x04000000
+#define COP_ALPHA_SOURCE_VALUE 0x08000000
+
VOL32 command; /* 0x24 */
#define COP_OP_NULL 0x00000000
#define COP_OP_LINE 0x20000000
@@ -174,6 +183,9 @@ void
tridentDrawEnable (ScreenPtr pScreen);
void
+tridentDrawSync (ScreenPtr pScreen);
+
+void
tridentDrawDisable (ScreenPtr pScreen);
void
diff --git a/hw/kdrive/trident/tridentcurs.c b/hw/kdrive/trident/tridentcurs.c
index 9c4ebb5d0..241b5bd1a 100644
--- a/hw/kdrive/trident/tridentcurs.c
+++ b/hw/kdrive/trident/tridentcurs.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/trident/tridentcurs.c,v 1.1 1999/11/19 13:54:01 hohndel Exp $ */
#include "trident.h"
#include "cursorstr.h"
@@ -82,39 +82,14 @@ tridentMoveCursor (ScreenPtr pScreen, int x, int y)
_tridentMoveCursor (pScreen, x, y);
}
-
static void
tridentAllocCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
- xColorItem sourceColor, maskColor;
-
- /*
- * Set these to an invalid pixel value so that
- * when the store colors comes through, the cursor
- * won't get recolored
- */
- pCurPriv->source = ~0;
- pCurPriv->mask = ~0;
- /*
- * XXX S3 bug workaround; s3 chip doesn't use RGB values from
- * the cursor color registers as documented, rather it uses
- * them to index the DAC. This is in the errata though.
- */
- 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);
- pCurPriv->source = sourceColor.pixel;
- pCurPriv->mask = maskColor.pixel;
+ KdAllocateCursorPixels (pScreen, pCursor,
+ &pCurPriv->source, &pCurPriv->mask);
switch (pScreenPriv->screen->bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
diff --git a/hw/kdrive/trident/tridentdraw.c b/hw/kdrive/trident/tridentdraw.c
index f64444c53..2bb4c5763 100644
--- a/hw/kdrive/trident/tridentdraw.c
+++ b/hw/kdrive/trident/tridentdraw.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/trident/tridentdraw.c,v 1.1 1999/11/19 13:54:01 hohndel Exp $ */
#include "trident.h"
#include "tridentdraw.h"
@@ -84,7 +84,7 @@ tridentFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
_tridentRect(cop,pBox->x1,pBox->y1,pBox->x2-1,pBox->y2-1,cmd);
pBox++;
}
- _tridentWaitIdleEmpty(cop);
+ KdMarkSync(pDrawable->pScreen);
}
void
@@ -154,7 +154,7 @@ tridentCopyNtoN (DrawablePtr pSrcDrawable,
cop->command = cmd;
pbox++;
}
- _tridentWaitIdleEmpty(cop);
+ KdMarkSync(pDstDrawable->pScreen);
}
RegionPtr
@@ -173,8 +173,8 @@ tridentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
srcx, srcy, width, height,
dstx, dsty, tridentCopyNtoN, 0, 0);
}
- return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
- srcx, srcy, width, height, dstx, dsty);
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
}
BOOL
@@ -217,7 +217,7 @@ tridentFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
if (!tridentFillOk (pGC))
{
- fbFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
return;
}
nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
@@ -261,10 +261,10 @@ tridentFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
width = *pwidth++;
if (width)
{
- _tridentRect(cop,x,y,x + width,y,cmd);
+ _tridentRect(cop,x,y,x + width - 1,y,cmd);
}
}
- _tridentWaitIdleEmpty (cop);
+ KdMarkSync(pDrawable->pScreen);
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
}
@@ -291,7 +291,7 @@ tridentPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
if (!tridentFillOk (pGC))
{
- fbPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
+ KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
return;
}
prgnClip = fbGetCompositeClip(pGC);
@@ -491,7 +491,7 @@ tridentSolidBoxClipped (DrawablePtr pDrawable,
_tridentRect(cop,partX1, partY1, partX2-1, partY2-1,cmd);
}
- _tridentWaitIdleEmpty(cop);
+ KdMarkSync(pDrawable->pScreen);
}
void
@@ -527,7 +527,7 @@ tridentImageGlyphBlt (DrawablePtr pDrawable,
depthMask = FbFullMask(pDrawable->depth);
if ((pGC->planemask & depthMask) != depthMask)
{
- fbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
+ KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
return;
}
glyph = 0;
@@ -575,6 +575,8 @@ tridentImageGlyphBlt (DrawablePtr pDrawable,
opaque = FALSE;
}
+ KdCheckSync (pDrawable->pScreen);
+
ppci = ppciInit;
while (nglyph--)
{
@@ -623,25 +625,25 @@ tridentImageGlyphBlt (DrawablePtr pDrawable,
static const GCOps tridentOps = {
tridentFillSpans,
- fbSetSpans,
- fbPutImage,
+ KdCheckSetSpans,
+ KdCheckPutImage,
tridentCopyArea,
- fbCopyPlane,
- fbPolyPoint,
- fbPolyLine,
- fbPolySegment,
+ KdCheckCopyPlane,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
miPolyRectangle,
- fbPolyArc,
+ KdCheckPolyArc,
miFillPolygon,
tridentPolyFillRect,
- fbPolyFillArc,
+ KdCheckPolyFillArc,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
tridentImageGlyphBlt,
- fbPolyGlyphBlt,
- fbPushPixels,
+ KdCheckPolyGlyphBlt,
+ KdCheckPushPixels,
#ifdef NEED_LINEHELPER
,NULL
#endif
@@ -657,7 +659,7 @@ tridentValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
if (pDrawable->type == DRAWABLE_WINDOW)
pGC->ops = (GCOps *) &tridentOps;
else
- pGC->ops = (GCOps *) &fbGCOps;
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
}
GCFuncs tridentGCFuncs = {
@@ -778,13 +780,17 @@ tridentPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
#endif
break;
}
- fbPaintWindow (pWin, pRegion, what);
+ KdCheckPaintWindow (pWin, pRegion, what);
}
Bool
tridentDrawInit (ScreenPtr pScreen)
{
/*
+ * Hook up asynchronous drawing
+ */
+ KdScreenInitAsync (pScreen);
+ /*
* Replace various fb screen functions
*/
pScreen->CreateGC = tridentCreateGC;
@@ -803,6 +809,7 @@ tridentDrawEnable (ScreenPtr pScreen)
CARD32 base;
CARD16 stride;
CARD32 format;
+ CARD32 alpha;
int tries;
stride = pScreenPriv->screen->pixelStride;
@@ -845,7 +852,7 @@ tridentDrawEnable (ScreenPtr pScreen)
_tridentRect (cop, 0, 0,
pScreenPriv->screen->width, pScreenPriv->screen->height,
cmd);
- _tridentWaitIdleEmpty (cop);
+ KdMarkSync (pScreen);
}
void
@@ -857,3 +864,11 @@ void
tridentDrawFini (ScreenPtr pScreen)
{
}
+
+void
+tridentDrawSync (ScreenPtr pScreen)
+{
+ SetupTrident(pScreen);
+
+ _tridentWaitIdleEmpty(cop);
+}
diff --git a/hw/kdrive/trident/tridentdraw.h b/hw/kdrive/trident/tridentdraw.h
index 5fa64d2a7..7b61a4a3b 100644
--- a/hw/kdrive/trident/tridentdraw.h
+++ b/hw/kdrive/trident/tridentdraw.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/trident/tridentdraw.h,v 1.1 1999/11/19 13:54:02 hohndel Exp $ */
#ifndef _TRIDENTDRAW_H_
#define _TRIDENTDRAW_H_
@@ -30,10 +30,13 @@
tridentCardInfo(pScreenPriv); \
Cop *cop = tridentc->cop
+#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
+
#define _tridentInit(cop,tridentc) { \
if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
(cop)->multi = (tridentc)->cop_depth; \
(cop)->multi = (tridentc)->cop_stride; \
+ (cop)->multi = TridentAlpha; \
} \
#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
@@ -56,7 +59,7 @@
#define _tridentWaitDone(cop) while ((cop)->status & COP_STATUS_BUSY)
-#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop);
+#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop)
#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
diff --git a/hw/kdrive/trident/tridentstub.c b/hw/kdrive/trident/tridentstub.c
index b0005e7c7..74afe7200 100644
--- a/hw/kdrive/trident/tridentstub.c
+++ b/hw/kdrive/trident/tridentstub.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentstub.c,v 1.1 1999/11/19 13:54:02 hohndel Exp $ */
#include "trident.h"
@@ -47,8 +47,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}
diff --git a/hw/kdrive/trio/s3.c b/hw/kdrive/trio/s3.c
index 3233173cb..182c59b17 100644
--- a/hw/kdrive/trio/s3.c
+++ b/hw/kdrive/trio/s3.c
@@ -21,139 +21,13 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.1 1999/11/19 13:54:02 hohndel Exp $ */
#include "s3.h"
#define REGISTERS_OFFSET (0x1000000)
#define PACKED_OFFSET (0x8100)
-/*
- * Clock synthesis:
- *
- * f_out = f_ref * ((M + 2) / ((N + 2) * (1 << R)))
- *
- * Constraints:
- *
- * 1. 135MHz <= f_ref * ((M + 2) / (N + 2)) <= 270 MHz
- * 2. N >= 1
- *
- * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
- * Horizontal refresh rate = clock / (hsize + hblank)
- */
-
-#define DEFAULT_S3_TIMING 1
-
-S3Timing s3Timings[] = {
- /* FP BP BLANK */
- /* M N R blank bios5 */
- { 640, 480, 60,
- 16, 48, 160, /* horizontal 31.321 KHz */
- 10, 33, 45, /* vertical 59.568 Hz */
- 26, 0, 3, /* pixel 25.057 MHz */
- },
-
- { 800, 600, 85,
- 32, 152, 248, /* horizontal 53.673 KHz */
- 1, 27, 31, /* vertical 85.060 Hz */
- 108, 5, 2, /* pixel 56.249 MHz */
- },
- { 800, 600, 75,
- 16, 160, 256, /* horizontal 46.891 KHz */
- 1, 21, 25, /* vertical 75.025 Hz */
- 81, 4, 2, /* pixel 49.516 MHz */
- },
- { 800, 600, 72,
- 56, 64, 240, /* horizontal 48.186 KHz */
- 37, 23, 66, /* vertical 72.351 Hz */
- 26, 0, 2, /* pixel 50.113 MHz */
- },
-
- { 1024, 768, 85,
- 48, 208, 352, /* horizontal 68.676 KHz */
- 1, 36, 40, /* vertical 84.996 Hz */
- 64, 3, 1, /* pixel 94.499 MHz */
- },
- { 1024, 768, 75,
- 16, 176, 288, /* horizontal 60.022 KHz */
- 1, 28, 32, /* vertical 75.028 Hz */
- 20, 0, 1, /* pixel 78.749 MHz */
- },
- { 1024, 768, 70,
- 24, 144, 304, /* horizontal 56.604 KHz */
- 3, 29, 38, /* vertical 70.227 Hz */
- 40, 2, 1, /* pixel 75.170 MHz */
- },
- { 1024, 768, 66,
- 24, 144, 304, /* horizontal 53.234 KHz */
- 3, 29, 38, /* vertical 66.047 Hz */
- 77, 6, 1, /* pixel 70.695 MHz */
- },
-
- { 1152, 900, 85,
- 48, 208, 384, /* horizontal 79.900 KHz */
- 1, 32, 38, /* vertical 85.181 Hz */
- 118, 5, 1, /* pixel 122.726 MHz */
- },
- { 1152, 900, 75,
- 32, 208, 384, /* horizontal 70.495 Khz */
- 1, 32, 38, /* vertical 75.154 Hz */
- 119, 6, 1, /* pixel 108.280 MHz */
- },
- { 1152, 900, 70,
- 32, 208, 384, /* horizontal 65.251 KHz */
- 2, 32, 38, /* vertical 69.564 Hz */
- 12, 0, 0, /* pixel 100.226 MHz */
- },
- { 1152, 900, 66,
- 32, 208, 384, /* horizontal 61.817 KHz */
- 1, 32, 38, /* vertical 65.903 Hz */
- 124, 17, 0, /* pixel 94.951 MHz */
- },
- { 1280, 1024, 85,
- 16, 248, 416, /* horizontal 90.561 KHz */
- 1, 40, 45, /* vertical 84.717 Hz */
- 116, 9, 0, /* pixel 153.593 MHz */
- },
- { 1280, 1024, 75,
- 16, 248, 408, /* horizontal 80.255 KHz */
- 1, 38, 42, /* vertical 75.285 Hz */
- 111, 4, 1, /* pixel 134.828 MHz */
- },
- { 1280, 1024, 70,
- 32, 248, 400, /* horizontal 74.573 KHz */
- 0, 36, 39, /* vertical 70.153 Hz */
- 68, 2, 1, /* pixel 125.283 MHz */
- },
- { 1280, 1024, 66,
- 32, 248, 400, /* horizontal 70.007 KHz */
- 0, 36, 39, /* vertical 65.858 Hz */
- 113, 5, 1, /* pixel 117.612 MHz */
- },
-
- { 1600, 1200, 85,
- 64, 304, 560, /* horizontal 106.059 KHz */
- 1, 46, 50, /* vertical 84.847 Hz */
- 126, 6, 0, /* pixel 229.088 MHz */
- },
- { 1600, 1200, 75,
- 64, 304, 560, /* horizontal 93.748 KHz */
- 1, 46, 50, /* vertical 74.999 Hz */
- 97, 5, 0, /* pixel 202.497 MHz */
- },
- { 1600, 1200, 70,
- 56, 304, 588, /* horizontal 87.524 KHz */
- 1, 46, 50, /* vertical 70.019 Hz */
- 105, 6, 0, /* pixel 191.503 MHz */
- },
- { 1600, 1200, 65,
- 56, 308, 524, /* horizontal 80.050 KHz */
- 1, 38, 42, /* vertical 64.453 Hz */
- 93, 6, 0, /* pixel 170.026 MHz */
- },
-};
-
-#define NUM_S3_TIMINGS (sizeof (s3Timings) / sizeof (s3Timings[0]))
CARD8
_s3ReadIndexRegister (volatile CARD8 *base, CARD8 index)
@@ -245,20 +119,7 @@ _s3LoadCrtc (S3Ptr s3, S3Crtc *crtc)
crtc->dclk_value_high = GetSrtc (s3, 0x13);
crtc->control_2 = GetSrtc (s3, 0x15);
crtc->ramdac_control = GetSrtc (s3, 0x18);
-
- crtc->dclk_value_low_savage = GetSrtc (s3, 0x36);
- crtc->dclk_pll_m0_savage_0_7 = GetSrtc (s3, 0x37);
- crtc->dclk_pll_m1_savage_0_7 = GetSrtc (s3, 0x38);
- crtc->extended_seq_39 = GetSrtc (s3, 0x39);
-
- fprintf (stderr, "SR1A 0x%x SR1B 0x%x\n",
- GetSrtc (s3, 0x1a),
- GetSrtc (s3, 0x1b));
- fprintf (stderr, "SR36 0x%x SR37 0x%x SR38 0x%x SR39 0x%x\n",
- GetSrtc (s3, 0x36),
- GetSrtc (s3, 0x37),
- GetSrtc (s3, 0x38),
- GetSrtc (s3, 0x39));
+
/* combine values */
switch (crtc_ge_screen_width(crtc)) {
@@ -391,12 +252,8 @@ _s3SetDepth (S3Ptr s3, S3Crtc *crtc)
*/
save_3c2 = s3->crt_vga_3cc;
DRAW_DEBUG ((DEBUG_S3INIT, "save_3c2 0x%x", save_3c2));
- s3->crt_vga_3c2 = 0x0f;
+ s3->crt_vga_3c2 = save_3c2 | 0x0c;
- PutSrtc (s3, 0x36, crtc->dclk_value_low_savage);
- PutSrtc (s3, 0x37, crtc->dclk_pll_m0_savage_0_7);
- PutSrtc (s3, 0x38, crtc->dclk_pll_m1_savage_0_7);
- PutSrtc (s3, 0x39, crtc->extended_seq_39);
PutSrtc(s3, 0x12, crtc->dclk_value_low);
PutSrtc(s3, 0x13, crtc->dclk_value_high);
@@ -453,7 +310,6 @@ s3Reset (S3CardInfo *s3c)
s3->scissors_br = 0x0fff0fff;
_s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, save->clock_mode);
- PutSrtc(s3, 0x08, save->locksrtc);
PutCrtc(s3, 0x39, save->lock2);
PutCrtc(s3, 0x38, save->lock1);
@@ -478,11 +334,6 @@ s3Save (S3CardInfo *s3c)
save->lock1 = GetCrtc(s3, 0x38);
save->lock2 = GetCrtc(s3, 0x39);
- save->locksrtc = GetSrtc (s3, 0x08);
-
- /* unlock srtc registers to read them */
- PutSrtc (s3, 0x08, 0x06);
-
save->clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01);
_s3UnlockExt (s3);
@@ -502,10 +353,8 @@ s3CardInit (KdCardInfo *card)
S3Ptr s3;
int size;
CARD8 *registers;
- CARD32 s3FrameBuffer;
- CARD32 s3Registers;
+ CARD32 s3Address = card->attr.address[0];
CARD8 *temp_buffer;
- CARD32 max_memory;
DRAW_DEBUG ((DEBUG_S3INIT, "s3CardInit"));
s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo));
@@ -519,23 +368,8 @@ s3CardInit (KdCardInfo *card)
card->driver = s3c;
- if (card->attr.naddr > 1)
- {
- s3FrameBuffer = card->attr.address[1];
- s3Registers = card->attr.address[0];
- max_memory = 32 * 1024 * 1024;
- s3c->savage = TRUE;
- }
- else
- {
- s3FrameBuffer = card->attr.address[0];
- s3Registers = s3FrameBuffer + REGISTERS_OFFSET;
- max_memory = 4 * 1024 * 1024;
- s3c->savage = FALSE;
- }
-
- fprintf (stderr, "S3 at 0x%x/0x%x\n", s3Registers, s3FrameBuffer);
- registers = KdMapDevice (s3Registers,
+ fprintf (stderr, "S3 at 0x%x\n", s3Address);
+ registers = KdMapDevice (s3Address + REGISTERS_OFFSET,
sizeof (S3) + PACKED_OFFSET);
if (!registers)
{
@@ -546,34 +380,30 @@ s3CardInit (KdCardInfo *card)
s3c->registers = registers;
s3c->s3 = s3;
-#if 0
s3->crt_vga_3c3 = 1; /* wake up part from deep sleep */
s3->crt_vga_3c2 = 0x01 | 0x02 | 0x0c;
s3->crt_vga_3c4 = 0x58;
s3->crt_vga_3c5 = 0x10 | 0x3;
-#endif
/*
* Can't trust S3 register value for frame buffer amount, must compute
*/
- temp_buffer = KdMapDevice (s3FrameBuffer, max_memory);
+ temp_buffer = KdMapDevice (s3Address, 4096 * 1024);
- s3c->memory = KdFrameBufferSize (temp_buffer, max_memory);
+ s3c->memory = KdFrameBufferSize (temp_buffer, 4096 * 1024);
- fprintf (stderr, "Frame buffer 0x%x\n", s3c->memory);
-
DRAW_DEBUG ((DEBUG_S3INIT, "Detected frame buffer %d", s3c->memory));
KdUnmapDevice (temp_buffer, 4096 * 1024);
if (!s3c->memory)
{
- ErrorF ("Can't detect s3 frame buffer at 0x%x\n", s3FrameBuffer);
+ ErrorF ("Can't detect s3 frame buffer\n");
goto bail3;
}
- s3c->frameBuffer = KdMapDevice (s3FrameBuffer, s3c->memory);
+ s3c->frameBuffer = KdMapDevice (s3Address, s3c->memory);
if (!s3c->frameBuffer)
{
ErrorF ("Can't map s3 frame buffer\n");
@@ -593,6 +423,60 @@ bail0:
}
Bool
+s3ModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
+{
+ if (t->horizontal != 1600 &&
+ t->horizontal != 1280 &&
+ t->horizontal != 1152 &&
+ t->horizontal != 800 &&
+ t->horizontal != 640)
+ return FALSE;
+ if (t->clock > S3_MAX_CLOCK * 2)
+ return FALSE;
+}
+
+Bool
+s3ModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ S3CardInfo *s3c = (S3CardInfo *) card->driver;
+ int screen_size;
+ int pixel_width;
+ int byte_width;
+
+ if (screen->depth >= 24)
+ {
+ screen->depth = 24;
+ screen->bitsPerPixel = 32;
+ }
+ else if (screen->depth >= 16)
+ {
+ screen->depth = 16;
+ screen->bitsPerPixel = 16;
+ }
+ else if (screen->depth >= 15)
+ {
+ screen->depth = 15;
+ screen->bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->depth = 8;
+ screen->bitsPerPixel = 8;
+ }
+
+ byte_width = screen->width * (screen->bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->pixelStride = pixel_width;
+ screen->byteStride = byte_width;
+
+ screen_size = byte_width * screen->height;
+
+ return screen_size <= s3c->memory;
+}
+
+Bool
s3ScreenInit (KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
@@ -606,7 +490,7 @@ s3ScreenInit (KdScreenInfo *screen)
int pixel_width;
int m, n, r;
int i;
- S3Timing *t;
+ const KdMonitorTiming *t;
DRAW_DEBUG ((DEBUG_S3INIT, "s3ScreenInit"));
s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo));
@@ -626,29 +510,12 @@ s3ScreenInit (KdScreenInfo *screen)
DRAW_DEBUG ((DEBUG_S3INIT, "Requested parameters %dx%dx%d",
screen->width, screen->height, screen->rate));
- for (i = 0, t = s3Timings; i < NUM_S3_TIMINGS; i++, t++)
- {
- DRAW_DEBUG ((DEBUG_S3INIT, "Available parameters %dx%dx%d",
- t->horizontal, t->vertical, t->rate));
- if (t->horizontal >= screen->width &&
- t->vertical >= screen->height &&
- (!screen->rate || t->rate <= screen->rate))
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
screen->rate = t->rate;
screen->width = t->horizontal;
screen->height = t->vertical;
+ s3GetClock (t->clock, &m, &n, &r, 127, 31, 3);
#if 0
- s3GetClock (t, &m, &n, &r,
- s3c->savage ? 511 : 127,
- s3c->savage ? 127 : 31,
- s3c->savage ? 4 : 3);
-#else
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
-#endif
-#if 1
fprintf (stderr, "computed %d,%d,%d (%d) provided %d,%d,%d (%d)\n",
m, n, r, S3_CLOCK(m,n,r),
t->dac_m, t->dac_n, t->dac_r,
@@ -657,97 +524,13 @@ s3ScreenInit (KdScreenInfo *screen)
/*
* Can only operate in pixel-doubled mode at 8 bits per pixel
*/
- if (s3c->savage)
- {
- if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- screen->depth = 16;
- }
- else
- {
- if (screen->depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- screen->depth = 8;
- }
+ if (screen->depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
+ screen->depth = 8;
- for (;;)
+ if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported))
{
- if (screen->depth >= 24)
- {
- screen->depth = 24;
- screen->bitsPerPixel = 32;
- }
- else if (screen->depth >= 16)
- {
- screen->depth = 16;
- screen->bitsPerPixel = 16;
- }
- else if (screen->depth >= 15)
- {
- screen->depth = 15;
- screen->bitsPerPixel = 16;
- }
- else
- {
- screen->depth = 8;
- screen->bitsPerPixel = 8;
- }
-
- /* Normalize width to supported values */
-
- if (screen->width >= 1600)
- screen->width = 1600;
- else if (screen->width >= 1280)
- screen->width = 1280;
- else if (screen->width >= 1152)
- screen->width = 1152;
- else if (screen->width >= 1024)
- screen->width = 1024;
- else if (screen->width >= 800)
- screen->width = 800;
- else
- screen->width = 640;
-
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
- pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
-
- screen_size = byte_width * screen->height;
-
- if (screen_size <= s3c->memory)
- break;
-
- /*
- * Fix requested depth and geometry until it works
- */
- if (screen->depth > 16)
- screen->depth = 16;
- else if (screen->depth > 8)
- screen->depth = 8;
- else if (screen->width > 1152)
- {
- screen->width = 1152;
- screen->height = 900;
- }
- else if (screen->width > 1024)
- {
- screen->width = 1024;
- screen->height = 768;
- }
- else if (screen->width > 800)
- {
- screen->width = 800;
- screen->height = 600;
- }
- else if (screen->width > 640)
- {
- screen->width = 640;
- screen->height = 480;
- }
- else
- {
- xfree (s3s);
- return FALSE;
- }
+ xfree (s3s);
+ return FALSE;
}
memory = s3c->memory - screen_size;
@@ -886,7 +669,7 @@ s3Enable (ScreenPtr pScreen)
int h_blank_extend_;
int i;
CARD16 cursor_address;
- S3Timing *t;
+ const KdMonitorTiming *t;
int m, n, r;
DRAW_DEBUG ((DEBUG_S3INIT, "s3Enable"));
@@ -894,17 +677,7 @@ s3Enable (ScreenPtr pScreen)
DRAW_DEBUG ((DEBUG_S3INIT, "requested bpp %d current %d",
pScreenPriv->bitsPerPixel, s3c->save.crtc.bits_per_pixel));
- for (i = 0; i < NUM_S3_TIMINGS; i++)
- {
- t = &s3Timings[i];
-
- if (t->horizontal == screen->width &&
- t->vertical == screen->height &&
- t->rate <= screen->rate)
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
hfp = t->hfp;
hbp = t->hbp;
@@ -919,58 +692,23 @@ s3Enable (ScreenPtr pScreen)
crtcR = s3c->save.crtc;
crtc = &crtcR;
-#if 0
- if (s3c->savage)
- {
- m = ((int) crtc->dclk_pll_m_savage_8 << 8) | crtc->dclk_pll_m0_savage_0_7;
- n = (crtc->dclk_pll_n_savage_6 << 6) | crtc->dclk_pll_n_savage_0_5;
- r = (crtc->dclk_pll_r_savage_2 << 2) | crtc->dclk_pll_r_savage_0_1;
- fprintf (stderr, "old clock %d, %d, %d\n", m, n, r);
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
-#if 0
- s3GetClock (t, &m, &n, &r, 511, 127, 4);
- crtc->dclk_pll_m0_savage_0_7 = m;
- crtc->dclk_pll_m1_savage_0_7 = m;
- crtc->dclk_pll_m_savage_8 = m >> 8;
- crtc->dclk_pll_n_savage_0_5 = n;
- crtc->dclk_pll_n_savage_6 = n >> 6;
- crtc->dclk_pll_r_savage_0_1 = r;
- crtc->dclk_pll_r_savage_2 = r >> 2;
- crtc->dclk_pll_select_savage = 1;
-#endif
- fprintf (stderr, "new clock %d, %d, %d\n", m, n, r);
- }
- else
- {
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
- crtc->dclk_pll_m_trio = m;
- crtc->dclk_pll_n_trio = n;
- crtc->dclk_pll_r_trio = r;
- }
+ s3GetClock (t->clock, &m, &n, &r, 127, 31, 3);
+ crtc->dclk_pll_m_trio = m;
+ crtc->dclk_pll_n_trio = n;
+ crtc->dclk_pll_r_trio = r;
- if (!s3c->savage)
- {
- crtc->alt_refresh_count = 0x02;
- crtc->enable_alt_refresh = 1;
- }
- else
- {
- crtc->alt_refresh_count = 1;
- crtc->enable_alt_refresh = 0;
- }
+ crtc->alt_refresh_count = 0x02;
+ crtc->enable_alt_refresh = 1;
crtc->enable_256_or_more = 1;
DRAW_DEBUG ((DEBUG_S3INIT, "memory_bus_size %d\n", crtc->memory_bus_size));
- if (!s3c->savage)
- crtc->memory_bus_size = 1;
+ crtc->memory_bus_size = 1;
- if (!s3c->savage)
- crtc->dclk_over_2 = 0;
+ crtc->dclk_over_2 = 0;
crtc->dclk_invert = 0;
crtc->enable_clock_double = 0;
crtc->delay_blank = 0;
- if (!s3c->savage)
- crtc->extended_bios_5 = 0;
+ crtc->extended_bios_5 = 0;
/*
* Compute character lengths for horizontal timing values
*/
@@ -987,11 +725,12 @@ s3Enable (ScreenPtr pScreen)
* Set up for double-pixel mode, switch color modes,
* divide the dclk and delay h blank by 2 dclks
*/
- if (S3_CLOCK(m, n, r) > S3_MAX_CLOCK)
+ if (S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio,
+ crtc->dclk_pll_r_trio) > S3_MAX_CLOCK)
{
DRAW_DEBUG ((DEBUG_S3INIT, "S3 clock %g > 80MHz, using pixel double mode",
- S3_CLOCK(crtc->dclk_pll_m, crtc->dclk_pll_n,
- crtc->dclk_pll_r)));
+ S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio,
+ crtc->dclk_pll_r_trio)));
crtc->color_mode = 1;
crtc->dclk_over_2 = 1;
crtc->enable_clock_double = 1;
@@ -1001,50 +740,18 @@ s3Enable (ScreenPtr pScreen)
h_adjust = 1;
break;
case 16:
- if (s3c->savage)
- {
- hactive = screen->width / 4;
- hblank /= 4;
- hfp /= 4;
- hbp /= 4;
- h_screen_off = hactive * 2;
- crtc->pixel_length = 1;
- if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- {
- if (crtc->depth == 15)
- crtc->color_mode = 3;
- else
- crtc->color_mode = 5;
- crtc->dclk_over_2 = 1;
- crtc->enable_clock_double = 1;
- crtc->delay_blank = 2;
- }
- else
- {
- if (crtc->depth == 15)
- crtc->color_mode = 2;
- else
- crtc->color_mode = 4;
- crtc->dclk_over_2 = 0;
- crtc->enable_clock_double = 0;
- }
- h_adjust = 1;
- }
+ hactive = screen->width / 4;
+ hblank /= 4;
+ hfp /= 4;
+ hbp /= 4;
+ h_screen_off = hactive;
+ crtc->pixel_length = 1;
+ crtc->extended_bios_5 = 2;
+ if (crtc->depth == 15)
+ crtc->color_mode = 3;
else
- {
- hactive = screen->width / 4;
- hblank /= 4;
- hfp /= 4;
- hbp /= 4;
- h_screen_off = hactive;
- crtc->pixel_length = 1;
- crtc->extended_bios_5 = 2;
- if (crtc->depth == 15)
- crtc->color_mode = 3;
- else
- crtc->color_mode = 5;
- h_adjust = 2;
- }
+ crtc->color_mode = 5;
+ h_adjust = 2;
break;
case 32:
hactive = screen->width / 8;
@@ -1057,7 +764,6 @@ s3Enable (ScreenPtr pScreen)
h_adjust = 1;
break;
}
-#endif
/*
* X server starts frame buffer at top of memory
@@ -1066,7 +772,6 @@ s3Enable (ScreenPtr pScreen)
crtc_start_address (crtc)));
crtc_set_start_address (crtc, 0);
-#if 0
/*
* Compute horizontal register values from timings
*/
@@ -1119,7 +824,6 @@ s3Enable (ScreenPtr pScreen)
crtc_set_v_display_end (crtc, v_display_end);
crtc_set_v_blank_start (crtc, v_blank_start);
crtc->v_blank_end_0_7 = v_blank_end;
-#endif
/*
* Set cursor
@@ -1277,6 +981,7 @@ s3CardFini (KdCardInfo *card)
KdCardFuncs s3Funcs = {
s3CardInit,
s3ScreenInit,
+ 0,
s3Preserve,
s3Enable,
s3DPMS,
@@ -1291,8 +996,15 @@ KdCardFuncs s3Funcs = {
s3RecolorCursor,
s3DrawInit,
s3DrawEnable,
+ s3DrawSync,
s3DrawDisable,
s3DrawFini,
s3GetColors,
s3PutColors,
};
+
+void
+S3InitCard (KdCardAttr *attr)
+{
+ KdCardInfoAdd (&s3Funcs, attr, 0);
+}
diff --git a/hw/kdrive/trio/s3.h b/hw/kdrive/trio/s3.h
index 97374045f..578690558 100644
--- a/hw/kdrive/trio/s3.h
+++ b/hw/kdrive/trio/s3.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/trio/s3.h,v 1.1 1999/11/19 13:54:03 hohndel Exp $ */
#ifndef _S3_H_
#define _S3_H_
@@ -87,8 +87,7 @@ typedef volatile struct _s3 {
VOL32 alt_mix; /* 8134 */
VOL32 scissors_tl; /* 8138 */
VOL32 scissors_br; /* 813c */
- VOL16 pix_cntl; /* 8140 */
- VOL16 mult_misc2; /* 8142 */
+ VOL32 pix_cntl_mult_misc2; /* 8140 */
VOL32 mult_misc_read_sel; /* 8144 */
VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */
VOL8 _pad3[0x19c]; /* 814c */
@@ -231,6 +230,7 @@ typedef volatile struct _s3 {
#define PATTERN_L 0x8000
#define PATTERN_H 0x9000
#define PIX_CNTL 0xa000
+#define CONTROL_MISC2 0xd000
#define PIX_TRANS 0xe2e8
/* Advanced Function Control Regsiter */
@@ -347,13 +347,19 @@ typedef volatile struct _s3 {
#define FIFO_SLOTS 13
+#define GPSLOT(n) (1 << ((n) > 8 ? (15 - ((n) - 9)) : (8 - (n))))
+
+/* Wait for n slots to become available */
#if 0
-/* Wait for one slot to become available */
-#define _s3WaitSlot(s3) { \
- DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlot 0x%x", (s3)->cmd_gp_stat)); \
- while ((s3)->cmd_gp_stat & GPBUSY_1) ; \
- DRAW_DEBUG ((DEBUG_CRTC, " s3 slot available")); \
+#define _s3WaitSlots(s3,n) { \
+ DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlots 0x%x %d", (s3)->cmd_gp_stat, n)); \
+ while (((s3)->cmd_gp_stat & GPSLOT(n)) != 0); \
+ DRAW_DEBUG ((DEBUG_CRTC, " s3 0x%x %d slots ready", (s3)->cmd_gp_stat, n)); \
}
+#else
+/* let PCI retries solve this problem */
+#define _s3WaitSlots(s3,n)
+#endif
/* Wait until queue is empty */
#define _s3WaitEmpty(s3) { \
@@ -375,11 +381,6 @@ typedef volatile struct _s3 {
while ((s3)->cmd_gp_stat & GPBUSY) ; \
DRAW_DEBUG ((DEBUG_CRTC, " s3 idle")); \
}
-#endif
-#define _s3WaitSlot(s3)
-#define _s3WaitEmpty(s3)
-#define _s3WaitIdleEmpty(s3)
-#define _s3WaitIdle(s3)
typedef struct _s3Cursor {
int width, height;
@@ -1072,25 +1073,6 @@ typedef struct _crtc {
#define S3_MAX_CLOCK 135000 /* KHz */
#endif
-typedef struct _s3Timing {
- /* label */
- int horizontal;
- int vertical;
- int rate;
- /* horizontal timing */
- int hfp; /* front porch */
- int hbp; /* back porch */
- int hblank; /* blanking */
- /* vertical timing */
- int vfp; /* front porch */
- int vbp; /* back porch */
- int vblank; /* blanking */
- /* clock values */
- int dac_m;
- int dac_n;
- int dac_r;
-} S3Timing;
-
typedef struct _s3Save {
CARD8 cursor_fg;
CARD8 cursor_bg;
@@ -1112,6 +1094,7 @@ typedef struct _s3CardInfo {
CARD8 *registers; /* pointer to register map */
S3Save save;
Bool savage;
+ Bool need_sync;
} S3CardInfo;
typedef struct _s3ScreenInfo {
@@ -1148,6 +1131,7 @@ void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
Bool s3DrawInit (ScreenPtr pScreen);
void s3DrawEnable (ScreenPtr pScreen);
+void s3DrawSync (ScreenPtr pScreen);
void s3DrawDisable (ScreenPtr pScreen);
void s3DrawFini (ScreenPtr pScreen);
@@ -1156,7 +1140,7 @@ void s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
void S3InitCard (KdCardAttr *attr);
-void s3GetClock (S3Timing *t, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
+void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
CARD8 _s3ReadIndexRegister (VOL8 *base, CARD8 index);
void _s3WriteIndexRegister (VOL8 *base, CARD8 index, CARD8 value);
@@ -1209,30 +1193,4 @@ extern KdCardFuncs s3Funcs;
#define S3_TILE_SIZE 8
-/*
- * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order,
- * but it's willing to take them in LSB byte order. These macros
- * flip bits around without flipping bytes. Instead of using a table
- * and burning memory bandwidth, do them in place with the CPU.
- */
-
-/* The MIPS compiler automatically places these constants in registers */
-#define S3InvertBits32(v) { \
- v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
- v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
- v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-#define S3InvertBits16(v) { \
- v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
- v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
- v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
-}
-
-#define S3InvertBits8(v) { \
- v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
- v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
- v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
-}
-
#endif /* _S3_H_ */
diff --git a/hw/kdrive/trio/s3clock.c b/hw/kdrive/trio/s3clock.c
index 1c4f893dd..15a9b3069 100644
--- a/hw/kdrive/trio/s3clock.c
+++ b/hw/kdrive/trio/s3clock.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/trio/s3clock.c,v 1.1 1999/11/19 13:54:03 hohndel Exp $ */
#include "s3.h"
@@ -44,16 +44,12 @@
#define MAX_VCO 360000.0
void
-s3GetClock (S3Timing *t, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
+s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
{
int M, N, R, bestM, bestN;
int f_vco, f_out;
- int target;
int err, abserr, besterr;
- target = ((t->horizontal + t->hblank) *
- (t->vertical + t->vblank) *
- t->rate) / 1000;
/*
* Compute correct R value to keep VCO in range
*/
diff --git a/hw/kdrive/trio/s3curs.c b/hw/kdrive/trio/s3curs.c
index 6cbdd4f7a..79ec038c6 100644
--- a/hw/kdrive/trio/s3curs.c
+++ b/hw/kdrive/trio/s3curs.c
@@ -21,9 +21,10 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3curs.c,v 1.1 1999/11/19 13:54:06 hohndel Exp $ */
#include "s3.h"
+#include "s3draw.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
@@ -94,31 +95,8 @@ s3AllocCursorColors (ScreenPtr pScreen)
CursorPtr pCursor = pCurPriv->pCursor;
xColorItem sourceColor, maskColor;
- /*
- * Set these to an invalid pixel value so that
- * when the store colors comes through, the cursor
- * won't get recolored
- */
- pCurPriv->source = ~0;
- pCurPriv->mask = ~0;
- /*
- * XXX S3 bug workaround; s3 chip doesn't use RGB values from
- * the cursor color registers as documented, rather it uses
- * them to index the DAC. This is in the errata though.
- */
- 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);
-
- pCurPriv->source = sourceColor.pixel;
- pCurPriv->mask = maskColor.pixel;
+ KdAllocateCursorPixels (pScreen, pCursor,
+ &pCurPriv->source, &pCurPriv->mask);
switch (pScreenPriv->screen->bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
@@ -192,8 +170,9 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
CursorBitsPtr bits = pCursor->bits;
int w, h;
unsigned char r[2], g[2], b[2];
- unsigned short *ram, *msk, *mskLine, *src, *srcLine;
- unsigned short and, xor;
+ unsigned long *ram;
+ unsigned long *msk, *mskLine, *src, *srcLine;
+ unsigned long and, xor;
int i, j;
int cursor_address;
int wsrc;
@@ -204,11 +183,6 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
*/
s3AllocCursorColors (pScreen);
- /*
- * Lock S3 so the cursor doesn't move while we're setting it
- */
- LockS3(s3c);
-
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
@@ -216,24 +190,25 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
/*
* Stick new image into cursor memory
*/
- ram = (unsigned short *) s3s->cursor_base;
- mskLine = (unsigned short *) bits->mask;
- srcLine = (unsigned short *) bits->source;
+ ram = (unsigned long *) s3s->cursor_base;
+ mskLine = (unsigned long *) bits->mask;
+ srcLine = (unsigned long *) bits->source;
h = bits->height;
if (h > S3_CURSOR_HEIGHT)
h = S3_CURSOR_HEIGHT;
- wsrc = BitmapBytePad(bits->width) / 2; /* words per line */
+ wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */
- for (i = 0; i < S3_CURSOR_HEIGHT; i++) {
+ for (i = 0; i < S3_CURSOR_HEIGHT; i++)
+ {
msk = mskLine;
src = srcLine;
mskLine += wsrc;
srcLine += wsrc;
- for (j = 0; j < S3_CURSOR_WIDTH / 16; j++) {
+ for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) {
- unsigned short m, s;
+ unsigned long m, s;
if (i < h && j < wsrc)
{
@@ -244,14 +219,14 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
}
else
{
- and = 0xffff;
- xor = 0x0000;
+ and = 0xffffffff;
+ xor = 0x00000000;
}
- S3InvertBits16(and);
- *ram++ = and;
- S3InvertBits16(xor);
- *ram++ = xor;
+ S3AdjustBits32(and);
+ S3AdjustBits32(xor);
+ *ram++ = (and & 0xffff) | (xor << 16);
+ *ram++ = (and >> 16) | (xor & 0xffff0000);
}
}
@@ -302,7 +277,11 @@ s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
if (pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
@@ -397,7 +376,11 @@ s3CursorEnable (ScreenPtr pScreen)
{
if (pCurPriv->pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
diff --git a/hw/kdrive/trio/s3stub.c b/hw/kdrive/trio/s3stub.c
index 59773f725..597294e6e 100644
--- a/hw/kdrive/trio/s3stub.c
+++ b/hw/kdrive/trio/s3stub.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3stub.c,v 1.1 1999/11/19 13:54:06 hohndel Exp $ */
#include "s3.h"
@@ -52,8 +52,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}
diff --git a/hw/kdrive/ts300/ts300.c b/hw/kdrive/ts300/ts300.c
index 6e3778db0..f1afe4ee9 100644
--- a/hw/kdrive/ts300/ts300.c
+++ b/hw/kdrive/ts300/ts300.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/ts300/ts300.c,v 1.1 1999/11/19 13:54:06 hohndel Exp $ */
#include "kdrive.h"
@@ -123,9 +123,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}
-
diff --git a/hw/kdrive/vxworks/Imakefile b/hw/kdrive/vxworks/Imakefile
new file mode 100644
index 000000000..603b9b6f4
--- /dev/null
+++ b/hw/kdrive/vxworks/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $XFree86: $
+#include <Server.tmpl>
+
+SRCS = vxworks.c vxkbd.c vxkmouse.c
+
+OBJS = vxworks.o vxkbd.o vxkmouse.o
+
+INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../../fb -I../../../mi -I../../../include -I../../../os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(vxworks,$(OBJS))
+
+DependTarget()
diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c
new file mode 100644
index 000000000..0d04f48a8
--- /dev/null
+++ b/hw/kdrive/vxworks/vxkbd.c
@@ -0,0 +1,262 @@
+/*
+ * $Id$
+ *
+ * Copyright © 1999 Network Computing Devices, Inc. All rights reserved.
+ *
+ * Author: Keith Packard
+ */
+
+#include "kdrive.h"
+#include "kkeymap.h"
+#include <X11/keysym.h>
+#include <inputstr.h>
+
+#define VXWORKS_WIDTH 2
+
+KeySym VxWorksKeymap[] = {
+/*7 f1 */ XK_F1, NoSymbol,
+/*8 escape */ XK_Escape, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+/*13 tab */ XK_Tab, NoSymbol,
+/*14 ` */ XK_grave, XK_asciitilde,
+/*15 f2 */ XK_F2, NoSymbol,
+ NoSymbol, NoSymbol,
+/*17 lctrl */ XK_Control_L, NoSymbol,
+/*18 lshift */ XK_Shift_L, NoSymbol,
+ NoSymbol, NoSymbol,
+/*20 lock */ XK_Caps_Lock, NoSymbol,
+/*21 q */ XK_Q, NoSymbol,
+/*22 1 */ XK_1, XK_exclam,
+/*23 f3 */ XK_F3, NoSymbol,
+ NoSymbol, NoSymbol,
+/*25 lalt */ XK_Meta_L, XK_Alt_L,
+/*26 z */ XK_Z, NoSymbol,
+/*27 s */ XK_S, NoSymbol,
+/*28 a */ XK_A, NoSymbol,
+/*29 w */ XK_W, NoSymbol,
+/*30 2 */ XK_2, XK_at,
+/*31 f4 */ XK_F4, NoSymbol,
+ NoSymbol, NoSymbol,
+/*33 c */ XK_C, NoSymbol,
+/*34 x */ XK_X, NoSymbol,
+/*35 d */ XK_D, NoSymbol,
+/*36 e */ XK_E, NoSymbol,
+/*37 4 */ XK_4, XK_dollar,
+/*38 3 */ XK_3, XK_numbersign,
+/*39 f5 */ XK_F5, NoSymbol,
+ NoSymbol, NoSymbol,
+/*41 space */ XK_space, NoSymbol,
+/*42 v */ XK_V, NoSymbol,
+/*43 f */ XK_F, NoSymbol,
+/*44 t */ XK_T, NoSymbol,
+/*45 r */ XK_R, NoSymbol,
+/*46 5 */ XK_5, XK_percent,
+/*47 f6 */ XK_F6, NoSymbol,
+ NoSymbol, NoSymbol,
+/*49 n */ XK_N, NoSymbol,
+/*50 b */ XK_B, NoSymbol,
+/*51 h */ XK_H, NoSymbol,
+/*52 g */ XK_G, NoSymbol,
+/*53 y */ XK_Y, NoSymbol,
+/*54 6 */ XK_6, XK_asciicircum,
+/*55 f7 */ XK_F7, NoSymbol,
+ NoSymbol, NoSymbol,
+/*57 ralt */ XK_Meta_R, XK_Alt_R,
+/*58 m */ XK_M, NoSymbol,
+/*59 j */ XK_J, NoSymbol,
+/*60 u */ XK_U, NoSymbol,
+/*61 7 */ XK_7, XK_ampersand,
+/*62 8 */ XK_8, XK_asterisk,
+/*63 f8 */ XK_F8, NoSymbol,
+ NoSymbol, NoSymbol,
+/*65 , */ XK_comma, XK_less,
+/*66 k */ XK_K, NoSymbol,
+/*67 i */ XK_I, NoSymbol,
+/*68 o */ XK_O, NoSymbol,
+/*69 0 */ XK_0, XK_parenright,
+/*70 9 */ XK_9, XK_parenleft,
+/*71 f9 */ XK_F9, NoSymbol,
+ NoSymbol, NoSymbol,
+/*73 . */ XK_period, XK_greater,
+/*74 / */ XK_slash, XK_question,
+/*75 l */ XK_L, NoSymbol,
+/*76 ; */ XK_semicolon, XK_colon,
+/*77 p */ XK_P, NoSymbol,
+/*78 - */ XK_minus, XK_underscore,
+/*79 f10 */ XK_F10, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+/*82 ' */ XK_apostrophe, XK_quotedbl,
+ NoSymbol, NoSymbol,
+/*84 [ */ XK_bracketleft, XK_braceleft,
+/*85 = */ XK_equal, XK_plus,
+/*86 f11 */ XK_F11, NoSymbol,
+/*87 sysrq */ XK_Sys_Req, XK_Print,
+/*88 rctrl */ XK_Control_R, NoSymbol,
+/*89 rshift */ XK_Shift_R, NoSymbol,
+/*90 enter */ XK_Return, NoSymbol,
+/*91 ] */ XK_bracketright, XK_braceright,
+/*92 \ */ XK_backslash, XK_bar,
+ NoSymbol, NoSymbol,
+/*94 f12 */ XK_F12, NoSymbol,
+/*95 scrolllock*/ XK_Scroll_Lock, NoSymbol,
+/*96 down */ XK_Down, NoSymbol,
+/*97 left */ XK_Left, NoSymbol,
+/*98 pause */ XK_Break, XK_Pause,
+/*99 up */ XK_Up, NoSymbol,
+/*100 delete */ XK_Delete, NoSymbol,
+/*101 end */ XK_End, NoSymbol,
+/*102 bs */ XK_BackSpace, NoSymbol,
+/*103 insert */ XK_Insert, NoSymbol,
+ NoSymbol, NoSymbol,
+/*105 np 1 */ XK_KP_End, XK_KP_1,
+/*106 right */ XK_Right, NoSymbol,
+/*107 np 4 */ XK_KP_Left, XK_KP_4,
+/*108 np 7 */ XK_KP_Home, XK_KP_7,
+/*109 pgdn */ XK_Page_Down, NoSymbol,
+/*110 home */ XK_Home, NoSymbol,
+/*111 pgup */ XK_Page_Up, NoSymbol,
+/*112 np 0 */ XK_KP_Insert, XK_KP_0,
+/*113 np . */ XK_KP_Delete, XK_KP_Decimal,
+/*114 np 2 */ XK_KP_Down, XK_KP_2,
+/*115 np 5 */ XK_KP_5, NoSymbol,
+/*116 np 6 */ XK_KP_Right, XK_KP_6,
+/*117 np 8 */ XK_KP_Up, XK_KP_8,
+/*118 numlock */ XK_Num_Lock, NoSymbol,
+/*119 np / */ XK_KP_Divide, NoSymbol,
+ NoSymbol, NoSymbol,
+/*121 np enter */ XK_KP_Enter, NoSymbol,
+/*122 np 3 */ XK_KP_Page_Down, XK_KP_3,
+ NoSymbol, NoSymbol,
+/*124 np + */ XK_KP_Add, NoSymbol,
+/*125 np 9 */ XK_KP_Page_Up, XK_KP_9,
+/*126 np * */ XK_KP_Multiply, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+/*132 np - */ XK_KP_Subtract, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol,
+/*139 lwin */ XK_Super_L, NoSymbol,
+/*140 rwin */ XK_Super_R, NoSymbol,
+/*141 menu */ XK_Menu, NoSymbol,
+};
+
+void
+VxWorksKeyboardLoad (void)
+{
+ KeySym *k;
+
+ kdMinScanCode = 7;
+ kdKeymapWidth = VXWORKS_WIDTH;
+ kdMaxScanCode = 141;
+ memcpy (kdKeymap, VxWorksKeymap, sizeof (VxWorksKeymap));
+}
+
+static int kbdFd = -1;
+
+#include <errno.h>
+#include <event.h>
+#include <kbd_ioctl.h>
+
+extern KeybdCtrl defaultKeyboardControl;
+
+static void
+VxWorksSetAutorepeat (unsigned char *repeats, Bool on)
+{
+ int i;
+ unsigned char mask;
+ int scan_code;
+ int key_code;
+ unsigned char realkc;
+
+ if (on)
+ {
+ realkc = 1;
+ ioctl (kbdFd, KBD_ALL_REPEAT, &realkc);
+ for (scan_code = 7; scan_code <= 141; scan_code++)
+ {
+ key_code = scan_code + 1;
+ i = key_code >> 3;
+ mask = 1 << (key_code & 7);
+ if ((repeats[i] & mask) == 0)
+ {
+ realkc = scan_code;
+ ioctl (kbdFd, KBD_NO_REPEAT, &realkc);
+ }
+ }
+ }
+ else
+ {
+ realkc = 0;
+ ioctl (kbdFd, KBD_ALL_REPEAT, &realkc);
+ }
+}
+
+int
+VxWorksKeyboardInit (void)
+{
+
+ kbdFd = open ("/dev/kbd", O_RDONLY, 0);
+ if (kbdFd < 0)
+ ErrorF ("keyboard open failure %d\n", errno);
+ VxWorksSetAutorepeat (defaultKeyboardControl.autoRepeats, TRUE);
+ return -1;
+}
+
+void
+VxWorksKeyboardFini (int fd)
+{
+ if (kbdFd >= 0)
+ {
+ close (kbdFd);
+ kbdFd = -1;
+ }
+}
+
+void
+VxWorksKeyboardRead (int fd)
+{
+}
+
+void
+VxWorksKeyboardLeds (int leds)
+{
+ DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice ();
+ KeybdCtrl *ctrl = &pKeyboard->kbdfeed->ctrl;
+ led_ioctl_info led_info;
+ int i;
+
+ VxWorksSetAutorepeat (ctrl->autoRepeats, ctrl->autoRepeat);
+ for (i = 0; i < 3; i++)
+ {
+ led_info.bit_n = 1 << i;
+ led_info.OFF_or_ON = (leds & (1 << i)) != 0;
+ led_info.reversed = 0;
+ ioctl (kbdFd, KBD_SET_LED, &led_info);
+ }
+}
+
+void
+VxWorksKeyboardBell (int volume, int frequency, int duration)
+{
+}
+
+KdKeyboardFuncs VxWorksKeyboardFuncs = {
+ VxWorksKeyboardLoad,
+ VxWorksKeyboardInit,
+ VxWorksKeyboardRead,
+ VxWorksKeyboardLeds,
+ VxWorksKeyboardBell,
+ VxWorksKeyboardFini,
+ 3,
+};
diff --git a/hw/kdrive/vxworks/vxmouse.c b/hw/kdrive/vxworks/vxmouse.c
new file mode 100644
index 000000000..d885fff99
--- /dev/null
+++ b/hw/kdrive/vxworks/vxmouse.c
@@ -0,0 +1,121 @@
+/*
+ * $Id$
+ *
+ * Copyright © 1999 Network Computing Devices, Inc. All rights reserved.
+ *
+ * Author: Keith Packard
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include "Xpoll.h"
+#include <event.h>
+#include <smem.h>
+
+static unsigned long mouseState;
+
+#define BUTTON1 0x01
+#define BUTTON2 0x02
+#define BUTTON3 0x04
+
+#include <errno.h>
+
+static int mouseFd = -1;
+
+static eventqueue *eventQueue;
+
+void
+VxMouseRead (int mousePort)
+{
+ Event ev;
+ int dx, dy;
+ unsigned long flags;
+ unsigned long mask;
+ int n;
+
+ while (eventQueue->head != eventQueue->tail)
+ {
+ ev = *eventQueue->head;
+ if (eventQueue->head >= &eventQueue->events[eventQueue->size-1])
+ eventQueue->head = &eventQueue->events[0];
+ else
+ eventQueue->head++;
+ switch (ev.e_type) {
+ case E_BUTTON:
+ switch (ev.e_device) {
+ case E_MOUSE:
+ switch (ev.e_key) {
+ case BUTTON1:
+ mask = KD_BUTTON_1;
+ break;
+ case BUTTON2:
+ mask = KD_BUTTON_2;
+ break;
+ case BUTTON3:
+ mask = KD_BUTTON_3;
+ break;
+ default:
+ mask = 0;
+ break;
+ }
+ if (ev.e_direction == E_KBUP)
+ mouseState &= ~mask;
+ else
+ mouseState |= mask;
+ KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA, 0, 0);
+ break;
+ case E_DKB:
+ KdEnqueueKeyboardEvent (ev.e_key, ev.e_direction == E_KBUP);
+ break;
+ }
+ break;
+ case E_MMOTION:
+ KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA,
+ ev.e_x, ev.e_y);
+ break;
+ }
+ }
+}
+
+int
+VxMouseInit (void)
+{
+ int mousePort;
+ unsigned long ev_size;
+
+ mouseState = 0;
+ mousePort = open ("/dev/xdev", O_RDONLY, 0);
+ if (mousePort < 0)
+ ErrorF ("event port open failure %d\n", errno);
+ mouseFd = open ("/dev/mouse", O_RDONLY, 0);
+ if (mouseFd < 0)
+ ErrorF ("mouse open failure %d\n", errno);
+ if (eventQueue == 0)
+ {
+ ioctl (mousePort, EVENT_QUEUE_SMSIZE, &ev_size);
+ eventQueue = (eventqueue *) smem_get ("event", ev_size, (SM_READ|SM_WRITE));
+ }
+ return mousePort;
+}
+
+void
+VxMouseFini (int mousePort)
+{
+ if (mousePort >= 0)
+ close (mousePort);
+ if (mouseFd >= 0)
+ {
+ close (mouseFd);
+ mouseFd = -1;
+ }
+}
+
+KdMouseFuncs VxWorksMouseFuncs = {
+ VxMouseInit,
+ VxMouseRead,
+ VxMouseFini
+};
diff --git a/hw/kdrive/vxworks/vxworks.c b/hw/kdrive/vxworks/vxworks.c
new file mode 100644
index 000000000..7ca4182e6
--- /dev/null
+++ b/hw/kdrive/vxworks/vxworks.c
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * Copyright © 1999 Network Computing Devices, Inc. All rights reserved.
+ *
+ * Author: Keith Packard
+ */
+
+#include "kdrive.h"
+#include <X11/keysym.h>
+
+int
+VxWorksInit (void)
+{
+ return 1;
+}
+
+void
+VxWorksEnable (void)
+{
+}
+
+Bool
+VxWorksSpecialKey (KeySym sym)
+{
+ switch (sym) {
+ case XK_Sys_Req:
+ download(1, "setup", 0);
+ return TRUE;
+ case XK_Break:
+ download(1, "launcher", 0);
+ return TRUE;
+ case XK_Delete:
+ dispatchException |= DE_REBOOT;
+ return TRUE;
+ case XK_BackSpace:
+ dispatchException |= DE_RESET;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+VxWorksDisable (void)
+{
+}
+
+void
+VxWorksFini (void)
+{
+}
+
+KdOsFuncs VxWorksFuncs = {
+ VxWorksInit,
+ VxWorksEnable,
+ VxWorksSpecialKey,
+ VxWorksDisable,
+ VxWorksFini,
+};
+
+void
+OsVendorInit (void)
+{
+ KdOsInit (&VxWorksFuncs);
+}