3336. Fx up new MMIO macros (#3337, Matt Grossman).
3335. Clean up compiler warnings in lib/font/bitmap (#3411, Matt Grossman). 3334. TGA fixes, add sync on green (#3410, Matt Grossman). 3333. Fix NULL pointer dereference in libXaw (#3406, Christopher Sekiya). 3332. Add Rage128 support (#3405, Rik Faith, funded by ATI). 3331. Add MTRR support for NetBSD and OpenBSD. Add new NetBSD aperture driver (#3404, Matthieu Herrb). 3330. Xterm patch #121 (#3402, Thomas Dickey). 3329. Rendition driver bugfixes and alpha related cleanups (#3400, Dejan Ilic, Marc Langenbach, Egbert Eich). 3328. Add void input device (#3392, Frederic Lepied). 3327. Changed the Xon serial option to be able to select xon/xoff for input, output or both. Add support for Graphire models. Change wacom init phase to use new Xoff option (#3391, Frederic Lepied). 3326. Change the SwapAxes option to SwapXY in elographics/microtouch driver to match an already existing option in the Dynapro driver. Add a Focus class capability to the elographics driver (#3395, Patrick Lecoanet). 3325. Update mouse rate handling (#3388, Harald Koenig). 3324. Fix NULL pointer dereference in misprite.c (#3380, Edward Wang). 3323. Add FBDev and ShadowFB support to glint driver. Add new option "NoWriteBitmap" (#3383, Michel Daenzer). 3322. Update SuperProbe to handle S3 Savage4, Savage200 and clean up Trio3D/Savage3D detection (#3382,3384 Harald Koenig). 3321. Add new framebuffer code and tiny X DDX architecture (#3379, Keith Packard). 3320. Add DGA2 documentation (#3378, Mark Vojkovich). 3319. Update XFree86 manpage wrt -bpp/-depth/-fbbpp (#3377, Andy Isaacson). 3318. Make SuperProbe check primary cards, only (#3374, Harald Koenig). 3317. Add SilkenMouse to *BSD (#3373, Matthieu Herrb). 3316. Allow SilkenMouse to work if not all drivers of an OS support SIGIO (#3372, Keith Packard). 3315. Fix a few problems in TGA driver and add support for backing store and SilkenMouse (#3371, Matt Grossman). 3314. Add smarter scheduler (#3370, Keith Packard). 3313. Xterm patch #120 (#3369, Thomas Dickey). 3312. Enable xf86SetKbdRate function on Solaris 8 (#3364, David Holland). 3311. Fix some bugs and add acceleration to Rendition server (#3360, Dejan Ilic). 3310. Make raw DDC information available as properties in the root window (#3357, Andrew Aitchison). 3309. Fix for xf86CreateRootWindow (#3355, Andrew Aitchison). 3308. Add manpage for the chips driver (#3353, David Bateman). 3307. Update contact info (#3352, Andrew van der Stock). 3306. Add kbd rate support for Linux (#3363, Harald Koenig). 3305. Update Portuguese XKB map (#3351, Joao Esteves, Francisco Colaco). 3304. Fix text clipping in 3dfx driver (#3349, Henrik Harmsen). 3303. Fix S3 ViRGE hw cursor (#3348, Harald Koenig). 3302. Fix clipping in 3dfx driver (#3342, Daryll Strauss). 3301. Enable SilkenMouse for 3dfx driver (#3341, Henrik Harmsen). 3300. Enable SIGIO support on LynxOS (#3339, Thomas Mueller). 3299. Get TRUE defined in sigio.c. Fix xterm compile problem on ISC (#3338, Michael Rohleder). 3298. Correct DPMS suspend/standby modes for 3dfx driver (#3336, Henrik Harmsen) 3297. Xterm patch #119 (#3335, Thomas Dickey).
This commit is contained in:
commit
f13b792a3a
20
hw/kdrive/Imakefile
Normal file
20
hw/kdrive/Imakefile
Normal file
|
@ -0,0 +1,20 @@
|
|||
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 $
|
||||
#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
|
||||
|
||||
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
|
||||
|
||||
INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../fb -I../../mi -I../../include -I../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(kdrive,$(OBJS))
|
||||
|
||||
SpecialCObjectRule(kdrive,,$(EXT_DEFINES))
|
||||
|
||||
DependTarget()
|
15
hw/kdrive/fbdev/Imakefile
Normal file
15
hw/kdrive/fbdev/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = fbdev.c fbinit.c
|
||||
|
||||
OBJS = fbdev.o fbinit.o
|
||||
|
||||
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(fbdev,$(OBJS))
|
||||
DependTarget()
|
256
hw/kdrive/fbdev/fbdev.c
Normal file
256
hw/kdrive/fbdev/fbdev.c
Normal file
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "fbdev.h"
|
||||
|
||||
Bool
|
||||
fbdevInitialize (KdCardInfo *card, FbdevPriv *priv)
|
||||
{
|
||||
int k;
|
||||
if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) {
|
||||
perror("Error opening /dev/fb0\n");
|
||||
return FALSE;
|
||||
}
|
||||
if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) {
|
||||
perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
|
||||
close (priv->fd);
|
||||
return FALSE;
|
||||
}
|
||||
if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) {
|
||||
perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
|
||||
close (priv->fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->fb = (unsigned char *) mmap ((caddr_t) NULL,
|
||||
priv->fix.smem_len,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED,
|
||||
priv->fd, 0);
|
||||
|
||||
if (priv->fb == (char *)-1)
|
||||
{
|
||||
perror("ERROR: mmap framebuffer fails!");
|
||||
close (priv->fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
fbdevCardInit (KdCardInfo *card)
|
||||
{
|
||||
int k;
|
||||
char *pixels;
|
||||
FbdevPriv *priv;
|
||||
|
||||
priv = (FbdevPriv *) xalloc (sizeof (FbdevPriv));
|
||||
if (!priv)
|
||||
return FALSE;
|
||||
|
||||
if (!fbdevInitialize (card, priv))
|
||||
{
|
||||
xfree (priv);
|
||||
return FALSE;
|
||||
}
|
||||
card->driver = priv;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
fbdevScreenInit (KdScreenInfo *screen)
|
||||
{
|
||||
FbdevPriv *priv = screen->card->driver;
|
||||
Pixel allbits;
|
||||
int depth;
|
||||
|
||||
screen->width = priv->var.xres;
|
||||
screen->height = priv->var.yres;
|
||||
screen->depth = priv->var.bits_per_pixel;
|
||||
screen->bitsPerPixel = priv->var.bits_per_pixel;
|
||||
screen->byteStride = priv->fix.line_length;
|
||||
screen->pixelStride = (priv->fix.line_length * 8 /
|
||||
priv->var.bits_per_pixel);
|
||||
switch (priv->fix.visual) {
|
||||
case FB_VISUAL_PSEUDOCOLOR:
|
||||
screen->visuals = ((1 << StaticGray) |
|
||||
(1 << GrayScale) |
|
||||
(1 << StaticColor) |
|
||||
(1 << PseudoColor) |
|
||||
(1 << TrueColor) |
|
||||
(1 << DirectColor));
|
||||
screen->blueMask = 0x00;
|
||||
screen->greenMask = 0x00;
|
||||
screen->redMask = 0x00;
|
||||
break;
|
||||
case FB_VISUAL_TRUECOLOR:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->redMask = FbStipMask (priv->var.red.offset, priv->var.red.length);
|
||||
screen->greenMask = FbStipMask (priv->var.green.offset, priv->var.green.length);
|
||||
screen->blueMask = FbStipMask (priv->var.blue.offset, priv->var.blue.length);
|
||||
allbits = screen->redMask | screen->greenMask | screen->blueMask;
|
||||
depth = 32;
|
||||
while (depth && !(allbits & (1 << (depth - 1))))
|
||||
depth--;
|
||||
screen->depth = depth;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
screen->rate = 72;
|
||||
screen->frameBuffer = (CARD8 *) (priv->fb);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fbdevPreserve (KdCardInfo *card)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fbdevEnable (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
FbdevPriv *priv = pScreenPriv->card->driver;
|
||||
int k;
|
||||
|
||||
priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
|
||||
|
||||
/* display it on the LCD */
|
||||
k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
|
||||
if (k < 0)
|
||||
perror ("FBIOPUT_VSCREENINFO");
|
||||
}
|
||||
|
||||
Bool
|
||||
fbdevDPMS (ScreenPtr pScreen, int mode)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
FbdevPriv *priv = pScreenPriv->card->driver;
|
||||
|
||||
if (!ioctl (priv->fd, FBIOPUT_POWERMODE, &mode))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
fbdevDisable (ScreenPtr pScreen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fbdevRestore (KdCardInfo *card)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fbdevScreenFini (KdScreenInfo *screen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fbdevCardFini (KdCardInfo *card)
|
||||
{
|
||||
int k;
|
||||
FbdevPriv *priv = card->driver;
|
||||
|
||||
munmap (priv->fb, priv->fix.smem_len);
|
||||
close (priv->fd);
|
||||
xfree (priv);
|
||||
}
|
||||
|
||||
void
|
||||
fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
FbdevPriv *priv = pScreenPriv->card->driver;
|
||||
struct fb_cmap cmap;
|
||||
int p;
|
||||
int k;
|
||||
int min, max;
|
||||
|
||||
min = 256;
|
||||
max = 0;
|
||||
for (k = 0; k < n; k++)
|
||||
{
|
||||
if (pdefs[k].pixel < min)
|
||||
min = pdefs[k].pixel;
|
||||
if (pdefs[k].pixel > max)
|
||||
max = pdefs[k].pixel;
|
||||
}
|
||||
cmap.start = min;
|
||||
cmap.len = max - min + 1;
|
||||
cmap.red = &priv->red[min];
|
||||
cmap.green = &priv->green[min];;
|
||||
cmap.blue = &priv->blue[min];
|
||||
cmap.transp = 0;
|
||||
k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
|
||||
if (k < 0)
|
||||
{
|
||||
perror ("can't get colormap");
|
||||
return;
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
p = pdefs->pixel;
|
||||
pdefs->red = priv->red[p];
|
||||
pdefs->green = priv->green[p];
|
||||
pdefs->blue = priv->blue[p];
|
||||
pdefs++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
FbdevPriv *priv = pScreenPriv->card->driver;
|
||||
struct fb_cmap cmap;
|
||||
int p;
|
||||
int min, max;
|
||||
|
||||
min = 256;
|
||||
max = 0;
|
||||
while (n--)
|
||||
{
|
||||
p = pdefs->pixel;
|
||||
priv->red[p] = pdefs->red;
|
||||
priv->green[p] = pdefs->green;
|
||||
priv->blue[p] = pdefs->blue;
|
||||
if (p < min)
|
||||
min = p;
|
||||
if (p > max)
|
||||
max = p;
|
||||
pdefs++;
|
||||
}
|
||||
cmap.start = min;
|
||||
cmap.len = max - min + 1;
|
||||
cmap.red = &priv->red[min];
|
||||
cmap.green = &priv->green[min];
|
||||
cmap.blue = &priv->blue[min];
|
||||
cmap.transp = 0;
|
||||
ioctl (priv->fd, FBIOPUTCMAP, &cmap);
|
||||
}
|
81
hw/kdrive/fbdev/fbdev.h
Normal file
81
hw/kdrive/fbdev/fbdev.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _FBDEV_H_
|
||||
#define _FBDEV_H_
|
||||
#include "kdrive.h"
|
||||
#include <stdio.h>
|
||||
#include <linux/fb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
typedef struct _fbdevPriv {
|
||||
struct fb_var_screeninfo var;
|
||||
struct fb_fix_screeninfo fix;
|
||||
__u16 red[256];
|
||||
__u16 green[256];
|
||||
__u16 blue[256];
|
||||
int fd;
|
||||
char *fb;
|
||||
} FbdevPriv;
|
||||
|
||||
Bool
|
||||
fbdevInitialize (KdCardInfo *card, FbdevPriv *priv);
|
||||
|
||||
Bool
|
||||
fbdevCardInit (KdCardInfo *card);
|
||||
|
||||
Bool
|
||||
fbdevScreenInit (KdScreenInfo *screen);
|
||||
|
||||
void
|
||||
fbdevPreserve (KdCardInfo *card);
|
||||
|
||||
void
|
||||
fbdevEnable (ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
fbdevDPMS (ScreenPtr pScreen, int mode);
|
||||
|
||||
void
|
||||
fbdevDisable (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
fbdevRestore (KdCardInfo *card);
|
||||
|
||||
void
|
||||
fbdevScreenFini (KdScreenInfo *screen);
|
||||
|
||||
void
|
||||
fbdevCardFini (KdCardInfo *card);
|
||||
|
||||
void
|
||||
fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
|
||||
|
||||
void
|
||||
fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
|
||||
|
||||
|
||||
#endif /* _FBDEV_H_ */
|
78
hw/kdrive/fbdev/fbinit.c
Normal file
78
hw/kdrive/fbdev/fbinit.c
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include <fbdev.h>
|
||||
|
||||
KdCardFuncs fbdevFuncs = {
|
||||
fbdevCardInit, /* cardinit */
|
||||
fbdevScreenInit, /* scrinit */
|
||||
fbdevPreserve, /* preserve */
|
||||
fbdevEnable, /* enable */
|
||||
fbdevDPMS, /* dpms */
|
||||
fbdevDisable, /* disable */
|
||||
fbdevRestore, /* restore */
|
||||
fbdevScreenFini, /* scrfini */
|
||||
fbdevCardFini, /* cardfini */
|
||||
|
||||
0, /* initCursor */
|
||||
0, /* enableCursor */
|
||||
0, /* disableCursor */
|
||||
0, /* finiCursor */
|
||||
0, /* recolorCursor */
|
||||
|
||||
0, /* initAccel */
|
||||
0, /* enableAccel */
|
||||
0, /* disableAccel */
|
||||
0, /* finiAccel */
|
||||
|
||||
fbdevGetColors, /* getColors */
|
||||
fbdevPutColors, /* putColors */
|
||||
};
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
|
||||
KdCardInfoAdd (&fbdevFuncs, &attr, 0);
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
15
hw/kdrive/itsy/Imakefile
Normal file
15
hw/kdrive/itsy/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = itsy.c ts.c kbd.c
|
||||
|
||||
OBJS = itsy.o ts.o kbd.o
|
||||
|
||||
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(itsy,$(OBJS))
|
||||
DependTarget()
|
311
hw/kdrive/itsy/itsy.c
Normal file
311
hw/kdrive/itsy/itsy.c
Normal file
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "itsy.h"
|
||||
|
||||
/* struct with LCD characteristics defined in fb_brutus.h */
|
||||
static struct FbLcdParamsStruct fbLcdParams;
|
||||
static int fb_d;
|
||||
static int fbn;
|
||||
Bool
|
||||
itsyCardInit (KdCardInfo *card)
|
||||
{
|
||||
int k;
|
||||
char *fb;
|
||||
char *pixels;
|
||||
|
||||
if ((fb_d = open("/dev/fbclone", O_RDWR)) < 0) {
|
||||
perror("Error opening /dev/fb\n");
|
||||
return FALSE;
|
||||
}
|
||||
if ((k=ioctl(fb_d, FB_LCD_PARAMS, &fbLcdParams)) != 0) {
|
||||
perror("Error with /dev/fb ioctl FB_LCD_PARAMS call");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fb = (char *) mmap ((caddr_t) NULL, fbLcdParams.frameBufferSize,
|
||||
PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fb_d, 0);
|
||||
|
||||
fprintf (stderr, "fb mapped at 0x%x\n", fb);
|
||||
if (fb == (char *)-1) {
|
||||
perror("ERROR: mmap framebuffer fails!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
card->driver = fb;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
itsyScreenInit (KdScreenInfo *screen)
|
||||
{
|
||||
CARD8 *fb = screen->card->driver;
|
||||
|
||||
screen->width = fbLcdParams.screenSizeH;
|
||||
screen->height = fbLcdParams.screenSizeV;
|
||||
screen->depth = fbLcdParams.bitsPerPixel;
|
||||
screen->bitsPerPixel = fbLcdParams.bitsPerPixel;
|
||||
screen->byteStride = fbLcdParams.frameBufferSizeH;
|
||||
screen->pixelStride = (fbLcdParams.frameBufferSizeH * 8 /
|
||||
fbLcdParams.bitsPerPixel);
|
||||
fprintf (stderr, "width %d height %d depth %d pstride %d bstride %d\n",
|
||||
screen->width, screen->height, screen->depth,
|
||||
screen->pixelStride, screen->byteStride);
|
||||
screen->dumb = FALSE;
|
||||
screen->softCursor = TRUE;
|
||||
screen->blueMask = 0;
|
||||
screen->greenMask = 0;
|
||||
screen->redMask = 0;
|
||||
screen->visuals = 1 << StaticGray;
|
||||
screen->rate = 72;
|
||||
screen->frameBuffer = (CARD8 *) (fb +
|
||||
fbLcdParams.pixelDataOffset +
|
||||
(fbLcdParams.reserveTopRows *
|
||||
screen->byteStride));
|
||||
fprintf (stderr, "Frame buffer 0x%x\n", screen->frameBuffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
itsyPreserve (KdCardInfo *card)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
itsyEnable (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
|
||||
fprintf (stderr, "Enabling LCD display\n");
|
||||
/* display it on the LCD */
|
||||
ioctl(fb_d, FB_LCD_SHOW, 0);
|
||||
}
|
||||
|
||||
Bool
|
||||
itsyDPMS (ScreenPtr pScreen, int mode)
|
||||
{
|
||||
if (mode)
|
||||
ioctl (fb_d, FB_LCD_OFF, 0);
|
||||
else
|
||||
ioctl (fb_d, FB_LCD_ON, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
itsyDisable (ScreenPtr pScreen)
|
||||
{
|
||||
/* ioctl (fb_d, FB_LCD_SWITCH, 0); */
|
||||
/* fprintf (stderr, "Disabling LCD display\n");*/
|
||||
}
|
||||
|
||||
void
|
||||
itsyRestore (KdCardInfo *card)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
itsyScreenFini (KdScreenInfo *screen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
itsyCardFini (KdCardInfo *card)
|
||||
{
|
||||
int k;
|
||||
|
||||
fprintf (stderr, "Unmapping driver at 0x%x\n", card->driver);
|
||||
munmap (card->driver, fbLcdParams.frameBufferSize);
|
||||
fprintf (stderr, "Releasing fbn %d\n", fbn);
|
||||
/* release it */
|
||||
if (ioctl(fb_d, FB_LCD_FREE, fbn) != 0) {
|
||||
printf("FB_LCD_FREE of %d fails!\n", fbn);
|
||||
}
|
||||
close (fb_d);
|
||||
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 */
|
||||
itsyPreserve, /* preserve */
|
||||
itsyEnable, /* enable */
|
||||
itsyDPMS, /* dpms */
|
||||
itsyDisable, /* disable */
|
||||
itsyRestore, /* restore */
|
||||
itsyScreenFini, /* scrfini */
|
||||
itsyCardFini, /* cardfini */
|
||||
|
||||
0, /* initCursor */
|
||||
0, /* enableCursor */
|
||||
0, /* disableCursor */
|
||||
0, /* finiCursor */
|
||||
0, /* recolorCursor */
|
||||
|
||||
itsySetupScreen, /* initAccel */
|
||||
0, /* enableAccel */
|
||||
0, /* disableAccel */
|
||||
0, /* finiAccel */
|
||||
|
||||
0, /* getColors */
|
||||
0, /* putColors */
|
||||
};
|
||||
|
||||
void
|
||||
InitCard (void)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
|
||||
KdCardInfoAdd (&itsyFuncs, &attr, 0);
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&itsyTsMouseFuncs, &itsyKeyboardFuncs);
|
||||
}
|
||||
|
||||
int itsySessionFd = -1;
|
||||
|
||||
int
|
||||
ItsyOsInit (void)
|
||||
{
|
||||
pid_t sid;
|
||||
int i;
|
||||
itsy_session_info info;
|
||||
|
||||
if (itsySessionFd < 0)
|
||||
{
|
||||
itsySessionFd = open ("/dev/session", 0);
|
||||
ErrorF("itsySessionFD %d\n", itsySessionFd);
|
||||
}
|
||||
|
||||
(void) setsid ();
|
||||
sid = getsid (0);
|
||||
ErrorF ("Session ID %d PID %d\n", sid, getpid ());
|
||||
info.sid = sid;
|
||||
strcpy (info.name, "X");
|
||||
if (itsySessionFd >= 0)
|
||||
{
|
||||
i = ioctl (itsySessionFd, SESSION_SET_INFO, &info);
|
||||
if (i < 0)
|
||||
perror ("SESSION_SET_INFO");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
ItsyOsEnable (void)
|
||||
{
|
||||
itsy_session_request req;
|
||||
int i;
|
||||
|
||||
#define MANAGER_SID_TO_FOREGROUND 2
|
||||
|
||||
req.operation = MANAGER_SID_TO_FOREGROUND;
|
||||
req.data = 0;
|
||||
if (itsySessionFd >= 0)
|
||||
{
|
||||
i = ioctl (itsySessionFd, SESSION_MANAGER_REQUEST, &req);
|
||||
if (i < 0)
|
||||
perror ("SESSION_MANAGER_REQUEST");
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
ItsyOsSpecialKey (KeySym sym)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ItsyOsDisable (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ItsyOsFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
KdOsFuncs ItsyOsFuncs = {
|
||||
ItsyOsInit,
|
||||
ItsyOsEnable,
|
||||
ItsyOsSpecialKey,
|
||||
ItsyOsDisable,
|
||||
ItsyOsFini,
|
||||
};
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&ItsyOsFuncs);
|
||||
}
|
42
hw/kdrive/itsy/itsy.h
Normal file
42
hw/kdrive/itsy/itsy.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/itsy_fb.h>
|
||||
#include <linux/itsy_ts.h>
|
||||
#include <linux/itsy_buttons.h>
|
||||
#include <linux/itsy_session.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define FB_HEIGHT 200
|
||||
#define FB_WIDTH 320
|
||||
#define FB_DEPTH 4
|
||||
#define FB_PALETTE_SIZE 16
|
||||
|
||||
extern KdMouseFuncs itsyTsMouseFuncs;
|
||||
extern KdKeyboardFuncs itsyKeyboardFuncs;
|
234
hw/kdrive/itsy/kbd.c
Normal file
234
hw/kdrive/itsy/kbd.c
Normal file
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "itsy.h"
|
||||
#include "kkeymap.h"
|
||||
#include <X11/keysym.h>
|
||||
#include <linux/itsy_buttons.h>
|
||||
|
||||
#define ITSY_WIDTH 2
|
||||
|
||||
KeySym ItsyKeymap[] = {
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
/* 4 11 */ XK_3, XK_numbersign,
|
||||
/* 5 12 */ XK_4, XK_dollar,
|
||||
/* 6 13 */ XK_5, XK_percent,
|
||||
/* 7 14 */ XK_6, XK_asciicircum,
|
||||
/* 8 15 */ XK_7, XK_ampersand,
|
||||
/* 9 16 */ XK_8, XK_asterisk,
|
||||
/* 10 17 */ XK_9, XK_parenleft,
|
||||
/* 11 18 */ XK_0, XK_parenright,
|
||||
/* 12 19 */ XK_minus, XK_underscore,
|
||||
/* 13 20 */ XK_equal, XK_plus,
|
||||
/* 14 21 */ XK_BackSpace, NoSymbol,
|
||||
/* 15 22 */ XK_Tab, NoSymbol,
|
||||
/* 16 23 */ XK_Q, NoSymbol,
|
||||
/* 17 24 */ XK_W, NoSymbol,
|
||||
/* 18 25 */ XK_E, NoSymbol,
|
||||
/* 19 26 */ XK_R, NoSymbol,
|
||||
/* 20 27 */ XK_T, NoSymbol,
|
||||
/* 21 28 */ XK_Y, NoSymbol,
|
||||
/* 22 29 */ XK_U, NoSymbol,
|
||||
/* 23 30 */ XK_I, NoSymbol,
|
||||
/* 24 31 */ XK_O, NoSymbol,
|
||||
/* 25 32 */ XK_P, NoSymbol,
|
||||
/* 26 33 */ XK_bracketleft, XK_braceleft,
|
||||
/* 27 34 */ XK_bracketright, XK_braceright,
|
||||
/* 28 35 */ XK_Return, NoSymbol,
|
||||
/* 29 36 */ XK_Control_L, NoSymbol,
|
||||
/* 30 37 */ XK_A, NoSymbol,
|
||||
/* 31 38 */ XK_S, NoSymbol,
|
||||
/* 32 39 */ XK_D, NoSymbol,
|
||||
/* 33 40 */ XK_F, NoSymbol,
|
||||
/* 34 41 */ XK_G, NoSymbol,
|
||||
/* 35 42 */ XK_H, NoSymbol,
|
||||
/* 36 43 */ XK_J, NoSymbol,
|
||||
/* 37 44 */ XK_K, NoSymbol,
|
||||
/* 38 45 */ XK_L, NoSymbol,
|
||||
/* 39 46 */ XK_semicolon, XK_colon,
|
||||
/* 40 47 */ XK_apostrophe, XK_quotedbl,
|
||||
/* 41 48 */ XK_grave, XK_asciitilde,
|
||||
/* 42 49 */ XK_Shift_L, NoSymbol,
|
||||
/* 43 50 */ XK_backslash, XK_bar,
|
||||
/* 44 51 */ XK_Z, NoSymbol,
|
||||
/* 45 52 */ XK_X, NoSymbol,
|
||||
/* 46 53 */ XK_C, NoSymbol,
|
||||
/* 47 54 */ XK_V, NoSymbol,
|
||||
/* 48 55 */ XK_B, NoSymbol,
|
||||
/* 49 56 */ XK_N, NoSymbol,
|
||||
/* 50 57 */ XK_M, NoSymbol,
|
||||
/* 51 58 */ XK_comma, XK_less,
|
||||
/* 52 59 */ XK_period, XK_greater,
|
||||
/* 53 60 */ XK_slash, XK_question,
|
||||
/* 54 61 */ XK_Shift_R, NoSymbol,
|
||||
/* 55 62 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 56 63 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 57 64 */ XK_space, NoSymbol,
|
||||
/* 58 65 */ XK_Caps_Lock, NoSymbol,
|
||||
/* 59 66 */ XK_F1, NoSymbol,
|
||||
/* 60 67 */ XK_F2, NoSymbol,
|
||||
/* 61 68 */ XK_F3, NoSymbol,
|
||||
/* 62 69 */ XK_F4, NoSymbol,
|
||||
/* 63 70 */ XK_F5, NoSymbol,
|
||||
/* 64 71 */ XK_F6, NoSymbol,
|
||||
/* 65 72 */ XK_F7, NoSymbol,
|
||||
/* 66 73 */ XK_F8, NoSymbol,
|
||||
/* 67 74 */ XK_F9, NoSymbol,
|
||||
/* 68 75 */ XK_F10, NoSymbol,
|
||||
/* 69 76 */ XK_Break, XK_Pause,
|
||||
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* 71 78 */ XK_KP_Home, XK_KP_7,
|
||||
/* 72 79 */ XK_KP_Up, XK_KP_8,
|
||||
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
|
||||
/* 74 81 */ XK_KP_Subtract, NoSymbol,
|
||||
/* 75 82 */ XK_KP_Left, XK_KP_4,
|
||||
/* 76 83 */ XK_KP_5, NoSymbol,
|
||||
/* 77 84 */ XK_KP_Right, XK_KP_6,
|
||||
/* 78 85 */ XK_KP_Add, NoSymbol,
|
||||
/* 79 86 */ XK_KP_End, XK_KP_1,
|
||||
/* 80 87 */ XK_KP_Down, XK_KP_2,
|
||||
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
|
||||
/* 82 89 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 84 91 */ NoSymbol, NoSymbol,
|
||||
/* 85 92 */ NoSymbol, NoSymbol,
|
||||
/* 86 93 */ NoSymbol, NoSymbol,
|
||||
/* 87 94 */ XK_F11, NoSymbol,
|
||||
/* 88 95 */ XK_F12, NoSymbol,
|
||||
|
||||
/* These are remapped from the extended set (using ExtendMap) */
|
||||
|
||||
/* 89 96 */ XK_Control_R, NoSymbol,
|
||||
/* 90 97 */ XK_KP_Enter, NoSymbol,
|
||||
/* 91 98 */ XK_KP_Divide, NoSymbol,
|
||||
/* 92 99 */ XK_Sys_Req, XK_Print,
|
||||
/* 93 100 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 94 101 */ XK_Num_Lock, NoSymbol,
|
||||
/* 95 102 */ XK_Home, NoSymbol,
|
||||
/* 96 103 */ XK_Up, NoSymbol,
|
||||
/* 97 104 */ XK_Page_Up, NoSymbol,
|
||||
/* 98 105 */ XK_Left, NoSymbol,
|
||||
/* 99 106 */ XK_Right, NoSymbol,
|
||||
/* 100 107 */ XK_End, NoSymbol,
|
||||
/* 101 108 */ XK_Down, NoSymbol,
|
||||
/* 102 109 */ XK_Page_Down, NoSymbol,
|
||||
/* 103 110 */ XK_Insert, NoSymbol,
|
||||
/* 104 111 */ XK_Delete, NoSymbol,
|
||||
/* 105 112 */ XK_Super_L, NoSymbol,
|
||||
/* 106 113 */ XK_Super_R, NoSymbol,
|
||||
/* 107 114 */ XK_Menu, NoSymbol,
|
||||
|
||||
/* Itsy hardware buttons */
|
||||
#define ITSY_BUTTON_FIRST 108
|
||||
#define ITSY_BUTTON_LAST 116
|
||||
|
||||
/* 108 115 */ XK_Next, NoSymbol, /* right button on side */
|
||||
/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */
|
||||
/* 110 117 */ XK_Up, NoSymbol, /* joypad */
|
||||
/* 111 118 */ XK_Down, NoSymbol,
|
||||
/* 112 119 */ XK_Left, NoSymbol,
|
||||
/* 113 120 */ XK_Right, NoSymbol,
|
||||
/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */
|
||||
/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */
|
||||
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
|
||||
};
|
||||
|
||||
static unsigned long itsyButtonState;
|
||||
|
||||
void
|
||||
ItsyKeyboardLoad (void)
|
||||
{
|
||||
KeySym *k;
|
||||
|
||||
itsyButtonState = 0;
|
||||
kdMinScanCode = 1;
|
||||
kdKeymapWidth = ITSY_WIDTH;
|
||||
kdMaxScanCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
|
||||
memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
|
||||
}
|
||||
|
||||
int
|
||||
ItsyKeyboardInit (void)
|
||||
{
|
||||
int butPort;
|
||||
|
||||
butPort = open ("/dev/buttons", 0);
|
||||
fprintf (stderr, "butPort %d\n", butPort);
|
||||
return butPort;
|
||||
}
|
||||
|
||||
void
|
||||
ItsyKeyboardFini (int fd)
|
||||
{
|
||||
if (fd >= 0)
|
||||
close (fd);
|
||||
}
|
||||
|
||||
void
|
||||
ItsyKeyboardRead (int fd)
|
||||
{
|
||||
itsy_buttons_event event;
|
||||
int b;
|
||||
unsigned long bit;
|
||||
unsigned long change;
|
||||
unsigned long buttons;
|
||||
|
||||
if (read (fd, &event, sizeof (event)) == sizeof (event))
|
||||
{
|
||||
buttons = event.state;
|
||||
change = buttons ^ itsyButtonState;
|
||||
if (!change)
|
||||
return;
|
||||
for (b = ITSY_BUTTON_FIRST; b <= ITSY_BUTTON_LAST; b++)
|
||||
{
|
||||
bit = (1 << (b - ITSY_BUTTON_FIRST));
|
||||
if (change & bit)
|
||||
KdEnqueueKeyboardEvent (b, (buttons & bit) == 0);
|
||||
}
|
||||
itsyButtonState = buttons;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ItsyKeyboardLeds (int leds)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ItsyKeyboardBell (int volume, int frequency, int duration)
|
||||
{
|
||||
}
|
||||
|
||||
KdKeyboardFuncs itsyKeyboardFuncs = {
|
||||
ItsyKeyboardLoad,
|
||||
ItsyKeyboardInit,
|
||||
ItsyKeyboardRead,
|
||||
ItsyKeyboardLeds,
|
||||
ItsyKeyboardBell,
|
||||
ItsyKeyboardFini,
|
||||
0,
|
||||
};
|
209
hw/kdrive/itsy/ts.c
Normal file
209
hw/kdrive/itsy/ts.c
Normal file
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#define NEED_EVENTS
|
||||
#include "itsy.h"
|
||||
#include "Xproto.h"
|
||||
#include "inputstr.h"
|
||||
#include "Xpoll.h"
|
||||
|
||||
int
|
||||
itsyTsReadBytes (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
|
||||
itsyTsRead (int tsPort)
|
||||
{
|
||||
ts_event event;
|
||||
long buf[3];
|
||||
int n;
|
||||
long pressure;
|
||||
long x, y;
|
||||
unsigned long flags;
|
||||
unsigned long buttons;
|
||||
|
||||
n = itsyTsReadBytes (tsPort, (char *) &event,
|
||||
sizeof (event), sizeof (event));
|
||||
if (n == sizeof (event))
|
||||
{
|
||||
if (event.pressure)
|
||||
{
|
||||
flags = KD_BUTTON_1;
|
||||
x = event.point.x;
|
||||
y = event.point.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = KD_MOUSE_DELTA;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
KdEnqueueMouseEvent (flags, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define ITSY_DEBUG_LOW 1
|
||||
|
||||
//
|
||||
// Touch screen parameters are stored
|
||||
// in the flash. This code is taken from 'wm1'.
|
||||
//
|
||||
void itsySetTouchCalibration (int mou_filedsc,
|
||||
int xs, int xt, int ys, int yt, int xys)
|
||||
{
|
||||
int k, ibuf[10];
|
||||
|
||||
ibuf[0] = xs;
|
||||
ibuf[1] = xt;
|
||||
ibuf[2] = ys;
|
||||
ibuf[3] = yt;
|
||||
ibuf[4] = xys;
|
||||
if ((k=ioctl(mou_filedsc, TS_SET_CALM, ibuf)) != 0) {
|
||||
fprintf(stderr, "ERROR: ioctl TS_SET_CALM returns %d\n", k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int itsyReadFlashBlock(int location, signed char *data, int dbytes)
|
||||
{
|
||||
int offset, bytes;
|
||||
int flashfd;
|
||||
|
||||
flashfd = open("/dev/flash1", O_RDONLY);
|
||||
if (flashfd < 0) return(0);
|
||||
|
||||
offset = lseek(flashfd, location, SEEK_SET);
|
||||
if (offset != location) {
|
||||
close(flashfd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
bytes = read(flashfd, data, dbytes);
|
||||
if (bytes != dbytes) {
|
||||
close(flashfd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
close(flashfd);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
#define RAMSIZE (0x400000)
|
||||
#define MONITOR_BLOCKSIZE (32)
|
||||
/**********************************************************************/
|
||||
|
||||
/* code for storing calibration into flash */
|
||||
|
||||
#define CALIBRATE_BLOCKSIZE (32)
|
||||
#define CALIBRATE_OFFSET (RAMSIZE-MONITOR_BLOCKSIZE-CALIBRATE_BLOCKSIZE)
|
||||
#define CALIBRATE_MAGIC_NUM (0x0babedee)
|
||||
|
||||
|
||||
static int check_if_calibrated_and_set(int mou_filedsc)
|
||||
{
|
||||
signed char cal_data[CALIBRATE_BLOCKSIZE];
|
||||
int *iptr;
|
||||
|
||||
if (itsyReadFlashBlock(CALIBRATE_OFFSET,
|
||||
cal_data, CALIBRATE_BLOCKSIZE) == 0) {
|
||||
if ( ITSY_DEBUG_LOW ) {
|
||||
fprintf(stderr,"unable to read calibration data for touch screen\n");
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
iptr = (int *) cal_data;
|
||||
if (iptr[0] == CALIBRATE_MAGIC_NUM) {
|
||||
if ( ITSY_DEBUG_LOW ) {
|
||||
fprintf(stderr,"Calibrating touch screen using %d, %d, %d, %d, %d\n",
|
||||
iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
|
||||
}
|
||||
itsySetTouchCalibration(mou_filedsc, iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
|
||||
return(1);
|
||||
}
|
||||
else {
|
||||
if ( ITSY_DEBUG_LOW ) {
|
||||
fprintf(stderr,"Couldn't calibrate screen\n");
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
itsyTsInit (void)
|
||||
{
|
||||
int tsPort;
|
||||
|
||||
tsPort = open ("/dev/ts", 0);
|
||||
fprintf (stderr, "tsPort %d\n", tsPort);
|
||||
#if 0
|
||||
if (tsPort >= 0)
|
||||
check_if_calibrated_and_set (tsPort);
|
||||
#endif
|
||||
return tsPort;
|
||||
}
|
||||
|
||||
void
|
||||
itsyTsFini (int tsPort)
|
||||
{
|
||||
if (tsPort >= 0)
|
||||
close (tsPort);
|
||||
}
|
||||
|
||||
KdMouseFuncs itsyTsMouseFuncs = {
|
||||
itsyTsInit,
|
||||
itsyTsRead,
|
||||
itsyTsFini
|
||||
};
|
||||
|
440
hw/kdrive/keyboard.c
Normal file
440
hw/kdrive/keyboard.c
Normal file
|
@ -0,0 +1,440 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#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 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,
|
||||
};
|
322
hw/kdrive/linux.c
Normal file
322
hw/kdrive/linux.c
Normal file
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#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;
|
||||
|
||||
ven_dev = (((CARD32) vendor) << 16) | ((CARD32) device);
|
||||
f = fopen ("/proc/bus/pci/devices", "r");
|
||||
if (!f)
|
||||
return FALSE;
|
||||
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 (;;)
|
||||
{
|
||||
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,
|
||||
};
|
132
hw/kdrive/ps2.c
Normal file
132
hw/kdrive/ps2.c
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#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
|
||||
};
|
15
hw/kdrive/savage/Imakefile
Normal file
15
hw/kdrive/savage/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = s3.c s3clock.c s3cmap.c s3curs.c s3draw.c s3gc.c s3reg.c s3stub.c
|
||||
|
||||
OBJS = s3.o s3clock.o s3cmap.o s3curs.o s3draw.o s3gc.o s3reg.o s3stub.o
|
||||
|
||||
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(savage,$(OBJS))
|
||||
DependTarget()
|
997
hw/kdrive/savage/s3.c
Normal file
997
hw/kdrive/savage/s3.c
Normal file
|
@ -0,0 +1,997 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
#define REGISTERS_OFFSET (0x1000000)
|
||||
#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)
|
||||
{
|
||||
CARD8 clock_mode;
|
||||
|
||||
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)
|
||||
{
|
||||
S3CardInfo *s3c;
|
||||
S3Ptr s3;
|
||||
S3Vga *s3vga;
|
||||
int size;
|
||||
CARD8 *registers;
|
||||
CARD32 s3FrameBuffer;
|
||||
CARD32 s3Registers;
|
||||
CARD8 *temp_buffer;
|
||||
CARD32 max_memory;
|
||||
VGA32 save_linear_window_size;
|
||||
VGA32 save_enable_linear;
|
||||
VGA32 save_register_lock_2;
|
||||
|
||||
s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo));
|
||||
if (!s3c)
|
||||
{
|
||||
goto bail0;
|
||||
}
|
||||
|
||||
memset (s3c, '\0', sizeof (S3CardInfo));
|
||||
|
||||
card->driver = s3c;
|
||||
|
||||
if (card->attr.naddr > 1)
|
||||
{
|
||||
s3FrameBuffer = card->attr.address[1];
|
||||
s3Registers = card->attr.address[0];
|
||||
max_memory = 32 * 1024 * 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
s3FrameBuffer = card->attr.address[0];
|
||||
s3Registers = s3FrameBuffer + REGISTERS_OFFSET;
|
||||
max_memory = 16 * 1024 * 1024;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "S3 at 0x%x/0x%x\n", s3Registers, s3FrameBuffer);
|
||||
#endif
|
||||
registers = KdMapDevice (s3Registers,
|
||||
sizeof (S3) + PACKED_OFFSET);
|
||||
if (!registers)
|
||||
{
|
||||
ErrorF ("Can't map s3 device\n");
|
||||
goto bail2;
|
||||
}
|
||||
s3 = (S3Ptr) (registers + PACKED_OFFSET);
|
||||
s3c->registers = registers;
|
||||
s3c->s3 = s3;
|
||||
|
||||
s3vga = &s3c->s3vga;
|
||||
s3RegInit (s3vga, (VGAVOL8 *) (registers + IOMAP_OFFSET));
|
||||
|
||||
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);
|
||||
save_enable_linear = s3Get (s3vga, s3_enable_linear);
|
||||
s3Set (s3vga, s3_linear_window_size, 3);
|
||||
s3Set (s3vga, s3_enable_linear, 1);
|
||||
VgaFlush (&s3vga->card);
|
||||
VgaFinish (&s3vga->card);
|
||||
|
||||
/*
|
||||
* Can't trust S3 register value for frame buffer amount, must compute
|
||||
*/
|
||||
temp_buffer = KdMapDevice (s3FrameBuffer, max_memory);
|
||||
|
||||
s3c->memory = KdFrameBufferSize (temp_buffer, max_memory);
|
||||
|
||||
s3Set (s3vga, s3_linear_window_size, save_linear_window_size);
|
||||
s3Set (s3vga, s3_enable_linear, save_enable_linear);
|
||||
VgaFlush (&s3vga->card);
|
||||
s3SetImm (s3vga, s3_register_lock_2, save_register_lock_2);
|
||||
VgaFinish (&s3vga->card);
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Frame buffer 0x%x\n", s3c->memory);
|
||||
#endif
|
||||
KdUnmapDevice (temp_buffer, max_memory);
|
||||
|
||||
if (!s3c->memory)
|
||||
{
|
||||
ErrorF ("Can't detect s3 frame buffer at 0x%x\n", s3FrameBuffer);
|
||||
goto bail3;
|
||||
}
|
||||
|
||||
s3c->frameBuffer = KdMapDevice (s3FrameBuffer, s3c->memory);
|
||||
if (!s3c->frameBuffer)
|
||||
{
|
||||
ErrorF ("Can't map s3 frame buffer\n");
|
||||
goto bail3;
|
||||
}
|
||||
|
||||
card->driver = s3c;
|
||||
|
||||
return TRUE;
|
||||
bail3:
|
||||
KdUnmapDevice ((void *) s3, sizeof (S3));
|
||||
bail2:
|
||||
bail1:
|
||||
xfree (s3c);
|
||||
bail0:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo));
|
||||
if (!s3s)
|
||||
return FALSE;
|
||||
|
||||
memset (s3s, '\0', sizeof (S3ScreenInfo));
|
||||
|
||||
if (!screen->width || !screen->height)
|
||||
{
|
||||
screen->width = 800;
|
||||
screen->height = 600;
|
||||
screen->rate = 72;
|
||||
}
|
||||
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];
|
||||
screen->rate = t->rate;
|
||||
screen->width = t->horizontal;
|
||||
screen->height = t->vertical;
|
||||
s3GetClock (S3ModeClock(t), &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));
|
||||
#endif
|
||||
/*
|
||||
* Can only operate in pixel-doubled mode at 8 bits per pixel
|
||||
*/
|
||||
if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
|
||||
screen->depth = 16;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
memory = s3c->memory - screen_size;
|
||||
|
||||
/*
|
||||
* Stick frame buffer at start of memory
|
||||
*/
|
||||
screen->frameBuffer = s3c->frameBuffer;
|
||||
|
||||
/*
|
||||
* Stick cursor at end of memory
|
||||
*/
|
||||
if (memory >= 2048)
|
||||
{
|
||||
s3s->cursor_base = s3c->frameBuffer + (s3c->memory - 2048);
|
||||
memory -= 2048;
|
||||
}
|
||||
else
|
||||
s3s->cursor_base = 0;
|
||||
|
||||
/*
|
||||
* Use remaining memory for off-screen storage, but only use
|
||||
* one piece (either right or bottom).
|
||||
*/
|
||||
if (memory >= byte_width * 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;
|
||||
}
|
||||
else if (pixel_width - 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_height = screen->height;
|
||||
}
|
||||
else
|
||||
s3s->offscreen = 0;
|
||||
|
||||
switch (screen->depth) {
|
||||
case 8:
|
||||
screen->visuals = ((1 << StaticGray) |
|
||||
(1 << GrayScale) |
|
||||
(1 << StaticColor) |
|
||||
(1 << PseudoColor) |
|
||||
(1 << TrueColor) |
|
||||
(1 << DirectColor));
|
||||
screen->blueMask = 0x00;
|
||||
screen->greenMask = 0x00;
|
||||
screen->redMask = 0x00;
|
||||
break;
|
||||
case 15:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x001f;
|
||||
screen->greenMask = 0x03e0;
|
||||
screen->redMask = 0x7c00;
|
||||
break;
|
||||
case 16:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x001f;
|
||||
screen->greenMask = 0x07e0;
|
||||
screen->redMask = 0xf800;
|
||||
break;
|
||||
case 24:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x0000ff;
|
||||
screen->greenMask = 0x00ff00;
|
||||
screen->redMask = 0xff0000;
|
||||
break;
|
||||
}
|
||||
|
||||
screen->driver = s3s;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
s3Preserve (KdCardInfo *card)
|
||||
{
|
||||
S3CardInfo *s3c = card->driver;
|
||||
S3Ptr s3 = s3c->s3;
|
||||
S3Vga *s3vga = &s3c->s3vga;
|
||||
S3Save *save = &s3c->save;
|
||||
CARD8 t1, t2;
|
||||
CARD8 *cursor_base;
|
||||
|
||||
s3Save (s3vga);
|
||||
_s3SetBlank (s3, s3vga, TRUE);
|
||||
/*
|
||||
* Preserve the first part of the frame buffer which holds
|
||||
* the text mode fonts and data
|
||||
*/
|
||||
s3Set (s3vga, s3_linear_window_size, 3);
|
||||
s3Set (s3vga, s3_enable_linear, 1);
|
||||
VgaFlush (&s3vga->card);
|
||||
memcpy (save->text_save, s3c->frameBuffer, S3_TEXT_SAVE);
|
||||
/*
|
||||
* Preserve graphics engine state
|
||||
*/
|
||||
save->alt_mix = s3->alt_mix;
|
||||
save->write_mask = s3->write_mask;
|
||||
save->fg = s3->fg;
|
||||
save->bg = s3->bg;
|
||||
_s3SetBlank (s3, s3vga, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the card for rendering. Manipulate the initial settings
|
||||
* of the card here.
|
||||
*/
|
||||
void
|
||||
s3Enable (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
KdCardInfo *card = pScreenPriv->card;
|
||||
KdScreenInfo *screen = pScreenPriv->screen;
|
||||
s3CardInfo (pScreenPriv);
|
||||
s3ScreenInfo (pScreenPriv);
|
||||
|
||||
S3Vga *s3vga = &s3c->s3vga;
|
||||
int hactive, hblank, hfp, hbp;
|
||||
int vactive, vblank, vfp, vbp;
|
||||
int hsize;
|
||||
|
||||
int h_total;
|
||||
int h_display_end;
|
||||
int h_blank_start;
|
||||
int h_blank_end;
|
||||
int h_sync_start;
|
||||
int h_sync_end;
|
||||
int h_screen_off;
|
||||
int h_start_fifo_fetch;
|
||||
|
||||
int primary_stream_l1;
|
||||
|
||||
int v_total;
|
||||
int v_retrace_start;
|
||||
int v_retrace_end;
|
||||
int v_display_end;
|
||||
int v_blank_start;
|
||||
int v_blank_end;
|
||||
|
||||
int h_blank_start_adjust;
|
||||
int h_blank_end_adjust;
|
||||
int h_sync_extend;
|
||||
int h_blank_extend;
|
||||
int i;
|
||||
CARD16 cursor_address;
|
||||
S3Timing *t;
|
||||
int m, n, r;
|
||||
Bool clock_double;
|
||||
|
||||
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];
|
||||
|
||||
hfp = t->hfp;
|
||||
hbp = t->hbp;
|
||||
hblank = t->hblank;
|
||||
hactive = t->horizontal;
|
||||
|
||||
vfp = t->vfp;
|
||||
vbp = t->vbp;
|
||||
vblank = t->vblank;
|
||||
vactive = t->vertical;
|
||||
|
||||
m = s3Get (s3vga, s3_dclk_m);
|
||||
n = s3Get (s3vga, s3_dclk_n);
|
||||
r = s3Get (s3vga, s3_dclk_r);
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "old clock %d, %d, %d\n", m, n, r);
|
||||
#endif
|
||||
clock_double = FALSE;
|
||||
s3GetClock (S3ModeClock(t), &m, &n, &r, 511, 127, 4);
|
||||
if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
|
||||
clock_double = TRUE;
|
||||
s3Set (s3vga, s3_clock_select, 3);
|
||||
s3Set (s3vga, s3_dclk_m, m);
|
||||
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);
|
||||
#endif
|
||||
|
||||
s3Set (s3vga, s3_select_graphics_mode, 1);
|
||||
s3Set (s3vga, s3_enable_blinking, 0);
|
||||
s3Set (s3vga, s3_enable_vga_16bit, 0);
|
||||
s3Set (s3vga, s3_enhanced_memory_mapping, 1);
|
||||
s3Set (s3vga, s3_enable_sff, 1);
|
||||
s3Set (s3vga, s3_enable_2d_access, 1);
|
||||
s3Set (s3vga, s3_byte_mode, 1);
|
||||
s3Set (s3vga, s3_max_scan_line, 0);
|
||||
s3Set (s3vga, s3_linear_window_size, 3);
|
||||
s3Set (s3vga, s3_enable_linear, 1);
|
||||
s3Set (s3vga, s3_enable_2d_3d, 1);
|
||||
s3Set (s3vga, s3_refresh_control, 1);
|
||||
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, 0); /* eliminate white border */
|
||||
#endif
|
||||
s3Set (s3vga, s3_disable_v_retrace_int, 1);
|
||||
s3Set (s3vga, s3_horz_sync_neg, 0);
|
||||
s3Set (s3vga, s3_vert_sync_neg, 0);
|
||||
|
||||
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_cpu_timeout, 0x1f);
|
||||
s3Set (s3vga, s3_fifo_fetch_timing, 1);
|
||||
s3Set (s3vga, s3_fifo_drain_delay, 7);
|
||||
|
||||
|
||||
s3Set (s3vga, s3_delay_h_enable, 0);
|
||||
s3Set (s3vga, s3_sdclk_skew, 0);
|
||||
|
||||
/*
|
||||
* Compute character lengths for horizontal timing values
|
||||
*/
|
||||
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);
|
||||
/*
|
||||
* Set up for double-pixel mode, switch color modes,
|
||||
* divide the dclk and delay h blank by 2 dclks
|
||||
*/
|
||||
if (clock_double)
|
||||
{
|
||||
s3Set (s3vga, s3_color_mode, 1);
|
||||
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;
|
||||
}
|
||||
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)
|
||||
s3Set (s3vga, s3_color_mode, 3);
|
||||
else
|
||||
s3Set (s3vga, s3_color_mode, 5);
|
||||
s3Set (s3vga, s3_dclk_over_2, 1);
|
||||
s3Set (s3vga, s3_enable_clock_double, 1);
|
||||
s3Set (s3vga, s3_border_select, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (screen->depth == 15)
|
||||
s3Set (s3vga, s3_color_mode, 2);
|
||||
else
|
||||
s3Set (s3vga, s3_color_mode, 4);
|
||||
s3Set (s3vga, s3_dclk_over_2, 0);
|
||||
s3Set (s3vga, s3_enable_clock_double, 0);
|
||||
s3Set (s3vga, s3_delay_blank, 0);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* X server starts frame buffer at top of memory
|
||||
*/
|
||||
s3Set (s3vga, s3_start_address, 0);
|
||||
|
||||
/*
|
||||
* Compute horizontal register values from timings
|
||||
*/
|
||||
h_total = hactive + hblank - 5;
|
||||
h_display_end = hactive - 1;
|
||||
|
||||
h_sync_start = hactive + hfp;
|
||||
h_sync_end = hactive + hblank - hbp;
|
||||
/*
|
||||
* pad the blank values narrow a bit and use the border_select to
|
||||
* eliminate the remaining border; don't know why, but it doesn't
|
||||
* work in the documented fashion
|
||||
*/
|
||||
h_blank_start = hactive + 1 + h_blank_start_adjust;
|
||||
h_blank_end = hactive + hblank - 2 + h_blank_end_adjust;
|
||||
/*
|
||||
* The manual says h_total - 5, but the
|
||||
* bios does differently...
|
||||
*/
|
||||
if (screen->width >= 1600)
|
||||
h_start_fifo_fetch = h_total - 24;
|
||||
else if (screen->width >= 1280)
|
||||
h_start_fifo_fetch = h_total - 19;
|
||||
else if (screen->width >= 1024)
|
||||
h_start_fifo_fetch = h_total - 14;
|
||||
else if (screen->width >= 800)
|
||||
h_start_fifo_fetch = h_total - 10;
|
||||
else
|
||||
h_start_fifo_fetch = h_total - 5;
|
||||
|
||||
if (h_blank_end - h_blank_start >= 0x40)
|
||||
h_blank_extend = 1;
|
||||
else
|
||||
h_blank_extend = 0;
|
||||
|
||||
if (h_sync_end - h_sync_start >= 0x20)
|
||||
h_sync_extend = 1;
|
||||
else
|
||||
h_sync_extend = 0;
|
||||
|
||||
primary_stream_l1 = (screen->width * screen->bitsPerPixel / (8 * 8)) - 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "h_total %d h_display_end %d\n",
|
||||
h_total, h_display_end);
|
||||
fprintf (stderr, "h_sync_start %d h_sync_end %d h_sync_extend %d\n",
|
||||
h_sync_start, h_sync_end, h_sync_extend);
|
||||
fprintf (stderr, "h_blank_start %d h_blank_end %d h_blank_extend %d\n",
|
||||
h_blank_start, h_blank_end, h_blank_extend);
|
||||
#endif
|
||||
|
||||
s3Set (s3vga, s3_h_total, h_total);
|
||||
s3Set (s3vga, s3_h_display_end, h_display_end);
|
||||
s3Set (s3vga, s3_h_blank_start, h_blank_start);
|
||||
s3Set (s3vga, s3_h_blank_end, h_blank_end);
|
||||
s3Set (s3vga, s3_h_sync_start, h_sync_start);
|
||||
s3Set (s3vga, s3_h_sync_end, h_sync_end);
|
||||
s3Set (s3vga, s3_screen_offset, h_screen_off);
|
||||
s3Set (s3vga, s3_h_start_fifo_fetch, h_start_fifo_fetch);
|
||||
s3Set (s3vga, s3_h_sync_extend, h_sync_extend);
|
||||
s3Set (s3vga, s3_h_blank_extend, h_blank_extend);
|
||||
|
||||
s3Set (s3vga, s3_primary_stream_l1, primary_stream_l1);
|
||||
|
||||
v_total = vactive + vblank - 2;
|
||||
v_display_end = vactive - 1;
|
||||
|
||||
#if 0
|
||||
v_blank_start = vactive - 1;
|
||||
v_blank_end = v_blank_start + vblank - 1;
|
||||
#else
|
||||
v_blank_start = vactive - 1;
|
||||
v_blank_end = v_blank_start + vblank - 1;
|
||||
#endif
|
||||
|
||||
v_retrace_start = vactive + vfp;
|
||||
v_retrace_end = vactive + vblank - vbp;
|
||||
|
||||
s3Set (s3vga, s3_v_total, v_total);
|
||||
s3Set (s3vga, s3_v_retrace_start, v_retrace_start);
|
||||
s3Set (s3vga, s3_v_retrace_end, v_retrace_end);
|
||||
s3Set (s3vga, s3_v_display_end, v_display_end);
|
||||
s3Set (s3vga, s3_v_blank_start, v_blank_start);
|
||||
s3Set (s3vga, s3_v_blank_end, v_blank_end);
|
||||
|
||||
if (vactive >= 1024)
|
||||
s3Set (s3vga, s3_line_compare, 0x7ff);
|
||||
else
|
||||
s3Set (s3vga, s3_line_compare, 0x3ff);
|
||||
|
||||
/*
|
||||
* Set cursor
|
||||
*/
|
||||
if (!screen->softCursor)
|
||||
{
|
||||
cursor_address = (s3s->cursor_base - screen->frameBuffer) / 1024;
|
||||
|
||||
s3Set (s3vga, s3_cursor_address, cursor_address);
|
||||
s3Set (s3vga, s3_cursor_ms_x11, 0);
|
||||
s3Set (s3vga, s3_cursor_enable, 1);
|
||||
}
|
||||
else
|
||||
s3Set (s3vga, s3_cursor_enable, 0);
|
||||
|
||||
/*
|
||||
* Set accelerator
|
||||
*/
|
||||
switch (screen->width) {
|
||||
case 640: s3Set (s3vga, s3_ge_screen_width, 1); break;
|
||||
case 800: s3Set (s3vga, s3_ge_screen_width, 2); break;
|
||||
case 1024: s3Set (s3vga, s3_ge_screen_width, 0); break;
|
||||
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;
|
||||
}
|
||||
|
||||
#if 0
|
||||
crtc->l_parm_0_7 = screen->width / 4; /* Undocumented. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set DPMS to normal
|
||||
*/
|
||||
s3Set (s3vga, s3_hsync_control, 0);
|
||||
s3Set (s3vga, s3_vsync_control, 0);
|
||||
|
||||
_s3SetDepth (s3c->s3, s3vga);
|
||||
}
|
||||
|
||||
void
|
||||
s3Disable (ScreenPtr pScreen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
s3Restore (KdCardInfo *card)
|
||||
{
|
||||
S3CardInfo *s3c = card->driver;
|
||||
S3Ptr s3 = s3c->s3;
|
||||
S3Vga *s3vga = &s3c->s3vga;
|
||||
S3Save *save = &s3c->save;
|
||||
CARD8 *cursor_base;
|
||||
|
||||
/* graphics engine state */
|
||||
s3->alt_mix = save->alt_mix;
|
||||
s3->write_mask = save->write_mask;
|
||||
s3->fg = save->fg;
|
||||
s3->bg = save->bg;
|
||||
/* XXX should save and restore real values? */
|
||||
s3->scissors_tl = 0x00000000;
|
||||
s3->scissors_br = 0x0fff0fff;
|
||||
|
||||
_s3SetBlank (s3, s3vga, TRUE);
|
||||
VgaRestore (&s3vga->card);
|
||||
s3Set (s3vga, s3_linear_window_size, 3);
|
||||
s3Set (s3vga, s3_enable_linear, 1);
|
||||
VgaFlush (&s3vga->card);
|
||||
memcpy (s3c->frameBuffer, save->text_save, S3_TEXT_SAVE);
|
||||
s3Reset (s3vga);
|
||||
_s3SetBlank (s3, s3vga, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
_s3SetSync (S3CardInfo *s3c, int hsync, int vsync)
|
||||
{
|
||||
/* this abuses the macros defined to access the crtc structure */
|
||||
S3Ptr s3 = s3c->s3;
|
||||
S3Vga *s3vga = &s3c->s3vga;
|
||||
|
||||
s3Set (s3vga, s3_hsync_control, hsync);
|
||||
s3Set (s3vga, s3_vsync_control, vsync);
|
||||
VgaFlush (&s3vga->card);
|
||||
}
|
||||
|
||||
Bool
|
||||
s3DPMS (ScreenPtr pScreen, int mode)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
s3CardInfo(pScreenPriv);
|
||||
S3Vga *s3vga = &s3c->s3vga;
|
||||
|
||||
switch (mode) {
|
||||
case KD_DPMS_NORMAL:
|
||||
_s3SetSync (s3c, 0, 0);
|
||||
_s3SetBlank (s3c->s3, s3vga, FALSE);
|
||||
break;
|
||||
case KD_DPMS_STANDBY:
|
||||
_s3SetBlank (s3c->s3, s3vga, TRUE);
|
||||
_s3SetSync (s3c, 1, 0);
|
||||
break;
|
||||
case KD_DPMS_SUSPEND:
|
||||
_s3SetBlank (s3c->s3, s3vga, TRUE);
|
||||
_s3SetSync (s3c, 0, 1);
|
||||
break;
|
||||
case KD_DPMS_POWERDOWN:
|
||||
_s3SetBlank (s3c->s3, s3vga, TRUE);
|
||||
_s3SetSync (s3c, 1, 1);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
s3ScreenFini (KdScreenInfo *screen)
|
||||
{
|
||||
S3ScreenInfo *s3s = (S3ScreenInfo *) screen->driver;
|
||||
|
||||
xfree (s3s);
|
||||
screen->driver = 0;
|
||||
}
|
||||
|
||||
void
|
||||
s3CardFini (KdCardInfo *card)
|
||||
{
|
||||
S3CardInfo *s3c = (S3CardInfo *) card->driver;
|
||||
|
||||
KdUnmapDevice (s3c->frameBuffer, s3c->memory);
|
||||
KdUnmapDevice (s3c->registers, sizeof (S3) + PACKED_OFFSET);
|
||||
xfree (s3c);
|
||||
card->driver = 0;
|
||||
}
|
||||
|
||||
KdCardFuncs s3Funcs = {
|
||||
s3CardInit,
|
||||
s3ScreenInit,
|
||||
s3Preserve,
|
||||
s3Enable,
|
||||
s3DPMS,
|
||||
s3Disable,
|
||||
s3Restore,
|
||||
s3ScreenFini,
|
||||
s3CardFini,
|
||||
s3CursorInit,
|
||||
s3CursorEnable,
|
||||
s3CursorDisable,
|
||||
s3CursorFini,
|
||||
s3RecolorCursor,
|
||||
s3DrawInit,
|
||||
s3DrawEnable,
|
||||
s3DrawDisable,
|
||||
s3DrawFini,
|
||||
s3GetColors,
|
||||
s3PutColors,
|
||||
};
|
545
hw/kdrive/savage/s3.h
Normal file
545
hw/kdrive/savage/s3.h
Normal file
|
@ -0,0 +1,545 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _S3_H_
|
||||
#define _S3_H_
|
||||
|
||||
#include "kdrive.h"
|
||||
#include "s3reg.h"
|
||||
|
||||
#define PLATFORM 300
|
||||
|
||||
/* VESA Approved Register Definitions */
|
||||
|
||||
/*
|
||||
* Linear Addressing 000 0000 - 0ff ffff (16m)
|
||||
* Image data transfer 100 0000 - 100 7fff (32k)
|
||||
* PCI config 100 8000 - 100 8043
|
||||
* Packed enhanced regs 100 8100 - 100 814a
|
||||
* Streams regs 100 8180 - 100 81ff
|
||||
* Current Y pos 100 82e8
|
||||
* CRT VGA 3b? regs 100 83b0 - 100 83bf
|
||||
* CRT VGA 3c? regs 100 83c0 - 100 83cf
|
||||
* CRT VGA 3d? regs 100 83d0 - 100 83df
|
||||
* Subsystem status (42e8h) 100 8504
|
||||
* Advanced function (42e8h) 100 850c
|
||||
* Enhanced regs 100 86e8 - 100 eeea
|
||||
* Local peripheral bus 100 ff00 - 100 ff5c
|
||||
*
|
||||
* We don't care about the image transfer or PCI regs, so
|
||||
* this structure starts at the packed enhanced regs
|
||||
*/
|
||||
|
||||
typedef volatile CARD32 VOL32;
|
||||
typedef volatile CARD16 VOL16;
|
||||
typedef volatile CARD8 VOL8;
|
||||
|
||||
typedef volatile struct _s3 {
|
||||
VOL32 alt_curxy; /* 8100 */
|
||||
VOL32 _pad0; /* 8104 */
|
||||
VOL32 alt_step; /* 8108 */
|
||||
VOL32 _pad1; /* 810c */
|
||||
VOL32 err_term; /* 8110 */
|
||||
VOL32 _pad2; /* 8114 */
|
||||
VOL32 cmd_gp_stat; /* 8118 */
|
||||
VOL32 short_stroke; /* 811c */
|
||||
VOL32 bg; /* 8120 */
|
||||
VOL32 fg; /* 8124 */
|
||||
VOL32 write_mask; /* 8128 */
|
||||
VOL32 read_mask; /* 812c */
|
||||
VOL32 color_cmp; /* 8130 */
|
||||
VOL32 alt_mix; /* 8134 */
|
||||
VOL32 scissors_tl; /* 8138 */
|
||||
VOL32 scissors_br; /* 813c */
|
||||
VOL16 pix_cntl; /* 8140 */
|
||||
VOL16 mult_misc2; /* 8142 */
|
||||
VOL32 mult_misc_read_sel; /* 8144 */
|
||||
VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */
|
||||
VOL8 _pad3[0x19c]; /* 814c */
|
||||
VOL16 cur_y; /* 82e8 */
|
||||
VOL8 _pad4[0xc6]; /* 82ea */
|
||||
|
||||
VOL8 crt_vga_3b0; /* 83b0 */
|
||||
VOL8 crt_vga_3b1; /* 83b1 */
|
||||
VOL8 crt_vga_3b2; /* 83b2 */
|
||||
VOL8 crt_vga_3b3; /* 83b3 */
|
||||
VOL8 crt_vga_3b4; /* 83b4 */
|
||||
VOL8 crt_vga_3b5; /* 83b5 */
|
||||
VOL8 crt_vga_3b6; /* 83b6 */
|
||||
VOL8 crt_vga_3b7; /* 83b7 */
|
||||
VOL8 crt_vga_3b8; /* 83b8 */
|
||||
VOL8 crt_vga_3b9; /* 83b9 */
|
||||
VOL8 crt_vga_3ba; /* 83ba */
|
||||
VOL8 crt_vga_3bb; /* 83bb */
|
||||
VOL8 crt_vga_3bc; /* 83bc */
|
||||
VOL8 crt_vga_3bd; /* 83bd */
|
||||
VOL8 crt_vga_3be; /* 83be */
|
||||
VOL8 crt_vga_3bf; /* 83bf */
|
||||
|
||||
VOL8 crt_vga_3c0; /* 83c0 */
|
||||
VOL8 crt_vga_3c1; /* 83c1 */
|
||||
VOL8 crt_vga_3c2; /* 83c2 */
|
||||
VOL8 crt_vga_3c3; /* 83c3 */
|
||||
VOL8 crt_vga_3c4; /* 83c4 */
|
||||
VOL8 crt_vga_3c5; /* 83c5 */
|
||||
VOL8 crt_vga_dac_ad_mk; /* 83c6 */
|
||||
VOL8 crt_vga_dac_rd_ad; /* 83c7 */
|
||||
VOL8 crt_vga_dac_wt_ad; /* 83c8 */
|
||||
VOL8 crt_vga_dac_data; /* 83c9 */
|
||||
VOL8 crt_vga_3ca; /* 83ca */
|
||||
VOL8 crt_vga_3cb; /* 83cb */
|
||||
VOL8 crt_vga_3cc; /* 83cc */
|
||||
VOL8 crt_vga_3cd; /* 83cd */
|
||||
VOL8 crt_vga_3ce; /* 83ce */
|
||||
VOL8 crt_vga_3cf; /* 83cf */
|
||||
|
||||
VOL8 crt_vga_3d0; /* 83d0 */
|
||||
VOL8 crt_vga_3d1; /* 83d1 */
|
||||
VOL8 crt_vga_3d2; /* 83d2 */
|
||||
VOL8 crt_vga_3d3; /* 83d3 */
|
||||
VOL8 crt_vga_3d4; /* 83d4 */
|
||||
VOL8 crt_vga_3d5; /* 83d5 */
|
||||
VOL8 crt_vga_3d6; /* 83d6 */
|
||||
VOL8 crt_vga_3d7; /* 83d7 */
|
||||
VOL8 crt_vga_3d8; /* 83d8 */
|
||||
VOL8 crt_vga_3d9; /* 83d9 */
|
||||
VOL8 crt_vga_status_1; /* 83da */
|
||||
VOL8 crt_vga_3db; /* 83db */
|
||||
VOL8 crt_vga_3dc; /* 83dc */
|
||||
VOL8 crt_vga_3dd; /* 83dd */
|
||||
VOL8 crt_vga_3de; /* 83de */
|
||||
VOL8 crt_vga_3df; /* 83df */
|
||||
|
||||
VOL8 _pad5[0x124]; /* 83e0 */
|
||||
VOL16 subsys_status; /* 8504 */
|
||||
VOL8 _pad6[0x6]; /* 8506 */
|
||||
VOL16 adv_control; /* 850c */
|
||||
VOL8 _pad7[0x1da]; /* 850e */
|
||||
VOL16 cur_x; /* 86e8 */
|
||||
VOL8 _pad8[0x3fe]; /* 86ea */
|
||||
VOL16 desty_axstp; /* 8ae8 */
|
||||
VOL8 _pad9[0x3fe]; /* 8aea */
|
||||
VOL16 destx_diastp; /* 8ee8 */
|
||||
VOL8 _pad10[0x3fe]; /* 8eea */
|
||||
VOL16 enh_err_term; /* 92e8 */
|
||||
VOL8 _pad11[0x3fe]; /* 92ea */
|
||||
VOL16 maj_axis_pcnt; /* 96e8 */
|
||||
VOL8 _pad12[0x3fe]; /* 96ea */
|
||||
VOL16 enh_cmd_gp_stat; /* 9ae8 */
|
||||
VOL8 _pad13[0x3fe]; /* 9aea */
|
||||
VOL16 enh_short_stroke; /* 9ee8 */
|
||||
VOL8 _pad14[0x3fe]; /* 9eea */
|
||||
VOL16 enh_bg; /* a2e8 */
|
||||
VOL8 _pad15[0x3fe]; /* a2ea */
|
||||
VOL16 enh_fg; /* a6e8 */
|
||||
VOL8 _pad16[0x3fe]; /* a6ea */
|
||||
VOL16 enh_wrt_mask; /* aae8 */
|
||||
VOL8 _pad17[0x3fe]; /* aaea */
|
||||
VOL16 enh_rd_mask; /* aee8 */
|
||||
VOL8 _pad18[0x3fe]; /* aeea */
|
||||
VOL16 enh_color_cmp; /* b2e8 */
|
||||
VOL8 _pad19[0x3fe]; /* b2ea */
|
||||
VOL16 enh_bg_mix; /* b6e8 */
|
||||
VOL8 _pad20[0x3fe]; /* b6ea */
|
||||
VOL16 enh_fg_mix; /* bae8 */
|
||||
VOL8 _pad21[0x3fe]; /* baea */
|
||||
VOL16 enh_rd_reg_dt; /* bee8 */
|
||||
VOL8 _pad22[0x23fe]; /* beea */
|
||||
VOL32 pix_trans; /* e2e8 */
|
||||
|
||||
VOL8 _pad23[0x3a974]; /* e2ec */
|
||||
VOL32 alt_status_0; /* 48c60 */
|
||||
} S3, *S3Ptr;
|
||||
|
||||
#define VGA_STATUS_1_DTM 0x01
|
||||
#define VGA_STATUS_1_VSY 0x08
|
||||
|
||||
#define DAC_MASK 0x03c6
|
||||
#define DAC_R_INDEX 0x03c7
|
||||
#define DAC_W_INDEX 0x03c8
|
||||
#define DAC_DATA 0x03c9
|
||||
#define DISP_STAT 0x02e8
|
||||
#define H_TOTAL 0x02e8
|
||||
#define H_DISP 0x06e8
|
||||
#define H_SYNC_STRT 0x0ae8
|
||||
#define H_SYNC_WID 0x0ee8
|
||||
#define V_TOTAL 0x12e8
|
||||
#define V_DISP 0x16e8
|
||||
#define V_SYNC_STRT 0x1ae8
|
||||
#define V_SYNC_WID 0x1ee8
|
||||
#define DISP_CNTL 0x22e8
|
||||
#define ADVFUNC_CNTL 0x4ae8
|
||||
#define SUBSYS_STAT 0x42e8
|
||||
#define SUBSYS_CNTL 0x42e8
|
||||
#define ROM_PAGE_SEL 0x46e8
|
||||
#define CUR_Y 0x82e8
|
||||
#define CUR_X 0x86e8
|
||||
#define DESTY_AXSTP 0x8ae8
|
||||
#define DESTX_DIASTP 0x8ee8
|
||||
#define ERR_TERM 0x92e8
|
||||
#define MAJ_AXIS_PCNT 0x96e8
|
||||
#define GP_STAT 0x9ae8
|
||||
#define CMD 0x9ae8
|
||||
#define SHORT_STROKE 0x9ee8
|
||||
#define BKGD_COLOR 0xa2e8
|
||||
#define FRGD_COLOR 0xa6e8
|
||||
#define WRT_MASK 0xaae8
|
||||
#define RD_MASK 0xaee8
|
||||
#define COLOR_CMP 0xb2e8
|
||||
#define BKGD_MIX 0xb6e8
|
||||
#define FRGD_MIX 0xbae8
|
||||
#define MULTIFUNC_CNTL 0xbee8
|
||||
#define MIN_AXIS_PCNT 0x0000
|
||||
#define SCISSORS_T 0x1000
|
||||
#define SCISSORS_L 0x2000
|
||||
#define SCISSORS_B 0x3000
|
||||
#define SCISSORS_R 0x4000
|
||||
#define MEM_CNTL 0x5000
|
||||
#define PATTERN_L 0x8000
|
||||
#define PATTERN_H 0x9000
|
||||
#define PIX_CNTL 0xa000
|
||||
#define PIX_TRANS 0xe2e8
|
||||
|
||||
/* Advanced Function Control Regsiter */
|
||||
#define CLKSEL 0x0004
|
||||
#define DISABPASSTHRU 0x0001
|
||||
|
||||
/* Graphics Processor Status Register */
|
||||
|
||||
#define GPNSLOT 13
|
||||
|
||||
#define GPBUSY_1 0x0080
|
||||
#define GPBUSY_2 0x0040
|
||||
#define GPBUSY_3 0x0020
|
||||
#define GPBUSY_4 0x0010
|
||||
#define GPBUSY_5 0x0008
|
||||
#define GPBUSY_6 0x0004
|
||||
#define GPBUSY_7 0x0002
|
||||
#define GPBUSY_8 0x0001
|
||||
#define GPBUSY_9 0x8000
|
||||
#define GPBUSY_10 0x4000
|
||||
#define GPBUSY_11 0x2000
|
||||
#define GPBUSY_12 0x1000
|
||||
#define GPBUSY_13 0x0800
|
||||
|
||||
#define GPEMPTY 0x0400
|
||||
#define GPBUSY 0x0200
|
||||
#define DATDRDY 0x0100
|
||||
|
||||
/* Command Register */
|
||||
#define CMD_NOP 0x0000
|
||||
#define CMD_LINE 0x2000
|
||||
#define CMD_RECT 0x4000
|
||||
#define CMD_RECTV1 0x6000
|
||||
#define CMD_RECTV2 0x8000
|
||||
#define CMD_LINEAF 0xa000
|
||||
#define CMD_BITBLT 0xc000
|
||||
#define CMD_PATBLT 0xe000
|
||||
#define CMD_OP_MSK 0xe000
|
||||
#define BYTSEQ 0x1000
|
||||
#define _32BITNOPAD 0x0600
|
||||
#define _32BIT 0x0400
|
||||
#define _16BIT 0x0200
|
||||
#define _8BIT 0x0000
|
||||
#define PCDATA 0x0100
|
||||
#define INC_Y 0x0080
|
||||
#define YMAJAXIS 0x0040
|
||||
#define INC_X 0x0020
|
||||
#define DRAW 0x0010
|
||||
#define LINETYPE 0x0008
|
||||
#define LASTPIX 0x0004 /* Draw last pixel in line */
|
||||
#define PLANAR 0x0002
|
||||
#define WRTDATA 0x0001
|
||||
|
||||
/* Background Mix Register */
|
||||
#define BSS_BKGDCOL 0x0000
|
||||
#define BSS_FRGDCOL 0x0020
|
||||
#define BSS_PCDATA 0x0040
|
||||
#define BSS_BITBLT 0x0060
|
||||
|
||||
/* Foreground Mix Register */
|
||||
#define FSS_BKGDCOL 0x0000
|
||||
#define FSS_FRGDCOL 0x0020
|
||||
#define FSS_PCDATA 0x0040
|
||||
#define FSS_BITBLT 0x0060
|
||||
|
||||
/* The Mixes */
|
||||
#define MIX_MASK 0x001f
|
||||
|
||||
#define MIX_NOT_DST 0x0000
|
||||
#define MIX_0 0x0001
|
||||
#define MIX_1 0x0002
|
||||
#define MIX_DST 0x0003
|
||||
#define MIX_NOT_SRC 0x0004
|
||||
#define MIX_XOR 0x0005
|
||||
#define MIX_XNOR 0x0006
|
||||
#define MIX_SRC 0x0007
|
||||
#define MIX_NAND 0x0008
|
||||
#define MIX_NOT_SRC_OR_DST 0x0009
|
||||
#define MIX_SRC_OR_NOT_DST 0x000a
|
||||
#define MIX_OR 0x000b
|
||||
#define MIX_AND 0x000c
|
||||
#define MIX_SRC_AND_NOT_DST 0x000d
|
||||
#define MIX_NOT_SRC_AND_DST 0x000e
|
||||
#define MIX_NOR 0x000f
|
||||
|
||||
#define MIX_MIN 0x0010
|
||||
#define MIX_DST_MINUS_SRC 0x0011
|
||||
#define MIX_SRC_MINUS_DST 0x0012
|
||||
#define MIX_PLUS 0x0013
|
||||
#define MIX_MAX 0x0014
|
||||
#define MIX_HALF__DST_MINUS_SRC 0x0015
|
||||
#define MIX_HALF__SRC_MINUS_DST 0x0016
|
||||
#define MIX_AVERAGE 0x0017
|
||||
#define MIX_DST_MINUS_SRC_SAT 0x0018
|
||||
#define MIX_SRC_MINUS_DST_SAT 0x001a
|
||||
#define MIX_HALF__DST_MINUS_SRC_SAT 0x001c
|
||||
#define MIX_HALF__SRC_MINUS_DST_SAT 0x001e
|
||||
#define MIX_AVERAGE_SAT 0x001f
|
||||
|
||||
/* Pixel Control Register */
|
||||
#define MIXSEL_FRGDMIX 0x0000
|
||||
#define MIXSEL_PATT 0x0040
|
||||
#define MIXSEL_EXPPC 0x0080
|
||||
#define MIXSEL_EXPBLT 0x00c0
|
||||
#define COLCMPOP_F 0x0000
|
||||
#define COLCMPOP_T 0x0008
|
||||
#define COLCMPOP_GE 0x0010
|
||||
#define COLCMPOP_LT 0x0018
|
||||
#define COLCMPOP_NE 0x0020
|
||||
#define COLCMPOP_EQ 0x0028
|
||||
#define COLCMPOP_LE 0x0030
|
||||
#define COLCMPOP_GT 0x0038
|
||||
#define PLANEMODE 0x0004
|
||||
|
||||
|
||||
#define S3_SAVAGE4_SLOTS 0x0001ffff
|
||||
#define S3_SAVAGE4_2DI 0x00800000
|
||||
|
||||
#define _s3WaitLoop(mask,value){ \
|
||||
int __loop = 100000; \
|
||||
while (((s3)->alt_status_0 & (mask)) != (value)) \
|
||||
if (--__loop == 0) { \
|
||||
ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _s3WaitSlot(s3) _s3WaitLoop(0x1, 0x0)
|
||||
#define _s3WaitEmpty(s3) _s3WaitLoop(S3_SAVAGE4_SLOTS, 0)
|
||||
#define _s3WaitIdleEmpty(s3) _s3WaitLoop(S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, \
|
||||
S3_SAVAGE4_2DI)
|
||||
#define _s3WaitIdle(s3) _s3WaitLoop(S3_SAVAGE4_2DI, S3_SAVAGE4_2DI)
|
||||
|
||||
typedef struct _s3Cursor {
|
||||
int width, height;
|
||||
int xhot, yhot;
|
||||
Bool has_cursor;
|
||||
CursorPtr pCursor;
|
||||
Pixel source, mask;
|
||||
} S3Cursor;
|
||||
|
||||
typedef struct _s3PatternCache {
|
||||
int id;
|
||||
int x, y;
|
||||
} S3PatternCache;
|
||||
|
||||
typedef struct _s3Patterns {
|
||||
S3PatternCache *cache;
|
||||
int ncache;
|
||||
int last_used;
|
||||
int last_id;
|
||||
} S3Patterns;
|
||||
|
||||
#define S3_CLOCK_REF 14318 /* KHz */
|
||||
|
||||
#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
|
||||
|
||||
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;
|
||||
|
||||
#define S3_TEXT_SAVE (64*1024)
|
||||
|
||||
typedef struct _s3Save {
|
||||
CARD8 cursor_fg;
|
||||
CARD8 cursor_bg;
|
||||
CARD8 lock1;
|
||||
CARD8 lock2;
|
||||
CARD8 locksrtc;
|
||||
CARD8 clock_mode;
|
||||
CARD32 alt_mix;
|
||||
CARD32 write_mask;
|
||||
CARD32 fg;
|
||||
CARD32 bg;
|
||||
CARD8 text_save[S3_TEXT_SAVE];
|
||||
} S3Save;
|
||||
|
||||
typedef struct _s3CardInfo {
|
||||
S3Ptr s3; /* pointer to register structure */
|
||||
int memory; /* amount of memory */
|
||||
CARD8 *frameBuffer; /* pointer to frame buffer */
|
||||
CARD8 *registers; /* pointer to register map */
|
||||
S3Vga s3vga;
|
||||
S3Save save;
|
||||
} S3CardInfo;
|
||||
|
||||
typedef struct _s3ScreenInfo {
|
||||
CARD8 *cursor_base; /* pointer to cursor area */
|
||||
CARD8 *offscreen; /* pointer to offscreen area */
|
||||
int offscreen_y; /* top y coordinate of offscreen area */
|
||||
int offscreen_x; /* top x coordinate of offscreen area */
|
||||
int offscreen_width; /* width of offscreen area */
|
||||
int offscreen_height; /* height of offscreen area */
|
||||
S3Cursor cursor;
|
||||
S3Patterns patterns;
|
||||
} S3ScreenInfo;
|
||||
|
||||
#define getS3CardInfo(kd) ((S3CardInfo *) ((kd)->card->driver))
|
||||
#define s3CardInfo(kd) S3CardInfo *s3c = getS3CardInfo(kd)
|
||||
|
||||
#define getS3ScreenInfo(kd) ((S3ScreenInfo *) ((kd)->screen->driver))
|
||||
#define s3ScreenInfo(kd) S3ScreenInfo *s3s = getS3ScreenInfo(kd)
|
||||
|
||||
Bool s3CardInit (KdCardInfo *);
|
||||
Bool s3ScreenInit (KdScreenInfo *);
|
||||
void s3Enable (ScreenPtr pScreen);
|
||||
void s3Disable (ScreenPtr pScreen);
|
||||
void s3Fini (ScreenPtr pScreen);
|
||||
|
||||
Bool s3CursorInit (ScreenPtr pScreen);
|
||||
void s3CursorEnable (ScreenPtr pScreen);
|
||||
void s3CursorDisable (ScreenPtr pScreen);
|
||||
void s3CursorFini (ScreenPtr pScreen);
|
||||
void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
|
||||
|
||||
Bool s3DrawInit (ScreenPtr pScreen);
|
||||
void s3DrawEnable (ScreenPtr pScreen);
|
||||
void s3DrawDisable (ScreenPtr pScreen);
|
||||
void s3DrawFini (ScreenPtr pScreen);
|
||||
|
||||
void s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
|
||||
void s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Wait for the begining of the retrace interval
|
||||
*/
|
||||
|
||||
#define S3_RETRACE_LOOP_CHECK if (++_loop_count > 300000) {\
|
||||
DRAW_DEBUG ((DEBUG_FAILURE, "S3 wait loop failed at %s:%d", \
|
||||
__FILE__, __LINE__)); \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define DRAW_DEBUG(a)
|
||||
|
||||
#define _s3WaitVRetrace(s3) { \
|
||||
VOL8 *_status = &s3->crt_vga_status_1; \
|
||||
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; \
|
||||
_loop_count = 0; \
|
||||
while ((*_status & VGA_STATUS_1_VSY) == 0) S3_RETRACE_LOOP_CHECK; \
|
||||
}
|
||||
/*
|
||||
* Wait for the begining of the retrace interval
|
||||
*/
|
||||
#define _s3WaitVRetraceEnd(s3) { \
|
||||
VOL8 *_status = &s3->crt_vga_status_1; \
|
||||
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; \
|
||||
_loop_count = 0; \
|
||||
while ((*_status & VGA_STATUS_1_VSY) != 0) S3_RETRACE_LOOP_CHECK; \
|
||||
}
|
||||
|
||||
#define S3_CURSOR_WIDTH 64
|
||||
#define S3_CURSOR_HEIGHT 64
|
||||
#define S3_CURSOR_SIZE ((S3_CURSOR_WIDTH * S3_CURSOR_HEIGHT + 7) / 8)
|
||||
|
||||
#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_ */
|
41
hw/kdrive/savage/s3.nick
Normal file
41
hw/kdrive/savage/s3.nick
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* $XFree86: $ */
|
||||
|
||||
global f_ref = 14318000;
|
||||
|
||||
function s3_clock (m, n, r)
|
||||
{
|
||||
return f_ref * (m + 2) / ((n + 2) * (2 ^ r));
|
||||
}
|
||||
|
||||
function s3_near (f1, f2)
|
||||
{
|
||||
return abs (f1 - f2) < f1 / 10;
|
||||
}
|
||||
|
||||
function s3_clocks (f)
|
||||
{
|
||||
auto m, n, r, ft;
|
||||
auto dist, min_dist;
|
||||
auto min_m, min_n, min_r;
|
||||
|
||||
min_dist = f / 5;
|
||||
for (r = 0; r <= 3; r++)
|
||||
for (n = 0; n <= 31; n++)
|
||||
for (m = 0; m <= 127; m++)
|
||||
{
|
||||
ft = s3_clock (m, n, r);
|
||||
if (s3_near (ft, f))
|
||||
printf ("m %d n %d r %d = %d\n",
|
||||
m, n, r, ft);
|
||||
dist = abs (f - ft);
|
||||
if (dist < min_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
min_m = m;
|
||||
min_n = n;
|
||||
min_r = r;
|
||||
}
|
||||
}
|
||||
printf ("m %d n %d r %d f %d dist %d\n",
|
||||
min_m, min_n, min_r, s3_clock(min_m, min_n, min_r), min_dist);
|
||||
}
|
86
hw/kdrive/savage/s3clock.c
Normal file
86
hw/kdrive/savage/s3clock.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
|
||||
/* all in kHz */
|
||||
#define MIN_VCO 135000.0
|
||||
#define MAX_VCO 270000.0
|
||||
|
||||
void
|
||||
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 err, abserr, besterr;
|
||||
|
||||
/*
|
||||
* Compute correct R value to keep VCO in range
|
||||
*/
|
||||
for (R = 0; R <= maxR; R++)
|
||||
{
|
||||
f_vco = target * (1 << R);
|
||||
if (MIN_VCO <= f_vco && f_vco < MAX_VCO)
|
||||
break;
|
||||
}
|
||||
|
||||
/* M = f_out / f_ref * ((N + 2) * (1 << R)); */
|
||||
besterr = target;
|
||||
for (N = 0; N <= maxN; N++)
|
||||
{
|
||||
M = (target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) / S3_CLOCK_REF - 2;
|
||||
if (0 <= M && M <= maxM)
|
||||
{
|
||||
f_out = S3_CLOCK(M,N,R);
|
||||
err = target - f_out;
|
||||
if (err < 0)
|
||||
err = -err;
|
||||
if (err < besterr)
|
||||
{
|
||||
besterr = err;
|
||||
bestM = M;
|
||||
bestN = N;
|
||||
}
|
||||
}
|
||||
}
|
||||
*Mp = bestM;
|
||||
*Np = bestN;
|
||||
*Rp = R;
|
||||
}
|
67
hw/kdrive/savage/s3cmap.c
Normal file
67
hw/kdrive/savage/s3cmap.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
while (ndef--)
|
||||
{
|
||||
*dac_rd_ad = pdefs->pixel;
|
||||
pdefs->red = *dac_data << 8;
|
||||
pdefs->green = *dac_data << 8;
|
||||
pdefs->blue = *dac_data << 8;
|
||||
pdefs++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
_s3WaitVRetrace (s3);
|
||||
while (ndef--)
|
||||
{
|
||||
*dac_wt_ad = pdefs->pixel;
|
||||
*dac_data = pdefs->red >> 8;
|
||||
*dac_data = pdefs->green >> 8;
|
||||
*dac_data = pdefs->blue >> 8;
|
||||
pdefs++;
|
||||
}
|
||||
}
|
||||
|
418
hw/kdrive/savage/s3curs.c
Normal file
418
hw/kdrive/savage/s3curs.c
Normal file
|
@ -0,0 +1,418 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
#include "cursorstr.h"
|
||||
|
||||
#define SetupCursor(s) KdScreenPriv(s); \
|
||||
s3CardInfo(pScreenPriv); \
|
||||
s3ScreenInfo(pScreenPriv); \
|
||||
S3Ptr s3 = s3c->s3; \
|
||||
S3Vga *s3vga = &s3c->s3vga; \
|
||||
S3Cursor *pCurPriv = &s3s->cursor
|
||||
|
||||
static void
|
||||
_s3MoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CARD8 xlow, xhigh, ylow, yhigh;
|
||||
CARD8 xoff, yoff;
|
||||
|
||||
DRAW_DEBUG ((DEBUG_CURSOR, "s3MoveCursor %d %d", x, y));
|
||||
|
||||
x -= pCurPriv->xhot;
|
||||
xoff = 0;
|
||||
if (x < 0)
|
||||
{
|
||||
xoff = -x;
|
||||
x = 0;
|
||||
}
|
||||
y -= pCurPriv->yhot;
|
||||
yoff = 0;
|
||||
if (y < 0)
|
||||
{
|
||||
yoff = -y;
|
||||
y = 0;
|
||||
}
|
||||
xlow = (CARD8) x;
|
||||
xhigh = (CARD8) (x >> 8);
|
||||
ylow = (CARD8) y;
|
||||
yhigh = (CARD8) (y >> 8);
|
||||
|
||||
|
||||
/* This is the recommended order to move the cursor */
|
||||
|
||||
s3SetImm (s3vga, s3_cursor_xhigh, xhigh);
|
||||
s3SetImm (s3vga, s3_cursor_xlow, xlow);
|
||||
s3SetImm (s3vga, s3_cursor_ylow, ylow);
|
||||
s3SetImm (s3vga, s3_cursor_xoff, xoff);
|
||||
s3SetImm (s3vga, s3_cursor_yoff, yoff);
|
||||
s3SetImm (s3vga, s3_cursor_yhigh, yhigh);
|
||||
|
||||
DRAW_DEBUG ((DEBUG_CURSOR, "s3MoveCursor done"));
|
||||
}
|
||||
|
||||
static void
|
||||
s3MoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pCurPriv->has_cursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
_s3MoveCursor (pScreen, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
switch (pScreenPriv->screen->bitsPerPixel) {
|
||||
case 4:
|
||||
pCurPriv->source |= pCurPriv->source << 4;
|
||||
pCurPriv->mask |= pCurPriv->mask << 4;
|
||||
case 8:
|
||||
pCurPriv->source |= pCurPriv->source << 8;
|
||||
pCurPriv->mask |= pCurPriv->mask << 8;
|
||||
case 16:
|
||||
pCurPriv->source |= pCurPriv->source << 16;
|
||||
pCurPriv->mask |= pCurPriv->mask << 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_s3SetCursorColors (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
/* set foreground */
|
||||
/* Reset cursor color stack pointers */
|
||||
(void) s3GetImm (s3vga, s3_cursor_enable);
|
||||
s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source);
|
||||
s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source >> 8);
|
||||
s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source >> 16);
|
||||
|
||||
/* set background */
|
||||
/* Reset cursor color stack pointers */
|
||||
(void) s3GetImm (s3vga, s3_cursor_enable);
|
||||
s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask);
|
||||
s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask >> 8);
|
||||
s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask >> 16);
|
||||
}
|
||||
|
||||
void
|
||||
s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
xColorItem sourceColor, maskColor;
|
||||
|
||||
if (!pCurPriv->has_cursor || !pCursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pdef)
|
||||
{
|
||||
while (ndef)
|
||||
{
|
||||
if (pdef->pixel == pCurPriv->source ||
|
||||
pdef->pixel == pCurPriv->mask)
|
||||
break;
|
||||
ndef--;
|
||||
}
|
||||
if (!ndef)
|
||||
return;
|
||||
}
|
||||
s3AllocCursorColors (pScreen);
|
||||
_s3SetCursorColors (pScreen);
|
||||
}
|
||||
|
||||
static void
|
||||
s3LoadCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
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;
|
||||
int i, j;
|
||||
int cursor_address;
|
||||
int wsrc;
|
||||
unsigned char ramdac_control_;
|
||||
|
||||
/*
|
||||
* Allocate new colors
|
||||
*/
|
||||
s3AllocCursorColors (pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
pCurPriv->xhot = pCursor->bits->xhot;
|
||||
pCurPriv->yhot = pCursor->bits->yhot;
|
||||
|
||||
/*
|
||||
* Stick new image into cursor memory
|
||||
*/
|
||||
ram = (unsigned short *) s3s->cursor_base;
|
||||
mskLine = (unsigned short *) bits->mask;
|
||||
srcLine = (unsigned short *) bits->source;
|
||||
|
||||
h = bits->height;
|
||||
if (h > S3_CURSOR_HEIGHT)
|
||||
h = S3_CURSOR_HEIGHT;
|
||||
|
||||
wsrc = BitmapBytePad(bits->width) / 2; /* words 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++) {
|
||||
|
||||
unsigned short m, s;
|
||||
|
||||
if (i < h && j < wsrc)
|
||||
{
|
||||
m = *msk++;
|
||||
s = *src++;
|
||||
xor = m & s;
|
||||
and = ~m;
|
||||
}
|
||||
else
|
||||
{
|
||||
and = 0xffff;
|
||||
xor = 0x0000;
|
||||
}
|
||||
|
||||
S3InvertBits16(and);
|
||||
*ram++ = and;
|
||||
S3InvertBits16(xor);
|
||||
*ram++ = xor;
|
||||
}
|
||||
}
|
||||
|
||||
_s3WaitIdle (s3);
|
||||
|
||||
/* Set new color */
|
||||
_s3SetCursorColors (pScreen);
|
||||
|
||||
/* Enable the cursor */
|
||||
s3SetImm (s3vga, s3_cursor_enable, 1);
|
||||
|
||||
/* Wait for VRetrace to make sure the position is read */
|
||||
_s3WaitVRetrace (s3);
|
||||
|
||||
/* Move to new position */
|
||||
_s3MoveCursor (pScreen, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
s3UnloadCursor (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
/* Disable cursor */
|
||||
s3SetImm (s3vga, s3_cursor_enable, 0);
|
||||
}
|
||||
|
||||
static Bool
|
||||
s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return TRUE;
|
||||
|
||||
/* miRecolorCursor does this */
|
||||
if (pCurPriv->pCursor == pCursor)
|
||||
{
|
||||
if (pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
s3UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
s3SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCursor)
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
else
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
|
||||
miPointerSpriteFuncRec s3PointerSpriteFuncs = {
|
||||
s3RealizeCursor,
|
||||
s3UnrealizeCursor,
|
||||
s3SetCursor,
|
||||
s3MoveCursor,
|
||||
};
|
||||
|
||||
static void
|
||||
s3QueryBestSize (int class,
|
||||
unsigned short *pwidth, unsigned short *pheight,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case CursorShape:
|
||||
if (*pwidth > pCurPriv->width)
|
||||
*pwidth = pCurPriv->width;
|
||||
if (*pheight > pCurPriv->height)
|
||||
*pheight = pCurPriv->height;
|
||||
if (*pwidth > pScreen->width)
|
||||
*pwidth = pScreen->width;
|
||||
if (*pheight > pScreen->height)
|
||||
*pheight = pScreen->height;
|
||||
break;
|
||||
default:
|
||||
fbQueryBestSize (class, pwidth, pheight, pScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
s3CursorInit (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!s3s->cursor_base)
|
||||
{
|
||||
DRAW_DEBUG ((DEBUG_CURSOR,"Not enough screen memory for cursor %d", s3d->memory));
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pCurPriv->width = S3_CURSOR_WIDTH;
|
||||
pCurPriv->height= S3_CURSOR_HEIGHT;
|
||||
pScreen->QueryBestSize = s3QueryBestSize;
|
||||
miPointerInitialize (pScreen,
|
||||
&s3PointerSpriteFuncs,
|
||||
&kdPointerScreenFuncs,
|
||||
FALSE);
|
||||
pCurPriv->has_cursor = TRUE;
|
||||
pCurPriv->pCursor = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorEnable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
DRAW_DEBUG ((DEBUG_INIT, "s3CursorEnable"));
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
}
|
||||
else
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorDisable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorFini (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
pCurPriv->pCursor = NULL;
|
||||
}
|
2334
hw/kdrive/savage/s3draw.c
Normal file
2334
hw/kdrive/savage/s3draw.c
Normal file
File diff suppressed because it is too large
Load Diff
372
hw/kdrive/savage/s3draw.h
Normal file
372
hw/kdrive/savage/s3draw.h
Normal file
|
@ -0,0 +1,372 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _S3DRAW_H_
|
||||
#define _S3DRAW_H_
|
||||
|
||||
extern int s3GCPrivateIndex;
|
||||
extern int s3WindowPrivateIndex;
|
||||
|
||||
typedef struct _s3Pattern {
|
||||
S3PatternCache *cache;
|
||||
int id;
|
||||
PixmapPtr pPixmap;
|
||||
int fillStyle;
|
||||
int xrot, yrot;
|
||||
unsigned int fore, back;
|
||||
} s3PatternRec, *s3PatternPtr;
|
||||
|
||||
typedef struct _s3PrivGC {
|
||||
int type; /* type of drawable validated against */
|
||||
s3PatternPtr pPattern; /* pattern */
|
||||
} s3PrivGCRec, *s3PrivGCPtr;
|
||||
|
||||
#define s3GetGCPrivate(g) ((s3PrivGCPtr) \
|
||||
(g)->devPrivates[s3GCPrivateIndex].ptr)
|
||||
|
||||
#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g)
|
||||
|
||||
#define s3GetWindowPrivate(w) ((s3PatternPtr) \
|
||||
(w)->devPrivates[s3WindowPrivateIndex].ptr)
|
||||
|
||||
#define s3SetWindowPrivate(w,p) (\
|
||||
(w)->devPrivates[s3WindowPrivateIndex].ptr = (pointer) p)
|
||||
|
||||
|
||||
void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
|
||||
|
||||
#define SetupS3(s) KdScreenPriv(s); \
|
||||
s3CardInfo(pScreenPriv); \
|
||||
S3Ptr s3 = s3c->s3
|
||||
|
||||
#define WIDEN(x) ((unsigned long) (x))
|
||||
#define MERGE(a,b) ((WIDEN(a) << 16) | WIDEN(b))
|
||||
|
||||
#define _s3SetFg(s3,_fg) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " fg <- 0x%x", _fg));\
|
||||
s3->fg = (_fg); \
|
||||
}
|
||||
|
||||
#define _s3SetBg(s3,_bg) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " bg <- 0x%x", _bg));\
|
||||
s3->bg = (_bg); \
|
||||
}
|
||||
|
||||
#define _s3SetWriteMask(s3,_mask) {\
|
||||
DRAW_DEBUG((DEBUG_REGISTERS," write_mask <- 0x%x", _mask)); \
|
||||
s3->write_mask = (_mask); \
|
||||
}
|
||||
|
||||
#define _s3SetReadMask(s3,_mask) {\
|
||||
DRAW_DEBUG((DEBUG_REGISTERS," read_mask <- 0x%x", _mask)); \
|
||||
s3->read_mask = (_mask); \
|
||||
}
|
||||
|
||||
#define _s3SetPixelControl(s3,_ctl) { \
|
||||
DRAW_DEBUG((DEBUG_REGISTERS, " pix_cntl <- 0x%x", PIX_CNTL | (_ctl))); \
|
||||
s3->pix_cntl = PIX_CNTL | (_ctl); \
|
||||
}
|
||||
|
||||
#define _s3SetFgMix(s3,_mix) { \
|
||||
DRAW_DEBUG((DEBUG_REGISTERS, " fg_mix <- 0x%x", _mix)); \
|
||||
s3->enh_fg_mix = (_mix); \
|
||||
}
|
||||
|
||||
#define _s3SetBgMix(s3,_mix) { \
|
||||
DRAW_DEBUG((DEBUG_REGISTERS, " bg_mix <- 0x%x", _mix)); \
|
||||
s3->enh_bg_mix = (_mix); \
|
||||
}
|
||||
|
||||
#define _s3SetMix(s3,fg_mix,bg_mix) { \
|
||||
DRAW_DEBUG((DEBUG_REGISTERS, " alt_mix <- 0x%x", MERGE(fg_mix,bg_mix))); \
|
||||
s3->alt_mix = MERGE(fg_mix,bg_mix); \
|
||||
}
|
||||
|
||||
#define _s3SetCur(s3,_x,_y) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " alt_curxy <- 0x%x", MERGE(_x,_y))); \
|
||||
s3->alt_curxy = MERGE(_x,_y); \
|
||||
}
|
||||
|
||||
#define _s3SetStep(s3,_x,_y) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " alt_step <- 0x%x", MERGE(_x,_y))); \
|
||||
s3->alt_step = MERGE(_x,_y); \
|
||||
}
|
||||
|
||||
#define _s3SetErr(s3,_e) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " err_term <- 0x%x", _e)); \
|
||||
s3->err_term = (_e); \
|
||||
}
|
||||
|
||||
#define _s3SetPcnt(s3,_x,_y) { \
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " alt_pcnt <- 0x%x", MERGE(_x,_y))); \
|
||||
s3->alt_pcnt = MERGE(_x,_y); \
|
||||
}
|
||||
|
||||
#define _s3SetScissorsTl(s3,t,l) {\
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " scissors_tl <- 0x%x", MERGE(t,l))); \
|
||||
s3->scissors_tl = MERGE(t,l); \
|
||||
}
|
||||
|
||||
#define _s3SetScissorsBr(s3,b,r) {\
|
||||
DRAW_DEBUG ((DEBUG_REGISTERS, " scissors_br <- 0x%x", MERGE(b,r))); \
|
||||
s3->scissors_br = MERGE(b,r); \
|
||||
}
|
||||
|
||||
#define _s3CmdWait(s3)
|
||||
|
||||
#define _s3SetCmd(s3,_cmd) { \
|
||||
DRAW_DEBUG((DEBUG_REGISTERS, " cmd <- 0x%x", _cmd)); \
|
||||
_s3CmdWait(s3); \
|
||||
s3->cmd_gp_stat = (_cmd); \
|
||||
{ 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)); \
|
||||
_s3SetFg (s3, pix); \
|
||||
_s3SetWriteMask(s3,mask); \
|
||||
_s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL | MIX_SRC); \
|
||||
_s3SetPixelControl (s3, MIXSEL_FRGDMIX); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#define _s3SolidRect(s3,x,y,w,h) {\
|
||||
DRAW_DEBUG((DEBUG_RENDER,"solid rect %d,%d %dx%d",x,y,w,h)); \
|
||||
_s3CmdWait(s3); \
|
||||
_s3SetCur(s3, x, y); \
|
||||
_s3SetPcnt (s3, (w)-1, (h)-1); \
|
||||
_s3SetCmd (s3, CMD_RECT|INC_X|INC_Y|DRAW|WRTDATA); \
|
||||
DRAW_DEBUG((DEBUG_RENDER," done")); \
|
||||
}
|
||||
|
||||
#define _s3SolidLine(s3,maj,min,len,cmd) { \
|
||||
DRAW_DEBUG ((DEBUG_RENDER, "solid line 0x%x 0x%x 0x%x", maj, min, cmd)); \
|
||||
_s3CmdWait(s3); \
|
||||
_s3SetPcnt(s3, (len), 0); \
|
||||
_s3SetStep(s3, 2*((min) - (maj)), 2*(min)); \
|
||||
_s3SetErr(s3, 2*(min) - (maj)); \
|
||||
_s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \
|
||||
}
|
||||
|
||||
#define _s3SetTile(s3,alu,mask) { \
|
||||
DRAW_DEBUG ((DEBUG_SET,"set tile %d 0x%x", alu, mask)); \
|
||||
_s3SetWriteMask(s3, mask); \
|
||||
_s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT|s3alu[alu]); \
|
||||
_s3SetPixelControl (s3, MIXSEL_FRGDMIX); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
/*
|
||||
* For some reason, MIX_DST doesn't work in this mode; use MIX_OR with
|
||||
* an explicit 0 pixel value
|
||||
*/
|
||||
#define _s3SetStipple(s3,alu,mask,_fg) {\
|
||||
DRAW_DEBUG ((DEBUG_SET,"set stipple 0x%x %d 0x%x", _fg, alu, mask)); \
|
||||
_s3SetFg (s3, _fg); \
|
||||
_s3SetBg (s3, 0); \
|
||||
_s3SetWriteMask(s3,mask); \
|
||||
_s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL|MIX_OR); \
|
||||
_s3SetPixelControl (s3, MIXSEL_EXPBLT); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#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)); \
|
||||
_s3SetFg (s3, _fg); \
|
||||
_s3SetBg (s3, _bg); \
|
||||
_s3SetWriteMask(s3,mask); \
|
||||
_s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL|s3alu[alu]); \
|
||||
_s3SetPixelControl (s3, MIXSEL_EXPBLT); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
_s3SetCur (s3, px, py); \
|
||||
_s3SetStep (s3, x, y); \
|
||||
_s3SetPcnt (s3, (w)-1, (h)-1); \
|
||||
_s3SetCmd (s3, CMD_PATBLT|INC_X|INC_Y|DRAW|PLANAR|WRTDATA); \
|
||||
DRAW_DEBUG((DEBUG_RENDER," done")); \
|
||||
}
|
||||
|
||||
#define _s3SetBlt(s3,alu,mask) { \
|
||||
DRAW_DEBUG ((DEBUG_SET,"set blt %d 0x%x", alu, mask)); \
|
||||
_s3SetPixelControl (s3, MIXSEL_FRGDMIX); \
|
||||
_s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT | s3alu[alu]); \
|
||||
_s3SetWriteMask(s3, mask); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
_s3SetCur(s3,_sx,_sy); \
|
||||
_s3SetStep(s3,_dx,_dy); \
|
||||
_s3SetPcnt(s3,(_w)-1,(_h)-1); \
|
||||
_s3SetCmd (s3, CMD_BITBLT | (_dir) | DRAW | WRTDATA); \
|
||||
DRAW_DEBUG((DEBUG_RENDER," done")); \
|
||||
}
|
||||
|
||||
#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)); \
|
||||
_s3SetFg(s3,_fg); \
|
||||
_s3SetBg(s3,_bg); \
|
||||
_s3SetWriteMask(s3,mask); \
|
||||
_s3SetMix(s3,FSS_FRGDCOL|s3alu[alu], BSS_BKGDCOL|s3alu[alu]); \
|
||||
_s3SetPixelControl(s3,MIXSEL_EXPPC); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#define _s3SetTransparentPlaneBlt(s3,alu,mask,_fg) {\
|
||||
DRAW_DEBUG ((DEBUG_SET,"set transparent plane blt 0x%x %d 0x%x", \
|
||||
_fg, alu, mask)); \
|
||||
_s3SetFg(s3,_fg); \
|
||||
_s3SetWriteMask(s3,mask); \
|
||||
_s3SetMix(s3,FSS_FRGDCOL|s3alu[alu], BSS_BKGDCOL|MIX_DST); \
|
||||
_s3SetPixelControl(s3,MIXSEL_EXPPC); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
/* 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); \
|
||||
_s3SetCur(s3, x, y); \
|
||||
_s3SetPcnt (s3, (w)-1, (h)-1); \
|
||||
_s3SetCmd (s3, \
|
||||
CMD_RECT| /* Fill rectangle */ \
|
||||
BYTSEQ| /* LSB byte order */ \
|
||||
_32BIT| /* 32 bit data on 32 bit boundaries */ \
|
||||
PCDATA| /* Data from CPU */ \
|
||||
INC_X|INC_Y| /* X and Y both increasing */ \
|
||||
DRAW| /* Draw, not move */ \
|
||||
PLANAR| /* multi pixel */ \
|
||||
WRTDATA); \
|
||||
DRAW_DEBUG((DEBUG_RENDER," done")); \
|
||||
}
|
||||
|
||||
#define _s3SetClip(s3,pbox) {\
|
||||
DRAW_DEBUG ((DEBUG_SET, "set clip %dx%d -> %dx%d ", \
|
||||
pbox->x1, pbox->y1, pbox->x2, pbox->y2)); \
|
||||
_s3WaitEmpty(s3); \
|
||||
_s3SetScissorsTl(s3,(pbox)->x1, (pbox)->y1); \
|
||||
_s3SetScissorsBr(s3,(pbox)->x2 - 1, (pbox)->y2 - 1); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
#define _s3ResetClip(s3,pScreen) { \
|
||||
DRAW_DEBUG ((DEBUG_SET, "reset clip")); \
|
||||
_s3WaitEmpty(s3); \
|
||||
_s3SetScissorsTl(s3,0,0); \
|
||||
_s3SetScissorsBr(s3,pScreen->width - 1, pScreen->height - 1); \
|
||||
DRAW_DEBUG((DEBUG_SET," done")); \
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty);
|
||||
|
||||
RegionPtr
|
||||
s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
||||
int srcx, int srcy, int width, int height,
|
||||
int dstx, int dsty, unsigned long bitPlane);
|
||||
|
||||
void
|
||||
s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
|
||||
unsigned long pixel, int alu, unsigned long planemask);
|
||||
|
||||
void
|
||||
s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
|
||||
int alu, unsigned long planemask, s3PatternPtr pPattern);
|
||||
|
||||
void
|
||||
s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nrectFill, xRectangle *prectInit);
|
||||
|
||||
void
|
||||
s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||
DDXPointPtr ppt, int *pwidth, int fSorted);
|
||||
|
||||
void
|
||||
s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
|
||||
|
||||
void
|
||||
s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
|
||||
int mode, int count, DDXPointPtr ptsIn);
|
||||
|
||||
void
|
||||
s3PolyGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int xInit, int y,
|
||||
unsigned int nglyphInit,
|
||||
CharInfoPtr *ppciInit,
|
||||
pointer pglyphBase);
|
||||
|
||||
void
|
||||
s3ImageGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase);
|
||||
|
||||
void
|
||||
s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int xInit, int y,
|
||||
unsigned int nglyphInit,
|
||||
CharInfoPtr *ppciInit,
|
||||
pointer pglyphBase);
|
||||
|
||||
void
|
||||
s3PolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y,
|
||||
unsigned int nglyph, CharInfoPtr *ppci,
|
||||
pointer pglyphBase);
|
||||
|
||||
void
|
||||
s3Polylines (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int nptInit, DDXPointPtr pptInit);
|
||||
|
||||
void
|
||||
s3PolySegment (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nsegInit, xSegment *pSegInit);
|
||||
|
||||
void
|
||||
s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
|
||||
unsigned long pixel, int alu, unsigned long planemask);
|
||||
|
||||
void s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable);
|
||||
|
||||
void
|
||||
s3CheckGCFill (GCPtr pGC);
|
||||
|
||||
void
|
||||
s3MoveGCFill (GCPtr pGC);
|
||||
|
||||
#endif
|
388
hw/kdrive/savage/s3gc.c
Normal file
388
hw/kdrive/savage/s3gc.c
Normal file
|
@ -0,0 +1,388 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
#include "s3draw.h"
|
||||
|
||||
#include "Xmd.h"
|
||||
#include "gcstruct.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "regionstr.h"
|
||||
#include "mistruct.h"
|
||||
#include "fontstruct.h"
|
||||
#include "dixfontstr.h"
|
||||
#include "migc.h"
|
||||
|
||||
/*
|
||||
* Common op groups. Common assumptions:
|
||||
*
|
||||
* lineWidth 0
|
||||
* lineStyle LineSolid
|
||||
* fillStyle FillSolid
|
||||
* rop GXcopy
|
||||
* font <= 32 pixels wide
|
||||
*/
|
||||
|
||||
/* TE font, >= 4 pixels wide, one clip rectangle */
|
||||
static GCOps s3TEOps1Rect = {
|
||||
s3FillSpans,
|
||||
fbSetSpans,
|
||||
fbPutImage,
|
||||
s3CopyArea,
|
||||
s3CopyPlane,
|
||||
fbPolyPoint,
|
||||
s3Polylines,
|
||||
s3PolySegment,
|
||||
miPolyRectangle,
|
||||
fbPolyArc,
|
||||
s3FillPoly1Rect,
|
||||
s3PolyFillRect,
|
||||
s3PolyFillArcSolid,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
s3ImageTEGlyphBlt,
|
||||
s3PolyTEGlyphBlt,
|
||||
fbPushPixels,
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
extern GCOps fbGCOps;
|
||||
|
||||
/* Non TE font, one clip rectangle */
|
||||
static GCOps s3NonTEOps1Rect = {
|
||||
s3FillSpans,
|
||||
fbSetSpans,
|
||||
fbPutImage,
|
||||
s3CopyArea,
|
||||
s3CopyPlane,
|
||||
fbPolyPoint,
|
||||
s3Polylines,
|
||||
s3PolySegment,
|
||||
miPolyRectangle,
|
||||
fbPolyArc,
|
||||
s3FillPoly1Rect,
|
||||
s3PolyFillRect,
|
||||
s3PolyFillArcSolid,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
s3ImageGlyphBlt,
|
||||
s3PolyGlyphBlt,
|
||||
fbPushPixels
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/* TE font, != 1 clip rect (including 0) */
|
||||
static GCOps s3TEOps = {
|
||||
s3FillSpans,
|
||||
fbSetSpans,
|
||||
fbPutImage,
|
||||
s3CopyArea,
|
||||
s3CopyPlane,
|
||||
fbPolyPoint,
|
||||
s3Polylines,
|
||||
s3PolySegment,
|
||||
miPolyRectangle,
|
||||
fbPolyArc,
|
||||
miFillPolygon,
|
||||
s3PolyFillRect,
|
||||
s3PolyFillArcSolid,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
s3ImageTEGlyphBlt,
|
||||
s3PolyTEGlyphBlt,
|
||||
fbPushPixels
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Non TE font, != 1 clip rect (including 0) */
|
||||
static GCOps s3NonTEOps = {
|
||||
s3FillSpans,
|
||||
fbSetSpans,
|
||||
fbPutImage,
|
||||
s3CopyArea,
|
||||
s3CopyPlane,
|
||||
fbPolyPoint,
|
||||
s3Polylines,
|
||||
s3PolySegment,
|
||||
miPolyRectangle,
|
||||
fbPolyArc,
|
||||
miFillPolygon,
|
||||
s3PolyFillRect,
|
||||
s3PolyFillArcSolid,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
s3ImageGlyphBlt,
|
||||
s3PolyGlyphBlt,
|
||||
fbPushPixels
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
static GCOps *
|
||||
s3MatchCommon (DrawablePtr pDraw, GCPtr pGC, FbGCPrivPtr fbPriv)
|
||||
{
|
||||
KdScreenPriv (pDraw->pScreen);
|
||||
|
||||
if (!REGION_NOTEMPTY(pDraw->pScreen,fbGetCompositeClip(pGC)))
|
||||
{
|
||||
DRAW_DEBUG ((DEBUG_CLIP, "Empty composite clip, clipping all ops"));
|
||||
return &kdNoopOps;
|
||||
}
|
||||
|
||||
if (pDraw->type != DRAWABLE_WINDOW)
|
||||
return (GCOps *) &fbGCOps;
|
||||
|
||||
if (pGC->lineWidth != 0)
|
||||
return 0;
|
||||
if (pGC->lineStyle != LineSolid)
|
||||
return 0;
|
||||
if (pGC->fillStyle != FillSolid)
|
||||
return 0;
|
||||
if (fbPriv->and != 0)
|
||||
return 0;
|
||||
if (pGC->font)
|
||||
{
|
||||
if (TERMINALFONT(pGC->font))
|
||||
{
|
||||
if (fbPriv->oneRect)
|
||||
return &s3TEOps1Rect;
|
||||
else
|
||||
return &s3TEOps;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fbPriv->oneRect)
|
||||
return &s3NonTEOps1Rect;
|
||||
else
|
||||
return &s3NonTEOps;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
|
||||
{
|
||||
int new_type; /* drawable type has changed */
|
||||
int new_onerect; /* onerect value has changed */
|
||||
int new_origin;
|
||||
|
||||
/* flags for changing the proc vector */
|
||||
FbGCPrivPtr fbPriv;
|
||||
s3PrivGCPtr s3Priv;
|
||||
int oneRect;
|
||||
|
||||
fbPriv = fbGetGCPrivate(pGC);
|
||||
s3Priv = s3GetGCPrivate(pGC);
|
||||
|
||||
new_type = FALSE;
|
||||
new_onerect = FALSE;
|
||||
new_origin = FALSE;
|
||||
|
||||
/*
|
||||
* If the type of drawable has changed, fix up accelerated functions
|
||||
*/
|
||||
if (s3Priv->type != pDrawable->type)
|
||||
{
|
||||
new_type = TRUE;
|
||||
s3Priv->type = pDrawable->type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check tile/stipple origin
|
||||
*/
|
||||
if (pGC->lastWinOrg.x != pDrawable->x || pGC->lastWinOrg.y != pDrawable->y)
|
||||
new_origin = TRUE;
|
||||
|
||||
/*
|
||||
* Call down to FB to set clip list and rrop values
|
||||
*/
|
||||
oneRect = fbPriv->oneRect;
|
||||
|
||||
fbValidateGC (pGC, changes, pDrawable);
|
||||
|
||||
if (oneRect != fbPriv->oneRect)
|
||||
new_onerect = TRUE;
|
||||
|
||||
/*
|
||||
* Check accelerated pattern if necessary
|
||||
*/
|
||||
if (changes & (GCFillStyle|GCStipple|GCTile))
|
||||
s3CheckGCFill (pGC);
|
||||
else if (s3Priv->pPattern &&
|
||||
(new_origin || changes & (GCTileStipXOrigin|GCTileStipYOrigin)))
|
||||
s3MoveGCFill (pGC);
|
||||
|
||||
/*
|
||||
* Try to match common vector
|
||||
*/
|
||||
|
||||
if (new_type || new_onerect ||
|
||||
(changes & (GCLineWidth|GCLineStyle|GCFillStyle|
|
||||
GCFont|GCForeground|GCFunction|GCPlaneMask)))
|
||||
{
|
||||
GCOps *newops;
|
||||
|
||||
if (newops = s3MatchCommon (pDrawable, pGC, fbPriv))
|
||||
{
|
||||
if (pGC->ops->devPrivate.val)
|
||||
miDestroyGCOps (pGC->ops);
|
||||
pGC->ops = newops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No common vector matched, create private ops vector and
|
||||
* fill it in
|
||||
*/
|
||||
if (!pGC->ops->devPrivate.val)
|
||||
{
|
||||
/*
|
||||
* Switch from noop vector by first switching to fb
|
||||
* vector and fixing it up
|
||||
*/
|
||||
if (pGC->ops == &kdNoopOps)
|
||||
{
|
||||
pGC->ops = (GCOps *) &fbGCOps;
|
||||
new_type = TRUE;
|
||||
}
|
||||
pGC->ops = miCreateGCOps (pGC->ops);
|
||||
pGC->ops->devPrivate.val = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fills
|
||||
*/
|
||||
if (new_type || (changes & (GCFillStyle|GCTile|GCStipple)))
|
||||
{
|
||||
pGC->ops->FillSpans = fbFillSpans;
|
||||
pGC->ops->PolyFillRect = fbPolyFillRect;
|
||||
if (s3Priv->type == DRAWABLE_WINDOW &&
|
||||
(pGC->fillStyle != FillTiled || s3Priv->pPattern))
|
||||
{
|
||||
pGC->ops->FillSpans = s3FillSpans;
|
||||
pGC->ops->PolyFillRect = s3PolyFillRect;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Blt
|
||||
*/
|
||||
if (new_type)
|
||||
{
|
||||
pGC->ops->CopyArea = fbCopyArea;
|
||||
pGC->ops->CopyPlane = fbCopyPlane;
|
||||
if (s3Priv->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
pGC->ops->CopyArea = s3CopyArea;
|
||||
pGC->ops->CopyPlane = s3CopyPlane;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
if (new_type || (changes & (GCLineStyle|GCLineWidth|GCFillStyle)))
|
||||
{
|
||||
pGC->ops->Polylines = fbPolyLine;
|
||||
pGC->ops->PolySegment = fbPolySegment;
|
||||
if (pGC->lineStyle == LineSolid &&
|
||||
pGC->lineWidth == 0 &&
|
||||
pGC->fillStyle == FillSolid &&
|
||||
s3Priv->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
pGC->ops->Polylines = s3Polylines;
|
||||
pGC->ops->PolySegment = s3PolySegment;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Polygons
|
||||
*/
|
||||
if (new_type || new_onerect || (changes & (GCFillStyle)))
|
||||
{
|
||||
pGC->ops->FillPolygon = miFillPolygon;
|
||||
if (s3Priv->type == DRAWABLE_WINDOW &&
|
||||
fbPriv->oneRect &&
|
||||
pGC->fillStyle == FillSolid)
|
||||
{
|
||||
pGC->ops->FillPolygon = s3FillPoly1Rect;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Filled arcs
|
||||
*/
|
||||
if (new_type || (changes & GCFillStyle))
|
||||
{
|
||||
pGC->ops->PolyFillArc = fbPolyFillArc;
|
||||
if (s3Priv->type == DRAWABLE_WINDOW &&
|
||||
pGC->fillStyle == FillSolid)
|
||||
{
|
||||
pGC->ops->PolyFillArc = s3PolyFillArcSolid;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Text
|
||||
*/
|
||||
if (new_type || (changes & (GCFont|GCFillStyle)))
|
||||
{
|
||||
pGC->ops->PolyGlyphBlt = fbPolyGlyphBlt;
|
||||
pGC->ops->ImageGlyphBlt = fbImageGlyphBlt;
|
||||
if (s3Priv->type == DRAWABLE_WINDOW && pGC->font)
|
||||
{
|
||||
if (pGC->fillStyle == FillSolid)
|
||||
{
|
||||
if (TERMINALFONT(pGC->font))
|
||||
pGC->ops->PolyGlyphBlt = s3PolyTEGlyphBlt;
|
||||
else
|
||||
pGC->ops->PolyGlyphBlt = s3PolyGlyphBlt;
|
||||
}
|
||||
if (TERMINALFONT(pGC->font))
|
||||
pGC->ops->ImageGlyphBlt = s3ImageTEGlyphBlt;
|
||||
else
|
||||
pGC->ops->ImageGlyphBlt = s3ImageGlyphBlt;
|
||||
}
|
||||
}
|
||||
}
|
1144
hw/kdrive/savage/s3reg.c
Normal file
1144
hw/kdrive/savage/s3reg.c
Normal file
File diff suppressed because it is too large
Load Diff
195
hw/kdrive/savage/s3reg.h
Normal file
195
hw/kdrive/savage/s3reg.h
Normal file
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _S3REG_H_
|
||||
#define _S3REG_H_
|
||||
|
||||
#include "vga.h"
|
||||
|
||||
#define S3_SR 0
|
||||
#define S3_NSR 0x70
|
||||
#define S3_GR (S3_SR+S3_NSR)
|
||||
#define S3_NGR 0x09
|
||||
#define S3_AR (S3_GR+S3_NGR)
|
||||
#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)
|
||||
|
||||
extern VgaReg s3_h_total[];
|
||||
extern VgaReg s3_h_display_end[];
|
||||
extern VgaReg s3_h_blank_start[];
|
||||
extern VgaReg s3_h_blank_end[];
|
||||
extern VgaReg s3_display_skew[];
|
||||
extern VgaReg s3_h_sync_start[];
|
||||
extern VgaReg s3_h_sync_end[];
|
||||
extern VgaReg s3_h_skew[];
|
||||
extern VgaReg s3_v_total[];
|
||||
extern VgaReg s3_preset_row_scan[];
|
||||
extern VgaReg s3_max_scan_line[];
|
||||
extern VgaReg s3_start_address[];
|
||||
extern VgaReg s3_v_retrace_start[];
|
||||
extern VgaReg s3_v_retrace_end[];
|
||||
extern VgaReg s3_clear_v_retrace_int[];
|
||||
extern VgaReg s3_disable_v_retrace_int[];
|
||||
extern VgaReg s3_lock_crtc[];
|
||||
extern VgaReg s3_v_display_end[];
|
||||
extern VgaReg s3_screen_offset[];
|
||||
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_v_total_double[];
|
||||
extern VgaReg s3_word_mode[];
|
||||
extern VgaReg s3_byte_mode[];
|
||||
extern VgaReg s3_line_compare[];
|
||||
extern VgaReg s3_device_id[];
|
||||
extern VgaReg s3_revision[];
|
||||
extern VgaReg s3_enable_vga_16bit[];
|
||||
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_vert[];
|
||||
extern VgaReg s3_lock_horz[];
|
||||
extern VgaReg s3_io_disable[];
|
||||
extern VgaReg s3_mem_size[];
|
||||
extern VgaReg s3_register_lock_1 [];
|
||||
extern VgaReg s3_register_lock_2 [];
|
||||
extern VgaReg s3_refresh_control[];
|
||||
extern VgaReg s3_enable_256[];
|
||||
extern VgaReg s3_disable_pci_read_bursts[];
|
||||
extern VgaReg s3_h_start_fifo_fetch[];
|
||||
extern VgaReg s3_enable_2d_access[];
|
||||
extern VgaReg s3_interlace[];
|
||||
extern VgaReg s3_old_screen_off_8[];
|
||||
extern VgaReg s3_h_counter_double_mode[];
|
||||
extern VgaReg s3_cursor_enable[];
|
||||
extern VgaReg s3_cursor_right[];
|
||||
extern VgaReg s3_cursor_xhigh[];
|
||||
extern VgaReg s3_cursor_xlow[];
|
||||
extern VgaReg s3_cursor_yhigh[];
|
||||
extern VgaReg s3_cursor_ylow[];
|
||||
extern VgaReg s3_cursor_fg[];
|
||||
extern VgaReg s3_cursor_bg[];
|
||||
extern VgaReg s3_cursor_address[];
|
||||
extern VgaReg s3_cursor_xoff[];
|
||||
extern VgaReg s3_cursor_yoff[];
|
||||
extern VgaReg s3_ge_screen_width[];
|
||||
extern VgaReg s3_pixel_length[];
|
||||
extern VgaReg s3_big_endian_linear[];
|
||||
extern VgaReg s3_mmio_select[];
|
||||
extern VgaReg s3_mmio_window[];
|
||||
extern VgaReg s3_swap_nibbles[];
|
||||
extern VgaReg s3_cursor_ms_x11[];
|
||||
extern VgaReg s3_linear_window_size[];
|
||||
extern VgaReg s3_enable_linear[];
|
||||
extern VgaReg s3_h_blank_extend[];
|
||||
extern VgaReg s3_h_sync_extend[];
|
||||
extern VgaReg s3_sdclk_skew[];
|
||||
extern VgaReg s3_delay_blank[];
|
||||
extern VgaReg s3_delay_h_enable[];
|
||||
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_master_control_unit_timeout[];
|
||||
extern VgaReg s3_command_buffer_timeout[];
|
||||
extern VgaReg s3_lpb_timeout[];
|
||||
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_primary_stream_l1[];
|
||||
|
||||
extern VgaReg s3_dot_clock_8[];
|
||||
extern VgaReg s3_screen_off[];
|
||||
extern VgaReg s3_enable_write_plane[];
|
||||
extern VgaReg s3_extended_memory_access[];
|
||||
extern VgaReg s3_sequential_addressing_mode[];
|
||||
extern VgaReg s3_select_chain_4_mode[];
|
||||
|
||||
extern VgaReg s3_unlock_extended_sequencer[];
|
||||
extern VgaReg s3_linear_addressing_control[];
|
||||
extern VgaReg s3_disable_io_ports[];
|
||||
extern VgaReg s3_hsync_control[];
|
||||
extern VgaReg s3_vsync_control[];
|
||||
extern VgaReg s3_mclk_n[];
|
||||
extern VgaReg s3_mclk_r[];
|
||||
extern VgaReg s3_mclk_m[];
|
||||
extern VgaReg s3_dclk_n[];
|
||||
extern VgaReg s3_dclk_r[];
|
||||
extern VgaReg s3_dclk_m[];
|
||||
extern VgaReg s3_mclk_load[];
|
||||
extern VgaReg s3_dclk_load[];
|
||||
extern VgaReg s3_dclk_over_2[];
|
||||
extern VgaReg s3_clock_load_imm[];
|
||||
extern VgaReg s3_dclk_invert[];
|
||||
extern VgaReg s3_enable_clock_double[];
|
||||
extern VgaReg s3_dclk_double_15_16_invert[];
|
||||
extern VgaReg s3_enable_gamma_correction[];
|
||||
extern VgaReg s3_enable_8_bit_luts[];
|
||||
extern VgaReg s3_dclk_control[];
|
||||
extern VgaReg s3_vga_dclk_n[];
|
||||
extern VgaReg s3_vga_dclk_r[];
|
||||
extern VgaReg s3_vga_dclk_m1[];
|
||||
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_clock_select[];
|
||||
extern VgaReg s3_horz_sync_neg[];
|
||||
extern VgaReg s3_vert_sync_neg[];
|
||||
|
||||
#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))
|
||||
#define s3SetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v))
|
||||
|
||||
typedef struct _s3Vga {
|
||||
VgaCard card;
|
||||
VgaValue values[S3_NREG];
|
||||
VGA32 save_lock_crtc;
|
||||
VGA32 save_register_lock_1;
|
||||
VGA32 save_register_lock_2;
|
||||
VGA32 save_unlock_extended_sequencer;
|
||||
VGA32 save_lock_dac_writes;
|
||||
VGA32 save_lock_horz;
|
||||
VGA32 save_lock_vert;
|
||||
VGA32 save_dot_clock_8;
|
||||
} S3Vga;
|
||||
|
||||
void
|
||||
s3RegInit (S3Vga *s3vga, VGAVOL8 *mmio);
|
||||
|
||||
void
|
||||
s3Save (S3Vga *s3vga);
|
||||
|
||||
void
|
||||
s3Reset (S3Vga *s3vga);
|
||||
|
||||
#endif /* _S3REG_H_ */
|
141
hw/kdrive/savage/s3rtst.c
Normal file
141
hw/kdrive/savage/s3rtst.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "s3reg.h"
|
||||
|
||||
typedef struct {
|
||||
VgaReg *reg;
|
||||
char *name;
|
||||
} NamedVgaReg;
|
||||
|
||||
NamedVgaReg s3VRegs[] = {
|
||||
s3_h_total, "h_total",
|
||||
s3_h_display_end, "h_display_end",
|
||||
s3_h_blank_start, "h_blank_start",
|
||||
s3_h_blank_end, "h_blank_end",
|
||||
s3_display_skew, "display_skew",
|
||||
s3_h_sync_start, "h_sync_start",
|
||||
s3_h_sync_end, "h_sync_end",
|
||||
s3_h_skew, "h_skew",
|
||||
s3_v_total, "v_total",
|
||||
s3_preset_row_scan, "preset_row_scan",
|
||||
s3_max_scan_line, "max_scan_line",
|
||||
s3_start_address, "start_address",
|
||||
s3_v_retrace_start, "v_retrace_start",
|
||||
s3_v_retrace_end, "v_retrace_end",
|
||||
s3_clear_v_retrace_int, "clear_v_retrace_int",
|
||||
s3_disable_v_retrace_int, "disable_v_retrace_int",
|
||||
s3_lock_crtc, "lock_crtc",
|
||||
s3_v_display_end, "v_display_end",
|
||||
s3_screen_offset, "screen_offset",
|
||||
s3_count_by_4_mode, "count_by_4_mode",
|
||||
s3_doubleword_mode, "doubleword_mode",
|
||||
s3_v_blank_start, "v_blank_start",
|
||||
s3_v_blank_end, "v_blank_end",
|
||||
s3_v_total_double, "v_total_double",
|
||||
s3_word_mode, "word_mode",
|
||||
s3_byte_mode, "byte_mode",
|
||||
s3_line_compare, "line_compare",
|
||||
s3_device_id, "device_id",
|
||||
s3_revision, "revision",
|
||||
s3_lock_vert, "lock_vert",
|
||||
s3_lock_horz, "lock_horz",
|
||||
s3_io_disable, "io_disable",
|
||||
s3_mem_size, "mem_size",
|
||||
s3_register_lock_1 , "register_lock_1 ",
|
||||
s3_register_lock_2 , "register_lock_2 ",
|
||||
s3_refresh_control, "refresh_control",
|
||||
s3_enable_256, "enable_256",
|
||||
s3_enable_pci_read_bursts, "enable_pci_read_bursts",
|
||||
s3_h_start_fifo_fetch, "h_start_fifo_fetch",
|
||||
s3_interlace, "interlace",
|
||||
s3_old_screen_off_8, "old_screen_off_8",
|
||||
s3_h_counter_double_mode, "h_counter_double_mode",
|
||||
s3_hardware_cursor_enable, "hardware_cursor_enable",
|
||||
s3_hardware_cursor_right, "hardware_cursor_right",
|
||||
s3_hardware_cursor_x, "hardware_cursor_x",
|
||||
s3_hardware_cursor_y, "hardware_cursor_y",
|
||||
s3_hardware_cursor_fg, "hardware_cursor_fg",
|
||||
s3_cursor_address, "cursor_address",
|
||||
s3_cursor_start_x, "cursor_start_x",
|
||||
s3_cursor_start_y, "cursor_start_y",
|
||||
s3_ge_screen_width, "ge_screen_width",
|
||||
s3_pixel_length, "pixel_length",
|
||||
s3_big_endian_linear, "big_endian_linear",
|
||||
s3_mmio_select, "mmio_select",
|
||||
s3_mmio_window, "mmio_window",
|
||||
s3_swap_nibbles, "swap_nibbles",
|
||||
s3_hardware_cursor_ms_x11, "hardware_cursor_ms_x11",
|
||||
s3_h_blank_extend, "h_blank_extend",
|
||||
s3_h_sync_extend, "h_sync_extend",
|
||||
s3_enable_2d_3d, "enable_2d_3d",
|
||||
s3_pci_disconnect_enable, "pci_disconnect_enable",
|
||||
s3_pci_retry_enable, "pci_retry_enable",
|
||||
s3_color_mode, "color_mode",
|
||||
s3_screen_off, "screen_off",
|
||||
s3_unlock_extended_sequencer, "unlock_extended_sequencer",
|
||||
s3_disable_io_ports, "disable_io_ports",
|
||||
s3_hsync_control, "hsync_control",
|
||||
s3_vsync_control, "vsync_control",
|
||||
s3_mclk_n, "mclk_n",
|
||||
s3_mclk_r, "mclk_r",
|
||||
s3_mclk_m, "mclk_m",
|
||||
s3_dclk_n, "dclk_n",
|
||||
s3_dclk_r, "dclk_r",
|
||||
s3_dclk_m, "dclk_m",
|
||||
s3_mclk_load, "mclk_load",
|
||||
s3_dclk_load, "dclk_load",
|
||||
s3_dclk_over_2, "dclk_over_2",
|
||||
s3_clock_load_imm, "clock_load_imm",
|
||||
s3_dclk_invert, "dclk_invert",
|
||||
s3_enable_clock_double, "enable_clock_double",
|
||||
s3_dclk_double_15_16_invert, "dclk_double_15_16_invert",
|
||||
s3_enable_gamma_correction, "enable_gamma_correction",
|
||||
s3_enable_8_bit_luts, "enable_8_bit_luts",
|
||||
s3_dclk_control, "dclk_control",
|
||||
s3_vga_dclk_n, "vga_dclk_n",
|
||||
s3_vga_dclk_r, "vga_dclk_r",
|
||||
s3_vga_dclk_m1, "vga_dclk_m1",
|
||||
s3_vga_dclk_m2, "vga_dclk_m2",
|
||||
s3_vga_clk_select, "vga_clk_select",
|
||||
s3_clock_select, "clock_select",
|
||||
};
|
||||
|
||||
#define NUM_S3_VREGS (sizeof (s3VRegs)/ sizeof (s3VRegs[0]))
|
||||
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
iopl(3);
|
||||
s3SetImm(s3_register_lock_1, 0x48);
|
||||
s3SetImm(s3_register_lock_2, 0xa0);
|
||||
s3SetImm(s3_unlock_extended_sequencer, 0x06);
|
||||
for (i = 0; i < NUM_S3_VREGS; i++)
|
||||
printf ("%-20.20s %8x\n", s3VRegs[i].name, s3Get (s3VRegs[i].reg));
|
||||
s3Restore ();
|
||||
}
|
60
hw/kdrive/savage/s3stub.c
Normal file
60
hw/kdrive/savage/s3stub.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
CARD32 count;
|
||||
|
||||
count = 0;
|
||||
while (LinuxFindPci (0x5333, 0x8a22, count, &attr))
|
||||
{
|
||||
KdCardInfoAdd (&s3Funcs, &attr, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
||||
|
15
hw/kdrive/sis530/Imakefile
Normal file
15
hw/kdrive/sis530/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = sis.c sisclock.c siscmap.c siscurs.c sisdraw.c sisio.c sisstub.c
|
||||
|
||||
OBJS = sis.o sisclock.o siscmap.o siscurs.o sisdraw.o sisio.o sisstub.o
|
||||
|
||||
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(sis530,$(OBJS))
|
||||
DependTarget()
|
953
hw/kdrive/sis530/sis.c
Normal file
953
hw/kdrive/sis530/sis.c
Normal file
|
@ -0,0 +1,953 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "sis.h"
|
||||
|
||||
#define MAX_FB_SIZE (4096 * 1024)
|
||||
|
||||
#define MMIO_SIZE (64 * 1024)
|
||||
|
||||
#define SIS_TIMING_BAIL 2
|
||||
|
||||
SisTiming sisTimings[] = {
|
||||
/* FP BP BLANK */
|
||||
{ 640, 480, 85,
|
||||
56, 80, 192, /* horizontal 43.265 KHz */
|
||||
1, 25, 29, /* vertical 85.000 Hz */
|
||||
/* pixel 35.996 MHz */
|
||||
},
|
||||
|
||||
{ 640, 480, 75,
|
||||
16, 120, 200, /* horizontal 37.500 KHz */
|
||||
1, 16, 20, /* vertical 75.000 Hz */
|
||||
/* pixel 31.500 MHz */
|
||||
},
|
||||
|
||||
{ 640, 480, 60,
|
||||
16, 48, 160, /* horizontal 31.321 KHz */
|
||||
10, 33, 45, /* vertical 59.568 Hz */
|
||||
/* pixel 25.057 MHz */
|
||||
},
|
||||
|
||||
{ 800, 600, 85,
|
||||
32, 152, 248, /* horizontal 53.673 KHz */
|
||||
1, 27, 31, /* vertical 85.060 Hz */
|
||||
/* pixel 56.249 MHz */
|
||||
},
|
||||
{ 800, 600, 75,
|
||||
16, 160, 256, /* horizontal 46.891 KHz */
|
||||
1, 21, 25, /* vertical 75.025 Hz */
|
||||
/* pixel 49.516 MHz */
|
||||
},
|
||||
{ 800, 600, 72,
|
||||
56, 64, 240, /* horizontal 48.186 KHz */
|
||||
37, 23, 66, /* vertical 72.351 Hz */
|
||||
/* pixel 50.113 MHz */
|
||||
},
|
||||
|
||||
{ 1024, 768, 85,
|
||||
48, 208, 352, /* horizontal 68.676 KHz */
|
||||
1, 36, 40, /* vertical 84.996 Hz */
|
||||
/* pixel 94.499 MHz */
|
||||
},
|
||||
{ 1024, 768, 75,
|
||||
16, 176, 288, /* horizontal 60.022 KHz */
|
||||
1, 28, 32, /* vertical 75.028 Hz */
|
||||
/* pixel 78.749 MHz */
|
||||
},
|
||||
{ 1024, 768, 70,
|
||||
24, 144, 304, /* horizontal 56.604 KHz */
|
||||
3, 29, 38, /* vertical 70.227 Hz */
|
||||
/* pixel 75.170 MHz */
|
||||
},
|
||||
{ 1024, 768, 66,
|
||||
24, 144, 304, /* horizontal 53.234 KHz */
|
||||
3, 29, 38, /* vertical 66.047 Hz */
|
||||
/* pixel 70.695 MHz */
|
||||
},
|
||||
|
||||
{ 1152, 900, 85,
|
||||
48, 208, 384, /* horizontal 79.900 KHz */
|
||||
1, 32, 38, /* vertical 85.181 Hz */
|
||||
/* pixel 122.726 MHz */
|
||||
},
|
||||
{ 1152, 900, 75,
|
||||
32, 208, 384, /* horizontal 70.495 Khz */
|
||||
1, 32, 38, /* vertical 75.154 Hz */
|
||||
/* pixel 108.280 MHz */
|
||||
},
|
||||
{ 1152, 900, 70,
|
||||
32, 208, 384, /* horizontal 65.251 KHz */
|
||||
2, 32, 38, /* vertical 69.564 Hz */
|
||||
/* pixel 100.226 MHz */
|
||||
},
|
||||
{ 1152, 900, 66,
|
||||
32, 208, 384, /* horizontal 61.817 KHz */
|
||||
1, 32, 38, /* vertical 65.903 Hz */
|
||||
/* pixel 94.951 MHz */
|
||||
},
|
||||
{ 1280, 1024, 85,
|
||||
16, 248, 416, /* horizontal 90.561 KHz */
|
||||
1, 40, 45, /* vertical 84.717 Hz */
|
||||
/* pixel 153.593 MHz */
|
||||
},
|
||||
{ 1280, 1024, 75,
|
||||
16, 248, 408, /* horizontal 80.255 KHz */
|
||||
1, 38, 42, /* vertical 75.285 Hz */
|
||||
/* pixel 134.828 MHz */
|
||||
},
|
||||
{ 1280, 1024, 70,
|
||||
32, 248, 400, /* horizontal 74.573 KHz */
|
||||
0, 36, 39, /* vertical 70.153 Hz */
|
||||
/* pixel 125.283 MHz */
|
||||
},
|
||||
{ 1280, 1024, 66,
|
||||
32, 248, 400, /* horizontal 70.007 KHz */
|
||||
0, 36, 39, /* vertical 65.858 Hz */
|
||||
/* pixel 117.612 MHz */
|
||||
},
|
||||
|
||||
{ 1600, 1200, 85,
|
||||
64, 304, 560, /* horizontal 106.059 KHz */
|
||||
1, 46, 50, /* vertical 84.847 Hz */
|
||||
/* pixel 229.088 MHz */
|
||||
},
|
||||
{ 1600, 1200, 75,
|
||||
64, 304, 560, /* horizontal 93.748 KHz */
|
||||
1, 46, 50, /* vertical 74.999 Hz */
|
||||
/* pixel 202.497 MHz */
|
||||
},
|
||||
{ 1600, 1200, 70,
|
||||
56, 304, 588, /* horizontal 87.524 KHz */
|
||||
1, 46, 50, /* vertical 70.019 Hz */
|
||||
/* pixel 191.503 MHz */
|
||||
},
|
||||
{ 1600, 1200, 65,
|
||||
56, 308, 524, /* horizontal 80.050 KHz */
|
||||
1, 38, 42, /* vertical 64.453 Hz */
|
||||
/* pixel 170.026 MHz */
|
||||
},
|
||||
};
|
||||
|
||||
#define NUM_SIS_TIMINGS (sizeof (sisTimings) / sizeof (sisTimings[0]))
|
||||
|
||||
Bool
|
||||
sisCardInit (KdCardInfo *card)
|
||||
{
|
||||
SisCardInfo *sisc;
|
||||
SisPtr sis;
|
||||
int size;
|
||||
CARD8 *registers;
|
||||
CARD8 *temp_buffer;
|
||||
|
||||
sisc = (SisCardInfo *) xalloc (sizeof (SisCardInfo));
|
||||
if (!sisc)
|
||||
goto bail0;
|
||||
|
||||
temp_buffer = KdMapDevice (card->attr.address[0], MAX_FB_SIZE);
|
||||
if (!temp_buffer)
|
||||
goto bail1;
|
||||
|
||||
sisc->memory = KdFrameBufferSize (temp_buffer, MAX_FB_SIZE);
|
||||
|
||||
KdUnmapDevice (temp_buffer, MAX_FB_SIZE);
|
||||
|
||||
if (!sisc->memory)
|
||||
{
|
||||
ErrorF ("Can't detect SiS530 frame buffer\n");
|
||||
goto bail1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Map frame buffer and MMIO registers
|
||||
*/
|
||||
sisc->frameBuffer = KdMapDevice (card->attr.address[0], sisc->memory);
|
||||
if (!sisc->frameBuffer)
|
||||
goto bail1;
|
||||
|
||||
sisc->registers = KdMapDevice (card->attr.address[1], MMIO_SIZE);
|
||||
if (!sisc->registers)
|
||||
goto bail2;
|
||||
|
||||
/*
|
||||
* Offset from base of MMIO to registers
|
||||
*/
|
||||
sisc->sis = (SisPtr) (sisc->registers + SIS_MMIO_OFFSET);
|
||||
sisc->cpu_bitblt = (VOL32 *) sisc->registers;
|
||||
sisc->io_base = card->attr.io;
|
||||
|
||||
/*
|
||||
* enable access to SiS ports (no MMIO available)
|
||||
*/
|
||||
ioperm (sisc->io_base, 0x80, 1);
|
||||
card->driver = sisc;
|
||||
|
||||
return TRUE;
|
||||
bail2:
|
||||
KdUnmapDevice (sisc->frameBuffer, sisc->memory);
|
||||
bail1:
|
||||
xfree (sisc);
|
||||
bail0:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SisTiming *
|
||||
sisGetTiming (int width, int height, int rate)
|
||||
{
|
||||
int i;
|
||||
SisTiming *t;
|
||||
|
||||
for (i = 0; i < NUM_SIS_TIMINGS; i++)
|
||||
{
|
||||
t = &sisTimings[i];
|
||||
if (t->horizontal >= width &&
|
||||
t->vertical >= height &&
|
||||
(!rate || t->rate <= rate))
|
||||
return t;
|
||||
}
|
||||
return &sisTimings[SIS_TIMING_BAIL];
|
||||
}
|
||||
|
||||
Bool
|
||||
sisScreenInit (KdScreenInfo *screen)
|
||||
{
|
||||
KdCardInfo *card = screen->card;
|
||||
SisCardInfo *sisc = (SisCardInfo *) card->driver;
|
||||
SisScreenInfo *siss;
|
||||
int i;
|
||||
SisTiming *t;
|
||||
CARD32 memory;
|
||||
int byte_width, pixel_width, screen_size;
|
||||
|
||||
siss = (SisScreenInfo *) xalloc (sizeof (SisScreenInfo));
|
||||
if (!siss)
|
||||
return FALSE;
|
||||
|
||||
memset (siss, '\0', sizeof (SisScreenInfo));
|
||||
|
||||
if (!screen->width || !screen->height)
|
||||
{
|
||||
screen->width = 800;
|
||||
screen->height = 600;
|
||||
screen->rate = 72;
|
||||
}
|
||||
if (!screen->depth)
|
||||
screen->depth = 8;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (screen->depth >= 24)
|
||||
{
|
||||
screen->depth = 24;
|
||||
screen->bitsPerPixel = 24;
|
||||
}
|
||||
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 <= sisc->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 (siss);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
t = sisGetTiming (screen->width, screen->height, screen->rate);
|
||||
screen->rate = t->rate;
|
||||
screen->width = t->horizontal;
|
||||
screen->height = t->vertical;
|
||||
|
||||
/*
|
||||
* Take requested geometry and adjust to fit possible geometries
|
||||
*/
|
||||
switch (screen->depth) {
|
||||
case 4:
|
||||
screen->bitsPerPixel = 4;
|
||||
break;
|
||||
case 8:
|
||||
screen->bitsPerPixel = 8;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
screen->bitsPerPixel = 16;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
screen->bitsPerPixel = 24;
|
||||
screen->dumb = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
screen->byteStride = screen->width * (screen->bitsPerPixel >> 3);
|
||||
screen->pixelStride = screen->width;
|
||||
|
||||
memory = sisc->memory - screen_size;
|
||||
|
||||
screen->frameBuffer = sisc->frameBuffer;
|
||||
|
||||
/*
|
||||
* Cursor lives in the last 16k of memory
|
||||
*/
|
||||
if (memory >= 16384 && !screen->softCursor)
|
||||
{
|
||||
siss->cursor_base = sisc->frameBuffer + (sisc->memory - 16384);
|
||||
siss->cursor_off = siss->cursor_base - sisc->frameBuffer;
|
||||
memory -= 16384;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->softCursor = TRUE;
|
||||
siss->cursor_base = 0;
|
||||
siss->cursor_off = 0;
|
||||
}
|
||||
|
||||
if (memory > 8192)
|
||||
{
|
||||
siss->expand = screen->frameBuffer + screen_size;
|
||||
siss->expand_off = siss->expand - sisc->frameBuffer;
|
||||
siss->expand_len = memory;
|
||||
memory = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
siss->expand = 0;
|
||||
siss->expand_len = 0;
|
||||
}
|
||||
|
||||
switch (screen->depth) {
|
||||
case 8:
|
||||
screen->visuals = ((1 << StaticGray) |
|
||||
(1 << GrayScale) |
|
||||
(1 << StaticColor) |
|
||||
(1 << PseudoColor) |
|
||||
(1 << TrueColor) |
|
||||
(1 << DirectColor));
|
||||
screen->blueMask = 0x00;
|
||||
screen->greenMask = 0x00;
|
||||
screen->redMask = 0x00;
|
||||
break;
|
||||
case 15:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x001f;
|
||||
screen->greenMask = 0x03e0;
|
||||
screen->redMask = 0x7c00;
|
||||
break;
|
||||
case 16:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x001f;
|
||||
screen->greenMask = 0x07e0;
|
||||
screen->redMask = 0xf800;
|
||||
break;
|
||||
case 24:
|
||||
screen->visuals = (1 << TrueColor);
|
||||
screen->blueMask = 0x0000ff;
|
||||
screen->greenMask = 0x00ff00;
|
||||
screen->redMask = 0xff0000;
|
||||
break;
|
||||
}
|
||||
|
||||
screen->driver = siss;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_sisGetCrtc (SisCardInfo *sisc, SisCrtc *crtc)
|
||||
{
|
||||
crtc->misc_output = _sisInb(sisc->io_base+0x4c);
|
||||
crtc->h_total_0_7 = GetCrtc (sisc, 0x00);
|
||||
crtc->h_display_end_0_7 = GetCrtc (sisc, 0x01);
|
||||
crtc->h_blank_start_0_7 = GetCrtc (sisc, 0x02);
|
||||
crtc->_h_blank_end = GetCrtc (sisc, 0x03);
|
||||
crtc->h_sync_start_0_7 = GetCrtc (sisc, 0x04);
|
||||
crtc->_h_sync_end = GetCrtc (sisc, 0x05);
|
||||
crtc->v_total_0_7 = GetCrtc (sisc, 0x06);
|
||||
crtc->crtc_overflow = GetCrtc (sisc, 0x07);
|
||||
crtc->preset_row_scan = GetCrtc (sisc, 0x08);
|
||||
crtc->_max_scan_line = GetCrtc (sisc, 0x09);
|
||||
|
||||
crtc->start_address_8_15 = GetCrtc (sisc, 0x0c);
|
||||
crtc->start_address_0_7 = GetCrtc (sisc, 0x0d);
|
||||
|
||||
crtc->v_retrace_start_0_7 = GetCrtc (sisc, 0x10);
|
||||
crtc->_v_retrace_end = GetCrtc (sisc, 0x11);
|
||||
crtc->v_display_end_0_7 = GetCrtc (sisc, 0x12);
|
||||
crtc->screen_off_0_7 = GetCrtc (sisc, 0x13);
|
||||
crtc->_underline_location = GetCrtc (sisc, 0x14);
|
||||
crtc->v_blank_start_0_7 = GetCrtc (sisc, 0x15);
|
||||
crtc->v_blank_end_0_7 = GetCrtc (sisc, 0x16);
|
||||
crtc->crtc_mode = GetCrtc (sisc, 0x17);
|
||||
|
||||
crtc->line_compare_0_7 = GetCrtc (sisc, 0x18);
|
||||
|
||||
crtc->mode_control = GetArtc (sisc, 0x10);
|
||||
crtc->screen_border_color = GetArtc (sisc, 0x11);
|
||||
crtc->enable_color_plane = GetArtc (sisc, 0x12);
|
||||
crtc->horizontal_pixel_pan = GetArtc (sisc, 0x13);
|
||||
|
||||
crtc->mode_register = GetGrtc (sisc, 0x5);
|
||||
|
||||
crtc->clock_mode = GetSrtc (sisc, 0x1);
|
||||
|
||||
crtc->graphics_mode = GetSrtc (sisc, 0x6);
|
||||
crtc->misc_control_0 = GetSrtc (sisc, 0x7);
|
||||
crtc->crt_cpu_threshold_control_0 = GetSrtc (sisc, 0x8);
|
||||
crtc->crt_cpu_threshold_control_1 = GetSrtc (sisc, 0x9);
|
||||
crtc->extended_crt_overflow = GetSrtc (sisc, 0xa);
|
||||
crtc->misc_control_1 = GetSrtc (sisc, 0xb);
|
||||
crtc->misc_control_2 = GetSrtc (sisc, 0xc);
|
||||
|
||||
crtc->ddc_and_power_control = GetSrtc (sisc, 0x11);
|
||||
crtc->extended_horizontal_overflow = GetSrtc (sisc, 0x12);
|
||||
crtc->extended_clock_generator = GetSrtc (sisc, 0x13);
|
||||
crtc->cursor_0_red = GetSrtc (sisc, 0x14);
|
||||
crtc->cursor_0_green = GetSrtc (sisc, 0x15);
|
||||
crtc->cursor_0_blue = GetSrtc (sisc, 0x16);
|
||||
crtc->cursor_1_red = GetSrtc (sisc, 0x17);
|
||||
crtc->cursor_1_green = GetSrtc (sisc, 0x18);
|
||||
crtc->cursor_1_blue = GetSrtc (sisc, 0x19);
|
||||
crtc->cursor_h_start_0_7 = GetSrtc (sisc, 0x1a);
|
||||
crtc->cursor_h_start_1 = GetSrtc (sisc, 0x1b);
|
||||
crtc->cursor_h_preset_0_5 = GetSrtc (sisc, 0x1c);
|
||||
crtc->cursor_v_start_0_7 = GetSrtc (sisc, 0x1d);
|
||||
crtc->cursor_v_start_1 = GetSrtc (sisc, 0x1e);
|
||||
crtc->cursor_v_preset_0_5 = GetSrtc (sisc, 0x1f);
|
||||
crtc->linear_base_19_26 = GetSrtc (sisc, 0x20);
|
||||
crtc->linear_base_1 = GetSrtc (sisc, 0x21);
|
||||
|
||||
crtc->graphics_engine_0 = GetSrtc (sisc, 0x26);
|
||||
crtc->graphics_engine_1 = GetSrtc (sisc, 0x27);
|
||||
crtc->internal_mclk_0 = GetSrtc (sisc, 0x28);
|
||||
crtc->internal_mclk_1 = GetSrtc (sisc, 0x29);
|
||||
crtc->internal_vclk_0 = GetSrtc (sisc, 0x2A);
|
||||
crtc->internal_vclk_1 = GetSrtc (sisc, 0x2B);
|
||||
|
||||
crtc->misc_control_7 = GetSrtc (sisc, 0x38);
|
||||
|
||||
crtc->misc_control_11 = GetSrtc (sisc, 0x3E);
|
||||
crtc->misc_control_12 = GetSrtc (sisc, 0x3F);
|
||||
}
|
||||
|
||||
static void
|
||||
_sisSetBlank (SisCardInfo *sisc, Bool blank)
|
||||
{
|
||||
CARD8 clock;
|
||||
|
||||
clock = GetSrtc (sisc, 0x01);
|
||||
if (blank)
|
||||
clock |= 0x20;
|
||||
else
|
||||
clock &= ~0x20;
|
||||
PutSrtc (sisc, 0x01, clock);
|
||||
}
|
||||
|
||||
static void
|
||||
_sisSetCrtc (SisCardInfo *sisc, SisCrtc *crtc)
|
||||
{
|
||||
_sisOutb(crtc->misc_output, sisc->io_base+0x4c);
|
||||
_sisSetBlank (sisc, TRUE);
|
||||
PutCrtc (sisc, 0x00, crtc->h_total_0_7);
|
||||
PutCrtc (sisc, 0x01, crtc->h_display_end_0_7);
|
||||
PutCrtc (sisc, 0x02, crtc->h_blank_start_0_7);
|
||||
PutCrtc (sisc, 0x03, crtc->_h_blank_end);
|
||||
PutCrtc (sisc, 0x04, crtc->h_sync_start_0_7);
|
||||
PutCrtc (sisc, 0x05, crtc->_h_sync_end);
|
||||
PutCrtc (sisc, 0x06, crtc->v_total_0_7);
|
||||
PutCrtc (sisc, 0x07, crtc->crtc_overflow);
|
||||
PutCrtc (sisc, 0x08, crtc->preset_row_scan);
|
||||
PutCrtc (sisc, 0x09, crtc->_max_scan_line);
|
||||
|
||||
PutCrtc (sisc, 0x0c, crtc->start_address_8_15);
|
||||
PutCrtc (sisc, 0x0d, crtc->start_address_0_7);
|
||||
|
||||
PutCrtc (sisc, 0x10, crtc->v_retrace_start_0_7);
|
||||
PutCrtc (sisc, 0x11, crtc->_v_retrace_end);
|
||||
PutCrtc (sisc, 0x12, crtc->v_display_end_0_7);
|
||||
PutCrtc (sisc, 0x13, crtc->screen_off_0_7);
|
||||
PutCrtc (sisc, 0x14, crtc->_underline_location);
|
||||
PutCrtc (sisc, 0x15, crtc->v_blank_start_0_7);
|
||||
PutCrtc (sisc, 0x16, crtc->v_blank_end_0_7);
|
||||
PutCrtc (sisc, 0x17, crtc->crtc_mode);
|
||||
PutCrtc (sisc, 0x18, crtc->line_compare_0_7);
|
||||
|
||||
PutArtc (sisc, 0x10, crtc->mode_control);
|
||||
PutArtc (sisc, 0x11, crtc->screen_border_color);
|
||||
PutArtc (sisc, 0x12, crtc->enable_color_plane);
|
||||
PutArtc (sisc, 0x13, crtc->horizontal_pixel_pan);
|
||||
|
||||
PutGrtc (sisc, 0x5, crtc->mode_register);
|
||||
|
||||
PutSrtc (sisc, 0x1, crtc->clock_mode | 0x20);
|
||||
|
||||
PutSrtc (sisc, 0x6, crtc->graphics_mode);
|
||||
PutSrtc (sisc, 0x7, crtc->misc_control_0);
|
||||
PutSrtc (sisc, 0x8, crtc->crt_cpu_threshold_control_0);
|
||||
PutSrtc (sisc, 0x9, crtc->crt_cpu_threshold_control_1);
|
||||
PutSrtc (sisc, 0xa, crtc->extended_crt_overflow);
|
||||
PutSrtc (sisc, 0xb, crtc->misc_control_1);
|
||||
PutSrtc (sisc, 0xc, crtc->misc_control_2);
|
||||
|
||||
PutSrtc (sisc, 0x11, crtc->ddc_and_power_control);
|
||||
PutSrtc (sisc, 0x12, crtc->extended_horizontal_overflow);
|
||||
PutSrtc (sisc, 0x13, crtc->extended_clock_generator);
|
||||
PutSrtc (sisc, 0x14, crtc->cursor_0_red);
|
||||
PutSrtc (sisc, 0x15, crtc->cursor_0_green);
|
||||
PutSrtc (sisc, 0x16, crtc->cursor_0_blue);
|
||||
PutSrtc (sisc, 0x17, crtc->cursor_1_red);
|
||||
PutSrtc (sisc, 0x18, crtc->cursor_1_green);
|
||||
PutSrtc (sisc, 0x19, crtc->cursor_1_blue);
|
||||
PutSrtc (sisc, 0x1a, crtc->cursor_h_start_0_7);
|
||||
PutSrtc (sisc, 0x1b, crtc->cursor_h_start_1);
|
||||
PutSrtc (sisc, 0x1c, crtc->cursor_h_preset_0_5);
|
||||
PutSrtc (sisc, 0x1d, crtc->cursor_v_start_0_7);
|
||||
PutSrtc (sisc, 0x1e, crtc->cursor_v_start_1);
|
||||
PutSrtc (sisc, 0x1f, crtc->cursor_v_preset_0_5);
|
||||
PutSrtc (sisc, 0x20, crtc->linear_base_19_26);
|
||||
PutSrtc (sisc, 0x21, crtc->linear_base_1);
|
||||
|
||||
PutSrtc (sisc, 0x26, crtc->graphics_engine_0);
|
||||
PutSrtc (sisc, 0x27, crtc->graphics_engine_1);
|
||||
PutSrtc (sisc, 0x28, crtc->internal_mclk_0);
|
||||
PutSrtc (sisc, 0x29, crtc->internal_mclk_1);
|
||||
PutSrtc (sisc, 0x2A, crtc->internal_vclk_0);
|
||||
PutSrtc (sisc, 0x2B, crtc->internal_vclk_1);
|
||||
|
||||
PutSrtc (sisc, 0x38, crtc->misc_control_7);
|
||||
|
||||
PutSrtc (sisc, 0x3E, crtc->misc_control_11);
|
||||
PutSrtc (sisc, 0x3F, crtc->misc_control_12);
|
||||
|
||||
_sisSetBlank (sisc, FALSE);
|
||||
}
|
||||
|
||||
CARD8
|
||||
_sisReadIndexRegister (CARD32 base, CARD8 index)
|
||||
{
|
||||
CARD8 ret;
|
||||
|
||||
_sisOutb (index, base);
|
||||
ret = _sisInb (base+1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value)
|
||||
{
|
||||
_sisOutb (index, base);
|
||||
_sisOutb (value, base+1);
|
||||
}
|
||||
|
||||
void
|
||||
sisPreserve (KdCardInfo *card)
|
||||
{
|
||||
SisCardInfo *sisc = card->driver;
|
||||
CARD8 *r = sisc->registers;
|
||||
int a, i, l;
|
||||
CARD8 line[16];
|
||||
CARD8 prev[16];
|
||||
BOOL gotone;
|
||||
|
||||
sisc->save.sr5 = GetSrtc(sisc,0x5);
|
||||
if (sisc->save.sr5 != 0x21)
|
||||
sisc->save.sr5 = 0x86;
|
||||
/* unlock extension registers */
|
||||
PutSrtc(sisc,0x5,0x86);
|
||||
|
||||
/* enable MMIO access to registers */
|
||||
sisc->save.srb = GetSrtc(sisc,0xb);
|
||||
PutSrtc(sisc, 0xb, sisc->save.srb | 0x60);
|
||||
_sisGetCrtc (sisc, &sisc->save.crtc);
|
||||
}
|
||||
|
||||
void
|
||||
sisEnable (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
KdScreenInfo *screen = pScreenPriv->screen;
|
||||
KdCardInfo *card = pScreenPriv->card;
|
||||
SisCardInfo *sisc = card->driver;
|
||||
SisScreenInfo *siss = screen->driver;
|
||||
SisTiming *t;
|
||||
SisCrtc crtc;
|
||||
unsigned long pixel;
|
||||
|
||||
int hactive;
|
||||
int hblank;
|
||||
int hfp;
|
||||
int hbp;
|
||||
|
||||
int vactive;
|
||||
int vblank;
|
||||
int vfp;
|
||||
int vbp;
|
||||
|
||||
int h_total;
|
||||
int h_display_end;
|
||||
int h_blank_start;
|
||||
int h_blank_end;
|
||||
int h_sync_start;
|
||||
int h_sync_end;
|
||||
int h_screen_off;
|
||||
|
||||
int h_adjust;
|
||||
|
||||
int v_total;
|
||||
int v_retrace_start;
|
||||
int v_retrace_end;
|
||||
int v_display_end;
|
||||
int v_blank_start;
|
||||
int v_blank_end;
|
||||
|
||||
crtc = sisc->save.crtc;
|
||||
|
||||
t = sisGetTiming (screen->width, screen->height, screen->rate);
|
||||
|
||||
/* CR11 */
|
||||
crtc.disable_v_retrace_int = 1;
|
||||
|
||||
/* 3CC/3C2 */
|
||||
crtc.io_address_select = 1;
|
||||
crtc.display_ram_enable = 1;
|
||||
crtc.clock_select = 3;
|
||||
|
||||
/* SR6 */
|
||||
crtc.graphics_mode = 0;
|
||||
crtc.graphics_mode_linear = 1;
|
||||
crtc.enhanced_graphics_mode = 1;
|
||||
|
||||
/* SRB */
|
||||
crtc.cpu_bitblt_enable = 1;
|
||||
crtc.memory_mapped_mode = 3;
|
||||
|
||||
/* SRC */
|
||||
crtc.graphics_mode_32bit_enable = 1;
|
||||
crtc.text_mode_16bit_enable = 0;
|
||||
crtc.read_ahead_enable = 1;
|
||||
|
||||
/* SR11 */
|
||||
crtc.acpi_enable = 0;
|
||||
crtc.kbd_cursor_activate = 0;
|
||||
crtc.video_memory_activate = 0;
|
||||
crtc.vga_standby = 0;
|
||||
crtc.vga_suspend = 0;
|
||||
|
||||
/* AR10 */
|
||||
crtc.mode_control = 0;
|
||||
crtc.graphics_mode_enable = 1;
|
||||
/* AR11 */
|
||||
crtc.screen_border_color = 0;
|
||||
/* AR12 */
|
||||
crtc.enable_color_plane = 0xf;
|
||||
/* AR13 */
|
||||
crtc.horizontal_pixel_pan = 0;
|
||||
|
||||
/* SR27 */
|
||||
crtc.logical_screen_width = 3;
|
||||
crtc.graphics_prog_enable = 1;
|
||||
|
||||
/* SR38 */
|
||||
crtc.extended_clock_select = 0;
|
||||
|
||||
if (siss->cursor_base)
|
||||
{
|
||||
crtc_set_cursor_start_addr (&crtc, siss->cursor_off);
|
||||
crtc.graphics_mode_hw_cursor = 0;
|
||||
}
|
||||
|
||||
hactive = t->horizontal;
|
||||
hblank = t->hblank;
|
||||
hbp = t->hbp;
|
||||
hfp = t->hfp;
|
||||
|
||||
vactive = t->vertical;
|
||||
vblank = t->vblank;
|
||||
vbp = t->vbp;
|
||||
vfp = t->vfp;
|
||||
|
||||
pixel = (hactive + hblank) * (vactive + vblank) * t->rate;
|
||||
|
||||
switch (screen->bitsPerPixel) {
|
||||
case 8:
|
||||
hactive /= 8;
|
||||
hblank /= 8;
|
||||
hfp /= 8;
|
||||
hbp /= 8;
|
||||
|
||||
crtc.color_mode_256 = 1;
|
||||
h_screen_off = hactive;
|
||||
h_adjust = 1;
|
||||
|
||||
break;
|
||||
case 16:
|
||||
hactive /= 8;
|
||||
hblank /= 8;
|
||||
hfp /= 8;
|
||||
hbp /= 8;
|
||||
|
||||
h_screen_off = hactive * 2;
|
||||
h_adjust = 1;
|
||||
|
||||
crtc.color_mode_256 = 0;
|
||||
|
||||
if (screen->depth == 15)
|
||||
crtc.graphics_mode_32k = 1;
|
||||
else
|
||||
crtc.graphics_mode_64k = 1;
|
||||
break;
|
||||
case 24:
|
||||
hactive /= 8;
|
||||
hblank /= 8;
|
||||
hfp /= 8;
|
||||
hbp /= 8;
|
||||
|
||||
h_screen_off = hactive * 3;
|
||||
h_adjust = 1;
|
||||
|
||||
crtc.color_mode_256 = 0;
|
||||
|
||||
/* SR6 */
|
||||
crtc.graphics_mode_true = 1;
|
||||
/* SR7 */
|
||||
crtc.direct_color_24bit = 0;
|
||||
/* SR9 */
|
||||
crtc.true_color_32bpp = 0;
|
||||
/* SRB */
|
||||
crtc.true_color_order = 1;
|
||||
break;
|
||||
case 32:
|
||||
hactive /= 8;
|
||||
hblank /= 8;
|
||||
hfp /= 8;
|
||||
hbp /= 8;
|
||||
|
||||
h_screen_off = hactive * 4;
|
||||
h_adjust = 1;
|
||||
|
||||
crtc.color_mode_256 = 0;
|
||||
|
||||
/* SR6 */
|
||||
crtc.graphics_mode_true = 1;
|
||||
/* SR7 */
|
||||
crtc.direct_color_24bit = 0;
|
||||
/* SR9 */
|
||||
crtc.true_color_32bpp = 1;
|
||||
/* SRB */
|
||||
crtc.true_color_order = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
sisGetClock (pixel, &crtc);
|
||||
|
||||
crtc.high_speed_dac_0 = crtc.high_speed_dac_1 = pixel > 135000000;
|
||||
|
||||
sisEngThresh (&crtc, pixel, screen->bitsPerPixel);
|
||||
|
||||
/*
|
||||
* Compute horizontal register values from timings
|
||||
*/
|
||||
h_total = hactive + hblank - 5;
|
||||
h_display_end = hactive - 1;
|
||||
h_blank_start = h_display_end;
|
||||
h_blank_end = h_blank_start + hblank;
|
||||
|
||||
h_sync_start = hactive + hfp + h_adjust;
|
||||
h_sync_end = h_sync_start + hblank - hbp - hfp;
|
||||
|
||||
crtc_set_h_total(&crtc, h_total);
|
||||
crtc_set_h_display_end (&crtc, h_display_end);
|
||||
crtc_set_h_blank_start (&crtc, h_blank_start);
|
||||
crtc_set_h_blank_end (&crtc, h_blank_end);
|
||||
crtc_set_h_sync_start (&crtc, h_sync_start);
|
||||
crtc_set_h_sync_end (&crtc, h_sync_end);
|
||||
crtc_set_screen_off (&crtc, h_screen_off);
|
||||
|
||||
v_total = vactive + vblank - 2;
|
||||
v_retrace_start = vactive + vfp - 1;
|
||||
v_retrace_end = v_retrace_start + vblank - vbp - vfp;
|
||||
v_display_end = vactive - 1;
|
||||
v_blank_start = vactive - 1;
|
||||
v_blank_end = v_blank_start + vblank /* - 1 */;
|
||||
|
||||
crtc_set_v_total(&crtc, v_total);
|
||||
crtc_set_v_retrace_start (&crtc, v_retrace_start);
|
||||
crtc.v_retrace_end_0_3 = v_retrace_end;
|
||||
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;
|
||||
|
||||
_sisSetCrtc (sisc, &crtc);
|
||||
}
|
||||
|
||||
Bool
|
||||
sisDPMS (ScreenPtr pScreen, int mode)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
sisCardInfo(pScreenPriv);
|
||||
union ddc_and_power_control_u _ddc_and_power_control_u;
|
||||
|
||||
ddc_and_power_control = sisc->save.crtc.ddc_and_power_control;
|
||||
|
||||
kbd_cursor_activate = 0;
|
||||
video_memory_activate = 0;
|
||||
vga_standby = 0;
|
||||
vga_suspend = 0;
|
||||
acpi_enable = 0;
|
||||
switch (mode) {
|
||||
case KD_DPMS_NORMAL:
|
||||
break;
|
||||
case KD_DPMS_STANDBY:
|
||||
vga_standby = 1;
|
||||
break;
|
||||
case KD_DPMS_SUSPEND:
|
||||
vga_suspend = 1;
|
||||
break;
|
||||
case KD_DPMS_POWERDOWN:
|
||||
acpi_enable = 1;
|
||||
break;
|
||||
}
|
||||
PutSrtc (sisc, 0x11, ddc_and_power_control);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
sisDisable (ScreenPtr pScreen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sisRestore (KdCardInfo *card)
|
||||
{
|
||||
SisCardInfo *sisc = (SisCardInfo *) card->driver;
|
||||
|
||||
_sisSetCrtc (sisc, &sisc->save.crtc);
|
||||
PutSrtc (sisc, 0xb, sisc->save.srb);
|
||||
PutSrtc (sisc, 0x5, sisc->save.sr5);
|
||||
}
|
||||
|
||||
void
|
||||
sisScreenFini (KdScreenInfo *screen)
|
||||
{
|
||||
SisScreenInfo *siss = (SisScreenInfo *) screen->driver;
|
||||
|
||||
xfree (siss);
|
||||
screen->driver = 0;
|
||||
}
|
||||
|
||||
void
|
||||
sisCardFini (KdCardInfo *card)
|
||||
{
|
||||
SisCardInfo *sisc = (SisCardInfo *) card->driver;
|
||||
|
||||
KdUnmapDevice (sisc->frameBuffer, sisc->memory);
|
||||
KdUnmapDevice (sisc->registers, sizeof (SisRec));
|
||||
ioperm (sisc->io_base, 0x80, 0);
|
||||
}
|
||||
|
||||
KdCardFuncs sisFuncs = {
|
||||
sisCardInit,
|
||||
sisScreenInit,
|
||||
sisPreserve,
|
||||
sisEnable,
|
||||
sisDPMS,
|
||||
sisDisable,
|
||||
sisRestore,
|
||||
sisScreenFini,
|
||||
sisCardFini,
|
||||
sisCursorInit,
|
||||
sisCursorEnable,
|
||||
sisCursorDisable,
|
||||
sisCursorFini,
|
||||
0,
|
||||
sisDrawInit,
|
||||
sisDrawEnable,
|
||||
sisDrawDisable,
|
||||
sisDrawFini,
|
||||
sisGetColors,
|
||||
sisPutColors,
|
||||
};
|
1152
hw/kdrive/sis530/sis.h
Normal file
1152
hw/kdrive/sis530/sis.h
Normal file
File diff suppressed because it is too large
Load Diff
232
hw/kdrive/sis530/sisclock.c
Normal file
232
hw/kdrive/sis530/sisclock.c
Normal file
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "sis.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define FREF 14318180
|
||||
#define MIN_VCO FREF
|
||||
#define MAX_VCO 230000000
|
||||
#define MAX_PSN 0 /* no pre scaler for this chip */
|
||||
#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */
|
||||
#define max_VLD 1
|
||||
|
||||
/*
|
||||
* Compute clock values given target frequency
|
||||
*/
|
||||
void
|
||||
sisGetClock (unsigned long clock, SisCrtc *crtc)
|
||||
{
|
||||
unsigned char reg7, reg13, reg2a, reg2b;
|
||||
int M, N, P, VLD;
|
||||
|
||||
int bestM, bestN, bestP, bestPSN, bestVLD;
|
||||
double bestError, abest = 42.0, bestFout;
|
||||
|
||||
double Fvco, Fout;
|
||||
double error, aerror;
|
||||
|
||||
double target = (double) clock;
|
||||
|
||||
int M_min = 2;
|
||||
int M_max = 128;
|
||||
|
||||
int low_N = 2;
|
||||
int high_N = 32;
|
||||
int PSN = 1;
|
||||
|
||||
/*
|
||||
* fd = fref*(Numerator/Denumerator)*(Divider/PostScaler)
|
||||
*
|
||||
* M = Numerator [1:128]
|
||||
* N = DeNumerator [1:32]
|
||||
* VLD = Divider (Vco Loop Divider) : divide by 1, 2
|
||||
* P = Post Scaler : divide by 1, 2, 3, 4
|
||||
* PSN = Pre Scaler (Reference Divisor Select)
|
||||
*
|
||||
* result in vclk[]
|
||||
*/
|
||||
|
||||
P = 1;
|
||||
if (target < MAX_VCO / 2)
|
||||
P = 2;
|
||||
if (target < MAX_VCO / 3)
|
||||
P = 3;
|
||||
if (target < MAX_VCO / 4)
|
||||
P = 4;
|
||||
if (target < MAX_VCO / 6)
|
||||
P = 6;
|
||||
if (target < MAX_VCO / 8)
|
||||
P = 8;
|
||||
|
||||
Fvco = P * target;
|
||||
|
||||
for (N = low_N; N <= high_N; N++)
|
||||
{
|
||||
double M_desired = Fvco / FREF * N;
|
||||
|
||||
if (M_desired > M_max * max_VLD)
|
||||
continue;
|
||||
|
||||
if ( M_desired > M_max )
|
||||
{
|
||||
M = (int)(M_desired / 2 + 0.5);
|
||||
VLD = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
M = (int)(M_desired + 0.5);
|
||||
VLD = 1;
|
||||
}
|
||||
|
||||
Fout = (double)FREF * (M * VLD)/(N * P);
|
||||
error = (target - Fout) / target;
|
||||
aerror = (error < 0) ? -error : error;
|
||||
if (aerror < abest)
|
||||
{
|
||||
abest = aerror;
|
||||
bestError = error;
|
||||
bestM = M;
|
||||
bestN = N;
|
||||
bestP = P;
|
||||
bestPSN = PSN;
|
||||
bestVLD = VLD;
|
||||
bestFout = Fout;
|
||||
}
|
||||
}
|
||||
|
||||
crtc->vclk_numerator = bestM - 1;
|
||||
crtc->vclk_divide_by_2 = bestVLD == 2;
|
||||
|
||||
crtc->vclk_denominator = bestN - 1;
|
||||
switch (bestP) {
|
||||
case 1:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_1;
|
||||
crtc->vclk_post_scale_2 = 0;
|
||||
break;
|
||||
case 2:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_2;
|
||||
crtc->vclk_post_scale_2 = 0;
|
||||
break;
|
||||
case 3:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_3;
|
||||
crtc->vclk_post_scale_2 = 0;
|
||||
break;
|
||||
case 4:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_4;
|
||||
crtc->vclk_post_scale_2 = 0;
|
||||
break;
|
||||
case 6:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_3;
|
||||
crtc->vclk_post_scale_2 = 1;
|
||||
break;
|
||||
case 8:
|
||||
crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_4;
|
||||
crtc->vclk_post_scale_2 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
crtc->vclk_vco_gain = 1;
|
||||
|
||||
/*
|
||||
* Don't know how to set mclk for local frame buffer; for
|
||||
* shared frame buffer, mclk is hardwired to bus speed (100MHz)?
|
||||
*/
|
||||
}
|
||||
|
||||
sisCalcMclk (SisCrtc *crtc)
|
||||
{
|
||||
int mclk, Numer, DeNumer;
|
||||
double Divider, Scalar;
|
||||
|
||||
Numer = crtc->mclk_numerator;
|
||||
DeNumer = crtc->mclk_denominator;
|
||||
Divider = crtc->mclk_divide_by_2 ? 2.0 : 1.0;
|
||||
Scalar = 1.0;
|
||||
if (crtc->mclk_post_scale_2)
|
||||
{
|
||||
switch (crtc->mclk_post_scale) {
|
||||
case 2:
|
||||
Scalar = 6.0;
|
||||
break;
|
||||
case 3:
|
||||
Scalar = 8.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (crtc->mclk_post_scale) {
|
||||
case 0:
|
||||
Scalar = 1.0;
|
||||
break;
|
||||
case 1:
|
||||
Scalar = 2.0;
|
||||
break;
|
||||
case 2:
|
||||
Scalar = 3.0;
|
||||
break;
|
||||
case 3:
|
||||
Scalar = 4.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mclk = (int)(FREF*((double)(Numer+1)/(double)(DeNumer+1))*(Divider/Scalar));
|
||||
|
||||
return(mclk);
|
||||
}
|
||||
|
||||
#define UMA_FACTOR 60
|
||||
#define LFB_FACTOR 30 // Only if local frame buffer
|
||||
#define SIS_SAYS_SO 0x1F // But how is the performance??
|
||||
#define CRT_ENG_THRESH 0x0F // But how is the performance??
|
||||
#define BUS_WIDTH 64
|
||||
#define DFP_BUS_WIDTH 32 // rumour has it for digital flat panel ??
|
||||
#define MEGAHZ (1<<20)
|
||||
|
||||
void
|
||||
sisEngThresh (SisCrtc *crtc, unsigned long vclk, int bpp)
|
||||
{
|
||||
int threshlow, mclk;
|
||||
|
||||
mclk = sisCalcMclk(crtc) / 1000000;
|
||||
vclk = vclk / 1000000;
|
||||
threshlow = ((((UMA_FACTOR*vclk*bpp)/
|
||||
(mclk*BUS_WIDTH))+1)/2)+4;
|
||||
|
||||
crtc->crt_cpu_threshold_low_0_3 = threshlow;
|
||||
crtc->crt_cpu_threshold_low_4 = threshlow >> 4;
|
||||
|
||||
crtc->crt_cpu_threshold_high_0_3 = (SIS_SAYS_SO & 0xf);
|
||||
crtc->crt_cpu_threshold_high_4 = 0;
|
||||
|
||||
crtc->crt_engine_threshold_high_0_3 = CRT_ENG_THRESH;
|
||||
crtc->crt_engine_threshold_high_4 = 1;
|
||||
|
||||
crtc->ascii_attribute_threshold_0_2 = (SIS_SAYS_SO >> 4);
|
||||
|
||||
crtc->crt_threshold_full_control = SIS_CRT_64_STAGE_THRESHOLD;
|
||||
}
|
64
hw/kdrive/sis530/siscmap.c
Normal file
64
hw/kdrive/sis530/siscmap.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "sis.h"
|
||||
|
||||
void
|
||||
sisGetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
sisCardInfo(pScreenPriv);
|
||||
|
||||
LockSis (sisc);
|
||||
while (ndef--)
|
||||
{
|
||||
_sisOutb (pdefs->pixel, sisc->io_base+SIS_DAC_INDEX_READ);
|
||||
pdefs->red = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10;
|
||||
pdefs->green = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10;
|
||||
pdefs->blue = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10;
|
||||
pdefs++;
|
||||
}
|
||||
UnlockSis (sisc);
|
||||
}
|
||||
|
||||
void
|
||||
sisPutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
sisCardInfo(pScreenPriv);
|
||||
|
||||
LockSis(sisc);
|
||||
_sisWaitVRetrace (sisc);
|
||||
while (ndef--)
|
||||
{
|
||||
_sisOutb (pdefs->pixel, sisc->io_base+SIS_DAC_INDEX_WRITE);
|
||||
_sisOutb (pdefs->red >> 10, sisc->io_base+SIS_DAC_DATA);
|
||||
_sisOutb (pdefs->green >> 10, sisc->io_base+SIS_DAC_DATA);
|
||||
_sisOutb (pdefs->blue >> 10, sisc->io_base+SIS_DAC_DATA);
|
||||
pdefs++;
|
||||
}
|
||||
UnlockSis(sisc);
|
||||
}
|
||||
|
364
hw/kdrive/sis530/siscurs.c
Normal file
364
hw/kdrive/sis530/siscurs.c
Normal file
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "sis.h"
|
||||
#include "cursorstr.h"
|
||||
|
||||
#define SetupCursor(s) KdScreenPriv(s); \
|
||||
sisCardInfo(pScreenPriv); \
|
||||
sisScreenInfo(pScreenPriv); \
|
||||
SisPtr sis = sisc->sis; \
|
||||
SisCursor *pCurPriv = &siss->cursor
|
||||
|
||||
static void
|
||||
_sisMoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CARD8 xlow, xhigh, ylow, yhigh;
|
||||
CARD8 xoff, yoff;
|
||||
|
||||
x -= pCurPriv->xhot;
|
||||
xoff = 0;
|
||||
if (x < 0)
|
||||
{
|
||||
xoff = -x;
|
||||
x = 0;
|
||||
}
|
||||
y -= pCurPriv->yhot;
|
||||
yoff = 0;
|
||||
if (y < 0)
|
||||
{
|
||||
yoff = -y;
|
||||
y = 0;
|
||||
}
|
||||
xlow = (CARD8) x;
|
||||
xhigh = (CARD8) (x >> 8);
|
||||
ylow = (CARD8) y;
|
||||
yhigh = (CARD8) (y >> 8);
|
||||
|
||||
PutSrtc (sisc, 0x5, 0x86);
|
||||
PutSrtc (sisc, 0x1c, xoff & 0x3f);
|
||||
PutSrtc (sisc, 0x1f, yoff & 0x3f);
|
||||
|
||||
PutSrtc (sisc, 0x1a, xlow);
|
||||
PutSrtc (sisc, 0x1b, xhigh & 0xf);
|
||||
|
||||
PutSrtc (sisc, 0x1d, ylow);
|
||||
PutSrtc (sisc, 0x1e, yhigh & 0x7);
|
||||
}
|
||||
|
||||
static void
|
||||
sisMoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pCurPriv->has_cursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
LockSis(sisc);
|
||||
_sisMoveCursor (pScreen, x, y);
|
||||
UnlockSis(sisc);
|
||||
}
|
||||
|
||||
static void
|
||||
_sisSetCursorColors (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
/* set foreground */
|
||||
PutSrtc (sisc, 0x17, pCursor->foreRed >> 10);
|
||||
PutSrtc (sisc, 0x18, pCursor->foreGreen >> 10);
|
||||
PutSrtc (sisc, 0x19, pCursor->foreBlue >> 10);
|
||||
|
||||
/* set background */
|
||||
PutSrtc (sisc, 0x14, pCursor->backRed >> 10);
|
||||
PutSrtc (sisc, 0x15, pCursor->backGreen >> 10);
|
||||
PutSrtc (sisc, 0x16, pCursor->backBlue >> 10);
|
||||
}
|
||||
|
||||
static void
|
||||
sisLoadCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
CursorBitsPtr bits = pCursor->bits;
|
||||
int w, h;
|
||||
unsigned short *ram, r;
|
||||
unsigned char *msk, *mskLine, *src, *srcLine;
|
||||
unsigned short m, s;
|
||||
|
||||
int i, j;
|
||||
int cursor_address;
|
||||
int src_stride, src_width;
|
||||
|
||||
CARD8 sr6;
|
||||
|
||||
/*
|
||||
* Lock Sis so the cursor doesn't move while we're setting it
|
||||
*/
|
||||
LockSis(sisc);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
pCurPriv->xhot = pCursor->bits->xhot;
|
||||
pCurPriv->yhot = pCursor->bits->yhot;
|
||||
|
||||
/*
|
||||
* Stick new image into cursor memory
|
||||
*/
|
||||
ram = (unsigned short *) siss->cursor_base;
|
||||
mskLine = (unsigned char *) bits->mask;
|
||||
srcLine = (unsigned char *) bits->source;
|
||||
|
||||
h = bits->height;
|
||||
if (h > SIS_CURSOR_HEIGHT)
|
||||
h = SIS_CURSOR_HEIGHT;
|
||||
|
||||
src_stride = BitmapBytePad(bits->width); /* bytes per line */
|
||||
src_width = (bits->width + 7) >> 3;
|
||||
|
||||
for (i = 0; i < SIS_CURSOR_HEIGHT; i++) {
|
||||
msk = mskLine;
|
||||
src = srcLine;
|
||||
mskLine += src_stride;
|
||||
srcLine += src_stride;
|
||||
for (j = 0; j < SIS_CURSOR_WIDTH / 8; j++) {
|
||||
|
||||
unsigned short m, s;
|
||||
|
||||
if (i < h && j < src_width)
|
||||
{
|
||||
m = *msk++;
|
||||
s = *src++ & m;
|
||||
m = ~m;
|
||||
/* mask off right side */
|
||||
if (j == src_width - 1 && (bits->width & 7))
|
||||
{
|
||||
m |= 0xff << (bits->width & 7);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m = 0xff;
|
||||
s = 0x00;
|
||||
}
|
||||
|
||||
/*
|
||||
* The SIS530 HW cursor format is: source(AND) bit,
|
||||
* then a mask(XOR) bit, etc.
|
||||
* byte swapping in sis530 is:
|
||||
* abcd ==> cdab
|
||||
*/
|
||||
|
||||
#define bit(a,n) (((a) >> (n)) & 0x1)
|
||||
|
||||
r = ((bit(m, 0) << 7) | (bit(s, 0) << 6) |
|
||||
(bit(m, 1) << 5) | (bit(s, 1) << 4) |
|
||||
(bit(m, 2) << 3) | (bit(s, 2) << 2) |
|
||||
(bit(m, 3) << 1) | (bit(s, 3) << 0) |
|
||||
(bit(m, 4) << 15) | (bit(s, 4) << 14) |
|
||||
(bit(m, 5) << 13) | (bit(s, 5) << 12) |
|
||||
(bit(m, 6) << 11) | (bit(s, 6) << 10) |
|
||||
(bit(m, 7) << 9) | (bit(s, 7) << 8));
|
||||
|
||||
*ram++ = r;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set new color */
|
||||
_sisSetCursorColors (pScreen);
|
||||
|
||||
/* Move to new position */
|
||||
_sisMoveCursor (pScreen, x, y);
|
||||
|
||||
/* Enable cursor */
|
||||
sr6 = GetSrtc (sisc, 0x6);
|
||||
sr6 |= 0x40;
|
||||
PutSrtc (sisc, 0x6, sr6);
|
||||
|
||||
UnlockSis(sisc);
|
||||
}
|
||||
|
||||
static void
|
||||
sisUnloadCursor (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CARD8 sr6;
|
||||
|
||||
LockSis (sisc);
|
||||
|
||||
/* Disable cursor */
|
||||
sr6 = GetSrtc (sisc, 0x6);
|
||||
sr6 &= ~0x40;
|
||||
PutSrtc (sisc, 0x6, sr6);
|
||||
PutSrtc (sisc, 0x1b, 0x00);
|
||||
|
||||
UnlockSis (sisc);
|
||||
}
|
||||
|
||||
static Bool
|
||||
sisRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return TRUE;
|
||||
|
||||
/* miRecolorCursor does this */
|
||||
if (pCurPriv->pCursor == pCursor)
|
||||
{
|
||||
if (pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
sisLoadCursor (pScreen, x, y);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
sisUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
sisSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCursor)
|
||||
sisLoadCursor (pScreen, x, y);
|
||||
else
|
||||
sisUnloadCursor (pScreen);
|
||||
}
|
||||
|
||||
miPointerSpriteFuncRec sisPointerSpriteFuncs = {
|
||||
sisRealizeCursor,
|
||||
sisUnrealizeCursor,
|
||||
sisSetCursor,
|
||||
sisMoveCursor,
|
||||
};
|
||||
|
||||
static void
|
||||
sisQueryBestSize (int class,
|
||||
unsigned short *pwidth, unsigned short *pheight,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case CursorShape:
|
||||
if (*pwidth > pCurPriv->width)
|
||||
*pwidth = pCurPriv->width;
|
||||
if (*pheight > pCurPriv->height)
|
||||
*pheight = pCurPriv->height;
|
||||
if (*pwidth > pScreen->width)
|
||||
*pwidth = pScreen->width;
|
||||
if (*pheight > pScreen->height)
|
||||
*pheight = pScreen->height;
|
||||
break;
|
||||
default:
|
||||
fbQueryBestSize (class, pwidth, pheight, pScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
sisCursorInit (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!siss->cursor_base)
|
||||
{
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pCurPriv->width = SIS_CURSOR_WIDTH;
|
||||
pCurPriv->height= SIS_CURSOR_HEIGHT;
|
||||
pScreen->QueryBestSize = sisQueryBestSize;
|
||||
miPointerInitialize (pScreen,
|
||||
&sisPointerSpriteFuncs,
|
||||
&kdPointerScreenFuncs,
|
||||
FALSE);
|
||||
pCurPriv->has_cursor = TRUE;
|
||||
pCurPriv->pCursor = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
sisCursorEnable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
sisLoadCursor (pScreen, x, y);
|
||||
}
|
||||
else
|
||||
sisUnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sisCursorDisable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
sisUnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sisCursorFini (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
pCurPriv->pCursor = NULL;
|
||||
}
|
1656
hw/kdrive/sis530/sisdraw.c
Normal file
1656
hw/kdrive/sis530/sisdraw.c
Normal file
File diff suppressed because it is too large
Load Diff
183
hw/kdrive/sis530/sisdraw.h
Normal file
183
hw/kdrive/sis530/sisdraw.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _SISDRAW_H_
|
||||
#define _SISDRAW_H_
|
||||
|
||||
#define SetupSis(s) KdScreenPriv(s); \
|
||||
sisCardInfo(pScreenPriv); \
|
||||
SisPtr sis = sisc->sis
|
||||
|
||||
#define SIS_CMD_BITBLT (0)
|
||||
#define SIS_CMD_COLOR_EXPAND (1)
|
||||
#define SIS_CMD_ENH_COLOR_EXPAND (2)
|
||||
#define SIS_CMD_MULTI_SCANLINE (3)
|
||||
#define SIS_CMD_LINE (4)
|
||||
#define SIS_CMD_TRAPEZOID (5)
|
||||
#define SIS_CMD_TRANSPARENT_BITBLT (6)
|
||||
|
||||
#define SIS_CMD_SRC_SCREEN (0 << 4)
|
||||
#define SIS_CMD_SRC_CPU (1 << 4)
|
||||
|
||||
#define SIS_CMD_PAT_FG (0 << 6)
|
||||
#define SIS_CMD_PAT_PATTERN (1 << 6)
|
||||
#define SIS_CMD_PAT_MONO (2 << 6)
|
||||
|
||||
/* 8->15 rop */
|
||||
|
||||
#define SIS_CMD_DEC_X (0 << 16)
|
||||
#define SIS_CMD_INC_X (1 << 16)
|
||||
|
||||
#define SIS_CMD_DEC_Y (0 << 17)
|
||||
#define SIS_CMD_INC_Y (1 << 17)
|
||||
|
||||
#define SIS_CMD_RECT_CLIP_DISABLE (0 << 18)
|
||||
#define SIS_CMD_RECT_CLIP_ENABLE (1 << 18)
|
||||
|
||||
#define SIS_CMD_OPAQUE (0 << 20)
|
||||
#define SIS_CMD_TRANSPARENT (1 << 20)
|
||||
|
||||
#define SIS_CMD_RECT_CLIP_MERGE (0 << 26)
|
||||
#define SIS_CMD_RECT_CLIP_DONT_MERGE (1 << 26)
|
||||
|
||||
#define SIS_STAT_2D_IDLE (1 << 31)
|
||||
#define SIS_STAT_3D_IDLE (1 << 30)
|
||||
#define SIS_STAT_EMPTY (1 << 29)
|
||||
#define SIS_STAT_CPU_BITBLT (0xf << 24)
|
||||
#define SIS_STAT_ENH_COLOR_EXPAND (1 << 23)
|
||||
#define SIS_STAT_AVAIL (0x1fff)
|
||||
|
||||
extern CARD8 sisPatRop[16];
|
||||
extern CARD8 sisBltRop[16];
|
||||
|
||||
#define _sisSetSolidRect(sis,pix,alu,cmd) {\
|
||||
(sis)->u.general.pattern_fg = (pix); \
|
||||
(cmd) = (SIS_CMD_BITBLT | \
|
||||
SIS_CMD_SRC_SCREEN | \
|
||||
SIS_CMD_PAT_FG | \
|
||||
(sisPatRop[alu] << 8) | \
|
||||
SIS_CMD_INC_X | \
|
||||
SIS_CMD_INC_Y | \
|
||||
SIS_CMD_RECT_CLIP_DISABLE | \
|
||||
SIS_CMD_OPAQUE | \
|
||||
SIS_CMD_RECT_CLIP_DONT_MERGE); \
|
||||
}
|
||||
|
||||
#define _sisClip(sis,x1,y1,x2,y2) { \
|
||||
(sis)->u.general.clip_left = (x1); \
|
||||
(sis)->u.general.clip_top = (y1); \
|
||||
(sis)->u.general.clip_right = (x2); \
|
||||
(sis)->u.general.clip_bottom = (y2); \
|
||||
}
|
||||
|
||||
#define _sisRect(sis,x,y,w,h,cmd) { \
|
||||
(sis)->u.general.dst_x = (x); \
|
||||
(sis)->u.general.dst_y = (y); \
|
||||
(sis)->u.general.rect_width = (w); \
|
||||
(sis)->u.general.rect_height = (h); \
|
||||
(sis)->u.general.command = (cmd); \
|
||||
}
|
||||
|
||||
#define _sisSetTransparentPlaneBlt(sis, alu, fg, cmd) { \
|
||||
(sis)->u.general.src_fg = (fg); \
|
||||
(cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
|
||||
SIS_CMD_SRC_CPU | \
|
||||
SIS_CMD_PAT_FG | \
|
||||
(sisBltRop[alu] << 8) | \
|
||||
SIS_CMD_INC_X | \
|
||||
SIS_CMD_INC_Y | \
|
||||
SIS_CMD_RECT_CLIP_DISABLE | \
|
||||
SIS_CMD_TRANSPARENT | \
|
||||
SIS_CMD_RECT_CLIP_DONT_MERGE); \
|
||||
}
|
||||
|
||||
#define _sisSetOpaquePlaneBlt(sis, alu, fg, bg, cmd) { \
|
||||
(sis)->u.general.src_fg = (fg); \
|
||||
(sis)->u.general.src_bg = (bg); \
|
||||
(cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
|
||||
SIS_CMD_SRC_CPU | \
|
||||
SIS_CMD_PAT_FG | \
|
||||
(sisBltRop[alu] << 8) | \
|
||||
SIS_CMD_INC_X | \
|
||||
SIS_CMD_INC_Y | \
|
||||
SIS_CMD_RECT_CLIP_DISABLE | \
|
||||
SIS_CMD_OPAQUE | \
|
||||
SIS_CMD_RECT_CLIP_DONT_MERGE); \
|
||||
}
|
||||
|
||||
#define _sisPlaneBlt(sis,x,y,w,h,cmd) _sisSolidRect(sis,x,y,w,h,cmd)
|
||||
|
||||
#define _sisSetBlt(sis,alu,cmd) { \
|
||||
(sis)->u.general.src_base = (sis)->u.general.dst_base; \
|
||||
(sis)->u.general.src_pitch = (sis)->u.general.dst_pitch; \
|
||||
(cmd) = (SIS_CMD_RECT_CLIP_DONT_MERGE |\
|
||||
(sisBltRop[alu] << 8) |\
|
||||
SIS_CMD_PAT_FG |\
|
||||
SIS_CMD_SRC_SCREEN |\
|
||||
SIS_CMD_BITBLT); \
|
||||
}
|
||||
|
||||
#define _sisBlt(sis,sx,sy,dx,dy,w,h,cmd) { \
|
||||
(sis)->u.general.src_x = (sx); \
|
||||
(sis)->u.general.src_y = (sy); \
|
||||
(sis)->u.general.dst_x = (dx); \
|
||||
(sis)->u.general.dst_y = (dy); \
|
||||
(sis)->u.general.rect_width = (w); \
|
||||
(sis)->u.general.rect_height = (h); \
|
||||
(sis)->u.general.command = (cmd); \
|
||||
}
|
||||
|
||||
#define SIS_IE (SIS_STAT_2D_IDLE|SIS_STAT_EMPTY)
|
||||
|
||||
#define _sisWaitIdleEmpty(sis) \
|
||||
while (((sis)->u.general.status & SIS_IE) != SIS_IE)
|
||||
|
||||
/*
|
||||
* Ok, so the Sis530 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 SisInvertBits32(v) { \
|
||||
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
|
||||
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
|
||||
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
|
||||
}
|
||||
|
||||
#define SisInvertBits16(v) { \
|
||||
v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
|
||||
v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
|
||||
v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
|
||||
}
|
||||
|
||||
#define SisInvertBits8(v) { \
|
||||
v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
|
||||
v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
|
||||
v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
|
||||
}
|
||||
|
||||
#endif
|
30
hw/kdrive/sis530/sisio.c
Normal file
30
hw/kdrive/sis530/sisio.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifdef linux
|
||||
#define extern
|
||||
#include <asm/io.h>
|
||||
#undef extern
|
||||
#endif
|
53
hw/kdrive/sis530/sisstub.c
Normal file
53
hw/kdrive/sis530/sisstub.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "sis.h"
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
if (LinuxFindPci (0x1039, 0x6306, 0, &attr))
|
||||
KdCardInfoAdd (&sisFuncs, &attr, 0);
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
231
hw/kdrive/src/kcmap.c
Normal file
231
hw/kdrive/src/kcmap.c
Normal file
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
|
||||
/*
|
||||
* Put the entire colormap into the DAC
|
||||
*/
|
||||
|
||||
void
|
||||
KdSetColormap (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
ColormapPtr pCmap = pScreenPriv->pInstalledmap;
|
||||
Pixel pixels[KD_MAX_PSEUDO_SIZE];
|
||||
xrgb colors[KD_MAX_PSEUDO_SIZE];
|
||||
xColorItem defs[KD_MAX_PSEUDO_SIZE];
|
||||
int i;
|
||||
|
||||
if (!pScreenPriv->card->cfuncs->putColors)
|
||||
return;
|
||||
if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (!pCmap)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Make DIX convert pixels into RGB values -- this handles
|
||||
* true/direct as well as pseudo/static visuals
|
||||
*/
|
||||
|
||||
for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
|
||||
pixels[i] = i;
|
||||
|
||||
QueryColors (pCmap, (1 << pScreenPriv->screen->depth), pixels, colors);
|
||||
|
||||
for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
|
||||
{
|
||||
defs[i].pixel = i;
|
||||
defs[i].red = colors[i].red;
|
||||
defs[i].green = colors[i].green;
|
||||
defs[i].blue = colors[i].blue;
|
||||
defs[i].flags = DoRed|DoGreen|DoBlue;
|
||||
}
|
||||
|
||||
(*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen,
|
||||
(1 << pScreenPriv->screen->depth),
|
||||
defs);
|
||||
|
||||
/* recolor hardware cursor */
|
||||
if (pScreenPriv->card->cfuncs->recolorCursor)
|
||||
(*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* When the hardware is enabled, save the hardware colors and store
|
||||
* the current colormap
|
||||
*/
|
||||
void
|
||||
KdEnableColormap (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
int i;
|
||||
|
||||
if (!pScreenPriv->card->cfuncs->putColors)
|
||||
return;
|
||||
if (pScreenPriv->screen->depth <= KD_MAX_PSEUDO_DEPTH)
|
||||
{
|
||||
for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
|
||||
pScreenPriv->systemPalette[i].pixel = i;
|
||||
(*pScreenPriv->card->cfuncs->getColors) (pScreen,
|
||||
(1 << pScreenPriv->screen->depth),
|
||||
pScreenPriv->systemPalette);
|
||||
}
|
||||
KdSetColormap (pScreen);
|
||||
}
|
||||
|
||||
void
|
||||
KdDisableColormap (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
|
||||
if (!pScreenPriv->card->cfuncs->putColors)
|
||||
return;
|
||||
if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
|
||||
return;
|
||||
|
||||
(*pScreenPriv->card->cfuncs->putColors) (pScreen,
|
||||
(1 << pScreenPriv->screen->depth),
|
||||
pScreenPriv->systemPalette);
|
||||
}
|
||||
|
||||
/*
|
||||
* KdInstallColormap
|
||||
*
|
||||
* This function is called when the server receives a request to install a
|
||||
* colormap or when the server needs to install one on its own, like when
|
||||
* there's no window manager running and the user has moved the pointer over
|
||||
* an X client window. It needs to build an identity Windows palette for the
|
||||
* colormap and realize it into the Windows system palette.
|
||||
*/
|
||||
void
|
||||
KdInstallColormap (ColormapPtr pCmap)
|
||||
{
|
||||
KdScreenPriv(pCmap->pScreen);
|
||||
|
||||
if (pCmap == pScreenPriv->pInstalledmap)
|
||||
return;
|
||||
|
||||
/* Tell X clients that the installed colormap is going away. */
|
||||
if (pScreenPriv->pInstalledmap)
|
||||
WalkTree(pScreenPriv->pInstalledmap->pScreen, TellLostMap,
|
||||
(pointer) &(pScreenPriv->pInstalledmap->mid));
|
||||
|
||||
/* Take note of the new installed colorscreen-> */
|
||||
pScreenPriv->pInstalledmap = pCmap;
|
||||
|
||||
KdSetColormap (pCmap->pScreen);
|
||||
|
||||
/* Tell X clients of the new colorscreen-> */
|
||||
WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid));
|
||||
}
|
||||
|
||||
/*
|
||||
* KdUninstallColormap
|
||||
*
|
||||
* This function uninstalls a colormap by installing the default X colorscreen->
|
||||
* The default X colormap itself cannot be uninstalled.
|
||||
*/
|
||||
void
|
||||
KdUninstallColormap (ColormapPtr pCmap)
|
||||
{
|
||||
KdScreenPriv(pCmap->pScreen);
|
||||
|
||||
if (pCmap == pScreenPriv->pInstalledmap)
|
||||
{
|
||||
Colormap defMapID = pCmap->pScreen->defColormap;
|
||||
|
||||
if ((Colormap) pCmap->mid != defMapID)
|
||||
{
|
||||
ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
|
||||
RT_COLORMAP);
|
||||
if (defMap)
|
||||
(*pCmap->pScreen->InstallColormap)(defMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
|
||||
if (pScreenPriv->pInstalledmap)
|
||||
{
|
||||
*pCmaps = pScreenPriv->pInstalledmap->mid;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* KdStoreColors
|
||||
*
|
||||
* This function is called whenever the server receives a request to store
|
||||
* color values into one or more entries in the currently installed X
|
||||
* colormap; it can be either the default colormap or a private colorscreen->
|
||||
*/
|
||||
void
|
||||
KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs)
|
||||
{
|
||||
KdScreenPriv(pCmap->pScreen);
|
||||
VisualPtr pVisual;
|
||||
xColorItem expanddefs[KD_MAX_PSEUDO_SIZE];
|
||||
|
||||
if (pCmap != pScreenPriv->pInstalledmap)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->card->cfuncs->putColors)
|
||||
return;
|
||||
|
||||
if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
/* Check for DirectColor or TrueColor being simulated on a PseudoColor device. */
|
||||
pVisual = pCmap->pVisual;
|
||||
if ((pVisual->class | DynamicClass) == DirectColor)
|
||||
{
|
||||
/*
|
||||
* Expand DirectColor or TrueColor color values into a PseudoColor
|
||||
* format. Defer to the Color Framebuffer (CFB) code to do that.
|
||||
*/
|
||||
ndef = fbExpandDirectColors(pCmap, ndef, pdefs, expanddefs);
|
||||
pdefs = expanddefs;
|
||||
}
|
||||
|
||||
(*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, ndef, pdefs);
|
||||
|
||||
/* recolor hardware cursor */
|
||||
if (pScreenPriv->card->cfuncs->recolorCursor)
|
||||
(*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, ndef, pdefs);
|
||||
}
|
883
hw/kdrive/src/kcolor.c
Normal file
883
hw/kdrive/src/kcolor.c
Normal file
|
@ -0,0 +1,883 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
/* $XConsortium: oscolor.c,v 1.23 94/04/17 20:27:04 dpw Exp $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
#include <stdio.h>
|
||||
#include "os.h"
|
||||
#include "opaque.h"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
unsigned char
|
||||
KdToLower (unsigned char a)
|
||||
{
|
||||
if ((a >= XK_A) && (a <= XK_Z))
|
||||
return a + (XK_a - XK_A);
|
||||
else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis))
|
||||
return a + (XK_agrave - XK_Agrave);
|
||||
else if ((a >= XK_Ooblique) && (a <= XK_Thorn))
|
||||
return a + (XK_oslash - XK_Ooblique);
|
||||
else
|
||||
return a;
|
||||
}
|
||||
|
||||
int
|
||||
KdStrCaseCmp (unsigned char *s1, unsigned char *s2, int l2)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c1 = KdToLower (*s1++);
|
||||
if (l2 == 0)
|
||||
c2 = '\0';
|
||||
else
|
||||
c2 = KdToLower (*s2++);
|
||||
if (!c1 || !c2)
|
||||
break;
|
||||
if (c1 != c2)
|
||||
break;
|
||||
l2--;
|
||||
}
|
||||
return c2 - c1;
|
||||
}
|
||||
|
||||
typedef struct _kdNamedColor {
|
||||
unsigned short red;
|
||||
unsigned short green;
|
||||
unsigned short blue;
|
||||
unsigned char *name;
|
||||
} KdNamedColor;
|
||||
|
||||
#define C 0x101
|
||||
|
||||
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",
|
||||
250*C, 235*C, 215*C, "AntiqueWhite",
|
||||
255*C, 239*C, 219*C, "AntiqueWhite1",
|
||||
238*C, 223*C, 204*C, "AntiqueWhite2",
|
||||
205*C, 192*C, 176*C, "AntiqueWhite3",
|
||||
139*C, 131*C, 120*C, "AntiqueWhite4",
|
||||
127*C, 255*C, 212*C, "aquamarine",
|
||||
127*C, 255*C, 212*C, "aquamarine1",
|
||||
118*C, 238*C, 198*C, "aquamarine2",
|
||||
102*C, 205*C, 170*C, "aquamarine3",
|
||||
69*C, 139*C, 116*C, "aquamarine4",
|
||||
240*C, 255*C, 255*C, "azure",
|
||||
240*C, 255*C, 255*C, "azure1",
|
||||
224*C, 238*C, 238*C, "azure2",
|
||||
193*C, 205*C, 205*C, "azure3",
|
||||
131*C, 139*C, 139*C, "azure4",
|
||||
245*C, 245*C, 220*C, "beige",
|
||||
255*C, 228*C, 196*C, "bisque",
|
||||
255*C, 228*C, 196*C, "bisque1",
|
||||
238*C, 213*C, 183*C, "bisque2",
|
||||
205*C, 183*C, 158*C, "bisque3",
|
||||
139*C, 125*C, 107*C, "bisque4",
|
||||
0*C, 0*C, 0*C, "black",
|
||||
255*C, 235*C, 205*C, "blanched almond",
|
||||
255*C, 235*C, 205*C, "BlanchedAlmond",
|
||||
0*C, 0*C, 255*C, "blue",
|
||||
138*C, 43*C, 226*C, "blue violet",
|
||||
0*C, 0*C, 255*C, "blue1",
|
||||
0*C, 0*C, 238*C, "blue2",
|
||||
0*C, 0*C, 205*C, "blue3",
|
||||
0*C, 0*C, 139*C, "blue4",
|
||||
138*C, 43*C, 226*C, "BlueViolet",
|
||||
165*C, 42*C, 42*C, "brown",
|
||||
255*C, 64*C, 64*C, "brown1",
|
||||
238*C, 59*C, 59*C, "brown2",
|
||||
205*C, 51*C, 51*C, "brown3",
|
||||
139*C, 35*C, 35*C, "brown4",
|
||||
222*C, 184*C, 135*C, "burlywood",
|
||||
255*C, 211*C, 155*C, "burlywood1",
|
||||
238*C, 197*C, 145*C, "burlywood2",
|
||||
205*C, 170*C, 125*C, "burlywood3",
|
||||
139*C, 115*C, 85*C, "burlywood4",
|
||||
95*C, 158*C, 160*C, "cadet blue",
|
||||
95*C, 158*C, 160*C, "CadetBlue",
|
||||
152*C, 245*C, 255*C, "CadetBlue1",
|
||||
142*C, 229*C, 238*C, "CadetBlue2",
|
||||
122*C, 197*C, 205*C, "CadetBlue3",
|
||||
83*C, 134*C, 139*C, "CadetBlue4",
|
||||
127*C, 255*C, 0*C, "chartreuse",
|
||||
127*C, 255*C, 0*C, "chartreuse1",
|
||||
118*C, 238*C, 0*C, "chartreuse2",
|
||||
102*C, 205*C, 0*C, "chartreuse3",
|
||||
69*C, 139*C, 0*C, "chartreuse4",
|
||||
210*C, 105*C, 30*C, "chocolate",
|
||||
255*C, 127*C, 36*C, "chocolate1",
|
||||
238*C, 118*C, 33*C, "chocolate2",
|
||||
205*C, 102*C, 29*C, "chocolate3",
|
||||
139*C, 69*C, 19*C, "chocolate4",
|
||||
255*C, 127*C, 80*C, "coral",
|
||||
255*C, 114*C, 86*C, "coral1",
|
||||
238*C, 106*C, 80*C, "coral2",
|
||||
205*C, 91*C, 69*C, "coral3",
|
||||
139*C, 62*C, 47*C, "coral4",
|
||||
100*C, 149*C, 237*C, "cornflower blue",
|
||||
100*C, 149*C, 237*C, "CornflowerBlue",
|
||||
255*C, 248*C, 220*C, "cornsilk",
|
||||
255*C, 248*C, 220*C, "cornsilk1",
|
||||
238*C, 232*C, 205*C, "cornsilk2",
|
||||
205*C, 200*C, 177*C, "cornsilk3",
|
||||
139*C, 136*C, 120*C, "cornsilk4",
|
||||
0*C, 255*C, 255*C, "cyan",
|
||||
0*C, 255*C, 255*C, "cyan1",
|
||||
0*C, 238*C, 238*C, "cyan2",
|
||||
0*C, 205*C, 205*C, "cyan3",
|
||||
0*C, 139*C, 139*C, "cyan4",
|
||||
0*C, 0*C, 139*C, "dark blue",
|
||||
0*C, 139*C, 139*C, "dark cyan",
|
||||
184*C, 134*C, 11*C, "dark goldenrod",
|
||||
169*C, 169*C, 169*C, "dark gray",
|
||||
0*C, 100*C, 0*C, "dark green",
|
||||
169*C, 169*C, 169*C, "dark grey",
|
||||
189*C, 183*C, 107*C, "dark khaki",
|
||||
139*C, 0*C, 139*C, "dark magenta",
|
||||
85*C, 107*C, 47*C, "dark olive green",
|
||||
255*C, 140*C, 0*C, "dark orange",
|
||||
153*C, 50*C, 204*C, "dark orchid",
|
||||
139*C, 0*C, 0*C, "dark red",
|
||||
233*C, 150*C, 122*C, "dark salmon",
|
||||
143*C, 188*C, 143*C, "dark sea green",
|
||||
72*C, 61*C, 139*C, "dark slate blue",
|
||||
47*C, 79*C, 79*C, "dark slate gray",
|
||||
47*C, 79*C, 79*C, "dark slate grey",
|
||||
0*C, 206*C, 209*C, "dark turquoise",
|
||||
148*C, 0*C, 211*C, "dark violet",
|
||||
0*C, 0*C, 139*C, "DarkBlue",
|
||||
0*C, 139*C, 139*C, "DarkCyan",
|
||||
184*C, 134*C, 11*C, "DarkGoldenrod",
|
||||
255*C, 185*C, 15*C, "DarkGoldenrod1",
|
||||
238*C, 173*C, 14*C, "DarkGoldenrod2",
|
||||
205*C, 149*C, 12*C, "DarkGoldenrod3",
|
||||
139*C, 101*C, 8*C, "DarkGoldenrod4",
|
||||
169*C, 169*C, 169*C, "DarkGray",
|
||||
0*C, 100*C, 0*C, "DarkGreen",
|
||||
169*C, 169*C, 169*C, "DarkGrey",
|
||||
189*C, 183*C, 107*C, "DarkKhaki",
|
||||
139*C, 0*C, 139*C, "DarkMagenta",
|
||||
85*C, 107*C, 47*C, "DarkOliveGreen",
|
||||
202*C, 255*C, 112*C, "DarkOliveGreen1",
|
||||
188*C, 238*C, 104*C, "DarkOliveGreen2",
|
||||
162*C, 205*C, 90*C, "DarkOliveGreen3",
|
||||
110*C, 139*C, 61*C, "DarkOliveGreen4",
|
||||
255*C, 140*C, 0*C, "DarkOrange",
|
||||
255*C, 127*C, 0*C, "DarkOrange1",
|
||||
238*C, 118*C, 0*C, "DarkOrange2",
|
||||
205*C, 102*C, 0*C, "DarkOrange3",
|
||||
139*C, 69*C, 0*C, "DarkOrange4",
|
||||
153*C, 50*C, 204*C, "DarkOrchid",
|
||||
191*C, 62*C, 255*C, "DarkOrchid1",
|
||||
178*C, 58*C, 238*C, "DarkOrchid2",
|
||||
154*C, 50*C, 205*C, "DarkOrchid3",
|
||||
104*C, 34*C, 139*C, "DarkOrchid4",
|
||||
139*C, 0*C, 0*C, "DarkRed",
|
||||
233*C, 150*C, 122*C, "DarkSalmon",
|
||||
143*C, 188*C, 143*C, "DarkSeaGreen",
|
||||
193*C, 255*C, 193*C, "DarkSeaGreen1",
|
||||
180*C, 238*C, 180*C, "DarkSeaGreen2",
|
||||
155*C, 205*C, 155*C, "DarkSeaGreen3",
|
||||
105*C, 139*C, 105*C, "DarkSeaGreen4",
|
||||
72*C, 61*C, 139*C, "DarkSlateBlue",
|
||||
47*C, 79*C, 79*C, "DarkSlateGray",
|
||||
151*C, 255*C, 255*C, "DarkSlateGray1",
|
||||
141*C, 238*C, 238*C, "DarkSlateGray2",
|
||||
121*C, 205*C, 205*C, "DarkSlateGray3",
|
||||
82*C, 139*C, 139*C, "DarkSlateGray4",
|
||||
47*C, 79*C, 79*C, "DarkSlateGrey",
|
||||
0*C, 206*C, 209*C, "DarkTurquoise",
|
||||
148*C, 0*C, 211*C, "DarkViolet",
|
||||
255*C, 20*C, 147*C, "deep pink",
|
||||
0*C, 191*C, 255*C, "deep sky blue",
|
||||
255*C, 20*C, 147*C, "DeepPink",
|
||||
255*C, 20*C, 147*C, "DeepPink1",
|
||||
238*C, 18*C, 137*C, "DeepPink2",
|
||||
205*C, 16*C, 118*C, "DeepPink3",
|
||||
139*C, 10*C, 80*C, "DeepPink4",
|
||||
0*C, 191*C, 255*C, "DeepSkyBlue",
|
||||
0*C, 191*C, 255*C, "DeepSkyBlue1",
|
||||
0*C, 178*C, 238*C, "DeepSkyBlue2",
|
||||
0*C, 154*C, 205*C, "DeepSkyBlue3",
|
||||
0*C, 104*C, 139*C, "DeepSkyBlue4",
|
||||
105*C, 105*C, 105*C, "dim gray",
|
||||
105*C, 105*C, 105*C, "dim grey",
|
||||
105*C, 105*C, 105*C, "DimGray",
|
||||
105*C, 105*C, 105*C, "DimGrey",
|
||||
30*C, 144*C, 255*C, "dodger blue",
|
||||
30*C, 144*C, 255*C, "DodgerBlue",
|
||||
30*C, 144*C, 255*C, "DodgerBlue1",
|
||||
28*C, 134*C, 238*C, "DodgerBlue2",
|
||||
24*C, 116*C, 205*C, "DodgerBlue3",
|
||||
16*C, 78*C, 139*C, "DodgerBlue4",
|
||||
178*C, 34*C, 34*C, "firebrick",
|
||||
255*C, 48*C, 48*C, "firebrick1",
|
||||
238*C, 44*C, 44*C, "firebrick2",
|
||||
205*C, 38*C, 38*C, "firebrick3",
|
||||
139*C, 26*C, 26*C, "firebrick4",
|
||||
255*C, 250*C, 240*C, "floral white",
|
||||
255*C, 250*C, 240*C, "FloralWhite",
|
||||
34*C, 139*C, 34*C, "forest green",
|
||||
34*C, 139*C, 34*C, "ForestGreen",
|
||||
220*C, 220*C, 220*C, "gainsboro",
|
||||
248*C, 248*C, 255*C, "ghost white",
|
||||
248*C, 248*C, 255*C, "GhostWhite",
|
||||
255*C, 215*C, 0*C, "gold",
|
||||
255*C, 215*C, 0*C, "gold1",
|
||||
238*C, 201*C, 0*C, "gold2",
|
||||
205*C, 173*C, 0*C, "gold3",
|
||||
139*C, 117*C, 0*C, "gold4",
|
||||
218*C, 165*C, 32*C, "goldenrod",
|
||||
255*C, 193*C, 37*C, "goldenrod1",
|
||||
238*C, 180*C, 34*C, "goldenrod2",
|
||||
205*C, 155*C, 29*C, "goldenrod3",
|
||||
139*C, 105*C, 20*C, "goldenrod4",
|
||||
190*C, 190*C, 190*C, "gray",
|
||||
0*C, 0*C, 0*C, "gray0",
|
||||
3*C, 3*C, 3*C, "gray1",
|
||||
26*C, 26*C, 26*C, "gray10",
|
||||
255*C, 255*C, 255*C, "gray100",
|
||||
28*C, 28*C, 28*C, "gray11",
|
||||
31*C, 31*C, 31*C, "gray12",
|
||||
33*C, 33*C, 33*C, "gray13",
|
||||
36*C, 36*C, 36*C, "gray14",
|
||||
38*C, 38*C, 38*C, "gray15",
|
||||
41*C, 41*C, 41*C, "gray16",
|
||||
43*C, 43*C, 43*C, "gray17",
|
||||
46*C, 46*C, 46*C, "gray18",
|
||||
48*C, 48*C, 48*C, "gray19",
|
||||
5*C, 5*C, 5*C, "gray2",
|
||||
51*C, 51*C, 51*C, "gray20",
|
||||
54*C, 54*C, 54*C, "gray21",
|
||||
56*C, 56*C, 56*C, "gray22",
|
||||
59*C, 59*C, 59*C, "gray23",
|
||||
61*C, 61*C, 61*C, "gray24",
|
||||
64*C, 64*C, 64*C, "gray25",
|
||||
66*C, 66*C, 66*C, "gray26",
|
||||
69*C, 69*C, 69*C, "gray27",
|
||||
71*C, 71*C, 71*C, "gray28",
|
||||
74*C, 74*C, 74*C, "gray29",
|
||||
8*C, 8*C, 8*C, "gray3",
|
||||
77*C, 77*C, 77*C, "gray30",
|
||||
79*C, 79*C, 79*C, "gray31",
|
||||
82*C, 82*C, 82*C, "gray32",
|
||||
84*C, 84*C, 84*C, "gray33",
|
||||
87*C, 87*C, 87*C, "gray34",
|
||||
89*C, 89*C, 89*C, "gray35",
|
||||
92*C, 92*C, 92*C, "gray36",
|
||||
94*C, 94*C, 94*C, "gray37",
|
||||
97*C, 97*C, 97*C, "gray38",
|
||||
99*C, 99*C, 99*C, "gray39",
|
||||
10*C, 10*C, 10*C, "gray4",
|
||||
102*C, 102*C, 102*C, "gray40",
|
||||
105*C, 105*C, 105*C, "gray41",
|
||||
107*C, 107*C, 107*C, "gray42",
|
||||
110*C, 110*C, 110*C, "gray43",
|
||||
112*C, 112*C, 112*C, "gray44",
|
||||
115*C, 115*C, 115*C, "gray45",
|
||||
117*C, 117*C, 117*C, "gray46",
|
||||
120*C, 120*C, 120*C, "gray47",
|
||||
122*C, 122*C, 122*C, "gray48",
|
||||
125*C, 125*C, 125*C, "gray49",
|
||||
13*C, 13*C, 13*C, "gray5",
|
||||
127*C, 127*C, 127*C, "gray50",
|
||||
130*C, 130*C, 130*C, "gray51",
|
||||
133*C, 133*C, 133*C, "gray52",
|
||||
135*C, 135*C, 135*C, "gray53",
|
||||
138*C, 138*C, 138*C, "gray54",
|
||||
140*C, 140*C, 140*C, "gray55",
|
||||
143*C, 143*C, 143*C, "gray56",
|
||||
145*C, 145*C, 145*C, "gray57",
|
||||
148*C, 148*C, 148*C, "gray58",
|
||||
150*C, 150*C, 150*C, "gray59",
|
||||
15*C, 15*C, 15*C, "gray6",
|
||||
153*C, 153*C, 153*C, "gray60",
|
||||
156*C, 156*C, 156*C, "gray61",
|
||||
158*C, 158*C, 158*C, "gray62",
|
||||
161*C, 161*C, 161*C, "gray63",
|
||||
163*C, 163*C, 163*C, "gray64",
|
||||
166*C, 166*C, 166*C, "gray65",
|
||||
168*C, 168*C, 168*C, "gray66",
|
||||
171*C, 171*C, 171*C, "gray67",
|
||||
173*C, 173*C, 173*C, "gray68",
|
||||
176*C, 176*C, 176*C, "gray69",
|
||||
18*C, 18*C, 18*C, "gray7",
|
||||
179*C, 179*C, 179*C, "gray70",
|
||||
181*C, 181*C, 181*C, "gray71",
|
||||
184*C, 184*C, 184*C, "gray72",
|
||||
186*C, 186*C, 186*C, "gray73",
|
||||
189*C, 189*C, 189*C, "gray74",
|
||||
191*C, 191*C, 191*C, "gray75",
|
||||
194*C, 194*C, 194*C, "gray76",
|
||||
196*C, 196*C, 196*C, "gray77",
|
||||
199*C, 199*C, 199*C, "gray78",
|
||||
201*C, 201*C, 201*C, "gray79",
|
||||
20*C, 20*C, 20*C, "gray8",
|
||||
204*C, 204*C, 204*C, "gray80",
|
||||
207*C, 207*C, 207*C, "gray81",
|
||||
209*C, 209*C, 209*C, "gray82",
|
||||
212*C, 212*C, 212*C, "gray83",
|
||||
214*C, 214*C, 214*C, "gray84",
|
||||
217*C, 217*C, 217*C, "gray85",
|
||||
219*C, 219*C, 219*C, "gray86",
|
||||
222*C, 222*C, 222*C, "gray87",
|
||||
224*C, 224*C, 224*C, "gray88",
|
||||
227*C, 227*C, 227*C, "gray89",
|
||||
23*C, 23*C, 23*C, "gray9",
|
||||
229*C, 229*C, 229*C, "gray90",
|
||||
232*C, 232*C, 232*C, "gray91",
|
||||
235*C, 235*C, 235*C, "gray92",
|
||||
237*C, 237*C, 237*C, "gray93",
|
||||
240*C, 240*C, 240*C, "gray94",
|
||||
242*C, 242*C, 242*C, "gray95",
|
||||
245*C, 245*C, 245*C, "gray96",
|
||||
247*C, 247*C, 247*C, "gray97",
|
||||
250*C, 250*C, 250*C, "gray98",
|
||||
252*C, 252*C, 252*C, "gray99",
|
||||
0*C, 255*C, 0*C, "green",
|
||||
173*C, 255*C, 47*C, "green yellow",
|
||||
0*C, 255*C, 0*C, "green1",
|
||||
0*C, 238*C, 0*C, "green2",
|
||||
0*C, 205*C, 0*C, "green3",
|
||||
0*C, 139*C, 0*C, "green4",
|
||||
173*C, 255*C, 47*C, "GreenYellow",
|
||||
190*C, 190*C, 190*C, "grey",
|
||||
0*C, 0*C, 0*C, "grey0",
|
||||
3*C, 3*C, 3*C, "grey1",
|
||||
26*C, 26*C, 26*C, "grey10",
|
||||
255*C, 255*C, 255*C, "grey100",
|
||||
28*C, 28*C, 28*C, "grey11",
|
||||
31*C, 31*C, 31*C, "grey12",
|
||||
33*C, 33*C, 33*C, "grey13",
|
||||
36*C, 36*C, 36*C, "grey14",
|
||||
38*C, 38*C, 38*C, "grey15",
|
||||
41*C, 41*C, 41*C, "grey16",
|
||||
43*C, 43*C, 43*C, "grey17",
|
||||
46*C, 46*C, 46*C, "grey18",
|
||||
48*C, 48*C, 48*C, "grey19",
|
||||
5*C, 5*C, 5*C, "grey2",
|
||||
51*C, 51*C, 51*C, "grey20",
|
||||
54*C, 54*C, 54*C, "grey21",
|
||||
56*C, 56*C, 56*C, "grey22",
|
||||
59*C, 59*C, 59*C, "grey23",
|
||||
61*C, 61*C, 61*C, "grey24",
|
||||
64*C, 64*C, 64*C, "grey25",
|
||||
66*C, 66*C, 66*C, "grey26",
|
||||
69*C, 69*C, 69*C, "grey27",
|
||||
71*C, 71*C, 71*C, "grey28",
|
||||
74*C, 74*C, 74*C, "grey29",
|
||||
8*C, 8*C, 8*C, "grey3",
|
||||
77*C, 77*C, 77*C, "grey30",
|
||||
79*C, 79*C, 79*C, "grey31",
|
||||
82*C, 82*C, 82*C, "grey32",
|
||||
84*C, 84*C, 84*C, "grey33",
|
||||
87*C, 87*C, 87*C, "grey34",
|
||||
89*C, 89*C, 89*C, "grey35",
|
||||
92*C, 92*C, 92*C, "grey36",
|
||||
94*C, 94*C, 94*C, "grey37",
|
||||
97*C, 97*C, 97*C, "grey38",
|
||||
99*C, 99*C, 99*C, "grey39",
|
||||
10*C, 10*C, 10*C, "grey4",
|
||||
102*C, 102*C, 102*C, "grey40",
|
||||
105*C, 105*C, 105*C, "grey41",
|
||||
107*C, 107*C, 107*C, "grey42",
|
||||
110*C, 110*C, 110*C, "grey43",
|
||||
112*C, 112*C, 112*C, "grey44",
|
||||
115*C, 115*C, 115*C, "grey45",
|
||||
117*C, 117*C, 117*C, "grey46",
|
||||
120*C, 120*C, 120*C, "grey47",
|
||||
122*C, 122*C, 122*C, "grey48",
|
||||
125*C, 125*C, 125*C, "grey49",
|
||||
13*C, 13*C, 13*C, "grey5",
|
||||
127*C, 127*C, 127*C, "grey50",
|
||||
130*C, 130*C, 130*C, "grey51",
|
||||
133*C, 133*C, 133*C, "grey52",
|
||||
135*C, 135*C, 135*C, "grey53",
|
||||
138*C, 138*C, 138*C, "grey54",
|
||||
140*C, 140*C, 140*C, "grey55",
|
||||
143*C, 143*C, 143*C, "grey56",
|
||||
145*C, 145*C, 145*C, "grey57",
|
||||
148*C, 148*C, 148*C, "grey58",
|
||||
150*C, 150*C, 150*C, "grey59",
|
||||
15*C, 15*C, 15*C, "grey6",
|
||||
153*C, 153*C, 153*C, "grey60",
|
||||
156*C, 156*C, 156*C, "grey61",
|
||||
158*C, 158*C, 158*C, "grey62",
|
||||
161*C, 161*C, 161*C, "grey63",
|
||||
163*C, 163*C, 163*C, "grey64",
|
||||
166*C, 166*C, 166*C, "grey65",
|
||||
168*C, 168*C, 168*C, "grey66",
|
||||
171*C, 171*C, 171*C, "grey67",
|
||||
173*C, 173*C, 173*C, "grey68",
|
||||
176*C, 176*C, 176*C, "grey69",
|
||||
18*C, 18*C, 18*C, "grey7",
|
||||
179*C, 179*C, 179*C, "grey70",
|
||||
181*C, 181*C, 181*C, "grey71",
|
||||
184*C, 184*C, 184*C, "grey72",
|
||||
186*C, 186*C, 186*C, "grey73",
|
||||
189*C, 189*C, 189*C, "grey74",
|
||||
191*C, 191*C, 191*C, "grey75",
|
||||
194*C, 194*C, 194*C, "grey76",
|
||||
196*C, 196*C, 196*C, "grey77",
|
||||
199*C, 199*C, 199*C, "grey78",
|
||||
201*C, 201*C, 201*C, "grey79",
|
||||
20*C, 20*C, 20*C, "grey8",
|
||||
204*C, 204*C, 204*C, "grey80",
|
||||
207*C, 207*C, 207*C, "grey81",
|
||||
209*C, 209*C, 209*C, "grey82",
|
||||
212*C, 212*C, 212*C, "grey83",
|
||||
214*C, 214*C, 214*C, "grey84",
|
||||
217*C, 217*C, 217*C, "grey85",
|
||||
219*C, 219*C, 219*C, "grey86",
|
||||
222*C, 222*C, 222*C, "grey87",
|
||||
224*C, 224*C, 224*C, "grey88",
|
||||
227*C, 227*C, 227*C, "grey89",
|
||||
23*C, 23*C, 23*C, "grey9",
|
||||
229*C, 229*C, 229*C, "grey90",
|
||||
232*C, 232*C, 232*C, "grey91",
|
||||
235*C, 235*C, 235*C, "grey92",
|
||||
237*C, 237*C, 237*C, "grey93",
|
||||
240*C, 240*C, 240*C, "grey94",
|
||||
242*C, 242*C, 242*C, "grey95",
|
||||
245*C, 245*C, 245*C, "grey96",
|
||||
247*C, 247*C, 247*C, "grey97",
|
||||
250*C, 250*C, 250*C, "grey98",
|
||||
252*C, 252*C, 252*C, "grey99",
|
||||
240*C, 255*C, 240*C, "honeydew",
|
||||
240*C, 255*C, 240*C, "honeydew1",
|
||||
224*C, 238*C, 224*C, "honeydew2",
|
||||
193*C, 205*C, 193*C, "honeydew3",
|
||||
131*C, 139*C, 131*C, "honeydew4",
|
||||
255*C, 105*C, 180*C, "hot pink",
|
||||
255*C, 105*C, 180*C, "HotPink",
|
||||
255*C, 110*C, 180*C, "HotPink1",
|
||||
238*C, 106*C, 167*C, "HotPink2",
|
||||
205*C, 96*C, 144*C, "HotPink3",
|
||||
139*C, 58*C, 98*C, "HotPink4",
|
||||
205*C, 92*C, 92*C, "indian red",
|
||||
205*C, 92*C, 92*C, "IndianRed",
|
||||
255*C, 106*C, 106*C, "IndianRed1",
|
||||
238*C, 99*C, 99*C, "IndianRed2",
|
||||
205*C, 85*C, 85*C, "IndianRed3",
|
||||
139*C, 58*C, 58*C, "IndianRed4",
|
||||
255*C, 255*C, 240*C, "ivory",
|
||||
255*C, 255*C, 240*C, "ivory1",
|
||||
238*C, 238*C, 224*C, "ivory2",
|
||||
205*C, 205*C, 193*C, "ivory3",
|
||||
139*C, 139*C, 131*C, "ivory4",
|
||||
240*C, 230*C, 140*C, "khaki",
|
||||
255*C, 246*C, 143*C, "khaki1",
|
||||
238*C, 230*C, 133*C, "khaki2",
|
||||
205*C, 198*C, 115*C, "khaki3",
|
||||
139*C, 134*C, 78*C, "khaki4",
|
||||
230*C, 230*C, 250*C, "lavender",
|
||||
255*C, 240*C, 245*C, "lavender blush",
|
||||
255*C, 240*C, 245*C, "LavenderBlush",
|
||||
255*C, 240*C, 245*C, "LavenderBlush1",
|
||||
238*C, 224*C, 229*C, "LavenderBlush2",
|
||||
205*C, 193*C, 197*C, "LavenderBlush3",
|
||||
139*C, 131*C, 134*C, "LavenderBlush4",
|
||||
124*C, 252*C, 0*C, "lawn green",
|
||||
124*C, 252*C, 0*C, "LawnGreen",
|
||||
255*C, 250*C, 205*C, "lemon chiffon",
|
||||
255*C, 250*C, 205*C, "LemonChiffon",
|
||||
255*C, 250*C, 205*C, "LemonChiffon1",
|
||||
238*C, 233*C, 191*C, "LemonChiffon2",
|
||||
205*C, 201*C, 165*C, "LemonChiffon3",
|
||||
139*C, 137*C, 112*C, "LemonChiffon4",
|
||||
173*C, 216*C, 230*C, "light blue",
|
||||
240*C, 128*C, 128*C, "light coral",
|
||||
224*C, 255*C, 255*C, "light cyan",
|
||||
238*C, 221*C, 130*C, "light goldenrod",
|
||||
250*C, 250*C, 210*C, "light goldenrod yellow",
|
||||
211*C, 211*C, 211*C, "light gray",
|
||||
144*C, 238*C, 144*C, "light green",
|
||||
211*C, 211*C, 211*C, "light grey",
|
||||
255*C, 182*C, 193*C, "light pink",
|
||||
255*C, 160*C, 122*C, "light salmon",
|
||||
32*C, 178*C, 170*C, "light sea green",
|
||||
135*C, 206*C, 250*C, "light sky blue",
|
||||
132*C, 112*C, 255*C, "light slate blue",
|
||||
119*C, 136*C, 153*C, "light slate gray",
|
||||
119*C, 136*C, 153*C, "light slate grey",
|
||||
176*C, 196*C, 222*C, "light steel blue",
|
||||
255*C, 255*C, 224*C, "light yellow",
|
||||
173*C, 216*C, 230*C, "LightBlue",
|
||||
191*C, 239*C, 255*C, "LightBlue1",
|
||||
178*C, 223*C, 238*C, "LightBlue2",
|
||||
154*C, 192*C, 205*C, "LightBlue3",
|
||||
104*C, 131*C, 139*C, "LightBlue4",
|
||||
240*C, 128*C, 128*C, "LightCoral",
|
||||
224*C, 255*C, 255*C, "LightCyan",
|
||||
224*C, 255*C, 255*C, "LightCyan1",
|
||||
209*C, 238*C, 238*C, "LightCyan2",
|
||||
180*C, 205*C, 205*C, "LightCyan3",
|
||||
122*C, 139*C, 139*C, "LightCyan4",
|
||||
238*C, 221*C, 130*C, "LightGoldenrod",
|
||||
255*C, 236*C, 139*C, "LightGoldenrod1",
|
||||
238*C, 220*C, 130*C, "LightGoldenrod2",
|
||||
205*C, 190*C, 112*C, "LightGoldenrod3",
|
||||
139*C, 129*C, 76*C, "LightGoldenrod4",
|
||||
250*C, 250*C, 210*C, "LightGoldenrodYellow",
|
||||
211*C, 211*C, 211*C, "LightGray",
|
||||
144*C, 238*C, 144*C, "LightGreen",
|
||||
211*C, 211*C, 211*C, "LightGrey",
|
||||
255*C, 182*C, 193*C, "LightPink",
|
||||
255*C, 174*C, 185*C, "LightPink1",
|
||||
238*C, 162*C, 173*C, "LightPink2",
|
||||
205*C, 140*C, 149*C, "LightPink3",
|
||||
139*C, 95*C, 101*C, "LightPink4",
|
||||
255*C, 160*C, 122*C, "LightSalmon",
|
||||
255*C, 160*C, 122*C, "LightSalmon1",
|
||||
238*C, 149*C, 114*C, "LightSalmon2",
|
||||
205*C, 129*C, 98*C, "LightSalmon3",
|
||||
139*C, 87*C, 66*C, "LightSalmon4",
|
||||
32*C, 178*C, 170*C, "LightSeaGreen",
|
||||
135*C, 206*C, 250*C, "LightSkyBlue",
|
||||
176*C, 226*C, 255*C, "LightSkyBlue1",
|
||||
164*C, 211*C, 238*C, "LightSkyBlue2",
|
||||
141*C, 182*C, 205*C, "LightSkyBlue3",
|
||||
96*C, 123*C, 139*C, "LightSkyBlue4",
|
||||
132*C, 112*C, 255*C, "LightSlateBlue",
|
||||
119*C, 136*C, 153*C, "LightSlateGray",
|
||||
119*C, 136*C, 153*C, "LightSlateGrey",
|
||||
176*C, 196*C, 222*C, "LightSteelBlue",
|
||||
202*C, 225*C, 255*C, "LightSteelBlue1",
|
||||
188*C, 210*C, 238*C, "LightSteelBlue2",
|
||||
162*C, 181*C, 205*C, "LightSteelBlue3",
|
||||
110*C, 123*C, 139*C, "LightSteelBlue4",
|
||||
255*C, 255*C, 224*C, "LightYellow",
|
||||
255*C, 255*C, 224*C, "LightYellow1",
|
||||
238*C, 238*C, 209*C, "LightYellow2",
|
||||
205*C, 205*C, 180*C, "LightYellow3",
|
||||
139*C, 139*C, 122*C, "LightYellow4",
|
||||
50*C, 205*C, 50*C, "lime green",
|
||||
50*C, 205*C, 50*C, "LimeGreen",
|
||||
250*C, 240*C, 230*C, "linen",
|
||||
255*C, 0*C, 255*C, "magenta",
|
||||
255*C, 0*C, 255*C, "magenta1",
|
||||
238*C, 0*C, 238*C, "magenta2",
|
||||
205*C, 0*C, 205*C, "magenta3",
|
||||
139*C, 0*C, 139*C, "magenta4",
|
||||
176*C, 48*C, 96*C, "maroon",
|
||||
255*C, 52*C, 179*C, "maroon1",
|
||||
238*C, 48*C, 167*C, "maroon2",
|
||||
205*C, 41*C, 144*C, "maroon3",
|
||||
139*C, 28*C, 98*C, "maroon4",
|
||||
102*C, 205*C, 170*C, "medium aquamarine",
|
||||
0*C, 0*C, 205*C, "medium blue",
|
||||
186*C, 85*C, 211*C, "medium orchid",
|
||||
147*C, 112*C, 219*C, "medium purple",
|
||||
60*C, 179*C, 113*C, "medium sea green",
|
||||
123*C, 104*C, 238*C, "medium slate blue",
|
||||
0*C, 250*C, 154*C, "medium spring green",
|
||||
72*C, 209*C, 204*C, "medium turquoise",
|
||||
199*C, 21*C, 133*C, "medium violet red",
|
||||
102*C, 205*C, 170*C, "MediumAquamarine",
|
||||
0*C, 0*C, 205*C, "MediumBlue",
|
||||
186*C, 85*C, 211*C, "MediumOrchid",
|
||||
224*C, 102*C, 255*C, "MediumOrchid1",
|
||||
209*C, 95*C, 238*C, "MediumOrchid2",
|
||||
180*C, 82*C, 205*C, "MediumOrchid3",
|
||||
122*C, 55*C, 139*C, "MediumOrchid4",
|
||||
147*C, 112*C, 219*C, "MediumPurple",
|
||||
171*C, 130*C, 255*C, "MediumPurple1",
|
||||
159*C, 121*C, 238*C, "MediumPurple2",
|
||||
137*C, 104*C, 205*C, "MediumPurple3",
|
||||
93*C, 71*C, 139*C, "MediumPurple4",
|
||||
60*C, 179*C, 113*C, "MediumSeaGreen",
|
||||
123*C, 104*C, 238*C, "MediumSlateBlue",
|
||||
0*C, 250*C, 154*C, "MediumSpringGreen",
|
||||
72*C, 209*C, 204*C, "MediumTurquoise",
|
||||
199*C, 21*C, 133*C, "MediumVioletRed",
|
||||
25*C, 25*C, 112*C, "midnight blue",
|
||||
25*C, 25*C, 112*C, "MidnightBlue",
|
||||
245*C, 255*C, 250*C, "mint cream",
|
||||
245*C, 255*C, 250*C, "MintCream",
|
||||
255*C, 228*C, 225*C, "misty rose",
|
||||
255*C, 228*C, 225*C, "MistyRose",
|
||||
255*C, 228*C, 225*C, "MistyRose1",
|
||||
238*C, 213*C, 210*C, "MistyRose2",
|
||||
205*C, 183*C, 181*C, "MistyRose3",
|
||||
139*C, 125*C, 123*C, "MistyRose4",
|
||||
255*C, 228*C, 181*C, "moccasin",
|
||||
255*C, 222*C, 173*C, "navajo white",
|
||||
255*C, 222*C, 173*C, "NavajoWhite",
|
||||
255*C, 222*C, 173*C, "NavajoWhite1",
|
||||
238*C, 207*C, 161*C, "NavajoWhite2",
|
||||
205*C, 179*C, 139*C, "NavajoWhite3",
|
||||
139*C, 121*C, 94*C, "NavajoWhite4",
|
||||
0*C, 0*C, 128*C, "navy",
|
||||
0*C, 0*C, 128*C, "navy blue",
|
||||
0*C, 0*C, 128*C, "NavyBlue",
|
||||
253*C, 245*C, 230*C, "old lace",
|
||||
253*C, 245*C, 230*C, "OldLace",
|
||||
107*C, 142*C, 35*C, "olive drab",
|
||||
107*C, 142*C, 35*C, "OliveDrab",
|
||||
192*C, 255*C, 62*C, "OliveDrab1",
|
||||
179*C, 238*C, 58*C, "OliveDrab2",
|
||||
154*C, 205*C, 50*C, "OliveDrab3",
|
||||
105*C, 139*C, 34*C, "OliveDrab4",
|
||||
255*C, 165*C, 0*C, "orange",
|
||||
255*C, 69*C, 0*C, "orange red",
|
||||
255*C, 165*C, 0*C, "orange1",
|
||||
238*C, 154*C, 0*C, "orange2",
|
||||
205*C, 133*C, 0*C, "orange3",
|
||||
139*C, 90*C, 0*C, "orange4",
|
||||
255*C, 69*C, 0*C, "OrangeRed",
|
||||
255*C, 69*C, 0*C, "OrangeRed1",
|
||||
238*C, 64*C, 0*C, "OrangeRed2",
|
||||
205*C, 55*C, 0*C, "OrangeRed3",
|
||||
139*C, 37*C, 0*C, "OrangeRed4",
|
||||
218*C, 112*C, 214*C, "orchid",
|
||||
255*C, 131*C, 250*C, "orchid1",
|
||||
238*C, 122*C, 233*C, "orchid2",
|
||||
205*C, 105*C, 201*C, "orchid3",
|
||||
139*C, 71*C, 137*C, "orchid4",
|
||||
238*C, 232*C, 170*C, "pale goldenrod",
|
||||
152*C, 251*C, 152*C, "pale green",
|
||||
175*C, 238*C, 238*C, "pale turquoise",
|
||||
219*C, 112*C, 147*C, "pale violet red",
|
||||
238*C, 232*C, 170*C, "PaleGoldenrod",
|
||||
152*C, 251*C, 152*C, "PaleGreen",
|
||||
154*C, 255*C, 154*C, "PaleGreen1",
|
||||
144*C, 238*C, 144*C, "PaleGreen2",
|
||||
124*C, 205*C, 124*C, "PaleGreen3",
|
||||
84*C, 139*C, 84*C, "PaleGreen4",
|
||||
175*C, 238*C, 238*C, "PaleTurquoise",
|
||||
187*C, 255*C, 255*C, "PaleTurquoise1",
|
||||
174*C, 238*C, 238*C, "PaleTurquoise2",
|
||||
150*C, 205*C, 205*C, "PaleTurquoise3",
|
||||
102*C, 139*C, 139*C, "PaleTurquoise4",
|
||||
219*C, 112*C, 147*C, "PaleVioletRed",
|
||||
255*C, 130*C, 171*C, "PaleVioletRed1",
|
||||
238*C, 121*C, 159*C, "PaleVioletRed2",
|
||||
205*C, 104*C, 137*C, "PaleVioletRed3",
|
||||
139*C, 71*C, 93*C, "PaleVioletRed4",
|
||||
255*C, 239*C, 213*C, "papaya whip",
|
||||
255*C, 239*C, 213*C, "PapayaWhip",
|
||||
255*C, 218*C, 185*C, "peach puff",
|
||||
255*C, 218*C, 185*C, "PeachPuff",
|
||||
255*C, 218*C, 185*C, "PeachPuff1",
|
||||
238*C, 203*C, 173*C, "PeachPuff2",
|
||||
205*C, 175*C, 149*C, "PeachPuff3",
|
||||
139*C, 119*C, 101*C, "PeachPuff4",
|
||||
205*C, 133*C, 63*C, "peru",
|
||||
255*C, 192*C, 203*C, "pink",
|
||||
255*C, 181*C, 197*C, "pink1",
|
||||
238*C, 169*C, 184*C, "pink2",
|
||||
205*C, 145*C, 158*C, "pink3",
|
||||
139*C, 99*C, 108*C, "pink4",
|
||||
221*C, 160*C, 221*C, "plum",
|
||||
255*C, 187*C, 255*C, "plum1",
|
||||
238*C, 174*C, 238*C, "plum2",
|
||||
205*C, 150*C, 205*C, "plum3",
|
||||
139*C, 102*C, 139*C, "plum4",
|
||||
176*C, 224*C, 230*C, "powder blue",
|
||||
176*C, 224*C, 230*C, "PowderBlue",
|
||||
160*C, 32*C, 240*C, "purple",
|
||||
155*C, 48*C, 255*C, "purple1",
|
||||
145*C, 44*C, 238*C, "purple2",
|
||||
125*C, 38*C, 205*C, "purple3",
|
||||
85*C, 26*C, 139*C, "purple4",
|
||||
255*C, 0*C, 0*C, "red",
|
||||
255*C, 0*C, 0*C, "red1",
|
||||
238*C, 0*C, 0*C, "red2",
|
||||
205*C, 0*C, 0*C, "red3",
|
||||
139*C, 0*C, 0*C, "red4",
|
||||
188*C, 143*C, 143*C, "rosy brown",
|
||||
188*C, 143*C, 143*C, "RosyBrown",
|
||||
255*C, 193*C, 193*C, "RosyBrown1",
|
||||
238*C, 180*C, 180*C, "RosyBrown2",
|
||||
205*C, 155*C, 155*C, "RosyBrown3",
|
||||
139*C, 105*C, 105*C, "RosyBrown4",
|
||||
65*C, 105*C, 225*C, "royal blue",
|
||||
65*C, 105*C, 225*C, "RoyalBlue",
|
||||
72*C, 118*C, 255*C, "RoyalBlue1",
|
||||
67*C, 110*C, 238*C, "RoyalBlue2",
|
||||
58*C, 95*C, 205*C, "RoyalBlue3",
|
||||
39*C, 64*C, 139*C, "RoyalBlue4",
|
||||
139*C, 69*C, 19*C, "saddle brown",
|
||||
139*C, 69*C, 19*C, "SaddleBrown",
|
||||
250*C, 128*C, 114*C, "salmon",
|
||||
255*C, 140*C, 105*C, "salmon1",
|
||||
238*C, 130*C, 98*C, "salmon2",
|
||||
205*C, 112*C, 84*C, "salmon3",
|
||||
139*C, 76*C, 57*C, "salmon4",
|
||||
244*C, 164*C, 96*C, "sandy brown",
|
||||
244*C, 164*C, 96*C, "SandyBrown",
|
||||
46*C, 139*C, 87*C, "sea green",
|
||||
46*C, 139*C, 87*C, "SeaGreen",
|
||||
84*C, 255*C, 159*C, "SeaGreen1",
|
||||
78*C, 238*C, 148*C, "SeaGreen2",
|
||||
67*C, 205*C, 128*C, "SeaGreen3",
|
||||
46*C, 139*C, 87*C, "SeaGreen4",
|
||||
255*C, 245*C, 238*C, "seashell",
|
||||
255*C, 245*C, 238*C, "seashell1",
|
||||
238*C, 229*C, 222*C, "seashell2",
|
||||
205*C, 197*C, 191*C, "seashell3",
|
||||
139*C, 134*C, 130*C, "seashell4",
|
||||
160*C, 82*C, 45*C, "sienna",
|
||||
255*C, 130*C, 71*C, "sienna1",
|
||||
238*C, 121*C, 66*C, "sienna2",
|
||||
205*C, 104*C, 57*C, "sienna3",
|
||||
139*C, 71*C, 38*C, "sienna4",
|
||||
135*C, 206*C, 235*C, "sky blue",
|
||||
135*C, 206*C, 235*C, "SkyBlue",
|
||||
135*C, 206*C, 255*C, "SkyBlue1",
|
||||
126*C, 192*C, 238*C, "SkyBlue2",
|
||||
108*C, 166*C, 205*C, "SkyBlue3",
|
||||
74*C, 112*C, 139*C, "SkyBlue4",
|
||||
106*C, 90*C, 205*C, "slate blue",
|
||||
112*C, 128*C, 144*C, "slate gray",
|
||||
112*C, 128*C, 144*C, "slate grey",
|
||||
106*C, 90*C, 205*C, "SlateBlue",
|
||||
131*C, 111*C, 255*C, "SlateBlue1",
|
||||
122*C, 103*C, 238*C, "SlateBlue2",
|
||||
105*C, 89*C, 205*C, "SlateBlue3",
|
||||
71*C, 60*C, 139*C, "SlateBlue4",
|
||||
112*C, 128*C, 144*C, "SlateGray",
|
||||
198*C, 226*C, 255*C, "SlateGray1",
|
||||
185*C, 211*C, 238*C, "SlateGray2",
|
||||
159*C, 182*C, 205*C, "SlateGray3",
|
||||
108*C, 123*C, 139*C, "SlateGray4",
|
||||
112*C, 128*C, 144*C, "SlateGrey",
|
||||
255*C, 250*C, 250*C, "snow",
|
||||
255*C, 250*C, 250*C, "snow1",
|
||||
238*C, 233*C, 233*C, "snow2",
|
||||
205*C, 201*C, 201*C, "snow3",
|
||||
139*C, 137*C, 137*C, "snow4",
|
||||
0*C, 255*C, 127*C, "spring green",
|
||||
0*C, 255*C, 127*C, "SpringGreen",
|
||||
0*C, 255*C, 127*C, "SpringGreen1",
|
||||
0*C, 238*C, 118*C, "SpringGreen2",
|
||||
0*C, 205*C, 102*C, "SpringGreen3",
|
||||
0*C, 139*C, 69*C, "SpringGreen4",
|
||||
70*C, 130*C, 180*C, "steel blue",
|
||||
70*C, 130*C, 180*C, "SteelBlue",
|
||||
99*C, 184*C, 255*C, "SteelBlue1",
|
||||
92*C, 172*C, 238*C, "SteelBlue2",
|
||||
79*C, 148*C, 205*C, "SteelBlue3",
|
||||
54*C, 100*C, 139*C, "SteelBlue4",
|
||||
210*C, 180*C, 140*C, "tan",
|
||||
255*C, 165*C, 79*C, "tan1",
|
||||
238*C, 154*C, 73*C, "tan2",
|
||||
205*C, 133*C, 63*C, "tan3",
|
||||
139*C, 90*C, 43*C, "tan4",
|
||||
216*C, 191*C, 216*C, "thistle",
|
||||
255*C, 225*C, 255*C, "thistle1",
|
||||
238*C, 210*C, 238*C, "thistle2",
|
||||
205*C, 181*C, 205*C, "thistle3",
|
||||
139*C, 123*C, 139*C, "thistle4",
|
||||
255*C, 99*C, 71*C, "tomato",
|
||||
255*C, 99*C, 71*C, "tomato1",
|
||||
238*C, 92*C, 66*C, "tomato2",
|
||||
205*C, 79*C, 57*C, "tomato3",
|
||||
139*C, 54*C, 38*C, "tomato4",
|
||||
64*C, 224*C, 208*C, "turquoise",
|
||||
0*C, 245*C, 255*C, "turquoise1",
|
||||
0*C, 229*C, 238*C, "turquoise2",
|
||||
0*C, 197*C, 205*C, "turquoise3",
|
||||
0*C, 134*C, 139*C, "turquoise4",
|
||||
238*C, 130*C, 238*C, "violet",
|
||||
208*C, 32*C, 144*C, "violet red",
|
||||
208*C, 32*C, 144*C, "VioletRed",
|
||||
255*C, 62*C, 150*C, "VioletRed1",
|
||||
238*C, 58*C, 140*C, "VioletRed2",
|
||||
205*C, 50*C, 120*C, "VioletRed3",
|
||||
139*C, 34*C, 82*C, "VioletRed4",
|
||||
245*C, 222*C, 179*C, "wheat",
|
||||
255*C, 231*C, 186*C, "wheat1",
|
||||
238*C, 216*C, 174*C, "wheat2",
|
||||
205*C, 186*C, 150*C, "wheat3",
|
||||
139*C, 126*C, 102*C, "wheat4",
|
||||
255*C, 255*C, 255*C, "white",
|
||||
245*C, 245*C, 245*C, "white smoke",
|
||||
245*C, 245*C, 245*C, "WhiteSmoke",
|
||||
255*C, 255*C, 0*C, "yellow",
|
||||
154*C, 205*C, 50*C, "yellow green",
|
||||
255*C, 255*C, 0*C, "yellow1",
|
||||
238*C, 238*C, 0*C, "yellow2",
|
||||
205*C, 205*C, 0*C, "yellow3",
|
||||
139*C, 139*C, 0*C, "yellow4",
|
||||
154*C, 205*C, 50*C, "YellowGreen",
|
||||
};
|
||||
|
||||
#undef C
|
||||
|
||||
#define NUM_KD_COLORS (sizeof (KdColors) / sizeof (KdColors[0]))
|
||||
|
||||
Bool
|
||||
OsInitColors()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
OsLookupColor(int screen,
|
||||
char *s_name,
|
||||
unsigned int len,
|
||||
unsigned short *pred,
|
||||
unsigned short *pgreen,
|
||||
unsigned short *pblue)
|
||||
{
|
||||
KdNamedColor *c;
|
||||
unsigned char *name = (unsigned char *) s_name;
|
||||
int low, mid, high;
|
||||
int r;
|
||||
|
||||
low = 0;
|
||||
high = NUM_KD_COLORS;
|
||||
while (high - low > 0)
|
||||
{
|
||||
mid = (low + high) / 2;
|
||||
c = &KdColors[mid];
|
||||
r = KdStrCaseCmp (c->name, name, len);
|
||||
if (r == 0)
|
||||
{
|
||||
*pred = c->red;
|
||||
*pgreen = c->green;
|
||||
*pblue = c->blue;
|
||||
return TRUE;
|
||||
}
|
||||
if (r < 0)
|
||||
{
|
||||
if (high == mid)
|
||||
break;
|
||||
high = mid;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (low == mid)
|
||||
break;
|
||||
low = mid;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
872
hw/kdrive/src/kdrive.c
Normal file
872
hw/kdrive/src/kdrive.c
Normal file
|
@ -0,0 +1,872 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
#include <mivalidate.h>
|
||||
#include <dixstruct.h>
|
||||
|
||||
CARD8 kdBpp[] = { 1, 4, 8, 16, 24, 32 };
|
||||
|
||||
#define NUM_KD_BPP (sizeof (kdBpp) / sizeof (kdBpp[0]))
|
||||
|
||||
int kdScreenPrivateIndex;
|
||||
unsigned long kdGeneration;
|
||||
|
||||
Bool kdVideoTest;
|
||||
unsigned long kdVideoTestTime;
|
||||
Bool kdEmulateMiddleButton;
|
||||
Bool kdDisableZaphod;
|
||||
Bool kdEnabled;
|
||||
Bool kdSwitchPending;
|
||||
|
||||
void (*restoreHardware)(void);
|
||||
|
||||
/*
|
||||
* Carry arguments from InitOutput through driver initialization
|
||||
* to KdScreenInit
|
||||
*/
|
||||
|
||||
KdOsFuncs *kdOsFuncs;
|
||||
extern WindowPtr *WindowTable;
|
||||
|
||||
void
|
||||
KdSetRootClip (ScreenPtr pScreen, BOOL enable)
|
||||
{
|
||||
WindowPtr pWin = WindowTable[pScreen->myNum];
|
||||
WindowPtr pChild;
|
||||
Bool WasViewable = (Bool)(pWin->viewable);
|
||||
Bool anyMarked;
|
||||
RegionPtr pOldClip, bsExposed;
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
Bool dosave = FALSE;
|
||||
#endif
|
||||
WindowPtr pLayerWin;
|
||||
BoxRec box;
|
||||
|
||||
if (WasViewable)
|
||||
{
|
||||
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
|
||||
{
|
||||
(void) (*pScreen->MarkOverlappedWindows)(pChild,
|
||||
pChild,
|
||||
&pLayerWin);
|
||||
}
|
||||
(*pScreen->MarkWindow) (pWin);
|
||||
anyMarked = TRUE;
|
||||
if (pWin->valdata)
|
||||
{
|
||||
if (HasBorder (pWin))
|
||||
{
|
||||
RegionPtr borderVisible;
|
||||
|
||||
borderVisible = REGION_CREATE(pScreen, NullBox, 1);
|
||||
REGION_SUBTRACT(pScreen, borderVisible,
|
||||
&pWin->borderClip, &pWin->winSize);
|
||||
pWin->valdata->before.borderVisible = borderVisible;
|
||||
}
|
||||
pWin->valdata->before.resized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable)
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pScreen->width;
|
||||
box.y2 = pScreen->height;
|
||||
REGION_RESET(pScreen, &pWin->borderClip, &box);
|
||||
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
|
||||
}
|
||||
else
|
||||
{
|
||||
REGION_EMPTY(pScreen, &pWin->borderClip);
|
||||
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
|
||||
}
|
||||
|
||||
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
|
||||
|
||||
if (WasViewable)
|
||||
{
|
||||
if (pWin->backStorage)
|
||||
{
|
||||
pOldClip = REGION_CREATE(pScreen, NullBox, 1);
|
||||
REGION_COPY(pScreen, pOldClip, &pWin->clipList);
|
||||
}
|
||||
|
||||
if (pWin->firstChild)
|
||||
{
|
||||
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
|
||||
pWin->firstChild,
|
||||
(WindowPtr *)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*pScreen->MarkWindow) (pWin);
|
||||
anyMarked = TRUE;
|
||||
}
|
||||
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
if (DO_SAVE_UNDERS(pWin))
|
||||
{
|
||||
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
|
||||
}
|
||||
#endif /* DO_SAVE_UNDERS */
|
||||
|
||||
if (anyMarked)
|
||||
(*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
|
||||
}
|
||||
|
||||
if (pWin->backStorage &&
|
||||
((pWin->backingStore == Always) || WasViewable))
|
||||
{
|
||||
if (!WasViewable)
|
||||
pOldClip = &pWin->clipList; /* a convenient empty region */
|
||||
bsExposed = (*pScreen->TranslateBackingStore)
|
||||
(pWin, 0, 0, pOldClip,
|
||||
pWin->drawable.x, pWin->drawable.y);
|
||||
if (WasViewable)
|
||||
REGION_DESTROY(pScreen, pOldClip);
|
||||
if (bsExposed)
|
||||
{
|
||||
RegionPtr valExposed = NullRegion;
|
||||
|
||||
if (pWin->valdata)
|
||||
valExposed = &pWin->valdata->after.exposed;
|
||||
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
|
||||
if (valExposed)
|
||||
REGION_EMPTY(pScreen, valExposed);
|
||||
REGION_DESTROY(pScreen, bsExposed);
|
||||
}
|
||||
}
|
||||
if (WasViewable)
|
||||
{
|
||||
if (anyMarked)
|
||||
(*pScreen->HandleExposures)(pWin);
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
if (dosave)
|
||||
(*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
|
||||
#endif /* DO_SAVE_UNDERS */
|
||||
if (anyMarked && pScreen->PostValidateTree)
|
||||
(*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
|
||||
}
|
||||
if (pWin->realized)
|
||||
WindowsRestructured ();
|
||||
}
|
||||
|
||||
void
|
||||
KdDisableScreen (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
KdSetRootClip (pScreen, FALSE);
|
||||
KdDisableColormap (pScreen);
|
||||
if (!pScreenPriv->screen->dumb)
|
||||
(*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
|
||||
if (!pScreenPriv->screen->softCursor)
|
||||
(*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
|
||||
if (pScreenPriv->card->cfuncs->dpms)
|
||||
(*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
|
||||
pScreenPriv->enabled = FALSE;
|
||||
(*pScreenPriv->card->cfuncs->disable) (pScreen);
|
||||
}
|
||||
|
||||
void
|
||||
KdDisableScreens (void)
|
||||
{
|
||||
KdCardInfo *card;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
if (kdEnabled)
|
||||
{
|
||||
kdEnabled = FALSE;
|
||||
for (card = kdCardInfo; card; card = card->next)
|
||||
{
|
||||
for (screen = card->screenList; screen; screen = screen->next)
|
||||
if (screen->mynum == card->selected && screen->pScreen)
|
||||
KdDisableScreen (screen->pScreen);
|
||||
if (card->driver)
|
||||
(*card->cfuncs->restore) (card);
|
||||
}
|
||||
(*kdOsFuncs->Disable) ();
|
||||
KdDisableInput ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
KdEnableScreen (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv (pScreen);
|
||||
|
||||
if (pScreenPriv->enabled)
|
||||
return;
|
||||
(*pScreenPriv->card->cfuncs->enable) (pScreen);
|
||||
pScreenPriv->enabled = TRUE;
|
||||
pScreenPriv->card->selected = pScreenPriv->screen->mynum;
|
||||
if (!pScreenPriv->screen->softCursor)
|
||||
(*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
|
||||
if (!pScreenPriv->screen->dumb)
|
||||
(*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
|
||||
KdEnableColormap (pScreen);
|
||||
KdSetRootClip (pScreen, TRUE);
|
||||
if (pScreenPriv->card->cfuncs->dpms)
|
||||
(*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
|
||||
}
|
||||
|
||||
void
|
||||
KdEnableScreens (void)
|
||||
{
|
||||
KdCardInfo *card;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
if (!kdEnabled)
|
||||
{
|
||||
kdEnabled = TRUE;
|
||||
(*kdOsFuncs->Enable) ();
|
||||
for (card = kdCardInfo; card; card = card->next)
|
||||
{
|
||||
(*card->cfuncs->preserve) (card);
|
||||
for (screen = card->screenList; screen; screen = screen->next)
|
||||
if (screen->mynum == card->selected && screen->pScreen)
|
||||
KdEnableScreen (screen->pScreen);
|
||||
}
|
||||
KdEnableInput ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
KdProcessSwitch (void)
|
||||
{
|
||||
if (kdEnabled)
|
||||
KdDisableScreens ();
|
||||
else
|
||||
{
|
||||
KdReleaseAllKeys ();
|
||||
KdEnableScreens ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX(void)
|
||||
{
|
||||
KdDisableScreens ();
|
||||
if (kdOsFuncs)
|
||||
{
|
||||
if (kdEnabled)
|
||||
(*kdOsFuncs->Disable) ();
|
||||
(*kdOsFuncs->Fini) ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp ()
|
||||
{
|
||||
AbortDDX ();
|
||||
}
|
||||
|
||||
void
|
||||
KdParseScreen (KdScreenInfo *screen,
|
||||
char *arg)
|
||||
{
|
||||
screen->width = 0;
|
||||
screen->height = 0;
|
||||
screen->depth = 0;
|
||||
screen->rate = 0;
|
||||
if (!arg)
|
||||
return;
|
||||
|
||||
screen->width = atoi(arg);
|
||||
arg = strchr (arg, 'x');
|
||||
if (!arg)
|
||||
return;
|
||||
arg++;
|
||||
|
||||
screen->height = atoi(arg);
|
||||
arg = strchr (arg, 'x');
|
||||
if (!arg)
|
||||
return;
|
||||
arg++;
|
||||
|
||||
screen->depth = atoi(arg);
|
||||
arg = strchr (arg, 'x');
|
||||
if (!arg)
|
||||
return;
|
||||
arg++;
|
||||
|
||||
screen->rate = atoi(arg);
|
||||
arg = strchr (arg, 'x');
|
||||
if (!arg)
|
||||
return;
|
||||
arg++;
|
||||
}
|
||||
|
||||
Bool kdDumbDriver;
|
||||
Bool kdSoftCursor;
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc, char **argv, int i)
|
||||
{
|
||||
KdCardInfo *card;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
if (!strcmp (argv[i], "-card"))
|
||||
{
|
||||
if ((i+1) < argc)
|
||||
InitCard (argv[i+1]);
|
||||
else
|
||||
UseMsg ();
|
||||
return 2;
|
||||
}
|
||||
if (!strcmp (argv[i], "-screen"))
|
||||
{
|
||||
if ((i+1) < argc)
|
||||
{
|
||||
card = KdCardInfoLast ();
|
||||
if (!card)
|
||||
{
|
||||
InitCard (0);
|
||||
card = KdCardInfoLast ();
|
||||
}
|
||||
screen = KdScreenInfoAdd (card);
|
||||
KdParseScreen (screen, argv[i+1]);
|
||||
screen->dumb = kdDumbDriver;
|
||||
screen->softCursor = kdSoftCursor;
|
||||
kdDumbDriver = FALSE;
|
||||
kdSoftCursor = FALSE;
|
||||
}
|
||||
else
|
||||
UseMsg ();
|
||||
return 2;
|
||||
}
|
||||
if (!strcmp (argv[i], "-zaphod"))
|
||||
{
|
||||
kdDisableZaphod = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-3button"))
|
||||
{
|
||||
kdEmulateMiddleButton = FALSE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-2button"))
|
||||
{
|
||||
kdEmulateMiddleButton = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-dumb"))
|
||||
{
|
||||
kdDumbDriver = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-softCursor"))
|
||||
{
|
||||
kdSoftCursor = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-videoTest"))
|
||||
{
|
||||
kdVideoTest = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-standalone"))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* These are getting tossed in here until I can think of where
|
||||
* they really belong
|
||||
*/
|
||||
|
||||
void
|
||||
KdOsInit (KdOsFuncs *pOsFuncs)
|
||||
{
|
||||
kdOsFuncs = pOsFuncs;
|
||||
if (pOsFuncs)
|
||||
{
|
||||
if (serverGeneration == 1)
|
||||
(*pOsFuncs->Init) ();
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
KdAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
KdPrivScreenPtr pScreenPriv;
|
||||
|
||||
if (kdGeneration != serverGeneration)
|
||||
{
|
||||
kdScreenPrivateIndex = AllocateScreenPrivateIndex();
|
||||
kdGeneration = serverGeneration;
|
||||
}
|
||||
pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv));
|
||||
memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec));
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
KdSetScreenPriv (pScreen, pScreenPriv);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
KdCloseScreen (int index, ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
KdScreenInfo *screen = pScreenPriv->screen;
|
||||
KdCardInfo *card = pScreenPriv->card;
|
||||
Bool ret;
|
||||
|
||||
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
||||
ret = (*pScreen->CloseScreen) (index, pScreen);
|
||||
|
||||
if (pScreenPriv->dpmsState != KD_DPMS_NORMAL)
|
||||
(*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
|
||||
|
||||
if (screen->mynum == card->selected)
|
||||
KdDisableScreen (pScreen);
|
||||
|
||||
/*
|
||||
* Restore video hardware when last screen is closed
|
||||
*/
|
||||
if (screen == card->screenList)
|
||||
(*card->cfuncs->restore) (card);
|
||||
|
||||
if (!pScreenPriv->screen->dumb)
|
||||
(*card->cfuncs->finiAccel) (pScreen);
|
||||
|
||||
if (!pScreenPriv->screen->softCursor)
|
||||
(*card->cfuncs->finiCursor) (pScreen);
|
||||
|
||||
(*card->cfuncs->scrfini) (screen);
|
||||
|
||||
/*
|
||||
* Clean up card when last screen is closed, DIX closes them in
|
||||
* reverse order, thus we check for when the first in the list is closed
|
||||
*/
|
||||
if (screen == card->screenList)
|
||||
{
|
||||
(*card->cfuncs->cardfini) (card);
|
||||
/*
|
||||
* Clean up OS when last card is closed
|
||||
*/
|
||||
if (card == kdCardInfo)
|
||||
{
|
||||
if (kdEnabled)
|
||||
{
|
||||
kdEnabled = FALSE;
|
||||
(*kdOsFuncs->Disable) ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pScreenPriv->screen->pScreen = 0;
|
||||
|
||||
xfree ((pointer) pScreenPriv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bool
|
||||
KdSaveScreen (ScreenPtr pScreen, int on)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
int dpmsState;
|
||||
|
||||
if (!pScreenPriv->card->cfuncs->dpms)
|
||||
return FALSE;
|
||||
|
||||
dpmsState = pScreenPriv->dpmsState;
|
||||
switch (on) {
|
||||
case SCREEN_SAVER_OFF:
|
||||
dpmsState = KD_DPMS_NORMAL;
|
||||
break;
|
||||
case SCREEN_SAVER_ON:
|
||||
if (dpmsState == KD_DPMS_NORMAL)
|
||||
dpmsState = KD_DPMS_NORMAL+1;
|
||||
break;
|
||||
case SCREEN_SAVER_CYCLE:
|
||||
if (dpmsState < KD_DPMS_MAX)
|
||||
dpmsState++;
|
||||
break;
|
||||
case SCREEN_SAVER_FORCER:
|
||||
break;
|
||||
}
|
||||
if (dpmsState != pScreenPriv->dpmsState)
|
||||
{
|
||||
if (pScreenPriv->enabled)
|
||||
(*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
|
||||
pScreenPriv->dpmsState = dpmsState;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
KdCreateWindow (WindowPtr pWin)
|
||||
{
|
||||
if (!pWin->parent)
|
||||
{
|
||||
KdScreenPriv(pWin->drawable.pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
{
|
||||
REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip);
|
||||
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Pass through AddScreen, which doesn't take any closure */
|
||||
static KdScreenInfo *kdCurrentScreen;
|
||||
|
||||
Bool
|
||||
KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
|
||||
{
|
||||
KdScreenInfo *screen = kdCurrentScreen;
|
||||
KdCardInfo *card = screen->card;
|
||||
KdPrivScreenPtr pScreenPriv;
|
||||
|
||||
KdAllocatePrivates (pScreen);
|
||||
|
||||
pScreenPriv = KdGetScreenPriv(pScreen);
|
||||
|
||||
screen->pScreen = pScreen;
|
||||
pScreenPriv->screen = screen;
|
||||
pScreenPriv->card = card;
|
||||
pScreenPriv->bytesPerPixel = screen->bitsPerPixel >> 3;
|
||||
pScreenPriv->dpmsState = KD_DPMS_NORMAL;
|
||||
|
||||
/*
|
||||
* This is done in this order so that backing store wraps
|
||||
* our GC functions; fbFinishScreenInit initializes MI
|
||||
* backing store
|
||||
*/
|
||||
if (!fbSetupScreen (pScreen,
|
||||
screen->frameBuffer,
|
||||
screen->width, screen->height,
|
||||
screen->dpix, screen->dpiy,
|
||||
screen->pixelStride,
|
||||
screen->bitsPerPixel))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set colormap functions
|
||||
*/
|
||||
pScreen->InstallColormap = KdInstallColormap;
|
||||
pScreen->UninstallColormap = KdUninstallColormap;
|
||||
pScreen->ListInstalledColormaps = KdListInstalledColormaps;
|
||||
pScreen->StoreColors = KdStoreColors;
|
||||
|
||||
pScreen->SaveScreen = KdSaveScreen;
|
||||
pScreen->CreateWindow = KdCreateWindow;
|
||||
|
||||
if (!screen->dumb && card->cfuncs->initAccel)
|
||||
if (!(*card->cfuncs->initAccel) (pScreen))
|
||||
screen->dumb = TRUE;
|
||||
|
||||
if (!fbFinishScreenInit (pScreen,
|
||||
screen->frameBuffer,
|
||||
screen->width, screen->height,
|
||||
screen->dpix, screen->dpiy,
|
||||
screen->pixelStride,
|
||||
screen->bitsPerPixel))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Plug in our own block/wakeup handlers.
|
||||
* miScreenInit installs NoopDDA in both places
|
||||
*/
|
||||
pScreen->BlockHandler = KdBlockHandler;
|
||||
pScreen->WakeupHandler = KdWakeupHandler;
|
||||
|
||||
/*
|
||||
* Wrap CloseScreen, the order now is:
|
||||
* KdCloseScreen
|
||||
* miBSCloseScreen
|
||||
* fbCloseScreen
|
||||
*/
|
||||
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
||||
pScreen->CloseScreen = KdCloseScreen;
|
||||
|
||||
if (screen->softCursor ||
|
||||
!card->cfuncs->initCursor ||
|
||||
!(*card->cfuncs->initCursor) (pScreen))
|
||||
{
|
||||
/* Use MI for cursor display and event queueing. */
|
||||
screen->softCursor = TRUE;
|
||||
miDCInitialize(pScreen, &kdPointerScreenFuncs);
|
||||
}
|
||||
|
||||
if (!fbCreateDefColormap (pScreen))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the hardware
|
||||
*/
|
||||
if (!kdEnabled)
|
||||
{
|
||||
kdEnabled = TRUE;
|
||||
(*kdOsFuncs->Enable) ();
|
||||
}
|
||||
|
||||
if (screen->mynum == card->selected)
|
||||
{
|
||||
(*card->cfuncs->preserve) (card);
|
||||
(*card->cfuncs->enable) (pScreen);
|
||||
pScreenPriv->enabled = TRUE;
|
||||
if (!screen->softCursor)
|
||||
(*card->cfuncs->enableCursor) (pScreen);
|
||||
KdEnableColormap (pScreen);
|
||||
if (!screen->dumb)
|
||||
(*card->cfuncs->enableAccel) (pScreen);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
KdInitScreen (ScreenInfo *pScreenInfo,
|
||||
KdScreenInfo *screen,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
KdCardInfo *card = screen->card;
|
||||
int i;
|
||||
|
||||
(*card->cfuncs->scrinit) (screen);
|
||||
|
||||
if (!screen->dpix)
|
||||
screen->dpix = 75;
|
||||
|
||||
if (!screen->dpiy)
|
||||
screen->dpiy = 75;
|
||||
if (!card->cfuncs->initAccel)
|
||||
screen->dumb = TRUE;
|
||||
if (!card->cfuncs->initCursor)
|
||||
screen->softCursor = TRUE;
|
||||
|
||||
}
|
||||
|
||||
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,
|
||||
* also ensure that all screens comply with protocol
|
||||
* restrictions on equivalent formats for the same
|
||||
* depth on different screens
|
||||
*/
|
||||
for (card = kdCardInfo; card; card = card->next)
|
||||
{
|
||||
for (screen = card->screenList; screen; screen = screen->next)
|
||||
{
|
||||
if (!depthToBpp[screen->depth])
|
||||
depthToBpp[screen->depth] = screen->bitsPerPixel;
|
||||
else if (depthToBpp[screen->depth] != screen->bitsPerPixel)
|
||||
return FALSE;
|
||||
if (!bppToDepth[screen->bitsPerPixel])
|
||||
bppToDepth[screen->bitsPerPixel] = screen->depth;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in additional formats
|
||||
*/
|
||||
for (i = 0; i < NUM_KD_BPP; i++)
|
||||
if (!bppToDepth[kdBpp[i]] && !depthToBpp[kdBpp[i]])
|
||||
{
|
||||
bppToDepth[kdBpp[i]] = kdBpp[i];
|
||||
depthToBpp[kdBpp[i]] = kdBpp[i];
|
||||
}
|
||||
|
||||
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
|
||||
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
|
||||
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
|
||||
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
||||
|
||||
pScreenInfo->numPixmapFormats = 0;
|
||||
|
||||
for (i = 1; i <= 32; i++)
|
||||
{
|
||||
if (depthToBpp[i])
|
||||
{
|
||||
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
|
||||
format->depth = i;
|
||||
format->bitsPerPixel = depthToBpp[i];
|
||||
format->scanlinePad = BITMAP_SCANLINE_PAD;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
KdAddScreen (ScreenInfo *pScreenInfo,
|
||||
KdScreenInfo *screen,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
int i;
|
||||
/*
|
||||
* Fill in fb visual type masks for this screen
|
||||
*/
|
||||
for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
|
||||
{
|
||||
unsigned long visuals;
|
||||
Pixel rm, gm, bm;
|
||||
|
||||
if (pScreenInfo->formats[i].depth == screen->depth)
|
||||
{
|
||||
visuals = screen->visuals;
|
||||
rm = screen->redMask;
|
||||
gm = screen->greenMask;
|
||||
bm = screen->blueMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
visuals = 0;
|
||||
rm = gm = bm = 0;
|
||||
}
|
||||
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
|
||||
visuals,
|
||||
8,
|
||||
rm, gm, bm);
|
||||
}
|
||||
|
||||
kdCurrentScreen = screen;
|
||||
|
||||
AddScreen (KdScreenInit, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
KdInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
int i;
|
||||
KdCardInfo *card;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
if (!kdCardInfo)
|
||||
{
|
||||
InitCard (0);
|
||||
card = KdCardInfoLast ();
|
||||
screen = KdScreenInfoAdd (card);
|
||||
KdParseScreen (screen, 0);
|
||||
}
|
||||
/*
|
||||
* Initialize all of the screens for all of the cards
|
||||
*/
|
||||
for (card = kdCardInfo; card; card = card->next)
|
||||
{
|
||||
if ((*card->cfuncs->cardinit) (card))
|
||||
{
|
||||
for (screen = card->screenList; screen; screen = screen->next)
|
||||
KdInitScreen (pScreenInfo, screen, argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge the various pixmap formats together, this can fail
|
||||
* when two screens share depth but not bitsPerPixel
|
||||
*/
|
||||
if (!KdSetPixmapFormats (pScreenInfo))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Add all of the screens
|
||||
*/
|
||||
for (card = kdCardInfo; card; card = card->next)
|
||||
for (screen = card->screenList; screen; screen = screen->next)
|
||||
KdAddScreen (pScreenInfo, screen, argc, argv);
|
||||
}
|
||||
|
||||
#ifdef XTESTEXT1
|
||||
void
|
||||
XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
|
||||
int dev_type;
|
||||
int keycode;
|
||||
int keystate;
|
||||
int mousex;
|
||||
int mousey;
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
XTestGetPointerPos(fmousex, fmousey)
|
||||
short *fmousex, *fmousey;
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
XTestJumpPointer(jx, jy, dev_type)
|
||||
int jx;
|
||||
int jy;
|
||||
int dev_type;
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DPMSExtension
|
||||
void
|
||||
DPMSSet(int level)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
DPMSGet (int *level)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Bool
|
||||
DPMSSupported (void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
362
hw/kdrive/src/kdrive.h
Normal file
362
hw/kdrive/src/kdrive.h
Normal file
|
@ -0,0 +1,362 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "X.h"
|
||||
#define NEED_EVENTS
|
||||
#include "Xproto.h"
|
||||
#include "Xos.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "servermd.h"
|
||||
#include "mibstore.h"
|
||||
#include "colormapst.h"
|
||||
#include "gcstruct.h"
|
||||
#include "input.h"
|
||||
#include "mipointer.h"
|
||||
#include "mi.h"
|
||||
#include "dix.h"
|
||||
#include "fb.h"
|
||||
|
||||
extern WindowPtr *WindowTable;
|
||||
|
||||
#define KD_DPMS_NORMAL 0
|
||||
#define KD_DPMS_STANDBY 1
|
||||
#define KD_DPMS_SUSPEND 2
|
||||
#define KD_DPMS_POWERDOWN 3
|
||||
#define KD_DPMS_MAX KD_DPMS_POWERDOWN
|
||||
|
||||
/*
|
||||
* Configuration information per video card
|
||||
*/
|
||||
#define KD_MAX_CARD_ADDRESS 8
|
||||
typedef struct _KdCardAttr {
|
||||
CARD32 io;
|
||||
CARD32 address[KD_MAX_CARD_ADDRESS];
|
||||
int naddr;
|
||||
} KdCardAttr;
|
||||
|
||||
typedef struct _KdCardInfo {
|
||||
struct _KdCardFuncs *cfuncs;
|
||||
void *closure;
|
||||
KdCardAttr attr;
|
||||
void *driver;
|
||||
struct _KdScreenInfo *screenList;
|
||||
int selected;
|
||||
struct _KdCardInfo *next;
|
||||
} KdCardInfo;
|
||||
|
||||
extern KdCardInfo *kdCardInfo;
|
||||
|
||||
/*
|
||||
* Configuration information per X screen
|
||||
*/
|
||||
typedef struct _KdScreenInfo {
|
||||
struct _KdScreenInfo *next;
|
||||
KdCardInfo *card;
|
||||
ScreenPtr pScreen;
|
||||
void *driver;
|
||||
CARD8 *frameBuffer;
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
int rate;
|
||||
int bitsPerPixel;
|
||||
int pixelStride;
|
||||
int byteStride;
|
||||
int dpix, dpiy;
|
||||
unsigned long visuals;
|
||||
Pixel redMask, greenMask, blueMask;
|
||||
Bool dumb;
|
||||
Bool softCursor;
|
||||
int mynum;
|
||||
} KdScreenInfo;
|
||||
|
||||
typedef struct _KdCardFuncs {
|
||||
Bool (*cardinit) (KdCardInfo *); /* detect and map device */
|
||||
Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
|
||||
void (*preserve) (KdCardInfo *); /* save graphics card state */
|
||||
void (*enable) (ScreenPtr); /* set up for rendering */
|
||||
Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
|
||||
void (*disable) (ScreenPtr); /* turn off rendering */
|
||||
void (*restore) (KdCardInfo *); /* restore graphics card state */
|
||||
void (*scrfini) (KdScreenInfo *);/* close down screen */
|
||||
void (*cardfini) (KdCardInfo *); /* close down */
|
||||
|
||||
Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
|
||||
void (*enableCursor) (ScreenPtr); /* enable cursor */
|
||||
void (*disableCursor) (ScreenPtr); /* disable cursor */
|
||||
void (*finiCursor) (ScreenPtr); /* close down */
|
||||
void (*recolorCursor) (ScreenPtr, int, xColorItem *);
|
||||
|
||||
Bool (*initAccel) (ScreenPtr);
|
||||
void (*enableAccel) (ScreenPtr);
|
||||
void (*disableAccel) (ScreenPtr);
|
||||
void (*finiAccel) (ScreenPtr);
|
||||
|
||||
void (*getColors) (ScreenPtr, int, xColorItem *);
|
||||
void (*putColors) (ScreenPtr, int, xColorItem *);
|
||||
} KdCardFuncs;
|
||||
|
||||
#define KD_MAX_PSEUDO_DEPTH 8
|
||||
#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
|
||||
|
||||
typedef struct {
|
||||
KdScreenInfo *screen;
|
||||
KdCardInfo *card;
|
||||
|
||||
Bool enabled;
|
||||
int bytesPerPixel;
|
||||
|
||||
int dpmsState;
|
||||
|
||||
ColormapPtr pInstalledmap; /* current colormap */
|
||||
xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
|
||||
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
} KdPrivScreenRec, *KdPrivScreenPtr;
|
||||
|
||||
typedef struct _KdMouseFuncs {
|
||||
int (*Init) (void);
|
||||
void (*Read) (int);
|
||||
void (*Fini) (int);
|
||||
} KdMouseFuncs;
|
||||
|
||||
typedef struct _KdKeyboardFuncs {
|
||||
void (*Load) (void);
|
||||
int (*Init) (void);
|
||||
void (*Read) (int);
|
||||
void (*Leds) (int);
|
||||
void (*Bell) (int, int, int);
|
||||
void (*Fini) (int);
|
||||
int LockLed;
|
||||
} KdKeyboardFuncs;
|
||||
|
||||
typedef struct _KdOsFuncs {
|
||||
int (*Init) (void);
|
||||
void (*Enable) (void);
|
||||
Bool (*SpecialKey) (KeySym);
|
||||
void (*Disable) (void);
|
||||
void (*Fini) (void);
|
||||
} KdOsFuncs;
|
||||
|
||||
/*
|
||||
* This is the only completely portable way to
|
||||
* compute this info.
|
||||
*/
|
||||
|
||||
#ifndef BitsPerPixel
|
||||
#define BitsPerPixel(d) (\
|
||||
PixmapWidthPaddingInfo[d].notPower2 ? \
|
||||
(PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
|
||||
((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
|
||||
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
|
||||
#endif
|
||||
|
||||
extern int kdScreenPrivateIndex;
|
||||
extern unsigned long kdGeneration;
|
||||
extern Bool kdEnabled;
|
||||
extern Bool kdSwitchPending;
|
||||
extern Bool kdEmulateMiddleButton;
|
||||
extern Bool kdDisableZaphod;
|
||||
extern KdOsFuncs *kdOsFuncs;
|
||||
|
||||
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
|
||||
(pScreen)->devPrivates[kdScreenPrivateIndex].ptr)
|
||||
#define KdSetScreenPriv(pScreen,v) ((pScreen)->devPrivates[kdScreenPrivateIndex].ptr = \
|
||||
(pointer) v)
|
||||
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
|
||||
|
||||
/* knoop.c */
|
||||
extern GCOps kdNoopOps;
|
||||
|
||||
/* kcmap.c */
|
||||
void
|
||||
KdSetColormap (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
KdEnableColormap (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
KdDisableColormap (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
KdInstallColormap (ColormapPtr pCmap);
|
||||
|
||||
void
|
||||
KdUninstallColormap (ColormapPtr pCmap);
|
||||
|
||||
int
|
||||
KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
|
||||
|
||||
void
|
||||
KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
|
||||
|
||||
/* kdrive.c */
|
||||
extern miPointerScreenFuncRec kdPointerScreenFuncs;
|
||||
|
||||
void
|
||||
KdSetRootClip (ScreenPtr pScreen, BOOL enable);
|
||||
|
||||
void
|
||||
KdDisableScreen (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
KdDisableScreens (void);
|
||||
|
||||
void
|
||||
KdEnableScreen (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
KdEnableScreens (void);
|
||||
|
||||
void
|
||||
KdProcessSwitch (void);
|
||||
|
||||
void
|
||||
KdParseScreen (KdScreenInfo *screen,
|
||||
char *arg);
|
||||
|
||||
void
|
||||
KdOsInit (KdOsFuncs *pOsFuncs);
|
||||
|
||||
Bool
|
||||
KdAllocatePrivates (ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
KdCloseScreen (int index, ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
KdSaveScreen (ScreenPtr pScreen, int on);
|
||||
|
||||
Bool
|
||||
KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
|
||||
|
||||
void
|
||||
KdInitScreen (ScreenInfo *pScreenInfo,
|
||||
KdScreenInfo *screen,
|
||||
int argc,
|
||||
char **argv);
|
||||
|
||||
void
|
||||
KdInitCard (ScreenInfo *pScreenInfo,
|
||||
KdCardInfo *card,
|
||||
int argc,
|
||||
char **argv);
|
||||
|
||||
void
|
||||
KdInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv);
|
||||
|
||||
|
||||
|
||||
void
|
||||
KdInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc, char **argv);
|
||||
|
||||
/* kinfo.c */
|
||||
KdCardInfo *
|
||||
KdCardInfoAdd (KdCardFuncs *funcs,
|
||||
KdCardAttr *attr,
|
||||
void *closure);
|
||||
|
||||
KdCardInfo *
|
||||
KdCardInfoLast (void);
|
||||
|
||||
void
|
||||
KdCardInfoDispose (KdCardInfo *ci);
|
||||
|
||||
KdScreenInfo *
|
||||
KdScreenInfoAdd (KdCardInfo *ci);
|
||||
|
||||
void
|
||||
KdScreenInfoDispose (KdScreenInfo *si);
|
||||
|
||||
|
||||
/* kinput.c */
|
||||
void
|
||||
KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
|
||||
|
||||
void
|
||||
KdEnqueueKeyboardEvent(unsigned char scan_code,
|
||||
unsigned char is_up);
|
||||
|
||||
#define KD_BUTTON_1 0x01
|
||||
#define KD_BUTTON_2 0x02
|
||||
#define KD_BUTTON_3 0x04
|
||||
#define KD_MOUSE_DELTA 0x80000000
|
||||
|
||||
void
|
||||
KdEnqueueMouseEvent(unsigned long flags, int x, int y);
|
||||
|
||||
void
|
||||
KdEnqueueMotionEvent (int x, int y);
|
||||
|
||||
void
|
||||
KdReleaseAllKeys (void);
|
||||
|
||||
void
|
||||
KdSetLed (int led, Bool on);
|
||||
|
||||
void
|
||||
KdBlockHandler (int screen,
|
||||
pointer blockData,
|
||||
pointer timeout,
|
||||
pointer readmask);
|
||||
|
||||
void
|
||||
KdWakeupHandler (int screen,
|
||||
pointer data,
|
||||
unsigned long result,
|
||||
pointer readmask);
|
||||
|
||||
void
|
||||
KdDisableInput (void);
|
||||
|
||||
void
|
||||
KdEnableInput (void);
|
||||
|
||||
void
|
||||
ProcessInputEvents ();
|
||||
|
||||
extern KdMouseFuncs Ps2MouseFuncs;
|
||||
extern KdKeyboardFuncs LinuxKeyboardFuncs;
|
||||
extern KdOsFuncs LinuxFuncs;
|
||||
|
||||
/* kmap.c */
|
||||
void *
|
||||
KdMapDevice (CARD32 addr, CARD32 size);
|
||||
|
||||
void
|
||||
KdUnmapDevice (void *addr, CARD32 size);
|
||||
|
||||
/* ktest.c */
|
||||
Bool
|
||||
KdFrameBufferValid (CARD8 *base, int size);
|
||||
|
||||
int
|
||||
KdFrameBufferSize (CARD8 *base, int max);
|
110
hw/kdrive/src/kinfo.c
Normal file
110
hw/kdrive/src/kinfo.c
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
|
||||
KdCardInfo *kdCardInfo;
|
||||
|
||||
KdCardInfo *
|
||||
KdCardInfoAdd (KdCardFuncs *funcs,
|
||||
KdCardAttr *attr,
|
||||
void *closure)
|
||||
{
|
||||
KdCardInfo *ci, **prev;
|
||||
|
||||
ci = (KdCardInfo *) xalloc (sizeof (KdCardInfo));
|
||||
if (!ci)
|
||||
return 0;
|
||||
bzero (ci, sizeof (KdCardInfo));
|
||||
for (prev = &kdCardInfo; *prev; prev = &(*prev)->next);
|
||||
*prev = ci;
|
||||
ci->cfuncs = funcs;
|
||||
ci->attr = *attr;
|
||||
ci->closure = closure;
|
||||
ci->screenList = 0;
|
||||
ci->selected = 0;
|
||||
ci->next = 0;
|
||||
return ci;
|
||||
}
|
||||
|
||||
KdCardInfo *
|
||||
KdCardInfoLast (void)
|
||||
{
|
||||
KdCardInfo *ci;
|
||||
|
||||
if (!kdCardInfo)
|
||||
return 0;
|
||||
for (ci = kdCardInfo; ci->next; ci = ci->next);
|
||||
return ci;
|
||||
}
|
||||
|
||||
void
|
||||
KdCardInfoDispose (KdCardInfo *ci)
|
||||
{
|
||||
KdCardInfo **prev;
|
||||
|
||||
for (prev = &kdCardInfo; *prev; prev = &(*prev)->next)
|
||||
if (*prev == ci)
|
||||
{
|
||||
*prev = ci->next;
|
||||
xfree (ci);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KdScreenInfo *
|
||||
KdScreenInfoAdd (KdCardInfo *ci)
|
||||
{
|
||||
KdScreenInfo *si, **prev;
|
||||
int n;
|
||||
|
||||
si = (KdScreenInfo *) xalloc (sizeof (KdScreenInfo));
|
||||
if (!si)
|
||||
return 0;
|
||||
bzero (si, sizeof (KdScreenInfo));
|
||||
for (prev = &ci->screenList, n = 0; *prev; prev = &(*prev)->next, n++);
|
||||
*prev = si;
|
||||
si->next = 0;
|
||||
si->card = ci;
|
||||
si->mynum = n;
|
||||
return si;
|
||||
}
|
||||
|
||||
void
|
||||
KdScreenInfoDispose (KdScreenInfo *si)
|
||||
{
|
||||
KdCardInfo *ci = si->card;
|
||||
KdScreenInfo **prev;
|
||||
|
||||
for (prev = &ci->screenList; *prev; prev = &(*prev)->next)
|
||||
if (*prev == si)
|
||||
{
|
||||
*prev = si->next;
|
||||
xfree (si);
|
||||
if (!ci->screenList)
|
||||
KdCardInfoDispose (ci);
|
||||
break;
|
||||
}
|
||||
}
|
1331
hw/kdrive/src/kinput.c
Normal file
1331
hw/kdrive/src/kinput.c
Normal file
File diff suppressed because it is too large
Load Diff
235
hw/kdrive/src/kkeymap.c
Normal file
235
hw/kdrive/src/kkeymap.c
Normal file
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
#include <X11/keysym.h>
|
||||
#include "kkeymap.h"
|
||||
|
||||
/*
|
||||
* Map scan codes (both regular and synthesized from extended keys)
|
||||
* to X keysyms
|
||||
*/
|
||||
|
||||
KeySym kdKeymap[(MAX_SCANCODE - MIN_SCANCODE + 1) * MAX_WIDTH] = {
|
||||
/* These are directly mapped from DOS scanset 0 */
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
/* 4 11 */ XK_3, XK_numbersign,
|
||||
/* 5 12 */ XK_4, XK_dollar,
|
||||
/* 6 13 */ XK_5, XK_percent,
|
||||
/* 7 14 */ XK_6, XK_asciicircum,
|
||||
/* 8 15 */ XK_7, XK_ampersand,
|
||||
/* 9 16 */ XK_8, XK_asterisk,
|
||||
/* 10 17 */ XK_9, XK_parenleft,
|
||||
/* 11 18 */ XK_0, XK_parenright,
|
||||
/* 12 19 */ XK_minus, XK_underscore,
|
||||
/* 13 20 */ XK_equal, XK_plus,
|
||||
/* 14 21 */ XK_BackSpace, NoSymbol,
|
||||
/* 15 22 */ XK_Tab, NoSymbol,
|
||||
/* 16 23 */ XK_Q, NoSymbol,
|
||||
/* 17 24 */ XK_W, NoSymbol,
|
||||
/* 18 25 */ XK_E, NoSymbol,
|
||||
/* 19 26 */ XK_R, NoSymbol,
|
||||
/* 20 27 */ XK_T, NoSymbol,
|
||||
/* 21 28 */ XK_Y, NoSymbol,
|
||||
/* 22 29 */ XK_U, NoSymbol,
|
||||
/* 23 30 */ XK_I, NoSymbol,
|
||||
/* 24 31 */ XK_O, NoSymbol,
|
||||
/* 25 32 */ XK_P, NoSymbol,
|
||||
/* 26 33 */ XK_bracketleft, XK_braceleft,
|
||||
/* 27 34 */ XK_bracketright, XK_braceright,
|
||||
/* 28 35 */ XK_Return, NoSymbol,
|
||||
/* 29 36 */ XK_Control_L, NoSymbol,
|
||||
/* 30 37 */ XK_A, NoSymbol,
|
||||
/* 31 38 */ XK_S, NoSymbol,
|
||||
/* 32 39 */ XK_D, NoSymbol,
|
||||
/* 33 40 */ XK_F, NoSymbol,
|
||||
/* 34 41 */ XK_G, NoSymbol,
|
||||
/* 35 42 */ XK_H, NoSymbol,
|
||||
/* 36 43 */ XK_J, NoSymbol,
|
||||
/* 37 44 */ XK_K, NoSymbol,
|
||||
/* 38 45 */ XK_L, NoSymbol,
|
||||
/* 39 46 */ XK_semicolon, XK_colon,
|
||||
/* 40 47 */ XK_apostrophe, XK_quotedbl,
|
||||
/* 41 48 */ XK_grave, XK_asciitilde,
|
||||
/* 42 49 */ XK_Shift_L, NoSymbol,
|
||||
/* 43 50 */ XK_backslash, XK_bar,
|
||||
/* 44 51 */ XK_Z, NoSymbol,
|
||||
/* 45 52 */ XK_X, NoSymbol,
|
||||
/* 46 53 */ XK_C, NoSymbol,
|
||||
/* 47 54 */ XK_V, NoSymbol,
|
||||
/* 48 55 */ XK_B, NoSymbol,
|
||||
/* 49 56 */ XK_N, NoSymbol,
|
||||
/* 50 57 */ XK_M, NoSymbol,
|
||||
/* 51 58 */ XK_comma, XK_less,
|
||||
/* 52 59 */ XK_period, XK_greater,
|
||||
/* 53 60 */ XK_slash, XK_question,
|
||||
/* 54 61 */ XK_Shift_R, NoSymbol,
|
||||
/* 55 62 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 56 63 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 57 64 */ XK_space, NoSymbol,
|
||||
/* 58 65 */ XK_Caps_Lock, NoSymbol,
|
||||
/* 59 66 */ XK_F1, NoSymbol,
|
||||
/* 60 67 */ XK_F2, NoSymbol,
|
||||
/* 61 68 */ XK_F3, NoSymbol,
|
||||
/* 62 69 */ XK_F4, NoSymbol,
|
||||
/* 63 70 */ XK_F5, NoSymbol,
|
||||
/* 64 71 */ XK_F6, NoSymbol,
|
||||
/* 65 72 */ XK_F7, NoSymbol,
|
||||
/* 66 73 */ XK_F8, NoSymbol,
|
||||
/* 67 74 */ XK_F9, NoSymbol,
|
||||
/* 68 75 */ XK_F10, NoSymbol,
|
||||
/* 69 76 */ XK_Break, XK_Pause,
|
||||
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* 71 78 */ XK_KP_Home, XK_KP_7,
|
||||
/* 72 79 */ XK_KP_Up, XK_KP_8,
|
||||
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
|
||||
/* 74 81 */ XK_KP_Subtract, NoSymbol,
|
||||
/* 75 82 */ XK_KP_Left, XK_KP_4,
|
||||
/* 76 83 */ XK_KP_5, NoSymbol,
|
||||
/* 77 84 */ XK_KP_Right, XK_KP_6,
|
||||
/* 78 85 */ XK_KP_Add, NoSymbol,
|
||||
/* 79 86 */ XK_KP_End, XK_KP_1,
|
||||
/* 80 87 */ XK_KP_Down, XK_KP_2,
|
||||
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
|
||||
/* 82 89 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 84 91 */ NoSymbol, NoSymbol,
|
||||
/* 85 92 */ NoSymbol, NoSymbol,
|
||||
/* 86 93 */ NoSymbol, NoSymbol,
|
||||
/* 87 94 */ XK_F11, NoSymbol,
|
||||
/* 88 95 */ XK_F12, NoSymbol,
|
||||
|
||||
/* These are remapped from the extended set (using ExtendMap) */
|
||||
|
||||
/* 89 96 */ XK_Control_R, NoSymbol,
|
||||
/* 90 97 */ XK_KP_Enter, NoSymbol,
|
||||
/* 91 98 */ XK_KP_Divide, NoSymbol,
|
||||
/* 92 99 */ XK_Sys_Req, XK_Print,
|
||||
/* 93 100 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 94 101 */ XK_Num_Lock, NoSymbol,
|
||||
/* 95 102 */ XK_Home, NoSymbol,
|
||||
/* 96 103 */ XK_Up, NoSymbol,
|
||||
/* 97 104 */ XK_Page_Up, NoSymbol,
|
||||
/* 98 105 */ XK_Left, NoSymbol,
|
||||
/* 99 106 */ XK_Right, NoSymbol,
|
||||
/* 100 107 */ XK_End, NoSymbol,
|
||||
/* 101 108 */ XK_Down, NoSymbol,
|
||||
/* 102 109 */ XK_Page_Down, NoSymbol,
|
||||
/* 103 110 */ XK_Insert, NoSymbol,
|
||||
/* 104 111 */ XK_Delete, NoSymbol,
|
||||
/* 105 112 */ XK_Super_L, NoSymbol,
|
||||
/* 106 113 */ XK_Super_R, NoSymbol,
|
||||
/* 107 114 */ XK_Menu, NoSymbol,
|
||||
/* 108 115 */ NoSymbol, NoSymbol,
|
||||
/* 109 116 */ NoSymbol, NoSymbol,
|
||||
/* 110 117 */ NoSymbol, NoSymbol,
|
||||
/* 111 118 */ NoSymbol, NoSymbol,
|
||||
/* 112 119 */ NoSymbol, NoSymbol,
|
||||
;
|
||||
|
||||
/*
|
||||
* Map extended keys to additional scancodes
|
||||
*/
|
||||
KdExtendMap kdExtendMap[] = {
|
||||
0x1d, 89, /* Control_R */
|
||||
0x1c, 90, /* KP_Enter */
|
||||
0x35, 91, /* KP_Divide */
|
||||
0x37, 92, /* Sys_Req */
|
||||
0x38, 93, /* Alt_R */
|
||||
0x45, 94, /* Num_Lock */
|
||||
0x47, 95, /* Home */
|
||||
0x48, 96, /* Up */
|
||||
0x49, 97, /* Page_Up */
|
||||
0x4b, 98, /* Left */
|
||||
0x4d, 99, /* Right */
|
||||
0x4f, 100, /* End */
|
||||
0x50, 101, /* Down */
|
||||
0x51, 102, /* Page_Down */
|
||||
0x52, 103, /* Insert */
|
||||
0x53, 104, /* Delete */
|
||||
0x5b, 105, /* Super_L (Windows_L) */
|
||||
0x5c, 106, /* Super_R (Windows_R) */
|
||||
0x5d, 107, /* Menu */
|
||||
0x46, 69, /* Break (with control pressed) */
|
||||
};
|
||||
|
||||
#define NUM_EXTEND (sizeof (kdExtendMap)/ sizeof (kdExtendMap[0]))
|
||||
|
||||
int kdNumExtend = NUM_EXTEND;
|
||||
|
||||
/*
|
||||
* Map keys on Japanese keyboard far from zero back to reasonable values
|
||||
*/
|
||||
KdExtendMap kdJapanMap[] = {
|
||||
0x70, 108, /* next to Alt key */
|
||||
0x73, 109, /* dash/vbar */
|
||||
0x79, 110, /* right of space bar */
|
||||
0x7b, 111, /* left of space bar */
|
||||
0x7d, 112, /* Yen */
|
||||
};
|
||||
|
||||
#define NUM_JAPAN (sizeof (kdJapanMap)/sizeof (kdJapanMap[0]))
|
||||
|
||||
int kdNumJapan = NUM_JAPAN;
|
||||
|
||||
/*
|
||||
* List of locking key codes
|
||||
*/
|
||||
|
||||
CARD8 kdLockMap[] = {
|
||||
65,
|
||||
101,
|
||||
77,
|
||||
};
|
||||
|
||||
#define NUM_LOCK (sizeof (kdLockMap) / sizeof (kdLockMap[0]))
|
||||
|
||||
int kdNumLock = NUM_LOCK;
|
||||
|
||||
/*
|
||||
* Map containing list of keys which the X server makes locking when
|
||||
* the KEYMAP_LOCKING_ALTGR flag is set in CEKeymapFlags
|
||||
*/
|
||||
|
||||
CARD8 kdOptionalLockMap[] = {
|
||||
100,
|
||||
};
|
||||
|
||||
#define NUM_OPTIONAL_LOCK (sizeof (kdOptionalLockMap) / sizeof (kdOptionalLockMap[0]))
|
||||
|
||||
int kdNumOptionalLock = NUM_OPTIONAL_LOCK;
|
||||
|
||||
CARD8 kdModMap[MAP_LENGTH];
|
||||
|
||||
unsigned long kdKeymapFlags = 0;
|
||||
|
||||
KeySymsRec kdKeySyms = {
|
||||
kdKeymap,
|
||||
MIN_KEYCODE,
|
||||
MAX_KEYCODE,
|
||||
2
|
||||
};
|
53
hw/kdrive/src/kkeymap.h
Normal file
53
hw/kdrive/src/kkeymap.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
/*
|
||||
* All global variables and functions pertaining to keyboard key mapping
|
||||
* live in this header file.
|
||||
*/
|
||||
|
||||
#ifndef _KDKEYMP_H
|
||||
#define _KDKEYMP_H
|
||||
|
||||
/* Offset of MIN_SCANCODE to 8 (X minimum scancode value) */
|
||||
#define KD_KEY_OFFSET (8 - kdMinScanCode)
|
||||
|
||||
#define KD_MIN_KEYCODE 8
|
||||
#define KD_MAX_KEYCODE 254
|
||||
#define KD_MAX_WIDTH 4
|
||||
#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
|
||||
|
||||
extern int kdMinScanCode;
|
||||
extern int kdMaxScanCode;
|
||||
extern int kdMinKeyCode;
|
||||
extern int kdMaxKeyCode;
|
||||
extern int kdKeymapWidth;
|
||||
|
||||
extern KeySym kdKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH];
|
||||
|
||||
extern CARD8 kdModMap[MAP_LENGTH];
|
||||
|
||||
extern KeySymsRec kdKeySyms;
|
||||
|
||||
#endif /* _WINKEYMP_H */
|
200
hw/kdrive/src/kloadmap.c
Normal file
200
hw/kdrive/src/kloadmap.c
Normal file
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
#include "kkeymap.h"
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define KM_BUF 1024
|
||||
#define KM_EOF -1
|
||||
|
||||
typedef struct _km_file {
|
||||
HANDLE handle;
|
||||
char buf[KM_BUF];
|
||||
char *bufptr;
|
||||
DWORD remain;
|
||||
} km_file;
|
||||
|
||||
int
|
||||
km_fill (km_file *kf)
|
||||
{
|
||||
BOOL r;
|
||||
|
||||
NCD_DEBUG ((DEBUG_INIT, "km_fill"));
|
||||
r = ReadFile (kf->handle, kf->buf, KM_BUF,
|
||||
&kf->remain, NULL);
|
||||
NCD_DEBUG ((DEBUG_INIT, "Got %d", kf->remain));
|
||||
if (!r || !kf->remain)
|
||||
return KM_EOF;
|
||||
kf->bufptr = kf->buf;
|
||||
--kf->remain;
|
||||
return *kf->bufptr++;
|
||||
}
|
||||
|
||||
#define km_getchar(kf) ((kf)->remain-- ? *kf->bufptr++ : km_fill (kf))
|
||||
#else
|
||||
#define km_getchar(kf) getc(kf)
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
km_word (km_file *kf, char *buf, int len)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (c = km_getchar (kf)) {
|
||||
case KM_EOF:
|
||||
return FALSE;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
len--;
|
||||
while (len--)
|
||||
{
|
||||
*buf++ = c;
|
||||
switch (c = km_getchar (kf)) {
|
||||
case KM_EOF:
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
*buf++ = '\0';
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
km_int (km_file *kf, int *r)
|
||||
{
|
||||
char word[64];
|
||||
|
||||
if (km_word (kf, word, sizeof (word)))
|
||||
{
|
||||
*r = strtol (word, NULL, 0);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WCHAR *winKbdExtensions[] = {
|
||||
L".xku",
|
||||
L".xkb"
|
||||
};
|
||||
|
||||
#define NUM_KBD_EXTENSIONS (sizeof (winKbdExtensions) / sizeof (winKbdExtensions[0]))
|
||||
|
||||
BOOL
|
||||
winLoadKeymap (void)
|
||||
{
|
||||
WCHAR file[32 + KL_NAMELENGTH];
|
||||
WCHAR name[KL_NAMELENGTH];
|
||||
HKL layout;
|
||||
km_file kf;
|
||||
int width;
|
||||
BOOL ret;
|
||||
KeySym *m;
|
||||
int scancode;
|
||||
int w;
|
||||
int e;
|
||||
|
||||
layout = GetKeyboardLayout (0);
|
||||
/*
|
||||
* Pre-build 46 versions of ThinSTAR software return 0
|
||||
* for all layouts
|
||||
*/
|
||||
if (!layout)
|
||||
return FALSE;
|
||||
NCD_DEBUG ((DEBUG_INIT, "Keyboard layout 0x%x", layout));
|
||||
for (e = 0; e < NUM_KBD_EXTENSIONS; e++)
|
||||
{
|
||||
wstrcpy (file, L"\\Storage Card\\");
|
||||
wsprintf (name, TEXT("%08x"), layout);
|
||||
wstrcat (file, name);
|
||||
wstrcat (file, winKbdExtensions[e]);
|
||||
NCD_DEBUG ((DEBUG_INIT, "Loading keymap from %S", file));
|
||||
kf.handle = CreateFile (file,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (kf.handle != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
}
|
||||
if (kf.handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
NCD_DEBUG ((DEBUG_INIT, "No such file"));
|
||||
return FALSE;
|
||||
}
|
||||
ret = FALSE;
|
||||
kf.remain = 0;
|
||||
/*
|
||||
* Keymap format:
|
||||
*
|
||||
* flags (optional)
|
||||
* width
|
||||
* keycode -> keysym array (num_keycodes * width)
|
||||
*/
|
||||
if (!km_int (&kf, &width))
|
||||
goto bail1;
|
||||
if (width & KEYMAP_FLAGS)
|
||||
{
|
||||
CEKeymapFlags = (unsigned long) width;
|
||||
if (!km_int (&kf, &width))
|
||||
goto bail1;
|
||||
}
|
||||
else
|
||||
CEKeymapFlags = 0;
|
||||
if (width > MAX_WIDTH)
|
||||
goto bail1;
|
||||
NCD_DEBUG ((DEBUG_INIT, "Keymap width %d flags 0x%x",
|
||||
width, CEKeymapFlags));
|
||||
m = CEKeymap;
|
||||
for (scancode = MIN_SCANCODE; scancode <= MAX_SCANCODE; scancode++)
|
||||
{
|
||||
for (w = 0; w < width; w++)
|
||||
{
|
||||
if (!km_int (&kf, m))
|
||||
break;
|
||||
m++;
|
||||
}
|
||||
if (w != width)
|
||||
break;
|
||||
}
|
||||
CEKeySyms.mapWidth = width;
|
||||
ret = TRUE;
|
||||
bail1:
|
||||
CloseHandle (kf.handle);
|
||||
return ret;
|
||||
}
|
86
hw/kdrive/src/kmap.c
Normal file
86
hw/kdrive/src/kmap.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
|
||||
#ifdef linux
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
void *
|
||||
KdMapDevice (CARD32 addr, CARD32 size)
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
void *a;
|
||||
void *d;
|
||||
|
||||
d = VirtualAlloc (NULL, size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
if (!d)
|
||||
return NULL;
|
||||
DRAW_DEBUG ((DEBUG_S3INIT, "Virtual address of 0x%x is 0x%x", addr, d));
|
||||
a = VirtualCopyAddr (addr);
|
||||
DRAW_DEBUG ((DEBUG_S3INIT, "Translated address is 0x%x", a));
|
||||
if (!VirtualCopy (d, a, size,
|
||||
PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL))
|
||||
{
|
||||
DRAW_DEBUG ((DEBUG_FAILURE, "VirtualCopy failed %d",
|
||||
GetLastError ()));
|
||||
return NULL;
|
||||
}
|
||||
DRAW_DEBUG ((DEBUG_S3INIT, "Device mapped successfully"));
|
||||
return d;
|
||||
#endif
|
||||
#ifdef linux
|
||||
void *a;
|
||||
int fd;
|
||||
|
||||
fd = open ("/dev/mem", O_RDWR);
|
||||
if (fd < 0)
|
||||
FatalError ("KdMapDevice: failed to open /dev/mem (%s)\n",
|
||||
strerror (errno));
|
||||
|
||||
a = mmap ((caddr_t) 0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, addr);
|
||||
close (fd);
|
||||
if ((long) a == -1)
|
||||
FatalError ("KdMapDevice: failed to map frame buffer (%s)\n",
|
||||
strerror (errno));
|
||||
return a;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
KdUnmapDevice (void *addr, CARD32 size)
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
VirtualFree (addr, size, MEM_DECOMMIT);
|
||||
VirtualFree (addr, 0, MEM_RELEASE);
|
||||
#endif
|
||||
#ifdef linux
|
||||
munmap (addr, size);
|
||||
#endif
|
||||
}
|
||||
|
294
hw/kdrive/src/knoop.c
Normal file
294
hw/kdrive/src/knoop.c
Normal file
|
@ -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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
/*
|
||||
* GC ops that don't do anything
|
||||
*/
|
||||
|
||||
#include "kdrive.h"
|
||||
#include <gcstruct.h>
|
||||
|
||||
typedef void (* typeFillSpans)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*nInit*/,
|
||||
DDXPointPtr /*pptInit*/,
|
||||
int * /*pwidthInit*/,
|
||||
int /*fSorted*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typeSetSpans)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
char * /*psrc*/,
|
||||
DDXPointPtr /*ppt*/,
|
||||
int * /*pwidth*/,
|
||||
int /*nspans*/,
|
||||
int /*fSorted*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePutImage)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*depth*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
int /*w*/,
|
||||
int /*h*/,
|
||||
int /*leftPad*/,
|
||||
int /*format*/,
|
||||
char * /*pBits*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef RegionPtr (* typeCopyArea)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pSrc*/,
|
||||
DrawablePtr /*pDst*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*srcx*/,
|
||||
int /*srcy*/,
|
||||
int /*w*/,
|
||||
int /*h*/,
|
||||
int /*dstx*/,
|
||||
int /*dsty*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef RegionPtr (* typeCopyPlane)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pSrcDrawable*/,
|
||||
DrawablePtr /*pDstDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*srcx*/,
|
||||
int /*srcy*/,
|
||||
int /*width*/,
|
||||
int /*height*/,
|
||||
int /*dstx*/,
|
||||
int /*dsty*/,
|
||||
unsigned long /*bitPlane*/
|
||||
#endif
|
||||
);
|
||||
typedef void (* typePolyPoint)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*mode*/,
|
||||
int /*npt*/,
|
||||
DDXPointPtr /*pptInit*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolylines)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*mode*/,
|
||||
int /*npt*/,
|
||||
DDXPointPtr /*pptInit*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolySegment)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*nseg*/,
|
||||
xSegment * /*pSegs*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolyRectangle)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*nrects*/,
|
||||
xRectangle * /*pRects*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolyArc)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*narcs*/,
|
||||
xArc * /*parcs*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typeFillPolygon)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*shape*/,
|
||||
int /*mode*/,
|
||||
int /*count*/,
|
||||
DDXPointPtr /*pPts*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolyFillRect)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*nrectFill*/,
|
||||
xRectangle * /*prectInit*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolyFillArc)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*narcs*/,
|
||||
xArc * /*parcs*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef int (* typePolyText8)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
int /*count*/,
|
||||
char * /*chars*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef int (* typePolyText16)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
int /*count*/,
|
||||
unsigned short * /*chars*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typeImageText8)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
int /*count*/,
|
||||
char * /*chars*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typeImageText16)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
int /*count*/,
|
||||
unsigned short * /*chars*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typeImageGlyphBlt)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
unsigned int /*nglyph*/,
|
||||
CharInfoPtr * /*ppci*/,
|
||||
pointer /*pglyphBase*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePolyGlyphBlt)(
|
||||
#if NeedNestedPrototypes
|
||||
DrawablePtr /*pDrawable*/,
|
||||
GCPtr /*pGC*/,
|
||||
int /*x*/,
|
||||
int /*y*/,
|
||||
unsigned int /*nglyph*/,
|
||||
CharInfoPtr * /*ppci*/,
|
||||
pointer /*pglyphBase*/
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef void (* typePushPixels)(
|
||||
#if NeedNestedPrototypes
|
||||
GCPtr /*pGC*/,
|
||||
PixmapPtr /*pBitMap*/,
|
||||
DrawablePtr /*pDst*/,
|
||||
int /*w*/,
|
||||
int /*h*/,
|
||||
int /*x*/,
|
||||
int /*y*/
|
||||
#endif
|
||||
);
|
||||
|
||||
RegionPtr
|
||||
KdNoopCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty)
|
||||
{
|
||||
return NullRegion;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
KdNoopCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
||||
int srcx, int srcy, int width, int height,
|
||||
int dstx, int dsty, unsigned long bitPlane)
|
||||
{
|
||||
return NullRegion;
|
||||
}
|
||||
|
||||
GCOps kdNoopOps = {
|
||||
(typeFillSpans) NoopDDA, /* fill spans */
|
||||
(typeSetSpans) NoopDDA, /* set spans */
|
||||
(typePutImage) NoopDDA, /* put image */
|
||||
KdNoopCopyArea, /* copy area */
|
||||
KdNoopCopyPlane, /* copy plane */
|
||||
(typePolyPoint) NoopDDA, /* poly point */
|
||||
(typePolylines) NoopDDA, /* poly lines */
|
||||
(typePolySegment) NoopDDA, /* poly segment */
|
||||
(typePolyRectangle) NoopDDA, /* poly rectangle */
|
||||
(typePolyArc) NoopDDA, /* poly arc */
|
||||
(typeFillPolygon) NoopDDA, /* fill polygon */
|
||||
(typePolyFillRect) NoopDDA, /* poly fillrect */
|
||||
(typePolyFillArc) NoopDDA, /* poly fillarc */
|
||||
(typePolyText8) NoopDDA, /* text 8 */
|
||||
(typePolyText16) NoopDDA, /* text 16 */
|
||||
(typeImageText8) NoopDDA, /* itext 8 */
|
||||
(typeImageText16) NoopDDA, /* itext 16 */
|
||||
(typePolyGlyphBlt) NoopDDA, /* glyph blt */
|
||||
(typeImageGlyphBlt) NoopDDA, /* iglyph blt */
|
||||
(typePushPixels) NoopDDA, /* push pixels */
|
||||
#ifdef NEED_LINEHELPER
|
||||
(typeLineHelper) NULL,
|
||||
#endif
|
||||
};
|
76
hw/kdrive/src/ktest.c
Normal file
76
hw/kdrive/src/ktest.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
|
||||
|
||||
static CARD8 memoryPatterns[] = { 0xff, 0x00, 0x5a, 0xa5, 0xaa, 0x55 };
|
||||
|
||||
#define NUM_PATTERNS (sizeof (memoryPatterns) / sizeof (memoryPatterns[0]))
|
||||
|
||||
Bool
|
||||
KdFrameBufferValid (CARD8 *base, int size)
|
||||
{
|
||||
volatile CARD8 *b = (volatile CARD8 *) base;
|
||||
CARD8 save, test, compare;
|
||||
int i, j;
|
||||
|
||||
b = base + (size - 1);
|
||||
save = *b;
|
||||
|
||||
for (i = 0; i < NUM_PATTERNS; i++)
|
||||
{
|
||||
test = memoryPatterns[i];
|
||||
*b = test;
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
compare = *b;
|
||||
if (compare != test)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
*b = save;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
KdFrameBufferSize (CARD8 *base, int max)
|
||||
{
|
||||
int min, cur;
|
||||
|
||||
min = 0;
|
||||
while (min + 1 < max)
|
||||
{
|
||||
cur = (max + min) / 2;
|
||||
if (KdFrameBufferValid (base, cur))
|
||||
min = cur;
|
||||
else
|
||||
max = cur;
|
||||
}
|
||||
if (KdFrameBufferValid (base, max))
|
||||
return max;
|
||||
else
|
||||
return min;
|
||||
}
|
288
hw/kdrive/src/vga.c
Normal file
288
hw/kdrive/src/vga.c
Normal file
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "vga.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef linux
|
||||
#define extern
|
||||
#include <asm/io.h>
|
||||
#undef extern
|
||||
|
||||
#define _VgaInb(r) inb(r)
|
||||
#define _VgaOutb(v,r) outb(v,r)
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define VGA_DEBUG(a) fprintf a
|
||||
#else
|
||||
#define VGA_DEBUG(a)
|
||||
#endif
|
||||
|
||||
VGA8
|
||||
VgaInb (VGA16 r)
|
||||
{
|
||||
return _VgaInb(r);
|
||||
}
|
||||
|
||||
void
|
||||
VgaOutb (VGA8 v, VGA16 r)
|
||||
{
|
||||
_VgaOutb (v,r);
|
||||
}
|
||||
|
||||
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;
|
||||
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];
|
||||
break;
|
||||
case VgaAccessIndIo:
|
||||
_VgaOutb (map.index, map.port + map.addr);
|
||||
value = _VgaInb (map.port + map.value);
|
||||
VGA_DEBUG ((stderr, "%4x/%2x -> %2x\n", map.port, map.index, value));
|
||||
break;
|
||||
case VgaAccessDone:
|
||||
value = map.value;
|
||||
VGA_DEBUG ((stderr, "direct %4x -> %2x\n", reg, value));
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
break;
|
||||
case VgaAccessIndIo:
|
||||
VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value));
|
||||
_VgaOutb (map.index, map.port + map.addr);
|
||||
_VgaOutb (value, map.port + map.value);
|
||||
break;
|
||||
case VgaAccessDone:
|
||||
VGA_DEBUG ((stderr, "direct %4x <- %2x\n", reg, value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaPreserve (VgaCard *card)
|
||||
{
|
||||
VgaSave *s;
|
||||
VGA16 id;
|
||||
|
||||
for (s = card->saves; s->first != VGA_REG_NONE; s++)
|
||||
{
|
||||
for (id = s->first; id <= s->last; id++)
|
||||
{
|
||||
card->values[id].cur = VgaFetch (card, id);
|
||||
card->values[id].save = card->values[id].cur;
|
||||
card->values[id].flags = VGA_VALUE_VALID | VGA_VALUE_SAVED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaRestore (VgaCard *card)
|
||||
{
|
||||
VgaSave *s;
|
||||
VGA16 id;
|
||||
|
||||
for (s = card->saves; s->first != VGA_REG_NONE; s++)
|
||||
{
|
||||
for (id = s->first; id <= s->last; id++)
|
||||
{
|
||||
if (card->values[id].flags & VGA_VALUE_SAVED)
|
||||
{
|
||||
VgaStore (card, id, card->values[id].save);
|
||||
card->values[id].cur = card->values[id].save;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaFinish (VgaCard *card)
|
||||
{
|
||||
VGA16 id;
|
||||
|
||||
for (id = 0; id < card->max; id++)
|
||||
card->values[id].flags = 0;
|
||||
}
|
||||
|
||||
void
|
||||
_VgaSync (VgaCard *card, VGA16 id)
|
||||
{
|
||||
if (!(card->values[id].flags & VGA_VALUE_VALID))
|
||||
{
|
||||
card->values[id].cur = VgaFetch (card, id);
|
||||
card->values[id].flags |= VGA_VALUE_VALID;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaSet (VgaCard *card, VgaReg *reg, VGA32 value)
|
||||
{
|
||||
VGA8 v, mask, new;
|
||||
|
||||
while (reg->len)
|
||||
{
|
||||
if (reg->id != VGA_REG_NONE)
|
||||
{
|
||||
_VgaSync (card, reg->id);
|
||||
mask = ((1 << reg->len) - 1);
|
||||
new = value & mask;
|
||||
mask <<= reg->base;
|
||||
new <<= reg->base;
|
||||
v = card->values[reg->id].cur;
|
||||
v = v & ~mask | new;
|
||||
card->values[reg->id].cur = v;
|
||||
card->values[reg->id].flags |= VGA_VALUE_MODIFIED|VGA_VALUE_DIRTY;
|
||||
}
|
||||
value >>= reg->len;
|
||||
reg++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaFlushReg (VgaCard *card, VgaReg *reg)
|
||||
{
|
||||
while (reg->len)
|
||||
{
|
||||
if (reg->id != VGA_REG_NONE)
|
||||
{
|
||||
if (card->values[reg->id].flags & VGA_VALUE_DIRTY)
|
||||
{
|
||||
VgaStore (card, reg->id, card->values[reg->id].cur);
|
||||
card->values[reg->id].flags &= ~VGA_VALUE_DIRTY;
|
||||
}
|
||||
}
|
||||
reg++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value)
|
||||
{
|
||||
VgaSet (card, reg, value);
|
||||
VgaFlushReg (card, reg);
|
||||
}
|
||||
|
||||
VGA32
|
||||
VgaGet (VgaCard *card, VgaReg *reg)
|
||||
{
|
||||
VGA32 value, offset, v;
|
||||
VGA8 mask;
|
||||
|
||||
value = 0;
|
||||
offset = 0;
|
||||
while (reg->len)
|
||||
{
|
||||
if (reg->id != VGA_REG_NONE)
|
||||
{
|
||||
_VgaSync (card, reg->id);
|
||||
mask = ((1 << reg->len) - 1);
|
||||
v = (card->values[reg->id].cur >> reg->base) & mask;
|
||||
value |= (v << offset);
|
||||
}
|
||||
offset += reg->len;
|
||||
reg++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
VGA32
|
||||
VgaGetImm (VgaCard *card, VgaReg *reg)
|
||||
{
|
||||
VgaReg *r = reg;
|
||||
|
||||
while (r->len)
|
||||
{
|
||||
if (r->id != VGA_REG_NONE)
|
||||
card->values[r->id].flags &= ~VGA_VALUE_VALID;
|
||||
r++;
|
||||
}
|
||||
return VgaGet (card, reg);
|
||||
}
|
||||
|
||||
void
|
||||
VgaFlush (VgaCard *card)
|
||||
{
|
||||
VGA16 id;
|
||||
|
||||
for (id = 0; id < card->max; id++)
|
||||
{
|
||||
if (card->values[id].flags & VGA_VALUE_DIRTY)
|
||||
{
|
||||
VgaStore (card, id, card->values[id].cur);
|
||||
card->values[id].flags &= ~VGA_VALUE_DIRTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VgaFill (VgaCard *card, VGA16 low, VGA16 high)
|
||||
{
|
||||
VGA16 id;
|
||||
|
||||
for (id = low; id < high; id++)
|
||||
_VgaSync (card, id);
|
||||
}
|
132
hw/kdrive/src/vga.h
Normal file
132
hw/kdrive/src/vga.h
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _VGA_H_
|
||||
#define _VGA_H_
|
||||
|
||||
typedef unsigned long VGA32;
|
||||
typedef unsigned short VGA16;
|
||||
typedef unsigned char VGA8;
|
||||
typedef int VGABOOL;
|
||||
typedef volatile VGA8 VGAVOL8;
|
||||
|
||||
#define VGATRUE 1
|
||||
#define VGAFALSE 0
|
||||
|
||||
typedef struct _vgaReg {
|
||||
VGA16 id;
|
||||
VGA8 base;
|
||||
VGA8 len;
|
||||
} VgaReg;
|
||||
|
||||
#define VGA_REG_NONE 0xffff
|
||||
#define VGA_REG_END VGA_REG_NONE, 0, 0
|
||||
|
||||
typedef struct _vgaValue {
|
||||
VGA8 save;
|
||||
VGA8 cur;
|
||||
VGA16 flags;
|
||||
} VgaValue;
|
||||
|
||||
#define VGA_VALUE_VALID 1 /* value ever fetched */
|
||||
#define VGA_VALUE_MODIFIED 2 /* value ever changed */
|
||||
#define VGA_VALUE_DIRTY 4 /* value needs syncing */
|
||||
#define VGA_VALUE_SAVED 8 /* value preserved */
|
||||
|
||||
typedef enum _vgaAccess {
|
||||
VgaAccessMem, VgaAccessIo, VgaAccessIndMem, VgaAccessIndIo,
|
||||
VgaAccessDone,
|
||||
} VgaAccess;
|
||||
|
||||
typedef struct _vgaMap {
|
||||
VgaAccess access;
|
||||
VGA32 port;
|
||||
VGA8 addr; /* for Ind access; addr offset from port */
|
||||
VGA8 value; /* for Ind access; value offset from port */
|
||||
VGA8 index; /* for Ind access; index value */
|
||||
} VgaMap;
|
||||
|
||||
#define VGA_UNLOCK_FIXED 1 /* dont save current value */
|
||||
#define VGA_UNLOCK_LOCK 2 /* execute only on relock */
|
||||
#define VGA_UNLOCK_UNLOCK 4 /* execute only on unlock */
|
||||
|
||||
typedef struct _vgaSave {
|
||||
VGA16 first;
|
||||
VGA16 last;
|
||||
} VgaSave;
|
||||
|
||||
#define VGA_SAVE_END VGA_REG_NONE, VGA_REG_NONE
|
||||
|
||||
typedef struct _vgaCard {
|
||||
void (*map) (struct _vgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write);
|
||||
void *closure;
|
||||
int max;
|
||||
VgaValue *values;
|
||||
VgaSave *saves;
|
||||
} VgaCard;
|
||||
|
||||
VGA8
|
||||
VgaInb (VGA16 r);
|
||||
|
||||
void
|
||||
VgaOutb (VGA8 v, VGA16 r);
|
||||
|
||||
void
|
||||
VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value);
|
||||
|
||||
VGA32
|
||||
VgaGetImm (VgaCard *card, VgaReg *reg);
|
||||
|
||||
void
|
||||
VgaSet (VgaCard *card, VgaReg *reg, VGA32 value);
|
||||
|
||||
VGA32
|
||||
VgaGet (VgaCard *card, VgaReg *reg);
|
||||
|
||||
void
|
||||
VgaFlush (VgaCard *card);
|
||||
|
||||
void
|
||||
VgaFill (VgaCard *card, VGA16 low, VGA16 high);
|
||||
|
||||
void
|
||||
VgaPreserve (VgaCard *card);
|
||||
|
||||
void
|
||||
VgaRestore (VgaCard *card);
|
||||
|
||||
VGA8
|
||||
VgaFetch (VgaCard *card, VGA16 id);
|
||||
|
||||
void
|
||||
VgaStore (VgaCard *card, VGA16 id, VGA8 value);
|
||||
|
||||
VGA8
|
||||
_VgaFetchInd (VGA16 port, VGA8 reg);
|
||||
|
||||
void
|
||||
_VgaStoreInd (VGA16 port, VGA8 reg, VGA8 value);
|
||||
|
||||
#endif /* _VGA_H_ */
|
15
hw/kdrive/trident/Imakefile
Normal file
15
hw/kdrive/trident/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = trident.c tridentdraw.c tridentcurs.c tridentstub.c
|
||||
|
||||
OBJS = trident.o tridentdraw.o tridentcurs.o tridentstub.o
|
||||
|
||||
INCLUDES = -I.. -I../fbdev -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(trident,$(OBJS))
|
||||
DependTarget()
|
279
hw/kdrive/trident/trident.c
Normal file
279
hw/kdrive/trident/trident.c
Normal file
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "trident.h"
|
||||
#define extern
|
||||
#include <asm/io.h>
|
||||
#undef extern
|
||||
|
||||
#undef TRI_DEBUG
|
||||
|
||||
Bool
|
||||
tridentCardInit (KdCardInfo *card)
|
||||
{
|
||||
int k;
|
||||
char *pixels;
|
||||
TridentCardInfo *tridentc;
|
||||
|
||||
tridentc = (TridentCardInfo *) xalloc (sizeof (TridentCardInfo));
|
||||
if (!tridentc)
|
||||
return FALSE;
|
||||
|
||||
if (!fbdevInitialize (card, &tridentc->fb))
|
||||
{
|
||||
xfree (tridentc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
iopl (3);
|
||||
tridentc->cop_base = (CARD8 *) KdMapDevice (TRIDENT_COP_BASE,
|
||||
TRIDENT_COP_SIZE);
|
||||
tridentc->cop = (Cop *) (tridentc->cop_base + TRIDENT_COP_OFF);
|
||||
card->driver = tridentc;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
tridentScreenInit (KdScreenInfo *screen)
|
||||
{
|
||||
TridentCardInfo *tridentc = screen->card->driver;
|
||||
TridentScreenInfo *tridents;
|
||||
int screen_size, memory;
|
||||
|
||||
tridents = (TridentScreenInfo *) xalloc (sizeof (TridentScreenInfo));
|
||||
if (!tridents)
|
||||
return FALSE;
|
||||
memset (tridents, '\0', sizeof (TridentScreenInfo));
|
||||
if (!fbdevScreenInit (screen))
|
||||
{
|
||||
xfree (tridents);
|
||||
return FALSE;
|
||||
}
|
||||
if (!tridentc->cop)
|
||||
screen->dumb = TRUE;
|
||||
screen_size = screen->byteStride * screen->height;
|
||||
memory = (2048 + 512) * 1024;
|
||||
if (memory >= screen_size + 2048)
|
||||
{
|
||||
tridents->cursor_base = tridentc->fb.fb + memory - 2048;
|
||||
}
|
||||
else
|
||||
tridents->cursor_base = 0;
|
||||
screen->driver = tridents;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CARD8
|
||||
tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index)
|
||||
{
|
||||
CARD8 value;
|
||||
|
||||
outb (index, port);
|
||||
value = inb (port+1);
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value)
|
||||
{
|
||||
outb (index, port);
|
||||
outb (value, port+1);
|
||||
}
|
||||
|
||||
void
|
||||
tridentPause ()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 200 * 1000;
|
||||
select (1, 0, 0, 0, &tv);
|
||||
}
|
||||
|
||||
void
|
||||
tridentPreserve (KdCardInfo *card)
|
||||
{
|
||||
TridentCardInfo *tridentc = card->driver;
|
||||
|
||||
fbdevPreserve (card);
|
||||
tridentc->save.reg_3c4_0e = tridentReadIndex (tridentc, 0x3c4, 0x0e);
|
||||
tridentc->save.reg_3d4_36 = tridentReadIndex (tridentc, 0x3d4, 0x36);
|
||||
tridentc->save.reg_3d4_39 = tridentReadIndex (tridentc, 0x3d4, 0x39);
|
||||
tridentc->save.reg_3d4_62 = tridentReadIndex (tridentc, 0x3d4, 0x62);
|
||||
tridentc->save.reg_3ce_21 = tridentReadIndex (tridentc, 0x3ce, 0x21);
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf (stderr, "3c4 0e: %02x\n", tridentc->save.reg_3c4_0e);
|
||||
fprintf (stderr, "3d4 36: %02x\n", tridentc->save.reg_3d4_36);
|
||||
fprintf (stderr, "3d4 39: %02x\n", tridentc->save.reg_3d4_39);
|
||||
fprintf (stderr, "3d4 62: %02x\n", tridentc->save.reg_3d4_62);
|
||||
fprintf (stderr, "3ce 21: %02x\n", tridentc->save.reg_3ce_21);
|
||||
fflush (stderr);
|
||||
#endif
|
||||
tridentPause ();
|
||||
}
|
||||
|
||||
void
|
||||
tridentSetMMIO (TridentCardInfo *tridentc)
|
||||
{
|
||||
int tries;
|
||||
CARD8 v;
|
||||
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf (stderr, "Set MMIO\n");
|
||||
#endif
|
||||
/* enable config port writes */
|
||||
for (tries = 0; tries < 3; tries++)
|
||||
{
|
||||
/* enable direct read when GE busy, enable PCI retries */
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x62,
|
||||
tridentc->save.reg_3d4_62 | 0x70);
|
||||
/* make sure the chip is in new mode */
|
||||
tridentReadIndex (tridentc, 0x3c4, 0xb);
|
||||
/* enable access to upper registers */
|
||||
tridentWriteIndex (tridentc, 0x3c4, 0xe,
|
||||
tridentc->save.reg_3c4_0e | 0x80);
|
||||
v = tridentReadIndex (tridentc, 0x3c4, 0xe);
|
||||
if (!(v & 0x80))
|
||||
{
|
||||
fprintf (stderr, "Trident GE not enabled 0x%x\n", v);
|
||||
continue;
|
||||
}
|
||||
/* enable burst r/w, disable memory mapped ports */
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x39, 0x6);
|
||||
/* reset GE, enable GE, set GE to 0xbff00 */
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x92);
|
||||
if (tridentc->cop->status != 0xffffffff)
|
||||
break;
|
||||
}
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf (stderr, "COP status 0x%x\n", tridentc->cop->status);
|
||||
#endif
|
||||
if (tridentc->cop->status == 0xffffffff)
|
||||
FatalError ("Trident COP not visible\n");
|
||||
}
|
||||
|
||||
void
|
||||
tridentResetMMIO (TridentCardInfo *tridentc)
|
||||
{
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf (stderr, "Reset MMIO\n");
|
||||
#endif
|
||||
tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36);
|
||||
tridentWriteIndex (tridentc, 0x3c4, 0x0e, tridentc->save.reg_3c4_0e);
|
||||
tridentPause ();
|
||||
}
|
||||
|
||||
void
|
||||
tridentEnable (ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
TridentCardInfo *tridentc = pScreenPriv->card->driver;
|
||||
|
||||
fbdevEnable (pScreen);
|
||||
tridentSetMMIO (tridentc);
|
||||
}
|
||||
|
||||
void
|
||||
tridentDisable (ScreenPtr pScreen)
|
||||
{
|
||||
fbdevDisable (pScreen);
|
||||
}
|
||||
|
||||
const CARD8 tridentDPMSModes[4] = {
|
||||
0x80, /* KD_DPMS_NORMAL */
|
||||
0x8c, /* KD_DPMS_STANDBY */
|
||||
0x8c, /* KD_DPMS_STANDBY */
|
||||
0x8c, /* KD_DPMS_STANDBY */
|
||||
/* 0xb0, /* KD_DPMS_SUSPEND */
|
||||
/* 0xbc, /* KD_DPMS_POWERDOWN */
|
||||
};
|
||||
|
||||
Bool
|
||||
tridentDPMS (ScreenPtr pScreen, int mode)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
TridentCardInfo *tridentc = pScreenPriv->card->driver;
|
||||
|
||||
tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentDPMSModes[mode]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
tridentRestore (KdCardInfo *card)
|
||||
{
|
||||
TridentCardInfo *tridentc = card->driver;
|
||||
|
||||
tridentResetMMIO (tridentc);
|
||||
fbdevRestore (card);
|
||||
}
|
||||
|
||||
void
|
||||
tridentScreenFini (KdScreenInfo *screen)
|
||||
{
|
||||
TridentScreenInfo *tridents = (TridentScreenInfo *) screen->driver;
|
||||
|
||||
xfree (tridents);
|
||||
screen->driver = 0;
|
||||
}
|
||||
|
||||
void
|
||||
tridentCardFini (KdCardInfo *card)
|
||||
{
|
||||
TridentCardInfo *tridentc = card->driver;
|
||||
|
||||
if (tridentc->cop_base)
|
||||
KdUnmapDevice ((void *) tridentc->cop_base, TRIDENT_COP_SIZE);
|
||||
fbdevCardFini (card);
|
||||
}
|
||||
|
||||
KdCardFuncs tridentFuncs = {
|
||||
tridentCardInit, /* cardinit */
|
||||
tridentScreenInit, /* scrinit */
|
||||
tridentPreserve, /* preserve */
|
||||
tridentEnable, /* enable */
|
||||
tridentDPMS, /* dpms */
|
||||
tridentDisable, /* disable */
|
||||
tridentRestore, /* restore */
|
||||
tridentScreenFini, /* scrfini */
|
||||
tridentCardFini, /* cardfini */
|
||||
|
||||
tridentCursorInit, /* initCursor */
|
||||
tridentCursorEnable, /* enableCursor */
|
||||
tridentCursorDisable, /* disableCursor */
|
||||
tridentCursorFini, /* finiCursor */
|
||||
tridentRecolorCursor, /* recolorCursor */
|
||||
|
||||
tridentDrawInit, /* initAccel */
|
||||
tridentDrawEnable, /* enableAccel */
|
||||
tridentDrawDisable, /* disableAccel */
|
||||
tridentDrawFini, /* finiAccel */
|
||||
|
||||
fbdevGetColors, /* getColors */
|
||||
fbdevPutColors, /* putColors */
|
||||
};
|
205
hw/kdrive/trident/trident.h
Normal file
205
hw/kdrive/trident/trident.h
Normal file
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _TRIDENT_H_
|
||||
#define _TRIDENT_H_
|
||||
#include <fbdev.h>
|
||||
|
||||
/*
|
||||
* offset from ioport beginning
|
||||
*/
|
||||
#define TRIDENT_COP_BASE 0xbf000
|
||||
#define TRIDENT_COP_OFF 0x00f00
|
||||
#define TRIDENT_COP_SIZE (0x2000)
|
||||
|
||||
typedef volatile CARD8 VOL8;
|
||||
typedef volatile CARD16 VOL16;
|
||||
typedef volatile CARD32 VOL32;
|
||||
|
||||
typedef struct _cop {
|
||||
VOL32 src_start_xy; /* 0x00 */
|
||||
VOL32 src_end_xy; /* 0x04 */
|
||||
VOL32 dst_start_xy; /* 0x08 */
|
||||
VOL32 dst_end_xy; /* 0x0c */
|
||||
VOL32 alpha; /* 0x10 */
|
||||
CARD8 pad14[0xc]; /* 0x14 */
|
||||
VOL32 multi; /* 0x20 */
|
||||
|
||||
#define COP_MULTI_CLIP_TOP_LEFT 0x10000000
|
||||
#define COP_MULTI_DEPTH 0x40000000
|
||||
#define COP_MULTI_COLOR_KEY 0x70000000
|
||||
#define COP_MULTI_STYLE 0x50000000
|
||||
#define COP_MULTI_PATTERN 0x80000000
|
||||
#define COP_MULTI_ROP 0x90000000
|
||||
#define COP_MULTI_STRIDE 0x60000000
|
||||
#define COP_MULTI_Z 0xa0000000
|
||||
#define COP_MULTI_ALPHA 0xb0000000
|
||||
#define COP_MULTI_TEXTURE 0xd0000000
|
||||
#define COP_MULTI_TEXTURE_BOUND 0xe0000000
|
||||
#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
|
||||
|
||||
VOL32 command; /* 0x24 */
|
||||
#define COP_OP_NULL 0x00000000
|
||||
#define COP_OP_LINE 0x20000000
|
||||
#define COP_OP_BLT 0x80000000
|
||||
#define COP_OP_TEXT 0x90000000
|
||||
#define COP_OP_POLY 0xb0000000
|
||||
#define COP_OP_POLY2 0xe0000000
|
||||
#define COP_SCL_EXPAND 0x00800000
|
||||
#define COP_SCL_OPAQUE 0x00400000
|
||||
#define COP_SCL_REVERSE 0x00200000
|
||||
#define COP_SCL_MONO_OFF 0x001c0000
|
||||
#define COP_LIT_TEXTURE 0x00004000
|
||||
#define COP_BILINEAR 0x00002000
|
||||
#define COP_OP_ZBUF 0x00000800
|
||||
#define COP_OP_ROP 0x00000400
|
||||
#define COP_OP_FG 0x00000200
|
||||
#define COP_OP_FB 0x00000080
|
||||
#define COP_X_REVERSE 0x00000004
|
||||
#define COP_CLIP 0x00000001
|
||||
VOL32 texture_format; /* 0x28 */
|
||||
CARD8 pad2c[0x4]; /* 0x2c */
|
||||
|
||||
VOL32 clip_bottom_right; /* 0x30 */
|
||||
VOL32 dataIII; /* 0x34 */
|
||||
VOL32 dataIV; /* 0x38 */
|
||||
CARD8 pad3c[0x8]; /* 0x3c */
|
||||
|
||||
VOL32 fg; /* 0x44 */
|
||||
VOL32 bg; /* 0x48 */
|
||||
CARD8 pad4c[0x4]; /* 0x4c */
|
||||
|
||||
VOL32 pattern_fg; /* 0x50 */
|
||||
VOL32 pattern_bg; /* 0x54 */
|
||||
CARD8 pad58[0xc]; /* 0x58 */
|
||||
|
||||
VOL32 status; /* 0x64 */
|
||||
#define COP_STATUS_BE_BUSY 0x80000000
|
||||
#define COP_STATUS_DPE_BUSY 0x20000000
|
||||
#define COP_STATUS_MI_BUSY 0x10000000
|
||||
#define COP_STATUS_FIFO_BUSY 0x08000000
|
||||
#define COP_STATUS_WB_BUSY 0x00800000
|
||||
#define COP_STATUS_Z_FAILED 0x00400000
|
||||
#define COP_STATUS_EFFECTIVE 0x00200000
|
||||
#define COP_STATUS_LEFT_VIEW 0x00080000
|
||||
|
||||
CARD8 pad68[0x4]; /* 0x68 */
|
||||
|
||||
VOL32 src_offset; /* 0x6c */
|
||||
VOL32 z_offset; /* 0x70 */
|
||||
CARD8 pad74[0x4]; /* 0x74 */
|
||||
|
||||
VOL32 display_offset; /* 0x78 */
|
||||
VOL32 dst_offset; /* 0x7c */
|
||||
CARD8 pad80[0x34]; /* 0x80 */
|
||||
|
||||
VOL32 semaphore; /* 0xb4 */
|
||||
} Cop;
|
||||
|
||||
#define TRI_XY(x,y) ((y) << 16 | (x))
|
||||
|
||||
typedef struct _tridentSave {
|
||||
CARD8 reg_3c4_0e; /* config port value */
|
||||
CARD8 reg_3d4_36;
|
||||
CARD8 reg_3d4_39;
|
||||
CARD8 reg_3d4_62; /* GE setup */
|
||||
CARD8 reg_3ce_21; /* DPMS */
|
||||
} TridentSave;
|
||||
|
||||
typedef struct _tridentCardInfo {
|
||||
FbdevPriv fb;
|
||||
CARD8 *cop_base;
|
||||
Cop *cop;
|
||||
CARD32 cop_depth;
|
||||
CARD32 cop_stride;
|
||||
TridentSave save;
|
||||
} TridentCardInfo;
|
||||
|
||||
#define getTridentCardInfo(kd) ((TridentCardInfo *) ((kd)->card->driver))
|
||||
#define tridentCardInfo(kd) TridentCardInfo *tridentc = getTridentCardInfo(kd)
|
||||
|
||||
typedef struct _tridentCursor {
|
||||
int width, height;
|
||||
int xhot, yhot;
|
||||
Bool has_cursor;
|
||||
CursorPtr pCursor;
|
||||
Pixel source, mask;
|
||||
} TridentCursor;
|
||||
|
||||
#define TRIDENT_CURSOR_WIDTH 64
|
||||
#define TRIDENT_CURSOR_HEIGHT 64
|
||||
|
||||
typedef struct _tridentScreenInfo {
|
||||
CARD8 *cursor_base;
|
||||
TridentCursor cursor;
|
||||
} TridentScreenInfo;
|
||||
|
||||
#define getTridentScreenInfo(kd) ((TridentScreenInfo *) ((kd)->screen->driver))
|
||||
#define tridentScreenInfo(kd) TridentScreenInfo *tridents = getTridentScreenInfo(kd)
|
||||
|
||||
Bool
|
||||
tridentDrawInit (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentDrawEnable (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentDrawDisable (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentDrawFini (ScreenPtr pScreen);
|
||||
|
||||
CARD8
|
||||
tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index);
|
||||
|
||||
void
|
||||
tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value);
|
||||
|
||||
Bool
|
||||
tridentCursorInit (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentCursorEnable (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentCursorDisable (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentCursorFini (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
|
||||
|
||||
extern KdCardFuncs tridentFuncs;
|
||||
|
||||
#endif /* _TRIDENT_H_ */
|
414
hw/kdrive/trident/tridentcurs.c
Normal file
414
hw/kdrive/trident/tridentcurs.c
Normal file
|
@ -0,0 +1,414 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "trident.h"
|
||||
#include "cursorstr.h"
|
||||
|
||||
#define SetupCursor(s) KdScreenPriv(s); \
|
||||
tridentCardInfo(pScreenPriv); \
|
||||
tridentScreenInfo(pScreenPriv); \
|
||||
TridentCursor *pCurPriv = &tridents->cursor
|
||||
|
||||
static void
|
||||
_tridentMoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CARD8 xlow, xhigh, ylow, yhigh;
|
||||
CARD8 xoff, yoff;
|
||||
|
||||
x -= pCurPriv->xhot;
|
||||
xoff = 0;
|
||||
if (x < 0)
|
||||
{
|
||||
xoff = -x;
|
||||
x = 0;
|
||||
}
|
||||
y -= pCurPriv->yhot;
|
||||
yoff = 0;
|
||||
if (y < 0)
|
||||
{
|
||||
yoff = -y;
|
||||
y = 0;
|
||||
}
|
||||
xlow = (CARD8) x;
|
||||
xhigh = (CARD8) (x >> 8);
|
||||
ylow = (CARD8) y;
|
||||
yhigh = (CARD8) (y >> 8);
|
||||
|
||||
|
||||
/* This is the recommended order to move the cursor */
|
||||
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh);
|
||||
}
|
||||
|
||||
static void
|
||||
tridentMoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pCurPriv->has_cursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
_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;
|
||||
switch (pScreenPriv->screen->bitsPerPixel) {
|
||||
case 4:
|
||||
pCurPriv->source |= pCurPriv->source << 4;
|
||||
pCurPriv->mask |= pCurPriv->mask << 4;
|
||||
case 8:
|
||||
pCurPriv->source |= pCurPriv->source << 8;
|
||||
pCurPriv->mask |= pCurPriv->mask << 8;
|
||||
case 16:
|
||||
pCurPriv->source |= pCurPriv->source << 16;
|
||||
pCurPriv->mask |= pCurPriv->mask << 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tridentSetCursorColors (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
CARD32 fg, bg;
|
||||
|
||||
fg = pCurPriv->source;
|
||||
bg = pCurPriv->mask;
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x48, fg);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16);
|
||||
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8);
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16);
|
||||
}
|
||||
|
||||
void
|
||||
tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
xColorItem sourceColor, maskColor;
|
||||
|
||||
if (!pCurPriv->has_cursor || !pCursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pdef)
|
||||
{
|
||||
while (ndef)
|
||||
{
|
||||
if (pdef->pixel == pCurPriv->source ||
|
||||
pdef->pixel == pCurPriv->mask)
|
||||
break;
|
||||
ndef--;
|
||||
}
|
||||
if (!ndef)
|
||||
return;
|
||||
}
|
||||
tridentAllocCursorColors (pScreen);
|
||||
tridentSetCursorColors (pScreen);
|
||||
}
|
||||
|
||||
#define InvertBits32(v) { \
|
||||
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
|
||||
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
|
||||
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
|
||||
}
|
||||
|
||||
static void
|
||||
tridentLoadCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
CursorBitsPtr bits = pCursor->bits;
|
||||
int w, h;
|
||||
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
|
||||
int i, j;
|
||||
int cursor_address;
|
||||
int lwsrc;
|
||||
unsigned char ramdac_control_;
|
||||
CARD32 offset;
|
||||
|
||||
/*
|
||||
* Allocate new colors
|
||||
*/
|
||||
tridentAllocCursorColors (pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
pCurPriv->xhot = pCursor->bits->xhot;
|
||||
pCurPriv->yhot = pCursor->bits->yhot;
|
||||
|
||||
/*
|
||||
* Stick new image into cursor memory
|
||||
*/
|
||||
ram = (CARD32 *) tridents->cursor_base;
|
||||
mskLine = (CARD32 *) bits->mask;
|
||||
srcLine = (CARD32 *) bits->source;
|
||||
|
||||
h = bits->height;
|
||||
if (h > TRIDENT_CURSOR_HEIGHT)
|
||||
h = TRIDENT_CURSOR_HEIGHT;
|
||||
|
||||
lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
|
||||
|
||||
for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) {
|
||||
msk = mskLine;
|
||||
src = srcLine;
|
||||
mskLine += lwsrc;
|
||||
srcLine += lwsrc;
|
||||
for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) {
|
||||
|
||||
CARD32 m, s;
|
||||
|
||||
#if 1
|
||||
if (i < h && j < lwsrc)
|
||||
{
|
||||
m = *msk++;
|
||||
s = *src++;
|
||||
InvertBits32(m);
|
||||
InvertBits32(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
m = 0;
|
||||
s = 0;
|
||||
}
|
||||
#endif
|
||||
*ram++ = m;
|
||||
*ram++ = s;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set address for cursor bits */
|
||||
offset = tridents->cursor_base - (CARD8 *) tridentc->fb.fb;
|
||||
offset >>= 10;
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff));
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8));
|
||||
|
||||
/* Set new color */
|
||||
tridentSetCursorColors (pScreen);
|
||||
|
||||
/* Enable the cursor */
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1);
|
||||
|
||||
/* Move to new position */
|
||||
tridentMoveCursor (pScreen, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
tridentUnloadCursor (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
/* Disable cursor */
|
||||
tridentWriteIndex (tridentc, 0x3d4, 0x50, 0);
|
||||
}
|
||||
|
||||
static Bool
|
||||
tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return TRUE;
|
||||
|
||||
/* miRecolorCursor does this */
|
||||
if (pCurPriv->pCursor == pCursor)
|
||||
{
|
||||
if (pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
tridentLoadCursor (pScreen, x, y);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCursor)
|
||||
tridentLoadCursor (pScreen, x, y);
|
||||
else
|
||||
tridentUnloadCursor (pScreen);
|
||||
}
|
||||
|
||||
miPointerSpriteFuncRec tridentPointerSpriteFuncs = {
|
||||
tridentRealizeCursor,
|
||||
tridentUnrealizeCursor,
|
||||
tridentSetCursor,
|
||||
tridentMoveCursor,
|
||||
};
|
||||
|
||||
static void
|
||||
tridentQueryBestSize (int class,
|
||||
unsigned short *pwidth, unsigned short *pheight,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case CursorShape:
|
||||
if (*pwidth > pCurPriv->width)
|
||||
*pwidth = pCurPriv->width;
|
||||
if (*pheight > pCurPriv->height)
|
||||
*pheight = pCurPriv->height;
|
||||
if (*pwidth > pScreen->width)
|
||||
*pwidth = pScreen->width;
|
||||
if (*pheight > pScreen->height)
|
||||
*pheight = pScreen->height;
|
||||
break;
|
||||
default:
|
||||
fbQueryBestSize (class, pwidth, pheight, pScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
tridentCursorInit (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!tridents->cursor_base)
|
||||
{
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pCurPriv->width = TRIDENT_CURSOR_WIDTH;
|
||||
pCurPriv->height= TRIDENT_CURSOR_HEIGHT;
|
||||
pScreen->QueryBestSize = tridentQueryBestSize;
|
||||
miPointerInitialize (pScreen,
|
||||
&tridentPointerSpriteFuncs,
|
||||
&kdPointerScreenFuncs,
|
||||
FALSE);
|
||||
pCurPriv->has_cursor = TRUE;
|
||||
pCurPriv->pCursor = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
tridentCursorEnable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
tridentLoadCursor (pScreen, x, y);
|
||||
}
|
||||
else
|
||||
tridentUnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tridentCursorDisable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
tridentUnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tridentCursorFini (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
pCurPriv->pCursor = NULL;
|
||||
}
|
859
hw/kdrive/trident/tridentdraw.c
Normal file
859
hw/kdrive/trident/tridentdraw.c
Normal file
|
@ -0,0 +1,859 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "trident.h"
|
||||
#include "tridentdraw.h"
|
||||
|
||||
#include "Xmd.h"
|
||||
#include "gcstruct.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "regionstr.h"
|
||||
#include "mistruct.h"
|
||||
#include "fontstruct.h"
|
||||
#include "dixfontstr.h"
|
||||
#include "fb.h"
|
||||
#include "migc.h"
|
||||
#include "miline.h"
|
||||
|
||||
CARD8 tridentRop[16] = {
|
||||
/* GXclear */ 0x00, /* 0 */
|
||||
/* GXand */ 0x88, /* src AND dst */
|
||||
/* GXandReverse */ 0x44, /* src AND NOT dst */
|
||||
/* GXcopy */ 0xcc, /* src */
|
||||
/* GXandInverted*/ 0x22, /* NOT src AND dst */
|
||||
/* GXnoop */ 0xaa, /* dst */
|
||||
/* GXxor */ 0x66, /* src XOR dst */
|
||||
/* GXor */ 0xee, /* src OR dst */
|
||||
/* GXnor */ 0x11, /* NOT src AND NOT dst */
|
||||
/* GXequiv */ 0x99, /* NOT src XOR dst */
|
||||
/* GXinvert */ 0x55, /* NOT dst */
|
||||
/* GXorReverse */ 0xdd, /* src OR NOT dst */
|
||||
/* GXcopyInverted*/ 0x33, /* NOT src */
|
||||
/* GXorInverted */ 0xbb, /* NOT src OR dst */
|
||||
/* GXnand */ 0x77, /* NOT src OR NOT dst */
|
||||
/* GXset */ 0xff, /* 1 */
|
||||
};
|
||||
|
||||
#define tridentFillPix(bpp,pixel) {\
|
||||
if (bpp == 8) \
|
||||
{ \
|
||||
pixel = pixel & 0xff; \
|
||||
pixel = pixel | pixel << 8; \
|
||||
} \
|
||||
if (bpp <= 16) \
|
||||
{ \
|
||||
pixel = pixel & 0xffff; \
|
||||
pixel = pixel | pixel << 16; \
|
||||
} \
|
||||
}
|
||||
void
|
||||
tridentFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
|
||||
unsigned long pixel, int alu)
|
||||
{
|
||||
SetupTrident(pDrawable->pScreen);
|
||||
CARD32 cmd;
|
||||
|
||||
tridentFillPix(pDrawable->bitsPerPixel,pixel);
|
||||
_tridentInit(cop,tridentc);
|
||||
_tridentSetSolidRect(cop,pixel,alu,cmd);
|
||||
while (nBox--)
|
||||
{
|
||||
_tridentRect(cop,pBox->x1,pBox->y1,pBox->x2-1,pBox->y2-1,cmd);
|
||||
pBox++;
|
||||
}
|
||||
_tridentWaitIdleEmpty(cop);
|
||||
}
|
||||
|
||||
void
|
||||
tridentCopyNtoN (DrawablePtr pSrcDrawable,
|
||||
DrawablePtr pDstDrawable,
|
||||
GCPtr pGC,
|
||||
BoxPtr pbox,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown,
|
||||
Pixel bitplane,
|
||||
void *closure)
|
||||
{
|
||||
SetupTrident(pDstDrawable->pScreen);
|
||||
int srcX, srcY, dstX, dstY;
|
||||
int w, h;
|
||||
CARD32 flags;
|
||||
CARD32 cmd;
|
||||
CARD8 alu;
|
||||
|
||||
if (pGC)
|
||||
{
|
||||
alu = pGC->alu;
|
||||
if (sourceInvarient (pGC->alu))
|
||||
{
|
||||
tridentFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
alu = GXcopy;
|
||||
|
||||
_tridentInit(cop,tridentc);
|
||||
cop->multi = COP_MULTI_PATTERN;
|
||||
cop->multi = COP_MULTI_ROP | tridentRop[alu];
|
||||
if (reverse)
|
||||
upsidedown = TRUE;
|
||||
cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FB;
|
||||
if (upsidedown)
|
||||
cmd |= COP_X_REVERSE;
|
||||
while (nbox--)
|
||||
{
|
||||
if (upsidedown)
|
||||
{
|
||||
cop->src_start_xy = TRI_XY (pbox->x2 + dx - 1,
|
||||
pbox->y2 + dy - 1);
|
||||
cop->src_end_xy = TRI_XY (pbox->x1 + dx,
|
||||
pbox->y1 + dy);
|
||||
cop->dst_start_xy = TRI_XY (pbox->x2 - 1,
|
||||
pbox->y2 - 1);
|
||||
cop->dst_end_xy = TRI_XY (pbox->x1,
|
||||
pbox->y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cop->src_start_xy = TRI_XY (pbox->x1 + dx,
|
||||
pbox->y1 + dy);
|
||||
cop->src_end_xy = TRI_XY (pbox->x2 + dx - 1,
|
||||
pbox->y2 + dy - 1);
|
||||
cop->dst_start_xy = TRI_XY (pbox->x1,
|
||||
pbox->y1);
|
||||
cop->dst_end_xy = TRI_XY (pbox->x2 - 1,
|
||||
pbox->y2 - 1);
|
||||
}
|
||||
cop->command = cmd;
|
||||
pbox++;
|
||||
}
|
||||
_tridentWaitIdleEmpty(cop);
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
tridentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty)
|
||||
{
|
||||
KdScreenPriv(pDstDrawable->pScreen);
|
||||
FbBits depthMask;
|
||||
|
||||
depthMask = FbFullMask (pDstDrawable->depth);
|
||||
if ((pGC->planemask & depthMask) == depthMask &&
|
||||
pSrcDrawable->type == DRAWABLE_WINDOW &&
|
||||
pDstDrawable->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
|
||||
srcx, srcy, width, height,
|
||||
dstx, dsty, tridentCopyNtoN, 0, 0);
|
||||
}
|
||||
return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
|
||||
srcx, srcy, width, height, dstx, dsty);
|
||||
}
|
||||
|
||||
BOOL
|
||||
tridentFillOk (GCPtr pGC)
|
||||
{
|
||||
FbBits depthMask;
|
||||
|
||||
depthMask = FbFullMask(pGC->depth);
|
||||
if ((pGC->planemask & depthMask) != depthMask)
|
||||
return FALSE;
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
return TRUE;
|
||||
#if 0
|
||||
case FillTiled:
|
||||
return (tridentPatternDimOk (pGC->tile.pixmap->drawable.width) &&
|
||||
tridentPatternDimOk (pGC->tile.pixmap->drawable.height));
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
return (tridentPatternDimOk (pGC->stipple->drawable.width) &&
|
||||
tridentPatternDimOk (pGC->stipple->drawable.height));
|
||||
#endif
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
tridentFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||
DDXPointPtr ppt, int *pwidth, int fSorted)
|
||||
{
|
||||
SetupTrident(pDrawable->pScreen);
|
||||
DDXPointPtr pptFree;
|
||||
FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
|
||||
int *pwidthFree;/* copies of the pointers to free */
|
||||
CARD32 cmd;
|
||||
int nTmp;
|
||||
INT16 x, y;
|
||||
int width;
|
||||
CARD32 pixel;
|
||||
|
||||
if (!tridentFillOk (pGC))
|
||||
{
|
||||
fbFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
|
||||
return;
|
||||
}
|
||||
nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree)
|
||||
{
|
||||
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;
|
||||
_tridentInit(cop,tridentc);
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
pixel = pGC->fgPixel;
|
||||
tridentFillPix (pDrawable->bitsPerPixel,pixel);
|
||||
_tridentSetSolidRect(cop,pixel,pGC->alu,cmd);
|
||||
break;
|
||||
#if 0
|
||||
case FillTiled:
|
||||
cmd = tridentTilePrepare (pGC->tile.pixmap,
|
||||
pGC->patOrg.x + pDrawable->x,
|
||||
pGC->patOrg.y + pDrawable->y,
|
||||
pGC->alu);
|
||||
break;
|
||||
default:
|
||||
cmd = tridentStipplePrepare (pDrawable, pGC);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
x = ppt->x;
|
||||
y = ppt->y;
|
||||
ppt++;
|
||||
width = *pwidth++;
|
||||
if (width)
|
||||
{
|
||||
_tridentRect(cop,x,y,x + width,y,cmd);
|
||||
}
|
||||
}
|
||||
_tridentWaitIdleEmpty (cop);
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
}
|
||||
|
||||
#define NUM_STACK_RECTS 1024
|
||||
|
||||
void
|
||||
tridentPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nrectFill, xRectangle *prectInit)
|
||||
{
|
||||
SetupTrident(pDrawable->pScreen);
|
||||
xRectangle *prect;
|
||||
RegionPtr prgnClip;
|
||||
register BoxPtr pbox;
|
||||
register BoxPtr pboxClipped;
|
||||
BoxPtr pboxClippedBase;
|
||||
BoxPtr pextent;
|
||||
BoxRec stackRects[NUM_STACK_RECTS];
|
||||
FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
|
||||
int numRects;
|
||||
int n;
|
||||
int xorg, yorg;
|
||||
int x, y;
|
||||
|
||||
if (!tridentFillOk (pGC))
|
||||
{
|
||||
fbPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
|
||||
return;
|
||||
}
|
||||
prgnClip = fbGetCompositeClip(pGC);
|
||||
xorg = pDrawable->x;
|
||||
yorg = pDrawable->y;
|
||||
|
||||
if (xorg || yorg)
|
||||
{
|
||||
prect = prectInit;
|
||||
n = nrectFill;
|
||||
while(n--)
|
||||
{
|
||||
prect->x += xorg;
|
||||
prect->y += yorg;
|
||||
prect++;
|
||||
}
|
||||
}
|
||||
|
||||
prect = prectInit;
|
||||
|
||||
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
|
||||
if (numRects > NUM_STACK_RECTS)
|
||||
{
|
||||
pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
|
||||
if (!pboxClippedBase)
|
||||
return;
|
||||
}
|
||||
else
|
||||
pboxClippedBase = stackRects;
|
||||
|
||||
pboxClipped = pboxClippedBase;
|
||||
|
||||
if (REGION_NUM_RECTS(prgnClip) == 1)
|
||||
{
|
||||
int x1, y1, x2, y2, bx2, by2;
|
||||
|
||||
pextent = REGION_RECTS(prgnClip);
|
||||
x1 = pextent->x1;
|
||||
y1 = pextent->y1;
|
||||
x2 = pextent->x2;
|
||||
y2 = pextent->y2;
|
||||
while (nrectFill--)
|
||||
{
|
||||
if ((pboxClipped->x1 = prect->x) < x1)
|
||||
pboxClipped->x1 = x1;
|
||||
|
||||
if ((pboxClipped->y1 = prect->y) < y1)
|
||||
pboxClipped->y1 = y1;
|
||||
|
||||
bx2 = (int) prect->x + (int) prect->width;
|
||||
if (bx2 > x2)
|
||||
bx2 = x2;
|
||||
pboxClipped->x2 = bx2;
|
||||
|
||||
by2 = (int) prect->y + (int) prect->height;
|
||||
if (by2 > y2)
|
||||
by2 = y2;
|
||||
pboxClipped->y2 = by2;
|
||||
|
||||
prect++;
|
||||
if ((pboxClipped->x1 < pboxClipped->x2) &&
|
||||
(pboxClipped->y1 < pboxClipped->y2))
|
||||
{
|
||||
pboxClipped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int x1, y1, x2, y2, bx2, by2;
|
||||
|
||||
pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
|
||||
x1 = pextent->x1;
|
||||
y1 = pextent->y1;
|
||||
x2 = pextent->x2;
|
||||
y2 = pextent->y2;
|
||||
while (nrectFill--)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
if ((box.x1 = prect->x) < x1)
|
||||
box.x1 = x1;
|
||||
|
||||
if ((box.y1 = prect->y) < y1)
|
||||
box.y1 = y1;
|
||||
|
||||
bx2 = (int) prect->x + (int) prect->width;
|
||||
if (bx2 > x2)
|
||||
bx2 = x2;
|
||||
box.x2 = bx2;
|
||||
|
||||
by2 = (int) prect->y + (int) prect->height;
|
||||
if (by2 > y2)
|
||||
by2 = y2;
|
||||
box.y2 = by2;
|
||||
|
||||
prect++;
|
||||
|
||||
if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
|
||||
continue;
|
||||
|
||||
n = REGION_NUM_RECTS (prgnClip);
|
||||
pbox = REGION_RECTS(prgnClip);
|
||||
|
||||
/* clip the rectangle to each box in the clip region
|
||||
this is logically equivalent to calling Intersect()
|
||||
*/
|
||||
while(n--)
|
||||
{
|
||||
pboxClipped->x1 = max(box.x1, pbox->x1);
|
||||
pboxClipped->y1 = max(box.y1, pbox->y1);
|
||||
pboxClipped->x2 = min(box.x2, pbox->x2);
|
||||
pboxClipped->y2 = min(box.y2, pbox->y2);
|
||||
pbox++;
|
||||
|
||||
/* see if clipping left anything */
|
||||
if(pboxClipped->x1 < pboxClipped->x2 &&
|
||||
pboxClipped->y1 < pboxClipped->y2)
|
||||
{
|
||||
pboxClipped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pboxClipped != pboxClippedBase)
|
||||
{
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
tridentFillBoxSolid(pDrawable,
|
||||
pboxClipped-pboxClippedBase, pboxClippedBase,
|
||||
pGC->fgPixel, pGC->alu);
|
||||
break;
|
||||
#if 0
|
||||
case FillTiled:
|
||||
tridentFillBoxTiled(pDrawable,
|
||||
pboxClipped-pboxClippedBase, pboxClippedBase,
|
||||
pGC->tile.pixmap,
|
||||
pGC->patOrg.x + pDrawable->x,
|
||||
pGC->patOrg.y + pDrawable->y,
|
||||
pGC->alu);
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
tridentFillBoxStipple (pDrawable, pGC,
|
||||
pboxClipped-pboxClippedBase, pboxClippedBase);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (pboxClippedBase != stackRects)
|
||||
xfree(pboxClippedBase);
|
||||
}
|
||||
|
||||
void
|
||||
tridentSolidBoxClipped (DrawablePtr pDrawable,
|
||||
RegionPtr pClip,
|
||||
int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2,
|
||||
FbBits fg)
|
||||
{
|
||||
SetupTrident (pDrawable->pScreen);
|
||||
BoxPtr pbox;
|
||||
int nbox;
|
||||
int partX1, partX2, partY1, partY2;
|
||||
CARD32 cmd;
|
||||
|
||||
_tridentInit (cop, tridentc);
|
||||
_tridentSetSolidRect (cop, fg, GXcopy, cmd);
|
||||
|
||||
for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
|
||||
nbox--;
|
||||
pbox++)
|
||||
{
|
||||
partX1 = pbox->x1;
|
||||
if (partX1 < x1)
|
||||
partX1 = x1;
|
||||
|
||||
partX2 = pbox->x2;
|
||||
if (partX2 > x2)
|
||||
partX2 = x2;
|
||||
|
||||
if (partX2 <= partX1)
|
||||
continue;
|
||||
|
||||
partY1 = pbox->y1;
|
||||
if (partY1 < y1)
|
||||
partY1 = y1;
|
||||
|
||||
partY2 = pbox->y2;
|
||||
if (partY2 > y2)
|
||||
partY2 = y2;
|
||||
|
||||
if (partY2 <= partY1)
|
||||
continue;
|
||||
|
||||
_tridentRect(cop,partX1, partY1, partX2-1, partY2-1,cmd);
|
||||
}
|
||||
_tridentWaitIdleEmpty(cop);
|
||||
}
|
||||
|
||||
void
|
||||
tridentImageGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppciInit,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
|
||||
CharInfoPtr *ppci;
|
||||
CharInfoPtr pci;
|
||||
unsigned char *pglyph; /* pointer bits in glyph */
|
||||
int gWidth, gHeight; /* width and height of glyph */
|
||||
FbStride gStride; /* stride of glyph */
|
||||
Bool opaque;
|
||||
int n;
|
||||
int gx, gy;
|
||||
void (*glyph) (FbBits *,
|
||||
FbStride,
|
||||
int,
|
||||
FbStip *,
|
||||
FbBits,
|
||||
int,
|
||||
int);
|
||||
FbBits *dst;
|
||||
FbStride dstStride;
|
||||
int dstBpp;
|
||||
FbBits depthMask;
|
||||
|
||||
depthMask = FbFullMask(pDrawable->depth);
|
||||
if ((pGC->planemask & depthMask) != depthMask)
|
||||
{
|
||||
fbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
|
||||
return;
|
||||
}
|
||||
glyph = 0;
|
||||
fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
|
||||
switch (dstBpp) {
|
||||
case 8: glyph = fbGlyph8; break;
|
||||
case 16: glyph = fbGlyph16; break;
|
||||
case 24: glyph = fbGlyph24; break;
|
||||
case 32: glyph = fbGlyph32; break;
|
||||
}
|
||||
|
||||
x += pDrawable->x;
|
||||
y += pDrawable->y;
|
||||
|
||||
if (TERMINALFONT (pGC->font) && !glyph)
|
||||
{
|
||||
opaque = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int xBack, widthBack;
|
||||
int yBack, heightBack;
|
||||
|
||||
ppci = ppciInit;
|
||||
n = nglyph;
|
||||
widthBack = 0;
|
||||
while (n--)
|
||||
widthBack += (*ppci++)->metrics.characterWidth;
|
||||
|
||||
xBack = x;
|
||||
if (widthBack < 0)
|
||||
{
|
||||
xBack += widthBack;
|
||||
widthBack = -widthBack;
|
||||
}
|
||||
yBack = y - FONTASCENT(pGC->font);
|
||||
heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
|
||||
tridentSolidBoxClipped (pDrawable,
|
||||
fbGetCompositeClip(pGC),
|
||||
xBack,
|
||||
yBack,
|
||||
xBack + widthBack,
|
||||
yBack + heightBack,
|
||||
pPriv->bg);
|
||||
opaque = FALSE;
|
||||
}
|
||||
|
||||
ppci = ppciInit;
|
||||
while (nglyph--)
|
||||
{
|
||||
pci = *ppci++;
|
||||
pglyph = FONTGLYPHBITS(pglyphBase, pci);
|
||||
gWidth = GLYPHWIDTHPIXELS(pci);
|
||||
gHeight = GLYPHHEIGHTPIXELS(pci);
|
||||
if (gWidth && gHeight)
|
||||
{
|
||||
gx = x + pci->metrics.leftSideBearing;
|
||||
gy = y - pci->metrics.ascent;
|
||||
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
|
||||
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
|
||||
{
|
||||
(*glyph) (dst + gy * dstStride,
|
||||
dstStride,
|
||||
dstBpp,
|
||||
(FbStip *) pglyph,
|
||||
pPriv->fg,
|
||||
gx,
|
||||
gHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
|
||||
fbPutXYImage (pDrawable,
|
||||
fbGetCompositeClip(pGC),
|
||||
pPriv->fg,
|
||||
pPriv->bg,
|
||||
pPriv->pm,
|
||||
GXcopy,
|
||||
opaque,
|
||||
|
||||
gx,
|
||||
gy,
|
||||
gWidth, gHeight,
|
||||
|
||||
(FbStip *) pglyph,
|
||||
gStride,
|
||||
0);
|
||||
}
|
||||
}
|
||||
x += pci->metrics.characterWidth;
|
||||
}
|
||||
}
|
||||
|
||||
static const GCOps tridentOps = {
|
||||
tridentFillSpans,
|
||||
fbSetSpans,
|
||||
fbPutImage,
|
||||
tridentCopyArea,
|
||||
fbCopyPlane,
|
||||
fbPolyPoint,
|
||||
fbPolyLine,
|
||||
fbPolySegment,
|
||||
miPolyRectangle,
|
||||
fbPolyArc,
|
||||
miFillPolygon,
|
||||
tridentPolyFillRect,
|
||||
fbPolyFillArc,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
tridentImageGlyphBlt,
|
||||
fbPolyGlyphBlt,
|
||||
fbPushPixels,
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
void
|
||||
tridentValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
|
||||
{
|
||||
FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
|
||||
|
||||
fbValidateGC (pGC, changes, pDrawable);
|
||||
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
pGC->ops = (GCOps *) &tridentOps;
|
||||
else
|
||||
pGC->ops = (GCOps *) &fbGCOps;
|
||||
}
|
||||
|
||||
GCFuncs tridentGCFuncs = {
|
||||
tridentValidateGC,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
miDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip
|
||||
};
|
||||
|
||||
int
|
||||
tridentCreateGC (GCPtr pGC)
|
||||
{
|
||||
if (!fbCreateGC (pGC))
|
||||
return FALSE;
|
||||
|
||||
if (pGC->depth != 1)
|
||||
pGC->funcs = &tridentGCFuncs;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
tridentCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
KdScreenPriv(pScreen);
|
||||
RegionRec rgnDst;
|
||||
int dx, dy;
|
||||
WindowPtr pwinRoot;
|
||||
|
||||
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
|
||||
|
||||
dx = ptOldOrg.x - pWin->drawable.x;
|
||||
dy = ptOldOrg.y - pWin->drawable.y;
|
||||
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
|
||||
|
||||
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
|
||||
|
||||
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
|
||||
|
||||
fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
|
||||
0,
|
||||
&rgnDst, dx, dy, tridentCopyNtoN, 0, 0);
|
||||
|
||||
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
|
||||
}
|
||||
|
||||
void
|
||||
tridentPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
|
||||
{
|
||||
KdScreenPriv(pWin->drawable.pScreen);
|
||||
PixmapPtr pTile;
|
||||
|
||||
if (!REGION_NUM_RECTS(pRegion))
|
||||
return;
|
||||
switch (what) {
|
||||
case PW_BACKGROUND:
|
||||
switch (pWin->backgroundState) {
|
||||
case None:
|
||||
return;
|
||||
case ParentRelative:
|
||||
do {
|
||||
pWin = pWin->parent;
|
||||
} while (pWin->backgroundState == ParentRelative);
|
||||
(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
|
||||
what);
|
||||
return;
|
||||
#if 0
|
||||
case BackgroundPixmap:
|
||||
pTile = pWin->background.pixmap;
|
||||
if (tridentPatternDimOk (pTile->drawable.width) &&
|
||||
tridentPatternDimOk (pTile->drawable.height))
|
||||
{
|
||||
tridentFillBoxTiled ((DrawablePtr)pWin,
|
||||
(int)REGION_NUM_RECTS(pRegion),
|
||||
REGION_RECTS(pRegion),
|
||||
pTile,
|
||||
pWin->drawable.x, pWin->drawable.y, GXcopy);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case BackgroundPixel:
|
||||
tridentFillBoxSolid((DrawablePtr)pWin,
|
||||
(int)REGION_NUM_RECTS(pRegion),
|
||||
REGION_RECTS(pRegion),
|
||||
pWin->background.pixel, GXcopy);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case PW_BORDER:
|
||||
if (pWin->borderIsPixel)
|
||||
{
|
||||
tridentFillBoxSolid((DrawablePtr)pWin,
|
||||
(int)REGION_NUM_RECTS(pRegion),
|
||||
REGION_RECTS(pRegion),
|
||||
pWin->border.pixel, GXcopy);
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
pTile = pWin->border.pixmap;
|
||||
if (tridentPatternDimOk (pTile->drawable.width) &&
|
||||
tridentPatternDimOk (pTile->drawable.height))
|
||||
{
|
||||
tridentFillBoxTiled ((DrawablePtr)pWin,
|
||||
(int)REGION_NUM_RECTS(pRegion),
|
||||
REGION_RECTS(pRegion),
|
||||
pTile,
|
||||
pWin->drawable.x, pWin->drawable.y, GXcopy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
fbPaintWindow (pWin, pRegion, what);
|
||||
}
|
||||
|
||||
Bool
|
||||
tridentDrawInit (ScreenPtr pScreen)
|
||||
{
|
||||
/*
|
||||
* Replace various fb screen functions
|
||||
*/
|
||||
pScreen->CreateGC = tridentCreateGC;
|
||||
pScreen->CopyWindow = tridentCopyWindow;
|
||||
pScreen->PaintWindowBackground = tridentPaintWindow;
|
||||
pScreen->PaintWindowBorder = tridentPaintWindow;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
tridentDrawEnable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupTrident(pScreen);
|
||||
CARD32 cmd;
|
||||
CARD32 base;
|
||||
CARD16 stride;
|
||||
CARD32 format;
|
||||
int tries;
|
||||
|
||||
stride = pScreenPriv->screen->pixelStride;
|
||||
switch (pScreenPriv->screen->bitsPerPixel) {
|
||||
case 8:
|
||||
format = COP_DEPTH_8;
|
||||
break;
|
||||
case 16:
|
||||
format = COP_DEPTH_16;
|
||||
break;
|
||||
case 24:
|
||||
format = COP_DEPTH_24_32;
|
||||
break;
|
||||
case 32:
|
||||
format = COP_DEPTH_24_32;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* compute a few things which will be set every time the
|
||||
* accelerator is used; this avoids problems with APM
|
||||
*/
|
||||
tridentc->cop_depth = COP_MULTI_DEPTH | format;
|
||||
tridentc->cop_stride = COP_MULTI_STRIDE | (stride << 16) | (stride);
|
||||
|
||||
#define NUM_TRIES 100000
|
||||
for (tries = 0; tries < NUM_TRIES; tries++)
|
||||
if (!(cop->status & COP_STATUS_BUSY))
|
||||
break;
|
||||
if (cop->status & COP_STATUS_BUSY)
|
||||
FatalError ("Can't initialize graphics coprocessor");
|
||||
cop->multi = COP_MULTI_CLIP_TOP_LEFT;
|
||||
cop->multi = COP_MULTI_MASK | 0;
|
||||
cop->src_offset = 0;
|
||||
cop->dst_offset = 0;
|
||||
cop->z_offset = 0;
|
||||
cop->clip_bottom_right = 0x0fff0fff;
|
||||
|
||||
_tridentInit(cop,tridentc);
|
||||
_tridentSetSolidRect(cop, pScreen->blackPixel, GXcopy, cmd);
|
||||
_tridentRect (cop, 0, 0,
|
||||
pScreenPriv->screen->width, pScreenPriv->screen->height,
|
||||
cmd);
|
||||
_tridentWaitIdleEmpty (cop);
|
||||
}
|
||||
|
||||
void
|
||||
tridentDrawDisable (ScreenPtr pScreen)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
tridentDrawFini (ScreenPtr pScreen)
|
||||
{
|
||||
}
|
63
hw/kdrive/trident/tridentdraw.h
Normal file
63
hw/kdrive/trident/tridentdraw.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifndef _TRIDENTDRAW_H_
|
||||
#define _TRIDENTDRAW_H_
|
||||
|
||||
#define SetupTrident(s) KdScreenPriv(s); \
|
||||
tridentCardInfo(pScreenPriv); \
|
||||
Cop *cop = tridentc->cop
|
||||
|
||||
#define _tridentInit(cop,tridentc) { \
|
||||
if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
|
||||
(cop)->multi = (tridentc)->cop_depth; \
|
||||
(cop)->multi = (tridentc)->cop_stride; \
|
||||
} \
|
||||
|
||||
#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
|
||||
cop->multi = COP_MULTI_PATTERN; \
|
||||
cop->multi = COP_MULTI_ROP | tridentRop[alu]; \
|
||||
cop->fg = (pix); \
|
||||
cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
|
||||
}
|
||||
|
||||
#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
|
||||
(cop)->dst_start_xy = TRI_XY (x1,y1); \
|
||||
(cop)->dst_end_xy = TRI_XY(x2,y2); \
|
||||
(cop)->command = (cmd); \
|
||||
}
|
||||
|
||||
#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \
|
||||
COP_STATUS_DPE_BUSY | \
|
||||
COP_STATUS_MI_BUSY | \
|
||||
COP_STATUS_FIFO_BUSY)
|
||||
|
||||
#define _tridentWaitDone(cop) while ((cop)->status & COP_STATUS_BUSY)
|
||||
|
||||
#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop);
|
||||
|
||||
#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
|
||||
|
||||
#endif
|
54
hw/kdrive/trident/tridentstub.c
Normal file
54
hw/kdrive/trident/tridentstub.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "trident.h"
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
|
||||
if (LinuxFindPci (0x1023, 0x9525, 0, &attr))
|
||||
KdCardInfoAdd (&tridentFuncs, &attr, 0);
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
21
hw/kdrive/trio/Imakefile
Normal file
21
hw/kdrive/trio/Imakefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = s3.c s3clock.c s3cmap.c s3curs.c s3draw.c s3gc.c s3stub.c
|
||||
|
||||
OBJS = s3.o s3clock.o s3cmap.o s3curs.o s3draw.o s3gc.o s3stub.o
|
||||
|
||||
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
DEFINES = -DS3_TRIO
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(trio,$(OBJS))
|
||||
DependTarget()
|
||||
|
||||
LinkSourceFile(s3draw.h,../savage)
|
||||
LinkSourceFile(s3draw.c,../savage)
|
||||
LinkSourceFile(s3gc.c,../savage)
|
1298
hw/kdrive/trio/s3.c
Normal file
1298
hw/kdrive/trio/s3.c
Normal file
File diff suppressed because it is too large
Load Diff
1238
hw/kdrive/trio/s3.h
Normal file
1238
hw/kdrive/trio/s3.h
Normal file
File diff suppressed because it is too large
Load Diff
89
hw/kdrive/trio/s3clock.c
Normal file
89
hw/kdrive/trio/s3clock.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
|
||||
/* all in kHz */
|
||||
#define MIN_VCO 180000.0
|
||||
#define MAX_VCO 360000.0
|
||||
|
||||
void
|
||||
s3GetClock (S3Timing *t, 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
|
||||
*/
|
||||
for (R = 0; R <= maxR; R++)
|
||||
{
|
||||
f_vco = target * (1 << R);
|
||||
if (MIN_VCO <= f_vco && f_vco < MAX_VCO)
|
||||
break;
|
||||
}
|
||||
|
||||
/* M = f_out / f_ref * ((N + 2) * (1 << R)); */
|
||||
besterr = target;
|
||||
for (N = 0; N <= maxN; N++)
|
||||
{
|
||||
M = (target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) / S3_CLOCK_REF - 2;
|
||||
if (0 <= M && M <= maxM)
|
||||
{
|
||||
f_out = S3_CLOCK(M,N,R);
|
||||
err = target - f_out;
|
||||
if (err < 0)
|
||||
err = -err;
|
||||
if (err < besterr)
|
||||
{
|
||||
besterr = err;
|
||||
bestM = M;
|
||||
bestN = N;
|
||||
}
|
||||
}
|
||||
}
|
||||
*Mp = bestM;
|
||||
*Np = bestN;
|
||||
*Rp = R;
|
||||
}
|
70
hw/kdrive/trio/s3cmap.c
Normal file
70
hw/kdrive/trio/s3cmap.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
LockS3 (s3c);
|
||||
while (ndef--)
|
||||
{
|
||||
*dac_rd_ad = pdefs->pixel;
|
||||
pdefs->red = *dac_data << 10;
|
||||
pdefs->green = *dac_data << 10;
|
||||
pdefs->blue = *dac_data << 10;
|
||||
pdefs++;
|
||||
}
|
||||
UnlockS3(s3c);
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
LockS3(s3c);
|
||||
_s3WaitVRetrace (s3);
|
||||
while (ndef--)
|
||||
{
|
||||
*dac_wt_ad = pdefs->pixel;
|
||||
*dac_data = pdefs->red >> 10;
|
||||
*dac_data = pdefs->green >> 10;
|
||||
*dac_data = pdefs->blue >> 10;
|
||||
pdefs++;
|
||||
}
|
||||
UnlockS3(s3c);
|
||||
}
|
||||
|
433
hw/kdrive/trio/s3curs.c
Normal file
433
hw/kdrive/trio/s3curs.c
Normal file
|
@ -0,0 +1,433 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
#include "cursorstr.h"
|
||||
|
||||
#define SetupCursor(s) KdScreenPriv(s); \
|
||||
s3CardInfo(pScreenPriv); \
|
||||
s3ScreenInfo(pScreenPriv); \
|
||||
S3Ptr s3 = s3c->s3; \
|
||||
S3Cursor *pCurPriv = &s3s->cursor
|
||||
|
||||
static void
|
||||
_s3MoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CARD8 xlow, xhigh, ylow, yhigh;
|
||||
CARD8 xoff, yoff;
|
||||
|
||||
x -= pCurPriv->xhot;
|
||||
xoff = 0;
|
||||
if (x < 0)
|
||||
{
|
||||
xoff = -x;
|
||||
x = 0;
|
||||
}
|
||||
y -= pCurPriv->yhot;
|
||||
yoff = 0;
|
||||
if (y < 0)
|
||||
{
|
||||
yoff = -y;
|
||||
y = 0;
|
||||
}
|
||||
xlow = (CARD8) x;
|
||||
xhigh = (CARD8) (x >> 8);
|
||||
ylow = (CARD8) y;
|
||||
yhigh = (CARD8) (y >> 8);
|
||||
|
||||
|
||||
/* This is the recommended order to move the cursor */
|
||||
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x46, xhigh);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x47, xlow);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x49, ylow);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4e, xoff);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4f, yoff);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x48, yhigh);
|
||||
}
|
||||
|
||||
static void
|
||||
s3MoveCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pCurPriv->has_cursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
LockS3(s3c);
|
||||
_s3UnlockExt(s3);
|
||||
_s3MoveCursor (pScreen, x, y);
|
||||
_s3LockExt(s3);
|
||||
UnlockS3(s3c);
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
switch (pScreenPriv->screen->bitsPerPixel) {
|
||||
case 4:
|
||||
pCurPriv->source |= pCurPriv->source << 4;
|
||||
pCurPriv->mask |= pCurPriv->mask << 4;
|
||||
case 8:
|
||||
pCurPriv->source |= pCurPriv->source << 8;
|
||||
pCurPriv->mask |= pCurPriv->mask << 8;
|
||||
case 16:
|
||||
pCurPriv->source |= pCurPriv->source << 16;
|
||||
pCurPriv->mask |= pCurPriv->mask << 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_s3SetCursorColors (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
/* set foreground */
|
||||
/* Reset cursor color stack pointers */
|
||||
(void) _s3ReadIndexRegister(&s3->crt_vga_3d4, 0x45);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source >> 8);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source >> 16);
|
||||
|
||||
/* set background */
|
||||
/* Reset cursor color stack pointers */
|
||||
(void) _s3ReadIndexRegister(&s3->crt_vga_3d4, 0x45);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask >> 8);
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask >> 16);
|
||||
}
|
||||
|
||||
void
|
||||
s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
xColorItem sourceColor, maskColor;
|
||||
|
||||
if (!pCurPriv->has_cursor || !pCursor)
|
||||
return;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pdef)
|
||||
{
|
||||
while (ndef)
|
||||
{
|
||||
if (pdef->pixel == pCurPriv->source ||
|
||||
pdef->pixel == pCurPriv->mask)
|
||||
break;
|
||||
ndef--;
|
||||
}
|
||||
if (!ndef)
|
||||
return;
|
||||
}
|
||||
s3AllocCursorColors (pScreen);
|
||||
LockS3 (s3c);
|
||||
_s3UnlockExt(s3);
|
||||
_s3SetCursorColors (pScreen);
|
||||
_s3LockExt (s3);
|
||||
UnlockS3 (s3c);
|
||||
}
|
||||
|
||||
static void
|
||||
s3LoadCursor (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
CursorPtr pCursor = pCurPriv->pCursor;
|
||||
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;
|
||||
int i, j;
|
||||
int cursor_address;
|
||||
int wsrc;
|
||||
unsigned char ramdac_control_;
|
||||
|
||||
/*
|
||||
* Allocate new colors
|
||||
*/
|
||||
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;
|
||||
|
||||
/*
|
||||
* Stick new image into cursor memory
|
||||
*/
|
||||
ram = (unsigned short *) s3s->cursor_base;
|
||||
mskLine = (unsigned short *) bits->mask;
|
||||
srcLine = (unsigned short *) bits->source;
|
||||
|
||||
h = bits->height;
|
||||
if (h > S3_CURSOR_HEIGHT)
|
||||
h = S3_CURSOR_HEIGHT;
|
||||
|
||||
wsrc = BitmapBytePad(bits->width) / 2; /* words 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++) {
|
||||
|
||||
unsigned short m, s;
|
||||
|
||||
if (i < h && j < wsrc)
|
||||
{
|
||||
m = *msk++;
|
||||
s = *src++;
|
||||
xor = m & s;
|
||||
and = ~m;
|
||||
}
|
||||
else
|
||||
{
|
||||
and = 0xffff;
|
||||
xor = 0x0000;
|
||||
}
|
||||
|
||||
S3InvertBits16(and);
|
||||
*ram++ = and;
|
||||
S3InvertBits16(xor);
|
||||
*ram++ = xor;
|
||||
}
|
||||
}
|
||||
|
||||
_s3WaitIdle (s3);
|
||||
_s3UnlockExt (s3);
|
||||
|
||||
/* Set new color */
|
||||
_s3SetCursorColors (pScreen);
|
||||
|
||||
/* Enable the cursor */
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x45, 0x01);
|
||||
|
||||
/* Wait for VRetrace to make sure the position is read */
|
||||
_s3WaitVRetrace (s3);
|
||||
|
||||
/* Move to new position */
|
||||
_s3MoveCursor (pScreen, x, y);
|
||||
|
||||
_s3LockExt (s3);
|
||||
UnlockS3(s3c);
|
||||
}
|
||||
|
||||
static void
|
||||
s3UnloadCursor (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
LockS3 (s3c);
|
||||
_s3UnlockExt(s3);
|
||||
|
||||
/* Disable cursor */
|
||||
_s3WriteIndexRegister (&s3->crt_vga_3d4, 0x45, 0);
|
||||
|
||||
_s3LockExt(s3);
|
||||
UnlockS3 (s3c);
|
||||
}
|
||||
|
||||
static Bool
|
||||
s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return TRUE;
|
||||
|
||||
/* miRecolorCursor does this */
|
||||
if (pCurPriv->pCursor == pCursor)
|
||||
{
|
||||
if (pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
s3UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
s3SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
|
||||
{
|
||||
SetupCursor(pScreen);
|
||||
|
||||
pCurPriv->pCursor = pCursor;
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCursor)
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
else
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
|
||||
miPointerSpriteFuncRec s3PointerSpriteFuncs = {
|
||||
s3RealizeCursor,
|
||||
s3UnrealizeCursor,
|
||||
s3SetCursor,
|
||||
s3MoveCursor,
|
||||
};
|
||||
|
||||
static void
|
||||
s3QueryBestSize (int class,
|
||||
unsigned short *pwidth, unsigned short *pheight,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case CursorShape:
|
||||
if (*pwidth > pCurPriv->width)
|
||||
*pwidth = pCurPriv->width;
|
||||
if (*pheight > pCurPriv->height)
|
||||
*pheight = pCurPriv->height;
|
||||
if (*pwidth > pScreen->width)
|
||||
*pwidth = pScreen->width;
|
||||
if (*pheight > pScreen->height)
|
||||
*pheight = pScreen->height;
|
||||
break;
|
||||
default:
|
||||
fbQueryBestSize (class, pwidth, pheight, pScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
s3CursorInit (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!s3s->cursor_base)
|
||||
{
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pCurPriv->width = S3_CURSOR_WIDTH;
|
||||
pCurPriv->height= S3_CURSOR_HEIGHT;
|
||||
pScreen->QueryBestSize = s3QueryBestSize;
|
||||
miPointerInitialize (pScreen,
|
||||
&s3PointerSpriteFuncs,
|
||||
&kdPointerScreenFuncs,
|
||||
FALSE);
|
||||
pCurPriv->has_cursor = TRUE;
|
||||
pCurPriv->pCursor = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorEnable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
miPointerPosition (&x, &y);
|
||||
s3LoadCursor (pScreen, x, y);
|
||||
}
|
||||
else
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorDisable (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
if (!pScreenPriv->enabled)
|
||||
return;
|
||||
|
||||
if (pCurPriv->has_cursor)
|
||||
{
|
||||
if (pCurPriv->pCursor)
|
||||
{
|
||||
s3UnloadCursor (pScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
s3CursorFini (ScreenPtr pScreen)
|
||||
{
|
||||
SetupCursor (pScreen);
|
||||
|
||||
pCurPriv->pCursor = NULL;
|
||||
}
|
59
hw/kdrive/trio/s3stub.c
Normal file
59
hw/kdrive/trio/s3stub.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* $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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "s3.h"
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardAttr attr;
|
||||
CARD32 count;
|
||||
|
||||
count = 0;
|
||||
while (LinuxFindPci (0x5333, 0x8904, count, &attr))
|
||||
{
|
||||
KdCardInfoAdd (&s3Funcs, &attr, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
15
hw/kdrive/ts300/Imakefile
Normal file
15
hw/kdrive/ts300/Imakefile
Normal file
|
@ -0,0 +1,15 @@
|
|||
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 $
|
||||
#include <Server.tmpl>
|
||||
|
||||
SRCS = ts300.c
|
||||
|
||||
OBJS = ts300.o
|
||||
|
||||
INCLUDES = -I../trio -I../sis530 -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
|
||||
-I../../../fb -I../../../mi -I../../../include -I../../../os \
|
||||
-I$(EXTINCSRC) -I$(XINCLUDESRC)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(ts300,$(OBJS))
|
||||
DependTarget()
|
131
hw/kdrive/ts300/ts300.c
Normal file
131
hw/kdrive/ts300/ts300.c
Normal file
|
@ -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.
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include "kdrive.h"
|
||||
|
||||
extern KdCardFuncs sisFuncs;
|
||||
extern KdCardFuncs s3Funcs;
|
||||
|
||||
/*
|
||||
* Kludgy code to parse the ascii /proc/pci file as the TS300
|
||||
* is running a 2.0 kernel
|
||||
*/
|
||||
BOOL
|
||||
HasPCI (char *name, KdCardAttr *attr)
|
||||
{
|
||||
FILE *f;
|
||||
char line[1024];
|
||||
BOOL waiting;
|
||||
BOOL found = FALSE;
|
||||
char *mem;
|
||||
|
||||
f = fopen ("/proc/pci", "r");
|
||||
if (!f)
|
||||
return FALSE;
|
||||
waiting = FALSE;
|
||||
attr->naddr = 0;
|
||||
while (fgets (line, sizeof (line), f))
|
||||
{
|
||||
if (waiting)
|
||||
{
|
||||
|
||||
if (mem = strstr (line, "memory at "))
|
||||
{
|
||||
mem += strlen ("memory at ");
|
||||
attr->address[attr->naddr++] = strtoul (mem, NULL, 0);
|
||||
found = TRUE;
|
||||
}
|
||||
else if (mem = strstr (line, "I/O at "))
|
||||
{
|
||||
mem += strlen ("I/O at ");
|
||||
attr->io = strtoul (mem, NULL, 0);
|
||||
found = TRUE;
|
||||
}
|
||||
else if (strstr (line, "Bus") && strstr (line, "device") &&
|
||||
strstr (line, "function"))
|
||||
break;
|
||||
}
|
||||
else if (strstr (line, "VGA compatible controller"))
|
||||
{
|
||||
if (strstr (line, name))
|
||||
waiting = TRUE;
|
||||
}
|
||||
}
|
||||
fclose (f);
|
||||
return found;
|
||||
}
|
||||
|
||||
typedef struct _PCICard {
|
||||
char *user;
|
||||
char *name;
|
||||
KdCardFuncs *funcs;
|
||||
} PCICard;
|
||||
|
||||
PCICard PCICards[] = {
|
||||
"sis", "Silicon Integrated Systems", &sisFuncs,
|
||||
"s3", "S3 Inc.", &s3Funcs,
|
||||
};
|
||||
|
||||
#define NUM_PCI_CARDS (sizeof (PCICards) / sizeof (PCICards[0]))
|
||||
|
||||
void
|
||||
InitCard (char *name)
|
||||
{
|
||||
KdCardInfo *card;
|
||||
CARD32 fb;
|
||||
int i;
|
||||
KdCardAttr attr;
|
||||
|
||||
for (i = 0; i < NUM_PCI_CARDS; i++)
|
||||
{
|
||||
if (!name || !strcmp (name, PCICards[i].user))
|
||||
{
|
||||
if (HasPCI (PCICards[i].name, &attr))
|
||||
{
|
||||
KdCardInfoAdd (PCICards[i].funcs, &attr, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
KdInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
KdOsInit (&LinuxFuncs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user