diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:03:47 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:03:47 +0000 |
commit | c57959ad6a4c0f5329762f401fd7871ffb2ee90c (patch) | |
tree | f223828f827382311611edf114ddd0c42cb3b23f /hw/kdrive | |
parent | 9508a382f8a9f241dab097d921b6d290c1c3a776 (diff) |
merge XFree86 4.3.0.1 to -CURRENT
Diffstat (limited to 'hw/kdrive')
177 files changed, 0 insertions, 63310 deletions
diff --git a/hw/kdrive/Imakefile b/hw/kdrive/Imakefile deleted file mode 100644 index 2ff182c38..000000000 --- a/hw/kdrive/Imakefile +++ /dev/null @@ -1,34 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/Imakefile,v 1.7 2001/05/23 08:56:08 alanh Exp $ -KDRIVE=. -#include "Kdrive.tmpl" - -#if BuildRender -RENDERSRCS=kpict.c -RENDEROBJS=kpict.o -#endif - -#if BuildXvExt -XVSRCS=kxv.c -XVOBJS=kxv.o -#endif - -#if XipaqServer -DEFINES = -DXIPAQ -#endif - -SRCS = kaa.c kcmap.c kcolor.c kdrive.c kinfo.c kinput.c kmap.c knoop.c ktest.c \ - vga.c kasync.c kmode.c kcurscol.c kshadow.c $(RENDERSRCS) $(XVSRCS) - -OBJS = kaa.o kcmap.o kcolor.o kdrive.o kinfo.o kinput.o kmap.o knoop.o ktest.o \ - vga.o kasync.o kmode.o kcurscol.o kshadow.o $(RENDEROBJS) $(XVOBJS) - -INCLUDES = $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(kdrive,$(OBJS)) - -SpecialCObjectRule(kdrive,,$(EXT_DEFINES)) - -InstallManPage(Xkdrive,$(MANDIR)) -DependTarget() diff --git a/hw/kdrive/Kdrive.tmpl b/hw/kdrive/Kdrive.tmpl deleted file mode 100644 index e259b59a2..000000000 --- a/hw/kdrive/Kdrive.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/Kdrive.tmpl,v 1.3tsi Exp $ - -#include <Server.tmpl> - -#if BuildRender -RENDERINCS=-I$(KDRIVE)/../../render -#endif - -#if BuildRandR -RANDRINCS=-I$(KDRIVE)/../../randr -#endif - -KDINCS = -I$(KDRIVE) -I$(XBUILDINCDIR) -I$(FONTINCSRC) \ - -I$(KDRIVE)/../../fb -I$(KDRIVE)/../../mi -I$(KDRIVE)/../../Xext \ - -I$(KDRIVE)/../../miext/shadow -I$(KDRIVE)/../../miext/layer \ - -I$(KDRIVE)/../../include -I$(KDRIVE)/../../os \ - -I$(EXTINCSRC) -I$(XINCLUDESRC) $(RENDERINCS) $(RANDRINCS) diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am deleted file mode 100644 index eb185616d..000000000 --- a/hw/kdrive/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -if KDRIVEVESA -VESA_SUBDIRS = vesa mach64 mga nvidia r128 smi -endif - -SUBDIRS = \ - src \ - linux \ - fbdev \ - $(VESA_SUBDIRS) - diff --git a/hw/kdrive/Xkdrive.man b/hw/kdrive/Xkdrive.man deleted file mode 100644 index b4f1a977d..000000000 --- a/hw/kdrive/Xkdrive.man +++ /dev/null @@ -1,77 +0,0 @@ -.\" $RCSId: xc/programs/Xserver/hw/kdrive/Xkdrive.man,v 1.3 2001/01/24 00:06:10 dawes Exp $ -.\" -.TH Xkdrive 1 __vendorversion__ -.SH NAME -Xkdrive \- tiny X server -.SH SYNOPSIS -.B Xvesa -.RI [ :display ] -.RI [ option ...] - -.B Xfbdev -.RI [ :display ] -.RI [ option ...] - -.B Xigs -.RI [ :display ] -.RI [ option ...] - -.B Xtrident -.RI [ :display ] -.RI [ option ...] - -.B Xsis530 -.RI [ :display ] -.RI [ option ...] - -.B Xtrio -.RI [ :display ] -.RI [ option ...] - -.B Xitsy -.RI [ :display ] -.RI [ option ...] -.SH DESCRIPTION -.B Xkdrive -is a family of X servers designed to be particularly small. This -manual page describes the common functionality of the -.B Xkdrive -servers; for information on a specific X server, please refer to the -relevant manual page. -.SH OPTIONS -In addition to the standard options accepted by all X servers (see -Xserver(1)), all the -.B Xkdrive -servers accept the following options: -.TP 8 -.B -card \fIpcmcia\fP -use pcmcia card as additional screen. -.TP 8 -.B -dumb -disable hardware acceleration. -.TP 8 -.B -origin \fIX\fP,\fIY\fP -Locates the next screen in the Xinerama virtual screen. -.TP 8 -.B -screen \fIwidth\fBx\fIheight\fR[\fBx\fIdepth\fR[\fBx\fIfreq\fR]]\fR[\fB@\fIrotation\fR]\fB -use a screen of the specified \fIwidth\fP, \fIheight\fP, screen \fIdepth\fP, \fIfrequency\fP, and \fIrotation\fP (0, 90, 180 and 270 are legal values). -.TP 8 -.B -softCursor -disable the hardware cursor. -.TP 8 -.B -videoTest -start the server, pause momentarily, and exit. -.TP 8 -.B -zaphod -disable switching screens by moving the pointer across a screen boundary. -.TP 8 -.B -2button -enable emulation of a middle mouse button by chording. -.TP 8 -.B -3button -disable emulation of a middle mouse button by chording. -.SH SEE ALSO -X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), Xvesa(1), Xfbdev(1). -.SH AUTHORS -The Xkdrive common core was written by Keith Packard, -and is based on the Sample Implementation of X. diff --git a/hw/kdrive/chips/Imakefile b/hw/kdrive/chips/Imakefile deleted file mode 100644 index 72970d837..000000000 --- a/hw/kdrive/chips/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/chips/Imakefile,v 1.6 2000/10/20 00:19:51 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = chips.c chipsdraw.c chipsstub.c - -OBJS = chips.o chipsdraw.o chipsstub.o - -INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/vesa - -NormalLibraryObjectRule() -NormalLibraryTarget(chips,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/chips/chips.c b/hw/kdrive/chips/chips.c deleted file mode 100644 index c0b0bb6a8..000000000 --- a/hw/kdrive/chips/chips.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright © 2001 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.18 2001/06/04 09:45:42 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "chips.h" -#include <sys/io.h> - -#undef CHIPS_DEBUG - -Bool -chipsCardInit (KdCardInfo *card) -{ - int k; - char *pixels; - ChipsCardInfo *chipsc; - CARD8 r00, r01, r02; - CARD8 r39; - - chipsc = (ChipsCardInfo *) xalloc (sizeof (ChipsCardInfo)); - if (!chipsc) - return FALSE; - - iopl (3); - - if (!vesaInitialize (card, &chipsc->vesa)) - { - xfree (chipsc); - return FALSE; - } - -#ifdef USE_PCI - chipsc->window = (CARD32 *) (chipsc->cop_base + 0x10000); -#else - chipsc->window = 0; -#endif - card->driver = chipsc; - - return TRUE; -} - -Bool -chipsScreenInit (KdScreenInfo *screen) -{ - ChipsCardInfo *chipsc = screen->card->driver; - ChipsScreenInfo *chipss; - int screen_size, memory; - CARD32 mmio_base; - CARD32 mmio_size; - - chipss = (ChipsScreenInfo *) xalloc (sizeof (ChipsScreenInfo)); - if (!chipss) - return FALSE; - memset (chipss, '\0', sizeof (ChipsScreenInfo)); - if (!vesaScreenInitialize (screen, &chipss->vesa)) - { - xfree (chipss); - return FALSE; - } - - if (chipss->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - if (!screen->dumb) - { - chipss->mmio_base = (CARD8 *) KdMapDevice (CHIPS_MMIO_BASE(chipss), - CHIPS_MMIO_SIZE(chipss)); - - if (chipss->mmio_base) - { - KdSetMappedMode (CHIPS_MMIO_BASE(chipss), - CHIPS_MMIO_SIZE(chipss), - KD_MAPPED_MODE_REGISTERS); - } - else - screen->dumb = TRUE; - } - else - chipss->mmio_base = 0; - - chipss->screen = chipss->vesa.fb; - memory = chipss->vesa.fb_size; - - screen_size = screen->fb[0].byteStride * screen->height; - - if (chipss->screen && memory >= screen_size + 2048) - { - memory -= 2048; - chipss->cursor_base = chipss->screen + memory - 2048; - } - else - chipss->cursor_base = 0; - memory -= screen_size; - if (memory > screen->fb[0].byteStride) - { - chipss->off_screen = chipss->screen + screen_size; - chipss->off_screen_size = memory; - } - else - { - chipss->off_screen = 0; - chipss->off_screen_size = 0; - } - screen->driver = chipss; - return TRUE; -} - -Bool -chipsInitScreen (ScreenPtr pScreen) -{ - return vesaInitScreen (pScreen); -} - -Bool -chipsFinishInitScreen (ScreenPtr pScreen) -{ - return vesaFinishInitScreen (pScreen); -} - -CARD8 -chipsReadXR (ChipsScreenInfo *chipss, CARD8 index) -{ - CARD8 value; - outb (index, 0x3d6); - value = inb (0x3d7); - return value; -} - -void -chipsWriteXR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value) -{ - outb (index, 0x3d6); - outb (value, 0x3d7); -} - -CARD8 -chipsReadFR (ChipsScreenInfo *chipss, CARD8 index) -{ - CARD8 value; - outb (index, 0x3d0); - value = inb (0x3d1); - return value; -} - -void -chipsWriteFR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value) -{ - outb (index, 0x3d0); - outb (value, 0x3d1); -} - -CARD8 -chipsReadSeq (ChipsScreenInfo *chipss, CARD8 index) -{ - CARD8 value; - outb (index, 0x3c4); - value = inb (0x3c5); - return value; -} - -void -chipsWriteSeq (ChipsScreenInfo *chipss, CARD8 index, CARD8 value) -{ - outb (index, 0x3c4); - outb (value, 0x3c5); -} - -void -chipsPreserve (KdCardInfo *card) -{ - ChipsCardInfo *chipss = card->driver; - vesaPreserve(card); -} - -void -chipsSetMMIO (ChipsCardInfo *chipsc) -{ -} - -void -chipsResetMMIO (ChipsCardInfo *chipsc) -{ -} - -Bool -chipsEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - ChipsCardInfo *chipsc = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - chipsSetMMIO (chipsc); - return TRUE; -} - -Bool -chipsDPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - chipsScreenInfo(pScreenPriv); - - ErrorF ("seqreg 0x01 0x%x\n", chipsReadSeq (chipss, 0x1)); - ErrorF ("dpmsreg XR61 0x%x\n", chipsReadXR (chipss, 0x61)); - ErrorF ("dpmsreg XR73 0x%x\n", chipsReadXR (chipss, 0x73)); - - ErrorF ("flat panel FR05 0x%x\n", chipsReadFR (chipss, 0x5)); - ErrorF ("flat panel XR52 0x%x\n", chipsReadXR (chipss, 0x52)); - return TRUE; -} - -void -chipsDisable (ScreenPtr pScreen) -{ - vesaDisable (pScreen); -} - -void -chipsRestore (KdCardInfo *card) -{ - ChipsCardInfo *chipsc = card->driver; - - chipsResetMMIO (chipsc); - vesaRestore (card); -} - -void -chipsScreenFini (KdScreenInfo *screen) -{ - ChipsScreenInfo *chipss = (ChipsScreenInfo *) screen->driver; - - if (chipss->mmio_base) - { - KdUnmapDevice ((void *) chipss->mmio_base, CHIPS_MMIO_SIZE(chipss)); - KdResetMappedMode (CHIPS_MMIO_BASE(chipss), - CHIPS_MMIO_SIZE(chipss), - KD_MAPPED_MODE_REGISTERS); - } - vesaScreenFini (screen); - xfree (chipss); - screen->driver = 0; -} - -void -chipsCardFini (KdCardInfo *card) -{ - ChipsCardInfo *chipsc = card->driver; - - vesaCardFini (card); -} - -#define chipsCursorInit (void *) 0 -#define chipsCursorEnable (void *) 0 -#define chipsCursorDisable (void *) 0 -#define chipsCursorFini (void *) 0 -#define chipsRecolorCursor (void *) 0 - -KdCardFuncs chipsFuncs = { - chipsCardInit, /* cardinit */ - chipsScreenInit, /* scrinit */ - chipsInitScreen, /* initScreen */ - chipsPreserve, /* preserve */ - chipsEnable, /* enable */ - vesaDPMS, /* dpms */ - chipsDisable, /* disable */ - chipsRestore, /* restore */ - chipsScreenFini, /* scrfini */ - chipsCardFini, /* cardfini */ - - chipsCursorInit, /* initCursor */ - chipsCursorEnable, /* enableCursor */ - chipsCursorDisable, /* disableCursor */ - chipsCursorFini, /* finiCursor */ - chipsRecolorCursor, /* recolorCursor */ - - chipsDrawInit, /* initAccel */ - chipsDrawEnable, /* enableAccel */ - chipsDrawSync, /* syncAccel */ - chipsDrawDisable, /* disableAccel */ - chipsDrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ - chipsFinishInitScreen /* finishInitScreen */ -}; diff --git a/hw/kdrive/chips/chips.h b/hw/kdrive/chips/chips.h deleted file mode 100644 index 869a0717c..000000000 --- a/hw/kdrive/chips/chips.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Id: chips.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/chips/chips.h,v 1.9 2000/11/29 08:42:25 keithp Exp $ */ - -#ifndef _CHIPS_H_ -#define _CHIPS_H_ -#include <vesa.h> - -/* - * offset from ioport beginning - */ - -#define HIQV -#ifdef HIQV -#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x400000) -#else -#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x200000) -#endif -#define CHIPS_MMIO_SIZE(c) (0x20000) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _chipsSave { - int dummy; -} ChipsSave; - -typedef struct _chipsCardInfo { - VesaCardPrivRec vesa; - CARD32 *window; - Bool mmio; - ChipsSave save; -} ChipsCardInfo; - -#define getChipsCardInfo(kd) ((ChipsCardInfo *) ((kd)->card->driver)) -#define chipsCardInfo(kd) ChipsCardInfo *chipsc = getChipsCardInfo(kd) - -typedef struct _chipsCursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; - Pixel source, mask; -} ChipsCursor; - -#define CHIPS_CURSOR_WIDTH 64 -#define CHIPS_CURSOR_HEIGHT 64 - -typedef struct _chipsScreenInfo { - VesaScreenPrivRec vesa; - CARD8 *mmio_base; - CARD8 *cursor_base; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - ChipsCursor cursor; -} ChipsScreenInfo; - -#define getChipsScreenInfo(kd) ((ChipsScreenInfo *) ((kd)->screen->driver)) -#define chipsScreenInfo(kd) ChipsScreenInfo *chipss = getChipsScreenInfo(kd) - -Bool -chipsDrawInit (ScreenPtr pScreen); - -void -chipsDrawEnable (ScreenPtr pScreen); - -void -chipsDrawSync (ScreenPtr pScreen); - -void -chipsDrawDisable (ScreenPtr pScreen); - -void -chipsDrawFini (ScreenPtr pScreen); - -CARD8 -chipsReadXR (ChipsScreenInfo *chipsc, CARD8 index); - -void -chipsWriteXR (ChipsScreenInfo *chipsc, CARD8 index, CARD8 value); - -Bool -chipsCursorInit (ScreenPtr pScreen); - -void -chipsCursorEnable (ScreenPtr pScreen); - -void -chipsCursorDisable (ScreenPtr pScreen); - -void -chipsCursorFini (ScreenPtr pScreen); - -void -chipsRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); - -extern KdCardFuncs chipsFuncs; - -#endif /* _CHIPS_H_ */ diff --git a/hw/kdrive/chips/chipsdraw.c b/hw/kdrive/chips/chipsdraw.c deleted file mode 100644 index 4fc210597..000000000 --- a/hw/kdrive/chips/chipsdraw.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Id: tridentdraw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.10 2001/06/03 18:48:19 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "chips.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 chipsBltRop[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 */ -}; - -CARD8 chipsSolidRop[16] = { - /* GXclear */ 0x00, /* 0 */ - /* GXand */ 0xa0, /* src AND dst */ - /* GXandReverse */ 0x50, /* src AND NOT dst */ - /* GXcopy */ 0xf0, /* src */ - /* GXandInverted*/ 0x0a, /* NOT src AND dst */ - /* GXnoop */ 0xaa, /* dst */ - /* GXxor */ 0x5a, /* src XOR dst */ - /* GXor */ 0xfa, /* src OR dst */ - /* GXnor */ 0x05, /* NOT src AND NOT dst */ - /* GXequiv */ 0xa5, /* NOT src XOR dst */ - /* GXinvert */ 0x55, /* NOT dst */ - /* GXorReverse */ 0xf5, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x0f, /* NOT src */ - /* GXorInverted */ 0xaf, /* NOT src OR dst */ - /* GXnand */ 0x5f, /* NOT src OR NOT dst */ - /* GXset */ 0xff, /* 1 */ -}; - -/* Definitions for the Chips and Technology BitBLT engine communication. */ -/* These are done using Memory Mapped IO, of the registers */ -/* BitBLT modes for register 93D0. */ - -#ifdef HIQV -#define ctPATCOPY 0xF0 -#define ctLEFT2RIGHT 0x000 -#define ctRIGHT2LEFT 0x100 -#define ctTOP2BOTTOM 0x000 -#define ctBOTTOM2TOP 0x200 -#define ctSRCSYSTEM 0x400 -#define ctDSTSYSTEM 0x800 -#define ctSRCMONO 0x1000 -#define ctBGTRANSPARENT 0x22000 -#define ctCOLORTRANSENABLE 0x4000 -#define ctCOLORTRANSDISABLE 0x0 -#define ctCOLORTRANSDST 0x8000 -#define ctCOLORTRANSROP 0x0 -#define ctCOLORTRANSEQUAL 0x10000L -#define ctCOLORTRANSNEQUAL 0x0 -#define ctPATMONO 0x40000L -#define ctPATSOLID 0x80000L -#define ctPATSTART0 0x000000L -#define ctPATSTART1 0x100000L -#define ctPATSTART2 0x200000L -#define ctPATSTART3 0x300000L -#define ctPATSTART4 0x400000L -#define ctPATSTART5 0x500000L -#define ctPATSTART6 0x600000L -#define ctPATSTART7 0x700000L -#define ctSRCFG 0x000000L /* Where is this for the 65550?? */ -#else -#define ctPATCOPY 0xF0 -#define ctTOP2BOTTOM 0x100 -#define ctBOTTOM2TOP 0x000 -#define ctLEFT2RIGHT 0x200 -#define ctRIGHT2LEFT 0x000 -#define ctSRCFG 0x400 -#define ctSRCMONO 0x800 -#define ctPATMONO 0x1000 -#define ctBGTRANSPARENT 0x2000 -#define ctSRCSYSTEM 0x4000 -#define ctPATSOLID 0x80000L -#define ctPATSTART0 0x00000L -#define ctPATSTART1 0x10000L -#define ctPATSTART2 0x20000L -#define ctPATSTART3 0x30000L -#define ctPATSTART4 0x40000L -#define ctPATSTART5 0x50000L -#define ctPATSTART6 0x60000L -#define ctPATSTART7 0x70000L -#endif - -#define chipsFillPix(bpp,pixel) {\ - if (bpp == 8) \ - { \ - pixel = pixel & 0xff; \ - } \ - else if (bpp == 16) \ - { \ - pixel = pixel & 0xffff; \ - } \ -} - -static VOL8 *mmio; -static CARD32 byteStride; -static CARD32 bytesPerPixel; -static CARD32 pixelStride; - -void -chipsSet (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - chipsScreenInfo(pScreenPriv); - - mmio = chipss->mmio_base; - byteStride = pScreenPriv->screen->fb[0].byteStride; - bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3; - pixelStride = pScreenPriv->screen->fb[0].pixelStride; -} - -#ifdef HIQV -#define CHIPS_BR0 0x00 /* offset */ -#define CHIPS_BR1 0x04 /* bg */ -#define CHIPS_BR2 0x08 /* fg */ -#define CHIPS_BR3 0x0c /* monochrome */ -#define CHIPS_BR4 0x10 /* bitblt */ -#define CHIPS_BR5 0x14 /* pattern addr */ -#define CHIPS_BR6 0x18 /* source addr */ -#define CHIPS_BR7 0x1c /* dst addr */ -#define CHIPS_BR8 0x20 /* dst w/h */ -#else -#define CHIPS_DR0 0x83d0 -#define CHIPS_DR1 0x87d0 -#define CHIPS_DR2 0x8bd0 -#define CHIPS_DR3 0x8fd0 -#define CHIPS_DR4 0x93d0 -#define CHIPS_DR5 0x97d0 -#define CHIPS_DR6 0x9bd0 -#define CHIPS_DR7 0x9fd0 -#endif - -#define DBG(x) - -void -chipsPitch (int src, int dst) -{ - CARD32 p; - - p = ((dst & 0xffff) << 16) | (src & 0xffff); - DBG(ErrorF ("\tpitch 0x%x\n", p)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR0) = p; -#else - *(VOL32 *) (mmio + CHIPS_DR0) = p; -#endif -} - -void -chipsBg (Pixel bg) -{ - DBG(ErrorF ("\tbg 0x%x\n", bg)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff; -#else - *(VOL32 *) (mmio + CHIPS_DR2) = bg; -#endif -} - -void -chipsFg (Pixel fg) -{ - DBG(ErrorF ("\tfg 0x%x\n", fg)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR2) = fg; -#else - *(VOL32 *) (mmio + CHIPS_DR3) = fg; -#endif -} - -void -chipsOp (CARD32 op) -{ - DBG(ErrorF ("\top 0x%x\n", op)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR4) = op; -#else - *(VOL32 *) (mmio + CHIPS_DR4) = op; -#endif -} - -void -chipsRopSolid (int rop) -{ - CARD32 op; - - op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO; - chipsOp (op); -} - -void -chipsSrc (int addr) -{ - DBG(ErrorF ("\tsrc 0x%x\n", addr)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR6) = addr; -#else - *(VOL32 *) (mmio + CHIPS_DR5) = addr; -#endif -} - -void -chipsDst (int addr) -{ - DBG(ErrorF ("\tdst 0x%x\n", addr)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR7) = addr; -#else - *(VOL32 *) (mmio + CHIPS_DR6) = addr; -#endif -} - -void -chipsWidthHeightGo (int w, int h) -{ - DBG(ErrorF ("\twidth height %d/%d\n", w, h)); -#ifdef HIQV - *(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff); -#else - *(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff); -#endif -} - -void -chipsWaitIdle () -{ -#ifdef HIQV - int timeout = 0; - CARD8 tmp; - VOL32 *br4 = (VOL32 *) (mmio + CHIPS_BR4); - - DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4)); - DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20))); - for (;;) - { - if ((*br4 & 0x80000000) == 0) - break; - tmp = chipsReadXR (0, 0x20); - if ((tmp & 1) == 0) - break; - if (++timeout > 1000000) - { - ErrorF ("timeout\n"); - tmp = chipsReadXR (0, 0x20); - chipsWriteXR (0, 0x20, tmp | 2); - sleep (1); - chipsWriteXR (0, 0x20, tmp); - sleep (1); - } - } -#else - while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000) - ; -#endif -} - -Bool -chipsPrepareSolid (DrawablePtr pDrawable, - int alu, - Pixel pm, - Pixel fg) -{ - FbBits depthMask; - - DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg)); - depthMask = FbFullMask(pDrawable->depth); - if ((pm & depthMask) != depthMask) - return FALSE; - else - { - chipsSet (pDrawable->pScreen); - chipsWaitIdle (); - chipsFillPix(pDrawable->bitsPerPixel,fg); - chipsFg (fg); - chipsBg (fg); - chipsRopSolid (alu); - chipsPitch (byteStride, byteStride); - return TRUE; - } -} - -void -chipsSolid (int x1, int y1, int x2, int y2) -{ - CARD32 dst; - int w, h; - - DBG(ErrorF (" Solid %dx%d %dx%d\n", x1, y1, x2, y2)); - dst = y1 * byteStride + x1 * bytesPerPixel; - w = (x2 - x1) * bytesPerPixel; - h = (y2 - y1); - chipsWaitIdle (); - chipsDst (dst); - chipsWidthHeightGo (w, h); -} - -void -chipsDoneSolid (void) -{ -} - -static CARD32 copyOp; -Bool -chipsPrepareCopy (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - int dx, - int dy, - int alu, - Pixel pm) -{ - FbBits depthMask; - - DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg)); - depthMask = FbFullMask(pDstDrawable->depth); - if ((pm & depthMask) != depthMask) - return FALSE; - else - { - copyOp = chipsBltRop[alu]; - if (dy >= 0) - copyOp |= ctTOP2BOTTOM; - else - copyOp |= ctBOTTOM2TOP; - if (dx >= 0) - copyOp |= ctLEFT2RIGHT; - else - copyOp |= ctRIGHT2LEFT; - chipsSet (pDstDrawable->pScreen); - chipsWaitIdle (); - chipsOp (copyOp); - chipsPitch (byteStride, byteStride); - return TRUE; - } -} - -void -chipsCopy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - int src, dst; - if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP) - { - src = (srcY + h - 1) * byteStride; - dst = (dstY + h - 1) * byteStride; - } - else - { - src = srcY * byteStride; - dst = dstY * byteStride; - } - if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT) - { - src = src + (srcX + w) * bytesPerPixel - 1; - dst = dst + (dstX + w) * bytesPerPixel - 1; - } - else - { - src = src + srcX * bytesPerPixel; - dst = dst + dstX * bytesPerPixel; - } - chipsWaitIdle (); - chipsSrc (src); - chipsDst (dst); - chipsWidthHeightGo (w * bytesPerPixel, h); -} - -void -chipsDoneCopy (void) -{ -} - -KaaScreenPrivRec chipsKaa = { - chipsPrepareSolid, - chipsSolid, - chipsDoneSolid, - - chipsPrepareCopy, - chipsCopy, - chipsDoneCopy, -}; - -Bool -chipsDrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - chipsScreenInfo(pScreenPriv); - - switch (pScreenPriv->screen->fb[0].bitsPerPixel) { - case 8: - case 16: - break; - default: - return FALSE; - } - - if (!kaaDrawInit (pScreen, &chipsKaa)) - return FALSE; - - return TRUE; -} - -void -chipsDrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - chipsScreenInfo(pScreenPriv); - CARD8 mode; - - switch (pScreenPriv->screen->fb[0].bitsPerPixel) { - case 8: - mode = 0x00; - break; - case 16: - mode = 0x10; - break; - } - chipsSet (pScreen); - chipsWaitIdle (); - chipsWriteXR (chipss, 0x20, mode); - - KdMarkSync (pScreen); -} - -void -chipsDrawDisable (ScreenPtr pScreen) -{ -} - -void -chipsDrawFini (ScreenPtr pScreen) -{ -} - -void -chipsDrawSync (ScreenPtr pScreen) -{ - chipsSet (pScreen); - chipsWaitIdle (); -} diff --git a/hw/kdrive/chips/chipsstub.c b/hw/kdrive/chips/chipsstub.c deleted file mode 100644 index e46df972e..000000000 --- a/hw/kdrive/chips/chipsstub.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Id: chipsstub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/chips/chipsstub.c,v 1.1 2001/09/05 07:12:42 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "chips.h" - -extern int chips_clk, chips_mclk; - -void -InitCard (char *name) -{ - KdCardAttr attr; - - KdCardInfoAdd (&chipsFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/fbdev/Imakefile b/hw/kdrive/fbdev/Imakefile deleted file mode 100644 index 6f9650937..000000000 --- a/hw/kdrive/fbdev/Imakefile +++ /dev/null @@ -1,19 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/Imakefile,v 1.4 2001/05/23 08:56:08 alanh Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -#if XipaqServer -DEFINES = -DXIPAQ -#endif - -SRCS = fbdev.c fbinit.c - -OBJS = fbdev.o fbinit.o - -INCLUDES = $(KDINCS) -I. - -NormalLibraryObjectRule() -NormalLibraryTarget(fbdev,$(OBJS)) -InstallManPage(Xfbdev,$(MANDIR)) -DependTarget() diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am deleted file mode 100644 index 3a8131cfb..000000000 --- a/hw/kdrive/fbdev/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - @XSERVER_CFLAGS@ - -noinst_LIBRARIES = libfbdev.a - -bin_PROGRAMS = Xfbdev - -if TSLIB -TSLIB_FLAG = -lts -endif - -libfbdev_a_SOURCES = \ - fbdev.c \ - fbdev.h - -Xfbdev_SOURCES = \ - fbinit.c - -Xfbdev_LDADD = \ - libfbdev.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - -Xfbdev_DEPENDENCIES = \ - libfbdev.a \ - @KDRIVE_LIBS@ - diff --git a/hw/kdrive/fbdev/Xfbdev.man b/hw/kdrive/fbdev/Xfbdev.man deleted file mode 100644 index bfdae168f..000000000 --- a/hw/kdrive/fbdev/Xfbdev.man +++ /dev/null @@ -1,28 +0,0 @@ -.\" $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man,v 1.4 2001/01/27 18:20:40 dawes Exp $ -.\" -.TH Xfbdev 1 __vendorversion__ -.SH NAME -Xfbdev \- Linux framebuffer device tiny X server -.SH SYNOPSIS -.B Xfbdev -.RI [ :display ] -.RI [ option ...] -.SH DESCRIPTION -.B Xfbdev -is a generic X server for Linux. -.B Xfbdev -doesn't know about any particular hardware, and uses the framebuffer -provided by the Linux framebuffer device. -.SH OPTIONS -.B Xfbdev -accepts the common options of the Xkdrive family of servers. Please -see Xkdrive(1). -.SH KEYBOARD -To be written. -.SH SEE ALSO -X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1). -.SH AUTHORS -The -.B Xfbdev -server was written by Keith Packard. - diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c deleted file mode 100644 index 113584070..000000000 --- a/hw/kdrive/fbdev/fbdev.c +++ /dev/null @@ -1,693 +0,0 @@ -/* - * Id: fbdev.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.31 2002/10/14 18:01:40 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "fbdev.h" -#include <sys/ioctl.h> - -extern int KdTsPhyScreen; - -Bool -fbdevInitialize (KdCardInfo *card, FbdevPriv *priv) -{ - int k; - unsigned long off; - if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) { - perror("Error opening /dev/fb0\n"); - return FALSE; - } - /* quiet valgrind */ - memset (&priv->fix, '\0', sizeof (priv->fix)); - if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) { - perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO"); - close (priv->fd); - return FALSE; - } - /* quiet valgrind */ - memset (&priv->var, '\0', sizeof (priv->var)); - 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_base = (unsigned char *) mmap ((caddr_t) NULL, - priv->fix.smem_len, - PROT_READ|PROT_WRITE, - MAP_SHARED, - priv->fd, 0); - - if (priv->fb_base == (char *)-1) - { - perror("ERROR: mmap framebuffer fails!"); - close (priv->fd); - return FALSE; - } - off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize(); - priv->fb = priv->fb_base + off; - return TRUE; -} - -Bool -fbdevCardInit (KdCardInfo *card) -{ - FbdevPriv *priv; - - priv = (FbdevPriv *) xalloc (sizeof (FbdevPriv)); - if (!priv) - return FALSE; - - if (!fbdevInitialize (card, priv)) - { - xfree (priv); - return FALSE; - } - card->driver = priv; - - return TRUE; -} - -#define FBDEV_KLUDGE_FORMAT -#ifdef FBDEV_KLUDGE_FORMAT -static Pixel -fbdevMakeContig (Pixel orig, Pixel others) -{ - Pixel low; - - low = lowbit (orig) >> 1; - while (low && (others & low) == 0) - { - orig |= low; - low >>= 1; - } - return orig; -} -#endif - -Bool -fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) -{ - FbdevPriv *priv = screen->card->driver; - Pixel allbits; - int depth; - Bool gray; - - depth = priv->var.bits_per_pixel; - gray = priv->var.grayscale; - - switch (priv->fix.visual) { - case FB_VISUAL_PSEUDOCOLOR: - if (gray) - { - screen->fb[0].visuals = (1 << StaticGray); - /* could also support GrayScale, but what's the point? */ - } - else - { - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - } - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case FB_VISUAL_STATIC_PSEUDOCOLOR: - if (gray) - { - screen->fb[0].visuals = (1 << StaticGray); - } - else - { - screen->fb[0].visuals = (1 << StaticColor); - } - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case FB_VISUAL_TRUECOLOR: - case FB_VISUAL_DIRECTCOLOR: - screen->fb[0].visuals = (1 << TrueColor); -#define Mask(o,l) (((1 << l) - 1) << o) - screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length); - screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length); - screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length); -#ifdef FBDEV_KLUDGE_FORMAT - /* - * This is a kludge so that Render will work -- fill in the gaps - * in the pixel - */ - screen->fb[0].redMask = fbdevMakeContig (screen->fb[0].redMask, - screen->fb[0].greenMask| - screen->fb[0].blueMask); - - screen->fb[0].greenMask = fbdevMakeContig (screen->fb[0].greenMask, - screen->fb[0].redMask| - screen->fb[0].blueMask); - - screen->fb[0].blueMask = fbdevMakeContig (screen->fb[0].blueMask, - screen->fb[0].redMask| - screen->fb[0].greenMask); - -#endif - allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask; - depth = 32; - while (depth && !(allbits & (1 << (depth - 1)))) - depth--; - break; - default: - return FALSE; - break; - } - screen->rate = 72; - scrpriv->randr = screen->randr; - - return fbdevMapFramebuffer (screen); -} - -Bool -fbdevScreenInit (KdScreenInfo *screen) -{ - FbdevScrPriv *scrpriv; - - scrpriv = xalloc (sizeof (FbdevScrPriv)); - if (!scrpriv) - return FALSE; - memset (scrpriv, '\0', sizeof (FbdevScrPriv)); - screen->driver = scrpriv; - if (!fbdevScreenInitialize (screen, scrpriv)) - { - screen->driver = 0; - xfree (scrpriv); - return FALSE; - } - return TRUE; -} - -void * -fbdevWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - - if (!pScreenPriv->enabled) - return 0; - *size = priv->fix.line_length; - return (CARD8 *) priv->fb + row * priv->fix.line_length + offset; -} - -Bool -fbdevMapFramebuffer (KdScreenInfo *screen) -{ - FbdevScrPriv *scrpriv = screen->driver; - KdMouseMatrix m; - FbdevPriv *priv = screen->card->driver; - - if (scrpriv->randr != RR_Rotate_0) - scrpriv->shadow = TRUE; - else - scrpriv->shadow = FALSE; - - KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height); - - KdSetMouseMatrix (&m); - - screen->width = priv->var.xres; - screen->height = priv->var.yres; - screen->memory_base = (CARD8 *) (priv->fb); - screen->memory_size = 0; - screen->off_screen_base = 0; - screen->fb[0].depth = priv->var.bits_per_pixel; - screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel; - - if (scrpriv->shadow) - { - if (!KdShadowFbAlloc (screen, 0, - scrpriv->randr & (RR_Rotate_90|RR_Rotate_270))) - return FALSE; - } - else - { - screen->fb[0].byteStride = priv->fix.line_length; - screen->fb[0].pixelStride = (priv->fix.line_length * 8 / - priv->var.bits_per_pixel); - screen->fb[0].frameBuffer = (CARD8 *) (priv->fb); - } - - return TRUE; -} - -void -fbdevSetScreenSizes (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - FbdevPriv *priv = screen->card->driver; - - if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180)) - { - pScreen->width = priv->var.xres; - pScreen->height = priv->var.yres; - pScreen->mmWidth = screen->width_mm; - pScreen->mmHeight = screen->height_mm; - } - else - { - pScreen->width = priv->var.yres; - pScreen->height = priv->var.xres; - pScreen->mmWidth = screen->height_mm; - pScreen->mmHeight = screen->width_mm; - } -} - -Bool -fbdevUnmapFramebuffer (KdScreenInfo *screen) -{ - KdShadowFbFree (screen, 0); - return TRUE; -} - -Bool -fbdevSetShadow (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - ShadowUpdateProc update; - ShadowWindowProc window; - - window = fbdevWindowLinear; - update = 0; - if (scrpriv->randr) - update = shadowUpdateRotatePacked; - else - update = shadowUpdatePacked; - return KdShadowSet (pScreen, scrpriv->randr, update, window); -} - - -#ifdef RANDR -Bool -fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - RRScreenSizePtr pSize; - Rotation randr; - int n; - - *rotations = RR_Rotate_All|RR_Reflect_All; - - for (n = 0; n < pScreen->numDepths; n++) - if (pScreen->allowedDepths[n].numVids) - break; - if (n == pScreen->numDepths) - return FALSE; - - pSize = RRRegisterSize (pScreen, - screen->width, - screen->height, - screen->width_mm, - screen->height_mm); - - randr = KdSubRotation (scrpriv->randr, screen->randr); - - RRSetCurrentConfig (pScreen, randr, 0, pSize); - - return TRUE; -} - -Bool -fbdevRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - Bool wasEnabled = pScreenPriv->enabled; - FbdevScrPriv oldscr; - int oldwidth; - int oldheight; - int oldmmwidth; - int oldmmheight; - int newwidth, newheight; - - if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) - { - newwidth = pSize->width; - newheight = pSize->height; - } - else - { - newwidth = pSize->height; - newheight = pSize->width; - } - - if (wasEnabled) - KdDisableScreen (pScreen); - - oldscr = *scrpriv; - - oldwidth = screen->width; - oldheight = screen->height; - oldmmwidth = pScreen->mmWidth; - oldmmheight = pScreen->mmHeight; - - /* - * Set new configuration - */ - - scrpriv->randr = KdAddRotation (screen->randr, randr); - - KdOffscreenSwapOut (screen->pScreen); - - fbdevUnmapFramebuffer (screen); - - if (!fbdevMapFramebuffer (screen)) - goto bail4; - - if (!fbdevSetShadow (screen->pScreen)) - goto bail4; - - fbdevSetScreenSizes (screen->pScreen); - - /* - * Set frame buffer mapping - */ - (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), - pScreen->width, - pScreen->height, - screen->fb[0].depth, - screen->fb[0].bitsPerPixel, - screen->fb[0].byteStride, - screen->fb[0].frameBuffer); - - /* set the subpixel order */ - - KdSetSubpixelOrder (pScreen, scrpriv->randr); - if (wasEnabled) - KdEnableScreen (pScreen); - - return TRUE; - -bail4: - fbdevUnmapFramebuffer (screen); - *scrpriv = oldscr; - (void) fbdevMapFramebuffer (screen); - pScreen->width = oldwidth; - pScreen->height = oldheight; - pScreen->mmWidth = oldmmwidth; - pScreen->mmHeight = oldmmheight; - - if (wasEnabled) - KdEnableScreen (pScreen); - return FALSE; -} - -Bool -fbdevRandRInit (ScreenPtr pScreen) -{ - rrScrPrivPtr pScrPriv; - - if (!RRScreenInit (pScreen)) - return FALSE; - - pScrPriv = rrGetScrPriv(pScreen); - pScrPriv->rrGetInfo = fbdevRandRGetInfo; - pScrPriv->rrSetConfig = fbdevRandRSetConfig; - return TRUE; -} -#endif - -Bool -fbdevCreateColormap (ColormapPtr pmap) -{ - ScreenPtr pScreen = pmap->pScreen; - KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - VisualPtr pVisual; - int i; - int nent; - xColorItem *pdefs; - - switch (priv->fix.visual) { - case FB_VISUAL_STATIC_PSEUDOCOLOR: - pVisual = pmap->pVisual; - nent = pVisual->ColormapEntries; - pdefs = ALLOCATE_LOCAL (nent * sizeof (xColorItem)); - if (!pdefs) - return FALSE; - for (i = 0; i < nent; i++) - pdefs[i].pixel = i; - fbdevGetColors (pScreen, 0, nent, pdefs); - for (i = 0; i < nent; i++) - { - pmap->red[i].co.local.red = pdefs[i].red; - pmap->red[i].co.local.green = pdefs[i].green; - pmap->red[i].co.local.blue = pdefs[i].blue; - } - DEALLOCATE_LOCAL (pdefs); - return TRUE; - default: - return fbInitializeColormap (pmap); - } -} - -Bool -fbdevInitScreen (ScreenPtr pScreen) -{ -#ifdef TOUCHSCREEN - KdTsPhyScreen = pScreen->myNum; -#endif - - pScreen->CreateColormap = fbdevCreateColormap; - return TRUE; -} - -Bool -fbdevFinishInitScreen (ScreenPtr pScreen) -{ - if (!shadowSetup (pScreen)) - return FALSE; - -#ifdef RANDR - if (!fbdevRandRInit (pScreen)) - return FALSE; -#endif - - return TRUE; -} - - -Bool -fbdevCreateResources (ScreenPtr pScreen) -{ - return fbdevSetShadow (pScreen); -} - -void -fbdevPreserve (KdCardInfo *card) -{ -} - -Bool -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"); - return FALSE; - } - - if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) - { - struct fb_cmap cmap; - int i; - - for (i = 0; - i < (1 << priv->var.red.length) || - i < (1 << priv->var.green.length) || - i < (1 << priv->var.blue.length); i++) - { - priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1); - priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1); - priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1); - } - cmap.start = 0; - cmap.len = i; - cmap.red = &priv->red[0]; - cmap.green = &priv->green[0]; - cmap.blue = &priv->blue[0]; - cmap.transp = 0; - ioctl (priv->fd, FBIOPUTCMAP, &cmap); - } - return TRUE; -} - -Bool -fbdevDPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - static int oldmode = -1; - - if (mode == oldmode) - return TRUE; -#ifdef FBIOPUT_POWERMODE - if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) - { - oldmode = mode; - return TRUE; - } -#endif -#ifdef FBIOBLANK - if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) - { - oldmode = mode; - return TRUE; - } -#endif - return FALSE; -} - -void -fbdevDisable (ScreenPtr pScreen) -{ -} - -void -fbdevRestore (KdCardInfo *card) -{ -} - -void -fbdevScreenFini (KdScreenInfo *screen) -{ -} - -void -fbdevCardFini (KdCardInfo *card) -{ - FbdevPriv *priv = card->driver; - - munmap (priv->fb_base, priv->fix.smem_len); - close (priv->fd); - xfree (priv); -} - -void -fbdevGetColors (ScreenPtr pScreen, int fb, 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 fb, 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); -} diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h deleted file mode 100644 index d37b99597..000000000 --- a/hw/kdrive/fbdev/fbdev.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Id: fbdev.h,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.11 2001/06/03 21:52:45 keithp Exp $ */ - -#ifndef _FBDEV_H_ -#define _FBDEV_H_ -#include <stdio.h> -#include <linux/fb.h> -#include <unistd.h> -#include <sys/mman.h> -#include "kdrive.h" - -#ifdef RANDR -#include "randrstr.h" -#endif - -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; - char *fb_base; -} FbdevPriv; - -typedef struct _fbdevScrPriv { - Rotation randr; - Bool shadow; - PixmapPtr pShadow; -} FbdevScrPriv; - -extern KdCardFuncs fbdevFuncs; - -Bool -fbdevInitialize (KdCardInfo *card, FbdevPriv *priv); - -Bool -fbdevCardInit (KdCardInfo *card); - -Bool -fbdevScreenInit (KdScreenInfo *screen); - -Bool -fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv); - -Bool -fbdevInitScreen (ScreenPtr pScreen); - -Bool -fbdevFinishInitScreen (ScreenPtr pScreen); - -Bool -fbdevCreateResources (ScreenPtr pScreen); - -void -fbdevPreserve (KdCardInfo *card); - -Bool -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 fb, int n, xColorItem *pdefs); - -void -fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); - -Bool -fbdevMapFramebuffer (KdScreenInfo *screen); - -void * -fbdevWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void -fbdevSetScreenSizes (ScreenPtr pScreen); - -Bool -fbdevUnmapFramebuffer (KdScreenInfo *screen); - -Bool -fbdevSetShadow (ScreenPtr pScreen); - -Bool -fbdevCreateColormap (ColormapPtr pmap); - -#ifdef RANDR -Bool -fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations); - -Bool -fbdevRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize); -Bool -fbdevRandRInit (ScreenPtr pScreen); - -#endif - -#endif /* _FBDEV_H_ */ diff --git a/hw/kdrive/fbdev/fbinit.c b/hw/kdrive/fbdev/fbinit.c deleted file mode 100644 index 533aa9bf8..000000000 --- a/hw/kdrive/fbdev/fbinit.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Id: fbinit.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.8 2001/05/29 17:47:55 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <fbdev.h> - -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 (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -#ifdef TOUCHSCREEN - KdInitTouchScreen (&TsFuncs); -#endif -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} - - - -KdCardFuncs fbdevFuncs = { - fbdevCardInit, /* cardinit */ - fbdevScreenInit, /* scrinit */ - fbdevInitScreen, /* initScreen */ - fbdevFinishInitScreen, /* finishInitScreen */ - fbdevCreateResources, /* createRes */ - 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, /* syncAccel */ - 0, /* disableAccel */ - 0, /* finiAccel */ - - fbdevGetColors, /* getColors */ - fbdevPutColors, /* putColors */ -}; diff --git a/hw/kdrive/i810/Imakefile b/hw/kdrive/i810/Imakefile deleted file mode 100644 index 32850275d..000000000 --- a/hw/kdrive/i810/Imakefile +++ /dev/null @@ -1,21 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/i810/Imakefile,v 1.6 2000/10/20 00:19:51 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -#if BuildXvExt -XVSRCS = i810_video.c -XVOBJS = i810_video.o -#endif - -SRCS = i810.c i810stub.c i810draw.c i810_cursor.c $(XVSRCS) - -OBJS = i810.o i810stub.o i810draw.o i810_cursor.o $(XVOBJS) - -DEFINES = XvExtensionDefines /* -DI810CFG_SHOW_OVERSCAN */ - -INCLUDES = -I. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(i810,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/i810/i810.c b/hw/kdrive/i810/i810.c deleted file mode 100644 index e36ea816e..000000000 --- a/hw/kdrive/i810/i810.c +++ /dev/null @@ -1,2104 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - - -/* $RCSId: xc/programs/Xserver/hw/kdrive/i810/i810.c,v 1.1 2001/03/30 02:18:41 keithp Exp $ */ - -/* - * i810.c - KDrive driver for the i810 chipset - * - * Authors: - * Pontus Lidman <pontus.lidman@nokia.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kxv.h" - -#include "i810.h" -#include "linux/agp.h" - -#include "i810draw.h" - -Bool i810InitVideo(ScreenPtr pScreen); - -#ifndef I810_DEBUG -int I810_DEBUG = (0 -/* | DEBUG_ALWAYS_SYNC */ -/* | DEBUG_VERBOSE_ACCEL */ -/* | DEBUG_VERBOSE_SYNC */ -/* | DEBUG_VERBOSE_VGA */ -/* | DEBUG_VERBOSE_RING */ -/* | DEBUG_VERBOSE_OUTREG */ -/* | DEBUG_VERBOSE_MEMORY */ -/* | DEBUG_VERBOSE_CURSOR */ - ); -#endif - - -static Bool -i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t); - -static void -i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode ); - -Bool -i810CardInit (KdCardInfo *card) -{ - int i; - - I810CardInfo *i810c; - -/* fprintf(stderr,"i810CardInit\n"); */ - - i810c = (I810CardInfo *) xalloc (sizeof (I810CardInfo)); - - if (!i810c) - return FALSE; - - /* 2MB Video RAM */ - i810c->videoRam=2048; - - /* Find FB address */ - - if (card->attr.address[1] != 0) { - i810c->LinearAddr = card->attr.address[0] & 0xFF000000; - - if (!i810c->LinearAddr) { - fprintf(stderr,"No valid FB address in PCI config space(1)\n"); - xfree(i810c); - return FALSE; - } else { -/* fprintf(stderr,"Linear framebuffer at %lx\n",i810c->LinearAddr); */ - } - } else { - fprintf(stderr,"No valid FB address in PCI config space(2)\n"); - xfree(i810c); - return FALSE; - } - - if (card->attr.address[1]) { - - i810c->MMIOAddr = card->attr.address[1] & 0xFFF80000; - - i810c->MMIOBase = - KdMapDevice (i810c->MMIOAddr, I810_REG_SIZE); - if (!i810c->MMIOBase) { - fprintf(stderr,"No valid MMIO address in PCI config space(1)\n"); - xfree(i810c); - return FALSE; - } else { - - } - } else { - fprintf(stderr,"No valid MMIO address in PCI config space(2)\n"); - xfree(i810c); - return FALSE; - } - -/* fprintf(stderr,"Mapped 0x%x bytes of MMIO regs at phys 0x%lx virt %p\n", */ -/* I810_REG_SIZE,i810c->MMIOAddr,i810c->MMIOBase); */ - - /* Find out memory bus frequency. - */ - - { - unsigned long *p; - unsigned char *LinuxGetPciCfg(KdCardAttr *attr); - - - if (!(p= (unsigned long *) LinuxGetPciCfg(&card->attr))) - return FALSE; - -/* fprintf(stderr,"Frequency long %lx\n",p[WHTCFG_PAMR_DRP]); */ - - if ( (p[WHTCFG_PAMR_DRP] & LM_FREQ_MASK) == LM_FREQ_133 ) - i810c->LmFreqSel = 133; - else - i810c->LmFreqSel = 100; - - xfree(p); - -/* fprintf(stderr,"Selected frequency %d\n",i810c->LmFreqSel); */ - } - -/* fprintf(stderr,"Will alloc AGP framebuffer: %d kByte\n",i810c->videoRam); */ - - /* Since we always want write combining on first 32 mb of framebuffer - * we pass a mapsize of 32 mb */ - i810c->FbMapSize = 32*1024*1024; - - for (i = 2 ; i < i810c->FbMapSize ; i <<= 1); - i810c->FbMapSize = i; - - i810c->FbBase = - KdMapDevice (i810c->LinearAddr, i810c->FbMapSize); - - if (!i810c->FbBase) return FALSE; -/* fprintf(stderr,"Mapped 0x%lx bytes of framebuffer at %p\n", */ -/* i810c->FbMapSize,i810c->FbBase); */ - - card->driver=i810c; - - return TRUE; -} - -void -i810ScreenFini (KdScreenInfo *screen) -{ - I810ScreenInfo *i810s = (I810ScreenInfo *) screen->driver; - - xfree (i810s); - screen->driver = 0; -} - -Bool -i810InitScreen (ScreenPtr pScreen) { - -#ifdef XV - i810InitVideo(pScreen); -#endif - return TRUE; -} - -void -i810CardFini (KdCardInfo *card) -{ - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - KdUnmapDevice (i810c->FbBase, i810c->FbMapSize); - KdUnmapDevice (i810c->MMIOBase, I810_REG_SIZE); - xfree (i810c); - card->driver = 0; -} - -struct wm_info { - double freq; - unsigned int wm; -}; - -struct wm_info i810_wm_8_100[] = { - { 0, 0x22003000 }, - { 25.2, 0x22003000 }, - { 28.0, 0x22003000 }, - { 31.5, 0x22003000 }, - { 36.0, 0x22007000 }, - { 40.0, 0x22007000 }, - { 45.0, 0x22007000 }, - { 49.5, 0x22008000 }, - { 50.0, 0x22008000 }, - { 56.3, 0x22008000 }, - { 65.0, 0x22008000 }, - { 75.0, 0x22008000 }, - { 78.8, 0x22008000 }, - { 80.0, 0x22008000 }, - { 94.0, 0x22008000 }, - { 96.0, 0x22107000 }, - { 99.0, 0x22107000 }, - { 108.0, 0x22107000 }, - { 121.0, 0x22107000 }, - { 128.9, 0x22107000 }, - { 132.0, 0x22109000 }, - { 135.0, 0x22109000 }, - { 157.5, 0x2210b000 }, - { 162.0, 0x2210b000 }, - { 175.5, 0x2210b000 }, - { 189.0, 0x2220e000 }, - { 202.5, 0x2220e000 } -}; - -struct wm_info i810_wm_16_100[] = { - { 0, 0x22004000 }, - { 25.2, 0x22006000 }, - { 28.0, 0x22006000 }, - { 31.5, 0x22007000 }, - { 36.0, 0x22007000 }, - { 40.0, 0x22007000 }, - { 45.0, 0x22007000 }, - { 49.5, 0x22009000 }, - { 50.0, 0x22009000 }, - { 56.3, 0x22108000 }, - { 65.0, 0x2210e000 }, - { 75.0, 0x2210e000 }, - { 78.8, 0x2210e000 }, - { 80.0, 0x22210000 }, - { 94.5, 0x22210000 }, - { 96.0, 0x22210000 }, - { 99.0, 0x22210000 }, - { 108.0, 0x22210000 }, - { 121.0, 0x22210000 }, - { 128.9, 0x22210000 }, - { 132.0, 0x22314000 }, - { 135.0, 0x22314000 }, - { 157.5, 0x22415000 }, - { 162.0, 0x22416000 }, - { 175.5, 0x22416000 }, - { 189.0, 0x22416000 }, - { 195.0, 0x22416000 }, - { 202.5, 0x22416000 } -}; - - -struct wm_info i810_wm_24_100[] = { - { 0, 0x22006000 }, - { 25.2, 0x22009000 }, - { 28.0, 0x22009000 }, - { 31.5, 0x2200a000 }, - { 36.0, 0x2210c000 }, - { 40.0, 0x2210c000 }, - { 45.0, 0x2210c000 }, - { 49.5, 0x22111000 }, - { 50.0, 0x22111000 }, - { 56.3, 0x22111000 }, - { 65.0, 0x22214000 }, - { 75.0, 0x22214000 }, - { 78.8, 0x22215000 }, - { 80.0, 0x22216000 }, - { 94.5, 0x22218000 }, - { 96.0, 0x22418000 }, - { 99.0, 0x22418000 }, - { 108.0, 0x22418000 }, - { 121.0, 0x22418000 }, - { 128.9, 0x22419000 }, - { 132.0, 0x22519000 }, - { 135.0, 0x4441d000 }, - { 157.5, 0x44419000 }, - { 162.0, 0x44419000 }, - { 175.5, 0x44419000 }, - { 189.0, 0x44419000 }, - { 195.0, 0x44419000 }, - { 202.5, 0x44419000 } -}; - -struct wm_info i810_wm_32_100[] = { - { 0, 0x2210b000 }, - { 60, 0x22415000 }, /* 0x314000 works too */ - { 80, 0x22419000 } /* 0x518000 works too */ -}; - - -struct wm_info i810_wm_8_133[] = { - { 0, 0x22003000 }, - { 25.2, 0x22003000 }, - { 28.0, 0x22003000 }, - { 31.5, 0x22003000 }, - { 36.0, 0x22007000 }, - { 40.0, 0x22007000 }, - { 45.0, 0x22007000 }, - { 49.5, 0x22008000 }, - { 50.0, 0x22008000 }, - { 56.3, 0x22008000 }, - { 65.0, 0x22008000 }, - { 75.0, 0x22008000 }, - { 78.8, 0x22008000 }, - { 80.0, 0x22008000 }, - { 94.0, 0x22008000 }, - { 96.0, 0x22107000 }, - { 99.0, 0x22107000 }, - { 108.0, 0x22107000 }, - { 121.0, 0x22107000 }, - { 128.9, 0x22107000 }, - { 132.0, 0x22109000 }, - { 135.0, 0x22109000 }, - { 157.5, 0x2210b000 }, - { 162.0, 0x2210b000 }, - { 175.5, 0x2210b000 }, - { 189.0, 0x2220e000 }, - { 202.5, 0x2220e000 } -}; - - -struct wm_info i810_wm_16_133[] = { - { 0, 0x22004000 }, - { 25.2, 0x22006000 }, - { 28.0, 0x22006000 }, - { 31.5, 0x22007000 }, - { 36.0, 0x22007000 }, - { 40.0, 0x22007000 }, - { 45.0, 0x22007000 }, - { 49.5, 0x22009000 }, - { 50.0, 0x22009000 }, - { 56.3, 0x22108000 }, - { 65.0, 0x2210e000 }, - { 75.0, 0x2210e000 }, - { 78.8, 0x2210e000 }, - { 80.0, 0x22210000 }, - { 94.5, 0x22210000 }, - { 96.0, 0x22210000 }, - { 99.0, 0x22210000 }, - { 108.0, 0x22210000 }, - { 121.0, 0x22210000 }, - { 128.9, 0x22210000 }, - { 132.0, 0x22314000 }, - { 135.0, 0x22314000 }, - { 157.5, 0x22415000 }, - { 162.0, 0x22416000 }, - { 175.5, 0x22416000 }, - { 189.0, 0x22416000 }, - { 195.0, 0x22416000 }, - { 202.5, 0x22416000 } -}; - -struct wm_info i810_wm_24_133[] = { - { 0, 0x22006000 }, - { 25.2, 0x22009000 }, - { 28.0, 0x22009000 }, - { 31.5, 0x2200a000 }, - { 36.0, 0x2210c000 }, - { 40.0, 0x2210c000 }, - { 45.0, 0x2210c000 }, - { 49.5, 0x22111000 }, - { 50.0, 0x22111000 }, - { 56.3, 0x22111000 }, - { 65.0, 0x22214000 }, - { 75.0, 0x22214000 }, - { 78.8, 0x22215000 }, - { 80.0, 0x22216000 }, - { 94.5, 0x22218000 }, - { 96.0, 0x22418000 }, - { 99.0, 0x22418000 }, - { 108.0, 0x22418000 }, - { 121.0, 0x22418000 }, - { 128.9, 0x22419000 }, - { 132.0, 0x22519000 }, - { 135.0, 0x4441d000 }, - { 157.5, 0x44419000 }, - { 162.0, 0x44419000 }, - { 175.5, 0x44419000 }, - { 189.0, 0x44419000 }, - { 195.0, 0x44419000 }, - { 202.5, 0x44419000 } -}; - -static void -i810WriteControlMMIO(I810CardInfo *i810c, int addr, CARD8 index, CARD8 val) { - moutb(addr, index); - moutb(addr+1, val); -} - -static CARD8 -i810ReadControlMMIO(I810CardInfo *i810c, int addr, CARD8 index) { - moutb(addr, index); - return minb(addr+1); -} - -Bool -i810ModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t) -{ - /* This is just a guess. */ - if (t->horizontal > 1600 || t->horizontal < 640) return FALSE; - if (t->vertical > 1200 || t->horizontal < 350) return FALSE; - return TRUE; -} - -Bool -i810ModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - int byte_width, pixel_width, screen_size; - -/* fprintf(stderr,"i810ModeUsable\n"); */ - - if (screen->fb[0].depth >= 24) - { - screen->fb[0].depth = 24; - screen->fb[0].bitsPerPixel = 24; - screen->dumb = TRUE; - } - else if (screen->fb[0].depth >= 16) - { - screen->fb[0].depth = 16; - screen->fb[0].bitsPerPixel = 16; - } - else if (screen->fb[0].depth >= 15) - { - screen->fb[0].depth = 15; - screen->fb[0].bitsPerPixel = 16; - } - else - { - screen->fb[0].depth = 8; - screen->fb[0].bitsPerPixel = 8; - } - byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3); - pixel_width = screen->width; - - screen->fb[0].pixelStride = pixel_width; - screen->fb[0].byteStride = byte_width; - - screen_size = byte_width * screen->height; - - return screen_size <= (i810c->videoRam * 1024); -} - -int i810AllocateGARTMemory( KdScreenInfo *screen ) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - unsigned long size = i810c->videoRam * 1024; - - int key; - long tom = 0; - unsigned long physical; - - if (!KdAgpGARTSupported()) - return FALSE; - - if (!KdAcquireGART(screen->mynum)) - return FALSE; - - /* This allows the 2d only Xserver to regen */ - i810c->agpAcquired2d = TRUE; - - /* Treat the gart like video memory - we assume we own all that is - * there, so ignore EBUSY errors. Don't try to remove it on - * failure, either, as other X server may be using it. - */ - - if ((key = KdAllocateGARTMemory(screen->mynum, size, 0, NULL)) == -1) - return FALSE; - - i810c->VramOffset = 0; - i810c->VramKey = key; - - if (!KdBindGARTMemory(screen->mynum, key, 0)) - return FALSE; - - - i810c->SysMem.Start = 0; - i810c->SysMem.Size = size; - i810c->SysMem.End = size; - i810c->SavedSysMem = i810c->SysMem; - - tom = i810c->SysMem.End; - - i810c->DcacheMem.Start = 0; - i810c->DcacheMem.End = 0; - i810c->DcacheMem.Size = 0; - i810c->CursorPhysical = 0; - - /* Dcache - half the speed of normal ram, so not really useful for - * a 2d server. Don't bother reporting its presence. This is - * mapped in addition to the requested amount of system ram. - */ - size = 1024 * 4096; - - /* Keep it 512K aligned for the sake of tiled regions. - */ - tom += 0x7ffff; - tom &= ~0x7ffff; - - if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_DCACHE_MEMORY, NULL)) != -1) { - i810c->DcacheOffset= tom; - i810c->DcacheKey = key; - if (!KdBindGARTMemory(screen->mynum, key, tom)) { - fprintf(stderr,"Allocation of %ld bytes for DCACHE failed\n", size); - i810c->DcacheKey = -1; - } else { - i810c->DcacheMem.Start = tom; - i810c->DcacheMem.Size = size; - i810c->DcacheMem.End = i810c->DcacheMem.Start + i810c->DcacheMem.Size; - tom = i810c->DcacheMem.End; - } - } else { - fprintf(stderr, - "No physical memory available for %ld bytes of DCACHE\n", - size); - i810c->DcacheKey = -1; - } - - /* Mouse cursor -- The i810 (crazy) needs a physical address in - * system memory from which to upload the cursor. We get this from - * the agpgart module using a special memory type. - */ - - /* 4k for the cursor is excessive, I'm going to steal 3k for - * overlay registers later - */ - - size = 4096; - - if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_PHYS_MEMORY, - &physical)) == -1) { - fprintf(stderr, - "No physical memory available for HW cursor\n"); - i810c->HwcursKey = -1; - } else { - i810c->HwcursOffset= tom; - i810c->HwcursKey = key; - if (!KdBindGARTMemory(screen->mynum, key, tom)) { - fprintf(stderr, - "Allocation of %ld bytes for HW cursor failed\n", - size); - i810c->HwcursKey = -1; - } else { - i810c->CursorPhysical = physical; - i810c->CursorStart = tom; - tom += size; - } - } - - /* Overlay register buffer -- Just like the cursor, the i810 needs a - * physical address in system memory from which to upload the overlay - * registers. - */ - if (i810c->CursorStart != 0) { - i810c->OverlayPhysical = i810c->CursorPhysical + 1024; - i810c->OverlayStart = i810c->CursorStart + 1024; - } - - - i810c->GttBound = 1; - - return TRUE; -} - -/* Allocate from a memrange, returns success */ - -int i810AllocLow( I810MemRange *result, I810MemRange *pool, int size ) -{ - if (size > pool->Size) return FALSE; - - pool->Size -= size; - result->Size = size; - result->Start = pool->Start; - result->End = pool->Start += size; - return TRUE; -} - -int i810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) -{ - if (size > pool->Size) return 0; - - pool->Size -= size; - result->Size = size; - result->End = pool->End; - result->Start = pool->End -= size; - return 1; -} - -Bool -i810AllocateFront(KdScreenInfo *screen) { - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - int cache_lines = -1; - - if(i810c->DoneFrontAlloc) - return TRUE; - - memset(&(i810c->FbMemBox), 0, sizeof(BoxRec)); - /* Alloc FrontBuffer/Ring/Accel memory */ - i810c->FbMemBox.x1=0; - i810c->FbMemBox.x2=screen->width; - i810c->FbMemBox.y1=0; - i810c->FbMemBox.y2=screen->height; - - /* This could be made a command line option */ - cache_lines = 0; - - if(cache_lines >= 0) - i810c->FbMemBox.y2 += cache_lines; - else { - /* make sure there is enough for two DVD sized YUV buffers */ - i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384; - if (screen->width <= 1024) - i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384; - cache_lines = i810c->FbMemBox.y2 - screen->height; - } - - if (I810_DEBUG) - ErrorF("Adding %i scanlines for pixmap caching\n", cache_lines); - - /* Reserve room for the framebuffer and pixcache. Put at the top - * of memory so we can have nice alignment for the tiled regions at - * the start of memory. - */ - i810AllocLow( &(i810c->FrontBuffer), - &(i810c->SysMem), - ((i810c->FbMemBox.x2 * - i810c->FbMemBox.y2 * - i810c->cpp) + 4095) & ~4095); - - memset( &(i810c->LpRing), 0, sizeof( I810RingBuffer ) ); - if(i810AllocLow( &(i810c->LpRing.mem), &(i810c->SysMem), 16*4096 )) { - if (I810_DEBUG & DEBUG_VERBOSE_MEMORY) - ErrorF( "ring buffer at local %lx\n", - i810c->LpRing.mem.Start); - - i810c->LpRing.tail_mask = i810c->LpRing.mem.Size - 1; - i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start; - i810c->LpRing.head = 0; - i810c->LpRing.tail = 0; - i810c->LpRing.space = 0; - } - - if ( i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 64*1024 ) || - i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 16*1024 ) ) { - if (I810_DEBUG & DEBUG_VERBOSE_MEMORY) - ErrorF("Allocated Scratch Memory\n"); - } - -#ifdef XV - /* 720x720 is just how much memory the mpeg player needs for overlays */ - - if ( i810AllocHigh( &i810c->XvMem, &(i810c->SysMem), 720*720*2 )) { - if (I810_DEBUG & DEBUG_VERBOSE_MEMORY) - ErrorF("Allocated overlay Memory\n"); - } -#endif - - i810c->DoneFrontAlloc = TRUE; - return TRUE; -} - -static Bool -i810MapMem(KdScreenInfo *screen) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start; - - return TRUE; -} - - -Bool -i810ScreenInit (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810ScreenInfo *i810s; - - int i; - - const KdMonitorTiming *t; - -/* fprintf(stderr,"i810ScreenInit\n"); */ - - i810s = (I810ScreenInfo *) xalloc (sizeof (I810ScreenInfo)); - if (!i810s) - return FALSE; - - memset (i810s, '\0', sizeof (I810ScreenInfo)); - - /* Default dimensions */ - if (!screen->width || !screen->height) - { - screen->width = 720; - screen->height = 576; - screen->rate = 52; -#if 0 - screen->width = 1024; - screen->height = 768; - screen->rate = 72; -#endif - } - - if (!screen->fb[0].depth) - screen->fb[0].depth = 16; - - t = KdFindMode (screen, i810ModeSupported); - - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - - if (!KdTuneMode (screen, i810ModeUsable, i810ModeSupported)) - { - xfree (i810c); - return FALSE; - } - -/* fprintf(stderr,"Screen rate %d horiz %d vert %d\n",t->rate,t->horizontal,t->vertical); */ - - switch (screen->fb[0].depth) { - case 8: - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case 15: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x03e0; - screen->fb[0].redMask = 0x7c00; - - i810c->colorKey = 0x043f; - - break; - case 16: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x07e0; - screen->fb[0].redMask = 0xf800; - - i810c->colorKey = 0x083f; - - break; - case 24: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x0000ff; - screen->fb[0].greenMask = 0x00ff00; - screen->fb[0].redMask = 0xff0000; - - i810c->colorKey = 0x0101ff; - - break; - default: - fprintf(stderr,"Unsupported depth %d\n",screen->fb[0].depth); - return FALSE; - } - - - - /* Set all colours to black */ - for (i=0; i<768; i++) i810c->vga.ModeReg.DAC[i] = 0x00; - - /* ... and the overscan */ - if (screen->fb[0].depth >= 4) - i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF; - - /* Could be made a command-line option */ - -#ifdef I810CFG_SHOW_OVERSCAN - i810c->vga.ModeReg.DAC[765] = 0x3F; - i810c->vga.ModeReg.DAC[766] = 0x00; - i810c->vga.ModeReg.DAC[767] = 0x3F; - i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF; - i810c->vga.ShowOverscan = TRUE; -#else - i810c->vga.ShowOverscan = FALSE; -#endif - - i810c->vga.paletteEnabled = FALSE; - i810c->vga.cmapSaved = FALSE; - i810c->vga.MMIOBase = i810c->MMIOBase; - - i810c->cpp = screen->fb[0].bitsPerPixel/8; - - /* move to initscreen? */ - - switch (screen->fb[0].bitsPerPixel) { - case 8: - i810c->MaxClock = 203000; - break; - case 16: - i810c->MaxClock = 163000; - break; - case 24: - i810c->MaxClock = 136000; - break; - case 32: /* not supported */ - i810c->MaxClock = 86000; - default: - fprintf(stderr,"Unsupported bpp %d\n",screen->fb[0].bitsPerPixel); - return FALSE; - } - - if (!i810AllocateGARTMemory( screen )) { - return FALSE; - } - - i810AllocateFront(screen); - - /* Map LpRing memory */ - if (!i810MapMem(screen)) return FALSE; - - screen->fb[0].frameBuffer = i810c->FbBase; - - screen->driver = i810s; - - return TRUE; -} - -/* - * I810Save -- - * - * This function saves the video state. It reads all of the SVGA registers - * into the vgaI810Rec data structure. There is in general no need to - * mask out bits here - just read the registers. - */ -static void -DoSave(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg, Bool saveFonts) -{ - - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - - int i; - - /* Save VGA registers */ - - vgaReg->MiscOutReg = mmioReadMiscOut(vgap); - if (vgaReg->MiscOutReg & 0x01) - vgap->IOBase = VGA_IOBASE_COLOR; - else - vgap->IOBase = VGA_IOBASE_MONO; - - for (i = 0; i < VGA_NUM_CRTC; i++) { - vgaReg->CRTC[i] = mmioReadCrtc(vgap, i); - } - - mmioEnablePalette(vgap); - for (i = 0; i < VGA_NUM_ATTR; i++) { - vgaReg->Attribute[i] = mmioReadAttr(vgap, i); - } - mmioDisablePalette(vgap); - - for (i = 0; i < VGA_NUM_GFX; i++) { - vgaReg->Graphics[i] = mmioReadGr(vgap, i); - } - - for (i = 1; i < VGA_NUM_SEQ; i++) { - vgaReg->Sequencer[i] = mmioReadSeq(vgap, i); - } - - /* - * The port I/O code necessary to read in the extended registers - * into the fields of the I810Rec structure goes here. - */ - i810Reg->IOControl = mmioReadCrtc(vgap, IO_CTNL); - i810Reg->AddressMapping = i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING); - i810Reg->BitBLTControl = INREG8(BITBLT_CNTL); - i810Reg->VideoClk2_M = INREG16(VCLK2_VCO_M); - i810Reg->VideoClk2_N = INREG16(VCLK2_VCO_N); - i810Reg->VideoClk2_DivisorSel = INREG8(VCLK2_VCO_DIV_SEL); - - i810Reg->ExtVertTotal=mmioReadCrtc(vgap, EXT_VERT_TOTAL); - i810Reg->ExtVertDispEnd=mmioReadCrtc(vgap, EXT_VERT_DISPLAY); - i810Reg->ExtVertSyncStart=mmioReadCrtc(vgap, EXT_VERT_SYNC_START); - i810Reg->ExtVertBlankStart=mmioReadCrtc(vgap, EXT_VERT_BLANK_START); - i810Reg->ExtHorizTotal=mmioReadCrtc(vgap, EXT_HORIZ_TOTAL); - i810Reg->ExtHorizBlank=mmioReadCrtc(vgap, EXT_HORIZ_BLANK); - i810Reg->ExtOffset=mmioReadCrtc(vgap, EXT_OFFSET); - i810Reg->InterlaceControl=mmioReadCrtc(vgap, INTERLACE_CNTL); - - i810Reg->PixelPipeCfg0 = INREG8(PIXPIPE_CONFIG_0); - i810Reg->PixelPipeCfg1 = INREG8(PIXPIPE_CONFIG_1); - i810Reg->PixelPipeCfg2 = INREG8(PIXPIPE_CONFIG_2); - i810Reg->DisplayControl = INREG8(DISPLAY_CNTL); - i810Reg->LMI_FIFO_Watermark = INREG(FWATER_BLC); - - for (i = 0 ; i < 8 ; i++) - i810Reg->Fence[i] = INREG(FENCE+i*4); - - i810Reg->LprbTail = INREG(LP_RING + RING_TAIL); - i810Reg->LprbHead = INREG(LP_RING + RING_HEAD); - i810Reg->LprbStart = INREG(LP_RING + RING_START); - i810Reg->LprbLen = INREG(LP_RING + RING_LEN); - - if ((i810Reg->LprbTail & TAIL_ADDR) != (i810Reg->LprbHead & HEAD_ADDR) && - i810Reg->LprbLen & RING_VALID) { - i810PrintErrorState( card ); - FatalError( "Active ring not flushed\n"); - } - - if (I810_DEBUG) { - fprintf(stderr,"Got mode in I810Save:\n"); - i810PrintMode( vgaReg, i810Reg ); - } -} - -void i810Preserve(KdCardInfo *card) { - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - -/* fprintf(stderr,"i810Preserve\n"); */ - DoSave(card, &vgap->SavedReg, &i810c->SavedReg, TRUE); -} - -/* Famous last words - */ -void -i810PrintErrorState(KdCardInfo *card) -{ - - I810CardInfo *i810c = card->driver; - - fprintf(stderr, "pgetbl_ctl: 0x%lx pgetbl_err: 0x%lx\n", - INREG(PGETBL_CTL), - INREG(PGE_ERR)); - - fprintf(stderr, "ipeir: %lx iphdr: %lx\n", - INREG(IPEIR), - INREG(IPEHR)); - - fprintf(stderr, "LP ring tail: %lx head: %lx len: %lx start %lx\n", - INREG(LP_RING + RING_TAIL), - INREG(LP_RING + RING_HEAD) & HEAD_ADDR, - INREG(LP_RING + RING_LEN), - INREG(LP_RING + RING_START)); - - fprintf(stderr, "eir: %x esr: %x emr: %x\n", - INREG16(EIR), - INREG16(ESR), - INREG16(EMR)); - - fprintf(stderr, "instdone: %x instpm: %x\n", - INREG16(INST_DONE), - INREG8(INST_PM)); - - fprintf(stderr, "memmode: %lx instps: %lx\n", - INREG(MEMMODE), - INREG(INST_PS)); - - fprintf(stderr, "hwstam: %x ier: %x imr: %x iir: %x\n", - INREG16(HWSTAM), - INREG16(IER), - INREG16(IMR), - INREG16(IIR)); -} - -Bool -i810BindGARTMemory( KdScreenInfo *screen ) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - - if (!i810c->GttBound) { - if (!KdAcquireGART(screen->mynum)) - return FALSE; - if (!KdBindGARTMemory(screen->mynum, i810c->VramKey, - i810c->VramOffset)) - - return FALSE; - if (i810c->DcacheKey != -1) { - if (!KdBindGARTMemory(screen->mynum, i810c->DcacheKey, - i810c->DcacheOffset)) - return FALSE; - } - if (i810c->HwcursKey != -1) { - if (!KdBindGARTMemory(screen->mynum, i810c->HwcursKey, - i810c->HwcursOffset)) - return FALSE; - } - i810c->GttBound = 1; - } - return TRUE; -} - -Bool -i810UnbindGARTMemory(KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - - - if (KdAgpGARTSupported() && i810c->GttBound) { - if (!KdUnbindGARTMemory(screen->mynum, i810c->VramKey)) - return FALSE; - if (i810c->DcacheKey != -1) { - if (!KdUnbindGARTMemory(screen->mynum, i810c->DcacheKey)) - return FALSE; - } - if (i810c->HwcursKey != -1) { - if (!KdUnbindGARTMemory(screen->mynum, i810c->HwcursKey)) - return FALSE; - } - if (!KdReleaseGART(screen->mynum)) - return FALSE; - i810c->GttBound = 0; - } - return TRUE; -} - -/* - * I810CalcVCLK -- - * - * Determine the closest clock frequency to the one requested. - */ - -#define MAX_VCO_FREQ 600.0 -#define TARGET_MAX_N 30 -#define REF_FREQ 24.0 - -#define CALC_VCLK(m,n,p) \ - (double)m / ((double)n * (1 << p)) * 4 * REF_FREQ - -static void -i810CalcVCLK( KdScreenInfo *screen, double freq ) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - I810RegPtr i810Reg = &i810c->ModeReg; - - int m, n, p; - double f_out, f_best; - double f_err; - double f_vco; - int m_best = 0, n_best = 0, p_best = 0; - double f_target = freq; - double err_max = 0.005; - double err_target = 0.001; - double err_best = 999999.0; - - p_best = p = log(MAX_VCO_FREQ/f_target)/log((double)2); - f_vco = f_target * (1 << p); - - n = 2; - do { - n++; - m = f_vco / (REF_FREQ / (double)n) / (double)4.0 + 0.5; - if (m < 3) m = 3; - f_out = CALC_VCLK(m,n,p); - f_err = 1.0 - (f_target/f_out); - if (fabs(f_err) < err_max) { - m_best = m; - n_best = n; - f_best = f_out; - err_best = f_err; - } - } while ((fabs(f_err) >= err_target) && - ((n <= TARGET_MAX_N) || (fabs(err_best) > err_max))); - - if (fabs(f_err) < err_target) { - m_best = m; - n_best = n; - } - - i810Reg->VideoClk2_M = (m_best-2) & 0x3FF; - i810Reg->VideoClk2_N = (n_best-2) & 0x3FF; - i810Reg->VideoClk2_DivisorSel = (p_best << 4); - -/* fprintf(stderr, "Setting dot clock to %.1f MHz " */ -/* "[ 0x%x 0x%x 0x%x ] " */ -/* "[ %d %d %d ]\n", */ -/* CALC_VCLK(m_best,n_best,p_best), */ -/* i810Reg->VideoClk2_M, */ -/* i810Reg->VideoClk2_N, */ -/* i810Reg->VideoClk2_DivisorSel, */ -/* m_best, n_best, p_best); */ -} - -/* - * I810CalcFIFO -- - * - * Calculate burst length and FIFO watermark. - */ - -#define Elements(x) (sizeof(x)/sizeof(*x)) - -unsigned int -i810CalcWatermark( KdScreenInfo *screen, double freq, Bool dcache ) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - - - struct wm_info *tab; - int nr; - int i; - - if (i810c->LmFreqSel == 100) { - switch(screen->fb[0].bitsPerPixel) { - case 8: - tab = i810_wm_8_100; - nr = Elements(i810_wm_8_100); - break; - case 16: - tab = i810_wm_16_100; - nr = Elements(i810_wm_16_100); - break; - case 24: - tab = i810_wm_24_100; - nr = Elements(i810_wm_24_100); - break; - default: - return 0; - } - } else { - switch(screen->fb[0].bitsPerPixel) { - case 8: - tab = i810_wm_8_133; - nr = Elements(i810_wm_8_133); - break; - case 16: - tab = i810_wm_16_133; - nr = Elements(i810_wm_16_133); - break; - case 24: - tab = i810_wm_24_133; - nr = Elements(i810_wm_24_133); - break; - default: - return 0; - } - } - - for (i = 0 ; i < nr && tab[i].freq < freq ; i++); - - if (i == nr) - i--; - -/* fprintf(stderr,"chose watermark 0x%x: (tab.freq %.1f)\n", */ -/* tab[i].wm, tab[i].freq); */ - - /* None of these values (sourced from intel) have watermarks for - * the dcache memory. Fake it for now by using the same watermark - * for both... - * - * Update: this is probably because dcache isn't real useful as - * framebuffer memory, so intel's drivers don't need watermarks - * for that memory because they never use it to feed the ramdacs. - * We do use it in the fallback mode, so keep the watermarks for - * now. - */ - if (dcache) - return (tab[i].wm & ~0xffffff) | ((tab[i].wm>>12) & 0xfff); - else - return tab[i].wm; -} - -static void i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode ) -{ - int i; - - fprintf(stderr," MiscOut: %x\n", vgaReg->MiscOutReg); - - - fprintf(stderr,"SEQ: "); - for (i = 0 ; i < VGA_NUM_SEQ ; i++) { - if ((i&7)==0) fprintf(stderr,"\n"); - fprintf(stderr," %d: %x", i, vgaReg->Sequencer[i]); - } - fprintf(stderr,"\n"); - - fprintf(stderr,"CRTC: "); - for (i = 0 ; i < VGA_NUM_CRTC ; i++) { - if ((i&3)==0) fprintf(stderr,"\n"); - fprintf(stderr," CR%02x: %2x", i, vgaReg->CRTC[i]); - } - fprintf(stderr,"\n"); - - fprintf(stderr,"GFX: "); - for (i = 0 ; i < VGA_NUM_GFX ; i++) { - if ((i&3)==0) fprintf(stderr,"\n"); - fprintf(stderr," GR%02x: %02x", i, vgaReg->Graphics[i]); - } - fprintf(stderr,"\n"); - - fprintf(stderr,"ATTR: "); - for (i = 0 ; i < VGA_NUM_ATTR ; i++) { - if ((i&7)==0) fprintf(stderr,"\n"); - fprintf(stderr," %d: %x", i, vgaReg->Attribute[i]); - } - fprintf(stderr,"\n"); - - - fprintf(stderr," DisplayControl: %x\n", mode->DisplayControl); - fprintf(stderr," PixelPipeCfg0: %x\n", mode->PixelPipeCfg0); - fprintf(stderr," PixelPipeCfg1: %x\n", mode->PixelPipeCfg1); - fprintf(stderr," PixelPipeCfg2: %x\n", mode->PixelPipeCfg2); - fprintf(stderr," VideoClk2_M: %x\n", mode->VideoClk2_M); - fprintf(stderr," VideoClk2_N: %x\n", mode->VideoClk2_N); - fprintf(stderr," VideoClk2_DivisorSel: %x\n", mode->VideoClk2_DivisorSel); - fprintf(stderr," AddressMapping: %x\n", mode->AddressMapping); - fprintf(stderr," IOControl: %x\n", mode->IOControl); - fprintf(stderr," BitBLTControl: %x\n", mode->BitBLTControl); - fprintf(stderr," ExtVertTotal: %x\n", mode->ExtVertTotal); - fprintf(stderr," ExtVertDispEnd: %x\n", mode->ExtVertDispEnd); - fprintf(stderr," ExtVertSyncStart: %x\n", mode->ExtVertSyncStart); - fprintf(stderr," ExtVertBlankStart: %x\n", mode->ExtVertBlankStart); - fprintf(stderr," ExtHorizTotal: %x\n", mode->ExtHorizTotal); - fprintf(stderr," ExtHorizBlank: %x\n", mode->ExtHorizBlank); - fprintf(stderr," ExtOffset: %x\n", mode->ExtOffset); - fprintf(stderr," InterlaceControl: %x\n", mode->InterlaceControl); - fprintf(stderr," LMI_FIFO_Watermark: %x\n", mode->LMI_FIFO_Watermark); - fprintf(stderr," LprbTail: %x\n", mode->LprbTail); - fprintf(stderr," LprbHead: %x\n", mode->LprbHead); - fprintf(stderr," LprbStart: %x\n", mode->LprbStart); - fprintf(stderr," LprbLen: %x\n", mode->LprbLen); - fprintf(stderr," OverlayActiveStart: %x\n", mode->OverlayActiveStart); - fprintf(stderr," OverlayActiveEnd: %x\n", mode->OverlayActiveEnd); -} - - -/* - * i810VGASeqReset - * perform a sequencer reset. - * - * The i815 documentation states that these bits are not used by the - * HW, but still warns about not programming them... - */ - -void -i810VGASeqReset(i810VGAPtr vgap, Bool start) -{ - if (start) - { - mmioWriteSeq(vgap, 0x00, 0x01); /* Synchronous Reset */ - } - else - { - mmioWriteSeq(vgap, 0x00, 0x03); /* End Reset */ - } -} - -void -i810VGAProtect(KdCardInfo *card, Bool on) -{ - - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - - unsigned char tmp; - - if (on) { - /* - * Turn off screen and disable sequencer. - */ - tmp = mmioReadSeq(vgap, 0x01); - - i810VGASeqReset(vgap, TRUE); /* start synchronous reset */ - mmioWriteSeq(vgap, 0x01, tmp | 0x20); /* disable the display */ - - mmioEnablePalette(vgap); - } else { - /* - * Reenable sequencer, then turn on screen. - */ - - tmp = mmioReadSeq(vgap, 0x01); - - mmioWriteSeq(vgap, 0x01, tmp & ~0x20); /* reenable display */ - i810VGASeqReset(vgap, FALSE); /* clear synchronousreset */ - - mmioDisablePalette(vgap); - } -} - -/* - * i810VGABlankScreen -- blank the screen. - */ - -void -i810VGABlankScreen(KdCardInfo *card, Bool on) -{ - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - - unsigned char scrn; - - scrn = mmioReadSeq(vgap, 0x01); - - if (on) { - scrn &= ~0x20; /* enable screen */ - } else { - scrn |= 0x20; /* blank screen */ - } - - mmioWriteSeq(vgap,0x00,0x01); - mmioWriteSeq(vgap, 0x01, scrn); /* change mode */ - mmioWriteSeq(vgap,0x00,0x03); -} - -/* Restore hardware state */ - -static void -DoRestore(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg, - Bool restoreFonts) { - - - I810CardInfo *i810c = card->driver; - - i810VGAPtr vgap = &i810c->vga; - - unsigned char temp; - unsigned int itemp; - int i; - - if (I810_DEBUG & DEBUG_VERBOSE_VGA) { - fprintf(stderr,"Setting mode in DoRestore:\n"); - i810PrintMode( vgaReg, i810Reg ); - } - - /* Blank screen (i810vgaprotect) */ - i810VGAProtect(card, TRUE); - - /* Should wait for at least two hsync and no more than two vsync - before writing PIXCONF and turning the display on (?) */ - usleep(50000); - - /* Turn off DRAM Refresh */ - temp = INREG8( DRAM_ROW_CNTL_HI ); - temp &= ~DRAM_REFRESH_RATE; - temp |= DRAM_REFRESH_DISABLE; - OUTREG8( DRAM_ROW_CNTL_HI, temp ); - - usleep(1000); /* Wait 1 ms */ - - /* Write the M, N and P values */ - OUTREG16( VCLK2_VCO_M, i810Reg->VideoClk2_M); - OUTREG16( VCLK2_VCO_N, i810Reg->VideoClk2_N); - OUTREG8( VCLK2_VCO_DIV_SEL, i810Reg->VideoClk2_DivisorSel); - - /* - * Turn on 8 bit dac mode, if requested. This is needed to make - * sure that vgaHWRestore writes the values into the DAC properly. - * The problem occurs if 8 bit dac mode is requested and the HW is - * in 6 bit dac mode. If this happens, all the values are - * automatically shifted left twice by the HW and incorrect colors - * will be displayed on the screen. The only time this can happen - * is at server startup time and when switching back from a VT. - */ - temp = INREG8(PIXPIPE_CONFIG_0); - temp &= 0x7F; /* Save all but the 8 bit dac mode bit */ - temp |= (i810Reg->PixelPipeCfg0 & DAC_8_BIT); - OUTREG8( PIXPIPE_CONFIG_0, temp ); - - /* - * Code to restore any SVGA registers that have been saved/modified - * goes here. Note that it is allowable, and often correct, to - * only modify certain bits in a register by a read/modify/write cycle. - * - * A special case - when using an external clock-setting program, - * this function must not change bits associated with the clock - * selection. This condition can be checked by the condition: - * - * if (i810Reg->std.NoClock >= 0) - * restore clock-select bits. - */ - - /* VGA restore */ - if (vgaReg->MiscOutReg & 0x01) - vgap->IOBase = VGA_IOBASE_COLOR; - else - vgap->IOBase = VGA_IOBASE_MONO; - - mmioWriteMiscOut(vgap, vgaReg->MiscOutReg); - - for (i = 1; i < VGA_NUM_SEQ; i++) - mmioWriteSeq(vgap, i, vgaReg->Sequencer[i]); - - /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */ - /* = CR11 */ - mmioWriteCrtc(vgap, 17, vgaReg->CRTC[17] & ~0x80); - - for (i = 0; i < VGA_NUM_CRTC; i++) { - mmioWriteCrtc(vgap, i, vgaReg->CRTC[i]); - } - - for (i = 0; i < VGA_NUM_GFX; i++) - mmioWriteGr(vgap, i, vgaReg->Graphics[i]); - - mmioEnablePalette(vgap); - for (i = 0; i < VGA_NUM_ATTR; i++) - mmioWriteAttr(vgap, i, vgaReg->Attribute[i]); - mmioDisablePalette(vgap); - - - mmioWriteCrtc(vgap, EXT_VERT_TOTAL, i810Reg->ExtVertTotal); - mmioWriteCrtc(vgap, EXT_VERT_DISPLAY, i810Reg->ExtVertDispEnd); - mmioWriteCrtc(vgap, EXT_VERT_SYNC_START, i810Reg->ExtVertSyncStart); - mmioWriteCrtc(vgap, EXT_VERT_BLANK_START, i810Reg->ExtVertBlankStart); - mmioWriteCrtc(vgap, EXT_HORIZ_TOTAL, i810Reg->ExtHorizTotal); - mmioWriteCrtc(vgap, EXT_HORIZ_BLANK, i810Reg->ExtHorizBlank); - - /* write CR40, CR42 first etc to get CR13 written as described in PRM */ - - mmioWriteCrtc(vgap, EXT_START_ADDR_HI, 0); - mmioWriteCrtc(vgap, EXT_START_ADDR, EXT_START_ADDR_ENABLE); - - mmioWriteCrtc(vgap, EXT_OFFSET, i810Reg->ExtOffset); - mmioWriteCrtc(vgap, 0x13, vgaReg->CRTC[0x13]); - - temp=mmioReadCrtc(vgap, INTERLACE_CNTL); - temp &= ~INTERLACE_ENABLE; - temp |= i810Reg->InterlaceControl; - mmioWriteCrtc(vgap, INTERLACE_CNTL, temp); - - temp=i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING); - temp &= 0xE0; /* Save reserved bits 7:5 */ - temp |= i810Reg->AddressMapping; - i810WriteControlMMIO(i810c, GRX, ADDRESS_MAPPING, temp); - - /* Setting the OVRACT Register for video overlay*/ - OUTREG(0x6001C, (i810Reg->OverlayActiveEnd << 16) | i810Reg->OverlayActiveStart); - - /* Turn on DRAM Refresh */ - temp = INREG8( DRAM_ROW_CNTL_HI ); - temp &= ~DRAM_REFRESH_RATE; - temp |= DRAM_REFRESH_60HZ; - OUTREG8( DRAM_ROW_CNTL_HI, temp ); - - temp = INREG8( BITBLT_CNTL ); - temp &= ~COLEXP_MODE; - temp |= i810Reg->BitBLTControl; - OUTREG8( BITBLT_CNTL, temp ); - - temp = INREG8( DISPLAY_CNTL ); - temp &= ~(VGA_WRAP_MODE | GUI_MODE); - temp |= i810Reg->DisplayControl; - OUTREG8( DISPLAY_CNTL, temp ); - - - temp = INREG8( PIXPIPE_CONFIG_0 ); - temp &= 0x64; /* Save reserved bits 6:5,2 */ - temp |= i810Reg->PixelPipeCfg0; - OUTREG8( PIXPIPE_CONFIG_0, temp ); - - temp = INREG8( PIXPIPE_CONFIG_2 ); - temp &= 0xF3; /* Save reserved bits 7:4,1:0 */ - temp |= i810Reg->PixelPipeCfg2; - OUTREG8( PIXPIPE_CONFIG_2, temp ); - - temp = INREG8( PIXPIPE_CONFIG_1 ); - temp &= ~DISPLAY_COLOR_MODE; - temp &= 0xEF; /* Restore the CRT control bit */ - temp |= i810Reg->PixelPipeCfg1; - OUTREG8( PIXPIPE_CONFIG_1, temp ); - - OUTREG16(EIR, 0); - - itemp = INREG(FWATER_BLC); - itemp &= ~(LM_BURST_LENGTH | LM_FIFO_WATERMARK | - MM_BURST_LENGTH | MM_FIFO_WATERMARK ); - itemp |= i810Reg->LMI_FIFO_Watermark; - OUTREG(FWATER_BLC, itemp); - - - for (i = 0 ; i < 8 ; i++) { - OUTREG( FENCE+i*4, i810Reg->Fence[i] ); - if (I810_DEBUG & DEBUG_VERBOSE_VGA) - fprintf(stderr,"Fence Register : %x\n", i810Reg->Fence[i]); - } - - /* First disable the ring buffer (Need to wait for empty first?, if so - * should probably do it before entering this section) - */ - itemp = INREG(LP_RING + RING_LEN); - itemp &= ~RING_VALID_MASK; - OUTREG(LP_RING + RING_LEN, itemp ); - - /* Set up the low priority ring buffer. - */ - OUTREG(LP_RING + RING_TAIL, 0 ); - OUTREG(LP_RING + RING_HEAD, 0 ); - - i810c->LpRing.head = 0; - i810c->LpRing.tail = 0; - - itemp = INREG(LP_RING + RING_START); - itemp &= ~(START_ADDR); - itemp |= i810Reg->LprbStart; - OUTREG(LP_RING + RING_START, itemp ); - - itemp = INREG(LP_RING + RING_LEN); - itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK); - itemp |= i810Reg->LprbLen; - OUTREG(LP_RING + RING_LEN, itemp ); - - i810VGAProtect(card, FALSE); - - temp=mmioReadCrtc(vgap, IO_CTNL); - temp &= ~(EXTENDED_ATTR_CNTL | EXTENDED_CRTC_CNTL); - temp |= i810Reg->IOControl; - mmioWriteCrtc(vgap, IO_CTNL, temp); - /* Protect CRTC[0-7] */ - mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80); -} - - -static Bool -i810SetMode(KdScreenInfo *screen, const KdMonitorTiming *t) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - - I810RegPtr i810Reg = &i810c->ModeReg; - vgaRegPtr pVga = &vgap->ModeReg; - - double dclk = t->clock/1000.0; - - switch (screen->fb[0].bitsPerPixel) { - case 8: - pVga->CRTC[0x13] = screen->width >> 3; - i810Reg->ExtOffset = screen->width >> 11; - i810Reg->PixelPipeCfg1 = DISPLAY_8BPP_MODE; - i810Reg->BitBLTControl = COLEXP_8BPP; - break; - case 16: - i810Reg->PixelPipeCfg1 = DISPLAY_16BPP_MODE; - pVga->CRTC[0x13] = screen->width >> 2; - i810Reg->ExtOffset = screen->width >> 10; - i810Reg->BitBLTControl = COLEXP_16BPP; - break; - case 24: - pVga->CRTC[0x13] = (screen->width * 3) >> 3; - i810Reg->ExtOffset = (screen->width * 3) >> 11; - - i810Reg->PixelPipeCfg1 = DISPLAY_24BPP_MODE; - i810Reg->BitBLTControl = COLEXP_24BPP; - break; - default: - break; - } - - i810Reg->PixelPipeCfg0 = DAC_8_BIT; - - /* Do not delay CRT Blank: needed for video overlay */ - i810Reg->PixelPipeCfg1 |= 0x10; - - /* Turn on Extended VGA Interpretation */ - i810Reg->IOControl = EXTENDED_CRTC_CNTL; - - /* Turn on linear and page mapping */ - i810Reg->AddressMapping = (LINEAR_MODE_ENABLE | - GTT_MEM_MAP_ENABLE); - - /* Turn on GUI mode */ - i810Reg->DisplayControl = HIRES_MODE; - - i810Reg->OverlayActiveStart = t->horizontal + t->hblank - 32; - i810Reg->OverlayActiveEnd = t->horizontal - 32; - - /* Turn on interlaced mode if necessary (it's not) */ - i810Reg->InterlaceControl = INTERLACE_DISABLE; - - /* - * Set the overscan color to 0. - * NOTE: This only affects >8bpp mode. - */ - pVga->Attribute[0x11] = 0; - - /* - * Calculate the VCLK that most closely matches the requested dot - * clock. - */ - i810CalcVCLK(screen, dclk); - - /* Since we program the clocks ourselves, always use VCLK2. */ - pVga->MiscOutReg |= 0x0C; - - /* Calculate the FIFO Watermark and Burst Length. */ - i810Reg->LMI_FIFO_Watermark = i810CalcWatermark(screen, dclk, FALSE); - - /* Setup the ring buffer */ - i810Reg->LprbTail = 0; - i810Reg->LprbHead = 0; - i810Reg->LprbStart = i810c->LpRing.mem.Start; - - if (i810Reg->LprbStart) - i810Reg->LprbLen = ((i810c->LpRing.mem.Size-4096) | - RING_NO_REPORT | RING_VALID); - else - i810Reg->LprbLen = RING_INVALID; - - return TRUE; -} - -static Bool -i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t) -{ - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - vgaRegPtr pVga; - -/* fprintf(stderr,"i810ModeInit\n"); */ - - i810VGAUnlock(vgap); - - if (!i810VGAInit(screen, t)) return FALSE; - pVga = &vgap->ModeReg; - - if (!i810SetMode(screen, t)) return FALSE; - - DoRestore(screen->card, &vgap->ModeReg, &i810c->ModeReg, FALSE); - - return TRUE; -} - -Bool -i810VGAInit(KdScreenInfo *screen, const KdMonitorTiming *t) -{ - unsigned int i; - - int hactive, hblank, hbp, hfp; - int vactive, vblank, vbp, vfp; - int h_screen_off, h_adjust, h_total, h_display_end, h_blank_start; - int h_blank_end, h_sync_start, h_sync_end, v_total, v_retrace_start; - int v_retrace_end, v_display_end, v_blank_start, v_blank_end; - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - - i810VGAPtr vgap = &i810c->vga; - I810RegPtr ireg = &i810c->ModeReg; - - - vgaRegPtr regp; - int depth = screen->fb[0].depth; - - regp = &vgap->ModeReg; - - /* - * compute correct Hsync & Vsync polarity - */ - - regp->MiscOutReg = 0x23; - if (t->vpol == KdSyncNegative) regp->MiscOutReg |= 0x40; - if (t->hpol == KdSyncNegative) regp->MiscOutReg |= 0x80; - - /* - * Time Sequencer - */ - if (depth == 4) - regp->Sequencer[0] = 0x02; - else - regp->Sequencer[0] = 0x00; - /* No support for 320 or 360 x resolution */ - regp->Sequencer[1] = 0x01; - - if (depth == 1) - regp->Sequencer[2] = 1 << BIT_PLANE; - else - regp->Sequencer[2] = 0x0F; - - regp->Sequencer[3] = 0x00; /* Font select */ - - if (depth < 8) - regp->Sequencer[4] = 0x06; /* Misc */ - else - regp->Sequencer[4] = 0x0E; /* Misc */ - - hactive = t->horizontal; - hblank = t->hblank; - hbp = t->hbp; - hfp = t->hfp; - - vactive = t->vertical; - vblank = t->vblank; - vbp = t->vbp; - vfp = t->vfp; - - switch (screen->fb[0].bitsPerPixel) { - case 8: - hactive /= 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - 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; - break; - case 24: - hactive /= 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - - h_screen_off = hactive * 3; - h_adjust = 1; - break; - case 32: - hactive /= 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - - h_screen_off = hactive * 4; - h_adjust = 1; - break; - } - - /* - * 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; - - /* Set CRTC regs for horizontal timings */ - regp->CRTC[0x0] = h_total; - ireg->ExtHorizTotal=(h_total & 0x100) >> 8; - - regp->CRTC[0x1] = h_display_end; - - regp->CRTC[0x2] = h_blank_start; - - regp->CRTC[0x3] = 0x80 | (h_blank_end & 0x1f); - regp->CRTC[0x5] = (h_blank_end & 0x20) << 2; - - regp->CRTC[0x4] = h_sync_start; - - regp->CRTC[0x5] |= h_sync_end & 0x1f; - - regp->CRTC[0x13] = h_screen_off; - ireg->ExtOffset = h_screen_off >> 8; - - /* Compute vertical timings */ - 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 */; - - regp->CRTC[0x6] = v_total; - ireg->ExtVertTotal = v_total >> 8; - - regp->CRTC[0x10] = v_retrace_start; - ireg->ExtVertSyncStart = v_retrace_start >> 8; - - regp->CRTC[0x11] = v_retrace_end; - - regp->CRTC[0x12] = v_display_end; - ireg->ExtVertDispEnd = v_display_end >> 8; - - regp->CRTC[0x15] = v_blank_start; - ireg->ExtVertBlankStart = v_blank_start >> 8; - - regp->CRTC[0x16] = v_blank_end; - - if (depth < 8) - regp->CRTC[23] = 0xE3; - else - regp->CRTC[23] = 0xC3; - regp->CRTC[24] = 0xFF; - - /* - * Graphics Display Controller - */ - regp->Graphics[0] = 0x00; - regp->Graphics[1] = 0x00; - regp->Graphics[2] = 0x00; - regp->Graphics[3] = 0x00; - if (depth == 1) { - regp->Graphics[4] = BIT_PLANE; - regp->Graphics[5] = 0x00; - } else { - regp->Graphics[4] = 0x00; - if (depth == 4) - regp->Graphics[5] = 0x02; - else - regp->Graphics[5] = 0x40; - } - regp->Graphics[6] = 0x05; - regp->Graphics[7] = 0x0F; - regp->Graphics[8] = 0xFF; - - if (depth == 1) { - /* Initialise the Mono map according to which bit-plane gets used */ - - Bool flipPixels = FALSE; /* maybe support this in the future? */ - - for (i=0; i<16; i++) - if (((i & (1 << BIT_PLANE)) != 0) != flipPixels) - regp->Attribute[i] = WHITE_VALUE; - else - regp->Attribute[i] = BLACK_VALUE; - - regp->Attribute[16] = 0x01; /* -VGA2- */ - if (!vgap->ShowOverscan) - regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */ - } else { - regp->Attribute[0] = 0x00; /* standard colormap translation */ - regp->Attribute[1] = 0x01; - regp->Attribute[2] = 0x02; - regp->Attribute[3] = 0x03; - regp->Attribute[4] = 0x04; - regp->Attribute[5] = 0x05; - regp->Attribute[6] = 0x06; - regp->Attribute[7] = 0x07; - regp->Attribute[8] = 0x08; - regp->Attribute[9] = 0x09; - regp->Attribute[10] = 0x0A; - regp->Attribute[11] = 0x0B; - regp->Attribute[12] = 0x0C; - regp->Attribute[13] = 0x0D; - regp->Attribute[14] = 0x0E; - regp->Attribute[15] = 0x0F; - if (depth == 4) - regp->Attribute[16] = 0x81; - else - regp->Attribute[16] = 0x41; - /* Attribute[17] (overscan) was initialised earlier */ - } - regp->Attribute[18] = 0x0F; - regp->Attribute[19] = 0x00; - regp->Attribute[20] = 0x00; - - return(TRUE); -} - -void -i810VGALock(i810VGAPtr vgap) -{ - /* Protect CRTC[0-7] */ - mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) & ~0x80); -} - -void -i810VGAUnlock(i810VGAPtr vgap) -{ - /* Unprotect CRTC[0-7] */ - mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80); -} - -static void -i810Restore(KdCardInfo *card) { - - I810CardInfo *i810c = card->driver; - - i810VGAPtr vgap = &i810c->vga; - - if (I810_DEBUG) - fprintf(stderr,"i810Restore\n"); - - DoRestore(card, &vgap->SavedReg, &i810c->SavedReg, TRUE); -} - -Bool -i810Enable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - I810CardInfo *i810c = card->driver; - i810VGAPtr vgap = &i810c->vga; - const KdMonitorTiming *t; - - if (I810_DEBUG) - fprintf(stderr,"i810Enable\n"); - - vgap->IOBase = (mmioReadMiscOut(vgap) & 0x01) ? - VGA_IOBASE_COLOR : VGA_IOBASE_MONO; - - { - I810RegPtr i810Reg = &i810c->ModeReg; - int i; - - for (i = 0 ; i < 8 ; i++) - i810Reg->Fence[i] = 0; - } - - t = KdFindMode (screen, i810ModeSupported); - - if (!i810BindGARTMemory(screen)) - return FALSE; - - if (!i810ModeInit(screen, t)) return FALSE; - - { - /* DPMS power on state */ - - unsigned char SEQ01=0; - int DPMSSyncSelect=0; - - SEQ01 = 0x00; - DPMSSyncSelect = HSYNC_ON | VSYNC_ON; - - SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20; - i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01); - - /* Set the DPMS mode */ - OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect); - } -#ifdef XV - KdXVEnable (pScreen); -#endif - return TRUE; -} - - -void -i810Disable(ScreenPtr pScreen) { - - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - I810CardInfo *i810c = card->driver; - - i810VGAPtr vgap = &i810c->vga; - - if (I810_DEBUG) - fprintf(stderr,"i810Disable\n"); - -#ifdef XV - KdXVDisable (pScreen); -#endif - i810Restore(screen->card); - - if (!i810UnbindGARTMemory(screen)) - return; - - i810VGALock(vgap); -} - - -static Bool -i810DPMS(ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - I810CardInfo *i810c = card->driver; - - unsigned char SEQ01=0; - int DPMSSyncSelect=0; - - if (I810_DEBUG) - fprintf(stderr,"i810DPMS: %d\n",mode); - - switch (mode) { - case KD_DPMS_NORMAL: - /* Screen: On; HSync: On, VSync: On */ - SEQ01 = 0x00; - DPMSSyncSelect = HSYNC_ON | VSYNC_ON; - break; - case KD_DPMS_STANDBY: - /* Screen: Off; HSync: Off, VSync: On */ - SEQ01 = 0x20; - DPMSSyncSelect = HSYNC_OFF | VSYNC_ON; - break; - case KD_DPMS_SUSPEND: - /* Screen: Off; HSync: On, VSync: Off */ - SEQ01 = 0x20; - DPMSSyncSelect = HSYNC_ON | VSYNC_OFF; - break; - case KD_DPMS_POWERDOWN: - /* Screen: Off; HSync: Off, VSync: Off */ - SEQ01 = 0x20; - DPMSSyncSelect = HSYNC_OFF | VSYNC_OFF; - break; - } - - /* Turn the screen on/off */ - SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20; - i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01); - - /* Set the DPMS mode */ - OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect); - return TRUE; -} - - -void i810GetColors (ScreenPtr pScreen, int fb, int ndefs, xColorItem *c) { - - if (I810_DEBUG) - fprintf(stderr,"i810GetColors (NOT IMPLEMENTED)\n"); -} - -#define DACDelay(hw) \ - do { \ - unsigned char temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ - temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ - } while (0) - -void i810PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) { - - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - i810VGAPtr vgap = &i810c->vga; - - if (I810_DEBUG) - fprintf(stderr,"i810PutColors\n"); - - while (ndef--) - { - mmioWriteDacWriteAddr(vgap, pdefs->pixel); - DACDelay(vgap); - mmioWriteDacData(vgap, pdefs->red); - DACDelay(vgap); - mmioWriteDacData(vgap, pdefs->green); - DACDelay(vgap); - mmioWriteDacData(vgap, pdefs->blue); - DACDelay(vgap); - - pdefs++; - } -} - - -KdCardFuncs i810Funcs = { - i810CardInit, /* cardinit */ - i810ScreenInit, /* scrinit */ - i810InitScreen, /* initScreen */ - i810Preserve, /* preserve */ - i810Enable, /* enable */ - i810DPMS, /* dpms */ - i810Disable, /* disable */ - i810Restore, /* restore */ - i810ScreenFini, /* scrfini */ - i810CardFini, /* cardfini */ - - i810CursorInit, /* initCursor */ - i810CursorEnable, /* enableCursor */ - i810CursorDisable, /* disableCursor */ - i810CursorFini, /* finiCursor */ - NULL, /* recolorCursor */ - - i810InitAccel, /* initAccel */ - i810EnableAccel, /* enableAccel */ - i810SyncAccel, /* syncAccel */ - i810DisableAccel, /* disableAccel */ - i810FiniAccel, /* finiAccel */ - - i810GetColors, /* getColors */ - i810PutColors, /* putColors */ -}; diff --git a/hw/kdrive/i810/i810.h b/hw/kdrive/i810/i810.h deleted file mode 100644 index bb8091fe4..000000000 --- a/hw/kdrive/i810/i810.h +++ /dev/null @@ -1,503 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/* $RCSId: $ */ - -/* - * Author: - * Pontus Lidman <pontus.lidman@nokia.com> - */ - -#ifndef _I810_H_ -#define _I810_H_ - -#include "i810_reg.h" - -/* Globals */ - -typedef struct _I810Rec *I810Ptr; - -/* Linear region allocated in framebuffer. - */ -typedef struct { - unsigned long Start; - unsigned long End; - unsigned long Size; -} I810MemRange; - -typedef struct { - int tail_mask; - I810MemRange mem; - unsigned char *virtual_start; - int head; - int tail; - int space; -} I810RingBuffer; - -typedef struct { - unsigned char DisplayControl; - unsigned char PixelPipeCfg0; - unsigned char PixelPipeCfg1; - unsigned char PixelPipeCfg2; - unsigned short VideoClk2_M; - unsigned short VideoClk2_N; - unsigned char VideoClk2_DivisorSel; - unsigned char AddressMapping; - unsigned char IOControl; - unsigned char BitBLTControl; - unsigned char ExtVertTotal; - unsigned char ExtVertDispEnd; - unsigned char ExtVertSyncStart; - unsigned char ExtVertBlankStart; - unsigned char ExtHorizTotal; - unsigned char ExtHorizBlank; - unsigned char ExtOffset; - unsigned char InterlaceControl; - unsigned int LMI_FIFO_Watermark; - - unsigned int LprbTail; - unsigned int LprbHead; - unsigned int LprbStart; - unsigned int LprbLen; - - unsigned int Fence[8]; - - unsigned short OverlayActiveStart; - unsigned short OverlayActiveEnd; - - -} I810RegRec, *I810RegPtr; - -#define minb(p) *(volatile CARD8 *)(i810c->MMIOBase + (p)) -#define moutb(p,v) *(volatile CARD8 *)(i810c->MMIOBase + (p)) = (v) - -#define OUT_RING(n) { \ - if (I810_DEBUG & DEBUG_VERBOSE_RING) \ - ErrorF( "OUT_RING %x: %x\n", outring, n); \ - *(volatile unsigned int *)(virt + outring) = n; \ - outring += 4; \ - outring &= ringmask; \ -} - -#define ADVANCE_LP_RING() { \ - i810c->LpRing.tail = outring; \ - OUTREG(LP_RING + RING_TAIL, outring); \ -} - -#ifdef __GNUC__ -#define LP_RING_MESSAGE(n) \ - ErrorF("BEGIN_LP_RING %d in %s\n", n, __FUNCTION__) -#else -#define LP_RING_MESSAGE(n) \ - ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__) -#endif - -#define BEGIN_LP_RING(n) \ - unsigned int outring, ringmask; \ - volatile unsigned char *virt; \ - if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) i810Sync( screen ); \ - if (i810c->LpRing.space < n*4) i810WaitLpRing( screen, n*4, 0); \ - i810c->LpRing.space -= n*4; \ - if (I810_DEBUG & DEBUG_VERBOSE_RING) \ - LP_RING_MESSAGE(n); \ - outring = i810c->LpRing.tail; \ - ringmask = i810c->LpRing.tail_mask; \ - virt = i810c->LpRing.virtual_start; - -/* Memory mapped register access macros */ -#define INREG8(addr) *(volatile CARD8 *)(i810c->MMIOBase + (addr)) -#define INREG16(addr) *(volatile CARD16 *)(i810c->MMIOBase + (addr)) -#define INREG(addr) *(volatile CARD32 *)(i810c->MMIOBase + (addr)) - -#define OUTREG8(addr, val) do { \ - *(volatile CARD8 *)(i810c->MMIOBase + (addr)) = (val); \ - if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \ - ErrorF( "OUTREG8(%x, %x)\n", addr, val); \ -} while (0) - -#define OUTREG16(addr, val) do { \ - *(volatile CARD16 *)(i810c->MMIOBase + (addr)) = (val); \ - if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \ - ErrorF( "OUTREG16(%x, %x)\n", addr, val); \ -} while (0) - -#define OUTREG(addr, val) do { \ - *(volatile CARD32 *)(i810c->MMIOBase + (addr)) = (val); \ - if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \ - ErrorF( "OUTREG(%x, %x)\n", addr, val); \ -} while (0) - -/* To remove all debugging, make sure I810_DEBUG is defined as a - * preprocessor symbol, and equal to zero. - */ - -#define I810_DEBUG 0 - -#ifndef I810_DEBUG -#warning "Debugging enabled - expect reduced performance" -extern int I810_DEBUG; -#endif - -#define DEBUG_VERBOSE_ACCEL 0x1 -#define DEBUG_VERBOSE_SYNC 0x2 -#define DEBUG_VERBOSE_VGA 0x4 -#define DEBUG_VERBOSE_RING 0x8 -#define DEBUG_VERBOSE_OUTREG 0x10 -#define DEBUG_VERBOSE_MEMORY 0x20 -#define DEBUG_VERBOSE_CURSOR 0x40 -#define DEBUG_ALWAYS_SYNC 0x80 -#define DEBUG_VERBOSE_DRI 0x100 - - -/* Size of the mmio region. - */ -#define I810_REG_SIZE 0x80000 - -/* PCI identifiers */ -#ifndef PCI_CHIP_I810 -#define PCI_CHIP_I810 0x7121 -#define PCI_CHIP_I810_DC100 0x7123 -#define PCI_CHIP_I810_E 0x7125 -#define PCI_CHIP_I815 0x1132 -#define PCI_CHIP_I810_BRIDGE 0x7120 -#define PCI_CHIP_I810_DC100_BRIDGE 0x7122 -#define PCI_CHIP_I810_E_BRIDGE 0x7124 -#define PCI_CHIP_I815_BRIDGE 0x1130 -#endif - - -#define IS_I810(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I810 || \ - i810c->PciInfo->chipType == PCI_CHIP_I810_DC100 || \ - i810c->PciInfo->chipType == PCI_CHIP_I810_E) -#define IS_I815(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I815) - - -/* default number of VGA registers stored internally */ -#define VGA_NUM_CRTC 25 /* 0x19 */ -#define VGA_NUM_SEQ 5 -#define VGA_NUM_GFX 9 -#define VGA_NUM_ATTR 21 - -/* - * Settings of standard VGA registers. - */ -typedef struct { - unsigned char MiscOutReg; /* */ - unsigned char CRTC[VGA_NUM_CRTC]; /* Crtc Controller */ - unsigned char Sequencer[VGA_NUM_SEQ]; /* Video Sequencer */ - unsigned char Graphics[VGA_NUM_GFX]; /* Video Graphics */ - unsigned char Attribute[VGA_NUM_ATTR]; /* Video Atribute */ - unsigned char DAC[768]; /* Internal Colorlookuptable */ -} vgaRegRec, *vgaRegPtr; - - -typedef struct _i810VGARec *i810VGAPtr; - -/* VGA registers */ -typedef struct _i810VGARec { - int IOBase; /* I/O Base address */ - CARD8 * MMIOBase; /* Pointer to MMIO start */ - vgaRegRec SavedReg; /* saved registers */ - vgaRegRec ModeReg; /* register settings for - current mode */ - Bool ShowOverscan; - Bool paletteEnabled; - Bool cmapSaved; -} i810VGARec; - -typedef struct _i810CardInfo { - int videoRam; - int MaxClock; - long FbMapSize; - int cpp; /* chars per pixel */ - - unsigned long LinearAddr; - unsigned long MMIOAddr; - - unsigned char *MMIOBase; - unsigned char *FbBase; - - Bool GttBound; - Bool agpAcquired2d; - int VramKey; - unsigned long VramOffset; - int DcacheKey; - unsigned long DcacheOffset; - int HwcursKey; - unsigned long HwcursOffset; - - I810MemRange DcacheMem; - I810MemRange SysMem; - - I810MemRange SavedDcacheMem; - I810MemRange SavedSysMem; - - unsigned int bufferOffset; /* for I810SelectBuffer */ - Bool DoneFrontAlloc; - BoxRec FbMemBox; - I810MemRange FrontBuffer; - I810MemRange Scratch; - I810MemRange XvMem; - - int LmFreqSel; - - i810VGARec vga; - - I810RegRec SavedReg; - I810RegRec ModeReg; - I810RingBuffer LpRing; - - unsigned int BR[20]; - - int CursorOffset; - unsigned long CursorPhysical; - unsigned long CursorStart; - unsigned long OverlayPhysical; - unsigned long OverlayStart; - int colorKey; - - Bool NeedToSync; /* Need to sync accel stuff */ - - int nextColorExpandBuf; - - ScreenBlockHandlerProcPtr BlockHandler; - -#ifdef XV - KdVideoAdaptorPtr adaptor; -#endif - -} I810CardInfo; - -#define getI810CardInfo(kd) ((I810CardInfo *) ((kd)->card->driver)) -#define i810CardInfo(kd) I810CardInfo *i810c = getI810CardInfo(kd) - -#define getI810ScreenInfo(kd) ((I810ScreenInfo *) ((kd)->screen->driver)) -#define i810ScreenInfo(kd) I810ScreenInfo *i810s = getI810ScreenInfo(kd) - -typedef struct _i810Cursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; -} i810Cursor, *i810CursorPtr; - -typedef struct _i810ScreenInfo { - i810Cursor cursor; -} I810ScreenInfo; - -#define I810_CURSOR_HEIGHT 64 -#define I810_CURSOR_WIDTH 64 - -/* init functions (i810.c) */ - -Bool -i810CardInit (KdCardInfo *card); - -Bool -i810ScreenInit (KdScreenInfo *screen); - -/* The cursor functions (i810_cursor.c) */ - -Bool -i810CursorInit(ScreenPtr pScreen); - -void -i810CursorEnable (ScreenPtr pScreen); - -void -i810CursorDisable (ScreenPtr pScreen); - -void -i810CursorFini (ScreenPtr pScreen); - -/* Accel functions (i810draw.c) */ - -Bool -i810InitAccel(ScreenPtr); - -void -i810EnableAccel (ScreenPtr); - -void -i810SyncAccel (ScreenPtr); - -void -i810DisableAccel (ScreenPtr); - -void -i810FiniAccel (ScreenPtr); - -void -i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask); - - -extern KdCardFuncs i810Funcs; - -/* Standard VGA registers */ - -#define VGA_ATTR_INDEX 0x3C0 -#define VGA_ATTR_DATA_W 0x3C0 -#define VGA_ATTR_DATA_R 0x3C1 -#define VGA_IN_STAT_0 0x3C2 /* read */ -#define VGA_MISC_OUT_W 0x3C2 /* write */ -#define VGA_ENABLE 0x3C3 -#define VGA_SEQ_INDEX 0x3C4 -#define VGA_SEQ_DATA 0x3C5 -#define VGA_DAC_MASK 0x3C6 -#define VGA_DAC_READ_ADDR 0x3C7 -#define VGA_DAC_WRITE_ADDR 0x3C8 -#define VGA_DAC_DATA 0x3C9 -#define VGA_FEATURE_R 0x3CA /* read */ -#define VGA_MISC_OUT_R 0x3CC /* read */ -#define VGA_GRAPH_INDEX 0x3CE -#define VGA_GRAPH_DATA 0x3CF - -#define VGA_IOBASE_MONO 0x3B0 -#define VGA_IOBASE_COLOR 0x3D0 - -#define VGA_CRTC_INDEX_OFFSET 0x04 -#define VGA_CRTC_DATA_OFFSET 0x05 -#define VGA_IN_STAT_1_OFFSET 0x0A /* read */ -#define VGA_FEATURE_W_OFFSET 0x0A /* write */ - -/* VGA stuff */ -#define BIT_PLANE 3 /* Which plane we write to in mono mode */ - -/* DAC indices for white and black */ -#define WHITE_VALUE 0x3F -#define BLACK_VALUE 0x00 -#define OVERSCAN_VALUE 0x01 - -#define OVERSCAN 0x11 /* Index of OverScan register */ - -void -i810VGAUnlock(i810VGAPtr vgap); - -void -i810VGALock(i810VGAPtr vgap); - -Bool -i810VGAInit(KdScreenInfo *scrninfp, const KdMonitorTiming *t); - -void -i810VGABlankScreen(KdCardInfo *card, Bool on); - -void -i810AdjustFrame(KdScreenInfo *screen, int x, int y, int flags); - -Bool -i810VGAMapMem(KdCardInfo *card); - -void -i810VGASave(KdCardInfo *card, vgaRegPtr save, int flags); - -void -i810PrintErrorState(KdCardInfo *card); - -void -i810VGAGetIOBase(i810VGAPtr vgap); - -/* - * MMIO versions of the register access functions. These require - * hwp->MemBase to be set in such a way that when the standard VGA port - * address is added the correct memory address results. - */ - -#define Vminb(p) ( *(volatile CARD8 *)(vgap->MMIOBase + (p))) -#define Vmoutb(p,v) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)) = (v)) - -#define mmioWriteCrtc(vgap, index, value) { \ - Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index); \ - Vmoutb(vgap->IOBase + VGA_CRTC_DATA_OFFSET, value); \ -} - -#define mmioReadCrtc(vgap, index) ( \ - Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index), \ - Vminb(vgap->IOBase + VGA_CRTC_DATA_OFFSET) \ -) - -#define mmioWriteGr(vgap, index, value) { \ - Vmoutb(VGA_GRAPH_INDEX, index); \ - Vmoutb(VGA_GRAPH_DATA, value); \ -} - -#define mmioReadGr(vgap, index) ( \ - Vmoutb(VGA_GRAPH_INDEX, index), \ - Vminb(VGA_GRAPH_DATA) \ -) - -#define mmioWriteSeq(vgap, index, value) {\ - Vmoutb(VGA_SEQ_INDEX, index); \ - Vmoutb(VGA_SEQ_DATA, value); \ -} - -#define mmioReadSeq(vgap, index) ( \ - Vmoutb(VGA_SEQ_INDEX, index), \ - Vminb(VGA_SEQ_DATA) \ -) - -#define mmioWriteAttr(vgap, index, value) { \ - (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \ - Vmoutb(VGA_ATTR_INDEX, index); \ - Vmoutb(VGA_ATTR_DATA_W, value); \ -} - -#define mmioReadAttr(vgap, index) ( \ - (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET), \ - Vmoutb(VGA_ATTR_INDEX, index), \ - Vminb(VGA_ATTR_DATA_R) \ -) - -#define mmioWriteMiscOut(vgap, value) Vmoutb(VGA_MISC_OUT_W, value) - - -#define mmioReadMiscOut(vgap) Vminb(VGA_MISC_OUT_R) - -#define mmioEnablePalette(vgap) { \ - (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \ - Vmoutb(VGA_ATTR_INDEX, 0x00); \ - vgap->paletteEnabled = TRUE; \ -} - -#define mmioDisablePalette(vgap) { \ - (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \ - Vmoutb(VGA_ATTR_INDEX, 0x20); \ - vgap->paletteEnabled = FALSE; \ -} - -#define mmioWriteDacWriteAddr(vgap, value) Vmoutb(VGA_DAC_WRITE_ADDR, value) - -#define mmioWriteDacData(vgap, value) Vmoutb(VGA_DAC_DATA, value) - -#endif /* _I810_H_ */ diff --git a/hw/kdrive/i810/i810_cursor.c b/hw/kdrive/i810/i810_cursor.c deleted file mode 100644 index c448f3471..000000000 --- a/hw/kdrive/i810/i810_cursor.c +++ /dev/null @@ -1,418 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - - - -/* $RCSId: xc/programs/Xserver/hw/kdrive/i810/i810_cursor.c,v 1.2 2001/12/10 16:34:20 keithp Exp $ */ - -/* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */ - -/* - * Authors: - * Keith Whitwell <keith@tungstengraphics.com> - * Pontus Lidman <pontus.lidman@nokia.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kxv.h" -#include "i810.h" -#include "cursorstr.h" - -#define SetupCursor(s) KdScreenPriv(s); \ - i810CardInfo(pScreenPriv); \ - i810ScreenInfo(pScreenPriv); \ - i810Cursor *pCurPriv = &i810s->cursor - - -static void -writeStandardMMIO(I810CardInfo *i810c, int addr, CARD8 val) { - moutb(addr, val); -} - -void -_i810MoveCursor(ScreenPtr pScreen, int x, int y) { - SetupCursor(pScreen); - int flag; - - if (I810_DEBUG & DEBUG_VERBOSE_CURSOR) - ErrorF( "I810SetCursorPosition %d %d\n", x, y); - - x += i810c->CursorOffset; - - if (x >= 0) flag = CURSOR_X_POS; - else { - flag = CURSOR_X_NEG; - x=-x; - } - - OUTREG8( CURSOR_X_LO, x&0xFF); - OUTREG8( CURSOR_X_HI, (((x >> 8) & 0x07) | flag)); - - if (y >= 0) flag = CURSOR_Y_POS; - else { - flag = CURSOR_Y_NEG; - y=-y; - } - OUTREG8( CURSOR_Y_LO, y&0xFF); - OUTREG8( CURSOR_Y_HI, (((y >> 8) & 0x07) | flag)); - - /* Enable cursor */ - OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical); - OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C); - -} - -static void i810LoadCursor(ScreenPtr pScreen, int x, int y); - -static void -i810MoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor (pScreen); - - if (!pCurPriv->has_cursor) - return; - - if (!pScreenPriv->enabled) - return; - - _i810MoveCursor (pScreen, x, y); - - i810LoadCursor(pScreen, x, y); -} - -static void -_i810SetCursorColors(ScreenPtr pScreen) { /* int bg, int fg */ - - SetupCursor(pScreen); - int tmp; - - int bg = 0xffffff; - int fg = 0x000000; - - tmp=INREG8(PIXPIPE_CONFIG_0); - tmp |= EXTENDED_PALETTE; - OUTREG8( PIXPIPE_CONFIG_0, tmp); - - writeStandardMMIO(i810c, DACMASK, 0xFF); - writeStandardMMIO(i810c, DACWX, 0x04); - - writeStandardMMIO(i810c, DACDATA, (bg & 0x00FF0000) >> 16); - writeStandardMMIO(i810c, DACDATA, (bg & 0x0000FF00) >> 8); - writeStandardMMIO(i810c, DACDATA, (bg & 0x000000FF)); - - writeStandardMMIO(i810c, DACDATA, (fg & 0x00FF0000) >> 16); - writeStandardMMIO(i810c, DACDATA, (fg & 0x0000FF00) >> 8); - writeStandardMMIO(i810c, DACDATA, (fg & 0x000000FF)); - - tmp=INREG8( PIXPIPE_CONFIG_0 ); - tmp &= ~EXTENDED_PALETTE; - OUTREG8( PIXPIPE_CONFIG_0, tmp ); -} - -#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 i810LoadCursor(ScreenPtr pScreen, int x, int y) { - - SetupCursor(pScreen); - - int w, h; - unsigned short r; - unsigned int *msk, *mskLine, *src, *srcLine; - - int i, j; - int src_stride, src_width; - - CursorPtr pCursor = pCurPriv->pCursor; - CursorBitsPtr bits = pCursor->bits; - CARD8 tmp; - unsigned int *ram, *ramLine; - - pCurPriv->pCursor = pCursor; - pCurPriv->xhot = pCursor->bits->xhot; - pCurPriv->yhot = pCursor->bits->yhot; - - ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart); - mskLine = (unsigned int *) (bits->mask); - srcLine = (unsigned int *) (bits->source); - - h = bits->height; - if (h > I810_CURSOR_HEIGHT) - h = I810_CURSOR_HEIGHT; - - src_stride = BitmapBytePad(bits->width); /* bytes per line */ - src_stride = (src_stride +3) >> 2; - src_width = (bits->width + 31) >> 5; - - for (i = 0; i < I810_CURSOR_HEIGHT; i++) { - - msk = mskLine; - src = srcLine; - ram = ramLine; - mskLine += src_stride; - srcLine += src_stride; - ramLine += I810_CURSOR_WIDTH / 16; - - for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) { - - unsigned long m, s, b1, b2; - - if (i < h && j < src_width) - { - m = *msk++; - s = *src++ & m; - m = ~m; - /* mask off right side */ - if (j == src_width - 1 && (bits->width & 31)) - { - m |= 0xffffffff << (bits->width & 31); - } - } - else - { - m = 0xffffffff; - s = 0x00000000; - } - - InvertBits32(s); - InvertBits32(m); - - ram[2+j]=s; - ram[0+j]=m; - } - } - /* Set new color */ - _i810SetCursorColors (pScreen); - - /* Move to new position */ - _i810MoveCursor (pScreen, x, y); - - /* Enable cursor */ - OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical); - OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C); - - tmp = INREG8( PIXPIPE_CONFIG_0 ); - tmp |= HW_CURSOR_ENABLE; - OUTREG8( PIXPIPE_CONFIG_0, tmp); -} - -static void -i810UnloadCursor(ScreenPtr pScreen) { - - SetupCursor(pScreen); - - unsigned char tmp; - - tmp=INREG8( PIXPIPE_CONFIG_0 ); - tmp &= ~HW_CURSOR_ENABLE; - OUTREG8( PIXPIPE_CONFIG_0, tmp); -} - - -static Bool -i810RealizeCursor (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); - i810LoadCursor (pScreen, x, y); - } - } - return TRUE; -} - -static Bool -i810UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) -{ - return TRUE; -} - -static void -i810SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) -{ - SetupCursor(pScreen); - - pCurPriv->pCursor = pCursor; - - if (!pScreenPriv->enabled) - return; - - if (pCursor) - i810LoadCursor (pScreen, x, y); - else - i810UnloadCursor (pScreen); -} - -miPointerSpriteFuncRec i810PointerSpriteFuncs = { - i810RealizeCursor, - i810UnrealizeCursor, - i810SetCursor, - i810MoveCursor, -}; - -static void -i810QueryBestSize (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 -i810CursorInit(ScreenPtr pScreen) -{ - - SetupCursor(pScreen); - - if (!i810c->CursorStart) { - pCurPriv->has_cursor = FALSE; - return FALSE; - } - - pCurPriv->width = I810_CURSOR_WIDTH; - pCurPriv->height= I810_CURSOR_HEIGHT; - pScreen->QueryBestSize = i810QueryBestSize; - miPointerInitialize (pScreen, - &i810PointerSpriteFuncs, - &kdPointerScreenFuncs, - FALSE); - pCurPriv->has_cursor = TRUE; - pCurPriv->pCursor = NULL; - return TRUE; -} - -void -i810CursorEnable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - int x, y; - - miPointerPosition (&x, &y); - i810LoadCursor (pScreen, x, y); - } - else - i810UnloadCursor (pScreen); - } -} - -void -i810CursorDisable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!pScreenPriv->enabled) - return; - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - i810UnloadCursor (pScreen); - } - } -} - -void -i810CursorFini (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - pCurPriv->pCursor = NULL; -} - diff --git a/hw/kdrive/i810/i810_reg.h b/hw/kdrive/i810/i810_reg.h deleted file mode 100644 index e6648a1de..000000000 --- a/hw/kdrive/i810/i810_reg.h +++ /dev/null @@ -1,696 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/i810/i810_reg.h,v 1.1 2001/03/30 02:18:41 keithp Exp $ */ - -/* - * Authors: - * Keith Whitwell <keith@tungstengraphics.com> - * Pontus Lidman <pontus.lidman@nokia.com> - * - * based on the i740 driver by - * Kevin E. Martin <kevin@precisioninsight.com> - * - * - */ - -/* I/O register offsets - */ -#define SRX 0x3C4 /* p208 */ -#define GRX 0x3CE /* p213 */ -#define ARX 0x3C0 /* p224 */ - -/* VGA Color Palette Registers */ -#define DACMASK 0x3C6 /* p232 */ -#define DACSTATE 0x3C7 /* p232 */ -#define DACRX 0x3C7 /* p233 */ -#define DACWX 0x3C8 /* p233 */ -#define DACDATA 0x3C9 /* p233 */ - -/* CRT Controller Registers (CRX) */ -#define START_ADDR_HI 0x0C /* p246 */ -#define START_ADDR_LO 0x0D /* p247 */ -#define VERT_SYNC_END 0x11 /* p249 */ -#define EXT_VERT_TOTAL 0x30 /* p257 */ -#define EXT_VERT_DISPLAY 0x31 /* p258 */ -#define EXT_VERT_SYNC_START 0x32 /* p259 */ -#define EXT_VERT_BLANK_START 0x33 /* p260 */ -#define EXT_HORIZ_TOTAL 0x35 /* p261 */ -#define EXT_HORIZ_BLANK 0x39 /* p261 */ -#define EXT_START_ADDR 0x40 /* p262 */ -#define EXT_START_ADDR_ENABLE 0x80 -#define EXT_OFFSET 0x41 /* p263 */ -#define EXT_START_ADDR_HI 0x42 /* p263 */ -#define INTERLACE_CNTL 0x70 /* p264 */ -#define INTERLACE_ENABLE 0x80 -#define INTERLACE_DISABLE 0x00 - -/* Miscellaneous Output Register - */ -#define MSR_R 0x3CC /* p207 */ -#define MSR_W 0x3C2 /* p207 */ -#define IO_ADDR_SELECT 0x01 - -#define MDA_BASE 0x3B0 /* p207 */ -#define CGA_BASE 0x3D0 /* p207 */ - -/* CR80 - IO Control, p264 - */ -#define IO_CTNL 0x80 -#define EXTENDED_ATTR_CNTL 0x02 -#define EXTENDED_CRTC_CNTL 0x01 - -/* GR10 - Address mapping, p221 - */ -#define ADDRESS_MAPPING 0x10 -#define PAGE_TO_LOCAL_MEM_ENABLE 0x10 -#define GTT_MEM_MAP_ENABLE 0x08 -#define PACKED_MODE_ENABLE 0x04 -#define LINEAR_MODE_ENABLE 0x02 -#define PAGE_MAPPING_ENABLE 0x01 - -/* Blitter control, p378 - */ -#define BITBLT_CNTL 0x7000c -#define COLEXP_MODE 0x30 -#define COLEXP_8BPP 0x00 -#define COLEXP_16BPP 0x10 -#define COLEXP_24BPP 0x20 -#define COLEXP_RESERVED 0x30 -#define BITBLT_STATUS 0x01 - -/* p375. - */ -#define DISPLAY_CNTL 0x70008 -#define VGA_WRAP_MODE 0x02 -#define VGA_WRAP_AT_256KB 0x00 -#define VGA_NO_WRAP 0x02 -#define GUI_MODE 0x01 -#define STANDARD_VGA_MODE 0x00 -#define HIRES_MODE 0x01 - -/* p375 - */ -#define PIXPIPE_CONFIG_0 0x70009 -#define DAC_8_BIT 0x80 -#define DAC_6_BIT 0x00 -#define HW_CURSOR_ENABLE 0x10 -#define EXTENDED_PALETTE 0x01 - -/* p375 - */ -#define PIXPIPE_CONFIG_1 0x7000a -#define DISPLAY_COLOR_MODE 0x0F -#define DISPLAY_VGA_MODE 0x00 -#define DISPLAY_8BPP_MODE 0x02 -#define DISPLAY_15BPP_MODE 0x04 -#define DISPLAY_16BPP_MODE 0x05 -#define DISPLAY_24BPP_MODE 0x06 -#define DISPLAY_32BPP_MODE 0x07 - -/* p375 - */ -#define PIXPIPE_CONFIG_2 0x7000b -#define DISPLAY_GAMMA_ENABLE 0x08 -#define DISPLAY_GAMMA_DISABLE 0x00 -#define OVERLAY_GAMMA_ENABLE 0x04 -#define OVERLAY_GAMMA_DISABLE 0x00 - - -/* p380 - */ -#define DISPLAY_BASE 0x70020 -#define DISPLAY_BASE_MASK 0x03fffffc - - -/* Cursor control registers, pp383-384 - */ -#define CURSOR_CONTROL 0x70080 -#define CURSOR_ORIGIN_SCREEN 0x00 -#define CURSOR_ORIGIN_DISPLAY 0x10 -#define CURSOR_MODE 0x07 -#define CURSOR_MODE_DISABLE 0x00 -#define CURSOR_MODE_32_4C_AX 0x01 -#define CURSOR_MODE_64_3C 0x04 -#define CURSOR_MODE_64_4C_AX 0x05 -#define CURSOR_MODE_64_4C 0x06 -#define CURSOR_MODE_RESERVED 0x07 -#define CURSOR_BASEADDR 0x70084 -#define CURSOR_BASEADDR_MASK 0x1FFFFF00 -#define CURSOR_X_LO 0x70088 -#define CURSOR_X_HI 0x70089 -#define CURSOR_X_POS 0x00 -#define CURSOR_X_NEG 0x80 -#define CURSOR_Y_LO 0x7008A -#define CURSOR_Y_HI 0x7008B -#define CURSOR_Y_POS 0x00 -#define CURSOR_Y_NEG 0x80 - - - -/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm - * not sure they refer to local (graphics) memory. - * - * These details are for the local memory control registers, - * (pp301-310). The test machines are not equiped with local memory, - * so nothing is tested. Only a single row seems to be supported. - */ -#define DRAM_ROW_TYPE 0x3000 -#define DRAM_ROW_0 0x01 -#define DRAM_ROW_0_SDRAM 0x01 -#define DRAM_ROW_0_EMPTY 0x00 -#define DRAM_ROW_CNTL_LO 0x3001 -#define DRAM_PAGE_MODE_CTRL 0x10 -#define DRAM_RAS_TO_CAS_OVRIDE 0x08 -#define DRAM_CAS_LATENCY 0x04 -#define DRAM_RAS_TIMING 0x02 -#define DRAM_RAS_PRECHARGE 0x01 -#define DRAM_ROW_CNTL_HI 0x3002 -#define DRAM_REFRESH_RATE 0x18 -#define DRAM_REFRESH_DISABLE 0x00 -#define DRAM_REFRESH_60HZ 0x08 -#define DRAM_REFRESH_FAST_TEST 0x10 -#define DRAM_REFRESH_RESERVED 0x18 -#define DRAM_SMS 0x07 -#define DRAM_SMS_NORMAL 0x00 -#define DRAM_SMS_NOP_ENABLE 0x01 -#define DRAM_SMS_ABPCE 0x02 -#define DRAM_SMS_MRCE 0x03 -#define DRAM_SMS_CBRCE 0x04 - -/* p307 - */ -#define DPMS_SYNC_SELECT 0x5002 -#define VSYNC_CNTL 0x08 -#define VSYNC_ON 0x00 -#define VSYNC_OFF 0x08 -#define HSYNC_CNTL 0x02 -#define HSYNC_ON 0x00 -#define HSYNC_OFF 0x02 - - - -/* p317, 319 - */ -#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */ -#define VCLK2_VCO_N 0x600a -#define VCLK2_VCO_DIV_SEL 0x6012 -#define POST_DIV_SELECT 0x70 -#define POST_DIV_1 0x00 -#define POST_DIV_2 0x10 -#define POST_DIV_4 0x20 -#define POST_DIV_8 0x30 -#define POST_DIV_16 0x40 -#define POST_DIV_32 0x50 -#define VCO_LOOP_DIV_BY_4M 0x00 -#define VCO_LOOP_DIV_BY_16M 0x04 - - -/* Instruction Parser Mode Register - * - p281 - * - 2 new bits. - */ -#define INST_PM 0x20c0 -#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */ -#define SYNC_PACKET_FLUSH_ENABLE 0x10 -#define TWO_D_INST_DISABLE 0x08 -#define THREE_D_INST_DISABLE 0x04 -#define STATE_VAR_UPDATE_DISABLE 0x02 -#define PAL_STIP_DISABLE 0x01 - -#define INST_DONE 0x2090 -#define INST_PS 0x20c4 - -#define MEMMODE 0x20dc - - -/* Instruction parser error register. p279 - */ -#define IPEIR 0x2088 -#define IPEHR 0x208C - - -/* General error reporting regs, p296 - */ -#define EIR 0x20B0 -#define EMR 0x20B4 -#define ESR 0x20B8 -#define IP_ERR 0x0001 -#define ERROR_RESERVED 0xffc6 - - -/* Interrupt Control Registers - * - new bits for i810 - * - new register hwstam (mask) - */ -#define HWSTAM 0x2098 /* p290 */ -#define IER 0x20a0 /* p291 */ -#define IIR 0x20a4 /* p292 */ -#define IMR 0x20a8 /* p293 */ -#define ISR 0x20ac /* p294 */ -#define HW_ERROR 0x8000 -#define SYNC_STATUS_TOGGLE 0x1000 -#define DPY_0_FLIP_PENDING 0x0800 -#define DPY_1_FLIP_PENDING 0x0400 /* not implemented on i810 */ -#define OVL_0_FLIP_PENDING 0x0200 -#define OVL_1_FLIP_PENDING 0x0100 /* not implemented on i810 */ -#define DPY_0_VBLANK 0x0080 -#define DPY_0_EVENT 0x0040 -#define DPY_1_VBLANK 0x0020 /* not implemented on i810 */ -#define DPY_1_EVENT 0x0010 /* not implemented on i810 */ -#define HOST_PORT_EVENT 0x0008 /* */ -#define CAPTURE_EVENT 0x0004 /* */ -#define USER_DEFINED 0x0002 -#define BREAKPOINT 0x0001 - - -#define INTR_RESERVED (0x6000 | \ - DPY_1_FLIP_PENDING | \ - OVL_1_FLIP_PENDING | \ - DPY_1_VBLANK | \ - DPY_1_EVENT | \ - HOST_PORT_EVENT | \ - CAPTURE_EVENT ) - -/* FIFO Watermark and Burst Length Control Register - * - * - different offset and contents on i810 (p299) (fewer bits per field) - * - some overlay fields added - * - what does it all mean? - */ -#define FWATER_BLC 0x20d8 -#define MM_BURST_LENGTH 0x00700000 -#define MM_FIFO_WATERMARK 0x0001F000 -#define LM_BURST_LENGTH 0x00000700 -#define LM_FIFO_WATERMARK 0x0000001F - - -/* Fence/Tiling ranges [0..7] - */ -#define FENCE 0x2000 -#define FENCE_NR 8 - -#define FENCE_START_MASK 0x03F80000 -#define FENCE_X_MAJOR 0x00000000 -#define FENCE_Y_MAJOR 0x00001000 -#define FENCE_SIZE_MASK 0x00000700 -#define FENCE_SIZE_512K 0x00000000 -#define FENCE_SIZE_1M 0x00000100 -#define FENCE_SIZE_2M 0x00000200 -#define FENCE_SIZE_4M 0x00000300 -#define FENCE_SIZE_8M 0x00000400 -#define FENCE_SIZE_16M 0x00000500 -#define FENCE_SIZE_32M 0x00000600 -#define FENCE_PITCH_MASK 0x00000070 -#define FENCE_PITCH_1 0x00000000 -#define FENCE_PITCH_2 0x00000010 -#define FENCE_PITCH_4 0x00000020 -#define FENCE_PITCH_8 0x00000030 -#define FENCE_PITCH_16 0x00000040 -#define FENCE_PITCH_32 0x00000050 -#define FENCE_VALID 0x00000001 - - -/* Registers to control page table, p274 - */ -#define PGETBL_CTL 0x2020 -#define PGETBL_ADDR_MASK 0xFFFFF000 -#define PGETBL_ENABLE_MASK 0x00000001 -#define PGETBL_ENABLED 0x00000001 - -/* Register containing pge table error results, p276 - */ -#define PGE_ERR 0x2024 -#define PGE_ERR_ADDR_MASK 0xFFFFF000 -#define PGE_ERR_ID_MASK 0x00000038 -#define PGE_ERR_CAPTURE 0x00000000 -#define PGE_ERR_OVERLAY 0x00000008 -#define PGE_ERR_DISPLAY 0x00000010 -#define PGE_ERR_HOST 0x00000018 -#define PGE_ERR_RENDER 0x00000020 -#define PGE_ERR_BLITTER 0x00000028 -#define PGE_ERR_MAPPING 0x00000030 -#define PGE_ERR_CMD_PARSER 0x00000038 -#define PGE_ERR_TYPE_MASK 0x00000007 -#define PGE_ERR_INV_TABLE 0x00000000 -#define PGE_ERR_INV_PTE 0x00000001 -#define PGE_ERR_MIXED_TYPES 0x00000002 -#define PGE_ERR_PAGE_MISS 0x00000003 -#define PGE_ERR_ILLEGAL_TRX 0x00000004 -#define PGE_ERR_LOCAL_MEM 0x00000005 -#define PGE_ERR_TILED 0x00000006 - - - -/* Page table entries loaded via mmio region, p323 - */ -#define PTE_BASE 0x10000 -#define PTE_ADDR_MASK 0x3FFFF000 -#define PTE_TYPE_MASK 0x00000006 -#define PTE_LOCAL 0x00000002 -#define PTE_MAIN_UNCACHED 0x00000000 -#define PTE_MAIN_CACHED 0x00000006 -#define PTE_VALID_MASK 0x00000001 -#define PTE_VALID 0x00000001 - - -/* Ring buffer registers, p277, overview p19 - */ -#define LP_RING 0x2030 -#define HP_RING 0x2040 - -#define RING_TAIL 0x00 -#define TAIL_ADDR 0x000FFFF8 - -#define RING_HEAD 0x04 -#define HEAD_WRAP_COUNT 0xFFE00000 -#define HEAD_WRAP_ONE 0x00200000 -#define HEAD_ADDR 0x001FFFFC - -#define RING_START 0x08 -#define START_ADDR 0x00FFFFF8 - -#define RING_LEN 0x0C -#define RING_NR_PAGES 0x000FF000 -#define RING_REPORT_MASK 0x00000006 -#define RING_REPORT_64K 0x00000002 -#define RING_REPORT_128K 0x00000004 -#define RING_NO_REPORT 0x00000000 -#define RING_VALID_MASK 0x00000001 -#define RING_VALID 0x00000001 -#define RING_INVALID 0x00000000 - - - -/* BitBlt Instructions - * - * There are many more masks & ranges yet to add. - */ -#define BR00_BITBLT_CLIENT 0x40000000 -#define BR00_OP_COLOR_BLT 0x10000000 -#define BR00_OP_SRC_COPY_BLT 0x10C00000 -#define BR00_OP_FULL_BLT 0x11400000 -#define BR00_OP_MONO_SRC_BLT 0x11800000 -#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000 -#define BR00_OP_MONO_PAT_BLT 0x11C00000 -#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22) -#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000 - - -#define BR00_TPCY_DISABLE 0x00000000 -#define BR00_TPCY_ENABLE 0x00000010 - -#define BR00_TPCY_ROP 0x00000000 -#define BR00_TPCY_NO_ROP 0x00000020 -#define BR00_TPCY_EQ 0x00000000 -#define BR00_TPCY_NOT_EQ 0x00000040 - -#define BR00_PAT_MSB_FIRST 0x00000000 /* ? */ - -#define BR00_PAT_VERT_ALIGN 0x000000e0 - -#define BR00_LENGTH 0x0000000F - -#define BR09_DEST_ADDR 0x03FFFFFF - -#define BR11_SOURCE_PITCH 0x00003FFF - -#define BR12_SOURCE_ADDR 0x03FFFFFF - -#define BR13_SOLID_PATTERN 0x80000000 -#define BR13_RIGHT_TO_LEFT 0x40000000 -#define BR13_LEFT_TO_RIGHT 0x00000000 -#define BR13_MONO_TRANSPCY 0x20000000 -#define BR13_USE_DYN_DEPTH 0x04000000 -#define BR13_DYN_8BPP 0x00000000 -#define BR13_DYN_16BPP 0x01000000 -#define BR13_DYN_24BPP 0x02000000 -#define BR13_ROP_MASK 0x00FF0000 -#define BR13_DEST_PITCH 0x0000FFFF -#define BR13_PITCH_SIGN_BIT 0x00008000 - -#define BR14_DEST_HEIGHT 0xFFFF0000 -#define BR14_DEST_WIDTH 0x0000FFFF - -#define BR15_PATTERN_ADDR 0x03FFFFFF - -#define BR16_SOLID_PAT_COLOR 0x00FFFFFF -#define BR16_BACKGND_PAT_CLR 0x00FFFFFF - -#define BR17_FGND_PAT_CLR 0x00FFFFFF - -#define BR18_SRC_BGND_CLR 0x00FFFFFF -#define BR19_SRC_FGND_CLR 0x00FFFFFF - - -/* Instruction parser instructions - */ - -#define INST_PARSER_CLIENT 0x00000000 -#define INST_OP_FLUSH 0x02000000 -#define INST_FLUSH_MAP_CACHE 0x00000001 - -#define INST_DEST_BUFFER_INFO 0x06800000 - -#define INST_FRONT_BUFFER_INFO 0x06000000 -#define FRONT_INFO_ASYNC_FLIP 1<<6 -#define FRONT_INFO_PITCH_B 8 - -#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) - - -/* Registers in the i810 host-pci bridge pci config space which affect - * the i810 graphics operations. - */ -#define SMRAM_MISCC 0x70 -#define GMS 0x000000c0 -#define GMS_DISABLE 0x00000000 -#define GMS_ENABLE_BARE 0x00000040 -#define GMS_ENABLE_512K 0x00000080 -#define GMS_ENABLE_1M 0x000000c0 -#define USMM 0x00000030 -#define USMM_DISABLE 0x00000000 -#define USMM_TSEG_ZERO 0x00000010 -#define USMM_TSEG_512K 0x00000020 -#define USMM_TSEG_1M 0x00000030 -#define GFX_MEM_WIN_SIZE 0x00010000 -#define GFX_MEM_WIN_32M 0x00010000 -#define GFX_MEM_WIN_64M 0x00000000 - -/* Overkill? I don't know. Need to figure out top of mem to make the - * SMRAM calculations come out. Linux seems to have problems - * detecting it all on its own, so this seems a reasonable double - * check to any user supplied 'mem=...' boot param. - * - * ... unfortunately this reg doesn't work according to spec on the - * test hardware. - */ -#define WHTCFG_PAMR_DRP 0x50 -#define SYS_DRAM_ROW_0_SHIFT 16 -#define SYS_DRAM_ROW_1_SHIFT 20 -#define DRAM_MASK 0x0f -#define DRAM_VALUE_0 0 -#define DRAM_VALUE_1 8 -/* No 2 value defined */ -#define DRAM_VALUE_3 16 -#define DRAM_VALUE_4 16 -#define DRAM_VALUE_5 24 -#define DRAM_VALUE_6 32 -#define DRAM_VALUE_7 32 -#define DRAM_VALUE_8 48 -#define DRAM_VALUE_9 64 -#define DRAM_VALUE_A 64 -#define DRAM_VALUE_B 96 -#define DRAM_VALUE_C 128 -#define DRAM_VALUE_D 128 -#define DRAM_VALUE_E 192 -#define DRAM_VALUE_F 256 /* nice one, geezer */ -#define LM_FREQ_MASK 0x10 -#define LM_FREQ_133 0x10 -#define LM_FREQ_100 0x00 - - - - -/* These are 3d state registers, but the state is invarient, so we let - * the X server handle it: - */ - - - -/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135 - */ -#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1) -#define CC1_UPDATE_KILL_WRITE (1<<28) -#define CC1_ENABLE_KILL_WRITE (1<<27) -#define CC1_DISABLE_KILL_WRITE 0 -#define CC1_UPDATE_COLOR_IDX (1<<26) -#define CC1_UPDATE_CHROMA_LOW (1<<25) -#define CC1_UPDATE_CHROMA_HI (1<<24) -#define CC1_CHROMA_LOW_MASK ((1<<24)-1) -#define CC2_COLOR_IDX_SHIFT 24 -#define CC2_COLOR_IDX_MASK (0xff<<24) -#define CC2_CHROMA_HI_MASK ((1<<24)-1) - - -#define GFX_CMD_CONTEXT_SEL ((0<<29)|(0x5<<23)) -#define CS_UPDATE_LOAD (1<<17) -#define CS_UPDATE_USE (1<<16) -#define CS_UPDATE_LOAD (1<<17) -#define CS_LOAD_CTX0 0 -#define CS_LOAD_CTX1 (1<<8) -#define CS_USE_CTX0 0 -#define CS_USE_CTX1 (1<<0) - -/* 3D Rendering Engine */ - -#define RENDER_CLIENT 0x60000000 - -/* Primitive rendering instruction */ - -#define GFX_PRIMITIVE 0x1f000000 -#define PRIMITIVE_TRIANGLE 0 << 18 -#define PRIMITIVE_TRI_STRIP 1 << 18 -#define PRIMITIVE_TRI_REV_STRIP 2 << 18 -#define PRIMITIVE_TRI_FAN 3 << 18 -#define PRIMITIVE_POLYGON 4 << 18 -#define PRIMITIVE_LINE 5 << 18 -#define PRIMITIVE_LINE_STRIP 6 << 18 -#define PRIMITIVE_RECTANGLE 7 << 18 - -/* Vertex format instruction */ -#define GFX_VERTEX_FORMAT 0x05000000 -#define VERTEX_0_TEXCOORDS 0 << 8 -#define VERTEX_1_TEXCOORDS 1 << 8 -#define VERTEX_2_TEXCOORDS 2 << 8 -#define VERTEX_SPECULAR_FOG 1 << 7 -#define VERTEX_DIFFUSE_ALPHA 1 << 6 -#define VERTEX_Z_OFFSET 1 << 5 -#define VERTEX_POS_XYZ 1 << 1 -#define VERTEX_POS_XYZ_RHW 2 << 1 -#define VERTEX_POS_XY 3 << 1 -#define VERTEX_POS_XY_RHW 4 << 1 - -/* Drawing Rectangle Info instruction */ - -#define GFX_DRAWING_RECTANGLE_INFO 0x1d800003 -#define GFX_DRAWING_CLIP_DISABLE 1<<31 - -/* Boolean enable 1 */ -#define GFX_BOOLEAN_ENA_1 0x03000000 -#define BOOL1_ALPHA_SETUP_MASK 1<<17 -#define BOOL1_ALPHA_SETUP_BIT 1<<16 -#define BOOL1_FOG_ENABLE_MASK 1<<7 -#define BOOL1_FOG_ENABLE_BIT 1<<6 -#define BOOL1_ALPHA_TEST_MASK 1<<5 -#define BOOL1_ALPHA_TEST_BIT 1<<4 -#define BOOL1_BLEND_ENABLE_MASK 1<<3 -#define BOOL1_BLEND_ENABLE_BIT 1<<2 -#define BOOL1_Z_ENABLE_MASK 1<<1 -#define BOOL1_Z_ENABLE_BIT 1<<0 - -/* Boolean enable 2 */ -#define GFX_BOOLEAN_ENA_2 0x04000000 -#define BOOL2_MAPPING_CACHE_MASK 1<<17 -#define BOOL2_MAPPING_CACHE_BIT 1<<16 -#define BOOL2_ALPHA_DITHER_MASK 1<<15 -#define BOOL2_ALPHA_DITHER_BIT 1<<14 -#define BOOL2_FOG_DITHER_MASK 1<<13 -#define BOOL2_FOG_DITHER_BIT 1<<12 -#define BOOL2_SPECULAR_DITHER_MASK 1<<11 -#define BOOL2_SPECULAR_DITHER_BIT 1<<10 -#define BOOL2_COLOR_DITHER_MASK 1<<9 -#define BOOL2_COLOR_DITHER_BIT 1<<8 -#define BOOL2_FB_WRITE_MASK 1<<3 -#define BOOL2_FB_WRITE_BIT 1<<2 -#define BOOL2_Z_WRITE_MASK 1<<1 -#define BOOL2_Z_WRITE_BIT 1<<0 - -/* Dest buffer variables */ - -#define GFX_DEST_BUFFER_VARIABLES 0x1d850000 - -#define DEST_BUF_VAR_8BIT 0 << 8 -#define DEST_BUF_VAR_555 1 << 8 -#define DEST_BUF_VAR_565 2 << 8 - -/* map color blend stages */ - -#define GFX_MAP_COLOR_BLEND_STAGES 0 - -#define MAP_BLEND_STAGE_B 20 -#define MAP_BLEND_ACC_SEL_MASK 1<<19 -#define MAP_BLEND_ACC_SEL_BIT 1<<18 -#define MAP_BLEND_ARG1_MASK 1<<17 -#define MAP_BLEND_ARG1_B 14 -#define MAP_BLEND_REPLICATE_ARG1 1<<13 -#define MAP_BLEND_INVERT_ARG1 1<<12 - -#define MAP_BLEND_ARG2_MASK 1<<11 -#define MAP_BLEND_ARG2_B 8 -#define MAP_BLEND_REPLICATE_ARG2 1<<7 -#define MAP_BLEND_INVERT_ARG2 1<<6 - -#define MAP_BLEND_COLOR_OP_MASK 1<<5 -#define MAP_BLEND_COLOR_OP_B 0 - -#define GFX_SCISSOR_ENABLE 0x1c800000 - -#define SCISSOR_ENABLE_MASK 1<<1 -#define SCISSOR_ENABLE_BIT 1<<0 diff --git a/hw/kdrive/i810/i810_video.c b/hw/kdrive/i810/i810_video.c deleted file mode 100644 index 8f4cfcf27..000000000 --- a/hw/kdrive/i810/i810_video.c +++ /dev/null @@ -1,1136 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/*************************************************************************** - -Copyright 2000 Intel Corporation. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - - -/* - * i810_video.c: i810 KDrive Xv driver. - * Based on the XFree86 i810 Xv driver by Jonathan Bian. - * - * Authors: - * Jonathan Bian <jonathan.bian@intel.com> - * Pontus Lidman <pontus.lidman@nokia.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kxv.h" -#include "i810.h" - -#include "Xv.h" - -#include "../../xfree86/common/fourcc.h" - -typedef struct { - CARD32 size; - CARD32 offset; -} FBLinearRec, *FBLinearPtr; - -#define OFF_DELAY 250 /* milliseconds */ -#define FREE_DELAY 15000 - -#define OFF_TIMER 0x01 -#define FREE_TIMER 0x02 -#define CLIENT_VIDEO_ON 0x04 - -#define TIMER_MASK (OFF_TIMER | FREE_TIMER) - -static KdVideoAdaptorPtr i810SetupImageVideo(ScreenPtr); -static void i810StopVideo(KdScreenInfo *, pointer, Bool); -static int i810SetPortAttribute(KdScreenInfo *, Atom, int, pointer); -static int i810GetPortAttribute(KdScreenInfo *, Atom, int *, pointer); -static void i810QueryBestSize(KdScreenInfo *, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int i810PutImage( KdScreenInfo *, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int i810QueryImageAttributes(KdScreenInfo *, - int, unsigned short *, unsigned short *, int *, int *); - -static void i810BlockHandler(int, pointer, pointer, pointer); - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -static Atom xvBrightness, xvContrast, xvColorKey; - -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 -#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) - -#define OVERLAY_UPDATE(p) OUTREG(0x30000, p | 0x80000000); - -/* - * OV0CMD - Overlay Command Register - */ -#define VERTICAL_CHROMINANCE_FILTER 0x70000000 -#define VC_SCALING_OFF 0x00000000 -#define VC_LINE_REPLICATION 0x10000000 -#define VC_UP_INTERPOLATION 0x20000000 -#define VC_PIXEL_DROPPING 0x50000000 -#define VC_DOWN_INTERPOLATION 0x60000000 -#define VERTICAL_LUMINANCE_FILTER 0x0E000000 -#define VL_SCALING_OFF 0x00000000 -#define VL_LINE_REPLICATION 0x02000000 -#define VL_UP_INTERPOLATION 0x04000000 -#define VL_PIXEL_DROPPING 0x0A000000 -#define VL_DOWN_INTERPOLATION 0x0C000000 -#define HORIZONTAL_CHROMINANCE_FILTER 0x01C00000 -#define HC_SCALING_OFF 0x00000000 -#define HC_LINE_REPLICATION 0x00400000 -#define HC_UP_INTERPOLATION 0x00800000 -#define HC_PIXEL_DROPPING 0x01400000 -#define HC_DOWN_INTERPOLATION 0x01800000 -#define HORIZONTAL_LUMINANCE_FILTER 0x00380000 -#define HL_SCALING_OFF 0x00000000 -#define HL_LINE_REPLICATION 0x00080000 -#define HL_UP_INTERPOLATION 0x00100000 -#define HL_PIXEL_DROPPING 0x00280000 -#define HL_DOWN_INTERPOLATION 0x00300000 - -#define Y_ADJUST 0x00010000 -#define OV_BYTE_ORDER 0x0000C000 -#define UV_SWAP 0x00004000 -#define Y_SWAP 0x00008000 -#define Y_AND_UV_SWAP 0x0000C000 -#define SOURCE_FORMAT 0x00003C00 -#define RGB_555 0x00000800 -#define RGB_565 0x00000C00 -#define YUV_422 0x00002000 -#define YUV_411 0x00002400 -#define YUV_420 0x00003000 -#define YUV_410 0x00003800 -#define BUFFER_AND_FIELD 0x00000006 -#define BUFFER0_FIELD0 0x00000000 -#define BUFFER1_FIELD0 0x00000004 -#define OVERLAY_ENABLE 0x00000001 - -/* - * DOV0STA - Display/Overlay 0 Status Register - */ -#define DOV0STA 0x30008 - -#define MINUV_SCALE 0x1 - -#define RGB16ToColorKey(c) \ - (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3)) - -#define RGB15ToColorKey(c) \ - (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3)) - -Bool i810InitVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; - KdVideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - -/* fprintf(stderr,"i810InitVideo\n"); */ - - if (screen->fb[0].bitsPerPixel != 8) - { - newAdaptor = i810SetupImageVideo(pScreen); - } - - num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(KdVideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(KdVideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - KdXVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - return TRUE; -} - -/* client libraries expect an encoding */ -static KdVideoEncodingRec DummyEncoding[1] = -{ - { - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} - } -}; - -#define NUM_FORMATS 3 - -static KdVideoFormatRec Formats[NUM_FORMATS] = -{ - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} -}; - -#define NUM_ATTRIBUTES 3 - -static KdAttributeRec Attributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, - {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} -}; - -#define NUM_IMAGES 4 - -static KdImageRec Images[NUM_IMAGES] = -{ - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - XVIMAGE_UYVY -}; - -typedef struct { - CARD32 OBUF_0Y; - CARD32 OBUF_1Y; - CARD32 OBUF_0U; - CARD32 OBUF_0V; - CARD32 OBUF_1U; - CARD32 OBUF_1V; - CARD32 OV0STRIDE; - CARD32 YRGB_VPH; - CARD32 UV_VPH; - CARD32 HORZ_PH; - CARD32 INIT_PH; - CARD32 DWINPOS; - CARD32 DWINSZ; - CARD32 SWID; - CARD32 SWIDQW; - CARD32 SHEIGHT; - CARD32 YRGBSCALE; - CARD32 UVSCALE; - CARD32 OV0CLRC0; - CARD32 OV0CLRC1; - CARD32 DCLRKV; - CARD32 DCLRKM; - CARD32 SCLRKVH; - CARD32 SCLRKVL; - CARD32 SCLRKM; - CARD32 OV0CONF; - CARD32 OV0CMD; -} I810OverlayRegRec, *I810OverlayRegPtr; - -typedef struct { - CARD32 YBuf0offset; - CARD32 UBuf0offset; - CARD32 VBuf0offset; - - CARD32 YBuf1offset; - CARD32 UBuf1offset; - CARD32 VBuf1offset; - - unsigned char currentBuf; - - unsigned char brightness; - unsigned char contrast; - - RegionRec clip; - CARD32 colorKey; - - CARD32 videoStatus; - Time offTime; - Time freeTime; - FBLinearPtr linear; -} I810PortPrivRec, *I810PortPrivPtr; - -#define GET_PORT_PRIVATE(screen) \ - (I810PortPrivPtr)(((I810CardInfo *) (screen->card->driver))->adaptor->pPortPrivates[0].ptr) - -static void i810ResetVideo(KdScreenInfo *screen) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr; - I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); - - /* - * Default to maximum image size in YV12 - */ - - overlay->YRGB_VPH = 0; - overlay->UV_VPH = 0; - overlay->HORZ_PH = 0; - overlay->INIT_PH = 0; - overlay->DWINPOS = 0; - overlay->DWINSZ = (IMAGE_MAX_HEIGHT << 16) | IMAGE_MAX_WIDTH; - overlay->SWID = IMAGE_MAX_WIDTH | (IMAGE_MAX_WIDTH << 15); - overlay->SWIDQW = (IMAGE_MAX_WIDTH >> 3) | (IMAGE_MAX_WIDTH << 12); - overlay->SHEIGHT = IMAGE_MAX_HEIGHT | (IMAGE_MAX_HEIGHT << 15); - overlay->YRGBSCALE = 0x80004000; /* scale factor 1 */ - overlay->UVSCALE = 0x80004000; /* scale factor 1 */ - overlay->OV0CLRC0 = 0x4000; /* brightness: 0 contrast: 1.0 */ - overlay->OV0CLRC1 = 0x80; /* saturation: bypass */ - - /* - * Enable destination color keying - */ - switch(screen->fb[0].depth) { - case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); - overlay->DCLRKM = 0x80070307; - break; - case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); - overlay->DCLRKM = 0x80070707; - break; - default: overlay->DCLRKV = pPriv->colorKey; - overlay->DCLRKM = 0x80000000; - break; - } - - overlay->SCLRKVH = 0; - overlay->SCLRKVL = 0; - overlay->SCLRKM = 0; /* source color key disable */ - overlay->OV0CONF = 0; /* two 720 pixel line buffers */ - - overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST | - YUV_420; - - OVERLAY_UPDATE(i810c->OverlayPhysical); -} - - -static KdVideoAdaptorPtr -i810SetupImageVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - - KdVideoAdaptorPtr adapt; - I810PortPrivPtr pPriv; - -/* fprintf(stderr,"i810SetupImageVideo\n"); */ - - if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + - sizeof(I810PortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "I810 Video Overlay"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (I810PortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = i810StopVideo; - adapt->SetPortAttribute = i810SetPortAttribute; - adapt->GetPortAttribute = i810GetPortAttribute; - adapt->QueryBestSize = i810QueryBestSize; - adapt->PutImage = i810PutImage; - adapt->QueryImageAttributes = i810QueryImageAttributes; - - pPriv->colorKey = i810c->colorKey & ((1 << screen->fb[0].depth) - 1); - pPriv->videoStatus = 0; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->linear = NULL; - pPriv->currentBuf = 0; - - /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); - - i810c->adaptor = adapt; - - i810c->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = i810BlockHandler; - - xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - xvContrast = MAKE_ATOM("XV_CONTRAST"); - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - - i810ResetVideo(screen); - - return adapt; -} - - -/* I810ClipVideo - - - Takes the dst box in standard X BoxRec form (top and left - edges inclusive, bottom and right exclusive). The new dst - box is returned. The source boundaries are given (x1, y1 - inclusive, x2, y2 exclusive) and returned are the new source - boundaries in 16.16 fixed point. -*/ - -static void -I810ClipVideo( - BoxPtr dst, - INT32 *x1, - INT32 *x2, - INT32 *y1, - INT32 *y2, - BoxPtr extents, /* extents of the clip region */ - INT32 width, - INT32 height -){ - INT32 vscale, hscale, delta; - int diff; - - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - - *x1 <<= 16; *x2 <<= 16; - *y1 <<= 16; *y2 <<= 16; - - diff = extents->x1 - dst->x1; - if(diff > 0) { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } - diff = dst->x2 - extents->x2; - if(diff > 0) { - dst->x2 = extents->x2; - *x2 -= diff * hscale; - } - diff = extents->y1 - dst->y1; - if(diff > 0) { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } - diff = dst->y2 - extents->y2; - if(diff > 0) { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } - - if(*x1 < 0) { - diff = (- *x1 + hscale - 1)/ hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } - delta = *x2 - (width << 16); - if(delta > 0) { - diff = (delta + hscale - 1)/ hscale; - dst->x2 -= diff; - *x2 -= diff * hscale; - } - if(*y1 < 0) { - diff = (- *y1 + vscale - 1)/ vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } - delta = *y2 - (height << 16); - if(delta > 0) { - diff = (delta + vscale - 1)/ vscale; - dst->y2 -= diff; - *y2 -= diff * vscale; - } -} - -static void -i810StopVideo(KdScreenInfo *screen, pointer data, Bool exit) -{ - I810PortPrivPtr pPriv = (I810PortPrivPtr)data; - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); - - REGION_EMPTY(screen->pScreen, &pPriv->clip); - - if(exit) { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - overlay->OV0CMD &= 0xFFFFFFFE; - OVERLAY_UPDATE(i810c->OverlayPhysical); - } - if(pPriv->linear) { - xfree(pPriv->linear); - pPriv->linear = NULL; - } - pPriv->videoStatus = 0; - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } - -} - -static int -i810SetPortAttribute( - KdScreenInfo *screen, - Atom attribute, - int value, - pointer data -){ - I810PortPrivPtr pPriv = (I810PortPrivPtr)data; - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); - - if(attribute == xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - pPriv->brightness = value; - overlay->OV0CLRC0 &= 0xFFFFFF00; - overlay->OV0CLRC0 |= value; - OVERLAY_UPDATE(i810c->OverlayPhysical); - } else - if(attribute == xvContrast) { - if((value < 0) || (value > 255)) - return BadValue; - pPriv->contrast = value; - overlay->OV0CLRC0 &= 0xFFFE00FF; - overlay->OV0CLRC0 |= value << 9; - OVERLAY_UPDATE(i810c->OverlayPhysical); - } else - if(attribute == xvColorKey) { - pPriv->colorKey = value; - switch(screen->fb[0].depth) { - case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); - break; - case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); - break; - default: overlay->DCLRKV = pPriv->colorKey; - break; - } - OVERLAY_UPDATE(i810c->OverlayPhysical); - REGION_EMPTY(screen->pScreen, &pPriv->clip); - } else return BadMatch; - - return Success; -} - -static int -i810GetPortAttribute( - KdScreenInfo *screen, - Atom attribute, - int *value, - pointer data -){ - I810PortPrivPtr pPriv = (I810PortPrivPtr)data; - - if(attribute == xvBrightness) { - *value = pPriv->brightness; - } else - if(attribute == xvContrast) { - *value = pPriv->contrast; - } else - if(attribute == xvColorKey) { - *value = pPriv->colorKey; - } else return BadMatch; - - return Success; -} - -static void -i810QueryBestSize( - KdScreenInfo *screen, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; -} - - -static void -I810CopyPackedData( - KdScreenInfo *screen, - unsigned char *buf, - int srcPitch, - int dstPitch, - int top, - int left, - int h, - int w - ) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr; - unsigned char *src, *dst; - - src = buf + (top*srcPitch) + (left<<1); - - if (pPriv->currentBuf == 0) - dst = i810c->FbBase + pPriv->YBuf0offset; - else - dst = i810c->FbBase + pPriv->YBuf1offset; - - w <<= 1; - while(h--) { - memcpy(dst, src, w); - src += srcPitch; - dst += dstPitch; - } -} - -static void -i810CopyPlanarData( - KdScreenInfo *screen, - unsigned char *buf, - int srcPitch, - int dstPitch, /* of chroma */ - int srcH, - int top, - int left, - int h, - int w, - int id - ) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr; - int i; - unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3; - - /* Copy Y data */ - src1 = buf + (top*srcPitch) + left; - if (pPriv->currentBuf == 0) - dst1 = i810c->FbBase + pPriv->YBuf0offset; - else - dst1 = i810c->FbBase + pPriv->YBuf1offset; - - for (i = 0; i < h; i++) { - memcpy(dst1, src1, w); - src1 += srcPitch; - dst1 += dstPitch << 1; - } - - /* Copy V data for YV12, or U data for I420 */ - src2 = buf + (srcH*srcPitch) + ((top*srcPitch)>>2) + (left>>1); - if (pPriv->currentBuf == 0) { - if (id == FOURCC_I420) - dst2 = i810c->FbBase + pPriv->UBuf0offset; - else - dst2 = i810c->FbBase + pPriv->VBuf0offset; - } else { - if (id == FOURCC_I420) - dst2 = i810c->FbBase + pPriv->UBuf1offset; - else - dst2 = i810c->FbBase + pPriv->VBuf1offset; - } - - for (i = 0; i < h/2; i++) { - memcpy(dst2, src2, w/2); - src2 += srcPitch>>1; - dst2 += dstPitch; - } - - /* Copy U data for YV12, or V data for I420 */ - src3 = buf + (srcH*srcPitch) + ((srcH*srcPitch)>>2) + ((top*srcPitch)>>2) + (left>>1); - if (pPriv->currentBuf == 0) { - if (id == FOURCC_I420) - dst3 = i810c->FbBase + pPriv->VBuf0offset; - else - dst3 = i810c->FbBase + pPriv->UBuf0offset; - } else { - if (id == FOURCC_I420) - dst3 = i810c->FbBase + pPriv->VBuf1offset; - else - dst3 = i810c->FbBase + pPriv->UBuf1offset; - } - - for (i = 0; i < h/2; i++) { - memcpy(dst3, src3, w/2); - src3 += srcPitch>>1; - dst3 += dstPitch; - } -} - -static void -i810DisplayVideo( - KdScreenInfo *screen, - int id, - short width, short height, - int dstPitch, /* of chroma for 4:2:0 */ - int x1, int y1, int x2, int y2, - BoxPtr dstBox, - short src_w, short src_h, - short drw_w, short drw_h -){ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr; - I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); - int xscaleInt, xscaleFract, yscaleInt, yscaleFract; - int xscaleIntUV = 0, xscaleFractUV = 0, yscaleIntUV = 0, yscaleFractUV = 0; - unsigned int swidth; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - swidth = (width + 7) & ~7; - overlay->SWID = (swidth << 15) | swidth; - overlay->SWIDQW = (swidth << 12) | (swidth >> 3); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - swidth = ((width + 3) & ~3) << 1; - overlay->SWID = swidth; - overlay->SWIDQW = swidth >> 3; - break; - } - - overlay->SHEIGHT = height | (height << 15); - overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1; - overlay->DWINSZ = ((dstBox->y2 - dstBox->y1) << 16) | - (dstBox->x2 - dstBox->x1); - - /* buffer locations */ - overlay->OBUF_0Y = pPriv->YBuf0offset; - overlay->OBUF_1Y = pPriv->YBuf1offset; - overlay->OBUF_0U = pPriv->UBuf0offset; - overlay->OBUF_0V = pPriv->VBuf0offset; - overlay->OBUF_1U = pPriv->UBuf1offset; - overlay->OBUF_1V = pPriv->VBuf1offset; - - /* - * Calculate horizontal and vertical scaling factors, default to 1:1 - */ - overlay->YRGBSCALE = 0x80004000; - overlay->UVSCALE = 0x80004000; - - /* - * Initially, YCbCr and Overlay Enable and - * vertical chrominance up interpolation and horozontal chrominance - * up interpolation - */ - overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST | - OVERLAY_ENABLE; - - if ((drw_w != src_w) || (drw_h != src_h)) - { - xscaleInt = (src_w / drw_w) & 0x3; - xscaleFract = (src_w << 12) / drw_w; - yscaleInt = (src_h / drw_h) & 0x3; - yscaleFract = (src_h << 12) / drw_h; - - overlay->YRGBSCALE = (xscaleInt << 15) | - ((xscaleFract & 0xFFF) << 3) | - (yscaleInt) | - ((yscaleFract & 0xFFF) << 20); - - if (drw_w > src_w) - { - /* horizontal up-scaling */ - overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER; - overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER; - overlay->OV0CMD |= (HC_UP_INTERPOLATION | HL_UP_INTERPOLATION); - } - - if (drw_h > src_h) - { - /* vertical up-scaling */ - overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER; - overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER; - overlay->OV0CMD |= (VC_UP_INTERPOLATION | VL_UP_INTERPOLATION); - } - - if (drw_w < src_w) - { - /* horizontal down-scaling */ - overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER; - overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER; - overlay->OV0CMD |= (HC_DOWN_INTERPOLATION | HL_DOWN_INTERPOLATION); - } - - if (drw_h < src_h) - { - /* vertical down-scaling */ - overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER; - overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER; - overlay->OV0CMD |= (VC_DOWN_INTERPOLATION | VL_DOWN_INTERPOLATION); - } - - /* now calculate the UV scaling factor */ - - if (xscaleFract) - { - xscaleFractUV = xscaleFract >> MINUV_SCALE; - overlay->OV0CMD &= ~HC_DOWN_INTERPOLATION; - overlay->OV0CMD |= HC_UP_INTERPOLATION; - } - - if (xscaleInt) - { - xscaleIntUV = xscaleInt >> MINUV_SCALE; - if (xscaleIntUV) - { - overlay->OV0CMD &= ~HC_UP_INTERPOLATION; - } - } - - if (yscaleFract) - { - yscaleFractUV = yscaleFract >> MINUV_SCALE; - overlay->OV0CMD &= ~VC_DOWN_INTERPOLATION; - overlay->OV0CMD |= VC_UP_INTERPOLATION; - } - - if (yscaleInt) - { - yscaleIntUV = yscaleInt >> MINUV_SCALE; - if (yscaleIntUV) - { - overlay->OV0CMD &= ~VC_UP_INTERPOLATION; - overlay->OV0CMD |= VC_DOWN_INTERPOLATION; - } - } - - overlay->UVSCALE = yscaleIntUV | ((xscaleFractUV & 0xFFF) << 3) | - ((yscaleFractUV & 0xFFF) << 20); - } - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - overlay->OV0STRIDE = (dstPitch << 1) | (dstPitch << 16); - overlay->OV0CMD &= ~SOURCE_FORMAT; - overlay->OV0CMD |= YUV_420; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - overlay->OV0STRIDE = dstPitch; - overlay->OV0CMD &= ~SOURCE_FORMAT; - overlay->OV0CMD |= YUV_422; - overlay->OV0CMD &= ~OV_BYTE_ORDER; - if (id == FOURCC_UYVY) - overlay->OV0CMD |= Y_SWAP; - break; - } - - overlay->OV0CMD &= ~BUFFER_AND_FIELD; - if (pPriv->currentBuf == 0) - overlay->OV0CMD |= BUFFER0_FIELD0; - else - overlay->OV0CMD |= BUFFER1_FIELD0; - - OVERLAY_UPDATE(i810c->OverlayPhysical); - -} - -static FBLinearPtr -i810AllocateMemory( - KdScreenInfo *screen, - FBLinearPtr linear, - int size -){ - KdCardInfo *card=screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - FBLinearPtr new_linear; - - if(linear) { - if(linear->size >= size) - return linear; - else - ErrorF("Ran out of memory for overlay buffer, requested size = %d\n",size); - } - - new_linear = xalloc(sizeof(FBLinearRec)); - new_linear->size = i810c->XvMem.Size; - new_linear->offset = i810c->XvMem.Start; - -/* fprintf(stderr,"Overlay mem offset %lx\n",new_linear->offset); */ - - return new_linear; -} - -static int -i810PutImage( - KdScreenInfo *screen, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810PortPrivPtr pPriv = (I810PortPrivPtr)data; - INT32 x1, x2, y1, y2; - int srcPitch, dstPitch; - int top, left, npixels, nlines, size; - BoxRec dstBox; - - /* Clip */ - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - I810ClipVideo(&dstBox, &x1, &x2, &y1, &y2, - REGION_EXTENTS(pScreen, clipBoxes), width, height); - - if((x1 >= x2) || (y1 >= y2)) - return Success; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - srcPitch = (width + 3) & ~3; - dstPitch = ((width >> 1) + 7) & ~7; /* of chroma */ - size = dstPitch * height * 3; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - srcPitch = (width << 1); - dstPitch = (srcPitch + 7) & ~7; - size = dstPitch * height; - break; - } - - if(!(pPriv->linear = i810AllocateMemory(screen, pPriv->linear, - (screen->fb[0].bitsPerPixel == 16) ? size : (size >> 1)))) - return BadAlloc; - - /* fixup pointers */ - pPriv->YBuf0offset = pPriv->linear->offset; - pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height); - pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height >> 1); - - pPriv->YBuf1offset = pPriv->linear->offset + size; - pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height); - pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height >> 1); - - /* wait for the last rendered buffer to be flipped in */ - while (((INREG(DOV0STA)&0x00100000)>>20) != pPriv->currentBuf); - - /* buffer swap */ - if (pPriv->currentBuf == 0) - pPriv->currentBuf = 1; - else - pPriv->currentBuf = 0; - - /* copy data */ - top = y1 >> 16; - left = (x1 >> 16) & ~1; - npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - top &= ~1; - nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; - i810CopyPlanarData(screen, buf, srcPitch, dstPitch, height, top, left, - nlines, npixels, id); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - nlines = ((y2 + 0xffff) >> 16) - top; - I810CopyPackedData(screen, buf, srcPitch, dstPitch, top, left, nlines, - npixels); - break; - } - - /* update cliplist */ - if(!REGION_EQUAL(screen->pScreen, &pPriv->clip, clipBoxes)) { - REGION_COPY(screen->pScreen, &pPriv->clip, clipBoxes); - i810FillBoxSolid(screen, REGION_NUM_RECTS(clipBoxes), - REGION_RECTS(clipBoxes), - pPriv->colorKey, GXcopy, ~0); - /* - XAAFillSolidRects(screen, pPriv->colorKey, GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), - REGION_RECTS(clipBoxes)); - */ - } - - - i810DisplayVideo(screen, id, width, height, dstPitch, - x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); - - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -i810QueryImageAttributes( - KdScreenInfo *screen, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int size, tmp; - - if(*w > 720) *w = 720; - if(*h > 576) *h = 576; - - *w = (*w + 1) & ~1; - if(offsets) offsets[0] = 0; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - *h = (*h + 1) & ~1; - size = (*w + 3) & ~3; - if(pitches) pitches[0] = size; - size *= *h; - if(offsets) offsets[1] = size; - tmp = ((*w >> 1) + 3) & ~3; - if(pitches) pitches[1] = pitches[2] = tmp; - tmp *= (*h >> 1); - size += tmp; - if(offsets) offsets[2] = size; - size += tmp; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - size = *w << 1; - if(pitches) pitches[0] = size; - size *= *h; - break; - } - - return size; -} - -static void -i810BlockHandler ( - int i, - pointer blockData, - pointer pTimeout, - pointer pReadmask -){ - ScreenPtr pScreen = screenInfo.screens[i]; - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810PortPrivPtr pPriv = GET_PORT_PRIVATE(screen); - I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); - - pScreen->BlockHandler = i810c->BlockHandler; - - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - - pScreen->BlockHandler = i810BlockHandler; - - if(pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); - if(pPriv->videoStatus & OFF_TIMER) { - if(pPriv->offTime < currentTime.milliseconds) { - /* Turn off the overlay */ - overlay->OV0CMD &= 0xFFFFFFFE; - OVERLAY_UPDATE(i810c->OverlayPhysical); - - pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - } - } else { /* FREE_TIMER */ - if(pPriv->freeTime < currentTime.milliseconds) { - if(pPriv->linear) { - xfree(pPriv->linear); - pPriv->linear = NULL; - } - pPriv->videoStatus = 0; - } - } - } -} diff --git a/hw/kdrive/i810/i810draw.c b/hw/kdrive/i810/i810draw.c deleted file mode 100644 index d6d857c4f..000000000 --- a/hw/kdrive/i810/i810draw.c +++ /dev/null @@ -1,606 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/* Hardware accelerated drawing for KDrive i810 driver. - Author: Pontus Lidman <pontus.lidman@nokia.com> -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#ifdef XV -#include "kxv.h" -#endif -#include "i810.h" -#include "i810_reg.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" -#include "picturestr.h" - -#define NUM_STACK_RECTS 1024 - -void -i810Sync( KdScreenInfo *screen ); -int -i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis ); - -void -i810EmitInvarientState(KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - BEGIN_LP_RING( 10 ); - - OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); - OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 ); - OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); - OUT_RING( 0 ); - - - OUT_RING( GFX_OP_COLOR_CHROMA_KEY ); - OUT_RING( CC1_UPDATE_KILL_WRITE | - CC1_DISABLE_KILL_WRITE | - CC1_UPDATE_COLOR_IDX | - CC1_UPDATE_CHROMA_LOW | - CC1_UPDATE_CHROMA_HI | - 0); - OUT_RING( 0 ); - OUT_RING( 0 ); - - /* No depth buffer in KDrive yet */ - /* OUT_RING( CMD_OP_Z_BUFFER_INFO ); */ - /* OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */ - - ADVANCE_LP_RING(); -} - -static unsigned int i810PatternRop[16] = { - 0x00, /* GXclear */ - 0xA0, /* GXand */ - 0x50, /* GXandReverse */ - 0xF0, /* GXcopy */ - 0x0A, /* GXandInvert */ - 0xAA, /* GXnoop */ - 0x5A, /* GXxor */ - 0xFA, /* GXor */ - 0x05, /* GXnor */ - 0xA5, /* GXequiv */ - 0x55, /* GXinvert */ - 0xF5, /* GXorReverse */ - 0x0F, /* GXcopyInvert */ - 0xAF, /* GXorInverted */ - 0x5F, /* GXnand */ - 0xFF /* GXset */ -}; - -void -i810SetupForSolidFill(KdScreenInfo *screen, int color, int rop, - unsigned int planemask) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF( "i810SetupForFillRectSolid color: %x rop: %x mask: %x\n", - color, rop, planemask); - - /* Color blit, p166 */ - i810c->BR[13] = (BR13_SOLID_PATTERN | - (i810PatternRop[rop] << 16) | - (screen->width * i810c->cpp)); - i810c->BR[16] = color; -} - - -void -i810SubsequentSolidFillRect(KdScreenInfo *screen, int x, int y, int w, int h) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF( "i810SubsequentFillRectSolid %d,%d %dx%d\n", - x,y,w,h); - - { - BEGIN_LP_RING(6); - - OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 ); - OUT_RING( i810c->BR[13] ); - OUT_RING( (h << 16) | (w * i810c->cpp)); - OUT_RING( i810c->bufferOffset + - (y * screen->width + x) * i810c->cpp); - - OUT_RING( i810c->BR[16]); - OUT_RING( 0 ); /* pad to quadword */ - - ADVANCE_LP_RING(); - } -} - - -BOOL -i810FillOk (GCPtr pGC) -{ - FbBits depthMask; - - switch (pGC->fillStyle) { - case FillSolid: - return TRUE; - /* More cases later... */ - } - return FALSE; -} - -void -i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask) -{ - i810SetupForSolidFill(screen, pixel, alu, planemask); - while (nBox--) - { - i810SubsequentSolidFillRect(screen, pBox->x1, pBox->y1, - pBox->x2-pBox->x1, pBox->y2-pBox->y1); - pBox++; - } - KdMarkSync(screen->pScreen); -} - - -void -i810PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - - - 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; - KdScreenPriv(pDrawable->pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - - if (!i810FillOk (pGC)) - { - KdCheckPolyFillRect (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: - i810FillBoxSolid(screen, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->fgPixel, pGC->alu, pGC->planemask); - break; - /* More cases later... */ - } - } - if (pboxClippedBase != stackRects) - xfree(pboxClippedBase); -} - -void -i810RefreshRing(KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR; - i810c->LpRing.tail = INREG(LP_RING + RING_TAIL); - i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8); - if (i810c->LpRing.space < 0) - i810c->LpRing.space += i810c->LpRing.mem.Size; - - i810c->NeedToSync = TRUE; -} - -int -i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis ) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - I810RingBuffer *ring = &(i810c->LpRing); - int iters = 0; - int start = 0; - int now = 0; - int last_head = 0; - int first = 0; - - /* If your system hasn't moved the head pointer in 2 seconds, I'm going to - * call it crashed. - */ - if (timeout_millis == 0) - timeout_millis = 2000; - - if (I810_DEBUG) { - fprintf(stderr, "i810WaitLpRing %d\n", n); - first = GetTimeInMillis(); - } - - while (ring->space < n) - { - int i; - - ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR; - ring->space = ring->head - (ring->tail+8); - - if (ring->space < 0) - ring->space += ring->mem.Size; - - iters++; - now = GetTimeInMillis(); - if ( start == 0 || now < start || ring->head != last_head) { - if (I810_DEBUG) - if (now > start) - fprintf(stderr, "space: %d wanted %d\n", ring->space, n ); - start = now; - last_head = ring->head; - } else if ( now - start > timeout_millis ) { - - i810PrintErrorState( screen->card ); - fprintf(stderr, "space: %d wanted %d\n", ring->space, n ); - FatalError("lockup\n"); - } - - for (i = 0 ; i < 2000 ; i++) - ; - } - - if (I810_DEBUG) - { - now = GetTimeInMillis(); - if (now - first) { - fprintf(stderr,"Elapsed %d ms\n", now - first); - fprintf(stderr, "space: %d wanted %d\n", ring->space, n ); - } - } - - return iters; -} - -void -i810Sync( KdScreenInfo *screen ) -{ - KdCardInfo *card = screen->card; - I810CardInfo *i810c = card->driver; - - if (I810_DEBUG) - fprintf(stderr, "i810Sync\n"); - - /* Send a flush instruction and then wait till the ring is empty. - * This is stronger than waiting for the blitter to finish as it also - * flushes the internal graphics caches. - */ - { - BEGIN_LP_RING(2); - OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); - OUT_RING( 0 ); /* pad to quadword */ - ADVANCE_LP_RING(); - } - - i810WaitLpRing(screen, i810c->LpRing.mem.Size - 8, 0 ); - - i810c->LpRing.space = i810c->LpRing.mem.Size - 8; - i810c->nextColorExpandBuf = 0; -} - -static const GCOps i810Ops = { - KdCheckFillSpans, - KdCheckSetSpans, - KdCheckPutImage, - KdCheckCopyArea, - KdCheckCopyPlane, - KdCheckPolyPoint, - KdCheckPolylines, - KdCheckPolySegment, - miPolyRectangle, - KdCheckPolyArc, - miFillPolygon, - i810PolyFillRect, - miPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - KdCheckImageGlyphBlt, - KdCheckPolyGlyphBlt, - KdCheckPushPixels, -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -void -i810ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - - fbValidateGC (pGC, changes, pDrawable); - - if (pDrawable->type == DRAWABLE_WINDOW) - pGC->ops = (GCOps *) &i810Ops; - else - pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; -} - -GCFuncs i810GCFuncs = { - i810ValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -int -i810CreateGC (GCPtr pGC) -{ - if (!fbCreateGC (pGC)) - return FALSE; - - if (pGC->depth != 1) - pGC->funcs = &i810GCFuncs; - - return TRUE; -} - -static void -i810SetRingRegs( KdScreenInfo *screen ) { - unsigned int itemp; - - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - - OUTREG(LP_RING + RING_TAIL, 0 ); - OUTREG(LP_RING + RING_HEAD, 0 ); - - itemp = INREG(LP_RING + RING_START); - itemp &= ~(START_ADDR); - itemp |= i810c->LpRing.mem.Start; - OUTREG(LP_RING + RING_START, itemp ); - - itemp = INREG(LP_RING + RING_LEN); - itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK); - itemp |= ((i810c->LpRing.mem.Size-4096) | RING_NO_REPORT | RING_VALID); - OUTREG(LP_RING + RING_LEN, itemp ); -} - -Bool -i810InitAccel(ScreenPtr pScreen) -{ - -/* fprintf(stderr,"i810InitAccel\n"); */ - - /* - * Hook up asynchronous drawing - */ - KdScreenInitAsync (pScreen); - /* - * Replace various fb screen functions - */ - pScreen->CreateGC = i810CreateGC; - - return TRUE; -} - -void -i810EnableAccel(ScreenPtr pScreen) -{ - - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = screen->card; - I810CardInfo *i810c = (I810CardInfo *) card->driver; - -/* fprintf(stderr,"i810EnableAccel\n"); */ - - if (i810c->LpRing.mem.Size == 0) { - ErrorF("No memory for LpRing!! Acceleration not functional!!\n"); - } - - i810SetRingRegs( screen ); - - KdMarkSync (pScreen); -} - - -void -i810SyncAccel(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - - i810Sync(screen); -} - -void -i810DisableAccel(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - -/* fprintf(stderr,"i810DisableAccel\n"); */ - i810RefreshRing( screen ); - i810Sync( screen ); -} - -void -i810FiniAccel(ScreenPtr pScreen) -{ -/* fprintf(stderr,"i810FiniAccel\n"); */ - -} diff --git a/hw/kdrive/i810/i810draw.h b/hw/kdrive/i810/i810draw.h deleted file mode 100644 index 7c8c04489..000000000 --- a/hw/kdrive/i810/i810draw.h +++ /dev/null @@ -1,46 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/* Hardware accelerated drawing for KDrive i810 driver, header file. - Author: Pontus Lidman <pontus.lidman@nokia.com> -*/ - - -#ifndef _I810DRAW_H_ -#define _I810DRAW_H_ - -void i810RefreshRing(KdScreenInfo *screen); -int i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis ); -void i810Sync( KdScreenInfo *screen ); - -#endif /* _I810DRAW_H_ */ diff --git a/hw/kdrive/i810/i810stub.c b/hw/kdrive/i810/i810stub.c deleted file mode 100644 index fc028288b..000000000 --- a/hw/kdrive/i810/i810stub.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $RCSId: $ */ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/* Stub functions for the i810 KDrive driver - Author: Pontus Lidman <pontus.lidman@nokia.com> -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kxv.h" -#include "i810.h" - -static const int i810Cards[]={ PCI_CHIP_I810, PCI_CHIP_I810_DC100, PCI_CHIP_I810_E }; - -#define numI810Cards (sizeof(i810Cards) / sizeof(i810Cards[0])) - -void -InitCard (char *name) -{ - KdCardAttr attr; - int i; - - Bool LinuxFindPci(CARD16, CARD16, CARD32, KdCardAttr *); - - for (i = 0; i < numI810Cards; i++) - if (LinuxFindPci (0x8086, i810Cards[i], 0, &attr)) - KdCardInfoAdd (&i810Funcs, &attr, (void *) i810Cards[i]); -} - - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - int KdProcessArgument(int, char **, int); - - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/igs/Imakefile b/hw/kdrive/igs/Imakefile deleted file mode 100644 index 2214ee5ba..000000000 --- a/hw/kdrive/igs/Imakefile +++ /dev/null @@ -1,13 +0,0 @@ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/igs/Imakefile,v 1.2 2000/05/24 23:52:47 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = igs.c igscmap.c igscurs.c igsdraw.c igsreg.c igsstub.c - -OBJS = igs.o igscmap.o igscurs.o igsdraw.o igsreg.o igsstub.o - -INCLUDES = -I. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(igs,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/igs/igs.c b/hw/kdrive/igs/igs.c deleted file mode 100644 index 1b0907d4f..000000000 --- a/hw/kdrive/igs/igs.c +++ /dev/null @@ -1,669 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/igs/igs.c,v 1.2 2000/05/24 23:52:47 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igs.h" - -Bool -igsCardInit (KdCardInfo *card) -{ - int k; - char *pixels; - IgsCardInfo *igsc; - - igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo)); - if (!igsc) - return FALSE; - - memset (igsc, '\0', sizeof (IgsCardInfo)); - - igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] + - IGS_FB, - IGS_MEM); - - igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] + - IGS_VGA, - 64 * 1024); - - igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] + - IGS_COP_OFFSET, - sizeof (Cop5xxx)); - - igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] + - IGS_COP_DATA, - IGS_COP_DATA_LEN); - - igsRegInit (&igsc->igsvga, igsc->vga); - - card->driver = igsc; - - return TRUE; -} - -Bool -igsModeSupported (KdScreenInfo *screen, - const KdMonitorTiming *t) -{ - /* make sure the clock isn't too fast */ - if (t->clock > IGS_MAX_CLOCK) - return FALSE; - /* width must be a multiple of 16 */ - if (t->horizontal & 0xf) - return FALSE; - return TRUE; -} - -Bool -igsModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - int screen_size; - int pixel_width; - int byte_width; - int fb = 0; - - screen_size = 0; - if (screen->fb[fb].depth >= 24) - { - screen->fb[fb].depth = 24; - if (screen->fb[fb].bitsPerPixel != 24) - screen->fb[fb].bitsPerPixel = 32; - } - else if (screen->fb[fb].depth >= 16) - { - screen->fb[fb].depth = 16; - screen->fb[fb].bitsPerPixel = 16; - } - else if (screen->fb[fb].depth >= 15) - { - screen->fb[fb].depth = 15; - screen->fb[fb].bitsPerPixel = 16; - } - else if (screen->fb[fb].depth >= 12) - { - screen->fb[fb].depth = 12; - screen->fb[fb].bitsPerPixel = 16; - } - else - { - screen->fb[fb].depth = 8; - screen->fb[fb].bitsPerPixel = 8; - } - - byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3); - pixel_width = screen->width; - screen->fb[fb].pixelStride = pixel_width; - screen->fb[fb].byteStride = byte_width; - screen_size += byte_width * screen->height; - - return TRUE; -} - -Bool -igsScreenInit (KdScreenInfo *screen) -{ - IgsCardInfo *igsc = screen->card->driver; - int fb = 0; - IgsScreenInfo *igss; - int screen_size, memory; - int pattern_size; - int tile_size; - int stipple_size; - int poffset, boffset; - const KdMonitorTiming *t; - - if (!screen->width || !screen->height) - { - screen->width = 800; - screen->height = 600; - screen->rate = 72; - } - if (!screen->fb[0].depth) - screen->fb[0].depth = 8; - - t = KdFindMode (screen, igsModeSupported); - - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - - if (!KdTuneMode (screen, igsModeUsable, igsModeSupported)) - { - return FALSE; - } - - igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo)); - if (!igss) - return FALSE; - - memset (igss, '\0', sizeof (IgsScreenInfo)); - - screen_size = screen->fb[fb].byteStride * screen->height; - memory = IGS_MEM; - memory -= screen_size; - if (memory >= 1024) - { - igss->cursor_offset = memory - 1024; -#if BITMAP_BIT_ORDER == MSBFirst - igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] + - igss->cursor_offset, - 1024); -#else - igss->cursor_base = igsc->frameBuffer + igss->cursor_offset; -#endif - memory -= 1024; - } - else - igss->cursor_base = 0; - - tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN; - stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN; - pattern_size = tile_size + stipple_size; - if (memory >= pattern_size) - { - boffset = screen_size; - poffset = boffset * 8 / screen->fb[fb].bitsPerPixel; - igss->tile.offset = poffset; - igss->tile.base = igsc->frameBuffer + boffset; - - boffset = screen_size + tile_size; - poffset = boffset * 8 / screen->fb[fb].bitsPerPixel; - igss->stipple.offset = poffset; - igss->stipple.base = igsc->frameBuffer + boffset; - - memory -= pattern_size; - } - else - { - igss->tile.base = 0; - igss->stipple.base = 0; - } - - switch (screen->fb[fb].depth) { - case 8: - screen->fb[fb].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[fb].blueMask = 0x00; - screen->fb[fb].greenMask = 0x00; - screen->fb[fb].redMask = 0x00; - break; - case 15: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x001f; - screen->fb[fb].greenMask = 0x03e0; - screen->fb[fb].redMask = 0x7c00; - break; - case 16: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x001f; - screen->fb[fb].greenMask = 0x07e0; - screen->fb[fb].redMask = 0xf800; - break; - case 24: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x0000ff; - screen->fb[fb].greenMask = 0x00ff00; - screen->fb[fb].redMask = 0xff0000; - break; - } - - screen->fb[fb].pixelStride = screen->width; - screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3); - screen->fb[fb].frameBuffer = igsc->frameBuffer; - if (!igsc->cop) - screen->dumb = TRUE; - screen->driver = igss; - return TRUE; -} - -Bool -igsInitScreen(ScreenPtr pScreen) -{ - return TRUE; -} - -void -igsPreserve (KdCardInfo *card) -{ - IgsCardInfo *igsc = card->driver; - IgsVga *igsvga = &igsc->igsvga; - - igsSave (igsvga); -} - -void -igsSetBlank (IgsVga *igsvga, Bool blank) -{ - igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0); -} - -void -igsSetSync (IgsCardInfo *igsc, int hsync, int vsync) -{ - IgsVga *igsvga = &igsc->igsvga; - - igsSet (igsvga, igs_mexhsyn, hsync); - igsSet (igsvga, igs_mexvsyn, vsync); - VgaFlush (&igsvga->card); -} - - -/* - * Clock synthesis: - * - * scale = p ? (2 * p) : 1 - * f_out = f_ref * ((M + 1) / ((N + 1) * scale)) - * - * Constraints: - * - * 1. 115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz - * 2. N >= 1 - * - * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank)) - * Horizontal refresh rate = clock / (hsize + hblank) - */ - -/* all in kHz */ - -void -igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco) -{ - int M, N, P, bestM, bestN; - int f_vco, f_out; - int err, abserr, besterr; - - /* - * Compute correct P value to keep VCO in range - */ - for (P = 0; P <= maxP; P++) - { - f_vco = target * IGS_SCALE(P); - if (f_vco >= minVco) - break; - } - - /* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */ - besterr = target; - for (N = 1; N <= maxN; N++) - { - M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1; - if (0 <= M && M <= maxM) - { - f_out = IGS_CLOCK(M,N,P); - err = target - f_out; - if (err < 0) - err = -err; - if (err < besterr) - { - besterr = err; - bestM = M; - bestN = N; - } - } - } - *Mp = bestM; - *Np = bestN; - *Pp = P; -} - -Bool -igsEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - KdScreenInfo *screen = pScreenPriv->screen; - IgsCardInfo *igsc = card->driver; - IgsVga *igsvga = &igsc->igsvga; - const KdMonitorTiming *t; - int hactive, hblank, hfp, hbp; - int vactive, vblank, vfp, vbp; - int hsize; - int fb = 0; - int m, n, r; - 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 v_total; - int v_retrace_start; - int v_retrace_end; - int v_display_end; - int v_blank_start; - int v_blank_end; - int offset; - int num_fetch; - int m_m, m_n, m_r; - - - igsSetBlank (igsvga, TRUE); - - t = KdFindMode (screen, igsModeSupported); - - igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO); - - /* - * Set the chip so that 0x400000 is a big-endian frame buffer - * with the correct byte swapping enabled - */ - igsSet (igsvga, igs_biga22force, 0); - igsSet (igsvga, igs_biga22en, 1); - igsSet (igsvga, igs_biga24en, 1); - /* - * Enable 8-bit DACs - */ - igsSet (igsvga, igs_rampwdn, 0); - igsSet (igsvga, igs_dac6_8, 1); - igsSet (igsvga, igs_dacpwdn, 0); - /* - * Set overscan to black - */ - igsSet (igsvga, igs_overscan_red, 0x00); - igsSet (igsvga, igs_overscan_green, 0x00); - igsSet (igsvga, igs_overscan_blue, 0x00); - /* - * Enable PCI retries - */ - igsSet (igsvga, igs_iow_retry, 1); - igsSet (igsvga, igs_mw_retry, 1); - igsSet (igsvga, igs_mr_retry, 1); - igsSet (igsvga, igs_pci_burst_write, 1); - igsSet (igsvga, igs_pci_burst_read, 1); - /* - * Set FIFO - */ - igsSet (igsvga, igs_memgopg, 1); - igsSet (igsvga, igs_memr2wpg, 0); - igsSet (igsvga, igs_crtff16, 0); - igsSet (igsvga, igs_fifomust, 0xff); - igsSet (igsvga, igs_fifogen, 0xff); - /* - * Enable CRT reg access - */ - igsSetImm (igsvga, igs_ena_vr_access, 1); - igsSetImm (igsvga, igs_crt_protect, 0); - - hfp = t->hfp; - hbp = t->hbp; - hblank = t->hblank; - hactive = t->horizontal; - offset = screen->fb[0].byteStride; - - vfp = t->vfp; - vbp = t->vbp; - vblank = t->vblank; - vactive = t->vertical; - - /* - * Compute character lengths for horizontal timing values - */ - hactive = screen->width / 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - offset /= 8; - - switch (screen->fb[fb].bitsPerPixel) { - case 8: - igsSet (igsvga, igs_overscan_red, pScreen->blackPixel); - igsSet (igsvga, igs_overscan_green, pScreen->blackPixel); - igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel); - igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8); - igsSet (igsvga, igs_mode_sel, IGS_MODE_8); - igsSet (igsvga, igs_ramdacbypass, 0); - break; - case 16: - igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16); - igsSet (igsvga, igs_ramdacbypass, 1); - switch (screen->fb[fb].depth) { - case 12: - igsSet (igsvga, igs_mode_sel, IGS_MODE_4444); - break; - case 15: - igsSet (igsvga, igs_mode_sel, IGS_MODE_5551); - break; - case 16: - igsSet (igsvga, igs_mode_sel, IGS_MODE_565); - break; - } - break; - case 24: - igsSet (igsvga, igs_ramdacbypass, 1); - igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8); - igsSet (igsvga, igs_mode_sel, IGS_MODE_888); - break; - case 32: - igsSet (igsvga, igs_ramdacbypass, 1); - igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32); - igsSet (igsvga, igs_mode_sel, IGS_MODE_8888); - break; - } - - /* - * 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_end = hactive + hblank - 1 - 1; - - num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1; - - v_total = vactive + vblank - 2; - v_display_end = vactive - 1; - - v_blank_start = vactive - 1; - v_blank_end = v_blank_start + vblank - 1; - - v_retrace_start = vactive + vfp; - v_retrace_end = vactive + vblank - vbp; - -#if 0 -#define chk(a,b,c) fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c); - - chk("h_total", igs_h_total, h_total); - chk("h_display_end", igs_h_de_end, h_display_end); - chk("h_sync_start", igs_h_rstart, h_sync_start); - chk("h_sync_end", igs_h_rend, h_sync_end&0x1f); - chk("h_blank_start", igs_h_bstart, h_blank_start); - chk("h_blank_end", igs_h_bend, h_blank_end&0x3f); - chk("offset", igs_offset, offset); - chk("num_fetch", igs_num_fetch, num_fetch); - - chk("v_total", igs_v_total, v_total); - chk("v_display_end", igs_v_de_end, v_display_end); - chk("v_blank_start", igs_v_bstart, v_blank_start); - chk("v_blank_end", igs_v_bend, v_blank_end&0xf); - chk("v_retrace_start", igs_v_rstart, v_retrace_start); - chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf); - chk("vclk_m", igs_vclk_m, m); - chk("vclk_n", igs_vclk_n, n); - chk("vclk_p", igs_vclk_p, r); - - fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk", - IGS_CLOCK(igsGet(igsvga,igs_vclk_m), - igsGet(igsvga,igs_vclk_n), - igsGet(igsvga,igs_vclk_p)), - IGS_CLOCK(m,n,r)); -#endif - igsSet (igsvga, igs_h_total, h_total); - igsSet (igsvga, igs_h_de_end, h_display_end); - igsSet (igsvga, igs_h_rstart, h_sync_start); - igsSet (igsvga, igs_h_rend, h_sync_end); - igsSet (igsvga, igs_h_bstart, h_blank_start); - igsSet (igsvga, igs_h_bend, h_blank_end); - igsSet (igsvga, igs_offset, offset); - igsSet (igsvga, igs_num_fetch, num_fetch); - - igsSet (igsvga, igs_v_total, v_total); - igsSet (igsvga, igs_v_de_end, v_display_end); - igsSet (igsvga, igs_v_bstart, v_blank_start); - igsSet (igsvga, igs_v_bend, v_blank_end&0xf); - igsSet (igsvga, igs_v_rstart, v_retrace_start); - igsSet (igsvga, igs_v_rend, v_retrace_end&0xf); - - igsSet (igsvga, igs_vclk_m, m); - igsSet (igsvga, igs_vclk_n, n); - igsSet (igsvga, igs_vclk_p, r); - igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000); - VgaFlush (&igsvga->card); - - igsSetImm (igsvga, igs_frqlat, 0); - igsSetImm (igsvga, igs_frqlat, 1); - igsSetImm (igsvga, igs_frqlat, 0); - - igsSetBlank (igsvga, FALSE); -#if 0 -#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b)) - -#include "reg.dbg" - - { - VGA16 reg; - char buf[128]; - - for (reg = 0; reg < IGS_NREG; reg++) - fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg), - VgaFetch (&igsvga->card, reg)); - } -#endif - return TRUE; -} - -Bool -igsDPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - IgsCardInfo *igsc = pScreenPriv->card->driver; - IgsVga *igsvga = &igsc->igsvga; - - switch (mode) { - case KD_DPMS_NORMAL: - igsSetSync (igsc, 0, 0); - igsSetBlank (igsvga, FALSE); - break; - case KD_DPMS_STANDBY: - igsSetBlank (igsvga, TRUE); - igsSetSync (igsc, 1, 0); - break; - case KD_DPMS_SUSPEND: - igsSetBlank (igsvga, TRUE); - igsSetSync (igsc, 0, 1); - break; - case KD_DPMS_POWERDOWN: - igsSetBlank (igsvga, TRUE); - igsSetSync (igsc, 1, 1); - break; - } - return TRUE; -} - -void -igsDisable (ScreenPtr pScreen) -{ -} - -void -igsRestore (KdCardInfo *card) -{ - IgsCardInfo *igsc = card->driver; - IgsVga *igsvga = &igsc->igsvga; - - igsReset (igsvga); -} - -void -igsScreenFini (KdScreenInfo *screen) -{ - IgsScreenInfo *igss = (IgsScreenInfo *) screen->driver; - -#if BITMAP_BIT_ORDER == MSBFirst - if (igss->cursor_base) - KdUnmapDevice ((void *) igss->cursor_base, 1024); -#endif - xfree (igss); - screen->driver = 0; -} - -void -igsCardFini (KdCardInfo *card) -{ - IgsCardInfo *igsc = card->driver; - - if (igsc->copData) - KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN); - if (igsc->cop) - KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx)); - if (igsc->vga) - KdUnmapDevice ((void *) igsc->vga, 64 * 1024); - if (igsc->frameBuffer) - KdUnmapDevice (igsc->frameBuffer, IGS_MEM); - xfree (igsc); - card->driver = 0; -} - -KdCardFuncs igsFuncs = { - igsCardInit, /* cardinit */ - igsScreenInit, /* scrinit */ - igsInitScreen, - igsPreserve, /* preserve */ - igsEnable, /* enable */ - igsDPMS, /* dpms */ - igsDisable, /* disable */ - igsRestore, /* restore */ - igsScreenFini, /* scrfini */ - igsCardFini, /* cardfini */ - - igsCursorInit, /* initCursor */ - igsCursorEnable, /* enableCursor */ - igsCursorDisable, /* disableCursor */ - igsCursorFini, /* finiCursor */ - 0, /* recolorCursor */ - - igsDrawInit, /* initAccel */ - igsDrawEnable, /* enableAccel */ - igsDrawSync, /* drawSync */ - igsDrawDisable, /* disableAccel */ - igsDrawFini, /* finiAccel */ - - igsGetColors, /* getColors */ - igsPutColors, /* putColors */ -}; diff --git a/hw/kdrive/igs/igs.h b/hw/kdrive/igs/igs.h deleted file mode 100644 index 264425022..000000000 --- a/hw/kdrive/igs/igs.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/igs/igs.h,v 1.1 2000/05/06 22:17:43 keithp Exp $ - * - * 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. - */ - -#ifndef _IGS_H_ -#define _IGS_H_ - -#include "kdrive.h" -#include "igsreg.h" - -extern KdCardFuncs igsFuncs; - -/* - * FB 0x00000000 - * VGA 0x00800000 - * Blt window 0x008a0000 - * Coprocessor 0x008bf000 - */ - -#if BITMAP_BIT_ORDER == MSBFirst -#define IGS_FB 0x00400000 -#else -#define IGS_FB 0x00000000 -#endif -#define IGS_VGA 0x00800000 -#define IGS_COP_DATA 0x008a0000 -#define IGS_COP_DATA_LEN 0x00010000 -#define IGS_COP_OFFSET 0x008bf000 -/* give audio 1/2 meg at end */ -#if 1 -#define IGS_MEM ((4096-512)*1024) -#else -#define IGS_MEM ((4096)*1024) -#endif - -#define IGS_CLOCK_REF 24576 /* KHz */ - -#define IGS_SCALE(p) ((p) ? (2 * (p)) : 1) - -#define IGS_CLOCK(m,n,p) ((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p))) - -#define IGS_MAX_CLOCK 260000 - -#define IGS_MIN_VCO 115000 - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _Cop5xxx { - VOL8 pad000[0x10]; /* 0x000 */ - - VOL32 control; /* 0x010 */ -#define IGS_CONTROL_HBLTW_RDYZ 0x0100 -#define IGS_CONTROL_MALLWBEPTZ 0x0200 -#define IGS_CONTROL_CMDFF 0x0400 -#define IGS_CONTROL_SOP 0x0800 -#define IGS_CONTROL_OPS 0x1000 -#define IGS_CONTROL_TER 0x2000 -#define IGS_CONTROL_HBACKZ 0x4000 -#define IGS_CONTROL_BUSY 0x8000 - - VOL8 pad014[0x04]; /* 0x014 */ - - VOL32 src1_stride; /* 0x018 */ - - VOL32 format; /* 0x01c */ - -#define IGS_FORMAT_8BPP 0 -#define IGS_FORMAT_16BPP 1 -#define IGS_FORMAT_24BPP 2 -#define IGS_FORMAT_32BPP 3 - - VOL32 bres_error; /* 0x020 */ - VOL32 bres_k1; /* 0x024 */ - VOL32 bres_k2; /* 0x028 */ - VOL8 pad02c[0x1c]; /* 0x02c */ - - VOL32 mix; /* 0x048 */ -#define IGS_MIX_FG 0x00ff -#define IGS_MIX_BG 0xff00 -#define IGS_MAKE_MIX(fg,bg) ((fg) | ((bg) << 8)) - -#define IGS_MIX_ZERO 0x0 -#define IGS_MIX_SRC_AND_DST 0x1 -#define IGS_MIX_SRC_AND_NOT_DST 0x2 -#define IGS_MIX_SRC 0x3 -#define IGS_MIX_NOT_SRC_AND_DST 0x4 -#define IGS_MIX_DST 0x5 -#define IGS_MIX_SRC_XOR_DST 0x6 -#define IGS_MIX_SRC_OR_DST 0x7 -#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8 -#define IGS_MIX_SRC_XOR_NOT_DST 0x9 -#define IGS_MIX_NOT_DST 0xa -#define IGS_MIX_SRC_OR_NOT_DST 0xb -#define IGS_MIX_NOT_SRC 0xc -#define IGS_MIX_NOT_SRC_OR_DST 0xd -#define IGS_MIX_NOT_SRC_OR_NOT_DST 0xe -#define IGS_MIX_ONE 0xf - - VOL32 colorComp; /* 0x04c */ - VOL32 planemask; /* 0x050 */ - - VOL8 pad054[0x4]; /* 0x054 */ - - VOL32 fg; /* 0x058 */ - VOL32 bg; /* 0x05c */ - VOL32 dim; /* 0x060 */ -#define IGS_MAKE_DIM(w,h) ((w) | ((h) << 16)) - VOL8 pad5[0x0c]; /* 0x064 */ - - VOL32 src1_base_address; /* 0x070 */ - VOL8 pad074[0x04]; /* 0x074 */ - - VOL32 rotate; /* 0x078 */ -#define IGS_MAKE_ROTATE(x,y) ((x) | ((y) << 16)) - VOL32 operation; /* 0x07c */ - -/* OCT[2:0] */ -#define IGS_DRAW_X_MAJOR 0x00000000 -#define IGS_DRAW_Y_MAJOR 0x00000001 -#define IGS_DRAW_T_B 0x00000000 -#define IGS_DRAW_B_T 0x00000002 -#define IGS_DRAW_L_R 0x00000000 -#define IGS_DRAW_R_L 0x00000004 - -/* Draw_Mode[1:0] */ -#define IGS_DRAW_ALL 0x00000000 -#define IGS_DRAW_NOT_FIRST 0x00000010 -#define IGS_DRAW_NOT_LAST 0x00000020 -#define IGS_DRAW_NOT_FIRST_LAST 0x00000030 - -/* TRPS[1:0] */ -#define IGS_TRANS_SRC1 0x00000000 -#define IGS_TRANS_SRC2 0x00000100 -#define IGS_TRANS_DST 0x00000200 -/* TRPS2 Transparent Invert */ -#define IGS_TRANS_INVERT 0x00000400 -/* TRPS3, Transparent Enable */ -#define IGS_TRANS_ENABLE 0x00000800 - -/* PPS[3:0], Pattern Pixel Select */ -#define IGS_PIXEL_TEXT_OPAQUE 0x00001000 -#define IGS_PIXEL_STIP_OPAQUE 0x00002000 -#define IGS_PIXEL_LINE_OPAQUE 0x00003000 -#define IGS_PIXEL_TEXT_TRANS 0x00005000 -#define IGS_PIXEL_STIP_TRANS 0x00006000 -#define IGS_PIXEL_LINE_TRANS 0x00007000 -#define IGS_PIXEL_FG 0x00008000 -#define IGS_PIXEL_TILE 0x00009000 -#define IGS_PIXEL_TILE_OPAQUE 0x0000d000 - -/* HostBltEnable[1:0] */ -#define IGS_HBLT_DISABLE 0x00000000 -#define IGS_HBLT_READ 0x00010000 -#define IGS_HBLT_WRITE_1 0x00020000 -#define IGS_HBLT_WRITE_2 0x00030000 - -/* Src2MapSelect[2:0], Src2 map select mode */ -#define IGS_SRC2_NORMAL 0x00000000 -#define IGS_SRC2_MONO_OPAQUE 0x00100000 -#define IGS_SRC2_FG 0x00200000 -#define IGS_SRC2_MONO_TRANS 0x00500000 - -/* StepFunction[3:0], Step function select */ -#define IGS_STEP_DRAW_AND_STEP 0x04000000 -#define IGS_STEP_LINE_DRAW 0x05000000 -#define IGS_STEP_PXBLT 0x08000000 -#define IGS_STEP_INVERT_PXBLT 0x09000000 -#define IGS_STEP_TERNARY_PXBLT 0x0b000000 - -/* FGS */ -#define IGS_FGS_FG 0x00000000 -#define IGS_FGS_SRC 0x20000000 - -/* BGS */ -#define IGS_BGS_BG 0x00000000 -#define IGS_BGS_SRC 0x80000000 - VOL8 pad080[0x90]; /* 0x080 */ - - VOL32 debug_control; /* 0x110 */ - VOL8 pad114[0x04]; /* 0x114 */ - - VOL32 src2_stride; /* 0x118 */ - VOL8 pad11c[0x14]; /* 0x11c */ - - VOL32 extension; /* 0x130 */ - -#define IGS_BURST_ENABLE 0x01 -#define IGS_STYLE_LINE 0x02 -#define IGS_ADDITIONAL_WAIT 0x04 -#define IGS_BLOCK_COP_REG 0x08 -#define IGS_TURBO_MONO 0x10 -#define IGS_SELECT_SAMPLE 0x40 -#define IGS_MDSBL_RD_B_WR 0x80 -#define IGS_WRMRSTZ 0x100 -#define IGS_TEST_MTST 0x200 - - VOL32 style_line; /* 0x134 */ -#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \ - ((roll_over) | \ - ((style_line_inc) << 8) | \ - ((style_line_patern) << 16) | \ - ((style_line_accumullator) << 24)) - VOL32 style_line_pattern_index; /* 0x138 */ - - VOL32 mono_burst_total; /* 0x13c */ - VOL8 pad140[0x10]; /* 0x140 */ - - VOL32 pat_x_rotate; /* 0x150 */ - VOL8 pad154[0x1c]; /* 0x154 */ - - VOL32 src1_start; /* 0x170 */ - VOL32 src2_start; /* 0x174 */ - VOL32 dst_start; /* 0x178 */ - VOL8 pad17c[0x9c]; /* 0x17c */ - - VOL32 dst_stride; /* 0x218 */ -} Cop5xxx; - -typedef struct _igsCardInfo { - Cop5xxx *cop; - VOL8 *vga; - VOL32 *copData; - CARD8 *frameBuffer; - IgsVga igsvga; -} IgsCardInfo; - -#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver)) -#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd) - -typedef struct _igsCursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; - Pixel source, mask; -} IgsCursor; - -#define IGS_CURSOR_WIDTH 64 -#define IGS_CURSOR_HEIGHT 64 - -typedef struct _igsPattern { - INT32 xrot, yrot; - CARD32 serial_number; - CARD8 *base; - CARD32 offset; -} IgsPattern; - -#define IGS_NUM_PATTERN 8 -#define IGS_PATTERN_WIDTH 8 -#define IGS_PATTERN_HEIGHT 8 - -typedef struct _igsPatternCache { - CARD8 *base; - CARD32 offset; - IgsPattern pattern[IGS_NUM_PATTERN]; - int next; -} IgsPatternCache; - -typedef struct _igsScreenInfo { - CARD8 *cursor_base; - CARD32 cursor_offset; - IgsCursor cursor; - IgsPatternCache tile; - IgsPatternCache stipple; -} IgsScreenInfo; - -#define IgsTileSize(bpp) (IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT) -#define IgsStippleSize(bpp) (IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT) - -#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver)) -#define igsScreenInfo(kd) IgsScreenInfo *igss = getIgsScreenInfo(kd) - -Bool -igsDrawInit (ScreenPtr pScreen); - -void -igsDrawEnable (ScreenPtr pScreen); - -void -igsDrawDisable (ScreenPtr pScreen); - -void -igsDrawSync (ScreenPtr pScreen); - -void -igsDrawFini (ScreenPtr pScreen); - -void -igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); - -void -igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); - -Bool -igsCursorInit (ScreenPtr pScreen); - -void -igsCursorEnable (ScreenPtr pScreen); - -void -igsCursorDisable (ScreenPtr pScreen); - -void -igsCursorFini (ScreenPtr pScreen); - -#endif /* _IGS_H_ */ diff --git a/hw/kdrive/igs/igscmap.c b/hw/kdrive/igs/igscmap.c deleted file mode 100644 index e6dc04e7b..000000000 --- a/hw/kdrive/igs/igscmap.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * $RCSId: $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igs.h" - -#define IGS_DAC_SHIFT 8 -void -igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - igsCardInfo(pScreenPriv); - IgsVga *igsvga = &igsc->igsvga; - - while (ndef--) - { - igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel); - pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; - pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; - pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; - pdefs++; - } -} - -void -igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - igsCardInfo(pScreenPriv); - IgsVga *igsvga = &igsc->igsvga; - - while (ndef--) - { - igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel); - igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT); - igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT); - igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT); - pdefs++; - } -} - diff --git a/hw/kdrive/igs/igscurs.c b/hw/kdrive/igs/igscurs.c deleted file mode 100644 index 6bdc61658..000000000 --- a/hw/kdrive/igs/igscurs.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * $RCSId: $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igs.h" -#include "cursorstr.h" - -#define SetupCursor(s) KdScreenPriv(s); \ - igsCardInfo(pScreenPriv); \ - igsScreenInfo(pScreenPriv); \ - IgsCursor *pCurPriv = &igss->cursor; \ - IgsVga *igsvga = &igsc->igsvga - -static void -_igsMoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor(pScreen); - 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; - } - - igsSet (igsvga, igs_sprite_x, x); - igsSet (igsvga, igs_sprite_preset_x, xoff); - igsSet (igsvga, igs_sprite_y, y); - igsSet (igsvga, igs_sprite_preset_y, yoff); -} - -static void -igsMoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor (pScreen); - - if (!pCurPriv->has_cursor) - return; - - if (!pScreenPriv->enabled) - return; - - _igsMoveCursor (pScreen, x, y); - VgaFlush (&igsvga->card); -} - - -static void -igsSetCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - - igsSetImm (igsvga, igs_cursor_write_index, 0); - igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8); - igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8); - igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8); - igsSetImm (igsvga, igs_cursor_write_index, 1); - igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8); - igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8); - igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8); -} - -#if BITMAP_BIT_ORDER == MSBFirst -#define IgsAdjustCursor(v) { \ - v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ - v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ - v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ - v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \ - v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \ -} -#else -#define IgsAdjustCursor(v) -#endif - -#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1)) -#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \ - (ExplodeBits2((v) & 0x3))) -#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \ - (ExplodeBits4((v) & 0xf))) -#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \ - (ExplodeBits8((v) & 0xff))) -static void -igsLoadCursor (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; - CARD32 b0, b1; - - pCurPriv->pCursor = pCursor; - pCurPriv->xhot = pCursor->bits->xhot; - pCurPriv->yhot = pCursor->bits->yhot; - - /* - * Stick new image into cursor memory - */ - ram = (CARD32 *) igss->cursor_base; - mskLine = (CARD32 *) bits->mask; - srcLine = (CARD32 *) bits->source; - - h = bits->height; - if (h > IGS_CURSOR_HEIGHT) - h = IGS_CURSOR_HEIGHT; - - lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ - - for (i = 0; i < IGS_CURSOR_HEIGHT; i++) { - msk = mskLine; - src = srcLine; - mskLine += lwsrc; - srcLine += lwsrc; - for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) { - - CARD32 m, s; - - if (i < h && j < lwsrc) - { - m = *msk++; - s = *src++; - IgsAdjustCursor(m); - IgsAdjustCursor(s); - } - else - { - m = 0; - s = 0; - } - s &= m; - m = ~m; - b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1); - b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1); - *ram++ = b0; - *ram++ = b1; - } - } - - /* Set new color */ - igsSetCursorColors (pScreen); - - /* Set address for cursor bits */ - offset = igss->cursor_offset; - offset >>= 10; - igsSet (igsvga, igs_sprite_addr, offset); - - /* Assume TV interpolation off */ - igsSet (igsvga, igs_hcshf, 3); - /* Enable the cursor */ - igsSet (igsvga, igs_sprite_visible, 1); - igsSet (igsvga, igs_sprite_64x64, 1); - /* Move to new position */ - _igsMoveCursor (pScreen, x, y); - - VgaFlush (&igsvga->card); -} - -static void -igsUnloadCursor (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - /* Disable cursor */ - igsSet (igsvga, igs_sprite_visible, 0); - VgaFlush (&igsvga->card); -} - -static Bool -igsRealizeCursor (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); - igsLoadCursor (pScreen, x, y); - } - } - return TRUE; -} - -static Bool -igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) -{ - return TRUE; -} - -static void -igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) -{ - SetupCursor(pScreen); - - pCurPriv->pCursor = pCursor; - - if (!pScreenPriv->enabled) - return; - - if (pCursor) - igsLoadCursor (pScreen, x, y); - else - igsUnloadCursor (pScreen); -} - -miPointerSpriteFuncRec igsPointerSpriteFuncs = { - igsRealizeCursor, - igsUnrealizeCursor, - igsSetCursor, - igsMoveCursor, -}; - -static void -igsQueryBestSize (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 -igsCursorInit (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!igss->cursor_base) - { - pCurPriv->has_cursor = FALSE; - return FALSE; - } - - pCurPriv->width = IGS_CURSOR_WIDTH; - pCurPriv->height= IGS_CURSOR_HEIGHT; - pScreen->QueryBestSize = igsQueryBestSize; - miPointerInitialize (pScreen, - &igsPointerSpriteFuncs, - &kdPointerScreenFuncs, - FALSE); - pCurPriv->has_cursor = TRUE; - pCurPriv->pCursor = NULL; - return TRUE; -} - -void -igsCursorEnable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - int x, y; - - miPointerPosition (&x, &y); - igsLoadCursor (pScreen, x, y); - } - else - igsUnloadCursor (pScreen); - } -} - -void -igsCursorDisable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!pScreenPriv->enabled) - return; - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - igsUnloadCursor (pScreen); - } - } -} - -void -igsCursorFini (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - pCurPriv->pCursor = NULL; -} diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c deleted file mode 100644 index d92ea6653..000000000 --- a/hw/kdrive/igs/igsdraw.c +++ /dev/null @@ -1,1538 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/igs/igsdraw.c,v 1.1 2000/05/06 22:17:43 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igs.h" -#include "igsdraw.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 igsPatRop[16] = { - /* GXclear */ 0x00, /* 0 */ - /* GXand */ 0xa0, /* src AND dst */ - /* GXandReverse */ 0x50, /* src AND NOT dst */ - /* GXcopy */ 0xf0, /* src */ - /* GXandInverted*/ 0x0a, /* NOT src AND dst */ - /* GXnoop */ 0xaa, /* dst */ - /* GXxor */ 0x5a, /* src XOR dst */ - /* GXor */ 0xfa, /* src OR dst */ - /* GXnor */ 0x05, /* NOT src AND NOT dst */ - /* GXequiv */ 0xa5, /* NOT src XOR dst */ - /* GXinvert */ 0x55, /* NOT dst */ - /* GXorReverse */ 0xf5, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x0f, /* NOT src */ - /* GXorInverted */ 0xaf, /* NOT src OR dst */ - /* GXnand */ 0x5f, /* NOT src OR NOT dst */ - /* GXset */ 0xff, /* 1 */ -}; - -/* - * Handle pixel transfers - */ - -#define BURST -#ifdef BURST -#define PixTransDeclare VOL32 *pix_trans_base = igsc->copData,\ - *pix_trans = pix_trans_base -#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 16384) pix_trans = pix_trans_base -#define PixTransStore(t) *pix_trans++ = (t) -#else -#define PixTransDeclare VOL32 *pix_trans = igsc->copData -#define PixTransStart(n) -#define PixTransStore(t) *pix_trans = (t) -#endif - -static IgsPattern * -igsSetPattern (ScreenPtr pScreen, - PixmapPtr pPixmap, - CARD8 fillStyle, - INT32 xrot, - INT32 yrot) -{ - KdScreenPriv(pScreen); - igsCardInfo(pScreenPriv); - igsScreenInfo(pScreenPriv); - int i; - IgsPatternCache *c; - IgsPattern *p; - - if (fillStyle == FillTiled) - c = &igss->tile; - else - c = &igss->stipple; - for (i = 0; i < IGS_NUM_PATTERN; i++) - { - p = &c->pattern[i]; - if (p->serial_number == pPixmap->drawable.serialNumber && - p->xrot == xrot && - p->yrot == yrot) - { - return p; - } - } - p = &c->pattern[c->next]; - if (++c->next == IGS_NUM_PATTERN) - c->next = 0; - p->serial_number = pPixmap->drawable.serialNumber; - p->xrot = xrot; - p->yrot = yrot; - - if (fillStyle != FillTiled) - { - FbStip *pix; - FbStride pixStride; - int pixBpp; - int pixXoff, pixYoff; - CARD8 tmp[8]; - CARD32 *pat; - int stipX, stipY; - int y; - FbStip bits; - - fbGetStipDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, pixXoff, pixYoff); - - modulus (-yrot - pixYoff, pPixmap->drawable.height, stipY); - modulus (-xrot - pixXoff, FB_UNIT, stipX); - - pat = (CARD32 *) p->base; - - for (y = 0; y < 8; y++) - { - bits = pix[stipY * pixStride]; - FbRotLeft (bits, stipX); - tmp[y] = (CARD8) bits; - stipY++; - if (stipY == pPixmap->drawable.height) - stipY = 0; - } - for (i = 0; i < 2; i++) - { - bits = (tmp[i*4+0] | - (tmp[i*4+1] << 8) | - (tmp[i*4+2] << 16) | - (tmp[i*4+3] << 24)); - IgsAdjustBits32 (bits); - *pat++ = bits; - } - } - else - { - FbBits *pix; - FbStride pixStride; - int pixBpp; - FbBits *pat; - FbStride patStride; - int patBpp; - int patXoff, patYoff; - - fbGetDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, patXoff, patYoff); - - pat = (FbBits *) p->base; - patBpp = pixBpp; - patStride = (patBpp * IGS_PATTERN_WIDTH) / (8 * sizeof (FbBits)); - - fbTile (pat, patStride, 0, - patBpp * IGS_PATTERN_WIDTH, IGS_PATTERN_HEIGHT, - - pix, pixStride, - pPixmap->drawable.width * pixBpp, - pPixmap->drawable.height, - GXcopy, FB_ALLONES, pixBpp, - (xrot - patXoff) * pixBpp, yrot - patYoff); - } - return p; -} - -void -igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - - _igsSetSolidRect(cop,alu,planemask,pixel,cmd); - while (nBox--) - { - _igsRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - -void -igsFillBoxTiled (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - PixmapPtr pPixmap, int xrot, int yrot, int alu) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - IgsPattern *p = igsSetPattern (pDrawable->pScreen, - pPixmap, - FillTiled, - xrot, yrot); - - _igsSetTiledRect(cop,alu,planemask,p->offset,cmd); - while (nBox--) - { - _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - -void -igsFillBoxStippled (DrawablePtr pDrawable, GCPtr pGC, - int nBox, BoxPtr pBox) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - int xrot = pGC->patOrg.x + pDrawable->x; - int yrot = pGC->patOrg.y + pDrawable->y; - IgsPattern *p = igsSetPattern (pDrawable->pScreen, - pGC->stipple, - pGC->fillStyle, - xrot, yrot); - if (pGC->fillStyle == FillStippled) - { - _igsSetStippledRect (cop,pGC->alu,planemask,pGC->fgPixel,p->offset,cmd); - } - else - { - _igsSetOpaqueStippledRect (cop,pGC->alu,planemask, - pGC->fgPixel,pGC->bgPixel,p->offset,cmd); - } - while (nBox--) - { - _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - - -void -igsStipple (ScreenPtr pScreen, - CARD32 cmd, - FbStip *psrcBase, - FbStride widthSrc, - int srcx, - int srcy, - int dstx, - int dsty, - int width, - int height) -{ - SetupIgs(pScreen); - FbStip *psrcLine, *psrc; - FbStride widthRest; - FbStip bits, tmp, lastTmp; - int leftShift, rightShift; - int nl, nlMiddle; - int r; - PixTransDeclare; - - /* Compute blt address and parameters */ - psrc = psrcBase + srcy * widthSrc + (srcx >> 5); - nlMiddle = (width + 31) >> 5; - leftShift = srcx & 0x1f; - rightShift = 32 - leftShift; - widthRest = widthSrc - nlMiddle; - - _igsPlaneBlt(cop,dstx,dsty,width,height,cmd); - - if (leftShift == 0) - { - while (height--) - { - nl = nlMiddle; - PixTransStart(nl); - while (nl--) - { - tmp = *psrc++; - IgsAdjustBits32 (tmp); - PixTransStore (tmp); - } - psrc += widthRest; - } - } - else - { - widthRest--; - while (height--) - { - bits = *psrc++; - nl = nlMiddle; - PixTransStart(nl); - while (nl--) - { - tmp = FbStipLeft(bits, leftShift); - bits = *psrc++; - tmp |= FbStipRight(bits, rightShift); - IgsAdjustBits32(tmp); - PixTransStore (tmp); - } - psrc += widthRest; - } - } -} - -void -igsCopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupIgs(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)) - { - igsFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); - return; - } - } - else - alu = GXcopy; - - _igsSetBlt(cop,alu,pGC->planemask,reverse,upsidedown,cmd); - while (nbox--) - { - w = pbox->x2 - pbox->x1; - h = pbox->y2 - pbox->y1; - if (reverse) - dstX = pbox->x2 - 1; - else - dstX = pbox->x1; - srcX = dstX + dx; - - if (upsidedown) - dstY = pbox->y2 - 1; - else - dstY = pbox->y1; - - srcY = dstY + dy; - - _igsBlt (cop, srcX, srcY, dstX, dstY, w, h, cmd); - pbox++; - } - KdMarkSync (pDstDrawable->pScreen); -} - -RegionPtr -igsCopyArea(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, igsCopyNtoN, 0, 0); - } - return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, dstx, dsty); -} - -typedef struct _igs1toNargs { - unsigned long copyPlaneFG, copyPlaneBG; - Bool opaque; -} igs1toNargs; - -void -igsCopy1toN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupIgs(pDstDrawable->pScreen); - - igs1toNargs *args = closure; - int dstx, dsty; - FbStip *psrcBase; - FbStride widthSrc; - int srcBpp; - int srcXoff, srcYoff; - CARD32 cmd; - - if (args->opaque && sourceInvarient (pGC->alu)) - { - igsFillBoxSolid (pDstDrawable, nbox, pbox, - pGC->bgPixel, pGC->alu, pGC->planemask); - return; - } - - fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); - - if (args->opaque) - { - _igsSetOpaquePlaneBlt (cop, pGC->alu, pGC->planemask, args->copyPlaneFG, - args->copyPlaneBG, cmd); - } - else - { - _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, - args->copyPlaneFG, cmd); - } - - while (nbox--) - { - dstx = pbox->x1; - dsty = pbox->y1; - - igsStipple (pDstDrawable->pScreen, cmd, - psrcBase, widthSrc, - dstx + dx - srcXoff, dsty + dy - srcYoff, - dstx, dsty, - pbox->x2 - dstx, pbox->y2 - dsty); - pbox++; - } - KdMarkSync (pDstDrawable->pScreen); -} - -RegionPtr -igsCopyPlane (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int srcx, - int srcy, - int width, - int height, - int dstx, - int dsty, - unsigned long bitPlane) -{ - RegionPtr ret; - igs1toNargs args; - FbBits depthMask; - - depthMask = FbFullMask (pDstDrawable->depth); - if ((pGC->planemask & depthMask) == depthMask && - pDstDrawable->type == DRAWABLE_WINDOW && - pSrcDrawable->depth == 1) - { - args.copyPlaneFG = pGC->fgPixel; - args.copyPlaneBG = pGC->bgPixel; - args.opaque = TRUE; - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, igsCopy1toN, bitPlane, &args); - } - return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, bitPlane); -} - -#if 0 -/* would you believe this is slower than fb? */ -void -igsPushPixels (GCPtr pGC, - PixmapPtr pBitmap, - DrawablePtr pDrawable, - int w, - int h, - int x, - int y) -{ - igs1toNargs args; - FbBits depthMask; - - depthMask = FbFullMask (pDstDrawable->depth); - if ((pGC->planemask & depthMask) == depthMask && - pDrawable->type == DRAWABLE_WINDOW && - pGC->fillStyle == FillSolid) - { - args.opaque = FALSE; - args.copyPlaneFG = pGC->fgPixel; - (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC, - 0, 0, w, h, x, y, igsCopy1toN, 1, &args); - } - else - { - KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y); - } -} -#else -#define igsPushPixels KdCheckPushPixels -#endif - -BOOL -igsFillOk (GCPtr pGC) -{ - FbBits depthMask; - - depthMask = FbFullMask(pGC->depth); - if ((pGC->planemask & depthMask) != depthMask) - return FALSE; - switch (pGC->fillStyle) { - case FillSolid: - return TRUE; - case FillTiled: - return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) && - igsPatternDimOk (pGC->tile.pixmap->drawable.height)); - case FillStippled: - case FillOpaqueStippled: - return (igsPatternDimOk (pGC->stipple->drawable.width) && - igsPatternDimOk (pGC->stipple->drawable.height)); - } - return FALSE; -} - -void -igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - SetupIgs(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; - IgsPattern *p; - - if (!igsFillOk (pGC)) - { - KdCheckFillSpans (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; - switch (pGC->fillStyle) { - case FillSolid: - _igsSetSolidRect(cop,pGC->alu,pGC->planemask,pGC->fgPixel,cmd); - break; - case FillTiled: - p = igsSetPattern (pDrawable->pScreen, - pGC->tile.pixmap, - FillTiled, - pGC->patOrg.x + pDrawable->x, - pGC->patOrg.y + pDrawable->y); - _igsSetTiledRect (cop,pGC->alu,pGC->planemask,p->offset,cmd); - break; - default: - p = igsSetPattern (pDrawable->pScreen, - pGC->stipple, - pGC->fillStyle, - pGC->patOrg.x + pDrawable->x, - pGC->patOrg.y + pDrawable->y); - if (pGC->fillStyle == FillStippled) - { - _igsSetStippledRect (cop,pGC->alu,pGC->planemask, - pGC->fgPixel,p->offset,cmd); - } - else - { - _igsSetOpaqueStippledRect (cop,pGC->alu,pGC->planemask, - pGC->fgPixel,pGC->bgPixel,p->offset,cmd); - } - break; - } - while (n--) - { - x = ppt->x; - y = ppt->y; - ppt++; - width = *pwidth++; - if (width) - { - _igsPatRect(cop,x,y,width,1,cmd); - } - } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); - KdMarkSync (pDrawable->pScreen); -} - -#define NUM_STACK_RECTS 1024 - -void -igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - SetupIgs(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 (!igsFillOk (pGC)) - { - KdCheckPolyFillRect (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: - igsFillBoxSolid(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->fgPixel, pGC->alu, pGC->planemask); - break; - case FillTiled: - igsFillBoxTiled(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->tile.pixmap, - pGC->patOrg.x + pDrawable->x, - pGC->patOrg.y + pDrawable->y, - pGC->alu); - break; - case FillStippled: - case FillOpaqueStippled: - igsFillBoxStippled (pDrawable, pGC, - pboxClipped-pboxClippedBase, pboxClippedBase); - break; - } - } - if (pboxClippedBase != stackRects) - xfree(pboxClippedBase); -} - -int -igsTextInRegion (GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci) -{ - int w; - FontPtr pfont = pGC->font; - BoxRec bbox; - - if (FONTCONSTMETRICS(pfont)) - w = FONTMAXBOUNDS(pfont,characterWidth) * nglyph; - else - { - w = 0; - while (nglyph--) - w += (*ppci++)->metrics.characterWidth; - } - if (w < 0) - { - bbox.x1 = x + w; - bbox.x2 = x; - } - else - { - bbox.x1 = x; - bbox.x2 = x + w; - } - w = FONTMINBOUNDS(pfont,leftSideBearing); - if (w < 0) - bbox.x1 += w; - w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); - if (w > 0) - bbox.x2 += w; - bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); - bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); - - return RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox); -} - -void -igsGlyphBltClipped (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - Bool image) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - int h; - int w; - int xBack, yBack; - int hBack, wBack; - int lw; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - unsigned long *bits; - BoxPtr extents; - BoxRec bbox; - CARD32 b; - CharInfoPtr *ppci; - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr pBox; - int nbox; - int x1, y1, x2, y2; - unsigned char alu; - Bool set; - PixTransDeclare; - - if (image) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - h = nglyph; - ppci = ppciInit; - while (h--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - if (wBack) - { - _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd); - for (nbox = REGION_NUM_RECTS (pClip), - pBox = REGION_RECTS (pClip); - nbox--; - pBox++) - { - x1 = xBack; - x2 = xBack + wBack; - y1 = yBack; - y2 = yBack + hBack; - if (x1 < pBox->x1) x1 = pBox->x1; - if (x2 > pBox->x2) x2 = pBox->x2; - if (y1 < pBox->y1) y1 = pBox->y1; - if (y2 > pBox->y2) y2 = pBox->y2; - if (x1 < x2 && y1 < y2) - { - _igsRect (cop, x1, y1, x2 - x1, y2 - y1, cmd); - } - } - KdMarkSync (pDrawable->pScreen); - } - } - else - { - wBack = 0; - alu = pGC->alu; - } - - ppci = ppciInit; - set = FALSE; - while (nglyph--) - { - pci = *ppci++; - h = pci->metrics.ascent + pci->metrics.descent; - w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - x1 = x + pci->metrics.leftSideBearing; - y1 = y - pci->metrics.ascent; - bbox.x1 = x1; - bbox.y1 = y1; - bbox.x2 = x1 + w; - bbox.y2 = y1 + h; - switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox)) - { - case rgnIN: - lw = h * ((w + 31) >> 5); - if (lw) - { - if (!set) - { - _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd); - set = TRUE; - } - _igsPlaneBlt(cop, - x + pci->metrics.leftSideBearing, - y - pci->metrics.ascent, - w, h, cmd); - bits = (unsigned long *) pci->bits; - PixTransStart (lw); - while (lw--) - { - b = *bits++; - IgsAdjustBits32 (b); - PixTransStore(b); - } - KdMarkSync (pDrawable->pScreen); - } - break; - case rgnPART: - set = FALSE; - KdCheckSync (pDrawable->pScreen); - fbPutXYImage (pDrawable, - pClip, - fbPriv->fg, - fbPriv->bg, - fbPriv->pm, - alu, - FALSE, - x1, y1, - w, h, - (FbStip *) pci->bits, - (w + 31) >> 5, - 0); - break; - case rgnOUT: - break; - } - x += pci->metrics.characterWidth; - } -} - -void -igsGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - Bool image) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - int h; - int w; - int xBack, yBack; - int hBack, wBack; - int lw; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - unsigned long *bits; - BoxPtr extents; - BoxRec bbox; - CARD32 b; - CharInfoPtr *ppci; - unsigned char alu; - PixTransDeclare; - - /* - * Paint background for image text - */ - if (image) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - h = nglyph; - ppci = ppciInit; - while (h--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - if (wBack) - { - _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd); - _igsRect (cop, xBack, yBack, wBack, hBack, cmd); - } - } - else - { - wBack = 0; - alu = pGC->alu; - } - - _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd); - ppci = ppciInit; - while (nglyph--) - { - pci = *ppci++; - h = pci->metrics.ascent + pci->metrics.descent; - w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - lw = h * ((w + 31) >> 5); - if (lw) - { - _igsPlaneBlt(cop, - x + pci->metrics.leftSideBearing, - y - pci->metrics.ascent, - w, h, cmd); - bits = (unsigned long *) pci->bits; - PixTransStart(lw); - while (lw--) - { - b = *bits++; - IgsAdjustBits32 (b); - PixTransStore(b); - } - } - x += pci->metrics.characterWidth; - } - KdMarkSync (pDrawable->pScreen); -} - -void -igsTEGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int xInit, - int yInit, - unsigned int nglyph, - CharInfoPtr *ppci, - Bool image) -{ - SetupIgs(pDrawable->pScreen); - CARD32 cmd; - int x, y; - int h, lw, lwTmp; - int w; - FontPtr pfont = pGC->font; - unsigned long *char1, *char2, *char3, *char4; - int widthGlyphs, widthGlyph; - BoxRec bbox; - CARD32 tmp; - PixTransDeclare; - - widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); - if (!widthGlyph) - return; - - h = FONTASCENT(pfont) + FONTDESCENT(pfont); - if (!h) - return; - - x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing); - y = yInit - FONTASCENT(pfont); - - if (image) - { - _igsSetOpaquePlaneBlt (cop, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel, cmd); - } - else - { - _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, pGC->fgPixel, cmd); - } - -#if BITMAP_BIT_ORDER == LSBFirst -#define SHIFT << -#else -#define SHIFT >> -#endif - -#define LoopIt(count, w, loadup, fetch) \ - while (nglyph >= count) \ - { \ - nglyph -= count; \ - _igsPlaneBlt (cop, x, y, w, h, cmd); \ - x += w; \ - loadup \ - lwTmp = h; \ - PixTransStart(h); \ - while (lwTmp--) { \ - tmp = fetch; \ - IgsAdjustBits32(tmp); \ - PixTransStore(tmp); \ - } \ - } - - if (widthGlyph <= 8) - { - widthGlyphs = widthGlyph << 2; - LoopIt(4, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits; - char4 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | ((*char3++ | (*char4++ - SHIFT widthGlyph)) - SHIFT widthGlyph)) - SHIFT widthGlyph))) - } - else if (widthGlyph <= 10) - { - widthGlyphs = (widthGlyph << 1) + widthGlyph; - LoopIt(3, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph))) - } - else if (widthGlyph <= 16) - { - widthGlyphs = widthGlyph << 1; - LoopIt(2, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | (*char2++ SHIFT widthGlyph))) - } - lw = h * ((widthGlyph + 31) >> 5); - while (nglyph--) - { - _igsPlaneBlt (cop, x, y, widthGlyph, h, cmd); - x += widthGlyph; - char1 = (unsigned long *) (*ppci++)->bits; - lwTmp = lw; - PixTransStart(lw); - while (lwTmp--) - { - tmp = *char1++; - IgsAdjustBits32(tmp); - PixTransStore(tmp); - } - } - KdMarkSync (pDrawable->pScreen); -} - -/* - * Blt glyphs using image transfer window - */ - -void -igsPolyGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - if (pGC->fillStyle != FillSolid || - fbGetGCPrivate(pGC)->pm != FB_ALLONES) - { - KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); - return; - } - x += pDrawable->x; - y += pDrawable->y; - - switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) { - case rgnIN: - if (TERMINALFONT(pGC->font)) - igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE); - else - igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE); - break; - case rgnPART: - igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, FALSE); - break; - case rgnOUT: - break; - } -} - -void -igsImageGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - if (fbGetGCPrivate(pGC)->pm != FB_ALLONES) - { - KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); - return; - } - x += pDrawable->x; - y += pDrawable->y; - - switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) { - case rgnIN: - if (TERMINALFONT(pGC->font)) - igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE); - else - igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE); - break; - case rgnPART: - igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, TRUE); - break; - case rgnOUT: - break; - } -} - -static void -igsInvalidatePattern (IgsPatternCache *c, - PixmapPtr pPixmap) -{ - int i; - - if (c->base) - { - for (i = 0; i < IGS_NUM_PATTERN; i++) - { - if (c->pattern[i].serial_number == pPixmap->drawable.serialNumber) - c->pattern[i].serial_number = ~0; - } - } -} - -static void -igsInitPattern (IgsPatternCache *c, int bsize, int psize) -{ - int i; - int boffset; - int poffset; - - for (i = 0; i < IGS_NUM_PATTERN; i++) - { - boffset = i * bsize; - poffset = i * psize; - c->pattern[i].xrot = -1; - c->pattern[i].yrot = -1; - c->pattern[i].serial_number = ~0; - c->pattern[i].offset = c->offset + poffset; - c->pattern[i].base = c->base + boffset; - } - c->next = 0; -} - -static const GCOps igsOps = { - igsFillSpans, - KdCheckSetSpans, - KdCheckPutImage, - igsCopyArea, - igsCopyPlane, - KdCheckPolyPoint, - KdCheckPolylines, - KdCheckPolySegment, - miPolyRectangle, - KdCheckPolyArc, - miFillPolygon, - igsPolyFillRect, - KdCheckPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - igsImageGlyphBlt, - igsPolyGlyphBlt, - igsPushPixels, -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -void -igsValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - - fbValidateGC (pGC, changes, pDrawable); - - if (pDrawable->type == DRAWABLE_WINDOW) - pGC->ops = (GCOps *) &igsOps; - else - pGC->ops = (GCOps *) &fbGCOps; -} - -GCFuncs igsGCFuncs = { - igsValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -int -igsCreateGC (GCPtr pGC) -{ - if (!fbCreateGC (pGC)) - return FALSE; - - if (pGC->depth != 1) - pGC->funcs = &igsGCFuncs; - - return TRUE; -} - -void -igsCopyWindow(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, igsCopyNtoN, 0, 0); - - REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); -} - -void -igsPaintWindow(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; - case BackgroundPixmap: - pTile = pWin->background.pixmap; - if (igsPatternDimOk (pTile->drawable.width) && - igsPatternDimOk (pTile->drawable.height)) - { - igsFillBoxTiled ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pTile, - pWin->drawable.x, pWin->drawable.y, GXcopy); - return; - } - break; - case BackgroundPixel: - igsFillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixel, GXcopy, ~0); - return; - } - break; - case PW_BORDER: - if (pWin->borderIsPixel) - { - igsFillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixel, GXcopy, ~0); - return; - } - else - { - pTile = pWin->border.pixmap; - if (igsPatternDimOk (pTile->drawable.width) && - igsPatternDimOk (pTile->drawable.height)) - { - igsFillBoxTiled ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pTile, - pWin->drawable.x, pWin->drawable.y, GXcopy); - return; - } - } - break; - } - KdCheckPaintWindow (pWin, pRegion, what); -} - -Bool -igsDrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - igsCardInfo(pScreenPriv); - igsScreenInfo(pScreenPriv); - int i; - int pattern_size; - int boffset, poffset; - - KdScreenInitAsync (pScreen); - - /* - * Replace various fb screen functions - */ - pScreen->CreateGC = igsCreateGC; - pScreen->CopyWindow = igsCopyWindow; - pScreen->PaintWindowBackground = igsPaintWindow; - pScreen->PaintWindowBorder = igsPaintWindow; - - /* - * Initialize patterns - */ - if (igss->tile.base) - { - pattern_size = IgsTileSize(pScreenPriv->screen->fb[0].bitsPerPixel); - igsInitPattern (&igss->tile, - pattern_size, - pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel); - pattern_size = IgsStippleSize(pScreenPriv->screen->fb[0].bitsPerPixel); - igsInitPattern (&igss->stipple, - pattern_size, - pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel); - } - return TRUE; -} - -void -igsDrawEnable (ScreenPtr pScreen) -{ - SetupIgs(pScreen); - CARD32 cmd; - CARD32 base; - CARD16 stride; - CARD32 format; - - stride = pScreenPriv->screen->fb[0].pixelStride; - _igsWaitIdleEmpty(cop); - _igsReset(cop); - switch (pScreenPriv->screen->fb[0].bitsPerPixel) { - case 8: - format = IGS_FORMAT_8BPP; - break; - case 16: - format = IGS_FORMAT_16BPP; - break; - case 24: - format = IGS_FORMAT_24BPP; - break; - case 32: - format = IGS_FORMAT_32BPP; - break; - } - cop->format = format; - cop->dst_stride = stride - 1; - cop->src1_stride = stride - 1; - cop->src2_stride = stride - 1; - cop->src1_start = 0; - cop->src2_start = 0; - cop->extension |= IGS_BLOCK_COP_REG | IGS_BURST_ENABLE; - - _igsSetSolidRect(cop, GXcopy, ~0, pScreen->blackPixel, cmd); - _igsRect (cop, 0, 0, - pScreenPriv->screen->width, pScreenPriv->screen->height, - cmd); - _igsWaitIdleEmpty (cop); -} - -void -igsDrawDisable (ScreenPtr pScreen) -{ -} - -void -igsDrawFini (ScreenPtr pScreen) -{ -} - -void -igsDrawSync (ScreenPtr pScreen) -{ - SetupIgs(pScreen); - - _igsWaitIdleEmpty(cop); -} diff --git a/hw/kdrive/igs/igsdraw.h b/hw/kdrive/igs/igsdraw.h deleted file mode 100644 index c969826b1..000000000 --- a/hw/kdrive/igs/igsdraw.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/igs/igsdraw.h,v 1.1 2000/05/06 22:17:43 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifndef _IGSDRAW_H_ -#define _IGSDRAW_H_ - -extern CARD8 igsPatRop[]; - -#define SetupIgs(s) KdScreenPriv(s); \ - igsCardInfo(pScreenPriv); \ - Cop5xxx *cop = igsc->cop; \ - int cop_stride = pScreenPriv->screen->fb[0].pixelStride - -#define _igsWaitLoop(cop,mask,value) { \ - int __loop = 1000000; \ - while (((cop)->control & (mask)) != (value)) { \ - if (--__loop <= 0) { \ - FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \ - } \ - } \ -} - -#define _igsWaitDone(cop) _igsWaitLoop(cop, \ - (IGS_CONTROL_BUSY| \ - IGS_CONTROL_MALLWBEPTZ), \ - 0) - -#if 1 -#define _igsWaitFull(cop) _igsWaitLoop(cop, \ - IGS_CONTROL_CMDFF, \ - 0) -#else -#define _igsWaitFull(cop) _igsWaitDone(cop) -#endif - -#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop) -#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \ - (IGS_CONTROL_HBACKZ| \ - IGS_CONTROL_CMDFF), \ - 0) - -#define _igsReset(cop) ((cop)->control = 0) - -#define IgsInvertBits32(v) { \ - v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ - v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ - v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ -} - -#define IgsInvertBits16(v) { \ - v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \ - v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \ - v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \ -} - -#define IgsInvertBits8(v) { \ - v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \ - v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \ - v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \ -} - -#define IgsByteSwap32(x) ((x) = (((x) >> 24) | \ - (((x) >> 8) & 0xff00) | \ - (((x) << 8) & 0xff0000) | \ - ((x) << 24))) - -#define IgsByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8)) - -#define igsPatternDimOk(d) ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0)) - -#if BITMAP_BIT_ORDER == LSBFirst -#define IgsAdjustBits32(b) IgsInvertBits32(b) -#define IgsAdjustBits16(x) IgsInvertBits16(x) -#else -#define IgsAdjustBits32(x) IgsByteSwap32(x) -#define IgsAdjustBits16(x) IgsByteSwap16(x) -#endif - -#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\ - _igsWaitFull(cop); \ - (cop)->mix = IGS_MAKE_MIX(alu,alu); \ - (cop)->fg = (pix); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_FG | \ - IGS_HBLT_DISABLE | \ - IGS_SRC2_NORMAL | \ - IGS_STEP_PXBLT | \ - IGS_FGS_FG | \ - IGS_BGS_BG); \ -} - -#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\ - _igsWaitFull(cop); \ - (cop)->mix = IGS_MAKE_MIX(alu,alu); \ - (cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \ - (cop)->src1_start = (base); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_TILE | \ - IGS_HBLT_DISABLE | \ - IGS_SRC2_NORMAL | \ - IGS_STEP_PXBLT | \ - IGS_FGS_SRC | \ - IGS_BGS_BG); \ -} - -#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\ - _igsWaitFull(cop); \ - (cop)->mix = IGS_MAKE_MIX(alu,alu); \ - (cop)->src1_start = (base); \ - (cop)->fg = (pix); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_STIP_TRANS | \ - IGS_HBLT_DISABLE | \ - IGS_SRC2_NORMAL | \ - IGS_STEP_PXBLT | \ - IGS_FGS_FG | \ - IGS_BGS_BG); \ -} - -#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\ - _igsWaitFull(cop); \ - (cop)->mix = IGS_MAKE_MIX(alu,alu); \ - (cop)->src1_start = (base); \ - (cop)->fg = (_fg); \ - (cop)->bg = (_bg); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_STIP_OPAQUE | \ - IGS_HBLT_DISABLE | \ - IGS_SRC2_NORMAL | \ - IGS_STEP_PXBLT | \ - IGS_FGS_FG | \ - IGS_BGS_BG); \ -} - -#define _igsRect(cop,x,y,w,h,cmd) { \ - _igsWaitFull(cop); \ - (cop)->dst_start = (x) + (y) * (cop_stride); \ - (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ - (cop)->operation = (cmd); \ -} - -#define _igsPatRect(cop,x,y,w,h,cmd) { \ - _igsWaitFull(cop); \ - (cop)->dst_start = (x) + (y) * (cop_stride); \ - (cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \ - (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ - (cop)->operation = (cmd); \ -} - -#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \ - _igsWaitFull(cop); \ - (cop)->mix = IGS_MAKE_MIX(alu,alu); \ - (cop)->src1_stride = cop_stride - 1; \ - (cmd) = (IGS_DRAW_ALL | \ - IGS_PIXEL_FG | \ - IGS_HBLT_DISABLE | \ - IGS_SRC2_NORMAL | \ - IGS_STEP_PXBLT | \ - IGS_FGS_SRC | \ - IGS_BGS_BG); \ - if (backwards) (cmd) |= IGS_DRAW_R_L; \ - if (upsidedown) (cmd) |= IGS_DRAW_B_T; \ -} - -#if 0 -#define _igsPreparePlaneBlt(cop) { \ - _igsReset(cop); \ - (cop)->dst_stride = cop_stride - 1; \ - (cop)->src1_stride = cop_stride - 1; \ - (cop)->src2_stride = cop_stride - 1; \ - (cop)->format = IGS_FORMAT_16BPP; \ - (cop)->src1_start = 0; \ - (cop)->src2_start = 0; \ -} -#else -#define _igsPreparePlaneBlt(cop) -#endif - -#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \ - _igsWaitIdleEmpty(cop); \ - _igsPreparePlaneBlt(cop); \ - (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \ - (cop)->fg = (fg_pix); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_FG | \ - IGS_HBLT_WRITE_2 | \ - IGS_SRC2_MONO_TRANS | \ - IGS_STEP_TERNARY_PXBLT | \ - IGS_FGS_FG | \ - IGS_BGS_BG); \ -} - -#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \ - _igsWaitIdleEmpty(cop); \ - _igsPreparePlaneBlt(cop); \ - (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \ - (cop)->fg = (fg_pix); \ - (cop)->bg = (bg_pix); \ - (cmd) = (IGS_DRAW_T_B | \ - IGS_DRAW_L_R | \ - IGS_DRAW_ALL | \ - IGS_PIXEL_FG | \ - IGS_HBLT_WRITE_2 | \ - IGS_SRC2_MONO_OPAQUE | \ - IGS_STEP_TERNARY_PXBLT | \ - IGS_FGS_FG | \ - IGS_BGS_BG); \ -} - -#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \ -/* _igsWaitFull(cop); */ \ - (cop)->dst_start = (x) + (y) * (cop_stride); \ - (cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \ - (cop)->operation = (cmd); \ -/* _igsWaitHostBltAck(cop); */ \ -} - -#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \ - _igsWaitFull(cop); \ - (cop)->dst_start = (dx) + (dy) * cop_stride; \ - (cop)->src1_start = (sx) + (sy) * cop_stride; \ - (cop)->src1_stride = cop_stride - 1; \ - (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ - (cop)->operation = (cmd); \ -} - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/igs/igsreg.c b/hw/kdrive/igs/igsreg.c deleted file mode 100644 index d63fce035..000000000 --- a/hw/kdrive/igs/igsreg.c +++ /dev/null @@ -1,971 +0,0 @@ -/* - * $RCSId: $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igsreg.h" -#include <stdio.h> - -#define CR00 IGS_CR+0x00 -#define CR01 IGS_CR+0x01 -#define CR02 IGS_CR+0x02 -#define CR03 IGS_CR+0x03 -#define CR04 IGS_CR+0x04 -#define CR05 IGS_CR+0x05 -#define CR06 IGS_CR+0x06 -#define CR07 IGS_CR+0x07 -#define CR08 IGS_CR+0x08 -#define CR09 IGS_CR+0x09 -#define CR0A IGS_CR+0x0A -#define CR0B IGS_CR+0x0B -#define CR0C IGS_CR+0x0C -#define CR0D IGS_CR+0x0D -#define CR0E IGS_CR+0x0E -#define CR0F IGS_CR+0x0F -#define CR10 IGS_CR+0x10 -#define CR11 IGS_CR+0x11 -#define CR12 IGS_CR+0x12 -#define CR13 IGS_CR+0x13 -#define CR14 IGS_CR+0x14 -#define CR15 IGS_CR+0x15 -#define CR16 IGS_CR+0x16 -#define CR17 IGS_CR+0x17 -#define CR18 IGS_CR+0x18 -#define CR19 IGS_CR+0x19 -#define CR1A IGS_CR+0x1A -#define CR1B IGS_CR+0x1B -#define CR1C IGS_CR+0x1C -#define CR1D IGS_CR+0x1D -#define CR1E IGS_CR+0x1E -#define CR1F IGS_CR+0x1F -#define CR20 IGS_CR+0x20 -#define CR21 IGS_CR+0x21 -#define CR22 IGS_CR+0x22 -#define CR23 IGS_CR+0x23 -#define CR24 IGS_CR+0x24 -#define CR25 IGS_CR+0x25 -#define CR26 IGS_CR+0x26 -#define CR27 IGS_CR+0x27 -#define CR28 IGS_CR+0x28 -#define CR29 IGS_CR+0x29 -#define CR2A IGS_CR+0x2A -#define CR2B IGS_CR+0x2B -#define CR2C IGS_CR+0x2C -#define CR2D IGS_CR+0x2D -#define CR2E IGS_CR+0x2E -#define CR2F IGS_CR+0x2F -#define CR30 IGS_CR+0x30 -#define CR31 IGS_CR+0x31 -#define CR32 IGS_CR+0x32 -#define CR33 IGS_CR+0x33 -#define CR34 IGS_CR+0x34 -#define CR35 IGS_CR+0x35 -#define CR36 IGS_CR+0x36 -#define CR37 IGS_CR+0x37 -#define CR38 IGS_CR+0x38 -#define CR39 IGS_CR+0x39 -#define CR3A IGS_CR+0x3A -#define CR3B IGS_CR+0x3B -#define CR3C IGS_CR+0x3C -#define CR3D IGS_CR+0x3D -#define CR3E IGS_CR+0x3E -#define CR3F IGS_CR+0x3F -#define CR40 IGS_CR+0x40 -#define CR41 IGS_CR+0x41 -#define CR42 IGS_CR+0x42 -#define CR43 IGS_CR+0x43 -#define CR44 IGS_CR+0x44 -#define CR45 IGS_CR+0x45 -#define CR46 IGS_CR+0x46 -#define CR47 IGS_CR+0x47 -#define CR48 IGS_CR+0x48 - -#define CR_FIRST CR00 -#define CR_LAST CR48 - -#define SR00 IGS_SR+0x00 -#define SR01 IGS_SR+0x01 -#define SR02 IGS_SR+0x02 -#define SR03 IGS_SR+0x03 -#define SR04 IGS_SR+0x04 - -#define SR_FIRST SR00 -#define SR_LAST SR04 - -#define AR00 IGS_AR+0x00 -#define AR01 IGS_AR+0x01 -#define AR02 IGS_AR+0x02 -#define AR03 IGS_AR+0x03 -#define AR04 IGS_AR+0x04 -#define AR05 IGS_AR+0x05 -#define AR06 IGS_AR+0x06 -#define AR07 IGS_AR+0x07 -#define AR08 IGS_AR+0x08 -#define AR09 IGS_AR+0x09 -#define AR0A IGS_AR+0x0A -#define AR0B IGS_AR+0x0B -#define AR0C IGS_AR+0x0C -#define AR0D IGS_AR+0x0D -#define AR0E IGS_AR+0x0E -#define AR0F IGS_AR+0x0F -#define AR10 IGS_AR+0x10 -#define AR11 IGS_AR+0x11 -#define AR12 IGS_AR+0x12 -#define AR13 IGS_AR+0x13 -#define AR14 IGS_AR+0x14 - -#define AR_FIRST AR00 -#define AR_LAST AR14 - -#define GR00 IGS_GR+0x00 -#define GR01 IGS_GR+0x01 -#define GR02 IGS_GR+0x02 -#define GR03 IGS_GR+0x03 -#define GR04 IGS_GR+0x04 -#define GR05 IGS_GR+0x05 -#define GR06 IGS_GR+0x06 -#define GR07 IGS_GR+0x07 -#define GR08 IGS_GR+0x08 -#define GR09 IGS_GR+0x09 -#define GR0A IGS_GR+0x0A -#define GR0B IGS_GR+0x0B -#define GR0C IGS_GR+0x0C -#define GR0D IGS_GR+0x0D -#define GR0E IGS_GR+0x0E -#define GR0F IGS_GR+0x0F -#define GR10 IGS_GR+0x10 -#define GR11 IGS_GR+0x11 -#define GR12 IGS_GR+0x12 -#define GR13 IGS_GR+0x13 -#define GR14 IGS_GR+0x14 -#define GR15 IGS_GR+0x15 -#define GR16 IGS_GR+0x16 -#define GR17 IGS_GR+0x17 -#define GR18 IGS_GR+0x18 -#define GR19 IGS_GR+0x19 -#define GR1A IGS_GR+0x1A -#define GR1B IGS_GR+0x1B -#define GR1C IGS_GR+0x1C -#define GR1D IGS_GR+0x1D -#define GR1E IGS_GR+0x1E -#define GR1F IGS_GR+0x1F -#define GR20 IGS_GR+0x20 -#define GR21 IGS_GR+0x21 -#define GR22 IGS_GR+0x22 -#define GR23 IGS_GR+0x23 -#define GR24 IGS_GR+0x24 -#define GR25 IGS_GR+0x25 -#define GR26 IGS_GR+0x26 -#define GR27 IGS_GR+0x27 -#define GR28 IGS_GR+0x28 -#define GR29 IGS_GR+0x29 -#define GR2A IGS_GR+0x2A -#define GR2B IGS_GR+0x2B -#define GR2C IGS_GR+0x2C -#define GR2D IGS_GR+0x2D -#define GR2E IGS_GR+0x2E -#define GR2F IGS_GR+0x2F -#define GR30 IGS_GR+0x30 -#define GR31 IGS_GR+0x31 -#define GR32 IGS_GR+0x32 -#define GR33 IGS_GR+0x33 -#define GR34 IGS_GR+0x34 -#define GR35 IGS_GR+0x35 -#define GR36 IGS_GR+0x36 -#define GR37 IGS_GR+0x37 -#define GR38 IGS_GR+0x38 -#define GR39 IGS_GR+0x39 -#define GR3A IGS_GR+0x3A -#define GR3B IGS_GR+0x3B -#define GR3C IGS_GR+0x3C -#define GR3D IGS_GR+0x3D -#define GR3E IGS_GR+0x3E -#define GR3F IGS_GR+0x3F -#define GR40 IGS_GR+0x40 -#define GR41 IGS_GR+0x41 -#define GR42 IGS_GR+0x42 -#define GR43 IGS_GR+0x43 -#define GR44 IGS_GR+0x44 -#define GR45 IGS_GR+0x45 -#define GR46 IGS_GR+0x46 -#define GR47 IGS_GR+0x47 -#define GR48 IGS_GR+0x48 -#define GR49 IGS_GR+0x49 -#define GR4A IGS_GR+0x4A -#define GR4B IGS_GR+0x4B -#define GR4C IGS_GR+0x4C -#define GR4D IGS_GR+0x4D -#define GR4E IGS_GR+0x4E -#define GR4F IGS_GR+0x4F -#define GR50 IGS_GR+0x50 -#define GR51 IGS_GR+0x51 -#define GR52 IGS_GR+0x52 -#define GR53 IGS_GR+0x53 -#define GR54 IGS_GR+0x54 -#define GR55 IGS_GR+0x55 -#define GR56 IGS_GR+0x56 -#define GR57 IGS_GR+0x57 -#define GR58 IGS_GR+0x58 -#define GR59 IGS_GR+0x59 -#define GR5A IGS_GR+0x5A -#define GR5B IGS_GR+0x5B -#define GR5C IGS_GR+0x5C -#define GR5D IGS_GR+0x5D -#define GR5E IGS_GR+0x5E -#define GR5F IGS_GR+0x5F -#define GR60 IGS_GR+0x60 -#define GR61 IGS_GR+0x61 -#define GR62 IGS_GR+0x62 -#define GR63 IGS_GR+0x63 -#define GR64 IGS_GR+0x64 -#define GR65 IGS_GR+0x65 -#define GR66 IGS_GR+0x66 -#define GR67 IGS_GR+0x67 -#define GR68 IGS_GR+0x68 -#define GR69 IGS_GR+0x69 -#define GR6A IGS_GR+0x6A -#define GR6B IGS_GR+0x6B -#define GR6C IGS_GR+0x6C -#define GR6D IGS_GR+0x6D -#define GR6E IGS_GR+0x6E -#define GR6F IGS_GR+0x6F -#define GR70 IGS_GR+0x70 -#define GR71 IGS_GR+0x71 -#define GR72 IGS_GR+0x72 -#define GR73 IGS_GR+0x73 -#define GR74 IGS_GR+0x74 -#define GR75 IGS_GR+0x75 -#define GR76 IGS_GR+0x76 -#define GR77 IGS_GR+0x77 -#define GR78 IGS_GR+0x78 -#define GR79 IGS_GR+0x79 -#define GR7A IGS_GR+0x7A -#define GR7B IGS_GR+0x7B -#define GR7C IGS_GR+0x7C -#define GR7D IGS_GR+0x7D -#define GR7E IGS_GR+0x7E -#define GR7F IGS_GR+0x7F -#define GR80 IGS_GR+0x80 -#define GR81 IGS_GR+0x81 -#define GR82 IGS_GR+0x82 -#define GR83 IGS_GR+0x83 -#define GR84 IGS_GR+0x84 -#define GR85 IGS_GR+0x85 -#define GR86 IGS_GR+0x86 -#define GR87 IGS_GR+0x87 -#define GR88 IGS_GR+0x88 -#define GR89 IGS_GR+0x89 -#define GR8A IGS_GR+0x8A -#define GR8B IGS_GR+0x8B -#define GR8C IGS_GR+0x8C -#define GR8D IGS_GR+0x8D -#define GR8E IGS_GR+0x8E -#define GR8F IGS_GR+0x8F -#define GR90 IGS_GR+0x90 -#define GR91 IGS_GR+0x91 -#define GR92 IGS_GR+0x92 -#define GR93 IGS_GR+0x93 -#define GR94 IGS_GR+0x94 -#define GR95 IGS_GR+0x95 -#define GR96 IGS_GR+0x96 -#define GR97 IGS_GR+0x97 -#define GR98 IGS_GR+0x98 -#define GR99 IGS_GR+0x99 -#define GR9A IGS_GR+0x9A -#define GR9B IGS_GR+0x9B -#define GR9C IGS_GR+0x9C -#define GR9D IGS_GR+0x9D -#define GR9E IGS_GR+0x9E -#define GR9F IGS_GR+0x9F -#define GRA0 IGS_GR+0xA0 -#define GRA1 IGS_GR+0xA1 -#define GRA2 IGS_GR+0xA2 -#define GRA3 IGS_GR+0xA3 -#define GRA4 IGS_GR+0xA4 -#define GRA5 IGS_GR+0xA5 -#define GRA6 IGS_GR+0xA6 -#define GRA7 IGS_GR+0xA7 -#define GRA8 IGS_GR+0xA8 -#define GRA9 IGS_GR+0xA9 -#define GRAA IGS_GR+0xAA -#define GRAB IGS_GR+0xAB -#define GRAC IGS_GR+0xAC -#define GRAD IGS_GR+0xAD -#define GRAE IGS_GR+0xAE -#define GRAF IGS_GR+0xAF -#define GRB0 IGS_GR+0xB0 -#define GRB1 IGS_GR+0xB1 -#define GRB2 IGS_GR+0xB2 -#define GRB3 IGS_GR+0xB3 -#define GRB4 IGS_GR+0xB4 -#define GRB5 IGS_GR+0xB5 -#define GRB6 IGS_GR+0xB6 -#define GRB7 IGS_GR+0xB7 -#define GRB8 IGS_GR+0xB8 -#define GRB9 IGS_GR+0xB9 -#define GRBA IGS_GR+0xBA -#define GRBB IGS_GR+0xBB -#define GRBC IGS_GR+0xBC -#define GRBD IGS_GR+0xBD -#define GRBE IGS_GR+0xBE -#define GRBF IGS_GR+0xBF - -#define GR_FIRST GR00 -#define GR_LAST GRBF - -#define GREX3C IGS_GREX+(0x3c-IGS_GREXBASE) - -VgaReg igs_h_total[] = { - CR00, 0, 8, - VGA_REG_END -}; - -VgaReg igs_h_de_end[] = { - CR01, 0, 8, - VGA_REG_END -}; - -VgaReg igs_h_bstart[] = { - CR02, 0, 8, - VGA_REG_END -}; - -VgaReg igs_h_bend[] = { - CR03, 0, 5, - CR05, 7, 1, - VGA_REG_END -}; - -VgaReg igs_de_skew[] = { - CR03, 5, 2, - VGA_REG_END -}; - -VgaReg igs_ena_vr_access[] = { - CR03, 7, 1, - VGA_REG_END -}; - -VgaReg igs_h_rstart[] = { - CR04, 0, 8, - VGA_REG_END -}; - -VgaReg igs_h_rend[] = { - CR05, 0, 5, - VGA_REG_END -}; - -VgaReg igs_h_rdelay[] = { - CR05, 5, 2, - VGA_REG_END -}; - -VgaReg igs_v_total[] = { - CR06, 0, 8, - CR07, 0, 1, - CR07, 5, 1, - GR11, 0, 1, - VGA_REG_END -}; - -VgaReg igs_v_rstart[] = { - CR10, 0, 8, - CR07, 2, 1, - CR07, 7, 1, - GR11, 2, 1, - VGA_REG_END -}; - -VgaReg igs_v_rend[] = { - CR11, 0, 4, - VGA_REG_END -}; - -VgaReg igs_clear_v_int[] = { - CR11, 4, 1, - VGA_REG_END -}; - -VgaReg igs_disable_v_int[] = { - CR11, 5, 1, - VGA_REG_END -}; - -VgaReg igs_bandwidth[] = { - CR11, 6, 1, - VGA_REG_END -}; - -VgaReg igs_crt_protect[] = { - CR11, 7, 1, - VGA_REG_END -}; - -VgaReg igs_v_de_end[] = { - CR12, 0, 8, - CR07, 1, 1, - CR07, 6, 1, - GR11, 1, 1, - VGA_REG_END -}; - -VgaReg igs_offset[] = { - CR13, 0, 8, - GR15, 4, 2, - VGA_REG_END -}; - -VgaReg igs_v_bstart[] = { - CR15, 0, 8, - CR07, 3, 1, - CR09, 5, 1, - GR11, 3, 1, - VGA_REG_END -}; - -VgaReg igs_v_bend[] = { - CR16, 0, 7, - VGA_REG_END -}; - -VgaReg igs_linecomp[] = { - CR18, 0, 8, - CR07, 4, 1, - CR09, 6, 1, - GR11, 4, 1, - VGA_REG_END -}; - -VgaReg igs_ivideo[] = { - GR11, 5, 1, - VGA_REG_END -}; - -VgaReg igs_num_fetch[] = { - GR14, 0, 8, - GR15, 0, 2, - VGA_REG_END -}; - -VgaReg igs_wcrt0[] = { - CR1F, 0, 1, - VGA_REG_END -}; - -VgaReg igs_wcrt1[] = { - CR1F, 1, 1, - VGA_REG_END -}; - -VgaReg igs_rcrts1[] = { - CR1F, 4, 1, - VGA_REG_END -}; - -VgaReg igs_selwk[] = { - CR1F, 6, 1, - VGA_REG_END -}; - -VgaReg igs_dot_clock_8[] = { - SR01, 0, 1, - VGA_REG_END -}; - -VgaReg igs_screen_off[] = { - SR01, 5, 1, - VGA_REG_END -}; - -VgaReg igs_enable_write_plane[] = { - SR02, 0, 4, - VGA_REG_END -}; - -VgaReg igs_mexhsyn[] = { - GR16, 0, 2, - VGA_REG_END -}; - -VgaReg igs_mexvsyn[] = { - GR16, 2, 2, - VGA_REG_END -}; - -VgaReg igs_pci_burst_write[] = { - GR30, 5, 1, - VGA_REG_END -}; - -VgaReg igs_pci_burst_read[] = { - GR30, 7, 1, - VGA_REG_END -}; - -VgaReg igs_iow_retry[] = { - GREX3C, 0, 1, - VGA_REG_END -}; - -VgaReg igs_mw_retry[] = { - GREX3C, 1, 1, - VGA_REG_END -}; - -VgaReg igs_mr_retry[] = { - GREX3C, 2, 1, - VGA_REG_END -}; - - - -VgaReg igs_biga22en[] = { - GR3D, 4, 1, - VGA_REG_END -}; - -VgaReg igs_biga24en[] = { - GR3D, 5, 1, - VGA_REG_END -}; - -VgaReg igs_biga22force[] = { - GR3D, 6, 1, - VGA_REG_END -}; - -VgaReg igs_bigswap[] = { - GR3F, 0, 6, - VGA_REG_END -}; - -/* #define IGS_BIGSWAP_8 0x3f */ -/* #define IGS_BIGSWAP_16 0x2a */ -/* #define IGS_BIGSWAP_32 0x00 */ - -VgaReg igs_sprite_x[] = { - GR50, 0, 8, - GR51, 0, 3, - VGA_REG_END -}; - -VgaReg igs_sprite_preset_x[] = { - GR52, 0, 6, - VGA_REG_END -}; - -VgaReg igs_sprite_y[] = { - GR53, 0, 8, - GR54, 0, 3, - VGA_REG_END -}; - -VgaReg igs_sprite_preset_y[] = { - GR55, 0, 6, - VGA_REG_END -}; - -VgaReg igs_sprite_visible[] = { - GR56, 0, 1, - VGA_REG_END -}; - -VgaReg igs_sprite_64x64[] = { - GR56, 1, 1, - VGA_REG_END -}; - -VgaReg igs_mgrext[] = { - GR57, 0, 1, - VGA_REG_END -}; - -VgaReg igs_hcshf[] = { - GR57, 4, 2, - VGA_REG_END -}; - -VgaReg igs_mbpfix[] = { - GR57, 6, 2, - VGA_REG_END -}; - -VgaReg igs_overscan_red[] = { - GR58, 0, 8, - VGA_REG_END -}; - -VgaReg igs_overscan_green[] = { - GR59, 0, 8, - VGA_REG_END -}; - -VgaReg igs_overscan_blue[] = { - GR5A, 0, 8, - VGA_REG_END -}; - -VgaReg igs_memgopg[] = { - GR73, 2, 1, - VGA_REG_END -}; - -VgaReg igs_memr2wpg[] = { - GR73, 1, 1, - VGA_REG_END -}; - -VgaReg igs_crtff16[] = { - GR73, 3, 1, - VGA_REG_END -}; - -VgaReg igs_fifomust[] = { - GR74, 0, 5, - VGA_REG_END -}; - -VgaReg igs_fifogen[] = { - GR75, 0, 5, - VGA_REG_END -}; - -VgaReg igs_mode_sel[] = { - GR77, 0, 4, - VGA_REG_END -}; - -/* #define IGS_MODE_TEXT 0 */ -/* #define IGS_MODE_8 1 */ -/* #define IGS_MODE_565 2 */ -/* #define IGS_MODE_5551 6 */ -/* #define IGS_MODE_8888 3 */ -/* #define IGS_MODE_888 4 */ -/* #define IGS_MODE_332 9 */ -/* #define IGS_MODE_4444 10 */ - -VgaReg igs_sprite_addr[] = { - GR7E, 0, 8, - GR7F, 0, 4, - VGA_REG_END -}; - -VgaReg igs_fastmpie[] = { - GR9E, 0, 1, - VGA_REG_END -}; - -VgaReg igs_vclk_m[] = { - GRB0, 0, 8, - GRBA, 0, 3, - VGA_REG_END -}; - -VgaReg igs_vclk_n[] = { - GRB1, 0, 5, - GRBA, 3, 3, - VGA_REG_END -}; - -VgaReg igs_vfsel[] = { - GRB1, 5, 1, - VGA_REG_END -}; - -VgaReg igs_vclk_p[] = { - GRB1, 6, 2, - GRBA, 6, 1, - VGA_REG_END -}; - -VgaReg igs_frqlat[] = { - GRB9, 7, 1, - VGA_REG_END -}; - - -VgaReg igs_dac_mask[] = { - IGS_DAC + 0, 0, 8, - VGA_REG_END -}; - -VgaReg igs_dac_read_index[] = { - IGS_DAC + 1, 0, 8, - VGA_REG_END -}; - -VgaReg igs_dac_write_index[] = { - IGS_DAC + 2, 0, 8, - VGA_REG_END -}; - -VgaReg igs_dac_data[] = { - IGS_DAC + 3, 0, 8, - VGA_REG_END -}; - -VgaReg igs_rampwdn[] = { - IGS_DACEX + 0, 0, 1, - VGA_REG_END -}; - -VgaReg igs_dac6_8[] = { - IGS_DACEX + 0, 1, 1, - VGA_REG_END -}; - -VgaReg igs_ramdacbypass[] = { - IGS_DACEX + 0, 4, 1, - VGA_REG_END -}; - -VgaReg igs_dacpwdn[] = { - IGS_DACEX + 0, 6, 1, - VGA_REG_END -}; - -VgaReg igs_cursor_read_index[] = { - IGS_DACEX + 1, 0, 8, - VGA_REG_END -}; - -VgaReg igs_cursor_write_index[] = { - IGS_DACEX + 2, 0, 8, - VGA_REG_END -}; - -VgaReg igs_cursor_data[] = { - IGS_DACEX + 3, 0, 8, - VGA_REG_END -}; - -VGA8 -_igsInb (VgaCard *card, VGA16 port) -{ - VGAVOL8 *reg; - - if (card->closure) - return VgaReadMemb ((VGA32) card->closure + port); - else - return VgaInb (port); -} - -void -_igsOutb (VgaCard *card, VGA8 value, VGA16 port) -{ - if (card->closure) - VgaWriteMemb (value, (VGA32) card->closure + port); - else - VgaOutb (value, port); -} - -void -_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write) -{ - if (reg < IGS_SR + IGS_NSR) - { - map->access = VgaAccessIndIo; - map->port = 0x3c4; - map->addr = 0; - map->value = 1; - map->index = reg - IGS_SR; - } - else if (reg < IGS_GR + IGS_NGR) - { - map->access = VgaAccessIndIo; - map->port = 0x3ce; - map->addr = 0; - map->value = 1; - map->index = reg - IGS_GR; - } - else if (reg < IGS_GREX + IGS_NGREX) - { - VGA8 gr33; - - map->access = VgaAccessDone; - _igsOutb (card, 0x33, 0x3ce); - gr33 = _igsInb (card, 0x3cf); - _igsOutb (card, gr33 | 0x40, 0x3cf); - _igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce); - if (write) - _igsOutb (card, map->value, 0x3cf); - else - map->value = _igsInb (card, 0x3cf); - _igsOutb (card, 0x33, 0x3ce); - _igsOutb (card, gr33, 0x3cf); - return; - } - else if (reg < IGS_AR + IGS_NAR) - { - reg -= IGS_AR; - map->access = VgaAccessDone; - /* reset AFF to index */ - (void) _igsInb (card, 0x3da); - if (reg >= 16) - reg |= 0x20; - _igsOutb (card, reg, 0x3c0); - if (write) - _igsOutb (card, map->value, 0x3c0); - else - map->value = _igsInb (card, 0x3c1); - if (!(reg & 0x20)) - { - /* enable video display again */ - (void) _igsInb (card, 0x3da); - _igsOutb (card, 0x20, 0x3c0); - } - return; - } - else if (reg < IGS_CR + IGS_NCR) - { - map->access = VgaAccessIndIo; - map->port = 0x3d4; - map->addr = 0; - map->value = 1; - map->index = reg - IGS_CR; - } - else if (reg < IGS_DAC + IGS_NDAC) - { - map->access = VgaAccessIo; - map->port = 0x3c6 + reg - IGS_DAC; - } - else if (reg < IGS_DACEX + IGS_NDACEX) - { - VGA8 gr56; - reg = 0x3c6 + reg - IGS_DACEX; - map->access = VgaAccessDone; - _igsOutb (card, 0x56, 0x3ce); - gr56 = _igsInb (card, 0x3cf); - _igsOutb (card, gr56 | 4, 0x3cf); - if (write) - _igsOutb (card, map->value, reg); - else - map->value = _igsInb (card, reg); - _igsOutb (card, gr56, 0x3cf); - return; - } - else switch (reg) { - case IGS_MISC_OUT: - map->access = VgaAccessIo; - if (write) - map->port = 0x3c2; - else - map->port = 0x3cc; - break; - case IGS_INPUT_STATUS_1: - map->access = VgaAccessIo; - map->port = 0x3da; - break; - } - if (card->closure) - { - map->port = map->port + (VGA32) card->closure; - if (map->access == VgaAccessIo) - map->access = VgaAccessMem; - if (map->access == VgaAccessIndIo) - map->access = VgaAccessIndMem; - } -} - -VgaSave igsSaves[] = { - CR00, CR18, - SR01, SR02, - GR11, GRBA, - IGS_MISC_OUT, IGS_MISC_OUT, - VGA_SAVE_END -}; - -void -igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio) -{ - igsvga->card.map = _igsRegMap; - igsvga->card.closure = (void *) mmio; - igsvga->card.max = IGS_NREG; - igsvga->card.values = igsvga->values; - igsvga->card.saves = igsSaves; -} - -void -igsSave (IgsVga *igsvga) -{ - igsSetImm (igsvga, igs_wcrt0, 1); - igsSetImm (igsvga, igs_wcrt1, 1); - igsSetImm (igsvga, igs_rcrts1, 1); - igsSetImm (igsvga, igs_selwk, 1); - VgaPreserve (&igsvga->card); -} - -void -igsReset (IgsVga *igsvga) -{ - VgaRestore (&igsvga->card); - igsSetImm (igsvga, igs_frqlat, 0); - igsSetImm (igsvga, igs_frqlat, 1); - igsSetImm (igsvga, igs_frqlat, 0); - VgaFinish (&igsvga->card); -} - -char * -igsRegName(char *buf, VGA16 reg) -{ - if (reg < IGS_SR + IGS_NSR) - { - sprintf (buf, " SR%02X", reg - IGS_SR); - } - else if (reg < IGS_GR + IGS_NGR) - { - sprintf (buf, " GR%02X", reg - IGS_GR); - } - else if (reg < IGS_GREX + IGS_NGREX) - { - sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE); - } - else if (reg < IGS_AR + IGS_NAR) - { - sprintf (buf, " AR%02X", reg - IGS_AR); - } - else if (reg < IGS_CR + IGS_NCR) - { - sprintf (buf, " CR%02X", reg - IGS_CR); - } - else if (reg < IGS_DAC + IGS_NDAC) - { - sprintf (buf, " DAC%02X", reg - IGS_DAC); - } - else if (reg < IGS_DACEX + IGS_NDACEX) - { - sprintf (buf, "DACX%02X", reg - IGS_DACEX); - } - else switch (reg) { - case IGS_MISC_OUT: - sprintf (buf, "MISC_O"); - break; - case IGS_INPUT_STATUS_1: - sprintf (buf, "IN_S_1"); - break; - } - return buf; -} diff --git a/hw/kdrive/igs/igsreg.h b/hw/kdrive/igs/igsreg.h deleted file mode 100644 index ddccd8907..000000000 --- a/hw/kdrive/igs/igsreg.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * $RCSId: $ - * - * Copyright © 2000 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. - */ - -#ifndef _IGSREG_H_ -#define _IGSREG_H_ - -#include "vga.h" - -#define IGS_SR 0 -#define IGS_NSR 5 -#define IGS_GR (IGS_SR+IGS_NSR) -#define IGS_NGR 0xC0 -#define IGS_GREX (IGS_GR+IGS_NGR) -#define IGS_GREXBASE 0x3c -#define IGS_NGREX 1 -#define IGS_AR (IGS_GREX+IGS_NGREX) -#define IGS_NAR 0x15 -#define IGS_CR (IGS_AR+IGS_NAR) -#define IGS_NCR 0x48 -#define IGS_DAC (IGS_CR+IGS_NCR) -#define IGS_NDAC 4 -#define IGS_DACEX (IGS_DAC+IGS_NDAC) -#define IGS_NDACEX 4 -#define IGS_MISC_OUT (IGS_DACEX + IGS_NDACEX) -#define IGS_INPUT_STATUS_1 (IGS_MISC_OUT+1) -#define IGS_NREG (IGS_INPUT_STATUS_1+1) - -extern VgaReg igs_h_total[]; -extern VgaReg igs_h_de_end[]; -extern VgaReg igs_h_bstart[]; -extern VgaReg igs_h_bend[]; -extern VgaReg igs_de_skew[]; -extern VgaReg igs_ena_vr_access[]; -extern VgaReg igs_h_rstart[]; -extern VgaReg igs_h_rend[]; -extern VgaReg igs_h_rdelay[]; -extern VgaReg igs_v_total[]; -extern VgaReg igs_v_rstart[]; -extern VgaReg igs_v_rend[]; -extern VgaReg igs_clear_v_int[]; -extern VgaReg igs_disable_v_int[]; -extern VgaReg igs_bandwidth[]; -extern VgaReg igs_crt_protect[]; -extern VgaReg igs_v_de_end[]; -extern VgaReg igs_offset[]; -extern VgaReg igs_v_bstart[]; -extern VgaReg igs_v_bend[]; -extern VgaReg igs_linecomp[]; -extern VgaReg igs_ivideo[]; -extern VgaReg igs_num_fetch[]; -extern VgaReg igs_wcrt0[]; -extern VgaReg igs_wcrt1[]; -extern VgaReg igs_rcrts1[]; -extern VgaReg igs_selwk[]; -extern VgaReg igs_dot_clock_8[]; -extern VgaReg igs_screen_off[]; -extern VgaReg igs_enable_write_plane[]; -extern VgaReg igs_mexhsyn[]; -extern VgaReg igs_mexvsyn[]; -extern VgaReg igs_pci_burst_write[]; -extern VgaReg igs_pci_burst_read[]; -extern VgaReg igs_iow_retry[]; -extern VgaReg igs_mw_retry[]; -extern VgaReg igs_mr_retry[]; -extern VgaReg igs_biga22en[]; -extern VgaReg igs_biga24en[]; -extern VgaReg igs_biga22force[]; -extern VgaReg igs_bigswap[]; -#define IGS_BIGSWAP_8 0x3f -#define IGS_BIGSWAP_16 0x2a -#define IGS_BIGSWAP_32 0x00 -extern VgaReg igs_sprite_x[]; -extern VgaReg igs_sprite_preset_x[]; -extern VgaReg igs_sprite_y[]; -extern VgaReg igs_sprite_preset_y[]; -extern VgaReg igs_sprite_visible[]; -extern VgaReg igs_sprite_64x64[]; -extern VgaReg igs_mgrext[]; -extern VgaReg igs_hcshf[]; -extern VgaReg igs_mbpfix[]; -extern VgaReg igs_overscan_red[]; -extern VgaReg igs_overscan_green[]; -extern VgaReg igs_overscan_blue[]; -extern VgaReg igs_memgopg[]; -extern VgaReg igs_memr2wpg[]; -extern VgaReg igs_crtff16[]; -extern VgaReg igs_fifomust[]; -extern VgaReg igs_fifogen[]; -extern VgaReg igs_mode_sel[]; -#define IGS_MODE_TEXT 0 -#define IGS_MODE_8 1 -#define IGS_MODE_565 2 -#define IGS_MODE_5551 6 -#define IGS_MODE_8888 3 -#define IGS_MODE_888 4 -#define IGS_MODE_332 9 -#define IGS_MODE_4444 10 -extern VgaReg igs_sprite_addr[]; -extern VgaReg igs_fastmpie[]; -extern VgaReg igs_vclk_m[]; -extern VgaReg igs_vclk_n[]; -extern VgaReg igs_vfsel[]; -extern VgaReg igs_vclk_p[]; -extern VgaReg igs_frqlat[]; -extern VgaReg igs_dac_mask[]; -extern VgaReg igs_dac_read_index[]; -extern VgaReg igs_dac_write_index[]; -extern VgaReg igs_dac_data[]; -extern VgaReg igs_rampwdn[]; -extern VgaReg igs_dac6_8[]; -extern VgaReg igs_ramdacbypass[]; -extern VgaReg igs_dacpwdn[]; -extern VgaReg igs_cursor_read_index[]; -extern VgaReg igs_cursor_write_index[]; -extern VgaReg igs_cursor_data[]; - -#define igsGet(sv,r) VgaGet(&(sv)->card, (r)) -#define igsGetImm(sv,r) VgaGetImm(&(sv)->card, (r)) -#define igsSet(sv,r,v) VgaSet(&(sv)->card, (r), (v)) -#define igsSetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v)) - -typedef struct _igsVga { - VgaCard card; - VgaValue values[IGS_NREG]; -} IgsVga; - -void -igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio); - -void -igsSave (IgsVga *igsvga); - -void -igsReset (IgsVga *igsvga); - -#endif /* _IGSREG_H_ */ diff --git a/hw/kdrive/igs/igsstub.c b/hw/kdrive/igs/igsstub.c deleted file mode 100644 index 832c9df23..000000000 --- a/hw/kdrive/igs/igsstub.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/igs/igsstub.c,v 1.2 2000/05/24 23:52:48 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "igs.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - CARD32 count; - - count = 0; -#ifdef EMBED - attr.address[0] = 0x10000000; /* Adomo Wing video base address */ - attr.io = 0; - attr.naddr = 1; -#else - while (LinuxFindPci (0x10ea, 0x5000, count, &attr)) -#endif - { - KdCardInfoAdd (&igsFuncs, &attr, 0); - count++; - } -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/ipaq/Imakefile b/hw/kdrive/ipaq/Imakefile deleted file mode 100644 index 9658ea7e5..000000000 --- a/hw/kdrive/ipaq/Imakefile +++ /dev/null @@ -1,13 +0,0 @@ -XCOMM $RCSId: $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = ipaq.c - -OBJS = ipaq.o - -INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/fbdev -I$(KDRIVE)/pcmcia - -NormalLibraryObjectRule() -NormalLibraryTarget(ipaq,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/ipaq/ipaq.c b/hw/kdrive/ipaq/ipaq.c deleted file mode 100644 index fcdfefd82..000000000 --- a/hw/kdrive/ipaq/ipaq.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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. - * - * Adapted from ts300.c by Alan Hourihane <alanh@fairlite.demon.co.uk> - * For the Compaq IPAQ handheld, with the HP VGA Out Card (F1252A). - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/ipaq/ipaq.c,v 1.2 2001/05/29 17:47:55 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "pcmcia.h" - -extern KdCardFuncs pcmciaFuncs; - -void -InitCard (char *name) -{ - KdCardAttr attr; - if (name && !strcmp(name, "pcmcia")) - KdCardInfoAdd (&pcmciaFuncs, &attr, 0); - else - KdCardInfoAdd (&fbdevFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -#ifdef TOUCHSCREEN - KdInitTouchScreen (&TsFuncs); -#endif -} - -extern pcmciaDisplayModeRec pcmciaDefaultModes[]; - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/itsy/Imakefile b/hw/kdrive/itsy/Imakefile deleted file mode 100644 index 1c646af6f..000000000 --- a/hw/kdrive/itsy/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = itsy.c ts.c kbd.c - -OBJS = itsy.o ts.o kbd.o - -INCLUDES = -I. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(itsy,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/itsy/itsy.c b/hw/kdrive/itsy/itsy.c deleted file mode 100644 index ef8ca6dad..000000000 --- a/hw/kdrive/itsy/itsy.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Id: itsy.c,v 1.1 1999/11/02 18:39:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/itsy/itsy.c,v 1.2 1999/12/30 03:03:09 robin Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; -} - -static unsigned short itsyIntensity[16] = { - 0xffff, - 0xffff, - 0xedb6, - 0xdb6d, - 0xc924, - 0xb6db, - 0xa492, - 0x9249, - 0x8000, - 0x6db6, - 0x5b6d, - 0x4924, - 0x36db, - 0x2492, - 0x1249, - 0x0000, -}; - -Bool -itsyCreateColormap (ColormapPtr pmap) -{ - int i; - - for (i = 0; i < 16; i++) - { - pmap->red[i].co.local.red = itsyIntensity[i]; - pmap->red[i].co.local.green = itsyIntensity[i]; - pmap->red[i].co.local.blue = itsyIntensity[i]; - } - return TRUE; -} - -Bool -itsyInitScreen (ScreenPtr pScreen) -{ - pScreen->CreateColormap = itsyCreateColormap; - return TRUE; -} - -void -itsyPreserve (KdCardInfo *card) -{ -} - -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"); -} - -KdCardFuncs itsyFuncs = { - itsyCardInit, /* cardinit */ - itsyScreenInit, /* scrinit */ - itsyInitScreen, /* initScreen */ - itsyPreserve, /* preserve */ - itsyEnable, /* enable */ - itsyDPMS, /* dpms */ - itsyDisable, /* disable */ - itsyRestore, /* restore */ - itsyScreenFini, /* scrfini */ - itsyCardFini, /* cardfini */ - - 0, /* initCursor */ - 0, /* enableCursor */ - 0, /* disableCursor */ - 0, /* finiCursor */ - 0, /* recolorCursor */ - - 0, /* 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); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/itsy/itsy.h b/hw/kdrive/itsy/itsy.h deleted file mode 100644 index 3c1fdd79e..000000000 --- a/hw/kdrive/itsy/itsy.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Id: itsy.h,v 1.1 1999/11/02 18:39:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/itsy/itsy.h,v 1.1 1999/11/19 13:53:53 hohndel Exp $ */ - -#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; diff --git a/hw/kdrive/itsy/kbd.c b/hw/kdrive/itsy/kbd.c deleted file mode 100644 index eec6514e1..000000000 --- a/hw/kdrive/itsy/kbd.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Id: kbd.c,v 1.1 1999/11/02 18:39:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/itsy/kbd.c,v 1.1 1999/11/19 13:53:53 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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, -}; diff --git a/hw/kdrive/itsy/ts.c b/hw/kdrive/itsy/ts.c deleted file mode 100644 index 10efe90c8..000000000 --- a/hw/kdrive/itsy/ts.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Id: ts.c,v 1.1 1999/11/02 18:39:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/itsy/ts.c,v 1.1 1999/11/19 13:53:54 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include "itsy.h" -#include <X11/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 -}; - diff --git a/hw/kdrive/linux/Imakefile b/hw/kdrive/linux/Imakefile deleted file mode 100644 index c4fc2642f..000000000 --- a/hw/kdrive/linux/Imakefile +++ /dev/null @@ -1,25 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.8 2001/10/12 06:33:09 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -#if TouchScreen -#if HasTsLib -TSSRCS = tslib.c -TSOBJS = tslib.o -#else -TSSRCS = ts.c -TSOBJS = ts.o -#endif -#endif - -SRCS = keyboard.c linux.c mouse.c ps2.c bus.c ms.c agp.c $(TSSRCS) - -OBJS = keyboard.o linux.o mouse.o ps2.o bus.o ms.o agp.o $(TSOBJS) - -INCLUDES = -I. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(linux,$(OBJS)) - -DependTarget() diff --git a/hw/kdrive/linux/Makefile.am b/hw/kdrive/linux/Makefile.am deleted file mode 100644 index 1edd7713f..000000000 --- a/hw/kdrive/linux/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - @XSERVER_CFLAGS@ - - -noinst_LIBRARIES = liblinux.a - -if TSLIB -TSLIB_C = tslib.c -endif - -if H3600_TS -TS_C = ts.c -endif - -liblinux_a_SOURCES = \ - agp.c \ - agp.h \ - bus.c \ - keyboard.c \ - klinux.h \ - linux.c \ - mouse.c \ - ms.c \ - ps2.c \ - $(TSLIB_C) \ - $(TS_C) - -liblinux_a_DEPENDENCIES = \ - agp.c \ - bus.c \ - keyboard.c \ - linux.c \ - mouse.c \ - ms.c \ - ps2.c \ - $(TSLIB_C) \ - $(TS_C) - diff --git a/hw/kdrive/linux/agp.c b/hw/kdrive/linux/agp.c deleted file mode 100644 index d401e03a1..000000000 --- a/hw/kdrive/linux/agp.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Abstraction of the AGP GART interface. - * - * This version is for both Linux and FreeBSD. - * - * Copyright © 2000-2001 Nokia Home Communications - * Copyright © 2000 VA Linux Systems, Inc. - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - - */ - -/* $RCSId: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.4 2000/08/28 18:12:56 dawes Exp $ */ - -/* - * Author: Pontus Lidman <pontus.lidman@nokia.com> (adaption to KDrive) and others - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/X.h> - -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/ioctl.h> - -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> - -#include "agp.h" - -#if defined(linux) -#include <asm/ioctl.h> - -#include <linux/agpgart.h> - -#elif defined(__FreeBSD__) -#include <sys/ioctl.h> -#include <sys/agpio.h> -#endif - -#ifndef AGP_DEVICE -#define AGP_DEVICE "/dev/agpgart" -#endif -/* AGP page size is independent of the host page size. */ -#ifndef AGP_PAGE_SIZE -#define AGP_PAGE_SIZE 4096 -#endif -#define AGPGART_MAJOR_VERSION 0 -#define AGPGART_MINOR_VERSION 99 - -static int gartFd = -1; -static int acquiredScreen = -1; - -/* - * Open /dev/agpgart. Keep it open until server exit. - */ - -static Bool -GARTInit(void) -{ - static Bool initDone = FALSE; - struct _agp_info agpinf; - - if (initDone) - return (gartFd != -1); - - initDone = TRUE; - - if (gartFd == -1) - gartFd = open(AGP_DEVICE, O_RDWR, 0); - else - return FALSE; - - if (gartFd == -1) { - fprintf(stderr, "Unable to open " AGP_DEVICE " (%s)\n", - strerror(errno)); - return FALSE; - } - - KdAcquireGART(-1); - /* Check the kernel driver version. */ - if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { - fprintf(stderr, "GARTInit: AGPIOC_INFO failed (%s)\n", - strerror(errno)); - close(gartFd); - gartFd = -1; - return FALSE; - } - KdReleaseGART(-1); - -#if defined(linux) - /* Per Dave Jones, every effort will be made to keep the - * agpgart interface backwards compatible, so allow all - * future versions. - */ - if ( -#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */ - agpinf.version.major < AGPGART_MAJOR_VERSION || -#endif - (agpinf.version.major == AGPGART_MAJOR_VERSION && - agpinf.version.minor < AGPGART_MINOR_VERSION)) { - fprintf(stderr, - "Kernel agpgart driver version is not current" - " (%d.%d vs %d.%d)\n", - agpinf.version.major, agpinf.version.minor, - AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION); - close(gartFd); - gartFd = -1; - return FALSE; - } -#endif - - return TRUE; -} - -Bool -KdAgpGARTSupported() -{ - return GARTInit(); -} - -AgpInfoPtr -KdGetAGPInfo(int screenNum) -{ - struct _agp_info agpinf; - AgpInfoPtr info; - - if (!GARTInit()) - return NULL; - - - if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) { - fprintf(stderr, "Failed to allocate AgpInfo\n"); - return NULL; - } - - if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { - fprintf(stderr, - "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", - strerror(errno)); - return NULL; - } - - info->bridgeId = agpinf.bridge_id; - info->agpMode = agpinf.agp_mode; - info->base = agpinf.aper_base; - info->size = agpinf.aper_size; - info->totalPages = agpinf.pg_total; - info->systemPages = agpinf.pg_system; - info->usedPages = agpinf.pg_used; - - return info; -} - -/* - * XXX If multiple screens can acquire the GART, should we have a reference - * count instead of using acquiredScreen? - */ - -Bool -KdAcquireGART(int screenNum) -{ - if (screenNum != -1 && !GARTInit()) - return FALSE; - - if (screenNum == -1 || acquiredScreen != screenNum) { - if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { - fprintf(stderr, - "AGPIOC_ACQUIRE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = screenNum; - } - - return TRUE; -} - -Bool -KdReleaseGART(int screenNum) -{ - if (screenNum != -1 && !GARTInit()) - return FALSE; - - if (acquiredScreen == screenNum) { - if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { - fprintf(stderr, - "AGPIOC_RELEASE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = -1; - return TRUE; - } - return FALSE; -} - -int -KdAllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical) -{ - struct _agp_allocate alloc; - int pages; - - /* - * Allocates "size" bytes of GART memory (rounds up to the next - * page multiple) or type "type". A handle (key) for the allocated - * memory is returned. On error, the return value is -1. - */ - - if (!GARTInit() || acquiredScreen != screenNum) - return -1; - - pages = (size / AGP_PAGE_SIZE); - if (size % AGP_PAGE_SIZE != 0) - pages++; - - /* XXX check for pages == 0? */ - - alloc.pg_count = pages; - alloc.type = type; - - if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { - fprintf(stderr, "KdAllocateGARTMemory: " - "allocation of %d pages failed\n\t(%s)\n", pages, - strerror(errno)); - return -1; - } - - if (physical) - *physical = alloc.physical; - - return alloc.key; -} - - -/* Bind GART memory with "key" at "offset" */ -Bool -KdBindGARTMemory(int screenNum, int key, unsigned long offset) -{ - struct _agp_bind bind; - int pageOffset; - - if (!GARTInit() || acquiredScreen != screenNum) - return FALSE; - - if (acquiredScreen != screenNum) { - fprintf(stderr, - "AGP not acquired by this screen\n"); - return FALSE; - } - - if (offset % AGP_PAGE_SIZE != 0) { - fprintf(stderr, "KdBindGARTMemory: " - "offset (0x%lx) is not page-aligned (%d)\n", - offset, AGP_PAGE_SIZE); - return FALSE; - } - pageOffset = offset / AGP_PAGE_SIZE; - - bind.pg_start = pageOffset; - bind.key = key; - - if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { - fprintf(stderr, "KdBindGARTMemory: " - "binding of gart memory with key %d\n" - "\tat offset 0x%lx failed (%s)\n", - key, offset, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - -/* Unbind GART memory with "key" */ -Bool -KdUnbindGARTMemory(int screenNum, int key) -{ - struct _agp_unbind unbind; - - if (!GARTInit() || acquiredScreen != screenNum) - return FALSE; - - if (acquiredScreen != screenNum) { - fprintf(stderr, - "AGP not acquired by this screen\n"); - return FALSE; - } - - unbind.priority = 0; - unbind.key = key; - - if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { - fprintf(stderr, "KdUnbindGARTMemory: " - "unbinding of gart memory with key %d " - "failed (%s)\n", key, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - -/* XXX Interface may change. */ -Bool -KdEnableAGP(int screenNum, CARD32 mode) -{ - agp_setup setup; - - if (!GARTInit() || acquiredScreen != screenNum) - return FALSE; - - setup.agp_mode = mode; - if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { - fprintf(stderr, "KdEnableAGP: " - "AGPIOC_SETUP with mode %ld failed (%s)\n", - mode, strerror(errno)); - return FALSE; - } - - return TRUE; -} - diff --git a/hw/kdrive/linux/agp.h b/hw/kdrive/linux/agp.h deleted file mode 100644 index 419dee1b4..000000000 --- a/hw/kdrive/linux/agp.h +++ /dev/null @@ -1,71 +0,0 @@ -/* COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 2000, 2001 Nokia Home Communications - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group */ - -/* agp.h - header file for KDrive AGP GART interface - * - * Author: Pontus Lidman <pontus.lidman@nokia.com> - * - */ - -#ifndef _AGP_H_ -#define _AGP_H_ - -#include <X11/Xdefs.h> -#include <X11/Xmd.h> - -/* These two definitions must be consistent with the kernel's, - but using 1 or 2 in driver code is even uglier */ -#define AGP_DCACHE_MEMORY 1 -#define AGP_PHYS_MEMORY 2 - -typedef struct _AgpInfo { - unsigned long bridgeId; - unsigned long agpMode; - unsigned long base; - unsigned long size; - unsigned long totalPages; - unsigned long systemPages; - unsigned long usedPages; -} AgpInfo, *AgpInfoPtr; - -extern Bool KdAgpGARTSupported(void); -extern AgpInfoPtr KdGetAGPInfo(int screenNum); -extern Bool KdAcquireGART(int screenNum); -extern Bool KdReleaseGART(int screenNum); -extern int KdAllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical); -extern Bool KdBindGARTMemory(int screenNum, int key, unsigned long offset); -extern Bool KdUnbindGARTMemory(int screenNum, int key); -extern Bool KdEnableAGP(int screenNum, CARD32 mode); - -#endif /* _AGP_H_ */ diff --git a/hw/kdrive/linux/bus.c b/hw/kdrive/linux/bus.c deleted file mode 100644 index 15d2ba846..000000000 --- a/hw/kdrive/linux/bus.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/bus.c,v 1.2 2001/06/29 14:00:41 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" - -/* /dev/adbmouse is a busmouse */ - -static void -BusRead (int adbPort, void *closure) -{ - unsigned char buf[3]; - int n; - int dx, dy; - unsigned long flags; - - n = read (adbPort, buf, 3); - if (n == 3) - { - flags = KD_MOUSE_DELTA; - dx = (char) buf[1]; - dy = -(char) buf[2]; - if ((buf[0] & 4) == 0) - flags |= KD_BUTTON_1; - if ((buf[0] & 2) == 0) - flags |= KD_BUTTON_2; - if ((buf[0] & 1) == 0) - flags |= KD_BUTTON_3; - KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy); - } -} - -char *BusNames[] = { - "/dev/adbmouse", - "/dev/mouse", -}; - -#define NUM_BUS_NAMES (sizeof (BusNames) / sizeof (BusNames[0])) - -int BusInputType; - -static int -BusInit (void) -{ - int i; - int busPort; - int n = 0; - - if (!BusInputType) - BusInputType = KdAllocInputType (); - - for (i = 0; i < NUM_BUS_NAMES; i++) - { - busPort = open (BusNames[i], 0); - { - KdRegisterFd (BusInputType, busPort, BusRead, 0); - n++; - } - } - return n; -} - -static void -BusFini (void) -{ - KdUnregisterFds (BusInputType, TRUE); -} - -KdMouseFuncs BusMouseFuncs = { - BusInit, - BusFini -}; diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c deleted file mode 100644 index 97b0683de..000000000 --- a/hw/kdrive/linux/keyboard.c +++ /dev/null @@ -1,487 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.10 2001/11/08 10:26:24 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kkeymap.h" -#include <linux/keyboard.h> -#include <linux/kd.h> -#define XK_PUBLISHING -#include <X11/keysym.h> -#include <termios.h> -#include <sys/ioctl.h> - -extern int LinuxConsoleFd; - -static const KeySym linux_to_x[256] = { - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, XK_Escape, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, - XK_space, XK_exclam, XK_quotedbl, XK_numbersign, - XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, - XK_parenleft, XK_parenright, XK_asterisk, XK_plus, - XK_comma, XK_minus, XK_period, XK_slash, - XK_0, XK_1, XK_2, XK_3, - XK_4, XK_5, XK_6, XK_7, - XK_8, XK_9, XK_colon, XK_semicolon, - XK_less, XK_equal, XK_greater, XK_question, - XK_at, XK_A, XK_B, XK_C, - XK_D, XK_E, XK_F, XK_G, - XK_H, XK_I, XK_J, XK_K, - XK_L, XK_M, XK_N, XK_O, - XK_P, XK_Q, XK_R, XK_S, - XK_T, XK_U, XK_V, XK_W, - XK_X, XK_Y, XK_Z, XK_bracketleft, - XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, - XK_grave, XK_a, XK_b, XK_c, - XK_d, XK_e, XK_f, XK_g, - XK_h, XK_i, XK_j, XK_k, - XK_l, XK_m, XK_n, XK_o, - XK_p, XK_q, XK_r, XK_s, - XK_t, XK_u, XK_v, XK_w, - XK_x, XK_y, XK_z, XK_braceleft, - XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace, - 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_ALTGR), - (1 << KG_ALTGR) | (1 << KG_SHIFT) -}; - -static void -readKernelMapping(void) -{ - KeySym *k; - int i, j; - struct kbentry kbe; - int minKeyCode, maxKeyCode; - int row; - - minKeyCode = NR_KEYS; - maxKeyCode = 0; - row = 0; - for (i = 0; i < NR_KEYS && row < KD_MAX_LENGTH; ++i) - { - kbe.kb_index = i; - - k = kdKeymap + row * KD_MAX_WIDTH; - - for (j = 0; j < KD_MAX_WIDTH; ++j) - { - unsigned short kval; - - k[j] = NoSymbol; - - kbe.kb_table = tbl[j]; - kbe.kb_value = 0; - 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_Mode_switch; - 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; - -#ifdef KT_X - case KT_X: - /* depends on new keyboard symbols in file linux/keyboard.h */ - if(kbe.kb_value == K_XMENU) k[j] = XK_Menu; - if(kbe.kb_value == K_XTELEPHONE) k[j] = XK_telephone; - break; -#endif -#ifdef KT_XF - case KT_XF: - /* special linux keysyms which map directly to XF86 keysyms */ - k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00; - break; -#endif - - 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; - row++; - } - kdMinScanCode = minKeyCode; - kdMaxScanCode = maxKeyCode; -} - -static void -LinuxKeyboardLoad (void) -{ - readKernelMapping (); -} - -static void -LinuxKeyboardRead (int fd, void *closure) -{ - 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++; - } - } -} - -static int LinuxKbdTrans; -static struct termios LinuxTermios; -static int LinuxKbdType; - -static int -LinuxKeyboardEnable (int fd, void *closure) -{ - struct termios nTty; - unsigned char buf[256]; - int n; - - ioctl (fd, KDGKBMODE, &LinuxKbdTrans); - tcgetattr (fd, &LinuxTermios); - - ioctl(fd, 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(fd, TCSANOW, &nTty); - /* - * Flush any pending keystrokes - */ - while ((n = read (fd, buf, sizeof (buf))) > 0) - ; - return fd; -} - -static void -LinuxKeyboardDisable (int fd, void *closure) -{ - ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans); - tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios); -} - -static int -LinuxKeyboardInit (void) -{ - if (!LinuxKbdType) - LinuxKbdType = KdAllocInputType (); - - KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0); - LinuxKeyboardEnable (LinuxConsoleFd, 0); - KdRegisterFdEnableDisable (LinuxConsoleFd, - LinuxKeyboardEnable, - LinuxKeyboardDisable); - return 1; -} - -static void -LinuxKeyboardFini (void) -{ - LinuxKeyboardDisable (LinuxConsoleFd, 0); - KdUnregisterFds (LinuxKbdType, FALSE); -} - -static void -LinuxKeyboardLeds (int leds) -{ - ioctl (LinuxConsoleFd, KDSETLED, leds & 7); -} - -static 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, - LinuxKeyboardLeds, - LinuxKeyboardBell, - LinuxKeyboardFini, - 3, -}; diff --git a/hw/kdrive/linux/klinux.h b/hw/kdrive/linux/klinux.h deleted file mode 100644 index 29ebe3aa9..000000000 --- a/hw/kdrive/linux/klinux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifndef _KLINUX_H_ -#define _KLINUX_H_ - -Bool -LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr); - -unsigned char * -LinuxGetPciCfg(KdCardAttr *attr); - -#endif /* _KLINUX_H_ */ diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c deleted file mode 100644 index 555102925..000000000 --- a/hw/kdrive/linux/linux.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/linux.c,v 1.6 2001/07/24 21:26:17 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "klinux.h" -#include <errno.h> -#include <signal.h> -#include <linux/vt.h> -#include <linux/kd.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <X11/keysym.h> -#include <linux/apm_bios.h> - -static int vtno; -int LinuxConsoleFd; -int LinuxApmFd = -1; -static int activeVT; -static Bool enabled; - -static void -LinuxVTRequest (int sig) -{ - kdSwitchPending = TRUE; -} - -/* Check before chowning -- this avoids touching the file system */ -static 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); -} - -static int -LinuxInit (void) -{ - int fd = -1; - char vtname[11]; - struct vt_stat vts; - - LinuxConsoleFd = -1; - /* check if we're run with euid==0 */ - if (geteuid() != 0) - { - FatalError("LinuxInit: Server must be suid root\n"); - } - - if (kdVirtualTerminal >= 0) - vtno = kdVirtualTerminal; - else - { - 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); - - 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. - */ - memset (&vts, '\0', sizeof (vts)); /* valgrind */ - 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, addr; - int n; - CARD32 ven_dev; - Bool ret = FALSE; - int i; - - ven_dev = (((CARD32) vendor) << 16) | ((CARD32) device); - f = fopen ("/proc/bus/pci/devices", "r"); - if (!f) - return FALSE; - attr->io = 0; - while (fgets (line, sizeof (line)-1, f)) - { - line[sizeof(line)-1] = '\0'; - l = line; - bus = strtoul (l, &end, 16); - if (end == l) - continue; - l = end; - id = strtoul (l, &end, 16); - if (end == l) - continue; - l = end; - if (id != ven_dev) - continue; - if (count--) - continue; - (void) strtoul (l, &end, 16); - if (end == l) - continue; - l = end; - n = 0; - for (i = 0; i < 6; i++) - { - addr = strtoul (l, &end, 16); - if (end == l) - break; - if (addr & 1) - attr->io = addr & ~0xf; - else - { - if (n == KD_MAX_CARD_ADDRESS) - break; - attr->address[n++] = addr & ~0xf; - } - l = end; - } - while (n > 0) - { - if (attr->address[n-1] != 0) - break; - n--; - } - attr->naddr = n; - attr->bus = bus; - ret = TRUE; - break; - } - fclose (f); - return ret; -} - -unsigned char * -LinuxGetPciCfg(KdCardAttr *attr) -{ - char filename[256]; - FILE *f; - unsigned char *cfg; - int r; - - snprintf(filename, 255, "/proc/bus/pci/%02x/%02x.%x", - attr->bus >> 8, (attr->bus & 0xff) >> 3, attr->bus & 7); -/* fprintf(stderr,"Find card on path %s\n",filename); */ - - if (!(f=fopen(filename,"r"))) - return NULL; - - if (!(cfg=xalloc(256))) - { - fclose(f); - return NULL; - } - - if (256 != (r=fread(cfg, 1, 256, f))) - { - fprintf(stderr,"LinuxGetPciCfg: read %d, expected 256\n",r); - free(cfg); - cfg=NULL; - } - fclose(f); -/* fprintf(stderr,"LinuxGetPciCfg: success, returning %p\n",cfg); */ - return cfg; -} - -static void -LinuxSetSwitchMode (int mode) -{ - struct sigaction act; - struct vt_mode VT; - - if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) - { - FatalError ("LinuxInit: VT_GETMODE failed\n"); - } - - if (mode == VT_PROCESS) - { - act.sa_handler = LinuxVTRequest; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; - sigaction (SIGUSR1, &act, 0); - - VT.mode = mode; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - } - else - { - act.sa_handler = SIG_IGN; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; - sigaction (SIGUSR1, &act, 0); - - VT.mode = mode; - VT.relsig = 0; - VT.acqsig = 0; - } - if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) - { - FatalError("LinuxInit: VT_SETMODE failed\n"); - } -} - -static void -LinuxApmBlock (pointer blockData, OSTimePtr pTimeout, pointer pReadmask) -{ -} - -static Bool LinuxApmRunning; - -static void -LinuxApmWakeup (pointer blockData, int result, pointer pReadmask) -{ - fd_set *readmask = (fd_set *) pReadmask; - - if (result > 0 && LinuxApmFd >= 0 && FD_ISSET (LinuxApmFd, readmask)) - { - apm_event_t event; - Bool running = LinuxApmRunning; - int cmd = APM_IOC_SUSPEND; - - while (read (LinuxApmFd, &event, sizeof (event)) == sizeof (event)) - { - switch (event) { - case APM_SYS_STANDBY: - case APM_USER_STANDBY: - running = FALSE; - cmd = APM_IOC_STANDBY; - break; - case APM_SYS_SUSPEND: - case APM_USER_SUSPEND: - case APM_CRITICAL_SUSPEND: - running = FALSE; - cmd = APM_IOC_SUSPEND; - break; - case APM_NORMAL_RESUME: - case APM_CRITICAL_RESUME: - case APM_STANDBY_RESUME: - running = TRUE; - break; - } - } - if (running && !LinuxApmRunning) - { - KdResume (); - LinuxApmRunning = TRUE; - } - else if (!running && LinuxApmRunning) - { - KdSuspend (); - LinuxApmRunning = FALSE; - ioctl (LinuxApmFd, cmd, 0); - } - } -} - -#ifdef FNONBLOCK -#define NOBLOCK FNONBLOCK -#else -#define NOBLOCK FNDELAY -#endif - -static void -LinuxEnable (void) -{ - if (enabled) - return; - if (kdSwitchPending) - { - kdSwitchPending = FALSE; - ioctl (LinuxConsoleFd, VT_RELDISP, VT_ACKACQ); - } - /* - * Open the APM driver - */ - LinuxApmFd = open ("/dev/apm_bios", 2); - if (LinuxApmFd < 0 && errno == ENOENT) - LinuxApmFd = open ("/dev/misc/apm_bios", 2); - if (LinuxApmFd >= 0) - { - LinuxApmRunning = TRUE; - fcntl (LinuxApmFd, F_SETFL, fcntl (LinuxApmFd, F_GETFL) | NOBLOCK); - RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0); - AddEnabledDevice (LinuxApmFd); - } - - /* - * now get the VT - */ - LinuxSetSwitchMode (VT_AUTO); - if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0) - { - FatalError("LinuxInit: VT_ACTIVATE failed\n"); - } - if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0) - { - FatalError("LinuxInit: VT_WAITACTIVE failed\n"); - } - LinuxSetSwitchMode (VT_PROCESS); - if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) - { - FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n"); - } - enabled = TRUE; -} - -static Bool -LinuxSpecialKey (KeySym sym) -{ - struct vt_stat vts; - int con; - - if (XK_F1 <= sym && sym <= XK_F12) - { - con = sym - XK_F1 + 1; - memset (&vts, '\0', sizeof (vts)); /* valgrind */ - ioctl (LinuxConsoleFd, VT_GETSTATE, &vts); - if (con != vts.v_active && (vts.v_state & (1 << con))) - { - ioctl (LinuxConsoleFd, VT_ACTIVATE, con); - return TRUE; - } - } - return FALSE; -} - -static void -LinuxDisable (void) -{ - ioctl(LinuxConsoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ - if (kdSwitchPending) - { - kdSwitchPending = FALSE; - ioctl (LinuxConsoleFd, VT_RELDISP, 1); - } - enabled = FALSE; - if (LinuxApmFd >= 0) - { - RemoveBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0); - RemoveEnabledDevice (LinuxApmFd); - close (LinuxApmFd); - LinuxApmFd = -1; - } -} - -static 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 */ - } - memset (&vts, '\0', sizeof (vts)); /* valgrind */ - 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) - { - memset (&vts, '\0', sizeof (vts)); /* valgrind */ - ioctl (fd, VT_GETSTATE, &vts); - if (ioctl (fd, VT_DISALLOCATE, vtno) < 0) - fprintf (stderr, "Can't deallocate console %d errno %d\n", vtno, errno); - close (fd); - } - return; -} - -KdOsFuncs LinuxFuncs = { - LinuxInit, - LinuxEnable, - LinuxSpecialKey, - LinuxDisable, - LinuxFini, -}; - -void -OsVendorInit (void) -{ - KdOsInit (&LinuxFuncs); -} diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c deleted file mode 100644 index 1faffd27b..000000000 --- a/hw/kdrive/linux/mouse.c +++ /dev/null @@ -1,1011 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/mouse.c,v 1.6 2002/08/02 16:11:35 keithp Exp $ - * - * Copyright © 2001 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <errno.h> -#include <termios.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" - -#undef DEBUG -#undef DEBUG_BYTES -#define KBUFIO_SIZE 256 -#define MOUSE_TIMEOUT 100 - -typedef struct _kbufio { - int fd; - unsigned char buf[KBUFIO_SIZE]; - int avail; - int used; -} Kbufio; - -static Bool -MouseWaitForReadable (int fd, int timeout) -{ - fd_set set; - struct timeval tv, *tp; - int n; - CARD32 done; - - done = GetTimeInMillis () + timeout; - for (;;) - { - FD_ZERO (&set); - FD_SET (fd, &set); - if (timeout == -1) - tp = 0; - else - { - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - tp = &tv; - } - n = select (fd + 1, &set, 0, 0, tp); - if (n > 0) - return TRUE; - if (n < 0 && (errno == EAGAIN || errno == EINTR)) - { - timeout = (int) (done - GetTimeInMillis ()); - if (timeout > 0) - continue; - } - break; - } - return FALSE; -} - -static int -MouseReadByte (Kbufio *b, int timeout) -{ - int n; - if (b->avail <= b->used) - { - if (timeout && !MouseWaitForReadable (b->fd, timeout)) - { -#ifdef DEBUG_BYTES - ErrorF ("\tTimeout %d\n", timeout); -#endif - return -1; - } - n = read (b->fd, b->buf, KBUFIO_SIZE); - if (n <= 0) - return -1; - b->avail = n; - b->used = 0; - } -#ifdef DEBUG_BYTES - ErrorF ("\tget %02x\n", b->buf[b->used]); -#endif - return b->buf[b->used++]; -} - -#if NOTUSED -static int -MouseFlush (Kbufio *b, char *buf, int size) -{ - CARD32 now = GetTimeInMillis (); - CARD32 done = now + 100; - int c; - int n = 0; - - while ((c = MouseReadByte (b, done - now)) != -1) - { - if (buf) - { - if (n == size) - { - memmove (buf, buf + 1, size - 1); - n--; - } - buf[n++] = c; - } - now = GetTimeInMillis (); - if ((INT32) (now - done) >= 0) - break; - } - return n; -} - -static int -MousePeekByte (Kbufio *b, int timeout) -{ - int c; - - c = MouseReadByte (b, timeout); - if (c != -1) - --b->used; - return c; -} -#endif /* NOTUSED */ - -static Bool -MouseWaitForWritable (int fd, int timeout) -{ - fd_set set; - struct timeval tv, *tp; - int n; - - FD_ZERO (&set); - FD_SET (fd, &set); - if (timeout == -1) - tp = 0; - else - { - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - tp = &tv; - } - n = select (fd + 1, 0, &set, 0, tp); - if (n > 0) - return TRUE; - return FALSE; -} - -static Bool -MouseWriteByte (int fd, unsigned char c, int timeout) -{ - int ret; - -#ifdef DEBUG_BYTES - ErrorF ("\tput %02x\n", c); -#endif - for (;;) - { - ret = write (fd, &c, 1); - if (ret == 1) - return TRUE; - if (ret == 0) - return FALSE; - if (errno != EWOULDBLOCK) - return FALSE; - if (!MouseWaitForWritable (fd, timeout)) - return FALSE; - } -} - -static Bool -MouseWriteBytes (int fd, unsigned char *c, int n, int timeout) -{ - while (n--) - if (!MouseWriteByte (fd, *c++, timeout)) - return FALSE; - return TRUE; -} - -#define MAX_MOUSE 10 /* maximum length of mouse protocol */ -#define MAX_SKIP 16 /* number of error bytes before switching */ -#define MAX_VALID 4 /* number of valid packets before accepting */ - -typedef struct _kmouseProt { - char *name; - Bool (*Complete) (KdMouseInfo *mi, unsigned char *ev, int ne); - int (*Valid) (KdMouseInfo *mi, unsigned char *ev, int ne); - Bool (*Parse) (KdMouseInfo *mi, unsigned char *ev, int ne); - Bool (*Init) (KdMouseInfo *mi); - unsigned char headerMask, headerValid; - unsigned char dataMask, dataValid; - Bool tty; - unsigned int c_iflag; - unsigned int c_oflag; - unsigned int c_lflag; - unsigned int c_cflag; - unsigned int speed; - unsigned char *init; - unsigned long state; -} KmouseProt; - -typedef enum _kmouseStage { - MouseBroken, MouseTesting, MouseWorking -} KmouseStage; - -typedef struct _kmouse { - Kbufio iob; - const KmouseProt *prot; - int i_prot; - KmouseStage stage; /* protocol verification stage */ - Bool tty; /* mouse device is a tty */ - int valid; /* sequential valid events */ - int tested; /* bytes scanned during Testing phase */ - int invalid;/* total invalid bytes for this protocol */ - unsigned long state; /* private per protocol, init to prot->state */ -} Kmouse; - -static int mouseValid (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - const KmouseProt *prot = km->prot; - int i; - - for (i = 0; i < ne; i++) - if ((ev[i] & prot->headerMask) == prot->headerValid) - break; - if (i != 0) - return i; - for (i = 1; i < ne; i++) - if ((ev[i] & prot->dataMask) != prot->dataValid) - return -1; - return 0; -} - -static Bool threeComplete (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - return ne == 3; -} - -static Bool fourComplete (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - return ne == 4; -} - -static Bool fiveComplete (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - return ne == 5; -} - -static Bool MouseReasonable (KdMouseInfo *mi, unsigned long flags, int dx, int dy) -{ - Kmouse *km = mi->driver; - - if (km->stage == MouseWorking) - return TRUE; - if (dx < -50 || dx > 50) - { -#ifdef DEBUG - ErrorF ("Large X %d\n", dx); -#endif - return FALSE; - } - if (dy < -50 || dy > 50) - { -#ifdef DEBUG - ErrorF ("Large Y %d\n", dy); -#endif - return FALSE; - } - return TRUE; -} - -/* - * Standard PS/2 mouse protocol - */ -static Bool ps2Parse (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - int dx, dy, dz; - unsigned long flags; - unsigned long flagsrelease = 0; - - flags = KD_MOUSE_DELTA; - if (ev[0] & 4) - flags |= KD_BUTTON_2; - if (ev[0] & 2) - flags |= KD_BUTTON_3; - if (ev[0] & 1) - flags |= KD_BUTTON_1; - - if (ne > 3) - { - dz = (int) (signed char) ev[3]; - if (dz < 0) - { - flags |= KD_BUTTON_4; - flagsrelease = KD_BUTTON_4; - } - else if (dz > 0) - { - flags |= KD_BUTTON_5; - flagsrelease = KD_BUTTON_5; - } - } - - dx = ev[1]; - if (ev[0] & 0x10) - dx -= 256; - dy = ev[2]; - if (ev[0] & 0x20) - dy -= 256; - dy = -dy; - if (!MouseReasonable (mi, flags, dx, dy)) - return FALSE; - if (km->stage == MouseWorking) - { - KdEnqueueMouseEvent (mi, flags, dx, dy); - if (flagsrelease) - { - flags &= ~flagsrelease; - KdEnqueueMouseEvent (mi, flags, dx, dy); - } - } - return TRUE; -} - -static Bool ps2Init (KdMouseInfo *mi); - -static const KmouseProt ps2Prot = { - "ps/2", - threeComplete, mouseValid, ps2Parse, ps2Init, - 0x08, 0x08, 0x00, 0x00, - FALSE -}; - -static const KmouseProt imps2Prot = { - "imps/2", - fourComplete, mouseValid, ps2Parse, ps2Init, - 0x08, 0x08, 0x00, 0x00, - FALSE -}; - -static const KmouseProt exps2Prot = { - "exps/2", - fourComplete, mouseValid, ps2Parse, ps2Init, - 0x08, 0x08, 0x00, 0x00, - FALSE -}; - -/* - * Once the mouse is known to speak ps/2 protocol, go and find out - * what advanced capabilities it has and turn them on - */ - -/* these extracted from FreeBSD 4.3 sys/dev/kbd/atkbdcreg.h */ - -/* aux device commands (sent to KBD_DATA_PORT) */ -#define PSMC_SET_SCALING11 0x00e6 -#define PSMC_SET_SCALING21 0x00e7 -#define PSMC_SET_RESOLUTION 0x00e8 -#define PSMC_SEND_DEV_STATUS 0x00e9 -#define PSMC_SET_STREAM_MODE 0x00ea -#define PSMC_SEND_DEV_DATA 0x00eb -#define PSMC_SET_REMOTE_MODE 0x00f0 -#define PSMC_SEND_DEV_ID 0x00f2 -#define PSMC_SET_SAMPLING_RATE 0x00f3 -#define PSMC_ENABLE_DEV 0x00f4 -#define PSMC_DISABLE_DEV 0x00f5 -#define PSMC_SET_DEFAULTS 0x00f6 -#define PSMC_RESET_DEV 0x00ff - -/* PSMC_SET_RESOLUTION argument */ -#define PSMD_RES_LOW 0 /* typically 25ppi */ -#define PSMD_RES_MEDIUM_LOW 1 /* typically 50ppi */ -#define PSMD_RES_MEDIUM_HIGH 2 /* typically 100ppi (default) */ -#define PSMD_RES_HIGH 3 /* typically 200ppi */ -#define PSMD_MAX_RESOLUTION PSMD_RES_HIGH - -/* PSMC_SET_SAMPLING_RATE */ -#define PSMD_MAX_RATE 255 /* FIXME: not sure if it's possible */ - -/* aux device ID */ -#define PSM_MOUSE_ID 0 -#define PSM_BALLPOINT_ID 2 -#define PSM_INTELLI_ID 3 -#define PSM_EXPLORER_ID 4 -#define PSM_4DMOUSE_ID 6 -#define PSM_4DPLUS_ID 8 - -static unsigned char ps2_init[] = { - PSMC_ENABLE_DEV, - 0, -}; - -#define NINIT_PS2 1 - -static unsigned char wheel_3button_init[] = { - PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 100, - PSMC_SET_SAMPLING_RATE, 80, - PSMC_SEND_DEV_ID, - 0, -}; - -#define NINIT_IMPS2 4 - -static unsigned char wheel_5button_init[] = { - PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 100, - PSMC_SET_SAMPLING_RATE, 80, - PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 80, - PSMC_SEND_DEV_ID, - 0 -}; - -#define NINIT_EXPS2 7 - -static unsigned char intelli_init[] = { - PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 100, - PSMC_SET_SAMPLING_RATE, 80, - 0 -}; - -#define NINIT_INTELLI 3 - -static int -ps2SkipInit (KdMouseInfo *mi, int ninit, Bool ret_next) -{ - Kmouse *km = mi->driver; - int c = -1; - int skipping; - Bool waiting; - - skipping = 0; - waiting = FALSE; - while (ninit || ret_next) - { - c = MouseReadByte (&km->iob, MOUSE_TIMEOUT); - if (c == -1) - break; - /* look for ACK */ - if (c == 0xfa) - { - ninit--; - if (ret_next) - waiting = TRUE; - } - /* look for packet start -- not the response */ - else if ((c & 0x08) == 0x08) - waiting = FALSE; - else if (waiting) - break; - } - return c; -} - -static Bool -ps2Init (KdMouseInfo *mi) -{ - Kmouse *km = mi->driver; - int skipping; - Bool waiting; - int id; - unsigned char *init; - int ninit; - - /* Send Intellimouse initialization sequence */ - MouseWriteBytes (km->iob.fd, intelli_init, strlen (intelli_init), 100); - /* - * Send ID command - */ - if (!MouseWriteByte (km->iob.fd, PSMC_SEND_DEV_ID, 100)) - return FALSE; - skipping = 0; - waiting = FALSE; - id = ps2SkipInit (mi, 0, TRUE); - switch (id) { - case 3: - init = wheel_3button_init; - ninit = NINIT_IMPS2; - km->prot = &imps2Prot; - break; - case 4: - init = wheel_5button_init; - ninit = NINIT_EXPS2; - km->prot = &exps2Prot; - break; - default: - init = ps2_init; - ninit = NINIT_PS2; - km->prot = &ps2Prot; - break; - } - if (init) - MouseWriteBytes (km->iob.fd, init, strlen (init), 100); - /* - * Flush out the available data to eliminate responses to the - * initialization string. Make sure any partial event is - * skipped - */ - (void) ps2SkipInit (mi, ninit, FALSE); - return TRUE; -} - -static Bool busParse (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - int dx, dy; - unsigned long flags; - - flags = KD_MOUSE_DELTA; - dx = (signed char) ev[1]; - dy = -(signed char) ev[2]; - if ((ev[0] & 4) == 0) - flags |= KD_BUTTON_1; - if ((ev[0] & 2) == 0) - flags |= KD_BUTTON_2; - if ((ev[0] & 1) == 0) - flags |= KD_BUTTON_3; - if (!MouseReasonable (mi, flags, dx, dy)) - return FALSE; - if (km->stage == MouseWorking) - KdEnqueueMouseEvent (mi, flags, dx, dy); - return TRUE; -} - -static const KmouseProt busProt = { - "bus", - threeComplete, mouseValid, busParse, 0, - 0xf8, 0x00, 0x00, 0x00, - FALSE -}; - -/* - * Standard MS serial protocol, three bytes - */ - -static Bool msParse (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - int dx, dy; - unsigned long flags; - - flags = KD_MOUSE_DELTA; - - if (ev[0] & 0x20) - flags |= KD_BUTTON_1; - if (ev[0] & 0x10) - flags |= KD_BUTTON_3; - - dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F)); - dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F)); - if (!MouseReasonable (mi, flags, dx, dy)) - return FALSE; - if (km->stage == MouseWorking) - KdEnqueueMouseEvent (mi, flags, dx, dy); - return TRUE; -} - -static const KmouseProt msProt = { - "ms", - threeComplete, mouseValid, msParse, 0, - 0xc0, 0x40, 0xc0, 0x00, - TRUE, - IGNPAR, - 0, - 0, - CS7 | CSTOPB | CREAD | CLOCAL, - B1200, -}; - -/* - * Logitech mice send 3 or 4 bytes, the only way to tell is to look at the - * first byte of a synchronized protocol stream and see if it's got - * any bits turned on that can't occur in that fourth byte - */ -static Bool logiComplete (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - - if ((ev[0] & 0x40) == 0x40) - return ne == 3; - if (km->stage != MouseBroken && (ev[0] & ~0x23) == 0) - return ne == 1; - return FALSE; -} - -static int logiValid (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - const KmouseProt *prot = km->prot; - int i; - - for (i = 0; i < ne; i++) - { - if ((ev[i] & 0x40) == 0x40) - break; - if (km->stage != MouseBroken && (ev[i] & ~0x23) == 0) - break; - } - if (i != 0) - return i; - for (i = 1; i < ne; i++) - if ((ev[i] & prot->dataMask) != prot->dataValid) - return -1; - return 0; -} - -static Bool logiParse (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - int dx, dy; - unsigned long flags; - - flags = KD_MOUSE_DELTA; - - if (ne == 3) - { - if (ev[0] & 0x20) - flags |= KD_BUTTON_1; - if (ev[0] & 0x10) - flags |= KD_BUTTON_3; - - dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F)); - dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F)); - flags |= km->state & KD_BUTTON_2; - } - else - { - if (ev[0] & 0x20) - flags |= KD_BUTTON_2; - dx = 0; - dy = 0; - flags |= km->state & (KD_BUTTON_1|KD_BUTTON_3); - } - - if (!MouseReasonable (mi, flags, dx, dy)) - return FALSE; - if (km->stage == MouseWorking) - KdEnqueueMouseEvent (mi, flags, dx, dy); - return TRUE; -} - -static const KmouseProt logiProt = { - "logitech", - logiComplete, logiValid, logiParse, 0, - 0xc0, 0x40, 0xc0, 0x00, - TRUE, - IGNPAR, - 0, - 0, - CS7 | CSTOPB | CREAD | CLOCAL, - B1200, -}; - -/* - * Mouse systems protocol, 5 bytes - */ -static Bool mscParse (KdMouseInfo *mi, unsigned char *ev, int ne) -{ - Kmouse *km = mi->driver; - int dx, dy; - unsigned long flags; - - flags = KD_MOUSE_DELTA; - - if (!(ev[0] & 0x4)) - flags |= KD_BUTTON_1; - if (!(ev[0] & 0x2)) - flags |= KD_BUTTON_2; - if (!(ev[0] & 0x1)) - flags |= KD_BUTTON_3; - dx = (signed char)(ev[1]) + (signed char)(ev[3]); - dy = - ((signed char)(ev[2]) + (signed char)(ev[4])); - - if (!MouseReasonable (mi, flags, dx, dy)) - return FALSE; - if (km->stage == MouseWorking) - KdEnqueueMouseEvent (mi, flags, dx, dy); - return TRUE; -} - -static const KmouseProt mscProt = { - "msc", - fiveComplete, mouseValid, mscParse, 0, - 0xf8, 0x80, 0x00, 0x00, - TRUE, - IGNPAR, - 0, - 0, - CS8 | CSTOPB | CREAD | CLOCAL, - B1200, -}; - -/* - * Use logitech before ms -- they're the same except that - * logitech sometimes has a fourth byte - */ -static const KmouseProt *kmouseProts[] = { - &ps2Prot, &imps2Prot, &exps2Prot, &busProt, &logiProt, &msProt, &mscProt, -}; - -#define NUM_PROT (sizeof (kmouseProts) / sizeof (kmouseProts[0])) - -static void -MouseInitProtocol (Kmouse *km) -{ - int ret; - struct termios t; - - if (km->prot->tty) - { - ret = tcgetattr (km->iob.fd, &t); - - if (ret >= 0) - { - t.c_iflag = km->prot->c_iflag; - t.c_oflag = km->prot->c_oflag; - t.c_lflag = km->prot->c_lflag; - t.c_cflag = km->prot->c_cflag; - cfsetispeed (&t, km->prot->speed); - cfsetospeed (&t, km->prot->speed); - ret = tcsetattr (km->iob.fd, TCSANOW, &t); - } - } - km->stage = MouseBroken; - km->valid = 0; - km->tested = 0; - km->invalid = 0; - km->state = km->prot->state; -} - -static void -MouseFirstProtocol (Kmouse *km, char *prot) -{ - if (prot) - { - for (km->i_prot = 0; km->i_prot < NUM_PROT; km->i_prot++) - if (!strcmp (prot, kmouseProts[km->i_prot]->name)) - break; - if (km->i_prot == NUM_PROT) - { - int i; - ErrorF ("Unknown mouse protocol \"%s\". Pick one of:", prot); - for (i = 0; i < NUM_PROT; i++) - ErrorF (" %s", kmouseProts[i]->name); - ErrorF ("\n"); - } - else - { - km->prot = kmouseProts[km->i_prot]; - if (km->tty && !km->prot->tty) - ErrorF ("Mouse device is serial port, protocol %s is not serial protocol\n", - prot); - else if (!km->tty && km->prot->tty) - ErrorF ("Mouse device is not serial port, protocol %s is serial protocol\n", - prot); - } - } - if (!km->prot) - { - for (km->i_prot = 0; kmouseProts[km->i_prot]->tty != km->tty; km->i_prot++) - ; - km->prot = kmouseProts[km->i_prot]; - } - MouseInitProtocol (km); -} - -static void -MouseNextProtocol (Kmouse *km) -{ - do - { - if (!km->prot) - km->i_prot = 0; - else - if (++km->i_prot == NUM_PROT) km->i_prot = 0; - km->prot = kmouseProts[km->i_prot]; - } while (km->prot->tty != km->tty); - MouseInitProtocol (km); - ErrorF ("Switching to mouse protocol \"%s\"\n", km->prot->name); -} - -static void -MouseRead (int mousePort, void *closure) -{ - KdMouseInfo *mi = closure; - Kmouse *km = mi->driver; - unsigned char event[MAX_MOUSE]; - int ne; - int c; - int i; - int timeout; - - timeout = 0; - ne = 0; - for(;;) - { - c = MouseReadByte (&km->iob, timeout); - if (c == -1) - { - if (ne) - { - km->invalid += ne + km->tested; - km->valid = 0; - km->tested = 0; - km->stage = MouseBroken; - } - break; - } - event[ne++] = c; - i = (*km->prot->Valid) (mi, event, ne); - if (i != 0) - { -#ifdef DEBUG - ErrorF ("Mouse protocol %s broken %d of %d bytes bad\n", - km->prot->name, i > 0 ? i : ne, ne); -#endif - if (i > 0 && i < ne) - { - ne -= i; - memmove (event, event + i, ne); - } - else - { - i = ne; - ne = 0; - } - km->invalid += i + km->tested; - km->valid = 0; - km->tested = 0; - km->stage = MouseBroken; - if (km->invalid > MAX_SKIP) - { - MouseNextProtocol (km); - ne = 0; - } - timeout = 0; - } - else - { - if ((*km->prot->Complete) (mi, event, ne)) - { - if ((*km->prot->Parse) (mi, event, ne)) - { - switch (km->stage) - { - case MouseBroken: -#ifdef DEBUG - ErrorF ("Mouse protocol %s seems OK\n", - km->prot->name); -#endif - /* do not zero invalid to accumulate invalid bytes */ - km->valid = 0; - km->tested = 0; - km->stage = MouseTesting; - /* fall through ... */ - case MouseTesting: - km->valid++; - km->tested += ne; - if (km->valid > MAX_VALID) - { -#ifdef DEBUG - ErrorF ("Mouse protocol %s working\n", - km->prot->name); -#endif - km->stage = MouseWorking; - km->invalid = 0; - km->tested = 0; - km->valid = 0; - if (km->prot->Init && !(*km->prot->Init) (mi)) - km->stage = MouseBroken; - } - break; - case MouseWorking: - break; - } - } - else - { - km->invalid += ne + km->tested; - km->valid = 0; - km->tested = 0; - km->stage = MouseBroken; - } - ne = 0; - timeout = 0; - } - else - timeout = MOUSE_TIMEOUT; - } - } -} - -int MouseInputType; - -char *kdefaultMouse[] = { - "/dev/mouse", - "/dev/psaux", - "/dev/input/mice", - "/dev/adbmouse", - "/dev/ttyS0", - "/dev/ttyS1", -}; - -#define NUM_DEFAULT_MOUSE (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0])) - -static Bool -MouseInit (void) -{ - int i; - int fd; - Kmouse *km; - KdMouseInfo *mi, *next; - int n = 0; - char *prot; - - if (!MouseInputType) - MouseInputType = KdAllocInputType (); - - for (mi = kdMouseInfo; mi; mi = next) - { - next = mi->next; - prot = mi->prot; - if (mi->inputType) - continue; - if (!mi->name) - { - for (i = 0; i < NUM_DEFAULT_MOUSE; i++) - { - fd = open (kdefaultMouse[i], 2); - if (fd >= 0) - { - mi->name = KdSaveString (kdefaultMouse[i]); - break; - } - } - } - else - fd = open (mi->name, 2); - - if (fd >= 0) - { - km = (Kmouse *) xalloc (sizeof (Kmouse)); - if (km) - { - km->iob.fd = fd; - km->iob.avail = km->iob.used = 0; - km->prot = 0; - km->i_prot = 0; - km->tty = isatty (fd); - mi->driver = km; - mi->inputType = MouseInputType; - MouseFirstProtocol (km, mi->prot); - if (KdRegisterFd (MouseInputType, fd, MouseRead, (void *) mi)) - n++; - } - else - close (fd); - } - } - return TRUE; -} - -static void -MouseFini (void) -{ - KdMouseInfo *mi; - - KdUnregisterFds (MouseInputType, TRUE); - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->inputType == MouseInputType) - { - xfree (mi->driver); - mi->driver = 0; - mi->inputType = 0; - } - } -} - -KdMouseFuncs LinuxMouseFuncs = { - MouseInit, - MouseFini, -}; diff --git a/hw/kdrive/linux/ms.c b/hw/kdrive/linux/ms.c deleted file mode 100644 index b29f6527b..000000000 --- a/hw/kdrive/linux/ms.c +++ /dev/null @@ -1,163 +0,0 @@ -/* -Copyright (c) 2001 by Juliusz Chroboczek -Copyright (c) 1999 by Keith Packard - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/linux/ms.c,v 1.1 2001/08/09 20:45:15 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <errno.h> -#include <termios.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" - -static int -MsReadBytes (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; -} - -static void -MsRead (int port, void *closure) -{ - unsigned char buf[3 * 200]; - unsigned char *b; - int n; - int dx, dy; - unsigned long flags; - - while ((n = MsReadBytes (port, buf, sizeof (buf), 3)) > 0) - { - b = buf; - while (n >= 3) - { - flags = KD_MOUSE_DELTA; - - if (b[0] & 0x20) - flags |= KD_BUTTON_1; - if (b[0] & 0x10) - flags |= KD_BUTTON_3; - - dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3F)); - dy = (char)(((b[0] & 0x0C) << 4) | (b[2] & 0x3F)); - n -= 3; - b += 3; - KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy); - } - } -} - -int MsInputType; - -static int -MsInit (void) -{ - int port; - char *device = "/dev/mouse"; - struct termios t; - int ret; - - if (!MsInputType) - MsInputType = KdAllocInputType (); - port = open (device, O_RDWR | O_NONBLOCK); - if(port < 0) { - ErrorF("Couldn't open %s (%d)\n", device, (int)errno); - return 0; - } else if (port == 0) { - ErrorF("Opening %s returned 0! Please complain to Keith.\n", - device); - goto bail; - } - - if(!isatty(port)) { - ErrorF("%s is not a tty\n", device); - goto bail; - } - - ret = tcgetattr(port, &t); - if(ret < 0) { - ErrorF("Couldn't tcgetattr(%s): %d\n", device, errno); - goto bail; - } - t.c_iflag &= ~ (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | - IGNCR | ICRNL | IXON | IXOFF); - t.c_oflag &= ~ OPOST; - t.c_lflag &= ~ (ECHO | ECHONL | ICANON | ISIG | IEXTEN); - t.c_cflag &= ~ (CSIZE | PARENB); - t.c_cflag |= CS8 | CLOCAL | CSTOPB; - - cfsetispeed (&t, B1200); - cfsetospeed (&t, B1200); - t.c_cc[VMIN] = 1; - t.c_cc[VTIME] = 0; - ret = tcsetattr(port, TCSANOW, &t); - if(ret < 0) { - ErrorF("Couldn't tcsetattr(%s): %d\n", device, errno); - goto bail; - } - if (KdRegisterFd (MsInputType, port, MsRead, (void *) 0)) - return 1; - - bail: - close(port); - return 0; -} - -static void -MsFini (void) -{ - KdUnregisterFds (MsInputType, TRUE); -} - -KdMouseFuncs MsMouseFuncs = { - MsInit, - MsFini -}; diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c deleted file mode 100644 index da3372011..000000000 --- a/hw/kdrive/linux/ps2.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/ps2.c,v 1.6 2001/10/12 06:33:10 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" - -static 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; -} - -char *Ps2Names[] = { - "/dev/psaux", -/* "/dev/mouse", */ - "/dev/input/mice", -}; - -#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0])) - -static void -Ps2Read (int ps2Port, void *closure) -{ - unsigned char buf[3 * 200]; - unsigned char *b; - int n; - int dx, dy; - unsigned long flags; - unsigned long left_button = KD_BUTTON_1; - unsigned long right_button = KD_BUTTON_3; - -#undef SWAP_USB -#ifdef SWAP_USB - if (id == 2) - { - left_button = KD_BUTTON_3; - right_button = KD_BUTTON_1; - } -#endif - 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 |= right_button; - if (b[0] & 1) - flags |= left_button; - - 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 (kdMouseInfo, flags, dx, dy); - } - } -} - -int Ps2InputType; - -static int -Ps2Init (void) -{ - int i; - int ps2Port; - int n; - - if (!Ps2InputType) - Ps2InputType = KdAllocInputType (); - n = 0; - for (i = 0; i < NUM_PS2_NAMES; i++) - { - ps2Port = open (Ps2Names[i], 0); - if (ps2Port >= 0) - { - if (KdRegisterFd (Ps2InputType, ps2Port, Ps2Read, (void *) i)) - n++; - } - } - return n; -} - -static void -Ps2Fini (void) -{ - KdUnregisterFds (Ps2InputType, TRUE); -} - -KdMouseFuncs Ps2MouseFuncs = { - Ps2Init, - Ps2Fini -}; diff --git a/hw/kdrive/linux/ts.c b/hw/kdrive/linux/ts.c deleted file mode 100644 index 9051c0d61..000000000 --- a/hw/kdrive/linux/ts.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.9 2002/08/15 18:07:48 keithp Exp $ - * - * Derived from ps2.c by Jim Gettys - * - * Copyright © 1999 Keith Packard - * Copyright © 2000 Compaq Computer Corporation - * - * 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 or Compaq not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard and Compaq makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD AND COMPAQ DISCLAIM 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" -#include <sys/ioctl.h> -#include <linux/h3600_ts.h> /* touch screen events */ - -static long lastx = 0, lasty = 0; - -int KdTsPhyScreen = 0; - -static int -TsReadBytes (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; -} - -static void -TsRead (int tsPort, void *closure) -{ - KdMouseInfo *mi = closure; - TS_EVENT event; - int n; - long x, y; - unsigned long flags; - - n = TsReadBytes (tsPort, (char *) &event, sizeof (event), sizeof (event)); - if (n == sizeof (event)) - { - if (event.pressure) - { - /* - * HACK ATTACK. (static global variables used !) - * Here we test for the touch screen driver actually being on the - * touch screen, if it is we send absolute coordinates. If not, - * then we send delta's so that we can track the entire vga screen. - */ - if (KdCurScreen == KdTsPhyScreen) { - flags = KD_BUTTON_1; - x = event.x; - y = event.y; - } - else - { - flags = /* KD_BUTTON_1 |*/ KD_MOUSE_DELTA; - if ((lastx == 0) || (lasty == 0)) { - x = 0; - y = 0; - } else { - x = event.x - lastx; - y = event.y - lasty; - } - lastx = event.x; - lasty = event.y; - } - } else { - flags = KD_MOUSE_DELTA; - x = 0; - y = 0; - lastx = 0; - lasty = 0; - } - KdEnqueueMouseEvent (mi, flags, x, y); - } -} - -char *TsNames[] = { - "/dev/ts", - "/dev/h3600_ts" /* temporary name; note this code can try - to open more than one device */ -}; - -#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0])) - -int TsInputType; - -static int -TsEnable (int fd, void *closure) -{ - KdMouseInfo *mi = (KdMouseInfo *)closure; - - return open (mi->name, 0); -} - -static void -TsDisable (int fd, void *closure) -{ - close (fd); -} - -static int -TsInit (void) -{ - int i; - int fd; - KdMouseInfo *mi, *next; - int n = 0; - - if (!TsInputType) - TsInputType = KdAllocInputType (); - - for (mi = kdMouseInfo; mi; mi = next) - { - next = mi->next; - if (mi->inputType) - continue; - if (!mi->name) - { - for (i = 0; i < NUM_TS_NAMES; i++) - { - fd = open (TsNames[i], 0); - if (fd >= 0) - { - mi->name = KdSaveString (TsNames[i]); - break; - } - } - } - else - fd = open (mi->name, 0); - if (fd >= 0) - { - struct h3600_ts_calibration cal; - /* - * Check to see if this is a touch screen - */ - if (ioctl (fd, TS_GET_CAL, &cal) != -1) - { - mi->driver = (void *) fd; - mi->inputType = TsInputType; - if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi)) - { - /* Set callbacks for vt switches etc */ - KdRegisterFdEnableDisable (fd, TsEnable, TsDisable); - - n++; - } - } - else - close (fd); - } - } - - return 0; -} - -static void -TsFini (void) -{ - KdMouseInfo *mi; - - KdUnregisterFds (TsInputType, TRUE); - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->inputType == TsInputType) - { - mi->driver = 0; - mi->inputType = 0; - } - } -} - -KdMouseFuncs TsFuncs = { - TsInit, - TsFini -}; diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c deleted file mode 100644 index 7d8bfdf84..000000000 --- a/hw/kdrive/linux/tslib.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/linux/tslib.c,v 1.1 2002/11/01 22:27:49 keithp Exp $ - * TSLIB based touchscreen driver for TinyX - * Derived from ts.c by Keith Packard - * Derived from ps2.c by Jim Gettys - * - * Copyright © 1999 Keith Packard - * Copyright © 2000 Compaq Computer Corporation - * Copyright © 2002 MontaVista Software 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 Keith Packard or Compaq not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard and Compaq makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD AND COMPAQ DISCLAIM 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. - * - * 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 Michael Taht or MontaVista not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Michael Taht and Montavista make no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * MICHAEL TAHT AND MONTAVISTA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL EITHER 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. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" -#include <sys/ioctl.h> -#include <tslib.h> - -static long lastx = 0, lasty = 0; -static struct tsdev *tsDev = NULL; - -/* extern int TSLibWantRawData; */ - -int KdTsPhyScreen = 0; - -static void -TsRead (int tsPort, void *closure) -{ - KdMouseInfo *mi = closure; - struct ts_sample event; - int n; - long x, y; - unsigned long flags; - - /* - if (TSLibWantRawData) - n = ts_read_raw(tsDev, &event, 1); - else - */ - - n = ts_read(tsDev, &event, 1); - - if (n == 1) - { - if (event.pressure) - { - /* - * HACK ATTACK. (static global variables used !) - * Here we test for the touch screen driver actually being on the - * touch screen, if it is we send absolute coordinates. If not, - * then we send delta's so that we can track the entire vga screen. - */ - if (KdCurScreen == KdTsPhyScreen) { - flags = KD_BUTTON_1; - x = event.x; - y = event.y; - } else { - flags = /* KD_BUTTON_1 |*/ KD_MOUSE_DELTA; - if ((lastx == 0) || (lasty == 0)) { - x = 0; - y = 0; - } else { - x = event.x - lastx; - y = event.y - lasty; - } - lastx = event.x; - lasty = event.y; - } - } else { - flags = KD_MOUSE_DELTA; - x = 0; - y = 0; - lastx = 0; - lasty = 0; - } - - KdEnqueueMouseEvent (mi, flags, x, y); - } -} - -static char *TsNames[] = { - NULL, - "/dev/ts", - "/dev/touchscreen/0", -}; - -#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0])) - -int TsInputType; - -static int -TslibEnable (int not_needed_fd, void *closure) -{ - KdMouseInfo *mi = closure; - int fd = 0; - - fprintf(stderr, "%s() called\n", __func__); - - if(!(tsDev = ts_open(mi->name, 0))) { - fprintf(stderr, "%s() failed to open %s\n", __func__, mi->name ); - return -1; /* XXX Not sure what to return here */ - } - - ts_config(tsDev); - fd=ts_fd(tsDev); - - return fd; -} - -static void -TslibDisable (int fd, void *closure) -{ - ts_close(tsDev); -} - -static int -TslibInit (void) -{ - int i, j = 0; - KdMouseInfo *mi, *next; - int fd= 0; - int n = 0; - - if (!TsInputType) - TsInputType = KdAllocInputType (); - - for (mi = kdMouseInfo; mi; mi = next) - { - next = mi->next; - if (mi->inputType) - continue; - - /* Check for tslib env var device setting */ - if ((TsNames[0] = getenv("TSLIB_TSDEVICE")) == NULL) - j++; - - if (!mi->name) - { - for (i = j; i < NUM_TS_NAMES; i++) - { - - /* XXX Should check for */ - - if(!(tsDev = ts_open(TsNames[i],0))) continue; - ts_config(tsDev); - fd=ts_fd(tsDev); - if (fd >= 0) - { - mi->name = KdSaveString (TsNames[i]); - break; - } - } - } else { - - if(!(tsDev = ts_open(mi->name,0))) - continue; - ts_config(tsDev); - fd=ts_fd(tsDev); - - } - - if (fd > 0 && tsDev != 0) - { - mi->driver = (void *) fd; - mi->inputType = TsInputType; - if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi)) - n++; - - /* Set callbacks for vt switches etc */ - KdRegisterFdEnableDisable (fd, TslibEnable, TslibDisable); - - } - else - { - fprintf(stderr, "%s() failed to open tslib\n", __func__); - if (fd > 0) close(fd); - } - - - } - - return n; -} - -static void -TslibFini (void) -{ - KdMouseInfo *mi; - - KdUnregisterFds (TsInputType, TRUE); - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->inputType == TsInputType) - { - if(mi->driver) ts_close(tsDev); - mi->driver = 0; - mi->inputType = 0; - } - } -} - -KdMouseFuncs TsFuncs = { - TslibInit, - TslibFini -}; diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am deleted file mode 100644 index 47202971a..000000000 --- a/hw/kdrive/mach64/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xmach64 - -if TSLIB -TSLIB_FLAG = -lts -endif - - -noinst_LIBRARIES = libmach64.a - -libmach64_a_SOURCES = \ - mach64.c \ - mach64draw.c \ - mach64video.c \ - fourcc.h \ - mach64.h \ - mach64draw.h - -Xmach64_SOURCES = \ - mach64stub.c - -MACH64_LIBS = \ - libmach64.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a - - -Xmach64_LDADD = \ - $(MACH64_LIBS) \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - - -Xmach64_DEPENDENCIES = $(MACH64_LIBS) @KDRIVE_LIBS@ diff --git a/hw/kdrive/mach64/fourcc.h b/hw/kdrive/mach64/fourcc.h deleted file mode 100644 index b19f5decc..000000000 --- a/hw/kdrive/mach64/fourcc.h +++ /dev/null @@ -1,134 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.4 2003/04/23 21:51:24 tsi Exp $ */ - -/* - This header file contains listings of STANDARD guids for video formats. - Please do not place non-registered, or incomplete entries in this file. - A list of some popular fourcc's are at: http://www.webartz.com/fourcc/ - For an explanation of fourcc <-> guid mappings see RFC2361. -*/ - -#ifndef _XF86_FOURCC_H_ -#define _XF86_FOURCC_H_ 1 - -#define FOURCC_YUY2 0x32595559 -#define XVIMAGE_YUY2 \ - { \ - FOURCC_YUY2, \ - XvYUV, \ - LSBFirst, \ - {'Y','U','Y','2', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 1, 1, \ - {'Y','U','Y','V', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_YV12 0x32315659 -#define XVIMAGE_YV12 \ - { \ - FOURCC_YV12, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','1','2', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 12, \ - XvPlanar, \ - 3, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 2, 2, \ - {'Y','V','U', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_I420 0x30323449 -#define XVIMAGE_I420 \ - { \ - FOURCC_I420, \ - XvYUV, \ - LSBFirst, \ - {'I','4','2','0', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 12, \ - XvPlanar, \ - 3, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 2, 2, \ - {'Y','U','V', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - - -#define FOURCC_UYVY 0x59565955 -#define XVIMAGE_UYVY \ - { \ - FOURCC_UYVY, \ - XvYUV, \ - LSBFirst, \ - {'U','Y','V','Y', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 1, 1, \ - {'U','Y','V','Y', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_IA44 0x34344149 -#define XVIMAGE_IA44 \ - { \ - FOURCC_IA44, \ - XvYUV, \ - LSBFirst, \ - {'I','A','4','4', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 8, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 1, 1, \ - 1, 1, 1, \ - {'A','I', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_AI44 0x34344941 -#define XVIMAGE_AI44 \ - { \ - FOURCC_AI44, \ - XvYUV, \ - LSBFirst, \ - {'A','I','4','4', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 8, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 1, 1, \ - 1, 1, 1, \ - {'I','A', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#endif /* _XF86_FOURCC_H_ */ diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c deleted file mode 100644 index 3d24045da..000000000 --- a/hw/kdrive/mach64/mach64.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright © 2001 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.10 2002/10/14 18:01:41 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" -#include <sys/io.h> - -static Bool -mach64CardInit (KdCardInfo *card) -{ - Mach64CardInfo *mach64c; - - mach64c = (Mach64CardInfo *) xalloc (sizeof (Mach64CardInfo)); - if (!mach64c) - return FALSE; - - (void) mach64MapReg (card, mach64c); - mach64c->lcdEnabled = FALSE; - - if (!vesaInitialize (card, &mach64c->vesa)) - { - xfree (mach64c); - return FALSE; - } - - card->driver = mach64c; - - return TRUE; -} - -static Bool -mach64ScreenInit (KdScreenInfo *screen) -{ - Mach64CardInfo *mach64c = screen->card->driver; - Mach64ScreenInfo *mach64s; - - mach64s = (Mach64ScreenInfo *) xalloc (sizeof (Mach64ScreenInfo)); - if (!mach64s) - return FALSE; - memset (mach64s, '\0', sizeof (Mach64ScreenInfo)); - if (!vesaScreenInitialize (screen, &mach64s->vesa)) - { - xfree (mach64s); - return FALSE; - } - if (!mach64c->reg) - screen->dumb = TRUE; - if (mach64s->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - switch (screen->fb[0].depth) { - case 8: - mach64s->colorKey = 0xff; - break; - case 15: - case 16: - mach64s->colorKey = 0x001e; - break; - case 24: - mach64s->colorKey = 0x0000fe; - break; - default: - mach64s->colorKey = 1; - break; - } - screen->driver = mach64s; - return TRUE; -} - -static Bool -mach64InitScreen (ScreenPtr pScreen) -{ -#ifdef XV - mach64InitVideo(pScreen); -#endif - return vesaInitScreen (pScreen); -} - -#ifdef RANDR -static Bool -mach64RandRSetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - KdCheckSync (pScreen); - - if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize)) - return FALSE; - - return TRUE; -} - -static void -mach64RandRInit (ScreenPtr pScreen) -{ - rrScrPriv(pScreen); - - pScrPriv->rrSetConfig = mach64RandRSetConfig; -} -#endif - -static Bool -mach64FinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - ret = vesaFinishInitScreen (pScreen); -#ifdef RANDR - mach64RandRInit (pScreen); -#endif - return ret; -} - -static Bool -mach64CreateResources (ScreenPtr pScreen) -{ - return vesaCreateResources (pScreen); -} - -CARD32 -mach64ReadLCD (Reg *reg, int id) -{ - CARD32 LCD_INDEX; - - LCD_INDEX = reg->LCD_INDEX & ~(0x3f); - reg->LCD_INDEX = (LCD_INDEX | id); - return reg->LCD_DATA; -} - -void -mach64WriteLCD (Reg *reg, int id, CARD32 data) -{ - CARD32 LCD_INDEX; - - LCD_INDEX = reg->LCD_INDEX & ~(0x3f); - reg->LCD_INDEX = (LCD_INDEX | id); - reg->LCD_DATA = data; -} - -void -mach64Preserve (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - Reg *reg = mach64c->reg; - - vesaPreserve(card); - if (reg) - { - mach64c->save.LCD_GEN_CTRL = mach64ReadLCD (reg, 1); - } -} - -Bool -mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card)); - - if (!mach64c->reg_base) - { - mach64c->reg = 0; - mach64c->media_reg = 0; - return FALSE; - } - - KdSetMappedMode (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card)); - mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card)); - return TRUE; -} - -void -mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - if (mach64c->reg_base) - { - KdResetMappedMode (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card)); - mach64c->reg_base = 0; - mach64c->reg = 0; - mach64c->media_reg = 0; - } -} - -void -mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - if (!mach64c->reg_base) - mach64MapReg (card, mach64c); - if (mach64c->reg) - { - if (mach64c->reg->GUI_STAT == 0xffffffff) - FatalError ("Mach64 REG not visible\n"); - } -} - -void -mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - mach64UnmapReg (card, mach64c); -} - -Bool -mach64Enable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - - mach64SetMMIO (pScreenPriv->card, mach64c); - mach64DPMS (pScreen, KD_DPMS_NORMAL); -#ifdef XV - KdXVEnable (pScreen); -#endif - return TRUE; -} - -void -mach64Disable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - -#ifdef XV - KdXVDisable (pScreen); -#endif - mach64ResetMMIO (pScreenPriv->card, mach64c); - vesaDisable (pScreen); -} - -const CARD8 mach64DPMSModes[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 */ -}; - -#define PWR_MGT_ON (1 << 0) -#define PWR_MGT_MODE (3 << 1) -#define PWR_MGT_MODE_PIN (0 << 1) -#define PWR_MGT_MODE_REG (1 << 1) -#define PWR_MGT_MODE_TIMER (2 << 1) -#define PWR_MGR_MODE_PCI (3 << 1) -#define AUTO_PWRUP_EN (1 << 3) -#define ACTIVITY_PIN_ON (1 << 4) -#define STANDBY_POL (1 << 5) -#define SUSPEND_POL (1 << 6) -#define SELF_REFRESH (1 << 7) -#define ACTIVITY_PIN_EN (1 << 8) -#define KEYBD_SNOOP (1 << 9) -#define DONT_USE_F32KHZ (1 << 10) -#define TRISTATE_MEM_EN (1 << 11) -#define LCDENG_TEST_MODE (0xf << 12) -#define STANDBY_COUNT (0xf << 16) -#define SUSPEND_COUNT (0xf << 20) -#define BIASON (1 << 24) -#define BLON (1 << 25) -#define DIGON (1 << 26) -#define PM_D3_RST_ENB (1 << 27) -#define STANDBY_NOW (1 << 28) -#define SUSPEND_NOW (1 << 29) -#define PWR_MGT_STATUS (3 << 30) -#define PWR_MGT_STATUS_ON (0 << 30) -#define PWR_MGT_STATUS_STANDBY (1 << 30) -#define PWR_MGT_STATUS_SUSPEND (2 << 30) -#define PWR_MGT_STATUS_TRANSITION (3 << 30) - -Bool -mach64DPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - int hsync_off = 0, vsync_off = 0, blank = 0; - CARD32 CRTC_GEN_CNTL; - CARD32 LCD_GEN_CTRL; - Reg *reg = mach64c->reg; - - if (!reg) - return FALSE; - - CRTC_GEN_CNTL = reg->CRTC_GEN_CNTL; - LCD_GEN_CTRL = mach64ReadLCD (reg, 1); - - switch (mode) { - case KD_DPMS_NORMAL: - hsync_off = 0; - vsync_off = 0; - blank = 0; - break; - case KD_DPMS_STANDBY: - hsync_off = 1; - vsync_off = 0; - blank = 1; - break; - case KD_DPMS_SUSPEND: - hsync_off = 0; - vsync_off = 1; - blank = 1; - break; - case KD_DPMS_POWERDOWN: - hsync_off = 1; - vsync_off = 1; - blank = 1; - } - - if (hsync_off) - CRTC_GEN_CNTL |= (1 << 2); - else - CRTC_GEN_CNTL &= ~(1 << 2); - if (vsync_off) - CRTC_GEN_CNTL |= (1 << 3); - else - CRTC_GEN_CNTL &= ~(1 << 3); - if (blank) - { - mach64c->lcdEnabled = (LCD_GEN_CTRL & (1 << 1)) != 0; - LCD_GEN_CTRL &= ~(1 << 1); - CRTC_GEN_CNTL |= (1 << 6); - - } - else - { - if (!(LCD_GEN_CTRL & 3) || mach64c->lcdEnabled) - LCD_GEN_CTRL |= (1 << 1); - CRTC_GEN_CNTL &= ~(1 << 6); - } - - KdCheckSync (pScreen); - - mach64WriteLCD (reg, 1, LCD_GEN_CTRL); - - reg->CRTC_GEN_CNTL = CRTC_GEN_CNTL; - return TRUE; -} - -static void -mach64Restore (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - Reg *reg = mach64c->reg; - - if (reg) - { - mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL); - } - mach64ResetMMIO (card, mach64c); - vesaRestore (card); -} - -static void -mach64ScreenFini (KdScreenInfo *screen) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; -#ifdef XV - mach64FiniVideo(screen->pScreen); -#endif - vesaScreenFini (screen); - xfree (mach64s); - screen->driver = 0; -} - -static void -mach64CardFini (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - - mach64UnmapReg (card, mach64c); - vesaCardFini (card); - xfree (mach64c); -} - -#define mach64CursorInit 0 /* initCursor */ -#define mach64CursorEnable 0 /* enableCursor */ -#define mach64CursorDisable 0 /* disableCursor */ -#define mach64CursorFini 0 /* finiCursor */ -#define mach64RecolorCursor 0 /* recolorCursor */ - -KdCardFuncs mach64Funcs = { - mach64CardInit, /* cardinit */ - mach64ScreenInit, /* scrinit */ - mach64InitScreen, /* initScreen */ - mach64FinishInitScreen, /* finishInitScreen */ - mach64CreateResources, /* createRes */ - mach64Preserve, /* preserve */ - mach64Enable, /* enable */ - mach64DPMS, /* dpms */ - mach64Disable, /* disable */ - mach64Restore, /* restore */ - mach64ScreenFini, /* scrfini */ - mach64CardFini, /* cardfini */ - - mach64CursorInit, /* initCursor */ - mach64CursorEnable, /* enableCursor */ - mach64CursorDisable, /* disableCursor */ - mach64CursorFini, /* finiCursor */ - mach64RecolorCursor, /* recolorCursor */ - - mach64DrawInit, /* initAccel */ - mach64DrawEnable, /* enableAccel */ - mach64DrawSync, /* syncAccel */ - mach64DrawDisable, /* disableAccel */ - mach64DrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; diff --git a/hw/kdrive/mach64/mach64.h b/hw/kdrive/mach64/mach64.h deleted file mode 100644 index 68e762b3b..000000000 --- a/hw/kdrive/mach64/mach64.h +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Id: mach64.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * Copyright © 2001 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64.h,v 1.5 2001/06/23 03:41:24 keithp Exp $ */ - -#ifndef _MACH64_H_ -#define _MACH64_H_ -#include <vesa.h> -#include "kxv.h" - -/* - * offset from ioport beginning - */ - -#define MACH64_REG_BASE(c) ((c)->attr.address[1]) -#define MACH64_REG_SIZE(c) (4096) - -#define MACH64_REG_OFF(c) (1024) -#define MACH64_MEDIA_REG_OFF(c) (0) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _Reg { - VOL32 CRTC_H_TOTAL_DISP; /* 0x00 */ - VOL32 CRTC_H_SYNC_STRT_WID; /* 0x01 */ - VOL32 CRTC_V_TOTAL_DISP; /* 0x02 */ - VOL32 CRTC_V_SYNC_STRT_WID; /* 0x03 */ - VOL32 CRTC_VLINE_CRNT_VLINE; /* 0x04 */ - VOL32 CRTC_OFF_PITCH; /* 0x05 */ - VOL32 CRTC_INT_CNTL; /* 0x06 */ - VOL32 CRTC_GEN_CNTL; /* 0x07 */ - VOL32 DSP_CONFIG; /* 0x08 */ - VOL32 DSP_ON_OFF; /* 0x09 */ - VOL32 TIMER_CONFIG; /* 0x0a */ - VOL32 MEM_BUF_CNTL; /* 0x0b */ - VOL32 unused0; /* 0x0c */ - VOL32 MEM_ADDR_CONFIG; /* 0x0d */ - VOL32 CRT_TRAP; /* 0x0e */ - VOL32 I2C_CNTL_0; /* 0x0f */ - VOL32 OVR_CLR; /* 0x10 */ - VOL32 OVR_WID_LEFT_RIGHT; /* 0x11 */ - VOL32 OVR_WID_TOP_BOTTOM; /* 0x12 */ - VOL32 VGA_DSP_CONFIG; /* 0x13 */ - VOL32 VGA_DSP_ON_OFF; /* 0x14 */ - VOL32 DSP2_CONFIG; /* 0x15 */ - VOL32 DSP2_ON_OFF; /* 0x16 */ - VOL32 CRTC2_OFF_PITCH; /* 0x17 */ - VOL32 CUR_CLR0; /* 0x18 */ - VOL32 CUR_CLR1; /* 0x19 */ - VOL32 CUR_OFFSET; /* 0x1a */ - VOL32 CUR_HORZ_VERT_POSN; /* 0x1b */ - VOL32 CUR_HORZ_VERT_OFF; /* 0x1c */ - VOL32 TV_OUT_INDEX; /* 0x1d */ - VOL32 GP_IO; /* 0x1e */ - VOL32 HW_DEBUG; /* 0x1f */ - VOL32 SCRATCH_REG0; /* 0x20 */ - VOL32 SCRATCH_REG1; - VOL32 SCRATCH_REG2; - VOL32 SCRATCH_REG3; - VOL32 CLOCK_CNTL; - VOL32 CONFIG_STAT1; - VOL32 CONFIG_STAT2; - VOL32 TV_OUT_DATA; - VOL32 BUS_CNTL; /* 0x28 */ - VOL32 LCD_INDEX; /* 0x29 */ - VOL32 LCD_DATA; /* 0x2a */ - VOL32 EXT_MEM_CNTL; - VOL32 MEM_CNTL; - VOL32 MEM_VGA_WP_SEL; - VOL32 MEM_VGA_RP_SEL; - VOL32 I2C_CNTL_1; - VOL32 DAC_REGS; /* 0x30 */ - VOL32 DAC_CNTL; /* 0x31 */ - VOL32 unused_32; - VOL32 unused_33; - VOL32 GEN_TEST_CNTL; /* 0x34 */ - VOL32 CUSTOM_MACRO_CNTL; - VOL32 unused36; - VOL32 CONFIG_CNTL; - VOL32 CONFIG_CHIP_ID; - VOL32 CONFIG_STAT0; - VOL32 CRC_SIG; - VOL32 unused_3b; - VOL32 unused_3c; - VOL32 unused_3d; - VOL32 unused_3e; - VOL32 unused_3f; - VOL32 DST_OFF_PITCH; /* 0x40 */ - VOL32 DST_X; - VOL32 DST_Y; - VOL32 DST_Y_X; - VOL32 DST_WIDTH; - VOL32 DST_HEIGHT; - VOL32 DST_HEIGHT_WIDTH; - VOL32 DST_X_WIDTH; - VOL32 DST_BRES_LNTH; - VOL32 DST_BRES_ERR; - VOL32 DST_BRES_INC; - VOL32 DST_BRES_DEC; - VOL32 DST_CNTL; - VOL32 DST_Y_X_ALIAS; - VOL32 TRAIL_BRES_ERR; - VOL32 TRAIL_BRES_INC; - VOL32 TRAIL_BRES_DEC; - VOL32 LEAD_BRES_LNTH; - VOL32 Z_OFF_PITCH; - VOL32 Z_CNTL; - VOL32 ALPHA_TST_CNTL; - VOL32 unused55; - VOL32 SECONDARY_STW_EXP; - VOL32 SECONDARY_S_X_INC; - VOL32 SECONDARY_S_Y_INC; - VOL32 SECONDARY_S_START; - VOL32 SECONDARY_W_X_INC; - VOL32 SECONDARY_W_Y_INC; - VOL32 SECONDARY_W_START; - VOL32 SECONDARY_T_X_INC; - VOL32 SECONDARY_T_Y_INC; - VOL32 SECONDARY_T_START; - VOL32 SRC_OFF_PITCH; - VOL32 SRC_X; - VOL32 SRC_Y; - VOL32 SRC_Y_X; - VOL32 SRC_WIDTH1; - VOL32 SRC_HEIGHT1; - VOL32 SRC_HEIGHT1_WIDTH1; - VOL32 SRC_X_START; - VOL32 SRC_Y_START; - VOL32 SRC_Y_X_START; - VOL32 SRC_WIDTH2; - VOL32 SRC_HEIGHT2; - VOL32 SRC_HEIGHT2_WIDTH2; - VOL32 SRC_CNTL; - VOL32 unused6e; - VOL32 unused6f; - union { - struct { - VOL32 SCALE_OFF; /* 0x70 */ - VOL32 unused71; - VOL32 unused72; - VOL32 unused73; - VOL32 unused74; - VOL32 unused75; - VOL32 unused76; - VOL32 SCALE_WIDTH; - VOL32 SCALE_HEIGHT; - VOL32 unused79; - VOL32 unused7a; - VOL32 SCALE_PITCH; - VOL32 SCALE_X_INC; - VOL32 SCALE_Y_INC; - VOL32 SCALE_VACC; - VOL32 SCALE_3D_CNTL; /* 0x7f */ - } scaler; - struct { - VOL32 TEX_0_OFF; /* 0x70 */ - VOL32 TEX_1_OFF; - VOL32 TEX_2_OFF; - VOL32 TEX_3_OFF; - VOL32 TEX_4_OFF; - VOL32 TEX_5_OFF; - VOL32 TEX_6_OFF; - VOL32 TEX_7_OFF; - VOL32 TEX_8_OFF; - VOL32 TEX_9_OFF; - VOL32 TEX_10_OFF; - VOL32 S_Y_INC; - VOL32 RED_X_INC; - VOL32 GREEN_X_INC; /* 0x7d */ - VOL32 unused7e; - VOL32 unused7f; - } texture; - } u; - VOL32 HOST_DATA[16]; /* 0x80 */ - VOL32 HOST_CNTL; /* 0x90 */ - VOL32 BM_HOSTDATA; /* 0x91 */ - VOL32 BM_ADDR; /* 0x92 */ - VOL32 BM_GUI_TABLE_CMD; /* 0x93 */ - VOL32 unused94; /* 0x94 */ - VOL32 unused95; /* 0x95 */ - VOL32 unused96; /* 0x96 */ - VOL32 FOG_TABLE_INDEX; /* 0x97 */ - VOL32 FOG_TABLE_DATA[8]; /* 0x98 */ - VOL32 PAT_REG0; /* 0xa0 */ - VOL32 PAT_REG1; - VOL32 PAT_CNTL; - VOL32 unused_0a3; - VOL32 unused_0a4; - VOL32 unused_0a5; - VOL32 unused_0a6; - VOL32 unused_0a7; - VOL32 SC_LEFT; - VOL32 SC_RIGHT; - VOL32 SC_LEFT_RIGHT; - VOL32 SC_TOP; - VOL32 SC_BOTTOM; - VOL32 SC_TOP_BOTTOM; - VOL32 USR1_DST_OFF_PITCH; - VOL32 USR2_DST_OFF_PITCH; - VOL32 DP_BKGD_CLR; /* 0xb0 */ - VOL32 DP_FRGD_CLR; - VOL32 DP_WRITE_MSK; - VOL32 unused_0b3; - VOL32 DP_PIX_WIDTH; - VOL32 DP_MIX; - VOL32 DP_SRC; - VOL32 DP_FRGD_CLR_MIX; - VOL32 DP_FRGD_BKGD_CLR; - VOL32 unused_0b9; - VOL32 DST_X_Y; - VOL32 DST_WIDTH_HEIGHT; - VOL32 USR_DST_PITCH; - VOL32 unused_0bd; - VOL32 DP_SET_GUI_ENGINE2; - VOL32 DP_SET_GUI_ENGINE; - VOL32 CLR_CMP_CLR; /* 0xc0 */ - VOL32 CLR_CMP_MSK; - VOL32 CLR_CMP_CNTL; - VOL32 unused_0c3; - VOL32 FIFO_STAT; - VOL32 unused_0c5; - VOL32 unused_0c6; - VOL32 unused_0c7; - VOL32 unused_0c8; - VOL32 unused_0c9; - VOL32 unused_0ca; - VOL32 unused_0cb; - VOL32 GUI_TRAJ_CNTL; - VOL32 unused_0cd; - VOL32 GUI_STAT; - VOL32 unused_0cf; - VOL32 TEX_PALETTE_INDEX; - VOL32 STW_EXP; - VOL32 LOG_MAX_INC; - VOL32 S_X_INC; - VOL32 S_Y_INC_2_SCALE_PITCH; - VOL32 S_START; - VOL32 W_X_INC; - VOL32 W_Y_INC; - VOL32 W_START; - VOL32 T_X_INC; - VOL32 T_Y_INC_SECONDARY_SCALE_PITCH; - VOL32 T_START; - VOL32 TEX_SIZE_PITCH; - VOL32 TEX_CNTL; - VOL32 SECONDARY_TEX_OFFSET_SECONDARY_SCALE_OFF; - VOL32 TEX_PALETTE; - VOL32 SCALE_PITCH_BOTH; /* 0xe0 */ - VOL32 SECONDARY_SCALE_OFF_ACC; - VOL32 SCALE_OFF_ACC; - VOL32 SCALE_DST_Y_X; - VOL32 unused_0e4; - VOL32 unused_0e5; - VOL32 COMPOSITE_SHADOW_ID; - VOL32 SECONDARY_SCALE_X_INC_SPECULAR_RED_X_INC; - VOL32 SPECULAR_RED_Y_INC; - VOL32 SPECULAR_RED_START_SECONDARY_SCALE_HACC;; - VOL32 SPECULAR_GREEN_X_INC; - VOL32 SPECULAR_GREEN_Y_INC; - VOL32 SPECULAR_GREEN_START; - VOL32 SPECULAR_BLUE_X_INC; - VOL32 SPECULAR_BLUE_Y_INC; - VOL32 SPECULAR_BLUE_START; - VOL32 RED_X_INC_SCALE_X_INC; - VOL32 RED_Y_INC; - VOL32 RED_START_SCALE_HACC; - VOL32 GREEN_X_INC_SCALE_Y_INC; - VOL32 GREEN_Y_INC_SECONDARY_SCALE_Y_INC; - VOL32 GREEN_START_SECONDARY_SCALE_VACC; - VOL32 BLUE_X_INC; - VOL32 BLUE_Y_INC; - VOL32 BLUE_START; - VOL32 Z_X_INC; - VOL32 Z_Y_INC; - VOL32 Z_START; - VOL32 ALPHA_X_INC; - VOL32 FOG_X_INC; - VOL32 ALPHA_Y_INC; - VOL32 FOG_Y_INC; - VOL32 ALPHA_START; - VOL32 FOG_START; - VOL32 unused_0ff; -} Reg; /* 0x100 */ - -#define DST_X_DIR (1 << 0) -#define DST_Y_DIR (1 << 1) -#define DST_Y_MAJOR (1 << 2) -#define DST_X_TILE (1 << 3) -#define DST_Y_TILE (1 << 4) -#define DST_LAST_PEL (1 << 5) -#define DST_POLYGON_EN (1 << 6) -#define DST_24_ROT_EN (1 << 7) -#define DST_24_ROT(n) ((n) << 8) -#define DST_BRES_ZERO (1 << 11) -#define DST_POLYGON_RTEDGE_DIS (1 << 12) -#define TRAIL_X_DIR (1 << 13) -#define TRAP_FILL_DIR (1 << 14) -#define TRAIL_BRES_SIGN (1 << 15) -#define SRC_PATT_EN (1 << 16) -#define SRC_PATT_ROT_EN (1 << 17) -#define SRC_LINEAR_EN (1 << 18) -#define SRC_BYTE_ALIGN (1 << 19) -#define SRC_LINE_X_DIR (1 << 20) -#define SRC_8x8x8_BRUSH (1 << 21) -#define FAST_FILL_EN (1 << 22) -#define SRC_TRACK_DST (1 << 23) -#define PAT_MONO_EN (1 << 24) -#define PAT_CLR_4x2_EN (1 << 25) -#define PAT_CLR_8x1_EN (1 << 26) -#define HOST_BYTE_ALIGN (1 << 28) -#define HOST_BIG_ENDIAN_EN (1 << 29) - -/* BUS_CNTL bits */ -#define BUS_DBL_RESYNC (1 << 0) -#define BUS_MSTR_RESET (1 << 1) -#define BUS_FLUSH_BUF (1 << 2) -#define BUS_STOP_REQ_DIS (1 << 3) -#define BUS_APER_REG_DIS (1 << 4) -#define BUS_EXTRA_PIPE_DIS (1 << 5) -#define BUS_MASTER_DIS (1 << 6) -#define ROM_WRT_EN (1 << 7) -#define CHIP_HIDDEN_REV (3 << 8) -#define BUS_PCI_READ_RETRY_EN (1 << 13) -#define BUS_PCI_WRT_RETRY_EN (1 << 15) -#define BUS_RETRY_WS (0xf << 16) -#define BUS_MSTR_RD_MULT (1 << 20) -#define BUS_MSTR_RD_LINE (1 << 21) -#define BUS_SUSPEND (1 << 22) -#define LAT16X (1 << 23) -#define BUS_RD_DISCARD_EN (1 << 24) -#define BUS_RD_ABORT_EN (1 << 25) -#define BUS_MSTR_WS (1 << 26) -#define BUS_EXT_REG_EN (1 << 27) -#define BUS_MSTR_DISCONNECT_EN (1 << 28) -#define BUS_WRT_BURST (1 << 29) -#define BUS_READ_BURST (1 << 30) -#define BUS_RDY_READ_DLY (1 << 31) - -#define SCALE_PIX_EXPAND (1 << 0) -#define SCALE_Y2R_TEMP (1 << 1) -#define SCALE_HORZ_MODE (1 << 2) -#define SCALE_VERT_MODE (1 << 3) -#define SCALE_SIGNED_UV (1 << 4) -#define SCALE_GAMMA_SEL (3 << 5) -#define SCALE_GAMMA_BRIGHT (0 << 5) -#define SCALE_GAMMA_22 (1 << 5) -#define SCALE_GAMMA_18 (2 << 5) -#define SCALE_GAMMA_14 (3 << 5) -#define SCALE_DISP_SEL (1 << 7) -#define SCALE_BANDWIDTH (1 << 26) -#define SCALE_DIS_LIMIT (1 << 27) -#define SCALE_CLK_FORCE_ON (1 << 29) -#define SCALE_OVERLAY_EN (1 << 30) -#define SCALE_EN (1 << 31) - -#define VIDEO_IN_VYUY422 (0xb) -#define VIDEO_IN_YVYU422 (0xc) -#define SCALER_IN_15bpp (0x3 << 16) -#define SCALER_IN_16bpp (0x4 << 16) -#define SCALER_IN_32bpp (0x6 << 16) -#define SCALER_IN_YUV_9 (0x9 << 16) -#define SCALER_IN_YUV_12 (0xa << 16) -#define SCALER_IN_VYUY422 (0xb << 16) -#define SCALER_IN_YVYU422 (0xc << 16) - -#define CAP_INPUT_MODE (1 << 0) -#define CAP_BUF_MODE (1 << 2) -#define CAP_START_BUF (1 << 3) -#define CAP_BUF_TYPE_FIELD (0 << 4) -#define CAP_BUF_TYPE_ALTERNATING (1 << 4) -#define CAP_BUF_TYPE_FRAME (2 << 4) - -#define OVL_BUF_MODE (1 << 28) -#define OVL_BUF_NEXT (1 << 29) - -#define CAP_TRIGGER (3 << 0) -#define OVL_CUR_BUF (1 << 5) -#define OVL_BUF_STATUS (1 << 6) -#define CAP_BUF_STATUS (1 << 7) -#define CAPTURE_EN (1 << 31) - -typedef struct _MediaReg { - VOL32 OVERLAY_Y_X_START; /* 0x100 */ - VOL32 OVERLAY_Y_X_END; - VOL32 OVERLAY_VIDEO_KEY_CLR; - VOL32 OVERLAY_VIDEO_KEY_MSK; - VOL32 OVERLAY_GRAPHICS_KEY_CLR; - VOL32 OVERLAY_GRAPHICS_KEY_MSK; - VOL32 OVERLAY_KEY_CNTL; - VOL32 unused_107; - VOL32 OVERLAY_SCALE_INC; - VOL32 OVERLAY_SCALE_CNTL; - VOL32 SCALER_HEIGHT_WIDTH; - VOL32 SCALER_TEST; - VOL32 unused_10c; - VOL32 SCALER_BUF0_OFFSET; - VOL32 SCALER_BUF1_OFFSET; - VOL32 SCALER_BUF_PITCH; - VOL32 CAPTURE_START_END; /* 0x110 */ - VOL32 CAPTURE_X_WIDTH; - VOL32 VIDEO_FORMAT; - VOL32 VBI_START_END; - VOL32 CAPTURE_CONFIG; - VOL32 TRIG_CNTL; - VOL32 OVERLAY_EXCLUSIVE_HORZ; - VOL32 OVERLAY_EXCLUSIVE_VERT; - VOL32 VBI_WIDTH; - VOL32 CAPTURE_DEBUG; - VOL32 VIDEO_SYNC_TEST; - VOL32 unused_11b; - VOL32 SNAPSHOT_VH_COUNTS; - VOL32 SNAPSHOT_F_COUNT; - VOL32 N_VIF_COUNT; - VOL32 SNAPSHOT_VIF_COUNT; - VOL32 CAPTURE_BUF0_OFFSET; /* 0x120 */ - VOL32 CAPTURE_BUF1_OFFSET; - VOL32 ONESHOT_BUF_OFFSET; - VOL32 unused_123; - VOL32 unused_124; - VOL32 unused_125; - VOL32 unused_126; - VOL32 unused_127; - VOL32 unused_128; - VOL32 unused_129; - VOL32 unused_12a; - VOL32 unused_12b; - VOL32 SNAPSHOT2_VH_COUNTS; - VOL32 SNAPSHOT2_F_COUNT; - VOL32 N_VIF2_COUNT; - VOL32 SNAPSHOT2_VIF_COUNT; - VOL32 MPP_CONFIG; /* 0x130 */ - VOL32 MPP_STROBE_SEQ; - VOL32 MPP_ADDR; - VOL32 MPP_DATA; - VOL32 unused_134; - VOL32 unused_135; - VOL32 unused_136; - VOL32 unused_137; - VOL32 unused_138; - VOL32 unused_139; - VOL32 unused_13a; - VOL32 unused_13b; - VOL32 unused_13c; - VOL32 unused_13d; - VOL32 unused_13e; - VOL32 unused_13f; - VOL32 TVO_CNTL; /* 0x140 */ - VOL32 unused_141[15]; - VOL32 unused_150; /* 0x150 */ - VOL32 CRT_HORZ_VERT_LOAD; /* 0x151 */ - VOL32 AGP_BASE; /* 0x152 */ - VOL32 AGP_CNTL; /* 0x153 */ - VOL32 SCALER_COLOUR_CNTL; /* 0x154 */ - VOL32 SCALER_H_COEFF0; /* 0x155 */ - VOL32 SCALER_H_COEFF1; /* 0x156 */ - VOL32 SCALER_H_COEFF2; /* 0x157 */ - VOL32 SCALER_H_COEFF3; /* 0x158 */ - VOL32 SCALER_H_COEFF4; /* 0x159 */ - VOL32 unused_15a; - VOL32 unused_15b; - VOL32 GUI_CMDFIFO_DEBUG; - VOL32 GUI_CMDFIFO_DATA; - VOL32 GUI_CNTL; - VOL32 unused_15f; - VOL32 BM_FRAME_BUF_OFFSET; /* 0x160 */ - VOL32 BM_SYSTEM_MEM_ADDR; - VOL32 BM_COMMAND; - VOL32 BM_STATUS; - VOL32 unused_164[10]; - VOL32 BM_GUI_TABLE; - VOL32 BM_SYSTEM_TABLE; - VOL32 unused_170[5]; /* 0x170 */ - VOL32 SCALER_BUF0_OFFSET_U; - VOL32 SCALER_BUF0_OFFSET_V; - VOL32 SCALER_BUF1_OFFSET_U; - VOL32 SCALER_BUF1_OFFSET_V; - VOL32 unused_179[7]; - VOL32 unused_180[16]; /* 0x180 */ - VOL32 setup_engine[0x40]; /* 0x190 */ - VOL32 dvd_subpicture[0x30]; /* 0x1d0 */ -} MediaReg; - -#define MACH64_XY(x,y) (((x) & 0x7fff) | (((y) & 0x7fff) << 16)) -#define MACH64_YX(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16)) - -typedef struct _mach64Save { - CARD32 LCD_GEN_CTRL; -} Mach64Save; - -typedef struct _mach64CardInfo { - VesaCardPrivRec vesa; - CARD8 *reg_base; - Reg *reg; - MediaReg *media_reg; - Mach64Save save; - Bool lcdEnabled; -} Mach64CardInfo; - -#define getMach64CardInfo(kd) ((Mach64CardInfo *) ((kd)->card->driver)) -#define mach64CardInfo(kd) Mach64CardInfo *mach64c = getMach64CardInfo(kd) - -typedef struct _mach64Cursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; - Pixel source, mask; -} Mach64Cursor; - -#define MACH64_CURSOR_WIDTH 64 -#define MACH64_CURSOR_HEIGHT 64 - -/* - * Xv information, optional - */ -typedef struct _mach64PortPriv { - CARD32 YBuf0Offset; - - CARD32 YBuf1Offset; - - CARD8 currentBuf; - - int brightness; - int saturation; - - RegionRec clip; - CARD32 colorKey; - - Bool videoOn; - Time offTime; - Time freeTime; - CARD32 size; - CARD32 offset; - KdOffscreenArea *off_screen; -} Mach64PortPrivRec, *Mach64PortPrivPtr; - -Bool mach64InitVideo(ScreenPtr pScreen); -void mach64FiniVideo(ScreenPtr pScreen); - -typedef struct _mach64ScreenInfo { - VesaScreenPrivRec vesa; - CARD32 DP_PIX_WIDTH; - CARD32 DP_SET_GUI_ENGINE; - Bool bpp24; - Mach64Cursor cursor; - CARD32 colorKey; - KdVideoAdaptorPtr pAdaptor; -} Mach64ScreenInfo; - -#define getMach64ScreenInfo(kd) ((Mach64ScreenInfo *) ((kd)->screen->driver)) -#define mach64ScreenInfo(kd) Mach64ScreenInfo *mach64s = getMach64ScreenInfo(kd) - -CARD32 -mach64ReadLCD (Reg *reg, int id); - -void -mach64WriteLCD (Reg *reg, int id, CARD32 data); - -void -mach64Preserve (KdCardInfo *card); - -Bool -mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c); - -Bool -mach64Enable (ScreenPtr pScreen); - -void -mach64Disable (ScreenPtr pScreen); - -Bool -mach64DPMS (ScreenPtr pScreen, int mode); - -void -mach64WaitAvail(Reg *reg, int n); - -void -mach64WaitIdle (Reg *reg); - -Bool -mach64DrawSetup (ScreenPtr pScreen); - -Bool -mach64DrawInit (ScreenPtr pScreen); - -void -mach64DrawReinit (ScreenPtr pScreen); - -void -mach64DrawEnable (ScreenPtr pScreen); - -void -mach64DrawSync (ScreenPtr pScreen); - -void -mach64DrawDisable (ScreenPtr pScreen); - -void -mach64DrawFini (ScreenPtr pScreen); - -CARD8 -mach64ReadIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index); - -void -mach64WriteIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index, CARD8 value); - -Bool -mach64CursorInit (ScreenPtr pScreen); - -void -mach64CursorEnable (ScreenPtr pScreen); - -void -mach64CursorDisable (ScreenPtr pScreen); - -void -mach64CursorFini (ScreenPtr pScreen); - -void -mach64RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); - -extern KdCardFuncs mach64Funcs; - -#endif /* _MACH64_H_ */ diff --git a/hw/kdrive/mach64/mach64curs.c b/hw/kdrive/mach64/mach64curs.c deleted file mode 100644 index b5d7cd16c..000000000 --- a/hw/kdrive/mach64/mach64curs.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Id: tridentcurs.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.6 2000/09/03 05:11:20 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 *) tridents->screen; - 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; -} diff --git a/hw/kdrive/mach64/mach64draw.c b/hw/kdrive/mach64/mach64draw.c deleted file mode 100644 index d93e7dff7..000000000 --- a/hw/kdrive/mach64/mach64draw.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Id: mach64draw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.6 2001/07/23 03:44:17 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" -#include "mach64draw.h" - -#include <X11/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" -#include "picturestr.h" - -CARD8 mach64Rop[16] = { - /* GXclear */ 0x01, /* 0 */ - /* GXand */ 0x0c, /* src AND dst */ - /* GXandReverse */ 0x0d, /* src AND NOT dst */ - /* GXcopy */ 0x07, /* src */ - /* GXandInverted*/ 0x0e, /* NOT src AND dst */ - /* GXnoop */ 0x03, /* dst */ - /* GXxor */ 0x05, /* src XOR dst */ - /* GXor */ 0x0b, /* src OR dst */ - /* GXnor */ 0x0f, /* NOT src AND NOT dst */ - /* GXequiv */ 0x06, /* NOT src XOR dst */ - /* GXinvert */ 0x00, /* NOT dst */ - /* GXorReverse */ 0x0a, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x04, /* NOT src */ - /* GXorInverted */ 0x09, /* NOT src OR dst */ - /* GXnand */ 0x08, /* NOT src OR NOT dst */ - /* GXset */ 0x02, /* 1 */ -}; - -#define MACH64_DRAW_COMBO_SOLID 0x1 -#define MACH64_DRAW_COMBO_COPY 0x8 - -#define SYNC_ALWAYS 0 -#if SYNC_ALWAYS -static ScreenPtr mach64Screen; -#endif -static Reg *reg; -static CARD32 avail; -static CARD32 triple; - -#define IDX(reg,n) (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP) - -void -mach64WaitAvail(Reg *reg, int n) -{ - if (avail < n) - { - while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n) - ; - } - avail -= n; -} - -void -mach64WaitIdle (Reg *reg) -{ - while (reg->GUI_STAT & 1) - ; -} - -static Bool -mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait) -{ - ScreenPtr pScreen = pDst->drawable.pScreen; - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - mach64CardInfo(pScreenPriv); - CARD32 DST_PITCH; - CARD32 DST_OFFSET; - CARD32 SRC_PITCH; - CARD32 SRC_OFFSET; - - reg = mach64c->reg; - triple = mach64s->bpp24; -#if SYNC_ALWAYS - mach64Screen = pScreen; -#endif - if (!reg) - return FALSE; - - /* - * No acceleration for other formats (yet) - */ - if (pDst->drawable.bitsPerPixel != pScreenPriv->screen->fb[0].bitsPerPixel) - return FALSE; - - /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ - DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel; - if (triple) - DST_PITCH *= 3; - /* bytes / 8 */ - DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3; - - mach64WaitAvail(reg, wait + (pSrc ? 5 : 4)); - reg->DP_SET_GUI_ENGINE = mach64s->DP_SET_GUI_ENGINE | (combo << 20); - reg->DP_PIX_WIDTH = mach64s->DP_PIX_WIDTH; - reg->DST_OFF_PITCH = ((DST_OFFSET << 0) | /* USR1_DST_OFFSET */ - (DST_PITCH << 22) | /* USR1_DST_PITCH */ - 0); - if (pSrc) - { - /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ - SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel; - if (triple) - SRC_PITCH *= 3; - /* bytes / 8 */ - SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3; - - reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) | - (SRC_PITCH << 22) | - 0); - } - return TRUE; -} - -static Bool -mach64PrepareSolid (PixmapPtr pPixmap, - int alu, - Pixel pm, - Pixel fg) -{ - if (!mach64Setup (pPixmap, 0, 1, 3)) - return FALSE; - reg->DP_MIX = (mach64Rop[alu] << 16) | 0; - reg->DP_WRITE_MSK = pm; - reg->DP_FRGD_CLR = fg; - return TRUE; -} - -static void -mach64Solid (int x1, int y1, int x2, int y2) -{ - if (triple) - { - CARD32 traj; - - x1 *= 3; - x2 *= 3; - - traj = (DST_X_DIR | - DST_Y_DIR | - DST_24_ROT_EN | - DST_24_ROT((x1 / 4) % 6)); - mach64WaitAvail (reg, 1); - reg->GUI_TRAJ_CNTL = traj; - } - mach64WaitAvail(reg,2); - reg->DST_X_Y = MACH64_XY(x1,y1); - reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1); -} - -static void -mach64DoneSolid (void) -{ -#if SYNC_ALWAYS - KdCheckSync (mach64Screen); -#endif -} - -static int copyDx; -static int copyDy; -static CARD32 copyCombo; - -static Bool -mach64PrepareCopy (PixmapPtr pSrcPixmap, - PixmapPtr pDstPixmap, - int dx, - int dy, - int alu, - Pixel pm) -{ - copyCombo = 8 | 2 | 1; - copyDx = dx; - copyDy = dy; - - /* - * Avoid going backwards when copying pixmaps to the screen. - * This should reduce tearing somewhat - */ - if (pSrcPixmap == pDstPixmap) - { - if (dx <= 0) - copyCombo &= ~1; - if (dy <= 0) - copyCombo &= ~2; - } - - if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2)) - return FALSE; - - reg->DP_MIX = (mach64Rop[alu] << 16) | 0; - reg->DP_WRITE_MSK = pm; - return TRUE; -} - -static void -mach64Copy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - if (triple) - { - CARD32 traj; - - srcX *= 3; - dstX *= 3; - w *= 3; - - traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6); - - if (copyCombo & 1) - traj |= 1; - if (copyCombo & 2) - traj |= 2; - - mach64WaitAvail (reg, 1); - reg->GUI_TRAJ_CNTL = traj; - } - if ((copyCombo & 1) == 0) - { - srcX += w - 1; - dstX += w - 1; - } - if ((copyCombo & 2) == 0) - { - srcY += h - 1; - dstY += h - 1; - } - mach64WaitAvail (reg, 4); - reg->SRC_Y_X = MACH64_YX(srcX, srcY); - reg->SRC_WIDTH1 = w; - reg->DST_Y_X = MACH64_YX(dstX, dstY); - reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h); -} - -static void -mach64DoneCopy (void) -{ -#if SYNC_ALWAYS - KdCheckSync (mach64Screen); -#endif -} - -KaaScreenInfoRec mach64Kaa = { - mach64PrepareSolid, - mach64Solid, - mach64DoneSolid, - - mach64PrepareCopy, - mach64Copy, - mach64DoneCopy, - - 64, /* Offscreen byte alignment */ - 64, /* Offscreen pitch */ - KAA_OFFSCREEN_PIXMAPS, /* Flags */ -}; - -Bool -mach64DrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - - if (pScreenPriv->screen->fb[0].depth == 4) - return FALSE; - - if (!kaaDrawInit (pScreen, &mach64Kaa)) - return FALSE; - - return TRUE; -} - -#define PIX_FORMAT_MONO 0 -#define PIX_FORMAT_PSEUDO_8 2 -#define PIX_FORMAT_TRUE_1555 3 -#define PIX_FORMAT_TRUE_565 4 -#define PIX_FORMAT_TRUE_8888 6 -#define PIX_FORMAT_TRUE_332 7 -#define PIX_FORMAT_GRAY_8 8 -#define PIX_FORMAT_YUV_422 0xb -#define PIX_FORMAT_YUV_444 0xe -#define PIX_FORMAT_TRUE_4444 0xf - -void -mach64DrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - CARD32 DP_PIX_WIDTH = 0; - CARD32 SET_DP_DST_PIX_WIDTH = 0; - - avail = 0; - mach64s->bpp24 = FALSE; - - switch (pScreenPriv->screen->fb[0].depth) { - case 1: - DP_PIX_WIDTH = ((PIX_FORMAT_MONO << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_MONO << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_MONO << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_MONO; - break; - case 4: - FatalError ("mach64 can't accelerate 4bpp"); - break; - case 8: - DP_PIX_WIDTH = ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_PSEUDO_8; - break; - case 15: - DP_PIX_WIDTH = ((PIX_FORMAT_TRUE_1555 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_1555 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_1555 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_TRUE_1555; - break; - case 16: - DP_PIX_WIDTH = ((PIX_FORMAT_TRUE_565 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_565 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_565 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_TRUE_565; - break; - case 24: - if (pScreenPriv->screen->fb[0].bitsPerPixel == 24) - { - mach64s->bpp24 = TRUE; - DP_PIX_WIDTH = ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_PSEUDO_8; - } - else - { - DP_PIX_WIDTH = ((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0); - SET_DP_DST_PIX_WIDTH = PIX_FORMAT_TRUE_8888; - } - break; - } - - mach64s->DP_PIX_WIDTH = DP_PIX_WIDTH; - mach64s->DP_SET_GUI_ENGINE = ((SET_DP_DST_PIX_WIDTH << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0); - KdMarkSync (pScreen); -} - -void -mach64DrawDisable (ScreenPtr pScreen) -{ -} - -void -mach64DrawFini (ScreenPtr pScreen) -{ - kaaDrawFini (pScreen); -} - -void -mach64DrawSync (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64CardInfo(pScreenPriv); - reg = mach64c->reg; - - mach64WaitIdle (reg); -} diff --git a/hw/kdrive/mach64/mach64draw.h b/hw/kdrive/mach64/mach64draw.h deleted file mode 100644 index b7053ae49..000000000 --- a/hw/kdrive/mach64/mach64draw.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Id: tridentdraw.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.4 2000/10/11 06:04:40 keithp Exp $ */ - -#ifndef _TRIDENTDRAW_H_ -#define _TRIDENTDRAW_H_ - -#define SetupTrident(s) KdScreenPriv(s); \ - tridentCardInfo(pScreenPriv); \ - Cop *cop = tridentc->cop - -#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) - -#define _tridentInit(cop,tridentc) { \ - if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \ - (cop)->multi = (tridentc)->cop_depth; \ - (cop)->multi = (tridentc)->cop_stride; \ - (cop)->multi = TridentAlpha; \ -} \ - -#define _tridentSetSolidRect(cop,pix,alu,cmd) {\ - 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); \ - _tridentWaitDone(cop); \ - (cop)->command = (cmd); \ -} - -#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ - COP_STATUS_DPE_BUSY | \ - COP_STATUS_MI_BUSY) - -#define _tridentWaitDone(cop) { \ - int __q__ = 500000; \ - while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ - ; \ - if (!__q__) \ - (cop)->status = 0; \ -} - -#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop) - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/mach64/mach64stub.c b/hw/kdrive/mach64/mach64stub.c deleted file mode 100644 index 29ebb1bc1..000000000 --- a/hw/kdrive/mach64/mach64stub.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Id: mach64stub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64stub.c,v 1.2 2001/10/12 06:33:10 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" -#include <klinux.h> - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x1002, 0x4c4d, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); - else if (LinuxFindPci (0x1002, 0x4c49, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); - else if (LinuxFindPci (0x1002, 0x4c46, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/mach64/mach64video.c b/hw/kdrive/mach64/mach64video.c deleted file mode 100644 index 23d671580..000000000 --- a/hw/kdrive/mach64/mach64video.c +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * Copyright © 2001 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.9tsi Exp $ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" - -#include <X11/extensions/Xv.h> -#include "fourcc.h" - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -static Atom xvBrightness, xvSaturation, xvColorKey; - -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 - -static void -mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - - if (!media) - return; - - if(pPortPriv->videoOn) - { - mach64WaitIdle (reg); - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - /* wait for buffer to be finished */ - while (((media->TRIG_CNTL >> 6) & 1) != 0) - ; - mach64WaitAvail (reg, 1); - media->OVERLAY_SCALE_CNTL = 0; - pPortPriv->videoOn = FALSE; - mach64WaitIdle (reg); - } - if (pPortPriv->off_screen) - { - KdOffscreenFree (pPortPriv->off_screen); - pPortPriv->off_screen = 0; - } -} - -static int -mach64SetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int value, - pointer data) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - - if(attribute == xvBrightness) - { - if(value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->brightness = value; - } - else if(attribute == xvSaturation) - { - if (value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->saturation = value; - } - else if(attribute == xvColorKey) - { - if (pPortPriv->colorKey != value) - { - pPortPriv->colorKey = value; - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - } - } - else - return BadMatch; - - return Success; -} - -static int -mach64GetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int *value, - pointer data) -{ - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - - if(attribute == xvBrightness) - *value = pPortPriv->brightness; - else if(attribute == xvSaturation) - *value = pPortPriv->saturation; - else if(attribute == xvColorKey) - *value = pPortPriv->colorKey; - else - return BadMatch; - - return Success; -} - -static void -mach64QueryBestSize(KdScreenInfo *screen, - Bool motion, - short vid_w, - short vid_h, - short drw_w, - short drw_h, - unsigned int *p_w, - unsigned int *p_h, - pointer data) -{ - *p_w = drw_w; - *p_h = drw_h; -} - - -static void -mach64CopyPackedData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int dstPitch, - int srcW, - int srcH, - int top, - int left, - int h, - int w) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - CARD8 *src = buf, *dst; - int srcDown = srcPitch, srcRight = 2, srcNext; - int p; - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - src = buf; - srcDown = srcPitch; - srcRight = 2; - break; - case RR_Rotate_90: - src = buf + (srcH - 1) * 2; - srcDown = -2; - srcRight = srcPitch; - break; - case RR_Rotate_180: - src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; - srcDown = -srcPitch; - srcRight = -2; - break; - case RR_Rotate_270: - src = buf + srcPitch * (srcW - 1); - srcDown = 2; - srcRight = -srcPitch; - break; - } - - src = src + top*srcDown + left*srcRight; - - if (pPortPriv->currentBuf == 0) - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - srcRight >>= 1; - srcNext = srcRight >> 1; - while(h--) - { - CARD16 *s = (CARD16 *) src; - CARD32 *d = (CARD32 *) dst; - p = w; - while (p--) - { - *d++ = s[0] | (s[srcNext] << 16); - s += srcRight; - } - src += srcPitch; - dst += dstPitch; - } -} - -static void -mach64CopyPlanarData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int srcPitch2, - int dstPitch, /* of chroma */ - int srcW, - int srcH, - int height, - int top, - int left, - int h, - int w, - int id) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - int i, j; - CARD8 *src1, *src2, *src3, *dst1; - int srcDown = srcPitch, srcDown2 = srcPitch2; - int srcRight = 2, srcRight2 = 1, srcNext = 1; - - /* compute source data pointers */ - src1 = buf; - src2 = src1 + height * srcPitch; - src3 = src2 + (height >> 1) * srcPitch2; - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - srcDown = srcPitch; - srcDown2 = srcPitch2; - srcRight = 2; - srcRight2 = 1; - srcNext = 1; - break; - case RR_Rotate_90: - src1 = src1 + srcH - 1; - src2 = src2 + (srcH >> 1) - 1; - src3 = src3 + (srcH >> 1) - 1; - srcDown = -1; - srcDown2 = -1; - srcRight = srcPitch * 2; - srcRight2 = srcPitch2; - srcNext = srcPitch; - break; - case RR_Rotate_180: - src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); - src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - srcDown = -srcPitch; - srcDown2 = -srcPitch2; - srcRight = -2; - srcRight2 = -1; - srcNext = -1; - break; - case RR_Rotate_270: - src1 = src1 + srcPitch * (srcW - 1); - src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); - srcDown = 1; - srcDown2 = 1; - srcRight = -srcPitch * 2; - srcRight2 = -srcPitch2; - srcNext = -srcPitch; - break; - } - - /* adjust for origin */ - src1 += top * srcDown + left * srcNext; - src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - - if (id == FOURCC_I420) - { - CARD8 *srct = src2; - src2 = src3; - src3 = srct; - } - - if (pPortPriv->currentBuf == 0) - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - for (j = 0; j < h; j++) - { - CARD32 *dst = (CARD32 *) dst1; - CARD8 *s1l = src1; - CARD8 *s1r = src1 + srcNext; - CARD8 *s2 = src2; - CARD8 *s3 = src3; - - for (i = 0; i < w; i++) - { - *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); - s1l += srcRight; - s1r += srcRight; - s2 += srcRight2; - s3 += srcRight2; - } - src1 += srcDown; - dst1 += dstPitch; - if (j & 1) - { - src2 += srcDown2; - src3 += srcDown2; - } - } -} - -static void -mach64PaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg) -{ - GCPtr pGC; - CARD32 val[2]; - xRectangle *rects, *r; - BoxPtr pBox = REGION_RECTS (pRgn); - int nBox = REGION_NUM_RECTS (pRgn); - - rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle)); - if (!rects) - goto bail0; - r = rects; - while (nBox--) - { - r->x = pBox->x1 - pDraw->x; - r->y = pBox->y1 - pDraw->y; - r->width = pBox->x2 - pBox->x1; - r->height = pBox->y2 - pBox->y1; - r++; - pBox++; - } - - pGC = GetScratchGC (pDraw->depth, pDraw->pScreen); - if (!pGC) - goto bail1; - - val[0] = fg; - val[1] = IncludeInferiors; - ChangeGC (pGC, GCForeground|GCSubwindowMode, val); - - ValidateGC (pDraw, pGC); - - (*pGC->ops->PolyFillRect) (pDraw, pGC, - REGION_NUM_RECTS (pRgn), rects); - - FreeScratchGC (pGC); -bail1: - DEALLOCATE_LOCAL (rects); -bail0: - ; -} - -/* Mach64ClipVideo - - - Takes the dst box in standard X BoxRec form (top and left - edges inclusive, bottom and right exclusive). The new dst - box is returned. The source boundaries are given (x1, y1 - inclusive, x2, y2 exclusive) and returned are the new source - boundaries in 16.16 fixed point. -*/ - -static void -Mach64ClipVideo(BoxPtr dst, - INT32 *x1, - INT32 *x2, - INT32 *y1, - INT32 *y2, - BoxPtr extents, /* extents of the clip region */ - INT32 width, - INT32 height) -{ - INT32 vscale, hscale, delta; - int diff; - - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - - *x1 <<= 16; *x2 <<= 16; - *y1 <<= 16; *y2 <<= 16; - - diff = extents->x1 - dst->x1; - if(diff > 0) { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } - diff = dst->x2 - extents->x2; - if(diff > 0) { - dst->x2 = extents->x2; - *x2 -= diff * hscale; - } - diff = extents->y1 - dst->y1; - if(diff > 0) { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } - diff = dst->y2 - extents->y2; - if(diff > 0) { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } - - if(*x1 < 0) { - diff = (- *x1 + hscale - 1)/ hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } - delta = *x2 - (width << 16); - if(delta > 0) { - diff = (delta + hscale - 1)/ hscale; - dst->x2 -= diff; - *x2 -= diff * hscale; - } - if(*y1 < 0) { - diff = (- *y1 + vscale - 1)/ vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } - delta = *y2 - (height << 16); - if(delta > 0) { - diff = (delta + vscale - 1)/ vscale; - dst->y2 -= diff; - *y2 -= diff * vscale; - } -} - -static void -mach64DisplayVideo(KdScreenInfo *screen, - int id, - int dstPitch, /* of chroma for 4:2:0 */ - int x1, - int y1, - int x2, - int y2, - int dst_x1, - int dst_y1, - int dst_x2, - int dst_y2, - short src_w, - short src_h, - short drw_w, - short drw_h) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - int HORZ_INC, VERT_INC; - CARD32 SCALER_IN; - int bright; - int sat; - - if (id == FOURCC_UYVY) - SCALER_IN = SCALER_IN_YVYU422; - else - SCALER_IN = SCALER_IN_VYUY422; - - mach64WaitAvail (reg, 4); - - media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; - - /* color key */ - media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; - media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; - /* set key control to obey only graphics color key */ - media->OVERLAY_KEY_CNTL = 0x50; - - mach64WaitAvail (reg, 9); - media->CAPTURE_DEBUG = 0; - /* no exclusive video region */ - media->OVERLAY_EXCLUSIVE_HORZ = 0; - media->OVERLAY_EXCLUSIVE_VERT = 0; - /* scaling coefficients */ - media->SCALER_H_COEFF0 = 0x00002000; - media->SCALER_H_COEFF1 = 0x0D06200D; - media->SCALER_H_COEFF2 = 0x0D0A1C0D; - media->SCALER_H_COEFF3 = 0x0C0E1A0C; - media->SCALER_H_COEFF4 = 0x0C14140C; - media->SCALER_TEST = 0; - - mach64WaitAvail (reg, 2); - media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | - SCALE_GAMMA_BRIGHT | - SCALE_BANDWIDTH | - SCALE_OVERLAY_EN | - SCALE_EN); - - bright = (pPortPriv->brightness * 64 / 1000); - if (bright < -0x40) - bright = -0x40; - if (bright > 0x3f) - bright = 0x3f; - bright = bright & 0x7f; - sat = ((pPortPriv->saturation * 31 + 31000) / 2000); - if (sat > 0x1f) - sat = 0x1f; - if (sat < 0) - sat = 0; - - media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ - (sat << 8) | /* SATURATION_U */ - (sat << 16) | /* SATURATION_V */ - (0 << 21) | /* SCALER_VERT_ADJ_UV */ - (0 << 28)); /* SCALER_HORZ_ADJ_UV */ - - VERT_INC = (src_h << 12) / drw_h; - HORZ_INC = (src_w << 12) / drw_w; - - mach64WaitAvail (reg, 13); - - /* lock registers to prevent non-atomic update */ - media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1); - /* ending screen coordinate */ - media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2); - - media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC); - - media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; - - media->SCALER_BUF_PITCH = dstPitch >> 1; - media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); - - media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; - - /* set XY location and unlock */ - media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1); -} - -static void -mach64VideoSave (KdOffscreenArea *area) -{ - ScreenPtr pScreen = area->screen; - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - - if (pPortPriv->off_screen == area) - pPortPriv->off_screen = 0; -} - -static int -mach64PutImage(KdScreenInfo *screen, - DrawablePtr pDraw, - short src_x, - short src_y, - short drw_x, - short drw_y, - short src_w, - short src_h, - short drw_w, - short drw_h, - int id, - unsigned char *buf, - short width, - short height, - Bool sync, - RegionPtr clipBoxes, - pointer data) -{ - KdCardInfo *card = screen->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - MediaReg *media = mach64c->media_reg; - INT32 x1, x2, y1, y2; - int randr = mach64s->vesa.randr; - int srcPitch, srcPitch2, dstPitch; - int top, left, npixels, nlines, size; - BoxRec dstBox; - int dst_width = width, dst_height = height; - int rot_x1, rot_y1, rot_x2, rot_y2; - int dst_x1, dst_y1, dst_x2, dst_y2; - int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; - - /* Clip */ - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2, - REGION_EXTENTS(pScreen, clipBoxes), width, height); - - if((x1 >= x2) || (y1 >= y2)) - return Success; - - if (!media) - return BadAlloc; - - if (randr & (RR_Rotate_0|RR_Rotate_180)) - { - dst_width = width; - dst_height = height; - rot_src_w = src_w; - rot_src_h = src_h; - rot_drw_w = drw_w; - rot_drw_h = drw_h; - } - else - { - dst_width = height; - dst_height = width; - rot_src_w = src_h; - rot_src_h = src_w; - rot_drw_w = drw_h; - rot_drw_h = drw_w; - } - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - default: - dst_x1 = dstBox.x1; - dst_y1 = dstBox.y1; - dst_x2 = dstBox.x2; - dst_y2 = dstBox.y2; - rot_x1 = x1; - rot_y1 = y1; - rot_x2 = x2; - rot_y2 = y2; - break; - case RR_Rotate_90: - dst_x1 = dstBox.y1; - dst_y1 = screen->height - dstBox.x2; - dst_x2 = dstBox.y2; - dst_y2 = screen->height - dstBox.x1; - - rot_x1 = y1; - rot_y1 = (src_w << 16) - x2; - rot_x2 = y2; - rot_y2 = (src_w << 16) - x1; - break; - case RR_Rotate_180: - dst_x1 = screen->width - dstBox.x2; - dst_y1 = screen->height - dstBox.y2; - dst_x2 = screen->width - dstBox.x1; - dst_y2 = screen->height - dstBox.y1; - rot_x1 = (src_w << 16) - x2; - rot_y1 = (src_h << 16) - y2; - rot_x2 = (src_w << 16) - x1; - rot_y2 = (src_h << 16) - y1; - break; - case RR_Rotate_270: - dst_x1 = screen->width - dstBox.y2; - dst_y1 = dstBox.x1; - dst_x2 = screen->width - dstBox.y1; - dst_y2 = dstBox.x2; - rot_x1 = (src_h << 16) - y2; - rot_y1 = x1; - rot_x2 = (src_h << 16) - y1; - rot_y2 = x2; - break; - } - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width + 3) & ~3; - srcPitch2 = ((width >> 1) + 3) & ~3; - size = dstPitch * (int) dst_height; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width << 1); - srcPitch2 = 0; - size = dstPitch * (int) dst_height; - break; - } - - if (pPortPriv->off_screen && size != pPortPriv->size) - { - KdOffscreenFree (pPortPriv->off_screen); - pPortPriv->off_screen = 0; - } - - if (!pPortPriv->off_screen) - { - pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64, - TRUE, mach64VideoSave, - pPortPriv); - if (!pPortPriv->off_screen) - return BadAlloc; - } - - pPortPriv->offset = pPortPriv->off_screen->offset; - pPortPriv->size = size; - /* fixup pointers */ - - pPortPriv->YBuf0Offset = pPortPriv->offset; - pPortPriv->YBuf1Offset = pPortPriv->offset + size; - -#if 0 - mach64WaitIdle (reg); - - if (pPortPriv->videoOn) - { - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - } -#endif - /* - * Use the other buffer - */ - pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; - - /* copy data */ - top = rot_y1 >> 16; - left = (rot_x1 >> 16) & ~1; - npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - top &= ~1; - nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; - mach64CopyPlanarData(screen, buf, randr, - srcPitch, srcPitch2, dstPitch, - rot_src_w, rot_src_h, height, - top, left, nlines, npixels, id); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - nlines = ((rot_y2 + 0xffff) >> 16) - top; - mach64CopyPackedData(screen, buf, randr, - srcPitch, dstPitch, - rot_src_w, rot_src_h, - top, left, nlines, - npixels); - break; - } - - mach64DisplayVideo(screen, id, dstPitch, - rot_x1, rot_y1, rot_x2, rot_y2, - dst_x1, dst_y1, - dst_x2, dst_y2, - rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); - - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey); - } - - pPortPriv->videoOn = TRUE; - - return Success; -} - -static int -mach64QueryImageAttributes(KdScreenInfo *screen, - int id, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) -{ - int size, tmp; - - if(*w > IMAGE_MAX_WIDTH) - *w = IMAGE_MAX_WIDTH; - if(*h > IMAGE_MAX_HEIGHT) - *h = IMAGE_MAX_HEIGHT; - - *w = (*w + 1) & ~1; - if(offsets) offsets[0] = 0; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - *h = (*h + 1) & ~1; - size = (*w + 3) & ~3; - if(pitches) - pitches[0] = size; - size *= *h; - if(offsets) - offsets[1] = size; - tmp = ((*w >> 1) + 3) & ~3; - if(pitches) - pitches[1] = pitches[2] = tmp; - tmp *= (*h >> 1); - size += tmp; - if(offsets) - offsets[2] = size; - size += tmp; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - size = *w << 1; - if(pitches) - pitches[0] = size; - size *= *h; - break; - } - - return size; -} - - -/* client libraries expect an encoding */ -static KdVideoEncodingRec DummyEncoding[1] = -{ - { - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} - } -}; - -#define NUM_FORMATS 3 - -static KdVideoFormatRec Formats[NUM_FORMATS] = -{ - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} -}; - -#define NUM_ATTRIBUTES 3 - -static KdAttributeRec Attributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, - {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} -}; - -#define NUM_IMAGES 4 - -static KdImageRec Images[NUM_IMAGES] = -{ - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - XVIMAGE_UYVY -}; - -static void mach64ResetVideo(KdScreenInfo *screen) -{ -} - -static int -mach64ReputImage (KdScreenInfo *screen, - DrawablePtr pDraw, - short drw_x, - short drw_y, - RegionPtr clipBoxes, - pointer data) -{ - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - BoxPtr pOldExtents = REGION_EXTENTS (screen->pScreen, &pPortPriv->clip); - BoxPtr pNewExtents = REGION_EXTENTS (screen->pScreen, clipBoxes); - - if (pOldExtents->x1 == pNewExtents->x1 && - pOldExtents->x2 == pNewExtents->x2 && - pOldExtents->y1 == pNewExtents->y1 && - pOldExtents->y2 == pNewExtents->y2) - { - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey); - } - return Success; - } - return BadMatch; -} - -static KdVideoAdaptorPtr -mach64SetupImageVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr adapt; - Mach64PortPrivPtr pPortPriv; - - if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + - sizeof(Mach64PortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "Mach64 Video Overlay"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = mach64StopVideo; - adapt->SetPortAttribute = mach64SetPortAttribute; - adapt->GetPortAttribute = mach64GetPortAttribute; - adapt->QueryBestSize = mach64QueryBestSize; - adapt->PutImage = mach64PutImage; - adapt->ReputImage = mach64ReputImage; - adapt->QueryImageAttributes = mach64QueryImageAttributes; - - pPortPriv->colorKey = mach64s->colorKey; - pPortPriv->videoOn = FALSE; - pPortPriv->brightness = 0; - pPortPriv->saturation = 0; - pPortPriv->currentBuf = 0; - pPortPriv->off_screen = 0; - pPortPriv->size = 0; - pPortPriv->offset = 0; - - /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); - - mach64s->pAdaptor = adapt; - - xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - xvSaturation = MAKE_ATOM("XV_SATURATION"); - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - - mach64ResetVideo(screen); - - return adapt; -} - -Bool mach64InitVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; - KdVideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - KdCardInfo *card = pScreenPriv->card; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - - mach64s->pAdaptor = NULL; - - if (!mach64c->media_reg) - return FALSE; - - newAdaptor = mach64SetupImageVideo(pScreen); - - num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); - - if(newAdaptor) - { - if(!num_adaptors) - { - num_adaptors = 1; - adaptors = &newAdaptor; - } - else - { - newAdaptors = xalloc((num_adaptors + 1) * - sizeof(KdVideoAdaptorPtr*)); - if(newAdaptors) - { - memcpy(newAdaptors, adaptors, - num_adaptors * sizeof(KdVideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - KdXVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - return TRUE; -} - -void -mach64FiniVideo (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - KdVideoAdaptorPtr adapt = mach64s->pAdaptor; - - if (adapt) - { - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); - REGION_UNINIT (pScreen, &pPortPriv->clip); - xfree (adapt); - } -} diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am deleted file mode 100644 index 56fa3a0cf..000000000 --- a/hw/kdrive/mga/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xmga - -noinst_LIBRARIES = libmga.a - -if TSLIB -TSLIB_FLAG = -lts -endif - -libmga_a_SOURCES = \ - mgadraw.c \ - mga.c \ - mga.h - -Xmga_SOURCES = \ - mgastub.c - -Xmga_LDADD = \ - libmga.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - diff --git a/hw/kdrive/mga/mga.c b/hw/kdrive/mga/mga.c deleted file mode 100644 index 556b9b18f..000000000 --- a/hw/kdrive/mga/mga.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mga.h" - -static Bool -mgaCardInit (KdCardInfo *card) -{ - MgaCardInfo *mgac; - - mgac = (MgaCardInfo *) xalloc (sizeof (MgaCardInfo)); - if (!mgac) - return FALSE; - - mgaMapReg (card, mgac); - - if (!vesaInitialize (card, &mgac->vesa)) - { - xfree (mgac); - return FALSE; - } - - mgac->fifo_size = 0; - - card->driver = mgac; - - return TRUE; -} - -static Bool -mgaScreenInit (KdScreenInfo *screen) -{ - MgaScreenInfo *mgas; - - mgas = (MgaScreenInfo *) xalloc (sizeof (MgaScreenInfo)); - if (!mgas) - return FALSE; - memset (mgas, '\0', sizeof (MgaScreenInfo)); - if (!vesaScreenInitialize (screen, &mgas->vesa)) - { - xfree (mgas); - return FALSE; - } -#if 0 - /* if (!mgac->reg) - screen->dumb = TRUE; */ - - if (mgas->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - - fprintf (stderr, "vesa mapping is %d\n", mgas->vesa.mapping); -#endif - screen->driver = mgas; - return TRUE; -} - -static Bool -mgaInitScreen (ScreenPtr pScreen) -{ - return vesaInitScreen (pScreen); -} - -static Bool -mgaFinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - - ret = vesaFinishInitScreen (pScreen); - - return ret; -} - -static Bool -mgaCreateResources (ScreenPtr pScreen) -{ - return vesaCreateResources (pScreen); -} - -static void -mgaPreserve (KdCardInfo *card) -{ - vesaPreserve (card); -} - -Bool -mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac) -{ - mgac->reg_base = (CARD8 *) KdMapDevice (MGA_REG_BASE (card), - MGA_REG_SIZE (card)); - - if (!mgac->reg_base) - { - return FALSE; - } - - KdSetMappedMode (MGA_REG_BASE (card), - MGA_REG_SIZE (card), - KD_MAPPED_MODE_REGISTERS); - - return TRUE; -} - -void -mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac) -{ - if (mgac->reg_base) - { - KdResetMappedMode (MGA_REG_BASE (card), - MGA_REG_SIZE (card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) mgac->reg_base, MGA_REG_SIZE (card)); - mgac->reg_base = 0; - // mgac->reg = 0; - } -} - -void -mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac) -{ - if (!mgac->reg_base) - mgaMapReg (card, mgac); -} - -void -mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac) -{ - mgaUnmapReg (card, mgac); -} - -static Bool -mgaDPMS (ScreenPtr pScreen, int mode) -{ - /* XXX */ - return TRUE; -} - -static Bool -mgaEnable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - MgaCardInfo *mgac = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - - mgaSetMMIO (pScreenPriv->card, mgac); - mgaDPMS (pScreen, KD_DPMS_NORMAL); - - return TRUE; -} - -static void -mgaDisable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - MgaCardInfo *mgac = pScreenPriv->card->driver; - - mgaResetMMIO (pScreenPriv->card, mgac); - - vesaDisable (pScreen); -} - -static void -mgaRestore (KdCardInfo *card) -{ - MgaCardInfo *mgac = card->driver; - - mgaResetMMIO (card, mgac); - vesaRestore (card); -} - -static void -mgaScreenFini (KdScreenInfo *screen) -{ - MgaScreenInfo *mgas = (MgaScreenInfo *) screen->driver; - - vesaScreenFini (screen); - xfree (mgas); - screen->driver = 0; -} - -static void -mgaCardFini (KdCardInfo *card) -{ - MgaCardInfo *mgac = (MgaCardInfo *)card->driver; - - mgaUnmapReg (card, mgac); - vesaCardFini (card); -} - -KdCardFuncs mgaFuncs = { - mgaCardInit, /* cardinit */ - mgaScreenInit, /* scrinit */ - mgaInitScreen, /* initScreen */ - mgaFinishInitScreen, /* finishInitScreen */ - mgaCreateResources, /* createRes */ - mgaPreserve, /* preserve */ - mgaEnable, /* enable */ - mgaDPMS, /* dpms */ - mgaDisable, /* disable */ - mgaRestore, /* restore */ - mgaScreenFini, /* scrfini */ - mgaCardFini, /* cardfini */ - - 0, /* initCursor */ - 0, /* enableCursor */ - 0, /* disableCursor */ - 0, /* finiCursor */ - 0, /* recolorCursor */ - - mgaDrawInit, /* initAccel */ - mgaDrawEnable, /* enableAccel */ - mgaDrawSync, /* syncAccel */ - mgaDrawDisable, /* disableAccel */ - mgaDrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; - diff --git a/hw/kdrive/mga/mga.h b/hw/kdrive/mga/mga.h deleted file mode 100644 index ff9716d85..000000000 --- a/hw/kdrive/mga/mga.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ - -#ifndef _MGA_H_ -#define _MGA_H_ -#include <vesa.h> -#include <klinux.h> - -#define MGA_REG_BASE(c) ((c)->attr.address[1]) -#define MGA_REG_SIZE(c) (0x4000) - -#define MGA_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v)) -#define MGA_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a))) - -#define MGA_REG_EXEC (0x0100) -#define MGA_REG_DWGCTL (0x1c00) -#define MGA_REG_PLNWT (0x1c1c) -#define MGA_REG_FCOL (0x1c24) -#define MGA_REG_MACCESS (0x1c04) -#define MGA_REG_SGN (0x1c58) -#define MGA_REG_AR0 (0x1c60) -#define MGA_REG_AR1 (0x1c64) -#define MGA_REG_AR2 (0x1c68) -#define MGA_REG_AR3 (0x1c6C) -#define MGA_REG_AR4 (0x1c70) -#define MGA_REG_AR5 (0x1c74) -#define MGA_REG_AR6 (0x1c78) - -#define MGA_REG_CXBNDRY (0x1c80) -#define MGA_REG_FXBNDRY (0x1c84) -#define MGA_REG_YDSTLEN (0x1c88) -#define MGA_REG_PITCH (0x1c8c) -#define MGA_REG_YTOP (0x1c98) -#define MGA_REG_YBOT (0x1c9c) -#define MGA_REG_FIFOSTATUS (0x1e10) -#define MGA_REG_STATUS (0x1e14) -#define MGA_REG_SRCORG (0x2cb4) -#define MGA_REG_DSTORG (0x2cb8) - -#define MGA_PW8 (0) -#define MGA_PW16 (1) -#define MGA_PW24 (2) -#define MGA_PW32 (3) - -/* Drawing opcodes */ -#define MGA_OPCOD_TRAP (4) -#define MGA_OPCOD_BITBLT (8) - -#define MGA_DWGCTL_SOLID (1 << 11) -#define MGA_DWGCTL_ARZERO (1 << 12) -#define MGA_DWGCTL_SGNZERO (1 << 13) -#define MGA_DWGCTL_SHIFTZERO (1 << 14) - -#define MGA_DWGCTL_BFCOL (2 << 25) - -#define MGA_ATYPE_RPL (0 << 4) -#define MGA_ATYPE_RSTR (1 << 4) -#define MGA_ATYPE_ZI (3 << 4) -#define MGA_ATYPE_BLK (4 << 4) -#define MGA_ATYPE_I (7 << 4) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _mgaCardInfo { - VesaCardPrivRec vesa; - CARD8 *reg_base; - int fifo_size; -} MgaCardInfo; - -#define getMgaCardInfo(kd) ((MgaCardInfo *) ((kd)->card->driver)) -#define mgaCardInfo(kd) MgaCardInfo *mgac = getMgaCardInfo(kd) - -typedef struct _mgaScreenInfo { - VesaScreenPrivRec vesa; - - int pitch; - int pw; - -} MgaScreenInfo; - -#define getMgaScreenInfo(kd) ((MgaScreenInfo *) ((kd)->screen->driver)) -#define mgaScreenInfo(kd) MgaScreenInfo *mgas = getMgaScreenInfo(kd) - -Bool -mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac); - -void -mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac); - -void -mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac); - -void -mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac); - -Bool -mgaDrawSetup (ScreenPtr pScreen); - -Bool -mgaDrawInit (ScreenPtr pScreen); - -void -mgaDrawEnable (ScreenPtr pScreen); - -void -mgaDrawSync (ScreenPtr pScreen); - -void -mgaDrawDisable (ScreenPtr pScreen); - -void -mgaDrawFini (ScreenPtr pScreen); - -extern KdCardFuncs mgaFuncs; - -#endif /* _MGA_H_ */ diff --git a/hw/kdrive/mga/mgadraw.c b/hw/kdrive/mga/mgadraw.c deleted file mode 100644 index 04cd44fc9..000000000 --- a/hw/kdrive/mga/mgadraw.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mga.h" - -CARD32 mgaRop[16] = { - /* GXclear */ MGA_ATYPE_RPL | 0x00000000, /* 0 */ - /* GXand */ MGA_ATYPE_RSTR | 0x00080000, /* src AND dst */ - /* GXandReverse */ MGA_ATYPE_RSTR | 0x00040000, /* src AND NOT dst */ - /* GXcopy */ MGA_ATYPE_RSTR | 0x000c0000, /* src */ - /* GXandInverted */ MGA_ATYPE_RSTR | 0x00020000, /* NOT src AND dst */ - /* GXnoop */ MGA_ATYPE_RSTR | 0x000a0000, /* dst */ - /* GXxor */ MGA_ATYPE_RSTR | 0x00060000, /* src XOR dst */ - /* GXor */ MGA_ATYPE_RSTR | 0x000e0000, /* src OR dst */ - /* GXnor */ MGA_ATYPE_RSTR | 0x00010000, /* NOT src AND NOT dst */ - /* GXequiv */ MGA_ATYPE_RSTR | 0x00090000, /* NOT src XOR dst */ - /* GXinvert */ MGA_ATYPE_RSTR | 0x00050000, /* NOT dst */ - /* GXorReverse */ MGA_ATYPE_RSTR | 0x000d0000, /* src OR NOT dst */ - /* GXcopyInverted */ MGA_ATYPE_RPL | 0x00030000, /* NOT src */ - /* GXorInverted */ MGA_ATYPE_RSTR | 0x000b0000, /* NOT src OR dst */ - /* GXnand */ MGA_ATYPE_RSTR | 0x00070000, /* NOT src OR NOT dst */ - /* GXset */ MGA_ATYPE_RPL | 0x000f0000 /* 1 */ -}; - -static VOL8 *mmio; -int fifo_size; -int pitch, src_pitch; -int dir; - -static void -mgaWaitAvail (int n) -{ - if (fifo_size < n) { - while ((fifo_size = MGA_IN32 (mmio, MGA_REG_FIFOSTATUS) & 0xff) < n) - ; - } - - fifo_size -= n; -} - -static void -mgaWaitIdle (void) -{ - while (MGA_IN32 (mmio, MGA_REG_STATUS) & 0x10000); -} - -static Bool -mgaSetup (ScreenPtr pScreen, int wait) -{ - KdScreenPriv (pScreen); - mgaScreenInfo (pScreenPriv); - mgaCardInfo (pScreenPriv); - - fifo_size = 0; - mmio = mgac->reg_base; - pitch = mgas->pitch; - - if (!mmio) - return FALSE; - - mgaWaitAvail (wait + 4); - MGA_OUT32 (mmio, MGA_REG_MACCESS, mgas->pw); - MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000); - MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000); - MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff); - - return TRUE; -} - -static Bool -mgaPrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg) -{ - KdScreenPriv(pPixmap->drawable.pScreen); - int cmd; - int dst_org; - - cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO | - MGA_DWGCTL_SHIFTZERO | mgaRop[alu]; - - dst_org = (int)pPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base; - - mgaSetup (pPixmap->drawable.pScreen, 5); - - MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org); - MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3)); - MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); - MGA_OUT32 (mmio, MGA_REG_FCOL, fg); - MGA_OUT32 (mmio, MGA_REG_PLNWT, pm); - - return TRUE; -} - -static void -mgaSolid (int x1, int y1, int x2, int y2) -{ - mgaWaitAvail (2); - - MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff)); - MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1)); -} - -static void -mgaDoneSolid (void) -{ -} - -#define BLIT_LEFT 1 -#define BLIT_UP 4 - -static Bool -mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, - int dx, int dy, int alu, Pixel pm) -{ - KdScreenPriv(pSrcPixmap->drawable.pScreen); - - int cmd; - - cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu]; - - dir = 0; - - if (dy < 0) - dir |= BLIT_UP; - if (dx < 0) - dir |= BLIT_LEFT; - - mgaSetup (pSrcPixmap->drawable.pScreen, 7); - - MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base)); - MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base)); - MGA_OUT32 (mmio, MGA_REG_PITCH, pDstPixmap->devKind / (pDstPixmap->drawable.bitsPerPixel >> 3)); - src_pitch = pSrcPixmap->devKind / (pSrcPixmap->drawable.bitsPerPixel >> 3); - - MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); - MGA_OUT32 (mmio, MGA_REG_SGN, dir); - MGA_OUT32 (mmio, MGA_REG_PLNWT, pm); - MGA_OUT32 (mmio, MGA_REG_AR5, src_pitch * (dy < 0 ? -1 : 1) ); - - return TRUE; -} - -static void -mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h) -{ - int start, end; - - if (dir & BLIT_UP) - { - srcY += h - 1; - dstY += h - 1; - } - - w--; - start = end = srcY * src_pitch + srcX; - - if (dir & BLIT_LEFT) - start += w; - else - end += w; - - mgaWaitAvail (4); - MGA_OUT32 (mmio, MGA_REG_AR0, end); - MGA_OUT32 (mmio, MGA_REG_AR3, start); - MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff)); - MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h); -} - -static void -mgaDoneCopy (void) -{ -} - -KaaScreenInfoRec mgaKaa = { - mgaPrepareSolid, - mgaSolid, - mgaDoneSolid, - - mgaPrepareCopy, - mgaCopy, - mgaDoneCopy, - - 192, /* Offscreen byte alignment */ - 64, /* Offset pitch */ - KAA_OFFSCREEN_PIXMAPS, /* Flags */ -}; - -Bool -mgaDrawInit (ScreenPtr pScreen) -{ - if (!kaaDrawInit (pScreen, &mgaKaa)) - return FALSE; - - return TRUE; -} - -void -mgaDrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - mgaScreenInfo (pScreenPriv); - - mgas->pitch = pScreenPriv->screen->width; - - switch (pScreenPriv->screen->fb[0].depth) { - case 8: - mgas->pw = MGA_PW8; - break; - case 16: - mgas->pw = MGA_PW16; - break; - case 24: - mgas->pw = MGA_PW24; - break; - case 32: - mgas->pw = MGA_PW32; - break; - default: - FatalError ("unsupported pixel format"); - } - - KdMarkSync (pScreen); -} - -void -mgaDrawDisable (ScreenPtr pScreen) -{ -} - -void -mgaDrawFini (ScreenPtr pScreen) -{ -} - -void -mgaDrawSync (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - mgaCardInfo (pScreenPriv); - - mmio = mgac->reg_base; - - mgaWaitIdle (); -} diff --git a/hw/kdrive/mga/mgastub.c b/hw/kdrive/mga/mgastub.c deleted file mode 100644 index 45f6f5792..000000000 --- a/hw/kdrive/mga/mgastub.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mga.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x102b, 0x0525, 0, &attr)) - KdCardInfoAdd (&mgaFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/nvidia/Makefile.am b/hw/kdrive/nvidia/Makefile.am deleted file mode 100644 index 41ad93691..000000000 --- a/hw/kdrive/nvidia/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xnvidia - -noinst_LIBRARIES = libnvidia.a - -# nvidiavideo.c - -libnvidia_a_SOURCES = \ - nvidia.c \ - nvidiadraw.c \ - fourcc.h \ - nvidia.h \ - nvidiadraw.h - - -Xnvidia_SOURCES = \ - nvidiastub.c - -Xnvidia_LDADD = \ - libnvidia.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ diff --git a/hw/kdrive/nvidia/fourcc.h b/hw/kdrive/nvidia/fourcc.h deleted file mode 100644 index b19f5decc..000000000 --- a/hw/kdrive/nvidia/fourcc.h +++ /dev/null @@ -1,134 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.4 2003/04/23 21:51:24 tsi Exp $ */ - -/* - This header file contains listings of STANDARD guids for video formats. - Please do not place non-registered, or incomplete entries in this file. - A list of some popular fourcc's are at: http://www.webartz.com/fourcc/ - For an explanation of fourcc <-> guid mappings see RFC2361. -*/ - -#ifndef _XF86_FOURCC_H_ -#define _XF86_FOURCC_H_ 1 - -#define FOURCC_YUY2 0x32595559 -#define XVIMAGE_YUY2 \ - { \ - FOURCC_YUY2, \ - XvYUV, \ - LSBFirst, \ - {'Y','U','Y','2', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 1, 1, \ - {'Y','U','Y','V', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_YV12 0x32315659 -#define XVIMAGE_YV12 \ - { \ - FOURCC_YV12, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','1','2', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 12, \ - XvPlanar, \ - 3, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 2, 2, \ - {'Y','V','U', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_I420 0x30323449 -#define XVIMAGE_I420 \ - { \ - FOURCC_I420, \ - XvYUV, \ - LSBFirst, \ - {'I','4','2','0', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 12, \ - XvPlanar, \ - 3, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 2, 2, \ - {'Y','U','V', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - - -#define FOURCC_UYVY 0x59565955 -#define XVIMAGE_UYVY \ - { \ - FOURCC_UYVY, \ - XvYUV, \ - LSBFirst, \ - {'U','Y','V','Y', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 2, 2, \ - 1, 1, 1, \ - {'U','Y','V','Y', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_IA44 0x34344149 -#define XVIMAGE_IA44 \ - { \ - FOURCC_IA44, \ - XvYUV, \ - LSBFirst, \ - {'I','A','4','4', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 8, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 1, 1, \ - 1, 1, 1, \ - {'A','I', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_AI44 0x34344941 -#define XVIMAGE_AI44 \ - { \ - FOURCC_AI44, \ - XvYUV, \ - LSBFirst, \ - {'A','I','4','4', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 8, \ - XvPacked, \ - 1, \ - 0, 0, 0, 0, \ - 8, 8, 8, \ - 1, 1, 1, \ - 1, 1, 1, \ - {'I','A', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#endif /* _XF86_FOURCC_H_ */ diff --git a/hw/kdrive/nvidia/nvidia.c b/hw/kdrive/nvidia/nvidia.c deleted file mode 100644 index fa53476b1..000000000 --- a/hw/kdrive/nvidia/nvidia.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "nvidia.h" -#include <sys/io.h> - -static Bool -nvidiaCardInit (KdCardInfo *card) -{ - NvidiaCardInfo *nvidiac; - - nvidiac = (NvidiaCardInfo *) xalloc (sizeof (NvidiaCardInfo)); - if (!nvidiac) - return FALSE; - - (void) nvidiaMapReg (card, nvidiac); - - if (!vesaInitialize (card, &nvidiac->vesa)) - { - xfree (nvidiac); - return FALSE; - } - - card->driver = nvidiac; - - return TRUE; -} - -static Bool -nvidiaScreenInit (KdScreenInfo *screen) -{ - NvidiaCardInfo *nvidiac = screen->card->driver; - NvidiaScreenInfo *nvidias; - int screen_size, memory; - - nvidias = (NvidiaScreenInfo *) xalloc (sizeof (NvidiaScreenInfo)); - if (!nvidias) - return FALSE; - memset (nvidias, '\0', sizeof (NvidiaScreenInfo)); - if (!vesaScreenInitialize (screen, &nvidias->vesa)) - { - xfree (nvidias); - return FALSE; - } - if (!nvidiac->reg_base) - screen->dumb = TRUE; - if (nvidias->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - nvidias->screen = nvidias->vesa.fb; - memory = nvidias->vesa.fb_size; - screen_size = screen->fb[0].byteStride * screen->height; - if (nvidias->screen && memory >= screen_size + 2048) - { - memory -= 2048; - nvidias->cursor_base = nvidias->screen + memory - 2048; - } - else - nvidias->cursor_base = 0; - screen->softCursor = TRUE; /* XXX for now */ - memory -= screen_size; - if (memory > screen->fb[0].byteStride) - { - nvidias->off_screen = nvidias->screen + screen_size; - nvidias->off_screen_size = memory; - } - else - { - nvidias->off_screen = 0; - nvidias->off_screen_size = 0; - } - screen->driver = nvidias; - return TRUE; -} - -static Bool -nvidiaInitScreen (ScreenPtr pScreen) -{ -#if 0 -#ifdef XV - KdScreenPriv(pScreen); - NvidiaCardInfo *nvidiac = pScreenPriv->screen->card->driver; - if (nvidiac->media_reg && nvidiac->reg) - nvidiaInitVideo(pScreen); -#endif -#endif - return vesaInitScreen (pScreen); -} - -#ifdef RANDR -static Bool -nvidiaRandRSetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - KdCheckSync (pScreen); - - if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize)) - return FALSE; - - return TRUE; -} - -static void -nvidiaRandRInit (ScreenPtr pScreen) -{ - rrScrPriv(pScreen); - - pScrPriv->rrSetConfig = nvidiaRandRSetConfig; -} -#endif - -static Bool -nvidiaFinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - ret = vesaFinishInitScreen (pScreen); -#ifdef RANDR - nvidiaRandRInit (pScreen); -#endif - return ret; -} - -void -nvidiaPreserve (KdCardInfo *card) -{ - vesaPreserve(card); -} - -void -nvidiaOutb (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 val) -{ - asm volatile ("outb %b0,%w1" : : "a" (val), "d" (port)); -} - -CARD8 -nvidiaInb (NvidiaCardInfo *nvidiac, CARD16 port) -{ - CARD8 v; - asm volatile ("inb %w1,%b0" : "=a" (v) : "d" (port)); - return v; -} - -CARD8 -nvidiaGetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id) -{ - CARD8 ret; - DBGOUT ("nvidiaGetIndex(0x%x,0x%x)\n", addr, id); - nvidiaOutb (nvidiac, addr, id); - ret = nvidiaInb (nvidiac, data); - DBGOUT (" -> 0x%x\n", ret); - return ret; -} - -void -nvidiaSetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id, CARD8 val) -{ - DBGOUT ("nvidiaSetIndex(0x%x,0x%x) = 0x%x\n", addr, id, val); - nvidiaOutb (nvidiac, addr, id); - nvidiaOutb (nvidiac, data, val); -} - -static void vgaLockUnlock (NvidiaCardInfo *nvidiac, Bool lock) -{ - CARD8 cr11; - ENTER (); - cr11 = nvidiaGetIndex (nvidiac, 0x3d4, 0x3d5, 0x11); - if (lock) cr11 |= 0x80; - else cr11 &= ~0x80; - nvidiaSetIndex (nvidiac, 0x3d4, 0x3d5, 0x11, cr11); - LEAVE (); -} - -static void nvidiaLockUnlock (NvidiaCardInfo *nvidiac, Bool lock) -{ - if (NVIDIA_IS_3(nvidiac)) - nvidiaSetIndex (nvidiac, 0x3c4, 0x3c5, 0x06, lock ? 0x99 : 0x57); - else - nvidiaSetIndex (nvidiac, 0x3c4, 0x3c5, 0x1f, lock ? 0x99 : 0x57); - vgaLockUnlock(nvidiac, lock); -} - -Bool -nvidiaMapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac) -{ - nvidiac->reg_base = (CARD8 *) KdMapDevice (NVIDIA_REG_BASE(card), - NVIDIA_REG_SIZE(card)); - - if (!nvidiac->reg_base) - { - nvidiac->mmio = 0; - nvidiac->rop = 0; - nvidiac->blt = 0; - nvidiac->rect = 0; - return FALSE; - } - - nvidiac->mmio = (CARD8 *) (nvidiac->reg_base + NVIDIA_MMIO_OFF(card)); - nvidiac->rop = (NvidiaRop *) (nvidiac->reg_base + NVIDIA_ROP_OFF(card)); - nvidiac->rect = (NvidiaRectangle *) (nvidiac->reg_base + NVIDIA_RECTANGLE_OFF(card)); - nvidiac->blt = (NvidiaScreenBlt *) (nvidiac->reg_base + NVIDIA_BLT_OFF(card)); - nvidiac->busy = (NvidiaBusy *) (nvidiac->reg_base + NVIDIA_BUSY_OFF(card)); - KdSetMappedMode (NVIDIA_REG_BASE(card), - NVIDIA_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - return TRUE; -} - -void -nvidiaUnmapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac) -{ - if (nvidiac->reg_base) - { - KdResetMappedMode (NVIDIA_REG_BASE(card), - NVIDIA_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) nvidiac->reg_base, NVIDIA_REG_SIZE(card)); - nvidiac->reg_base = 0; - nvidiac->rop = 0; - nvidiac->blt = 0; - nvidiac->rect = 0; - } -} - -void -nvidiaSetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac) -{ - if (!nvidiac->reg_base) - nvidiaMapReg (card, nvidiac); - nvidiaLockUnlock (nvidiac, FALSE); - nvidiac->fifo_free = 0; - nvidiac->fifo_size = nvidiac->rop->FifoFree.FifoFree; -} - -void -nvidiaResetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac) -{ - nvidiaUnmapReg (card, nvidiac); - nvidiaLockUnlock (nvidiac, TRUE); -} - -Bool -nvidiaEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - NvidiaCardInfo *nvidiac = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - - nvidiaSetMMIO (pScreenPriv->card, nvidiac); -#ifdef XV - KdXVEnable (pScreen); -#endif - return TRUE; -} - -void -nvidiaDisable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - NvidiaCardInfo *nvidiac = pScreenPriv->card->driver; - -#ifdef XV - KdXVDisable (pScreen); -#endif - nvidiaResetMMIO (pScreenPriv->card, nvidiac); - vesaDisable (pScreen); -} - -static Bool -nvidiaDPMS (ScreenPtr pScreen, int mode) -{ - return vesaDPMS (pScreen, mode); -} - -static void -nvidiaRestore (KdCardInfo *card) -{ - NvidiaCardInfo *nvidiac = card->driver; - - nvidiaResetMMIO (card, nvidiac); - vesaRestore (card); -} - -static void -nvidiaScreenFini (KdScreenInfo *screen) -{ - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - - vesaScreenFini (screen); - xfree (nvidias); - screen->driver = 0; -} - -static void -nvidiaCardFini (KdCardInfo *card) -{ - NvidiaCardInfo *nvidiac = card->driver; - - nvidiaUnmapReg (card, nvidiac); - vesaCardFini (card); -} - -#define nvidiaCursorInit 0 /* initCursor */ -#define nvidiaCursorEnable 0 /* enableCursor */ -#define nvidiaCursorDisable 0 /* disableCursor */ -#define nvidiaCursorFini 0 /* finiCursor */ -#define nvidiaRecolorCursor 0 /* recolorCursor */ - -KdCardFuncs nvidiaFuncs = { - nvidiaCardInit, /* cardinit */ - nvidiaScreenInit, /* scrinit */ - nvidiaInitScreen, /* initScreen */ - nvidiaFinishInitScreen, /* finishInitScreen */ - vesaCreateResources, /* createRes */ - nvidiaPreserve, /* preserve */ - nvidiaEnable, /* enable */ - nvidiaDPMS, /* dpms */ - nvidiaDisable, /* disable */ - nvidiaRestore, /* restore */ - nvidiaScreenFini, /* scrfini */ - nvidiaCardFini, /* cardfini */ - - nvidiaCursorInit, /* initCursor */ - nvidiaCursorEnable, /* enableCursor */ - nvidiaCursorDisable, /* disableCursor */ - nvidiaCursorFini, /* finiCursor */ - nvidiaRecolorCursor, /* recolorCursor */ - - nvidiaDrawInit, /* initAccel */ - nvidiaDrawEnable, /* enableAccel */ - nvidiaDrawSync, /* syncAccel */ - nvidiaDrawDisable, /* disableAccel */ - nvidiaDrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; diff --git a/hw/kdrive/nvidia/nvidia.h b/hw/kdrive/nvidia/nvidia.h deleted file mode 100644 index 083ffc0ea..000000000 --- a/hw/kdrive/nvidia/nvidia.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifndef _NVIDIA_H_ -#define _NVIDIA_H_ -#include <vesa.h> -#include "kxv.h" -#include "klinux.h" - -/* - * offset from ioport beginning - */ - -#define DEBUG -#ifdef DEBUG -#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a) -#else -#define DBGOUT(fmt,a...) -#endif - -#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__) -#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__) - -#define NVIDIA_REG_BASE(c) ((c)->attr.address[0]) -#define NVIDIA_REG_SIZE(c) (16 * 1024 * 1024) - -#define NVIDIA_PCIO_OFF(c) (0x601000) -#define NVIDIA_MMIO_OFF(c) (NVIDIA_PCIO_OFF(c) + 0) -#define NVIDIA_FIFO_OFF(c) (0x800000) -#define NVIDIA_ROP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0) -#define NVIDIA_CLIP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x2000) -#define NVIDIA_PATT_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x4000) -#define NVIDIA_PIXMAP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x6000) -#define NVIDIA_BLT_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x8000) -#define NVIDIA_RECTANGLE_OFF(c) (NVIDIA_FIFO_OFF(c) + 0xa000) -#define NVIDIA_LINE_OFF(c) (NVIDIA_FIFO_OFF(c) + 0xc000) -#define NVIDIA_IS_3(c) (0) -#define NVIDIA_BUSY(c) (NVIDIA_IS_3(c) ? 0x6b0 : 0x700) -#define NVIDIA_BUSY_OFF(c) (0x400000 + NVIDIA_BUSY(c)) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -#define NVIDIA_XY(x,y) ((x) | ((y) << 16)) - -typedef struct { -#if X_BYTE_ORDER == X_BIG_ENDIAN - VOL32 FifoFree; -#else - VOL16 FifoFree; - VOL16 Nop; -#endif -} NvidiaFifoFree; - -/* - * Raster OPeration. Windows style ROP3. - */ -typedef struct { - VOL32 reserved00[4]; - NvidiaFifoFree FifoFree; - VOL32 reserved01[0x0BB]; - VOL32 Rop3; -} NvidiaRop; - -/* - * 2D filled rectangle. - */ -typedef struct { - VOL32 reserved00[4]; - NvidiaFifoFree FifoFree; - VOL32 reserved01[0x0BB]; - VOL32 reserved03[(0x040)-1]; - VOL32 Color1A; - VOL32 TopLeft; - VOL32 WidthHeight; -} NvidiaRectangle; - -/* - * 2D screen-screen BLT. - */ -typedef struct { - VOL32 reserved00[4]; - NvidiaFifoFree FifoFree; - VOL32 reserved01[0x0BB]; - VOL32 TopLeftSrc; - VOL32 TopLeftDst; - VOL32 WidthHeight; -} NvidiaScreenBlt; - -typedef struct { - VOL32 busy; -} NvidiaBusy; - -typedef struct _nvidiaCardInfo { - VesaCardPrivRec vesa; - CARD8 *reg_base; - int fifo_free; - int fifo_size; - CARD8 *mmio; - NvidiaRop *rop; - NvidiaRectangle *rect; - NvidiaScreenBlt *blt; - NvidiaBusy *busy; -} NvidiaCardInfo; - -#define getNvidiaCardInfo(kd) ((NvidiaCardInfo *) ((kd)->card->driver)) -#define nvidiaCardInfo(kd) NvidiaCardInfo *nvidiac = getNvidiaCardInfo(kd) - -/* - * Xv information, optional - */ -typedef struct _nvidiaPortPriv { - CARD32 YBuf0Offset; - - CARD32 YBuf1Offset; - - CARD8 currentBuf; - - int brightness; - int saturation; - - RegionRec clip; - CARD32 colorKey; - - Bool videoOn; - Time offTime; - Time freeTime; - CARD32 size; - CARD32 offset; -} NvidiaPortPrivRec, *NvidiaPortPrivPtr; - -Bool nvidiaInitVideo(ScreenPtr pScreen); - -typedef struct _nvidiaScreenInfo { - VesaScreenPrivRec vesa; - CARD8 *cursor_base; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - KdVideoAdaptorPtr pAdaptor; -} NvidiaScreenInfo; - -#define getNvidiaScreenInfo(kd) ((NvidiaScreenInfo *) ((kd)->screen->driver)) -#define nvidiaScreenInfo(kd) NvidiaScreenInfo *nvidias = getNvidiaScreenInfo(kd) - -void -nvidiaPreserve (KdCardInfo *card); - -void -nvidiaOutb (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 val); - -CARD8 -nvidiaInb (NvidiaCardInfo *nvidiac, CARD16 port); - -CARD8 -nvidiaGetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id); - -void -nvidiaSetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id, CARD8 val); - -Bool -nvidiaMapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac); - -void -nvidiaUnmapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac); - -void -nvidiaSetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac); - -void -nvidiaResetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac); - -Bool -nvidiaEnable (ScreenPtr pScreen); - -void -nvidiaDisable (ScreenPtr pScreen); - -void -nvidiaWait (NvidiaCardInfo *card, NvidiaFifoFree *free, int n); - -void -nvidiaWaitIdle (NvidiaCardInfo *card); - -Bool -nvidiaDrawSetup (ScreenPtr pScreen); - -Bool -nvidiaDrawInit (ScreenPtr pScreen); - -void -nvidiaDrawReinit (ScreenPtr pScreen); - -void -nvidiaDrawEnable (ScreenPtr pScreen); - -void -nvidiaDrawSync (ScreenPtr pScreen); - -void -nvidiaDrawDisable (ScreenPtr pScreen); - -void -nvidiaDrawFini (ScreenPtr pScreen); - -CARD8 -nvidiaReadIndex (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 index); - -void -nvidiaWriteIndex (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 index, CARD8 value); - -Bool -nvidiaCursorInit (ScreenPtr pScreen); - -void -nvidiaCursorEnable (ScreenPtr pScreen); - -void -nvidiaCursorDisable (ScreenPtr pScreen); - -void -nvidiaCursorFini (ScreenPtr pScreen); - -void -nvidiaRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); - -extern KdCardFuncs nvidiaFuncs; - -#endif /* _NVIDIA_H_ */ diff --git a/hw/kdrive/nvidia/nvidiacurs.c b/hw/kdrive/nvidia/nvidiacurs.c deleted file mode 100644 index b5d7cd16c..000000000 --- a/hw/kdrive/nvidia/nvidiacurs.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Id: tridentcurs.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.6 2000/09/03 05:11:20 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 *) tridents->screen; - 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; -} diff --git a/hw/kdrive/nvidia/nvidiadraw.c b/hw/kdrive/nvidia/nvidiadraw.c deleted file mode 100644 index b49ed7805..000000000 --- a/hw/kdrive/nvidia/nvidiadraw.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "nvidia.h" -#include "nvidiadraw.h" - -#include <X11/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" -#include "picturestr.h" - -CARD8 nvidiaRop[16] = { - /* GXclear */ 0x01, /* 0 */ - /* GXand */ 0x0c, /* src AND dst */ - /* GXandReverse */ 0x0d, /* src AND NOT dst */ - /* GXcopy */ 0x07, /* src */ - /* GXandInverted*/ 0x0e, /* NOT src AND dst */ - /* GXnoop */ 0x03, /* dst */ - /* GXxor */ 0x05, /* src XOR dst */ - /* GXor */ 0x0b, /* src OR dst */ - /* GXnor */ 0x0f, /* NOT src AND NOT dst */ - /* GXequiv */ 0x06, /* NOT src XOR dst */ - /* GXinvert */ 0x00, /* NOT dst */ - /* GXorReverse */ 0x0a, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x04, /* NOT src */ - /* GXorInverted */ 0x09, /* NOT src OR dst */ - /* GXnand */ 0x08, /* NOT src OR NOT dst */ - /* GXset */ 0x02, /* 1 */ -}; - -static NvidiaCardInfo *card; - -void -nvidiaWait (NvidiaCardInfo *card, NvidiaFifoFree *free, int n) -{ - while (card->fifo_free < n) - { - card->fifo_free = free->FifoFree >> 2; - } - card->fifo_free -= n; -} - -void -nvidiaWaitIdle (NvidiaCardInfo *card) -{ - while (card->fifo_free < card->fifo_size || (card->busy->busy & 1)) - { - card->fifo_free = card->rop->FifoFree.FifoFree >> 2; - } -} - -static Bool -nvidiaPrepareSolid (PixmapPtr pPixmap, - int alu, - Pixel pm, - Pixel fg) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - - card = nvidiac; - if (~pm & FbFullMask(pPixmap->drawable.depth)) - return FALSE; - nvidiaWait (nvidiac, &nvidiac->rop->FifoFree, 1); - nvidiac->rop->Rop3 = nvidiaRop[alu]; - nvidiaWait (nvidiac, &nvidiac->rect->FifoFree, 1); - nvidiac->rect->Color1A = fg; - return TRUE; -} - -static void -nvidiaSolid (int x1, int y1, int x2, int y2) -{ - nvidiaWait (card, &card->rect->FifoFree, 2); - card->rect->TopLeft = NVIDIA_XY(x1,y1); - card->rect->WidthHeight = NVIDIA_XY(x2-x1,y2-y1); -} - -static void -nvidiaDoneSolid (void) -{ -} - - -static Bool -nvidiaPrepareCopy (PixmapPtr pSrcPixmap, - PixmapPtr pDstPixmap, - int dx, - int dy, - int alu, - Pixel pm) -{ - ScreenPtr pScreen = pDstPixmap->drawable.pScreen; - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - - card = nvidiac; - if (~pm & FbFullMask(pDstPixmap->drawable.depth)) - return FALSE; - nvidiaWait (nvidiac, &card->rop->FifoFree, 1); - nvidiac->rop->Rop3 = nvidiaRop[alu]; - return TRUE; -} - -static void -nvidiaCopy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - nvidiaWait (card, &card->blt->FifoFree, 3); - card->blt->TopLeftSrc = NVIDIA_XY(srcX, srcY); - card->blt->TopLeftDst = NVIDIA_XY(dstX, dstY); - card->blt->WidthHeight = NVIDIA_XY(w, h); -} - -static void -nvidiaDoneCopy (void) -{ -} - -KaaScreenInfoRec nvidiaKaa = { - nvidiaPrepareSolid, - nvidiaSolid, - nvidiaDoneSolid, - - nvidiaPrepareCopy, - nvidiaCopy, - nvidiaDoneCopy, -}; - -Bool -nvidiaDrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - Bool ret = TRUE; - - ENTER (); - if (pScreenPriv->screen->fb[0].depth == 4) - ret = FALSE; - - if (ret && !nvidiac->rop) - { - ErrorF ("Failed to map fifo registers\n"); - ret = FALSE; - } - if (ret && !nvidiac->rop->FifoFree.FifoFree) - { - ErrorF ("Fifo appears broken\n"); - ret = FALSE; - } - if (ret && !kaaDrawInit (pScreen, &nvidiaKaa)) - { - ErrorF ("kaaDrawInit failed\n"); - ret = FALSE; - } - - LEAVE (); - return ret; -} - -#define PIX_FORMAT_MONO 0 -#define PIX_FORMAT_PSEUDO_8 2 -#define PIX_FORMAT_TRUE_1555 3 -#define PIX_FORMAT_TRUE_565 4 -#define PIX_FORMAT_TRUE_8888 6 -#define PIX_FORMAT_TRUE_332 7 -#define PIX_FORMAT_GRAY_8 8 -#define PIX_FORMAT_YUV_422 0xb -#define PIX_FORMAT_YUV_444 0xe -#define PIX_FORMAT_TRUE_4444 0xf - -void -nvidiaDrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - - ENTER (); - nvidiac->fifo_size = nvidiac->rop->FifoFree.FifoFree; - nvidiac->fifo_free = 0; - KdMarkSync (pScreen); - LEAVE (); -} - -void -nvidiaDrawDisable (ScreenPtr pScreen) -{ -} - -void -nvidiaDrawFini (ScreenPtr pScreen) -{ -} - -void -nvidiaDrawSync (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - - nvidiaWaitIdle (nvidiac); -} diff --git a/hw/kdrive/nvidia/nvidiadraw.h b/hw/kdrive/nvidia/nvidiadraw.h deleted file mode 100644 index b7053ae49..000000000 --- a/hw/kdrive/nvidia/nvidiadraw.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Id: tridentdraw.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.4 2000/10/11 06:04:40 keithp Exp $ */ - -#ifndef _TRIDENTDRAW_H_ -#define _TRIDENTDRAW_H_ - -#define SetupTrident(s) KdScreenPriv(s); \ - tridentCardInfo(pScreenPriv); \ - Cop *cop = tridentc->cop - -#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) - -#define _tridentInit(cop,tridentc) { \ - if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \ - (cop)->multi = (tridentc)->cop_depth; \ - (cop)->multi = (tridentc)->cop_stride; \ - (cop)->multi = TridentAlpha; \ -} \ - -#define _tridentSetSolidRect(cop,pix,alu,cmd) {\ - 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); \ - _tridentWaitDone(cop); \ - (cop)->command = (cmd); \ -} - -#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ - COP_STATUS_DPE_BUSY | \ - COP_STATUS_MI_BUSY) - -#define _tridentWaitDone(cop) { \ - int __q__ = 500000; \ - while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ - ; \ - if (!__q__) \ - (cop)->status = 0; \ -} - -#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop) - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/nvidia/nvidiastub.c b/hw/kdrive/nvidia/nvidiastub.c deleted file mode 100644 index 285a73844..000000000 --- a/hw/kdrive/nvidia/nvidiastub.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "nvidia.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x10de, 0x0112, 0, &attr)) - KdCardInfoAdd (&nvidiaFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/nvidia/nvidiavideo.c b/hw/kdrive/nvidia/nvidiavideo.c deleted file mode 100644 index 04cc8044c..000000000 --- a/hw/kdrive/nvidia/nvidiavideo.c +++ /dev/null @@ -1,1018 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "nvidia.h" - -#include <X11/extensions/Xv.h> -#include "fourcc.h" - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -static Atom xvBrightness, xvSaturation, xvColorKey; - -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 - -static void -nvidiaStopVideo(KdScreenInfo *screen, pointer data, Bool exit) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = nvidiac->reg; - MediaReg *media = nvidiac->media_reg; - - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - - if (!media) - return; - - if(pPortPriv->videoOn) - { - nvidiaWaitIdle (reg); - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - /* wait for buffer to be finished */ - while (((media->TRIG_CNTL >> 6) & 1) != 0) - ; - nvidiaWaitAvail (reg, 1); - media->OVERLAY_SCALE_CNTL = 0; - pPortPriv->videoOn = FALSE; - nvidiaWaitIdle (reg); - } -} - -static int -nvidiaSetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int value, - pointer data) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - MediaReg *media = nvidiac->media_reg; - - if(attribute == xvBrightness) - { - if(value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->brightness = value; - } - else if(attribute == xvSaturation) - { - if (value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->saturation = value; - } - else if(attribute == xvColorKey) - { - if (pPortPriv->colorKey != value) - { - pPortPriv->colorKey = value; - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - } - } - else - return BadMatch; - - return Success; -} - -static int -nvidiaGetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int *value, - pointer data) -{ - NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; - - if(attribute == xvBrightness) - *value = pPortPriv->brightness; - else if(attribute == xvSaturation) - *value = pPortPriv->saturation; - else if(attribute == xvColorKey) - *value = pPortPriv->colorKey; - else - return BadMatch; - - return Success; -} - -static void -nvidiaQueryBestSize(KdScreenInfo *screen, - Bool motion, - short vid_w, - short vid_h, - short drw_w, - short drw_h, - unsigned int *p_w, - unsigned int *p_h, - pointer data) -{ - *p_w = drw_w; - *p_h = drw_h; -} - - -static void -nvidiaCopyPackedData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int dstPitch, - int srcW, - int srcH, - int top, - int left, - int h, - int w) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - CARD8 *src, *dst; - int srcDown, srcRight, srcNext; - int p; - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - src = buf; - srcDown = srcPitch; - srcRight = 2; - break; - case RR_Rotate_90: - src = buf + (srcH - 1) * 2; - srcDown = -2; - srcRight = srcPitch; - break; - case RR_Rotate_180: - src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; - srcDown = -srcPitch; - srcRight = -2; - break; - case RR_Rotate_270: - src = buf + srcPitch * (srcW - 1); - srcDown = 2; - srcRight = -srcPitch; - break; - } - - src = src + top*srcDown + left*srcRight; - - if (pPortPriv->currentBuf == 0) - dst = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf0Offset; - else - dst = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - srcRight >>= 1; - srcNext = srcRight >> 1; - while(h--) - { - CARD16 *s = (CARD16 *) src; - CARD32 *d = (CARD32 *) dst; - p = w; - while (p--) - { - *d++ = s[0] | (s[srcNext] << 16); - s += srcRight; - } - src += srcPitch; - dst += dstPitch; - } -} - -static void -nvidiaCopyPlanarData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int srcPitch2, - int dstPitch, /* of chroma */ - int srcW, - int srcH, - int height, - int top, - int left, - int h, - int w, - int id) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - int i, j; - CARD8 *src1, *src2, *src3, *dst1; - int srcDown, srcDown2, srcRight, srcRight2, srcNext; - - /* compute source data pointers */ - src1 = buf; - src2 = src1 + height * srcPitch; - src3 = src2 + (height >> 1) * srcPitch2; - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - srcDown = srcPitch; - srcDown2 = srcPitch2; - srcRight = 2; - srcRight2 = 1; - srcNext = 1; - break; - case RR_Rotate_90: - src1 = src1 + srcH - 1; - src2 = src2 + (srcH >> 1) - 1; - src3 = src3 + (srcH >> 1) - 1; - srcDown = -1; - srcDown2 = -1; - srcRight = srcPitch * 2; - srcRight2 = srcPitch2; - srcNext = srcPitch; - break; - case RR_Rotate_180: - src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); - src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - srcDown = -srcPitch; - srcDown2 = -srcPitch2; - srcRight = -2; - srcRight2 = -1; - srcNext = -1; - break; - case RR_Rotate_270: - src1 = src1 + srcPitch * (srcW - 1); - src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); - srcDown = 1; - srcDown2 = 1; - srcRight = -srcPitch * 2; - srcRight2 = -srcPitch2; - srcNext = -srcPitch; - break; - } - - /* adjust for origin */ - src1 += top * srcDown + left * srcNext; - src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - - if (id == FOURCC_I420) - { - CARD8 *srct = src2; - src2 = src3; - src3 = srct; - } - - if (pPortPriv->currentBuf == 0) - dst1 = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf0Offset; - else - dst1 = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - for (j = 0; j < h; j++) - { - CARD32 *dst = (CARD32 *) dst1; - CARD8 *s1l = src1; - CARD8 *s1r = src1 + srcNext; - CARD8 *s2 = src2; - CARD8 *s3 = src3; - - for (i = 0; i < w; i++) - { - *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); - s1l += srcRight; - s1r += srcRight; - s2 += srcRight2; - s3 += srcRight2; - } - src1 += srcDown; - dst1 += dstPitch; - if (j & 1) - { - src2 += srcDown2; - src3 += srcDown2; - } - } -} - -static void -nvidiaPaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg) -{ - WindowPtr pRoot = WindowTable[pScreen->myNum]; - GCPtr pGC; - CARD32 val[2]; - xRectangle *rects, *r; - BoxPtr pBox = REGION_RECTS (pRgn); - int nBox = REGION_NUM_RECTS (pRgn); - - rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle)); - if (!rects) - goto bail0; - r = rects; - while (nBox--) - { - r->x = pBox->x1; - r->y = pBox->y1; - r->width = pBox->x2 - pBox->x1; - r->height = pBox->y2 - pBox->y1; - r++; - pBox++; - } - - pGC = GetScratchGC (pRoot->drawable.depth, pScreen); - if (!pGC) - goto bail1; - - val[0] = fg; - val[1] = IncludeInferiors; - ChangeGC (pGC, GCForeground|GCSubwindowMode, val); - - ValidateGC (&pRoot->drawable, pGC); - - (*pGC->ops->PolyFillRect) (&pRoot->drawable, pGC, - REGION_NUM_RECTS (pRgn), rects); - - FreeScratchGC (pGC); -bail1: - DEALLOCATE_LOCAL (rects); -bail0: - ; -} - -/* NvidiaClipVideo - - - Takes the dst box in standard X BoxRec form (top and left - edges inclusive, bottom and right exclusive). The new dst - box is returned. The source boundaries are given (x1, y1 - inclusive, x2, y2 exclusive) and returned are the new source - boundaries in 16.16 fixed point. -*/ - -static void -NvidiaClipVideo(BoxPtr dst, - INT32 *x1, - INT32 *x2, - INT32 *y1, - INT32 *y2, - BoxPtr extents, /* extents of the clip region */ - INT32 width, - INT32 height) -{ - INT32 vscale, hscale, delta; - int diff; - - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - - *x1 <<= 16; *x2 <<= 16; - *y1 <<= 16; *y2 <<= 16; - - diff = extents->x1 - dst->x1; - if(diff > 0) { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } - diff = dst->x2 - extents->x2; - if(diff > 0) { - dst->x2 = extents->x2; - *x2 -= diff * hscale; - } - diff = extents->y1 - dst->y1; - if(diff > 0) { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } - diff = dst->y2 - extents->y2; - if(diff > 0) { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } - - if(*x1 < 0) { - diff = (- *x1 + hscale - 1)/ hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } - delta = *x2 - (width << 16); - if(delta > 0) { - diff = (delta + hscale - 1)/ hscale; - dst->x2 -= diff; - *x2 -= diff * hscale; - } - if(*y1 < 0) { - diff = (- *y1 + vscale - 1)/ vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } - delta = *y2 - (height << 16); - if(delta > 0) { - diff = (delta + vscale - 1)/ vscale; - dst->y2 -= diff; - *y2 -= diff * vscale; - } -} - -static void -nvidiaDisplayVideo(KdScreenInfo *screen, - int id, - int dstPitch, /* of chroma for 4:2:0 */ - int x1, - int y1, - int x2, - int y2, - int dst_x1, - int dst_y1, - int dst_x2, - int dst_y2, - short src_w, - short src_h, - short drw_w, - short drw_h) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = nvidiac->reg; - MediaReg *media = nvidiac->media_reg; - int xscaleInt, xscaleFract, yscaleInt, yscaleFract; - int xscaleIntUV = 0, xscaleFractUV = 0; - int yscaleIntUV = 0, yscaleFractUV = 0; - int randr = nvidias->vesa.randr; - int HORZ_INC, VERT_INC; - CARD32 SCALER_IN; - CARD32 OVERLAY_SCALE_CNTL; - int tmp; - int left; - int bright; - int sat; - - if (id == FOURCC_UYVY) - SCALER_IN = SCALER_IN_YVYU422; - else - SCALER_IN = SCALER_IN_VYUY422; - - nvidiaWaitAvail (reg, 4); - - media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; - - /* color key */ - media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; - media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; - /* set key control to obey only graphics color key */ - media->OVERLAY_KEY_CNTL = 0x50; - - nvidiaWaitAvail (reg, 9); - media->CAPTURE_DEBUG = 0; - /* no exclusive video region */ - media->OVERLAY_EXCLUSIVE_HORZ = 0; - media->OVERLAY_EXCLUSIVE_VERT = 0; - /* scaling coefficients */ - media->SCALER_H_COEFF0 = 0x00002000; - media->SCALER_H_COEFF1 = 0x0D06200D; - media->SCALER_H_COEFF2 = 0x0D0A1C0D; - media->SCALER_H_COEFF3 = 0x0C0E1A0C; - media->SCALER_H_COEFF4 = 0x0C14140C; - media->SCALER_TEST = 0; - - nvidiaWaitAvail (reg, 2); - media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | - SCALE_GAMMA_BRIGHT | - SCALE_BANDWIDTH | - SCALE_OVERLAY_EN | - SCALE_EN); - - bright = (pPortPriv->brightness * 64 / 1000); - if (bright < -0x40) - bright = -0x40; - if (bright > 0x3f) - bright = 0x3f; - bright = bright & 0x7f; - sat = ((pPortPriv->saturation * 31 + 31000) / 2000); - if (sat > 0x1f) - sat = 0x1f; - if (sat < 0) - sat = 0; - - media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ - (sat << 8) | /* SATURATION_U */ - (sat << 16) | /* SATURATION_V */ - (0 << 21) | /* SCALER_VERT_ADJ_UV */ - (0 << 28)); /* SCALER_HORZ_ADJ_UV */ - - VERT_INC = (src_h << 12) / drw_h; - HORZ_INC = (src_w << 12) / drw_w; - - nvidiaWaitAvail (reg, 13); - - /* lock registers to prevent non-atomic update */ - media->OVERLAY_Y_X_START = 0x80000000 | NVIDIA_YX (dst_x1, dst_y1); - /* ending screen coordinate */ - media->OVERLAY_Y_X_END = 0x80000000 | NVIDIA_YX (dst_x2, dst_y2); - - media->OVERLAY_SCALE_INC = NVIDIA_YX(HORZ_INC, VERT_INC); - - media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; - - media->SCALER_BUF_PITCH = dstPitch >> 1; - media->SCALER_HEIGHT_WIDTH = NVIDIA_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); - - media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; - - /* set XY location and unlock */ - media->OVERLAY_Y_X_START = NVIDIA_YX (dst_x1, dst_y1); -} - -static int -nvidiaPutImage(KdScreenInfo *screen, - short src_x, - short src_y, - short drw_x, - short drw_y, - short src_w, - short src_h, - short drw_w, - short drw_h, - int id, - unsigned char *buf, - short width, - short height, - Bool sync, - RegionPtr clipBoxes, - pointer data) -{ - KdCardInfo *card = screen->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; - Reg *reg = nvidiac->reg; - MediaReg *media = nvidiac->media_reg; - INT32 x1, x2, y1, y2; - int randr = nvidias->vesa.randr; - int srcPitch, srcPitch2, dstPitch; - int top, left, npixels, nlines, size; - BoxRec dstBox; - int dst_width = width, dst_height = height; - int rot_x1, rot_y1, rot_x2, rot_y2; - int dst_x1, dst_y1, dst_x2, dst_y2; - int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; - - /* Clip */ - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - NvidiaClipVideo(&dstBox, &x1, &x2, &y1, &y2, - REGION_EXTENTS(pScreen, clipBoxes), width, height); - - if((x1 >= x2) || (y1 >= y2)) - return Success; - - if (!media) - return BadAlloc; - - if (randr & (RR_Rotate_0|RR_Rotate_180)) - { - dst_width = width; - dst_height = height; - rot_src_w = src_w; - rot_src_h = src_h; - rot_drw_w = drw_w; - rot_drw_h = drw_h; - } - else - { - dst_width = height; - dst_height = width; - rot_src_w = src_h; - rot_src_h = src_w; - rot_drw_w = drw_h; - rot_drw_h = drw_w; - } - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - dst_x1 = dstBox.x1; - dst_y1 = dstBox.y1; - dst_x2 = dstBox.x2; - dst_y2 = dstBox.y2; - rot_x1 = x1; - rot_y1 = y1; - rot_x2 = x2; - rot_y2 = y2; - break; - case RR_Rotate_90: - dst_x1 = dstBox.y1; - dst_y1 = screen->height - dstBox.x2; - dst_x2 = dstBox.y2; - dst_y2 = screen->height - dstBox.x1; - - rot_x1 = y1; - rot_y1 = (src_w << 16) - x2; - rot_x2 = y2; - rot_y2 = (src_w << 16) - x1; - break; - case RR_Rotate_180: - dst_x1 = screen->width - dstBox.x2; - dst_y1 = screen->height - dstBox.y2; - dst_x2 = screen->width - dstBox.x1; - dst_y2 = screen->height - dstBox.y1; - rot_x1 = (src_w << 16) - x2; - rot_y1 = (src_h << 16) - y2; - rot_x2 = (src_w << 16) - x1; - rot_y2 = (src_h << 16) - y1; - break; - case RR_Rotate_270: - dst_x1 = screen->width - dstBox.y2; - dst_y1 = dstBox.x1; - dst_x2 = screen->width - dstBox.y1; - dst_y2 = dstBox.x2; - rot_x1 = (src_h << 16) - y2; - rot_y1 = x1; - rot_x2 = (src_h << 16) - y1; - rot_y2 = x2; - break; - } - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width + 3) & ~3; - srcPitch2 = ((width >> 1) + 3) & ~3; - size = dstPitch * (int) dst_height; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width << 1); - size = dstPitch * (int) dst_height; - break; - } - - pPortPriv->offset = nvidias->off_screen - (CARD8 *) nvidias->vesa.fb; - /* fixup pointers */ - - pPortPriv->YBuf0Offset = pPortPriv->offset; - pPortPriv->YBuf1Offset = pPortPriv->offset + size; - -#if 0 - nvidiaWaitIdle (reg); - - if (pPortPriv->videoOn) - { - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - } -#endif - /* - * Use the other buffer - */ - pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; - - /* copy data */ - top = rot_y1 >> 16; - left = (rot_x1 >> 16) & ~1; - npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - top &= ~1; - nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; - nvidiaCopyPlanarData(screen, buf, randr, - srcPitch, srcPitch2, dstPitch, - rot_src_w, rot_src_h, height, - top, left, nlines, npixels, id); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - nlines = ((rot_y2 + 0xffff) >> 16) - top; - nvidiaCopyPackedData(screen, buf, randr, - srcPitch, dstPitch, - rot_src_w, rot_src_h, - top, left, nlines, - npixels); - break; - } - - nvidiaDisplayVideo(screen, id, dstPitch, - rot_x1, rot_y1, rot_x2, rot_y2, - dst_x1, dst_y1, - dst_x2, dst_y2, - rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); - - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - nvidiaPaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); - } - - pPortPriv->videoOn = TRUE; - - return Success; -} - -static int -nvidiaQueryImageAttributes(KdScreenInfo *screen, - int id, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) -{ - int size, tmp; - - if(*w > IMAGE_MAX_WIDTH) - *w = IMAGE_MAX_WIDTH; - if(*h > IMAGE_MAX_HEIGHT) - *h = IMAGE_MAX_HEIGHT; - - *w = (*w + 1) & ~1; - if(offsets) offsets[0] = 0; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - *h = (*h + 1) & ~1; - size = (*w + 3) & ~3; - if(pitches) - pitches[0] = size; - size *= *h; - if(offsets) - offsets[1] = size; - tmp = ((*w >> 1) + 3) & ~3; - if(pitches) - pitches[1] = pitches[2] = tmp; - tmp *= (*h >> 1); - size += tmp; - if(offsets) - offsets[2] = size; - size += tmp; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - size = *w << 1; - if(pitches) - pitches[0] = size; - size *= *h; - break; - } - - return size; -} - - -/* client libraries expect an encoding */ -static KdVideoEncodingRec DummyEncoding[1] = -{ - { - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} - } -}; - -#define NUM_FORMATS 3 - -static KdVideoFormatRec Formats[NUM_FORMATS] = -{ - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} -}; - -#define NUM_ATTRIBUTES 3 - -static KdAttributeRec Attributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, - {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} -}; - -#define NUM_IMAGES 4 - -static KdImageRec Images[NUM_IMAGES] = -{ - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - XVIMAGE_UYVY -}; - -static void nvidiaResetVideo(KdScreenInfo *screen) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; - MediaReg *media = nvidiac->media_reg; - - /* - * Default to maximum image size in YV12 - */ - -} - -static int -nvidiaReputImage (KdScreenInfo *screen, - short drw_x, - short drw_y, - RegionPtr clipBoxes, - pointer data) -{ - ScreenPtr pScreen = screen->pScreen; - NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; - BoxPtr pOldExtents = REGION_EXTENTS (pScreen, &pPortPriv->clip); - BoxPtr pNewExtents = REGION_EXTENTS (pScreen, clipBoxes); - - if (pOldExtents->x1 == pNewExtents->x1 && - pOldExtents->x2 == pNewExtents->x2 && - pOldExtents->y1 == pNewExtents->y1 && - pOldExtents->y2 == pNewExtents->y2) - { - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - nvidiaPaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); - } - return Success; - } - return BadMatch; -} - -static KdVideoAdaptorPtr -nvidiaSetupImageVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - nvidiaCardInfo(pScreenPriv); - nvidiaScreenInfo(pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - KdVideoAdaptorPtr adapt; - NvidiaPortPrivPtr pPortPriv; - - if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + - sizeof(NvidiaPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "Nvidia Video Overlay"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPortPriv = (NvidiaPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = nvidiaStopVideo; - adapt->SetPortAttribute = nvidiaSetPortAttribute; - adapt->GetPortAttribute = nvidiaGetPortAttribute; - adapt->QueryBestSize = nvidiaQueryBestSize; - adapt->PutImage = nvidiaPutImage; - adapt->ReputImage = nvidiaReputImage; - adapt->QueryImageAttributes = nvidiaQueryImageAttributes; - - pPortPriv->colorKey = nvidias->colorKey; - pPortPriv->videoOn = FALSE; - pPortPriv->brightness = 0; - pPortPriv->saturation = 0; - pPortPriv->currentBuf = 0; - - /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); - - nvidias->pAdaptor = adapt; - - xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - xvSaturation = MAKE_ATOM("XV_SATURATION"); - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - - nvidiaResetVideo(screen); - - return adapt; -} - -Bool nvidiaInitVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; - KdVideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - KdCardInfo *card = pScreenPriv->card; - NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; - NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; - - if (!nvidiac->media_reg) - return FALSE; - - newAdaptor = nvidiaSetupImageVideo(pScreen); - - num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); - - if(newAdaptor) - { - if(!num_adaptors) - { - num_adaptors = 1; - adaptors = &newAdaptor; - } - else - { - newAdaptors = xalloc((num_adaptors + 1) * - sizeof(KdVideoAdaptorPtr*)); - if(newAdaptors) - { - memcpy(newAdaptors, adaptors, - num_adaptors * sizeof(KdVideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - KdXVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - return TRUE; -} diff --git a/hw/kdrive/pcmcia/Imakefile b/hw/kdrive/pcmcia/Imakefile deleted file mode 100644 index 29da5c418..000000000 --- a/hw/kdrive/pcmcia/Imakefile +++ /dev/null @@ -1,13 +0,0 @@ -XCOMM $RCSId: $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = pcmcia.c pcmciacurs.c pcmciastub.c pcmciashadow.c pcmciarotate.c - -OBJS = pcmcia.o pcmciacurs.o pcmciastub.o pcmciashadow.o pcmciarotate.o - -INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/fbdev - -NormalLibraryObjectRule() -NormalLibraryTarget(pcmcia,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/pcmcia/modes.h b/hw/kdrive/pcmcia/modes.h deleted file mode 100644 index 9087e9e74..000000000 --- a/hw/kdrive/pcmcia/modes.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - */ -/* $RCSId: $ */ - -#define V_NHSYNC 0x01 -#define V_NVSYNC 0x02 -#define V_PHSYNC 0x04 -#define V_PVSYNC 0x08 -#define V_INTERLACE 0x10 - -pcmciaDisplayModeRec pcmciaDefaultModes [] = { -/* 640x400 @ 70Hz (VGA) hsync: 37.9kHz */ - {640, 400, 70 ,31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC}, -/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */ - {640, 480, 60 ,25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC}, -/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */ - {640, 480, 72 ,31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC}, -/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */ - {640, 480, 75 ,31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC}, -/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */ - {640, 480, 85 ,36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC}, -/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */ - {800, 600, 56 ,36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC}, -/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */ - {800, 600, 60 ,40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC}, -/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */ - {800, 600, 72 ,50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC}, -/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */ - {800, 600, 75 ,49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC}, -/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */ - {800, 600, 85 ,56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC}, -/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */ - {1024, 768, 43 ,44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE}, -/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */ - {1024, 768, 60 ,65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC}, -/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */ - {1024, 768, 70 ,75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC}, -/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */ - {1024, 768, 75 ,78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC}, -/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */ - {1024, 768, 85 ,94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC}, -/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */ - {1152, 864, 75 ,108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -}; diff --git a/hw/kdrive/pcmcia/pcmcia.c b/hw/kdrive/pcmcia/pcmcia.c deleted file mode 100644 index 087b0a604..000000000 --- a/hw/kdrive/pcmcia/pcmcia.c +++ /dev/null @@ -1,1200 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * - * A driver for the following PCMCIA cards... - * Hewlett Packards HP VGA Out (Model F1252A) - * Colorgraphics Voyager VGA - * - * Tested running under a Compaq IPAQ Pocket PC running Linux - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/pcmcia/pcmcia.c,v 1.6 2002/10/14 18:01:41 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "pcmcia.h" -#define extern -#include <asm/io.h> -#undef extern - -#define CLOCK 14318 /* KHz */ -#define CLK_N(a,b) (a & 0xff) -#define CLK_M(a,b) ((b) & 0x3f) -#define CLK_K(a,b) (((b) >> 6) & 3) -#define CLK_FREQ(a,b) (((CLK_N(a,b) + 8) * CLOCK) / ((CLK_M(a,b)+2) << CLK_K(a,b))) - -extern void -tridentUpdatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf); -extern void -cirrusUpdatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf); - -static Bool -tridentSetCLK(int clock, CARD8 *a, CARD8 *b); - -static Bool -CirrusFindClock(int freq, int *num_out, int *den_out); - -Bool -pcmciaCardInit (KdCardInfo *card) -{ - pcmciaCardInfo *pcmciac; - CARD8 r9; - - pcmciac = (pcmciaCardInfo *) xalloc (sizeof (pcmciaCardInfo)); - if (!pcmciac) - return FALSE; - - pcmciac->cop_base = (CARD8 *) KdMapDevice (PCMCIA_COP_BASE(card), - PCMCIA_COP_SIZE(card)); - - r9 = pcmciaReadIndex (pcmciac, 0x3c4, 0x09); - /* - * Crude detection.... - * The trident chip has a read only register at 0x09, which returns 0x4. - * If it's not that, we assume the cirrus chip. - * BREAKAGE.! If we have an anonymous PCMCIA card inserted, we could - * potentially smash something here. FIXME ! - */ - if (r9 == 0x04) { - ErrorF("PCMCIA: Found HP VGA card\n"); - pcmciac->HP = TRUE; /* Select HP VGA Out Card */ - } else { - ErrorF("PCMCIA: Found Voyager VGA card\n"); - pcmciac->HP = FALSE; /* Select Voyager VGA Card */ - } - - if (pcmciac->HP) { - /* needed by the accelerator - later */ - pcmciac->cop = (Cop *) (pcmciac->cop_base + TRIDENT_COP_OFF(card)); - } - - /* - * Map frame buffer - */ - if (pcmciac->HP) - pcmciac->fb = KdMapDevice (0x2ce00000, 0x80000); - else - pcmciac->fb = KdMapDevice (0x2c0a0000, 0x10000); /*64K bank switched*/ - - if (!pcmciac->fb) - return FALSE; - - pcmciac->window = 0; - - card->driver = pcmciac; - - return TRUE; -} - -Bool -pcmciaModeSupported (KdScreenInfo *screen, - const KdMonitorTiming *t) -{ - KdCardInfo *card = screen->card; - pcmciaCardInfo *pcmciac = (pcmciaCardInfo *) card->driver; - - if (pcmciac->HP) - { - CARD8 a, b; - if (!tridentSetCLK (t->clock, &a, &b)) - return FALSE; - } - else - { - int a, b; - if (!CirrusFindClock (t->clock, &a, &b)) - return FALSE; - } - - /* width must be a multiple of 16 */ - if (t->horizontal & 0xf) - return FALSE; - return TRUE; -} - -Bool -pcmciaModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - pcmciaCardInfo *pcmciac = (pcmciaCardInfo *) card->driver; - int screen_size; - int pixel_width; - int byte_width; - int fb; - - if (screen->fb[0].depth == 8) - screen->fb[0].bitsPerPixel = 8; - else if (screen->fb[0].depth == 15 || screen->fb[0].depth == 16) - screen->fb[0].bitsPerPixel = 16; - else - return FALSE; - - screen_size = 0; - screen->fb[0].pixelStride = screen->width; - screen->fb[0].byteStride = screen->width * (screen->fb[0].bitsPerPixel >>3); - screen->fb[0].frameBuffer = pcmciac->fb; - screen_size = screen->fb[0].byteStride * screen->height; - - return screen_size <= pcmciac->memory; -} - -Bool -pcmciaScreenInit (KdScreenInfo *screen) -{ - pcmciaCardInfo *pcmciac = screen->card->driver; - pcmciaScreenInfo *pcmcias; - int screen_size, memory; - int i; - const KdMonitorTiming *t; - - pcmcias = (pcmciaScreenInfo *) xalloc (sizeof (pcmciaScreenInfo)); - if (!pcmcias) - return FALSE; - memset (pcmcias, '\0', sizeof (pcmciaScreenInfo)); - - /* if (!pcmciac->cop) */ - screen->dumb = TRUE; - - if (screen->fb[0].depth < 8) - screen->fb[0].depth = 8; - - /* default to 16bpp */ - if (!screen->fb[0].depth) - screen->fb[0].depth = 16; - - /* default to 60Hz refresh */ - if (!screen->width || !screen->height) - { - screen->width = 640; - screen->height = 400; - screen->rate = 60; - } - - pcmciac->memory = 512 * 1024; - if (pcmciac->HP && !screen->softCursor && screen->fb[0].depth == 8) - { - /* ack, bail on the HW cursor for everything -- no ARGB falback */ - pcmcias->cursor_base = 0; -#if 0 - /* Let's do hw cursor for the HP card, only in 8bit mode though */ - pcmcias->cursor_base = pcmcias->screen + pcmciac->memory - 4096; - pcmciac->memory -= 4096; -#endif - } - - pcmcias->screen = pcmciac->fb; - screen->driver = pcmcias; - - t = KdFindMode (screen, pcmciaModeSupported); - - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - - pcmcias->randr = screen->randr; - - if (!KdTuneMode (screen, pcmciaModeUsable, pcmciaModeSupported)) - { - xfree (pcmcias); - return FALSE; - } - - switch (screen->fb[0].depth) { - case 4: - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case 8: - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case 15: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x03e0; - screen->fb[0].redMask = 0x7c00; - break; - case 16: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x07e0; - screen->fb[0].redMask = 0xf800; - break; - } - - return TRUE; -} - -void * -tridentWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - - if (!pScreenPriv->enabled) - return 0; - - *size = pScreenPriv->screen->fb[0].byteStride; - return (CARD8 *) pcmciac->fb + row * pScreenPriv->screen->fb[0].byteStride + offset; -} - -void * -cirrusWindowWindowed (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - int bank, boffset; - - if (!pScreenPriv->enabled) - return 0; - - bank = (row * pScreenPriv->screen->fb[0].byteStride) / 0x1000; - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0B, 0x0c); - pcmciaWriteIndex(pcmciac, 0x3ce, 0x09, bank); - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0A, bank); - *size = pScreenPriv->screen->fb[0].byteStride; - return (CARD8 *) pcmciac->fb + (row * pScreenPriv->screen->fb[0].byteStride) - (bank * 0x1000) + offset; -} - -LayerPtr -pcmciaLayerCreate (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; - ShadowUpdateProc update; - ShadowWindowProc window; - PixmapPtr pPixmap; - int kind; - - if (pcmciac->HP) { - window = tridentWindowLinear; - if (pcmcias->randr == RR_Rotate_0) - update = tridentUpdatePacked; - else - update = pcmciaUpdateRotatePacked; - } else { - window = cirrusWindowWindowed; - if (pcmcias->randr == RR_Rotate_0) - update = cirrusUpdatePacked; - else - update = pcmciaUpdateRotatePacked; - } - - if (!update) - abort (); - - kind = LAYER_SHADOW; - pPixmap = 0; - - return LayerCreate (pScreen, kind, screen->fb[0].depth, - pPixmap, update, window, pcmcias->randr, 0); -} - -void -pcmciaConfigureScreen (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevPriv *priv = pScreenPriv->card->driver; - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; - KdMouseMatrix m; - - KdComputeMouseMatrix (&m, pcmcias->randr, - screen->width, screen->height); - - if (m.matrix[0][0]) - { - pScreen->width = screen->width; - pScreen->height = screen->height; - pScreen->mmWidth = screen->width_mm; - pScreen->mmHeight = screen->height_mm; - } - else - { - pScreen->width = screen->height; - pScreen->height = screen->width; - pScreen->mmWidth = screen->height_mm; - pScreen->mmHeight = screen->width_mm; - } - KdSetMouseMatrix (&m); -} - -#ifdef RANDR - -Bool -pcmciaRandRSupported (ScreenPtr pScreen, - const KdMonitorTiming *t) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - KdScreenInfo *screen = pScreenPriv->screen; - int screen_size; - int byteStride; - - /* Make sure the clock is supported */ - if (!pcmciaModeSupported (screen, t)) - return FALSE; - /* Check for sufficient memory */ - byteStride = screen->width * (screen->fb[0].bitsPerPixel >>3); - screen_size = byteStride * screen->height; - - return screen_size <= pcmciac->memory; -} - -Bool -pcmciaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) -{ - KdScreenPriv(pScreen); - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; - - *rotations = (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270| - RR_Reflect_X|RR_Reflect_Y); - - return KdRandRGetInfo (pScreen, pcmcias->randr, pcmciaRandRSupported); -} - -int -pcmciaLayerAdd (WindowPtr pWin, pointer value) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - LayerPtr pLayer = (LayerPtr) value; - - if (!LayerWindowAdd (pScreen, pLayer, pWin)) - return WT_STOPWALKING; - - return WT_WALKCHILDREN; -} - -int -pcmciaLayerRemove (WindowPtr pWin, pointer value) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - LayerPtr pLayer = (LayerPtr) value; - - LayerWindowRemove (pScreen, pLayer, pWin); - - return WT_WALKCHILDREN; -} - -pcmciaRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevPriv *priv = pScreenPriv->card->driver; - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; - Bool wasEnabled = pScreenPriv->enabled; - int newwidth, newheight; - LayerPtr pNewLayer; - int kind; - int oldrandr = pcmcias->randr; - PixmapPtr pPixmap; - const KdMonitorTiming *t; - - randr = KdAddRotation (screen->randr, randr); - - t = KdRandRGetTiming (pScreen, pcmciaRandRSupported, rate, pSize); - - if (wasEnabled) - KdDisableScreen (pScreen); - - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - - pcmcias->randr = randr; - pcmciaConfigureScreen (pScreen); - - pNewLayer = pcmciaLayerCreate (pScreen); - - if (!pNewLayer) - { - pcmcias->randr = oldrandr; - pcmciaConfigureScreen (pScreen); - if (wasEnabled) - KdEnableScreen (pScreen); - return FALSE; - } - - if (WalkTree (pScreen, pcmciaLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING) - { - WalkTree (pScreen, pcmciaLayerRemove, (pointer) pNewLayer); - LayerDestroy (pScreen, pNewLayer); - pcmcias->randr = oldrandr; - pcmciaConfigureScreen (pScreen); - if (wasEnabled) - KdEnableScreen (pScreen); - return FALSE; - } - WalkTree (pScreen, pcmciaLayerRemove, (pointer) pcmcias->pLayer); - LayerDestroy (pScreen, pcmcias->pLayer); - pcmcias->pLayer = pNewLayer; - if (wasEnabled) - KdEnableScreen (pScreen); - return TRUE; -} - -Bool -pcmciaRandRInit (ScreenPtr pScreen) -{ - rrScrPrivPtr pScrPriv; - - if (!RRScreenInit (pScreen)) - return FALSE; - - pScrPriv = rrGetScrPriv(pScreen); - pScrPriv->rrGetInfo = pcmciaRandRGetInfo; - pScrPriv->rrSetConfig = pcmciaRandRSetConfig; - return TRUE; -} -#endif - -Bool -pcmciaInitScreen (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; - - if (!LayerStartInit (pScreen)) - return FALSE; - if (!LayerFinishInit (pScreen)) - return FALSE; - - pcmciaConfigureScreen (pScreen); - - pcmcias->pLayer = pcmciaLayerCreate (pScreen); - if (!pcmcias->pLayer) - return FALSE; -#ifdef RANDR - if (!pcmciaRandRInit (pScreen)) - return FALSE; -#endif - return TRUE; -} - -CARD8 -pcmciaReadIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index) -{ - CARD8 value; - - pcmciac->cop_base[port] = index; - value = pcmciac->cop_base[port+1]; - return value; -} - -void -pcmciaWriteIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index, CARD8 value) -{ - pcmciac->cop_base[port] = index; - pcmciac->cop_base[port+1] = value; -} - -CARD8 -pcmciaReadReg (pcmciaCardInfo *pcmciac, CARD16 port) -{ - CARD8 value; - - value = pcmciac->cop_base[port]; - - return value; -} - -void -pcmciaWriteReg (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 value) -{ - pcmciac->cop_base[port] = value; -} - - -void -pcmciaPause () -{ - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 50 * 1000; - select (1, 0, 0, 0, &tv); -} - -void -pcmciaPreserve (KdCardInfo *card) -{ -} - -/* CLOCK_FACTOR is double the osc freq in kHz (osc = 14.31818 MHz) */ -#define CLOCK_FACTOR 28636 - -/* stability constraints for internal VCO -- MAX_VCO also determines the maximum Video pixel clock */ -#define MIN_VCO CLOCK_FACTOR -#define MAX_VCO 111000 - -/* clock in kHz is (numer * CLOCK_FACTOR / (denom & 0x3E)) >> (denom & 1) */ -#define VCOVAL(n, d) \ - ((((n) & 0x7F) * CLOCK_FACTOR / ((d) & 0x3E)) ) - -#define CLOCKVAL(n, d) \ - (VCOVAL(n, d) >> ((d) & 1)) - -static Bool -CirrusFindClock(int freq, int *num_out, int *den_out) -{ - int n; - int num = 0, den = 0; - int mindiff; - - /* - * If max_clock is greater than the MAX_VCO default, ignore - * MAX_VCO. On the other hand, if MAX_VCO is higher than max_clock, - * make use of the higher MAX_VCO value. - */ - - mindiff = freq; - for (n = 0x10; n < 0x7f; n++) { - int d; - for (d = 0x14; d < 0x3f; d++) { - int c, diff; - /* Avoid combinations that can be unstable. */ - if ((VCOVAL(n, d) < MIN_VCO) || (VCOVAL(n, d) > MAX_VCO)) - continue; - c = CLOCKVAL(n, d); - diff = abs(c - freq); - if (diff < mindiff) { - mindiff = diff; - num = n; - den = d; - } - } - } - if (n == 0x80) - return FALSE; - - *num_out = num; - *den_out = den; - - return TRUE; -} - - -static Bool -tridentSetCLK(int clock, CARD8 *a, CARD8 *b) -{ - int powerup[4] = { 1,2,4,8 }; - int clock_diff = 750; - int freq, ffreq; - int m, n, k; - int p, q, r, s; - int startn, endn; - int endm, endk; - - p = q = r = s = 0; - - startn = 0; - endn = 121; - endm = 31; - endk = 1; - - freq = clock; - - for (k=0;k<=endk;k++) - for (n=startn;n<=endn;n++) - for (m=1;m<=endm;m++) - { - ffreq = ( ( ((n + 8) * CLOCK) / ((m + 2) * powerup[k]) )); - if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) - { - clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; - p = n; q = m; r = k; s = ffreq; - } - } - -#if 0 - ErrorF ("ffreq %d clock %d\n", s, clock); -#endif - if (s == 0) - return FALSE; - - /* N is first 7bits, first M bit is 8th bit */ - *a = ((1 & q) << 7) | p; - /* first 4bits are rest of M, 1bit for K value */ - *b = (((q & 0xFE) >> 1) | (r << 4)); - return TRUE; -} - -Bool -pcmciaEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; - int i,j; - unsigned char Sequencer[6]; - unsigned char CRTC[31]; - unsigned char Graphics[9]; - unsigned char Attribute[21]; - unsigned char MiscOutReg; - const KdMonitorTiming *t; - int hactive, hblank, hfp, hbp; - int vactive, vblank, vfp, vbp; - - int h_active; - int h_total; - int h_display_end; - int h_sync_start; - int h_sync_end; - int h_skew = 0; - - int v_active; - int v_total; - int v_sync_start; - int v_sync_end; - int v_skew = 0; - - t = KdFindMode (screen, pcmciaModeSupported); - - hactive = t->horizontal; - hfp = t->hfp; - hbp = t->hbp; - hblank = t->hblank; - - h_active = hactive; - h_sync_start = hactive + hfp; - h_sync_end = hactive + hblank - hbp; - h_total = hactive + hblank; - - vactive = t->vertical; - vfp = t->vfp; - vbp = t->vbp; - vblank = t->vblank; - - v_active = vactive; - v_sync_start = vactive + vfp; - v_sync_end = vactive + vblank - vbp; - v_total = vactive + vblank; - - /* - * compute correct Hsync & Vsync polarity - */ - - MiscOutReg = 0x23; - if (t->hpol == KdSyncNegative) - MiscOutReg |= 0x40; - if (t->vpol == KdSyncNegative) - MiscOutReg |= 0x80; - - /* - * Time Sequencer - */ - if (pScreenPriv->screen->fb[0].depth == 4) - Sequencer[0] = 0x02; - else - Sequencer[0] = 0x00; - Sequencer[1] = 0x01; - Sequencer[2] = 0x0F; - Sequencer[3] = 0x00; /* Font select */ - if (pScreenPriv->screen->fb[0].depth < 8) - Sequencer[4] = 0x06; /* Misc */ - else - Sequencer[4] = 0x0E; /* Misc */ - Sequencer[5] = 0x00; - - /* - * CRTC Controller - */ - CRTC[0] = ((h_total) >> 3) - 5; - CRTC[1] = (hactive >> 3) - 1; - CRTC[2] = ((min(h_sync_start,h_active)) >> 3) - 1; - CRTC[3] = ((((min(h_sync_end,h_total)) >> 3) - 1) & 0x1F) | 0x80; - i = (((h_skew << 2) + 0x10) & ~0x1F); - if (i < 0x80) - CRTC[3] |= i; - CRTC[4] = (h_sync_start >> 3); - CRTC[5] = (((((min(h_sync_end,h_total)) >> 3) - 1) & 0x20) << 2) - | (((h_sync_end >> 3)) & 0x1F); - - CRTC[6] = (v_total - 2) & 0xFF; - CRTC[7] = (((v_total - 2) & 0x100) >> 8) - | (((v_active - 1) & 0x100) >> 7) - | ((v_sync_start & 0x100) >> 6) - | ((((min(v_sync_start,v_active)) - 1) & 0x100) >> 5) - | 0x10 - | (((v_total - 2) & 0x200) >> 4) - | (((v_active - 1) & 0x200) >> 3) - | ((v_sync_start & 0x200) >> 2); - CRTC[8] = 0x00; - CRTC[9] = ((((min(v_sync_start,v_active))-1) & 0x200) >> 4) | 0x40; - CRTC[10] = 0x00; - CRTC[11] = 0x00; - CRTC[12] = 0x00; - CRTC[13] = 0x00; - CRTC[14] = 0x00; - CRTC[15] = 0x00; - CRTC[16] = v_sync_start & 0xFF; - CRTC[17] = (v_sync_end & 0x0F) | 0x20; - CRTC[18] = (v_active - 1) & 0xFF; - if (pScreenPriv->screen->fb[0].depth == 4) - CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 4; - else - if (pScreenPriv->screen->fb[0].depth == 8) - CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 3; - else - if (pScreenPriv->screen->fb[0].depth == 16 || - pScreenPriv->screen->fb[0].depth == 15) - CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 2; - CRTC[20] = 0x00; - CRTC[21] = ((min(v_sync_end,v_active)) - 1) & 0xFF; - CRTC[22] = ((min(v_sync_end,v_active)) - 1) & 0xFF; - if (pScreenPriv->screen->fb[0].depth < 8) - CRTC[23] = 0xE3; - else - CRTC[23] = 0xC3; - CRTC[24] = 0xFF; - CRTC[25] = 0x00; - CRTC[26] = 0x00; -#if 0 - if (!pcmciac->HP) - if (mode.Flags & V_INTERLACE) CRTC[26] |= 0x01; -#endif - if (pcmciac->HP) - CRTC[27] = 0x00; - else - CRTC[27] = 0x22; - CRTC[28] = 0x00; - CRTC[29] = 0x00; - CRTC[30] = 0x80; -#if 0 - if (pcmciac->HP) - if (mode.Flags & V_INTERLACE) CRTC[30] |= 0x04; -#endif - -{ - int nExtBits = 0; - CARD32 ExtBits; - CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6; - - CRTC[3] = (CRTC[3] & ~0x1F) - | ((((min(h_sync_end,h_total)) >> 3) - 1) & 0x1F); - CRTC[5] = (CRTC[5] & ~0x80) - | (((((min(h_sync_end,h_total)) >> 3) - 1) & 0x20) << 2); - ExtBits = (((min(h_sync_end,h_total)) >> 3) - 1) & ExtBitMask; - - /* First the horizontal case */ - if ((((min(h_sync_end,h_total)) >> 3) == (h_total >> 3))) - { - int i = (CRTC[3] & 0x1F) - | ((CRTC[5] & 0x80) >> 2) - | ExtBits; - if ((i-- > ((((min(h_sync_start,h_active)) >> 3) - 1) - & (0x3F | ExtBitMask))) - && ((min(h_sync_end,h_total)) == h_total)) - i = 0; - CRTC[3] = (CRTC[3] & ~0x1F) | (i & 0x1F); - CRTC[5] = (CRTC[5] & ~0x80) | ((i << 2) & 0x80); - ExtBits = i & ExtBitMask; - } -} -{ - CARD32 ExtBits; - CARD32 ExtBitMask = 0; - /* If width is not known nBits should be 0. In this - * case BitMask is set to 0 so we can check for it. */ - CARD32 BitMask = 0; - int VBlankStart = ((min(v_sync_start,v_active)) - 1) & 0xFF; - CRTC[22] = ((min(v_sync_end,v_total)) - 1) & 0xFF; - ExtBits = ((min(v_sync_end,v_total)) - 1) & ExtBitMask; - - if ((min(v_sync_end,v_total)) == v_total) - /* Null top overscan */ - { - int i = CRTC[22] | ExtBits; - if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask))) - || ((i > VBlankStart) && /* 8-bit case */ - ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */ - !(CRTC[9] & 0x9F)) /* 1 scanline/row */ - i = 0; - else - i = (i - 1); - CRTC[22] = i & 0xFF; - ExtBits = i & 0xFF00; - } -} - - /* - * Graphics Display Controller - */ - Graphics[0] = 0x00; - Graphics[1] = 0x00; - Graphics[2] = 0x00; - Graphics[3] = 0x00; - Graphics[4] = 0x00; - if (pScreenPriv->screen->fb[0].depth == 4) - Graphics[5] = 0x02; - else - Graphics[5] = 0x40; - Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */ - Graphics[7] = 0x0F; - Graphics[8] = 0xFF; - - Attribute[0] = 0x00; /* standard colormap translation */ - Attribute[1] = 0x01; - Attribute[2] = 0x02; - Attribute[3] = 0x03; - Attribute[4] = 0x04; - Attribute[5] = 0x05; - Attribute[6] = 0x06; - Attribute[7] = 0x07; - Attribute[8] = 0x08; - Attribute[9] = 0x09; - Attribute[10] = 0x0A; - Attribute[11] = 0x0B; - Attribute[12] = 0x0C; - Attribute[13] = 0x0D; - Attribute[14] = 0x0E; - Attribute[15] = 0x0F; - if (pScreenPriv->screen->fb[0].depth == 4) - Attribute[16] = 0x81; - else - Attribute[16] = 0x41; - if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) - Attribute[17] = 0x00; - else - Attribute[17] = 0xFF; - Attribute[18] = 0x0F; - Attribute[19] = 0x00; - Attribute[20] = 0x00; - - /* Wake up the card */ - if (pcmciac->HP) { - pcmciaWriteReg(pcmciac, 0x3c3, 0x1); - pcmciaWriteReg(pcmciac, 0x46e8, 0x10); - } else { - pcmciaWriteReg(pcmciac, 0x105, 0x1); - pcmciaWriteReg(pcmciac, 0x46e8, 0x1f); - pcmciaWriteReg(pcmciac, 0x102, 0x1); - pcmciaWriteReg(pcmciac, 0x46e8, 0xf); - pcmciaWriteReg(pcmciac, 0x3c3, 0x1); - } - - if (pcmciac->HP) { - /* unlock */ - pcmciaWriteIndex(pcmciac, 0x3c4, 0x11, 0x92); - j = pcmciaReadIndex(pcmciac, 0x3c4, 0xb); - pcmciaWriteIndex(pcmciac, 0x3c4, 0xe, 0xc2); - - /* switch on dac */ - pcmciaWriteIndex(pcmciac, 0x3d4, 0x29, 0x24); - /* switch on the accelerator */ - pcmciaWriteIndex(pcmciac, 0x3d4, 0x36, 0x80); - - /* bump up memory clk */ - pcmciaWriteReg(pcmciac, 0x43c6, 0x65); - pcmciaWriteReg(pcmciac, 0x43c7, 0x00); - } else { - /* unlock */ - pcmciaWriteIndex(pcmciac, 0x3c4, 0x06, 0x12); - pcmciaWriteReg(pcmciac, 0x3c2, MiscOutReg); - } - - /* synchronous reset */ - pcmciaWriteIndex(pcmciac, 0x3c4, 0, 0); - - pcmciaWriteReg(pcmciac, 0x3da, 0x10); - - for (i=0;i<6;i++) - pcmciaWriteIndex(pcmciac, 0x3c4, i, Sequencer[i]); - - if (pcmciac->HP) { - /* Stick chip into color mode */ - pcmciaWriteIndex(pcmciac, 0x3ce, 0x2f, 0x06); - /* Switch on Linear addressing */ - pcmciaWriteIndex(pcmciac, 0x3d4, 0x21, 0x2e); - } else { - /* Stick chip into 8bit access mode - ugh! */ - pcmciaWriteIndex(pcmciac, 0x3c4, 0x0F, 0x20); /* 0x26 ? */ - /* reset mclk */ - pcmciaWriteIndex(pcmciac, 0x3c4, 0x1F, 0); - } - - pcmciaWriteIndex(pcmciac, 0x3c4, 0, 0x3); - - for (i=0;i<31;i++) - pcmciaWriteIndex(pcmciac, 0x3d4, i, CRTC[i]); - - for (i=0;i<9;i++) - pcmciaWriteIndex(pcmciac, 0x3ce, i, Graphics[i]); - - j = pcmciaReadReg(pcmciac, 0x3da); - - for (i=0;i<21;i++) { - pcmciaWriteReg(pcmciac, 0x3c0, i); - pcmciaWriteReg(pcmciac, 0x3c0, Attribute[i]); - } - - j = pcmciaReadReg(pcmciac, 0x3da); - pcmciaWriteReg(pcmciac, 0x3c0, 0x20); - - j = pcmciaReadReg(pcmciac, 0x3c8); - j = pcmciaReadReg(pcmciac, 0x3c6); - j = pcmciaReadReg(pcmciac, 0x3c6); - j = pcmciaReadReg(pcmciac, 0x3c6); - j = pcmciaReadReg(pcmciac, 0x3c6); - switch (pScreenPriv->screen->fb[0].depth) { - /* This is here for completeness, when/if we ever do 4bpp */ - case 4: - pcmciaWriteReg(pcmciac, 0x3c6, 0x0); - if (pcmciac->HP) { - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x90); - pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x00); - } else - pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x00); - break; - case 8: - pcmciaWriteReg(pcmciac, 0x3c6, 0x0); - if (pcmciac->HP) { - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x92); - pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x00); - } else - pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x01); - break; - case 15: - if (pcmciac->HP) { - pcmciaWriteReg(pcmciac, 0x3c6, 0x10); - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x9a); - pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x04); - } else { - pcmciaWriteReg(pcmciac, 0x3c6, 0xC0); - pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x03); - } - break; - case 16: - if (pcmciac->HP) { - pcmciaWriteReg(pcmciac, 0x3c6, 0x30); - pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x9a); - pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x04); - } else { - pcmciaWriteReg(pcmciac, 0x3c6, 0xC1); - pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x03); - } - break; - } - j = pcmciaReadReg(pcmciac, 0x3c8); - - pcmciaWriteReg(pcmciac, 0x3c6, 0xff); - - for (i=0;i<256;i++) { - pcmciaWriteReg(pcmciac, 0x3c8, i); - pcmciaWriteReg(pcmciac, 0x3c9, i); - pcmciaWriteReg(pcmciac, 0x3c9, i); - pcmciaWriteReg(pcmciac, 0x3c9, i); - } - - /* Set the Clock */ - if (pcmciac->HP) { - CARD8 a,b; - int clock = t->clock; - if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) - clock *= 2; - tridentSetCLK(clock, &a, &b); - pcmciaWriteReg(pcmciac, 0x43c8, a); - pcmciaWriteReg(pcmciac, 0x43c9, b); - } else { - int num, den; - unsigned char tmp; - int clock = t->clock; - if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) - clock *= 2; - - CirrusFindClock(clock, &num, &den); - - tmp = pcmciaReadIndex(pcmciac, 0x3c4, 0x0d); - pcmciaWriteIndex(pcmciac, 0x3c4, 0x0d, (tmp & 0x80) | num); - tmp = pcmciaReadIndex(pcmciac, 0x3c4, 0x1d); - pcmciaWriteIndex(pcmciac, 0x3c4, 0x1d, (tmp & 0xc0) | den); - } - pcmciaWriteReg(pcmciac, 0x3c2, MiscOutReg | 0x08); - -#if 1 - for (i=1;i<0x3f;i++) - ErrorF("0x3c4:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3c4, i)); - - ErrorF("\n"); - - for (i=0;i<0x3f;i++) - ErrorF("0x3ce:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3ce, i)); - - ErrorF("\n"); - - for (i=0;i<0x3f;i++) - ErrorF("0x3d4:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3d4, i)); -#endif - - return TRUE; -} - -void -pcmciaDisable (ScreenPtr pScreen) -{ -} - -const CARD8 tridentDPMSModes[4] = { - 0x00, /* KD_DPMS_NORMAL */ - 0x01, /* KD_DPMS_STANDBY */ - 0x02, /* KD_DPMS_SUSPEND */ - 0x03, /* KD_DPMS_POWERDOWN */ -}; - -Bool -pcmciaDPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - - if (pcmciac->HP) { - pcmciaWriteIndex (pcmciac, 0x3ce, 0x23, tridentDPMSModes[mode]); - pcmciaPause (); - } else { - /* Voyager */ - } - - return TRUE; -} - -void -pcmciaRestore (KdCardInfo *card) -{ -} - -void -pcmciaScreenFini (KdScreenInfo *screen) -{ - pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; - - xfree (pcmcias); - screen->driver = 0; -} - -void -pcmciaCardFini (KdCardInfo *card) -{ - pcmciaCardInfo *pcmciac = card->driver; - - if (pcmciac->cop_base) - KdUnmapDevice ((void *) pcmciac->cop_base, PCMCIA_COP_SIZE(card)); -} - -void -pcmciaGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - - while (ndef--) - { - pcmciaWriteReg (pcmciac, 0x3C7, pdefs->pixel); - pdefs->red = pcmciaReadReg (pcmciac, 0x3C9) << 10; - pdefs->green = pcmciaReadReg (pcmciac, 0x3C9) << 10; - pdefs->blue = pcmciaReadReg (pcmciac, 0x3C9) << 10; - pdefs++; - } -} - -void -pcmciaPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; - - while (ndef--) - { - pcmciaWriteReg (pcmciac, 0x3C8, pdefs->pixel); - pcmciaWriteReg (pcmciac, 0x3C9, pdefs->red >> 10); - pcmciaWriteReg (pcmciac, 0x3C9, pdefs->green >> 10); - pcmciaWriteReg (pcmciac, 0x3C9, pdefs->blue >> 10); - pdefs++; - } -} - - -KdCardFuncs pcmciaFuncs = { - pcmciaCardInit, /* cardinit */ - pcmciaScreenInit, /* scrinit */ - pcmciaInitScreen, /* initScreen */ - pcmciaPreserve, /* preserve */ - pcmciaEnable, /* enable */ - pcmciaDPMS, /* dpms */ - pcmciaDisable, /* disable */ - pcmciaRestore, /* restore */ - pcmciaScreenFini, /* scrfini */ - pcmciaCardFini, /* cardfini */ - - pcmciaCursorInit, /* initCursor */ - pcmciaCursorEnable, /* enableCursor */ - pcmciaCursorDisable, /* disableCursor */ - pcmciaCursorFini, /* finiCursor */ - pcmciaRecolorCursor, /* recolorCursor */ - -#if 0 /* not yet */ - pcmciaDrawInit, /* initAccel */ - pcmciaDrawEnable, /* enableAccel */ - pcmciaDrawSync, /* syncAccel */ - pcmciaDrawDisable, /* disableAccel */ - pcmciaDrawFini, /* finiAccel */ -#else - 0, - 0, - 0, - 0, - 0, -#endif - - pcmciaGetColors, /* getColors */ - pcmciaPutColors, /* putColors */ -}; diff --git a/hw/kdrive/pcmcia/pcmcia.h b/hw/kdrive/pcmcia/pcmcia.h deleted file mode 100644 index cb4d13a6c..000000000 --- a/hw/kdrive/pcmcia/pcmcia.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/pcmcia/pcmcia.h,v 1.1 2001/05/23 08:56:09 alanh Exp $ */ - -#ifndef _PCMCIA_H_ -#define _PCMCIA_H_ - -#include <fbdev.h> - -/* - * offset from ioport beginning - */ - -#define PCMCIA_COP_BASE(c) 0x20000000 -#define PCMCIA_COP_SIZE(c) 0x10000 -#define TRIDENT_COP_OFF(c) 0x2100 - -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 - - -#define COP_ALPHA_SRC_BLEND_0 0x00000000 -#define COP_ALPHA_SRC_BLEND_1 0x00000001 -#define COP_ALPHA_SRC_BLEND_SRC_C 0x00000002 -#define COP_ALPHA_SRC_BLEND_1_SRC_C 0x00000003 -#define COP_ALPHA_SRC_BLEND_SRC_A 0x00000004 -#define COP_ALPHA_SRC_BLEND_1_SRC_A 0x00000005 -#define COP_ALPHA_SRC_BLEND_DST_A 0x00000006 -#define COP_ALPHA_SRC_BLEND_1_DST_A 0x00000007 -#define COP_ALPHA_SRC_BLEND_DST_C 0x00000008 -#define COP_ALPHA_SRC_BLEND_1_DST_C 0x00000009 -#define COP_ALPHA_SRC_BLEND_SAT 0x0000000A -#define COP_ALPHA_SRC_BLEND_BG 0x0000000B - -#define COP_ALPHA_DST_BLEND_0 0x00000000 -#define COP_ALPHA_DST_BLEND_1 0x00000010 -#define COP_ALPHA_DST_BLEND_SRC_C 0x00000020 -#define COP_ALPHA_DST_BLEND_1_SRC_C 0x00000030 -#define COP_ALPHA_DST_BLEND_SRC_A 0x00000040 -#define COP_ALPHA_DST_BLEND_1_SRC_A 0x00000050 -#define COP_ALPHA_DST_BLEND_DST_A 0x00000060 -#define COP_ALPHA_DST_BLEND_1_DST_A 0x00000070 -#define COP_ALPHA_DST_BLEND_DST_C 0x00000080 -#define COP_ALPHA_DST_BLEND_1_DST_C 0x00000090 -#define COP_ALPHA_DST_BLEND_OTHER 0x000000A0 - -#define COP_ALPHA_RESULT_ALPHA 0x00100000 -#define COP_ALPHA_DEST_ALPHA 0x00200000 -#define COP_ALPHA_SOURCE_ALPHA 0x00400000 -#define COP_ALPHA_WRITE_ENABLE 0x00800000 -#define COP_ALPHA_TEST_ENABLE 0x01000000 -#define COP_ALPHA_BLEND_ENABLE 0x02000000 -#define COP_ALPHA_DEST_VALUE 0x04000000 -#define COP_ALPHA_SOURCE_VALUE 0x08000000 - - VOL32 command; /* 0x24 */ -#define COP_OP_NULL 0x00000000 -#define COP_OP_LINE 0x20000000 -#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 _pcmciaCardInfo { - CARD8 *fb; - Bool HP; - CARD32 memory; - CARD8 *cop_base; - Cop *cop; - CARD32 *window; - CARD32 cop_depth; - CARD32 cop_stride; -} pcmciaCardInfo; - -#define getpcmciaCardInfo(kd) ((pcmciaCardInfo *) ((kd)->card->driver)) -#define pcmciaCardInfo(kd) pcmciaCardInfo *pcmciac = getpcmciaCardInfo(kd) - -typedef struct _pcmciaCursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; - Pixel source, mask; -} pcmciaCursor; - -#define PCMCIA_CURSOR_WIDTH 64 -#define PCMCIA_CURSOR_HEIGHT 64 - -typedef struct _pcmciaScreenInfo { - CARD8 *cursor_base; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - int randr; - LayerPtr pLayer; - pcmciaCursor cursor; -} pcmciaScreenInfo; - -#define getpcmciaScreenInfo(kd) ((pcmciaScreenInfo *) ((kd)->screen->driver)) -#define pcmciaScreenInfo(kd) pcmciaScreenInfo *pcmcias = getpcmciaScreenInfo(kd) - -Bool -pcmciaDrawInit (ScreenPtr pScreen); - -void -pcmciaDrawEnable (ScreenPtr pScreen); - -void -pcmciaDrawSync (ScreenPtr pScreen); - -void -pcmciaDrawDisable (ScreenPtr pScreen); - -void -pcmciaDrawFini (ScreenPtr pScreen); - -CARD8 -pcmciaReadIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index); - -void -pcmciaWriteIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index, CARD8 value); - -void -pcmciaWriteReg (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 value); - -Bool -pcmciaCursorInit (ScreenPtr pScreen); - -void -pcmciaCursorEnable (ScreenPtr pScreen); - -void -pcmciaCursorDisable (ScreenPtr pScreen); - -void -pcmciaCursorFini (ScreenPtr pScreen); - -void -pcmciaRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); - -void -pcmciaUpdateRotatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf); - -typedef struct _pcmciaDisplayModeRec { - int Width; - int Height; - int Refresh; - int Clock; /* pixel clock freq */ - int HDisplay; /* horizontal timing */ - int HSyncStart; - int HSyncEnd; - int HTotal; - int HSkew; - int VDisplay; /* vertical timing */ - int VSyncStart; - int VSyncEnd; - int VTotal; - int VScan; - int Flags; -} pcmciaDisplayModeRec, *pcmciaDisplayModePtr; - -extern KdCardFuncs pcmciaFuncs; - -#endif /* _PCMCIA_H_ */ diff --git a/hw/kdrive/pcmcia/pcmciacurs.c b/hw/kdrive/pcmcia/pcmciacurs.c deleted file mode 100644 index 1cb86cfe9..000000000 --- a/hw/kdrive/pcmcia/pcmciacurs.c +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - */ -/* $RCSId: $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "pcmcia.h" -#include "cursorstr.h" - -#define SetupCursor(s) KdScreenPriv(s); \ - pcmciaCardInfo(pScreenPriv); \ - pcmciaScreenInfo(pScreenPriv); \ - pcmciaCursor *pCurPriv = &pcmcias->cursor - -static void -_pcmciaMoveCursor (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; - } - - /* This is the recommended order to move the cursor */ - if (pcmciac->HP) { - xlow = (CARD8) x; - xhigh = (CARD8) (x >> 8); - ylow = (CARD8) y; - yhigh = (CARD8) (y >> 8); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x40, xlow); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x41, xhigh); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x42, ylow); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x43, yhigh); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x46, xoff); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x47, yoff); - } else { - x >>= 3; - y >>= 3; - xlow = (CARD8) x; - xhigh = (CARD8) (x >> 8); - ylow = (CARD8) y; - yhigh = (CARD8) (y >> 8); - /* Don't be alarmed, yes the upper 3bits of the index are correct */ - pcmciaWriteIndex (pcmciac, 0x3c4, 0x10 | xhigh << 5, xlow); - pcmciaWriteIndex (pcmciac, 0x3c4, 0x11 | yhigh << 5, ylow); - } -} - -static void -pcmciaMoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor (pScreen); - - if (!pCurPriv->has_cursor) - return; - - if (!pScreenPriv->enabled) - return; - - _pcmciaMoveCursor (pScreen, x, y); -} - -static void -pcmciaAllocCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 -pcmciaSetCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - CARD32 fg, bg; - - fg = pCurPriv->source; - bg = pCurPriv->mask; - - if (pcmciac->HP) { - /* - * This trident chip uses the palette for it's cursor colors - ouch! - * We enforce it to always stay the black/white colors as we don't - * want it to muck with the overscan color. Tough. Use softCursor - * if you want to change cursor colors. - */ - pcmciaWriteReg (pcmciac, 0x3c8, 0xff); /* DAC 0 */ - pcmciaWriteReg (pcmciac, 0x3c9, 0x00); - pcmciaWriteReg (pcmciac, 0x3c9, 0x00); - pcmciaWriteReg (pcmciac, 0x3c9, 0x00); - pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 255 */ - pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); - pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); - pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); - } else { - CARD8 temp; - temp = pcmciaReadIndex(pcmciac, 0x3c4, 0x12); - pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, (temp & 0xFE) | 0x02); - - pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 256 */ - pcmciaWriteReg (pcmciac, 0x3c9, fg); - pcmciaWriteReg (pcmciac, 0x3c9, fg >> 8); - pcmciaWriteReg (pcmciac, 0x3c9, fg >> 16); - pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 257 */ - pcmciaWriteReg (pcmciac, 0x3c9, bg); - pcmciaWriteReg (pcmciac, 0x3c9, bg >> 8); - pcmciaWriteReg (pcmciac, 0x3c9, bg >> 16); - - pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, temp); - } -} - -void -pcmciaRecolorCursor (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; - } - pcmciaAllocCursorColors (pScreen); - pcmciaSetCursorColors (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 -pcmciaLoadCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor(pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - CursorBitsPtr bits = pCursor->bits; - int w, h; - CARD8 *ram; - CARD32 *msk, *mskLine, *src, *srcLine; - int i, j; - int cursor_address; - int lwsrc; - unsigned char ramdac_control_; - CARD32 offset; - - /* - * Allocate new colors - */ - pcmciaAllocCursorColors (pScreen); - - pCurPriv->pCursor = pCursor; - pCurPriv->xhot = pCursor->bits->xhot; - pCurPriv->yhot = pCursor->bits->yhot; - - /* - * Stick new image into cursor memory - */ - if (pcmciac->HP) { - ram = (CARD8 *) pcmcias->cursor_base; - } else { - /* The last bank */ - ram = (CARD8 *) pcmciac->fb; - pcmciaWriteIndex (pcmciac, 0x3ce, 0x09, 0x7f); - pcmciaWriteIndex (pcmciac, 0x3ce, 0x0A, 0x7f); - } - - mskLine = (CARD32 *) bits->mask; - srcLine = (CARD32 *) bits->source; - - h = bits->height; - if (h > PCMCIA_CURSOR_HEIGHT) - h = PCMCIA_CURSOR_HEIGHT; - - lwsrc = BitmapBytePad(bits->width) / 4; - - for (i = 0; i < PCMCIA_CURSOR_HEIGHT; i++) { - msk = mskLine; - src = srcLine; - mskLine += lwsrc; - srcLine += lwsrc; - for (j = 0; j < PCMCIA_CURSOR_WIDTH / 32; j++) { - - CARD32 m, s; - - if (i < h && j < lwsrc) - { - m = *msk++; - s = *src++; - InvertBits32(m); - InvertBits32(s); - } - else - { - m = 0; - s = 0; - } - - /* Do 8bit access */ - *ram++ = (m & 0xff); - *ram++ = (m & 0xff00) >> 8; - *ram++ = (m & 0xff0000) >> 16; - *ram++ = (m & 0xff000000) >> 24; - *ram++ = (s & 0xff); - *ram++ = (s & 0xff00) >> 8; - *ram++ = (s & 0xff0000) >> 16; - *ram++ = (s & 0xff000000) >> 24; - } - } - - /* Set address for cursor bits */ - if (pcmciac->HP) { - offset = pcmcias->cursor_base - (CARD8 *) pcmcias->screen; - offset >>= 10; - pcmciaWriteIndex (pcmciac, 0x3d4, 0x44, (CARD8) (offset & 0xff)); - pcmciaWriteIndex (pcmciac, 0x3d4, 0x45, (CARD8) (offset >> 8)); - } else { - pcmciaWriteIndex (pcmciac, 0x3c4, 0x13, 15); /* ?? */ - } - - /* Set new color */ - pcmciaSetCursorColors (pScreen); - - /* Enable the cursor */ - if (pcmciac->HP) - pcmciaWriteIndex (pcmciac, 0x3d4, 0x50, 0xc1); - else - pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, 0x05); - - /* Move to new position */ - pcmciaMoveCursor (pScreen, x, y); -} - -static void -pcmciaUnloadCursor (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - /* Disable cursor */ - if (pcmciac->HP) - pcmciaWriteIndex (pcmciac, 0x3d4, 0x50, 0); - else - pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, 0); -} - -static Bool -pcmciaRealizeCursor (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); - pcmciaLoadCursor (pScreen, x, y); - } - } - return TRUE; -} - -static Bool -pcmciaUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) -{ - return TRUE; -} - -static void -pcmciaSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) -{ - SetupCursor(pScreen); - - pCurPriv->pCursor = pCursor; - - if (!pScreenPriv->enabled) - return; - - if (pCursor) - pcmciaLoadCursor (pScreen, x, y); - else - pcmciaUnloadCursor (pScreen); -} - -miPointerSpriteFuncRec pcmciaPointerSpriteFuncs = { - pcmciaRealizeCursor, - pcmciaUnrealizeCursor, - pcmciaSetCursor, - pcmciaMoveCursor, -}; - -static void -pcmciaQueryBestSize (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 -pcmciaCursorInit (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!pcmcias->cursor_base) - { - pCurPriv->has_cursor = FALSE; - return FALSE; - } - - pCurPriv->width = PCMCIA_CURSOR_WIDTH; - pCurPriv->height= PCMCIA_CURSOR_HEIGHT; - pScreen->QueryBestSize = pcmciaQueryBestSize; - miPointerInitialize (pScreen, - &pcmciaPointerSpriteFuncs, - &kdPointerScreenFuncs, - FALSE); - pCurPriv->has_cursor = TRUE; - pCurPriv->pCursor = NULL; - return TRUE; -} - -void -pcmciaCursorEnable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - int x, y; - - miPointerPosition (&x, &y); - pcmciaLoadCursor (pScreen, x, y); - } - else - pcmciaUnloadCursor (pScreen); - } -} - -void -pcmciaCursorDisable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!pScreenPriv->enabled) - return; - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - pcmciaUnloadCursor (pScreen); - } - } -} - -void -pcmciaCursorFini (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - pCurPriv->pCursor = NULL; -} diff --git a/hw/kdrive/pcmcia/pcmciarotate.c b/hw/kdrive/pcmcia/pcmciarotate.c deleted file mode 100644 index 6ac7efbfd..000000000 --- a/hw/kdrive/pcmcia/pcmciarotate.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/miext/shadow/shrotate.c,v 1.3 2001/07/21 04:13:26 keithp Exp $ - * - * Copyright © 2001 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include "font.h" -#include "dixfontstr.h" -#include "fontstruct.h" -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -/* - * These indicate which way the source (shadow) is scanned when - * walking the screen in a particular direction - */ - -#define LEFT_TO_RIGHT 1 -#define RIGHT_TO_LEFT -1 -#define TOP_TO_BOTTOM 2 -#define BOTTOM_TO_TOP -2 - -typedef CARD16 PcBits; -typedef INT32 PcStride; - -#define PC_SHIFT 4 -#define PC_UNIT (1 << PC_SHIFT) -#define PC_HALFUNIT (1 << (PC_SHIFT-1)) -#define PC_MASK (PC_UNIT - 1) -#define PC_ALLONES ((PcBits) -1) - -#define PcScrRight(x,b) FbScrRight(x,b) -#define PcScrLeft(x,b) FbScrLeft(x,b) -#define PcBitsMask(x,w) (PcScrRight(PC_ALLONES,(x) & PC_MASK) & \ - PcScrLeft(PC_ALLONES,(PC_UNIT - ((x) + (w))) & PC_MASK)) - -#define pcGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ - PixmapPtr _pPix; \ - if ((pDrawable)->type != DRAWABLE_PIXMAP) \ - _pPix = fbGetWindowPixmap(pDrawable); \ - else \ - _pPix = (PixmapPtr) (pDrawable); \ - (pointer) = (PcBits *) _pPix->devPrivate.ptr; \ - (stride) = ((int) _pPix->devKind) / sizeof (PcBits); \ - (bpp) = _pPix->drawable.bitsPerPixel; \ - (xoff) = 0; \ - (yoff) = 0; \ -} - -void -pcmciaUpdateRotatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = &pBuf->damage; - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - PcBits *shaBits; - PcStride shaStride; - int shaBpp; - int shaXoff, shaYoff; - int box_x1, box_x2, box_y1, box_y2; - int sha_x1, sha_y1; - int scr_x1, scr_x2, scr_y1, scr_y2, scr_w, scr_h; - int scr_x, scr_y; - int w; - int pixelsPerBits; - int pixelsMask; - PcStride shaStepOverY, shaStepDownY, shaStepOverX, shaStepDownX; - PcBits *shaLine, *sha; - int shaHeight = pShadow->drawable.height; - int shaWidth = pShadow->drawable.width; - PcBits shaMask; - int shaFirstShift, shaShift; - int o_x_dir; - int o_y_dir; - int x_dir; - int y_dir; - - pcGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff); - pixelsPerBits = (sizeof (PcBits) * 8) / shaBpp; - pixelsMask = ~(pixelsPerBits - 1); - shaMask = PcBitsMask (PC_UNIT-shaBpp, shaBpp); - /* - * Compute rotation related constants to walk the shadow - */ - o_x_dir = LEFT_TO_RIGHT; - o_y_dir = TOP_TO_BOTTOM; - if (pBuf->randr & SHADOW_REFLECT_X) - o_x_dir = -o_x_dir; - if (pBuf->randr & SHADOW_REFLECT_Y) - o_y_dir = -o_y_dir; - switch (pBuf->randr & (SHADOW_ROTATE_ALL)) { - case SHADOW_ROTATE_0: /* upper left shadow -> upper left screen */ - default: - x_dir = o_x_dir; - y_dir = o_y_dir; - break; - case SHADOW_ROTATE_90: /* upper right shadow -> upper left screen */ - x_dir = o_y_dir; - y_dir = -o_x_dir; - break; - case SHADOW_ROTATE_180: /* lower right shadow -> upper left screen */ - x_dir = -o_x_dir; - y_dir = -o_y_dir; - break; - case SHADOW_ROTATE_270: /* lower left shadow -> upper left screen */ - x_dir = -o_y_dir; - y_dir = o_x_dir; - break; - } - switch (x_dir) { - case LEFT_TO_RIGHT: - shaStepOverX = shaBpp; - shaStepOverY = 0; - break; - case TOP_TO_BOTTOM: - shaStepOverX = 0; - shaStepOverY = shaStride; - break; - case RIGHT_TO_LEFT: - shaStepOverX = -shaBpp; - shaStepOverY = 0; - break; - case BOTTOM_TO_TOP: - shaStepOverX = 0; - shaStepOverY = -shaStride; - break; - } - switch (y_dir) { - case TOP_TO_BOTTOM: - shaStepDownX = 0; - shaStepDownY = shaStride; - break; - case RIGHT_TO_LEFT: - shaStepDownX = -shaBpp; - shaStepDownY = 0; - break; - case BOTTOM_TO_TOP: - shaStepDownX = 0; - shaStepDownY = -shaStride; - break; - case LEFT_TO_RIGHT: - shaStepDownX = shaBpp; - shaStepDownY = 0; - break; - } - - while (nbox--) - { - box_x1 = pbox->x1; - box_y1 = pbox->y1; - box_x2 = pbox->x2; - box_y2 = pbox->y2; - pbox++; - - /* - * Compute screen and shadow locations for this box - */ - switch (x_dir) { - case LEFT_TO_RIGHT: - scr_x1 = box_x1 & pixelsMask; - scr_x2 = (box_x2 + pixelsPerBits - 1) & pixelsMask; - - sha_x1 = scr_x1; - break; - case TOP_TO_BOTTOM: - scr_x1 = box_y1 & pixelsMask; - scr_x2 = (box_y2 + pixelsPerBits - 1) & pixelsMask; - - sha_y1 = scr_x1; - break; - case RIGHT_TO_LEFT: - scr_x1 = (shaWidth - box_x2) & pixelsMask; - scr_x2 = (shaWidth - box_x1 + pixelsPerBits - 1) & pixelsMask; - - sha_x1 = (shaWidth - scr_x1 - 1); - break; - case BOTTOM_TO_TOP: - scr_x1 = (shaHeight - box_y2) & pixelsMask; - scr_x2 = (shaHeight - box_y1 + pixelsPerBits - 1) & pixelsMask; - - sha_y1 = (shaHeight - scr_x1 - 1); - break; - } - switch (y_dir) { - case TOP_TO_BOTTOM: - scr_y1 = box_y1; - scr_y2 = box_y2; - - sha_y1 = scr_y1; - break; - case RIGHT_TO_LEFT: - scr_y1 = (shaWidth - box_x2); - scr_y2 = (shaWidth - box_x1); - - sha_x1 = box_x2 - 1; - break; - case BOTTOM_TO_TOP: - scr_y1 = shaHeight - box_y2; - scr_y2 = shaHeight - box_y1; - - sha_y1 = box_y2 - 1; - break; - case LEFT_TO_RIGHT: - scr_y1 = box_x1; - scr_y2 = box_x2; - - sha_x1 = box_x1; - break; - } - scr_w = ((scr_x2 - scr_x1) * shaBpp) >> PC_SHIFT; - scr_h = scr_y2 - scr_y1; - scr_y = scr_y1; - - /* shift amount for first pixel on screen */ - shaFirstShift = PC_UNIT - ((sha_x1 * shaBpp) & PC_MASK) - shaBpp; - - /* pointer to shadow data first placed on screen */ - shaLine = (shaBits + - sha_y1 * shaStride + - ((sha_x1 * shaBpp) >> PC_SHIFT)); - - /* - * Copy the bits, always write across the physical frame buffer - * to take advantage of write combining. - */ - while (scr_h--) - { - int p; - PcBits bits; - PcBits *win; - int i; - CARD32 winSize; - - sha = shaLine; - shaShift = shaFirstShift; - w = scr_w; - scr_x = scr_x1 * shaBpp >> PC_SHIFT; - - while (w) - { - /* - * Map some of this line - */ - win = (PcBits *) (*pBuf->window) (pScreen, - scr_y, - scr_x << 1, - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - i = (winSize >> 1); - if (i > w) - i = w; - w -= i; - scr_x += i; - /* - * Copy the portion of the line mapped - */ - while (i--) - { - bits = 0; - p = pixelsPerBits; - /* - * Build one word of output from multiple inputs - * - * Note that for 90/270 rotations, this will walk - * down the shadow hitting each scanline once. - * This is probably not very efficient. - */ - while (p--) - { - bits = PcScrLeft(bits, shaBpp); - bits |= PcScrRight (*sha, shaShift) & shaMask; - - shaShift -= shaStepOverX; - if (shaShift >= PC_UNIT) - { - shaShift -= PC_UNIT; - sha--; - } - else if (shaShift < 0) - { - shaShift += PC_UNIT; - sha++; - } - sha += shaStepOverY; - } - *win++ = bits; - } - } - scr_y++; - shaFirstShift -= shaStepDownX; - if (shaFirstShift >= PC_UNIT) - { - shaFirstShift -= PC_UNIT; - shaLine--; - } - else if (shaFirstShift < 0) - { - shaFirstShift += PC_UNIT; - shaLine++; - } - shaLine += shaStepDownY; - } - } -} diff --git a/hw/kdrive/pcmcia/pcmciashadow.c b/hw/kdrive/pcmcia/pcmciashadow.c deleted file mode 100644 index abe73a0ba..000000000 --- a/hw/kdrive/pcmcia/pcmciashadow.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/pcmcia/pcmciashadow.c,v 1.1 2001/05/23 08:56:09 alanh Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include "font.h" -#include "dixfontstr.h" -#include "fontstruct.h" -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -void -tridentUpdatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = &pBuf->damage; - PixmapPtr pShadow = pBuf->pPixmap; - shadowScrPriv(pScreen); - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - FbBits *winBase, *win; - CARD32 winSize; - - fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = pbox->x1 * shaBpp; - y = pbox->y1; - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - scrLine = (x >> FB_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - x &= FB_MASK; - w = (w + x + FB_MASK) >> FB_SHIFT; - - while (h--) - { - winSize = 0; - scrBase = 0; - width = w; - scr = scrLine; - sha = shaLine; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (FbBits *) (*pBuf->window) (pScreen, - y, - scr * sizeof (FbBits), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - scrBase = scr; - winSize /= sizeof (FbBits); - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; - { - CARD16 *sha16 = (CARD16*)sha; - CARD16 *win16 = (CARD16*)win; - while (i--) - { - *win16++ = *sha16++; - *win16++ = *sha16++; - } - } - } - shaLine += shaStride; - y++; - } - pbox++; - } -} - -void -cirrusUpdatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = &pBuf->damage; - PixmapPtr pShadow = pBuf->pPixmap; - shadowScrPriv(pScreen); - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - FbBits *winBase, *win; - CARD32 winSize; - - fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = pbox->x1 * shaBpp; - y = pbox->y1; - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - scrLine = (x >> FB_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - x &= FB_MASK; - w = (w + x + FB_MASK) >> FB_SHIFT; - - while (h--) - { - winSize = 0; - scrBase = 0; - width = w; - scr = scrLine; - sha = shaLine; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (FbBits *) (*pBuf->window) (pScreen, - y, - scr * sizeof (FbBits), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - scrBase = scr; - winSize /= sizeof (FbBits); - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; - { - CARD8 *sha8 = (CARD8*)sha; - CARD8 *win8 = (CARD8*)win; - while (i--) - { - *win8++ = *sha8++; - *win8++ = *sha8++; - *win8++ = *sha8++; - *win8++ = *sha8++; - } - } - } - shaLine += shaStride; - y++; - } - pbox++; - } -} diff --git a/hw/kdrive/pcmcia/pcmciastub.c b/hw/kdrive/pcmcia/pcmciastub.c deleted file mode 100644 index 8759f4a08..000000000 --- a/hw/kdrive/pcmcia/pcmciastub.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * 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 Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE 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. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/pcmcia/pcmciastub.c,v 1.1 2001/05/23 08:56:09 alanh Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "pcmcia.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - - KdCardInfoAdd (&pcmciaFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -extern pcmciaDisplayModeRec pcmciaDefaultModes[]; - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/r128/Makefile.am b/hw/kdrive/r128/Makefile.am deleted file mode 100644 index a3a989c41..000000000 --- a/hw/kdrive/r128/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xr128 - -if TSLIB -TSLIB_FLAG = -lts -endif - -noinst_LIBRARIES = libr128.a - -libr128_a_SOURCES = \ - r128draw.c \ - r128.c \ - r128.h - -Xr128_SOURCES = \ - r128stub.c - -Xr128_LDADD = \ - libr128.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - diff --git a/hw/kdrive/r128/r128.c b/hw/kdrive/r128/r128.c deleted file mode 100644 index 2be8b26d2..000000000 --- a/hw/kdrive/r128/r128.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "r128.h" - -static Bool -r128CardInit (KdCardInfo *card) -{ - R128CardInfo *r128c; - - r128c = (R128CardInfo *) xalloc (sizeof (R128CardInfo)); - if (!r128c) - return FALSE; - - r128MapReg (card, r128c); - - if (!vesaInitialize (card, &r128c->vesa)) - { - xfree (r128c); - return FALSE; - } - - r128c->fifo_size = 0; - - card->driver = r128c; - - return TRUE; -} - -static Bool -r128ScreenInit (KdScreenInfo *screen) -{ - R128ScreenInfo *r128s; - int screen_size, memory; - - r128s = (R128ScreenInfo *) xalloc (sizeof (R128ScreenInfo)); - if (!r128s) - return FALSE; - memset (r128s, '\0', sizeof (R128ScreenInfo)); - if (!vesaScreenInitialize (screen, &r128s->vesa)) - { - xfree (r128s); - return FALSE; - } -#if 0 - /* if (!r128c->reg) - screen->dumb = TRUE; */ - - if (r128s->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - - fprintf (stderr, "vesa mapping is %d\n", r128s->vesa.mapping); -#endif - r128s->screen = r128s->vesa.fb; - - memory = r128s->vesa.fb_size; - screen_size = screen->fb[0].byteStride * screen->height; - - memory -= screen_size; - if (memory > screen->fb[0].byteStride) - { - r128s->off_screen = r128s->screen + screen_size; - r128s->off_screen_size = memory; - } - else - { - r128s->off_screen = 0; - r128s->off_screen_size = 0; - } - screen->driver = r128s; - return TRUE; -} - -static Bool -r128InitScreen (ScreenPtr pScreen) -{ - return vesaInitScreen (pScreen); -} - -static Bool -r128FinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - - ret = vesaFinishInitScreen (pScreen); - - return ret; -} - -static void -r128Preserve (KdCardInfo *card) -{ - vesaPreserve (card); -} - -Bool -r128MapReg (KdCardInfo *card, R128CardInfo *r128c) -{ - r128c->reg_base = (CARD8 *) KdMapDevice (R128_REG_BASE (card), - R128_REG_SIZE (card)); - - if (!r128c->reg_base) - { - return FALSE; - } - - KdSetMappedMode (R128_REG_BASE (card), - R128_REG_SIZE (card), - KD_MAPPED_MODE_REGISTERS); - - return TRUE; -} - -void -r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c) -{ - if (r128c->reg_base) - { - KdResetMappedMode (R128_REG_BASE (card), - R128_REG_SIZE (card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) r128c->reg_base, R128_REG_SIZE (card)); - r128c->reg_base = 0; - } -} - -void -r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c) -{ - if (!r128c->reg_base) - r128MapReg (card, r128c); -} - -void -r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c) -{ - r128UnmapReg (card, r128c); -} - - -static Bool -r128DPMS (ScreenPtr pScreen, int mode) -{ - /* XXX */ - return TRUE; -} - -static Bool -r128Enable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - R128CardInfo *r128c = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - - r128SetMMIO (pScreenPriv->card, r128c); - r128DPMS (pScreen, KD_DPMS_NORMAL); - - return TRUE; -} - -static void -r128Disable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - R128CardInfo *r128c = pScreenPriv->card->driver; - - r128ResetMMIO (pScreenPriv->card, r128c); - vesaDisable (pScreen); -} - -static void -r128Restore (KdCardInfo *card) -{ - R128CardInfo *r128c = card->driver; - - r128ResetMMIO (card, r128c); - vesaRestore (card); -} - -static void -r128ScreenFini (KdScreenInfo *screen) -{ - R128ScreenInfo *r128s = (R128ScreenInfo *) screen->driver; - - vesaScreenFini (screen); - xfree (r128s); - screen->driver = 0; -} - -static void -r128CardFini (KdCardInfo *card) -{ - R128CardInfo *r128c = (R128CardInfo *)card->driver; - - r128UnmapReg (card, r128c); - vesaCardFini (card); -} - -KdCardFuncs r128Funcs = { - r128CardInit, /* cardinit */ - r128ScreenInit, /* scrinit */ - r128InitScreen, /* initScreen */ - r128FinishInitScreen, /* finishInitScreen */ - vesaCreateResources,/* createRes */ - r128Preserve, /* preserve */ - r128Enable, /* enable */ - r128DPMS, /* dpms */ - r128Disable, /* disable */ - r128Restore, /* restore */ - r128ScreenFini, /* scrfini */ - r128CardFini, /* cardfini */ - - 0, /* initCursor */ - 0, /* enableCursor */ - 0, /* disableCursor */ - 0, /* finiCursor */ - 0, /* recolorCursor */ - - r128DrawInit, /* initAccel */ - r128DrawEnable, /* enableAccel */ - r128DrawSync, /* syncAccel */ - r128DrawDisable, /* disableAccel */ - r128DrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; - diff --git a/hw/kdrive/r128/r128.h b/hw/kdrive/r128/r128.h deleted file mode 100644 index 8cf2bd4e2..000000000 --- a/hw/kdrive/r128/r128.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ - -#ifndef _R128_H_ -#define _R128_H_ -#include <vesa.h> - -#define R128_REG_BASE(c) ((c)->attr.address[1]) -#define R128_REG_SIZE(c) (0x4000) - -#define R128_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v)) -#define R128_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a))) - -#define R128_REG_GUI_STAT 0x1740 -#define R128_REG_DEFAULT_OFFSET 0x16e0 -#define R128_REG_DEFAULT_PITCH 0x16e4 -#define R128_REG_DP_GUI_MASTER_CNTL 0x146c -#define R128_REG_DP_BRUSH_FRGD_CLR 0x147c -#define R128_REG_DP_WRITE_MASK 0x16cc -#define R128_REG_DP_CNTL 0x16c0 -#define R128_REG_DST_WIDTH_HEIGHT 0x1598 -#define R128_REG_DST_Y_X 0x1438 -#define R128_REG_PC_NGUI_CTLSTAT 0x0184 -#define R128_REG_DST_HEIGHT_WIDTH 0x143c -#define R128_REG_SRC_Y_X 0x1434 -#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 -#define R128_AUX_SC_CNTL 0x1660 -#define R128_SC_TOP_LEFT 0x16ec -#define R128_SC_BOTTOM_RIGHT 0x16f0 - -#define R128_GMC_DST_DATATYPE_SHIFT 8 -#define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) -#define R128_GMC_AUX_CLIP_DIS (1 << 29) -#define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) -#define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) -#define R128_GMC_ROP3_SHIFT 16 -#define R128_DST_X_LEFT_TO_RIGHT (1 << 0) -#define R128_DST_Y_TOP_TO_BOTTOM (1 << 1) -#define R128_GUI_ACTIVE (1 << 31) -#define R128_PC_BUSY (1 << 31) -#define R128_DP_SRC_SOURCE_MEMORY (2 << 24) -#define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) -#define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _r128CardInfo { - VesaCardPrivRec vesa; - CARD8 *reg_base; - int fifo_size; -} R128CardInfo; - -#define getR128CardInfo(kd) ((R128CardInfo *) ((kd)->card->driver)) -#define r128CardInfo(kd) R128CardInfo *r128c = getR128CardInfo(kd) - -typedef struct _r128ScreenInfo { - VesaScreenPrivRec vesa; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - - int pitch; - int datatype; - - int dp_gui_master_cntl; -} R128ScreenInfo; - -#define getR128ScreenInfo(kd) ((R128ScreenInfo *) ((kd)->screen->driver)) -#define r128ScreenInfo(kd) R128ScreenInfo *r128s = getR128ScreenInfo(kd) - -Bool -r128MapReg (KdCardInfo *card, R128CardInfo *r128c); - -void -r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c); - -void -r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c); - -void -r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c); - -Bool -r128DrawSetup (ScreenPtr pScreen); - -Bool -r128DrawInit (ScreenPtr pScreen); - -void -r128DrawEnable (ScreenPtr pScreen); - -void -r128DrawSync (ScreenPtr pScreen); - -void -r128DrawDisable (ScreenPtr pScreen); - -void -r128DrawFini (ScreenPtr pScreen); - -extern KdCardFuncs r128Funcs; - -#endif /* _R128_H_ */ diff --git a/hw/kdrive/r128/r128draw.c b/hw/kdrive/r128/r128draw.c deleted file mode 100644 index be4dc79ae..000000000 --- a/hw/kdrive/r128/r128draw.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "r128.h" - -CARD8 r128SolidRop[16] = { - /* GXclear */ 0x00, /* 0 */ - /* GXand */ 0xa0, /* src AND dst */ - /* GXandReverse */ 0x50, /* src AND NOT dst */ - /* GXcopy */ 0xf0, /* src */ - /* GXandInverted*/ 0x0a, /* NOT src AND dst */ - /* GXnoop */ 0xaa, /* dst */ - /* GXxor */ 0x5a, /* src XOR dst */ - /* GXor */ 0xfa, /* src OR dst */ - /* GXnor */ 0x05, /* NOT src AND NOT dst */ - /* GXequiv */ 0xa5, /* NOT src XOR dst */ - /* GXinvert */ 0x55, /* NOT dst */ - /* GXorReverse */ 0xf5, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x0f, /* NOT src */ - /* GXorInverted */ 0xaf, /* NOT src OR dst */ - /* GXnand */ 0x5f, /* NOT src OR NOT dst */ - /* GXset */ 0xff, /* 1 */ -}; - -CARD8 r128BltRop[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 */ -}; - -int copydx, copydy; -int fifo_size; -char *mmio; - -static void -r128WaitAvail (int n) -{ - if (fifo_size < n) - { - while ((fifo_size = R128_IN32 (mmio, R128_REG_GUI_STAT) & 0xfff) < n) - ; - } - - fifo_size -= n; -} - -static void -r128WaitIdle (void) -{ - int tries; - - r128WaitAvail (64); - - tries = 1000000; - while (tries--) - { - if ((R128_IN32 (mmio, R128_REG_GUI_STAT) & R128_GUI_ACTIVE) == 0) - break; - } - - R128_OUT32 (mmio, R128_REG_PC_NGUI_CTLSTAT, - R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT | 0xff)); - - tries = 1000000; - while (tries--) - { - if ((R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT) & R128_PC_BUSY) != R128_PC_BUSY) - break; - } - -} - -static Bool -r128Setup (ScreenPtr pScreen, int wait) -{ - KdScreenPriv (pScreen); - r128ScreenInfo (pScreenPriv); - r128CardInfo (pScreenPriv); - - fifo_size = 0; - - mmio = r128c->reg_base; - - if (!mmio) - return FALSE; - - r128WaitAvail (2); - R128_OUT32 (mmio, R128_REG_DEFAULT_OFFSET, 0); - R128_OUT32 (mmio, R128_REG_DEFAULT_PITCH, r128s->pitch); - - r128WaitAvail (4); - R128_OUT32 (mmio, R128_AUX_SC_CNTL, 0); - R128_OUT32 (mmio, R128_DEFAULT_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX - | R128_DEFAULT_SC_BOTTOM_MAX)); - R128_OUT32 (mmio, R128_SC_TOP_LEFT, 0); - R128_OUT32 (mmio, R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX - | R128_DEFAULT_SC_BOTTOM_MAX)); - r128WaitAvail (wait); - return TRUE; -} - -static Bool -r128PrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg) -{ - KdScreenPriv (pPixmap->drawable.pScreen); - r128ScreenInfo (pScreenPriv); - - r128Setup (pPixmap->drawable.pScreen, 4); - R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | (r128SolidRop[alu] << R128_GMC_ROP3_SHIFT)); - R128_OUT32 (mmio, R128_REG_DP_BRUSH_FRGD_CLR, fg); - R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm); - R128_OUT32 (mmio, R128_REG_DP_CNTL, - (R128_DST_X_LEFT_TO_RIGHT | R128_DST_Y_TOP_TO_BOTTOM)); - - return TRUE; -} - -static void -r128Solid (int x1, int y1, int x2, int y2) -{ - r128WaitAvail (2); - R128_OUT32 (mmio, R128_REG_DST_Y_X, (y1 << 16) | x1); - R128_OUT32 (mmio, R128_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1)); - -} - -static void -r128DoneSolid (void) -{ -} - -static Bool -r128PrepareCopy (PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm) -{ - KdScreenPriv (pSrc->drawable.pScreen); - r128ScreenInfo (pScreenPriv); - - copydx = dx; - copydy = dy; - - r128Setup (pSrc->drawable.pScreen, 3); - R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | (r128BltRop[alu] << R128_GMC_ROP3_SHIFT) - | R128_DP_SRC_SOURCE_MEMORY); - R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm); - R128_OUT32 (mmio, R128_REG_DP_CNTL, - ((dx >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) - | (dy >= 0 ? R128_DST_Y_TOP_TO_BOTTOM : 0))); - - - return TRUE; -} - -static void -r128Copy (int srcX, int srcY, int dstX, int dstY, int w, int h) -{ - if (copydx < 0) - { - srcX += w - 1; - dstX += w - 1; - } - - if (copydy < 0) - { - srcY += h - 1; - dstY += h - 1; - } - - r128WaitAvail (3); - R128_OUT32 (mmio, R128_REG_SRC_Y_X, (srcY << 16) | srcX); - R128_OUT32 (mmio, R128_REG_DST_Y_X, (dstY << 16) | dstX); - R128_OUT32 (mmio, R128_REG_DST_HEIGHT_WIDTH, (h << 16) | w); -} - -static void -r128DoneCopy (void) -{ -} - -KaaScreenInfoRec r128Kaa = { - r128PrepareSolid, - r128Solid, - r128DoneSolid, - - r128PrepareCopy, - r128Copy, - r128DoneCopy, -}; - -Bool -r128DrawInit (ScreenPtr pScreen) -{ - if (!kaaDrawInit (pScreen, &r128Kaa)) - return FALSE; - - return TRUE; -} - -void -r128DrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - r128ScreenInfo (pScreenPriv); - - r128s->pitch = pScreenPriv->screen->width >> 3; - - switch (pScreenPriv->screen->fb[0].depth) { - case 8: - r128s->datatype = 2; - break; - case 15: - r128s->datatype = 3; - break; - case 16: - r128s->datatype = 4; - break; - case 24: - r128s->datatype = 5; - break; - case 32: - r128s->datatype = 6; - break; - default: - FatalError ("unsupported pixel format"); - } - - r128s->dp_gui_master_cntl = ((r128s->datatype << R128_GMC_DST_DATATYPE_SHIFT) - | R128_GMC_CLR_CMP_CNTL_DIS - | R128_GMC_AUX_CLIP_DIS); - - KdMarkSync (pScreen); -} - -void -r128DrawDisable (ScreenPtr pScreen) -{ -} - -void -r128DrawFini (ScreenPtr pScreen) -{ -} - -void -r128DrawSync (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - r128CardInfo (pScreenPriv); - - mmio = r128c->reg_base; - - r128WaitIdle (); -} diff --git a/hw/kdrive/r128/r128stub.c b/hw/kdrive/r128/r128stub.c deleted file mode 100644 index 30dc32c66..000000000 --- a/hw/kdrive/r128/r128stub.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ -/* $Header$ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "r128.h" -#include "klinux.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x1002, 0x4c46, 0, &attr)) - KdCardInfoAdd (&r128Funcs, &attr, 0); - else if (LinuxFindPci (0x1002, 0x5046, 0, &attr)) - KdCardInfoAdd (&r128Funcs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/savage/Imakefile b/hw/kdrive/savage/Imakefile deleted file mode 100644 index 4d7577900..000000000 --- a/hw/kdrive/savage/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $ -KDRIVE=.. -#include "../Kdrive.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. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(savage,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/savage/s3.c b/hw/kdrive/savage/s3.c deleted file mode 100644 index 06f23abaf..000000000 --- a/hw/kdrive/savage/s3.c +++ /dev/null @@ -1,1838 +0,0 @@ -/* - * Id: s3.c,v 1.3 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.4 2000/05/06 22:17:44 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" - -#define REGISTERS_OFFSET (0x1000000) -#define PACKED_OFFSET (0x8100) -#define IOMAP_OFFSET (0x8000) - -#define S3_MIN_CLOCK 250000 - -static void -_s3SetBlank (S3Ptr s3, S3Vga *s3vga, Bool blank) -{ - CARD8 clock_mode; - - s3SetImm(s3vga, s3_screen_off, blank ? 1 : 0); -} - -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; - VGA32 save_misc_output; - - s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo)); - if (!s3c) - { - goto bail0; - } - - memset (s3c, '\0', sizeof (S3CardInfo)); - - card->driver = s3c; - -#ifdef VXWORKS - s3c->bios_initialized = 0; -#else - s3c->bios_initialized = 1; -#endif - - if (card->attr.naddr > 1 && card->attr.address[1]) - { - s3FrameBuffer = card->attr.address[1]; - s3Registers = card->attr.address[0]; - 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)); - - if (!s3c->bios_initialized) - { - volatile CARD32 *wakeup; - - wakeup = (volatile CARD32 *) (registers + 0x8510); - ErrorF ("Wakeup S3 chip at 0x%x\n", wakeup); - ErrorF ("Wakeup was 0x%x\n", *wakeup); - /* wakeup the chip */ - *(volatile CARD32 *) (registers + 0x8510) = 1; - ErrorF ("Wakeup is 0x%x\n", *wakeup); - } - s3Set (s3vga, s3_io_addr_select, 1); - s3Set (s3vga, s3_enable_ram, 1); - VgaFlush (&s3vga->card); - - save_register_lock_2 = s3Get (s3vga, s3_register_lock_2); - s3SetImm (s3vga, s3_register_lock_2, 0xa0); - save_linear_window_size = s3Get (s3vga, s3_linear_window_size); - 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 -s3ModeSupported (KdScreenInfo *screen, - const KdMonitorTiming *t) -{ - if (screen->fb[1].depth) - { - /* - * Must have at least one true color stream - */ - if (screen->fb[0].depth <= 8 && - screen->fb[1].depth <= 8) - return FALSE; - } - /* make sure the clock isn't too fast */ - if (t->clock > S3_MAX_CLOCK * 2) - return FALSE; - /* width must be a multiple of 16 */ - if (t->horizontal & 0xf) - return FALSE; - return TRUE; -} - -Bool -s3ModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - S3CardInfo *s3c = (S3CardInfo *) card->driver; - int screen_size; - int pixel_width; - int byte_width; - int fb; - - screen_size = 0; - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - { - if (screen->fb[fb].depth >= 24) - { - screen->fb[fb].depth = 24; - if (screen->fb[fb].bitsPerPixel != 24) - screen->fb[fb].bitsPerPixel = 32; - } - else if (screen->fb[fb].depth >= 16) - { - screen->fb[fb].depth = 16; - screen->fb[fb].bitsPerPixel = 16; - } - else if (screen->fb[fb].depth >= 15) - { - screen->fb[fb].depth = 15; - screen->fb[fb].bitsPerPixel = 16; - } - else - { - screen->fb[fb].depth = 8; - screen->fb[fb].bitsPerPixel = 8; - } - - /* - * SGRAM requires stride % 64 == 0 - */ - screen->fb[fb].pixelStride = (screen->width + 63) & ~63; - screen->fb[fb].byteStride = screen->fb[fb].pixelStride * (screen->fb[fb].bitsPerPixel >> 3); - screen_size += screen->fb[fb].byteStride * screen->height; - } - - return screen_size <= s3c->memory; -} - -Bool -s3ScreenInit (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - S3CardInfo *s3c = (S3CardInfo *) card->driver; - S3ScreenInfo *s3s; - int memory; - int requested_memory; - int v_total, h_total; - int m, n, r; - int i; - const KdMonitorTiming *t; - int screen_size; - int fb; - int ma; - - s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo)); - if (!s3s) - return FALSE; - - memset (s3s, '\0', sizeof (S3ScreenInfo)); - -#ifdef PHOENIX - screen->width = 1152; - screen->height = 900; - screen->rate = 85; - screen->depth = 32; -#endif - if (!screen->width || !screen->height) - { - screen->width = 800; - screen->height = 600; - screen->rate = 72; - } - if (!screen->fb[0].depth) - screen->fb[0].depth = 8; - - t = KdFindMode (screen, s3ModeSupported); - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000); -#ifdef DEBUG - fprintf (stderr, "computed %d,%d,%d (%d)\n", - m, n, r, S3_CLOCK(m,n,r)); -#endif -#if 0 - /* - * Can only operate in pixel-doubled mode at 8 or 16 bits per pixel - */ - if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK) - screen->depth = 16; -#endif - - if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported)) - { - xfree (s3s); - return FALSE; - } - - s3s->fbmap[2] = -1; - if (screen->fb[1].depth) - { - if (screen->fb[0].bitsPerPixel >= 16) - { - s3s->fbmap[0] = 1; - s3s->fbmap[1] = 0; - } - else - { - s3s->fbmap[0] = 0; - s3s->fbmap[1] = 1; - } - } - else - { - s3s->fbmap[0] = 0; - s3s->fbmap[1] = -1; - } - - screen_size = 0; - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - screen_size += screen->fb[fb].byteStride * screen->height; - - memory = s3c->memory - screen_size; - - /* - * Stick cursor at end of memory - */ - if (memory >= 2048) - { - s3s->cursor_base = s3c->frameBuffer + (s3c->memory - 2048); - memory -= 2048; - } - else - s3s->cursor_base = 0; - - screen_size = 0; - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - { - fb = s3s->fbmap[ma]; - screen->fb[fb].frameBuffer = s3c->frameBuffer + screen_size; - screen_size += screen->fb[fb].byteStride * screen->height; - - REGION_INIT(pScreen, (&s3s->region[fb]), NullBox, 0); - if (screen->fb[fb].bitsPerPixel == 8) - s3s->fb[ma].chroma_key = 0xff; - else - s3s->fb[ma].chroma_key = 0; - - /* - * Use remaining memory for off-screen storage, but only use - * one piece (either right or bottom). - */ - if (memory >= screen->fb[fb].byteStride * S3_TILE_SIZE) - { - s3s->fb[ma].offscreen = screen->fb[fb].frameBuffer; - s3s->fb[ma].offscreen_x = 0; - s3s->fb[ma].offscreen_y = screen->height; - s3s->fb[ma].offscreen_width = screen->fb[fb].pixelStride; - s3s->fb[ma].offscreen_height = S3_TILE_SIZE; - memory -= s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride; - screen_size += s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride; - } - else - s3s->fb[ma].offscreen = 0; - - switch (screen->fb[fb].depth) { - case 8: - screen->fb[fb].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[fb].blueMask = 0x00; - screen->fb[fb].greenMask = 0x00; - screen->fb[fb].redMask = 0x00; - break; - case 15: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x001f; - screen->fb[fb].greenMask = 0x03e0; - screen->fb[fb].redMask = 0x7c00; - break; - case 16: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x001f; - screen->fb[fb].greenMask = 0x07e0; - screen->fb[fb].redMask = 0xf800; - break; - case 24: - screen->fb[fb].visuals = (1 << TrueColor); - screen->fb[fb].blueMask = 0x0000ff; - screen->fb[fb].greenMask = 0x00ff00; - screen->fb[fb].redMask = 0xff0000; - break; - } - } - - screen->driver = s3s; - - return TRUE; -} - -typedef struct _biosInit { - VGA16 reg; - VGA8 value; -} s3BiosInit; - -s3BiosInit s3BiosReg[] = { - S3_SR +0x15, 0x23, - S3_MISC_OUT, 0x2f, - 0xffff, 1, - S3_SR +0x15, 0x03, - - S3_SR + 0x0, 0x03, - S3_SR + 0x1, 0x00, - S3_SR + 0x2, 0x03, - S3_SR + 0x3, 0x00, - S3_SR + 0x4, 0x02, - S3_SR + 0x5, 0x05, - S3_SR + 0x6, 0x06, - S3_SR + 0x7, 0x07, -/* S3_SR + 0x8, 0x06, */ - S3_SR + 0x9, 0x00, - S3_SR + 0xa, 0x0a, - S3_SR + 0xb, 0x00, - S3_SR + 0xc, 0x0c, - S3_SR + 0xd, 0x00, - S3_SR + 0xe, 0x0e, - S3_SR + 0xf, 0x0f, - -/* S3_SR +0x10, 0x00, */ -/* S3_SR +0x11, 0x0c, */ - S3_SR +0x12, 0x01, - S3_SR +0x13, 0x52, - S3_SR +0x14, 0x00, - -/* S3_SR +0x15, 0x03, */ - - S3_SR +0x16, 0xc5, - S3_SR +0x17, 0xfc, - S3_SR +0x18, 0x40, - S3_SR +0x19, 0x00, - S3_SR +0x1a, 0x01, - S3_SR +0x1b, 0x02, - S3_SR +0x1c, 0x5d, - S3_SR +0x1d, 0x00, - S3_SR +0x1e, 0x00, - S3_SR +0x1f, 0x00, - S3_SR +0x20, 0x20, - S3_SR +0x21, 0x21, - S3_SR +0x22, 0x22, - S3_SR +0x23, 0x23, - S3_SR +0x24, 0x24, - S3_SR +0x25, 0x25, - S3_SR +0x26, 0x26, - S3_SR +0x27, 0x04, - S3_SR +0x28, 0xff, - S3_SR +0x29, 0x00, - S3_SR +0x2a, 0x2a, - S3_SR +0x2b, 0x2b, - S3_SR +0x2c, 0x2c, - S3_SR +0x2d, 0x2d, - S3_SR +0x2e, 0x2e, - S3_SR +0x2f, 0x2f, - S3_SR +0x30, 0x00, - S3_SR +0x31, 0x06, - S3_SR +0x32, 0x41, - S3_SR +0x33, 0x67, - S3_SR +0x34, 0x00, - S3_SR +0x35, 0x00, - S3_SR +0x36, 0x01, - S3_SR +0x37, 0x52, - S3_SR +0x38, 0x5d, - S3_SR +0x39, 0x05, - S3_SR +0x3a, 0x3a, - S3_SR +0x3b, 0x3b, - S3_SR +0x3c, 0x3c, - S3_SR +0x3d, 0x00, - S3_SR +0x3e, 0x3e, - S3_SR +0x3f, 0x00, - S3_SR +0x40, 0x40, - S3_SR +0x41, 0x41, - S3_SR +0x42, 0x42, - S3_SR +0x43, 0x43, - S3_SR +0x44, 0x44, - S3_SR +0x45, 0x45, - S3_SR +0x46, 0x46, - S3_SR +0x47, 0x47, - S3_SR +0x48, 0x48, - S3_SR +0x49, 0x49, - S3_SR +0x4a, 0x4a, - S3_SR +0x4b, 0x4b, - S3_SR +0x4c, 0x4c, - S3_SR +0x4d, 0x4d, - S3_SR +0x4e, 0x4e, - S3_SR +0x4f, 0x4f, - S3_SR +0x50, 0x00, - S3_SR +0x51, 0x00, - S3_SR +0x52, 0x00, - S3_SR +0x53, 0x00, - S3_SR +0x54, 0x00, - S3_SR +0x55, 0x00, - S3_SR +0x56, 0x00, - S3_SR +0x57, 0x00, - S3_SR +0x58, 0x00, - S3_SR +0x59, 0x70, - S3_SR +0x5a, 0x38, - S3_SR +0x5b, 0x08, - S3_SR +0x5c, 0x77, - S3_SR +0x5d, 0x77, - S3_SR +0x5e, 0x00, - S3_SR +0x5f, 0x00, - S3_SR +0x60, 0xff, - S3_SR +0x61, 0xbf, - S3_SR +0x62, 0xff, - S3_SR +0x63, 0xff, - S3_SR +0x64, 0xf7, - S3_SR +0x65, 0xff, - S3_SR +0x66, 0xff, - S3_SR +0x67, 0xff, - S3_SR +0x68, 0xff, - S3_SR +0x69, 0xff, - S3_SR +0x6a, 0xff, - S3_SR +0x6b, 0xff, - S3_SR +0x6c, 0xff, - S3_SR +0x6d, 0xff, - S3_SR +0x6e, 0x9b, - S3_SR +0x6f, 0xbf, - - S3_AR + 0x00, 0x00, - S3_AR + 0x01, 0x01, - S3_AR + 0x02, 0x02, - S3_AR + 0x03, 0x03, - S3_AR + 0x04, 0x04, - S3_AR + 0x05, 0x05, - S3_AR + 0x06, 0x06, - S3_AR + 0x07, 0x07, - S3_AR + 0x08, 0x08, - S3_AR + 0x09, 0x09, - S3_AR + 0x0a, 0x0a, - S3_AR + 0x0b, 0x0b, - S3_AR + 0x0c, 0x0c, - S3_AR + 0x0d, 0x0d, - S3_AR + 0x0e, 0x0e, - S3_AR + 0x0f, 0x0f, - S3_AR + 0x10, 0x05, - S3_AR + 0x11, 0x00, - S3_AR + 0x12, 0x0f, - S3_AR + 0x13, 0x08, - S3_AR + 0x14, 0x00, - - S3_GR + 0x00, 0x00, - S3_GR + 0x01, 0x00, - S3_GR + 0x02, 0x00, - S3_GR + 0x03, 0x00, - S3_GR + 0x04, 0x00, - S3_GR + 0x05, 0x10, - S3_GR + 0x06, 0x0e, - S3_GR + 0x07, 0x00, - - S3_CR + 0x00, 0x5f, - S3_CR + 0x01, 0x4f, - S3_CR + 0x02, 0x50, - S3_CR + 0x03, 0x82, - S3_CR + 0x04, 0x55, - S3_CR + 0x05, 0x81, - S3_CR + 0x06, 0xbf, - S3_CR + 0x07, 0x1f, - S3_CR + 0x08, 0x00, - S3_CR + 0x09, 0x4f, - S3_CR + 0x0a, 0x0d, - S3_CR + 0x0b, 0x0e, - S3_CR + 0x0c, 0x00, - S3_CR + 0x0d, 0x00, - S3_CR + 0x0e, 0x3f, - S3_CR + 0x0f, 0xff, - S3_CR + 0x10, 0x9c, - S3_CR + 0x11, 0x0e, - S3_CR + 0x12, 0x8f, - S3_CR + 0x13, 0x28, - S3_CR + 0x14, 0x1f, - S3_CR + 0x15, 0x96, - S3_CR + 0x16, 0xb9, - S3_CR + 0x17, 0xa3, - S3_CR + 0x18, 0xff, - S3_CR + 0x19, 0xdf, - S3_CR + 0x1a, 0xdf, - S3_CR + 0x1b, 0xdf, - S3_CR + 0x1c, 0xdf, - S3_CR + 0x1d, 0xdf, - S3_CR + 0x1e, 0xdf, - S3_CR + 0x1f, 0xdf, - S3_CR + 0x20, 0xdf, - S3_CR + 0x21, 0x00, -/* S3_CR + 0x22, 0x07, */ - S3_CR + 0x23, 0x00, - S3_CR + 0x24, 0xdf, - S3_CR + 0x25, 0xdf, - S3_CR + 0x26, 0x00, - S3_CR + 0x27, 0xdf, - S3_CR + 0x28, 0xdf, - S3_CR + 0x29, 0xdf, - S3_CR + 0x2a, 0xdf, - S3_CR + 0x2b, 0xdf, - S3_CR + 0x2c, 0xdf, - S3_CR + 0x2d, 0x8a, - S3_CR + 0x2e, 0x22, - S3_CR + 0x2f, 0x02, - S3_CR + 0x30, 0xe1, - S3_CR + 0x31, 0x05, - S3_CR + 0x32, 0x40, - S3_CR + 0x33, 0x08, - S3_CR + 0x34, 0x00, - S3_CR + 0x35, 0x00, - S3_CR + 0x36, 0xbf, - S3_CR + 0x37, 0x9b, -/* S3_CR + 0x38, 0x7b, */ -/* S3_CR + 0x39, 0xb8, */ - S3_CR + 0x3a, 0x45, - S3_CR + 0x3b, 0x5a, - S3_CR + 0x3c, 0x10, - S3_CR + 0x3d, 0x00, - S3_CR + 0x3e, 0xfd, - S3_CR + 0x3f, 0x00, - S3_CR + 0x40, 0x00, - S3_CR + 0x41, 0x92, - S3_CR + 0x42, 0xc0, - S3_CR + 0x43, 0x68, - S3_CR + 0x44, 0xff, - S3_CR + 0x45, 0xe8, - S3_CR + 0x46, 0xff, - S3_CR + 0x47, 0xff, - S3_CR + 0x48, 0xf8, - S3_CR + 0x49, 0xff, - S3_CR + 0x4a, 0xfe, - S3_CR + 0x4b, 0xff, - S3_CR + 0x4c, 0xff, - S3_CR + 0x4d, 0xff, - S3_CR + 0x4e, 0xff, - S3_CR + 0x4f, 0xff, - S3_CR + 0x50, 0x00, - S3_CR + 0x51, 0x00, - S3_CR + 0x52, 0x00, - S3_CR + 0x53, 0x00, - S3_CR + 0x54, 0x00, - S3_CR + 0x55, 0x00, - S3_CR + 0x56, 0x00, - S3_CR + 0x57, 0x00, -#if 0 - S3_CR + 0x58, 0x00, - S3_CR + 0x59, 0xf0, -#endif - S3_CR + 0x5a, 0x00, - S3_CR + 0x5b, 0x00, -#if 0 - S3_CR + 0x5c, 0x00, -#endif - S3_CR + 0x5d, 0x00, - S3_CR + 0x5e, 0x00, - S3_CR + 0x5f, 0x00, - S3_CR + 0x60, 0x09, - S3_CR + 0x61, 0x9d, - S3_CR + 0x62, 0xff, - S3_CR + 0x63, 0x00, - S3_CR + 0x64, 0xfd, - S3_CR + 0x65, 0x04, - S3_CR + 0x66, 0x88, - S3_CR + 0x67, 0x00, - S3_CR + 0x68, 0x7f, - S3_CR + 0x69, 0x00, - S3_CR + 0x6a, 0x00, - S3_CR + 0x6b, 0x00, - S3_CR + 0x6c, 0x00, - S3_CR + 0x6d, 0x11, - S3_CR + 0x6e, 0xff, - S3_CR + 0x6f, 0xfe, - - S3_CR + 0x70, 0x30, - S3_CR + 0x71, 0xc0, - S3_CR + 0x72, 0x07, - S3_CR + 0x73, 0x1f, - S3_CR + 0x74, 0x1f, - S3_CR + 0x75, 0x1f, - S3_CR + 0x76, 0x0f, - S3_CR + 0x77, 0x1f, - S3_CR + 0x78, 0x01, - S3_CR + 0x79, 0x01, - S3_CR + 0x7a, 0x1f, - S3_CR + 0x7b, 0x1f, - S3_CR + 0x7c, 0x17, - S3_CR + 0x7d, 0x17, - S3_CR + 0x7e, 0x17, - S3_CR + 0x7f, 0xfd, - S3_CR + 0x80, 0x00, - S3_CR + 0x81, 0x92, - S3_CR + 0x82, 0x10, - S3_CR + 0x83, 0x07, - S3_CR + 0x84, 0x42, - S3_CR + 0x85, 0x00, - S3_CR + 0x86, 0x00, - S3_CR + 0x87, 0x00, - S3_CR + 0x88, 0x10, - S3_CR + 0x89, 0xfd, - S3_CR + 0x8a, 0xfd, - S3_CR + 0x8b, 0xfd, - S3_CR + 0x8c, 0xfd, - S3_CR + 0x8d, 0xfd, - S3_CR + 0x8e, 0xfd, - S3_CR + 0x8f, 0xfd, - S3_CR + 0x90, 0x00, - S3_CR + 0x91, 0x4f, - S3_CR + 0x92, 0x10, - S3_CR + 0x93, 0x00, - S3_CR + 0x94, 0xfd, - S3_CR + 0x95, 0xfd, - S3_CR + 0x96, 0xfd, - S3_CR + 0x97, 0xfd, - S3_CR + 0x98, 0xfd, - S3_CR + 0x99, 0xff, - S3_CR + 0x9a, 0xfd, - S3_CR + 0x9b, 0xff, - S3_CR + 0x9c, 0xfd, - S3_CR + 0x9d, 0xfd, - S3_CR + 0x9e, 0xfd, - S3_CR + 0x9f, 0xff, - S3_CR + 0xa0, 0x0f, -#if 0 - S3_CR + 0xa1, 0x00, - S3_CR + 0xa2, 0x00, - S3_CR + 0xa3, 0x00, - S3_CR + 0xa4, 0x55, -#endif - S3_CR + 0xa5, 0x09, - S3_CR + 0xa6, 0x20, -#if 0 - S3_CR + 0xa7, 0x00, - S3_CR + 0xa8, 0x00, - S3_CR + 0xa9, 0x00, - S3_CR + 0xaa, 0x00, - S3_CR + 0xab, 0x00, - S3_CR + 0xac, 0x00, - S3_CR + 0xad, 0x00, - S3_CR + 0xae, 0x00, - S3_CR + 0xaf, 0x00, - S3_CR + 0xb0, 0xff, -#endif - S3_CR + 0xb1, 0x0e, -#if 0 - S3_CR + 0xb2, 0x55, - S3_CR + 0xb3, 0x00, - S3_CR + 0xb4, 0x55, - S3_CR + 0xb5, 0x00, - S3_CR + 0xb6, 0x00, -#endif - S3_CR + 0xb7, 0x84, -#if 0 - S3_CR + 0xb8, 0xff, - S3_CR + 0xb9, 0xff, - S3_CR + 0xba, 0xff, - S3_CR + 0xbb, 0xff, - S3_CR + 0xbc, 0xff, - S3_CR + 0xbd, 0xff, - S3_CR + 0xbe, 0xff, - S3_CR + 0xbf, 0xff, -#endif - - S3_SR +0x15, 0x23, - 0xffff, 1, - S3_SR +0x15, 0x03, - 0xffff, 1, -}; - -#define S3_NUM_BIOS_REG (sizeof (s3BiosReg) / sizeof (s3BiosReg[0])) - -typedef struct _bios32Init { - VGA16 offset; - VGA32 value; -} s3Bios32Init; - -s3Bios32Init s3Bios32Reg[] = { - 0x8168, 0x00000000, - 0x816c, 0x00000001, - 0x8170, 0x00000000, - 0x8174, 0x00000000, - 0x8178, 0x00000000, - 0x817c, 0x00000000, -#if 0 - 0x8180, 0x00140000, - 0x8184, 0x00000000, - 0x8188, 0x00000000, - 0x8190, 0x00000000, - 0x8194, 0x00000000, - 0x8198, 0x00000000, - 0x819c, 0x00000000, - 0x81a0, 0x00000000, -#endif - 0x81c0, 0x00000000, - 0x81c4, 0x01fbffff, - 0x81c8, 0x00f7ffbf, - 0x81cc, 0x00f7ff00, - 0x81d0, 0x11ffff7f, - 0x81d4, 0x7fffffdf, - 0x81d8, 0xfdfff9ff, - 0x81e0, 0xfd000000, - 0x81e4, 0x00000000, - 0x81e8, 0x00000000, - 0x81ec, 0x00010000, - 0x81f0, 0x07ff057f, - 0x81f4, 0x07ff07ff, - 0x81f8, 0x00000000, - 0x81fc, 0x00000000, - 0x8200, 0x00000000, - 0x8204, 0x00000000, - 0x8208, 0x33000000, - 0x820c, 0x7f000000, - 0x8210, 0x80000000, - 0x8214, 0x00000000, - 0x8218, 0xffffffff, - 0x8300, 0xff007fef, - 0x8304, 0xfffdf7bf, - 0x8308, 0xfdfffbff, -}; - -#define S3_NUM_BIOS32_REG (sizeof (s3Bios32Reg) / sizeof (s3Bios32Reg[0])) - -/* - * Initialize the card precisely as the bios does - */ -s3DoBiosInit (KdCardInfo *card) -{ - S3CardInfo *s3c = card->driver; - CARD32 *regs = (CARD32 *) s3c->registers; - S3Vga *s3vga = &s3c->s3vga; - int r; - - for (r = 0; r < S3_NUM_BIOS_REG; r++) - { - if (s3BiosReg[r].reg == 0xffff) - sleep (s3BiosReg[r].value); - else - VgaStore (&s3vga->card, s3BiosReg[r].reg, s3BiosReg[r].value); - } - VgaStore (&s3vga->card, S3_SR+0x10, 0x22); - VgaStore (&s3vga->card, S3_SR+0x11, 0x44); - VgaStore (&s3vga->card, S3_SR+0x15, 0x01); - sleep (1); - VgaStore (&s3vga->card, S3_SR+0x15, 0x03); - VgaStore (&s3vga->card, S3_CR+0x6f, 0xff); - VgaStore (&s3vga->card, S3_CR+0x3f, 0x3f); - sleep (1); - VgaStore (&s3vga->card, S3_CR+0x3f, 0x00); - VgaStore (&s3vga->card, S3_CR+0x6f, 0xfe); - VgaInvalidate (&s3vga->card); - for (r = 0; r < S3_NUM_BIOS32_REG; r++) - regs[s3Bios32Reg[r].offset/4] = s3Bios32Reg[r].value; -} - -void -s3Preserve (KdCardInfo *card) -{ - S3CardInfo *s3c = card->driver; - S3Ptr s3 = s3c->s3; - S3Vga *s3vga = &s3c->s3vga; - S3Save *save = &s3c->save; - CARD8 t1, t2; - CARD8 *cursor_base; - CARD8 streams_mode; - - s3Save (s3vga); - if (!s3c->bios_initialized) - s3DoBiosInit (card); - - _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; - /* - * Preserve streams processor state - */ - streams_mode = s3Get (s3vga, s3_streams_mode); - s3SetImm (s3vga, s3_streams_mode, 3); - save->global_bitmap_1 = s3->global_bitmap_1; - save->global_bitmap_2 = s3->global_bitmap_2; - save->adv_func_cntl = s3->adv_func_cntl; - save->primary_bitmap_1 = s3->primary_bitmap_1; - save->primary_bitmap_2 = s3->primary_bitmap_2; - save->secondary_bitmap_1 = s3->secondary_bitmap_1; - save->secondary_bitmap_2 = s3->secondary_bitmap_2; - save->primary_stream_control = s3->primary_stream_control; - save->blend_control = s3->blend_control; - save->primary_stream_addr_0 = s3->primary_stream_addr_0; - save->primary_stream_addr_1 = s3->primary_stream_addr_1; - save->primary_stream_stride = s3->primary_stream_stride; - save->primary_stream_xy = s3->primary_stream_xy; - save->primary_stream_size = s3->primary_stream_size; - save->primary_stream_mem = s3->primary_stream_mem; - save->secondary_stream_xy = s3->secondary_stream_xy; - save->secondary_stream_size = s3->secondary_stream_size; - save->streams_fifo = s3->streams_fifo; - s3SetImm (s3vga, s3_streams_mode, streams_mode); - _s3SetBlank (s3, s3vga, FALSE); -} - -/* - * Enable the card for rendering. Manipulate the initial settings - * of the card here. - */ -int s3CpuTimeout, s3AccelTimeout; - -void -s3SetGlobalBitmap (ScreenPtr pScreen, int ma) -{ - KdScreenPriv(pScreen); - s3ScreenInfo (pScreenPriv); - - if (s3s->current_ma != ma) - { - s3CardInfo (pScreenPriv); - S3Vga *s3vga = &s3c->s3vga; - S3Ptr s3 = s3c->s3; - CARD32 gb1, gb2; - int depth; - int length; - KdCheckSync (pScreen); - switch (s3s->fb[ma].accel_bpp) { - case 8: - case 24: - length = 0; - break; - case 16: - length = 1; - break; - case 32: - length = 3; - break; - } - s3SetImm (s3vga, s3_pixel_length, length); - gb1 = s3s->fb[ma].bitmap_offset; - gb2 = ((1 << 0) | - (0 << 2) | - (1 << 3) | - ((s3s->fb[ma].accel_stride >> 4) << 4) | - (s3s->fb[ma].accel_bpp << 16) | - (0 << 24) | - (1 << 28)); - s3->global_bitmap_1 = gb1; - s3->global_bitmap_2 = gb2; - s3->global_bitmap_2 = gb2; - s3s->current_ma = ma; - } -} - -Bool -s3Enable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - KdScreenInfo *screen = pScreenPriv->screen; - s3CardInfo (pScreenPriv); - s3ScreenInfo (pScreenPriv); - - S3Vga *s3vga = &s3c->s3vga; - S3Ptr s3 = s3c->s3; - 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[KD_MAX_FB]; - - int v_total; - int v_retrace_start; - int v_retrace_end; - int v_display_end; - int v_blank_start; - int v_blank_end; - int v_blank_start_adjust = 0; - int v_blank_end_adjust = 0; - - int h_blank_start_adjust = 0; - int h_blank_end_adjust = 0; - int h_sync_start_adjust = 0; - int h_sync_end_adjust = 0; - int h_start_fifo_fetch_adjust = 0; - int h_sync_extend; - int h_blank_extend; - int i; - CARD16 cursor_address; - const KdMonitorTiming *t; - int m, n, r; - Bool clock_double; - int cpu_timeout; - int accel_timeout; - int bytes_per_ms; - CARD32 control[2]; - int fb; - int ma; - - s3s->primary_depth = screen->fb[s3s->fbmap[0]].depth; - - s3s->use_streams = TRUE; - - t = KdFindMode (screen, s3ModeSupported); - - 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); -#define DEBUG_CLOCK -#ifdef DEBUG_CLOCK - fprintf (stderr, "old clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); -#endif - clock_double = FALSE; - s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000); - if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK && !s3s->use_streams) - 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_CLOCK - fprintf (stderr, "new clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); -#endif - - if (s3s->use_streams) - { - s3Set (s3vga, s3_streams_mode, 3); - s3Set (s3vga, s3_enable_l1_parameter, 1); - } - else - { - s3Set (s3vga, s3_streams_mode, 0); - s3Set (s3vga, s3_enable_l1_parameter, 0); - } - s3Set (s3vga, s3_flat_panel_output_control_1, 0); - s3Set (s3vga, s3_flat_panel_output_control_2, 0); - 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_2bk_cga, 1); - s3Set (s3vga, s3_4bk_hga, 1); - s3Set (s3vga, s3_v_total_double, 0); - s3Set (s3vga, s3_address_16k_wrap, 1); - s3Set (s3vga, s3_word_mode, 0); - s3Set (s3vga, s3_byte_mode, 1); - s3Set (s3vga, s3_hardware_reset, 1); - s3Set (s3vga, s3_max_scan_line, 0); - s3Set (s3vga, s3_linear_window_size, 3); - s3Set (s3vga, s3_enable_linear, 1); - 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_disconnect_enable, 1); - s3Set (s3vga, s3_primary_load_control, 0); - s3Set (s3vga, s3_secondary_load_control, 0); - s3Set (s3vga, s3_pci_retry_enable, 1); - s3Set (s3vga, s3_enable_256, 1); - s3Set (s3vga, s3_border_select, 1); /* eliminate white border */ - s3SetImm (s3vga, s3_lock_palette, 0); /* unlock palette/border regs */ - s3Set (s3vga, s3_disable_v_retrace_int, 1); - if (t->hpol == KdSyncPositive) - s3Set (s3vga, s3_horz_sync_neg, 0); - else - s3Set (s3vga, s3_horz_sync_neg, 1); - if (t->vpol == KdSyncPositive) - s3Set (s3vga, s3_vert_sync_neg, 0); - else - s3Set (s3vga, s3_vert_sync_neg, 1); - - s3Set (s3vga, s3_dot_clock_8, 1); - s3Set (s3vga, s3_enable_write_plane, 0xf); - s3Set (s3vga, s3_extended_memory_access, 1); - s3Set (s3vga, s3_sequential_addressing_mode, 1); - s3Set (s3vga, s3_select_chain_4_mode, 1); - s3Set (s3vga, s3_linear_addressing_control, 1); - - s3Set (s3vga, s3_enable_gamma_correction, 0); - - s3Set (s3vga, s3_enable_8_bit_luts, 1); - - s3Set (s3vga, s3_dclk_invert, 0); - s3Set (s3vga, s3_enable_clock_double, 0); - s3Set (s3vga, s3_dclk_over_2, 0); - - s3Set (s3vga, s3_delay_h_enable, 0); - s3Set (s3vga, s3_sdclk_skew, 0); - - s3Set (s3vga, s3_dac_mask, 0xff); - -#if 0 -#ifdef DEBUG_CLOCK - m = s3Get (s3vga, s3_mclk_m); - n = s3Get (s3vga, s3_mclk_n); - r = s3Get (s3vga, s3_mclk_r); - fprintf (stderr, "old mclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); -#endif - - s3GetClock (125282, &m, &n, &r, 127, 31, 3, 250000); - -#ifdef DEBUG_CLOCK - fprintf (stderr, "new mclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r)); -#endif - - s3Set (s3vga, s3_mclk_m, m); - s3Set (s3vga, s3_mclk_n, n); - s3Set (s3vga, s3_mclk_r, r); - -#ifdef DEBUG_CLOCK - m = s3Get (s3vga, s3_eclk_m); - n = s3Get (s3vga, s3_eclk_n); - r = s3Get (s3vga, s3_eclk_r); - fprintf (stderr, "old eclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); -#endif - -#define S3_ECLK 125282 - - s3GetClock (S3_ECLK, &m, &n, &r, 127, 31, 3, 250000); - -#ifdef DEBUG_CLOCK - fprintf (stderr, "new eclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r)); -#endif - - s3Set (s3vga, s3_eclk_m, m); - s3Set (s3vga, s3_eclk_n, n); - s3Set (s3vga, s3_eclk_r, r); -#endif - - /* - * Compute character lengths for horizontal timing values - */ - hactive = screen->width / 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - /* - * Set pixel size, choose clock doubling mode - */ - - bytes_per_ms = 0; - - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - { - fb = s3s->fbmap[ma]; - s3s->fb[ma].accel_bpp = screen->fb[fb].bitsPerPixel; - s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride; - s3s->fb[ma].bitmap_offset = screen->fb[fb].frameBuffer - s3c->frameBuffer; - switch (s3s->fb[ma].accel_bpp) { - case 8: - h_screen_off = hactive; - s3Set (s3vga, s3_pixel_length, 0); - s3Set (s3vga, s3_color_mode, 0); - control[ma] = 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_h_skew, 1); - h_blank_start_adjust = -3; - h_blank_end_adjust = -4; - s3Set (s3vga, s3_border_select, 0); - } - break; - case 16: - h_screen_off = hactive * 2; - s3Set (s3vga, s3_pixel_length, 1); - if (screen->fb[fb].depth == 15) - control[ma] = 3 << 24; - else - control[ma] = 5 << 24; - if (clock_double) - { - if (screen->fb[fb].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); - h_blank_start_adjust = 4; - h_blank_end_adjust = -4; - } - else - { - if (screen->fb[fb].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 24: - control[ma] = 6 << 24; - h_screen_off = hactive * 3; - s3s->fb[ma].accel_bpp = 8; - s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride * 3; - break; - case 32: - control[ma] = 7 << 24; - h_screen_off = hactive * 4; - s3Set (s3vga, s3_pixel_length, 3); - s3Set (s3vga, s3_color_mode, 0xd); - break; - } - bytes_per_ms += t->clock * (screen->fb[fb].bitsPerPixel / 8); - primary_stream_l1[ma] = (screen->width * screen->fb[fb].bitsPerPixel / (8 * 8)) - 1; - } - - /* - * X server starts frame buffer at top of memory - */ - s3Set (s3vga, s3_start_address, 0); - - /* - * Set various registers to avoid snow on the screen - */ - - fprintf (stderr, "bytes_per_ms %d\n", bytes_per_ms); - fprintf (stderr, "primary 0x%x master 0x%x command 0x%x lpb 0x%x cpu 0x%x 2d 0x%x\n", - s3Get (s3vga, s3_primary_stream_timeout), - s3Get (s3vga, s3_master_control_unit_timeout), - s3Get (s3vga, s3_command_buffer_timeout), - s3Get (s3vga, s3_lpb_timeout), - s3Get (s3vga, s3_cpu_timeout), - s3Get (s3vga, s3_2d_graphics_engine_timeout)); - - /* - * Test: - * accel x11perf -line500 - * cpu x11perf -circle500 - * - * cpu accel - * 1600x1200x32x85 (918000) 1 1 not enough - * 1600x1200x32x75 (810000) 3 2 - * 1600x1200x32x70 (756000) 4 3 - * 1600x1200x32x60 (648000) 6 5 - * - * 1280x1024x32x85 (630000) 6 4 - * 1280x1024x32x75 (540000) a 6 - * 1280x1024x32x60 (432000) 1f a - * - * 1152x900x32x85 (490000) a 6 - * 1152x900x32x75 (433000) 1f 8 - * 1152x900x32x70 (401000) 1f a - * 1152x900x32x66 (380000) 1f a - * - * 1024x768x32x85 (378000) 1f a - * 1024x768x32x75 (315000) 1f b - * 1024x768x32x70 (300000) 1f b - * 1024x768x32x60 (260000) 1f 12 - * - * 800x600x32x85 (225000) 1f 1a - * 800x600x32x72 (200000) 1f 1d - * 800x600x32x75 (198000) 1f 1d - * - * 1600x1200x16x85 (459000) 1f 8 - * 1600x1200x16x75 (405000) 1f a - * 1600x1200x16x70 (378000) 1f b - * 1600x1200x16x60 (324000) 1f f - * - * 1280x1024x16x85 (315000) 1f 12 - * 1280x1024x16x75 (270000) 1f 16 - * 1280x1024x16x60 (216000) 1f 1d - * - * 1600x1200x8x85 (229000) 1f 1f - * - */ - - if (s3CpuTimeout) - { - if (s3CpuTimeout < 0) - cpu_timeout = 0; - else - cpu_timeout = s3CpuTimeout; - if (s3AccelTimeout < 0) - accel_timeout = 0; - else if (s3AccelTimeout) - accel_timeout = s3AccelTimeout; - else - accel_timeout = s3CpuTimeout; - } - else if (bytes_per_ms >= 900000) - { - cpu_timeout = 0x01; - accel_timeout = 0x01; - } - else if (bytes_per_ms >= 800000) - { - cpu_timeout = 0x03; - accel_timeout = 0x02; - } - else if (bytes_per_ms >= 700000) - { - cpu_timeout = 0x04; - accel_timeout = 0x03; - } - else if (bytes_per_ms >= 600000) - { - cpu_timeout = 0x06; - accel_timeout = 0x04; - } - else if (bytes_per_ms >= 475000) - { - cpu_timeout = 0x0a; - accel_timeout = 0x06; - } - else if (bytes_per_ms >= 425000) - { - cpu_timeout = 0x1f; - accel_timeout = 0x8; - } - else if (bytes_per_ms >= 300000) - { - cpu_timeout = 0x1f; - accel_timeout = 0x0a; - } - else if (bytes_per_ms >= 250000) - { - cpu_timeout = 0x1f; - accel_timeout = 0x12; - } - else if (bytes_per_ms >= 200000) - { - cpu_timeout = 0x1f; - accel_timeout = 0x1a; - } - else - { - cpu_timeout = 0x1f; - accel_timeout = 0x1f; - } - - fprintf (stderr, "cpu 0x%x accel 0x%x\n", cpu_timeout, accel_timeout); - - s3Set (s3vga, s3_primary_stream_timeout, 0xc0); - s3Set (s3vga, s3_master_control_unit_timeout, 0xf); - s3Set (s3vga, s3_command_buffer_timeout, 0x1f); - s3Set (s3vga, s3_lpb_timeout, 0xf); - s3Set (s3vga, s3_2d_graphics_engine_timeout, accel_timeout); - s3Set (s3vga, s3_cpu_timeout, cpu_timeout); - - s3Set (s3vga, s3_fifo_fetch_timing, 1); - s3Set (s3vga, s3_fifo_drain_delay, 2); - - /* - * Compute horizontal register values from timings - */ - h_total = hactive + hblank - 5; - h_display_end = hactive - 1; - - h_sync_start = hactive + hfp + h_sync_start_adjust; - h_sync_end = hactive + hblank - hbp + h_sync_end_adjust; - /* - * 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; - - h_start_fifo_fetch += h_start_fifo_fetch_adjust; - 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; - -#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_dac_power_saving_disable, 0); - s3Set (s3vga, s3_dac_power_up_time, hactive + hblank); - - s3Set (s3vga, s3_primary_stream_l1, primary_stream_l1[0]); - - s3Set (s3vga, s3_streams_fifo_delay, 0); - - v_total = vactive + vblank - 2; - v_display_end = vactive - 1; - - v_blank_start = vactive - 1 + v_blank_start_adjust; - v_blank_end = v_blank_start + vblank - 1 + v_blank_end_adjust; - - 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 - s3c->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); - -#define MAKE_GBF(bds,be,stride,bpp,tile) (\ - ((bds) << 0) | \ - ((be) << 3) | \ - ((stride) << 4) | \ - ((bpp) << 16) | \ - ((tile) << 24)) - /* - * Set accelerator - */ - switch (screen->width) { -#if 0 - 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; -#endif - default: - s3Set (s3vga, s3_ge_screen_width, 7); /* use global bitmap descriptor */ - } - -#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); - - _s3SetBlank (s3, s3vga, TRUE); - if (s3s->use_streams) - s3Set (s3vga, s3_primary_stream_definition, 1); - else - s3Set (s3vga, s3_primary_stream_definition, 0); - - VgaFlush(&s3vga->card); - VgaSetImm (&s3vga->card, s3_clock_load_imm, 1); - VgaSetImm(&s3vga->card, s3_clock_load_imm, 0); - - - if (s3s->use_streams) - { - fb = s3s->fbmap[0]; - s3->primary_stream_control = control[0]; - s3->primary_stream_addr_0 = - s3->primary_stream_addr_1 = s3s->fb[0].bitmap_offset; - s3->primary_stream_stride = screen->fb[fb].byteStride; - s3->primary_stream_xy = (1 << 16) | 1; - s3->primary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height; - s3->primary_stream_mem = (screen->fb[fb].byteStride * screen->height) / 8 - 1; - if (s3s->fbmap[1] >= 0) - { - fb = s3s->fbmap[1]; - s3->blend_control = 5 << 24; - if (s3s->fb[0].accel_bpp == 8) - s3->chroma_key_control = 0x33000000 | s3s->fb[0].chroma_key; - else - s3->chroma_key_control = 0x13010101; - s3->secondary_stream_control = control[1] | screen->width; - s3->secondary_stream_h_scale = (1 << 15); - s3->color_adjustment = 0; - s3->secondary_stream_vscale = (1 << 15); - s3->secondary_stream_vinit = 0; - s3->secondary_stream_mbuf = 0; - s3->secondary_stream_addr_0 = - s3->secondary_stream_addr_1 = s3s->fb[1].bitmap_offset; - s3->secondary_stream_stride = screen->fb[fb].byteStride; - s3->secondary_stream_scount = screen->height; - s3->secondary_stream_xy = (1 << 16) | 1; - s3->secondary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height; - s3->secondary_stream_mem = (1 << 22) | ((screen->fb[fb].byteStride * screen->height) / 8 - 1); - } - else - { - s3->blend_control = 1 << 24; - s3->secondary_stream_xy = 0x07ff07ff; - s3->secondary_stream_size = 0x00010001; - } - s3->streams_fifo = (0x20 << 11) | (0x20 << 5) | 0x2; - } - s3->mult_misc_read_sel = (((1 << 9) | - (1 << 11) | - (0xe << 12)) | - (((0xe << 0) | - (0xf << 12)) << 16)); - - s3->cmd_overflow_buf_ptr = (1 << 3); - s3->bci_power_management = (1 << 9); - s3->adv_func_cntl = (3 << 8) | (1 << 4) | (1 << 2) | 1; - s3->primary_bitmap_1 = 0; - s3->primary_bitmap_2 = 0; - s3->secondary_bitmap_1 = 0; - s3->secondary_bitmap_2 = 0; - s3s->current_ma = -1; - _s3SetBlank (s3, s3vga, FALSE); -#if 0 - { - VGA16 r; - static CARD32 streams[][2] = { - /* PCI registers */ - 0x8000, 0x8024, - 0x802c, 0x8034, - 0x803c, 0x8040, -#if 0 - 0x8080, 0x808c, /* AGP */ -#endif - 0x80dc, 0x80e0, - - /* 2D registers */ - 0x8168, 0x8188, - 0x8190, 0x81a0, - 0x81c0, 0x81d8, - 0x81e0, 0x8218, - 0x8300, 0x8308, - 0x8504, 0x8510, - - /* LPB/VIP registers */ - 0xff00, 0xff18, - 0xff20, 0xff38, - 0xff40, 0xff40, - 0xff70, 0xff78, - 0xff8c, 0xffa0, - -#if 0 - /* 3D registers */ - 0x48508, 0x48508, - 0x48528, 0x48528, - 0x48548, 0x48548, - 0x48584, 0x485f0, -#endif - - /* motion compensation registers */ - 0x48900, 0x48924, -#if 0 - 0x48928, 0x48928, -#endif - - /* Mastered data transfer registers */ - 0x48a00, 0x48a1c, - - /* configuation/status registers */ - 0x48c00, 0x48c18, - 0x48c20, 0x48c24, - 0x48c40, 0x48c50, - 0x48c60, 0x48c64, - - 0, 0, - }; -#ifdef PHOENIX -#undef stderr -#define stderr stdout -#endif - CARD32 *regs = (CARD32 *) s3c->registers; - int i; - CARD32 reg; - - - for (r = S3_SR + 0; r < S3_SR + S3_NSR; r++) - fprintf (stderr, "SR%02x = %02x\n", r-S3_SR, VgaFetch (&s3vga->card, r)); - for (r = S3_GR + 0; r < S3_GR + S3_NGR; r++) - fprintf (stderr, "GR%02x = %02x\n", r-S3_GR, VgaFetch (&s3vga->card, r)); - for (r = S3_AR + 0; r < S3_AR + S3_NAR; r++) - fprintf (stderr, "AR%02x = %02x\n", r-S3_AR, VgaFetch (&s3vga->card, r)); - for (r = S3_CR + 0; r < S3_CR + S3_NCR; r++) - fprintf (stderr, "CR%02x = %02x\n", r-S3_CR, VgaFetch (&s3vga->card, r)); - for (r = S3_DAC + 0; r < S3_DAC + S3_NDAC; r++) - fprintf (stderr, "DAC%02x = %02x\n", r-S3_DAC, VgaFetch (&s3vga->card, r)); - fprintf (stderr, "MISC_OUT = %02x\n", VgaFetch (&s3vga->card, S3_MISC_OUT)); - fprintf (stderr, "INPUT_STATUS = %02x\n", VgaFetch (&s3vga->card, S3_INPUT_STATUS_1)); - - - for (i = 0; streams[i][0]; i++) - { - for (reg = streams[i][0]; reg <= streams[i][1]; reg += 4) - fprintf (stderr, "0x%4x: 0x%08x\n", reg, regs[reg/4]); - } - } -#endif - return TRUE; -} - -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; - CARD8 streams_mode; - - _s3SetBlank (s3, s3vga, TRUE); - /* streams processor state */ - streams_mode = s3Get (s3vga, s3_streams_mode); - s3SetImm (s3vga, s3_streams_mode, 3); - s3->global_bitmap_1 = save->global_bitmap_1; - s3->global_bitmap_2 = save->global_bitmap_2; - s3->adv_func_cntl = save->adv_func_cntl; - s3->primary_bitmap_1 = save->primary_bitmap_1; - s3->primary_bitmap_2 = save->primary_bitmap_2; - s3->secondary_bitmap_1 = save->secondary_bitmap_1; - s3->secondary_bitmap_2 = save->secondary_bitmap_2; - s3->primary_stream_control = save->primary_stream_control; - s3->blend_control = save->blend_control; - s3->primary_stream_addr_0 = save->primary_stream_addr_0; - s3->primary_stream_addr_0 = save->primary_stream_addr_0; - s3->primary_stream_stride = save->primary_stream_stride; - s3->primary_stream_xy = save->primary_stream_xy; - s3->primary_stream_size = save->primary_stream_size; - s3->primary_stream_mem = save->primary_stream_mem; - s3->secondary_stream_xy = save->secondary_stream_xy; - s3->secondary_stream_size = save->secondary_stream_size; - s3->streams_fifo = save->streams_fifo; - s3SetImm (s3vga, s3_streams_mode, streams_mode); - /* 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; - - 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; -} - -Bool -s3InitScreen(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - KdScreenInfo *screen = pScreenPriv->screen; - s3CardInfo (pScreenPriv); - s3ScreenInfo (pScreenPriv); - int ma, fb; - - if (screen->fb[1].depth) - { - FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); - - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - { - fb = s3s->fbmap[ma]; - pScrPriv->layer[fb].key = s3s->fb[ma].chroma_key; - } - } - 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, - s3InitScreen, - s3Preserve, - s3Enable, - s3DPMS, - s3Disable, - s3Restore, - s3ScreenFini, - s3CardFini, - s3CursorInit, - s3CursorEnable, - s3CursorDisable, - s3CursorFini, - s3RecolorCursor, - s3DrawInit, - s3DrawEnable, - s3DrawSync, - s3DrawDisable, - s3DrawFini, - s3GetColors, - s3PutColors, -}; diff --git a/hw/kdrive/savage/s3.h b/hw/kdrive/savage/s3.h deleted file mode 100644 index 86e1863b4..000000000 --- a/hw/kdrive/savage/s3.h +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Id: s3.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.4 2000/05/06 22:17:45 keithp Exp $ */ - -#ifndef _S3_H_ -#define _S3_H_ - -#include "kdrive.h" -#include "s3reg.h" - -/* 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 */ -#if 0 - VOL16 pix_cntl; /* 8140 */ - VOL16 mult_misc2; /* 8142 */ -#else - VOL32 pix_cntl_mult_misc2; /* 8140 */ -#endif - VOL32 mult_misc_read_sel; /* 8144 */ - VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */ - VOL8 _pad3a[0x1c]; /* 814c */ - VOL32 global_bitmap_1; /* 8168 */ - VOL32 global_bitmap_2; /* 816c */ - VOL32 primary_bitmap_1; /* 8170 */ - VOL32 primary_bitmap_2; /* 8174 */ - VOL32 secondary_bitmap_1; /* 8178 */ - VOL32 secondary_bitmap_2; /* 817c */ - VOL32 primary_stream_control; /* 8180 */ - VOL32 chroma_key_control; /* 8184 */ - VOL32 genlocking_control; /* 8188 */ - VOL8 _pad3b[0x4]; /* 818c */ - VOL32 secondary_stream_control; /* 8190 */ - VOL32 chroma_key_upper_bound; /* 8194 */ - VOL32 secondary_stream_h_scale; /* 8198 */ - VOL32 color_adjustment; /* 819c */ - VOL32 blend_control; /* 81a0 */ - VOL8 _pad3c[0x1c]; /* 81a4 */ - VOL32 primary_stream_addr_0; /* 81c0 */ - VOL32 primary_stream_addr_1; /* 81c4 */ - VOL32 primary_stream_stride; /* 81c8 */ - VOL32 secondary_stream_mbuf; /* 81cc */ - VOL32 secondary_stream_addr_0;/* 81d0 */ - VOL32 secondary_stream_addr_1;/* 81d4 */ - VOL32 secondary_stream_stride;/* 81d8 */ - VOL8 _pad81dc[4]; /* 81dc */ - VOL32 secondary_stream_vscale;/* 81e0 */ - VOL32 secondary_stream_vinit; /* 81e4 */ - VOL32 secondary_stream_scount;/* 81e8 */ - VOL32 streams_fifo; /* 81ec */ - VOL32 primary_stream_xy; /* 81f0 */ - VOL32 primary_stream_size; /* 81f4 */ - VOL32 secondary_stream_xy; /* 81f8 */ - VOL32 secondary_stream_size; /* 81fc */ - VOL8 _pad8200[0xe8]; /* 8200 */ - VOL32 cur_y; /* 82e8 */ - VOL8 _pad4[0x14]; /* 82ec */ - VOL32 primary_stream_mem; /* 8300 */ - VOL32 secondary_stream_mem; /* 8304 */ - VOL8 _pad8308[0xD2]; /* 8308 */ - VOL8 input_status_1; /* 83da */ - VOL8 _pad83db[0x131]; /* 83db */ - VOL32 adv_func_cntl; /* 850c */ - VOL8 _pad8510[0x5dd8]; /* 8510 */ - VOL32 pix_trans; /* e2e8 */ - VOL8 _pade2ec[0x3a92c]; /* e2ec */ - VOL32 cmd_overflow_buf_ptr; /* 48c18 */ - VOL8 _pad48c1c[0x8]; /* 48c1c */ - VOL32 bci_power_management; /* 48c24 */ - VOL8 _pad48c28[0x38]; /* 48c28 */ - VOL32 alt_status_0; /* 48c60 */ - VOL32 alt_status_1; /* 48c64 */ -} 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 CONTROL_MISC2 0xd000 -#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 - -/* Multifunction Control Misc 8144 */ -#define MISC_DST_BA_0 (0x0 << 0) -#define MISC_DST_BA_1 (0x1 << 0) -#define MISC_DST_BA_2 (0x2 << 0) -#define MISC_DST_BA_3 (0x3 << 0) -#define MISC_SRC_BA_0 (0x0 << 2) -#define MISC_SRC_BA_1 (0x1 << 2) -#define MISC_SRC_BA_2 (0x2 << 2) -#define MISC_SRC_BA_3 (0x3 << 2) -#define MISC_RSF (1 << 4) -#define MISC_EXT_CLIP (1 << 5) -#define MISC_SRC_NE (1 << 7) -#define MISC_ENB_CMP (1 << 8) -#define MISC_32B (1 << 9) -#define MISC_DC (1 << 11) -#define MISC_INDEX_E (0xe << 12) - -#define S3_SAVAGE4_SLOTS 0x0001ffff -#define S3_SAVAGE4_2DI 0x00800000 - -#define _s3WaitLoop(s3,mask,value){ \ - int __loop = 1000000; \ - while (((s3)->alt_status_0 & (mask)) != (value)) \ - if (--__loop == 0) { \ - ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \ - break; \ - } \ -} - -#define S3_SAVAGE4_ROOM 10 - -#define _s3WaitSlots(s3,n) { \ - int __loop = 1000000; \ - while (((s3)->alt_status_0 & S3_SAVAGE4_SLOTS) >= S3_SAVAGE4_ROOM-(n)) \ - if (--__loop == 0) { \ - ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \ - break; \ - } \ -} - -#define _s3WaitEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS, 0) -#define _s3WaitIdleEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, S3_SAVAGE4_2DI) -#define _s3WaitIdle(s3) _s3WaitLoop(s3,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)))) - -#define S3_MAX_CLOCK 150000 /* KHz */ - -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; - CARD32 global_bitmap_1; - CARD32 global_bitmap_2; - CARD32 adv_func_cntl; - CARD32 primary_bitmap_1; - CARD32 primary_bitmap_2; - CARD32 secondary_bitmap_1; - CARD32 secondary_bitmap_2; - CARD32 primary_stream_control; - CARD32 blend_control; - CARD32 primary_stream_addr_0; - CARD32 primary_stream_addr_1; - CARD32 primary_stream_stride; - CARD32 primary_stream_xy; - CARD32 primary_stream_size; - CARD32 primary_stream_mem; - CARD32 secondary_stream_xy; - CARD32 secondary_stream_size; - CARD32 streams_fifo; - 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; - Bool need_sync; - Bool bios_initialized; /* whether the bios has been run */ -} S3CardInfo; - -typedef struct _s3FbInfo { - 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 */ - S3Patterns patterns; - CARD32 bitmap_offset; - int accel_stride; - int accel_bpp; - CARD32 chroma_key; -} S3FBInfo; - -typedef struct _s3ScreenInfo { - CARD8 *cursor_base; /* pointer to cursor area */ - S3Cursor cursor; - Bool managing_border; - Bool use_streams; - int primary_depth; - int current_ma; - CARD32 border_pixel; - S3FBInfo fb[KD_MAX_FB]; - RegionRec region[KD_MAX_FB]; - int fbmap[KD_MAX_FB+1]; /* map from fb to stream */ -} 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 *); -Bool 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); - -void s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what); -void s3DumbCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); - -Bool s3DrawInit (ScreenPtr pScreen); -void s3DrawEnable (ScreenPtr pScreen); -void s3DrawSync (ScreenPtr pScreen); -void s3DrawDisable (ScreenPtr pScreen); -void s3DrawFini (ScreenPtr pScreen); - -void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); -void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); - -void S3InitCard (KdCardAttr *attr); - -void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco); - -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(s3vga) { \ - int _loop_count; \ - _loop_count = 0; \ - while (s3GetImm(s3vga, s3_vertical_sync_active) != 0) S3_RETRACE_LOOP_CHECK; \ - _loop_count = 0; \ - while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \ -} -#define _s3WaitVRetraceFast(s3) { \ - int _loop_count; \ - _loop_count = 0; \ - while (s3->input_status_1 & 8) S3_RETRACE_LOOP_CHECK; \ - _loop_count = 0; \ - while ((s3->input_status_1 & 8) == 0) S3_RETRACE_LOOP_CHECK; \ -} -/* - * Wait for the begining of the retrace interval - */ -#define _s3WaitVRetraceEnd(s3vga) { \ - int _loop_count; \ - _loop_count = 0; \ - while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \ - _loop_count = 0; \ - while (s3GetImm(s3vga, s3_vertical_sync_active) != 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 - -#endif /* _S3_H_ */ diff --git a/hw/kdrive/savage/s3.nick b/hw/kdrive/savage/s3.nick deleted file mode 100644 index 8f6791f87..000000000 --- a/hw/kdrive/savage/s3.nick +++ /dev/null @@ -1,41 +0,0 @@ -/* $RCSId: $ */ - -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); -} diff --git a/hw/kdrive/savage/s3clock.c b/hw/kdrive/savage/s3clock.c deleted file mode 100644 index e3286b8c2..000000000 --- a/hw/kdrive/savage/s3clock.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Id: s3clock.c,v 1.2 1999/11/02 06:16:29 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3clock.c,v 1.3 2000/02/23 20:30:02 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 */ - -void -s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco) -{ - 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 (f_vco >= minVco) - break; - } - - /* M = f_out / f_ref * ((N + 2) * (1 << R)); */ - besterr = target; - for (N = 1; N <= maxN; N++) - { - M = ((target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) + 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; -} diff --git a/hw/kdrive/savage/s3cmap.c b/hw/kdrive/savage/s3cmap.c deleted file mode 100644 index f10ac5752..000000000 --- a/hw/kdrive/savage/s3cmap.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Id: s3cmap.c,v 1.2 1999/11/02 06:16:29 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.4 2000/05/06 22:17:45 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" - -void -s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - s3CardInfo(pScreenPriv); - S3Vga *s3vga = &s3c->s3vga; - - while (ndef--) - { - s3SetImm (s3vga, s3_dac_read_index, pdefs->pixel); - pdefs->red = s3GetImm (s3vga, s3_dac_data) << 8; - pdefs->green = s3GetImm (s3vga, s3_dac_data) << 8; - pdefs->blue = s3GetImm (s3vga, s3_dac_data) << 8; - pdefs++; - } -} - -#ifndef S3_TRIO -#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d))) - -void -s3SetTrueChromaKey (ScreenPtr pScreen, int pfb, xColorItem *pdef) -{ - FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); - KdScreenPriv(pScreen); - s3ScreenInfo(pScreenPriv); - int fb, ma; - CARD32 key; - int r, g, b; - - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - { - fb = s3s->fbmap[ma]; - if (fb != pfb && pScreenPriv->screen->fb[fb].redMask) - { - r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask); - g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask); - b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask); - key = ((Shift(pdef->red,r) & pScreenPriv->screen->fb[fb].redMask) | - (Shift(pdef->green,g) & pScreenPriv->screen->fb[fb].greenMask) | - (Shift(pdef->blue,b) & pScreenPriv->screen->fb[fb].blueMask)); - if (pScrPriv->layer[fb].key != key) - { - pScrPriv->layer[fb].key = key; - (*pScrPriv->PaintKey) (&pScrPriv->layer[fb].u.run.pixmap->drawable, - &pScrPriv->layer[pfb].u.run.region, - pScrPriv->layer[fb].key, fb); - } - } - } -} -#endif - -void -s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - s3CardInfo(pScreenPriv); - s3ScreenInfo(pScreenPriv); - S3Vga *s3vga = &s3c->s3vga; - xColorItem *chroma = 0; - CARD32 key; - -#if 0 - _s3WaitVRetrace (s3vga); -#else - S3Ptr s3 = s3c->s3; - _s3WaitVRetraceFast(s3); -#endif -#ifndef S3_TRIO - if (pScreenPriv->screen->fb[1].depth) - { - FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); - key = pScrPriv->layer[fb].key; - } -#endif - else - key = ~0; - while (ndef--) - { - if (pdefs->pixel == key) - chroma = pdefs; - s3SetImm (s3vga, s3_dac_write_index, pdefs->pixel); - s3SetImm (s3vga, s3_dac_data, pdefs->red >> 8); - s3SetImm (s3vga, s3_dac_data, pdefs->green >> 8); - s3SetImm (s3vga, s3_dac_data, pdefs->blue >> 8); - pdefs++; - } -#ifndef S3_TRIO - if (chroma && !pScreenPriv->closed) - s3SetTrueChromaKey (pScreen, fb, chroma); -#endif -} - diff --git a/hw/kdrive/savage/s3curs.c b/hw/kdrive/savage/s3curs.c deleted file mode 100644 index eae7f642b..000000000 --- a/hw/kdrive/savage/s3curs.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Id: s3curs.c,v 1.2 1999/11/02 06:16:29 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3curs.c,v 1.3 2000/02/23 20:30:03 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" -#include "s3draw.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); -} - -#define S3Trunc(c) (((c) >> 8) & 0xff) - -#define S3CursColor(r,g,b) ((S3Trunc(r) << 16) | \ - (S3Trunc(g) << 8) | \ - (S3Trunc(b))) - -static void -s3AllocCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - - if (s3s->use_streams) - { - pCurPriv->source = S3CursColor(pCursor->foreRed, - pCursor->foreGreen, - pCursor->foreBlue); - pCurPriv->mask = S3CursColor(pCursor->backRed, - pCursor->backGreen, - pCursor->backBlue); - } - else - { - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 long *ram; - unsigned long *msk, *mskLine, *src, *srcLine; - unsigned long 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 long *) s3s->cursor_base; - mskLine = (unsigned long *) bits->mask; - srcLine = (unsigned long *) bits->source; - - h = bits->height; - if (h > S3_CURSOR_HEIGHT) - h = S3_CURSOR_HEIGHT; - - wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */ - - for (i = 0; i < S3_CURSOR_HEIGHT; i++) { - msk = mskLine; - src = srcLine; - mskLine += wsrc; - srcLine += wsrc; - for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) { - - unsigned long m, s; - - if (i < h && j < wsrc) - { - m = *msk++; - s = *src++; - xor = m & s; - and = ~m; - } - else - { - and = 0xffffffff; - xor = 0x00000000; - } - - S3AdjustBits32(and); - S3AdjustBits32(xor); -#define S3SwapNibbles(x) ((x) = (((x) & 0x0f0f0f0f) << 4 | \ - ((x) >> 4) & 0x0f0f0f0f)) - if (s3s->use_streams) - { - S3SwapNibbles(and); - S3SwapNibbles(xor); - } - *ram++ = (and & 0xffff) | (xor << 16); - *ram++ = (and >> 16) | (xor & 0xffff0000); - } - } - - _s3WaitIdle (s3); - - /* Set new color */ - _s3SetCursorColors (pScreen); - - /* Enable the cursor */ - s3SetImm (s3vga, s3_cursor_ms_x11, 0); - s3SetImm (s3vga, s3_cursor_enable, 1); - - /* Wait for VRetrace to make sure the position is read */ - _s3WaitVRetrace (s3vga); - - /* 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) - { -#ifdef FB_OLD_SCREEN - short x, y; -#else - int x, y; -#endif - - 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) - { -#ifdef FB_OLD_SCREEN - short x, y; -#else - int x, y; -#endif - - 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; -} diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c deleted file mode 100644 index cae765675..000000000 --- a/hw/kdrive/savage/s3draw.c +++ /dev/null @@ -1,3247 +0,0 @@ -/* - * Id: s3draw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.6 2001/05/29 04:54:11 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 "fb.h" -#include "migc.h" -#include "miline.h" - -/* - * Map X rops to S3 rops - */ - -short s3alu[16] = { - MIX_0, - MIX_AND, - MIX_SRC_AND_NOT_DST, - MIX_SRC, - MIX_NOT_SRC_AND_DST, - MIX_DST, - MIX_XOR, - MIX_OR, - MIX_NOR, - MIX_XNOR, - MIX_NOT_DST, - MIX_SRC_OR_NOT_DST, - MIX_NOT_SRC, - MIX_NOT_SRC_OR_DST, - MIX_NAND, - MIX_1 -}; - -/* - * Handle pixel transfers - */ - -#define BURST -#ifdef BURST -#define PixTransDeclare VOL32 *pix_trans_base = (VOL32 *) (s3c->registers),\ - *pix_trans = pix_trans_base -#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 8192) pix_trans = pix_trans_base -#define PixTransStore(t) *pix_trans++ = (t) -#else -#define PixTransDeclare VOL32 *pix_trans = &s3->pix_trans -#define PixTransStart(n) -#define PixTransStore(t) *pix_trans = (t) -#endif - -int s3GCPrivateIndex; -int s3WindowPrivateIndex; -int s3Generation; - -/* - s3DoBitBlt - ============= - Bit Blit for all window to window blits. -*/ - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -void -s3CopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupS3(pDstDrawable->pScreen); - int srcX, srcY, dstX, dstY; - int w, h; - int flags; - - if (sourceInvarient (pGC->alu)) - { - s3FillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); - return; - } - - s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); - _s3SetBlt(s3,pGC->alu,pGC->planemask); - DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x", - pGC->alu, pGC->planemask)); - while (nbox--) - { - w = pbox->x2 - pbox->x1; - h = pbox->y2 - pbox->y1; - flags = 0; - if (reverse) - { - dstX = pbox->x2 - 1; - } - else - { - dstX = pbox->x1; - flags |= INC_X; - } - srcX = dstX + dx; - - if (upsidedown) - { - dstY = pbox->y2 - 1; - } - else - { - dstY = pbox->y1; - flags |= INC_Y; - } - srcY = dstY + dy; - - _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); - pbox++; - } - MarkSyncS3 (pSrcDrawable->pScreen); -} - -RegionPtr -s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, int dstx, int dsty) -{ - SetupS3(pDstDrawable->pScreen); - - if (pSrcDrawable->type == DRAWABLE_WINDOW && - pDstDrawable->type == DRAWABLE_WINDOW) - { - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, s3CopyNtoN, 0, 0); - } - return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, dstx, dsty); -} - -typedef struct _s31toNargs { - unsigned long copyPlaneFG, copyPlaneBG; - Bool opaque; -} s31toNargs; - -void -_s3Stipple (S3CardInfo *s3c, - FbStip *psrcBase, - FbStride widthSrc, - int srcx, - int srcy, - int dstx, - int dsty, - int width, - int height) -{ - S3Ptr s3 = s3c->s3; - FbStip *psrcLine, *psrc; - FbStride widthRest; - FbStip bits, tmp, lastTmp; - int leftShift, rightShift; - int nl, nlMiddle; - int r; - PixTransDeclare; - - /* Compute blt address and parameters */ - psrc = psrcBase + srcy * widthSrc + (srcx >> 5); - nlMiddle = (width + 31) >> 5; - leftShift = srcx & 0x1f; - rightShift = 32 - leftShift; - widthRest = widthSrc - nlMiddle; - - _s3PlaneBlt(s3,dstx,dsty,width,height); - - if (leftShift == 0) - { - while (height--) - { - nl = nlMiddle; - PixTransStart(nl); - while (nl--) - { - tmp = *psrc++; - S3AdjustBits32 (tmp); - PixTransStore (tmp); - } - psrc += widthRest; - } - } - else - { - widthRest--; - while (height--) - { - bits = *psrc++; - nl = nlMiddle; - PixTransStart(nl); - while (nl--) - { - tmp = FbStipLeft(bits, leftShift); - bits = *psrc++; - tmp |= FbStipRight(bits, rightShift); - S3AdjustBits32(tmp); - PixTransStore (tmp); - } - psrc += widthRest; - } - } -} - -void -s3Copy1toN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupS3(pDstDrawable->pScreen); - - s31toNargs *args = closure; - int dstx, dsty; - FbStip *psrcBase; - FbStride widthSrc; - int srcBpp; - int srcXoff, srcYoff; - - if (args->opaque && sourceInvarient (pGC->alu)) - { - s3FillBoxSolid (pDstDrawable, nbox, pbox, - pGC->bgPixel, pGC->alu, pGC->planemask); - return; - } - - s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); - fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); - - if (args->opaque) - { - _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask,args->copyPlaneFG, - args->copyPlaneBG); - } - else - { - _s3SetTransparentPlaneBlt (s3, pGC->alu, - pGC->planemask, args->copyPlaneFG); - } - - while (nbox--) - { - dstx = pbox->x1; - dsty = pbox->y1; - - _s3Stipple (s3c, - psrcBase, widthSrc, - dstx + dx - srcXoff, dsty + dy - srcYoff, - dstx, dsty, - pbox->x2 - dstx, pbox->y2 - dsty); - pbox++; - } - MarkSyncS3 (pDstDrawable->pScreen); -} - -RegionPtr -s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long bitPlane) -{ - SetupS3 (pDstDrawable->pScreen); - RegionPtr ret; - s31toNargs args; - - if (pDstDrawable->type == DRAWABLE_WINDOW && - pSrcDrawable->depth == 1) - { - args.copyPlaneFG = pGC->fgPixel; - args.copyPlaneBG = pGC->bgPixel; - args.opaque = TRUE; - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, s3Copy1toN, bitPlane, &args); - } - return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, bitPlane); -} - -void -s3PushPixels (GCPtr pGC, PixmapPtr pBitmap, - DrawablePtr pDrawable, - int w, int h, int x, int y) -{ - SetupS3 (pDrawable->pScreen); - s31toNargs args; - - if (pDrawable->type == DRAWABLE_WINDOW && pGC->fillStyle == FillSolid) - { - args.opaque = FALSE; - args.copyPlaneFG = pGC->fgPixel; - (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC, - 0, 0, w, h, x, y, s3Copy1toN, 1, &args); - } - else - { - KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y); - } -} - -void -s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask) -{ - SetupS3(pDrawable->pScreen); - register int r; - - s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); - _s3SetSolidFill(s3,pixel,alu,planemask); - - while (nBox--) { - _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1); - pBox++; - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -_s3SetPattern (ScreenPtr pScreen, int ma, - int alu, unsigned long planemask, s3PatternPtr pPattern) -{ - SetupS3(pScreen); - S3PatternCache *cache; - - _s3LoadPattern (pScreen, ma, pPattern); - cache = pPattern->cache; - - switch (pPattern->fillStyle) { - case FillTiled: - _s3SetTile(s3,alu,planemask); - break; - case FillStippled: - _s3SetStipple(s3,alu,planemask,pPattern->fore); - break; - case FillOpaqueStippled: - _s3SetOpaqueStipple(s3,alu,planemask,pPattern->fore,pPattern->back); - break; - } -} - -void -s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - int alu, unsigned long planemask, s3PatternPtr pPattern) -{ - SetupS3(pDrawable->pScreen); - S3PatternCache *cache; - int patx, paty; - - s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); - _s3SetPattern (pDrawable->pScreen, s3DrawMap(pDrawable), alu, planemask, pPattern); - cache = pPattern->cache; - while (nBox--) - { - _s3PatRect(s3,cache->x, cache->y, - pBox->x1, pBox->y1, - pBox->x2-pBox->x1, pBox->y2-pBox->y1); - pBox++; - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3FillBoxLargeStipple (DrawablePtr pDrawable, GCPtr pGC, - int nBox, BoxPtr pBox) -{ - SetupS3(pDrawable->pScreen); - DrawablePtr pStipple = &pGC->stipple->drawable; - int xRot = pGC->patOrg.x + pDrawable->x; - int yRot = pGC->patOrg.y + pDrawable->y; - FbStip *stip; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; - int stipWidth, stipHeight; - int dstX, dstY, width, height; - - stipWidth = pStipple->width; - stipHeight = pStipple->height; - fbGetStipDrawable (pStipple, stip, stipStride, stipBpp, stipXoff, stipYoff); - - s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); - if (pGC->fillStyle == FillOpaqueStippled) - { - _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask, - pGC->fgPixel, pGC->bgPixel); - - } - else - { - _s3SetTransparentPlaneBlt(s3,pGC->alu,pGC->planemask, pGC->fgPixel); - } - - while (nBox--) - { - int stipX, stipY, sx; - int widthTmp; - int h, w; - int x, y; - - dstX = pBox->x1; - dstY = pBox->y1; - width = pBox->x2 - pBox->x1; - height = pBox->y2 - pBox->y1; - pBox++; - modulus (dstY - yRot - stipYoff, stipHeight, stipY); - modulus (dstX - xRot - stipXoff, stipWidth, stipX); - y = dstY; - while (height) - { - h = stipHeight - stipY; - if (h > height) - h = height; - height -= h; - widthTmp = width; - x = dstX; - sx = stipX; - while (widthTmp) - { - w = (stipWidth - sx); - if (w > widthTmp) - w = widthTmp; - widthTmp -= w; - _s3Stipple (s3c, - stip, - stipStride, - sx, stipY, - x, y, - w, h); - x += w; - sx = 0; - } - y += h; - stipY = 0; - } - } - MarkSyncS3 (pDrawable->pScreen); -} - -#define NUM_STACK_RECTS 1024 - -void -s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - s3GCPrivate(pGC); - xRectangle *prect; - RegionPtr prgnClip; - register BoxPtr pbox; - register BoxPtr pboxClipped; - BoxPtr pboxClippedBase; - BoxPtr pextent; - BoxRec stackRects[NUM_STACK_RECTS]; - int numRects; - int n; - int xorg, yorg; - int x, y; - - 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)ALLOCATE_LOCAL(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) - { - if (pGC->fillStyle == FillSolid) - s3FillBoxSolid(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->fgPixel, pGC->alu, pGC->planemask); - else if (s3Priv->pPattern) - s3FillBoxPattern (pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->alu, pGC->planemask, - s3Priv->pPattern); - else - s3FillBoxLargeStipple (pDrawable, pGC, - pboxClipped-pboxClippedBase, - pboxClippedBase); - } - if (pboxClippedBase != stackRects) - DEALLOCATE_LOCAL(pboxClippedBase); -} - -void -_s3FillSpanLargeStipple (DrawablePtr pDrawable, GCPtr pGC, - int n, DDXPointPtr ppt, int *pwidth) -{ - SetupS3 (pDrawable->pScreen); - DrawablePtr pStipple = &pGC->stipple->drawable; - int xRot = pGC->patOrg.x + pDrawable->x; - int yRot = pGC->patOrg.y + pDrawable->y; - FbStip *stip; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; - int stipWidth, stipHeight; - int dstX, dstY, width, height; - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - stipWidth = pStipple->width; - stipHeight = pStipple->height; - fbGetStipDrawable (pStipple, stip, stipStride, stipBpp, stipXoff, stipYoff); - if (pGC->fillStyle == FillOpaqueStippled) - { - _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask, - pGC->fgPixel, pGC->bgPixel); - - } - else - { - _s3SetTransparentPlaneBlt(s3,pGC->alu,pGC->planemask, pGC->fgPixel); - } - while (n--) - { - int stipX, stipY, sx; - int w; - int x, y; - - dstX = ppt->x; - dstY = ppt->y; - ppt++; - width = *pwidth++; - modulus (dstY - yRot - stipYoff, stipHeight, stipY); - modulus (dstX - xRot - stipXoff, stipWidth, stipX); - y = dstY; - x = dstX; - sx = stipX; - while (width) - { - w = (stipWidth - sx); - if (w > width) - w = width; - width -= w; - _s3Stipple (s3c, - stip, - stipStride, - sx, stipY, - x, y, - w, 1); - x += w; - sx = 0; - } - } -} - -void -s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - s3GCPrivate(pGC); - SetupS3(pDrawable->pScreen); - int x, y, x1, y1, x2, y2; - int width; - /* next three parameters are post-clip */ - int nTmp; - int *pwidthFree;/* copies of the pointers to free */ - DDXPointPtr pptFree; - BoxPtr extents; - S3PatternCache *cache; - RegionPtr pClip = fbGetCompositeClip (pGC); - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - if (REGION_NUM_RECTS(pClip) == 1 && - (pGC->fillStyle == FillSolid || s3Priv->pPattern)) - { - extents = REGION_RECTS(pClip); - x1 = extents->x1; - x2 = extents->x2; - y1 = extents->y1; - y2 = extents->y2; - if (pGC->fillStyle == FillSolid) - { - _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); - cache = 0; - } - else - { - _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask, - s3Priv->pPattern); - cache = s3Priv->pPattern->cache; - } - while (n--) - { - y = ppt->y; - if (y1 <= y && y < y2) - { - x = ppt->x; - width = *pwidth; - if (x < x1) - { - width -= (x1 - x); - x = x1; - } - if (x2 < x + width) - width = x2 - x; - if (width > 0) - { - if (cache) - { - _s3PatRect(s3, cache->x, cache->y, x, y, width, 1); - } - else - { - _s3SolidRect(s3,x,y,width,1); - } - } - } - ppt++; - pwidth++; - } - } - else - { - nTmp = n * miFindMaxBand(pClip); - 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; - if (pGC->fillStyle == FillSolid) - { - _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); - while (n--) - { - x = ppt->x; - y = ppt->y; - ppt++; - width = *pwidth++; - if (width) - { - _s3SolidRect(s3,x,y,width,1); - } - } - } - else if (s3Priv->pPattern) - { - _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask, - s3Priv->pPattern); - cache = s3Priv->pPattern->cache; - while (n--) - { - x = ppt->x; - y = ppt->y; - ppt++; - width = *pwidth++; - if (width) - { - _s3PatRect(s3, cache->x, cache->y, x, y, width, 1); - } - } - } - else - { - _s3FillSpanLargeStipple (pDrawable, pGC, n, ppt, pwidth); - } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); - } - MarkSyncS3 (pDrawable->pScreen); -} - -#include "mifillarc.h" - -#define FILLSPAN(s3,y,__x1,__x2) {\ - DRAW_DEBUG ((DEBUG_ARCS, "FILLSPAN %d: %d->%d", y, __x1, __x2)); \ - if ((__x2) >= (__x1)) {\ - _s3SolidRect(s3,(__x1),(y),(__x2)-(__x1)+1,1); \ - } \ -} - -#define FILLSLICESPANS(flip,__y) \ - if (!flip) \ - { \ - FILLSPAN(s3,__y,xl,xr) \ - } \ - else \ - { \ - xc = xorg - x; \ - FILLSPAN(s3, __y, xc, xr) \ - xc += slw - 1; \ - FILLSPAN(s3, __y, xl, xc) \ - } - -static void -_s3FillEllipse (DrawablePtr pDraw, S3Ptr s3, xArc *arc) -{ - KdScreenPriv(pDraw->pScreen); - int x, y, e; - int yk, xk, ym, xm, dx, dy, xorg, yorg; - int y_top, y_bot; - miFillArcRec info; - register int xpos; - int slw; - - s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw)); - miFillArcSetup(arc, &info); - MIFILLARCSETUP(); - y_top = pDraw->y + yorg - y; - y_bot = pDraw->y + yorg + y + dy; - xorg += pDraw->x; - while (y) - { - y_top++; - y_bot--; - MIFILLARCSTEP(slw); - if (!slw) - continue; - xpos = xorg - x; - _s3SolidRect (s3,xpos,y_top,slw,1); - if (miFillArcLower(slw)) - _s3SolidRect (s3,xpos,y_bot,slw,1); - } -} - - -static void -_s3FillArcSlice (DrawablePtr pDraw, GCPtr pGC, S3Ptr s3, xArc *arc) -{ - KdScreenPriv(pDraw->pScreen); - int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; - register int x, y, e; - miFillArcRec info; - miArcSliceRec slice; - int xl, xr, xc; - int y_top, y_bot; - - s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw)); - DRAW_DEBUG ((DEBUG_ARCS, "slice %dx%d+%d+%d %d->%d", - arc->width, arc->height, arc->x, arc->y, - arc->angle1, arc->angle2)); - miFillArcSetup(arc, &info); - miFillArcSliceSetup(arc, &slice, pGC); - DRAW_DEBUG ((DEBUG_ARCS, "edge1.x %d edge2.x %d", - slice.edge1.x, slice.edge2.x)); - MIFILLARCSETUP(); - DRAW_DEBUG ((DEBUG_ARCS, "xorg %d yorg %d", - xorg, yorg)); - xorg += pDraw->x; - yorg += pDraw->y; - y_top = yorg - y; - y_bot = yorg + y + dy; - slice.edge1.x += pDraw->x; - slice.edge2.x += pDraw->x; - DRAW_DEBUG ((DEBUG_ARCS, "xorg %d y_top %d y_bot %d", - xorg, y_top, y_bot)); - while (y > 0) - { - y_top++; - y_bot--; - MIFILLARCSTEP(slw); - MIARCSLICESTEP(slice.edge1); - MIARCSLICESTEP(slice.edge2); - if (miFillSliceUpper(slice)) - { - MIARCSLICEUPPER(xl, xr, slice, slw); - FILLSLICESPANS(slice.flip_top, y_top); - } - if (miFillSliceLower(slice)) - { - MIARCSLICELOWER(xl, xr, slice, slw); - FILLSLICESPANS(slice.flip_bot, y_bot); - } - } -} - -void -s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs) -{ - SetupS3(pDraw->pScreen); - xArc *arc; - int i; - int x, y; - BoxRec box; - RegionPtr pClip = fbGetCompositeClip(pGC); - BOOL set; - - set = FALSE; - for (; --narcs >= 0; parcs++) - { - if (miFillArcEmpty(parcs)) - continue; - if (miCanFillArc(parcs)) - { - box.x1 = parcs->x + pDraw->x; - box.y1 = parcs->y + pDraw->y; - box.x2 = box.x1 + (int)parcs->width + 1; - box.y2 = box.y1 + (int)parcs->height + 1; - switch (RECT_IN_REGION(pDraw->pScreen, pClip, &box)) - { - case rgnIN: - if (!set) - { - _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); - set = TRUE; - } - if ((parcs->angle2 >= FULLCIRCLE) || - (parcs->angle2 <= -FULLCIRCLE)) - { - DRAW_DEBUG ((DEBUG_ARCS, "Full circle ellipse %dx%d", - parcs->width, parcs->height)); - _s3FillEllipse (pDraw, s3, parcs); - } - else - { - DRAW_DEBUG ((DEBUG_ARCS, "Partial ellipse %dx%d", - parcs->width, parcs->height)); - _s3FillArcSlice (pDraw, pGC, s3, parcs); - } - /* fall through ... */ - case rgnOUT: - continue; - case rgnPART: - break; - } - } - if (set) - { - MarkSyncS3 (pDraw->pScreen); - set = FALSE; - } - KdCheckPolyFillArc(pDraw, pGC, 1, parcs); - } - if (set) - { - MarkSyncS3 (pDraw->pScreen); - set = FALSE; - } -} - -void -s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape, - int mode, int countInit, DDXPointPtr ptsIn) -{ - SetupS3(pDrawable->pScreen); - int nwidth; - int maxy; - int origin; - int count; - register int vertex1, vertex2; - int c; - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr extents; - int clip; - int y, sy; - int *vertex1p, *vertex2p; - int *endp; - int x1, x2, sx; - int dx1, dx2; - int dy1, dy2; - int e1, e2; - int step1, step2; - int sign1, sign2; - int h; - int l, r; - int nmiddle; - - if (mode == CoordModePrevious || REGION_NUM_RECTS(pClip) != 1) - { - KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn); - return; - } - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - sy = pDrawable->y; - sx = pDrawable->x; - origin = *((int *) &pDrawable->x); - origin -= (origin & 0x8000) << 1; - extents = &pClip->extents; - vertex1 = *((int *) &extents->x1) - origin; - vertex2 = *((int *) &extents->x2) - origin - 0x00010001; - clip = 0; - - y = 32767; - maxy = 0; - vertex2p = (int *) ptsIn; - endp = vertex2p + countInit; - if (shape == Convex) - { - count = countInit; - while (count--) - { - c = *vertex2p; - clip |= (c - vertex1) | (vertex2 - c); - c = intToY(c); - DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c)); - if (c < y) - { - y = c; - vertex1p = vertex2p; - } - vertex2p++; - if (c > maxy) - maxy = c; - } - } - else - { - int yFlip = 0; - dx1 = 1; - x2 = -1; - x1 = -1; - count = countInit; - while (count--) - { - c = *vertex2p; - clip |= (c - vertex1) | (vertex2 - c); - c = intToY(c); - DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c)); - if (c < y) - { - y = c; - vertex1p = vertex2p; - } - vertex2p++; - if (c > maxy) - maxy = c; - if (c == x1) - continue; - if (dx1 > 0) - { - if (x2 < 0) - x2 = c; - else - dx2 = dx1 = (c - x1) >> 31; - } - else - if ((c - x1) >> 31 != dx1) - { - dx1 = ~dx1; - yFlip++; - } - x1 = c; - } - x1 = (x2 - c) >> 31; - if (x1 != dx1) - yFlip++; - if (x1 != dx2) - yFlip++; - if (yFlip != 2) - clip = 0x8000; - } - if (y == maxy) - return; - - if (clip & 0x80008000) - { - KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn); - return; - } - _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); - - vertex2p = vertex1p; - vertex2 = vertex1 = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; -#define Setup(c,x,vertex,dx,dy,e,sign,step) {\ - x = intToX(vertex); \ - if (dy = intToY(c) - y) { \ - dx = intToX(c) - x; \ - step = 0; \ - if (dx >= 0) \ - { \ - e = 0; \ - sign = 1; \ - if (dx >= dy) {\ - step = dx / dy; \ - dx = dx % dy; \ - } \ - } \ - else \ - { \ - e = 1 - dy; \ - sign = -1; \ - dx = -dx; \ - if (dx >= dy) { \ - step = - (dx / dy); \ - dx = dx % dy; \ - } \ - } \ - } \ - x += sx; \ - vertex = c; \ -} - -#define Step(x,dx,dy,e,sign,step) {\ - x += step; \ - if ((e += dx) > 0) \ - { \ - x += sign; \ - e -= dy; \ - } \ -} - sy += y; - DRAW_DEBUG ((DEBUG_POLYGON, "Starting polygon at %d", sy)); - for (;;) - { - DRAW_DEBUG ((DEBUG_POLYGON, "vertex1 0x%x vertex2 0x%x y %d vy1 %d vy2 %d", - vertex1, vertex2, - y, intToY(vertex1), intToY (vertex2))); - if (y == intToY(vertex1)) - { - DRAW_DEBUG ((DEBUG_POLYGON, "Find next -- vertext")); - do - { - if (vertex1p == (int *) ptsIn) - vertex1p = endp; - c = *--vertex1p; - Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1); - DRAW_DEBUG ((DEBUG_POLYGON, "-- vertex 0x%x y %d", - vertex1, intToY(vertex1))); - } while (y >= intToY(vertex1)); - h = dy1; - } - else - { - Step(x1,dx1,dy1,e1,sign1,step1) - h = intToY(vertex1) - y; - } - if (y == intToY(vertex2)) - { - DRAW_DEBUG ((DEBUG_POLYGON, "Find next ++ vertext")); - do - { - c = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2) - DRAW_DEBUG ((DEBUG_POLYGON, "++ vertex 0x%x y %d", - vertex1, intToY(vertex1))); - } while (y >= intToY(vertex2)); - if (dy2 < h) - h = dy2; - } - else - { - Step(x2,dx2,dy2,e2,sign2,step2) - if ((c = (intToY(vertex2) - y)) < h) - h = c; - } - DRAW_DEBUG ((DEBUG_POLYGON, "This band %d", h)); - /* fill spans for this segment */ - for (;;) - { - nmiddle = x2 - x1; - DRAW_DEBUG ((DEBUG_POLYGON, "This span %d->%d", x1, x2)); - if (nmiddle) - { - l = x1; - if (nmiddle < 0) - { - nmiddle = -nmiddle; - l = x2; - } - _s3SolidRect(s3,l,sy,nmiddle,1); - } - y++; - sy++; - if (!--h) - break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - if (y == maxy) - break; - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3PolyGlyphBltClipped (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - pointer pglyphBase) -{ - SetupS3(pDrawable->pScreen); - int h; - int w; - int xBack, yBack; - int hBack, wBack; - int lw; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - unsigned long *bits; - BoxPtr extents; - BoxRec bbox; - CARD32 b; - CharInfoPtr *ppci; - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr pBox; - int nbox; - int x1, y1, x2, y2; - unsigned char alu; - Bool set; - PixTransDeclare; - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - x += pDrawable->x; - y += pDrawable->y; - - if (pglyphBase == (pointer) 1) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - h = nglyph; - ppci = ppciInit; - while (h--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - } - else - { - wBack = 0; - alu = pGC->alu; - } - - if (wBack) - { - _s3SetSolidFill (s3, pGC->bgPixel, GXcopy, pGC->planemask); - for (nbox = REGION_NUM_RECTS (pClip), - pBox = REGION_RECTS (pClip); - nbox--; - pBox++) - { - x1 = xBack; - x2 = xBack + wBack; - y1 = yBack; - y2 = yBack + hBack; - if (x1 < pBox->x1) x1 = pBox->x1; - if (x2 > pBox->x2) x2 = pBox->x2; - if (y1 < pBox->y1) y1 = pBox->y1; - if (y2 > pBox->y2) y2 = pBox->y2; - if (x1 < x2 && y1 < y2) - { - _s3SolidRect (s3, x1, y1, x2 - x1, y2 - y1); - } - } - MarkSyncS3 (pDrawable->pScreen); - } - ppci = ppciInit; - set = FALSE; - while (nglyph--) - { - pci = *ppci++; - h = pci->metrics.ascent + pci->metrics.descent; - w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - x1 = x + pci->metrics.leftSideBearing; - y1 = y - pci->metrics.ascent; - bbox.x1 = x1; - bbox.y1 = y1; - bbox.x2 = x1 + w; - bbox.y2 = y1 + h; - switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox)) - { - case rgnIN: -#if 1 - lw = h * ((w + 31) >> 5); - if (lw) - { - if (!set) - { - _s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel); - set = TRUE; - } - _s3PlaneBlt(s3, - x + pci->metrics.leftSideBearing, - y - pci->metrics.ascent, - w, h); - bits = (unsigned long *) pci->bits; - PixTransStart (lw); - while (lw--) - { - b = *bits++; - S3AdjustBits32 (b); - PixTransStore(b); - } - MarkSyncS3 (pDrawable->pScreen); - } - break; -#endif - case rgnPART: - set = FALSE; - CheckSyncS3 (pDrawable->pScreen); - fbPutXYImage (pDrawable, - pClip, - fbPriv->fg, - fbPriv->bg, - fbPriv->pm, - alu, - FALSE, - x1, y1, - w, h, - (FbStip *) pci->bits, - (w + 31) >> 5, - 0); - break; - case rgnOUT: - break; - } - x += pci->metrics.characterWidth; - } -} - -/* - * Blt glyphs using S3 image transfer register, this does both - * poly glyph blt and image glyph blt (when pglyphBase == 1) - */ - -void -s3PolyGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - pointer pglyphBase) -{ - SetupS3(pDrawable->pScreen); - int h; - int w; - int xBack, yBack; - int hBack, wBack; - int lw; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - unsigned long *bits; - BoxPtr extents; - BoxRec bbox; - CARD32 b; - CharInfoPtr *ppci; - unsigned char alu; - PixTransDeclare; - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - x += pDrawable->x; - y += pDrawable->y; - - /* compute an approximate (but covering) bounding box */ - ppci = ppciInit; - w = 0; - h = nglyph; - while (h--) - w += (*ppci++)->metrics.characterWidth; - if (w < 0) - { - bbox.x1 = x + w; - bbox.x2 = x; - } - else - { - bbox.x1 = x; - bbox.x2 = x + w; - } - w = FONTMINBOUNDS(pfont,leftSideBearing); - if (w < 0) - bbox.x1 += w; - w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); - if (w > 0) - bbox.x2 += w; - bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); - bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); - - DRAW_DEBUG ((DEBUG_TEXT, "PolyGlyphBlt %d box is %d %d", nglyph, - bbox.x1, bbox.x2)); - switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) - { - case rgnIN: - break; - case rgnPART: - s3PolyGlyphBltClipped(pDrawable, pGC, x - pDrawable->x, - y - pDrawable->y, - nglyph, ppciInit, pglyphBase); - case rgnOUT: - return; - } - - if (pglyphBase == (pointer) 1) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - h = nglyph; - ppci = ppciInit; - while (h--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - } - else - { - wBack = 0; - alu = pGC->alu; - } - - if (wBack) - { - _s3SetSolidFill (s3, pGC->bgPixel, GXcopy, pGC->planemask); - _s3SolidRect (s3, xBack, yBack, wBack, hBack); - } - _s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel); - ppci = ppciInit; - while (nglyph--) - { - pci = *ppci++; - h = pci->metrics.ascent + pci->metrics.descent; - w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - lw = h * ((w + 31) >> 5); - if (lw) - { - _s3PlaneBlt(s3, - x + pci->metrics.leftSideBearing, - y - pci->metrics.ascent, - w, h); - bits = (unsigned long *) pci->bits; - PixTransStart(lw); - while (lw--) - { - b = *bits++; - S3AdjustBits32 (b); - PixTransStore(b); - } - } - x += pci->metrics.characterWidth; - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3ImageGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - s3PolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (pointer) 1); -} - -/* - * Blt TE fonts using S3 image transfer. Differs from - * above in that it doesn't need to fill a solid rect for - * the background and it can draw multiple characters at a time - */ - -void -s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int xInit, int yInit, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - SetupS3(pDrawable->pScreen); - int x, y; - int h, lw, lwTmp; - int w; - FontPtr pfont = pGC->font; - unsigned long *char1, *char2, *char3, *char4; - int widthGlyphs, widthGlyph; - BoxRec bbox; - CARD32 tmp; - PixTransDeclare; - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); - if (!widthGlyph) - return; - - h = FONTASCENT(pfont) + FONTDESCENT(pfont); - if (!h) - return; - - DRAW_DEBUG ((DEBUG_TEXT, "ImageTEGlyphBlt chars are %d %d", - widthGlyph, h)); - - x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x; - y = yInit - FONTASCENT(pfont) + pDrawable->y; - - bbox.x1 = x; - bbox.x2 = x + (widthGlyph * nglyph); - bbox.y1 = y; - bbox.y2 = y + h; - - switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) - { - case rgnIN: - break; - case rgnPART: - if (pglyphBase == (pointer) 1) - pglyphBase = 0; - else - pglyphBase = (pointer) 1; - s3PolyGlyphBltClipped(pDrawable, pGC, - xInit, - yInit, - nglyph, ppci, - pglyphBase); - case rgnOUT: - return; - } - - if (pglyphBase == (pointer) 1) - { - _s3SetTransparentPlaneBlt (s3, pGC->alu, pGC->planemask, pGC->fgPixel); - } - else - { - _s3SetOpaquePlaneBlt (s3, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel); - } - -#if BITMAP_BIT_ORDER == LSBFirst -#define SHIFT << -#else -#define SHIFT >> -#endif - -#define LoopIt(count, w, loadup, fetch) \ - while (nglyph >= count) \ - { \ - nglyph -= count; \ - _s3PlaneBlt (s3, x, y, w, h); \ - x += w; \ - loadup \ - lwTmp = h; \ - PixTransStart(h); \ - while (lwTmp--) { \ - tmp = fetch; \ - S3AdjustBits32(tmp); \ - PixTransStore(tmp); \ - } \ - } - - if (widthGlyph <= 8) - { - widthGlyphs = widthGlyph << 2; - LoopIt(4, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits; - char4 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | ((*char3++ | (*char4++ - SHIFT widthGlyph)) - SHIFT widthGlyph)) - SHIFT widthGlyph))) - } - else if (widthGlyph <= 10) - { - widthGlyphs = (widthGlyph << 1) + widthGlyph; - LoopIt(3, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph))) - } - else if (widthGlyph <= 16) - { - widthGlyphs = widthGlyph << 1; - LoopIt(2, widthGlyphs, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | (*char2++ SHIFT widthGlyph))) - } - lw = h * ((widthGlyph + 31) >> 5); - while (nglyph--) - { - _s3PlaneBlt (s3, x, y, widthGlyph, h); - x += widthGlyph; - char1 = (unsigned long *) (*ppci++)->bits; - lwTmp = lw; - PixTransStart(lw); - while (lwTmp--) - { - tmp = *char1++; - S3AdjustBits32(tmp); - PixTransStore(tmp); - } - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3PolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int x, int y, - unsigned int nglyph, CharInfoPtr *ppci, - pointer pglyphBase) -{ - s3ImageTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (pointer) 1); -} - -Bool -_s3Segment (DrawablePtr pDrawable, - GCPtr pGC, - int x1, - int y1, - int x2, - int y2, - Bool drawLast, - Bool s3Set) -{ - SetupS3(pDrawable->pScreen); - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr pBox; - int nBox; - int adx; /* abs values of dx and dy */ - int ady; - int signdx; /* sign of dx and dy */ - int signdy; - int e, e1, e2; /* bresenham error and increments */ - int len; /* length of segment */ - int axis; /* major axis */ - int octant; - int cmd; - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - unsigned int oc1; /* outcode of point 1 */ - unsigned int oc2; /* outcode of point 2 */ - - CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, - 1, 1, octant); - - cmd = LASTPIX; - - if (adx > ady) - { - axis = X_AXIS; - e1 = ady << 1; - e2 = e1 - (adx << 1); - e = e1 - adx; - len = adx; - } - else - { - cmd |= YMAJAXIS; - axis = Y_AXIS; - e1 = adx << 1; - e2 = e1 - (ady << 1); - e = e1 - ady; - SetYMajorOctant(octant); - len = ady; - } - - /* S3 line drawing hardware has limited resolution for error terms */ - if (len >= 4096) - { - int dashOff = 0; - - KdCheckSync (pDrawable->pScreen); - fbSegment (pDrawable, pGC, x1, y1, x2, y2, drawLast, &dashOff); - return FALSE; - } - - FIXUP_ERROR (e, octant, bias); - - nBox = REGION_NUM_RECTS (pClip); - pBox = REGION_RECTS (pClip); - - if (signdx > 0) - cmd |= INC_X; - if (signdy > 0) - cmd |= INC_Y; - - /* we have bresenham parameters and two points. - all we have to do now is clip and draw. - */ - - if (drawLast) - len++; - while(nBox--) - { - oc1 = 0; - oc2 = 0; - OUTCODES(oc1, x1, y1, pBox); - OUTCODES(oc2, x2, y2, pBox); - if ((oc1 | oc2) == 0) - { - if (!s3Set) - { - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); - s3Set = TRUE; - } - _s3SetCur (s3, x1, y1); - _s3ClipLine (s3, cmd, e1, e2, e, len); - break; - } - else if (oc1 & oc2) - { - pBox++; - } - else - { - int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; - int clip1 = 0, clip2 = 0; - int clipdx, clipdy; - int err; - - if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2-1, - pBox->y2-1, - &new_x1, &new_y1, &new_x2, &new_y2, - adx, ady, &clip1, &clip2, - octant, bias, oc1, oc2) == -1) - { - pBox++; - continue; - } - - if (axis == X_AXIS) - len = abs(new_x2 - new_x1); - else - len = abs(new_y2 - new_y1); - if (clip2 != 0 || drawLast) - len++; - if (len) - { - /* unwind bresenham error term to first point */ - err = e; - if (clip1) - { - clipdx = abs(new_x1 - x1); - clipdy = abs(new_y1 - y1); - if (axis == X_AXIS) - err += (e2 - e1) * clipdy + e1 * clipdx; - else - err += (e2 - e1) * clipdx + e1 * clipdy; - } - if (!s3Set) - { - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); - s3Set = TRUE; - } - _s3SetCur (s3, new_x1, new_y1); - _s3ClipLine (s3, cmd, e1, e2, err, len); - } - pBox++; - } - } /* while (nBox--) */ - return s3Set; -} - -void -s3Polylines (DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr ppt) -{ - SetupS3(pDrawable->pScreen); - int x, y, nx, ny; - int ox = pDrawable->x, oy = pDrawable->y; - Bool s3Set = FALSE; - - if (!npt) - return; - - x = ppt->x + ox; - y = ppt->y + oy; - while (--npt) - { - ++ppt; - if (mode == CoordModePrevious) - { - nx = x + ppt->x; - ny = y + ppt->y; - } - else - { - nx = ppt->x + ox; - ny = ppt->y + oy; - } - s3Set = _s3Segment (pDrawable, pGC, x, y, nx, ny, - npt == 1 && pGC->capStyle != CapNotLast, - s3Set); - x = nx; - y = ny; - } - if (s3Set) - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3PolySegment (DrawablePtr pDrawable, GCPtr pGC, - int nsegInit, xSegment *pSegInit) -{ - SetupS3(pDrawable->pScreen); - int x, y; - int ox = pDrawable->x, oy = pDrawable->y; - RegionPtr pClip = fbGetCompositeClip (pGC); - BoxPtr pBox; - int nbox; - int nseg; - xSegment *pSeg; - int dx, dy; - int maj, min, len, inc; - int t; - CARD32 cmd; - CARD32 init_cmd; - Bool drawLast; - Bool s3Set = FALSE; - - drawLast = pGC->capStyle != CapNotLast; - - for (nseg = nsegInit, pSeg = pSegInit; nseg--; pSeg++) - { - s3Set = _s3Segment (pDrawable, pGC, pSeg->x1 + ox, pSeg->y1 + oy, - pSeg->x2 + ox, pSeg->y2 + oy, drawLast, s3Set); - - } - if (s3Set) - MarkSyncS3 (pDrawable->pScreen); -} - -/* - * Check to see if a pattern can be painted with the S3 - */ - -#define _s3CheckPatternSize(s) ((s) <= S3_TILE_SIZE && ((s) & ((s) - 1)) == 0) -#define s3CheckPattern(w,h) (_s3CheckPatternSize(w) && _s3CheckPatternSize(h)) - -Bool -s3AllocPattern (ScreenPtr pScreen, - int ma, - PixmapPtr pPixmap, - int xorg, int yorg, - int fillStyle, Pixel fg, Pixel bg, - s3PatternPtr *ppPattern) -{ - KdScreenPriv(pScreen); - s3ScreenInfo(pScreenPriv); - s3PatternPtr pPattern; - - if (s3s->fb[ma].patterns.cache && fillStyle != FillSolid && - s3CheckPattern (pPixmap->drawable.width, pPixmap->drawable.height)) - { - if (!(pPattern = *ppPattern)) - { - pPattern = (s3PatternPtr) xalloc (sizeof (s3PatternRec)); - if (!pPattern) - return FALSE; - *ppPattern = pPattern; - } - - pPattern->cache = 0; - pPattern->id = 0; - pPattern->pPixmap = pPixmap; - pPattern->fillStyle = fillStyle; - pPattern->xrot = (-xorg) & (S3_TILE_SIZE-1); - pPattern->yrot = (-yorg) & (S3_TILE_SIZE-1); - pPattern->fore = fg; - pPattern->back = bg; - return TRUE; - } - else - { - if (*ppPattern) - { - xfree (*ppPattern); - *ppPattern = 0; - } - return FALSE; - } -} - -void -s3CheckGCFill (GCPtr pGC) -{ - s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); - PixmapPtr pPixmap; - - switch (pGC->fillStyle) { - case FillSolid: - pPixmap = 0; - break; - case FillOpaqueStippled: - case FillStippled: - pPixmap = pGC->stipple; - break; - case FillTiled: - pPixmap = pGC->tile.pixmap; - break; - } - s3AllocPattern (pGC->pScreen, - s3GCMap(pGC), - pPixmap, - pGC->patOrg.x + pGC->lastWinOrg.x, - pGC->patOrg.y + pGC->lastWinOrg.y, - pGC->fillStyle, pGC->fgPixel, pGC->bgPixel, - &s3Priv->pPattern); -} - -void -s3MoveGCFill (GCPtr pGC) -{ - s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); - int xorg, yorg; - s3PatternPtr pPattern; - - if (pPattern = s3Priv->pPattern) - { - /* - * Reset origin - */ - xorg = pGC->patOrg.x + pGC->lastWinOrg.x; - yorg = pGC->patOrg.y + pGC->lastWinOrg.y; - pPattern->xrot = (-xorg) & (S3_TILE_SIZE - 1); - pPattern->yrot = (-yorg) & (S3_TILE_SIZE - 1); - /* - * Invalidate cache entry - */ - pPattern->id = 0; - pPattern->cache = 0; - } -} - -/* - * S3 Patterns. These are always full-depth images, stored in off-screen - * memory. - */ - -Pixel -s3FetchPatternPixel (s3PatternPtr pPattern, int x, int y) -{ - CARD8 *src; - CARD16 *src16; - CARD32 *src32; - PixmapPtr pPixmap = pPattern->pPixmap; - - x = (x + pPattern->xrot) % pPixmap->drawable.width; - y = (y + pPattern->yrot) % pPixmap->drawable.height; - src = (CARD8 *) pPixmap->devPrivate.ptr + y * pPixmap->devKind; - switch (pPixmap->drawable.bitsPerPixel) { - case 1: - return (src[x>>3] >> (x & 7)) & 1 ? 0xffffffff : 0x00; - case 4: - if (x & 1) - return src[x>>1] >> 4; - else - return src[x>>1] & 0xf; - case 8: - return src[x]; - case 16: - src16 = (CARD16 *) src; - return src16[x]; - case 32: - src32 = (CARD32 *) src; - return src32[x]; - } -} - -/* - * Place pattern image on screen; done with S3 locked - */ -void -_s3PutPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern) -{ - SetupS3(pScreen); - s3ScreenInfo(pScreenPriv); - int x, y; - CARD8 *dstLine, *dst8; - CARD16 *dst16; - CARD32 *dst32; - S3PatternCache *cache = pPattern->cache; -#ifdef S3_TRIO - int fb = 0; -#else - int fb = s3s->fbmap[ma]; -#endif - - DRAW_DEBUG ((DEBUG_PATTERN, "_s3PutPattern 0x%x id %d to %d %d", - pPattern, pPattern->id, cache->x, cache->y)); - - dstLine = (pScreenPriv->screen->fb[fb].frameBuffer + - cache->y * pScreenPriv->screen->fb[fb].byteStride + - cache->x * pScreenPriv->bytesPerPixel[fb]); - - CheckSyncS3 (pScreen); - - for (y = 0; y < S3_TILE_SIZE; y++) - { - switch (pScreenPriv->screen->fb[fb].bitsPerPixel) { - case 8: - dst8 = dstLine; - for (x = 0; x < S3_TILE_SIZE; x++) - *dst8++ = s3FetchPatternPixel (pPattern, x, y); - DRAW_DEBUG ((DEBUG_PATTERN, "%c%c%c%c%c%c%c%c", - dstLine[0] ? 'X' : ' ', - dstLine[1] ? 'X' : ' ', - dstLine[2] ? 'X' : ' ', - dstLine[3] ? 'X' : ' ', - dstLine[4] ? 'X' : ' ', - dstLine[5] ? 'X' : ' ', - dstLine[6] ? 'X' : ' ', - dstLine[7] ? 'X' : ' ')); - break; - case 16: - dst16 = (CARD16 *) dstLine; - for (x = 0; x < S3_TILE_SIZE; x++) - *dst16++ = s3FetchPatternPixel (pPattern, x, y); - break; - case 32: - dst32 = (CARD32 *) dstLine; - for (x = 0; x < S3_TILE_SIZE; x++) - *dst32++ = s3FetchPatternPixel (pPattern, x, y); - break; - } - dstLine += pScreenPriv->screen->fb[fb].byteStride; - } -} - -/* - * Load a stipple to off-screen memory; done with S3 locked - */ -void -_s3LoadPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern) -{ - SetupS3(pScreen); - s3ScreenInfo(pScreenPriv); - S3PatternCache *cache; - - DRAW_DEBUG((DEBUG_PATTERN, - "s3LoadPattern 0x%x id %d cache 0x%x cacheid %d", - pPattern, pPattern->id, pPattern->cache, - pPattern->cache ? pPattern->cache->id : -1)); - /* - * Check to see if its still loaded - */ - cache = pPattern->cache; - if (cache && cache->id == pPattern->id) - return; - /* - * Lame replacement strategy; assume we'll have plenty of room. - */ - cache = &s3s->fb[ma].patterns.cache[s3s->fb[ma].patterns.last_used]; - if (++s3s->fb[ma].patterns.last_used == s3s->fb[ma].patterns.ncache) - s3s->fb[ma].patterns.last_used = 0; - cache->id = ++s3s->fb[ma].patterns.last_id; - pPattern->id = cache->id; - pPattern->cache = cache; - _s3PutPattern (pScreen, ma, pPattern); -} - -void -s3DestroyGC (GCPtr pGC) -{ - s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); - - if (s3Priv->pPattern) - xfree (s3Priv->pPattern); - miDestroyGC (pGC); -} - -GCFuncs s3GCFuncs = { - s3ValidateGC, - miChangeGC, - miCopyGC, - s3DestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -int -s3CreateGC (GCPtr pGC) -{ - KdScreenPriv(pGC->pScreen); - s3ScreenInfo(pScreenPriv); - s3PrivGCPtr s3Priv; - - if (!fbCreateGC (pGC)) - return FALSE; - - if (pGC->depth != 1) - pGC->funcs = &s3GCFuncs; - - s3Priv = s3GetGCPrivate(pGC); - s3Priv->type = DRAWABLE_PIXMAP; - s3Priv->pPattern = 0; -#ifndef S3_TRIO - if (pGC->depth == s3s->primary_depth) - s3Priv->ma = 0; - else - s3Priv->ma = 1; -#endif - return TRUE; -} - -Bool -s3CreateWindow (WindowPtr pWin) -{ - KdScreenPriv(pWin->drawable.pScreen); - s3ScreenInfo(pScreenPriv); - - pWin->devPrivates[s3WindowPrivateIndex].ptr = 0; - return KdCreateWindow (pWin); -} - -Bool -s3DestroyWindow (WindowPtr pWin) -{ - s3PatternPtr pPattern; - if (pPattern = s3GetWindowPrivate(pWin)) - xfree (pPattern); - return fbDestroyWindow (pWin); -} - -Bool -s3ChangeWindowAttributes (WindowPtr pWin, Mask mask) -{ - KdScreenPriv(pWin->drawable.pScreen); - Bool ret; - s3PatternPtr pPattern; - PixmapPtr pPixmap; - int fillStyle; - - ret = fbChangeWindowAttributes (pWin, mask); - if (mask & CWBackPixmap) - { - if (pWin->backgroundState == BackgroundPixmap) - { - pPixmap = pWin->background.pixmap; - fillStyle = FillTiled; - } - else - { - pPixmap = 0; - fillStyle = FillSolid; - } - pPattern = s3GetWindowPrivate(pWin); - s3AllocPattern (pWin->drawable.pScreen, - s3DrawMap (&pWin->drawable), - pPixmap, - pWin->drawable.x, pWin->drawable.y, - fillStyle, 0, 0, &pPattern); - DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "Background pattern 0x%x pixmap 0x%x style %d", - pPattern, pPixmap, fillStyle)); - s3SetWindowPrivate (pWin, pPattern); - } - return ret; -} - - -#ifndef S3_TRIO -void -s3PaintKey (DrawablePtr pDrawable, - RegionPtr pRegion, - CARD32 pixel, - int fb) -{ - SetupS3 (pDrawable->pScreen); - s3ScreenInfo (pScreenPriv); - int nBox = REGION_NUM_RECTS(pRegion); - BoxPtr pBox = REGION_RECTS(pRegion); - int ma; - - if (!nBox) - return; - - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - if (s3s->fbmap[ma] == fb) - break; - s3SetGlobalBitmap (pDrawable->pScreen, ma); - _s3SetSolidFill (s3, pixel, GXcopy, 0xffffffff); - while (nBox--) - { - _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1); - pBox++; - } - MarkSyncS3 (pDrawable->pScreen); -} -#endif - -void -s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) -{ - SetupS3(pWin->drawable.pScreen); - s3ScreenInfo(pScreenPriv); - s3PatternPtr pPattern; - - DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d", - pWin->drawable.id, - pRegion->extents.x1, pRegion->extents.y1, - pRegion->extents.x2, pRegion->extents.y2, - REGION_NUM_RECTS(pRegion))); - 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; - case BackgroundPixmap: - pPattern = s3GetWindowPrivate(pWin); - if (pPattern) - { - s3FillBoxPattern ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - GXcopy, ~0, pPattern); - return; - } - break; - case BackgroundPixel: - s3FillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixel, GXcopy, ~0); - return; - } - break; - case PW_BORDER: -#ifndef S3_TRIO - if (s3s->fbmap[1] >= 0) - fbOverlayUpdateLayerRegion (pWin->drawable.pScreen, - fbOverlayWindowLayer (pWin), - pRegion); -#endif - if (pWin->borderIsPixel) - { - s3FillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixel, GXcopy, ~0); - return; - } - break; - } - KdCheckPaintWindow (pWin, pRegion, what); -} - -void -s3CopyWindowProc (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pboxOrig, - int nboxOrig, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupS3(pDstDrawable->pScreen); - s3ScreenInfo(pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - int srcX, srcY, dstX, dstY; - int x1, x2; - int w, h; - int flags; - int fb = (int) closure; - int ma; - BoxPtr pbox; - int nbox; - int bitsPerPixel; - -#ifdef S3_TRIO - ma = 0; -#else - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) - if (s3s->fbmap[ma] == fb) - break; -#endif - bitsPerPixel = screen->fb[fb].bitsPerPixel; - if (bitsPerPixel == 24) - dx *= 3; - nbox = nboxOrig; - pbox = pboxOrig; - s3SetGlobalBitmap (pDstDrawable->pScreen, ma); - _s3SetBlt(s3,GXcopy,~0); - while (nbox--) - { - x1 = pbox->x1; - x2 = pbox->x2; - if (bitsPerPixel == 24) - { - x1 *= 3; - x2 *= 3; - } - - w = x2 - x1; - h = pbox->y2 - pbox->y1; - flags = 0; - if (reverse) - { - dstX = x2 - 1; - } - else - { - dstX = x1; - flags |= INC_X; - } - srcX = dstX + dx; - - if (upsidedown) - { - dstY = pbox->y2 - 1; - } - else - { - dstY = pbox->y1; - flags |= INC_Y; - } - srcY = dstY + dy; - - _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); - pbox++; - } - MarkSyncS3 (pDstDrawable->pScreen); -} - -void -s3CopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - KdScreenPriv (pScreen); - s3ScreenInfo (pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - 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, s3CopyWindowProc, 0, 0); - - REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); -} - -void -s3_24FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask) -{ - SetupS3(pDrawable->pScreen); - register int r; - int x1, x2; - - s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); - _s3SetSolidFill(s3,pixel,alu,planemask); - - while (nBox--) { - x1 = pBox->x1 * 3; - x2 = pBox->x2 * 3; - _s3SolidRect(s3,x1,pBox->y1,x2-x1,pBox->y2-pBox->y1); - pBox++; - } - MarkSyncS3 (pDrawable->pScreen); -} - -#define ok24(p) (((p) & 0xffffff) == ((((p) & 0xff) << 16) | (((p) >> 8) & 0xffff))) - -void -s3_24FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - SetupS3(pDrawable->pScreen); - int x, y, x1, y1, x2, y2; - int width; - /* next three parameters are post-clip */ - int nTmp; - int *pwidthFree;/* copies of the pointers to free */ - DDXPointPtr pptFree; - BoxPtr extents; - RegionPtr pClip = fbGetCompositeClip (pGC); - - if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask)) - { - KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); - return; - } - - s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); - if (REGION_NUM_RECTS(pClip) == 1) - { - extents = REGION_RECTS(pClip); - x1 = extents->x1; - x2 = extents->x2; - y1 = extents->y1; - y2 = extents->y2; - _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); - while (n--) - { - y = ppt->y; - if (y1 <= y && y < y2) - { - x = ppt->x; - width = *pwidth; - if (x < x1) - { - width -= (x1 - x); - x = x1; - } - if (x2 < x + width) - width = x2 - x; - if (width > 0) - { - _s3SolidRect(s3,x*3,y,width*3,1); - } - } - ppt++; - pwidth++; - } - } - else - { - nTmp = n * miFindMaxBand(pClip); - 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; - _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); - while (n--) - { - x = ppt->x; - y = ppt->y; - ppt++; - width = *pwidth++; - if (width) - { - _s3SolidRect(s3,x*3,y,width*3,1); - } - } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); - } - MarkSyncS3 (pDrawable->pScreen); -} - -void -s3_24CopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupS3(pDstDrawable->pScreen); - int srcX, srcY, dstX, dstY; - int w, h; - int flags; - int x1, x2; - - if (sourceInvarient (pGC->alu)) - { - s3_24FillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); - return; - } - - s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); - _s3SetBlt(s3,pGC->alu,pGC->planemask); - DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x", - pGC->alu, pGC->planemask)); - dx *= 3; - while (nbox--) - { - x1 = pbox->x1 * 3; - x2 = pbox->x2 * 3; - w = x2 - x1; - h = pbox->y2 - pbox->y1; - flags = 0; - if (reverse) - { - dstX = x2 - 1; - } - else - { - dstX = x1; - flags |= INC_X; - } - srcX = dstX + dx; - - if (upsidedown) - { - dstY = pbox->y2 - 1; - } - else - { - dstY = pbox->y1; - flags |= INC_Y; - } - srcY = dstY + dy; - - _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); - pbox++; - } - MarkSyncS3 (pSrcDrawable->pScreen); -} - -RegionPtr -s3_24CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, int dstx, int dsty) -{ - SetupS3(pDstDrawable->pScreen); - - if (pSrcDrawable->type == DRAWABLE_WINDOW && - pDstDrawable->type == DRAWABLE_WINDOW && - ok24(pGC->planemask)) - { - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, s3_24CopyNtoN, 0, 0); - } - return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, dstx, dsty); -} - - -#define NUM_STACK_RECTS 1024 - -void -s3_24PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - s3GCPrivate(pGC); - xRectangle *prect; - RegionPtr prgnClip; - register BoxPtr pbox; - register BoxPtr pboxClipped; - BoxPtr pboxClippedBase; - BoxPtr pextent; - BoxRec stackRects[NUM_STACK_RECTS]; - int numRects; - int n; - int xorg, yorg; - int x, y; - - if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask)) - { - KdCheckPolyFillRect (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)ALLOCATE_LOCAL(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) - { - s3_24FillBoxSolid(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->fgPixel, pGC->alu, pGC->planemask); - } - if (pboxClippedBase != stackRects) - DEALLOCATE_LOCAL(pboxClippedBase); -} - -void -s3_24SolidBoxClipped (DrawablePtr pDrawable, - RegionPtr pClip, - int x1, - int y1, - int x2, - int y2, - FbBits fg) -{ - SetupS3 (pDrawable->pScreen); - BoxPtr pbox; - int nbox; - int partX1, partX2, partY1, partY2; - - s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); - _s3SetSolidFill(s3,fg,GXcopy,~0); - - 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; - - partX1 *= 3; - partX2 *= 3; - _s3SolidRect(s3,partX1, partY1, partX2-partX1, partY2-partY1); - } - MarkSyncS3(pDrawable->pScreen); -} - -void -s3_24ImageGlyphBlt (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; - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - FbBits depthMask; - int xBack, widthBack; - int yBack, heightBack; - - depthMask = FbFullMask(pDrawable->depth); - if (!ok24 (pGC->fgPixel) || - !ok24(pGC->bgPixel) || - !ok24(pGC->planemask)) - { - KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase); - return; - } - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - x += pDrawable->x; - y += pDrawable->y; - - 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); - s3_24SolidBoxClipped (pDrawable, - fbGetCompositeClip(pGC), - xBack, - yBack, - xBack + widthBack, - yBack + heightBack, - pPriv->bg); - - KdCheckSync (pDrawable->pScreen); - - 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 (gWidth <= sizeof (FbStip) * 8 && - fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) - { - fbGlyph24 (dst + (gy - dstYoff) * dstStride, - dstStride, - dstBpp, - (FbStip *) pglyph, - pPriv->fg, - gx - dstXoff, - gHeight); - } - else - { - gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); - fbPutXYImage (pDrawable, - fbGetCompositeClip(pGC), - pPriv->fg, - pPriv->bg, - pPriv->pm, - GXcopy, - FALSE, - - gx, - gy, - gWidth, gHeight, - - (FbStip *) pglyph, - gStride, - 0); - } - } - x += pci->metrics.characterWidth; - } -} - -static const GCOps s3_24GCOps = { - s3_24FillSpans, - KdCheckSetSpans, - KdCheckPutImage, - KdCheckCopyArea, - KdCheckCopyPlane, - KdCheckPolyPoint, - KdCheckPolylines, - KdCheckPolySegment, - KdCheckPolyRectangle, - KdCheckPolyArc, - KdCheckFillPolygon, - s3_24PolyFillRect, - KdCheckPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - s3_24ImageGlyphBlt, - KdCheckPolyGlyphBlt, - KdCheckPushPixels, -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -void -s3_24ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - if (pDrawable->type != DRAWABLE_WINDOW) - pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; - else - pGC->ops = (GCOps *) &s3_24GCOps; - fbValidateGC (pGC, changes, pDrawable); -} - -GCFuncs s3_24GCFuncs = { - s3_24ValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -Bool -s3_24CreateGC (GCPtr pGC) -{ - if (!fbCreateGC (pGC)) - return FALSE; - - if (pGC->depth != 1) - pGC->funcs = &s3_24GCFuncs; - - return TRUE; -} - -Bool -s3_24CreateWindow(WindowPtr pWin) -{ - return fbCreateWindow (pWin); -} - -void -s3_24PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) -{ - SetupS3(pWin->drawable.pScreen); - s3PatternPtr pPattern; - - DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d", - pWin->drawable.id, - pRegion->extents.x1, pRegion->extents.y1, - pRegion->extents.x2, pRegion->extents.y2, - REGION_NUM_RECTS(pRegion))); - 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; - case BackgroundPixel: - if (ok24(pWin->background.pixel)) - { - s3_24FillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixel, GXcopy, ~0); - return; - } - } - break; - case PW_BORDER: - if (pWin->borderIsPixel && ok24(pWin->border.pixel)) - { - s3_24FillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixel, GXcopy, ~0); - return; - } - break; - } - KdCheckPaintWindow (pWin, pRegion, what); -} - -Bool -s3DrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - s3ScreenInfo(pScreenPriv); - int ncache_w, ncache_h, ncache; - int px, py; - S3PatternCache *cache; - Bool dumb = FALSE; - int ma; - - switch (pScreenPriv->screen->fb[0].bitsPerPixel) { - case 8: - case 16: - case 32: - break; - case 24: - dumb = TRUE; - break; - default: - return FALSE; - } - /* - * Hook up asynchronous drawing - */ - RegisterSync (pScreen); - /* - * Replace various fb screen functions - */ - if (dumb) - { - pScreen->CreateGC = s3_24CreateGC; - pScreen->CreateWindow = s3_24CreateWindow; - pScreen->PaintWindowBackground = s3_24PaintWindow; - pScreen->PaintWindowBorder = s3_24PaintWindow; - pScreen->CopyWindow = s3CopyWindow; - } - else - { - if (serverGeneration != s3Generation) - { - s3GCPrivateIndex = AllocateGCPrivateIndex (); - s3WindowPrivateIndex = AllocateWindowPrivateIndex (); - s3Generation = serverGeneration; - } - if (!AllocateWindowPrivate(pScreen, s3WindowPrivateIndex, 0)) - return FALSE; - if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec))) - return FALSE; - pScreen->CreateGC = s3CreateGC; - pScreen->CreateWindow = s3CreateWindow; - pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes; - pScreen->DestroyWindow = s3DestroyWindow; - pScreen->PaintWindowBackground = s3PaintWindow; - pScreen->PaintWindowBorder = s3PaintWindow; -#ifndef S3_TRIO - if (pScreenPriv->screen->fb[1].depth) - { - FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); - - pScrPriv->PaintKey = s3PaintKey; - pScrPriv->CopyWindow = s3CopyWindowProc; - pScreen->CopyWindow = fbOverlayCopyWindow; - } - else -#endif - pScreen->CopyWindow = s3CopyWindow; - - /* - * Initialize patterns - */ -#ifdef S3_TRIO - ma = 0; -#else - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) -#endif - { - ncache_w = s3s->fb[ma].offscreen_width / S3_TILE_SIZE; - ncache_h = s3s->fb[ma].offscreen_height / S3_TILE_SIZE; - ncache = ncache_w * ncache_h; - if (ncache > 64) - ncache = 64; - DRAW_DEBUG ((DEBUG_S3INIT, "ncache_w %d ncache_h %d ncache %d", - ncache_w, ncache_h, ncache)); - s3s->fb[ma].patterns.cache = (S3PatternCache *) xalloc (ncache * sizeof (S3PatternCache)); - if (s3s->fb[ma].patterns.cache) - { - DRAW_DEBUG ((DEBUG_S3INIT, "Have pattern cache")); - s3s->fb[ma].patterns.ncache = ncache; - s3s->fb[ma].patterns.last_used = 0; - s3s->fb[ma].patterns.last_id = 0; - cache = s3s->fb[ma].patterns.cache; - for (py = 0; py < ncache_h && ncache; py++) - for (px = 0; px < ncache_w && ncache; px++) - { - cache->id = 0; - cache->x = s3s->fb[ma].offscreen_x + px * S3_TILE_SIZE; - cache->y = s3s->fb[ma].offscreen_y + py * S3_TILE_SIZE; - cache++; - ncache--; - } - } - } - } - return TRUE; -} - -void -s3DrawEnable (ScreenPtr pScreen) -{ - SetupS3(pScreen); - s3ScreenInfo(pScreenPriv); - int c; - int ma; - - s3SetGlobalBitmap (pScreen, 0); - _s3WaitIdleEmpty (s3); - if (pScreenPriv->screen->fb[0].bitsPerPixel == 24) - { - _s3SetScissorsTl(s3, 0, 0); - _s3SetScissorsBr(s3, pScreenPriv->screen->width*3 - 1, pScreenPriv->screen->height - 1); - _s3SetSolidFill(s3, pScreen->whitePixel, GXcopy, ~0); - _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width*3, pScreenPriv->screen->height); - } - else - { - /* - * Flush pattern cache - */ -#ifdef S3_TRIO - ma = 0; -#else - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) -#endif - { - for (c = 0; c < s3s->fb[ma].patterns.ncache; c++) - s3s->fb[ma].patterns.cache[c].id = 0; - } - - _s3SetScissorsTl(s3, 0, 0); - _s3SetScissorsBr(s3, pScreenPriv->screen->width - 1, pScreenPriv->screen->height - 1); - _s3SetSolidFill(s3, pScreen->blackPixel, GXcopy, ~0); - _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width, pScreenPriv->screen->height); - } - MarkSyncS3 (pScreen); -} - -void -s3DrawDisable (ScreenPtr pScreen) -{ - SetupS3 (pScreen); - _s3WaitIdleEmpty (s3); -} - -void -s3DrawFini (ScreenPtr pScreen) -{ - SetupS3(pScreen); - s3ScreenInfo(pScreenPriv); - int ma; - -#ifdef S3_TRIO - ma = 0; -#else - for (ma = 0; s3s->fbmap[ma] >= 0; ma++) -#endif - { - if (s3s->fb[ma].patterns.cache) - { - xfree (s3s->fb[ma].patterns.cache); - s3s->fb[ma].patterns.cache = 0; - s3s->fb[ma].patterns.ncache = 0; - } - } -} - -void -s3DrawSync (ScreenPtr pScreen) -{ - SetupS3(pScreen); - - _s3WaitIdleEmpty(s3c->s3); -} diff --git a/hw/kdrive/savage/s3draw.h b/hw/kdrive/savage/s3draw.h deleted file mode 100644 index a95b53b12..000000000 --- a/hw/kdrive/savage/s3draw.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Id: s3draw.h,v 1.2 1999/11/02 06:16:29 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.4 2000/05/06 22:17:47 keithp Exp $ */ - -#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 */ - int ma; /* stream descriptor */ - 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, int fb, s3PatternPtr pPattern); - -#define SetupS3(s) KdScreenPriv(s); \ - s3CardInfo(pScreenPriv); \ - S3Ptr s3 = s3c->s3 - -#ifdef S3_SYNC_DEBUG -#define SYNC_DEBUG() fprintf (stderr, "Sync at %s:%d\n", __FILE__,__LINE__) -#else -#define SYNC_DEBUG() -#endif - -#define S3_ASYNC -#ifdef S3_ASYNC -#define CheckSyncS3(s) KdCheckSync(s) -#define MarkSyncS3(s) KdMarkSync(s) -#define RegisterSync(screen) KdScreenInitAsync (screen) -#else -#define CheckSyncS3(s3c) -#define MarkSyncS3(s3c) _s3WaitIdleEmpty(s3c->s3) -#define RegisterSync(screen) -#endif - -#define WIDEN(x) ((unsigned long) (x)) -#define MERGE(a,b) ((WIDEN(a) << 16) | WIDEN(b)) - -#define s3BitmapDescriptor(_stream) ((_stream) + 1) - -#ifdef S3_TRIO -#define s3DrawMap(pDraw) 0 -#define s3SetGlobalBitmap(s,d) -#else -#define s3DrawMap(pDraw) ((pDraw)->depth == \ - getS3ScreenInfo(pScreenPriv)->primary_depth ? 0 : 1) -#endif - -#define s3GCMap(pGC) (s3GetGCPrivate(pGC)->ma) - -/* - * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order, - * but it's willing to take them in LSB byte order. These macros - * flip bits around without flipping bytes. Instead of using a table - * and burning memory bandwidth, do them in place with the CPU. - */ - -/* The MIPS compiler automatically places these constants in registers */ -#define S3InvertBits32(v) { \ - v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ - v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ - v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ -} - -#define S3InvertBits16(v) { \ - v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \ - v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \ - v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \ -} - -#define S3InvertBits8(v) { \ - v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \ - v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \ - v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \ -} - -#define S3ByteSwap32(x) ((x) = (((x) >> 24) | \ - (((x) >> 8) & 0xff00) | \ - (((x) << 8) & 0xff0000) | \ - ((x) << 24))) - -#define S3ByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8)) - -#if BITMAP_BIT_ORDER == LSBFirst -#define S3AdjustBits32(x) S3InvertBits32(x) -#define S3AdjustBits16(x) S3InvertBits16(x) -#else -#define S3AdjustBits32(x) S3ByteSwap32(x) -#define S3AdjustBits16(x) S3ByteSwap16(x) -#endif - -#define _s3WaitSlot(s3) _s3WaitSlots(s3,1) - -#define _s3SetFg(s3,_fg) { \ - DRAW_DEBUG ((DEBUG_REGISTERS, " fg <- 0x%x", _fg));\ - s3->fg = (_fg); \ -} - -#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_mult_misc2 = MERGE (CONTROL_MISC2, 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)); \ - _s3WaitSlots(s3,4); \ - _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)); \ - _s3WaitSlots(s3,3); \ - _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)); \ - _s3WaitSlots(s3,4); \ - _s3SetPcnt(s3, (len), 0); \ - _s3SetStep(s3, 2*((min) - (maj)), 2*(min)); \ - _s3SetErr(s3, 2*(min) - (maj)); \ - _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \ -} - -#define _s3ClipLine(s3,cmd,e1,e2,e,len) {\ - DRAW_DEBUG ((DEBUG_RENDER, "clip line 0x%x 0x%x 0x%x 0x%x 0x%x", cmd,e1,e2,e,len)); \ - _s3WaitSlots(s3, 4); \ - _s3SetPcnt (s3, (len), 0); \ - _s3SetStep (s3, e2, e1); \ - _s3SetErr (s3, e); \ - _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \ -} - -#define _s3SetTile(s3,alu,mask) { \ - DRAW_DEBUG ((DEBUG_SET,"set tile %d 0x%x", alu, mask)); \ - _s3WaitSlots(s3,3); \ - _s3SetWriteMask(s3, mask); \ - _s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT|s3alu[alu]); \ - _s3SetPixelControl (s3, MIXSEL_FRGDMIX); \ - 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)); \ - _s3WaitSlots(s3,5); \ - _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)); \ - _s3WaitSlots(s3,5); \ - _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)); \ - _s3WaitSlots(s3, 4); \ - _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)); \ - _s3WaitSlots(s3,3); \ - _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)); \ - _s3WaitSlots(s3,4); \ - _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)); \ - /* _s3WaitSlots(s3, 5); */ \ - _s3WaitIdleEmpty (s3); \ - _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)); \ - /*_s3WaitSlots(s3, 4); */ \ - _s3WaitIdleEmpty (s3); \ - _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)); \ - _s3WaitSlots(s3, 4); \ - _s3SetPixelControl(s3,MIXSEL_EXPPC); \ - _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)); \ - _s3WaitSlots(s3, 2); \ - _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")); \ - _s3WaitSlots(s3, 2); \ - _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 -s3PushPixels (GCPtr pGC, PixmapPtr pBitmap, - DrawablePtr pDrawable, - int w, int h, int x, int y); - -void -s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - unsigned long pixel, int alu, unsigned long planemask); - -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 -s3FillPoly (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); - -void -s3SyncProc (DrawablePtr pDrawable); - -#endif diff --git a/hw/kdrive/savage/s3gc.c b/hw/kdrive/savage/s3gc.c deleted file mode 100644 index 6faadff27..000000000 --- a/hw/kdrive/savage/s3gc.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Id: s3gc.c,v 1.2 1999/11/02 06:16:29 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3gc.c,v 1.3 2000/01/21 01:12:02 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 */ -static const GCOps s3TEOps = { - s3FillSpans, - KdCheckSetSpans, - KdCheckPutImage, - s3CopyArea, - s3CopyPlane, - KdCheckPolyPoint, - s3Polylines, - s3PolySegment, - KdCheckPolyRectangle, - KdCheckPolyArc, - s3FillPoly, - s3PolyFillRect, - s3PolyFillArcSolid, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - s3ImageTEGlyphBlt, - s3PolyTEGlyphBlt, - s3PushPixels -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -/* Non TE font */ -static const GCOps s3NonTEOps = { - s3FillSpans, - KdCheckSetSpans, - KdCheckPutImage, - s3CopyArea, - s3CopyPlane, - KdCheckPolyPoint, - s3Polylines, - s3PolySegment, - KdCheckPolyRectangle, - KdCheckPolyArc, - s3FillPoly, - s3PolyFillRect, - s3PolyFillArcSolid, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - s3ImageGlyphBlt, - s3PolyGlyphBlt, - s3PushPixels -#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 *) &kdAsyncPixmapGCOps; - - 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)) - return (GCOps *) &s3TEOps; - else - return (GCOps *) &s3NonTEOps; - } - return 0; -} - -void -s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - int new_type; /* drawable type has changed */ - int new_origin; - - /* flags for changing the proc vector */ - FbGCPrivPtr fbPriv; - s3PrivGCPtr s3Priv; - int oneRect; - GCOps *newops; - - fbPriv = fbGetGCPrivate(pGC); - s3Priv = s3GetGCPrivate(pGC); - - new_type = 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 - */ - - fbValidateGC (pGC, changes, pDrawable); - - /* - * 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 (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 *) &kdAsyncPixmapGCOps; - new_type = TRUE; - } - pGC->ops = miCreateGCOps (pGC->ops); - pGC->ops->devPrivate.val = 1; - } - - /* - * Fills - */ - if (new_type || (changes & (GCFillStyle|GCTile|GCStipple))) - { - pGC->ops->FillSpans = KdCheckFillSpans; - pGC->ops->PolyFillRect = KdCheckPolyFillRect; - 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 = s3CopyArea; - pGC->ops->CopyPlane = s3CopyPlane; - pGC->ops->PushPixels = s3PushPixels; - } - - /* - * Lines - */ - if (new_type || (changes & (GCLineStyle|GCLineWidth|GCFillStyle))) - { - pGC->ops->Polylines = KdCheckPolylines; - pGC->ops->PolySegment = KdCheckPolySegment; - 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 || (changes & (GCFillStyle))) - { - pGC->ops->FillPolygon = KdCheckFillPolygon; - if (s3Priv->type == DRAWABLE_WINDOW && - pGC->fillStyle == FillSolid) - { - pGC->ops->FillPolygon = s3FillPoly; - } - } - - /* - * Filled arcs - */ - if (new_type || (changes & GCFillStyle)) - { - pGC->ops->PolyFillArc = KdCheckPolyFillArc; - if (s3Priv->type == DRAWABLE_WINDOW && - pGC->fillStyle == FillSolid) - { - pGC->ops->PolyFillArc = s3PolyFillArcSolid; - } - } - - /* - * Text - */ - if (new_type || (changes & (GCFont|GCFillStyle))) - { - pGC->ops->PolyGlyphBlt = KdCheckPolyGlyphBlt; - pGC->ops->ImageGlyphBlt = KdCheckImageGlyphBlt; - 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; - } - } -} diff --git a/hw/kdrive/savage/s3reg.c b/hw/kdrive/savage/s3reg.c deleted file mode 100644 index 052bcf4d7..000000000 --- a/hw/kdrive/savage/s3reg.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* - * Id: s3reg.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3reg.c,v 1.3 2000/02/23 20:30:04 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3reg.h" - -#define CR00 S3_CR+0x00 -#define CR01 S3_CR+0x01 -#define CR02 S3_CR+0x02 -#define CR03 S3_CR+0x03 -#define CR04 S3_CR+0x04 -#define CR05 S3_CR+0x05 -#define CR06 S3_CR+0x06 -#define CR07 S3_CR+0x07 -#define CR08 S3_CR+0x08 -#define CR09 S3_CR+0x09 -#define CR0A S3_CR+0x0A -#define CR0B S3_CR+0x0B -#define CR0C S3_CR+0x0C -#define CR0D S3_CR+0x0D -#define CR0E S3_CR+0x0E -#define CR0F S3_CR+0x0F -#define CR10 S3_CR+0x10 -#define CR11 S3_CR+0x11 -#define CR12 S3_CR+0x12 -#define CR13 S3_CR+0x13 -#define CR14 S3_CR+0x14 -#define CR15 S3_CR+0x15 -#define CR16 S3_CR+0x16 -#define CR17 S3_CR+0x17 -#define CR18 S3_CR+0x18 -#define CR19 S3_CR+0x19 -#define CR1A S3_CR+0x1A -#define CR1B S3_CR+0x1B -#define CR1C S3_CR+0x1C -#define CR1D S3_CR+0x1D -#define CR1E S3_CR+0x1E -#define CR1F S3_CR+0x1F -#define CR20 S3_CR+0x20 -#define CR21 S3_CR+0x21 -#define CR22 S3_CR+0x22 -#define CR23 S3_CR+0x23 -#define CR24 S3_CR+0x24 -#define CR25 S3_CR+0x25 -#define CR26 S3_CR+0x26 -#define CR27 S3_CR+0x27 -#define CR28 S3_CR+0x28 -#define CR29 S3_CR+0x29 -#define CR2A S3_CR+0x2A -#define CR2B S3_CR+0x2B -#define CR2C S3_CR+0x2C -#define CR2D S3_CR+0x2D -#define CR2E S3_CR+0x2E -#define CR2F S3_CR+0x2F -#define CR30 S3_CR+0x30 -#define CR31 S3_CR+0x31 -#define CR32 S3_CR+0x32 -#define CR33 S3_CR+0x33 -#define CR34 S3_CR+0x34 -#define CR35 S3_CR+0x35 -#define CR36 S3_CR+0x36 -#define CR37 S3_CR+0x37 -#define CR38 S3_CR+0x38 -#define CR39 S3_CR+0x39 -#define CR3A S3_CR+0x3A -#define CR3B S3_CR+0x3B -#define CR3C S3_CR+0x3C -#define CR3D S3_CR+0x3D -#define CR3E S3_CR+0x3E -#define CR3F S3_CR+0x3F -#define CR40 S3_CR+0x40 -#define CR41 S3_CR+0x41 -#define CR42 S3_CR+0x42 -#define CR43 S3_CR+0x43 -#define CR44 S3_CR+0x44 -#define CR45 S3_CR+0x45 -#define CR46 S3_CR+0x46 -#define CR47 S3_CR+0x47 -#define CR48 S3_CR+0x48 -#define CR49 S3_CR+0x49 -#define CR4A S3_CR+0x4A -#define CR4B S3_CR+0x4B -#define CR4C S3_CR+0x4C -#define CR4D S3_CR+0x4D -#define CR4E S3_CR+0x4E -#define CR4F S3_CR+0x4F -#define CR50 S3_CR+0x50 -#define CR51 S3_CR+0x51 -#define CR52 S3_CR+0x52 -#define CR53 S3_CR+0x53 -#define CR54 S3_CR+0x54 -#define CR55 S3_CR+0x55 -#define CR56 S3_CR+0x56 -#define CR57 S3_CR+0x57 -#define CR58 S3_CR+0x58 -#define CR59 S3_CR+0x59 -#define CR5A S3_CR+0x5A -#define CR5B S3_CR+0x5B -#define CR5C S3_CR+0x5C -#define CR5D S3_CR+0x5D -#define CR5E S3_CR+0x5E -#define CR5F S3_CR+0x5F -#define CR60 S3_CR+0x60 -#define CR61 S3_CR+0x61 -#define CR62 S3_CR+0x62 -#define CR63 S3_CR+0x63 -#define CR64 S3_CR+0x64 -#define CR65 S3_CR+0x65 -#define CR66 S3_CR+0x66 -#define CR67 S3_CR+0x67 -#define CR68 S3_CR+0x68 -#define CR69 S3_CR+0x69 -#define CR6A S3_CR+0x6A -#define CR6B S3_CR+0x6B -#define CR6C S3_CR+0x6C -#define CR6D S3_CR+0x6D -#define CR6E S3_CR+0x6E -#define CR6F S3_CR+0x6F -#define CR70 S3_CR+0x70 -#define CR71 S3_CR+0x71 -#define CR72 S3_CR+0x72 -#define CR73 S3_CR+0x73 -#define CR74 S3_CR+0x74 -#define CR75 S3_CR+0x75 -#define CR76 S3_CR+0x76 -#define CR77 S3_CR+0x77 -#define CR78 S3_CR+0x78 -#define CR79 S3_CR+0x79 -#define CR7A S3_CR+0x7A -#define CR7B S3_CR+0x7B -#define CR7C S3_CR+0x7C -#define CR7D S3_CR+0x7D -#define CR7E S3_CR+0x7E -#define CR7F S3_CR+0x7F -#define CR80 S3_CR+0x80 -#define CR81 S3_CR+0x81 -#define CR82 S3_CR+0x82 -#define CR83 S3_CR+0x83 -#define CR84 S3_CR+0x84 -#define CR85 S3_CR+0x85 -#define CR86 S3_CR+0x86 -#define CR87 S3_CR+0x87 -#define CR88 S3_CR+0x88 -#define CR89 S3_CR+0x89 -#define CR8A S3_CR+0x8A -#define CR8B S3_CR+0x8B -#define CR8C S3_CR+0x8C -#define CR8D S3_CR+0x8D -#define CR8E S3_CR+0x8E -#define CR8F S3_CR+0x8F -#define CR90 S3_CR+0x90 -#define CR91 S3_CR+0x91 -#define CR92 S3_CR+0x92 -#define CR93 S3_CR+0x93 -#define CR94 S3_CR+0x94 -#define CR95 S3_CR+0x95 -#define CR96 S3_CR+0x96 -#define CR97 S3_CR+0x97 -#define CR98 S3_CR+0x98 -#define CR99 S3_CR+0x99 -#define CR9A S3_CR+0x9A -#define CR9B S3_CR+0x9B -#define CR9C S3_CR+0x9C -#define CR9D S3_CR+0x9D -#define CR9E S3_CR+0x9E -#define CR9F S3_CR+0x9F -#define CRA0 S3_CR+0xA0 -#define CRA1 S3_CR+0xA1 -#define CRA2 S3_CR+0xA2 -#define CRA3 S3_CR+0xA3 -#define CRA4 S3_CR+0xA4 -#define CRA5 S3_CR+0xA5 -#define CRA6 S3_CR+0xA6 -#define CRA7 S3_CR+0xA7 -#define CRA8 S3_CR+0xA8 -#define CRA9 S3_CR+0xA9 -#define CRAA S3_CR+0xAA -#define CRAB S3_CR+0xAB -#define CRAC S3_CR+0xAC -#define CRAD S3_CR+0xAD -#define CRAE S3_CR+0xAE -#define CRAF S3_CR+0xAF -#define CRB0 S3_CR+0xB0 -#define CRB1 S3_CR+0xB1 -#define CRB2 S3_CR+0xB2 -#define CRB3 S3_CR+0xB3 -#define CRB4 S3_CR+0xB4 -#define CRB5 S3_CR+0xB5 -#define CRB6 S3_CR+0xB6 -#define CRB7 S3_CR+0xB7 -#define CRB8 S3_CR+0xB8 -#define CRB9 S3_CR+0xB9 -#define CRBA S3_CR+0xBA -#define CRBB S3_CR+0xBB -#define CRBC S3_CR+0xBC -#define CRBD S3_CR+0xBD -#define CRBE S3_CR+0xBE -#define CRBF S3_CR+0xBF - -#define CR_FIRST CR00 - -VgaReg s3_h_total[] = { - CR00, 0, 8, - CR5D, 0, 1, - CR5F, 0, 2, - VGA_REG_END -}; - -VgaReg s3_h_display_end[] = { - CR01, 0, 8, - CR5D, 1, 1, - CR5F, 2, 2, - VGA_REG_END -}; - -VgaReg s3_h_blank_start[] = { - CR02, 0, 8, - CR5D, 2, 1, - CR5F, 4, 2, - VGA_REG_END -}; - -VgaReg s3_h_blank_end[] = { - CR03, 0, 5, - CR05, 7, 1, - VGA_REG_END -}; - -VgaReg s3_display_skew[] = { - CR03, 5, 2, - VGA_REG_END -}; - -VgaReg s3_h_sync_start[] = { - CR04, 0, 8, - CR5D, 4, 1, - CR5F, 6, 2, - VGA_REG_END -}; - -VgaReg s3_h_sync_end[] = { - CR05, 0, 5, - VGA_REG_END -}; - -VgaReg s3_h_skew[] = { - CR05, 5, 2, - VGA_REG_END -}; - -VgaReg s3_v_total[] = { - CR06, 0, 8, - CR07, 0, 1, - CR07, 5, 1, - CR5E, 0, 1, - VGA_REG_END -}; - -VgaReg s3_preset_row_scan[] = { - CR08, 0, 8, - VGA_REG_END -}; - -VgaReg s3_max_scan_line[] = { - CR09, 0, 5, - VGA_REG_END -}; - -VgaReg s3_start_address[] = { - CR0D, 0, 8, - CR0C, 0, 8, - CR69, 0, 7, - VGA_REG_END -}; - -VgaReg s3_v_retrace_start[] = { - CR10, 0, 8, - CR07, 2, 1, - CR07, 7, 1, - CR5E, 4, 1, - VGA_REG_END -}; - -VgaReg s3_v_retrace_end[] = { - CR11, 0, 4, - VGA_REG_END -}; - -VgaReg s3_clear_v_retrace_int[] = { - CR11, 4, 1, - VGA_REG_END -}; - -VgaReg s3_disable_v_retrace_int[] = { - CR11, 5, 1, - VGA_REG_END -}; - -VgaReg s3_lock_crtc[] = { - CR11, 7, 1, - VGA_REG_END -}; - -VgaReg s3_v_display_end[] = { - CR12, 0, 8, - CR07, 1, 1, - CR07, 6, 1, - CR5E, 1, 1, - VGA_REG_END -}; - -VgaReg s3_screen_offset[] = { - CR13, 0, 8, - CR51, 4, 2, - VGA_REG_END -}; - -VgaReg s3_count_by_4_mode[] = { - CR14, 5, 1, - VGA_REG_END -}; - -VgaReg s3_doubleword_mode[] = { - CR14, 6, 1, - VGA_REG_END -}; - -VgaReg s3_v_blank_start[] = { - CR15, 0, 8, - CR07, 3, 1, - CR09, 5, 1, - CR5E, 2, 1, - VGA_REG_END -}; - -VgaReg s3_v_blank_end[] = { - CR16, 0, 8, - VGA_REG_END -}; - -VgaReg s3_2bk_cga[] = { - CR17, 0, 1, - VGA_REG_END -}; - -VgaReg s3_4bk_hga[] = { - CR17, 1, 1, - VGA_REG_END -}; - -VgaReg s3_v_total_double[] = { - CR17, 2, 1, - VGA_REG_END -}; - -VgaReg s3_word_mode[] = { - CR17, 3, 1, - VGA_REG_END -}; - -VgaReg s3_address_16k_wrap[] = { - CR17, 5, 1, - VGA_REG_END -}; - -VgaReg s3_byte_mode[] = { - CR17, 6, 1, - VGA_REG_END -}; - -VgaReg s3_hardware_reset[] = { - CR17, 7, 1, - VGA_REG_END -}; - -VgaReg s3_line_compare[] = { - CR18, 0, 8, - CR07, 4, 1, - CR09, 6, 1, - CR5E, 6, 1, - VGA_REG_END -}; - -VgaReg s3_delay_primary_load[] = { - CR21, 1, 1, - VGA_REG_END -}; - -VgaReg s3_device_id[] = { - CR2E, 0, 8, - CR2D, 0, 8, - VGA_REG_END -}; - -VgaReg s3_revision[] = { - CR2F, 0, 8, - VGA_REG_END -}; - -VgaReg s3_enable_vga_16bit[] = { - CR31, 2, 1, - VGA_REG_END -}; - -VgaReg s3_enhanced_memory_mapping[] = { - CR31, 3, 1, - VGA_REG_END -}; - -VgaReg s3_lock_dac_writes[] = { - CR33, 4, 1, - VGA_REG_END -}; - -VgaReg s3_border_select[] = { - CR33, 5, 1, - VGA_REG_END -}; - -VgaReg s3_lock_palette[] = { - CR33, 6, 1, - VGA_REG_END -}; - -VgaReg s3_enable_sff[] = { - CR34, 4, 1, - VGA_REG_END -}; - -VgaReg s3_lock_vert[] = { - CR35, 4, 1, - VGA_REG_END -}; - -VgaReg s3_lock_horz[] = { - CR35, 5, 1, - VGA_REG_END -}; - -VgaReg s3_io_disable[] = { - CR36, 4, 1, - VGA_REG_END -}; - -VgaReg s3_mem_size[] = { - CR36, 5, 3, - VGA_REG_END -}; - -VgaReg s3_register_lock_1 [] = { - CR38, 0, 8, /* load with 0x48 */ - VGA_REG_END -}; - -VgaReg s3_register_lock_2 [] = { - CR39, 0, 8, /* load with 0xa0 */ - VGA_REG_END -}; - -VgaReg s3_refresh_control[] = { - CR3A, 0, 2, - VGA_REG_END -}; - -VgaReg s3_enable_256[] = { - CR3A, 4, 1, - VGA_REG_END -}; - -VgaReg s3_disable_pci_read_bursts[] = { - CR3A, 7, 1, - VGA_REG_END -}; - -VgaReg s3_h_start_fifo_fetch[] = { - CR3B, 0, 8, - CR5D, 6, 1, - CR5B, 2, 2, - VGA_REG_END -}; - -VgaReg s3_enable_2d_access[] = { - CR40, 0, 1, - VGA_REG_END -}; - -VgaReg s3_interlace[] = { - CR42, 5, 1, - VGA_REG_END -}; - -VgaReg s3_old_screen_off_8[] = { - CR43, 2, 1, - VGA_REG_END -}; - -VgaReg s3_h_counter_double_mode[] = { - CR43, 7, 1, - VGA_REG_END -}; - -VgaReg s3_cursor_enable[] = { - CR45, 0, 1, - VGA_REG_END -}; - -VgaReg s3_cursor_right[] = { - CR45, 4, 1, - VGA_REG_END -}; - -VgaReg s3_cursor_xhigh[] = { - CR46, 0, 3, - VGA_REG_END -}; - -VgaReg s3_cursor_xlow[] = { - CR47, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cursor_yhigh[] = { - CR48, 0, 3, - VGA_REG_END -}; - -VgaReg s3_cursor_ylow[] = { - CR49, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cursor_fg[] = { - CR4A, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cursor_bg[] = { - CR4B, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cursor_address[] = { - CR4D, 0, 8, - CR4C, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cursor_xoff[] = { - CR4E, 0, 6, - VGA_REG_END -}; - -VgaReg s3_cursor_yoff[] = { - CR4F, 0, 6, - VGA_REG_END -}; - -VgaReg s3_ge_screen_width[] = { - CR50, 6, 2, - CR50, 0, 1, - VGA_REG_END -}; - -VgaReg s3_pixel_length[] = { - CR50, 4, 2, - VGA_REG_END -}; - -VgaReg s3_big_endian_linear[] = { - CR53, 1, 2, - VGA_REG_END -}; - -VgaReg s3_mmio_select[] = { - CR53, 3, 2, - VGA_REG_END -}; - -VgaReg s3_mmio_window[] = { - CR53, 5, 1, - VGA_REG_END -}; - -VgaReg s3_swap_nibbles[] = { - CR53, 6, 1, - VGA_REG_END -}; - -VgaReg s3_cursor_ms_x11[] = { - CR55, 4, 1, - VGA_REG_END -}; - -VgaReg s3_linear_window_size[] = { - CR58, 0, 2, - VGA_REG_END -}; - -VgaReg s3_enable_linear[] = { - CR58, 4, 1, - VGA_REG_END -}; - -VgaReg s3_h_blank_extend[] = { - CR5D, 3, 1, - VGA_REG_END -}; - -VgaReg s3_h_sync_extend[] = { - CR5D, 5, 1, - VGA_REG_END -}; - -VgaReg s3_sdclk_skew[] = { - CR60, 0, 4, - VGA_REG_END -}; - -VgaReg s3_delay_blank[] = { - CR65, 3, 2, - VGA_REG_END -}; - -VgaReg s3_delay_h_enable[] = { - CR65, 6, 2, - CR65, 0, 1, - VGA_REG_END -}; - -VgaReg s3_enable_2d_3d[] = { - CR66, 0, 1, - VGA_REG_END -}; - -VgaReg s3_pci_disconnect_enable[] = { - CR66, 3, 1, - VGA_REG_END -}; - -VgaReg s3_primary_load_control[] = { - CR66, 4, 1, - VGA_REG_END -}; - -VgaReg s3_secondary_load_control[] = { - CR66, 5, 1, - VGA_REG_END -}; - -VgaReg s3_pci_retry_enable[] = { - CR66, 7, 1, - VGA_REG_END -}; - -VgaReg s3_streams_mode[] = { - CR67, 2, 2, - VGA_REG_END -}; - -VgaReg s3_color_mode[] = { - CR67, 4, 4, - VGA_REG_END -}; - -VgaReg s3_primary_stream_definition[] = { - CR69, 7, 1, - VGA_REG_END -}; - -VgaReg s3_primary_stream_timeout[] = { - CR71, 0, 8, - VGA_REG_END -}; - -VgaReg s3_master_control_unit_timeout[] = { - CR74, 0, 8, - VGA_REG_END -}; - -VgaReg s3_command_buffer_timeout[] = { - CR75, 0, 8, - VGA_REG_END -}; - -VgaReg s3_lpb_timeout[] = { - CR76, 0, 8, - VGA_REG_END -}; - -VgaReg s3_cpu_timeout[] = { - CR78, 0, 8, - VGA_REG_END -}; - -VgaReg s3_2d_graphics_engine_timeout[] = { - CR79, 0, 8, - VGA_REG_END -}; - -VgaReg s3_fifo_drain_delay[] = { - CR85, 0, 3, - VGA_REG_END -}; - -VgaReg s3_fifo_fetch_timing[] = { - CR85, 4, 1, - VGA_REG_END -}; - -VgaReg s3_dac_power_up_time[] = { - CR86, 0, 7, - VGA_REG_END -}; - -VgaReg s3_dac_power_saving_disable[] = { - CR86, 7, 1, - VGA_REG_END -}; - -VgaReg s3_flat_panel_output_control_1[] = { - CR90, 3, 1, - VGA_REG_END -}; - -VgaReg s3_streams_fifo_delay[] = { - CR90, 4, 2, - VGA_REG_END -}; - -VgaReg s3_flat_panel_output_control_2[] = { - CR90, 6, 1, - VGA_REG_END -}; - -VgaReg s3_enable_l1_parameter[] = { - CR90, 7, 1, - VGA_REG_END -}; - -VgaReg s3_primary_stream_l1[] = { - CR91, 0, 8, - CR90, 0, 3, - VGA_REG_END -}; - -#define CR_LAST CR91 - -#define SR00 S3_SR+0x00 -#define SR01 S3_SR+0x01 -#define SR02 S3_SR+0x02 -#define SR03 S3_SR+0x03 -#define SR04 S3_SR+0x04 -#define SR05 S3_SR+0x05 -#define SR06 S3_SR+0x06 -#define SR07 S3_SR+0x07 -#define SR08 S3_SR+0x08 -#define SR09 S3_SR+0x09 -#define SR0A S3_SR+0x0A -#define SR0B S3_SR+0x0B -#define SR0C S3_SR+0x0C -#define SR0D S3_SR+0x0D -#define SR0E S3_SR+0x0E -#define SR0F S3_SR+0x0F -#define SR10 S3_SR+0x10 -#define SR11 S3_SR+0x11 -#define SR12 S3_SR+0x12 -#define SR13 S3_SR+0x13 -#define SR14 S3_SR+0x14 -#define SR15 S3_SR+0x15 -#define SR16 S3_SR+0x16 -#define SR17 S3_SR+0x17 -#define SR18 S3_SR+0x18 -#define SR19 S3_SR+0x19 -#define SR1A S3_SR+0x1A -#define SR1B S3_SR+0x1B -#define SR1C S3_SR+0x1C -#define SR1D S3_SR+0x1D -#define SR1E S3_SR+0x1E -#define SR1F S3_SR+0x1F -#define SR20 S3_SR+0x20 -#define SR21 S3_SR+0x21 -#define SR22 S3_SR+0x22 -#define SR23 S3_SR+0x23 -#define SR24 S3_SR+0x24 -#define SR25 S3_SR+0x25 -#define SR26 S3_SR+0x26 -#define SR27 S3_SR+0x27 -#define SR28 S3_SR+0x28 -#define SR29 S3_SR+0x29 -#define SR2A S3_SR+0x2A -#define SR2B S3_SR+0x2B -#define SR2C S3_SR+0x2C -#define SR2D S3_SR+0x2D -#define SR2E S3_SR+0x2E -#define SR2F S3_SR+0x2F -#define SR30 S3_SR+0x30 -#define SR31 S3_SR+0x31 -#define SR32 S3_SR+0x32 -#define SR33 S3_SR+0x33 -#define SR34 S3_SR+0x34 -#define SR35 S3_SR+0x35 -#define SR36 S3_SR+0x36 -#define SR37 S3_SR+0x37 -#define SR38 S3_SR+0x38 -#define SR39 S3_SR+0x39 -#define SR3A S3_SR+0x3A -#define SR3B S3_SR+0x3B -#define SR3C S3_SR+0x3C -#define SR3D S3_SR+0x3D -#define SR3E S3_SR+0x3E -#define SR3F S3_SR+0x3F -#define SR40 S3_SR+0x40 -#define SR41 S3_SR+0x41 -#define SR42 S3_SR+0x42 -#define SR43 S3_SR+0x43 -#define SR44 S3_SR+0x44 -#define SR45 S3_SR+0x45 -#define SR46 S3_SR+0x46 -#define SR47 S3_SR+0x47 -#define SR48 S3_SR+0x48 -#define SR49 S3_SR+0x49 -#define SR4A S3_SR+0x4A -#define SR4B S3_SR+0x4B -#define SR4C S3_SR+0x4C -#define SR4D S3_SR+0x4D -#define SR4E S3_SR+0x4E -#define SR4F S3_SR+0x4F -#define SR50 S3_SR+0x50 -#define SR51 S3_SR+0x51 -#define SR52 S3_SR+0x52 -#define SR53 S3_SR+0x53 -#define SR54 S3_SR+0x54 -#define SR55 S3_SR+0x55 -#define SR56 S3_SR+0x56 -#define SR57 S3_SR+0x57 -#define SR58 S3_SR+0x58 -#define SR59 S3_SR+0x59 -#define SR5A S3_SR+0x5A -#define SR5B S3_SR+0x5B -#define SR5C S3_SR+0x5C -#define SR5D S3_SR+0x5D -#define SR5E S3_SR+0x5E -#define SR5F S3_SR+0x5F -#define SR60 S3_SR+0x60 -#define SR61 S3_SR+0x61 -#define SR62 S3_SR+0x62 -#define SR63 S3_SR+0x63 -#define SR64 S3_SR+0x64 -#define SR65 S3_SR+0x65 -#define SR66 S3_SR+0x66 -#define SR67 S3_SR+0x67 -#define SR68 S3_SR+0x68 -#define SR69 S3_SR+0x69 -#define SR6A S3_SR+0x6A -#define SR6B S3_SR+0x6B -#define SR6C S3_SR+0x6C -#define SR6D S3_SR+0x6D -#define SR6E S3_SR+0x6E -#define SR6F S3_SR+0x6F - -#define SR_FIRST SR02 - -VgaReg s3_dot_clock_8[] = { - SR01, 0, 1, - VGA_REG_END -}; - -VgaReg s3_screen_off[] = { - SR01, 5, 1, - VGA_REG_END -}; - -VgaReg s3_enable_write_plane[] = { - SR02, 0, 4, - VGA_REG_END -}; - -VgaReg s3_extended_memory_access[] = { - SR04, 1, 1, - VGA_REG_END -}; - -VgaReg s3_sequential_addressing_mode[] = { - SR04, 2, 1, - VGA_REG_END -}; - -VgaReg s3_select_chain_4_mode[] = { - SR04, 3, 1, - VGA_REG_END -}; - -VgaReg s3_unlock_extended_sequencer[] = { - SR08, 0, 8, /* write 0x06 */ - VGA_REG_END -}; - -VgaReg s3_linear_addressing_control[] = { - SR09, 0, 1, - VGA_REG_END -}; - -VgaReg s3_disable_io_ports[] = { - SR09, 7, 1, - VGA_REG_END -}; - -VgaReg s3_hsync_control[] = { - SR0D, 4, 2, - VGA_REG_END -}; - -VgaReg s3_vsync_control[] = { - SR0D, 6, 2, - VGA_REG_END -}; - -VgaReg s3_mclk_n[] = { - SR10, 0, 5, - VGA_REG_END -}; - -VgaReg s3_mclk_r[] = { - SR10, 5, 2, - VGA_REG_END -}; - -VgaReg s3_mclk_m[] = { - SR11, 0, 7, - VGA_REG_END -}; - -VgaReg s3_dclk_n[] = { - SR12, 0, 6, - SR29, 4, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_r[] = { - SR12, 6, 2, - SR29, 2, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_m[] = { - SR13, 0, 8, - SR29, 3, 1, - VGA_REG_END -}; - -VgaReg s3_mclk_load[] = { - SR15, 0, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_load[] = { - SR15, 1, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_over_2[] = { - SR15, 4, 1, - VGA_REG_END -}; - -VgaReg s3_clock_load_imm[] = { - SR15, 5, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_invert[] = { - SR15, 6, 1, - VGA_REG_END -}; - -VgaReg s3_enable_clock_double[] = { - SR18, 7, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_double_15_16_invert[] = { - SR1A, 0, 1, - VGA_REG_END -}; - -VgaReg s3_enable_gamma_correction[] = { - SR1B, 3, 1, - VGA_REG_END -}; - -VgaReg s3_enable_8_bit_luts[] = { - SR1B, 4, 1, - VGA_REG_END -}; - -VgaReg s3_dclk_control[] = { - SR1B, 7, 1, - VGA_REG_END -}; - -VgaReg s3_eclk_n[] = { - SR32, 0, 5, - VGA_REG_END -}; - -VgaReg s3_eclk_r[] = { - SR32, 5, 2, - VGA_REG_END -}; - -VgaReg s3_eclk_m[] = { - SR32, 0, 5, - VGA_REG_END -}; - -VgaReg s3_vga_dclk_n[] = { - SR36, 0, 6, - SR39, 4, 1, - VGA_REG_END -}; - -VgaReg s3_vga_dclk_r[] = { - SR36, 6, 2, - SR39, 2, 1, - VGA_REG_END -}; - -VgaReg s3_vga_dclk_m1[] = { - SR37, 0, 8, - SR39, 3, 1, - VGA_REG_END -}; - -VgaReg s3_vga_dclk_m2[] = { - SR38, 0, 8, - SR39, 3, 1, - VGA_REG_END -}; - -VgaReg s3_vga_clk_select[] = { - SR39, 0, 1, - VGA_REG_END -}; - -#define SR_LAST SR39 - -#define AR00 (S3_AR+0x00) -#define AR10 (S3_AR+0x10) -#define AR11 (S3_AR+0x11) -#define AR12 (S3_AR+0x12) -#define AR13 (S3_AR+0x13) -#define AR14 (S3_AR+0x14) - -#define AR_FIRST AR00 - -VgaReg s3_select_graphics_mode[] = { - AR10, 0, 1, - VGA_REG_END -}; - -VgaReg s3_enable_blinking[] = { - AR10, 3, 1, - VGA_REG_END -}; - -VgaReg s3_border_color[] = { - AR11, 0, 8, - VGA_REG_END -}; - -#define AR_LAST AR11 - -VgaReg s3_io_addr_select[] = { - S3_MISC_OUT, 0, 1, - VGA_REG_END -}; - -VgaReg s3_enable_ram[] = { - S3_MISC_OUT, 1, 1, - VGA_REG_END -}; - -VgaReg s3_clock_select[] = { - S3_MISC_OUT, 2, 2, - VGA_REG_END -}; - -VgaReg s3_horz_sync_neg[] = { - S3_MISC_OUT, 6, 1, - VGA_REG_END -}; - -VgaReg s3_vert_sync_neg[] = { - S3_MISC_OUT, 7, 1, - VGA_REG_END -}; - -VgaReg s3_display_mode_inactive[] = { - S3_INPUT_STATUS_1, 0, 1, - VGA_REG_END -}; - -VgaReg s3_vertical_sync_active[] = { - S3_INPUT_STATUS_1, 3, 1, - VGA_REG_END -}; - -VgaReg s3_dac_mask[] = { - S3_DAC + 0, 0, 8, - VGA_REG_END -}; - -VgaReg s3_dac_read_index[] = { - S3_DAC + 1, 0, 8, - VGA_REG_END -}; - -VgaReg s3_dac_write_index[] = { - S3_DAC + 2, 0, 8, - VGA_REG_END -}; - -VgaReg s3_dac_data[] = { - S3_DAC + 3, 0, 8, - VGA_REG_END -}; - -VGA8 -_s3Inb (VgaCard *card, VGA16 port) -{ - VGAVOL8 *reg; - - if (card->closure) - return VgaReadMemb ((VGA32) card->closure + port); - else - return VgaInb (port); -} - -void -_s3Outb (VgaCard *card, VGA8 value, VGA16 port) -{ - if (card->closure) - VgaWriteMemb (value, (VGA32) card->closure + port); - else - VgaOutb (value, port); -} - -void -_s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write) -{ - - if (reg < S3_SR + S3_NSR) - { - map->access = VgaAccessIndIo; - map->port = 0x3c4; - map->addr = 0; - map->value = 1; - map->index = reg - S3_SR; - } - else if (reg < S3_GR + S3_NGR) - { - map->access = VgaAccessIndIo; - map->port = 0x3ce; - map->addr = 0; - map->value = 1; - map->index = reg - S3_GR; - } - else if (reg < S3_AR + S3_NAR) - { - reg -= S3_AR; - map->access = VgaAccessDone; - /* reset AFF to index */ - (void) _s3Inb (card, 0x3da); - if (reg >= 16) - reg |= 0x20; - _s3Outb (card, reg, 0x3c0); - if (write) - _s3Outb (card, map->value, 0x3c0); - else - map->value = _s3Inb (card, 0x3c1); - if (!(reg & 0x20)) - { - /* enable video display again */ - (void) _s3Inb (card, 0x3da); - _s3Outb (card, 0x20, 0x3c0); - } - return; - } - else if (reg < S3_CR + S3_NCR) - { - map->access = VgaAccessIndIo; - map->port = 0x3d4; - map->addr = 0; - map->value = 1; - map->index = reg - S3_CR; - } - else if (reg < S3_DAC + S3_NDAC) - { - map->access = VgaAccessIo; - map->port = 0x3c6 + reg - S3_DAC; - } - else switch (reg) { - case S3_MISC_OUT: - map->access = VgaAccessIo; - if (write) - map->port = 0x3c2; - else - map->port = 0x3cc; - break; - case S3_INPUT_STATUS_1: - map->access = VgaAccessIo; - map->port = 0x3da; - break; - } - if (card->closure) - { - map->port = map->port + (VGA32) card->closure; - if (map->access == VgaAccessIo) - map->access = VgaAccessMem; - if (map->access == VgaAccessIndIo) - map->access = VgaAccessIndMem; - } -} - -VgaSave s3Saves[] = { - CR_FIRST, CR18, - CR31, CR_LAST, - SR_FIRST, SR15, - SR18, SR_LAST, - AR_FIRST, AR_LAST, - S3_MISC_OUT, S3_MISC_OUT, - VGA_SAVE_END -}; - -void -s3RegInit (S3Vga *s3vga, VGAVOL8 *mmio) -{ - s3vga->card.map = _s3RegMap; - s3vga->card.closure = (void *) mmio; - s3vga->card.max = S3_NREG; - s3vga->card.values = s3vga->values; - s3vga->card.saves = s3Saves; -} - -void -s3Save (S3Vga *s3vga) -{ - s3vga->save_lock_crtc = s3Get(s3vga, s3_lock_crtc); - s3SetImm (s3vga, s3_lock_crtc, 0); - s3vga->save_register_lock_1 = s3Get (s3vga, s3_register_lock_1); - s3SetImm (s3vga, s3_register_lock_1, 0x48); - s3vga->save_register_lock_2 = s3Get (s3vga, s3_register_lock_2); - s3SetImm (s3vga, s3_register_lock_2, 0xa5); - s3vga->save_unlock_extended_sequencer = s3Get (s3vga, s3_unlock_extended_sequencer); - s3SetImm (s3vga, s3_unlock_extended_sequencer, 0x06); - s3vga->save_lock_horz = s3Get (s3vga, s3_lock_horz); - s3SetImm (s3vga, s3_lock_horz, 0); - s3vga->save_lock_vert = s3Get (s3vga, s3_lock_vert); - s3SetImm (s3vga, s3_lock_vert, 0); - s3vga->save_dot_clock_8 = s3Get (s3vga, s3_dot_clock_8); - VgaPreserve (&s3vga->card); -} - -void -s3Reset (S3Vga *s3vga) -{ - VgaRestore (&s3vga->card); - s3SetImm (s3vga, s3_clock_load_imm, 1); - s3SetImm (s3vga, s3_clock_load_imm, 0); - s3SetImm (s3vga, s3_dot_clock_8, s3vga->save_dot_clock_8); - s3SetImm (s3vga, s3_lock_vert, s3vga->save_lock_vert); - s3SetImm (s3vga, s3_lock_horz, s3vga->save_lock_horz); - s3SetImm (s3vga, s3_lock_dac_writes, s3vga->save_lock_dac_writes); - s3SetImm (s3vga, s3_unlock_extended_sequencer, s3vga->save_unlock_extended_sequencer); - s3SetImm (s3vga, s3_register_lock_2, s3vga->save_register_lock_2); - s3SetImm (s3vga, s3_register_lock_1, s3vga->save_register_lock_1); - s3SetImm (s3vga, s3_lock_crtc, s3vga->save_lock_crtc); - VgaFinish (&s3vga->card); -} diff --git a/hw/kdrive/savage/s3reg.h b/hw/kdrive/savage/s3reg.h deleted file mode 100644 index 9b3c5447b..000000000 --- a/hw/kdrive/savage/s3reg.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Id: s3reg.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3reg.h,v 1.3 2000/02/23 20:30:05 dawes Exp $ */ - -#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_DAC (S3_CR+S3_NCR) -#define S3_NDAC 4 -#define S3_MISC_OUT (S3_DAC + S3_NDAC) -#define S3_INPUT_STATUS_1 (S3_MISC_OUT+1) -#define S3_NREG (S3_INPUT_STATUS_1+1) - -extern VgaReg s3_h_total[]; -extern VgaReg s3_h_display_end[]; -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_2bk_cga[]; -extern VgaReg s3_4bk_hga[]; -extern VgaReg s3_v_total_double[]; -extern VgaReg s3_address_16k_wrap[]; -extern VgaReg s3_word_mode[]; -extern VgaReg s3_byte_mode[]; -extern VgaReg s3_hardware_reset[]; -extern VgaReg s3_line_compare[]; -extern VgaReg s3_delay_primary_load[]; -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_palette[]; -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_primary_load_control[]; -extern VgaReg s3_secondary_load_control[]; -extern VgaReg s3_pci_retry_enable[]; -extern VgaReg s3_streams_mode[]; -extern VgaReg s3_color_mode[]; -extern VgaReg s3_primary_stream_definition[]; -extern VgaReg s3_primary_stream_timeout[]; -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_dac_power_up_time[]; -extern VgaReg s3_dac_power_saving_disable[]; -extern VgaReg s3_flat_panel_output_control_1[]; -extern VgaReg s3_streams_fifo_delay[]; -extern VgaReg s3_flat_panel_output_control_2[]; -extern VgaReg s3_enable_l1_parameter[]; -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_eclk_n[]; -extern VgaReg s3_eclk_r[]; -extern VgaReg s3_eclk_m[]; -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_border_color[]; - -extern VgaReg s3_io_addr_select[]; -extern VgaReg s3_enable_ram[]; -extern VgaReg s3_clock_select[]; -extern VgaReg s3_horz_sync_neg[]; -extern VgaReg s3_vert_sync_neg[]; - -extern VgaReg s3_display_mode_inactive[]; -extern VgaReg s3_vertical_sync_active[]; - -extern VgaReg s3_dac_mask[]; -extern VgaReg s3_dac_read_index[]; -extern VgaReg s3_dac_write_index[]; -extern VgaReg s3_dac_data[]; - -#define s3Get(sv,r) VgaGet(&(sv)->card, (r)) -#define s3GetImm(sv,r) VgaGetImm(&(sv)->card, (r)) -#define s3Set(sv,r,v) VgaSet(&(sv)->card, (r), (v)) -#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_ */ diff --git a/hw/kdrive/savage/s3rtst.c b/hw/kdrive/savage/s3rtst.c deleted file mode 100644 index c88e34585..000000000 --- a/hw/kdrive/savage/s3rtst.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Id: s3rtst.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3rtst.c,v 1.1 1999/11/19 13:53:57 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 (); -} diff --git a/hw/kdrive/savage/s3stub.c b/hw/kdrive/savage/s3stub.c deleted file mode 100644 index d5c55d598..000000000 --- a/hw/kdrive/savage/s3stub.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Id: s3stub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/savage/s3stub.c,v 1.3 2000/02/23 20:30:05 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; -#ifdef VXWORKS - attr.naddr = 2; - attr.io = 0; - attr.address[0] = 0xbc000000; /* registers */ - attr.address[1] = 0xba000000; /* frame buffer */ - KdCardInfoAdd (&s3Funcs, &attr, 0); -#else - CARD32 count; - - count = 0; - while (LinuxFindPci (0x5333, 0x8a22, count, &attr)) - { - KdCardInfoAdd (&s3Funcs, &attr, 0); - count++; - } -#endif -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ -#ifdef VXWORKS - KdInitInput (&VxWorksMouseFuncs, &VxWorksKeyboardFuncs); -#endif -#ifdef linux - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -#endif -} - -extern int s3CpuTimeout; -extern int s3AccelTimeout; - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!strcmp (argv[i], "-cpu")) - { - s3CpuTimeout = strtol(argv[i+1], NULL, 0); - return 2; - } - if (!strcmp (argv[i], "-accel")) - { - s3AccelTimeout = strtol (argv[i+1], NULL, 0); - return 2; - } - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/sis530/Imakefile b/hw/kdrive/sis530/Imakefile deleted file mode 100644 index 08ac126cc..000000000 --- a/hw/kdrive/sis530/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $ -KDRIVE=.. -#include "../Kdrive.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. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(sis530,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/sis530/sis.c b/hw/kdrive/sis530/sis.c deleted file mode 100644 index b2a95326e..000000000 --- a/hw/kdrive/sis530/sis.c +++ /dev/null @@ -1,924 +0,0 @@ -/* - * Id: sis.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sis.c,v 1.4 2000/05/06 22:17:49 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "sis.h" - -#define MAX_FB_SIZE (4096 * 1024) - -#define MMIO_SIZE (64 * 1024) - -int sisMemoryTable[8] = { - 1, 2, 4, 0, 0, 2, 4, 8 -}; - -Bool -sisCardInit (KdCardInfo *card) -{ - SisCardInfo *sisc; - SisPtr sis; - int size; - CARD8 *registers; - CARD8 *temp_buffer; - CARD8 save_sr5; - - sisc = (SisCardInfo *) xalloc (sizeof (SisCardInfo)); - if (!sisc) - goto bail0; - - sisc->io_base = card->attr.io; - /* - * enable access to SiS ports (no MMIO available) - */ - iopl(3); - save_sr5 = GetSrtc(sisc,0x5); - if (save_sr5 != 0x21) - save_sr5 = 0x86; - PutSrtc(sisc,0x5,0x86); -#if 0 - { - int i; - - for (i = 0; i <= 0x3f; i++) - fprintf (stderr, "SR%02x = %02x\n", i, GetSrtc(sisc,i)); - } -#endif - sisc->memory = sisMemoryTable[GetSrtc(sisc,0xc)&0x7] * 1024 * 1024; - - PutSrtc(sisc,0x5,save_sr5); - - 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; - - card->driver = sisc; - - return TRUE; -bail2: - KdUnmapDevice (sisc->frameBuffer, sisc->memory); -bail1: - xfree (sisc); -bail0: - return FALSE; -} - -Bool -sisModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t) -{ - if (t->horizontal != 1600 && - t->horizontal != 1280 && - t->horizontal != 1152 && - t->horizontal != 1024 && - t->horizontal != 800 && - t->horizontal != 640) - return FALSE; - return TRUE; -} - -Bool -sisModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - SisCardInfo *sisc = (SisCardInfo *) card->driver; - SisScreenInfo *siss; - int i; - KdMonitorTiming *t; - CARD32 memory; - int byte_width, pixel_width, screen_size; - - if (screen->fb[0].depth >= 24) - { - screen->fb[0].depth = 24; - screen->fb[0].bitsPerPixel = 24; - screen->dumb = TRUE; - } - else if (screen->fb[0].depth >= 16) - { - screen->fb[0].depth = 16; - screen->fb[0].bitsPerPixel = 16; - } - else if (screen->fb[0].depth >= 15) - { - screen->fb[0].depth = 15; - screen->fb[0].bitsPerPixel = 16; - } - else - { - screen->fb[0].depth = 8; - screen->fb[0].bitsPerPixel = 8; - } - byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3); - pixel_width = screen->width; - screen->fb[0].pixelStride = pixel_width; - screen->fb[0].byteStride = byte_width; - - screen_size = byte_width * screen->height; - - return screen_size <= sisc->memory; -} - -Bool -sisScreenInit (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - SisCardInfo *sisc = (SisCardInfo *) card->driver; - SisScreenInfo *siss; - int i; - const KdMonitorTiming *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->fb[0].depth) - screen->fb[0].depth = 8; - - t = KdFindMode (screen, sisModeSupported); - - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - - if (!KdTuneMode (screen, sisModeUsable, sisModeSupported)) - { - xfree (sisc); - return FALSE; - } - - memory = sisc->memory - screen_size; - - screen->fb[0].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->fb[0].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->fb[0].depth) { - case 8: - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case 15: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x03e0; - screen->fb[0].redMask = 0x7c00; - break; - case 16: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x07e0; - screen->fb[0].redMask = 0xf800; - break; - case 24: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x0000ff; - screen->fb[0].greenMask = 0x00ff00; - screen->fb[0].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->cursor_start = GetCrtc (sisc, 0x0a); - crtc->cursor_end = GetCrtc (sisc, 0x0a); - crtc->start_address_8_15 = GetCrtc (sisc, 0x0c); - crtc->start_address_0_7 = GetCrtc (sisc, 0x0d); - crtc->text_cursor_15_8 = GetCrtc (sisc, 0x0e); - crtc->text_cursor_7_0 = GetCrtc (sisc, 0x0f); - 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->misc_register = GetGrtc (sisc, 0x6); - crtc->color_dont_care = GetGrtc (sisc, 0x7); - - crtc->clock_mode = GetSrtc (sisc, 0x1); - crtc->color_plane_w_enable = GetSrtc (sisc, 0x2); - crtc->memory_mode = GetSrtc (sisc, 0x4); - - 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) -{ - _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, 0x0a, crtc->cursor_start); - PutCrtc (sisc, 0x0b, crtc->cursor_end); - PutCrtc (sisc, 0x0c, crtc->start_address_8_15); - PutCrtc (sisc, 0x0d, crtc->start_address_0_7); - PutCrtc (sisc, 0x0e, crtc->text_cursor_15_8); - PutCrtc (sisc, 0x0f, crtc->text_cursor_7_0); - 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); - PutGrtc (sisc, 0x6, crtc->misc_register); - PutGrtc (sisc, 0x7, crtc->color_dont_care); - - PutSrtc (sisc, 0x1, crtc->clock_mode | 0x20); - PutSrtc (sisc, 0x2, crtc->color_plane_w_enable); - PutSrtc (sisc, 0x4, crtc->memory_mode); - - 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); - -#if 0 - PutCrtc (sisc, 0x5b, 0x27); - PutCrtc (sisc, 0x5c, 0xe1); - PutCrtc (sisc, 0x5d, 0x00); - - PutSrtc (sisc, 0x5a, 0xe6); - PutSrtc (sisc, 0x5d, 0xa1); - PutSrtc (sisc, 0x9a, 0xe6); - PutSrtc (sisc, 0x9d, 0xa1); - PutSrtc (sisc, 0xda, 0xe6); - PutSrtc (sisc, 0xdd, 0x6c); -#endif - - _sisOutb(crtc->misc_output, sisc->io_base+0x42); - - outw (0x3c4, 0x0100); - outw (0x3c4, 0x0300); - - _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); -} - -CARD8 -_sisReadArtc (CARD32 base, CARD8 index) -{ - CARD8 ret; - - _sisInb (base+0x1a); - _sisOutb (index,base); - ret = _sisInb (base+1); - _sisInb (base+0x1a); - _sisOutb (0x20,base); - return ret; -} - -void -_sisWriteArtc (CARD32 base, CARD8 index, CARD8 value) -{ - _sisInb (base+0x1a); - _sisOutb (index|0x20,base); - _sisOutb (value,base); - _sisInb (base+0x1a); - _sisOutb (0x20,base); -} - -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); - /* unlock CRTC registers */ - PutCrtc(sisc,0x11,GetCrtc(sisc,0x11)&~0x80); - /* enable vga */ - _sisOutb(0x1,sisc->io_base+0x43); - - /* enable MMIO access to registers */ - sisc->save.srb = GetSrtc(sisc,0xb); - PutSrtc(sisc, 0xb, sisc->save.srb | 0x60); - _sisGetCrtc (sisc, &sisc->save.crtc); - memcpy (sisc->save.text_save, sisc->frameBuffer, SIS_TEXT_SAVE); -} - -Bool -sisEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - SisCardInfo *sisc = card->driver; - SisScreenInfo *siss = screen->driver; - const KdMonitorTiming *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 = KdFindMode (screen, sisModeSupported); - - /* CR9 */ - crtc.max_scan_line = 0; - - /* CRA */ - crtc.cursor_start = 0; - - /* CRB */ - crtc.cursor_end = 0; - - /* CRE */ - crtc.text_cursor_15_8 = 0; - - /* CRF */ - crtc.text_cursor_7_0 = 0; - - /* CR11 */ - crtc.disable_v_retrace_int = 1; - - /* CR14 */ - crtc.underline_location = 0; - crtc.count_by_four = 0; - crtc.doubleword_mode = 1; - - /* 3CC/3C2 */ - crtc.io_address_select = 1; - crtc.display_ram_enable = 1; - crtc.clock_select = 3; - - /* SR1 */ - crtc.clock_mode = 0; - crtc.dot_clock_8_9 = 1; - - /* SR2 */ - crtc.color_plane_w_enable = 0xf; - - /* SR4 */ - crtc.memory_mode = 0; - crtc.chain_4_enable = 1; - crtc.odd_even_disable = 1; - crtc.extended_memory_sz = 1; - - /* SR6 */ - crtc.graphics_mode_linear = 1; - crtc.enhanced_graphics_mode = 1; - - /* SR9 */ - crtc.crt_cpu_threshold_control_1 = 0; - - /* SRB */ -#if 0 - crtc.cpu_bitblt_enable = 1; -#endif - crtc.memory_mapped_mode = 3; - - /* SRC */ - crtc.graphics_mode_32bit_enable = 1; - 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; - - crtc.cursor_0_red = 0x3f; - crtc.cursor_0_green = 0x3f; - crtc.cursor_0_blue = 0x3f; - - /* SR20 */ - crtc.linear_base_19_26 = (card->attr.address[0] & 0x07f80000) >> 19; - - /* SR21 */ - crtc.linear_base_27_31 = (card->attr.address[0] & 0xf8000000) >> 27; - crtc.linear_aperture = SIS_LINEAR_APERTURE_4M; - - /* SR27 */ - crtc.logical_screen_width = 3; - crtc.graphics_prog_enable = 1; - - /* SR38 */ - crtc.extended_clock_select = 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; - - /* GR5 */ - crtc.mode_register = 0; - - /* GR6 */ - crtc.graphics_enable = 1; - crtc.chain_odd_even = 0; - crtc.memory_address_select = 1; - - /* GR7 */ - crtc.color_dont_care = 0xf; - 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->fb[0].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->fb[0].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->fb[0].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; - -#if 0 - crtc.h_blank_start_0_7 = 0x6a; - crtc._h_blank_end = 0x9a; - crtc.h_sync_start_0_7 = 0x6b; - crtc._h_sync_end = 0x9a; - - crtc.v_retrace_start_0_7 = 0x7d; - crtc._v_retrace_end = 0x23; - crtc.v_blank_start_0_7 = 0x7d; - crtc.v_blank_end_0_7 = 0x84; - - crtc.crt_cpu_threshold_control_0 = 0xdf; /* SR8 */ - crtc.crt_cpu_threshold_control_1 = 0x00; /* SR9 */ - crtc.extended_clock_generator = 0x40; /* SR13 */ - - crtc.cursor_h_start_0_7 = 0x83; - crtc.cursor_v_start_0_7 = 0x6c; - - crtc.internal_vclk_0 = 0x68; - crtc.internal_vclk_1 = 0xc4; - crtc.misc_control_7 = 0x70; -#endif - - _sisSetCrtc (sisc, &crtc); - return TRUE; -} - -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; - - memcpy (sisc->frameBuffer, sisc->save.text_save, SIS_TEXT_SAVE); - _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)); -} - -KdCardFuncs sisFuncs = { - sisCardInit, - sisScreenInit, - 0, - sisPreserve, - sisEnable, - sisDPMS, - sisDisable, - sisRestore, - sisScreenFini, - sisCardFini, - sisCursorInit, - sisCursorEnable, - sisCursorDisable, - sisCursorFini, - 0, - sisDrawInit, - sisDrawEnable, - sisDrawSync, - sisDrawDisable, - sisDrawFini, - sisGetColors, - sisPutColors, -}; diff --git a/hw/kdrive/sis530/sis.h b/hw/kdrive/sis530/sis.h deleted file mode 100644 index 2a39d0ba2..000000000 --- a/hw/kdrive/sis530/sis.h +++ /dev/null @@ -1,1218 +0,0 @@ -/* - * Id: sis.h,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.4 2000/05/06 22:17:49 keithp Exp $ */ - -#ifndef _SIS_H_ -#define _SIS_H_ -#include "kdrive.h" -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <asm/io.h> -#include <stdio.h> - -/* - * Linear Addressing 000 0000 - 0ff ffff (16m) - * Image data transfer 100 0000 - 100 7fff (32k) - * Empty 100 8000 - 100 81ff - * MMIO registers 100 8200 - 100 8480 - * - * We don't care about the image transfer or PCI regs, so - * this structure starts at the MMIO regs - */ - -typedef volatile CARD32 VOL32; -typedef volatile CARD16 VOL16; -typedef volatile CARD8 VOL8; - -#define SIS_MMIO_OFFSET 0x8200 - -typedef struct _sis530General { - VOL32 src_base; /* 8200 */ - VOL16 src_pitch; /* 8204 */ - VOL16 _pad0; /* 8206 */ - VOL16 src_y; /* 8208 */ - VOL16 src_x; /* 820a */ - VOL16 dst_y; /* 820c */ - VOL16 dst_x; /* 820e */ - VOL32 dst_base; /* 8210 */ - VOL16 dst_pitch; /* 8214 */ - VOL16 dst_height; /* 8216 */ - VOL16 rect_width; /* 8218 */ - VOL16 rect_height; /* 821a */ - VOL32 pattern_fg; /* 821c */ - VOL32 pattern_bg; /* 8220 */ - VOL32 src_fg; /* 8224 */ - VOL32 src_bg; /* 8228 */ - VOL8 mask[8]; /* 822c */ - VOL16 clip_left; /* 8234 */ - VOL16 clip_top; /* 8236 */ - VOL16 clip_right; /* 8238 */ - VOL16 clip_bottom; /* 823a */ - VOL32 command; /* 823c */ - VOL32 status; /* 8240 */ - VOL8 _pad1[0xbc]; /* 8244 */ - VOL8 pattern[256]; /* 8300 */ - /* 8400 */ -} SisGeneral; - -typedef struct _sis530Line { - VOL8 _pad0[8]; /* 8200 */ - VOL16 x0; /* 8208 */ - VOL16 y0; /* 820a */ - VOL16 x1; /* 820c */ - VOL16 y1; /* 820e */ - VOL32 dst_base; /* 8210 */ - VOL16 dst_pitch; /* 8214 */ - VOL16 dst_height; /* 8216 */ - VOL16 count; /* 8218 */ - VOL16 style_period; /* 821a */ - VOL32 fg; /* 821c */ - VOL32 bg; /* 8220 */ - VOL8 _pad1[8]; /* 8224 */ - VOL32 style0; /* 822c */ - VOL32 style1; /* 8228 */ - VOL16 clip_left; /* 8234 */ - VOL16 clip_top; /* 8236 */ - VOL16 clip_right; /* 8238 */ - VOL16 clip_bottom; /* 823a */ - VOL32 command; /* 823c */ - VOL32 status; /* 8240 */ - VOL8 _pad2[0xbc]; /* 8244 */ - struct { - VOL16 x; - VOL16 y; - } data[96]; /* 8300 */ - /* 8480 */ -} SisLine; - -typedef struct _sis530Transparent { - VOL32 src_base; /* 8200 */ - VOL16 src_pitch; /* 8204 */ - VOL16 _pad0; /* 8206 */ - VOL16 src_y; /* 8208 */ - VOL16 src_x; /* 820a */ - VOL16 dst_y; /* 820c */ - VOL16 dst_x; /* 820e */ - VOL32 dst_base; /* 8210 */ - VOL16 dst_pitch; /* 8214 */ - VOL16 dst_height; /* 8216 */ - VOL16 rect_width; /* 8218 */ - VOL16 rect_height; /* 821a */ - VOL32 dst_key_high; /* 821c */ - VOL32 dst_key_low; /* 8220 */ - VOL32 src_key_high; /* 8224 */ - VOL32 src_key_low; /* 8228 */ - VOL8 _pad1[8]; /* 822c */ - VOL16 clip_left; /* 8234 */ - VOL16 clip_top; /* 8236 */ - VOL16 clip_right; /* 8238 */ - VOL16 clip_bottom; /* 823a */ - VOL32 command; /* 823c */ - VOL32 status; /* 8240 */ - /* 8244 */ -} SisTransparent; - -typedef struct _sis530Multiple { - VOL8 _pad0[8]; /* 8200 */ - VOL16 count; /* 8208 */ - VOL16 y; /* 820a */ - VOL16 x0_start; /* 820c */ - VOL16 x0_end; /* 820e */ - VOL32 dst_base; /* 8210 */ - VOL16 dst_pitch; /* 8214 */ - VOL16 dst_height; /* 8216 */ - VOL8 _pad1[4]; /* 8218 */ - VOL32 fg; /* 821c */ - VOL32 bg; /* 8220 */ - VOL8 _pad2[8]; /* 8224 */ - VOL8 mask[8]; /* 822c */ - VOL16 clip_left; /* 8234 */ - VOL16 clip_top; /* 8236 */ - VOL16 clip_right; /* 8238 */ - VOL16 clip_bottom; /* 823a */ - VOL32 command; /* 823c */ - VOL32 status; /* 8240 */ - VOL16 x1_start; /* 8244 */ - VOL16 x1_end; /* 8246 */ - VOL8 _pad3[0xb8]; /* 8248 */ - VOL8 pattern[64]; /* 8300 */ - struct { - VOL16 x_start; - VOL16 y_end; - } data[80]; /* 8340 */ - /* 8480 */ -} SisMultiple; - -typedef struct _sis530Trapezoid { - VOL8 _pad0[8]; /* 8200 */ - VOL16 height; /* 8208 */ - VOL16 y; /* 820a */ - VOL16 left_x; /* 820c */ - VOL16 right_x; /* 820e */ - VOL32 dst_base; /* 8210 */ - VOL16 dst_pitch; /* 8214 */ - VOL16 dst_height; /* 8216 */ - VOL8 _pad1[4]; /* 8218 */ - VOL32 fg; /* 821c */ - VOL32 bg; /* 8220 */ - VOL8 _pad2[8]; /* 8224 */ - VOL8 mask[8]; /* 822c */ - VOL16 clip_left; /* 8234 */ - VOL16 clip_top; /* 8236 */ - VOL16 clip_right; /* 8238 */ - VOL16 clip_bottom; /* 823a */ - VOL32 command; /* 823c */ - VOL32 status; /* 8240 */ - VOL16 left_dx; /* 8244 */ - VOL16 left_dy; /* 8246 */ - VOL16 right_dx; /* 8248 */ - VOL16 right_dy; /* 824a */ - VOL32 left_error; /* 824c */ - VOL32 right_error; /* 8250 */ - /* 8254 */ -} SisTrapezoid; - -typedef struct _sisAccel { - VOL8 pad[0x80]; /* 8200 */ - VOL32 src_addr; /* 8280 */ - VOL32 dst_addr; /* 8284 */ - VOL32 pitch; /* 8288 */ - VOL32 dimension; /* 828c */ - VOL32 fg; /* 8290 */ - VOL32 bg; /* 8294 */ - - - VOL32 clip_ul; /* 82a0 */ - VOL32 clip_br; /* 82a4 */ - - VOL16 cmd; /* 82aa */ - - VOL8 pattern[256]; /* 82ac */ - -} SisAccel; - -typedef struct _sis530 { - union { - SisGeneral general; - SisLine line; - SisTransparent transparent; - SisMultiple multiple; - SisTrapezoid trapezoid; - SisAccel accel; - } u; -} SisRec, *SisPtr; - -typedef struct _sisCursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; -} SisCursor; - -#define SIS_CURSOR_WIDTH 64 -#define SIS_CURSOR_HEIGHT 64 - -typedef struct _sisClock { - CARD32 vclk_numerator; - BOOL vclk_divide_by_2; - CARD32 vclk_denominator; - CARD32 vclk_post_scale; - BOOL vclk_post_scale_2; - BOOL high_speed_dac; -} SisClockRec, *SisClockPtr; - -typedef struct _crtc { - - union { - struct { - CARD8 _io_address_select : 1; - CARD8 _display_ram_enable : 1; - CARD8 _clock_select : 2; - CARD8 : 1; - CARD8 _odd_even_page : 1; - CARD8 _h_sync_polarity : 1; - CARD8 _v_sync_polarity : 1; - } _misc_output_s; - CARD8 _misc_output; - } _misc_output_u; /* 3CC/3C2 */ - -#define misc_output _misc_output_u._misc_output -#define io_address_select _misc_output_u._misc_output_s._io_address_select -#define display_ram_enable _misc_output_u._misc_output_s._display_ram_enable -#define clock_select _misc_output_u._misc_output_s._clock_select -#define odd_even_page _misc_output_u._misc_output_s._odd_even_page -#define h_sync_polarity _misc_output_u._misc_output_s._h_sync_polarity -#define v_sync_polarity _misc_output_u._misc_output_s._v_sync_polarity - - CARD8 h_total_0_7; /* CR0 */ - CARD8 h_display_end_0_7; /* CR1 */ - CARD8 h_blank_start_0_7; /* CR2 */ - union { - struct { - CARD8 _h_blank_end_0_4 : 5; - CARD8 _display_skew : 2; - CARD8 : 1; - } _h_blank_end_s; - CARD8 __h_blank_end; /* CR3 */ - } _h_blank_end_u; -#define h_blank_end_0_4 _h_blank_end_u._h_blank_end_s._h_blank_end_0_4 -#define display_skew _h_blank_end_u._h_blank_end_s._display_skew -#define _h_blank_end _h_blank_end_u.__h_blank_end - - CARD8 h_sync_start_0_7; /* CR4 */ - - union { - struct { - CARD8 _h_sync_end_0_4 : 5; - CARD8 _horizontal_skew : 2; - CARD8 _h_blank_end_5 : 1; - } _h_sync_end_s; - CARD8 __h_sync_end; /* CR5 */ - } _h_sync_end_u; - -#define h_sync_end_0_4 _h_sync_end_u._h_sync_end_s._h_sync_end_0_4 -#define horizontal_skew _h_sync_end_u._h_sync_end_s._horizontal_skew -#define h_blank_end_5 _h_sync_end_u._h_sync_end_s._h_blank_end_5 -#define _h_sync_end _h_sync_end_u.__h_sync_end - - CARD8 v_total_0_7; /* CR6 */ - - union { - struct { - CARD8 _v_total_8 : 1; - CARD8 _v_display_end_8 : 1; - CARD8 _v_retrace_start_8 : 1; - CARD8 _v_blank_start_8 : 1; - CARD8 _line_compare_8 : 1; - CARD8 _v_total_9 : 1; - CARD8 _v_display_end_9 : 1; - CARD8 _v_retrace_start_9 : 1; - } _crtc_overflow_s; - CARD8 _crtc_overflow; /* CR7 */ - } _crtc_overflow_u; - -#define v_total_8 _crtc_overflow_u._crtc_overflow_s._v_total_8 -#define v_display_end_8 _crtc_overflow_u._crtc_overflow_s._v_display_end_8 -#define v_retrace_start_8 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_8 -#define v_blank_start_8 _crtc_overflow_u._crtc_overflow_s._v_blank_start_8 -#define line_compare_8 _crtc_overflow_u._crtc_overflow_s._line_compare_8 -#define v_total_9 _crtc_overflow_u._crtc_overflow_s._v_total_9 -#define v_display_end_9 _crtc_overflow_u._crtc_overflow_s._v_display_end_9 -#define v_retrace_start_9 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_9 -#define crtc_overflow _crtc_overflow_u._crtc_overflow - - CARD8 preset_row_scan; /* CR8 (unused) */ - - union { - struct { - CARD8 ___max_scan_line : 5; - CARD8 _v_blank_start_9 : 1; - CARD8 _line_compare_9 : 1; - CARD8 _double_scan : 1; - } _max_scan_line_s; - CARD8 __max_scan_line; /* CR9 */ - } _max_scan_line_u; - -#define max_scan_line _max_scan_line_u._max_scan_line_s.___max_scan_line -#define v_blank_start_9 _max_scan_line_u._max_scan_line_s._v_blank_start_9 -#define line_compare_9 _max_scan_line_u._max_scan_line_s._line_compare_9 -#define double_scan _max_scan_line_u._max_scan_line_s._double_scan -#define _max_scan_line _max_scan_line_u.__max_scan_line - - CARD8 cursor_start; /* CRA */ - CARD8 cursor_end; /* CRB */ - - CARD8 start_address_8_15; /* CRC */ - CARD8 start_address_0_7; /* CRD */ - - CARD8 text_cursor_15_8; /* CRE */ - CARD8 text_cursor_7_0; /* CRF */ - - CARD8 cursor_loc_high; - CARD8 cursor_loc_low; - - CARD8 v_retrace_start_0_7; /* CR10 */ - union { - struct { - CARD8 _v_retrace_end_0_3 : 4; - CARD8 _clear_v_retrace_int : 1; - CARD8 _disable_v_retrace_int : 1; - CARD8 _refresh_cycle_select : 1; - CARD8 _lock_crtc : 1; - } _v_retrace_end_s; - CARD8 __v_retrace_end; /* CR11 */ - } _v_retrace_end_u; - -#define v_retrace_end_0_3 _v_retrace_end_u._v_retrace_end_s._v_retrace_end_0_3 -#define clear_v_retrace_int _v_retrace_end_u._v_retrace_end_s._clear_v_retrace_int -#define disable_v_retrace_int _v_retrace_end_u._v_retrace_end_s._disable_v_retrace_int -#define refresh_cycle_select _v_retrace_end_u._v_retrace_end_s._refresh_cycle_select -#define lock_crtc _v_retrace_end_u._v_retrace_end_s._lock_crtc -#define _v_retrace_end _v_retrace_end_u.__v_retrace_end - - CARD8 v_display_end_0_7; /* CR12 */ - - CARD8 screen_off_0_7; /* CR13 */ - - union { - struct { - CARD8 ___underline_location : 5; - CARD8 _count_by_four : 1; - CARD8 _doubleword_mode : 1; - CARD8 : 1; - } _underline_location_s; - CARD8 __underline_location; /* CR14 */ - } _underline_location_u; - -#define underline_location _underline_location_u._underline_location_s.___underline_location -#define count_by_four _underline_location_u._underline_location_s._count_by_four -#define doubleword_mode _underline_location_u._underline_location_s._doubleword_mode -#define _underline_location _underline_location_u.__underline_location - - CARD8 v_blank_start_0_7; /* CR15 */ - CARD8 v_blank_end_0_7; /* CR16 */ - - union { - struct { - CARD8 _two_bk_cga : 1; - CARD8 _four_bk_cga : 1; - CARD8 _v_total_double : 1; - CARD8 _count_by_two : 1; - CARD8 : 1; - CARD8 _address_wrap : 1; - CARD8 _byte_mode : 1; - CARD8 _hardware_reset : 1; - } _crtc_mode_s; - CARD8 _crtc_mode; /* CR17 */ - } _crtc_mode_u; - -#define crtc_mode _crtc_mode_u._crtc_mode -#define two_bk_cga _crtc_mode_u._crtc_mode_s._two_bk_cga -#define four_bk_cga _crtc_mode_u._crtc_mode_s._four_bk_cga -#define v_total_double _crtc_mode_u._crtc_mode_s._v_total_double -#define count_by_two _crtc_mode_u._crtc_mode_s._count_by_two -#define address_wrap _crtc_mode_u._crtc_mode_s._address_wrap -#define byte_mode _crtc_mode_u._crtc_mode_s._byte_mode -#define hardware_reset _crtc_mode_u._crtc_mode_s._hardware_reset - - CARD8 line_compare_0_7; /* CR18 (unused) */ - - union { - struct { - CARD8 _graphics_mode_enable : 1; - CARD8 _attribute_byte_mda : 1; - CARD8 _line_graphics_enable : 1; - CARD8 _background_blink : 1; - CARD8 : 1; - CARD8 _pel_panning_compat : 1; - CARD8 _pixel_clock_double : 1; - CARD8 p4_p5_source_select : 1; - } _mode_control_s; - CARD8 _mode_control; - } _mode_control_u; /* AR10 */ - -#define mode_control _mode_control_u._mode_control -#define graphics_mode_enable _mode_control_u._mode_control_s._graphics_mode_enable -#define pixel_clock_double _mode_control_u._mode_control_s._pixel_clock_double - - CARD8 screen_border_color; /* AR11 */ - CARD8 enable_color_plane; /* AR12 */ - CARD8 horizontal_pixel_pan; /* AR13 */ - - union { - struct { - CARD8 _write_mode : 2; - CARD8 : 1; - CARD8 _read_mode : 1; - CARD8 _odd_even_addressing : 1; - CARD8 _shift_register_mode : 1; - CARD8 _color_mode_256 : 1; - CARD8 : 1; - } _mode_register_s; - CARD8 _mode_register; - } _mode_register_u; /* GR5 */ - -#define mode_register _mode_register_u._mode_register -#define color_mode_256 _mode_register_u._mode_register_s._color_mode_256 -#define odd_even_addressing _mode_register_u._mode_register_s._odd_even_addressing - - union { - struct { - CARD8 _graphics_enable : 1; - CARD8 _chain_odd_even : 1; - CARD8 _memory_address_select : 2; - CARD8 : 4; - } _misc_register_s; - CARD8 _misc_register; - } _misc_register_u; /* GR6 */ - -#define misc_register _misc_register_u._misc_register -#define graphics_enable _misc_register_u._misc_register_s._graphics_enable -#define chain_odd_even _misc_register_u._misc_register_s._chain_odd_even -#define memory_address_select _misc_register_u._misc_register_s._memory_address_select - - CARD8 color_dont_care; /* GR7 */ - - union { - struct { - CARD8 _dot_clock_8_9 : 1; - CARD8 : 1; - CARD8 _shifter_load_16 : 1; - CARD8 _dot_clock_divide_2 : 1; - CARD8 _shifter_load_32 : 1; - CARD8 _display_off : 1; - CARD8 : 2; - } _clock_mode_s; - CARD8 _clock_mode; - } _clock_mode_u; /* SR1 */ - -#define clock_mode _clock_mode_u._clock_mode -#define dot_clock_8_9 _clock_mode_u._clock_mode_s._dot_clock_8_9 -#define shifter_load_16 _clock_mode_u._clock_mode_s._shifter_load_16 -#define dot_clock_divide_2 _clock_mode_u._clock_mode_s._dot_clock_divide_2 -#define shifter_load_32 _clock_mode_u._clock_mode_s._shifter_load_32 -#define display_off _clock_mode_u._clock_mode_s._display_off - - CARD8 color_plane_w_enable; /* SR2 */ - - union { - struct { - CARD8 : 1; - CARD8 _extended_memory_size : 1; - CARD8 _odd_even_disable : 1; - CARD8 _chain_4_enable : 1; - CARD8 : 4; - } _memory_mode_s; - CARD8 _memory_mode; - } _memory_mode_u; /* SR4 */ - -#define memory_mode _memory_mode_u._memory_mode -#define extended_memory_sz _memory_mode_u._memory_mode_s._extended_memory_size -#define odd_even_disable _memory_mode_u._memory_mode_s._odd_even_disable -#define chain_4_enable _memory_mode_u._memory_mode_s._chain_4_enable - - union { - struct { - CARD8 _enhanced_text_mode : 1; - CARD8 _enhanced_graphics_mode : 1; - CARD8 _graphics_mode_32k : 1; - CARD8 _graphics_mode_64k : 1; - CARD8 _graphics_mode_true : 1; - CARD8 _graphics_mode_interlaced: 1; - CARD8 _graphics_mode_hw_cursor: 1; - CARD8 _graphics_mode_linear : 1; - } _graphics_mode_s; - CARD8 _graphics_mode; - } _graphics_mode_u; /* SR6 */ - -#define graphics_mode _graphics_mode_u._graphics_mode -#define enhanced_text_mode _graphics_mode_u._graphics_mode_s._enhanced_text_mode -#define enhanced_graphics_mode _graphics_mode_u._graphics_mode_s._enhanced_graphics_mode -#define graphics_mode_32k _graphics_mode_u._graphics_mode_s._graphics_mode_32k -#define graphics_mode_64k _graphics_mode_u._graphics_mode_s._graphics_mode_64k -#define graphics_mode_true _graphics_mode_u._graphics_mode_s._graphics_mode_true -#define graphics_mode_interlaced _graphics_mode_u._graphics_mode_s._graphics_mode_interlaced -#define graphics_mode_hw_cursor _graphics_mode_u._graphics_mode_s._graphics_mode_hw_cursor -#define graphics_mode_linear _graphics_mode_u._graphics_mode_s._graphics_mode_linear - - union { - struct { - CARD8 _external_dac_reference : 1; - CARD8 _high_speed_dac_0 : 1; - CARD8 _direct_color_24bit : 1; - CARD8 _multi_line_prefetch : 1; - CARD8 _extended_video_div_2 : 1; - CARD8 _ramdac_power_save : 1; - CARD8 : 1; - CARD8 _merge_video_fifo : 1; - } _misc_control_0_s; - CARD8 _misc_control_0; - } _misc_control_0_u; /* SR7 */ - -#define misc_control_0 _misc_control_0_u._misc_control_0 -#define external_dac_reference _misc_control_0_u._misc_control_0_s._external_dac_reference -#define high_speed_dac_0 _misc_control_0_u._misc_control_0_s._high_speed_dac_0 -#define direct_color_24bit _misc_control_0_u._misc_control_0_s._direct_color_24bit -#define multi_line_prefetch _misc_control_0_u._misc_control_0_s._multi_line_prefetch -#define extended_video_div_2 _misc_control_0_u._misc_control_0_s._extended_video_div_2 -#define ramdac_power_save _misc_control_0_u._misc_control_0_s._ramdac_power_save -#define merge_video_fifo _misc_control_0_u._misc_control_0_s._merge_video_fifo - - union { - struct { - CARD8 _crt_engine_threshold_high_0_3 : 4; - CARD8 _crt_cpu_threshold_low_0_3 : 4; - } _crt_cpu_threshold_control_0_s; - CARD8 _crt_cpu_threshold_control_0; - } _crt_cpu_threshold_control_0_u; /* SR8 */ - -#define crt_cpu_threshold_control_0 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0 -#define crt_engine_threshold_high_0_3 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_engine_threshold_high_0_3 -#define crt_cpu_threshold_low_0_3 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_cpu_threshold_low_0_3 - - union { - struct { - CARD8 _crt_cpu_threshold_high_0_3 : 4; - CARD8 _ascii_attribute_threshold_0_2 : 3; - CARD8 _true_color_32bpp : 1; - } _crt_cpu_threshold_control_1_s; - CARD8 _crt_cpu_threshold_control_1; - } _crt_cpu_threshold_control_1_u; /* SR9 */ - -#define crt_cpu_threshold_control_1 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1 -#define crt_cpu_threshold_high_0_3 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._crt_cpu_threshold_high_0_3 -#define ascii_attribute_threshold_0_2 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._ascii_attribute_threshold_0_2 -#define true_color_32bpp _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._true_color_32bpp - - union { - struct { - CARD8 _v_total_10 : 1; - CARD8 _v_display_end_10 : 1; - CARD8 _v_blank_start_10 : 1; - CARD8 _v_retrace_start_10 : 1; - CARD8 _screen_off_8_11 : 4; - } _extended_crt_overflow_s; - CARD8 _extended_crt_overflow; - } _extended_crt_overflow_u; /* SRA */ - -#define extended_crt_overflow _extended_crt_overflow_u._extended_crt_overflow -#define v_total_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_total_10 -#define v_display_end_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_display_end_10 -#define v_blank_start_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_blank_start_10 -#define v_retrace_start_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_retrace_start_10 -#define screen_off_8_11 _extended_crt_overflow_u._extended_crt_overflow_s._screen_off_8_11 - - union { - struct { - CARD8 _cpu_bitblt_enable : 1; /* enable CPU bitblt */ - CARD8 _packed_16_color_enable : 1; /* 2 pixels per byte? */ - CARD8 _io_gating : 1; /* when write buffer not empty */ - CARD8 _dual_segment_enable : 1; /* ? */ - CARD8 _true_color_modulation : 1; /* ? */ - CARD8 _memory_mapped_mode : 2; /* mmio enable */ - CARD8 _true_color_order : 1; /* 0: RGB 1: BGR */ - } _misc_control_1_s; - CARD8 _misc_control_1; /* SRB */ - } _misc_control_1_u; - -#define misc_control_1 _misc_control_1_u._misc_control_1 -#define cpu_bitblt_enable _misc_control_1_u._misc_control_1_s._cpu_bitblt_enable -#define memory_mapped_mode _misc_control_1_u._misc_control_1_s._memory_mapped_mode -#define true_color_modulation _misc_control_1_u._misc_control_1_s._true_color_modulation -#define true_color_order _misc_control_1_u._misc_control_1_s._true_color_order - - union { - struct { - CARD8 _sync_reset_enable : 1; - CARD8 _memory_configuration : 3; -#define SIS_MEMORY_CONFIG_1M_1BANK 0 -#define SIS_MEMORY_CONFIG_2M_2BANK 1 -#define SIS_MEMORY_CONFIG_4M_2BANK 2 -#define SIS_MEMORY_CONFIG_2M_1BANK 5 -#define SIS_MEMORY_CONFIG_4M_1BANK 6 -#define SIS_MEMORY_CONFIG_8M_2BANK 7 - CARD8 _test_mode_enable : 1; - CARD8 _read_ahead_enable : 1; - CARD8 _text_mode_16bit_enable : 1; - CARD8 _graphics_mode_32bit_enable : 1; - } _misc_control_2_s; - CARD8 _misc_control_2; - } _misc_control_2_u; /* SRC */ - -#define misc_control_2 _misc_control_2_u._misc_control_2 -#define sync_reset_enable _misc_control_2_u._misc_control_2_s._sync_reset_enable -#define memory_configuration _misc_control_2_u._misc_control_2_s._memory_configuration -#define test_mode_enable _misc_control_2_u._misc_control_2_s._test_mode_enable -#define read_ahead_enable _misc_control_2_u._misc_control_2_s._read_ahead_enable -#define text_mode_16bit_enable _misc_control_2_u._misc_control_2_s._text_mode_16bit_enable -#define graphics_mode_32bit_enable _misc_control_2_u._misc_control_2_s._graphics_mode_32bit_enable - - union ddc_and_power_control_u { - struct { - CARD8 _ddc_clk_programming : 1; - CARD8 _ddc_data_programming : 1; - CARD8 : 1; - CARD8 _acpi_enable : 1; - CARD8 _kbd_cursor_activate : 1; - CARD8 _video_memory_activate : 1; - CARD8 _vga_standby : 1; - CARD8 _vga_suspend : 1; - } _ddc_and_power_control_s; - CARD8 _ddc_and_power_control; - } _ddc_and_power_control_u; /* SR11 */ - -#define ddc_and_power_control _ddc_and_power_control_u._ddc_and_power_control -#define ddc_clk_programming _ddc_and_power_control_u._ddc_and_power_control_s._ddc_clk_programming -#define ddc_data_programming _ddc_and_power_control_u._ddc_and_power_control_s._ddc_data_programming -#define acpi_enable _ddc_and_power_control_u._ddc_and_power_control_s._acpi_enable -#define kbd_cursor_activate _ddc_and_power_control_u._ddc_and_power_control_s._kbd_cursor_activate -#define video_memory_activate _ddc_and_power_control_u._ddc_and_power_control_s._video_memory_activate -#define vga_standby _ddc_and_power_control_u._ddc_and_power_control_s._vga_standby -#define vga_suspend _ddc_and_power_control_u._ddc_and_power_control_s._vga_suspend - - union { - struct { - CARD8 _h_total_8 : 1; - CARD8 _h_display_end_8 : 1; - CARD8 _h_blank_start_8 : 1; - CARD8 _h_sync_start_8 : 1; - CARD8 _h_blank_end_6 : 1; - CARD8 _h_retrace_skew : 3; - } _extended_horizontal_overflow_s; - CARD8 _extended_horizontal_overflow; - } _extended_horizontal_overflow_u; /* SR12 */ -#define extended_horizontal_overflow _extended_horizontal_overflow_u._extended_horizontal_overflow -#define h_total_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_total_8 -#define h_display_end_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_display_end_8 -#define h_blank_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_start_8 -#define h_sync_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_start_8 -#define h_blank_end_6 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_end_6 -#define h_retrace_skew _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_retrace_skew - - union { - struct { - CARD8 : 6; - CARD8 _vclk_post_scale_2 : 1; - CARD8 _mclk_post_scale_2 : 1; - } _extended_clock_generator_s; - CARD8 _extended_clock_generator; - } _extended_clock_generator_u; /* SR13 */ - -#define extended_clock_generator _extended_clock_generator_u._extended_clock_generator -#define vclk_post_scale_2 _extended_clock_generator_u._extended_clock_generator_s._vclk_post_scale_2 -#define mclk_post_scale_2 _extended_clock_generator_u._extended_clock_generator_s._mclk_post_scale_2 - - CARD8 cursor_0_red; /* SR14 */ - CARD8 cursor_0_green; /* SR15 */ - CARD8 cursor_0_blue; /* SR16 */ - - CARD8 cursor_1_red; /* SR17 */ - CARD8 cursor_1_green; /* SR18 */ - CARD8 cursor_1_blue; /* SR19 */ - - CARD8 cursor_h_start_0_7; /* SR1A */ - union { - struct { - CARD8 _cursor_h_start_8_11 : 4; - CARD8 : 3; - CARD8 _cursor_mmio_enable : 1; - } _cusor_h_start_1_s; - CARD8 _cursor_h_start_1; - } _cursor_h_start_1_u; /* SR1B */ - -#define cursor_h_start_1 _cursor_h_start_1_u._cursor_h_start_1 -#define cursor_h_start_8_11 _cursor_h_start_1_u._cursor_h_start_1_s._cursor_h_start_8_11 - - CARD8 cursor_h_preset_0_5; /* SR1C */ - - CARD8 cursor_v_start_0_7; /* SR1D */ - - union { - struct { - CARD8 _cursor_v_start_8_10 : 3; - CARD8 _cursor_side_pattern : 1; - CARD8 _cursor_pattern : 4; - } _cusor_v_start_1_s; - CARD8 _cursor_v_start_1; - } _cursor_v_start_1_u; /* SR1E */ - -#define cursor_v_start_1 _cursor_v_start_1_u._cursor_v_start_1 - - CARD8 cursor_v_preset_0_5; /* SR1F */ - - CARD8 linear_base_19_26; /* SR20 */ - - union { - struct { - CARD8 _linear_base_27_31 : 5; - CARD8 _linear_aperture : 3; -#define SIS_LINEAR_APERTURE_512K 0 -#define SIS_LINEAR_APERTURE_1M 1 -#define SIS_LINEAR_APERTURE_2M 2 -#define SIS_LINEAR_APERTURE_4M 3 -#define SIS_LINEAR_APERTURE_8M 4 - } _linear_base_1_s; - CARD8 _linear_base_1; - } _linear_base_1_u; /* SR21 */ - -#define linear_base_1 _linear_base_1_u._linear_base_1 -#define linear_base_27_31 _linear_base_1_u._linear_base_1_s._linear_base_27_31 -#define linear_aperture _linear_base_1_u._linear_base_1_s._linear_aperture - - union { - struct { - CARD8 _screen_start_addr_20 : 1; - CARD8 : 3; - CARD8 _continuous_mem_access : 1; - CARD8 : 1; - CARD8 _power_down_dac : 1; - CARD8 : 1; - } _graphics_engine_0_s; - CARD8 _graphics_engine_0; - } _graphics_engine_0_u; /* SR26 */ - -#define graphics_engine_0 _graphics_engine_0_u._graphics_engine_0 - - - union { - struct { - CARD8 _screen_start_addr_16_19: 4; - CARD8 _logical_screen_width : 2; -#define SIS_LOG_SCREEN_WIDTH_1024 0 -#define SIS_LOG_SCREEN_WIDTH_2048 1 -#define SIS_LOG_SCREEN_WIDTH_4096 2 - CARD8 _graphics_prog_enable : 1; - CARD8 _turbo_queue_enable : 1; - } _graphics_engine_1_s; - CARD8 _graphics_engine_1; - } _graphics_engine_1_u; /* SR27 */ - -#define graphics_engine_1 _graphics_engine_1_u._graphics_engine_1 -#define screen_start_addr_16_19 _graphics_engine_1_u._graphics_engine_1_s._screen_start_addr_16_19 -#define logical_screen_width _graphics_engine_1_u._graphics_engine_1_s._logical_screen_width -#define graphics_prog_enable _graphics_engine_1_u._graphics_engine_1_s._graphics_prog_enable -#define turbo_queue_enable _graphics_engine_1_u._graphics_engine_1_s._turbo_queue_enable - - - union { - struct { - CARD8 _mclk_numerator : 7; - CARD8 _mclk_divide_by_2 : 1; - } _internal_mclk_0_s; - CARD8 _internal_mclk_0; - } _internal_mclk_0_u; /* SR28 */ - -#define internal_mclk_0 _internal_mclk_0_u._internal_mclk_0 -#define mclk_numerator _internal_mclk_0_u._internal_mclk_0_s._mclk_numerator -#define mclk_divide_by_2 _internal_mclk_0_u._internal_mclk_0_s._mclk_divide_by_2 - - union { - struct { - CARD8 _mclk_denominator : 5; - CARD8 _mclk_post_scale : 2; -#define SIS_MCLK_POST_SCALE_1 0 -#define SIS_MCLK_POST_SCALE_2 1 -#define SIS_MCLK_POST_SCALE_3 2 -#define SIS_MCLK_POST_SCALE_4 3 - CARD8 _mclk_vco_gain : 1; - } _internal_mclk_1_s; - CARD8 _internal_mclk_1; - } _internal_mclk_1_u; /* SR29 */ - -#define internal_mclk_1 _internal_mclk_1_u._internal_mclk_1 -#define mclk_denominator _internal_mclk_1_u._internal_mclk_1_s._mclk_denominator -#define mclk_post_scale _internal_mclk_1_u._internal_mclk_1_s._mclk_post_scale -#define mclk_vco_gain _internal_mclk_1_u._internal_mclk_1_s._mclk_vco_gain - - union { - struct { - CARD8 _vclk_numerator : 7; - CARD8 _vclk_divide_by_2 : 1; - } _internal_vclk_0_s; - CARD8 _internal_vclk_0; - } _internal_vclk_0_u; /* SR2A */ - -#define internal_vclk_0 _internal_vclk_0_u._internal_vclk_0 -#define vclk_numerator _internal_vclk_0_u._internal_vclk_0_s._vclk_numerator -#define vclk_divide_by_2 _internal_vclk_0_u._internal_vclk_0_s._vclk_divide_by_2 - - union { - struct { - CARD8 _vclk_denominator : 5; - CARD8 _vclk_post_scale : 2; -#define SIS_VCLK_POST_SCALE_1 0 -#define SIS_VCLK_POST_SCALE_2 1 -#define SIS_VCLK_POST_SCALE_3 2 -#define SIS_VCLK_POST_SCALE_4 3 - CARD8 _vclk_vco_gain : 1; - } _internal_vclk_1_s; - CARD8 _internal_vclk_1; - } _internal_vclk_1_u; /* SR2B */ - -#define internal_vclk_1 _internal_vclk_1_u._internal_vclk_1 -#define vclk_denominator _internal_vclk_1_u._internal_vclk_1_s._vclk_denominator -#define vclk_post_scale _internal_vclk_1_u._internal_vclk_1_s._vclk_post_scale -#define vclk_vco_gain _internal_vclk_1_u._internal_vclk_1_s._vclk_vco_gain - - union { - struct { - CARD8 _extended_clock_select : 2; -#define SIS_CLOCK_SELECT_INTERNAL 0 -#define SIS_CLOCK_SELECT_25MHZ 1 -#define SIS_CLOCK_SELECT_28MHZ 2 - CARD8 _disable_line_compare : 1; - CARD8 _disable_pci_read_t_o : 1; - CARD8 _cursor_start_addr_18_21: 4; - } _misc_control_7_s; - CARD8 _misc_control_7; - } _misc_control_7_u; /* SR38 */ - -#define misc_control_7 _misc_control_7_u._misc_control_7 -#define extended_clock_select _misc_control_7_u._misc_control_7_s._extended_clock_select -#define disable_line_compare _misc_control_7_u._misc_control_7_s._disable_line_compare -#define disable_pci_read_t_o _misc_control_7_u._misc_control_7_s._disable_pci_read_t_o -#define cursor_start_addr_18_21 _misc_control_7_u._misc_control_7_s._cursor_start_addr_18_21 - - union { - struct { - CARD8 _high_speed_dclk : 1; - CARD8 _sgram_block_write : 1; - CARD8 _cursor_start_addr_22 : 1; - CARD8 _dram_texture_read : 1; - CARD8 _sgram_16mb : 1; - CARD8 _agp_signal_delay : 2; - CARD8 _dclk_off : 1; - } _misc_control_11_s; - CARD8 _misc_control_11; - } _misc_control_11_u; /* SR3E */ - -#define misc_control_11 _misc_control_11_u._misc_control_11 -#define high_speed_dclk _misc_control_11_u._misc_control_11_s._high_speed_dclk -#define sgram_block_write _misc_control_11_u._misc_control_11_s.__sgram_block_write -#define cursor_start_addr_22 _misc_control_11_u._misc_control_11_s._cursor_start_addr_22 -#define dram_texture_read _misc_control_11_u._misc_control_11_s._dram_texture_read -#define sgram_16mb _misc_control_11_u._misc_control_11_s._sgram_16mb -#define agp_signal_delay _misc_control_11_u._misc_control_11_s._agp_signal_delay -#define dclk_off _misc_control_11_u._misc_control_11_s._dclk_off - - union { - struct { - CARD8 : 1; - CARD8 _flat_panel_low_enable : 1; - CARD8 _crt_cpu_threshold_low_4: 1; - CARD8 _crt_engine_threshold_high_4: 1; - CARD8 _crt_cpu_threshold_high_4 : 1; - CARD8 _crt_threshold_full_control : 2; -#define SIS_CRT_32_STAGE_THRESHOLD 0 -#define SIS_CRT_64_STAGE_THRESHOLD 1 -#define SIS_CRT_63_STAGE_THRESHOLD 2 -#define SIS_CRT_256_STAGE_THRESHOLD 3 - CARD8 _high_speed_dac_1 : 1; - } _misc_control_12_s; - CARD8 _misc_control_12; - } _misc_control_12_u; /* SR3F */ -#define misc_control_12 _misc_control_12_u._misc_control_12 -#define flat_panel_low_enable _misc_control_12_u._misc_control_12_s._flat_panel_low_enable -#define crt_cpu_threshold_low_4 _misc_control_12_u._misc_control_12_s._crt_cpu_threshold_low_4 -#define crt_engine_threshold_high_4 _misc_control_12_u._misc_control_12_s._crt_engine_threshold_high_4 -#define crt_cpu_threshold_high_4 _misc_control_12_u._misc_control_12_s._crt_cpu_threshold_high_4 -#define crt_threshold_full_control _misc_control_12_u._misc_control_12_s._crt_threshold_full_control -#define high_speed_dac_1 _misc_control_12_u._misc_control_12_s._high_speed_dac_1 - - /* computed values */ - CARD16 ge_screen_pitch; - CARD8 bits_per_pixel; - CARD8 depth; - CARD8 double_pixel_mode; - CARD16 pixel_width; -} SisCrtc; - -#define crtc_v_total(crtc) ((crtc)->v_total_0_7 | \ - ((crtc)->v_total_8 << 8) | \ - ((crtc)->v_total_9 << 9) | \ - ((crtc)->v_total_10 << 10)) - -#define crtc_set_v_total(crtc,v) { \ - ((crtc))->v_total_0_7 = (v); \ - ((crtc))->v_total_8 = (v) >> 8; \ - ((crtc))->v_total_9 = (v) >> 9; \ - ((crtc))->v_total_10 = (v) >> 10; \ -} - -#define crtc_v_display_end(crtc) ((crtc)->v_display_end_0_7 | \ - ((crtc)->v_display_end_8 << 8) | \ - ((crtc)->v_display_end_9 << 9) | \ - ((crtc)->v_display_end_10 << 10)) - -#define crtc_set_v_display_end(crtc,v) {\ - ((crtc))->v_display_end_0_7 = (v); \ - ((crtc))->v_display_end_8 = (v) >> 8; \ - ((crtc))->v_display_end_9 = (v) >> 9; \ - ((crtc))->v_display_end_10 = (v) >> 10; \ -} - -#define crtc_v_retrace_start(crtc) ((crtc)->v_retrace_start_0_7 | \ - ((crtc)->v_retrace_start_8 << 8) | \ - ((crtc)->v_retrace_start_9 << 9) | \ - ((crtc)->v_retrace_start_10 << 10)) - -#define crtc_set_v_retrace_start(crtc,v) {\ - ((crtc))->v_retrace_start_0_7 = (v); \ - ((crtc))->v_retrace_start_8 = (v) >> 8; \ - ((crtc))->v_retrace_start_9 = (v) >> 9; \ - ((crtc))->v_retrace_start_10 = (v) >> 10; \ -} - -#define crtc_v_blank_start(crtc) ((crtc)->v_blank_start_0_7 | \ - ((crtc)->v_blank_start_8 << 8) | \ - ((crtc)->v_blank_start_9 << 9) | \ - ((crtc)->v_blank_start_10 << 10)) - -#define crtc_set_v_blank_start(crtc,v) {\ - ((crtc))->v_blank_start_0_7 = (v); \ - ((crtc))->v_blank_start_8 = (v) >> 8; \ - ((crtc))->v_blank_start_9 = (v) >> 9; \ - ((crtc))->v_blank_start_10 = (v) >> 10; \ -} - -#define crtc_h_total(crtc) ((crtc)->h_total_0_7 | \ - ((crtc)->h_total_8 << 8)) - -#define crtc_set_h_total(crtc,v) {\ - ((crtc))->h_total_0_7 = (v); \ - ((crtc))->h_total_8 = (v) >> 8; \ -} - -#define crtc_h_display_end(crtc) ((crtc)->h_display_end_0_7 | \ - ((crtc)->h_display_end_8 << 8)) - -#define crtc_set_h_display_end(crtc,v) {\ - ((crtc))->h_display_end_0_7 = (v); \ - ((crtc))->h_display_end_8 = (v) >> 8; \ -} - -#define crtc_h_blank_start(crtc) ((crtc)->h_blank_start_0_7 | \ - ((crtc)->h_blank_start_8 << 8)) - -#define crtc_set_h_blank_start(crtc,v) {\ - ((crtc))->h_blank_start_0_7 = (v); \ - ((crtc))->h_blank_start_8 = (v) >> 8; \ -} - -#define crtc_h_blank_end(crtc) ((crtc)->h_blank_end_0_4 | \ - ((crtc)->h_blank_end_5 << 5)) - -#define crtc_set_h_blank_end(crtc,v) {\ - ((crtc))->h_blank_end_0_4 = (v); \ - ((crtc))->h_blank_end_5 = (v) >> 5; \ -} - -#define crtc_h_sync_start(crtc) ((crtc)->h_sync_start_0_7 | \ - ((crtc)->h_sync_start_8 << 8)) - -#define crtc_set_h_sync_start(crtc,v) {\ - ((crtc))->h_sync_start_0_7 = (v); \ - ((crtc))->h_sync_start_8 = (v) >> 8; \ -} - -#define crtc_h_sync_end(crtc) ((crtc)->h_sync_end_0_4) - -#define crtc_set_h_sync_end(crtc,v) {\ - ((crtc))->h_sync_end_0_4 = (v); \ -} - -#define crtc_screen_off(crtc) ((crtc)->screen_off_0_7 | \ - ((crtc)->screen_off_8_11 << 8)) - -#define crtc_set_screen_off(crtc,v) {\ - ((crtc))->screen_off_0_7 = (v); \ - ((crtc))->screen_off_8_11 = (v) >> 8; \ -} - -#define crtc_ge_screen_width(crtc) ((crtc)->ge_screen_width_0_1 | \ - ((crtc)->ge_screen_width_2 << 2)) - -#define crtc_set_ge_screen_width(crtc,v) { \ - (crtc)->ge_screen_width_0_1 = (v); \ - (crtc)->ge_screen_width_2 = (v) >> 2; \ -} - -#define crtc_h_start_fifo_fetch(crtc) ((crtc)->h_start_fifo_fetch_0_7 | \ - ((crtc)->h_start_fifo_fetch_8 << 8)) - -#define crtc_set_h_start_fifo_fetch(crtc,v) {\ - (crtc)->h_start_fifo_fetch_0_7 = (v); \ - (crtc)->h_start_fifo_fetch_8 = (v) >> 8; \ -} - -#define crtc_start_address(crtc) ((crtc)->start_address_0_7 | \ - ((crtc)->start_address_8_15 << 8) | \ - ((crtc)->start_address_16_19 << 16)) - -#define crtc_set_start_address(crtc,v) {\ - (crtc)->start_address_0_7 = (v); \ - (crtc)->start_address_8_15 = (v) >> 8; \ - (crtc)->start_address_16_19 = (v) >> 16; \ -} - -#define crtc_line_compare(crtc) ((crtc)->line_compare_0_7 | \ - ((crtc)->line_compare_8 << 8) | \ - ((crtc)->line_compare_9 << 9) | \ - ((crtc)->line_compare_10 << 10)) - -#define crtc_set_line_compare(crtc,v) { \ - ((crtc))->line_compare_0_7 = (v); \ - ((crtc))->line_compare_8 = (v) >> 8; \ - ((crtc))->line_compare_9 = (v) >> 9; \ - ((crtc))->line_compare_10 = (v) >> 10; \ -} - -#define crtc_set_cursor_start_addr(crtc,v) { \ - (crtc)->cursor_start_addr_18_21 = (v) >> 18; \ - (crtc)->cursor_start_addr_22 = (v) >> 22; \ -} - -#define _sisOutb(v,r) outb(v,r) -#define _sisInb(r) inb(r) - -#define SIS_DAC_INDEX_READ 0x47 -#define SIS_DAC_INDEX_WRITE 0x48 -#define SIS_DAC_DATA 0x49 - -#define GetCrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x54,i) -#define PutCrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x54,i,v) - -#define GetSrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x44,i) -#define PutSrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x44,i,v) - -#define GetArtc(sisc,i) _sisReadArtc ((sisc)->io_base+0x40,i) -#define PutArtc(sisc,i,v) _sisWriteArtc ((sisc)->io_base+0x40,i,v) - -#define GetGrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x4e,i) -#define PutGrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x4e,i,v) - -#define _sisWaitVRetrace(sisc) - -#define LockSis(sisc) -#define UnlockSis(sisc) - -typedef struct _sisTiming { - /* 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 */ -} SisTiming; - -#define SIS_TEXT_SAVE (64*1024) - -typedef struct _sisSave { - CARD8 srb; - CARD8 sr5; - SisCrtc crtc; - CARD8 text_save[SIS_TEXT_SAVE]; -} SisSave; - -typedef struct _sisCardInfo { - SisPtr sis; - int memory; - CARD8 *frameBuffer; - CARD8 *registers; - VOL32 *cpu_bitblt; - CARD32 io_base; - SisSave save; -} SisCardInfo; - -typedef struct _sisScreenInfo { - CARD8 *cursor_base; - CARD32 cursor_off; - CARD8 *expand; - CARD32 expand_off; - int expand_len; - SisCursor cursor; -} SisScreenInfo; - -#define getSisCardInfo(kd) ((SisCardInfo *) ((kd)->card->driver)) -#define sisCardInfo(kd) SisCardInfo *sisc = getSisCardInfo(kd) - -#define getSisScreenInfo(kd) ((SisScreenInfo *) ((kd)->screen->driver)) -#define sisScreenInfo(kd) SisScreenInfo *siss = getSisScreenInfo(kd) - -Bool sisCardInit (KdCardInfo *); -Bool sisScreenInit (KdScreenInfo *); -Bool sisEnable (ScreenPtr pScreen); -void sisDisable (ScreenPtr pScreen); -void sisFini (ScreenPtr pScreen); - -Bool sisCursorInit (ScreenPtr pScreen); -void sisCursorEnable (ScreenPtr pScreen); -void sisCursorDisable (ScreenPtr pScreen); -void sisCursorFini (ScreenPtr pScreen); -void sisRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs); - -Bool sisDrawInit (ScreenPtr pScreen); -void sisDrawEnable (ScreenPtr pScreen); -void sisDrawSync (ScreenPtr pScreen); -void sisDrawDisable (ScreenPtr pScreen); -void sisDrawFini (ScreenPtr pScreen); - -void sisGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); -void sisPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); - -void SISInitCard (KdCardAttr *attr); - -CARD8 _sisReadIndexRegister (CARD32 base, CARD8 index); -void _sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value); -CARD8 _sisReadArtc (CARD32 base, CARD8 index); -void _sisWriteArtc (CARD32 base, CARD8 index, CARD8 value); - -extern KdCardFuncs sisFuncs; - -/* - * sisclock.c - */ -void -sisGetClock (unsigned long clock, SisCrtc *crtc); - -void -sisEngThresh (SisCrtc *crtc, unsigned long vclk, int bpp); - -/* - * siscurs.c - */ - -Bool -sisCursorInit (ScreenPtr pScreen); - -void -sisCursorEnable (ScreenPtr pScreen); - -void -sisCursorDisable (ScreenPtr pScreen); - -void -sisCursorFini (ScreenPtr pScreen); - -/* sisdraw.c */ -Bool -sisDrawInit (ScreenPtr pScreen); - -void -sisDrawEnable (ScreenPtr pScreen); - -void -sisDrawDisable (ScreenPtr pScreen); - -void -sisDrawFini (ScreenPtr pScreen); - -#endif /* _SIS_H_ */ diff --git a/hw/kdrive/sis530/sisclock.c b/hw/kdrive/sis530/sisclock.c deleted file mode 100644 index 4db2a31b9..000000000 --- a/hw/kdrive/sis530/sisclock.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Id: sisclock.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sisclock.c,v 1.1 1999/11/19 13:53:59 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; -} diff --git a/hw/kdrive/sis530/siscmap.c b/hw/kdrive/sis530/siscmap.c deleted file mode 100644 index e52841e9d..000000000 --- a/hw/kdrive/sis530/siscmap.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Id: siscmap.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/siscmap.c,v 1.1 1999/11/19 13:53:59 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "sis.h" - -void -sisGetColors (ScreenPtr pScreen, int fb, 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 fb, 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); -} - diff --git a/hw/kdrive/sis530/siscurs.c b/hw/kdrive/sis530/siscurs.c deleted file mode 100644 index b507188c0..000000000 --- a/hw/kdrive/sis530/siscurs.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Id: siscurs.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/siscurs.c,v 1.1 1999/11/19 13:53:59 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; -} diff --git a/hw/kdrive/sis530/sisdraw.c b/hw/kdrive/sis530/sisdraw.c deleted file mode 100644 index 82618acab..000000000 --- a/hw/kdrive/sis530/sisdraw.c +++ /dev/null @@ -1,1726 +0,0 @@ -/* - * Id: sisdraw.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c,v 1.5 2000/08/09 17:52:44 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "sis.h" -#include "sisdraw.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 sisPatRop[16] = { - /* GXclear */ 0x00, /* 0 */ - /* GXand */ 0xa0, /* src AND dst */ - /* GXandReverse */ 0x50, /* src AND NOT dst */ - /* GXcopy */ 0xf0, /* src */ - /* GXandInverted*/ 0x0a, /* NOT src AND dst */ - /* GXnoop */ 0xaa, /* dst */ - /* GXxor */ 0x5a, /* src XOR dst */ - /* GXor */ 0xfa, /* src OR dst */ - /* GXnor */ 0x05, /* NOT src AND NOT dst */ - /* GXequiv */ 0xa5, /* NOT src XOR dst */ - /* GXinvert */ 0x55, /* NOT dst */ - /* GXorReverse */ 0xf5, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x0f, /* NOT src */ - /* GXorInverted */ 0xaf, /* NOT src OR dst */ - /* GXnand */ 0x5f, /* NOT src OR NOT dst */ - /* GXset */ 0xff, /* 1 */ -}; - -CARD8 sisBltRop[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 */ -}; - -/* Align blts to this boundary or risk trashing an in-progress expand */ -#define SIS_MIN_PATTERN 8 - -/* Do plane bits in this increment to balance CPU and graphics engine */ -#define SIS_PATTERN_INC 1024 - -typedef struct _SisExpand { - SisCardInfo *sisc; - SisScreenInfo *siss; - CARD32 off; - int last; -} SisExpand; - -static void -sisExpandInit (ScreenPtr pScreen, - SisExpand *e) -{ - KdScreenPriv(pScreen); - sisCardInfo(pScreenPriv); - sisScreenInfo(pScreenPriv); - - e->sisc = sisc; - e->siss = siss; - e->off = siss->expand_off; - e->last = 0; -} - -static CARD32 * -sisExpandAlloc (SisExpand *e, - int nb) -{ - SisCardInfo *sisc = e->sisc; - SisScreenInfo *siss = e->siss; - SisPtr sis = sisc->sis; - CARD32 off; - - /* round up to alignment boundary */ - nb = (nb + SIS_MIN_PATTERN-1) & ~(SIS_MIN_PATTERN-1); - - off = e->off + e->last; - if (off + nb > siss->expand_off + siss->expand_len) - { - _sisWaitIdleEmpty (sis); - off = siss->expand_off; - } - e->off = off; - e->last = nb; - return (CARD32 *) (sisc->frameBuffer + off); -} - -void -sisGlyphBltClipped (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - Bool imageBlt) -{ - SetupSis(pDrawable->pScreen); - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - int height; - int width; - int xBack, yBack; - int hBack, wBack; - int nb, bwidth, nl; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - CARD8 *bits8, b; - CARD16 *bits16; - CARD32 *bits32; - BoxPtr extents; - BoxRec bbox; - unsigned char alu; - CARD32 cmd; - SisExpand expand; - CARD32 *dst, d; - int nbytes; - int shift; - int x1, y1, x2, y2; - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr pBox; - int nbox; - int rect_in; - int widthBlt; - CharInfoPtr *ppci; - - x += pDrawable->x; - y += pDrawable->y; - - if (imageBlt) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - height = nglyph; - ppci = ppciInit; - while (height--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - } - else - { - wBack = 0; - alu = pGC->alu; - } - - if (wBack) - { - _sisSetSolidRect (sis, pGC->bgPixel, GXcopy, cmd); - for (nbox = REGION_NUM_RECTS (pClip), - pBox = REGION_RECTS (pClip); - nbox--; - pBox++) - { - x1 = xBack; - x2 = xBack + wBack; - y1 = yBack; - y2 = yBack + hBack; - if (x1 < pBox->x1) x1 = pBox->x1; - if (x2 > pBox->x2) x2 = pBox->x2; - if (y1 < pBox->y1) y1 = pBox->y1; - if (y2 > pBox->y2) y2 = pBox->y2; - if (x1 < x2 && y1 < y2) - { - _sisRect (sis, x1, y1, x2 - x1, y2 - y1, cmd); - } - } - } - - sisExpandInit (pDrawable->pScreen, &expand); - - sis->u.general.src_fg = pGC->fgPixel; - sis->u.general.src_pitch = 0; - sis->u.general.src_x = 0; - sis->u.general.src_y = 0; - - cmd = (SIS_CMD_ENH_COLOR_EXPAND | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_FG | - (sisBltRop[alu] << 8) | - SIS_CMD_INC_X | - SIS_CMD_INC_Y | - SIS_CMD_RECT_CLIP_ENABLE | - SIS_CMD_TRANSPARENT); - - ppci = ppciInit; - while (nglyph--) - { - pci = *ppci++; - height = pci->metrics.ascent + pci->metrics.descent; - width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - widthBlt = (width + 31) & ~31; - nb = (widthBlt >> 3) * height; - if (nb) - { - x1 = x + pci->metrics.leftSideBearing; - y1 = y - pci->metrics.ascent; - bbox.x1 = x1; - bbox.y1 = y1; - bbox.x2 = x1 + width; - bbox.y2 = y1 + height; - rect_in = RECT_IN_REGION(pGC->pScreen, pClip, &bbox); - if (rect_in != rgnOUT) - { - dst = sisExpandAlloc (&expand, nb); - - sis->u.general.src_base = expand.off; - sis->u.general.dst_x = x1; - sis->u.general.dst_y = y1; - sis->u.general.rect_width = widthBlt; - sis->u.general.rect_height = height; - nb >>= 2; - bits32 = (CARD32 *) pci->bits; - while (nb--) - { - d = *bits32++; - SisInvertBits32 (d); - *dst++ = d; - } - if (rect_in == rgnPART) - { - for (nbox = REGION_NUM_RECTS (pClip), - pBox = REGION_RECTS (pClip); - nbox--; - pBox++) - { - _sisClip (sis, pBox->x1, pBox->y1, pBox->x2, pBox->y2); - sis->u.general.command = cmd; - } - } - else - { - _sisClip (sis, 0, 0, x1+width, pScreenPriv->screen->height); - sis->u.general.command = cmd; - } - } - } - x += pci->metrics.characterWidth; - } - _sisClip (sis, 0, 0, - pScreenPriv->screen->width, pScreenPriv->screen->height); - KdMarkSync (pDrawable->pScreen); -} - -Bool -sisTEGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int xInit, - int yInit, - unsigned int nglyph, - CharInfoPtr *ppci, - Bool imageBlt) -{ - SetupSis(pDrawable->pScreen); - int x, y; - int widthGlyphs, widthGlyph; - int widthBlt; - FbBits depthMask; - int glyphsPer; - FontPtr pfont = pGC->font; - unsigned long *char1, *char2, *char3, *char4, *char5; - CARD8 alu; - CARD32 *dst, tmp; - CARD8 *dst8, *bits8; - int nb; - int bwidth; - CARD32 cmd; - int h; - BoxRec bbox; - SisExpand expand; - int lwTmp, lw; - int extra, n; - - widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); - if (!widthGlyph) - return TRUE; - - h = FONTASCENT(pfont) + FONTDESCENT(pfont); - if (!h) - return TRUE; - - x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x; - y = yInit - FONTASCENT(pfont) + pDrawable->y; - - bbox.x1 = x; - bbox.x2 = x + (widthGlyph * nglyph); - bbox.y1 = y; - bbox.y2 = y + h; - - switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) - { - case rgnPART: - if (x < 0 || y < 0) - return FALSE; - sisGlyphBltClipped (pDrawable, pGC, xInit, yInit, nglyph, ppci, imageBlt); - case rgnOUT: - return TRUE; - } - - if (widthGlyph <= 6) - glyphsPer = 5; - else if (widthGlyph <= 8) - glyphsPer = 4; - else if (widthGlyph <= 10) - glyphsPer = 3; - else if (widthGlyph <= 16) - glyphsPer = 2; - else - glyphsPer = 1; - - widthGlyphs = widthGlyph * glyphsPer; - widthBlt = widthGlyphs; - - /* make sure scanlines are 32-bit aligned */ - if (widthGlyphs <= 24) - widthBlt = 25; - - cmd = (SIS_CMD_ENH_COLOR_EXPAND | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_FG | - SIS_CMD_INC_X | - SIS_CMD_INC_Y); - - if (imageBlt) - { - sis->u.general.clip_right = bbox.x2; - cmd |= ((sisBltRop[GXcopy] << 8) | - SIS_CMD_OPAQUE | - SIS_CMD_RECT_CLIP_ENABLE); - } - else - { - cmd |= ((sisBltRop[pGC->alu] << 8) | - SIS_CMD_TRANSPARENT | - SIS_CMD_RECT_CLIP_DISABLE); - } - - sisExpandInit (pDrawable->pScreen, &expand); - - sis->u.general.src_fg = pGC->fgPixel; - sis->u.general.src_bg = pGC->bgPixel; - - bwidth = (widthBlt + 7) >> 3; - - nb = bwidth * h; - -#define LoopIt(count, loadup, fetch) \ - while (nglyph >= count) \ - { \ - nglyph -= count; \ - dst = sisExpandAlloc (&expand, nb); \ - sis->u.general.src_base = expand.off; \ - sis->u.general.src_pitch = 0; \ - sis->u.general.src_x = 0; \ - sis->u.general.src_y = 0; \ - sis->u.general.dst_x = x; \ - sis->u.general.dst_y = y; \ - sis->u.general.rect_width = widthBlt; \ - sis->u.general.rect_height = h; \ - x += widthGlyphs; \ - loadup \ - lwTmp = h; \ - while (lwTmp--) { \ - tmp = fetch; \ - SisInvertBits32(tmp); \ - *dst++ = tmp; \ - } \ - sis->u.general.command = cmd; \ - } - - switch (glyphsPer) { - case 5: - LoopIt(5, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits; - char4 = (unsigned long *) (*ppci++)->bits; - char5 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | ((*char3++ | ((*char4++ | (*char5++ - << widthGlyph)) - << widthGlyph)) - << widthGlyph)) - << widthGlyph))); - break; - case 4: - LoopIt(4, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits; - char4 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | ((*char3++ | (*char4++ - << widthGlyph)) - << widthGlyph)) - << widthGlyph))); - break; - case 3: - LoopIt(3, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits; - char3 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | ((*char2++ | (*char3++ << widthGlyph)) << widthGlyph))); - break; - case 2: - LoopIt(2, - char1 = (unsigned long *) (*ppci++)->bits; - char2 = (unsigned long *) (*ppci++)->bits;, - (*char1++ | (*char2++ << widthGlyph))); - break; - } - - widthBlt = (widthGlyph + 31) & ~31; - - bwidth = widthBlt >> 3; - - nb = bwidth * h; - - lw = (widthBlt >> 5) * h; - - while (nglyph--) - { - dst = (CARD32 *) sisExpandAlloc (&expand, nb); - char1 = (CARD32 *) (*ppci++)->bits; - sis->u.general.src_base = expand.off; - sis->u.general.src_pitch = 0; - sis->u.general.src_x = 0; - sis->u.general.src_y = 0; - sis->u.general.dst_x = x; - sis->u.general.dst_y = y; - sis->u.general.rect_width = widthBlt; - sis->u.general.rect_height = h; - lwTmp = lw; - while (lwTmp--) - { - tmp = *char1++; - SisInvertBits32 (tmp); - *dst++ = tmp; - } - sis->u.general.command = cmd; - x += widthGlyph; - } - if (imageBlt) - sis->u.general.clip_right = pScreenPriv->screen->width; - KdMarkSync (pDrawable->pScreen); - return TRUE; -} - -Bool -sisGlyphBlt(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - Bool imageBlt) -{ - SetupSis(pDrawable->pScreen); - int height; - int width; - int xBack, yBack; - int hBack, wBack; - int nb, bwidth, nl; - FontPtr pfont = pGC->font; - CharInfoPtr pci; - CARD8 *bits8, b; - CARD16 *bits16; - CARD32 *bits32; - BoxPtr extents; - BoxRec bbox; - CharInfoPtr *ppci; - unsigned char alu; - CARD32 cmd; - SisExpand expand; - CARD32 *dst, d; - int nbytes; - int shift; - - x += pDrawable->x; - y += pDrawable->y; - - /* compute an approximate (but covering) bounding box */ - ppci = ppciInit; - width = 0; - height = nglyph; - while (height--) - width += (*ppci++)->metrics.characterWidth; - if (width < 0) - { - bbox.x1 = x + width; - bbox.x2 = x; - } - else - { - bbox.x1 = x; - bbox.x2 = x + width; - } - width = FONTMINBOUNDS(pfont,leftSideBearing); - if (width < 0) - bbox.x1 += width; - width = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); - if (width > 0) - bbox.x2 += width; - bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); - bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); - - switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) - { - case rgnPART: - if (bbox.x1 < 0 || bbox.y1 < 0) - return FALSE; - sisGlyphBltClipped (pDrawable, pGC, - x - pDrawable->x, y - pDrawable->y, - nglyph, ppciInit, imageBlt); - case rgnOUT: - return TRUE; - } - - if (imageBlt) - { - xBack = x; - yBack = y - FONTASCENT(pGC->font); - wBack = 0; - hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - if (hBack) - { - height = nglyph; - ppci = ppciInit; - while (height--) - wBack += (*ppci++)->metrics.characterWidth; - } - if (wBack < 0) - { - xBack = xBack + wBack; - wBack = -wBack; - } - if (hBack < 0) - { - yBack = yBack + hBack; - hBack = -hBack; - } - alu = GXcopy; - } - else - { - wBack = 0; - alu = pGC->alu; - } - - if (wBack) - { - _sisSetSolidRect (sis, pGC->bgPixel, GXcopy, cmd); - _sisRect (sis, xBack, yBack, wBack, hBack, cmd); - } - - sisExpandInit (pDrawable->pScreen, &expand); - - sis->u.general.src_fg = pGC->fgPixel; - - cmd = (SIS_CMD_ENH_COLOR_EXPAND | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_FG | - (sisBltRop[alu] << 8) | - SIS_CMD_INC_X | - SIS_CMD_INC_Y | - SIS_CMD_RECT_CLIP_DISABLE | - SIS_CMD_TRANSPARENT); - - ppci = ppciInit; - while (nglyph--) - { - pci = *ppci++; - height = pci->metrics.ascent + pci->metrics.descent; - width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - /* - * For glyphs wider than 16 pixels, expand the blt to the nearest multiple - * of 32; this allows the scanlines to be padded to a 32-bit boundary - * instead of requiring byte packing - */ - if (width > 16) - width = (width + 31) & ~31; - bwidth = (width + 7) >> 3; - nb = bwidth * height; - if (nb) - { - dst = sisExpandAlloc (&expand, nb); - - sis->u.general.src_base = expand.off; - sis->u.general.src_pitch = 0; - sis->u.general.src_x = 0; - sis->u.general.src_y = 0; - sis->u.general.dst_x = x + pci->metrics.leftSideBearing; - sis->u.general.dst_y = y - pci->metrics.ascent; - sis->u.general.rect_width = width; - sis->u.general.rect_height = height; - switch (bwidth) { - case 1: - bits8 = (CARD8 *) pci->bits; - while (height >= 4) - { - d = (bits8[0] | (bits8[4] << 8) | - (bits8[8] << 16) | (bits8[12] << 24)); - SisInvertBits32(d); - *dst++ = d; - bits8 += 16; - height -= 4; - } - if (height) - { - switch (height) { - case 3: - d = bits8[0] | (bits8[4] << 8) | (bits8[8] << 16); - break; - case 2: - d = bits8[0] | (bits8[4] << 8); - break; - case 1: - d = bits8[0]; - break; - } - SisInvertBits32(d); - *dst++ = d; - } - break; - case 2: - bits16 = (CARD16 *) pci->bits; - while (height >= 2) - { - d = bits16[0] | (bits16[2] << 16); - SisInvertBits32(d); - *dst++ = d; - bits16 += 4; - height -= 2; - } - if (height) - { - d = bits16[0]; - SisInvertBits32(d); - *dst++ = d; - } - break; - default: - nb >>= 2; - bits32 = (CARD32 *) pci->bits; - while (nb--) - { - d = *bits32++; - SisInvertBits32 (d); - *dst++ = d; - } - } - sis->u.general.command = cmd; - } - x += pci->metrics.characterWidth; - } - KdMarkSync (pDrawable->pScreen); - return TRUE; -} -/* - * Blt glyphs using Sis image transfer register, this does both - * poly glyph blt and image glyph blt (when pglyphBase == 1) - */ - -void -sisPolyGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - FbBits depthMask; - - depthMask = FbFullMask (pDrawable->depth); - if ((pGC->planemask & depthMask) == depthMask && - pGC->fillStyle == FillSolid) - { - if (TERMINALFONT(pGC->font)) - { - if (sisTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE)) - return; - } - else - { - if (sisGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE)) - return; - } - } - KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); -} - -void -sisImageGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - FbBits depthMask; - - depthMask = FbFullMask (pDrawable->depth); - if ((pGC->planemask & depthMask) == depthMask) - { - if (TERMINALFONT(pGC->font)) - { - if (sisTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE)) - return; - } - else - { - if (sisGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE)) - return; - } - } - KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); -} - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#define sisPatternDimOk(d) ((d) <= 8 && (((d) & ((d) - 1)) == 0)) - -BOOL -sisFillOk (GCPtr pGC) -{ - FbBits depthMask; - - depthMask = FbFullMask(pGC->depth); - if ((pGC->planemask & depthMask) != depthMask) - return FALSE; - switch (pGC->fillStyle) { - case FillSolid: - return TRUE; - case FillTiled: - return (sisPatternDimOk (pGC->tile.pixmap->drawable.width) && - sisPatternDimOk (pGC->tile.pixmap->drawable.height)); - case FillStippled: - case FillOpaqueStippled: - return (sisPatternDimOk (pGC->stipple->drawable.width) && - sisPatternDimOk (pGC->stipple->drawable.height)); - } -} - -CARD32 -sisStipplePrepare (DrawablePtr pDrawable, GCPtr pGC) -{ - SetupSis(pGC->pScreen); - PixmapPtr pStip = pGC->stipple; - int stipHeight = pStip->drawable.height; - int xRot, yRot; - int rot, stipX, stipY; - FbStip *stip, *stipEnd, bits; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; /* XXX assumed to be zero */ - int y; - CARD32 cmd; - - xRot = pGC->patOrg.x + pDrawable->x; - yRot = pGC->patOrg.y + pDrawable->y; - modulus (- yRot, stipHeight, stipY); - modulus (- xRot, FB_UNIT, stipX); - rot = stipX; - - fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff); - for (y = 0; y < 8; y++) - { - bits = stip[stipY<<1]; - FbRotLeft(bits, rot); - SisInvertBits32(bits); - sis->u.general.mask[y] = (CARD8) bits; - stipY++; - if (stipY == stipHeight) - stipY = 0; - } - sis->u.general.pattern_fg = pGC->fgPixel; - - cmd = (SIS_CMD_BITBLT | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_MONO | - (sisPatRop[pGC->alu] << 8) | - SIS_CMD_INC_X | - SIS_CMD_INC_Y | - SIS_CMD_RECT_CLIP_DISABLE | - SIS_CMD_RECT_CLIP_DONT_MERGE); - if (pGC->fillStyle == FillOpaqueStippled) - { - sis->u.general.pattern_bg = pGC->bgPixel; - cmd |= SIS_CMD_OPAQUE; - } - else - cmd |= SIS_CMD_TRANSPARENT; - return cmd; -} - -CARD32 -sisTilePrepare (PixmapPtr pTile, int xRot, int yRot, CARD8 alu) -{ - SetupSis(pTile->drawable.pScreen); - int tileHeight = pTile->drawable.height; - int tileWidth = pTile->drawable.width; - FbBits *tile; - FbStride tileStride; - int tileBpp; - int tileXoff, tileYoff; /* XXX assumed to be zero */ - - fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff); - - /* - * Tile the pattern register - */ - fbTile ((FbBits *) sis->u.general.pattern, - (8 * tileBpp) >> FB_SHIFT, - 0, - - 8 * tileBpp, 8, - - tile, - tileStride, - tileWidth * tileBpp, - tileHeight, - GXcopy, FB_ALLONES, tileBpp, - xRot * tileBpp, - yRot); - - return (SIS_CMD_BITBLT | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_PATTERN | - (sisPatRop[alu] << 8) | - SIS_CMD_INC_X | - SIS_CMD_INC_Y | - SIS_CMD_RECT_CLIP_DISABLE | - SIS_CMD_RECT_CLIP_DONT_MERGE); -} - -void -sisFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, - unsigned long pixel, int alu) -{ - SetupSis(pDrawable->pScreen); - CARD32 cmd; - - _sisSetSolidRect(sis,pixel,alu,cmd); - - while (nBox--) - { - _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - -void -sisFillBoxStipple (DrawablePtr pDrawable, GCPtr pGC, - int nBox, BoxPtr pBox) -{ - SetupSis(pDrawable->pScreen); - CARD32 cmd; - - cmd = sisStipplePrepare (pDrawable, pGC); - - while (nBox--) - { - _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - -void -sisFillBoxTiled (DrawablePtr pDrawable, - int nBox, BoxPtr pBox, - PixmapPtr pTile, int xRot, int yRot, CARD8 alu) -{ - SetupSis (pDrawable->pScreen); - CARD32 cmd; - - cmd = sisTilePrepare (pTile, xRot, yRot, alu); - - while (nBox--) - { - _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); - pBox++; - } - KdMarkSync (pDrawable->pScreen); -} - -/* - sisDoBitBlt - ============= - Bit Blit for all window to window blits. -*/ - -void -sisCopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupSis(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)) - { - sisFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu); - return; - } - } - else - alu = GXcopy; - - _sisSetBlt(sis,alu,cmd); - while (nbox--) - { - w = pbox->x2 - pbox->x1; - h = pbox->y2 - pbox->y1; - flags = 0; - if (reverse) - { - dstX = pbox->x2 - 1; - } - else - { - dstX = pbox->x1; - flags |= SIS_CMD_INC_X; - } - srcX = dstX + dx; - - if (upsidedown) - { - dstY = pbox->y2 - 1; - } - else - { - dstY = pbox->y1; - flags |= SIS_CMD_INC_Y; - } - srcY = dstY + dy; - - _sisBlt (sis, srcX, srcY, dstX, dstY, w, h, cmd|flags); - pbox++; - } - KdMarkSync (pDstDrawable->pScreen); -} - -RegionPtr -sisCopyArea(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, sisCopyNtoN, 0, 0); - } - return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, dstx, dsty); -} - -typedef struct _sis1toNargs { - unsigned long copyPlaneFG, copyPlaneBG; -} sis1toNargs; - -void -_sisStipple (ScreenPtr pScreen, - FbStip *psrcBase, - FbStride widthSrc, - CARD8 alu, - int srcx, - int srcy, - int dstx, - int dsty, - int width, - int height) -{ - SetupSis(pScreen); - FbStip *psrcLine, *psrc; - FbStride widthRest; - FbStip bits, tmp, lastTmp; - int leftShift, rightShift; - int nl, nlMiddle; - int r; - SisExpand expand; - CARD32 *dst; - int hthis; - int hper; - int bwidth; - CARD32 cmd; - - sisExpandInit (pScreen, &expand); - - /* Compute blt address and parameters */ - psrc = psrcBase + srcy * widthSrc + (srcx >> 5); - nlMiddle = (width + 31) >> 5; - leftShift = srcx & 0x1f; - rightShift = 32 - leftShift; - widthRest = widthSrc - nlMiddle; - - cmd = (SIS_CMD_ENH_COLOR_EXPAND | - SIS_CMD_SRC_SCREEN | - SIS_CMD_PAT_FG | - (sisBltRop[alu] << 8) | - SIS_CMD_INC_X | - SIS_CMD_INC_Y | - SIS_CMD_OPAQUE | - SIS_CMD_RECT_CLIP_ENABLE); - - if (leftShift != 0) - widthRest--; - - sis->u.general.src_x = 0; - sis->u.general.src_y = 0; - sis->u.general.dst_x = dstx; - sis->u.general.rect_width = (width + 31) & ~31; - sis->u.general.clip_right = (dstx + width); - - bwidth = nlMiddle << 2; - hper = SIS_PATTERN_INC / bwidth; - if (hper == 0) - hper = 1; - - while (height) - { - hthis = hper; - if (hthis > height) - hthis = height; - dst = sisExpandAlloc (&expand, bwidth * hthis); - sis->u.general.src_base = expand.off; - sis->u.general.dst_y = dsty; - sis->u.general.rect_height = hthis; - - dsty += hthis; - height -= hthis; - - if (leftShift == 0) - { - while (hthis--) - { - nl = nlMiddle; - while (nl--) - { - tmp = *psrc++; - SisInvertBits32(tmp); - *dst++ = tmp; - } - psrc += widthRest; - } - } - else - { - while (hthis--) - { - bits = *psrc++; - nl = nlMiddle; - while (nl--) - { - tmp = FbStipLeft(bits, leftShift); - bits = *psrc++; - tmp |= FbStipRight(bits, rightShift); - SisInvertBits32(tmp); - *dst++ = tmp; - } - psrc += widthRest; - } - } - sis->u.general.command = cmd; - } - sis->u.general.clip_right = pScreenPriv->screen->width; -} - -void -sisCopy1toN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - SetupSis(pDstDrawable->pScreen); - - sis1toNargs *args = closure; - int dstx, dsty; - FbStip *psrcBase; - FbStride widthSrc; - int srcBpp; - int srcXoff, srcYoff; - - if (sourceInvarient (pGC->alu)) - { - sisFillBoxSolid (pDstDrawable, nbox, pbox, - pGC->bgPixel, pGC->alu); - return; - } - - fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); - - sis->u.general.src_fg = args->copyPlaneFG; - sis->u.general.src_bg = args->copyPlaneBG; - - while (nbox--) - { - dstx = pbox->x1; - dsty = pbox->y1; - - _sisStipple (pDstDrawable->pScreen, - psrcBase, widthSrc, - pGC->alu, - dstx + dx - srcXoff, dsty + dy - srcYoff, - dstx, dsty, - pbox->x2 - dstx, pbox->y2 - dsty); - pbox++; - } - KdMarkSync (pDstDrawable->pScreen); -} - -RegionPtr -sisCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long bitPlane) -{ - KdScreenPriv (pDstDrawable->pScreen); - RegionPtr ret; - sis1toNargs args; - FbBits depthMask; - - depthMask = FbFullMask (pDstDrawable->depth); - if ((pGC->planemask & depthMask) == depthMask && - pDstDrawable->type == DRAWABLE_WINDOW && - pSrcDrawable->depth == 1) - { - args.copyPlaneFG = pGC->fgPixel; - args.copyPlaneBG = pGC->bgPixel; - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, sisCopy1toN, bitPlane, &args); - } - return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, bitPlane); -} - -void -sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - SetupSis(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; - - if (!sisFillOk (pGC)) - { - KdCheckFillSpans (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; - switch (pGC->fillStyle) { - case FillSolid: - _sisSetSolidRect(sis,pGC->fgPixel,pGC->alu,cmd); - break; - case FillTiled: - cmd = sisTilePrepare (pGC->tile.pixmap, - pGC->patOrg.x + pDrawable->x, - pGC->patOrg.y + pDrawable->y, - pGC->alu); - break; - default: - cmd = sisStipplePrepare (pDrawable, pGC); - break; - } - while (n--) - { - x = ppt->x; - y = ppt->y; - ppt++; - width = *pwidth++; - if (width) - { - _sisRect(sis,x,y,width,1,cmd); - } - } - KdMarkSync (pDrawable->pScreen); - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); -} - -#define NUM_STACK_RECTS 1024 - -void -sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - SetupSis(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 (!sisFillOk (pGC)) - { - KdCheckPolyFillRect (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)ALLOCATE_LOCAL(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: - sisFillBoxSolid(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->fgPixel, pGC->alu); - break; - case FillTiled: - sisFillBoxTiled(pDrawable, - pboxClipped-pboxClippedBase, pboxClippedBase, - pGC->tile.pixmap, - pGC->patOrg.x + pDrawable->x, - pGC->patOrg.y + pDrawable->y, - pGC->alu); - break; - case FillStippled: - case FillOpaqueStippled: - sisFillBoxStipple (pDrawable, pGC, - pboxClipped-pboxClippedBase, pboxClippedBase); - break; - } - } - if (pboxClippedBase != stackRects) - DEALLOCATE_LOCAL(pboxClippedBase); -} - -static const GCOps sisOps = { - sisFillSpans, - KdCheckSetSpans, - KdCheckPutImage, - sisCopyArea, - sisCopyPlane, - KdCheckPolyPoint, - KdCheckPolylines, - KdCheckPolySegment, - miPolyRectangle, - KdCheckPolyArc, - miFillPolygon, - sisPolyFillRect, - KdCheckPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - sisImageGlyphBlt, - sisPolyGlyphBlt, - KdCheckPushPixels, -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -void -sisValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); - - fbValidateGC (pGC, changes, pDrawable); - - if (pDrawable->type == DRAWABLE_WINDOW) - pGC->ops = (GCOps *) &sisOps; - else - pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; -} - -GCFuncs sisGCFuncs = { - sisValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -int -sisCreateGC (GCPtr pGC) -{ - if (!fbCreateGC (pGC)) - return FALSE; - - if (pGC->depth != 1) - pGC->funcs = &sisGCFuncs; - - pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; - - return TRUE; -} - -void -sisCopyWindow(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, sisCopyNtoN, 0, 0); - - REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); -} - -void -sisPaintWindow(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; - case BackgroundPixmap: - pTile = pWin->background.pixmap; - if (sisPatternDimOk (pTile->drawable.width) && - sisPatternDimOk (pTile->drawable.height)) - { - sisFillBoxTiled ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pTile, - pWin->drawable.x, pWin->drawable.y, GXcopy); - return; - } - break; - case BackgroundPixel: - sisFillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixel, GXcopy); - return; - } - break; - case PW_BORDER: - if (pWin->borderIsPixel) - { - sisFillBoxSolid((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixel, GXcopy); - return; - } - else - { - pTile = pWin->border.pixmap; - if (sisPatternDimOk (pTile->drawable.width) && - sisPatternDimOk (pTile->drawable.height)) - { - sisFillBoxTiled ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pTile, - pWin->drawable.x, pWin->drawable.y, GXcopy); - return; - } - } - break; - } - KdCheckPaintWindow (pWin, pRegion, what); -} - -Bool -sisDrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - sisScreenInfo(pScreenPriv); - - /* - * Hook up asynchronous drawing - */ - KdScreenInitAsync (pScreen); - /* - * Replace various fb screen functions - */ - pScreen->CreateGC = sisCreateGC; - pScreen->CopyWindow = sisCopyWindow; - pScreen->PaintWindowBackground = sisPaintWindow; - pScreen->PaintWindowBorder = sisPaintWindow; - - return TRUE; -} - -void -sisDrawEnable (ScreenPtr pScreen) -{ - SetupSis(pScreen); - sisScreenInfo(pScreenPriv); - CARD32 cmd; - CARD32 base; - CARD16 stride; - CARD16 op; - - base = pScreenPriv->screen->fb[0].frameBuffer - sisc->frameBuffer; - stride = pScreenPriv->screen->fb[0].byteStride; -#if 0 - sis->u.general.dst_base = base; - sis->u.general.dst_pitch = stride; - sis->u.general.src_pitch = stride; - sis->u.general._pad0 = stride; - sis->u.general.dst_height = pScreenPriv->screen->height; - _sisClip (sis, 0, 0, - pScreenPriv->screen->width, pScreenPriv->screen->height); - _sisSetSolidRect(sis, pScreen->blackPixel, GXcopy, cmd); - _sisRect (sis, 0, 0, - pScreenPriv->screen->width, pScreenPriv->screen->height, - cmd); -#endif - base = (CARD32) (pScreenPriv->screen->fb[0].frameBuffer); - fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr); - sis->u.accel.src_addr = (base & 0x3fffff); - fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr); - sis->u.accel.dst_addr = (base & 0x3fffff); - sis->u.accel.pitch = (stride << 16) | stride; - sis->u.accel.dimension = ((pScreenPriv->screen->height-1) << 16 | - (pScreenPriv->screen->width - 1)); - sis->u.accel.fg = (sisBltRop[GXcopy] << 24) | 0xf800; - sis->u.accel.bg = (sisBltRop[GXcopy] << 24) | 0x00; - -#define sisLEFT2RIGHT 0x10 -#define sisRIGHT2LEFT 0x00 -#define sisTOP2BOTTOM 0x20 -#define sisBOTTOM2TOP 0x00 - -#define sisSRCSYSTEM 0x03 -#define sisSRCVIDEO 0x02 -#define sisSRCFG 0x01 -#define sisSRCBG 0x00 - -#define sisCMDBLT 0x0000 -#define sisCMDBLTMSK 0x0100 -#define sisCMDCOLEXP 0x0200 -#define sisCMDLINE 0x0300 - -#define sisCMDENHCOLEXP 0x2000 - -#define sisXINCREASE 0x10 -#define sisYINCREASE 0x20 -#define sisCLIPENABL 0x40 -#define sisCLIPINTRN 0x80 -#define sisCLIPEXTRN 0x00 - - -#define sisPATREG 0x08 -#define sisPATFG 0x04 -#define sisPATBG 0x00 - -#define sisLASTPIX 0x0800 -#define sisXMAJOR 0x0400 - - op = sisCMDBLT | sisLEFT2RIGHT | sisTOP2BOTTOM | sisSRCFG | sisPATFG; - - sis->u.accel.cmd = op; - - KdMarkSync (pScreen); -} - -void -sisDrawSync (ScreenPtr pScreen) -{ - SetupSis(pScreen); - - _sisWaitIdleEmpty (sis); -} - -void -sisDrawDisable (ScreenPtr pScreen) -{ -} - -void -sisDrawFini (ScreenPtr pScreen) -{ -} diff --git a/hw/kdrive/sis530/sisdraw.h b/hw/kdrive/sis530/sisdraw.h deleted file mode 100644 index 4bf67b2ac..000000000 --- a/hw/kdrive/sis530/sisdraw.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Id: sisdraw.h,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.h,v 1.1 1999/11/19 13:53:59 hohndel Exp $ */ - -#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 diff --git a/hw/kdrive/sis530/sisio.c b/hw/kdrive/sis530/sisio.c deleted file mode 100644 index 1a636a2f9..000000000 --- a/hw/kdrive/sis530/sisio.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Id: sisio.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sisio.c,v 1.1 1999/11/19 13:54:00 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#ifdef linux -#define extern -#include <asm/io.h> -#undef extern -#endif diff --git a/hw/kdrive/sis530/sisstub.c b/hw/kdrive/sis530/sisstub.c deleted file mode 100644 index f1f242b40..000000000 --- a/hw/kdrive/sis530/sisstub.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Id: sisstub.c,v 1.1 1999/11/02 08:20:07 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/sis530/sisstub.c,v 1.4 2000/08/09 17:52:44 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "sis.h" - -static const int sisCards[] = { 0x6306, 0x0200 }; - -#define numSisCards (sizeof (sisCards) / sizeof (sisCards[0])) - -void -InitCard (char *name) -{ - KdCardAttr attr; - int i; - - for (i = 0; i < numSisCards; i++) - if (LinuxFindPci (0x1039, sisCards[i], 0, &attr)) - KdCardInfoAdd (&sisFuncs, &attr, (void *) sisCards[i]); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am deleted file mode 100644 index 129330587..000000000 --- a/hw/kdrive/smi/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir)/hw/kdrive/fbdev \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @KDRIVE_INCS@ \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xsmi - -if TSLIB -TSLIB_FLAG = -lts -endif - -noinst_LIBRARIES = libsmi.a - -# smivideo.c # not ready yet - -libsmi_a_SOURCES = \ - smi.c \ - smi.h \ - smidraw.c \ - smidraw.h - -Xsmi_SOURCES = \ - smistub.c - -Xsmi_LDADD = \ - libsmi.a \ - $(top_builddir)/hw/kdrive/fbdev/libfbdev.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) diff --git a/hw/kdrive/smi/smi.c b/hw/kdrive/smi/smi.c deleted file mode 100644 index 635fca4da..000000000 --- a/hw/kdrive/smi/smi.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright © 2001 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: xc/programs/Xserver/hw/kdrive/smi/smi.c,v 1.11 2002/10/18 06:31:17 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "smi.h" -#include <sys/io.h> - -static Bool -smiCardInit (KdCardInfo *card) -{ - SmiCardInfo *smic; - - ENTER (); - smic = (SmiCardInfo *) xalloc (sizeof (SmiCardInfo)); - if (!smic) - return FALSE; - memset (smic, '\0', sizeof (SmiCardInfo)); - - (void) smiMapReg (card, smic); - - if (!subInitialize (card, &smic->sub)) - { - xfree (smic); - return FALSE; - } - - card->driver = smic; - LEAVE(); - return TRUE; -} - -static Bool -smiScreenInit (KdScreenInfo *screen) -{ - SmiCardInfo *smic = screen->card->driver; - SmiScreenInfo *smis; - - ENTER(); - smis = (SmiScreenInfo *) xalloc (sizeof (SmiScreenInfo)); - if (!smis) - return FALSE; - memset (smis, '\0', sizeof (SmiScreenInfo)); - screen->driver = smis; - if (!subScreenInitialize (screen, &smis->sub)) - { - xfree (smis); - return FALSE; - } - if (!smic->reg_base) - screen->dumb = TRUE; - screen->softCursor = TRUE; -#if SMI_VESA - smis->screen = smis->sub.fb; -#else - smis->screen = smic->sub.fb; -#endif - LEAVE(); - return TRUE; -} - -static Bool -smiInitScreen (ScreenPtr pScreen) -{ - Bool ret; - ENTER (); -#if 0 -#ifdef XV - KdScreenPriv(pScreen); - SmiCardInfo *smic = pScreenPriv->screen->card->driver; - if (smic->media_reg && smic->reg) - smiInitVideo(pScreen); -#endif -#endif - ret = subInitScreen (pScreen); - LEAVE(); - return ret; -} - -#ifdef RANDR -static Bool -smiRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) -{ - Bool ret; - - ENTER (); - KdCheckSync (pScreen); - - ret = subRandRSetConfig (pScreen, randr, rate, pSize); - LEAVE(); - return ret; -} - -static Bool -smiRandRInit (ScreenPtr pScreen) -{ - rrScrPriv(pScreen); - - ENTER (); - pScrPriv->rrSetConfig = smiRandRSetConfig; - LEAVE (); - return TRUE; -} -#endif - -static Bool -smiFinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - ret = subFinishInitScreen (pScreen); -#ifdef RANDR - smiRandRInit (pScreen); -#endif - return ret; -} - -void -smiPreserve (KdCardInfo *card) -{ - ENTER (); - subPreserve(card); - LEAVE(); -} - -Bool -smiMapReg (KdCardInfo *card, SmiCardInfo *smic) -{ - ENTER (); - smic->io_base = 0; /* only handles one SMI card at standard VGA address */ - smic->reg_base = (CARD8 *) KdMapDevice (SMI_REG_BASE(card), - SMI_REG_SIZE(card)); - - if (!smic->reg_base) - { - smic->dpr = 0; - return FALSE; - } - - KdSetMappedMode (SMI_REG_BASE(card), - SMI_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - smic->dpr = (DPR *) (smic->reg_base + SMI_DPR_OFF(card)); - LEAVE (); - return TRUE; -} - -void -smiUnmapReg (KdCardInfo *card, SmiCardInfo *smic) -{ - ENTER (); - if (smic->reg_base) - { - KdResetMappedMode (SMI_REG_BASE(card), - SMI_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) smic->reg_base, SMI_REG_SIZE(card)); - smic->reg_base = 0; - smic->dpr = 0; - } - LEAVE (); -} - -void -smiOutb (CARD16 port, CARD8 val) -{ - asm volatile ("outb %b0,%w1" : : "a" (val), "d" (port)); -} - -CARD8 -smiInb (CARD16 port) -{ - CARD8 v; - asm volatile ("inb %w1,%b0" : "=a" (v) : "d" (port)); - return v; -} - -CARD8 -smiGetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id) -{ - smiOutb (smic->io_base + addr, id); - return smiInb (smic->io_base + data); -} - -void -smiSetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id, CARD8 val) -{ - smiOutb (smic->io_base + addr, id); - smiOutb (smic->io_base + data, val); -} - -void -smiSetMMIO (KdCardInfo *card, SmiCardInfo *smic) -{ - ENTER (); - if (!smic->reg_base) - smiMapReg (card, smic); - LEAVE(); -} - -void -smiResetMMIO (KdCardInfo *card, SmiCardInfo *smic) -{ - smiUnmapReg (card, smic); -} - -static Bool -smiDPMS (ScreenPtr pScreen, int mode) -{ - Bool ret; - ENTER (); - ret = subDPMS (pScreen, mode); - LEAVE (); - return ret; -} - -Bool -smiEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - SmiCardInfo *smic = pScreenPriv->card->driver; - - ENTER (); - iopl (3); - if (!subEnable (pScreen)) - return FALSE; - - smiSetMMIO (pScreenPriv->card, smic); - smiDPMS (pScreen, KD_DPMS_NORMAL); -#if 0 -#ifdef XV - KdXVEnable (pScreen); -#endif -#endif - LEAVE (); - return TRUE; -} - -void -smiDisable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - SmiCardInfo *smic = pScreenPriv->card->driver; - - ENTER (); -#if 0 -#ifdef XV - KdXVDisable (pScreen); -#endif -#endif - smiResetMMIO (pScreenPriv->card, smic); - subDisable (pScreen); - LEAVE (); -} - -static void -smiRestore (KdCardInfo *card) -{ - ENTER (); - subRestore (card); - LEAVE(); -} - -static void -smiScreenFini (KdScreenInfo *screen) -{ - SmiScreenInfo *smis = (SmiScreenInfo *) screen->driver; - - ENTER (); - subScreenFini (screen); - xfree (smis); - screen->driver = 0; - LEAVE (); -} - -static void -smiCardFini (KdCardInfo *card) -{ - SmiCardInfo *smic = card->driver; - - ENTER (); - smiUnmapReg (card, smic); - subCardFini (card); - LEAVE (); -} - -#define smiCursorInit 0 /* initCursor */ -#define smiCursorEnable 0 /* enableCursor */ -#define smiCursorDisable 0 /* disableCursor */ -#define smiCursorFini 0 /* finiCursor */ -#define smiRecolorCursor 0 /* recolorCursor */ - -KdCardFuncs smiFuncs = { - smiCardInit, /* cardinit */ - smiScreenInit, /* scrinit */ - smiInitScreen, /* initScreen */ - smiFinishInitScreen, /* finishInitScreen */ - subCreateResources, /* createRes */ - smiPreserve, /* preserve */ - smiEnable, /* enable */ - smiDPMS, /* dpms */ - smiDisable, /* disable */ - smiRestore, /* restore */ - smiScreenFini, /* scrfini */ - smiCardFini, /* cardfini */ - - smiCursorInit, /* initCursor */ - smiCursorEnable, /* enableCursor */ - smiCursorDisable, /* disableCursor */ - smiCursorFini, /* finiCursor */ - smiRecolorCursor, /* recolorCursor */ - - smiDrawInit, /* initAccel */ - smiDrawEnable, /* enableAccel */ - smiDrawSync, /* syncAccel */ - smiDrawDisable, /* disableAccel */ - smiDrawFini, /* finiAccel */ - - subGetColors, /* getColors */ - subPutColors, /* putColors */ -}; diff --git a/hw/kdrive/smi/smi.h b/hw/kdrive/smi/smi.h deleted file mode 100644 index abee819bf..000000000 --- a/hw/kdrive/smi/smi.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Id: smi.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * Copyright © 2001 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: xc/programs/Xserver/hw/kdrive/smi/smi.h,v 1.6 2001/07/24 19:06:03 keithp Exp $ */ - -#ifndef _SMI_H_ -#define _SMI_H_ - -#define SMI_VESA 0 - -#if SMI_VESA -#include <vesa.h> -#define subGetColors vesaGetColors -#define subPutColors vesaPutColors -#define subInitialize vesaInitialize -#define subScreenInitialize vesaScreenInitialize -#define subInitScreen vesaInitScreen -#define subFinishInitScreen vesaFinishInitScreen -#define subCreateResources vesaCreateResources -#define subRandRSetConfig vesaRandRSetConfig -#define subPreserve vesaPreserve -#define subEnable vesaEnable -#define subDPMS vesaDPMS -#define subRestore vesaRestore -#define subScreenFini vesaScreenFini -#define subCardFini vesaCardFini -#define subDisable vesaDisable -#define SubCardPrivRec VesaCardPrivRec -#define SubScreenPrivRec VesaScreenPrivRec -#define subProcessArgument(c,v,i) vesaProcessArgument(c,v,i) -#else -#include <fbdev.h> -#define subGetColors fbdevGetColors -#define subPutColors fbdevPutColors -#define subInitialize fbdevInitialize -#define subScreenInitialize fbdevScreenInitialize -#define subInitScreen fbdevInitScreen -#define subFinishInitScreen fbdevFinishInitScreen -#define subCreateResources fbdevCreateResources -#define subRandRSetConfig fbdevRandRSetConfig -#define subPreserve fbdevPreserve -#define subEnable fbdevEnable -#define subDPMS fbdevDPMS -#define subRestore fbdevRestore -#define subScreenFini fbdevScreenFini -#define subCardFini fbdevCardFini -#define subDisable fbdevDisable -#define SubCardPrivRec FbdevPriv -#define SubScreenPrivRec FbdevScrPriv -#define subProcessArgument(c,v,i) 0 -#endif - -#include "kxv.h" - -#define SMI_DEBUG 0 -#if SMI_DEBUG -#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a) -#else -#define DBGOUT(fmt,a...) -#endif - -#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__) -#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__) - -/* - * offset from ioport beginning - */ - -#define SMI_IO_BASE(c) ((c)->attr.io) -#define SMI_REG_BASE(c) ((c)->attr.address[0]) -#define SMI_REG_SIZE(c) (4096) - -#define SMI_DPR_OFF(c) (0x00000) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -/* DPR reg */ -typedef struct _DPR { - VOL32 src_xy; /* 0x00 */ - VOL32 dst_xy; /* 0x04 */ - VOL32 dst_wh; /* 0x08 */ - VOL32 accel_cmd; /* 0x0c */ - VOL32 src_stride; /* 0x10 */ - VOL32 fg; /* 0x14 */ - VOL32 bg; /* 0x18 */ - VOL32 data_format; /* 0x1c */ - VOL32 transparent; /* 0x20 */ - VOL32 mask1; /* 0x24 ? */ - VOL32 mask2; /* 0x28 ? */ - VOL32 scissors_ul; /* 0x2c */ - VOL32 scissors_lr; /* 0x30 */ - VOL32 mask3; /* 0x34 */ - VOL32 mask4; /* 0x38 */ - VOL32 dst_stride; /* 0x3c */ - VOL32 unknown_40; /* 0x40 */ - VOL32 unknown_44; /* 0x44 */ -} DPR; - -#define SMI_XY(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16)) - -/* 2D Engine commands */ -#define SMI_TRANSPARENT_SRC 0x00000100 -#define SMI_TRANSPARENT_DEST 0x00000300 - -#define SMI_OPAQUE_PXL 0x00000000 -#define SMI_TRANSPARENT_PXL 0x00000400 - -#define SMI_MONO_PACK_8 0x00001000 -#define SMI_MONO_PACK_16 0x00002000 -#define SMI_MONO_PACK_32 0x00003000 - -#define SMI_ROP2_SRC 0x00008000 -#define SMI_ROP2_PAT 0x0000C000 -#define SMI_ROP3 0x00000000 - -#define SMI_BITBLT 0x00000000 -#define SMI_RECT_FILL 0x00010000 -#define SMI_TRAPEZOID_FILL 0x00030000 -#define SMI_SHORT_STROKE 0x00060000 -#define SMI_BRESENHAM_LINE 0x00070000 -#define SMI_HOSTBLT_WRITE 0x00080000 -#define SMI_HOSTBLT_READ 0x00090000 -#define SMI_ROTATE_BLT 0x000B0000 - -#define SMI_SRC_COLOR 0x00000000 -#define SMI_SRC_MONOCHROME 0x00400000 - -#define SMI_GRAPHICS_STRETCH 0x00800000 - -#define SMI_ROTATE_CW 0x01000000 -#define SMI_ROTATE_CCW 0x02000000 - -#define SMI_MAJOR_X 0x00000000 -#define SMI_MAJOR_Y 0x04000000 - -#define SMI_LEFT_TO_RIGHT 0x00000000 -#define SMI_RIGHT_TO_LEFT 0x08000000 - -#define SMI_COLOR_PATTERN 0x40000000 -#define SMI_MONO_PATTERN 0x00000000 - -#define SMI_QUICK_START 0x10000000 -#define SMI_START_ENGINE 0x80000000 - -#define VGA_SEQ_INDEX 0x3C4 -#define VGA_SEQ_DATA 0x3C5 - -typedef struct _smiCardInfo { - SubCardPrivRec sub; - CARD16 io_base; - CARD8 *reg_base; - DPR *dpr; - int avail; -} SmiCardInfo; - -#define getSmiCardInfo(kd) ((SmiCardInfo *) ((kd)->card->driver)) -#define smiCardInfo(kd) SmiCardInfo *smic = getSmiCardInfo(kd) - -typedef struct _smiScreenInfo { - SubScreenPrivRec sub; - CARD8 *screen; - CARD32 stride; - CARD32 data_format; - CARD8 dpr_vpr_enable; -} SmiScreenInfo; - -#define getSmiScreenInfo(kd) ((SmiScreenInfo *) ((kd)->screen->driver)) -#define smiScreenInfo(kd) SmiScreenInfo *smis = getSmiScreenInfo(kd) - -void -smiPreserve (KdCardInfo *card); - -Bool -smiMapReg (KdCardInfo *card, SmiCardInfo *smic); - -void -smiUnmapReg (KdCardInfo *card, SmiCardInfo *smic); - -void -smiOutb (CARD16 port, CARD8 val); - -CARD8 -smiInb (CARD16 port); - -CARD8 -smiGetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id); - -void -smiSetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id, CARD8 val); - -void -smiSetMMIO (KdCardInfo *card, SmiCardInfo *smic); - -void -smiResetMMIO (KdCardInfo *card, SmiCardInfo *smic); - -Bool -smiEnable (ScreenPtr pScreen); - -void -smiDisable (ScreenPtr pScreen); - -void -smiWaitAvail(SmiCardInfo *smic, int n); - -void -smiWaitIdle (SmiCardInfo *smic); - -Bool -smiDrawSetup (ScreenPtr pScreen); - -Bool -smiDrawInit (ScreenPtr pScreen); - -void -smiDrawReinit (ScreenPtr pScreen); - -void -smiDrawEnable (ScreenPtr pScreen); - -void -smiDrawSync (ScreenPtr pScreen); - -void -smiDrawDisable (ScreenPtr pScreen); - -void -smiDrawFini (ScreenPtr pScreen); - -CARD8 -smiReadIndex (SmiCardInfo *smic, CARD16 port, CARD8 index); - -void -smiWriteIndex (SmiCardInfo *smic, CARD16 port, CARD8 index, CARD8 value); - -extern KdCardFuncs smiFuncs; - -#endif /* _SMI_H_ */ diff --git a/hw/kdrive/smi/smidraw.c b/hw/kdrive/smi/smidraw.c deleted file mode 100644 index d1691fce0..000000000 --- a/hw/kdrive/smi/smidraw.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Id: smidraw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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: xc/programs/Xserver/hw/kdrive/smi/smidraw.c,v 1.7 2001/07/24 19:06:03 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "smi.h" -#include "smidraw.h" - -#include <X11/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" -#include "picturestr.h" - -CARD8 smiBltRop[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 */ -}; - -CARD8 smiSolidRop[16] = { - /* GXclear */ 0x00, /* 0 */ - /* GXand */ 0xa0, /* src AND dst */ - /* GXandReverse */ 0x50, /* src AND NOT dst */ - /* GXcopy */ 0xf0, /* src */ - /* GXandInverted*/ 0x0a, /* NOT src AND dst */ - /* GXnoop */ 0xaa, /* dst */ - /* GXxor */ 0x5a, /* src XOR dst */ - /* GXor */ 0xfa, /* src OR dst */ - /* GXnor */ 0x05, /* NOT src AND NOT dst */ - /* GXequiv */ 0xa5, /* NOT src XOR dst */ - /* GXinvert */ 0x55, /* NOT dst */ - /* GXorReverse */ 0xf5, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x0f, /* NOT src */ - /* GXorInverted */ 0xaf, /* NOT src OR dst */ - /* GXnand */ 0x5f, /* NOT src OR NOT dst */ - /* GXset */ 0xff, /* 1 */ -}; - - -#define GET_STATUS(smic) smiGetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) - -#define ENGINE_IDLE_EMPTY(smic) ((GET_STATUS(smic) & 0x18) == 0x10) -#define FIFO_EMPTY(smic) ((GET_STATUS(smic) & 0x10) == 0x10) - -#define MAX_FIFO 16 - -void -smiWaitAvail(SmiCardInfo *smic, int n) -{ - if (smic->avail < n) - { - while (!FIFO_EMPTY (smic)) - ; - smic->avail = MAX_FIFO; - } - smic->avail -= n; -} - -void -smiWaitIdle (SmiCardInfo *smic) -{ - while (!ENGINE_IDLE_EMPTY (smic)) - ; - smic->avail = MAX_FIFO; -} - -static SmiCardInfo *smic; -static SmiScreenInfo *smis; -static DPR *dpr; -static CARD32 accel_cmd; - -static Bool -smiSetup (ScreenPtr pScreen, int wait) -{ - KdScreenPriv(pScreen); - - smis = getSmiScreenInfo (pScreenPriv); - smic = getSmiCardInfo(pScreenPriv); - dpr = smic->dpr; - - if (!dpr) - return FALSE; - - /* enable DPR/VPR registers */ - smiSetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, - smis->dpr_vpr_enable); - - smiWaitAvail (smic, wait + 9); - dpr->src_stride = (smis->stride << 16) | smis->stride; - dpr->data_format = smis->data_format; - dpr->mask1 = 0xffffffff; - dpr->mask2 = 0xffffffff; - dpr->dst_stride = (smis->stride << 16) | smis->stride; - dpr->unknown_40 = 0x0; - dpr->unknown_44 = 0x0; - dpr->scissors_ul = 0x0; - dpr->scissors_lr = SMI_XY(4095,4095); - - return TRUE; -} - -static Bool -smiPrepareSolid (PixmapPtr pPixmap, - int alu, - Pixel pm, - Pixel fg) -{ - if (~pm & FbFullMask(pPixmap->drawable.depth)) - return FALSE; - - if (!smiSetup (pPixmap->drawable.pScreen, 3)) - return FALSE; - - accel_cmd = smiSolidRop[alu] | SMI_BITBLT | SMI_START_ENGINE; - dpr->fg = fg; - dpr->mask3 = 0xffffffff; - dpr->mask4 = 0xffffffff; - return TRUE; -} - -static void -smiSolid (int x1, int y1, int x2, int y2) -{ - smiWaitAvail(smic,3); - dpr->dst_xy = SMI_XY(x1,y1); - dpr->dst_wh = SMI_XY(x2-x1,y2-y1); - dpr->accel_cmd = accel_cmd; -} - -static void -smiDoneSolid (void) -{ -} - -static int copyDx; -static int copyDy; - -static Bool -smiPrepareCopy (PixmapPtr pSrcPixmap, - PixmapPtr pDstPixmap, - int dx, - int dy, - int alu, - Pixel pm) -{ - if (~pm & FbFullMask(pSrcPixmap->drawable.depth)) - return FALSE; - - if (!smiSetup (pSrcPixmap->drawable.pScreen, 0)) - return FALSE; - - accel_cmd = smiBltRop[alu] | SMI_BITBLT | SMI_START_ENGINE; - - copyDx = dx; - copyDy = dy; - if (dy < 0 || (dy == 0 && dx < 0)) - accel_cmd |= SMI_RIGHT_TO_LEFT; - return TRUE; -} - -static void -smiCopy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - if (accel_cmd & SMI_RIGHT_TO_LEFT) - { - srcX += w - 1; - dstX += w - 1; - srcY += h - 1; - dstY += h - 1; - } - smiWaitAvail (smic, 4); - dpr->src_xy = SMI_XY (srcX, srcY); - dpr->dst_xy = SMI_XY (dstX, dstY); - dpr->dst_wh = SMI_XY (w, h); - dpr->accel_cmd = accel_cmd; -} - -static void -smiDoneCopy (void) -{ -} - -KaaScreenInfoRec smiKaa = { - smiPrepareSolid, - smiSolid, - smiDoneSolid, - - smiPrepareCopy, - smiCopy, - smiDoneCopy, -}; - -Bool -smiDrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - smiCardInfo (pScreenPriv); - - ENTER (); - if (pScreenPriv->screen->fb[0].depth == 4) - { - LEAVE (); - return FALSE; - } - - if (!smic->dpr) - { - LEAVE (); - return FALSE; - } - - if (!kaaDrawInit (pScreen, &smiKaa)) - { - LEAVE (); - return FALSE; - } - - LEAVE (); - return TRUE; -} - -void -smiDrawEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - int i; - static const int xyAddress[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 }; - - ENTER (); - smis = getSmiScreenInfo (pScreenPriv); - smic = getSmiCardInfo(pScreenPriv); - dpr = smic->dpr; - - smis->stride = pScreenPriv->screen->fb[0].byteStride; - smis->dpr_vpr_enable = smiGetIndex (smic, VGA_SEQ_INDEX, - VGA_SEQ_DATA, 0x21) & ~0x03; - - switch (pScreenPriv->screen->fb[0].depth) { - case 8: - smis->data_format = 0x00000000; - break; - case 15: - case 16: - smis->data_format = 0x00100000; - smis->stride >>= 1; - break; - case 24: - smis->data_format = 0x00300000; - break; - case 32: - smis->data_format = 0x00200000; - smis->stride >>= 2; - break; - } - for (i = 0; i < sizeof(xyAddress) / sizeof(xyAddress[0]); i++) - { - if (xyAddress[i] == pScreenPriv->screen->fb[0].pixelStride) - { - smis->data_format |= i << 16; - break; - } - } - - smiSetup (pScreen, 0); - KdMarkSync (pScreen); - LEAVE (); -} - -void -smiDrawDisable (ScreenPtr pScreen) -{ - ENTER (); - smic = 0; - smis = 0; - dpr = 0; - accel_cmd = 0; - LEAVE (); -} - -void -smiDrawFini (ScreenPtr pScreen) -{ - ENTER (); - LEAVE (); -} - -void -smiDrawSync (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - smic = getSmiCardInfo(pScreenPriv); - - smiWaitIdle (smic); -} diff --git a/hw/kdrive/smi/smidraw.h b/hw/kdrive/smi/smidraw.h deleted file mode 100644 index 3ec0831fc..000000000 --- a/hw/kdrive/smi/smidraw.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Id: smidraw.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.h,v 1.1 2001/06/03 18:48:19 keithp Exp $ */ - -#ifndef _SMIDRAW_H_ -#define _SMIDRAW_H_ - -#define SetupSmi(s) KdScreenPriv(s); \ - smiCardInfo(pScreenPriv); \ - Cop *cop = smic->cop - -#define SmiAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) - -#define _smiInit(cop,smic) { \ - if ((cop)->status == 0xffffffff) smiSetMMIO(smic); \ - (cop)->multi = (smic)->cop_depth; \ - (cop)->multi = (smic)->cop_stride; \ - (cop)->multi = SmiAlpha; \ -} \ - -#define _smiSetSolidRect(cop,pix,alu,cmd) {\ - cop->multi = COP_MULTI_PATTERN; \ - cop->multi = COP_MULTI_ROP | smiRop[alu]; \ - cop->fg = (pix); \ - cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \ -} - -#define _smiRect(cop,x1,y1,x2,y2,cmd) { \ - (cop)->dst_start_xy = TRI_XY (x1,y1); \ - (cop)->dst_end_xy = TRI_XY(x2,y2); \ - _smiWaitDone(cop); \ - (cop)->command = (cmd); \ -} - -#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ - COP_STATUS_DPE_BUSY | \ - COP_STATUS_MI_BUSY) - -#define _smiWaitDone(cop) { \ - int __q__ = 500000; \ - while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ - ; \ - if (!__q__) \ - (cop)->status = 0; \ -} - -#define _smiWaitIdleEmpty(cop) _smiWaitDone(cop) - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/smi/smistub.c b/hw/kdrive/smi/smistub.c deleted file mode 100644 index fb4e1bad7..000000000 --- a/hw/kdrive/smi/smistub.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Id: smistub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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: xc/programs/Xserver/hw/kdrive/smi/smistub.c,v 1.4 2002/10/08 21:25:35 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "smi.h" -#include "klinux.h" - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x126f, 0x0720, 0, &attr)) - KdCardInfoAdd (&smiFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = subProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/smi/smivideo.c b/hw/kdrive/smi/smivideo.c deleted file mode 100644 index 2395ebec7..000000000 --- a/hw/kdrive/smi/smivideo.c +++ /dev/null @@ -1,1016 +0,0 @@ -/* - * Copyright © 2001 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: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.10 2003/04/23 21:51:18 tsi Exp $ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" - -#include "Xv.h" -#include "../../xfree86/common/fourcc.h" - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -static Atom xvBrightness, xvSaturation, xvColorKey; - -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 - -static void -mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - - if (!media) - return; - - if(pPortPriv->videoOn) - { - mach64WaitIdle (reg); - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - /* wait for buffer to be finished */ - while (((media->TRIG_CNTL >> 6) & 1) != 0) - ; - mach64WaitAvail (reg, 1); - media->OVERLAY_SCALE_CNTL = 0; - pPortPriv->videoOn = FALSE; - mach64WaitIdle (reg); - } -} - -static int -mach64SetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int value, - pointer data) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - MediaReg *media = mach64c->media_reg; - - if(attribute == xvBrightness) - { - if(value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->brightness = value; - } - else if(attribute == xvSaturation) - { - if (value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->saturation = value; - } - else if(attribute == xvColorKey) - { - if (pPortPriv->colorKey != value) - { - pPortPriv->colorKey = value; - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - } - } - else - return BadMatch; - - return Success; -} - -static int -mach64GetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int *value, - pointer data) -{ - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - - if(attribute == xvBrightness) - *value = pPortPriv->brightness; - else if(attribute == xvSaturation) - *value = pPortPriv->saturation; - else if(attribute == xvColorKey) - *value = pPortPriv->colorKey; - else - return BadMatch; - - return Success; -} - -static void -mach64QueryBestSize(KdScreenInfo *screen, - Bool motion, - short vid_w, - short vid_h, - short drw_w, - short drw_h, - unsigned int *p_w, - unsigned int *p_h, - pointer data) -{ - *p_w = drw_w; - *p_h = drw_h; -} - - -static void -mach64CopyPackedData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int dstPitch, - int srcW, - int srcH, - int top, - int left, - int h, - int w) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - CARD8 *src, *dst; - int srcDown, srcRight, srcNext; - int p; - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - src = buf; - srcDown = srcPitch; - srcRight = 2; - break; - case RR_Rotate_90: - src = buf + (srcH - 1) * 2; - srcDown = -2; - srcRight = srcPitch; - break; - case RR_Rotate_180: - src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; - srcDown = -srcPitch; - srcRight = -2; - break; - case RR_Rotate_270: - src = buf + srcPitch * (srcW - 1); - srcDown = 2; - srcRight = -srcPitch; - break; - } - - src = src + top*srcDown + left*srcRight; - - if (pPortPriv->currentBuf == 0) - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - srcRight >>= 1; - srcNext = srcRight >> 1; - while(h--) - { - CARD16 *s = (CARD16 *) src; - CARD32 *d = (CARD32 *) dst; - p = w; - while (p--) - { - *d++ = s[0] | (s[srcNext] << 16); - s += srcRight; - } - src += srcPitch; - dst += dstPitch; - } -} - -static void -mach64CopyPlanarData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int srcPitch2, - int dstPitch, /* of chroma */ - int srcW, - int srcH, - int height, - int top, - int left, - int h, - int w, - int id) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - int i, j; - CARD8 *src1, *src2, *src3, *dst1; - int srcDown, srcDown2, srcRight, srcRight2, srcNext; - - /* compute source data pointers */ - src1 = buf; - src2 = src1 + height * srcPitch; - src3 = src2 + (height >> 1) * srcPitch2; - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - srcDown = srcPitch; - srcDown2 = srcPitch2; - srcRight = 2; - srcRight2 = 1; - srcNext = 1; - break; - case RR_Rotate_90: - src1 = src1 + srcH - 1; - src2 = src2 + (srcH >> 1) - 1; - src3 = src3 + (srcH >> 1) - 1; - srcDown = -1; - srcDown2 = -1; - srcRight = srcPitch * 2; - srcRight2 = srcPitch2; - srcNext = srcPitch; - break; - case RR_Rotate_180: - src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); - src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - srcDown = -srcPitch; - srcDown2 = -srcPitch2; - srcRight = -2; - srcRight2 = -1; - srcNext = -1; - break; - case RR_Rotate_270: - src1 = src1 + srcPitch * (srcW - 1); - src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); - srcDown = 1; - srcDown2 = 1; - srcRight = -srcPitch * 2; - srcRight2 = -srcPitch2; - srcNext = -srcPitch; - break; - } - - /* adjust for origin */ - src1 += top * srcDown + left * srcNext; - src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - - if (id == FOURCC_I420) - { - CARD8 *srct = src2; - src2 = src3; - src3 = srct; - } - - if (pPortPriv->currentBuf == 0) - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - for (j = 0; j < h; j++) - { - CARD32 *dst = (CARD32 *) dst1; - CARD8 *s1l = src1; - CARD8 *s1r = src1 + srcNext; - CARD8 *s2 = src2; - CARD8 *s3 = src3; - - for (i = 0; i < w; i++) - { - *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); - s1l += srcRight; - s1r += srcRight; - s2 += srcRight2; - s3 += srcRight2; - } - src1 += srcDown; - dst1 += dstPitch; - if (j & 1) - { - src2 += srcDown2; - src3 += srcDown2; - } - } -} - -static void -mach64PaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg) -{ - WindowPtr pRoot = WindowTable[pScreen->myNum]; - GCPtr pGC; - CARD32 val[2]; - xRectangle *rects, *r; - BoxPtr pBox = REGION_RECTS (pRgn); - int nBox = REGION_NUM_RECTS (pRgn); - - rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle)); - if (!rects) - goto bail0; - r = rects; - while (nBox--) - { - r->x = pBox->x1; - r->y = pBox->y1; - r->width = pBox->x2 - pBox->x1; - r->height = pBox->y2 - pBox->y1; - r++; - pBox++; - } - - pGC = GetScratchGC (pRoot->drawable.depth, pScreen); - if (!pGC) - goto bail1; - - val[0] = fg; - val[1] = IncludeInferiors; - ChangeGC (pGC, GCForeground|GCSubwindowMode, val); - - ValidateGC (&pRoot->drawable, pGC); - - (*pGC->ops->PolyFillRect) (&pRoot->drawable, pGC, - REGION_NUM_RECTS (pRgn), rects); - - FreeScratchGC (pGC); -bail1: - DEALLOCATE_LOCAL (rects); -bail0: - ; -} - -/* Mach64ClipVideo - - - Takes the dst box in standard X BoxRec form (top and left - edges inclusive, bottom and right exclusive). The new dst - box is returned. The source boundaries are given (x1, y1 - inclusive, x2, y2 exclusive) and returned are the new source - boundaries in 16.16 fixed point. -*/ - -static void -Mach64ClipVideo(BoxPtr dst, - INT32 *x1, - INT32 *x2, - INT32 *y1, - INT32 *y2, - BoxPtr extents, /* extents of the clip region */ - INT32 width, - INT32 height) -{ - INT32 vscale, hscale, delta; - int diff; - - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - - *x1 <<= 16; *x2 <<= 16; - *y1 <<= 16; *y2 <<= 16; - - diff = extents->x1 - dst->x1; - if(diff > 0) { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } - diff = dst->x2 - extents->x2; - if(diff > 0) { - dst->x2 = extents->x2; - *x2 -= diff * hscale; - } - diff = extents->y1 - dst->y1; - if(diff > 0) { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } - diff = dst->y2 - extents->y2; - if(diff > 0) { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } - - if(*x1 < 0) { - diff = (- *x1 + hscale - 1)/ hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } - delta = *x2 - (width << 16); - if(delta > 0) { - diff = (delta + hscale - 1)/ hscale; - dst->x2 -= diff; - *x2 -= diff * hscale; - } - if(*y1 < 0) { - diff = (- *y1 + vscale - 1)/ vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } - delta = *y2 - (height << 16); - if(delta > 0) { - diff = (delta + vscale - 1)/ vscale; - dst->y2 -= diff; - *y2 -= diff * vscale; - } -} - -static void -mach64DisplayVideo(KdScreenInfo *screen, - int id, - int dstPitch, /* of chroma for 4:2:0 */ - int x1, - int y1, - int x2, - int y2, - int dst_x1, - int dst_y1, - int dst_x2, - int dst_y2, - short src_w, - short src_h, - short drw_w, - short drw_h) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - int xscaleInt, xscaleFract, yscaleInt, yscaleFract; - int xscaleIntUV = 0, xscaleFractUV = 0; - int yscaleIntUV = 0, yscaleFractUV = 0; - int randr = mach64s->vesa.randr; - int HORZ_INC, VERT_INC; - CARD32 SCALER_IN; - CARD32 OVERLAY_SCALE_CNTL; - int tmp; - int left; - int bright; - int sat; - - if (id == FOURCC_UYVY) - SCALER_IN = SCALER_IN_YVYU422; - else - SCALER_IN = SCALER_IN_VYUY422; - - mach64WaitAvail (reg, 4); - - media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; - - /* color key */ - media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; - media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; - /* set key control to obey only graphics color key */ - media->OVERLAY_KEY_CNTL = 0x50; - - mach64WaitAvail (reg, 9); - media->CAPTURE_DEBUG = 0; - /* no exclusive video region */ - media->OVERLAY_EXCLUSIVE_HORZ = 0; - media->OVERLAY_EXCLUSIVE_VERT = 0; - /* scaling coefficients */ - media->SCALER_H_COEFF0 = 0x00002000; - media->SCALER_H_COEFF1 = 0x0D06200D; - media->SCALER_H_COEFF2 = 0x0D0A1C0D; - media->SCALER_H_COEFF3 = 0x0C0E1A0C; - media->SCALER_H_COEFF4 = 0x0C14140C; - media->SCALER_TEST = 0; - - mach64WaitAvail (reg, 2); - media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | - SCALE_GAMMA_BRIGHT | - SCALE_BANDWIDTH | - SCALE_OVERLAY_EN | - SCALE_EN); - - bright = (pPortPriv->brightness * 64 / 1000); - if (bright < -0x40) - bright = -0x40; - if (bright > 0x3f) - bright = 0x3f; - bright = bright & 0x7f; - sat = ((pPortPriv->saturation * 31 + 31000) / 2000); - if (sat > 0x1f) - sat = 0x1f; - if (sat < 0) - sat = 0; - - media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ - (sat << 8) | /* SATURATION_U */ - (sat << 16) | /* SATURATION_V */ - (0 << 21) | /* SCALER_VERT_ADJ_UV */ - (0 << 28)); /* SCALER_HORZ_ADJ_UV */ - - VERT_INC = (src_h << 12) / drw_h; - HORZ_INC = (src_w << 12) / drw_w; - - mach64WaitAvail (reg, 13); - - /* lock registers to prevent non-atomic update */ - media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1); - /* ending screen coordinate */ - media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2); - - media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC); - - media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; - - media->SCALER_BUF_PITCH = dstPitch >> 1; - media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); - - media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; - - /* set XY location and unlock */ - media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1); -} - -static int -mach64PutImage(KdScreenInfo *screen, - short src_x, - short src_y, - short drw_x, - short drw_y, - short src_w, - short src_h, - short drw_w, - short drw_h, - int id, - unsigned char *buf, - short width, - short height, - Bool sync, - RegionPtr clipBoxes, - pointer data) -{ - KdCardInfo *card = screen->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - INT32 x1, x2, y1, y2; - int randr = mach64s->vesa.randr; - int srcPitch, srcPitch2, dstPitch; - int top, left, npixels, nlines, size; - BoxRec dstBox; - int dst_width = width, dst_height = height; - int rot_x1, rot_y1, rot_x2, rot_y2; - int dst_x1, dst_y1, dst_x2, dst_y2; - int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; - - /* Clip */ - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2, - REGION_EXTENTS(pScreen, clipBoxes), width, height); - - if((x1 >= x2) || (y1 >= y2)) - return Success; - - if (!media) - return BadAlloc; - - if (randr & (RR_Rotate_0|RR_Rotate_180)) - { - dst_width = width; - dst_height = height; - rot_src_w = src_w; - rot_src_h = src_h; - rot_drw_w = drw_w; - rot_drw_h = drw_h; - } - else - { - dst_width = height; - dst_height = width; - rot_src_w = src_h; - rot_src_h = src_w; - rot_drw_w = drw_h; - rot_drw_h = drw_w; - } - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - dst_x1 = dstBox.x1; - dst_y1 = dstBox.y1; - dst_x2 = dstBox.x2; - dst_y2 = dstBox.y2; - rot_x1 = x1; - rot_y1 = y1; - rot_x2 = x2; - rot_y2 = y2; - break; - case RR_Rotate_90: - dst_x1 = dstBox.y1; - dst_y1 = screen->height - dstBox.x2; - dst_x2 = dstBox.y2; - dst_y2 = screen->height - dstBox.x1; - - rot_x1 = y1; - rot_y1 = (src_w << 16) - x2; - rot_x2 = y2; - rot_y2 = (src_w << 16) - x1; - break; - case RR_Rotate_180: - dst_x1 = screen->width - dstBox.x2; - dst_y1 = screen->height - dstBox.y2; - dst_x2 = screen->width - dstBox.x1; - dst_y2 = screen->height - dstBox.y1; - rot_x1 = (src_w << 16) - x2; - rot_y1 = (src_h << 16) - y2; - rot_x2 = (src_w << 16) - x1; - rot_y2 = (src_h << 16) - y1; - break; - case RR_Rotate_270: - dst_x1 = screen->width - dstBox.y2; - dst_y1 = dstBox.x1; - dst_x2 = screen->width - dstBox.y1; - dst_y2 = dstBox.x2; - rot_x1 = (src_h << 16) - y2; - rot_y1 = x1; - rot_x2 = (src_h << 16) - y1; - rot_y2 = x2; - break; - } - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width + 3) & ~3; - srcPitch2 = ((width >> 1) + 3) & ~3; - size = dstPitch * (int) dst_height; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width << 1); - size = dstPitch * (int) dst_height; - break; - } - - pPortPriv->offset = mach64s->off_screen - (CARD8 *) mach64s->vesa.fb; - /* fixup pointers */ - - pPortPriv->YBuf0Offset = pPortPriv->offset; - pPortPriv->YBuf1Offset = pPortPriv->offset + size; - -#if 0 - mach64WaitIdle (reg); - - if (pPortPriv->videoOn) - { - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - } -#endif - /* - * Use the other buffer - */ - pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; - - /* copy data */ - top = rot_y1 >> 16; - left = (rot_x1 >> 16) & ~1; - npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - top &= ~1; - nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; - mach64CopyPlanarData(screen, buf, randr, - srcPitch, srcPitch2, dstPitch, - rot_src_w, rot_src_h, height, - top, left, nlines, npixels, id); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - nlines = ((rot_y2 + 0xffff) >> 16) - top; - mach64CopyPackedData(screen, buf, randr, - srcPitch, dstPitch, - rot_src_w, rot_src_h, - top, left, nlines, - npixels); - break; - } - - mach64DisplayVideo(screen, id, dstPitch, - rot_x1, rot_y1, rot_x2, rot_y2, - dst_x1, dst_y1, - dst_x2, dst_y2, - rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); - - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); - } - - pPortPriv->videoOn = TRUE; - - return Success; -} - -static int -mach64QueryImageAttributes(KdScreenInfo *screen, - int id, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) -{ - int size, tmp; - - if(*w > IMAGE_MAX_WIDTH) - *w = IMAGE_MAX_WIDTH; - if(*h > IMAGE_MAX_HEIGHT) - *h = IMAGE_MAX_HEIGHT; - - *w = (*w + 1) & ~1; - if(offsets) offsets[0] = 0; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - *h = (*h + 1) & ~1; - size = (*w + 3) & ~3; - if(pitches) - pitches[0] = size; - size *= *h; - if(offsets) - offsets[1] = size; - tmp = ((*w >> 1) + 3) & ~3; - if(pitches) - pitches[1] = pitches[2] = tmp; - tmp *= (*h >> 1); - size += tmp; - if(offsets) - offsets[2] = size; - size += tmp; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - size = *w << 1; - if(pitches) - pitches[0] = size; - size *= *h; - break; - } - - return size; -} - - -/* client libraries expect an encoding */ -static KdVideoEncodingRec DummyEncoding[1] = -{ - { - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} - } -}; - -#define NUM_FORMATS 3 - -static KdVideoFormatRec Formats[NUM_FORMATS] = -{ - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} -}; - -#define NUM_ATTRIBUTES 3 - -static KdAttributeRec Attributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, - {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} -}; - -#define NUM_IMAGES 4 - -static KdImageRec Images[NUM_IMAGES] = -{ - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - XVIMAGE_UYVY -}; - -static void mach64ResetVideo(KdScreenInfo *screen) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - MediaReg *media = mach64c->media_reg; - - /* - * Default to maximum image size in YV12 - */ - -} - -static int -mach64ReputImage (KdScreenInfo *screen, - short drw_x, - short drw_y, - RegionPtr clipBoxes, - pointer data) -{ - ScreenPtr pScreen = screen->pScreen; - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - BoxPtr pOldExtents = REGION_EXTENTS (pScreen, &pPortPriv->clip); - BoxPtr pNewExtents = REGION_EXTENTS (pScreen, clipBoxes); - - if (pOldExtents->x1 == pNewExtents->x1 && - pOldExtents->x2 == pNewExtents->x2 && - pOldExtents->y1 == pNewExtents->y1 && - pOldExtents->y2 == pNewExtents->y2) - { - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); - } - return Success; - } - return BadMatch; -} - -static KdVideoAdaptorPtr -mach64SetupImageVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64CardInfo(pScreenPriv); - mach64ScreenInfo(pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - KdVideoAdaptorPtr adapt; - Mach64PortPrivPtr pPortPriv; - - if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + - sizeof(Mach64PortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "Mach64 Video Overlay"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = mach64StopVideo; - adapt->SetPortAttribute = mach64SetPortAttribute; - adapt->GetPortAttribute = mach64GetPortAttribute; - adapt->QueryBestSize = mach64QueryBestSize; - adapt->PutImage = mach64PutImage; - adapt->ReputImage = mach64ReputImage; - adapt->QueryImageAttributes = mach64QueryImageAttributes; - - pPortPriv->colorKey = mach64s->colorKey; - pPortPriv->videoOn = FALSE; - pPortPriv->brightness = 0; - pPortPriv->saturation = 0; - pPortPriv->currentBuf = 0; - - /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); - - mach64s->pAdaptor = adapt; - - xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - xvSaturation = MAKE_ATOM("XV_SATURATION"); - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - - mach64ResetVideo(screen); - - return adapt; -} - -Bool mach64InitVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; - KdVideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - - if (!mach64c->media_reg) - return FALSE; - - newAdaptor = mach64SetupImageVideo(pScreen); - - num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); - - if(newAdaptor) - { - if(!num_adaptors) - { - num_adaptors = 1; - adaptors = &newAdaptor; - } - else - { - newAdaptors = xalloc((num_adaptors + 1) * - sizeof(KdVideoAdaptorPtr*)); - if(newAdaptors) - { - memcpy(newAdaptors, adaptors, - num_adaptors * sizeof(KdVideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - KdXVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - return TRUE; -} diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am deleted file mode 100644 index 103ec4ef2..000000000 --- a/hw/kdrive/src/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - @XSERVER_CFLAGS@ - -noinst_LIBRARIES = libkdrive.a - -libkdrive_a_SOURCES = \ - kaa.c \ - kasync.c \ - kcmap.c \ - kcurscol.c \ - kdrive.c \ - kdrive.h \ - kinfo.c \ - kinput.c \ - kkeymap.h \ - kmap.c \ - kmode.c \ - knoop.c \ - koffscreen.c \ - kpict.c \ - kshadow.c \ - ktest.c \ - kxv.c \ - kxv.h \ - vga.c \ - vga.h diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c deleted file mode 100644 index d861a232a..000000000 --- a/hw/kdrive/src/kaa.c +++ /dev/null @@ -1,1076 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/kaa.c,v 1.4 2001/06/04 09:45:41 keithp Exp $ - * - * Copyright © 2001 Keith Packard - * - * Partly based on code that is Copyright © The XFree86 Project 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 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "fontstruct.h" -#include "dixfontstr.h" - -#define DEBUG_MIGRATE 0 -#define DEBUG_PIXMAP 0 -#if DEBUG_MIGRATE -#define DBG_MIGRATE(a) ErrorF a -#else -#define DBG_MIGRATE(a) -#endif -#if DEBUG_PIXMAP -#define DBG_PIXMAP(a) ErrorF a -#else -#define DBG_PIXMAP(a) -#endif - -int kaaGeneration; -int kaaScreenPrivateIndex; -int kaaPixmapPrivateIndex; - -typedef struct { - KaaScreenInfoPtr info; -} KaaScreenPrivRec, *KaaScreenPrivPtr; - -typedef struct { - KdOffscreenArea *area; - int score; - int devKind; - DevUnion devPrivate; -} KaaPixmapPrivRec, *KaaPixmapPrivPtr; - -#define KAA_PIXMAP_SCORE_MOVE_IN 10 -#define KAA_PIXMAP_SCORE_MAX 20 -#define KAA_PIXMAP_SCORE_MOVE_OUT -10 -#define KAA_PIXMAP_SCORE_MIN -20 - -#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr)(s)->devPrivates[kaaScreenPrivateIndex].ptr) -#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = KaaGetScreenPriv(s) - -#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr)(p)->devPrivates[kaaPixmapPrivateIndex].ptr) -#define KaaSetPixmapPriv(p,a) ((p)->devPrivates[kaaPixmapPrivateIndex].ptr = (pointer) (a)) -#define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv(p) -#define KaaPixmapPitch(w) (((w) + (pKaaScr->info->offscreenPitch - 1)) & ~(pKaaScr->info->offscreenPitch - 1)) - -#define MIN_OFFPIX_SIZE (4096) - -static void -kaaPixmapSave (KdOffscreenArea *area) -{ - PixmapPtr pPixmap = area->privData; - KaaPixmapPriv(pPixmap); - int dst_pitch, src_pitch, bytes; - unsigned char *dst, *src; - int i; - - DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n", - pPixmap->drawable.id, - KaaGetPixmapPriv(pPixmap)->area ? - KaaGetPixmapPriv(pPixmap)->area->offset : -1, - pPixmap->drawable.width, - pPixmap->drawable.height)); - - KdCheckSync (pPixmap->drawable.pScreen); - - src_pitch = pPixmap->devKind; - dst_pitch = pKaaPixmap->devKind; - - src = pPixmap->devPrivate.ptr; - dst = pKaaPixmap->devPrivate.ptr; - - pPixmap->devKind = dst_pitch; - pPixmap->devPrivate.ptr = dst; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pKaaPixmap->area = NULL; - - bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch; - - i = pPixmap->drawable.height; - while (i--) { - memcpy (dst, src, bytes); - dst += dst_pitch; - src += src_pitch; - } -} - -static Bool -kaaPixmapAllocArea (PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - KaaScreenPriv (pScreen); - KaaPixmapPriv (pPixmap); - KdScreenPriv (pScreen); - int bpp = pPixmap->drawable.bitsPerPixel; - CARD16 h = pPixmap->drawable.height; - CARD16 w = pPixmap->drawable.width; - int pitch = KaaPixmapPitch (w); - - pKaaPixmap->devKind = pPixmap->devKind; - pKaaPixmap->devPrivate = pPixmap->devPrivate; - pKaaPixmap->area = KdOffscreenAlloc (pScreen, pitch * h * (bpp >> 3), - pKaaScr->info->offscreenByteAlign, - FALSE, - kaaPixmapSave, (pointer) pPixmap); - if (!pKaaPixmap->area) - return FALSE; - - DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n", - pPixmap->drawable.id, - KaaGetPixmapPriv(pPixmap)->area ? - KaaGetPixmapPriv(pPixmap)->area->offset : -1, - pPixmap->drawable.width, - pPixmap->drawable.height)); - pPixmap->devKind = pitch * (bpp >> 3); - pPixmap->devPrivate.ptr = (pointer) ((CARD8 *) pScreenPriv->screen->memory_base + pKaaPixmap->area->offset); - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - return TRUE; -} - -static void -kaaMoveInPixmap (PixmapPtr pPixmap) -{ - int dst_pitch, src_pitch, bytes; - unsigned char *dst, *src; - int i; - - return; - KdCheckSync (pPixmap->drawable.pScreen); - - DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n", - pPixmap->drawable.id, - KaaGetPixmapPriv(pPixmap)->area ? - KaaGetPixmapPriv(pPixmap)->area->offset : -1, - pPixmap->drawable.width, - pPixmap->drawable.height)); - - src = pPixmap->devPrivate.ptr; - src_pitch = pPixmap->devKind; - - if (!kaaPixmapAllocArea (pPixmap)) - return; - - dst = pPixmap->devPrivate.ptr; - dst_pitch = pPixmap->devKind; - - bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch; - - i = pPixmap->drawable.height; - while (i--) { - memcpy (dst, src, bytes); - dst += dst_pitch; - src += src_pitch; - } -} - -static void -kaaMoveOutPixmap (PixmapPtr pPixmap) -{ - KaaPixmapPriv (pPixmap); - KdOffscreenArea *area = pKaaPixmap->area; - - DBG_MIGRATE (("<- 0x%08x (0x%x) (%dx%d)\n", - pPixmap->drawable.id, - KaaGetPixmapPriv(pPixmap)->area ? - KaaGetPixmapPriv(pPixmap)->area->offset : -1, - pPixmap->drawable.width, - pPixmap->drawable.height)); - if (area) - { - kaaPixmapSave (area); - KdOffscreenFree (area); - } -} - -static void -kaaPixmapUseScreen (PixmapPtr pPixmap) -{ - KaaPixmapPriv (pPixmap); - - if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX) - { - pKaaPixmap->score++; - if (!pKaaPixmap->area && - pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN) - kaaMoveInPixmap (pPixmap); - } -} - -static void -kaaPixmapUseMemory (PixmapPtr pPixmap) -{ - KaaPixmapPriv (pPixmap); - - if (pKaaPixmap->score > KAA_PIXMAP_SCORE_MIN) - { - pKaaPixmap->score--; - if (pKaaPixmap->area && - pKaaPixmap->score <= KAA_PIXMAP_SCORE_MOVE_OUT) - kaaMoveOutPixmap (pPixmap); - } -} - -static Bool -kaaDestroyPixmap (PixmapPtr pPixmap) -{ - if (pPixmap->refcnt == 1) - { - KaaPixmapPriv (pPixmap); - if (pKaaPixmap->area) - { - DBG_PIXMAP(("-- 0x%08x (0x%x) (%dx%d)\n", - pPixmap->drawable.id, - KaaGetPixmapPriv(pPixmap)->area->offset, - pPixmap->drawable.width, - pPixmap->drawable.height)); - /* Free the offscreen area */ - KdOffscreenFree (pKaaPixmap->area); - pPixmap->devPrivate = pKaaPixmap->devPrivate; - pPixmap->devKind = pKaaPixmap->devKind; - } - } - return fbDestroyPixmap (pPixmap); -} - -static PixmapPtr -kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth) -{ - PixmapPtr pPixmap; - KaaPixmapPrivPtr pKaaPixmap; - int bpp; - - bpp = BitsPerPixel (depth); - if (bpp == 32 && depth == 24) - { - int fb; - KdScreenPriv (pScreen); - - for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++) - if (pScreenPriv->screen->fb[fb].depth == 24) - { - bpp = pScreenPriv->screen->fb[fb].bitsPerPixel; - break; - } - } - pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp); - if (!pPixmap) - return NULL; - pKaaPixmap = KaaGetPixmapPriv(pPixmap); - pKaaPixmap->score = 0; - pKaaPixmap->area = NULL; - - if (depth == pScreen->rootDepth && - (pPixmap->devKind * h) >= MIN_OFFPIX_SIZE) - kaaPixmapAllocArea (pPixmap); - return pPixmap; -} - -static Bool -kaaPixmapIsOffscreen(PixmapPtr p) -{ - ScreenPtr pScreen = p->drawable.pScreen; - KdScreenPriv(pScreen); - - return ((unsigned long) ((CARD8 *) p->devPrivate.ptr - - (CARD8 *) pScreenPriv->screen->memory_base) < - pScreenPriv->screen->memory_size); -} - -static PixmapPtr -kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp) -{ - PixmapPtr pPixmap; - int x, y; - - if (pDrawable->type == DRAWABLE_WINDOW) { - pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable); -#ifdef COMPOSITE - x = -pPixmap->screen_x; - y = -pPixmap->screen_y; -#else - x = 0; - y = 0; -#endif - } - else - { - pPixmap = (PixmapPtr) pDrawable; - x = 0; - y = 0; - } - if (kaaPixmapIsOffscreen (pPixmap)) - { - *xp = x; - *yp = y; - return pPixmap; - } - return NULL; -} - -static Bool -kaaDrawableIsOffscreen (DrawablePtr pDrawable) -{ - PixmapPtr pPixmap; - if (pDrawable->type == DRAWABLE_WINDOW) - pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable); - else - pPixmap = (PixmapPtr) pDrawable; - return kaaPixmapIsOffscreen (pPixmap); -} - -static void -kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - ScreenPtr pScreen = pDrawable->pScreen; - KdScreenPriv (pScreen); - KaaScreenPriv (pScreen); - RegionPtr pClip = fbGetCompositeClip(pGC); - PixmapPtr pPixmap; - BoxPtr pextent, pbox; - int nbox; - int extentX1, extentX2, extentY1, extentY2; - int fullX1, fullX2, fullY1; - int partX1, partX2; - int off_x, off_y; - - if (!pScreenPriv->enabled || - pGC->fillStyle != FillSolid || - !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &off_x, &off_y)) || - !(*pKaaScr->info->PrepareSolid) (pPixmap, - pGC->alu, - pGC->planemask, - pGC->fgPixel)) - { - KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); - return; - } - - pextent = REGION_EXTENTS(pGC->pScreen, pClip); - extentX1 = pextent->x1; - extentY1 = pextent->y1; - extentX2 = pextent->x2; - extentY2 = pextent->y2; - while (n--) - { - fullX1 = ppt->x; - fullY1 = ppt->y; - fullX2 = fullX1 + (int) *pwidth; - ppt++; - pwidth++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - nbox = REGION_NUM_RECTS (pClip); - if (nbox == 1) - { - (*pKaaScr->info->Solid) (fullX1 + off_x, fullY1 + off_y, - fullX2 + off_x, fullY1 + 1 + off_y); - } - else - { - pbox = REGION_RECTS(pClip); - while(nbox--) - { - if (pbox->y1 <= fullY1 && fullY1 < pbox->y2) - { - partX1 = pbox->x1; - if (partX1 < fullX1) - partX1 = fullX1; - partX2 = pbox->x2; - if (partX2 > fullX2) - partX2 = fullX2; - if (partX2 > partX1) - (*pKaaScr->info->Solid) (partX1 + off_x, fullY1 + off_y, - partX2 + off_x, fullY1 + 1 + off_y); - } - pbox++; - } - } - } - (*pKaaScr->info->DoneSolid) (); - KdMarkSync(pDrawable->pScreen); -} - -static void -kaaCopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - KdScreenPriv (pDstDrawable->pScreen); - KaaScreenPriv (pDstDrawable->pScreen); - PixmapPtr pSrcPixmap, pDstPixmap; - int src_off_x, src_off_y; - int dst_off_x, dst_off_y; - - /* Migrate pixmaps to same place as destination */ - if (pScreenPriv->enabled && pSrcDrawable->type == DRAWABLE_PIXMAP) { - if (kaaDrawableIsOffscreen (pDstDrawable)) - kaaPixmapUseScreen ((PixmapPtr) pSrcDrawable); - else - kaaPixmapUseMemory ((PixmapPtr) pSrcDrawable); - } - - if (pScreenPriv->enabled && - (pSrcPixmap = kaaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) && - (pDstPixmap = kaaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) && - (*pKaaScr->info->PrepareCopy) (pSrcPixmap, - pDstPixmap, - dx, - dy, - pGC ? pGC->alu : GXcopy, - pGC ? pGC->planemask : FB_ALLONES)) - { - while (nbox--) - { - (*pKaaScr->info->Copy) (pbox->x1 + dx + src_off_x, - pbox->y1 + dy + src_off_y, - pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - pbox++; - } - (*pKaaScr->info->DoneCopy) (); - KdMarkSync(pDstDrawable->pScreen); - } - else - { - KdCheckSync (pDstDrawable->pScreen); - fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, - pbox, nbox, dx, dy, reverse, upsidedown, - bitplane, closure); - } -} - -static RegionPtr -kaaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, int dstx, int dsty) -{ - return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, - srcx, srcy, width, height, - dstx, dsty, kaaCopyNtoN, 0, 0); -} - -static void -kaaPolyFillRect(DrawablePtr pDrawable, - GCPtr pGC, - int nrect, - xRectangle *prect) -{ - KdScreenPriv (pDrawable->pScreen); - KaaScreenPriv (pDrawable->pScreen); - RegionPtr pClip = fbGetCompositeClip(pGC); - PixmapPtr pPixmap; - register BoxPtr pbox; - BoxPtr pextent; - int extentX1, extentX2, extentY1, extentY2; - int fullX1, fullX2, fullY1, fullY2; - int partX1, partX2, partY1, partY2; - int xoff, yoff; - int xorg, yorg; - int n; - - if (!pScreenPriv->enabled || - pGC->fillStyle != FillSolid || - !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || - !(*pKaaScr->info->PrepareSolid) (pPixmap, - pGC->alu, - pGC->planemask, - pGC->fgPixel)) - { - KdCheckPolyFillRect (pDrawable, pGC, nrect, prect); - return; - } - - xorg = pDrawable->x; - yorg = pDrawable->y; - - pextent = REGION_EXTENTS(pGC->pScreen, pClip); - extentX1 = pextent->x1; - extentY1 = pextent->y1; - extentX2 = pextent->x2; - extentY2 = pextent->y2; - while (nrect--) - { - fullX1 = prect->x + xorg; - fullY1 = prect->y + yorg; - fullX2 = fullX1 + (int) prect->width; - fullY2 = fullY1 + (int) prect->height; - prect++; - - if (fullX1 < extentX1) - fullX1 = extentX1; - - if (fullY1 < extentY1) - fullY1 = extentY1; - - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullY2 > extentY2) - fullY2 = extentY2; - - if ((fullX1 >= fullX2) || (fullY1 >= fullY2)) - continue; - n = REGION_NUM_RECTS (pClip); - if (n == 1) - { - (*pKaaScr->info->Solid) (fullX1 + xoff, fullY1 + yoff, - fullX2 + xoff, fullY2 + yoff); - } - else - { - pbox = REGION_RECTS(pClip); - /* - * clip the rectangle to each box in the clip region - * this is logically equivalent to calling Intersect() - */ - while(n--) - { - partX1 = pbox->x1; - if (partX1 < fullX1) - partX1 = fullX1; - partY1 = pbox->y1; - if (partY1 < fullY1) - partY1 = fullY1; - partX2 = pbox->x2; - if (partX2 > fullX2) - partX2 = fullX2; - partY2 = pbox->y2; - if (partY2 > fullY2) - partY2 = fullY2; - - pbox++; - - if (partX1 < partX2 && partY1 < partY2) - (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff, - partX2 + xoff, partY2 + yoff); - } - } - } - (*pKaaScr->info->DoneSolid) (); - KdMarkSync(pDrawable->pScreen); -} - -static void -kaaSolidBoxClipped (DrawablePtr pDrawable, - RegionPtr pClip, - FbBits pm, - FbBits fg, - int x1, - int y1, - int x2, - int y2) -{ - KdScreenPriv (pDrawable->pScreen); - KaaScreenPriv (pDrawable->pScreen); - PixmapPtr pPixmap; - BoxPtr pbox; - int nbox; - int xoff, yoff; - int partX1, partX2, partY1, partY2; - - if (!pScreenPriv->enabled || - !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || - !(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg)) - { - KdCheckSync (pDrawable->pScreen); - fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel); - fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2, - fbAnd (GXcopy, fg, pm), - fbXor (GXcopy, fg, pm)); - return; - } - 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; - - (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff, - partX2 + xoff, partY2 + yoff); - } - (*pKaaScr->info->DoneSolid) (); - KdMarkSync(pDrawable->pScreen); -} - -static void -kaaImageGlyphBlt (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; - int dstXoff, dstYoff; - FbBits depthMask; - - depthMask = FbFullMask(pDrawable->depth); - if ((pGC->planemask & depthMask) != depthMask) - { - KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase); - return; - } - glyph = 0; - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - 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); - kaaSolidBoxClipped (pDrawable, - fbGetCompositeClip(pGC), - pGC->planemask, - pGC->bgPixel, - xBack, - yBack, - xBack + widthBack, - yBack + heightBack); - opaque = FALSE; - } - - KdCheckSync (pDrawable->pScreen); - - 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 + dstYoff) * dstStride, - dstStride, - dstBpp, - (FbStip *) pglyph, - pPriv->fg, - gx + dstXoff, - 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 kaaOps = { - kaaFillSpans, - KdCheckSetSpans, - KdCheckPutImage, - kaaCopyArea, - KdCheckCopyPlane, - KdCheckPolyPoint, - KdCheckPolylines, - KdCheckPolySegment, - miPolyRectangle, - KdCheckPolyArc, - miFillPolygon, - kaaPolyFillRect, - miPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - kaaImageGlyphBlt, - KdCheckPolyGlyphBlt, - KdCheckPushPixels, -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; - -static void -kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) -{ - fbValidateGC (pGC, changes, pDrawable); - - if (kaaDrawableIsOffscreen (pDrawable)) - pGC->ops = (GCOps *) &kaaOps; - else - pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; -} - -GCFuncs kaaGCFuncs = { - kaaValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip -}; - -static int -kaaCreateGC (GCPtr pGC) -{ - if (!fbCreateGC (pGC)) - return FALSE; - - pGC->funcs = &kaaGCFuncs; - - return TRUE; -} - - -static void -kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - RegionRec rgnDst; - int dx, dy; - PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); - - 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); -#ifdef COMPOSITE - if (pPixmap->screen_x || pPixmap->screen_y) - REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, - -pPixmap->screen_x, -pPixmap->screen_y); -#endif - - fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable, - 0, - &rgnDst, dx, dy, kaaCopyNtoN, 0, 0); - - REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); -} - -static void -kaaFillRegionSolid (DrawablePtr pDrawable, - RegionPtr pRegion, - Pixel pixel) -{ - KdScreenPriv(pDrawable->pScreen); - KaaScreenPriv(pDrawable->pScreen); - PixmapPtr pPixmap; - int xoff, yoff; - - if (pScreenPriv->enabled && - (pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) && - (*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel)) - { - int nbox = REGION_NUM_RECTS (pRegion); - BoxPtr pBox = REGION_RECTS (pRegion); - - while (nbox--) - { - (*pKaaScr->info->Solid) (pBox->x1 + xoff, pBox->y1 + yoff, - pBox->x2 + xoff, pBox->y2 + yoff); - pBox++; - } - (*pKaaScr->info->DoneSolid) (); - KdMarkSync(pDrawable->pScreen); - } - else - { - KdCheckSync (pDrawable->pScreen); - fbFillRegionSolid (pDrawable, pRegion, 0, - fbReplicatePixel (pixel, pDrawable->bitsPerPixel)); - } -} - -static void -kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) -{ - - 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; - case BackgroundPixel: - kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel); - return; - } - break; - case PW_BORDER: - if (pWin->borderIsPixel) - { - kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel); - return; - } - break; - } - KdCheckPaintWindow (pWin, pRegion, what); -} - -#ifdef RENDER -#include "mipict.h" - -static void -kaaComposite(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - if (op == PictOpSrc && !pMask) - { - /* - * Check for two special cases -- solid fill and copy area - */ - if (pSrc->pDrawable->width == 1 && pSrc->pDrawable->height == 1 && - pSrc->repeat) - { - ; - } - else if (!pSrc->repeat && pSrc->format == pDst->format) - { - RegionRec region; - - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - if (pMask) - { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - } - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height)) - return; - - - kaaCopyNtoN (pSrc->pDrawable, pDst->pDrawable, 0, - REGION_RECTS(®ion), REGION_NUM_RECTS(®ion), - xSrc - xDst, ySrc - yDst, - FALSE, FALSE, 0, 0); - return; - } - } - if (pSrc->pDrawable->type == DRAWABLE_PIXMAP) - kaaPixmapUseMemory ((PixmapPtr) pSrc->pDrawable); - if (pMask && pMask->pDrawable->type == DRAWABLE_PIXMAP) - kaaPixmapUseMemory ((PixmapPtr) pMask->pDrawable); -#if 0 - if (pDst->pDrawable->type == DRAWABLE_PIXMAP) - kaaPixmapUseMemory ((PixmapPtr) pDst->pDrawable); -#endif - - KdCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); -} -#endif - -Bool -kaaDrawInit (ScreenPtr pScreen, - KaaScreenInfoPtr pScreenInfo) -{ - KaaScreenPrivPtr pKaaScr; - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; -#ifdef RENDER - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); -#endif - - if (kaaGeneration != serverGeneration) - { - kaaScreenPrivateIndex = AllocateScreenPrivateIndex(); - kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex(); - kaaGeneration = serverGeneration; - } - - pKaaScr = xalloc (sizeof (KaaScreenPrivRec)); - - if (!pKaaScr) - return FALSE; - - pKaaScr->info = pScreenInfo; - - pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr; - - /* - * Hook up asynchronous drawing - */ - KdScreenInitAsync (pScreen); - /* - * Replace various fb screen functions - */ - pScreen->CreateGC = kaaCreateGC; - pScreen->CopyWindow = kaaCopyWindow; - pScreen->PaintWindowBackground = kaaPaintWindow; - pScreen->PaintWindowBorder = kaaPaintWindow; -#ifdef RENDER - if (ps) - ps->Composite = kaaComposite; -#endif - - /* - * Hookup offscreen pixmaps - */ - if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) && - screen->off_screen_base < screen->memory_size) - { - if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, - sizeof (KaaPixmapPrivRec))) - return FALSE; - pScreen->CreatePixmap = kaaCreatePixmap; - pScreen->DestroyPixmap = kaaDestroyPixmap; - } - else - { - if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0)) - return FALSE; - } - - return TRUE; -} - -void -kaaDrawFini (ScreenPtr pScreen) -{ - KaaScreenPriv(pScreen); - - xfree (pKaaScr); -} diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c deleted file mode 100644 index a2807e899..000000000 --- a/hw/kdrive/src/kasync.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Id: kasync.c,v 1.3 1999/11/24 04:29:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kasync.c,v 1.8 2001/03/30 02:15:19 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -/* - * These functions wrap the low-level fb rendering functions and - * synchronize framebuffer/accelerated drawing by stalling until - * the accelerator is idle - */ - -void -KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans, - DDXPointPtr ppt, int *pwidth, int fSorted) -{ - KdCheckSync (pDrawable->pScreen); - fbFillSpans (pDrawable, pGC, nspans, ppt, pwidth, fSorted); -} - -void -KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc, - DDXPointPtr ppt, int *pwidth, int nspans, int fSorted) -{ - KdCheckSync (pDrawable->pScreen); - fbSetSpans (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); -} - -void -KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, int format, - char *bits) -{ - KdCheckSync (pDrawable->pScreen); - fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits); -} - -RegionPtr -KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - KdCheckSync (pSrc->pScreen); - return fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); -} - -RegionPtr -KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty, - unsigned long bitPlane) -{ - KdCheckSync (pSrc->pScreen); - return fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, - bitPlane); -} - -void -KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, - DDXPointPtr pptInit) -{ - KdCheckSync (pDrawable->pScreen); - fbPolyPoint (pDrawable, pGC, mode, npt, pptInit); -} - -void -KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr ppt) -{ - - if (pGC->lineWidth == 0) - KdCheckSync (pDrawable->pScreen); - fbPolyLine (pDrawable, pGC, mode, npt, ppt); -} - -void -KdCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC, - int nsegInit, xSegment *pSegInit) -{ - if (pGC->lineWidth == 0) - KdCheckSync(pDrawable->pScreen); - fbPolySegment (pDrawable, pGC, nsegInit, pSegInit); -} - -void -KdCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC, - int nrects, xRectangle *prect) -{ - if (pGC->lineWidth == 0) - KdCheckSync(pDrawable->pScreen); - fbPolyRectangle (pDrawable, pGC, nrects, prect); -} - -void -KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *pArcs) -{ - if (pGC->lineWidth == 0) - { - KdCheckSync(pDrawable->pScreen); - fbPolyArc (pDrawable, pGC, narcs, pArcs); - } - else - miPolyArc (pDrawable, pGC, narcs, pArcs); -} - -#if 0 -void -KdCheckFillPolygon (DrawablePtr pDrawable, GCPtr pGC, - int shape, int mode, int count, DDXPointPtr pPts) -{ - KdCheckSync(pDrawable->pScreen); - fbFillPolygon (pDrawable, pGC, mode, count, pPts); -} -#endif - -void -KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrect, xRectangle *prect) -{ - KdCheckSync(pDrawable->pScreen); - fbPolyFillRect (pDrawable, pGC, nrect, prect); -} - -void -KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *pArcs) -{ - KdCheckSync(pDrawable->pScreen); - fbPolyFillArc (pDrawable, pGC, narcs, pArcs); -} - -void -KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) -{ - KdCheckSync(pDrawable->pScreen); - fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); -} - -void -KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) -{ - KdCheckSync(pDrawable->pScreen); - fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); -} - -void -KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap, - DrawablePtr pDrawable, - int w, int h, int x, int y) -{ - KdCheckSync(pDrawable->pScreen); - fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y); -} - -void -KdCheckGetImage (DrawablePtr pDrawable, - int x, int y, int w, int h, - unsigned int format, unsigned long planeMask, - char *d) -{ - KdCheckSync(pDrawable->pScreen); - fbGetImage (pDrawable, x, y, w, h, format, planeMask, d); -} - -void -KdCheckGetSpans (DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, - char *pdstStart) -{ - KdCheckSync(pDrawable->pScreen); - fbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); -} - -void -KdCheckSaveAreas (PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin) -{ - KdCheckSync(pWin->drawable.pScreen); - fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin); -} - -void -KdCheckRestoreAreas (PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin) -{ - KdCheckSync(pWin->drawable.pScreen); - fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin); -} - -void -KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what) -{ - KdCheckSync (pWin->drawable.pScreen); - fbPaintWindow (pWin, pRegion, what); -} - -void -KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - KdCheckSync (pWin->drawable.pScreen); - fbCopyWindow (pWin, ptOldOrg, prgnSrc); -} - -#if KD_MAX_FB > 1 -void -KdCheckPaintKey(DrawablePtr pDrawable, - RegionPtr pRegion, - CARD32 pixel, - int layer) -{ - KdCheckSync (pDrawable->pScreen); - fbOverlayPaintKey (pDrawable, pRegion, pixel, layer); -} - -void -KdCheckOverlayCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - KdCheckSync (pWin->drawable.pScreen); - fbOverlayCopyWindow (pWin, ptOldOrg, prgnSrc); -} -#endif - -void -KdScreenInitAsync (ScreenPtr pScreen) -{ - pScreen->GetImage = KdCheckGetImage; - pScreen->GetSpans = KdCheckGetSpans; - pScreen->PaintWindowBackground = KdCheckPaintWindow; - pScreen->PaintWindowBorder = KdCheckPaintWindow; - pScreen->CopyWindow = KdCheckCopyWindow; - -#ifndef FB_OLD_SCREEN - pScreen->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas; - pScreen->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas; -#else - pScreenPriv->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas; - pScreenPriv->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas; -#endif -#ifdef RENDER - KdPictureInitAsync (pScreen); -#endif -} - -/* - * Only need to stall for copyarea/copyplane - */ -const GCOps kdAsyncPixmapGCOps = { - fbFillSpans, - fbSetSpans, - fbPutImage, - KdCheckCopyArea, - KdCheckCopyPlane, - fbPolyPoint, - fbPolyLine, - fbPolySegment, - fbPolyRectangle, - fbPolyArc, - fbFillPolygon, - fbPolyFillRect, - fbPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - fbImageGlyphBlt, - fbPolyGlyphBlt, - fbPushPixels -#ifdef NEED_LINEHELPER - ,NULL -#endif -}; diff --git a/hw/kdrive/src/kcmap.c b/hw/kdrive/src/kcmap.c deleted file mode 100644 index 855dc6f02..000000000 --- a/hw/kdrive/src/kcmap.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Id: kcmap.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kcmap.c,v 1.4 2000/05/24 23:57:56 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -/* - * Put the entire colormap into the DAC - */ - -void -KdSetColormap (ScreenPtr pScreen, int fb) -{ - KdScreenPriv(pScreen); - ColormapPtr pCmap = pScreenPriv->pInstalledmap[fb]; - 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->fb[fb].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->fb[fb].depth); i++) - pixels[i] = i; - - QueryColors (pCmap, (1 << pScreenPriv->screen->fb[fb].depth), pixels, colors); - - for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].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, fb, - (1 << pScreenPriv->screen->fb[fb].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; - int fb; - Bool done = FALSE; - - if (!pScreenPriv->card->cfuncs->putColors) - return; - for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++) - { - if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH && !done) - { - for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++) - pScreenPriv->systemPalette[i].pixel = i; - (*pScreenPriv->card->cfuncs->getColors) (pScreen, fb, - (1 << pScreenPriv->screen->fb[fb].depth), - pScreenPriv->systemPalette); - done = TRUE; - } - KdSetColormap (pScreen, fb); - } -} - -void -KdDisableColormap (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - int fb; - - if (!pScreenPriv->card->cfuncs->putColors) - return; - for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++) - { - if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH) - { - (*pScreenPriv->card->cfuncs->putColors) (pScreen, fb, - (1 << pScreenPriv->screen->fb[fb].depth), - pScreenPriv->systemPalette); - break; - } - } -} - -static int -KdColormapFb (ColormapPtr pCmap) -{ - ScreenPtr pScreen = pCmap->pScreen; - KdScreenPriv (pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - int d; - DepthPtr depth; - int v; - VisualID vid = pCmap->pVisual->vid; - int fb; - - if (screen->fb[1].depth) - { - for (d = 0; d < pScreen->numDepths; d++) - { - depth = &pScreen->allowedDepths[d]; - for (v = 0; v < depth->numVids; v++) - { - if (depth->vids[v] == vid) - { - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - { - if (depth->depth == screen->fb[fb].depth) - return fb; - } - } - } - } - } - return 0; -} - -/* - * 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); - int fb = KdColormapFb (pCmap); - - if (pCmap == pScreenPriv->pInstalledmap[fb]) - return; - - /* Tell X clients that the installed colormap is going away. */ - if (pScreenPriv->pInstalledmap[fb]) - WalkTree(pScreenPriv->pInstalledmap[fb]->pScreen, TellLostMap, - (pointer) &(pScreenPriv->pInstalledmap[fb]->mid)); - - /* Take note of the new installed colorscreen-> */ - pScreenPriv->pInstalledmap[fb] = pCmap; - - KdSetColormap (pCmap->pScreen, fb); - - /* Tell X clients of the new colormap */ - WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid)); -} - -/* - * KdUninstallColormap - * - * This function uninstalls a colormap by either installing - * the default X colormap or erasing the installed colormap pointer. - * The default X colormap itself cannot be uninstalled. - */ -void -KdUninstallColormap (ColormapPtr pCmap) -{ - KdScreenPriv(pCmap->pScreen); - int fb = KdColormapFb (pCmap); - Colormap defMapID; - ColormapPtr defMap; - - /* ignore if not installed */ - if (pCmap != pScreenPriv->pInstalledmap[fb]) - return; - - /* ignore attempts to uninstall default colormap */ - defMapID = pCmap->pScreen->defColormap; - if ((Colormap) pCmap->mid == defMapID) - return; - - /* install default if on same fb */ - defMap = (ColormapPtr) LookupIDByType(defMapID, RT_COLORMAP); - if (defMap && KdColormapFb (defMap) == fb) - (*pCmap->pScreen->InstallColormap)(defMap); - else - { - /* uninstall and clear colormap pointer */ - WalkTree(pCmap->pScreen, TellLostMap, - (pointer) &(pCmap->mid)); - pScreenPriv->pInstalledmap[fb] = 0; - } -} - -int -KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps) -{ - KdScreenPriv(pScreen); - int fb; - int n = 0; - - for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++) - { - if (pScreenPriv->pInstalledmap[fb]) - { - *pCmaps++ = pScreenPriv->pInstalledmap[fb]->mid; - n++; - } - } - return n; -} - -/* - * 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]; - int fb = KdColormapFb (pCmap); - - if (pCmap != pScreenPriv->pInstalledmap[fb]) - return; - - if (!pScreenPriv->card->cfuncs->putColors) - return; - - if (pScreenPriv->screen->fb[fb].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, fb, ndef, pdefs); - - /* recolor hardware cursor */ - if (pScreenPriv->card->cfuncs->recolorCursor) - (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, ndef, pdefs); -} diff --git a/hw/kdrive/src/kcolor.c b/hw/kdrive/src/kcolor.c deleted file mode 100644 index bfff3a52c..000000000 --- a/hw/kdrive/src/kcolor.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Id: kcolor.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kcolor.c,v 1.2 1999/12/30 03:03:05 robin Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 (const unsigned char *s1, const 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; - const unsigned char *name; -} KdNamedColor; - -#define C 0x101 - -const KdNamedColor KdColors[] = { - { 240*C, 248*C, 255*C, "alice blue" }, - { 240*C, 248*C, 255*C, "AliceBlue" }, - { 250*C, 235*C, 215*C, "antique white" }, - { 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) -{ - const 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; -} diff --git a/hw/kdrive/src/kcurscol.c b/hw/kdrive/src/kcurscol.c deleted file mode 100644 index 50edf1735..000000000 --- a/hw/kdrive/src/kcurscol.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/kcurscol.c,v 1.4 2000/05/11 18:14:13 tsi Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "cursorstr.h" - -static int -KdComputeCmapShift (unsigned long mask) -{ - int shift; - unsigned long bit; - - shift = 16; - bit = 0x80000000; - while (!(mask & bit)) - { - shift--; - bit >>= 1; - } - return shift; -} - -#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d))) - -void -KdAllocateCursorPixels (ScreenPtr pScreen, - int fb, - CursorPtr pCursor, - Pixel *source, - Pixel *mask) -{ - xColorItem sourceColor, maskColor; - int r, g, b; - KdScreenPriv(pScreen); - - if (pScreenPriv->screen->fb[fb].redMask) - { - - r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask); - g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask); - b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask); - *source = ((Shift(pCursor->foreRed,r) & pScreenPriv->screen->fb[fb].redMask) | - (Shift(pCursor->foreGreen,g) & pScreenPriv->screen->fb[fb].greenMask) | - (Shift(pCursor->foreBlue,b) & pScreenPriv->screen->fb[fb].blueMask)); - *mask = ((Shift(pCursor->backRed,r) & pScreenPriv->screen->fb[fb].redMask) | - (Shift(pCursor->backGreen,g) & pScreenPriv->screen->fb[fb].greenMask) | - (Shift(pCursor->backBlue,b) & pScreenPriv->screen->fb[fb].blueMask)); - } - else - { - /* - * Set these to an invalid pixel value so that - * when the store colors comes through, the cursor - * won't get recolored - */ - *source = ~0; - *mask = ~0; - - sourceColor.red = pCursor->foreRed; - sourceColor.green = pCursor->foreGreen; - sourceColor.blue = pCursor->foreBlue; - FakeAllocColor(pScreenPriv->pInstalledmap[fb], &sourceColor); - maskColor.red = pCursor->backRed; - maskColor.green = pCursor->backGreen; - maskColor.blue = pCursor->backBlue; - FakeAllocColor(pScreenPriv->pInstalledmap[fb], &maskColor); - FakeFreeColor(pScreenPriv->pInstalledmap[fb], sourceColor.pixel); - FakeFreeColor(pScreenPriv->pInstalledmap[fb], maskColor.pixel); - *source = sourceColor.pixel; - *mask = maskColor.pixel; - } -} diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c deleted file mode 100644 index a6065f6f4..000000000 --- a/hw/kdrive/src/kdrive.c +++ /dev/null @@ -1,1471 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.29 2002/10/31 18:29:50 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#ifdef PSEUDO8 -#include "pseudo8/pseudo8.h" -#endif -#include <mivalidate.h> -#include <dixstruct.h> -#ifdef RANDR -#include <randrstr.h> -#endif - -#ifdef XV -#include "kxv.h" -#endif - -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif - -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 kdRawPointerCoordinates; -Bool kdDisableZaphod; -Bool kdEnabled; -int kdSubpixelOrder; -int kdVirtualTerminal = -1; -Bool kdSwitchPending; -char *kdSwitchCmd; -DDXPointRec kdOrigin; - -/* - * Carry arguments from InitOutput through driver initialization - * to KdScreenInit - */ - -KdOsFuncs *kdOsFuncs; -extern WindowPtr *WindowTable; - -void -KdSetRootClip (ScreenPtr pScreen, BOOL enable) -{ -#ifndef FB_OLD_SCREEN - WindowPtr pWin = WindowTable[pScreen->myNum]; - WindowPtr pChild; - Bool WasViewable; - Bool anyMarked = FALSE; - RegionPtr pOldClip = 0, bsExposed; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - BoxRec box; - - if (!pWin) - return; - WasViewable = (Bool)(pWin->viewable); - 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; - pWin->drawable.width = pScreen->width; - pWin->drawable.height = pScreen->height; - REGION_INIT (pScreen, &pWin->winSize, &box, 1); - REGION_INIT (pScreen, &pWin->borderSize, &box, 1); - 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 (); -#endif /* !FB_OLD_SCREEN */ -} - -void -KdDisableScreen (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - - if (!pScreenPriv->enabled) - return; - KdCheckSync (pScreen); - if (!pScreenPriv->closed) - KdSetRootClip (pScreen, FALSE); - KdDisableColormap (pScreen); - KdOffscreenSwapOut (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); -} - -static void -KdDoSwitchCmd (char *reason) -{ - if (kdSwitchCmd) - { - char *command = xalloc (strlen (kdSwitchCmd) + - 1 + - strlen (reason) + - 1); - if (!command) - return; - strcpy (command, kdSwitchCmd); - strcat (command, " "); - strcat (command, reason); - system (command); - xfree (command); - } -} - -void -KdSuspend (void) -{ - KdCardInfo *card; - KdScreenInfo *screen; - - if (kdEnabled) - { - 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); - } - KdDisableInput (); - KdDoSwitchCmd ("suspend"); - } -} - -void -KdDisableScreens (void) -{ - KdSuspend (); - if (kdEnabled) - { - (*kdOsFuncs->Disable) (); - kdEnabled = FALSE; - } -} - -Bool -KdEnableScreen (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - - if (pScreenPriv->enabled) - return TRUE; - if (!(*pScreenPriv->card->cfuncs->enable) (pScreen)) - return FALSE; - 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); - KdOffscreenSwapIn (pScreen); - KdEnableColormap (pScreen); - KdSetRootClip (pScreen, TRUE); - if (pScreenPriv->card->cfuncs->dpms) - (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState); - return TRUE; -} - -void -KdResume (void) -{ - KdCardInfo *card; - KdScreenInfo *screen; - - if (kdEnabled) - { - KdDoSwitchCmd ("resume"); - 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 (); - KdReleaseAllKeys (); - } -} - -void -KdEnableScreens (void) -{ - if (!kdEnabled) - { - kdEnabled = TRUE; - (*kdOsFuncs->Enable) (); - } - KdResume (); -} - -void -KdProcessSwitch (void) -{ - if (kdEnabled) - KdDisableScreens (); - else - KdEnableScreens (); -} - -void -AbortDDX(void) -{ - KdDisableScreens (); - if (kdOsFuncs) - { - if (kdEnabled) - (*kdOsFuncs->Disable) (); - (*kdOsFuncs->Fini) (); - KdDoSwitchCmd ("stop"); - } -} - -void -ddxUseMsg() -{ - ErrorF("\nTinyX Device Dependent Usage:\n"); - ErrorF("-card pcmcia Use PCMCIA card as additional screen\n"); - ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP{,DEPTH/BPP}[xFREQ]] Specify screen characteristics\n"); - ErrorF("-zaphod Disable cursor screen switching\n"); - ErrorF("-2button Emulate 3 button mouse\n"); - ErrorF("-3button Disable 3 button mouse emulation\n"); - ErrorF("-rawcoord Don't transform pointer coordinates on rotation\n"); - ErrorF("-dumb Disable hardware acceleration\n"); - ErrorF("-softCursor Force software cursor\n"); - ErrorF("-videoTest Start the server, pause momentarily and exit\n"); - ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n"); - ErrorF("-mouse path[,n] Filename of mouse device, n is number of buttons\n"); - ErrorF("-switchCmd Command to execute on vt switch\n"); - ErrorF("vtxx Use virtual terminal xx instead of the next available\n"); - ErrorF("\n"); -} - -void -ddxGiveUp () -{ - AbortDDX (); -} - -Bool kdDumbDriver; -Bool kdSoftCursor; - -static char * -KdParseFindNext (char *cur, char *delim, char *save, char *last) -{ - while (*cur && !strchr (delim, *cur)) - { - *save++ = *cur++; - } - *save = 0; - *last = *cur; - if (*cur) - cur++; - return cur; -} - -Rotation -KdAddRotation (Rotation a, Rotation b) -{ - Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All); - Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All); - - if (rotate > RR_Rotate_270) - rotate /= (RR_Rotate_270 * RR_Rotate_90); - return reflect | rotate; -} - -Rotation -KdSubRotation (Rotation a, Rotation b) -{ - Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All); - Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All); - - if (rotate > RR_Rotate_270) - rotate /= (RR_Rotate_270 * RR_Rotate_90); - return reflect | rotate; -} - -void -KdParseScreen (KdScreenInfo *screen, - char *arg) -{ - char delim; - char save[1024]; - int fb; - int i; - int pixels, mm; - - screen->dumb = kdDumbDriver; - screen->softCursor = kdSoftCursor; - screen->origin = kdOrigin; - screen->randr = RR_Rotate_0; - screen->width = 0; - screen->height = 0; - screen->width_mm = 0; - screen->height_mm = 0; - screen->subpixel_order = kdSubpixelOrder; - screen->rate = 0; - for (fb = 0; fb < KD_MAX_FB; fb++) - screen->fb[fb].depth = 0; - if (!arg) - return; - if (strlen (arg) >= sizeof (save)) - return; - - for (i = 0; i < 2; i++) - { - arg = KdParseFindNext (arg, "x/@XY", save, &delim); - if (!save[0]) - return; - - pixels = atoi(save); - mm = 0; - - if (delim == '/') - { - arg = KdParseFindNext (arg, "x@XY", save, &delim); - if (!save[0]) - return; - mm = atoi(save); - } - - if (i == 0) - { - screen->width = pixels; - screen->width_mm = mm; - } - else - { - screen->height = pixels; - screen->height_mm = mm; - } - if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y') - return; - } - - kdOrigin.x += screen->width; - kdOrigin.y = 0; - kdDumbDriver = FALSE; - kdSoftCursor = FALSE; - kdSubpixelOrder = SubPixelUnknown; - - if (delim == '@') - { - arg = KdParseFindNext (arg, "xXY", save, &delim); - if (save[0]) - { - int rotate = atoi (save); - if (rotate < 45) - screen->randr = RR_Rotate_0; - else if (rotate < 135) - screen->randr = RR_Rotate_90; - else if (rotate < 225) - screen->randr = RR_Rotate_180; - else if (rotate < 315) - screen->randr = RR_Rotate_270; - else - screen->randr = RR_Rotate_0; - } - } - if (delim == 'X') - { - arg = KdParseFindNext (arg, "xY", save, &delim); - screen->randr |= RR_Reflect_X; - } - - if (delim == 'Y') - { - arg = KdParseFindNext (arg, "xY", save, &delim); - screen->randr |= RR_Reflect_Y; - } - - fb = 0; - while (fb < KD_MAX_FB) - { - arg = KdParseFindNext (arg, "x/,", save, &delim); - if (!save[0]) - break; - screen->fb[fb].depth = atoi(save); - if (delim == '/') - { - arg = KdParseFindNext (arg, "x,", save, &delim); - if (!save[0]) - break; - screen->fb[fb].bitsPerPixel = atoi (save); - } - else - screen->fb[fb].bitsPerPixel = 0; - if (delim != ',') - break; - fb++; - } - - if (delim == 'x') - { - arg = KdParseFindNext (arg, "x", save, &delim); - if (save[0]) - screen->rate = atoi(save); - } -} - -/* - * Mouse argument syntax: - * - * device,protocol,options... - * - * Options are any of: - * 1-5 n button mouse - * 2button emulate middle button - * {NMO} Reorder buttons - */ - -char * -KdSaveString (char *str) -{ - char *n = (char *) xalloc (strlen (str) + 1); - - if (!n) - return 0; - strcpy (n, str); - return n; -} - -/* - * Parse mouse information. Syntax: - * - * <device>,<nbutton>,<protocol>{,<option>}... - * - * options: {nmo} pointer mapping (e.g. {321}) - * 2button emulate middle button - * 3button dont emulate middle button - */ - -void -KdParseMouse (char *arg) -{ - char save[1024]; - char delim; - KdMouseInfo *mi; - int i; - - mi = KdMouseInfoAdd (); - if (!mi) - return; - mi->name = 0; - mi->prot = 0; - mi->emulateMiddleButton = kdEmulateMiddleButton; - mi->transformCoordinates = !kdRawPointerCoordinates; - mi->nbutton = 3; - for (i = 0; i < KD_MAX_BUTTON; i++) - mi->map[i] = i + 1; - - if (!arg) - return; - if (strlen (arg) >= sizeof (save)) - return; - arg = KdParseFindNext (arg, ",", save, &delim); - if (!save[0]) - return; - mi->name = KdSaveString (save); - if (delim != ',') - return; - - arg = KdParseFindNext (arg, ",", save, &delim); - if (!save[0]) - return; - - if ('1' <= save[0] && save[0] <= '0' + KD_MAX_BUTTON && save[1] == '\0') - { - mi->nbutton = save[0] - '0'; - if (mi->nbutton > KD_MAX_BUTTON) - { - UseMsg (); - return; - } - } - - if (!delim != ',') - return; - - arg = KdParseFindNext (arg, ",", save, &delim); - - if (save[0]) - mi->prot = KdSaveString (save); - - while (delim == ',') - { - arg = KdParseFindNext (arg, ",", save, &delim); - if (save[0] == '{') - { - char *s = save + 1; - i = 0; - while (*s && *s != '}') - { - if ('1' <= *s && *s <= '0' + mi->nbutton) - mi->map[i] = *s - '0'; - else - UseMsg (); - s++; - } - } - else if (!strcmp (save, "2button")) - mi->emulateMiddleButton = TRUE; - else if (!strcmp (save, "3button")) - mi->emulateMiddleButton = FALSE; - else if (!strcmp (save, "rawcoord")) - mi->transformCoordinates = FALSE; - else if (!strcmp (save, "transform")) - mi->transformCoordinates = TRUE; - else - UseMsg (); - } -} - -void -KdParseRgba (char *rgba) -{ - if (!strcmp (rgba, "rgb")) - kdSubpixelOrder = SubPixelHorizontalRGB; - else if (!strcmp (rgba, "bgr")) - kdSubpixelOrder = SubPixelHorizontalBGR; - else if (!strcmp (rgba, "vrgb")) - kdSubpixelOrder = SubPixelVerticalRGB; - else if (!strcmp (rgba, "vbgr")) - kdSubpixelOrder = SubPixelVerticalBGR; - else if (!strcmp (rgba, "none")) - kdSubpixelOrder = SubPixelNone; - else - kdSubpixelOrder = SubPixelUnknown; -} - -int -KdProcessArgument (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 (); - } - if (card) { - screen = KdScreenInfoAdd (card); - KdParseScreen (screen, argv[i+1]); - } else - ErrorF("No matching card found!\n"); - } - 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], "-rawcoord")) - { - kdRawPointerCoordinates = 1; - 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], "-origin")) - { - if ((i+1) < argc) - { - char *x = argv[i+1]; - char *y = strchr (x, ','); - if (x) - kdOrigin.x = atoi (x); - else - kdOrigin.x = 0; - if (y) - kdOrigin.y = atoi(y+1); - else - kdOrigin.y = 0; - } - else - UseMsg (); - return 2; - } - if (!strcmp (argv[i], "-mouse")) - { - if ((i+1) < argc) - KdParseMouse (argv[i+1]); - else - UseMsg (); - return 2; - } - if (!strcmp (argv[i], "-rgba")) - { - if ((i+1) < argc) - KdParseRgba (argv[i+1]); - else - UseMsg (); - return 2; - } - if (!strcmp (argv[i], "-switchCmd")) - { - if ((i+1) < argc) - kdSwitchCmd = argv[i+1]; - else - UseMsg (); - return 2; - } - if (!strncmp (argv[i], "vt", 2) && - sscanf (argv[i], "vt%2d", &kdVirtualTerminal) == 1) - { - return 1; - } -#ifdef PSEUDO8 - return p8ProcessArgument (argc, argv, i); -#else - return 0; -#endif -} - -/* - * 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) - { - KdDoSwitchCmd ("start"); - (*pOsFuncs->Init) (); - } - } -} - -Bool -KdAllocatePrivates (ScreenPtr pScreen) -{ - KdPrivScreenPtr pScreenPriv; - - if (kdGeneration != serverGeneration) - { - kdScreenPrivateIndex = AllocateScreenPrivateIndex(); - kdGeneration = serverGeneration; - } - pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv)); - if (!pScreenPriv) - return FALSE; - memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec)); - KdSetScreenPriv (pScreen, pScreenPriv); - return TRUE; -} - -Bool -KdCreateScreenResources (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Bool ret; - - pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources; - ret = (*pScreen->CreateScreenResources) (pScreen); - pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; - pScreen->CreateScreenResources = KdCreateScreenResources; - if (ret && card->cfuncs->createRes) - ret = (*card->cfuncs->createRes) (pScreen); - return ret; -} - -Bool -KdCloseScreen (int index, ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdCardInfo *card = pScreenPriv->card; - Bool ret; - - pScreenPriv->closed = TRUE; - pScreen->CloseScreen = pScreenPriv->CloseScreen; - ret = (*pScreen->CloseScreen) (index, pScreen); - - if (screen->off_screen_base < screen->memory_size) - KdOffscreenFini (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) - { - if (kdEnabled) - (*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; -} - -static Bool -KdCreateWindow (WindowPtr pWin) -{ -#ifndef PHOENIX - if (!pWin->parent) - { - KdScreenPriv(pWin->drawable.pScreen); - - if (!pScreenPriv->enabled) - { - REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip); - REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); - } - } -#endif - return fbCreateWindow (pWin); -} - -void -KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - int subpixel_order = screen->subpixel_order; - Rotation subpixel_dir; - int i; - - static struct { - int subpixel_order; - Rotation direction; - } orders[] = { - { SubPixelHorizontalRGB, RR_Rotate_0 }, - { SubPixelHorizontalBGR, RR_Rotate_180 }, - { SubPixelVerticalRGB, RR_Rotate_270 }, - { SubPixelVerticalBGR, RR_Rotate_90 }, - }; - - static struct { - int bit; - int normal; - int reflect; - } reflects[] = { - { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR }, - { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB }, - { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR }, - { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB }, - }; - - /* map subpixel to direction */ - for (i = 0; i < 4; i++) - if (orders[i].subpixel_order == subpixel_order) - break; - if (i < 4) - { - subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction); - - /* map back to subpixel order */ - for (i = 0; i < 4; i++) - if (orders[i].direction & subpixel_dir) - { - subpixel_order = orders[i].subpixel_order; - break; - } - /* reflect */ - for (i = 0; i < 4; i++) - if ((randr & reflects[i].bit) && - reflects[i].normal == subpixel_order) - { - subpixel_order = reflects[i].reflect; - break; - } - } - PictureSetSubpixelOrder (pScreen, subpixel_order); -} - -/* 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; - int fb; - /* - * note that screen->fb is set up for the nominal orientation - * of the screen; that means if randr is rotated, the values - * there should reflect a rotated frame buffer (or shadow). - */ - Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0; - int width, height, *width_mmp, *height_mmp; - - KdAllocatePrivates (pScreen); - - pScreenPriv = KdGetScreenPriv(pScreen); - - if (!rotated) - { - width = screen->width; - height = screen->height; - width_mmp = &screen->width_mm; - height_mmp = &screen->height_mm; - } - else - { - width = screen->height; - height = screen->width; - width_mmp = &screen->height_mm; - height_mmp = &screen->width_mm; - } - screen->pScreen = pScreen; - pScreenPriv->screen = screen; - pScreenPriv->card = card; - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - pScreenPriv->bytesPerPixel[fb] = screen->fb[fb].bitsPerPixel >> 3; - pScreenPriv->dpmsState = KD_DPMS_NORMAL; -#ifdef PANORAMIX - dixScreenOrigins[pScreen->myNum] = screen->origin; -#endif - - if (!monitorResolution) - monitorResolution = 75; - /* - * This is done in this order so that backing store wraps - * our GC functions; fbFinishScreenInit initializes MI - * backing store - */ - if (!fbSetupScreen (pScreen, - screen->fb[0].frameBuffer, - width, height, - monitorResolution, monitorResolution, - screen->fb[0].pixelStride, - screen->fb[0].bitsPerPixel)) - { - return FALSE; - } - - /* - * Set colormap functions - */ - pScreen->InstallColormap = KdInstallColormap; - pScreen->UninstallColormap = KdUninstallColormap; - pScreen->ListInstalledColormaps = KdListInstalledColormaps; - pScreen->StoreColors = KdStoreColors; - - pScreen->SaveScreen = KdSaveScreen; - pScreen->CreateWindow = KdCreateWindow; - -#ifdef FB_OLD_SCREEN - pScreenPriv->BackingStoreFuncs.SaveAreas = fbSaveAreas; - pScreenPriv->BackingStoreFuncs.RestoreAreas = fbSaveAreas; - pScreenPriv->BackingStoreFuncs.SetClipmaskRgn = 0; - pScreenPriv->BackingStoreFuncs.GetImagePixmap = 0; - pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0; -#endif - -#if KD_MAX_FB > 1 - if (screen->fb[1].depth) - { - if (!fbOverlayFinishScreenInit (pScreen, - screen->fb[0].frameBuffer, - screen->fb[1].frameBuffer, - width, height, - monitorResolution, monitorResolution, - screen->fb[0].pixelStride, - screen->fb[1].pixelStride, - screen->fb[0].bitsPerPixel, - screen->fb[1].bitsPerPixel, - screen->fb[0].depth, - screen->fb[1].depth)) - { - return FALSE; - } - } - else -#endif - { - if (!fbFinishScreenInit (pScreen, - screen->fb[0].frameBuffer, - width, height, - monitorResolution, monitorResolution, - screen->fb[0].pixelStride, - screen->fb[0].bitsPerPixel)) - { - return FALSE; - } - } - - /* - * Fix screen sizes; for some reason mi takes dpi instead of mm. - * Rounding errors are annoying - */ - if (*width_mmp) - pScreen->mmWidth = *width_mmp; - else - *width_mmp = pScreen->mmWidth; - if (*height_mmp) - pScreen->mmHeight = *height_mmp; - else - *height_mmp = pScreen->mmHeight; - - /* - * Plug in our own block/wakeup handlers. - * miScreenInit installs NoopDDA in both places - */ - pScreen->BlockHandler = KdBlockHandler; - pScreen->WakeupHandler = KdWakeupHandler; - -#ifdef RENDER - if (!fbPictureInit (pScreen, 0, 0)) - return FALSE; -#endif - if (card->cfuncs->initScreen) - if (!(*card->cfuncs->initScreen) (pScreen)) - return FALSE; - - if (!screen->dumb && card->cfuncs->initAccel) - if (!(*card->cfuncs->initAccel) (pScreen)) - screen->dumb = TRUE; - - if (screen->off_screen_base < screen->memory_size) - KdOffscreenInit (pScreen); - -#ifdef PSEUDO8 - (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT); -#endif - - if (card->cfuncs->finishInitScreen) - if (!(*card->cfuncs->finishInitScreen) (pScreen)) - return FALSE; - -#if 0 - fbInitValidateTree (pScreen); -#endif - -#if 0 - pScreen->backingStoreSupport = Always; -#ifdef FB_OLD_SCREEN - miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs); -#else - miInitializeBackingStore (pScreen); -#endif -#endif - - - /* - * Wrap CloseScreen, the order now is: - * KdCloseScreen - * miBSCloseScreen - * fbCloseScreen - */ - pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = KdCloseScreen; - - pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; - pScreen->CreateScreenResources = KdCreateScreenResources; - - 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; - } - - KdSetSubpixelOrder (pScreen, screen->randr); - - /* - * Enable the hardware - */ - if (!kdEnabled) - { - kdEnabled = TRUE; - (*kdOsFuncs->Enable) (); - } - - if (screen->mynum == card->selected) - { - (*card->cfuncs->preserve) (card); - if (!(*card->cfuncs->enable) (pScreen)) - return FALSE; - 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; - - (*card->cfuncs->scrinit) (screen); - - if (!card->cfuncs->initAccel) - screen->dumb = TRUE; - if (!card->cfuncs->initCursor) - screen->softCursor = TRUE; -} - -static Bool -KdSetPixmapFormats (ScreenInfo *pScreenInfo) -{ - CARD8 depthToBpp[33]; /* depth -> bpp map */ - KdCardInfo *card; - KdScreenInfo *screen; - int i; - int bpp; - int fb; - PixmapFormatRec *format; - - for (i = 1; i <= 32; i++) - depthToBpp[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) - { - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - { - bpp = screen->fb[fb].bitsPerPixel; - if (bpp == 24) - bpp = 32; - if (!depthToBpp[screen->fb[fb].depth]) - depthToBpp[screen->fb[fb].depth] = bpp; - else if (depthToBpp[screen->fb[fb].depth] != bpp) - return FALSE; - } - } - } - - /* - * Fill in additional formats - */ - for (i = 0; i < NUM_KD_BPP; i++) - if (!depthToBpp[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; -} - -static 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; - int fb; - - visuals = 0; - rm = gm = bm = 0; - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - { - if (pScreenInfo->formats[i].depth == screen->fb[fb].depth) - { - visuals = screen->fb[fb].visuals; - rm = screen->fb[fb].redMask; - gm = screen->fb[fb].greenMask; - bm = screen->fb[fb].blueMask; - break; - } - } - fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth, - visuals, - 8, - rm, gm, bm); - } - - kdCurrentScreen = screen; - - AddScreen (KdScreenInit, argc, argv); -} - -#if 0 /* This function is not used currently */ - -int -KdDepthToFb (ScreenPtr pScreen, int depth) -{ - KdScreenPriv(pScreen); - int fb; - - for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb[fb].frameBuffer; fb++) - if (pScreenPriv->screen->fb[fb].depth == depth) - return fb; -} - -#endif - -void -KdInitOutput (ScreenInfo *pScreenInfo, - int argc, - char **argv) -{ - KdCardInfo *card; - KdScreenInfo *screen; - - if (!kdCardInfo) - { - InitCard (0); - if (!(card = KdCardInfoLast ())) - FatalError("No matching cards found!\n"); - 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 diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h deleted file mode 100644 index 8969e6f83..000000000 --- a/hw/kdrive/src/kdrive.h +++ /dev/null @@ -1,828 +0,0 @@ -/* - * Id: kdrive.h,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.29 2002/11/13 16:37:39 keithp Exp $ */ - -#include <stdio.h> -#include <X11/X.h> -#define NEED_EVENTS -#include <X11/Xproto.h> -#include <X11/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" -#include "fboverlay.h" -#include "shadow.h" -#include "randrstr.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 - -#ifndef KD_MAX_FB -#define KD_MAX_FB FB_OVERLAY_MAX -#endif - -#ifndef KD_MAX_CARD_ADDRESS -#define KD_MAX_CARD_ADDRESS 8 -#endif - -/* - * Configuration information per video card - */ - -typedef struct _KdCardAttr { - CARD32 io; - CARD32 address[KD_MAX_CARD_ADDRESS]; - int naddr; - int bus; -} KdCardAttr; - -typedef struct _KdCardInfo { - struct _KdCardFuncs *cfuncs; - void *closure; - KdCardAttr attr; - void *driver; - struct _KdScreenInfo *screenList; - int selected; - struct _KdCardInfo *next; - Bool needSync; -} KdCardInfo; - -extern KdCardInfo *kdCardInfo; - -/* - * Configuration information per X screen - */ -typedef struct _KdFrameBuffer { - CARD8 *frameBuffer; - int depth; - int bitsPerPixel; - int pixelStride; - int byteStride; - Bool shadow; - unsigned long visuals; - Pixel redMask, greenMask, blueMask; - void *closure; -} KdFrameBuffer; - -#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270) -#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y) - -typedef struct _KdScreenInfo { - struct _KdScreenInfo *next; - KdCardInfo *card; - ScreenPtr pScreen; - void *driver; - Rotation randr; /* rotation and reflection */ - int width; - int height; - int rate; - int width_mm; - int height_mm; - int subpixel_order; - Bool dumb; - Bool softCursor; - int mynum; - DDXPointRec origin; - KdFrameBuffer fb[KD_MAX_FB]; - CARD8 *memory_base; - unsigned long memory_size; - unsigned long off_screen_base; - struct _RealOffscreenArea *off_screen_areas; -} KdScreenInfo; - -typedef struct _KdCardFuncs { - Bool (*cardinit) (KdCardInfo *); /* detect and map device */ - Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */ - Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */ - Bool (*finishInitScreen) (ScreenPtr pScreen); - Bool (*createRes) (ScreenPtr); /* create screen resources */ - void (*preserve) (KdCardInfo *); /* save graphics card state */ - Bool (*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 (*syncAccel) (ScreenPtr); - void (*disableAccel) (ScreenPtr); - void (*finiAccel) (ScreenPtr); - - void (*getColors) (ScreenPtr, int, int, xColorItem *); - void (*putColors) (ScreenPtr, int, 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; - Bool closed; - int bytesPerPixel[KD_MAX_FB]; - - int dpmsState; - - ColormapPtr pInstalledmap[KD_MAX_FB]; /* current colormap */ - xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */ - - CreateScreenResourcesProcPtr CreateScreenResources; - CloseScreenProcPtr CloseScreen; -#ifdef FB_OLD_SCREEN - miBSFuncRec BackingStoreFuncs; -#endif -} KdPrivScreenRec, *KdPrivScreenPtr; - -typedef enum _kdMouseState { - start, - button_1_pend, - button_1_down, - button_2_down, - button_3_pend, - button_3_down, - synth_2_down_13, - synth_2_down_3, - synth_2_down_1, - num_input_states -} KdMouseState; - -#define KD_MAX_BUTTON 7 - -typedef struct _KdMouseInfo { - struct _KdMouseInfo *next; - void *driver; - void *closure; - char *name; - char *prot; - char map[KD_MAX_BUTTON]; - int nbutton; - Bool emulateMiddleButton; - unsigned long emulationTimeout; - Bool timeoutPending; - KdMouseState mouseState; - Bool eventHeld; - xEvent heldEvent; - unsigned char buttonState; - int emulationDx, emulationDy; - int inputType; - Bool transformCoordinates; -} KdMouseInfo; - -extern KdMouseInfo *kdMouseInfo; - -extern int KdCurScreen; - -KdMouseInfo *KdMouseInfoAdd (void); -void KdMouseInfoDispose (KdMouseInfo *mi); -void KdParseMouse (char *); - -typedef struct _KdMouseFuncs { - Bool (*Init) (void); - void (*Fini) (void); -} KdMouseFuncs; - -typedef struct _KdKeyboardFuncs { - void (*Load) (void); - int (*Init) (void); - void (*Leds) (int); - void (*Bell) (int, int, int); - void (*Fini) (void); - int LockLed; -} KdKeyboardFuncs; - -typedef struct _KdOsFuncs { - int (*Init) (void); - void (*Enable) (void); - Bool (*SpecialKey) (KeySym); - void (*Disable) (void); - void (*Fini) (void); -} KdOsFuncs; - -typedef enum _KdSyncPolarity { - KdSyncNegative, KdSyncPositive -} KdSyncPolarity; - -typedef struct _KdMonitorTiming { - /* label */ - int horizontal; - int vertical; - int rate; - /* pixel clock */ - int clock; /* in KHz */ - /* horizontal timing */ - int hfp; /* front porch */ - int hbp; /* back porch */ - int hblank; /* blanking */ - KdSyncPolarity hpol; /* polarity */ - /* vertical timing */ - int vfp; /* front porch */ - int vbp; /* back porch */ - int vblank; /* blanking */ - KdSyncPolarity vpol; /* polarity */ -} KdMonitorTiming; - -typedef struct _KdOffscreenArea { - ScreenPtr screen; - int offset; - int size; - pointer privData; -} KdOffscreenArea; - -extern const KdMonitorTiming kdMonitorTimings[]; -extern const int kdNumMonitorTimings; - -typedef struct _KdMouseMatrix { - int matrix[2][3]; -} KdMouseMatrix; - -typedef struct _KaaScreenInfo { - Bool (*PrepareSolid) (PixmapPtr pPixmap, - int alu, - Pixel planemask, - Pixel fg); - void (*Solid) (int x1, int y1, int x2, int y2); - void (*DoneSolid) (void); - - Bool (*PrepareCopy) (PixmapPtr pSrcPixmap, - PixmapPtr pDstPixmap, - Bool upsidedown, - Bool reverse, - int alu, - Pixel planemask); - void (*Copy) (int srcX, - int srcY, - int dstX, - int dstY, - int width, - int height); - void (*DoneCopy) (void); - - int offscreenByteAlign; - int offscreenPitch; - int flags; -} KaaScreenInfoRec, *KaaScreenInfoPtr; - -#define KAA_OFFSCREEN_PIXMAPS (1 << 0) - -/* - * 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 int kdVirtualTerminal; -extern char *kdSwitchCmd; -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) - -#define KdCheckSync(s) { \ - KdScreenPriv(s); \ - KdCardInfo *card = pScreenPriv->card; \ - if (card->needSync) { \ - card->needSync = FALSE; \ - (*card->cfuncs->syncAccel) (s); \ - } \ -} - -#define KdMarkSync(s) (KdGetScreenPriv(s)->card->needSync = TRUE) - -/* kaa.c */ -Bool -kaaDrawInit (ScreenPtr pScreen, - KaaScreenInfoPtr pScreenInfo); - -void -kaaDrawFini (ScreenPtr pScreen); - -void -kaaWrapGC (GCPtr pGC); - -void -kaaUnwrapGC (GCPtr pGC); - -/* kasync.c */ -void -KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans, - DDXPointPtr ppt, int *pwidth, int fSorted); - -void -KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc, - DDXPointPtr ppt, int *pwidth, int nspans, int fSorted); - -void -KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, int format, - char *bits); - -RegionPtr -KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty); - -RegionPtr -KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty, - unsigned long bitPlane); - -void -KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, - DDXPointPtr pptInit); - -void -KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr ppt); - -void -KdCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC, - int nsegInit, xSegment *pSegInit); - -void -KdCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC, - int nrects, xRectangle *prect); - -void -KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *pArcs); - -#define KdCheckFillPolygon miFillPolygon - -void -KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, - int nrect, xRectangle *prect); - -void -KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *pArcs); - -void -KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase); - -void -KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase); - -void -KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap, - DrawablePtr pDrawable, - int w, int h, int x, int y); - -void -KdCheckGetImage (DrawablePtr pDrawable, - int x, int y, int w, int h, - unsigned int format, unsigned long planeMask, - char *d); - -void -KdCheckGetSpans (DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, - char *pdstStart); - -void -KdCheckSaveAreas (PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin); - -void -KdCheckRestoreAreas (PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin); - -void -KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what); - -void -KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); - -void -KdCheckPaintKey(DrawablePtr pDrawable, - RegionPtr pRegion, - CARD32 pixel, - int layer); - -void -KdCheckOverlayCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); - -void -KdScreenInitAsync (ScreenPtr pScreen); - -void -KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what); - -extern const GCOps kdAsyncPixmapGCOps; - -/* knoop.c */ -extern GCOps kdNoopOps; - -/* kcmap.c */ -void -KdSetColormap (ScreenPtr pScreen, int fb); - -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); - -/* kcurscol.c */ -void -KdAllocateCursorPixels (ScreenPtr pScreen, - int fb, - CursorPtr pCursor, - Pixel *source, - Pixel *mask); - -/* kdrive.c */ -extern miPointerScreenFuncRec kdPointerScreenFuncs; - -void -KdSetRootClip (ScreenPtr pScreen, BOOL enable); - -void -KdDisableScreen (ScreenPtr pScreen); - -void -KdDisableScreens (void); - -Bool -KdEnableScreen (ScreenPtr pScreen); - -void -KdEnableScreens (void); - -void -KdSuspend (void); - -void -KdResume (void); - -void -KdProcessSwitch (void); - -Rotation -KdAddRotation (Rotation a, Rotation b); - -Rotation -KdSubRotation (Rotation a, Rotation b); - -void -KdParseScreen (KdScreenInfo *screen, - char *arg); - -char * -KdSaveString (char *str); - -void -KdParseMouse (char *arg); - -void -KdParseRgba (char *rgba); - -int -KdProcessArgument (int argc, char **argv, int i); - -void -KdOsInit (KdOsFuncs *pOsFuncs); - -Bool -KdAllocatePrivates (ScreenPtr pScreen); - -Bool -KdCreateScreenResources (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); - -void -KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr); - -/* 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 *); - -int -KdAllocInputType (void); - -Bool -KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure); - -void -KdRegisterFdEnableDisable (int fd, - int (*enable) (int fd, void *closure), - void (*disable) (int fd, void *closure)); - -void -KdUnregisterFds (int type, Bool do_close); - -#ifdef TOUCHSCREEN -void -KdInitTouchScreen(KdMouseFuncs *pTsFuncs); -#endif - -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_BUTTON_4 0x08 -#define KD_BUTTON_5 0x10 -#define KD_MOUSE_DELTA 0x80000000 - -void -KdEnqueueMouseEvent(KdMouseInfo *mi, unsigned long flags, int x, int y); - -void -KdEnqueueMotionEvent (KdMouseInfo *mi, int x, int y); - -void -KdReleaseAllKeys (void); - -void -KdSetLed (int led, Bool on); - -void -KdSetMouseMatrix (KdMouseMatrix *matrix); - -void -KdComputeMouseMatrix (KdMouseMatrix *matrix, Rotation randr, int width, int height); - -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 (void); - -extern KdMouseFuncs LinuxMouseFuncs; -extern KdMouseFuncs Ps2MouseFuncs; -extern KdMouseFuncs BusMouseFuncs; -extern KdMouseFuncs MsMouseFuncs; -#ifdef TOUCHSCREEN -extern KdMouseFuncs TsFuncs; -#endif -extern KdKeyboardFuncs LinuxKeyboardFuncs; -extern KdOsFuncs LinuxFuncs; - -extern KdMouseFuncs VxWorksMouseFuncs; -extern KdKeyboardFuncs VxWorksKeyboardFuncs; -extern KdOsFuncs VxWorksFuncs; - -/* kmap.c */ - -#define KD_MAPPED_MODE_REGISTERS 0 -#define KD_MAPPED_MODE_FRAMEBUFFER 1 - -void * -KdMapDevice (CARD32 addr, CARD32 size); - -void -KdUnmapDevice (void *addr, CARD32 size); - -void -KdSetMappedMode (CARD32 addr, CARD32 size, int mode); - -void -KdResetMappedMode (CARD32 addr, CARD32 size, int mode); - -/* kmode.c */ -const KdMonitorTiming * -KdFindMode (KdScreenInfo *screen, - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)); - -Bool -KdTuneMode (KdScreenInfo *screen, - Bool (*usable) (KdScreenInfo *), - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)); - -#ifdef RANDR -Bool -KdRandRGetInfo (ScreenPtr pScreen, - int randr, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *)); - -const KdMonitorTiming * -KdRandRGetTiming (ScreenPtr pScreen, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *), - int rate, - RRScreenSizePtr pSize); -#endif - -/* kpict.c */ -void -KdPictureInitAsync (ScreenPtr pScreen); - -#ifdef RENDER -void -KdCheckComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -#endif - -/* kshadow.c */ -Bool -KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate); - -void -KdShadowFbFree (KdScreenInfo *screen, int fb); - -Bool -KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window); - -void -KdShadowUnset (ScreenPtr pScreen); - -/* ktest.c */ -Bool -KdFrameBufferValid (CARD8 *base, int size); - -int -KdFrameBufferSize (CARD8 *base, int max); - -/* koffscreen.c */ -typedef void (*KdOffscreenSaveProc) (KdOffscreenArea *area); - -Bool -KdOffscreenInit (ScreenPtr pScreen); - -KdOffscreenArea * -KdOffscreenAlloc (ScreenPtr pScreen, int size, int align, - Bool locked, - KdOffscreenSaveProc save, - pointer privData); - -void -KdOffscreenFree (KdOffscreenArea *area); - -void -KdOffscreenSwapOut (ScreenPtr pScreen); - -void -KdOffscreenSwapIn (ScreenPtr pScreen); - -void -KdOffscreenFini (ScreenPtr pScreen); - -/* function prototypes to be implemented by the drivers */ -void -InitCard (char *name); diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c deleted file mode 100644 index 883f7e56c..000000000 --- a/hw/kdrive/src/kinfo.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Id: kinfo.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kinfo.c,v 1.2 2000/02/23 20:29:53 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; - } -} - -KdMouseInfo *kdMouseInfo; - -KdMouseInfo * -KdMouseInfoAdd (void) -{ - KdMouseInfo *mi, **prev; - - mi = (KdMouseInfo *) xalloc (sizeof (KdMouseInfo)); - if (!mi) - return 0; - bzero (mi, sizeof (KdMouseInfo)); - for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next); - *prev = mi; - return mi; -} - -void -KdMouseInfoDispose (KdMouseInfo *mi) -{ - KdMouseInfo **prev; - - for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next) - if (*prev == mi) - { - *prev = mi->next; - if (mi->name) - xfree (mi->name); - if (mi->prot) - xfree (mi->prot); - xfree (mi); - break; - } -} diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c deleted file mode 100644 index eb65cb98a..000000000 --- a/hw/kdrive/src/kinput.c +++ /dev/null @@ -1,1649 +0,0 @@ -/* - * Id: kinput.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.30 2002/11/13 16:37:39 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "inputstr.h" - -#define XK_PUBLISHING -#include <X11/keysym.h> -#if HAVE_X11_XF86KEYSYM_H -#include <X11/XF86keysym.h> -#endif -#include "kkeymap.h" -#include <signal.h> -#include <stdio.h> - -static DeviceIntPtr pKdKeyboard, pKdPointer; - -static KdMouseFuncs *kdMouseFuncs; -static KdKeyboardFuncs *kdKeyboardFuncs; -static int kdBellPitch; -static int kdBellDuration; -static int kdLeds; -static Bool kdInputEnabled; -static Bool kdOffScreen; -static unsigned long kdOffScreenTime; -static KdMouseMatrix kdMouseMatrix = { - { { 1, 0, 0 }, - { 0, 1, 0 } } -}; - -#ifdef TOUCHSCREEN -static KdMouseFuncs *kdTsFuncs; -#endif - -int kdMouseButtonCount; -int kdMinScanCode; -int kdMaxScanCode; -int kdMinKeyCode; -int kdMaxKeyCode; -int kdKeymapWidth = KD_MAX_WIDTH; -KeySym kdKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH]; -CARD8 kdModMap[MAP_LENGTH]; -KeySymsRec kdKeySyms; - - -void -KdResetInputMachine (void); - -#define KD_KEY_COUNT 248 - -CARD8 kdKeyState[KD_KEY_COUNT/8]; - -#define IsKeyDown(key) ((kdKeyState[(key) >> 3] >> ((key) & 7)) & 1) - -#define KD_MAX_INPUT_FDS 8 - -typedef struct _kdInputFd { - int type; - int fd; - void (*read) (int fd, void *closure); - int (*enable) (int fd, void *closure); - void (*disable) (int fd, void *closure); - void *closure; -} KdInputFd; - -KdInputFd kdInputFds[KD_MAX_INPUT_FDS]; -int kdNumInputFds; -int kdInputTypeSequence; - -static void -KdSigio (int sig) -{ - int i; - - for (i = 0; i < kdNumInputFds; i++) - (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure); -} - -static void -KdBlockSigio (void) -{ - sigset_t set; - - sigemptyset (&set); - sigaddset (&set, SIGIO); - sigprocmask (SIG_BLOCK, &set, 0); -} - -static void -KdUnblockSigio (void) -{ - sigset_t set; - - sigemptyset (&set); - sigaddset (&set, SIGIO); - sigprocmask (SIG_UNBLOCK, &set, 0); -} - -#undef VERIFY_SIGIO -#ifdef VERIFY_SIGIO - -void -KdAssertSigioBlocked (char *where) -{ - sigset_t set, old; - - sigemptyset (&set); - sigprocmask (SIG_BLOCK, &set, &old); - if (!sigismember (&old, SIGIO)) - ErrorF ("SIGIO not blocked at %s\n", where); -} - -#else - -#define KdAssertSigioBlocked(s) - -#endif - -static int kdnFds; - -#ifdef FNONBLOCK -#define NOBLOCK FNONBLOCK -#else -#define NOBLOCK FNDELAY -#endif - -static void -KdNonBlockFd (int fd) -{ - int flags; - flags = fcntl (fd, F_GETFL); - flags |= FASYNC|NOBLOCK; - fcntl (fd, F_SETFL, flags); -} - -static void -KdAddFd (int fd) -{ - struct sigaction act; - sigset_t set; - - kdnFds++; - fcntl (fd, F_SETOWN, getpid()); - KdNonBlockFd (fd); - AddEnabledDevice (fd); - memset (&act, '\0', sizeof act); - act.sa_handler = KdSigio; - sigemptyset (&act.sa_mask); - sigaddset (&act.sa_mask, SIGIO); - sigaddset (&act.sa_mask, SIGALRM); - sigaddset (&act.sa_mask, SIGVTALRM); - sigaction (SIGIO, &act, 0); - sigemptyset (&set); - sigprocmask (SIG_SETMASK, &set, 0); -} - -static void -KdRemoveFd (int fd) -{ - struct sigaction act; - int flags; - - kdnFds--; - RemoveEnabledDevice (fd); - flags = fcntl (fd, F_GETFL); - flags &= ~(FASYNC|NOBLOCK); - fcntl (fd, F_SETFL, flags); - if (kdnFds == 0) - { - memset (&act, '\0', sizeof act); - act.sa_handler = SIG_IGN; - sigemptyset (&act.sa_mask); - sigaction (SIGIO, &act, 0); - } -} - -int -KdAllocInputType (void) -{ - return ++kdInputTypeSequence; -} - -Bool -KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure) -{ - if (kdNumInputFds == KD_MAX_INPUT_FDS) - return FALSE; - kdInputFds[kdNumInputFds].type = type; - kdInputFds[kdNumInputFds].fd = fd; - kdInputFds[kdNumInputFds].read = read; - kdInputFds[kdNumInputFds].enable = 0; - kdInputFds[kdNumInputFds].disable = 0; - kdInputFds[kdNumInputFds].closure = closure; - ++kdNumInputFds; - if (kdInputEnabled) - KdAddFd (fd); - return TRUE; -} - -void -KdRegisterFdEnableDisable (int fd, - int (*enable) (int fd, void *closure), - void (*disable) (int fd, void *closure)) -{ - int i; - - for (i = 0; i < kdNumInputFds; i++) - if (kdInputFds[i].fd == fd) - { - kdInputFds[i].enable = enable; - kdInputFds[i].disable = disable; - break; - } -} - -void -KdUnregisterFds (int type, Bool do_close) -{ - int i, j; - - for (i = 0; i < kdNumInputFds;) - { - if (kdInputFds[i].type == type) - { - if (kdInputEnabled) - KdRemoveFd (kdInputFds[i].fd); - if (do_close) - close (kdInputFds[i].fd); - --kdNumInputFds; - for (j = i; j < kdNumInputFds; j++) - kdInputFds[j] = kdInputFds[j+1]; - } - else - i++; - } -} - -void -KdDisableInput (void) -{ - int i; - - for (i = 0; i < kdNumInputFds; i++) - { - KdRemoveFd (kdInputFds[i].fd); - if (kdInputFds[i].disable) - (*kdInputFds[i].disable) (kdInputFds[i].fd, kdInputFds[i].closure); - } - kdInputEnabled = FALSE; -} - -void -KdEnableInput (void) -{ - xEvent xE; - int i; - - kdInputEnabled = TRUE; - for (i = 0; i < kdNumInputFds; i++) - { - KdNonBlockFd (kdInputFds[i].fd); - if (kdInputFds[i].enable) - kdInputFds[i].fd = (*kdInputFds[i].enable) (kdInputFds[i].fd, kdInputFds[i].closure); - KdAddFd (kdInputFds[i].fd); - } - - /* reset screen saver */ - xE.u.keyButtonPointer.time = GetTimeInMillis (); - NoticeEventTime (&xE); -} - -static int -KdMouseProc(DeviceIntPtr pDevice, int onoff) -{ - BYTE map[KD_MAX_BUTTON]; - DevicePtr pDev = (DevicePtr)pDevice; - int i; - - if (!pDev) - return BadImplementation; - - switch (onoff) - { - case DEVICE_INIT: - for (i = 1; i <= kdMouseButtonCount; i++) - map[i] = i; - InitPointerDeviceStruct(pDev, map, kdMouseButtonCount, - miPointerGetMotionEvents, - (PtrCtrlProcPtr)NoopDDA, - miPointerGetMotionBufferSize()); - break; - - case DEVICE_ON: - pDev->on = TRUE; - pKdPointer = pDevice; -#ifdef TOUCHSCREEN - if (kdTsFuncs) - (*kdTsFuncs->Init) (); -#endif - if (kdMouseFuncs) - (*kdMouseFuncs->Init) (); - break; - case DEVICE_OFF: - case DEVICE_CLOSE: - if (pDev->on) - { - pDev->on = FALSE; - pKdPointer = 0; - if (kdMouseFuncs) - (*kdMouseFuncs->Fini) (); -#ifdef TOUCHSCREEN - if (kdTsFuncs) - (*kdTsFuncs->Fini) (); -#endif - } - break; - } - return Success; -} - -Bool -LegalModifier(unsigned int key, DevicePtr pDev) -{ - return TRUE; -} - -static void -KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something) -{ - if (kdInputEnabled) - (*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration); -} - - -static void -KdSetLeds (void) -{ - if (kdInputEnabled) - (*kdKeyboardFuncs->Leds) (kdLeds); -} - -void -KdSetLed (int led, Bool on) -{ - NoteLedState (pKdKeyboard, led, on); - kdLeds = pKdKeyboard->kbdfeed->ctrl.leds; - KdSetLeds (); -} - -void -KdSetMouseMatrix (KdMouseMatrix *matrix) -{ - kdMouseMatrix = *matrix; -} - -void -KdComputeMouseMatrix (KdMouseMatrix *m, Rotation randr, int width, int height) -{ - int x_dir = 1, y_dir = 1; - int i, j; - int size[2]; - - size[0] = width; size[1] = height; - if (randr & RR_Reflect_X) - x_dir = -1; - if (randr & RR_Reflect_Y) - y_dir = -1; - switch (randr & (RR_Rotate_All)) { - case RR_Rotate_0: - m->matrix[0][0] = x_dir; m->matrix[0][1] = 0; - m->matrix[1][0] = 0; m->matrix[1][1] = y_dir; - break; - case RR_Rotate_90: - m->matrix[0][0] = 0; m->matrix[0][1] = -x_dir; - m->matrix[1][0] = y_dir; m->matrix[1][1] = 0; - break; - case RR_Rotate_180: - m->matrix[0][0] = -x_dir; m->matrix[0][1] = 0; - m->matrix[1][0] = 0; m->matrix[1][1] = -y_dir; - break; - case RR_Rotate_270: - m->matrix[0][0] = 0; m->matrix[0][1] = x_dir; - m->matrix[1][0] = -y_dir; m->matrix[1][1] = 0; - break; - } - for (i = 0; i < 2; i++) - { - m->matrix[i][2] = 0; - for (j = 0 ; j < 2; j++) - if (m->matrix[i][j] < 0) - m->matrix[i][2] = size[j] - 1; - } -} - -static void -KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl) -{ - kdLeds = ctrl->leds; - kdBellPitch = ctrl->bell_pitch; - kdBellDuration = ctrl->bell_duration; - KdSetLeds (); -} - -static int -KdKeybdProc(DeviceIntPtr pDevice, int onoff) -{ - Bool ret; - DevicePtr pDev = (DevicePtr)pDevice; - - if (!pDev) - return BadImplementation; - - switch (onoff) - { - case DEVICE_INIT: - if (pDev != LookupKeyboardDevice()) - { - return !Success; - } - ret = InitKeyboardDeviceStruct(pDev, - &kdKeySyms, - kdModMap, - KdBell, KdKbdCtrl); - if (!ret) - return BadImplementation; - break; - case DEVICE_ON: - pDev->on = TRUE; - pKdKeyboard = pDevice; - if (kdKeyboardFuncs) - (*kdKeyboardFuncs->Init) (); - break; - case DEVICE_OFF: - case DEVICE_CLOSE: - pKdKeyboard = 0; - if (pDev->on) - { - pDev->on = FALSE; - if (kdKeyboardFuncs) - (*kdKeyboardFuncs->Fini) (); - } - break; - } - return Success; -} - -extern KeybdCtrl defaultKeyboardControl; - -static void -KdInitAutoRepeats (void) -{ - int key_code; - unsigned char mask; - int i; - unsigned char *repeats; - - repeats = defaultKeyboardControl.autoRepeats; - memset (repeats, '\0', 32); - for (key_code = KD_MIN_KEYCODE; key_code <= KD_MAX_KEYCODE; key_code++) - { - if (!kdModMap[key_code]) - { - i = key_code >> 3; - mask = 1 << (key_code & 7); - repeats[i] |= mask; - } - } -} - -const KdKeySymModsRec kdKeySymMods[] = { - { XK_Control_L, ControlMask }, - { XK_Control_R, ControlMask }, - { XK_Shift_L, ShiftMask }, - { XK_Shift_R, ShiftMask }, - { XK_Caps_Lock, LockMask }, - { XK_Shift_Lock, LockMask }, - { XK_Alt_L, Mod1Mask }, - { XK_Alt_R, Mod1Mask }, - { XK_Meta_L, Mod1Mask }, - { XK_Meta_R, Mod1Mask }, - { XK_Num_Lock, Mod2Mask }, - { XK_Super_L, Mod3Mask }, - { XK_Super_R, Mod3Mask }, - { XK_Hyper_L, Mod3Mask }, - { XK_Hyper_R, Mod3Mask }, - { XK_Mode_switch, Mod4Mask }, -#ifdef TOUCHSCREEN - /* PDA specific hacks */ -#ifdef XF86XK_Start - { XF86XK_Start, ControlMask }, -#endif - { XK_Menu, ShiftMask }, - { XK_telephone, Mod1Mask }, -#ifdef XF86XK_AudioRecord - { XF86XK_AudioRecord, Mod2Mask }, -#endif -#ifdef XF86XK_Calendar - { XF86XK_Calendar, Mod3Mask } -#endif -#endif -}; - -#define NUM_SYM_MODS (sizeof(kdKeySymMods) / sizeof(kdKeySymMods[0])) - -static void -KdInitModMap (void) -{ - int key_code; - int row; - int width; - KeySym *syms; - int i; - - width = kdKeySyms.mapWidth; - for (key_code = kdMinKeyCode; key_code <= kdMaxKeyCode; key_code++) - { - kdModMap[key_code] = 0; - syms = kdKeymap + (key_code - kdMinKeyCode) * width; - for (row = 0; row < width; row++, syms++) - { - for (i = 0; i < NUM_SYM_MODS; i++) - { - if (*syms == kdKeySymMods[i].modsym) - kdModMap[key_code] |= kdKeySymMods[i].modbit; - } - } - } -} - -void -KdInitInput(KdMouseFuncs *pMouseFuncs, - KdKeyboardFuncs *pKeyboardFuncs) -{ - DeviceIntPtr pKeyboard, pPointer; - KdMouseInfo *mi; - - if (!kdMouseInfo) - KdParseMouse (0); - kdMouseButtonCount = 0; - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->nbutton > kdMouseButtonCount) - kdMouseButtonCount = mi->nbutton; - } - - kdMouseFuncs = pMouseFuncs; - kdKeyboardFuncs = pKeyboardFuncs; - memset (kdKeyState, '\0', sizeof (kdKeyState)); - if (kdKeyboardFuncs) - (*kdKeyboardFuncs->Load) (); - kdMinKeyCode = kdMinScanCode + KD_KEY_OFFSET; - kdMaxKeyCode = kdMaxScanCode + KD_KEY_OFFSET; - kdKeySyms.map = kdKeymap; - kdKeySyms.minKeyCode = kdMinKeyCode; - kdKeySyms.maxKeyCode = kdMaxKeyCode; - kdKeySyms.mapWidth = kdKeymapWidth; - kdLeds = 0; - kdBellPitch = 1000; - kdBellDuration = 200; - kdInputEnabled = TRUE; - KdInitModMap (); - KdInitAutoRepeats (); - KdResetInputMachine (); - pPointer = AddInputDevice(KdMouseProc, TRUE); - pKeyboard = AddInputDevice(KdKeybdProc, TRUE); - RegisterPointerDevice(pPointer); - RegisterKeyboardDevice(pKeyboard); - miRegisterPointerDevice(screenInfo.screens[0], pPointer); - mieqInit(&pKeyboard->public, &pPointer->public); -#ifdef XINPUT - { - static long zero1, zero2; - - SetExtInputCheck (&zero1, &zero2); - } -#endif -} - -#ifdef TOUCHSCREEN -void -KdInitTouchScreen(KdMouseFuncs *pTsFuncs) -{ - kdTsFuncs = pTsFuncs; -} -#endif - -/* - * Middle button emulation state machine - * - * Possible transitions: - * Button 1 press v1 - * Button 1 release ^1 - * Button 2 press v2 - * Button 2 release ^2 - * Button 3 press v3 - * Button 3 release ^3 - * Button other press vo - * Button other release ^o - * Mouse motion <> - * Keyboard event k - * timeout ... - * outside box <-> - * - * States: - * start - * button_1_pend - * button_1_down - * button_2_down - * button_3_pend - * button_3_down - * synthetic_2_down_13 - * synthetic_2_down_3 - * synthetic_2_down_1 - * - * Transition diagram - * - * start - * v1 -> (hold) (settimeout) button_1_pend - * ^1 -> (deliver) start - * v2 -> (deliver) button_2_down - * ^2 -> (deliever) start - * v3 -> (hold) (settimeout) button_3_pend - * ^3 -> (deliver) start - * vo -> (deliver) start - * ^o -> (deliver) start - * <> -> (deliver) start - * k -> (deliver) start - * - * button_1_pend (button 1 is down, timeout pending) - * ^1 -> (release) (deliver) start - * v2 -> (release) (deliver) button_1_down - * ^2 -> (release) (deliver) button_1_down - * v3 -> (cleartimeout) (generate v2) synthetic_2_down_13 - * ^3 -> (release) (deliver) button_1_down - * vo -> (release) (deliver) button_1_down - * ^o -> (release) (deliver) button_1_down - * <-> -> (release) (deliver) button_1_down - * <> -> (deliver) button_1_pend - * k -> (release) (deliver) button_1_down - * ... -> (release) button_1_down - * - * button_1_down (button 1 is down) - * ^1 -> (deliver) start - * v2 -> (deliver) button_1_down - * ^2 -> (deliver) button_1_down - * v3 -> (deliver) button_1_down - * ^3 -> (deliver) button_1_down - * vo -> (deliver) button_1_down - * ^o -> (deliver) button_1_down - * <> -> (deliver) button_1_down - * k -> (deliver) button_1_down - * - * button_2_down (button 2 is down) - * v1 -> (deliver) button_2_down - * ^1 -> (deliver) button_2_down - * ^2 -> (deliver) start - * v3 -> (deliver) button_2_down - * ^3 -> (deliver) button_2_down - * vo -> (deliver) button_2_down - * ^o -> (deliver) button_2_down - * <> -> (deliver) button_2_down - * k -> (deliver) button_2_down - * - * button_3_pend (button 3 is down, timeout pending) - * v1 -> (generate v2) synthetic_2_down - * ^1 -> (release) (deliver) button_3_down - * v2 -> (release) (deliver) button_3_down - * ^2 -> (release) (deliver) button_3_down - * ^3 -> (release) (deliver) start - * vo -> (release) (deliver) button_3_down - * ^o -> (release) (deliver) button_3_down - * <-> -> (release) (deliver) button_3_down - * <> -> (deliver) button_3_pend - * k -> (release) (deliver) button_3_down - * ... -> (release) button_3_down - * - * button_3_down (button 3 is down) - * v1 -> (deliver) button_3_down - * ^1 -> (deliver) button_3_down - * v2 -> (deliver) button_3_down - * ^2 -> (deliver) button_3_down - * ^3 -> (deliver) start - * vo -> (deliver) button_3_down - * ^o -> (deliver) button_3_down - * <> -> (deliver) button_3_down - * k -> (deliver) button_3_down - * - * synthetic_2_down_13 (button 1 and 3 are down) - * ^1 -> (generate ^2) synthetic_2_down_3 - * v2 -> synthetic_2_down_13 - * ^2 -> synthetic_2_down_13 - * ^3 -> (generate ^2) synthetic_2_down_1 - * vo -> (deliver) synthetic_2_down_13 - * ^o -> (deliver) synthetic_2_down_13 - * <> -> (deliver) synthetic_2_down_13 - * k -> (deliver) synthetic_2_down_13 - * - * synthetic_2_down_3 (button 3 is down) - * v1 -> (deliver) synthetic_2_down_3 - * ^1 -> (deliver) synthetic_2_down_3 - * v2 -> synthetic_2_down_3 - * ^2 -> synthetic_2_down_3 - * ^3 -> start - * vo -> (deliver) synthetic_2_down_3 - * ^o -> (deliver) synthetic_2_down_3 - * <> -> (deliver) synthetic_2_down_3 - * k -> (deliver) synthetic_2_down_3 - * - * synthetic_2_down_1 (button 1 is down) - * ^1 -> start - * v2 -> synthetic_2_down_1 - * ^2 -> synthetic_2_down_1 - * v3 -> (deliver) synthetic_2_down_1 - * ^3 -> (deliver) synthetic_2_down_1 - * vo -> (deliver) synthetic_2_down_1 - * ^o -> (deliver) synthetic_2_down_1 - * <> -> (deliver) synthetic_2_down_1 - * k -> (deliver) synthetic_2_down_1 - */ - -typedef enum _inputClass { - down_1, up_1, - down_2, up_2, - down_3, up_3, - down_o, up_o, - motion, outside_box, - keyboard, timeout, - num_input_class -} KdInputClass; - -typedef enum _inputAction { - noop, - hold, - setto, - deliver, - release, - clearto, - gen_down_2, - gen_up_2 -} KdInputAction; - -#define MAX_ACTIONS 2 - -typedef struct _inputTransition { - KdInputAction actions[MAX_ACTIONS]; - KdMouseState nextState; -} KdInputTransition; - -KdInputTransition kdInputMachine[num_input_states][num_input_class] = { - /* start */ - { - { { hold, setto }, button_1_pend }, /* v1 */ - { { deliver, noop }, start }, /* ^1 */ - { { deliver, noop }, button_2_down }, /* v2 */ - { { deliver, noop }, start }, /* ^2 */ - { { hold, setto }, button_3_pend }, /* v3 */ - { { deliver, noop }, start }, /* ^3 */ - { { deliver, noop }, start }, /* vo */ - { { deliver, noop }, start }, /* ^o */ - { { deliver, noop }, start }, /* <> */ - { { deliver, noop }, start }, /* <-> */ - { { noop, noop }, start }, /* k */ - { { noop, noop }, start }, /* ... */ - }, - /* button_1_pend */ - { - { { noop, noop }, button_1_pend }, /* v1 */ - { { release, deliver }, start }, /* ^1 */ - { { release, deliver }, button_1_down }, /* v2 */ - { { release, deliver }, button_1_down }, /* ^2 */ - { { clearto, gen_down_2 }, synth_2_down_13 }, /* v3 */ - { { release, deliver }, button_1_down }, /* ^3 */ - { { release, deliver }, button_1_down }, /* vo */ - { { release, deliver }, button_1_down }, /* ^o */ - { { deliver, noop }, button_1_pend }, /* <> */ - { { release, deliver }, button_1_down }, /* <-> */ - { { noop, noop }, button_1_down }, /* k */ - { { release, noop }, button_1_down }, /* ... */ - }, - /* button_1_down */ - { - { { noop, noop }, button_1_down }, /* v1 */ - { { deliver, noop }, start }, /* ^1 */ - { { deliver, noop }, button_1_down }, /* v2 */ - { { deliver, noop }, button_1_down }, /* ^2 */ - { { deliver, noop }, button_1_down }, /* v3 */ - { { deliver, noop }, button_1_down }, /* ^3 */ - { { deliver, noop }, button_1_down }, /* vo */ - { { deliver, noop }, button_1_down }, /* ^o */ - { { deliver, noop }, button_1_down }, /* <> */ - { { deliver, noop }, button_1_down }, /* <-> */ - { { noop, noop }, button_1_down }, /* k */ - { { noop, noop }, button_1_down }, /* ... */ - }, - /* button_2_down */ - { - { { deliver, noop }, button_2_down }, /* v1 */ - { { deliver, noop }, button_2_down }, /* ^1 */ - { { noop, noop }, button_2_down }, /* v2 */ - { { deliver, noop }, start }, /* ^2 */ - { { deliver, noop }, button_2_down }, /* v3 */ - { { deliver, noop }, button_2_down }, /* ^3 */ - { { deliver, noop }, button_2_down }, /* vo */ - { { deliver, noop }, button_2_down }, /* ^o */ - { { deliver, noop }, button_2_down }, /* <> */ - { { deliver, noop }, button_2_down }, /* <-> */ - { { noop, noop }, button_2_down }, /* k */ - { { noop, noop }, button_2_down }, /* ... */ - }, - /* button_3_pend */ - { - { { clearto, gen_down_2 }, synth_2_down_13 }, /* v1 */ - { { release, deliver }, button_3_down }, /* ^1 */ - { { release, deliver }, button_3_down }, /* v2 */ - { { release, deliver }, button_3_down }, /* ^2 */ - { { release, deliver }, button_3_down }, /* v3 */ - { { release, deliver }, start }, /* ^3 */ - { { release, deliver }, button_3_down }, /* vo */ - { { release, deliver }, button_3_down }, /* ^o */ - { { deliver, noop }, button_3_pend }, /* <> */ - { { release, deliver }, button_3_down }, /* <-> */ - { { release, noop }, button_3_down }, /* k */ - { { release, noop }, button_3_down }, /* ... */ - }, - /* button_3_down */ - { - { { deliver, noop }, button_3_down }, /* v1 */ - { { deliver, noop }, button_3_down }, /* ^1 */ - { { deliver, noop }, button_3_down }, /* v2 */ - { { deliver, noop }, button_3_down }, /* ^2 */ - { { noop, noop }, button_3_down }, /* v3 */ - { { deliver, noop }, start }, /* ^3 */ - { { deliver, noop }, button_3_down }, /* vo */ - { { deliver, noop }, button_3_down }, /* ^o */ - { { deliver, noop }, button_3_down }, /* <> */ - { { deliver, noop }, button_3_down }, /* <-> */ - { { noop, noop }, button_3_down }, /* k */ - { { noop, noop }, button_3_down }, /* ... */ - }, - /* synthetic_2_down_13 */ - { - { { noop, noop }, synth_2_down_13 }, /* v1 */ - { { gen_up_2, noop }, synth_2_down_3 }, /* ^1 */ - { { noop, noop }, synth_2_down_13 }, /* v2 */ - { { noop, noop }, synth_2_down_13 }, /* ^2 */ - { { noop, noop }, synth_2_down_13 }, /* v3 */ - { { gen_up_2, noop }, synth_2_down_1 }, /* ^3 */ - { { deliver, noop }, synth_2_down_13 }, /* vo */ - { { deliver, noop }, synth_2_down_13 }, /* ^o */ - { { deliver, noop }, synth_2_down_13 }, /* <> */ - { { deliver, noop }, synth_2_down_13 }, /* <-> */ - { { noop, noop }, synth_2_down_13 }, /* k */ - { { noop, noop }, synth_2_down_13 }, /* ... */ - }, - /* synthetic_2_down_3 */ - { - { { deliver, noop }, synth_2_down_3 }, /* v1 */ - { { deliver, noop }, synth_2_down_3 }, /* ^1 */ - { { deliver, noop }, synth_2_down_3 }, /* v2 */ - { { deliver, noop }, synth_2_down_3 }, /* ^2 */ - { { noop, noop }, synth_2_down_3 }, /* v3 */ - { { noop, noop }, start }, /* ^3 */ - { { deliver, noop }, synth_2_down_3 }, /* vo */ - { { deliver, noop }, synth_2_down_3 }, /* ^o */ - { { deliver, noop }, synth_2_down_3 }, /* <> */ - { { deliver, noop }, synth_2_down_3 }, /* <-> */ - { { noop, noop }, synth_2_down_3 }, /* k */ - { { noop, noop }, synth_2_down_3 }, /* ... */ - }, - /* synthetic_2_down_1 */ - { - { { noop, noop }, synth_2_down_1 }, /* v1 */ - { { noop, noop }, start }, /* ^1 */ - { { deliver, noop }, synth_2_down_1 }, /* v2 */ - { { deliver, noop }, synth_2_down_1 }, /* ^2 */ - { { deliver, noop }, synth_2_down_1 }, /* v3 */ - { { deliver, noop }, synth_2_down_1 }, /* ^3 */ - { { deliver, noop }, synth_2_down_1 }, /* vo */ - { { deliver, noop }, synth_2_down_1 }, /* ^o */ - { { deliver, noop }, synth_2_down_1 }, /* <> */ - { { deliver, noop }, synth_2_down_1 }, /* <-> */ - { { noop, noop }, synth_2_down_1 }, /* k */ - { { noop, noop }, synth_2_down_1 }, /* ... */ - }, -}; - -#define EMULATION_WINDOW 10 -#define EMULATION_TIMEOUT 100 - -#define EventX(e) ((e)->u.keyButtonPointer.rootX) -#define EventY(e) ((e)->u.keyButtonPointer.rootY) - -static int -KdInsideEmulationWindow (KdMouseInfo *mi, xEvent *ev) -{ - if (ev->u.keyButtonPointer.pad1) - { - mi->emulationDx += EventX(ev); - mi->emulationDy += EventY(ev); - } - else - { - mi->emulationDx = EventX(&mi->heldEvent) - EventX(ev); - mi->emulationDy = EventY(&mi->heldEvent) - EventY(ev); - } - return (abs (mi->emulationDx) < EMULATION_WINDOW && - abs (mi->emulationDy) < EMULATION_WINDOW); -} - -static KdInputClass -KdClassifyInput (KdMouseInfo *mi, xEvent *ev) -{ - switch (ev->u.u.type) { - case ButtonPress: - switch (ev->u.u.detail) { - case 1: return down_1; - case 2: return down_2; - case 3: return down_3; - default: return down_o; - } - break; - case ButtonRelease: - switch (ev->u.u.detail) { - case 1: return up_1; - case 2: return up_2; - case 3: return up_3; - default: return up_o; - } - break; - case MotionNotify: - if (mi->eventHeld && !KdInsideEmulationWindow(mi, ev)) - return outside_box; - else - return motion; - default: - return keyboard; - } - return keyboard; -} - -#ifndef NDEBUG -char *kdStateNames[] = { - "start", - "button_1_pend", - "button_1_down", - "button_2_down", - "button_3_pend", - "button_3_down", - "synth_2_down_13", - "synth_2_down_3", - "synthetic_2_down_1", - "num_input_states" -}; - -char *kdClassNames[] = { - "down_1", "up_1", - "down_2", "up_2", - "down_3", "up_3", - "motion", "ouside_box", - "keyboard", "timeout", - "num_input_class" -}; - -char *kdActionNames[] = { - "noop", - "hold", - "setto", - "deliver", - "release", - "clearto", - "gen_down_2", - "gen_up_2", -}; -#endif - -static void -KdQueueEvent (xEvent *ev) -{ - KdAssertSigioBlocked ("KdQueueEvent"); - if (ev->u.u.type == MotionNotify) - { - if (ev->u.keyButtonPointer.pad1) - { - ev->u.keyButtonPointer.pad1 = 0; - miPointerDeltaCursor (ev->u.keyButtonPointer.rootX, - ev->u.keyButtonPointer.rootY, - ev->u.keyButtonPointer.time); - } - else - { - miPointerAbsoluteCursor(ev->u.keyButtonPointer.rootX, - ev->u.keyButtonPointer.rootY, - ev->u.keyButtonPointer.time); - } - } - else - { - mieqEnqueue (ev); - } -} - -static void -KdRunMouseMachine (KdMouseInfo *mi, KdInputClass c, xEvent *ev) -{ - KdInputTransition *t; - int a; - - t = &kdInputMachine[mi->mouseState][c]; - for (a = 0; a < MAX_ACTIONS; a++) - { - switch (t->actions[a]) { - case noop: - break; - case hold: - mi->eventHeld = TRUE; - mi->emulationDx = 0; - mi->emulationDy = 0; - mi->heldEvent = *ev; - break; - case setto: - mi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT; - mi->timeoutPending = TRUE; - break; - case deliver: - KdQueueEvent (ev); - break; - case release: - mi->eventHeld = FALSE; - mi->timeoutPending = FALSE; - KdQueueEvent (&mi->heldEvent); - break; - case clearto: - mi->timeoutPending = FALSE; - break; - case gen_down_2: - ev->u.u.detail = 2; - mi->eventHeld = FALSE; - KdQueueEvent (ev); - break; - case gen_up_2: - ev->u.u.detail = 2; - KdQueueEvent (ev); - break; - } - } - mi->mouseState = t->nextState; -} - -void -KdResetInputMachine (void) -{ - KdMouseInfo *mi; - - for (mi = kdMouseInfo; mi; mi = mi->next) - { - mi->mouseState = start; - mi->eventHeld = FALSE; - } -} - -static void -KdHandleMouseEvent (KdMouseInfo *mi, xEvent *ev) -{ - if (mi->emulateMiddleButton) - KdRunMouseMachine (mi, KdClassifyInput (mi, ev), ev); - else - KdQueueEvent (ev); -} - -static void -KdReceiveTimeout (KdMouseInfo *mi) -{ - KdRunMouseMachine (mi, timeout, 0); -} - -#define KILL_SEQUENCE ((1L << KK_CONTROL)|(1L << KK_ALT)|(1L << KK_F8)|(1L << KK_F10)) -#define SPECIAL_SEQUENCE ((1L << KK_CONTROL) | (1L << KK_ALT)) -#define SETKILLKEY(b) (KdSpecialKeys |= (1L << (b))) -#define CLEARKILLKEY(b) (KdSpecialKeys &= ~(1L << (b))) -#define KEYMAP (pKdKeyboard->key->curKeySyms) -#define KEYCOL1(k) (KEYMAP.map[((k)-kdMinKeyCode)*KEYMAP.mapWidth]) - -CARD32 KdSpecialKeys = 0; - -extern char dispatchException; - -/* - * kdCheckTermination - * - * This function checks for the key sequence that terminates the server. When - * detected, it sets the dispatchException flag and returns. The key sequence - * is: - * Control-Alt - * It's assumed that the server will be waken up by the caller when this - * function returns. - */ - -extern int nClients; - -static void -KdCheckSpecialKeys(xEvent *xE) -{ - KeySym sym = KEYCOL1(xE->u.u.detail); - - if (!pKdKeyboard) return; - - /* - * Ignore key releases - */ - - if (xE->u.u.type == KeyRelease) return; - -#ifdef XIPAQ - /* - * Check for buttons 1, 2 and 3 on the iPAQ - */ - if (sym == XK_Pointer_Button1 && kdMouseInfo) { - KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_1, 0, 0); - return; - } - if (sym == XK_Pointer_Button2 && kdMouseInfo) { - KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_2, 0, 0); - return; - } - if (sym == XK_Pointer_Button3 && kdMouseInfo) { - KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_3, 0, 0); - return; - } -#endif - - /* - * Check for control/alt pressed - */ - if ((pKdKeyboard->key->state & (ControlMask|Mod1Mask)) != - (ControlMask|Mod1Mask)) - return; - - - /* - * Let OS function see keysym first - */ - - if (kdOsFuncs->SpecialKey) - if ((*kdOsFuncs->SpecialKey) (sym)) - return; - - /* - * Now check for backspace or delete; these signal the - * X server to terminate - */ - switch (sym) { - case XK_BackSpace: - case XK_Delete: - case XK_KP_Delete: - /* - * Set the dispatch exception flag so the server will terminate the - * next time through the dispatch loop. - */ - dispatchException |= DE_TERMINATE; - break; - } -} - -/* - * kdEnqueueKeyboardEvent - * - * This function converts hardware keyboard event information into an X event - * and enqueues it using MI. It wakes up the server before returning so that - * the event will be processed normally. - * - */ - -static void -KdHandleKeyboardEvent (xEvent *ev) -{ - int key = ev->u.u.detail; - int byte; - CARD8 bit; - KdMouseInfo *mi; - - byte = key >> 3; - bit = 1 << (key & 7); - switch (ev->u.u.type) { - case KeyPress: - kdKeyState[byte] |= bit; - break; - case KeyRelease: - kdKeyState[byte] &= ~bit; - break; - } - for (mi = kdMouseInfo; mi; mi = mi->next) - KdRunMouseMachine (mi, keyboard, 0); - KdQueueEvent (ev); -} - -void -KdReleaseAllKeys (void) -{ - xEvent xE; - int key; - - KdBlockSigio (); - for (key = 0; key < KD_KEY_COUNT; key++) - if (IsKeyDown(key)) - { - xE.u.keyButtonPointer.time = GetTimeInMillis(); - xE.u.u.type = KeyRelease; - xE.u.u.detail = key; - KdHandleKeyboardEvent (&xE); - } - KdUnblockSigio (); -} - -static void -KdCheckLock (void) -{ - KeyClassPtr keyc = pKdKeyboard->key; - Bool isSet, shouldBeSet; - - if (kdKeyboardFuncs->LockLed) - { - isSet = (kdLeds & (1 << (kdKeyboardFuncs->LockLed-1))) != 0; - shouldBeSet = (keyc->state & LockMask) != 0; - if (isSet != shouldBeSet) - { - KdSetLed (kdKeyboardFuncs->LockLed, shouldBeSet); - } - } -} - -void -KdEnqueueKeyboardEvent(unsigned char scan_code, - unsigned char is_up) -{ - unsigned char key_code; - xEvent xE; - KeyClassPtr keyc; - - if (!pKdKeyboard) - return; - keyc = pKdKeyboard->key; - - xE.u.keyButtonPointer.time = GetTimeInMillis(); - - if (kdMinScanCode <= scan_code && scan_code <= kdMaxScanCode) - { - key_code = scan_code + KD_MIN_KEYCODE - kdMinScanCode; - - /* - * Set up this event -- the type may be modified below - */ - if (is_up) - xE.u.u.type = KeyRelease; - else - xE.u.u.type = KeyPress; - xE.u.u.detail = key_code; - - switch (KEYCOL1(key_code)) - { - case XK_Num_Lock: - case XK_Scroll_Lock: - case XK_Shift_Lock: - case XK_Caps_Lock: - if (xE.u.u.type == KeyRelease) - return; - if (IsKeyDown (key_code)) - xE.u.u.type = KeyRelease; - else - xE.u.u.type = KeyPress; - } - - /* - * Check pressed keys which are already down - */ - if (IsKeyDown (key_code) && xE.u.u.type == KeyPress) - { - KeybdCtrl *ctrl = &pKdKeyboard->kbdfeed->ctrl; - - /* - * Check auto repeat - */ - if (!ctrl->autoRepeat || keyc->modifierMap[key_code] || - !(ctrl->autoRepeats[key_code >> 3] & (1 << (key_code & 7)))) - { - return; - } - /* - * X delivers press/release even for autorepeat - */ - xE.u.u.type = KeyRelease; - KdHandleKeyboardEvent (&xE); - xE.u.u.type = KeyPress; - } - /* - * Check released keys which are already up - */ - else if (!IsKeyDown (key_code) && xE.u.u.type == KeyRelease) - { - return; - } - KdCheckSpecialKeys (&xE); - KdHandleKeyboardEvent (&xE); - } -} - -#define SetButton(mi, b, v, s) \ -{\ - xE.u.u.detail = mi->map[b]; \ - xE.u.u.type = v; \ - KdHandleMouseEvent (mi, &xE); \ -} - -#define Press(mi, b) SetButton(mi, b, ButtonPress, "Down") -#define Release(mi, b) SetButton(mi, b, ButtonRelease, "Up") - -/* - * kdEnqueueMouseEvent - * - * This function converts hardware mouse event information into X event - * information. A mouse movement event is passed off to MI to generate - * a MotionNotify event, if appropriate. Button events are created and - * passed off to MI for enqueueing. - */ - -static void -KdMouseAccelerate (DeviceIntPtr device, int *dx, int *dy) -{ - PtrCtrl *pCtrl = &device->ptrfeed->ctrl; - double speed = sqrt (*dx * *dx + *dy * *dy); - double accel; - double m; - - /* - * Ok, so we want it moving num/den times faster at threshold*2 - * - * accel = m *threshold + b - * 1 = m * 0 + b -> b = 1 - * - * num/den = m * (threshold * 2) + 1 - * - * num / den - 1 = m * threshold * 2 - * (num / den - 1) / threshold * 2 = m - */ - m = (((double) pCtrl->num / (double) pCtrl->den - 1.0) / - ((double) pCtrl->threshold * 2.0)); - accel = m * speed + 1; - *dx = accel * *dx; - *dy = accel * *dy; -} - -void -KdEnqueueMouseEvent(KdMouseInfo *mi, unsigned long flags, int rx, int ry) -{ - CARD32 ms; - xEvent xE; - unsigned char buttons; - int x, y; - int (*matrix)[3] = kdMouseMatrix.matrix; - unsigned long button; - int n; - - if (!pKdPointer) - return; - - ms = GetTimeInMillis(); - - if (flags & KD_MOUSE_DELTA) - { - if (mi->transformCoordinates) - { - x = matrix[0][0] * rx + matrix[0][1] * ry; - y = matrix[1][0] * rx + matrix[1][1] * ry; - } - else - { - x = rx; - y = ry; - } - KdMouseAccelerate (pKdPointer, &x, &y); - xE.u.keyButtonPointer.pad1 = 1; - } - else - { - if (mi->transformCoordinates) - { - x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2]; - y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2]; - } - else - { - x = rx; - y = ry; - } - xE.u.keyButtonPointer.pad1 = 0; - } - xE.u.keyButtonPointer.time = ms; - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - - xE.u.u.type = MotionNotify; - xE.u.u.detail = 0; - KdHandleMouseEvent (mi, &xE); - - buttons = flags; - - for (button = KD_BUTTON_1, n = 0; button <= KD_BUTTON_5; button <<= 1, n++) - { - if ((mi->buttonState & button) ^ (buttons & button)) - { - if (buttons & button) - { - Press(mi, n); - } - else - { - Release(mi, n); - } - } - } - mi->buttonState = buttons; -} - -void -KdEnqueueMotionEvent (KdMouseInfo *mi, int x, int y) -{ - xEvent xE; - CARD32 ms; - - ms = GetTimeInMillis(); - - xE.u.u.type = MotionNotify; - xE.u.keyButtonPointer.time = ms; - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - - KdHandleMouseEvent (mi, &xE); -} - -void -KdBlockHandler (int screen, - pointer blockData, - pointer timeout, - pointer readmask) -{ - KdMouseInfo *mi; - - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->timeoutPending) - { - int ms; - - ms = mi->emulationTimeout - GetTimeInMillis (); - if (ms < 0) - ms = 0; - AdjustWaitForDelay (timeout, ms); - } - } -} - -void -KdWakeupHandler (int screen, - pointer data, - unsigned long lresult, - pointer readmask) -{ - int result = (int) lresult; - fd_set *pReadmask = (fd_set *) readmask; - int i; - KdMouseInfo *mi; - - if (kdInputEnabled && result > 0) - { - for (i = 0; i < kdNumInputFds; i++) - if (FD_ISSET (kdInputFds[i].fd, pReadmask)) - { - KdBlockSigio (); - (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure); - KdUnblockSigio (); - } - } - for (mi = kdMouseInfo; mi; mi = mi->next) - { - if (mi->timeoutPending) - { - if ((long) (GetTimeInMillis () - mi->emulationTimeout) >= 0) - { - mi->timeoutPending = FALSE; - KdBlockSigio (); - KdReceiveTimeout (mi); - KdUnblockSigio (); - } - } - } - if (kdSwitchPending) - KdProcessSwitch (); -} - -#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin)) - -static Bool -KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) -{ - ScreenPtr pScreen = *ppScreen; - ScreenPtr pNewScreen; - int n; - int dx, dy; - int best_x, best_y; - int n_best_x, n_best_y; - CARD32 ms; - - if (kdDisableZaphod || screenInfo.numScreens <= 1) - return FALSE; - - if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height) - return FALSE; - - ms = GetTimeInMillis (); - if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000) - return FALSE; - kdOffScreen = TRUE; - kdOffScreenTime = ms; - n_best_x = -1; - best_x = 32767; - n_best_y = -1; - best_y = 32767; - for (n = 0; n < screenInfo.numScreens; n++) - { - pNewScreen = screenInfo.screens[n]; - if (pNewScreen == pScreen) - continue; - dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x; - dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y; - if (*x < 0) - { - if (dx <= 0 && -dx < best_x) - { - best_x = -dx; - n_best_x = n; - } - } - else if (*x >= pScreen->width) - { - if (dx >= 0 && dx < best_x) - { - best_x = dx; - n_best_x = n; - } - } - if (*y < 0) - { - if (dy <= 0 && -dy < best_y) - { - best_y = -dy; - n_best_y = n; - } - } - else if (*y >= pScreen->height) - { - if (dy >= 0 && dy < best_y) - { - best_y = dy; - n_best_y = n; - } - } - } - if (best_y < best_x) - n_best_x = n_best_y; - if (n_best_x == -1) - return FALSE; - pNewScreen = screenInfo.screens[n_best_x]; - - if (*x < 0) - *x += pNewScreen->width; - if (*y < 0) - *y += pNewScreen->height; - - if (*x >= pScreen->width) - *x -= pScreen->width; - if (*y >= pScreen->height) - *y -= pScreen->height; - - *ppScreen = pNewScreen; - return TRUE; -} - -static void -KdCrossScreen(ScreenPtr pScreen, Bool entering) -{ -#ifndef XIPAQ - if (entering) - KdEnableScreen (pScreen); - else - KdDisableScreen (pScreen); -#endif -} - -int KdCurScreen; /* current event screen */ - -static void -KdWarpCursor (ScreenPtr pScreen, int x, int y) -{ - KdBlockSigio (); - KdCurScreen = pScreen->myNum; - miPointerWarpCursor (pScreen, x, y); - KdUnblockSigio (); -} - -miPointerScreenFuncRec kdPointerScreenFuncs = -{ - KdCursorOffScreen, - KdCrossScreen, - KdWarpCursor -}; - -void -ProcessInputEvents () -{ - mieqProcessInputEvents(); - miPointerUpdate(); - if (kdSwitchPending) - KdProcessSwitch (); - KdCheckLock (); -} diff --git a/hw/kdrive/src/kkeymap.c b/hw/kdrive/src/kkeymap.c deleted file mode 100644 index bfab84038..000000000 --- a/hw/kdrive/src/kkeymap.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Id: kkeymap.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kkeymap.c,v 1.1 1999/11/19 13:53:49 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 -}; diff --git a/hw/kdrive/src/kkeymap.h b/hw/kdrive/src/kkeymap.h deleted file mode 100644 index ccc5e86f8..000000000 --- a/hw/kdrive/src/kkeymap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Id: kkeymap.h,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kkeymap.h,v 1.1 1999/11/19 13:53:50 hohndel Exp $ */ -/* - * All global variables and functions pertaining to keyboard key mapping - * live in this header file. - */ - -#ifndef _KKEYMAP_H -#define _KKEYMAP_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; - -typedef struct { - KeySym modsym; - int modbit; -} KdKeySymModsRec; - -#endif /* _KKEYMAP_H */ diff --git a/hw/kdrive/src/kloadmap.c b/hw/kdrive/src/kloadmap.c deleted file mode 100644 index 17ec880dd..000000000 --- a/hw/kdrive/src/kloadmap.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Id: kloadmap.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kloadmap.c,v 1.1 1999/11/19 13:53:50 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; -} diff --git a/hw/kdrive/src/kmap.c b/hw/kdrive/src/kmap.c deleted file mode 100644 index bd506996b..000000000 --- a/hw/kdrive/src/kmap.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Id: kmap.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/kmap.c,v 1.10 2001/07/24 21:26:17 keithp Exp $ */ - -#include <config.h> -#include "kdrive.h" - -#include <errno.h> -#include <unistd.h> -#include <sys/mman.h> -#ifdef HAVE_ASM_MTRR_H -#include <asm/mtrr.h> -#endif - -#include <sys/ioctl.h> - -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; - -#ifdef __arm__ - fd = open ("/dev/mem", O_RDWR|O_SYNC); -#else - fd = open ("/dev/mem", O_RDWR); -#endif - 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 -#ifdef VXWORKS - return (void *) addr; -#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 -#ifdef VXWORKS - ; -#endif -} - -#ifdef HAVE_ASM_MTRR_H -static int mtrr; -#endif - -void -KdSetMappedMode (CARD32 addr, CARD32 size, int mode) -{ -#ifdef HAVE_ASM_MTRR_H - struct mtrr_sentry sentry; - unsigned long base, bound; - unsigned int type = MTRR_TYPE_WRBACK; - - if (addr < 0x100000) - return; - if (!mtrr) - mtrr = open ("/proc/mtrr", 2); - if (mtrr > 0) - { - unsigned long nsize; - base = addr & ~((1<<22)-1); - bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1); - nsize = 1; - while (nsize < (bound - base)) - nsize <<= 1; - switch (mode) { - case KD_MAPPED_MODE_REGISTERS: - type = MTRR_TYPE_UNCACHABLE; - break; - case KD_MAPPED_MODE_FRAMEBUFFER: - type = MTRR_TYPE_WRCOMB; - break; - } - sentry.base = base; - sentry.size = nsize; - sentry.type = type; - - if (ioctl (mtrr, MTRRIOC_ADD_ENTRY, &sentry) < 0) - ErrorF ("MTRRIOC_ADD_ENTRY failed 0x%x 0x%x %d (errno %d)\n", - base, bound - base, type, errno); - } -#endif -} - -void -KdResetMappedMode (CARD32 addr, CARD32 size, int mode) -{ -#ifdef HAVE_ASM_MTRR_H - struct mtrr_sentry sentry; - unsigned long base, bound; - unsigned int type = MTRR_TYPE_WRBACK; - - if (addr < 0x100000) - return; - if (!mtrr) - mtrr = open ("/proc/mtrr", 2); - if (mtrr > 0) - { - unsigned long nsize; - base = addr & ~((1<<22)-1); - bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1); - nsize = 1; - while (nsize < (bound - base)) - nsize <<= 1; - switch (mode) { - case KD_MAPPED_MODE_REGISTERS: - type = MTRR_TYPE_UNCACHABLE; - break; - case KD_MAPPED_MODE_FRAMEBUFFER: - type = MTRR_TYPE_WRCOMB; - break; - } - sentry.base = base; - sentry.size = nsize; - sentry.type = type; - - if (ioctl (mtrr, MTRRIOC_DEL_ENTRY, &sentry) < 0) - ErrorF ("MTRRIOC_DEL_ENTRY failed 0x%x 0x%x %d (errno %d)\n", - base, bound - base, type, errno); - } -#endif -} diff --git a/hw/kdrive/src/kmode.c b/hw/kdrive/src/kmode.c deleted file mode 100644 index e1e82dce7..000000000 --- a/hw/kdrive/src/kmode.c +++ /dev/null @@ -1,385 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/kmode.c,v 1.7 2002/10/14 18:01:40 keithp Exp $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -const KdMonitorTiming kdMonitorTimings[] = { - /* H V Hz KHz */ - /* FP BP BLANK POLARITY */ - /* Other VESA modes */ - { 640, 350, 85, 31500, /* VESA */ - 32, 96, 192, KdSyncPositive, /* 26.413 */ - 32, 60, 95, KdSyncNegative, /* 59.354 */ - }, - { 640, 400, 60, 31500, /* VESA */ - 32, 96, 192, KdSyncNegative, /* 26.413 */ - 1, 41, 45, KdSyncPositive, /* 59.354 */ - }, - { 720, 400, 85, 35500, /* VESA */ - 36, 108, 216, KdSyncNegative, /* 37.927 */ - 1, 42, 46, KdSyncPositive, /* 85.039 */ - }, - - - /* Modeline "720x576" 29.000 720 736 800 880 576 577 580 625 */ - { - 720, 576, 52, 32954, /* PAL Video */ - 16, 80, 160, KdSyncPositive, /* 32.954 */ - 1, 45, 49, KdSyncPositive, /* 52.727 */ - }, - - /* 640x480 modes */ - { 640, 480, 85, 36000, /* VESA */ - 56, 80, 192, KdSyncNegative, /* 43.269 */ - 1, 25, 29, KdSyncNegative, /* 85.008 */ - }, - { 640, 480, 75, 31500, /* VESA */ - 16, 120, 200, KdSyncNegative, /* 37.500 */ - 1, 16, 20, KdSyncNegative, /* 75.000 */ - }, - { 640, 480, 72, 31500, /* VESA */ - 16, 120, 176, KdSyncNegative, /* 37.861 */ - 1, 20, 24, KdSyncNegative, /* 72.809 */ - }, - { 640, 480, 60, 25175, /* VESA */ - 16, 48, 160, KdSyncNegative, /* 31.469 */ - 10, 33, 45, KdSyncNegative, /* 59.940 */ - }, - - /* 800x600 modes */ - { 800, 600, 85, 56250, /* VESA */ - 32, 152, 248, KdSyncPositive, /* 53.674 */ - 1, 27, 31, KdSyncPositive, /* 85.061 */ - }, - { 800, 600, 75, 49500, /* VESA */ - 16, 160, 256, KdSyncPositive, /* 46.875 */ - 1, 21, 25, KdSyncPositive, /* 75.000 */ - }, - /* DEFAULT */ -#define MONITOR_TIMING_DEFAULT 9 - { 800, 600, 72, 50000, /* VESA */ - 56, 64, 240, KdSyncPositive, /* 48.077 */ - 37, 23, 66, KdSyncPositive, /* 72.188 */ - }, - { 800, 600, 60, 40000, /* VESA */ - 40, 88, 256, KdSyncPositive, /* 37.879 */ - 1, 23, 28, KdSyncPositive, /* 60.317 */ - }, - { 800, 600, 56, 36000, /* VESA */ - 24, 128, 224, KdSyncPositive, /* 35.156 */ - 1, 22, 25, KdSyncPositive, /* 56.250 */ - }, - - /* 1024x768 modes */ - { 1024, 768, 85, 94500, /* VESA */ - 48, 208, 352, KdSyncPositive, /* 68.677 */ - 1, 36, 40, KdSyncPositive, /* 84.997 */ - }, - { 1024, 768, 75, 78750, /* VESA */ - 16, 176, 288, KdSyncPositive, /* 60.023 */ - 1, 28, 32, KdSyncPositive, /* 75.029 */ - }, - { 1024, 768, 70, 75000, /* VESA */ - 24, 144, 304, KdSyncNegative, /* 56.476 */ - 3, 29, 38, KdSyncNegative, /* 70.069 */ - }, - { 1024, 768, 60, 65000, /* VESA */ - 24, 160, 320, KdSyncNegative, /* 48.363 */ - 3, 29, 38, KdSyncNegative, /* 60.004 */ - }, - - /* 1152x864 mode */ - { 1152, 864, 75, 108000, /* VESA */ - 64, 256, 448, KdSyncPositive, /* 67.500 */ - 1, 32, 36, KdSyncPositive, /* 75.000 */ - }, - - /* 1152x900 modes */ - { 1152, 900, 85, 122500, /* ADDED */ - 48, 208, 384, KdSyncPositive, /* 79.753 */ - 1, 32, 38, KdSyncPositive, /* 85.024 */ - }, - { 1152, 900, 75, 108250, /* ADDED */ - 32, 208, 384, KdSyncPositive, /* 70.475 */ - 1, 32, 38, KdSyncPositive, /* 75.133 */ - }, - { 1152, 900, 70, 100250, /* ADDED */ - 32, 208, 384, KdSyncPositive, /* 65.267 */ - 2, 32, 38, KdSyncPositive, /* 69.581 */ - }, - { 1152, 900, 66, 95000, /* ADDED */ - 32, 208, 384, KdSyncPositive, /* 61.849 */ - 1, 32, 38, KdSyncPositive, /* 65.937 */ - }, - - /* 1280x960 modes */ - { 1280, 960, 85, 148500, /* VESA */ - 64, 224, 448, KdSyncPositive, /* 85.938 */ - 1, 47, 51, KdSyncPositive, /* 85.002 */ - }, - { 1280, 960, 60, 108000, /* VESA */ - 96, 312, 520, KdSyncPositive, /* 60.000 */ - 1, 36, 40, KdSyncPositive, /* 60.000 */ - }, - - /* 1280x1024 modes */ - { 1280, 1024, 85, 157500, /* VESA */ - 64, 224, 448, KdSyncPositive, /* 91.146 */ - 1, 44, 48, KdSyncPositive, /* 85.024 */ - }, - { 1280, 1024, 75, 135000, /* VESA */ - 16, 248, 408, KdSyncPositive, /* 79.976 */ - 1, 38, 42, KdSyncPositive, /* 75.025 */ - }, - { 1280, 1024, 60, 108000, /* VESA */ - 48, 248, 408, KdSyncPositive, /* 63.981 */ - 1, 38, 42, KdSyncPositive, /* 60.020 */ - }, - - /* 1600x1200 modes */ - { 1600, 1200, 85, 229500, /* VESA */ - 64, 304, 560, KdSyncPositive, /* 106.250 */ - 1, 46, 50, KdSyncPositive, /* 85.000 */ - }, - { 1600, 1200, 75, 202500, /* VESA */ - 64, 304, 560, KdSyncPositive, /* 93.750 */ - 1, 46, 50, KdSyncPositive, /* 75.000 */ - }, - { 1600, 1200, 70, 189000, /* VESA */ - 64, 304, 560, KdSyncPositive, /* 87.500 */ - 1, 46, 50, KdSyncPositive, /* 70.000 */ - }, - { 1600, 1200, 65, 175500, /* VESA */ - 64, 304, 560, KdSyncPositive, /* 81.250 */ - 1, 46, 50, KdSyncPositive, /* 65.000 */ - }, - { 1600, 1200, 60, 162000, /* VESA */ - 64, 304, 560, KdSyncPositive, /* 75.000 */ - 1, 46, 50, KdSyncPositive, /* 60.000 */ - }, - - /* 1792x1344 modes */ - { 1792, 1344, 85, 301500, /* ADDED */ - 96, 352, 672, KdSyncNegative, /* 122.362 */ - 1, 92, 96, KdSyncPositive, /* 84.974 */ - }, - { 1792, 1344, 75, 261000, /* VESA */ - 96, 352, 664, KdSyncNegative, /* 106.270 */ - 1, 69, 73, KdSyncPositive, /* 74.997 */ - }, - { 1792, 1344, 60, 204750, /* VESA */ - 128, 328, 656, KdSyncNegative, /* 83.640 */ - 1, 46, 50, KdSyncPositive, /* 60.000 */ - }, - -#if 0 - { 1800, 1012, 75 }, - { 1906, 1072, 68 }, -#endif - - /* 1856x1392 modes */ - { 1856, 1392, 85, 330500, /* ADDED */ - 160, 352, 736, KdSyncNegative, /* 127.508 */ - 1, 104, 108, KdSyncPositive, /* 85.001 */ - }, - { 1856, 1392, 75, 288000, /* VESA */ - 128, 352, 704, KdSyncNegative, /* 112.500 */ - 1, 104, 108, KdSyncPositive, /* 75.000 */ - }, - { 1856, 1392, 60, 218250, /* VESA */ - 96, 352, 672, KdSyncNegative, /* 86.333 */ - 1, 43, 47, KdSyncPositive, /* 59.995 */ - }, - - /* 1920x1440 modes */ - { 1920, 1440, 85, 341750, /* ADDED */ - 160, 352, 760, KdSyncNegative, /* 127.512 */ - 1, 56, 60, KdSyncPositive, /* 85.012 */ - }, - { 1920, 1440, 75, 297000, /* VESA */ - 144, 352, 720, KdSyncNegative, /* 112.500 */ - 1, 56, 60, KdSyncPositive, /* 75.000 */ - }, - { 1920, 1440, 60, 234000, /* VESA */ - 128, 244, 680, KdSyncNegative, /* 90.000 */ - 1, 56, 60, KdSyncPositive, /* 60.000 */ - }, -}; - -#define NUM_MONITOR_TIMINGS (sizeof kdMonitorTimings/sizeof kdMonitorTimings[0]) - -const int kdNumMonitorTimings = NUM_MONITOR_TIMINGS; - -const KdMonitorTiming * -KdFindMode (KdScreenInfo *screen, - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)) -{ - int i; - const KdMonitorTiming *t; - - for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) - { - if ((*supported) (screen, t) && - t->horizontal == screen->width && - t->vertical == screen->height && - (!screen->rate || t->rate <= screen->rate)) - { - return t; - } - } - return &kdMonitorTimings[MONITOR_TIMING_DEFAULT]; -} - -static const KdMonitorTiming * -kdFindPrevSize (const KdMonitorTiming *old) -{ - const KdMonitorTiming *new, *prev; - - if (old == kdMonitorTimings) - return 0; - new = old; - /* - * Search for the previous size - */ - while (new != kdMonitorTimings) - { - new--; - if (new->horizontal != old->horizontal && - new->vertical != old->vertical) - { - break; - } - } - /* - * Match the refresh rate (<=) - */ - while (new != kdMonitorTimings) - { - prev = new - 1; - if (prev->horizontal == new->horizontal && - prev->vertical == new->vertical && - prev->rate > old->rate) - { - break; - } - new--; - } - return new; -} - -Bool -KdTuneMode (KdScreenInfo *screen, - Bool (*usable) (KdScreenInfo *), - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)) -{ - const KdMonitorTiming *t; - - while (!(*usable) (screen)) - { - /* - * Fix requested depth and geometry until it works - */ - if (screen->fb[1].depth) - screen->fb[1].depth = 0; - else if (screen->fb[0].depth > 16) - screen->fb[0].depth = 16; - else if (screen->fb[0].depth > 8) - screen->fb[0].depth = 8; - else - { - t = kdFindPrevSize (KdFindMode (screen, supported)); - if (!t) - return FALSE; - screen->width = t->horizontal; - screen->height = t->vertical; - screen->rate = t->rate; - } - } - return TRUE; -} - -#ifdef RANDR -Bool -KdRandRGetInfo (ScreenPtr pScreen, - int randr, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *)) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - int i; - const KdMonitorTiming *t; - - for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) - { - if ((*supported) (pScreen, t)) - { - RRScreenSizePtr pSize; - - pSize = RRRegisterSize (pScreen, - t->horizontal, - t->vertical, - screen->width_mm, - screen->height_mm); - if (!pSize) - return FALSE; - if (!RRRegisterRate (pScreen, pSize, t->rate)) - return FALSE; - if (t->horizontal == screen->width && - t->vertical == screen->height && - t->rate == screen->rate) - RRSetCurrentConfig (pScreen, randr, t->rate, pSize); - } - } - - return TRUE; -} - -const KdMonitorTiming * -KdRandRGetTiming (ScreenPtr pScreen, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *), - int rate, - RRScreenSizePtr pSize) -{ - int i; - const KdMonitorTiming *t; - - for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) - { - if (t->horizontal == pSize->width && - t->vertical == pSize->height && - t->rate == rate && - (*supported) (pScreen, t)) - return t; - } - return 0; -} -#endif diff --git a/hw/kdrive/src/knoop.c b/hw/kdrive/src/knoop.c deleted file mode 100644 index 26d7642f9..000000000 --- a/hw/kdrive/src/knoop.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Id: knoop.c,v 1.2 1999/11/02 06:16:28 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/knoop.c,v 1.1 1999/11/19 13:53:50 hohndel Exp $ */ - -/* - * GC ops that don't do anything - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 -); - -static RegionPtr -KdNoopCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, - int srcx, int srcy, int width, int height, int dstx, int dsty) -{ - return NullRegion; -} - -static 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 -}; diff --git a/hw/kdrive/src/koffscreen.c b/hw/kdrive/src/koffscreen.c deleted file mode 100644 index 71dfa6bb0..000000000 --- a/hw/kdrive/src/koffscreen.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2003 Anders Carlsson - * - * 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 Anders Carlsson not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Anders Carlsson makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ANDERS CARLSSON 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -#define DEBUG_OFFSCREEN 0 -#if DEBUG_OFFSCREEN -#define DBG_OFFSCREEN(a) ErrorF a -#else -#define DBG_OFFSCREEN(a) -#endif - -typedef struct _RealOffscreenArea { - KdOffscreenArea area; - - KdOffscreenSaveProc save; - - Bool locked; - - struct _RealOffscreenArea *prev; - struct _RealOffscreenArea *next; -} RealOffscreenArea; - -#if DEBUG_OFFSCREEN -static void -KdOffscreenValidate (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - RealOffscreenArea *prev = 0, *area; - - assert (pScreenPriv->screen->off_screen_areas->area.offset == 0); - for (area = pScreenPriv->screen->off_screen_areas; area; area = area->next) - { - if (prev) - assert (prev->area.offset + prev->area.size == area->area.offset); - - prev = area; - } - assert (prev->area.offset + prev->area.size == pScreenPriv->screen->memory_size); -} -#else -#define KdOffscreenValidate(s) -#endif - -static void -KdOffscreenKickOut (KdOffscreenArea *area) -{ - RealOffscreenArea *real_area = (RealOffscreenArea *) area; - if (real_area->save) - (*real_area->save) (area); - KdOffscreenFree (area); -} - -KdOffscreenArea * -KdOffscreenAlloc (ScreenPtr pScreen, int size, int align, - Bool locked, - KdOffscreenSaveProc save, - pointer privData) -{ - RealOffscreenArea *area, **prev; - KdScreenPriv (pScreen); - int tmp, real_size = 0; - - KdOffscreenValidate (pScreen); - if (!align) - align = 1; - - if (!size) - { - DBG_OFFSCREEN (("Alloc 0x%x -> EMPTY\n", size)); - return NULL; - } - - /* throw out requests that cannot fit */ - if (size > (pScreenPriv->screen->memory_size - pScreenPriv->screen->off_screen_base)) - { - DBG_OFFSCREEN (("Alloc 0x%x -> TOBIG\n", size)); - return NULL; - } - - /* Go through the areas */ - for (area = pScreenPriv->screen->off_screen_areas; area; area = area->next) - { - /* skip allocated areas */ - if (area->area.screen) - continue; - - /* adjust size to match alignment requirement */ - real_size = size; - tmp = area->area.offset % align; - if (tmp) - real_size += (align - tmp); - - /* does it fit? */ - if (real_size <= area->area.size) - break; - } - - if (!area) - { - /* - * Kick out existing users to make space. - * - * First, locate a region which can hold the desired object. - */ - - /* prev points at the first object to boot */ - prev = (RealOffscreenArea **) &pScreenPriv->screen->off_screen_areas; - while ((area = *prev)) - { - int avail; - RealOffscreenArea *scan; - - /* adjust size to match alignment requirement */ - real_size = size; - tmp = area->area.offset % align; - if (tmp) - real_size += (align - tmp); - - avail = 0; - /* now see if we can make room here */ - for (scan = area; scan; scan = scan->next) - { - if (scan->locked) - break; - avail += scan->area.size; - if (avail >= real_size) - break; - } - /* space? */ - if (avail >= real_size) - break; - - /* nope, try the next area */ - prev = &scan->next; - } - if (!area) - { - DBG_OFFSCREEN (("Alloc 0x%x -> NOSPACE\n", size)); - /* Could not allocate memory */ - KdOffscreenValidate (pScreen); - return NULL; - } - - /* - * Kick out first area if in use - */ - if (area->area.screen) - KdOffscreenKickOut (&area->area); - /* - * Now get the system to merge the other needed areas together - */ - while (area->area.size < real_size) - { - assert (area->next && area->next->area.screen); - KdOffscreenKickOut (&area->next->area); - } - } - - /* save extra space in new area */ - if (real_size < area->area.size) - { - RealOffscreenArea *new_area = xalloc (sizeof (RealOffscreenArea)); - if (!new_area) - return NULL; - new_area->area.offset = area->area.offset + real_size; - new_area->area.size = area->area.size - real_size; - new_area->area.screen = 0; - new_area->locked = FALSE; - new_area->save = 0; - if ((new_area->next = area->next)) - new_area->next->prev = new_area; - new_area->prev = area; - area->next = new_area; - area->area.size = real_size; - } - /* - * Mark this area as in use - */ - area->area.screen = pScreen; - area->area.privData = privData; - area->locked = locked; - area->save = save; - - KdOffscreenValidate (pScreen); - - DBG_OFFSCREEN (("Alloc 0x%x -> 0x%x\n", size, area->area.offset)); - return &area->area; -} - -void -KdOffscreenSwapOut (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - - KdOffscreenValidate (pScreen); - /* loop until a single free area spans the space */ - for (;;) - { - RealOffscreenArea *area = pScreenPriv->screen->off_screen_areas; - - if (!area) - break; - if (!area->area.screen) - { - area = area->next; - if (!area) - break; - } - assert (area->area.screen); - KdOffscreenKickOut (&area->area); - KdOffscreenValidate (pScreen); - } - KdOffscreenValidate (pScreen); - KdOffscreenFini (pScreen); -} - -void -KdOffscreenSwapIn (ScreenPtr pScreen) -{ - KdOffscreenInit (pScreen); -} - -/* merge the next free area into this one */ -static void -KdOffscreenMerge (KdOffscreenArea *area) -{ - RealOffscreenArea *real_area = (RealOffscreenArea *) area; - RealOffscreenArea *next = real_area->next; - - /* account for space */ - real_area->area.size += next->area.size; - /* frob pointers */ - if ((real_area->next = next->next)) - real_area->next->prev = real_area; - xfree (next); -} - -void -KdOffscreenFree (KdOffscreenArea *area) -{ - RealOffscreenArea *real_area = (RealOffscreenArea *) area; - RealOffscreenArea *next = real_area->next; - RealOffscreenArea *prev = real_area->prev; - - DBG_OFFSCREEN (("Free 0x%x -> 0x%x\n", area->size, area->offset)); - KdOffscreenValidate (pScreen); - - area->screen = NULL; - - /* link with next area if free */ - if (next && !next->area.screen) - KdOffscreenMerge (&real_area->area); - - /* link with prev area if free */ - if (prev && !prev->area.screen) - KdOffscreenMerge (&prev->area); - - KdOffscreenValidate (pScreen); -} - -Bool -KdOffscreenInit (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - RealOffscreenArea *area; - - /* Allocate a big free area */ - area = xalloc (sizeof (RealOffscreenArea)); - - if (!area) - return FALSE; - - area->area.screen = NULL; - area->area.offset = pScreenPriv->screen->off_screen_base; - area->area.size = pScreenPriv->screen->memory_size - area->area.offset; - area->save = 0; - area->locked = FALSE; - area->next = NULL; - area->prev = NULL; - - /* Add it to the free areas */ - pScreenPriv->screen->off_screen_areas = area; - - KdOffscreenValidate (pScreen); - - return TRUE; -} - -void -KdOffscreenFini (ScreenPtr pScreen) -{ - KdScreenPriv (pScreen); - RealOffscreenArea *area; - - /* just free all of the area records */ - while ((area = pScreenPriv->screen->off_screen_areas)) - { - pScreenPriv->screen->off_screen_areas = area->next; - xfree (area); - } -} diff --git a/hw/kdrive/src/kpict.c b/hw/kdrive/src/kpict.c deleted file mode 100644 index 25fb449a0..000000000 --- a/hw/kdrive/src/kpict.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * $RCSId: $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include <picturestr.h> -#include <mipict.h> -#include <fbpict.h> - -void -KdCheckComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - KdCheckSync (pDst->pDrawable->pScreen); - fbComposite (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); -} - -void -KdPictureInitAsync (ScreenPtr pScreen) -{ - PictureScreenPtr ps; - - ps = GetPictureScreen(pScreen); - ps->Composite = KdCheckComposite; -} diff --git a/hw/kdrive/src/kshadow.c b/hw/kdrive/src/kshadow.c deleted file mode 100644 index f4b593f26..000000000 --- a/hw/kdrive/src/kshadow.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * $RCSId: $ - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -Bool -KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate) -{ - int paddedWidth; - void *buf; - int width = rotate ? screen->height : screen->width; - int height = rotate ? screen->width : screen->height; - int bpp = screen->fb[fb].bitsPerPixel; - - /* use fb computation for width */ - paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits); - buf = xalloc (paddedWidth * height); - if (!buf) - return FALSE; - if (screen->fb[fb].shadow) - xfree (screen->fb[fb].frameBuffer); - screen->fb[fb].shadow = TRUE; - screen->fb[fb].frameBuffer = buf; - screen->fb[fb].byteStride = paddedWidth; - screen->fb[fb].pixelStride = paddedWidth * 8 / bpp; - return TRUE; -} - -void -KdShadowFbFree (KdScreenInfo *screen, int fb) -{ - if (screen->fb[fb].shadow) - { - xfree (screen->fb[fb].frameBuffer); - screen->fb[fb].frameBuffer = 0; - screen->fb[fb].shadow = FALSE; - } -} - -Bool -KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - int fb; - - for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) - { - if (screen->fb[fb].shadow) - return shadowSet (pScreen, (*pScreen->GetScreenPixmap) (pScreen), - update, window, randr, 0); - else - shadowUnset (pScreen); - } - return TRUE; -} - -void -KdShadowUnset (ScreenPtr pScreen) -{ - shadowUnset (pScreen); -} diff --git a/hw/kdrive/src/ktest.c b/hw/kdrive/src/ktest.c deleted file mode 100644 index 3fe3739a5..000000000 --- a/hw/kdrive/src/ktest.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Id: ktest.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/ktest.c,v 1.1 1999/11/19 13:53:50 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; -} diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c deleted file mode 100644 index ea36bc788..000000000 --- a/hw/kdrive/src/kxv.c +++ /dev/null @@ -1,1779 +0,0 @@ -/* - - XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com) - Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com> - - Copyright (C) 2000, 2001 - Nokia Home Communications - Copyright (C) 1998, 1999 - The XFree86 Project Inc. - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -*/ - -/* $RCSId: xc/programs/Xserver/hw/kdrive/kxv.c,v 1.3 2001/08/09 09:08:54 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" - -#include "scrnintstr.h" -#include "regionstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "mivalidate.h" -#include "validate.h" -#include "resource.h" -#include "gcstruct.h" -#include "dixstruct.h" - -#include <X11/extensions/Xv.h> -#include <X11/extensions/Xvproto.h> - -#include "kxv.h" - - -/* XvScreenRec fields */ - -static Bool KdXVCloseScreen(int, ScreenPtr); -static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *); - -/* XvAdaptorRec fields */ - -static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*); -static int KdXVFreePort(XvPortPtr); -static int KdXVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -static int KdXVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -static int KdXVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -static int KdXVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr); -static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); -static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *); -static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8, - CARD16, CARD16,CARD16, CARD16, - unsigned int*, unsigned int*); -static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16, - XvImagePtr, unsigned char*, Bool, - CARD16, CARD16); -static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr, - CARD16*, CARD16*, int*, int*); - - -/* ScreenRec fields */ - -static Bool KdXVCreateWindow(WindowPtr pWin); -static Bool KdXVDestroyWindow(WindowPtr pWin); -static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2); -static void KdXVClipNotify(WindowPtr pWin, int dx, int dy); - -/* misc */ -static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int); - - -int KdXVWindowIndex = -1; -int KdXvScreenIndex = -1; -static unsigned long KdXVGeneration = 0; -static unsigned long PortResource = 0; - -int (*XvGetScreenIndexProc)(void) = XvGetScreenIndex; -unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort; -int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit; - -#define GET_XV_SCREEN(pScreen) \ - ((XvScreenPtr)((pScreen)->devPrivates[KdXvScreenIndex].ptr)) - -#define GET_KDXV_SCREEN(pScreen) \ - ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) - -#define GET_KDXV_WINDOW(pWin) \ - ((KdXVWindowPtr)((pWin)->devPrivates[KdXVWindowIndex].ptr)) - -static KdXVInitGenericAdaptorPtr *GenDrivers = NULL; -static int NumGenDrivers = 0; - -int -KdXVRegisterGenericAdaptorDriver( - KdXVInitGenericAdaptorPtr InitFunc -){ - KdXVInitGenericAdaptorPtr *newdrivers; - -/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */ - - newdrivers = xrealloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) * - (1 + NumGenDrivers)); - if (!newdrivers) - return 0; - GenDrivers = newdrivers; - - GenDrivers[NumGenDrivers++] = InitFunc; - - return 1; -} - -int -KdXVListGenericAdaptors( - KdScreenInfo * screen, - KdVideoAdaptorPtr **adaptors -){ - int i,j,n,num; - KdVideoAdaptorPtr *DrivAdap,*new; - - num = 0; - *adaptors = NULL; - for (i = 0; i < NumGenDrivers; i++) { - n = GenDrivers[i](screen,&DrivAdap); - if (0 == n) - continue; - new = xrealloc(*adaptors, sizeof(KdVideoAdaptorPtr) * (num+n)); - if (NULL == new) - continue; - *adaptors = new; - for (j = 0; j < n; j++, num++) - (*adaptors)[num] = DrivAdap[j]; - } - return num; -} - -KdVideoAdaptorPtr -KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen) -{ - return xcalloc(1, sizeof(KdVideoAdaptorRec)); -} - -void -KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr) -{ - xfree(ptr); -} - - -Bool -KdXVScreenInit( - ScreenPtr pScreen, - KdVideoAdaptorPtr *adaptors, - int num -){ - KdXVScreenPtr ScreenPriv; - XvScreenPtr pxvs; - -/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */ - - if(KdXVGeneration != serverGeneration) { - if((KdXVWindowIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - KdXVGeneration = serverGeneration; - } - - if(!AllocateWindowPrivate(pScreen,KdXVWindowIndex,0)) - return FALSE; - - if(!XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc) - return FALSE; - - if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; - - KdXvScreenIndex = (*XvGetScreenIndexProc)(); - PortResource = (*XvGetRTPortProc)(); - - pxvs = GET_XV_SCREEN(pScreen); - - - /* Anyone initializing the Xv layer must provide these two. - The Xv di layer calls them without even checking if they exist! */ - - pxvs->ddCloseScreen = KdXVCloseScreen; - pxvs->ddQueryAdaptors = KdXVQueryAdaptors; - - /* The Xv di layer provides us with a private hook so that we don't - have to allocate our own screen private. They also provide - a CloseScreen hook so that we don't have to wrap it. I'm not - sure that I appreciate that. */ - - ScreenPriv = xalloc(sizeof(KdXVScreenRec)); - pxvs->devPriv.ptr = (pointer)ScreenPriv; - - if(!ScreenPriv) return FALSE; - - - ScreenPriv->CreateWindow = pScreen->CreateWindow; - ScreenPriv->DestroyWindow = pScreen->DestroyWindow; - ScreenPriv->WindowExposures = pScreen->WindowExposures; - ScreenPriv->ClipNotify = pScreen->ClipNotify; - -/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */ - - pScreen->CreateWindow = KdXVCreateWindow; - pScreen->DestroyWindow = KdXVDestroyWindow; - pScreen->WindowExposures = KdXVWindowExposures; - pScreen->ClipNotify = KdXVClipNotify; - - if(!KdXVInitAdaptors(pScreen, adaptors, num)) - return FALSE; - - return TRUE; -} - -static void -KdXVFreeAdaptor(XvAdaptorPtr pAdaptor) -{ - int i; - - if(pAdaptor->name) - xfree(pAdaptor->name); - - if(pAdaptor->pEncodings) { - XvEncodingPtr pEncode = pAdaptor->pEncodings; - - for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) { - if(pEncode->name) xfree(pEncode->name); - } - xfree(pAdaptor->pEncodings); - } - - if(pAdaptor->pFormats) - xfree(pAdaptor->pFormats); - - if(pAdaptor->pPorts) { - XvPortPtr pPort = pAdaptor->pPorts; - XvPortRecPrivatePtr pPriv; - - for(i = 0; i < pAdaptor->nPorts; i++, pPort++) { - pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - if(pPriv) { - if(pPriv->clientClip) - REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip); - if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) - REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip); - xfree(pPriv); - } - } - xfree(pAdaptor->pPorts); - } - - if(pAdaptor->nAttributes) { - XvAttributePtr pAttribute = pAdaptor->pAttributes; - - for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) { - if(pAttribute->name) xfree(pAttribute->name); - } - - xfree(pAdaptor->pAttributes); - } - - if(pAdaptor->nImages) - xfree(pAdaptor->pImages); - - if(pAdaptor->devPriv.ptr) - xfree(pAdaptor->devPriv.ptr); -} - -static Bool -KdXVInitAdaptors( - ScreenPtr pScreen, - KdVideoAdaptorPtr *infoPtr, - int number -) { - KdScreenPriv(pScreen); - KdScreenInfo * screen = pScreenPriv->screen; - - XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); - KdVideoAdaptorPtr adaptorPtr; - XvAdaptorPtr pAdaptor, pa; - XvAdaptorRecPrivatePtr adaptorPriv; - int na, numAdaptor; - XvPortRecPrivatePtr portPriv; - XvPortPtr pPort, pp; - int numPort; - KdAttributePtr attributePtr; - XvAttributePtr pAttribute, pat; - KdVideoFormatPtr formatPtr; - XvFormatPtr pFormat, pf; - int numFormat, totFormat; - KdVideoEncodingPtr encodingPtr; - XvEncodingPtr pEncode, pe; - KdImagePtr imagePtr; - XvImagePtr pImage, pi; - int numVisuals; - VisualPtr pVisual; - int i; - - pxvs->nAdaptors = 0; - pxvs->pAdaptors = NULL; - - if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec)))) - return FALSE; - - for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) { - adaptorPtr = infoPtr[na]; - - if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute || - !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize) - continue; - - /* client libs expect at least one encoding */ - if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings) - continue; - - pa->type = adaptorPtr->type; - - if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo) - pa->type &= ~XvVideoMask; - - if(!adaptorPtr->PutStill && !adaptorPtr->GetStill) - pa->type &= ~XvStillMask; - - if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes) - pa->type &= ~XvImageMask; - - if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage && - !adaptorPtr->PutStill) - pa->type &= ~XvInputMask; - - if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill) - pa->type &= ~XvOutputMask; - - if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask))) - continue; - if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask))) - continue; - - pa->pScreen = pScreen; - pa->ddAllocatePort = KdXVAllocatePort; - pa->ddFreePort = KdXVFreePort; - pa->ddPutVideo = KdXVPutVideo; - pa->ddPutStill = KdXVPutStill; - pa->ddGetVideo = KdXVGetVideo; - pa->ddGetStill = KdXVGetStill; - pa->ddStopVideo = KdXVStopVideo; - pa->ddPutImage = KdXVPutImage; - pa->ddSetPortAttribute = KdXVSetPortAttribute; - pa->ddGetPortAttribute = KdXVGetPortAttribute; - pa->ddQueryBestSize = KdXVQueryBestSize; - pa->ddQueryImageAttributes = KdXVQueryImageAttributes; - if((pa->name = xalloc(strlen(adaptorPtr->name) + 1))) - strcpy(pa->name, adaptorPtr->name); - - if(adaptorPtr->nEncodings && - (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) { - - for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0; - i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) - { - pe->id = encodingPtr->id; - pe->pScreen = pScreen; - if((pe->name = xalloc(strlen(encodingPtr->name) + 1))) - strcpy(pe->name, encodingPtr->name); - pe->width = encodingPtr->width; - pe->height = encodingPtr->height; - pe->rate.numerator = encodingPtr->rate.numerator; - pe->rate.denominator = encodingPtr->rate.denominator; - } - pa->nEncodings = adaptorPtr->nEncodings; - pa->pEncodings = pEncode; - } - - if(adaptorPtr->nImages && - (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) { - - for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages; - i < adaptorPtr->nImages; i++, pi++, imagePtr++) - { - pi->id = imagePtr->id; - pi->type = imagePtr->type; - pi->byte_order = imagePtr->byte_order; - memcpy(pi->guid, imagePtr->guid, 16); - pi->bits_per_pixel = imagePtr->bits_per_pixel; - pi->format = imagePtr->format; - pi->num_planes = imagePtr->num_planes; - pi->depth = imagePtr->depth; - pi->red_mask = imagePtr->red_mask; - pi->green_mask = imagePtr->green_mask; - pi->blue_mask = imagePtr->blue_mask; - pi->y_sample_bits = imagePtr->y_sample_bits; - pi->u_sample_bits = imagePtr->u_sample_bits; - pi->v_sample_bits = imagePtr->v_sample_bits; - pi->horz_y_period = imagePtr->horz_y_period; - pi->horz_u_period = imagePtr->horz_u_period; - pi->horz_v_period = imagePtr->horz_v_period; - pi->vert_y_period = imagePtr->vert_y_period; - pi->vert_u_period = imagePtr->vert_u_period; - pi->vert_v_period = imagePtr->vert_v_period; - memcpy(pi->component_order, imagePtr->component_order, 32); - pi->scanline_order = imagePtr->scanline_order; - } - pa->nImages = adaptorPtr->nImages; - pa->pImages = pImage; - } - - if(adaptorPtr->nAttributes && - (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) - { - for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0; - i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) - { - pat->flags = attributePtr->flags; - pat->min_value = attributePtr->min_value; - pat->max_value = attributePtr->max_value; - if((pat->name = xalloc(strlen(attributePtr->name) + 1))) - strcpy(pat->name, attributePtr->name); - } - pa->nAttributes = adaptorPtr->nAttributes; - pa->pAttributes = pAttribute; - } - - - totFormat = adaptorPtr->nFormats; - - if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) { - KdXVFreeAdaptor(pa); - continue; - } - for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats; - i < adaptorPtr->nFormats; i++, formatPtr++) - { - numVisuals = pScreen->numVisuals; - pVisual = pScreen->visuals; - - while(numVisuals--) { - if((pVisual->class == formatPtr->class) && - (pVisual->nplanes == formatPtr->depth)) { - - if(numFormat >= totFormat) { - void *moreSpace; - totFormat *= 2; - moreSpace = xrealloc(pFormat, - totFormat * sizeof(XvFormatRec)); - if(!moreSpace) break; - pFormat = moreSpace; - pf = pFormat + numFormat; - } - - pf->visual = pVisual->vid; - pf->depth = formatPtr->depth; - - pf++; - numFormat++; - } - pVisual++; - } - } - pa->nFormats = numFormat; - pa->pFormats = pFormat; - if(!numFormat) { - KdXVFreeAdaptor(pa); - continue; - } - - if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) { - KdXVFreeAdaptor(pa); - continue; - } - - adaptorPriv->flags = adaptorPtr->flags; - adaptorPriv->PutVideo = adaptorPtr->PutVideo; - adaptorPriv->PutStill = adaptorPtr->PutStill; - adaptorPriv->GetVideo = adaptorPtr->GetVideo; - adaptorPriv->GetStill = adaptorPtr->GetStill; - adaptorPriv->StopVideo = adaptorPtr->StopVideo; - adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute; - adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute; - adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize; - adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes; - adaptorPriv->PutImage = adaptorPtr->PutImage; - adaptorPriv->ReputImage = adaptorPtr->ReputImage; - - pa->devPriv.ptr = (pointer)adaptorPriv; - - if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) { - KdXVFreeAdaptor(pa); - continue; - } - for(pp = pPort, i = 0, numPort = 0; - i < adaptorPtr->nPorts; i++) { - - if(!(pp->id = FakeClientID(0))) - continue; - - if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate)))) - continue; - - if(!AddResource(pp->id, PortResource, pp)) { - xfree(portPriv); - continue; - } - - pp->pAdaptor = pa; - pp->pNotify = (XvPortNotifyPtr)NULL; - pp->pDraw = (DrawablePtr)NULL; - pp->client = (ClientPtr)NULL; - pp->grab.client = (ClientPtr)NULL; - pp->time = currentTime; - pp->devPriv.ptr = portPriv; - - portPriv->screen = screen; - portPriv->AdaptorRec = adaptorPriv; - portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr; - - pp++; - numPort++; - } - pa->nPorts = numPort; - pa->pPorts = pPort; - if(!numPort) { - KdXVFreeAdaptor(pa); - continue; - } - - pa->base_id = pPort->id; - - pa++; - numAdaptor++; - } - - if(numAdaptor) { - pxvs->nAdaptors = numAdaptor; - pxvs->pAdaptors = pAdaptor; - } else { - xfree(pAdaptor); - return FALSE; - } - - return TRUE; -} - -/* Video should be clipped to the intersection of the window cliplist - and the client cliplist specified in the GC for which the video was - initialized. When we need to reclip a window, the GC that started - the video may not even be around anymore. That's why we save the - client clip from the GC when the video is initialized. We then - use KdXVUpdateCompositeClip to calculate the new composite clip - when we need it. This is different from what DEC did. They saved - the GC and used it's clip list when they needed to reclip the window, - even if the client clip was different from the one the video was - initialized with. If the original GC was destroyed, they had to stop - the video. I like the new method better (MArk). - - This function only works for windows. Will need to rewrite when - (if) we support pixmap rendering. -*/ - -static void -KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) -{ - RegionPtr pregWin, pCompositeClip; - WindowPtr pWin; - Bool freeCompClip = FALSE; - - if(portPriv->pCompositeClip) - return; - - pWin = (WindowPtr)portPriv->pDraw; - - /* get window clip list */ - if(portPriv->subWindowMode == IncludeInferiors) { - pregWin = NotClippedByChildren(pWin); - freeCompClip = TRUE; - } else - pregWin = &pWin->clipList; - - if(!portPriv->clientClip) { - portPriv->pCompositeClip = pregWin; - portPriv->FreeCompositeClip = freeCompClip; - return; - } - - pCompositeClip = REGION_CREATE(pWin->pScreen, NullBox, 1); - REGION_COPY(pWin->pScreen, pCompositeClip, portPriv->clientClip); - REGION_TRANSLATE(pWin->pScreen, pCompositeClip, - portPriv->pDraw->x + portPriv->clipOrg.x, - portPriv->pDraw->y + portPriv->clipOrg.y); - REGION_INTERSECT(pWin->pScreen, pCompositeClip, pregWin, pCompositeClip); - - portPriv->pCompositeClip = pCompositeClip; - portPriv->FreeCompositeClip = TRUE; - - if(freeCompClip) { - REGION_DESTROY(pWin->pScreen, pregWin); - } -} - -/* Save the current clientClip and update the CompositeClip whenever - we have a fresh GC */ - -static void -KdXVCopyClip( - XvPortRecPrivatePtr portPriv, - GCPtr pGC -){ - /* copy the new clip if it exists */ - if((pGC->clientClipType == CT_REGION) && pGC->clientClip) { - if(!portPriv->clientClip) - portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1); - /* Note: this is in window coordinates */ - REGION_COPY(pGC->pScreen, portPriv->clientClip, pGC->clientClip); - } else if(portPriv->clientClip) { /* free the old clientClip */ - REGION_DESTROY(pGC->pScreen, portPriv->clientClip); - portPriv->clientClip = NULL; - } - - /* get rid of the old clip list */ - if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) { - REGION_DESTROY(pWin->pScreen, portPriv->pCompositeClip); - } - - portPriv->clipOrg = pGC->clipOrg; - portPriv->pCompositeClip = pGC->pCompositeClip; - portPriv->FreeCompositeClip = FALSE; - portPriv->subWindowMode = pGC->subWindowMode; -} - -static int -KdXVRegetVideo(XvPortRecPrivatePtr portPriv) -{ - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - int ret = Success; - Bool clippedAway = FALSE; - - KdXVUpdateCompositeClip(portPriv); - - /* translate the video region to the screen */ - WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; - WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; - WinBox.x2 = WinBox.x1 + portPriv->drw_w; - WinBox.y2 = WinBox.y1 + portPriv->drw_h; - - /* clip to the window composite clip */ - REGION_INIT(portPriv->pDraw->pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(portPriv->pDraw->pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); - - /* that's all if it's totally obscured */ - if(!REGION_NOTEMPTY(portPriv->pDraw->pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto CLIP_VIDEO_BAILOUT; - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw, - portPriv->vid_x, portPriv->vid_y, - WinBox.x1, WinBox.y1, - portPriv->vid_w, portPriv->vid_h, - portPriv->drw_w, portPriv->drw_h, - &ClipRegion, portPriv->DevPriv.ptr); - - if(ret == Success) - portPriv->isOn = XV_ON; - -CLIP_VIDEO_BAILOUT: - - if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - /* This clip was copied and only good for one shot */ - if(!portPriv->FreeCompositeClip) - portPriv->pCompositeClip = NULL; - - REGION_UNINIT(portPriv->pDraw->pScreen, &WinRegion); - REGION_UNINIT(portPriv->pDraw->pScreen, &ClipRegion); - - return ret; -} - - -static int -KdXVReputVideo(XvPortRecPrivatePtr portPriv) -{ - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - ScreenPtr pScreen = portPriv->pDraw->pScreen; - KdScreenPriv(pScreen); - KdScreenInfo *screen=pScreenPriv->screen; - int ret = Success; - Bool clippedAway = FALSE; - - KdXVUpdateCompositeClip(portPriv); - - /* translate the video region to the screen */ - WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; - WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; - WinBox.x2 = WinBox.x1 + portPriv->drw_w; - WinBox.y2 = WinBox.y1 + portPriv->drw_h; - - /* clip to the window composite clip */ - REGION_INIT(pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); - - /* clip and translate to the viewport */ - if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { - RegionRec VPReg; - BoxRec VPBox; - - VPBox.x1 = 0; - VPBox.y1 = 0; - VPBox.x2 = screen->width; - VPBox.y2 = screen->height; - - REGION_INIT(pScreen, &VPReg, &VPBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); - REGION_UNINIT(pScreen, &VPReg); - } - - /* that's all if it's totally obscured */ - if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto CLIP_VIDEO_BAILOUT; - } - - /* bailout if we have to clip but the hardware doesn't support it */ - if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { - BoxPtr clipBox = REGION_RECTS(&ClipRegion); - if( (REGION_NUM_RECTS(&ClipRegion) != 1) || - (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || - (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) - { - clippedAway = TRUE; - goto CLIP_VIDEO_BAILOUT; - } - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw, - portPriv->vid_x, portPriv->vid_y, - WinBox.x1, WinBox.y1, - portPriv->vid_w, portPriv->vid_h, - portPriv->drw_w, portPriv->drw_h, - &ClipRegion, portPriv->DevPriv.ptr); - - if(ret == Success) portPriv->isOn = XV_ON; - -CLIP_VIDEO_BAILOUT: - - if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - /* This clip was copied and only good for one shot */ - if(!portPriv->FreeCompositeClip) - portPriv->pCompositeClip = NULL; - - REGION_UNINIT(pScreen, &WinRegion); - REGION_UNINIT(pScreen, &ClipRegion); - - return ret; -} - -static int -KdXVReputImage(XvPortRecPrivatePtr portPriv) -{ - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - ScreenPtr pScreen = portPriv->pDraw->pScreen; - KdScreenPriv(pScreen); - KdScreenInfo *screen=pScreenPriv->screen; - int ret = Success; - Bool clippedAway = FALSE; - - KdXVUpdateCompositeClip(portPriv); - - /* translate the video region to the screen */ - WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; - WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; - WinBox.x2 = WinBox.x1 + portPriv->drw_w; - WinBox.y2 = WinBox.y1 + portPriv->drw_h; - - /* clip to the window composite clip */ - REGION_INIT(pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); - - /* clip and translate to the viewport */ - if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { - RegionRec VPReg; - BoxRec VPBox; - - VPBox.x1 = 0; - VPBox.y1 = 0; - VPBox.x2 = screen->width; - VPBox.y2 = screen->height; - - REGION_INIT(pScreen, &VPReg, &VPBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); - REGION_UNINIT(pScreen, &VPReg); - } - - /* that's all if it's totally obscured */ - if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto CLIP_VIDEO_BAILOUT; - } - - /* bailout if we have to clip but the hardware doesn't support it */ - if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { - BoxPtr clipBox = REGION_RECTS(&ClipRegion); - if( (REGION_NUM_RECTS(&ClipRegion) != 1) || - (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || - (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) - { - clippedAway = TRUE; - goto CLIP_VIDEO_BAILOUT; - } - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw, - WinBox.x1, WinBox.y1, - &ClipRegion, portPriv->DevPriv.ptr); - - portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF; - -CLIP_VIDEO_BAILOUT: - - if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - /* This clip was copied and only good for one shot */ - if(!portPriv->FreeCompositeClip) - portPriv->pCompositeClip = NULL; - - REGION_UNINIT(pScreen, &WinRegion); - REGION_UNINIT(pScreen, &ClipRegion); - - return ret; -} - - -static int -KdXVReputAllVideo(WindowPtr pWin, pointer data) -{ - KdXVWindowPtr WinPriv; - - if (pWin->drawable.type != DRAWABLE_WINDOW) - return WT_DONTWALKCHILDREN; - - WinPriv = GET_KDXV_WINDOW(pWin); - - while(WinPriv) { - if(WinPriv->PortRec->type == XvInputMask) - KdXVReputVideo(WinPriv->PortRec); - else - KdXVRegetVideo(WinPriv->PortRec); - WinPriv = WinPriv->next; - } - - return WT_WALKCHILDREN; -} - -static int -KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) -{ - KdXVWindowPtr winPriv, PrivRoot; - - winPriv = PrivRoot = GET_KDXV_WINDOW(pWin); - - /* Enlist our port in the window private */ - while(winPriv) { - if(winPriv->PortRec == portPriv) /* we're already listed */ - break; - winPriv = winPriv->next; - } - - if(!winPriv) { - winPriv = xalloc(sizeof(KdXVWindowRec)); - if(!winPriv) return BadAlloc; - winPriv->PortRec = portPriv; - winPriv->next = PrivRoot; - pWin->devPrivates[KdXVWindowIndex].ptr = (pointer)winPriv; - } - return Success; -} - - -static void -KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) -{ - KdXVWindowPtr winPriv, prevPriv = NULL; - - winPriv = GET_KDXV_WINDOW(pWin); - - while(winPriv) { - if(winPriv->PortRec == portPriv) { - if(prevPriv) - prevPriv->next = winPriv->next; - else - pWin->devPrivates[KdXVWindowIndex].ptr = - (pointer)winPriv->next; - xfree(winPriv); - break; - } - prevPriv = winPriv; - winPriv = winPriv->next; - } - portPriv->pDraw = NULL; -} - -/**** ScreenRec fields ****/ - - -static Bool -KdXVCreateWindow(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); - int ret; - - pScreen->CreateWindow = ScreenPriv->CreateWindow; - ret = (*pScreen->CreateWindow)(pWin); - pScreen->CreateWindow = KdXVCreateWindow; - - if(ret) pWin->devPrivates[KdXVWindowIndex].ptr = NULL; - - return ret; -} - - -static Bool -KdXVDestroyWindow(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); - KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin); - int ret; - - while(WinPriv) { - XvPortRecPrivatePtr pPriv = WinPriv->PortRec; - - if(pPriv->isOn > XV_OFF) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->screen, pPriv->DevPriv.ptr, TRUE); - pPriv->isOn = XV_OFF; - } - - pPriv->pDraw = NULL; - tmp = WinPriv; - WinPriv = WinPriv->next; - xfree(tmp); - } - - pWin->devPrivates[KdXVWindowIndex].ptr = NULL; - - pScreen->DestroyWindow = ScreenPriv->DestroyWindow; - ret = (*pScreen->DestroyWindow)(pWin); - pScreen->DestroyWindow = KdXVDestroyWindow; - - return ret; -} - - -static void -KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); - KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin); - KdXVWindowPtr pPrev; - XvPortRecPrivatePtr pPriv; - Bool AreasExposed; - - AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1)); - - pScreen->WindowExposures = ScreenPriv->WindowExposures; - (*pScreen->WindowExposures)(pWin, reg1, reg2); - pScreen->WindowExposures = KdXVWindowExposures; - - /* filter out XClearWindow/Area */ - if (!pWin->valdata) return; - - pPrev = NULL; - - while(WinPriv) { - pPriv = WinPriv->PortRec; - - /* Reput anyone with a reput function */ - - switch(pPriv->type) { - case XvInputMask: - KdXVReputVideo(pPriv); - break; - case XvOutputMask: - KdXVRegetVideo(pPriv); - break; - default: /* overlaid still/image*/ - if (pPriv->AdaptorRec->ReputImage) - KdXVReputImage(pPriv); - else if(AreasExposed) { - KdXVWindowPtr tmp; - - if (pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->screen, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = XV_PENDING; - } - pPriv->pDraw = NULL; - - if(!pPrev) - pWin->devPrivates[KdXVWindowIndex].ptr = - (pointer)(WinPriv->next); - else - pPrev->next = WinPriv->next; - tmp = WinPriv; - WinPriv = WinPriv->next; - xfree(tmp); - continue; - } - break; - } - pPrev = WinPriv; - WinPriv = WinPriv->next; - } -} - - -static void -KdXVClipNotify(WindowPtr pWin, int dx, int dy) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); - KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin); - KdXVWindowPtr tmp, pPrev = NULL; - XvPortRecPrivatePtr pPriv; - Bool visible = (pWin->visibility == VisibilityUnobscured) || - (pWin->visibility == VisibilityPartiallyObscured); - - while(WinPriv) { - pPriv = WinPriv->PortRec; - - if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) - REGION_DESTROY(pScreen, pPriv->pCompositeClip); - - pPriv->pCompositeClip = NULL; - - /* Stop everything except images, but stop them too if the - window isn't visible. But we only remove the images. */ - - if(pPriv->type || !visible) { - if(pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->screen, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = XV_PENDING; - } - - if(!pPriv->type) { /* overlaid still/image */ - pPriv->pDraw = NULL; - - if(!pPrev) - pWin->devPrivates[KdXVWindowIndex].ptr = - (pointer)(WinPriv->next); - else - pPrev->next = WinPriv->next; - tmp = WinPriv; - WinPriv = WinPriv->next; - xfree(tmp); - continue; - } - } - - pPrev = WinPriv; - WinPriv = WinPriv->next; - } - - if(ScreenPriv->ClipNotify) { - pScreen->ClipNotify = ScreenPriv->ClipNotify; - (*pScreen->ClipNotify)(pWin, dx, dy); - pScreen->ClipNotify = KdXVClipNotify; - } -} - - - -/**** Required XvScreenRec fields ****/ - -static Bool -KdXVCloseScreen(int i, ScreenPtr pScreen) -{ - XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); - XvAdaptorPtr pa; - int c; - - if(!ScreenPriv) return TRUE; - - pScreen->CreateWindow = ScreenPriv->CreateWindow; - pScreen->DestroyWindow = ScreenPriv->DestroyWindow; - pScreen->WindowExposures = ScreenPriv->WindowExposures; - pScreen->ClipNotify = ScreenPriv->ClipNotify; - -/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */ - - for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) { - KdXVFreeAdaptor(pa); - } - - if(pxvs->pAdaptors) - xfree(pxvs->pAdaptors); - - xfree(ScreenPriv); - - - return TRUE; -} - - -static int -KdXVQueryAdaptors( - ScreenPtr pScreen, - XvAdaptorPtr *p_pAdaptors, - int *p_nAdaptors -){ - XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); - - *p_nAdaptors = pxvs->nAdaptors; - *p_pAdaptors = pxvs->pAdaptors; - - return (Success); -} - -static Bool -KdXVRunning (ScreenPtr pScreen) -{ - return (KdXVGeneration == serverGeneration && - GET_XV_SCREEN(pScreen) != 0); -} - -Bool -KdXVEnable(ScreenPtr pScreen) -{ - if (!KdXVRunning (pScreen)) - return TRUE; - - WalkTree(pScreen, KdXVReputAllVideo, 0); - - return TRUE; -} - -void -KdXVDisable(ScreenPtr pScreen) -{ - XvScreenPtr pxvs; - KdXVScreenPtr ScreenPriv; - XvAdaptorPtr pAdaptor; - XvPortPtr pPort; - XvPortRecPrivatePtr pPriv; - int i, j; - - if (!KdXVRunning (pScreen)) - return; - - pxvs = GET_XV_SCREEN(pScreen); - ScreenPriv = GET_KDXV_SCREEN(pScreen); - - for(i = 0; i < pxvs->nAdaptors; i++) { - pAdaptor = &pxvs->pAdaptors[i]; - for(j = 0; j < pAdaptor->nPorts; j++) { - pPort = &pAdaptor->pPorts[j]; - pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - if(pPriv->isOn > XV_OFF) { - - (*pPriv->AdaptorRec->StopVideo)( - pPriv->screen, pPriv->DevPriv.ptr, TRUE); - pPriv->isOn = XV_OFF; - - if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) - REGION_DESTROY(pScreen, pPriv->pCompositeClip); - - pPriv->pCompositeClip = NULL; - - if(!pPriv->type && pPriv->pDraw) { /* still */ - KdXVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv); - } - } - } - } -} - -/**** XvAdaptorRec fields ****/ - -static int -KdXVAllocatePort( - unsigned long port, - XvPortPtr pPort, - XvPortPtr *ppPort -){ - *ppPort = pPort; - return Success; -} - -static int -KdXVFreePort(XvPortPtr pPort) -{ - return Success; -} - -static int -KdXVPutVideo( - ClientPtr client, - DrawablePtr pDraw, - XvPortPtr pPort, - GCPtr pGC, - INT16 vid_x, INT16 vid_y, - CARD16 vid_w, CARD16 vid_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - KdScreenPriv(portPriv->screen->pScreen); - int result; - - /* No dumping video to pixmaps... For now anyhow */ - if(pDraw->type != DRAWABLE_WINDOW) { - pPort->pDraw = (DrawablePtr)NULL; - return BadAlloc; - } - - /* If we are changing windows, unregister our port in the old window */ - if(portPriv->pDraw && (portPriv->pDraw != pDraw)) - KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - - /* Register our port with the new window */ - result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - if(result != Success) return result; - - portPriv->pDraw = pDraw; - portPriv->type = XvInputMask; - - /* save a copy of these parameters */ - portPriv->vid_x = vid_x; portPriv->vid_y = vid_y; - portPriv->vid_w = vid_w; portPriv->vid_h = vid_h; - portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; - portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; - - /* make sure we have the most recent copy of the clientClip */ - KdXVCopyClip(portPriv, pGC); - - /* To indicate to the DI layer that we were successful */ - pPort->pDraw = pDraw; - - if (!pScreenPriv->enabled) return Success; - - return(KdXVReputVideo(portPriv)); -} - -static int -KdXVPutStill( - ClientPtr client, - DrawablePtr pDraw, - XvPortPtr pPort, - GCPtr pGC, - INT16 vid_x, INT16 vid_y, - CARD16 vid_w, CARD16 vid_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - ScreenPtr pScreen = pDraw->pScreen; - KdScreenPriv(pScreen); - KdScreenInfo *screen=pScreenPriv->screen; - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - int ret = Success; - Bool clippedAway = FALSE; - - if (pDraw->type != DRAWABLE_WINDOW) - return BadAlloc; - - if (!pScreenPriv->enabled) return Success; - - WinBox.x1 = pDraw->x + drw_x; - WinBox.y1 = pDraw->y + drw_y; - WinBox.x2 = WinBox.x1 + drw_w; - WinBox.y2 = WinBox.y1 + drw_h; - - REGION_INIT(pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); - - if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { - RegionRec VPReg; - BoxRec VPBox; - - VPBox.x1 = 0; - VPBox.y1 = 0; - VPBox.x2 = screen->width; - VPBox.y2 = screen->height; - - REGION_INIT(pScreen, &VPReg, &VPBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); - REGION_UNINIT(pScreen, &VPReg); - } - - if(portPriv->pDraw) { - KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - } - - if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto PUT_STILL_BAILOUT; - } - - if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { - BoxPtr clipBox = REGION_RECTS(&ClipRegion); - if( (REGION_NUM_RECTS(&ClipRegion) != 1) || - (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || - (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) - { - clippedAway = TRUE; - goto PUT_STILL_BAILOUT; - } - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw, - vid_x, vid_y, WinBox.x1, WinBox.y1, - vid_w, vid_h, drw_w, drw_h, - &ClipRegion, portPriv->DevPriv.ptr); - - if((ret == Success) && - (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) { - - KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - portPriv->isOn = XV_ON; - portPriv->pDraw = pDraw; - portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; - portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; - portPriv->type = 0; /* no mask means it's transient and should - not be reput once it's removed */ - pPort->pDraw = pDraw; /* make sure we can get stop requests */ - } - -PUT_STILL_BAILOUT: - - if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - REGION_UNINIT(pScreen, &WinRegion); - REGION_UNINIT(pScreen, &ClipRegion); - - return ret; -} - -static int -KdXVGetVideo( - ClientPtr client, - DrawablePtr pDraw, - XvPortPtr pPort, - GCPtr pGC, - INT16 vid_x, INT16 vid_y, - CARD16 vid_w, CARD16 vid_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - int result; - KdScreenPriv(portPriv->screen->pScreen); - - /* No pixmaps... For now anyhow */ - if(pDraw->type != DRAWABLE_WINDOW) { - pPort->pDraw = (DrawablePtr)NULL; - return BadAlloc; - } - - /* If we are changing windows, unregister our port in the old window */ - if(portPriv->pDraw && (portPriv->pDraw != pDraw)) - KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - - /* Register our port with the new window */ - result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - if(result != Success) return result; - - portPriv->pDraw = pDraw; - portPriv->type = XvOutputMask; - - /* save a copy of these parameters */ - portPriv->vid_x = vid_x; portPriv->vid_y = vid_y; - portPriv->vid_w = vid_w; portPriv->vid_h = vid_h; - portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; - portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; - - /* make sure we have the most recent copy of the clientClip */ - KdXVCopyClip(portPriv, pGC); - - /* To indicate to the DI layer that we were successful */ - pPort->pDraw = pDraw; - - if(!pScreenPriv->enabled) return Success; - - return(KdXVRegetVideo(portPriv)); -} - -static int -KdXVGetStill( - ClientPtr client, - DrawablePtr pDraw, - XvPortPtr pPort, - GCPtr pGC, - INT16 vid_x, INT16 vid_y, - CARD16 vid_w, CARD16 vid_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - ScreenPtr pScreen = pDraw->pScreen; - KdScreenPriv(pScreen); - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - int ret = Success; - Bool clippedAway = FALSE; - - if (pDraw->type != DRAWABLE_WINDOW) - return BadAlloc; - - if(!pScreenPriv->enabled) return Success; - - WinBox.x1 = pDraw->x + drw_x; - WinBox.y1 = pDraw->y + drw_y; - WinBox.x2 = WinBox.x1 + drw_w; - WinBox.y2 = WinBox.y1 + drw_h; - - REGION_INIT(pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); - - if(portPriv->pDraw) { - KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - } - - if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto GET_STILL_BAILOUT; - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw, - vid_x, vid_y, WinBox.x1, WinBox.y1, - vid_w, vid_h, drw_w, drw_h, - &ClipRegion, portPriv->DevPriv.ptr); - -GET_STILL_BAILOUT: - - if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - REGION_UNINIT(pScreen, &WinRegion); - REGION_UNINIT(pScreen, &ClipRegion); - - return ret; -} - - - -static int -KdXVStopVideo( - ClientPtr client, - XvPortPtr pPort, - DrawablePtr pDraw -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - KdScreenPriv(portPriv->screen->pScreen); - - if(pDraw->type != DRAWABLE_WINDOW) - return BadAlloc; - - KdXVRemovePortFromWindow((WindowPtr)pDraw, portPriv); - - if(!pScreenPriv->enabled) return Success; - - /* Must free resources. */ - - if(portPriv->isOn > XV_OFF) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, TRUE); - portPriv->isOn = XV_OFF; - } - - return Success; -} - -static int -KdXVSetPortAttribute( - ClientPtr client, - XvPortPtr pPort, - Atom attribute, - INT32 value -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - - return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->screen, - attribute, value, portPriv->DevPriv.ptr)); -} - - -static int -KdXVGetPortAttribute( - ClientPtr client, - XvPortPtr pPort, - Atom attribute, - INT32 *p_value -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - - return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->screen, - attribute, (int *) p_value, portPriv->DevPriv.ptr)); -} - - - -static int -KdXVQueryBestSize( - ClientPtr client, - XvPortPtr pPort, - CARD8 motion, - CARD16 vid_w, CARD16 vid_h, - CARD16 drw_w, CARD16 drw_h, - unsigned int *p_w, unsigned int *p_h -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - - (*portPriv->AdaptorRec->QueryBestSize)(portPriv->screen, - (Bool)motion, vid_w, vid_h, drw_w, drw_h, - p_w, p_h, portPriv->DevPriv.ptr); - - return Success; -} - - -static int -KdXVPutImage( - ClientPtr client, - DrawablePtr pDraw, - XvPortPtr pPort, - GCPtr pGC, - INT16 src_x, INT16 src_y, - CARD16 src_w, CARD16 src_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h, - XvImagePtr format, - unsigned char* data, - Bool sync, - CARD16 width, CARD16 height -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - ScreenPtr pScreen = pDraw->pScreen; - KdScreenPriv(pScreen); - RegionRec WinRegion; - RegionRec ClipRegion; - BoxRec WinBox; - int ret = Success; - Bool clippedAway = FALSE; - - if (pDraw->type != DRAWABLE_WINDOW) - return BadAlloc; - - if(!pScreenPriv->enabled) return Success; - - WinBox.x1 = pDraw->x + drw_x; - WinBox.y1 = pDraw->y + drw_y; - WinBox.x2 = WinBox.x1 + drw_w; - WinBox.y2 = WinBox.y1 + drw_h; - - REGION_INIT(pScreen, &WinRegion, &WinBox, 1); - REGION_INIT(pScreen, &ClipRegion, NullBox, 1); - REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); - - if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { - RegionRec VPReg; - BoxRec VPBox; - - VPBox.x1 = 0; - VPBox.y1 = 0; - VPBox.x2 = pScreen->width; - VPBox.y2 = pScreen->height; - - REGION_INIT(pScreen, &VPReg, &VPBox, 1); - REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); - REGION_UNINIT(pScreen, &VPReg); - } - - if(portPriv->pDraw) { - KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - } - - if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { - clippedAway = TRUE; - goto PUT_IMAGE_BAILOUT; - } - - if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { - BoxPtr clipBox = REGION_RECTS(&ClipRegion); - if( (REGION_NUM_RECTS(&ClipRegion) != 1) || - (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || - (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) - { - clippedAway = TRUE; - goto PUT_IMAGE_BAILOUT; - } - } - - if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { - REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); - } - - ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw, - src_x, src_y, WinBox.x1, WinBox.y1, - src_w, src_h, drw_w, drw_h, format->id, data, width, height, - sync, &ClipRegion, portPriv->DevPriv.ptr); - - if((ret == Success) && - (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) { - - KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - portPriv->isOn = XV_ON; - portPriv->pDraw = pDraw; - portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; - portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; - portPriv->type = 0; /* no mask means it's transient and should - not be reput once it's removed */ - pPort->pDraw = pDraw; /* make sure we can get stop requests */ - } - -PUT_IMAGE_BAILOUT: - - if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { - (*portPriv->AdaptorRec->StopVideo)( - portPriv->screen, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = XV_PENDING; - } - - REGION_UNINIT(pScreen, &WinRegion); - REGION_UNINIT(pScreen, &ClipRegion); - - return ret; -} - - -static int -KdXVQueryImageAttributes( - ClientPtr client, - XvPortPtr pPort, - XvImagePtr format, - CARD16 *width, - CARD16 *height, - int *pitches, - int *offsets -){ - XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); - - return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->screen, - format->id, width, height, pitches, offsets); -} - - -/**************** Offscreen surface stuff *******************/ - -typedef struct { - KdOffscreenImagePtr images; - int num; -} OffscreenImageRec; - -static OffscreenImageRec OffscreenImages[MAXSCREENS]; -static Bool offscreenInited = FALSE; - -Bool -KdXVRegisterOffscreenImages( - ScreenPtr pScreen, - KdOffscreenImagePtr images, - int num -){ - if(!offscreenInited) { - bzero(OffscreenImages, sizeof(OffscreenImages[MAXSCREENS])); - offscreenInited = TRUE; - } - - OffscreenImages[pScreen->myNum].num = num; - OffscreenImages[pScreen->myNum].images = images; - - return TRUE; -} - -KdOffscreenImagePtr -KdXVQueryOffscreenImages( - ScreenPtr pScreen, - int *num -){ - if(!offscreenInited) { - *num = 0; - return NULL; - } - - *num = OffscreenImages[pScreen->myNum].num; - return OffscreenImages[pScreen->myNum].images; -} diff --git a/hw/kdrive/src/kxv.h b/hw/kdrive/src/kxv.h deleted file mode 100644 index 6335f7cb5..000000000 --- a/hw/kdrive/src/kxv.h +++ /dev/null @@ -1,305 +0,0 @@ -/* - - XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com) - Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com> - - Copyright (C) 2000, 2001 - Nokia Home Communications - Copyright (C) 1998, 1999 - The XFree86 Project Inc. - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -*/ - -/* $RCSId: xc/programs/Xserver/hw/kdrive/kxv.h,v 1.1 2001/03/30 02:18:41 keithp Exp $ */ - -#ifndef _XVDIX_H_ -#define _XVDIX_H_ - -#include "scrnintstr.h" -#include "regionstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "mivalidate.h" -#include "validate.h" -#include "resource.h" -#include "gcstruct.h" -#include "dixstruct.h" - -#include "../../Xext/xvdix.h" - -#define VIDEO_NO_CLIPPING 0x00000001 -#define VIDEO_INVERT_CLIPLIST 0x00000002 -#define VIDEO_OVERLAID_IMAGES 0x00000004 -#define VIDEO_OVERLAID_STILLS 0x00000008 -#define VIDEO_CLIP_TO_VIEWPORT 0x00000010 - -typedef struct { - int id; - int type; - int byte_order; - unsigned char guid[16]; - int bits_per_pixel; - int format; - int num_planes; - - /* for RGB formats only */ - int depth; - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - - /* for YUV formats only */ - unsigned int y_sample_bits; - unsigned int u_sample_bits; - unsigned int v_sample_bits; - unsigned int horz_y_period; - unsigned int horz_u_period; - unsigned int horz_v_period; - unsigned int vert_y_period; - unsigned int vert_u_period; - unsigned int vert_v_period; - char component_order[32]; - int scanline_order; -} KdImageRec, *KdImagePtr; - - -typedef struct { - KdScreenInfo * screen; - int id; - unsigned short width, height; - int *pitches; /* bytes */ - int *offsets; /* in bytes from start of framebuffer */ - DevUnion devPrivate; -} KdSurfaceRec, *KdSurfacePtr; - - -typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short vid_x, short vid_y, short drw_x, short drw_y, - short vid_w, short vid_h, short drw_w, short drw_h, - RegionPtr clipBoxes, pointer data ); -typedef int (* PutStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short vid_x, short vid_y, short drw_x, short drw_y, - short vid_w, short vid_h, short drw_w, short drw_h, - RegionPtr clipBoxes, pointer data ); -typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short vid_x, short vid_y, short drw_x, short drw_y, - short vid_w, short vid_h, short drw_w, short drw_h, - RegionPtr clipBoxes, pointer data ); -typedef int (* GetStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short vid_x, short vid_y, short drw_x, short drw_y, - short vid_w, short vid_h, short drw_w, short drw_h, - RegionPtr clipBoxes, pointer data ); -typedef void (* StopVideoFuncPtr)(KdScreenInfo * screen, pointer data, Bool Exit); -typedef int (* SetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute, - int value, pointer data); -typedef int (* GetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute, - int *value, pointer data); -typedef void (* QueryBestSizeFuncPtr)(KdScreenInfo * screen, Bool motion, - short vid_w, short vid_h, short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data); -typedef int (* PutImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short src_x, short src_y, short drw_x, short drw_y, - short src_w, short src_h, short drw_w, short drw_h, - int image, unsigned char* buf, short width, short height, Bool Sync, - RegionPtr clipBoxes, pointer data ); -typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw, - short drw_x, short drw_y, - RegionPtr clipBoxes, pointer data ); -typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen, - int image, unsigned short *width, unsigned short *height, - int *pitches, int *offsets); - -typedef enum { - XV_OFF, - XV_PENDING, - XV_ON -} XvStatus; - -/*** this is what the driver needs to fill out ***/ - -typedef struct { - int id; - char *name; - unsigned short width, height; - XvRationalRec rate; -} KdVideoEncodingRec, *KdVideoEncodingPtr; - -typedef struct { - char depth; - short class; -} KdVideoFormatRec, *KdVideoFormatPtr; - -typedef struct { - int flags; - int min_value; - int max_value; - char *name; -} KdAttributeRec, *KdAttributePtr; - -typedef struct { - unsigned int type; - int flags; - char *name; - int nEncodings; - KdVideoEncodingPtr pEncodings; - int nFormats; - KdVideoFormatPtr pFormats; - int nPorts; - DevUnion *pPortPrivates; - int nAttributes; - KdAttributePtr pAttributes; - int nImages; - KdImagePtr pImages; - PutVideoFuncPtr PutVideo; - PutStillFuncPtr PutStill; - GetVideoFuncPtr GetVideo; - GetStillFuncPtr GetStill; - StopVideoFuncPtr StopVideo; - SetPortAttributeFuncPtr SetPortAttribute; - GetPortAttributeFuncPtr GetPortAttribute; - QueryBestSizeFuncPtr QueryBestSize; - PutImageFuncPtr PutImage; - ReputImageFuncPtr ReputImage; - QueryImageAttributesFuncPtr QueryImageAttributes; -} KdVideoAdaptorRec, *KdVideoAdaptorPtr; - -typedef struct { - KdImagePtr image; - int flags; - int (*alloc_surface)(KdScreenInfo * screen, - int id, - unsigned short width, - unsigned short height, - KdSurfacePtr surface); - int (*free_surface)(KdSurfacePtr surface); - int (*display) (KdSurfacePtr surface, - short vid_x, short vid_y, - short drw_x, short drw_y, - short vid_w, short vid_h, - short drw_w, short drw_h, - RegionPtr clipBoxes); - int (*stop) (KdSurfacePtr surface); - int (*getAttribute) (KdScreenInfo * screen, Atom attr, INT32 *value); - int (*setAttribute) (KdScreenInfo * screen, Atom attr, INT32 value); - int max_width; - int max_height; - int num_attributes; - KdAttributePtr attributes; -} KdOffscreenImageRec, *KdOffscreenImagePtr; - -Bool -KdXVScreenInit( - ScreenPtr pScreen, - KdVideoAdaptorPtr *Adaptors, - int num -); - -typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen, - KdVideoAdaptorPtr **Adaptors); - -int -KdXVRegisterGenericAdaptorDriver( - KdXVInitGenericAdaptorPtr InitFunc -); - -int -KdXVListGenericAdaptors( - KdScreenInfo * screen, - KdVideoAdaptorPtr **Adaptors -); - -Bool -KdXVRegisterOffscreenImages( - ScreenPtr pScreen, - KdOffscreenImagePtr images, - int num -); - -KdOffscreenImagePtr -KdXVQueryOffscreenImages( - ScreenPtr pScreen, - int *num -); - -KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen); - -void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr); - -/* Must be called from KdCardInfo functions, can be called without Xv enabled */ -Bool KdXVEnable(ScreenPtr); -void KdXVDisable(ScreenPtr); - -/*** These are DDX layer privates ***/ - - -typedef struct { - CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; - ClipNotifyProcPtr ClipNotify; - WindowExposuresProcPtr WindowExposures; -} KdXVScreenRec, *KdXVScreenPtr; - -typedef struct { - int flags; - PutVideoFuncPtr PutVideo; - PutStillFuncPtr PutStill; - GetVideoFuncPtr GetVideo; - GetStillFuncPtr GetStill; - StopVideoFuncPtr StopVideo; - SetPortAttributeFuncPtr SetPortAttribute; - GetPortAttributeFuncPtr GetPortAttribute; - QueryBestSizeFuncPtr QueryBestSize; - PutImageFuncPtr PutImage; - ReputImageFuncPtr ReputImage; - QueryImageAttributesFuncPtr QueryImageAttributes; -} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr; - -typedef struct { - KdScreenInfo * screen; - DrawablePtr pDraw; - unsigned char type; - unsigned int subWindowMode; - DDXPointRec clipOrg; - RegionPtr clientClip; - RegionPtr pCompositeClip; - Bool FreeCompositeClip; - XvAdaptorRecPrivatePtr AdaptorRec; - XvStatus isOn; - Bool moved; - int vid_x, vid_y, vid_w, vid_h; - int drw_x, drw_y, drw_w, drw_h; - DevUnion DevPriv; -} XvPortRecPrivate, *XvPortRecPrivatePtr; - -typedef struct _KdXVWindowRec{ - XvPortRecPrivatePtr PortRec; - struct _KdXVWindowRec *next; -} KdXVWindowRec, *KdXVWindowPtr; - -#endif /* _XVDIX_H_ */ - diff --git a/hw/kdrive/src/vga.c b/hw/kdrive/src/vga.c deleted file mode 100644 index 7975d5c5c..000000000 --- a/hw/kdrive/src/vga.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Id: vga.c,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vga.c,v 1.2 1999/12/30 03:03:07 robin Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vga.h" -#include <stdio.h> - -#ifdef linux -#ifdef __i386__ -#define extern static -#include <asm/io.h> -#undef extern - -#define _VgaInb(r) inb(r) -#define _VgaOutb(v,r) outb(v,r) -#else -#define _VgaInb(r) 0 -#define _VgaOutb(v,r) -#endif - -#define _VgaByteAddr(a) ((VGAVOL8 *) (a)) -#define _VgaBytePort(a) (a) -#endif - -#ifdef VXWORKS -#define _VgaInb(r) 0 -#define _VgaOutb(v,r) 0 - -#define _VgaByteAddr(a) ((VGAVOL8 *) ((VGA32) (a) ^ 3)) -#define _VgaBytePort(a) 0 - -#undef stderr -#define stderr stdout - -#endif - -#undef VGA_DEBUG_REGISTERS -#ifdef VGA_DEBUG_REGISTERS -#define VGA_DEBUG(a) fprintf a -#else -#define VGA_DEBUG(a) -#endif - -VGA8 -VgaInb (VGA16 r) -{ - return _VgaInb(r); -} - -void -VgaOutb (VGA8 v, VGA16 r) -{ - _VgaOutb (v,r); -} - -VGA8 -VgaReadMemb (VGA32 addr) -{ - return *_VgaByteAddr(addr); -} - -void -VgaWriteMemb (VGA8 v, VGA32 addr) -{ - *_VgaByteAddr(addr) = v; -} - -VGA8 -VgaFetch (VgaCard *card, VGA16 reg) -{ - VgaMap map; - VGA8 value = 0; - - (*card->map) (card, reg, &map, VGAFALSE); - switch (map.access) { - case VgaAccessMem: - value = VgaReadMemb (map.port); - VGA_DEBUG ((stderr, "%08x -> %2x\n", map.port, value)); - break; - case VgaAccessIo: - value = _VgaInb (map.port); - VGA_DEBUG ((stderr, "%4x -> %2x\n", map.port, value)); - break; - case VgaAccessIndMem: - VgaWriteMemb (map.index, map.port + map.addr); - value = VgaReadMemb (map.port + map.value); - VGA_DEBUG ((stderr, "%4x/%2x -> %2x\n", map.port, map.index, value)); - break; - case VgaAccessIndIo: - _VgaOutb (map.index, map.port + map.addr); - 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; - - map.value = value; - (*card->map) (card, reg, &map, VGATRUE); - switch (map.access) { - case VgaAccessMem: - VGA_DEBUG ((stderr, "%8x <- %2x\n", map.port, value)); - VgaWriteMemb (map.value, map.port); - break; - case VgaAccessIo: - VGA_DEBUG ((stderr, "%4x <- %2x\n", map.port, value)); - _VgaOutb (value, map.port); - break; - case VgaAccessIndMem: - VgaWriteMemb (map.index, map.port + map.addr); - VgaWriteMemb (value, map.port + map.value); - VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value)); - break; - case VgaAccessIndIo: - VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value)); - _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 -VgaInvalidate (VgaCard *card) -{ - VGA16 id; - - for (id = 0; id < card->max; id++) - card->values[id].flags &= ~VGA_VALUE_VALID; -} - - -static 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); -} diff --git a/hw/kdrive/src/vga.h b/hw/kdrive/src/vga.h deleted file mode 100644 index 5d7e77307..000000000 --- a/hw/kdrive/src/vga.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Id: vga.h,v 1.1 1999/11/02 03:54:46 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vga.h,v 1.2 1999/12/30 03:03:07 robin Exp $ */ - -#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); - -VGA8 -VgaReadMemb (VGA32 addr); - -void -VgaWriteMemb (VGA8 v, VGA32 addr); - -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 -VgaInvalidate (VgaCard *card); - -void -VgaRestore (VgaCard *card); - -void -VgaFinish (VgaCard *card); - -void -VgaFlushReg (VgaCard *card, VgaReg *reg); - -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_ */ diff --git a/hw/kdrive/trident/Imakefile b/hw/kdrive/trident/Imakefile deleted file mode 100644 index 0dff5e91b..000000000 --- a/hw/kdrive/trident/Imakefile +++ /dev/null @@ -1,16 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/trident/Imakefile,v 1.5 2000/09/19 23:49:55 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = trident.c tridentdraw.c tridentcurs.c tridentstub.c - -OBJS = trident.o tridentdraw.o tridentcurs.o tridentstub.o - -DEFINES = -DVESA /* -DUSE_PCI*/ - -INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/fbdev -I$(KDRIVE)/vesa - -NormalLibraryObjectRule() -NormalLibraryTarget(trident,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/trident/trident.c b/hw/kdrive/trident/trident.c deleted file mode 100644 index 9423f90e0..000000000 --- a/hw/kdrive/trident/trident.c +++ /dev/null @@ -1,613 +0,0 @@ -/* - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.17 2001/06/03 18:48:19 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "trident.h" -#include <sys/io.h> - -#undef TRI_DEBUG - -int trident_clk = 0; -int trident_mclk = 0; - -#define CLOCK 14318 /* KHz */ -#define CLK_N(a,b) (a & 0xff) -#define CLK_M(a,b) ((b) & 0x3f) -#define CLK_K(a,b) (((b) >> 6) & 3) -#define CLK_FREQ(a,b) (((CLK_N(a,b) + 8) * CLOCK) / ((CLK_M(a,b)+2) << CLK_K(a,b))) - -Bool -tridentCardInit (KdCardInfo *card) -{ - int k; - char *pixels; - TridentCardInfo *tridentc; - CARD8 r39; - - tridentc = (TridentCardInfo *) xalloc (sizeof (TridentCardInfo)); - if (!tridentc) - return FALSE; - - iopl (3); - tridentc->cop_base = (CARD8 *) KdMapDevice (TRIDENT_COP_BASE(card), - TRIDENT_COP_SIZE(card)); - - if (tridentc->cop_base) - { - KdSetMappedMode (TRIDENT_COP_BASE(card), - TRIDENT_COP_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - } - tridentc->cop = (Cop *) (tridentc->cop_base + TRIDENT_COP_OFF(card)); - tridentc->mmio = FALSE; - r39 = tridentReadIndex (tridentc, 0x3d4, 0x39); - if (r39 & 1) - { - tridentc->mmio = TRUE; - r39 = tridentReadIndex (tridentc, 0x3d4, 0x39); - if ((r39 & 1) == 0) - { - ErrorF ("Trident: inconsisent IO mapping values\n"); - return FALSE; - } - } - -#ifdef VESA - if (!vesaInitialize (card, &tridentc->vesa)) -#else - if (!fbdevInitialize (card, &tridentc->fb)) -#endif - { - xfree (tridentc); - return FALSE; - } - -#ifdef USE_PCI - tridentc->window = (CARD32 *) (tridentc->cop_base + 0x10000); -#else - tridentc->window = 0; -#endif - 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)); -#ifdef VESA - if (!vesaScreenInitialize (screen, &tridents->vesa)) -#else - if (!fbdevScreenInitialize (screen, &tridents->fbdev)) -#endif - { - xfree (tridents); - return FALSE; - } - if (!tridentc->cop) - screen->dumb = TRUE; -#ifdef VESA - if (tridents->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - tridents->screen = tridents->vesa.fb; - memory = tridents->vesa.fb_size; -#else - tridents->screen = tridentc->fb.fb; - memory = (2048 + 512) * 1024; -#endif - screen_size = screen->fb[0].byteStride * screen->height; - if (tridents->screen && memory >= screen_size + 2048) - { - memory -= 2048; - tridents->cursor_base = tridents->screen + memory - 2048; - } - else - tridents->cursor_base = 0; - memory -= screen_size; - if (memory > screen->fb[0].byteStride) - { - tridents->off_screen = tridents->screen + screen_size; - tridents->off_screen_size = memory; - } - else - { - tridents->off_screen = 0; - tridents->off_screen_size = 0; - } - screen->driver = tridents; - return TRUE; -} - -Bool -tridentInitScreen (ScreenPtr pScreen) -{ -#ifdef VESA - return vesaInitScreen (pScreen); -#else - return fbdevInitScreen (pScreen); -#endif -} - -Bool -tridentFinishInitScreen (ScreenPtr pScreen) -{ -#ifdef VESA - return vesaFinishInitScreen (pScreen); -#endif -} - -CARD8 -tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index) -{ - CARD8 value; - - if (tridentc->mmio) - { - tridentc->cop_base[port] = index; - value = tridentc->cop_base[port+1]; - } - else - { - outb (index, port); - value = inb (port+1); - } - return value; -} - -void -tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value) -{ - if (tridentc->mmio) - { - tridentc->cop_base[port] = index; - tridentc->cop_base[port+1] = value; - } - else - { - outb (index, port); - outb (value, port+1); - } -} - -CARD8 -tridentReadReg (TridentCardInfo *tridentc, CARD16 port) -{ - CARD8 value; - - if (tridentc->mmio) - { - value = tridentc->cop_base[port]; - } - else - { - value = inb (port); - } - return value; -} - -void -tridentWriteReg (TridentCardInfo *tridentc, CARD16 port, CARD8 value) -{ - if (tridentc->mmio) - { - tridentc->cop_base[port] = value; - } - else - { - outb (value, port); - } -} - - -void -tridentPause () -{ - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 50 * 1000; - select (1, 0, 0, 0, &tv); -} - -void -tridentPreserve (KdCardInfo *card) -{ - TridentCardInfo *tridentc = card->driver; - -#ifdef VESA - vesaPreserve(card); -#else - fbdevPreserve (card); -#endif - tridentPause (); - 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); - tridentc->save.reg_3c2 = tridentReadReg (tridentc, 0x3cc); - tridentc->save.reg_3c4_16 = tridentReadIndex (tridentc, 0x3c4, 0x16); - tridentc->save.reg_3c4_17 = tridentReadIndex (tridentc, 0x3c4, 0x17); - tridentc->save.reg_3c4_18 = tridentReadIndex (tridentc, 0x3c4, 0x18); - tridentc->save.reg_3c4_19 = tridentReadIndex (tridentc, 0x3c4, 0x19); - ErrorF ("clk low 0x%x high 0x%x freq %d\n", - tridentc->save.reg_3c4_18, - tridentc->save.reg_3c4_19, - CLK_FREQ(tridentc->save.reg_3c4_18, - tridentc->save.reg_3c4_19)); -#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 -tridentSetCLK(int clock, CARD8 *a, CARD8 *b) -{ - int powerup[4] = { 1,2,4,8 }; - int clock_diff = 750; - int freq, ffreq; - int m, n, k; - int p, q, r, s; - int startn, endn; - int endm, endk; - - p = q = r = s = 0; - - startn = 64; - endn = 255; - endm = 63; - endk = 3; - - freq = clock; - - for (k=0;k<=endk;k++) - for (n=startn;n<=endn;n++) - for (m=1;m<=endm;m++) - { - ffreq = ( ( ((n + 8) * CLOCK) / ((m + 2) * powerup[k]) )); - if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) - { - clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; - p = n; q = m; r = k; s = ffreq; - } - } - - ErrorF ("ffreq %d clock %d\n", s, clock); - if (s == 0) - { - FatalError("Unable to set programmable clock.\n" - "Frequency %d is not a valid clock.\n" - "Please modify XF86Config for a new clock.\n", - freq); - } - - /* N is all 8bits */ - *a = p; - /* M is first 6bits, with K last 2bits */ - *b = (q & 0x3F) | (r << 6); -} - -void -tridentSetMCLK(int clock, CARD8 *a, CARD8 *b) -{ - int powerup[4] = { 1,2,4,8 }; - int clock_diff = 750; - int freq, ffreq; - int m,n,k; - int p, q, r, s; - int startn, endn; - int endm, endk; - - p = q = r = s = 0; - - startn = 64; - endn = 255; - endm = 63; - endk = 3; - - freq = clock; - - for (k=0;k<=endk;k++) - for (n=startn;n<=endn;n++) - for (m=1;m<=endm;m++) { - ffreq = ((((n+8)*CLOCK)/((m+2)*powerup[k]))); - if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) - { - clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; - p = n; q = m; r = k; s = ffreq; - } - } - - if (s == 0) - { - FatalError("Unable to set memory clock.\n" - "Frequency %d is not a valid clock.\n" - "Please modify XF86Config for a new clock.\n", - freq); - } - - /* N is all 8bits */ - *a = p; - /* M is first 6bits, with K last 2bits */ - *b = (q & 0x3F) | (r << 6); -} - -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 screen */ - tridentWriteIndex (tridentc, 0x3ce, 0x21, 0x80); -#ifdef USE_PCI - /* enable burst r/w, enable memory mapped ports */ - tridentWriteIndex (tridentc, 0x3d4, 0x39, 7); - tridentc->mmio = TRUE; - /* reset GE, enable GE, set GE to pci 1 */ - tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x90); -#else - /* 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); -#endif - /* set clock */ - if (trident_clk) - { - CARD8 a, b; - - a = tridentReadIndex (tridentc, 0x3c4, 0x18); - b = tridentReadIndex (tridentc, 0x3c4, 0x19); - ErrorF ("old clock 0x%x 0x%x %d\n", - a, b, CLK_FREQ(a,b)); - tridentSetCLK (trident_clk, &a, &b); - ErrorF ("clk %d-> 0x%x 0x%x %d\n", trident_clk, a, b, - CLK_FREQ(a,b)); -#if 1 - tridentWriteIndex (tridentc, 0x3c4, 0x18, a); - tridentWriteIndex (tridentc, 0x3c4, 0x19, b); -#endif - } - if (trident_mclk) - { - CARD8 a, b; - - tridentSetMCLK (trident_mclk, &a, &b); - ErrorF ("mclk %d -> 0x%x 0x%x\n", trident_mclk, a, b); -#if 0 - tridentWriteIndex (tridentc, 0x3c4, 0x16, a); - tridentWriteIndex (tridentc, 0x3c4, 0x17, b); -#endif - } - if (trident_clk || trident_mclk) - { - CARD8 mode; - - mode = tridentReadReg (tridentc, 0x3cc); - ErrorF ("old mode 0x%x\n", mode); - mode = (mode & 0xf3) | 0x08; - ErrorF ("new mode 0x%x\n", mode); -#if 1 - tridentWriteReg (tridentc, 0x3c2, mode); -#endif - } -#ifdef TRI_DEBUG - fprintf (stderr, "0x36: 0x%02x\n", - tridentReadIndex (tridentc, 0x3d4, 0x36)); -#endif - 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 - tridentPause (); -#if 0 - tridentWriteIndex (tridentc, 0x3c4, 0x16, tridentc->save.reg_3c4_16); - tridentWriteIndex (tridentc, 0x3c4, 0x17, tridentc->save.reg_3c4_17); -#endif - tridentWriteIndex (tridentc, 0x3c4, 0x18, tridentc->save.reg_3c4_18); - tridentWriteIndex (tridentc, 0x3c4, 0x19, tridentc->save.reg_3c4_19); - tridentWriteReg (tridentc, 0x3c2, tridentc->save.reg_3c2); - tridentPause (); - tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21); - tridentPause (); - tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62); - tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39); - tridentc->mmio = FALSE; - tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36); - tridentWriteIndex (tridentc, 0x3c4, 0x0e, tridentc->save.reg_3c4_0e); - tridentPause (); -} - -Bool -tridentEnable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - TridentCardInfo *tridentc = pScreenPriv->card->driver; - -#ifdef VESA - if (!vesaEnable (pScreen)) - return FALSE; -#else - if (!fbdevEnable (pScreen)) - return FALSE; -#endif - tridentSetMMIO (tridentc); - return TRUE; -} - -void -tridentDisable (ScreenPtr pScreen) -{ -#ifdef VESA - vesaDisable (pScreen); -#else - fbdevDisable (pScreen); -#endif -} - -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]); - tridentPause (); - return TRUE; -} - -void -tridentRestore (KdCardInfo *card) -{ - TridentCardInfo *tridentc = card->driver; - - tridentResetMMIO (tridentc); -#ifdef VESA - vesaRestore (card); -#else - fbdevRestore (card); -#endif -} - -void -tridentScreenFini (KdScreenInfo *screen) -{ - TridentScreenInfo *tridents = (TridentScreenInfo *) screen->driver; - -#ifdef VESA - vesaScreenFini (screen); -#endif - 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(card)); - KdResetMappedMode (TRIDENT_COP_BASE(card), - TRIDENT_COP_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - } -#ifdef VESA - vesaCardFini (card); -#else - fbdevCardFini (card); -#endif -} - -KdCardFuncs tridentFuncs = { - tridentCardInit, /* cardinit */ - tridentScreenInit, /* scrinit */ - tridentInitScreen, /* initScreen */ - 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 */ - tridentDrawSync, /* syncAccel */ - tridentDrawDisable, /* disableAccel */ - tridentDrawFini, /* finiAccel */ - -#ifdef VESA - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -#else - fbdevGetColors, /* getColors */ - fbdevPutColors, /* putColors */ -#endif - tridentFinishInitScreen /* finishInitScreen */ -}; diff --git a/hw/kdrive/trident/trident.h b/hw/kdrive/trident/trident.h deleted file mode 100644 index 0b0d8cb48..000000000 --- a/hw/kdrive/trident/trident.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Id: trident.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/trident.h,v 1.8 2000/10/20 00:19:51 keithp Exp $ */ - -#ifndef _TRIDENT_H_ -#define _TRIDENT_H_ -#ifdef VESA -#include <vesa.h> -#else -#include <fbdev.h> -#endif - -/* - * offset from ioport beginning - */ - -#ifdef USE_PCI -#define TRIDENT_COP_BASE(c) (c->attr.address[1]) -#define TRIDENT_COP_OFF(c) 0x2100 -#define TRIDENT_COP_SIZE(c) 0x20000 -#else -#define TRIDENT_COP_BASE(c) 0xbf000 -#define TRIDENT_COP_OFF(c) 0x00f00 -#define TRIDENT_COP_SIZE(c) (0x2000) -#endif - -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 - - -#define COP_ALPHA_SRC_BLEND_0 0x00000000 -#define COP_ALPHA_SRC_BLEND_1 0x00000001 -#define COP_ALPHA_SRC_BLEND_SRC_C 0x00000002 -#define COP_ALPHA_SRC_BLEND_1_SRC_C 0x00000003 -#define COP_ALPHA_SRC_BLEND_SRC_A 0x00000004 -#define COP_ALPHA_SRC_BLEND_1_SRC_A 0x00000005 -#define COP_ALPHA_SRC_BLEND_DST_A 0x00000006 -#define COP_ALPHA_SRC_BLEND_1_DST_A 0x00000007 -#define COP_ALPHA_SRC_BLEND_DST_C 0x00000008 -#define COP_ALPHA_SRC_BLEND_1_DST_C 0x00000009 -#define COP_ALPHA_SRC_BLEND_SAT 0x0000000A -#define COP_ALPHA_SRC_BLEND_BG 0x0000000B - -#define COP_ALPHA_DST_BLEND_0 0x00000000 -#define COP_ALPHA_DST_BLEND_1 0x00000010 -#define COP_ALPHA_DST_BLEND_SRC_C 0x00000020 -#define COP_ALPHA_DST_BLEND_1_SRC_C 0x00000030 -#define COP_ALPHA_DST_BLEND_SRC_A 0x00000040 -#define COP_ALPHA_DST_BLEND_1_SRC_A 0x00000050 -#define COP_ALPHA_DST_BLEND_DST_A 0x00000060 -#define COP_ALPHA_DST_BLEND_1_DST_A 0x00000070 -#define COP_ALPHA_DST_BLEND_DST_C 0x00000080 -#define COP_ALPHA_DST_BLEND_1_DST_C 0x00000090 -#define COP_ALPHA_DST_BLEND_OTHER 0x000000A0 - -#define COP_ALPHA_RESULT_ALPHA 0x00100000 -#define COP_ALPHA_DEST_ALPHA 0x00200000 -#define COP_ALPHA_SOURCE_ALPHA 0x00400000 -#define COP_ALPHA_WRITE_ENABLE 0x00800000 -#define COP_ALPHA_TEST_ENABLE 0x01000000 -#define COP_ALPHA_BLEND_ENABLE 0x02000000 -#define COP_ALPHA_DEST_VALUE 0x04000000 -#define COP_ALPHA_SOURCE_VALUE 0x08000000 - - VOL32 command; /* 0x24 */ -#define COP_OP_NULL 0x00000000 -#define COP_OP_LINE 0x20000000 -#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 */ - CARD8 reg_3c2; /* clock config */ - CARD8 reg_3c4_16; /* MCLKLow */ - CARD8 reg_3c4_17; /* MCLKHigh */ - CARD8 reg_3c4_18; /* ClockLow */ - CARD8 reg_3c4_19; /* ClockHigh */ -} TridentSave; - -typedef struct _tridentCardInfo { -#ifdef VESA - VesaCardPrivRec vesa; -#else - FbdevPriv fb; -#endif - CARD8 *cop_base; - Cop *cop; - CARD32 *window; - CARD32 cop_depth; - CARD32 cop_stride; - Bool mmio; - 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 { -#ifdef VESA - VesaScreenPrivRec vesa; -#else - FbdevScrPriv fbdev; -#endif - CARD8 *cursor_base; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - 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 -tridentDrawSync (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_ */ diff --git a/hw/kdrive/trident/tridentcurs.c b/hw/kdrive/trident/tridentcurs.c deleted file mode 100644 index 5f62294fb..000000000 --- a/hw/kdrive/trident/tridentcurs.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Id: tridentcurs.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.5 2000/08/29 17:20:15 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 *) tridents->screen; - 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; -} diff --git a/hw/kdrive/trident/tridentdraw.c b/hw/kdrive/trident/tridentdraw.c deleted file mode 100644 index 641d9239b..000000000 --- a/hw/kdrive/trident/tridentdraw.c +++ /dev/null @@ -1,499 +0,0 @@ -/* - * Id: tridentdraw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.10 2001/06/03 18:48:19 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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" -#include "picturestr.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; \ - } \ -} - -static Cop *cop; -static CARD32 cmd; - -Bool -tridentPrepareSolid (DrawablePtr pDrawable, - int alu, - Pixel pm, - Pixel fg) -{ - FbBits depthMask = FbFullMask(pDrawable->depth); - - if ((pm & depthMask) != depthMask) - return FALSE; - else - { - KdScreenPriv(pDrawable->pScreen); - tridentCardInfo(pScreenPriv); - cop = tridentc->cop; - - tridentFillPix(pDrawable->bitsPerPixel,fg); - _tridentInit(cop,tridentc); - _tridentSetSolidRect(cop,fg,alu,cmd); - return TRUE; - } -} - -void -tridentSolid (int x1, int y1, int x2, int y2) -{ - _tridentRect (cop, x1, y1, x2 - 1, y2 - 1, cmd); -} - -void -tridentDoneSolid (void) -{ -} - -Bool -tridentPrepareCopy (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - int dx, - int dy, - int alu, - Pixel pm) -{ - FbBits depthMask = FbFullMask(pDstDrawable->depth); - - if ((pm & depthMask) == depthMask) - { - KdScreenPriv(pDstDrawable->pScreen); - tridentCardInfo(pScreenPriv); - cop = tridentc->cop; - _tridentInit(cop,tridentc); - cop->multi = COP_MULTI_PATTERN; - cop->multi = COP_MULTI_ROP | tridentRop[alu]; - cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FB; - if (dx < 0 || dy < 0) - cmd |= COP_X_REVERSE; - return TRUE; - } - else - return FALSE; -} - -void -tridentCopy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - if (cmd & COP_X_REVERSE) - { - cop->src_start_xy = TRI_XY (srcX + w - 1, srcY + h - 1); - cop->src_end_xy = TRI_XY (srcX, srcY); - cop->dst_start_xy = TRI_XY (dstX + w - 1, dstY + h - 1); - cop->dst_end_xy = TRI_XY (dstX, dstY); - } - else - { - cop->src_start_xy = TRI_XY (srcX, srcY); - cop->src_end_xy = TRI_XY (srcX + w - 1, srcY + h - 1); - cop->dst_start_xy = TRI_XY (dstX, dstY); - cop->dst_end_xy = TRI_XY (dstX + w - 1, dstY + h - 1); - } - _tridentWaitDone (cop); - cop->command = cmd; -} - -void -tridentDoneCopy (void) -{ -} - -void -tridentComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - SetupTrident (pDst->pDrawable->pScreen); - tridentScreenInfo(pScreenPriv); - RegionRec region; - int n; - BoxPtr pbox; - CARD32 rgb; - CARD8 *msk, *mskLine; - FbBits *mskBits; - FbStride mskStride; - int mskBpp; - int mskXoff, mskYoff; - CARD32 *src, *srcLine; - CARD32 *off, *offLine; - FbBits *srcBits; - FbStride srcStride; - int srcXoff, srcYoff; - FbStride offStride; - int srcBpp; - int x_msk, y_msk, x_src, y_src, x_dst, y_dst; - int x2; - int w, h, w_this, h_this, w_remain; - CARD32 *off_screen; - int off_size = tridents->off_screen_size >> 2; - int off_width, off_height; - int stride = pScreenPriv->screen->fb[0].pixelStride; - int mskExtra; - CARD32 off_screen_offset = tridents->off_screen - tridents->screen; - int mode; - -#define MODE_NONE 0 -#define MODE_IMAGE 1 -#define MODE_MASK 2 - - rgb = *((CARD32 *) ((PixmapPtr) (pSrc->pDrawable))->devPrivate.ptr); - if (pMask && - !pMask->repeat && - pMask->format == PICT_a8 && - op == PictOpOver && - pSrc->repeat && - pSrc->pDrawable->width == 1 && - pSrc->pDrawable->height == 1 && - PICT_FORMAT_BPP(pSrc->format) == 32 && - (PICT_FORMAT_A(pSrc->format) == 0 || - (rgb & 0xff000000) == 0xff000000) && - pDst->pDrawable->bitsPerPixel == 32 && - pDst->pDrawable->type == DRAWABLE_WINDOW) - { - mode = MODE_MASK; - } - else if (!pMask && - op == PictOpOver && - !pSrc->repeat && - PICT_FORMAT_A(pSrc->format) == 8 && - PICT_FORMAT_BPP(pSrc->format) == 32 && - pDst->pDrawable->bitsPerPixel == 32 && - pDst->pDrawable->type == DRAWABLE_WINDOW) - { - mode = MODE_IMAGE; - } - else - mode = MODE_NONE; - - if (mode != MODE_NONE) - { - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - - fbGetDrawable (pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - - if (pMask) - { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - fbGetDrawable (pMask->pDrawable, mskBits, mskStride, mskBpp, mskXoff, mskYoff); - mskStride = mskStride * sizeof (FbBits) / sizeof (CARD8); - } - - if (!miComputeCompositeRegion (®ion, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height)) - return; - - _tridentInit(cop,tridentc); - - cop->multi = COP_MULTI_PATTERN; - cop->src_offset = off_screen_offset; - - if (mode == MODE_IMAGE) - { - cop->multi = (COP_MULTI_ALPHA | - COP_ALPHA_BLEND_ENABLE | - COP_ALPHA_WRITE_ENABLE | - 0x7 << 16 | - COP_ALPHA_DST_BLEND_1_SRC_A | - COP_ALPHA_SRC_BLEND_1); - } - else - { - rgb &= 0xffffff; - cop->multi = (COP_MULTI_ALPHA | - COP_ALPHA_BLEND_ENABLE | - COP_ALPHA_WRITE_ENABLE | - 0x7 << 16 | - COP_ALPHA_DST_BLEND_1_SRC_A | - COP_ALPHA_SRC_BLEND_SRC_A); - } - - n = REGION_NUM_RECTS (®ion); - pbox = REGION_RECTS (®ion); - - while (n--) - { - h = pbox->y2 - pbox->y1; - w = pbox->x2 - pbox->x1; - - offStride = (w + 7) & ~7; - off_height = off_size / offStride; - if (off_height > h) - off_height = h; - - cop->multi = COP_MULTI_STRIDE | (stride << 16) | offStride; - - y_dst = pbox->y1; - y_src = y_dst - yDst + ySrc; - y_msk = y_dst - yDst + yMask; - - x_dst = pbox->x1; - x_src = x_dst - xDst + xSrc; - x_msk = x_dst - xDst + xMask; - - if (mode == MODE_IMAGE) - srcLine = (CARD32 *) srcBits + (y_src - srcYoff) * srcStride + (x_src - srcXoff); - else - mskLine = (CARD8 *) mskBits + (y_msk - mskYoff) * mskStride + (x_msk - mskXoff); - - while (h) - { - h_this = h; - if (h_this > off_height) - h_this = off_height; - h -= h_this; - - offLine = (CARD32 *) tridents->off_screen; - - _tridentWaitDone(cop); - - cop->dst_start_xy = TRI_XY(x_dst, y_dst); - cop->dst_end_xy = TRI_XY(x_dst + w - 1, y_dst + h_this - 1); - cop->src_start_xy = TRI_XY(0,0); - cop->src_end_xy = TRI_XY(w - 1, h_this - 1); - - if (mode == MODE_IMAGE) - { - while (h_this--) - { - w_remain = w; - src = srcLine; - srcLine += srcStride; - off = offLine; - offLine += offStride; - while (w_remain--) - *off++ = *src++; - } - } - else - { - while (h_this--) - { - w_remain = w; - msk = mskLine; - mskLine += mskStride; - off = offLine; - offLine += offStride; - while (w_remain--) - *off++ = rgb | (*msk++ << 24); - } - } - - cop->command = (COP_OP_BLT | - COP_SCL_OPAQUE | - COP_OP_FB); - } - pbox++; - } - cop->src_offset = 0; - - KdMarkSync (pDst->pDrawable->pScreen); - } - else - { - KdCheckComposite (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); - } -} - -KaaScreenPrivRec tridentKaa = { - tridentPrepareSolid, - tridentSolid, - tridentDoneSolid, - - tridentPrepareCopy, - tridentCopy, - tridentDoneCopy, -}; - -Bool -tridentDrawInit (ScreenPtr pScreen) -{ - SetupTrident(pScreen); - tridentScreenInfo(pScreenPriv); - PictureScreenPtr ps = GetPictureScreen(pScreen); - - if (!kaaDrawInit (pScreen, &tridentKaa)) - return FALSE; - - if (ps && tridents->off_screen) - ps->Composite = tridentComposite; - - return TRUE; -} - -void -tridentDrawEnable (ScreenPtr pScreen) -{ - SetupTrident(pScreen); - CARD32 cmd; - CARD32 base; - CARD16 stride; - CARD32 format; - CARD32 alpha; - int tries; - int nwrite; - - stride = pScreenPriv->screen->fb[0].pixelStride; - switch (pScreenPriv->screen->fb[0].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); - KdMarkSync (pScreen); -} - -void -tridentDrawDisable (ScreenPtr pScreen) -{ -} - -void -tridentDrawFini (ScreenPtr pScreen) -{ -} - -void -tridentDrawSync (ScreenPtr pScreen) -{ - SetupTrident(pScreen); - - _tridentWaitIdleEmpty(cop); -} diff --git a/hw/kdrive/trident/tridentdraw.h b/hw/kdrive/trident/tridentdraw.h deleted file mode 100644 index ec09167a8..000000000 --- a/hw/kdrive/trident/tridentdraw.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Id: tridentdraw.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.2 1999/12/30 03:03:18 robin Exp $ */ - -#ifndef _TRIDENTDRAW_H_ -#define _TRIDENTDRAW_H_ - -#define SetupTrident(s) KdScreenPriv(s); \ - tridentCardInfo(pScreenPriv); \ - Cop *cop = tridentc->cop - -#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) - -#define _tridentInit(cop,tridentc) { \ - if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \ - (cop)->multi = (tridentc)->cop_depth; \ - (cop)->multi = (tridentc)->cop_stride; \ - (cop)->multi = TridentAlpha; \ -} \ - -#define _tridentSetSolidRect(cop,pix,alu,cmd) {\ - 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); \ - _tridentWaitDone(cop); \ - (cop)->command = (cmd); \ -} - -#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ - COP_STATUS_DPE_BUSY | \ - COP_STATUS_MI_BUSY) - -#define _tridentWaitDone(cop) { \ - int __q__ = 500000; \ - while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ - ; \ - if (!__q__) \ - (cop)->status = 0; \ -} - -#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop) - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/trident/tridentstub.c b/hw/kdrive/trident/tridentstub.c deleted file mode 100644 index 1e9761141..000000000 --- a/hw/kdrive/trident/tridentstub.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Id: tridentstub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentstub.c,v 1.5 2000/11/29 08:42:25 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "trident.h" - -extern int trident_clk, trident_mclk; - -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 (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!strcmp (argv[i], "-clk")) - { - if (i+1 < argc) - trident_clk = atoi (argv[i+1]); - else - UseMsg (); - return 2; - } - if (!strcmp (argv[i], "-mclk")) - { - if (i+1 < argc) - trident_mclk = atoi (argv[i+1]); - else - UseMsg (); - return 2; - } - -#ifdef VESA - if (!(ret = vesaProcessArgument (argc, argv, i))) -#endif - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/trio/Imakefile b/hw/kdrive/trio/Imakefile deleted file mode 100644 index 1cc1ecaac..000000000 --- a/hw/kdrive/trio/Imakefile +++ /dev/null @@ -1,20 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $ -KDRIVE=.. -#include "../Kdrive.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. $(KDINCS) - -DEFINES = -DS3_TRIO - -NormalLibraryObjectRule() -NormalLibraryTarget(trio,$(OBJS)) -DependTarget() - -LinkSourceFile(s3draw.h,../savage) -LinkSourceFile(s3draw.c,../savage) -LinkSourceFile(s3gc.c,../savage) diff --git a/hw/kdrive/trio/s3.c b/hw/kdrive/trio/s3.c deleted file mode 100644 index c8359733b..000000000 --- a/hw/kdrive/trio/s3.c +++ /dev/null @@ -1,1016 +0,0 @@ -/* - * Id: s3.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.4 2000/05/06 22:17:52 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" - -#define REGISTERS_OFFSET (0x1000000) -#define PACKED_OFFSET (0x8100) - - -CARD8 -_s3ReadIndexRegister (volatile CARD8 *base, CARD8 index) -{ - CARD8 ret; - *base = index; - ret = *(base + 1); - DRAW_DEBUG ((DEBUG_CRTC, " 0x%3x 0x%02x -> 0x%02x", - ((int) base) & 0xfff, index, ret)); - return ret; -} - -void -_s3WriteIndexRegister (volatile CARD8 *base, CARD8 index, CARD8 value) -{ - DRAW_DEBUG ((DEBUG_CRTC, " 0x%3x 0x%02x <- 0x%02x", - ((int) base) & 0xfff, index, value)); - *base = index; - *(base + 1) = value; -} - -/* - * Map the S3 card and detect its configuration. Do not touch the card - */ - -static void -_s3LoadCrtc (S3Ptr s3, S3Crtc *crtc) -{ - crtc->h_total_0_7 = GetCrtc (s3, 0x00); - crtc->h_display_end_0_7 = GetCrtc (s3, 0x01); - crtc->h_blank_start_0_7 = GetCrtc (s3, 0x02); - crtc->_h_blank_end = GetCrtc (s3, 0x03); - crtc->h_sync_start_0_7 = GetCrtc (s3, 0x04); - crtc->_h_sync_end = GetCrtc (s3, 0x05); - crtc->v_total_0_7 = GetCrtc (s3, 0x06); - crtc->crtc_overflow = GetCrtc (s3, 0x07); - crtc->preset_row_scan = GetCrtc (s3, 0x08); - crtc->_max_scan_line = GetCrtc (s3, 0x09); - - crtc->start_address_8_15 = GetCrtc (s3, 0x0c); - crtc->start_address_0_7 = GetCrtc (s3, 0x0d); - - crtc->v_retrace_start_0_7 = GetCrtc (s3, 0x10); - crtc->_v_retrace_end = GetCrtc (s3, 0x11); - crtc->v_display_end_0_7 = GetCrtc (s3, 0x12); - crtc->screen_off_0_7 = GetCrtc (s3, 0x13); - - crtc->v_blank_start_0_7 = GetCrtc (s3, 0x15); - crtc->v_blank_end_0_7 = GetCrtc (s3, 0x16); - - crtc->line_compare_0_7 = GetCrtc (s3, 0x18); - - crtc->memory_configuration = GetCrtc (s3, 0x31); - - crtc->misc_1 = GetCrtc (s3, 0x3a); - crtc->h_start_fifo_fetch_0_7 = GetCrtc (s3, 0x3b); - - crtc->mode_control = GetCrtc (s3, 0x42); - - crtc->hardware_cursor_mode = GetCrtc (s3, 0x45); - crtc->cursor_address_8_15 = GetCrtc (s3, 0x4C); - crtc->cursor_address_0_7 = GetCrtc (s3, 0x4D); - - crtc->extended_system_control_1 = GetCrtc (s3, 0x50); - crtc->extended_system_control_2 = GetCrtc (s3, 0x51); - - crtc->extended_memory_control = GetCrtc (s3, 0x53); - - crtc->extended_ramdac_control = GetCrtc (s3, 0x55); - - crtc->extended_horizontal_overflow = GetCrtc (s3, 0x5d); - crtc->extended_vertical_overflow = GetCrtc (s3, 0x5e); - - crtc->l_parm_0_7 = GetCrtc (s3, 0x62); - - crtc->extended_misc_control = GetCrtc (s3, 0x65); - - crtc->extended_misc_control_2 = GetCrtc (s3, 0x67); - - crtc->configuration_3 = GetCrtc (s3, 0x68); - - crtc->extended_system_control_3 = GetCrtc (s3, 0x69); - - crtc->extended_bios_5 = GetCrtc (s3, 0x6d); - - crtc->extended_sequencer_b = GetSrtc (s3, 0x0b); - crtc->extended_sequencer_d = GetSrtc (s3, 0x0d); - crtc->dclk_value_low = GetSrtc (s3, 0x12); - crtc->dclk_value_high = GetSrtc (s3, 0x13); - crtc->control_2 = GetSrtc (s3, 0x15); - crtc->ramdac_control = GetSrtc (s3, 0x18); - -/* combine values */ - - switch (crtc_ge_screen_width(crtc)) { - case 0: - if (crtc->enable_two_page) - crtc->ge_screen_pitch = 2048; - else - crtc->ge_screen_pitch = 1024; - break; - case 1: - crtc->ge_screen_pitch = 640; - break; - case 2: - /* ignore magic 1600x1200x4 mode */ - crtc->ge_screen_pitch = 800; - break; - case 3: - crtc->ge_screen_pitch = 1280; - break; - case 4: - crtc->ge_screen_pitch = 1152; - break; - case 5: - crtc->ge_screen_pitch = 0; /* reserved */ - break; - case 6: - crtc->ge_screen_pitch = 1600; - break; - case 7: - crtc->ge_screen_pitch = 0; /* reserved */ - break; - } - switch (crtc->pixel_length) { - case 0: - crtc->bits_per_pixel = 8; - crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 8; - break; - case 1: - crtc->bits_per_pixel = 16; - crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 4; - break; - case 3: - crtc->bits_per_pixel = 32; - crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 8; - break; - } - crtc->double_pixel_mode = 0; - switch (crtc->color_mode) { - case 0x0: - crtc->depth = 8; break; - case 0x1: - crtc->depth = 8; crtc->double_pixel_mode = 1; break; - case 0x3: - crtc->depth = 15; break; - case 0x5: - crtc->depth = 16; break; - case 0x7: - crtc->depth = 24; break; /* unused */ - case 0xd: - crtc->depth = 24; break; - } -} - -static void -_s3SetBlank (S3Ptr s3, Bool blank) -{ - CARD8 clock_mode; - - DRAW_DEBUG ((DEBUG_S3INIT, "3c4 at 0x%x\n", &s3->crt_vga_3c4)); - clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01); - if (blank) - clock_mode |= 0x20; - else - clock_mode &= ~0x20; - _s3WaitVRetrace (s3); - _s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, clock_mode); - DRAW_DEBUG ((DEBUG_S3INIT, "blank is set to 0x%x", clock_mode)); -} - -static void -_s3SetDepth (S3Ptr s3, S3Crtc *crtc) -{ - CARD8 save_3c2; - _s3SetBlank (s3, TRUE); - PutCrtc(s3, 0x38, 0x48); - PutCrtc(s3, 0x39, 0xA0); - PutCrtc(s3, 0x00, crtc->h_total_0_7); - PutCrtc(s3, 0x01, crtc->h_display_end_0_7); - PutCrtc(s3, 0x02, crtc->h_blank_start_0_7); - PutCrtc(s3, 0x03, crtc->_h_blank_end); - PutCrtc(s3, 0x04, crtc->h_sync_start_0_7); - PutCrtc(s3, 0x05, crtc->_h_sync_end); - PutCrtc(s3, 0x06, crtc->v_total_0_7); - PutCrtc(s3, 0x07, crtc->crtc_overflow); - PutCrtc(s3, 0x09, crtc->_max_scan_line); - PutCrtc(s3, 0x0c, crtc->start_address_8_15); - PutCrtc(s3, 0x0d, crtc->start_address_0_7); - PutCrtc(s3, 0x10, crtc->v_retrace_start_0_7); - PutCrtc(s3, 0x11, crtc->_v_retrace_end); - PutCrtc(s3, 0x12, crtc->v_display_end_0_7); - PutCrtc(s3, 0x13, crtc->screen_off_0_7); - PutCrtc(s3, 0x15, crtc->v_blank_start_0_7); - PutCrtc(s3, 0x16, crtc->v_blank_end_0_7); - PutCrtc(s3, 0x18, crtc->line_compare_0_7); - PutCrtc(s3, 0x31, crtc->memory_configuration); - PutCrtc(s3, 0x3a, crtc->misc_1); - PutCrtc(s3, 0x3b, crtc->h_start_fifo_fetch_0_7); - PutCrtc(s3, 0x42, crtc->mode_control); - PutCrtc(s3, 0x45, crtc->hardware_cursor_mode); - PutCrtc(s3, 0x4c, crtc->cursor_address_8_15); - PutCrtc(s3, 0x4d, crtc->cursor_address_0_7); - PutCrtc(s3, 0x50, crtc->extended_system_control_1); - PutCrtc(s3, 0x51, crtc->extended_system_control_2); - PutCrtc(s3, 0x53, crtc->extended_memory_control); - PutCrtc(s3, 0x55, crtc->extended_ramdac_control); - PutCrtc(s3, 0x5d, crtc->extended_horizontal_overflow); - PutCrtc(s3, 0x5e, crtc->extended_vertical_overflow); - PutCrtc(s3, 0x62, crtc->l_parm_0_7); - PutCrtc(s3, 0x65, crtc->extended_misc_control); - PutCrtc(s3, 0x67, crtc->extended_misc_control_2); - PutCrtc(s3, 0x68, crtc->configuration_3); - PutCrtc(s3, 0x69, crtc->extended_system_control_3); - PutCrtc(s3, 0x6d, crtc->extended_bios_5); - PutCrtc(s3, 0x39, 0x00); - PutCrtc(s3, 0x38, 0x00); - PutSrtc(s3, 0x0b, crtc->extended_sequencer_b); - PutSrtc(s3, 0x0d, crtc->extended_sequencer_d); - /* - * Move new dclk/mclk values into PLL - */ - save_3c2 = s3->crt_vga_3cc; - DRAW_DEBUG ((DEBUG_S3INIT, "save_3c2 0x%x", save_3c2)); - s3->crt_vga_3c2 = save_3c2 | 0x0c; - - PutSrtc(s3, 0x12, crtc->dclk_value_low); - PutSrtc(s3, 0x13, crtc->dclk_value_high); - - DRAW_DEBUG ((DEBUG_S3INIT, "Set PLL load enable, frobbing clk_load...")); - crtc->dfrq_en = 1; - PutSrtc(s3, 0x15, crtc->control_2); - PutSrtc(s3, 0x18, crtc->ramdac_control); - - DRAW_DEBUG ((DEBUG_S3INIT, "Clk load frobbed, restoring 3c2 to 0x%x", save_3c2)); - s3->crt_vga_3c2 = save_3c2; - - DRAW_DEBUG ((DEBUG_S3INIT, "Enabling display")); - _s3SetBlank (s3, FALSE); -} - -void -_s3RestoreCrtc (S3Ptr s3, S3Crtc *crtc) -{ - _s3SetDepth (s3, crtc); -} - -s3Reset (S3CardInfo *s3c) -{ - S3Ptr s3 = s3c->s3; - S3Save *save = &s3c->save; - CARD8 *cursor_base; - - LockS3 (s3c); - - _s3UnlockExt (s3); - - _s3RestoreCrtc (s3, &save->crtc); - - /* set foreground */ - /* Reset cursor color stack pointers */ - (void) GetCrtc(s3, 0x45); - PutCrtc(s3, 0x4a, save->cursor_fg); - /* XXX for deeper screens? */ - - /* set background */ - /* Reset cursor color stack pointers */ - (void) GetCrtc(s3, 0x45); - PutCrtc(s3, 0x4b, save->cursor_bg); - - _s3LockExt (s3); - - /* 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; - - _s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, save->clock_mode); - PutCrtc(s3, 0x39, save->lock2); - PutCrtc(s3, 0x38, save->lock1); - - UnlockS3 (s3c); -} - -void -s3Save (S3CardInfo *s3c) -{ - S3Ptr s3 = s3c->s3; - S3Save *save = &s3c->save; - S3Crtc newCrtc; - CARD8 t1, t2; - CARD8 *cursor_base; - - LockS3 (s3c); - - save->alt_mix = s3->alt_mix; - save->write_mask = s3->write_mask; - save->fg = s3->fg; - save->bg = s3->bg; - - save->lock1 = GetCrtc(s3, 0x38); - save->lock2 = GetCrtc(s3, 0x39); - save->clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01); - - _s3UnlockExt (s3); - save->cursor_fg = GetCrtc(s3, 0x4a); - save->cursor_bg = GetCrtc(s3, 0x4b); - - _s3LoadCrtc (s3, &save->crtc); - - _s3LockExt (s3); - - UnlockS3 (s3c); -} -Bool -s3CardInit (KdCardInfo *card) -{ - S3CardInfo *s3c; - S3Ptr s3; - int size; - CARD8 *registers; - CARD32 s3Address = card->attr.address[0]; - CARD8 *temp_buffer; - - DRAW_DEBUG ((DEBUG_S3INIT, "s3CardInit")); - s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo)); - if (!s3c) - { - DRAW_DEBUG ((DEBUG_FAILURE, "can't alloc s3 card info")); - goto bail0; - } - - memset (s3c, '\0', sizeof (S3CardInfo)); - - card->driver = s3c; - - fprintf (stderr, "S3 at 0x%x\n", s3Address); - registers = KdMapDevice (s3Address + REGISTERS_OFFSET, - 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; - - s3->crt_vga_3c3 = 1; /* wake up part from deep sleep */ - s3->crt_vga_3c2 = 0x01 | 0x02 | 0x0c; - - s3->crt_vga_3c4 = 0x58; - s3->crt_vga_3c5 = 0x10 | 0x3; - - /* - * Can't trust S3 register value for frame buffer amount, must compute - */ - temp_buffer = KdMapDevice (s3Address, 4096 * 1024); - - s3c->memory = KdFrameBufferSize (temp_buffer, 4096 * 1024); - - DRAW_DEBUG ((DEBUG_S3INIT, "Detected frame buffer %d", s3c->memory)); - - KdUnmapDevice (temp_buffer, 4096 * 1024); - - if (!s3c->memory) - { - ErrorF ("Can't detect s3 frame buffer\n"); - goto bail3; - } - - s3c->frameBuffer = KdMapDevice (s3Address, 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 -s3ModeSupported (KdScreenInfo *screen, - const KdMonitorTiming *t) -{ - if (t->horizontal != 1600 && - t->horizontal != 1280 && - t->horizontal != 1152 && - t->horizontal != 1024 && - t->horizontal != 800 && - t->horizontal != 640) - return FALSE; - if (t->clock > S3_MAX_CLOCK * 2) - return FALSE; - return TRUE; -} - -Bool -s3ModeUsable (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - S3CardInfo *s3c = (S3CardInfo *) card->driver; - int screen_size; - int pixel_width; - int byte_width; - - if (screen->fb[0].depth >= 24) - { - screen->fb[0].depth = 24; - screen->fb[0].bitsPerPixel = 32; - } - else if (screen->fb[0].depth >= 16) - { - screen->fb[0].depth = 16; - screen->fb[0].bitsPerPixel = 16; - } - else if (screen->fb[0].depth >= 15) - { - screen->fb[0].depth = 15; - screen->fb[0].bitsPerPixel = 16; - } - else - { - screen->fb[0].depth = 8; - screen->fb[0].bitsPerPixel = 8; - } - - byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3); - pixel_width = screen->width; - screen->fb[0].pixelStride = pixel_width; - screen->fb[0].byteStride = byte_width; - - screen_size = byte_width * screen->height; - - return screen_size <= s3c->memory; -} - -Bool -s3ScreenInit (KdScreenInfo *screen) -{ - KdCardInfo *card = screen->card; - S3CardInfo *s3c = (S3CardInfo *) card->driver; - S3ScreenInfo *s3s; - int screen_size; - int memory; - int requested_memory; - int v_total, h_total; - int byte_width; - int pixel_width; - int m, n, r; - int i; - const KdMonitorTiming *t; - - DRAW_DEBUG ((DEBUG_S3INIT, "s3ScreenInit")); - 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->fb[0].depth) - screen->fb[0].depth = 8; - - DRAW_DEBUG ((DEBUG_S3INIT, "Requested parameters %dx%dx%d", - screen->width, screen->height, screen->rate)); - t = KdFindMode (screen, s3ModeSupported); - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; - s3GetClock (t->clock, &m, &n, &r, 127, 31, 3); -#if 0 - 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->fb[0].depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK) - screen->fb[0].depth = 8; - - if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported)) - { - xfree (s3s); - return FALSE; - } - - memory = s3c->memory - screen_size; - - /* - * Stick frame buffer at start of memory - */ - screen->fb[0].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->fb[0].offscreen = s3c->frameBuffer + screen_size; - s3s->fb[0].offscreen_x = 0; - s3s->fb[0].offscreen_y = screen_size / byte_width; - s3s->fb[0].offscreen_width = pixel_width; - s3s->fb[0].offscreen_height = memory / byte_width; - memory -= s3s->fb[0].offscreen_height * byte_width; - } - else if (pixel_width - screen->width >= S3_TILE_SIZE) - { - s3s->fb[0].offscreen = s3c->frameBuffer + screen->width; - s3s->fb[0].offscreen_x = screen->width; - s3s->fb[0].offscreen_y = 0; - s3s->fb[0].offscreen_width = pixel_width - screen->width; - s3s->fb[0].offscreen_height = screen->height; - } - else - s3s->fb[0].offscreen = 0; - - DRAW_DEBUG ((DEBUG_S3INIT, "depth %d bits %d", screen->fb[0].depth, screen->fb[0].bitsPerPixel)); - - DRAW_DEBUG ((DEBUG_S3INIT, "Screen size %dx%d memory %d", - screen->width, screen->height, s3c->memory)); - DRAW_DEBUG ((DEBUG_S3INIT, "frame buffer 0x%x cursor 0x%x offscreen 0x%x", - s3c->frameBuffer, s3s->cursor_base, s3s->offscreen)); - DRAW_DEBUG ((DEBUG_S3INIT, "offscreen %dx%d+%d+%d", - s3s->offscreen_width, s3s->offscreen_height, - s3s->offscreen_x, s3s->offscreen_y)); - - switch (screen->fb[0].depth) { - case 8: - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case 15: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x03e0; - screen->fb[0].redMask = 0x7c00; - break; - case 16: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x001f; - screen->fb[0].greenMask = 0x07e0; - screen->fb[0].redMask = 0xf800; - break; - case 24: - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].blueMask = 0x0000ff; - screen->fb[0].greenMask = 0x00ff00; - screen->fb[0].redMask = 0xff0000; - break; - } - - screen->driver = s3s; - - return TRUE; -} - -void -s3Preserve (KdCardInfo *card) -{ - S3CardInfo *s3c = card->driver; - - s3Save (s3c); -} - -/* - * Enable the card for rendering. Manipulate the initial settings - * of the card here. - */ -Bool -s3Enable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - KdScreenInfo *screen = pScreenPriv->screen; - s3CardInfo (pScreenPriv); - s3ScreenInfo (pScreenPriv); - - S3Crtc crtcR, *crtc; - 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 v_total; - int v_retrace_start; - int v_retrace_end; - int v_display_end; - int v_blank_start; - int v_blank_end; - - int h_adjust; - int h_sync_extend_; - int h_blank_extend_; - int i; - CARD16 cursor_address; - const KdMonitorTiming *t; - int m, n, r; - - DRAW_DEBUG ((DEBUG_S3INIT, "s3Enable")); - - DRAW_DEBUG ((DEBUG_S3INIT, "requested bpp %d current %d", - pScreenPriv->bitsPerPixel, s3c->save.crtc.bits_per_pixel)); - - t = KdFindMode (screen, s3ModeSupported); - - hfp = t->hfp; - hbp = t->hbp; - hblank = t->hblank; - hactive = t->horizontal; - - vfp = t->vfp; - vbp = t->vbp; - vblank = t->vblank; - vactive = t->vertical; - - crtcR = s3c->save.crtc; - crtc = &crtcR; - - s3GetClock (t->clock, &m, &n, &r, 127, 31, 3); - crtc->dclk_pll_m_trio = m; - crtc->dclk_pll_n_trio = n; - crtc->dclk_pll_r_trio = r; - - crtc->alt_refresh_count = 0x02; - crtc->enable_alt_refresh = 1; - crtc->enable_256_or_more = 1; - - DRAW_DEBUG ((DEBUG_S3INIT, "memory_bus_size %d\n", crtc->memory_bus_size)); - crtc->memory_bus_size = 1; - - crtc->dclk_over_2 = 0; - crtc->dclk_invert = 0; - crtc->enable_clock_double = 0; - crtc->delay_blank = 0; - crtc->extended_bios_5 = 0; - /* - * Compute character lengths for horizontal timing values - */ - switch (screen->fb[0].bitsPerPixel) { - case 8: - hactive = screen->width / 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - h_screen_off = hactive; - crtc->pixel_length = 0; - crtc->color_mode = 0; - /* - * Set up for double-pixel mode, switch color modes, - * divide the dclk and delay h blank by 2 dclks - */ - if (S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio, - crtc->dclk_pll_r_trio) > S3_MAX_CLOCK) - { - DRAW_DEBUG ((DEBUG_S3INIT, "S3 clock %g > 80MHz, using pixel double mode", - S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio, - crtc->dclk_pll_r_trio))); - crtc->color_mode = 1; - crtc->dclk_over_2 = 1; - crtc->enable_clock_double = 1; - crtc->delay_blank = 2; - crtc->extended_bios_5 = 2; - } - h_adjust = 1; - break; - case 16: - hactive = screen->width / 4; - hblank /= 4; - hfp /= 4; - hbp /= 4; - h_screen_off = hactive; - crtc->pixel_length = 1; - crtc->extended_bios_5 = 2; - if (crtc->depth == 15) - crtc->color_mode = 3; - else - crtc->color_mode = 5; - h_adjust = 2; - break; - case 32: - hactive = screen->width / 8; - hblank /= 8; - hfp /= 8; - hbp /= 8; - h_screen_off = hactive * 4; - crtc->pixel_length = 3; - crtc->color_mode = 0xd; - h_adjust = 1; - break; - } - - /* - * X server starts frame buffer at top of memory - */ - DRAW_DEBUG ((DEBUG_S3INIT, "Old start address 0x%x\n", - crtc_start_address (crtc))); - crtc_set_start_address (crtc, 0); - - /* - * 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_adjust; - h_sync_start = hactive + hfp + h_adjust; - h_sync_end = h_sync_start + hblank - hbp - hfp; - h_start_fifo_fetch = h_total - 5; - - DRAW_DEBUG ((DEBUG_S3INIT, "blank_end 0x%x sync_end 0x%x sync_start 0x%x\n", - h_blank_end, h_sync_end, h_sync_start)); - - 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; - - DRAW_DEBUG ((DEBUG_S3INIT, "blank_end 0x%x sync_end 0x%x extend %d\n", - h_blank_end, h_sync_end, h_sync_extend_)); - - 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); - crtc_set_h_start_fifo_fetch (crtc, h_start_fifo_fetch); - crtc->h_sync_extend = h_sync_extend_; - crtc->h_blank_extend = h_blank_extend_; - - - v_total = vactive + vblank - 2; - v_retrace_start = vactive + vfp - 1; - v_retrace_end = v_retrace_start + vblank - vbp - 1; - 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; - - /* - * Set cursor - */ - if (!screen->softCursor) - { - cursor_address = (s3s->cursor_base - screen->fb[0].frameBuffer) / 1024; - - crtc->cursor_address_0_7 = cursor_address; - crtc->cursor_address_8_15 = cursor_address >> 8; - crtc->hardware_cursor_ms_x11 = 0; - crtc->hardware_cursor_enable = 1; - } - else - crtc->hardware_cursor_enable = 0; - - /* - * Set accelerator - */ - switch (screen->width) { - case 640: crtc_set_ge_screen_width(crtc,1); break; - case 800: crtc_set_ge_screen_width(crtc,2); break; - case 1024: crtc_set_ge_screen_width(crtc,0); break; - case 1152: crtc_set_ge_screen_width(crtc,4); break; - case 1280: crtc_set_ge_screen_width(crtc,3); break; - case 1600: crtc_set_ge_screen_width(crtc,6); break; - } - - /* - * Set depth values - */ - crtc->bits_per_pixel = screen->fb[0].bitsPerPixel; - crtc->depth = screen->fb[0].depth; - - crtc->l_parm_0_7 = screen->width / 4; /* Undocumented. */ - - crtc->disable_v_retrace_int = 1; /* don't let retrace interrupt */ - - DRAW_DEBUG ((DEBUG_S3INIT, "new h total %d display_end %d", - crtc_h_total(crtc), - crtc_h_display_end(crtc))); - DRAW_DEBUG ((DEBUG_S3INIT, " sync_start %d sync_end %d (%d)", - crtc_h_sync_start(crtc), - crtc_h_sync_end(crtc), h_sync_end)); - - DRAW_DEBUG ((DEBUG_S3INIT, " blank_start %d blank_end %d", - crtc_h_blank_start(crtc), - crtc_h_blank_end(crtc))); - - DRAW_DEBUG ((DEBUG_S3INIT, " screen_off %d start_fifo %d", - crtc_screen_off(crtc), crtc_h_start_fifo_fetch(crtc))); - - DRAW_DEBUG ((DEBUG_S3INIT, " active %d blank %d fp %d bp %d", - hactive, hblank, hfp, hbp)); - - DRAW_DEBUG ((DEBUG_S3INIT, "new v total %d display_end %d", - crtc_v_total(crtc), - crtc_v_display_end(crtc))); - DRAW_DEBUG ((DEBUG_S3INIT, " retrace_start %d retrace_end %d (%d)", - crtc_v_retrace_start(crtc), - crtc->v_retrace_end, - v_retrace_end)); - DRAW_DEBUG ((DEBUG_S3INIT, " blank_start %d blank_end %d", - crtc_v_blank_start(crtc), - crtc->v_blank_end_0_7)); - - DRAW_DEBUG ((DEBUG_S3INIT, " active %d blank %d fp %d bp %d", - vactive, vblank, vfp, vbp)); - - /* - * Set DPMS to normal - */ - crtc->hsync_control = 0; - crtc->vsync_control = 0; - - LockS3 (s3c); - _s3SetDepth (s3c->s3, crtc); - UnlockS3 (s3c); - return TRUE; -} - -void -s3Disable (ScreenPtr pScreen) -{ -} - -void -s3Restore (KdCardInfo *card) -{ - S3CardInfo *s3c = card->driver; - - s3Reset (s3c); -} - -void -_s3SetSync (S3CardInfo *s3c, int hsync, int vsync) -{ - /* this abuses the macros defined to access the crtc structure */ - union extended_sequencer_d_u _extended_sequencer_d_u; - S3Ptr s3 = s3c->s3; - - extended_sequencer_d = s3c->save.crtc.extended_sequencer_d; - hsync_control = hsync; - vsync_control = vsync; - PutSrtc (s3, 0x0d, extended_sequencer_d); -} - -Bool -s3DPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - s3CardInfo(pScreenPriv); - - switch (mode) { - case KD_DPMS_NORMAL: - _s3SetSync (s3c, 0, 0); - _s3SetBlank (s3c->s3, FALSE); - break; - case KD_DPMS_STANDBY: - _s3SetBlank (s3c->s3, TRUE); - _s3SetSync (s3c, 1, 0); - break; - case KD_DPMS_SUSPEND: - _s3SetBlank (s3c->s3, TRUE); - _s3SetSync (s3c, 0, 1); - break; - case KD_DPMS_POWERDOWN: - _s3SetBlank (s3c->s3, 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); -/* DeleteCriticalSection (&s3c->lock); */ - xfree (s3c); - card->driver = 0; -} - -KdCardFuncs s3Funcs = { - s3CardInit, - s3ScreenInit, - 0, - s3Preserve, - s3Enable, - s3DPMS, - s3Disable, - s3Restore, - s3ScreenFini, - s3CardFini, - s3CursorInit, - s3CursorEnable, - s3CursorDisable, - s3CursorFini, - s3RecolorCursor, - s3DrawInit, - s3DrawEnable, - s3DrawSync, - s3DrawDisable, - s3DrawFini, - s3GetColors, - s3PutColors, -}; - -void -S3InitCard (KdCardAttr *attr) -{ - KdCardInfoAdd (&s3Funcs, attr, 0); -} diff --git a/hw/kdrive/trio/s3.h b/hw/kdrive/trio/s3.h deleted file mode 100644 index 6f443ea97..000000000 --- a/hw/kdrive/trio/s3.h +++ /dev/null @@ -1,1203 +0,0 @@ -/* - * Id: s3.h,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.4 2000/05/06 22:17:53 keithp Exp $ */ - -#ifndef _S3_H_ -#define _S3_H_ - -#include "kdrive.h" - -#define PLATFORM 300 - -#define DRAW_DEBUG(a) - -#define DEBUG_S3INIT (DEBUG_ACCEL) -#define DEBUG_CRTC (DEBUG_ACCEL+1) -#define DEBUG_PATTERN (DEBUG_ACCEL+2) -#define DEBUG_RECT (DEBUG_ACCEL+3) -#define DEBUG_PAINT_WINDOW (DEBUG_ACCEL+4) -#define DEBUG_SET (DEBUG_ACCEL+5) -#define DEBUG_RENDER (DEBUG_ACCEL+6) -#define DEBUG_REGISTERS (DEBUG_ACCEL+7) -#define DEBUG_ARCS (DEBUG_ACCEL+8) -#define DEBUG_TEXT (DEBUG_ACCEL+9) -#define DEBUG_POLYGON (DEBUG_ACCEL+10) -#define DEBUG_CLIP (DEBUG_ACCEL+11) - -/* 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 */ - VOL32 pix_cntl_mult_misc2; /* 8140 */ - VOL32 mult_misc_read_sel; /* 8144 */ - VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */ - VOL8 _pad3[0x19c]; /* 814c */ - 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 */ -} 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 CONTROL_MISC2 0xd000 -#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 FIFO_SLOTS 13 - -#define GPSLOT(n) (1 << ((n) > 8 ? (15 - ((n) - 9)) : (8 - (n)))) - -/* Wait for n slots to become available */ -#if 0 -#define _s3WaitSlots(s3,n) { \ - DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlots 0x%x %d", (s3)->cmd_gp_stat, n)); \ - while (((s3)->cmd_gp_stat & GPSLOT(n)) != 0); \ - DRAW_DEBUG ((DEBUG_CRTC, " s3 0x%x %d slots ready", (s3)->cmd_gp_stat, n)); \ -} -#else -/* let PCI retries solve this problem */ -#define _s3WaitSlots(s3,n) -#endif - -/* Wait until queue is empty */ -#define _s3WaitEmpty(s3) { \ - DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitEmpty 0x%x", (s3)->cmd_gp_stat)); \ - while (!((s3)->cmd_gp_stat & GPEMPTY)) ; \ - DRAW_DEBUG ((DEBUG_CRTC, " s3 empty")); \ -} - -/* Wait until GP is idle and queue is empty */ -#define _s3WaitIdleEmpty(s3) { \ - DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitIdleEmpty 0x%x", (s3)->cmd_gp_stat)); \ - while (((s3)->cmd_gp_stat & (GPBUSY|GPEMPTY)) != GPEMPTY) ; \ - DRAW_DEBUG ((DEBUG_CRTC, " s3 idle empty")); \ -} - -/* Wait until GP is idle */ -#define _s3WaitIdle(s3) { \ - DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitIdle 0x%x", (s3)->cmd_gp_stat)); \ - while ((s3)->cmd_gp_stat & GPBUSY) ; \ - DRAW_DEBUG ((DEBUG_CRTC, " s3 idle")); \ -} - -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; - -typedef struct _crtc { - CARD8 h_total_0_7; /* CR0 */ - CARD8 h_display_end_0_7; /* CR1 */ - CARD8 h_blank_start_0_7; /* CR2 */ - union { - struct { - CARD8 _h_blank_end_0_4 : 5; - CARD8 _display_skew : 2; - CARD8 : 1; - } _h_blank_end_s; - CARD8 __h_blank_end; /* CR3 */ - } _h_blank_end_u; -#define h_blank_end_0_4 _h_blank_end_u._h_blank_end_s._h_blank_end_0_4 -#define display_skew _h_blank_end_u._h_blank_end_s._display_skew -#define _h_blank_end _h_blank_end_u.__h_blank_end - - CARD8 h_sync_start_0_7; /* CR4 */ - - union { - struct { - CARD8 _h_sync_end_0_4 : 5; - CARD8 _horizontal_skew : 2; - CARD8 _h_blank_end_5 : 1; - } _h_sync_end_s; - CARD8 __h_sync_end; /* CR5 */ - } _h_sync_end_u; - -#define h_sync_end_0_4 _h_sync_end_u._h_sync_end_s._h_sync_end_0_4 -#define horizontal_skew _h_sync_end_u._h_sync_end_s._horizontal_skew -#define h_blank_end_5 _h_sync_end_u._h_sync_end_s._h_blank_end_5 -#define _h_sync_end _h_sync_end_u.__h_sync_end - - CARD8 v_total_0_7; /* CR6 */ - - union { - struct { - CARD8 _v_total_8 : 1; - CARD8 _v_display_end_8 : 1; - CARD8 _v_retrace_start_8 : 1; - CARD8 _v_blank_start_8 : 1; - CARD8 _line_compare_8 : 1; - CARD8 _v_total_9 : 1; - CARD8 _v_display_end_9 : 1; - CARD8 _v_retrace_start_9 : 1; - } _crtc_overflow_s; - CARD8 _crtc_overflow; /* CR7 */ - } _crtc_overflow_u; - -#define v_total_8 _crtc_overflow_u._crtc_overflow_s._v_total_8 -#define v_display_end_8 _crtc_overflow_u._crtc_overflow_s._v_display_end_8 -#define v_retrace_start_8 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_8 -#define v_blank_start_8 _crtc_overflow_u._crtc_overflow_s._v_blank_start_8 -#define line_compare_8 _crtc_overflow_u._crtc_overflow_s._line_compare_8 -#define v_total_9 _crtc_overflow_u._crtc_overflow_s._v_total_9 -#define v_display_end_9 _crtc_overflow_u._crtc_overflow_s._v_display_end_9 -#define v_retrace_start_9 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_9 -#define crtc_overflow _crtc_overflow_u._crtc_overflow - - CARD8 preset_row_scan; /* CR8 (unused) */ - - union { - struct { - CARD8 _max_scan_line : 5; - CARD8 _v_blank_start_9 : 1; - CARD8 _line_compare_9 : 1; - CARD8 _double_scan : 1; - } _max_scan_line_s; - CARD8 __max_scan_line; /* CR9 */ - } _max_scan_line_u; - -#define max_scan_line _max_scan_line_u._max_scan_line_s._max_scan_line -#define v_blank_start_9 _max_scan_line_u._max_scan_line_s._v_blank_start_9 -#define line_compare_9 _max_scan_line_u._max_scan_line_s._line_compare_9 -#define double_scan _max_scan_line_u._max_scan_line_s._double_scan -#define _max_scan_line _max_scan_line_u.__max_scan_line - - CARD8 cursor_start; - CARD8 cursor_end; - - CARD8 start_address_8_15; /* CRC */ - CARD8 start_address_0_7; /* CRD */ - - CARD8 cursor_loc_high; - CARD8 cursor_loc_low; - - CARD8 v_retrace_start_0_7; /* CR10 */ - union { - struct { - CARD8 _v_retrace_end_0_3 : 4; - CARD8 _clear_v_retrace_int : 1; - CARD8 _disable_v_retrace_int : 1; - CARD8 _refresh_cycle_select : 1; - CARD8 _lock_crtc : 1; - } _v_retrace_end_s; - CARD8 __v_retrace_end; /* CR11 */ - } _v_retrace_end_u; - -#define v_retrace_end_0_3 _v_retrace_end_u._v_retrace_end_s._v_retrace_end_0_3 -#define clear_v_retrace_int _v_retrace_end_u._v_retrace_end_s._clear_v_retrace_int -#define disable_v_retrace_int _v_retrace_end_u._v_retrace_end_s._disable_v_retrace_int -#define refresh_cycle_select _v_retrace_end_u._v_retrace_end_s._refresh_cycle_select -#define lock_crtc _v_retrace_end_u._v_retrace_end_s._lock_crtc -#define _v_retrace_end _v_retrace_end_u.__v_retrace_end - - CARD8 v_display_end_0_7; /* CR12 */ - - CARD8 screen_off_0_7; /* CR13 */ - - union { - struct { - CARD8 _underline_location : 5; - CARD8 _count_by_four : 1; - CARD8 _doubleword_mode : 1; - CARD8 : 1; - } _underline_location_s; - CARD8 __underline_location; /* CR14 (unused) */ - } _underline_location_u; - -#define underline_location _underline_location_u._underline_location_s._underline_location -#define count_by_four _underline_location_u._underline_location_s._count_by_four -#define doubleword_mode _underline_location_u._underline_location_s._doubleword_mode -#define _underline_location _underline_location_u.__underline_location - - CARD8 v_blank_start_0_7; /* CR15 */ - CARD8 v_blank_end_0_7; /* CR16 */ - - union { - struct { - CARD8 _two_bk_cga : 1; - CARD8 _four_bk_cga : 1; - CARD8 _v_total_double : 1; - CARD8 _word_mode : 1; - CARD8 : 1; - CARD8 _address_wrap : 1; - CARD8 _byte_mode : 1; - CARD8 _hardware_reset : 1; - } _crtc_mode_s; - CARD8 _crtc_mode; /* CR17 (unused) */ - } _crtc_mode_u; - - CARD8 line_compare_0_7; /* CR18 (unused) */ - - union { - struct { - CARD8 _enable_base_offset : 1; - CARD8 _enable_two_page : 1; - CARD8 _enable_vga_16_bit : 1; - CARD8 _enhanced_mode_mapping : 1; - CARD8 _old_display_start : 2; - CARD8 _enable_high_speed_text : 1; - CARD8 : 1; - } _memory_configuration_s; - CARD8 _memory_configuration; /* CR31 (unused) */ - } _memory_configuration_u; - -#define memory_configuration _memory_configuration_u._memory_configuration -#define enable_base_offset _memory_configuration_u._memory_configuration_s._enable_base_offset -#define enable_two_page _memory_configuration_u._memory_configuration_s._enable_two_page -#define enable_vga_16_bit _memory_configuration_u._memory_configuration_s._enable_vga_16_bit -#define enhanved_mode_mapping _memory_configuration_u._memory_configuration_s._enhanced_mode_mapping -#define old_display_start _memory_configuration_u._memory_configuration_s._old_display_start -#define enable_high_speed_text _memory_configuration_u._memory_configuration_s._enable_high_speed_text - - union { - struct { - CARD8 _alt_refresh_count : 2; - CARD8 _enable_alt_refresh : 1; - CARD8 _enable_top_memory : 1; - CARD8 _enable_256_or_more : 1; - CARD8 _high_speed_text : 1; - CARD8 : 1; - CARD8 _pci_burst_disabled : 1; - } _misc_1_s; - CARD8 _misc_1; /* CR3A */ - } _misc_1_u; -#define misc_1 _misc_1_u._misc_1 -#define alt_refresh_count _misc_1_u._misc_1_s._alt_refresh_count -#define enable_alt_refresh _misc_1_u._misc_1_s._enable_alt_refresh -#define enable_top_memory _misc_1_u._misc_1_s._enable_top_memory -#define enable_256_or_more _misc_1_u._misc_1_s._enable_256_or_more -#define high_speed_text _misc_1_u._misc_1_s._high_speed_text -#define pci_burst_disabled _misc_1_u._misc_1_s._pci_burst_disabled - - CARD8 h_start_fifo_fetch_0_7; /* CR3B */ - - union { - struct { - CARD8 : 5; - CARD8 interlace : 1; - CARD8 : 2; - } _mode_control_s; - CARD8 _mode_control; /* CR42 */ - } _mode_control_u; - -#define mode_control _mode_control_u._mode_control - - union { - struct { - CARD8 : 2; - CARD8 _old_screen_off_8 : 1; - CARD8 : 4; - CARD8 h_counter_double_mode : 1; - } _extended_mode_s; - CARD8 _extended_mode; /* CR43 (unused) */ - } _extended_mode_u; - -#define extended_mode _extended_mode_u._extended_mode -#define old_screen_off_8 _extended_mode_u._extended_mode_s._old_screen_off_8 - - union { - struct { - CARD8 _hardware_cursor_enable : 1; - CARD8 : 3; - CARD8 _hardware_cursor_right : 1; - CARD8 : 3; - } _hardware_cursor_mode_s; - CARD8 _hardware_cursor_mode; /* CR45 */ - } _hardware_cursor_mode_u; - -#define hardware_cursor_mode _hardware_cursor_mode_u._hardware_cursor_mode -#define hardware_cursor_enable _hardware_cursor_mode_u._hardware_cursor_mode_s._hardware_cursor_enable - - CARD8 cursor_address_8_15; /* CR4C */ - CARD8 cursor_address_0_7; /* CR4D */ - - union { - struct { - CARD8 _ge_screen_width_2 : 1; - CARD8 : 3; - CARD8 _pixel_length : 2; - CARD8 _ge_screen_width_0_1 : 2; - } _extended_system_control_1_s; - CARD8 _extended_system_control_1; /* CR50 */ - } _extended_system_control_1_u; -#define ge_screen_width_2 _extended_system_control_1_u._extended_system_control_1_s._ge_screen_width_2 -#define pixel_length _extended_system_control_1_u._extended_system_control_1_s._pixel_length -#define ge_screen_width_0_1 _extended_system_control_1_u._extended_system_control_1_s._ge_screen_width_0_1 -#define extended_system_control_1 _extended_system_control_1_u._extended_system_control_1 - - union { - struct { - CARD8 : 4; - CARD8 _screen_off_8_9 : 2; - CARD8 : 2; - } _extended_system_control_2_s; - CARD8 _extended_system_control_2; /* CR51 */ - } _extended_system_control_2_u; -#define extended_system_control_2 _extended_system_control_2_u._extended_system_control_2 -#define screen_off_8_9 _extended_system_control_2_u._extended_system_control_2_s._screen_off_8_9 - - union { - struct { - CARD8 : 1; - CARD8 big_endian_linear : 2; - CARD8 mmio_select : 2; - CARD8 mmio_window : 1; - CARD8 swap_nibbles : 1; - CARD8 : 1; - } _extended_memory_control_s; - CARD8 _extended_memory_control; /* CR53 */ - } _extended_memory_control_u; -#define extended_memory_control _extended_memory_control_u._extended_memory_control - - union { - struct { - CARD8 : 2; - CARD8 _enable_gir : 1; - CARD8 : 1; - CARD8 _hardware_cursor_ms_x11 : 1; - CARD8 : 2; - CARD8 _tri_state_off_vclk : 1; - } _extended_ramdac_control_s; - CARD8 _extended_ramdac_control; /* CR55 */ - } _extended_ramdac_control_u; -#define extended_ramdac_control _extended_ramdac_control_u._extended_ramdac_control -#define hardware_cursor_ms_x11 _extended_ramdac_control_u._extended_ramdac_control_s._hardware_cursor_ms_x11 - - - union { - struct { - CARD8 _h_total_8 : 1; - CARD8 _h_display_end_8 : 1; - CARD8 _h_blank_start_8 : 1; - CARD8 _h_blank_extend : 1; /* extend h_blank by 64 */ - CARD8 _h_sync_start_8 : 1; - CARD8 _h_sync_extend : 1; /* extend h_sync by 32 */ - CARD8 _h_start_fifo_fetch_8 : 1; - CARD8 : 1; - } _extended_horizontal_overflow_s; - CARD8 _extended_horizontal_overflow; /* CR5D */ - } _extended_horizontal_overflow_u; -#define extended_horizontal_overflow _extended_horizontal_overflow_u._extended_horizontal_overflow -#define h_total_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_total_8 -#define h_display_end_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_display_end_8 -#define h_blank_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_start_8 -#define h_blank_extend _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_extend -#define h_sync_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_start_8 -#define h_sync_extend _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_extend -#define h_start_fifo_fetch_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_start_fifo_fetch_8 - - - union { - struct { - CARD8 _v_total_10 : 1; - CARD8 _v_display_end_10 : 1; - CARD8 _v_blank_start_10 : 1; - CARD8 : 1; - CARD8 _v_retrace_start_10 : 1; - CARD8 : 1; - CARD8 _line_compare_10 : 1; - CARD8 : 1; - } _extended_vertical_overflow_s; - CARD8 _extended_vertical_overflow; /* CR5E */ - } _extended_vertical_overflow_u; -#define extended_vertical_overflow _extended_vertical_overflow_u._extended_vertical_overflow -#define v_total_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_total_10 -#define v_display_end_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_display_end_10 -#define v_blank_start_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_blank_start_10 -#define v_retrace_start_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_retrace_start_10 -#define line_compare_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._line_compare_10 - - - CARD8 l_parm_0_7; /* CR62 (undocumented) */ - - union { - struct { - CARD8 : 3; - CARD8 _delay_blank : 2; - CARD8 : 3; - } _extended_misc_control_s; - CARD8 _extended_misc_control; /* CR65 */ - } _extended_misc_control_u; -#define extended_misc_control _extended_misc_control_u._extended_misc_control -#define delay_blank _extended_misc_control_u._extended_misc_control_s._delay_blank - - union { - struct { - CARD8 _v_clock_phase : 1; - CARD8 : 3; - CARD8 _color_mode : 4; - } _extended_misc_control_2_s; - CARD8 _extended_misc_control_2; /* CR67 */ - } _extended_misc_control_2_u; - -#define v_clock_phase _extended_misc_control_2_u._extended_misc_control_2_s._v_clock_phase -#define color_mode _extended_misc_control_2_u._extended_misc_control_2_s._color_mode -#define extended_misc_control_2 _extended_misc_control_2_u._extended_misc_control_2 - - - union { - struct { - CARD8 cas_oe_str : 2; - CARD8 ras_low : 1; - CARD8 ras_precharge : 1; - CARD8 : 3; - CARD8 _memory_bus_size : 1; /* 0 = 32, 1 = 32/64 */ - } _configuration_3_s; - CARD8 _configuration_3; /* CR68 */ - } _configuration_3_u; -#define configuration_3 _configuration_3_u._configuration_3 -#define memory_bus_size _configuration_3_u._configuration_3_s._memory_bus_size - - union { - struct { - CARD8 _start_address_16_19 : 4; - CARD8 : 4; - } _extended_system_control_3_s; - CARD8 _extended_system_control_3; /* CR69 */ - } _extended_system_control_3_u; -#define extended_system_control_3 _extended_system_control_3_u._extended_system_control_3 -#define start_address_16_19 _extended_system_control_3_u._extended_system_control_3_s._start_address_16_19 - - CARD8 extended_bios_5; /* CR6D */ - - union { - struct { - CARD8 dot_clock_vclki : 1; /* testing only */ - CARD8 vclki_with_vafc : 1; /* feature connector */ - CARD8 : 1; - CARD8 bpp_24_mode : 1; /* 24 bpp mode */ - CARD8 alt_color_mode : 4; /* feature connector mode */ - } _extended_sequencer_b_s; - CARD8 _extended_sequencer_b; /* SRB */ - } _extended_sequencer_b_u; - -#define extended_sequencer_b _extended_sequencer_b_u._extended_sequencer_b - - union extended_sequencer_d_u { - struct { - CARD8 enable_feature : 1; - CARD8 lpb_feature : 1; - CARD8 : 2; - CARD8 _hsync_control : 2; - CARD8 _vsync_control : 2; - } _extended_sequencer_d_s; - CARD8 _extended_sequencer_d; - } _extended_sequencer_d_u; - -#define extended_sequencer_d _extended_sequencer_d_u._extended_sequencer_d -#define hsync_control _extended_sequencer_d_u._extended_sequencer_d_s._hsync_control -#define vsync_control _extended_sequencer_d_u._extended_sequencer_d_s._vsync_control - - union { - struct { - CARD8 _dclk_pll_n : 5; - CARD8 _dclk_pll_r : 2; - CARD8 : 1; - } _dclk_value_low_s; - CARD8 _dclk_value_low; /* SR12 */ - } _dclk_value_low_u; - -#define dclk_value_low _dclk_value_low_u._dclk_value_low -#define dclk_pll_n_trio _dclk_value_low_u._dclk_value_low_s._dclk_pll_n -#define dclk_pll_r_trio _dclk_value_low_u._dclk_value_low_s._dclk_pll_r - - union { - struct { - CARD8 _dclk_pll_m : 7; - CARD8 : 1; - } _dclk_value_high_s; - CARD8 _dclk_value_high; /* SR13 */ - } _dclk_value_high_u; - -#define dclk_value_high _dclk_value_high_u._dclk_value_high -#define dclk_pll_m_trio _dclk_value_high_u._dclk_value_high_s._dclk_pll_m - - union { - struct { - CARD8 _mfrq_en : 1; - CARD8 _dfrq_en : 1; - CARD8 _mclk_out : 1; - CARD8 _vclk_out : 1; - CARD8 _dclk_over_2 : 1; - CARD8 _clk_load : 1; - CARD8 _dclk_invert : 1; - CARD8 _ena_2_cycle_write : 1; - } _control_2_s; - CARD8 _control_2; /* SR15 */ - } _control_2_u; - -#define control_2 _control_2_u._control_2 -#define mfrq_en _control_2_u._control_2_s._mfrq_en -#define dfrq_en _control_2_u._control_2_s._dfrq_en -#define mclk_out _control_2_u._control_2_s._mclk_out -#define vclk_out _control_2_u._control_2_s._vclk_out -#define dclk_over_2 _control_2_u._control_2_s._dclk_over_2 -#define clk_load _control_2_u._control_2_s._clk_load -#define dclk_invert _control_2_u._control_2_s._dclk_invert -#define ena_2_cycle_write _control_2_u._control_2_s._ena_2_cycle_write - - union { - struct { - CARD8 : 5; - CARD8 _dac_power_down : 1; - CARD8 _lut_write_control : 1; - CARD8 _enable_clock_double : 1; - } _ramdac_control_s; - CARD8 _ramdac_control; /* SR18 */ - } _ramdac_control_u; - -#define ramdac_control _ramdac_control_u._ramdac_control -#define enable_clock_double _ramdac_control_u._ramdac_control_s._enable_clock_double - - union { - struct { - CARD8 _dclk_pll_n : 6; - CARD8 _dclk_pll_r : 2; - } _dclk_value_low_s; - CARD8 _dclk_value_low; /* SR36 */ - } _dclk_value_low_savage_u; - -#define dclk_value_low_savage _dclk_value_low_savage_u._dclk_value_low -#define dclk_pll_n_savage_0_5 _dclk_value_low_savage_u._dclk_value_low_s._dclk_pll_n -#define dclk_pll_r_savage_0_1 _dclk_value_low_savage_u._dclk_value_low_s._dclk_pll_r - - CARD8 dclk_pll_m0_savage_0_7; /* SR37 */ - CARD8 dclk_pll_m1_savage_0_7; /* SR38 */ - - struct { - CARD8 _dclk_pll_m : 8; - } _dclk_value_high_s_savage; - - union { - struct { - CARD8 _dclk_select : 1; - CARD8 : 1; - CARD8 _dclk_pll_r_2 : 1; - CARD8 _dclk_pll_m_8 : 1; - CARD8 _dclk_pll_n_6 : 1; - CARD8 _pce : 1; - CARD8 _ccg : 1; - CARD8 _csp : 1; - } _extended_seq_39_s; - CARD8 _extended_seq_39; /* SR39 */ - } _extended_seq_39_u; - -#define extended_seq_39 _extended_seq_39_u._extended_seq_39 -#define dclk_pll_select_savage _extended_seq_39_u._extended_seq_39_s._dclk_select -#define dclk_pll_r_savage_2 _extended_seq_39_u._extended_seq_39_s._dclk_pll_r_2 -#define dclk_pll_m_savage_8 _extended_seq_39_u._extended_seq_39_s._dclk_pll_m_8 -#define dclk_pll_n_savage_6 _extended_seq_39_u._extended_seq_39_s._dclk_pll_n_6 - - /* computed values */ - CARD16 ge_screen_pitch; - CARD8 bits_per_pixel; - CARD8 depth; - CARD8 double_pixel_mode; - CARD16 pixel_width; -} S3Crtc; - -#define crtc_v_total(crtc) ((crtc)->v_total_0_7 | \ - ((crtc)->v_total_8 << 8) | \ - ((crtc)->v_total_9 << 9) | \ - ((crtc)->v_total_10 << 10)) - -#define crtc_set_v_total(crtc,v) { \ - ((crtc))->v_total_0_7 = (v); \ - ((crtc))->v_total_8 = (v) >> 8; \ - ((crtc))->v_total_9 = (v) >> 9; \ - ((crtc))->v_total_10 = (v) >> 10; \ -} - -#define crtc_v_display_end(crtc) ((crtc)->v_display_end_0_7 | \ - ((crtc)->v_display_end_8 << 8) | \ - ((crtc)->v_display_end_9 << 9) | \ - ((crtc)->v_display_end_10 << 10)) - -#define crtc_set_v_display_end(crtc,v) {\ - ((crtc))->v_display_end_0_7 = (v); \ - ((crtc))->v_display_end_8 = (v) >> 8; \ - ((crtc))->v_display_end_9 = (v) >> 9; \ - ((crtc))->v_display_end_10 = (v) >> 10; \ -} - -#define crtc_v_retrace_start(crtc) ((crtc)->v_retrace_start_0_7 | \ - ((crtc)->v_retrace_start_8 << 8) | \ - ((crtc)->v_retrace_start_9 << 9) | \ - ((crtc)->v_retrace_start_10 << 10)) - -#define crtc_set_v_retrace_start(crtc,v) {\ - ((crtc))->v_retrace_start_0_7 = (v); \ - ((crtc))->v_retrace_start_8 = (v) >> 8; \ - ((crtc))->v_retrace_start_9 = (v) >> 9; \ - ((crtc))->v_retrace_start_10 = (v) >> 10; \ -} - -#define crtc_v_blank_start(crtc) ((crtc)->v_blank_start_0_7 | \ - ((crtc)->v_blank_start_8 << 8) | \ - ((crtc)->v_blank_start_9 << 9) | \ - ((crtc)->v_blank_start_10 << 10)) - -#define crtc_set_v_blank_start(crtc,v) {\ - ((crtc))->v_blank_start_0_7 = (v); \ - ((crtc))->v_blank_start_8 = (v) >> 8; \ - ((crtc))->v_blank_start_9 = (v) >> 9; \ - ((crtc))->v_blank_start_10 = (v) >> 10; \ -} - -#define crtc_h_total(crtc) ((crtc)->h_total_0_7 | \ - ((crtc)->h_total_8 << 8)) - -#define crtc_set_h_total(crtc,v) {\ - ((crtc))->h_total_0_7 = (v); \ - ((crtc))->h_total_8 = (v) >> 8; \ -} - -#define crtc_h_display_end(crtc) ((crtc)->h_display_end_0_7 | \ - ((crtc)->h_display_end_8 << 8)) - -#define crtc_set_h_display_end(crtc,v) {\ - ((crtc))->h_display_end_0_7 = (v); \ - ((crtc))->h_display_end_8 = (v) >> 8; \ -} - -#define crtc_h_blank_start(crtc) ((crtc)->h_blank_start_0_7 | \ - ((crtc)->h_blank_start_8 << 8)) - -#define crtc_set_h_blank_start(crtc,v) {\ - ((crtc))->h_blank_start_0_7 = (v); \ - ((crtc))->h_blank_start_8 = (v) >> 8; \ -} - -#define crtc_h_blank_end(crtc) ((crtc)->h_blank_end_0_4 | \ - ((crtc)->h_blank_end_5 << 5)) - -#define crtc_set_h_blank_end(crtc,v) {\ - ((crtc))->h_blank_end_0_4 = (v); \ - ((crtc))->h_blank_end_5 = (v) >> 5; \ -} - -#define crtc_h_sync_start(crtc) ((crtc)->h_sync_start_0_7 | \ - ((crtc)->h_sync_start_8 << 8)) - -#define crtc_set_h_sync_start(crtc,v) {\ - ((crtc))->h_sync_start_0_7 = (v); \ - ((crtc))->h_sync_start_8 = (v) >> 8; \ -} - -#define crtc_h_sync_end(crtc) ((crtc)->h_sync_end_0_4) - -#define crtc_set_h_sync_end(crtc,v) {\ - ((crtc))->h_sync_end_0_4 = (v); \ -} - -#define crtc_screen_off(crtc) ((crtc)->screen_off_0_7 | \ - (((crtc)->screen_off_8_9 ? \ - ((crtc))->screen_off_8_9 : \ - ((crtc))->old_screen_off_8) << 8)) - -#define crtc_set_screen_off(crtc,v) {\ - ((crtc))->screen_off_0_7 = (v); \ - ((crtc))->old_screen_off_8 = 0; \ - ((crtc))->screen_off_8_9 = (v) >> 8; \ -} - -#define crtc_ge_screen_width(crtc) ((crtc)->ge_screen_width_0_1 | \ - ((crtc)->ge_screen_width_2 << 2)) - -#define crtc_set_ge_screen_width(crtc,v) { \ - (crtc)->ge_screen_width_0_1 = (v); \ - (crtc)->ge_screen_width_2 = (v) >> 2; \ -} - -#define crtc_h_start_fifo_fetch(crtc) ((crtc)->h_start_fifo_fetch_0_7 | \ - ((crtc)->h_start_fifo_fetch_8 << 8)) - -#define crtc_set_h_start_fifo_fetch(crtc,v) {\ - (crtc)->h_start_fifo_fetch_0_7 = (v); \ - (crtc)->h_start_fifo_fetch_8 = (v) >> 8; \ -} - -#define crtc_start_address(crtc) ((crtc)->start_address_0_7 | \ - ((crtc)->start_address_8_15 << 8) | \ - ((crtc)->start_address_16_19 << 16)) - -#define crtc_set_start_address(crtc,v) {\ - (crtc)->start_address_0_7 = (v); \ - (crtc)->start_address_8_15 = (v) >> 8; \ - (crtc)->start_address_16_19 = (v) >> 16; \ -} - -#define crtc_line_compare(crtc) ((crtc)->line_compare_0_7 | \ - ((crtc)->line_compare_8 << 8) | \ - ((crtc)->line_compare_9 << 9) | \ - ((crtc)->line_compare_10 << 10)) - -#define crtc_set_line_compare(crtc,v) { \ - ((crtc))->line_compare_0_7 = (v); \ - ((crtc))->line_compare_8 = (v) >> 8; \ - ((crtc))->line_compare_9 = (v) >> 9; \ - ((crtc))->line_compare_10 = (v) >> 10; \ -} - - -#define GetCrtc(s3,i) _s3ReadIndexRegister (&(s3)->crt_vga_3d4, (i)) -#define PutCrtc(s3,i,v) _s3WriteIndexRegister (&(s3)->crt_vga_3d4, (i), (v)) - -#define GetSrtc(s3,i) _s3ReadIndexRegister (&(s3)->crt_vga_3c4, (i)) -#define PutSrtc(s3,i,v) _s3WriteIndexRegister (&(s3)->crt_vga_3c4, (i), (v)) - -#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 _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; - S3Crtc crtc; -} 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 */ - S3Save save; - Bool savage; - Bool need_sync; -} S3CardInfo; - -typedef struct _s3FbInfo { - 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 */ - S3Patterns patterns; - CARD32 bitmap_offset; - int accel_stride; - int accel_bpp; -} S3FBInfo; - -typedef struct _s3ScreenInfo { - CARD8 *cursor_base; /* pointer to cursor area */ - S3Cursor cursor; - S3FBInfo fb[1]; -} S3ScreenInfo; - -#define LockS3(s3c) -#define UnlockS3(s3c) - -#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 *); -Bool 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 s3DrawSync (ScreenPtr pScreen); -void s3DrawDisable (ScreenPtr pScreen); -void s3DrawFini (ScreenPtr pScreen); - -void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); -void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); - -void S3InitCard (KdCardAttr *attr); - -void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR); - -CARD8 _s3ReadIndexRegister (VOL8 *base, CARD8 index); -void _s3WriteIndexRegister (VOL8 *base, CARD8 index, CARD8 value); - -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 _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; \ -} - -/* - * This extension register must contain a magic bit pattern to enable - * the remaining extended registers - */ - -#define _s3UnlockExt(s3) _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x39, 0xa0) -#define _s3LockExt(s3) _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x39, 0x00) - -#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 - -#endif /* _S3_H_ */ diff --git a/hw/kdrive/trio/s3clock.c b/hw/kdrive/trio/s3clock.c deleted file mode 100644 index f79dfa92d..000000000 --- a/hw/kdrive/trio/s3clock.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Id: s3clock.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3clock.c,v 1.2 1999/12/30 03:03:19 robin Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 (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; -} diff --git a/hw/kdrive/trio/s3cmap.c b/hw/kdrive/trio/s3cmap.c deleted file mode 100644 index 19e192ed0..000000000 --- a/hw/kdrive/trio/s3cmap.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Id: s3cmap.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3cmap.c,v 1.1 1999/11/19 13:54:05 hohndel Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" - -void -s3GetColors (ScreenPtr pScreen, int fb, 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 fb, 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); -} - diff --git a/hw/kdrive/trio/s3curs.c b/hw/kdrive/trio/s3curs.c deleted file mode 100644 index 9416b4398..000000000 --- a/hw/kdrive/trio/s3curs.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Id: s3curs.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3curs.c,v 1.2 1999/12/30 03:03:19 robin Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "s3.h" -#include "s3draw.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; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].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 long *ram; - unsigned long *msk, *mskLine, *src, *srcLine; - unsigned long 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 long *) s3s->cursor_base; - mskLine = (unsigned long *) bits->mask; - srcLine = (unsigned long *) bits->source; - - h = bits->height; - if (h > S3_CURSOR_HEIGHT) - h = S3_CURSOR_HEIGHT; - - wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */ - - for (i = 0; i < S3_CURSOR_HEIGHT; i++) - { - msk = mskLine; - src = srcLine; - mskLine += wsrc; - srcLine += wsrc; - for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) { - - unsigned long m, s; - - if (i < h && j < wsrc) - { - m = *msk++; - s = *src++; - xor = m & s; - and = ~m; - } - else - { - and = 0xffffffff; - xor = 0x00000000; - } - - S3AdjustBits32(and); - S3AdjustBits32(xor); - *ram++ = (and & 0xffff) | (xor << 16); - *ram++ = (and >> 16) | (xor & 0xffff0000); - } - } - - _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) - { -#ifdef FB_OLD_SCREEN - short x, y; -#else - int x, y; -#endif - - 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) - { -#ifdef FB_OLD_SCREEN - short x, y; -#else - int x, y; -#endif - - 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; -} diff --git a/hw/kdrive/trio/s3stub.c b/hw/kdrive/trio/s3stub.c deleted file mode 100644 index 80d8fd56a..000000000 --- a/hw/kdrive/trio/s3stub.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Id: s3stub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trio/s3stub.c,v 1.3 2000/02/23 20:30:13 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/ts300/Imakefile b/hw/kdrive/ts300/Imakefile deleted file mode 100644 index 329b4825b..000000000 --- a/hw/kdrive/ts300/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $ -XCOMM $RCSId: xc/programs/Xserver/hw/nvfb/Imakefile,v 3.8 1996/12/23 06:30:19 dawes Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = ts300.c - -OBJS = ts300.o - -INCLUDES = -I. $(KDINCS) -I../trio -I../sis530 - -NormalLibraryObjectRule() -NormalLibraryTarget(ts300,$(OBJS)) -DependTarget() diff --git a/hw/kdrive/ts300/ts300.c b/hw/kdrive/ts300/ts300.c deleted file mode 100644 index bd239d9fa..000000000 --- a/hw/kdrive/ts300/ts300.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Id: ts300.c,v 1.1 1999/11/02 08:17:24 keithp Exp $ - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/ts300/ts300.c,v 1.3 2000/02/23 20:30:14 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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 (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - return KdProcessArgument (argc, argv, i); -} diff --git a/hw/kdrive/vesa/Imakefile b/hw/kdrive/vesa/Imakefile deleted file mode 100644 index 785ef9927..000000000 --- a/hw/kdrive/vesa/Imakefile +++ /dev/null @@ -1,14 +0,0 @@ -XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/vesa/Imakefile,v 1.2 2000/09/03 05:11:22 keithp Exp $ -KDRIVE=.. -#include "../Kdrive.tmpl" - -SRCS = vesa.c vesainit.c vbe.c vga.c vm86.c - -OBJS = vesa.o vesainit.o vbe.o vga.o vm86.o - -INCLUDES = -I. $(KDINCS) - -NormalLibraryObjectRule() -NormalLibraryTarget(vesa,$(OBJS)) -InstallManPage(Xvesa,$(MANDIR)) -DependTarget() diff --git a/hw/kdrive/vesa/Makefile.am b/hw/kdrive/vesa/Makefile.am deleted file mode 100644 index bdcb10c0e..000000000 --- a/hw/kdrive/vesa/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - @XSERVER_CFLAGS@ - -noinst_LIBRARIES = libvesa.a - -bin_PROGRAMS = Xvesa - -if TSLIB -TSLIB_FLAG = -lts -endif - - -libvesa_a_SOURCES = \ - vesa.c \ - vesa.h \ - vbe.c \ - vbe.h \ - vga.c \ - vga.h \ - vm86.c \ - vm86.h - -Xvesa_SOURCES = \ - vesainit.c - -Xvesa_LDADD = \ - libvesa.a \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - -Xvesa_DEPENDENCIES = \ - libvesa.a \ - @KDRIVE_LIBS@ diff --git a/hw/kdrive/vesa/Xvesa.man b/hw/kdrive/vesa/Xvesa.man deleted file mode 100644 index fdac902ca..000000000 --- a/hw/kdrive/vesa/Xvesa.man +++ /dev/null @@ -1,101 +0,0 @@ -.\" $RCSId: xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man,v 1.5 2001/01/24 00:06:10 dawes Exp $ -.TH Xvesa 1 __vendorversion__ -.SH NAME -Xvesa \- VESA Bios Extensions tiny X server -.SH SYNOPSIS -.B Xvesa -.RI [ :display ] -.RI [ option ...] -.SH DESCRIPTION -.B Xvesa -is a generic X server for Linux on the x86 platform. -.B Xvesa -doesn't know about any particular hardware, and sets the video mode by -running the video BIOS in VM86 mode. -.B Xvesa -can use both standard VGA BIOS modes and any modes advertised by a -VESA BIOS if available. - -.B Xvesa -runs untrusted code with full privileges, and is therefore a fairly -insecure X server. -.B Run at your own risk. -.SH OPTIONS -In addition to the normal KDrive server's options (see Xkdrive(1)), -.B Xvesa -accepts the following command line switches: -.TP 8 -.B -mode \fIn\fB -specifies the VESA video mode to use. If mode -.I n -is not supported by your BIOS and hardware, -.B Xvesa -will fail, hang your system, damage your hardware, or cause a global -thermonuclear war; you are on your own. This option overrides any -.B -screen -options. -.TP 8 -.B -listmodes -list all supported video modes. If -.B -force -was specified before -.BR -listmodes , -lists all the modes that your BIOS claims to support, even those that -the -.B Xvesa -server won't be able to use. -.TP 8 -.B -force -disable some sanity checks and use the specified mode even if the -BIOS claims not to support it. -.TP 8 -.B -shadow -use a shadow framebuffer even if it is not strictly necessary. This -may dramatically improve performance on some hardware. -.TP 8 -.B -nolinear -don't use a linear framebuffer even if one is available. You don't -want to use this option. -.TP 8 -.B -swaprgb -pass RGB values in the order that works on broken BIOSes. Use this if -the colours are wrong in PseudoColor and 16 colour modes. -.TP 8 -.B -map-holes -use a contiguous (hole-less) memory map. This fixes a segmentation -violation with some rare BIOSes that violate the VESA specification, -but may cause slightly higher memory usage on systems that overcommit -memory. -.TP 8 -.B -verbose -emit diagnostic messages during BIOS initialization and teardown. -.SH KEYBOARD -Multiple key presses recognized directly by -.B Xvesa -are: -.TP 8 -.B Ctrl+Alt+Backspace -Immediately kill the server. -.TP 8 -.B Ctrl+Alt+F1...F12 -Switch to virtual console 1 through 12. -.SH BUGS -.B Xvesa -opens all IO ports and runs your VESA BIOS, which may be assumed to be -buggy. Allowing your users to run -.B Xvesa -is probably a security hole. - -.B Xvesa -records the current BIOS mode when it starts and restores that mode on -termination; if the video card has been reprogrammed by another application, -the display will almost certainly be trashed. The alternative of saving and -restoring the complete video card state has proven unreliable on most video -cards. -.SH SEE ALSO -X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1). -.SH AUTHORS -The VESA driver was written by Juliusz Chroboczek who didn't realise -what he was doing until it was too late. Keith Packard then added -support for standard VGA BIOS modes and is especially proud of 320x200 -16 colour mode. diff --git a/hw/kdrive/vesa/vbe.c b/hw/kdrive/vesa/vbe.c deleted file mode 100644 index 4bcedf08d..000000000 --- a/hw/kdrive/vesa/vbe.c +++ /dev/null @@ -1,679 +0,0 @@ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.9 2001/05/29 04:54:12 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vesa.h" - -int -VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib) -{ - int code; - int mark; - int vib_base; - VbeInfoBlock *vib_low; - - mark = Vm86MarkMemory (vi); - vib_base = Vm86AllocateMemory (vi, sizeof (VbeInfoBlock)); - vib_low = (VbeInfoBlock*)&(LM(vi, vib_base)); - vi->vms.regs.eax = 0x4F00; - vi->vms.regs.es = POINTER_SEGMENT(vib_base); - vi->vms.regs.edi = POINTER_OFFSET(vib_base); - memcpy(vib_low->VbeSignature, "VBE2", 4); - code = VbeDoInterrupt10(vi); - if(code >= 0) - { - if(memcmp(vib_low->VbeSignature, "VESA", 4) == 0) - *vib = *vib_low; - else - code = -1; - } - Vm86ReleaseMemory (vi, mark); - return code; -} - -int -VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib) -{ - int code; - int mark; - int vmib_base; - VbeModeInfoBlock *vmib_low; - - mark = Vm86MarkMemory (vi); - - vmib_base = Vm86AllocateMemory (vi, sizeof (VbeModeInfoBlock)); - vmib_low = (VbeModeInfoBlock*)&(LM(vi, vmib_base)); - - vi->vms.regs.eax = 0x4F01; - vi->vms.regs.ecx = mode&0xFFFF; - vi->vms.regs.es = POINTER_SEGMENT(vmib_base); - vi->vms.regs.edi = POINTER_OFFSET(vmib_base); - code = VbeDoInterrupt10(vi); - - if(code >= 0) - *vmib = *vmib_low; - Vm86ReleaseMemory (vi, mark); - return code; -} - -static int -VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib) -{ - U32 i, p; - unsigned char c; - int error = 0; - - ErrorF("VBE version %c.%c (", - ((vib->VbeVersion >> 8) & 0xFF) + '0', - (vib->VbeVersion & 0xFF)+'0'); - p = vib->OemStringPtr; - for(i = 0; 1; i++) { - c = Vm86Memory(vi, MAKE_POINTER_1(p+i)); - if(!c) break; - if (c >= ' ') - ErrorF("%c", c); - if (i > 32000) { - error = 1; - break; - } - } - ErrorF(")\n"); - ErrorF("DAC is %s, controller is %sVGA compatible%s\n", - (vib->Capabilities[0]&1)?"fixed":"switchable", - (vib->Capabilities[0]&2)?"not ":"", - (vib->Capabilities[0]&3)?", RAMDAC causes snow":""); - ErrorF("Total memory: %lu kilobytes\n", 64L*vib->TotalMemory); - if(error) - return -1; - return 0; -} - -#if 0 -static int -VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib) -{ - int supported = (vmib->ModeAttributes&0x1)?1:0; - int colour = (vmib->ModeAttributes&0x8)?1:0; - int graphics = (vmib->ModeAttributes&0x10)?1:0; - int vga_compatible = !((vmib->ModeAttributes&0x20)?1:0); - int linear_fb = (vmib->ModeAttributes&0x80)?1:0; - - ErrorF("0x%04X: %dx%dx%d%s", - (unsigned)mode, - (int)vmib->XResolution, (int)vmib->YResolution, - (int)vmib->BitsPerPixel, - colour?"":" (monochrome)", - graphics?"":" (graphics)", - vga_compatible?"":" (vga compatible)", - linear_fb?"":" (linear frame buffer)"); - switch(vmib->MemoryModel) { - case 0: - ErrorF(" text mode (%dx%d)", - (int)vmib->XCharSize, (int)vmib->YCharSize); - break; - case 1: - ErrorF(" CGA graphics"); - break; - case 2: - ErrorF(" Hercules graphics"); - break; - case 3: - ErrorF(" Planar (%d planes)", vmib->NumberOfPlanes); - break; - case 4: - ErrorF(" PseudoColor"); - break; - case 5: - ErrorF(" Non-chain 4, 256 colour"); - break; - case 6: - if(vmib->DirectColorModeInfo & 1) - ErrorF(" DirectColor"); - else - ErrorF(" TrueColor"); - ErrorF(" [%d:%d:%d:%d]", - vmib->RedMaskSize, vmib->GreenMaskSize, vmib->BlueMaskSize, - vmib->RsvdMaskSize); - if(vmib->DirectColorModeInfo & 2) - ErrorF(" (reserved bits are reserved)"); - break; - case 7: ErrorF("YUV"); - break; - default: - ErrorF("unknown MemoryModel 0x%X ", vmib->MemoryModel); - } - if(!supported) - ErrorF(" (unsupported)"); - else if(!linear_fb) - ErrorF(" (no linear framebuffer)"); - ErrorF("\n"); - return 0; -} -#endif - -void -VbeReportInfo (Vm86InfoPtr vi) -{ - VbeInfoBlock vib; - int code; - - code = VbeGetVib (vi, &vib); - if (code >= 0) - VbeReportVib(vi, &vib); -} - -int -VbeGetNmode (Vm86InfoPtr vi) -{ - VbeInfoBlock vib; - int code; - unsigned int p; - int n; - int mode; - - code = VbeGetVib (vi, &vib); - if (code >= 0) - { - p = MAKE_POINTER_1(vib.VideoModePtr); - for (n = 0; ; n++) - { - mode = Vm86MemoryW(vi, p); - if (mode == 0xffff) - break; - p += 2; - } - code = n; - } - return code; -} - -int -VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode) -{ - VbeInfoBlock vib; - int code; - unsigned int p; - int n; - int mode; - VbeModeInfoBlock vmib; - - code = VbeGetVib (vi, &vib); - if (code < 0) - return code; - - memset (modes, '\0', nmode * sizeof (VesaModeRec)); - - p = MAKE_POINTER_1(vib.VideoModePtr); - for (n = 0; n < nmode; n++) - { - mode = Vm86MemoryW(vi, p); - if (mode == 0xffff) - break; - modes[n].mode = mode; - modes[n].vbe = 1; - p += 2; - } - - nmode = n; - - for (n = 0; n < nmode; n++) - { - code = VbeGetVmib (vi, modes[n].mode, &vmib); - if (code >= 0) - { - modes[n].ModeAttributes = vmib.ModeAttributes; - modes[n].NumberOfPlanes = vmib.NumberOfPlanes; - modes[n].BitsPerPixel = vmib.BitsPerPixel; - modes[n].MemoryModel = vmib.MemoryModel; - modes[n].RedMaskSize = vmib.RedMaskSize; - modes[n].RedFieldPosition = vmib.RedFieldPosition; - modes[n].GreenMaskSize = vmib.GreenMaskSize; - modes[n].GreenFieldPosition = vmib.GreenFieldPosition; - modes[n].BlueMaskSize = vmib.BlueMaskSize; - modes[n].BlueFieldPosition = vmib.BlueFieldPosition; - modes[n].RsvdMaskSize = vmib.RsvdMaskSize; - modes[n].RsvdFieldPosition = vmib.RsvdFieldPosition; - modes[n].DirectColorModeInfo = vmib.DirectColorModeInfo; - modes[n].XResolution = vmib.XResolution; - modes[n].YResolution = vmib.YResolution; - modes[n].BytesPerScanLine = vmib.BytesPerScanLine; - } - } - - return nmode; -} - -VbeInfoPtr -VbeInit (Vm86InfoPtr vi) -{ - VbeInfoPtr vbe; - int code; - VbeInfoBlock vib; - - code = VbeGetVib (vi, &vib); - if (code < 0) - return 0; - - vbe = xalloc (sizeof (VbeInfoRec)); - if (!vbe) - return 0; - vbe->palette_format = 6; - vbe->palette_wait = TRUE; - return vbe; -} - -void -VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe) -{ - xfree (vbe); -} - -int -VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear, int direct) -{ - int code; - VbeInfoBlock vib; - int palette_wait = 0, palette_hi = 0; - - code = VbeGetVib (vi, &vib); - if (code < 0) - return -1; - - code = VbeGetVmib (vi, mode, &vbe->vmib); - if (code < 0) - return -1; - - mode = (mode & 0xffff) &~ 0x8000; - if (linear) - mode |= 0x4000; - - vi->vms.regs.eax = 0x4F02; - vi->vms.regs.ebx = mode; - code = VbeDoInterrupt10(vi); - if(code < 0) - return -1; - - vbe->windowA_offset = vbe->windowB_offset = -1; - vbe->last_window = 1; - - if (!direct) - { - if(vib.Capabilities[0] & 1) - palette_hi = 1; - if(vib.Capabilities[0] & 4) - palette_wait = 1; - - if(palette_hi || palette_wait) - VbeSetPaletteOptions(vi, vbe, palette_hi?8:6, palette_wait); - } - - return 0; -} - -int -VbeGetMode(Vm86InfoPtr vi, int *mode) -{ - int code; - - vi->vms.regs.eax = 0x4F03; - code = VbeDoInterrupt10(vi); - if(code < 0) - return - 1; - *mode = vi->vms.regs.ebx & 0xFFFF; - return 0; -} - -void * -VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys) -{ - U8 *fb; - VbeInfoBlock vib; - VbeModeInfoBlock vmib; - int size; - int pagesize = getpagesize(); - int before, after; - - if (VbeGetVib (vi, &vib) < 0) - return 0; - - if (VbeGetVmib (vi, mode, &vmib) < 0) - return 0; - - size = 1024 * 64L * vib.TotalMemory; - - *ret_size = size; - *ret_phys = vmib.PhysBasePtr; - - before = vmib.PhysBasePtr % pagesize; - after = pagesize - ((vmib.PhysBasePtr + size) % pagesize); - if(after == pagesize) - after = 0; - - fb = KdMapDevice (vmib.PhysBasePtr - before, before + size + after); - - if(fb == 0) - { - ErrorF("Failed to map framebuffer\n"); - return NULL; - } - - KdSetMappedMode (vmib.PhysBasePtr - before, before + size + after, - KD_MAPPED_MODE_FRAMEBUFFER); - - return fb + before; -} - -void -VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb) -{ - VbeInfoBlock vib; - VbeModeInfoBlock vmib; - int size; - int pagesize = getpagesize(); - int before, after; - - if (VbeGetVib (vi, &vib) < 0) - return; - - if (VbeGetVmib (vi, mode, &vmib) < 0) - return; - - size = 1024 * 64L * vib.TotalMemory; - - before = vmib.PhysBasePtr % pagesize; - after = pagesize - ((vmib.PhysBasePtr + size) % pagesize); - if(after == pagesize) - after = 0; - - fb = (void *) ((char *) fb - before); - - KdUnmapDevice (fb, before + size + after); - KdResetMappedMode (vmib.PhysBasePtr - before, before + size + after, - KD_MAPPED_MODE_FRAMEBUFFER); -} - -int -VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries) -{ - U8 *palette_scratch; - int mark; - int palette_base; - int i, code; - - if(number == 0) - return 0; - - if(first < 0 || number < 0 || first + number > 256) { - ErrorF("Cannot set %d, %d palette entries\n", first, number); - return -1; - } - if(vbe->palette_format < 6 || vbe->palette_format > 8) { - ErrorF("Impossible palette format %d\n", vbe->palette_format); - return -1; - } - - mark = Vm86MarkMemory (vi); - palette_base = Vm86AllocateMemory (vi, 4 * 256); - - palette_scratch = &LM(vi, palette_base); - - for(i=0; i<number*4; i++) - palette_scratch[i] = entries[i] >> (8 - vbe->palette_format); - - vi->vms.regs.eax = 0x4F09; - if(vbe->palette_wait) - vi->vms.regs.ebx = 0x80; - else - vi->vms.regs.ebx = 0x00; - vi->vms.regs.ecx = number; - vi->vms.regs.edx = first; - vi->vms.regs.es = POINTER_SEGMENT(palette_base); - vi->vms.regs.edi = POINTER_OFFSET(palette_base); - code = VbeDoInterrupt10(vi); - Vm86ReleaseMemory (vi, mark); - - if(code < 0) - return -1; - return 0; -} - -int -VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries) -{ - U8 *palette_scratch; - int mark; - int palette_base; - int i, code; - - if(number == 0) - return 0; - - if(first < 0 || number < 0 || first + number > 256) { - ErrorF("Cannot get %d, %d palette entries\n", first, number); - return -1; - } - if(vbe->palette_format < 6 || vbe->palette_format > 8) { - ErrorF("Impossible palette format %d\n", vbe->palette_format); - return -1; - } - - mark = Vm86MarkMemory (vi); - palette_base = Vm86AllocateMemory (vi, 4 * 256); - - palette_scratch = &LM(vi, palette_base); - - vi->vms.regs.eax = 0x4F09; - vi->vms.regs.ebx = 0x01; - vi->vms.regs.ecx = number; - vi->vms.regs.edx = first; - vi->vms.regs.es = POINTER_SEGMENT(palette_base); - vi->vms.regs.edi = POINTER_OFFSET(palette_base); - code = VbeDoInterrupt10(vi); - if(code >= 0) - { - for(i=0; i<number*4; i++) - entries[i] = palette_scratch[i] << (8-vbe->palette_format); - } - Vm86ReleaseMemory (vi, mark); - - return 0; -} - -int -VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait) -{ - int code; - - if(bits < 6 || bits > 8) { - ErrorF("Impossible palette format %d\n", bits); - return -1; - } - if(bits != vbe->palette_format) - { - vbe->palette_format = 0; - vi->vms.regs.eax = 0x4F08; - vi->vms.regs.ebx = bits << 8; - code = VbeDoInterrupt10(vi); - if(code < 0) - return -1; - vbe->palette_format = bits; - } - vbe->palette_wait = wait; - return 0; -} - -static int -VbeReallySetWindow(Vm86InfoPtr vi, U8 window, U16 winnum) -{ - int code; - vi->vms.regs.eax = 0x4F05; - vi->vms.regs.ebx = window; - vi->vms.regs.edx = winnum; - code = VbeDoInterrupt10(vi); - if(code < 0) - return -1; - return 0; -} - -void * -VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return) -{ - int window_size = vbe->vmib.WinSize * 1024; - int code; - int winnum; - - if(vbe->windowA_offset >= 0) - if(vbe->windowA_offset <= offset && vbe->windowA_offset + window_size > offset) - if(vbe->vmib.WinAAttributes & purpose) - goto windowA; - - if(vbe->windowB_offset >= 0) - if(vbe->windowB_offset <= offset && vbe->windowB_offset + window_size > offset) - if(vbe->vmib.WinBAttributes & purpose) - goto windowB; - - if(!(vbe->vmib.WinBAttributes & purpose) || - !(vbe->vmib.WinBAttributes & VBE_WINDOW_RELOCATE)) - goto set_windowA; - - if(!(vbe->vmib.WinAAttributes & purpose) || - !(vbe->vmib.WinAAttributes & VBE_WINDOW_RELOCATE)) - goto set_windowB; - - if(vbe->last_window) - goto set_windowA; - else - goto set_windowB; - -set_windowA: - winnum = offset / (vbe->vmib.WinGranularity * 1024); - code = VbeReallySetWindow(vi, 0, winnum); - if(code < 0) { - ErrorF("Couldn't set window A to %d*%d\n", - (int)winnum, (int)vbe->vmib.WinGranularity); - return NULL; - } - vbe->windowA_offset = winnum * vbe->vmib.WinGranularity * 1024; -windowA: - vbe->last_window = 0; - *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowA_offset); - return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinASegment, 0)))) + offset - vbe->windowA_offset; - -set_windowB: - winnum = offset / (vbe->vmib.WinGranularity * 1024); - code = VbeReallySetWindow(vi, 1, winnum); - if(code < 0) { - ErrorF("Couldn't set window B to %d*%d\n", - (int)winnum, (int)vbe->vmib.WinGranularity); - return NULL; - } - vbe->windowB_offset = winnum * vbe->vmib.WinGranularity * 1024; -windowB: - vbe->last_window = 1; - *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowB_offset); - return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset; -} - -static const int VbeDPMSModes[4] = { - 0x00, /* KD_DPMS_NORMAL */ - 0x01, /* KD_DPMS_STANDBY */ - 0x02, /* KD_DPMS_SUSPEND */ - 0x04, /* KD_DPMS_POWERDOWN */ -}; - -Bool -VbeDPMS(Vm86InfoPtr vi, int mode) -{ - int code; - - /* - * Check which modes are supported - */ - vi->vms.regs.eax = 0x4f10; - vi->vms.regs.ebx = 0x0000; - vi->vms.regs.es = 0; - vi->vms.regs.edi = 0; - code = VbeDoInterrupt10 (vi); - if (code < 0) - { - ErrorF ("No DPMS Support %d\n", code); - return FALSE; - } - /* Skip this stage if it's not supported */ - if (((vi->vms.regs.ebx >> 4) & VbeDPMSModes[mode]) != VbeDPMSModes[mode]) - return FALSE; - - /* Select this mode */ - vi->vms.regs.eax = 0x4f10; - vi->vms.regs.ebx = (VbeDPMSModes[mode] << 8) | 0x01; - code = VbeDoInterrupt10 (vi); - if (code < 0) - { - ErrorF ("DPMS failed %d\n", code); - return FALSE; - } - - return TRUE; -} - -int -VbeDoInterrupt10(Vm86InfoPtr vi) -{ - int code; - int oldax; - - oldax = vi->vms.regs.eax & 0xFFFF; - - code = Vm86DoInterrupt(vi, 0x10); - if(code < 0) - return -1; - - if((vi->vms.regs.eax & 0xFFFF) != 0x4F && (oldax & 0xFF00) == 0x4F00) { - ErrorF("Int 10h (0x%04X) failed: 0x%04X", - oldax, vi->vms.regs.eax & 0xFFFF); - if((oldax & 0xFF00) == 0x4F00) { - switch((vi->vms.regs.eax & 0xFF00)>>8) { - case 0: - ErrorF(" (success)\n"); - return 0; - case 1: - ErrorF(" (function call failed)\n"); - break; - case 2: - ErrorF(" (function not supported on this hardware)\n"); - break; - case 3: - ErrorF(" (function call invalid in this video mode)\n"); - break; - default: - ErrorF(" (unknown error)\n"); - break; - } return -1; - } else { - ErrorF("\n"); - } - } - return code; -} diff --git a/hw/kdrive/vesa/vbe.h b/hw/kdrive/vesa/vbe.h deleted file mode 100644 index 8aa3276d8..000000000 --- a/hw/kdrive/vesa/vbe.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.6 2001/05/29 04:54:12 keithp Exp $ */ - -#ifndef _VBE_H -#define _VBE_H - -#define VBE_WINDOW_RELOCATE 1 -#define VBE_WINDOW_READ 2 -#define VBE_WINDOW_WRITE 4 - -typedef struct _VbeInfoBlock { - U8 VbeSignature[4]; /* VBE Signature */ - U16 VbeVersion; /* VBE Version */ - U32 OemStringPtr; /* Pointer to OEM String */ - U8 Capabilities[4]; /* Capabilities of graphics controller */ - U32 VideoModePtr; /* Pointer to VideoModeList */ - U16 TotalMemory; /* Number of 64kb memory blocks */ -/* Added for VBE 2.0 */ - U16 OemSoftwareRev; /* VBE implementation Software revision */ - U32 OemVendorNamePtr; /* Pointer to Vendor Name String */ - U32 OemProductNamePtr; /* Pointer to Product Name String */ - U32 OemProductRevPtr; /* Pointer to Product Revision String */ - U8 Reserved[222]; /* Reserved for VBE implementation */ - U8 OemData[256]; /* Data Area for OEM Strings*/ -} __attribute__((packed)) VbeInfoBlock; - -typedef struct _VbeModeInfoBlock { -/* Mandatory information for all VBE revisions */ - U16 ModeAttributes; /* mode attributes */ - U8 WinAAttributes; /* window A attributes */ - U8 WinBAttributes; /* window B attributes */ - U16 WinGranularity; /* window granularity */ - U16 WinSize; /* window size */ - U16 WinASegment; /* window A start segment */ - U16 WinBSegment; /* window B start segment */ - U32 WinFuncPtr; /* pointer to window function */ - U16 BytesPerScanLine; /* bytes per scan line */ -/* Mandatory information for VBE 1.2 and above */ - U16 XResolution; /* horizontal resolution */ - U16 YResolution; /* vertical resolution */ - U8 XCharSize; /* character cell width in pixels */ - U8 YCharSize; /* character cell height in pixels */ - U8 NumberOfPlanes; /* number of memory planes */ - U8 BitsPerPixel; /* bits per pixel */ - U8 NumberOfBanks; /* number of banks */ - U8 MemoryModel; /* memory model type */ - U8 BankSize; /* bank size in KB */ - U8 NumberOfImagePages; /* number of images */ - U8 Reserved; /* reserved for page function */ -/* Direct Color fields (required for direct/6 and YUV/7 memory models) */ - U8 RedMaskSize; /* size of direct color red mask in bits */ - U8 RedFieldPosition; /* bit position of lsb of red mask */ - U8 GreenMaskSize; /* size of direct color green mask in bits */ - U8 GreenFieldPosition; /* bit position of lsb of green mask */ - U8 BlueMaskSize; /* size of direct color blue mask in bits */ - U8 BlueFieldPosition; /* bit position of lsb of blue mask */ - U8 RsvdMaskSize; /* size of direct color reserved mask bits*/ - U8 RsvdFieldPosition; /* bit position of lsb of reserved mask */ - U8 DirectColorModeInfo; /* direct color mode attributes */ -/* Mandatory information for VBE 2.0 and above */ - U32 PhysBasePtr; /* physical address for flat memory fb */ - U32 OffScreenMemOffset; /* pointer to start of off screen memory */ - U16 OffScreenMemSize; /* amount of off screen memory in 1k units */ - U8 Reserved2[206]; /* remainder of ModeInfoBlock */ -} __attribute__((packed)) VbeModeInfoBlock; - -typedef struct _VbeInfoRec { - U8 palette_format; - int palette_wait; - int windowA_offset; - int windowB_offset; - int window_size; - int last_window; - VbeModeInfoBlock vmib; -} VbeInfoRec, *VbeInfoPtr; - -typedef struct _SupVbeInfoBlock { - U8 SupVbeSignature[7]; /* Supplemental VBE Signature */ - U16 SupVbeVersion; /* Supplemental VBE Version*/ - U8 SupVbeSubFunc[8]; /* Bitfield of supported subfunctions */ - U16 OemSoftwareRev; /* OEM Software revision */ - U32 OemVendorNamePtr; /* Pointer to Vendor Name String */ - U32 OemProductNamePtr; /* Pointer to Product Name String */ - U32 OemProductRevPtr; /* Pointer to Product Revision String */ - U32 OemStringPtr; /* Pointer to OEM String */ - U8 Reserved[221]; /* Reserved */ -} __attribute__((packed)) SupVbeInfoBlock; - -int -VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib); - -int -VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib); - -void -VbeReportInfo (Vm86InfoPtr vi); - -int -VbeGetNmode (Vm86InfoPtr vi); - -int -VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode); - -VbeInfoPtr -VbeInit (Vm86InfoPtr vi); - -void -VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe); - -int -VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear, int direct); - -int -VbeGetMode(Vm86InfoPtr vi, int *mode); - -void * -VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys); - -void -VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb); - -int -VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries); - -int -VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries); - -int -VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait); - -void * -VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return); - -Bool -VbeDPMS(Vm86InfoPtr vi, int mode); - -int -VbeDoInterrupt10(Vm86InfoPtr vi); - -#endif diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c deleted file mode 100644 index 74bfb857e..000000000 --- a/hw/kdrive/vesa/vesa.c +++ /dev/null @@ -1,1782 +0,0 @@ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vesa.h" -#include "vga.h" -#include "vbe.h" -#ifdef RANDR -#include <randrstr.h> -#endif - -int vesa_video_mode = 0; -Bool vesa_force_mode = FALSE; -Bool vesa_swap_rgb = FALSE; -Bool vesa_shadow = FALSE; -Bool vesa_linear_fb = TRUE; -Bool vesa_restore = FALSE; -Bool vesa_verbose = FALSE; -Bool vesa_force_text = FALSE; -Bool vesa_restore_font = TRUE; -Bool vesa_map_holes = TRUE; - -#define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver) - -#define vesaWidth(scr,vmib) ((vmib)->XResolution) -#define vesaHeight(scr,vmib) ((vmib)->YResolution) - -static Bool -vesaModeSupportable (VesaModePtr mode, Bool complain) -{ - if((mode->ModeAttributes & 0x10) == 0) { - if(complain) - ErrorF("Text mode specified.\n"); - return FALSE; - } - if(mode->MemoryModel != 0x06 && mode->MemoryModel != 0x04 && mode->MemoryModel != 0x03) { - if(complain) - ErrorF("Unsupported memory model 0x%X\n", mode->MemoryModel); - return FALSE; - } - if((mode->ModeAttributes & 0x80) == 0) { - if ((mode->ModeAttributes & 0x40) != 0) { - if(complain) - ErrorF("Neither linear nor windowed framebuffer available in this mode\n"); - return FALSE; - } - } - if(!(mode->ModeAttributes & 1)) { - if(complain) - ErrorF("Mode not supported on this hardware\n"); - return FALSE; - } - return TRUE; -} - -static Bool -vesaModeSupported (VesaCardPrivPtr priv, VesaModePtr mode, Bool complain) -{ - if (!priv->vbeInfo && mode->vbe) { - if (complain) - ErrorF("VBE bios mode not usable.\n"); - return FALSE; - } - return vesaModeSupportable (mode, complain); -} - -void -vesaReportMode (VesaModePtr mode) -{ - int supported = (mode->ModeAttributes&MODE_SUPPORTED)?1:0; - int colour = (mode->ModeAttributes&MODE_COLOUR)?1:0; - int graphics = (mode->ModeAttributes&MODE_GRAPHICS)?1:0; - int vga_compatible = !((mode->ModeAttributes&MODE_VGA)?1:0); - int linear_fb = (mode->ModeAttributes&MODE_LINEAR)?1:0; - - ErrorF("0x%04X: %dx%dx%d%s%s", - (unsigned)mode->mode, - (int)mode->XResolution, (int)mode->YResolution, - vesaDepth (mode), - colour?"":" (monochrome)", - graphics?"":" (graphics)", - vga_compatible?"":" (vga compatible)", - linear_fb?"":" (linear frame buffer)"); - switch(mode->MemoryModel) { - case MEMORY_TEXT: - ErrorF(" text mode"); - break; - case MEMORY_CGA: - ErrorF(" CGA graphics"); - break; - case MEMORY_HERCULES: - ErrorF(" Hercules graphics"); - break; - case MEMORY_PLANAR: - ErrorF(" Planar (%d planes)", mode->NumberOfPlanes); - break; - case MEMORY_PSEUDO: - ErrorF(" PseudoColor"); - break; - case MEMORY_NONCHAIN: - ErrorF(" Non-chain 4, 256 colour"); - break; - case MEMORY_DIRECT: - if(mode->DirectColorModeInfo & MODE_DIRECT) - ErrorF(" DirectColor"); - else - ErrorF(" TrueColor"); - ErrorF(" [%d:%d:%d:%d]", - mode->RedMaskSize, mode->GreenMaskSize, mode->BlueMaskSize, - mode->RsvdMaskSize); - if(mode->DirectColorModeInfo & 2) - ErrorF(" (reserved bits are reserved)"); - break; - case MEMORY_YUV: - ErrorF("YUV"); - break; - default: - ErrorF("unknown MemoryModel 0x%X ", mode->MemoryModel); - } - if(!supported) - ErrorF(" (unsupported)"); - else if(!linear_fb) - ErrorF(" (no linear framebuffer)"); - ErrorF("\n"); -} - -VesaModePtr -vesaGetModes (Vm86InfoPtr vi, int *ret_nmode) -{ - VesaModePtr modes; - int nmode, nmodeVbe, nmodeVga; - int code; - - code = VgaGetNmode (vi); - if (code <= 0) - nmodeVga = 0; - else - nmodeVga = code; - - code = VbeGetNmode (vi); - if (code <= 0) - nmodeVbe = 0; - else - nmodeVbe = code; - - nmode = nmodeVga + nmodeVbe; - if (nmode <= 0) - return 0; - - modes = xalloc (nmode * sizeof (VesaModeRec)); - - memset (modes, '\0', nmode * sizeof (VesaModeRec)); - - if (nmodeVga) - { - code = VgaGetModes (vi, modes, nmodeVga); - if (code <= 0) - nmodeVga = 0; - else - nmodeVga = code; - } - - if (nmodeVbe) - { - code = VbeGetModes (vi, modes + nmodeVga, nmodeVbe); - if (code <= 0) - nmodeVbe = 0; - else - nmodeVbe = code; - } - - nmode = nmodeVga + nmodeVbe; - - if (nmode == 0) - { - xfree (modes); - modes = 0; - return 0; - } - *ret_nmode = nmode; - return modes; -} - -Bool -vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv) -{ - priv->vi = Vm86Setup(vesa_map_holes); - if(!priv->vi) - goto fail; - - priv->modes = vesaGetModes (priv->vi, &priv->nmode); - - if (!priv->modes) - goto fail; - - priv->vbeInfo = VbeInit (priv->vi); - - card->driver = priv; - - return TRUE; - -fail: - if(priv->vi) - Vm86Cleanup(priv->vi); - return FALSE; -} - -void -vesaListModes (void) -{ - Vm86InfoPtr vi; - VesaModePtr modes; - int nmode; - int n; - - vi = Vm86Setup (vesa_map_holes); - if (!vi) - { - ErrorF ("Can't setup vm86\n"); - } - else - { - modes = vesaGetModes (vi, &nmode); - if (!modes) - { - ErrorF ("No modes available\n"); - } - else - { - VbeReportInfo (vi); - for (n = 0; n < nmode; n++) - { - if (vesa_force_mode || vesaModeSupportable (modes+n, 0)) - vesaReportMode (modes+n); - } - xfree (modes); - } - Vm86Cleanup (vi); - } -} - -void -vesaTestMode (void) -{ - Vm86InfoPtr vi; - VesaModePtr modes; - VesaModePtr mode; - VbeInfoPtr vbeInfo; - int nmode; - int n; - - vi = Vm86Setup (vesa_map_holes); - if (!vi) - { - ErrorF ("Can't setup vm86\n"); - return; - } - modes = vesaGetModes (vi, &nmode); - if (!modes) - { - ErrorF ("No modes available\n"); - return; - } - VbeReportInfo (vi); - vbeInfo = VbeInit (vi); - for (n = 0; n < nmode; n++) - { - if (modes[n].mode == vesa_video_mode) - break; - } - if (n == nmode) - { - ErrorF ("no mode specified\n"); - return; - } - mode = &modes[n]; - if (mode->vbe) - { - ErrorF ("Enable VBE mode 0x%x\n", mode->mode); - VbeSetMode(vi, vbeInfo, mode->mode, FALSE, FALSE); - } - else - { - ErrorF ("Enable BIOS mode 0x%x\n", mode->mode); - VgaSetMode (vi, mode->mode); - } - sleep (2); - ErrorF ("Restore BIOS mode 0x%x\n", 3); - VgaSetMode (vi, 3); - xfree (modes); - Vm86Cleanup (vi); -} - -Bool -vesaCardInit(KdCardInfo *card) -{ - VesaCardPrivPtr priv; - - priv = xalloc(sizeof(VesaCardPrivRec)); - if(!priv) - return FALSE; - - if (!vesaInitialize (card, priv)) - { - xfree(priv); - return FALSE; - } - - return TRUE; -} - -int -vesaDepth (VesaModePtr mode) -{ - if (mode->MemoryModel == MEMORY_DIRECT) - return (mode->RedMaskSize + - mode->GreenMaskSize + - mode->BlueMaskSize); - else - return mode->BitsPerPixel; -} - -Bool -vesaModeGood (KdScreenInfo *screen, - VesaModePtr a) -{ - if (vesaWidth(screen,a) <= screen->width && - vesaHeight(screen,a) <= screen->height && - vesaDepth (a) >= screen->fb[0].depth) - { - return TRUE; - } - return FALSE; -} - -#define vabs(a) ((a) >= 0 ? (a) : -(a)) - -int -vesaSizeError (KdScreenInfo *screen, - VesaModePtr a) -{ - int xdist, ydist; - xdist = vabs (screen->width - vesaWidth(screen,a)); - ydist = vabs (screen->height - vesaHeight(screen,a)); - return xdist * xdist + ydist * ydist; -} - -Bool -vesaModeBetter (KdScreenInfo *screen, - VesaModePtr a, - VesaModePtr b) -{ - int aerr, berr; - - if (vesaModeGood (screen, a)) - { - if (!vesaModeGood (screen, b)) - return TRUE; - } - else - { - if (vesaModeGood (screen, b)) - return FALSE; - } - aerr = vesaSizeError (screen, a); - berr = vesaSizeError (screen, b); - if (aerr < berr) - return TRUE; - if (berr < aerr) - return FALSE; - if (vabs (screen->fb[0].depth - vesaDepth (a)) < - vabs (screen->fb[0].depth - vesaDepth (b))) - return TRUE; - return FALSE; -} - -VesaModePtr -vesaSelectMode (KdScreenInfo *screen) -{ - VesaCardPrivPtr priv = screen->card->driver; - int i, best; - - if (vesa_video_mode) - { - for (best = 0; best < priv->nmode; best++) - if (priv->modes[best].mode == vesa_video_mode && - (vesaModeSupported (priv, &priv->modes[best], FALSE) || - vesa_force_mode)) - return &priv->modes[best]; - } - for (best = 0; best < priv->nmode; best++) - { - if (vesaModeSupported (priv, &priv->modes[best], FALSE)) - break; - } - if (best == priv->nmode) - return 0; - for (i = best + 1; i < priv->nmode; i++) - if (vesaModeSupported (priv, &priv->modes[i], FALSE) && - vesaModeBetter (screen, &priv->modes[i], - &priv->modes[best])) - best = i; - return &priv->modes[best]; -} - -Bool -vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr) -{ - VesaModePtr mode; - - screen->driver = pscr; - - if (!screen->width || !screen->height) - { - screen->width = 640; - screen->height = 480; - } - if (!screen->fb[0].depth) - screen->fb[0].depth = 4; - - if (vesa_verbose) - ErrorF ("Mode requested %dx%dx%d\n", - screen->width, screen->height, screen->fb[0].depth); - - mode = vesaSelectMode (screen); - - if (!mode) - { - if (vesa_verbose) - ErrorF ("No selectable mode\n"); - return FALSE; - } - pscr->mode = *mode; - - if (vesa_verbose) - { - ErrorF ("\t"); - vesaReportMode (&pscr->mode); - } - - pscr->randr = screen->randr; - pscr->shadow = vesa_shadow; - pscr->origDepth = screen->fb[0].depth; - /* - * Compute visual support for the selected depth - */ - - switch (pscr->mode.MemoryModel) { - case MEMORY_DIRECT: - /* TrueColor or DirectColor */ - screen->fb[0].visuals = (1 << TrueColor); - screen->fb[0].redMask = - FbStipMask(pscr->mode.RedFieldPosition, pscr->mode.RedMaskSize); - screen->fb[0].greenMask = - FbStipMask(pscr->mode.GreenFieldPosition, pscr->mode.GreenMaskSize); - screen->fb[0].blueMask = - FbStipMask(pscr->mode.BlueFieldPosition, pscr->mode.BlueMaskSize); - break; - case MEMORY_PSEUDO: - /* PseudoColor */ - screen->fb[0].visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - case MEMORY_PLANAR: - /* 4 plane planar */ - if (pscr->mode.ModeAttributes & MODE_COLOUR) - screen->fb[0].visuals = (1 << StaticColor); - else - screen->fb[0].visuals = (1 << StaticGray); - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; - break; - default: - ErrorF("Unsupported VESA MemoryModel 0x%02X\n", - pscr->mode.MemoryModel); - return FALSE; - } - screen->rate = 72; - - return vesaMapFramebuffer (screen); -} - -Bool -vesaScreenInit(KdScreenInfo *screen) -{ - VesaScreenPrivPtr pscr; - - pscr = xcalloc (1, sizeof (VesaScreenPrivRec)); - if (!pscr) - return FALSE; - if (!vesaScreenInitialize (screen, pscr)) - return FALSE; - return TRUE; -} - -void * -vesaSetWindowPlanar(ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size) -{ - KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - static int plane; - int winSize; - void *base; - - plane = offset & 3; - VgaSetWritePlaneMask (priv->vi, (1 << plane)); - offset = offset >> 2; - if (pscr->mode.vbe) - { - base = VbeSetWindow (priv->vi, - priv->vbeInfo, - pscr->mode.BytesPerScanLine * row + offset, - mode, - &winSize); - } - else - { - base = VgaSetWindow (priv->vi, - pscr->mode.mode, - pscr->mode.BytesPerScanLine * row + offset, - mode, - &winSize); - } - *size = (CARD32) winSize; - return base; -} - -void * -vesaSetWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size) -{ - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - - *size = pscr->mode.BytesPerScanLine; - return (CARD8 *) pscr->fb + row * pscr->mode.BytesPerScanLine + offset; -} - -void * -vesaSetWindowWindowed (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size) -{ - KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - int winSize; - void *base; - - if (pscr->mode.vbe) - { - base = VbeSetWindow (priv->vi, - priv->vbeInfo, - pscr->mode.BytesPerScanLine * row + offset, - mode, - &winSize); - } - else - { - base = VgaSetWindow (priv->vi, - pscr->mode.mode, - pscr->mode.BytesPerScanLine * row + offset, - mode, - &winSize); - } - *size = (CARD32) winSize; - return base; -} - -void * -vesaWindowPlanar (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - - if (!pScreenPriv->enabled) - return 0; - return vesaSetWindowPlanar (pScreen, row, offset, mode, size); -} - -void * -vesaWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - - if (!pScreenPriv->enabled) - return 0; - return vesaSetWindowLinear (pScreen, row, offset, mode, size); -} - -void * -vesaWindowWindowed (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - - if (!pScreenPriv->enabled) - return 0; - return vesaSetWindowWindowed (pScreen, row, offset, mode, size); -} - -#define vesaInvertBits32(v) { \ - v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ - v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ - v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ -} - -void * -vesaWindowCga (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) -{ - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - int line; - - if (!pScreenPriv->enabled) - return 0; - *size = pscr->mode.BytesPerScanLine; - line = ((row & 1) << 13) + (row >> 1) * pscr->mode.BytesPerScanLine; - return (CARD8 *) pscr->fb + line + offset; -} - -void -vesaUpdateMono (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage(pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - FbBits *winBase = 0, *win; - CARD32 winSize; - FbBits bits; - - fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = pbox->x1 * shaBpp; - y = pbox->y1; - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - scrLine = (x >> FB_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - x &= FB_MASK; - w = (w + x + FB_MASK) >> FB_SHIFT; - - while (h--) - { - winSize = 0; - scrBase = 0; - width = w; - scr = scrLine; - sha = shaLine; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (FbBits *) (*pBuf->window) (pScreen, - y, - scr * sizeof (FbBits), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - scrBase = scr; - winSize /= sizeof (FbBits); - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; - while (i--) - { - bits = *sha++; - vesaInvertBits32(bits); - *win++ = bits; - } - } - shaLine += shaStride; - y++; - } - pbox++; - } -} - -static const CARD16 vga16Colors[16][3] = { - { 0, 0, 0, }, /* 0 */ - { 0, 0, 0xAA,}, /* 1 */ - { 0, 0xAA,0, }, /* 2 */ - { 0, 0xAA,0xAA,}, /* 3 */ - { 0xAA,0, 0, }, /* 4 */ - { 0xAA,0, 0xAA,}, /* 5 */ - { 0xAA,0x55,0, }, /* 6 */ - { 0xAA,0xAA,0xAA,}, /* 7 */ - { 0x55,0x55,0x55,}, /* 8 */ - { 0x55,0x55,0xFF,}, /* 9 */ - { 0x55,0xFF,0x55,}, /* 10 */ - { 0x55,0xFF,0xFF,}, /* 11 */ - { 0xFF,0x55,0x55,}, /* 12 */ - { 0xFF,0x55,0xFF,}, /* 13 */ - { 0xFF,0xFF,0x55,}, /* 14 */ - { 0xFF,0xFF,0xFF,}, /* 15 */ -}; - -Bool -vesaCreateColormap16 (ColormapPtr pmap) -{ - int i, j; - - if (pmap->pVisual->ColormapEntries == 16) - for (i = 0; i < pmap->pVisual->ColormapEntries; i++) - { - j = i & 0xf; - pmap->red[i].co.local.red = (vga16Colors[j][0]<<8)|vga16Colors[j][0]; - pmap->red[i].co.local.green = (vga16Colors[j][1]<<8)|vga16Colors[j][1]; - pmap->red[i].co.local.blue = (vga16Colors[j][2]<<8)|vga16Colors[j][2]; - } - return TRUE; -} - -void -vesaSetScreenSizes (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - VesaScreenPrivPtr pscr = screen->driver; - - if (pscr->randr & (RR_Rotate_0|RR_Rotate_180)) - { - pScreen->width = pscr->mode.XResolution; - pScreen->height = pscr->mode.YResolution; - pScreen->mmWidth = screen->width_mm; - pScreen->mmHeight = screen->height_mm; - } - else - { - pScreen->width = pscr->mode.YResolution; - pScreen->height = pscr->mode.XResolution; - pScreen->mmWidth = screen->height_mm; - pScreen->mmHeight = screen->width_mm; - } -} - -Bool -vesaSetShadow (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - ShadowUpdateProc update; - ShadowWindowProc window = 0; - - if (pscr->randr != RR_Rotate_0) - update = shadowUpdateRotatePacked; - else - update = shadowUpdatePacked; - switch (pscr->mapping) { - case VESA_LINEAR: - window = vesaWindowLinear; - break; - case VESA_WINDOWED: - window = vesaWindowWindowed; - break; - case VESA_PLANAR: - pScreen->CreateColormap = vesaCreateColormap16; - if (pScreenPriv->screen->fb[0].bitsPerPixel == 8) - update = shadowUpdatePlanar4x8; - else - update = shadowUpdatePlanar4; - window = vesaWindowPlanar; - break; - case VESA_MONO: - update = vesaUpdateMono; - if (pscr->mode.mode < 8) - window = vesaWindowCga; - else - window = vesaWindowLinear; - break; - } - - return KdShadowSet (pScreen, pscr->randr, update, window); -} - -Bool -vesaMapFramebuffer (KdScreenInfo *screen) -{ - VesaCardPrivPtr priv = screen->card->driver; - VesaScreenPrivPtr pscr = screen->driver; - int depth, bpp, fbbpp; - Pixel allbits; - KdMouseMatrix m; - - if (vesa_linear_fb) - { - pscr->mapping = VESA_LINEAR; - pscr->shadow = FALSE; - } - else - { - pscr->mapping = VESA_WINDOWED; - pscr->shadow = TRUE; - } - - depth = vesaDepth (&pscr->mode); - bpp = pscr->mode.BitsPerPixel; - - if (bpp > 24) - bpp = 32; - else if (bpp > 16) - bpp = 24; - else if (bpp > 8) - bpp = 16; - else if (bpp > 4) - bpp = 8; - else if (bpp > 1) - bpp = 4; - else - bpp = 1; - fbbpp = bpp; - - switch (pscr->mode.MemoryModel) { - case MEMORY_DIRECT: - allbits = (screen->fb[0].redMask | - screen->fb[0].greenMask | - screen->fb[0].blueMask); - depth = 32; - while (depth && !(allbits & (1 << (depth - 1)))) - depth--; - if (vesa_verbose) - ErrorF ("\tTrue Color red 0x%x green 0x%x blue 0x%x\n", - bpp, depth, - screen->fb[0].redMask, - screen->fb[0].greenMask, - screen->fb[0].blueMask); - break; - case MEMORY_PSEUDO: - if (vesa_verbose) - ErrorF ("\tPseudo Color bpp %d depth %d\n", - bpp, depth); - break; - case MEMORY_PLANAR: - if (bpp == 4) - { - bpp = screen->fb[0].bitsPerPixel; - if (bpp != 8) - bpp = 4; - depth = bpp; - } - if (bpp == 1) - { - pscr->mapping = VESA_MONO; - if (vesa_verbose) - ErrorF ("\tMonochrome\n"); - } - else - { - pscr->mapping = VESA_PLANAR; - if (vesa_verbose) - ErrorF ("\tStatic color bpp %d depth %d\n", - bpp, depth); - } - pscr->randr = RR_Rotate_0; - pscr->shadow = TRUE; - break; - default: - return FALSE; - } - - switch (fbbpp) { - case 8: - case 16: - case 32: - break; - default: - pscr->randr = RR_Rotate_0; - break; - } - - if (pscr->randr != RR_Rotate_0) - pscr->shadow = TRUE; - - if (vesa_shadow) - pscr->shadow = vesa_shadow; - - if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR)) - { - pscr->mapping = VESA_WINDOWED; - pscr->shadow = TRUE; - } - - screen->softCursor = TRUE; - - switch (pscr->mapping) { - case VESA_MONO: - case VESA_LINEAR: - if (pscr->mode.vbe) - pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, - pscr->mode.mode, - &pscr->fb_size, - &pscr->fb_phys); - else - pscr->fb = VgaMapFramebuffer (priv->vi, - pscr->mode.mode, - &pscr->fb_size, - &pscr->fb_phys); - if (!pscr->fb) - return FALSE; - break; - case VESA_WINDOWED: - pscr->fb = NULL; - break; - case VESA_PLANAR: - pscr->fb = NULL; - break; - } - - KdComputeMouseMatrix (&m, pscr->randr, - pscr->mode.XResolution, pscr->mode.YResolution); - - KdSetMouseMatrix (&m); - - screen->width = pscr->mode.XResolution; - screen->height = pscr->mode.YResolution; - screen->memory_base = pscr->fb; - screen->memory_size = pscr->fb_size; - screen->fb[0].depth = depth; - screen->fb[0].bitsPerPixel = bpp; - - if (pscr->shadow) - { - if (!KdShadowFbAlloc (screen, 0, - pscr->randr & (RR_Rotate_90|RR_Rotate_270))) - return FALSE; - screen->off_screen_base = screen->memory_size; - } - else - { - screen->fb[0].frameBuffer = (CARD8 *) (pscr->fb); - screen->fb[0].byteStride = pscr->mode.BytesPerScanLine; - screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / - screen->fb[0].bitsPerPixel); - screen->off_screen_base = screen->fb[0].byteStride * screen->height; - } - - return TRUE; -} - -void -vesaUnmapFramebuffer (KdScreenInfo *screen) -{ - VesaCardPrivPtr priv = screen->card->driver; - VesaScreenPrivPtr pscr = screen->driver; - - KdShadowFbFree (screen, 0); - if (pscr->fb) - { - if (pscr->mode.vbe) - VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, pscr->fb); - else - VgaUnmapFramebuffer (priv->vi); - pscr->fb = 0; - } -} - -#ifdef RANDR -Bool -vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) -{ - KdScreenPriv(pScreen); - VesaModePtr modes, mode; - KdScreenInfo *screen = pScreenPriv->screen; - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - int nmode; - int n; - RRScreenSizePtr pSize; - - *rotations = (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270| - RR_Reflect_X|RR_Reflect_Y); - /* - * Get mode information from BIOS -- every time in case - * something changes, like an external monitor is plugged in - */ - modes = vesaGetModes (priv->vi, &nmode); - if (!modes) - return FALSE; - if (priv->modes) - xfree (priv->modes); - priv->modes = modes; - priv->nmode = nmode; - for (n = 0; n < nmode; n++) - { - mode = &priv->modes[n]; - if (vesaModeSupported (priv, mode, FALSE)) - { - /* - * XXX limit reported modes to those matching the current - * format - */ - if (mode->NumberOfPlanes == pscr->mode.NumberOfPlanes && - mode->BitsPerPixel == pscr->mode.BitsPerPixel && - mode->MemoryModel == pscr->mode.MemoryModel && - mode->RedMaskSize == pscr->mode.RedMaskSize && - mode->RedFieldPosition == pscr->mode.RedFieldPosition && - mode->GreenMaskSize == pscr->mode.GreenMaskSize && - mode->GreenFieldPosition == pscr->mode.GreenFieldPosition && - mode->BlueMaskSize == pscr->mode.BlueMaskSize && - mode->BlueFieldPosition == pscr->mode.BlueFieldPosition) - { - int width, height, width_mm, height_mm; - if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) - { - width = mode->XResolution; - height = mode->YResolution; - width_mm = screen->width_mm; - height_mm = screen->height_mm; - } - else - { - width = mode->YResolution; - height = mode->XResolution; - width_mm = screen->height_mm; - height_mm = screen->width_mm; - } - pSize = RRRegisterSize (pScreen, - width, height, - width_mm, height_mm); - if (mode->XResolution == screen->width && - mode->YResolution == screen->height) - { - int randr = KdSubRotation (pscr->randr, screen->randr); - RRSetCurrentConfig (pScreen, randr, 0, pSize); - } - } - } - } - return TRUE; -} - -Bool -vesaRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) -{ - KdScreenPriv(pScreen); - VesaModePtr mode = 0; - KdScreenInfo *screen = pScreenPriv->screen; - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - int n; - Bool wasEnabled = pScreenPriv->enabled; - Bool ret = FALSE; - VesaScreenPrivRec oldscr; - int oldwidth; - int oldheight; - int oldmmwidth; - int oldmmheight; - int newwidth, newheight; - - if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) - { - newwidth = pSize->width; - newheight = pSize->height; - } - else - { - newwidth = pSize->height; - newheight = pSize->width; - } - for (n = 0; n < priv->nmode; n++) - { - mode = &priv->modes[n]; - if (vesaModeSupported (priv, mode, FALSE)) - { - /* - * XXX all we have to match is the size - */ - if (mode->XResolution == newwidth && - mode->YResolution == newheight && - mode->NumberOfPlanes == pscr->mode.NumberOfPlanes && - mode->BitsPerPixel == pscr->mode.BitsPerPixel && - mode->RedMaskSize == pscr->mode.RedMaskSize && - mode->RedFieldPosition == pscr->mode.RedFieldPosition && - mode->GreenMaskSize == pscr->mode.GreenMaskSize && - mode->GreenFieldPosition == pscr->mode.GreenFieldPosition && - mode->BlueMaskSize == pscr->mode.BlueMaskSize && - mode->BlueFieldPosition == pscr->mode.BlueFieldPosition) - break; - } - } - if (n == priv->nmode) - goto bail0; - - if (wasEnabled) - KdDisableScreen (pScreen); - - if (mode->mode != pscr->mode.mode) - { - ret = vesaSetMode (pScreen, mode); - if (!ret) - goto bail1; - } - - oldscr = *pscr; - - oldwidth = screen->width; - oldheight = screen->height; - oldmmwidth = pScreen->mmWidth; - oldmmheight = pScreen->mmHeight; - - /* - * Set new configuration - */ - - pscr->mode = *mode; - pscr->randr = KdAddRotation (screen->randr, randr); - - /* - * Can't rotate some formats - */ - switch (screen->fb[0].bitsPerPixel) { - case 8: - case 16: - case 32: - break; - default: - if (pscr->randr) - goto bail2; - break; - } - - KdOffscreenSwapOut (screen->pScreen); - - vesaUnmapFramebuffer (screen); - - if (!vesaMapFramebuffer (screen)) - goto bail3; - - vesaSetScreenSizes (screen->pScreen); - - if (!vesaSetShadow (screen->pScreen)) - goto bail4; - - /* - * Set frame buffer mapping - */ - (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), - pScreen->width, - pScreen->height, - screen->fb[0].depth, - screen->fb[0].bitsPerPixel, - screen->fb[0].byteStride, - screen->fb[0].frameBuffer); - - /* set the subpixel order */ - KdSetSubpixelOrder (pScreen, pscr->randr); - - if (wasEnabled) - KdEnableScreen (pScreen); - - return TRUE; - -bail4: - vesaUnmapFramebuffer (screen); - *pscr = oldscr; - (void) vesaMapFramebuffer (screen); - -bail3: - pScreen->width = oldwidth; - pScreen->height = oldheight; - pScreen->mmWidth = oldmmwidth; - pScreen->mmHeight = oldmmheight; - -bail2: - *pscr = oldscr; - - (void) vesaSetMode (pScreen, &pscr->mode); -bail1: - if (wasEnabled) - KdEnableScreen (pScreen); -bail0: - - return FALSE; -} - -Bool -vesaRandRInit (ScreenPtr pScreen) -{ - rrScrPrivPtr pScrPriv; - - if (!RRScreenInit (pScreen)) - return FALSE; - - pScrPriv = rrGetScrPriv(pScreen); - pScrPriv->rrGetInfo = vesaRandRGetInfo; - pScrPriv->rrSetConfig = vesaRandRSetConfig; - return TRUE; -} -#endif - -Bool -vesaInitScreen(ScreenPtr pScreen) -{ - return TRUE; -} - -Bool -vesaFinishInitScreen (ScreenPtr pScreen) -{ - if (!shadowSetup (pScreen)) - return FALSE; - -#ifdef RANDR - if (!vesaRandRInit (pScreen)) - return FALSE; -#endif - - return TRUE; -} - -Bool -vesaCreateResources (ScreenPtr pScreen) -{ - return vesaSetShadow (pScreen); -} - -Bool -vesaSetMode (ScreenPtr pScreen, - VesaModePtr mode) -{ - KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - int code; - - if (mode->vbe) - { - if (vesa_verbose) - ErrorF ("Enable VBE mode 0x%x\n", mode->mode); - code = VbeSetMode(priv->vi, priv->vbeInfo, mode->mode, - pscr->mapping == VESA_LINEAR, - mode->MemoryModel == MEMORY_DIRECT); - } - else - { - if (vesa_verbose) - ErrorF ("Enable BIOS mode 0x%x\n", mode->mode); - code = VgaSetMode (priv->vi, mode->mode); - } - - if(code < 0) - return FALSE; - - return TRUE; -} - -Bool -vesaEnable(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - KdScreenInfo *screen = pScreenPriv->screen; - int i; - CARD32 size; - char *p; - - if (!vesaSetMode (pScreen, &pscr->mode)) - return FALSE; - - switch (pscr->mapping) { - case VESA_MONO: - VgaSetWritePlaneMask (priv->vi, 0x1); - case VESA_LINEAR: - /* - * Remap the frame buffer if necessary - */ - if (!pscr->fb) - { - if (pscr->mode.vbe) - pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, - pscr->mode.mode, - &pscr->fb_size, - &pscr->fb_phys); - else - pscr->fb = VgaMapFramebuffer (priv->vi, - pscr->mode.mode, - &pscr->fb_size, - &pscr->fb_phys); - if (!pscr->fb) - return FALSE; - screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb); - /* - * Set frame buffer mapping - */ - if (!pscr->shadow) - { - (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), - pScreen->width, - pScreen->height, - screen->fb[0].depth, - screen->fb[0].bitsPerPixel, - screen->fb[0].byteStride, - screen->fb[0].frameBuffer); - } - } - if (vesa_restore_font) - memcpy (priv->text, pscr->fb, VESA_TEXT_SAVE); - break; - case VESA_WINDOWED: - if (vesa_restore_font) - { - for (i = 0; i < VESA_TEXT_SAVE;) - { - p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_READ, &size); - if(!p) { - ErrorF("Couldn't set window for saving VGA font\n"); - break; - } - if(i + size > VESA_TEXT_SAVE) - size = VESA_TEXT_SAVE - i; - memcpy(((char*)priv->text) + i, p, size); - i += size; - } - } - break; - case VESA_PLANAR: - if (vesa_restore_font) - { - for (i = 0; i < 4; i++) - { - p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_READ, &size); - memcpy (((char *)priv->text) + i * (VESA_TEXT_SAVE/4), p, - (VESA_TEXT_SAVE/4)); - } - } - break; - } - return TRUE; -} - -#ifndef TOSHIBA_SMM - -# ifdef linux -# define TOSHIBA_SMM 1 -# endif - -# ifndef TOSHIBA_SMM -# define TOSHIBA_SMM 0 -# endif - -#endif - -#if TOSHIBA_SMM -/* - * Toshiba laptops use a special interface to operate the backlight - */ -#include <sys/ioctl.h> -#define TOSH_PROC "/proc/toshiba" -#define TOSH_DEVICE "/dev/toshiba" -#define TOSH_SMM _IOWR('t', 0x90, SMMRegisters) - -typedef struct { - unsigned int eax; - unsigned int ebx __attribute__ ((packed)); - unsigned int ecx __attribute__ ((packed)); - unsigned int edx __attribute__ ((packed)); - unsigned int esi __attribute__ ((packed)); - unsigned int edi __attribute__ ((packed)); -} SMMRegisters; - -#define HCI_BACKLIGHT 0x0002 -#define HCI_DISABLE 0x0000 -#define HCI_ENABLE 0x0001 -#define HCI_GET 0xfe00, -#define HCI_SET 0xff00 - -Bool -toshibaDPMS (ScreenPtr pScreen, int mode) -{ - SMMRegisters regs; - static int fd; - - if (!fd) - fd = open (TOSH_DEVICE, 2); - if (fd < 0) - return FALSE; - regs.eax = HCI_SET; - regs.ebx = HCI_BACKLIGHT; - regs.ecx = mode ? HCI_DISABLE : HCI_ENABLE; - if (ioctl (fd, TOSH_SMM, ®s) < 0) - return FALSE; - return TRUE; -} -#endif /* TOSHIBA_SMM */ - -Bool -vesaDPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - -#if TOSHIBA_SMM - if (toshibaDPMS (pScreen, mode)) - return TRUE; -#endif - if (pscr->mode.vbe) - return VbeDPMS (priv->vi, mode); - return FALSE; -} - -void -vesaDisable(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - VesaCardPrivPtr priv = pScreenPriv->card->driver; - VesaScreenPrivPtr pscr = screen->driver; - int i=0; - CARD32 size; - char *p; - - if (vesa_restore_font) { - switch (pscr->mapping) { - case VESA_LINEAR: - case VESA_MONO: - memcpy(pscr->fb, priv->text, VESA_TEXT_SAVE); - break; - case VESA_WINDOWED: - while(i < VESA_TEXT_SAVE) { - p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_WRITE, &size); - if(!p) { - ErrorF("Couldn't set window for restoring VGA font\n"); - break; - } - if(i + size > VESA_TEXT_SAVE) - size = VESA_TEXT_SAVE - i; - memcpy(p, ((char*)priv->text) + i, size); - i += size; - } - break; - case VESA_PLANAR: - for (i = 0; i < 4; i++) - { - p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_WRITE, &size); - memcpy (p, - ((char *)priv->text) + i * (VESA_TEXT_SAVE/4), - (VESA_TEXT_SAVE/4)); - } - break; - } - } - vesaUnmapFramebuffer (screen); -} - -void -vesaPreserve(KdCardInfo *card) -{ - VesaCardPrivPtr priv = card->driver; - - /* The framebuffer might not be valid at this point, so we cannot - save the VGA fonts now; we do it in vesaEnable. */ - - if (VbeGetMode (priv->vi, &priv->old_vbe_mode) < 0) - priv->old_vbe_mode = -1; - - if (VgaGetMode (priv->vi, &priv->old_vga_mode) < 0) - priv->old_vga_mode = -1; - - if (vesa_verbose) - ErrorF ("Previous modes: VBE 0x%x BIOS 0x%x\n", - priv->old_vbe_mode, priv->old_vga_mode); -} - -void -vesaRestore(KdCardInfo *card) -{ - VesaCardPrivPtr priv = card->driver; - int n; - - if (vesa_force_text) - { - if (vesa_verbose) - ErrorF ("Forcing switch back to mode 3 text\n"); - priv->old_vbe_mode = -1; - priv->old_vga_mode = 3; - } - for (n = 0; n < priv->nmode; n++) - if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff)) - break; - - if (n < priv->nmode) - { - if (vesa_verbose) - ErrorF ("Restore VBE mode 0x%x\n", priv->old_vbe_mode); - VbeSetMode (priv->vi, priv->vbeInfo, priv->old_vbe_mode, 0, 0); - } - else - { - if (vesa_verbose) - ErrorF ("Restore BIOS mode 0x%x\n", priv->old_vga_mode); - VgaSetMode (priv->vi, priv->old_vga_mode); - } -} - -void -vesaCardFini(KdCardInfo *card) -{ - VesaCardPrivPtr priv = card->driver; - - if (priv->vbeInfo) - VbeCleanup (priv->vi, priv->vbeInfo); - if (priv->modes) - xfree (priv->modes); - Vm86Cleanup(priv->vi); -} - -void -vesaScreenFini(KdScreenInfo *screen) -{ - VesaScreenPrivPtr pscr = screen->driver; - - KdShadowFbFree (screen, 0); - vesaUnmapFramebuffer (screen); - screen->fb[0].depth = pscr->origDepth; -} - -int -vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries) -{ - if (priv->vga_palette) - return VgaSetPalette (priv->vi, first, number, entries); - else - return VbeSetPalette (priv->vi, priv->vbeInfo, first, number, entries); -} - - -int -vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries) -{ - int code; - - if (priv->vga_palette) - code = VgaGetPalette (priv->vi, first, number, entries); - else - { - code = VbeGetPalette (priv->vi, priv->vbeInfo, first, number, entries); - if (code < 0) - { - priv->vga_palette = 1; - code = VgaGetPalette (priv->vi, first, number, entries); - } - } - return code; -} - -void -vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - VesaCardPrivPtr priv = pScreenPriv->card->driver; - int p; - CARD8 *scratch; - int red, green, blue; - int min, max; - - if (vesa_swap_rgb) - { - red = 2; - green = 1; - blue = 0; - } - else - { - red = 0; - green = 1; - blue = 2; - } - - min = 256; - max = 0; - while (n--) - { - p = pdefs->pixel; - if (p < min) - min = p; - if (p > max) - max = p; - scratch = priv->cmap + (p * 4); - scratch[red] = pdefs->red >> 8; - scratch[green] = pdefs->green >> 8; - scratch[blue] = pdefs->blue >> 8; - scratch[3] = 0; - pdefs++; - if (pscr->mapping == VESA_PLANAR) - { - /* - * VGA modes are strange; this code covers all - * possible modes by duplicating the color information - * however the attribute registers might be set - */ - if (p < 16) - { - vesaSetPalette (priv, p, 1, scratch); - if (p >= 8) - vesaSetPalette (priv, p+0x30, 1, scratch); - else if (p == 6) - vesaSetPalette (priv, 0x14, 1, scratch); - } - } - } - if (pscr->mapping != VESA_PLANAR) - vesaSetPalette (priv, min, max-min+1, priv->cmap + min * 4); -} - -void -vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) -{ - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - VesaCardPrivPtr priv = pScreenPriv->card->driver; - int i; - int red, green, blue; - int min, max; - int p; - CARD8 *scratch; - - if (vesa_swap_rgb) - { - red = 2; - green = 1; - blue = 0; - } - else - { - red = 0; - green = 1; - blue = 2; - } - - min = 256; - max = 0; - for(i = 0; i < n; i++) - { - p = pdefs[i].pixel; - if (p < min) - min = p; - if (p > max) - max = p; - if (pscr->mapping == VESA_PLANAR) - vesaGetPalette (priv, p, 1, priv->cmap + p * 4); - } - if (pscr->mapping != VESA_PLANAR) - vesaGetPalette (priv, min, max - min + 1, priv->cmap + min * 4); - for (i = 0; i < n; i++) - { - p = pdefs[i].pixel; - scratch = priv->cmap + p * 4; - pdefs[i].red = scratch[red]<<8; - pdefs[i].green = scratch[green]<<8; - pdefs[i].blue = scratch[blue]<<8; - } -} - -int -vesaProcessArgument (int argc, char **argv, int i) -{ - if(!strcmp(argv[i], "-mode")) { - if(i+1 < argc) { - vesa_video_mode = strtol(argv[i+1], NULL, 0); - } else - UseMsg(); - return 2; - } else if(!strcmp(argv[i], "-force")) { - vesa_force_mode = TRUE; - return 1; - } else if(!strcmp(argv[i], "-listmodes")) { - vesaListModes(); - exit(0); - } else if(!strcmp(argv[i], "-vesatest")) { - vesaTestMode(); - exit (0); - } else if(!strcmp(argv[i], "-swaprgb")) { - vesa_swap_rgb = TRUE; - return 1; - } else if(!strcmp(argv[i], "-shadow")) { - vesa_shadow = TRUE; - return 1; - } else if(!strcmp(argv[i], "-nolinear")) { - vesa_linear_fb = FALSE; - return 1; - } else if(!strcmp(argv[i], "-verbose")) { - vesa_verbose = TRUE; - return 1; - } else if(!strcmp(argv[i], "-force-text")) { - vesa_force_text = TRUE; - return 1; - } else if(!strcmp(argv[i], "-map-holes")) { - vesa_map_holes = TRUE; - return 1; - } else if(!strcmp(argv[i], "-no-map-holes")) { - vesa_map_holes = FALSE; - return 1; - } else if(!strcmp(argv[i], "-trash-font")) { - vesa_restore_font = FALSE; - return 1; - } - - return 0; -} diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h deleted file mode 100644 index 4cad3ac2a..000000000 --- a/hw/kdrive/vesa/vesa.h +++ /dev/null @@ -1,298 +0,0 @@ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.13 2002/09/29 23:39:47 keithp Exp $ */ - -#ifndef _VESA_H_ -#define _VESA_H_ - -#include "kdrive.h" -#include "shadow.h" -#include "vm86.h" -#ifdef RANDR -#include "randrstr.h" -#endif - -#define VESA_TEXT_SAVE (64*1024) - -#define MODE_SUPPORTED 0x01 -#define MODE_COLOUR 0x08 -#define MODE_GRAPHICS 0x10 -#define MODE_VGA 0x20 -#define MODE_LINEAR 0x80 - -#define MODE_DIRECT 0x1 - -#define MEMORY_TEXT 0 -#define MEMORY_CGA 1 -#define MEMORY_HERCULES 2 -#define MEMORY_PLANAR 3 -#define MEMORY_PSEUDO 4 -#define MEMORY_NONCHAIN 5 -#define MEMORY_DIRECT 6 -#define MEMORY_YUV 7 - -typedef struct _VesaMode { - int mode; /* mode number */ - int vbe; /* a VBE mode */ - int ModeAttributes; /* mode attributes */ - int NumberOfPlanes; /* number of memory planes */ - int BitsPerPixel; /* bits per pixel */ - int MemoryModel; /* memory model type */ - int RedMaskSize; /* size of direct color red mask in bits */ - int RedFieldPosition; /* bit position of lsb of red mask */ - int GreenMaskSize; /* size of direct color green mask in bits */ - int GreenFieldPosition; /* bit position of lsb of green mask */ - int BlueMaskSize; /* size of direct color blue mask in bits */ - int BlueFieldPosition; /* bit position of lsb of blue mask */ - int RsvdMaskSize; /* size of direct color reserved mask bits*/ - int RsvdFieldPosition; /* bit position of lsb of reserved mask */ - int DirectColorModeInfo; /* direct color mode attributes */ - int XResolution; /* horizontal resolution */ - int YResolution; /* vertical resolution */ - int BytesPerScanLine; /* bytes per scan line */ -} VesaModeRec, *VesaModePtr; - -#include "vbe.h" -#include "vga.h" - -typedef struct _VesaCardPriv { - int vbe; - VesaModePtr modes; - int nmode; - Vm86InfoPtr vi; - int vga_palette; - int old_vbe_mode; - int old_vga_mode; - VbeInfoPtr vbeInfo; - char text[VESA_TEXT_SAVE]; - CARD8 cmap[256*4]; -} VesaCardPrivRec, *VesaCardPrivPtr; - -#define VESA_LINEAR 0 -#define VESA_WINDOWED 1 -#define VESA_PLANAR 2 -#define VESA_MONO 3 - -typedef struct _VesaScreenPriv { - VesaModeRec mode; - Bool shadow; - Rotation randr; - int mapping; - int origDepth; - void *fb; - int fb_size; - CARD32 fb_phys; - PixmapPtr pShadow; -} VesaScreenPrivRec, *VesaScreenPrivPtr; - -extern int vesa_video_mode; -extern Bool vesa_force_mode; - -void -vesaReportMode (VesaModePtr mode); - -VesaModePtr -vesaGetModes (Vm86InfoPtr vi, int *ret_nmode); - -void -vesaTestMode (void); - -void * -vesaSetWindowPlanar(ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size); - -void * -vesaSetWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size); - -void * -vesaSetWindowWindowed (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size); - -void * -vesaWindowPlanar (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void * -vesaWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void * -vesaWindowWindowed (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void * -vesaWindowCga (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void -vesaUpdateMono (ScreenPtr pScreen, - shadowBufPtr pBuf); - -Bool -vesaCreateColormap16 (ColormapPtr pmap); - -void -vesaSetScreenSizes (ScreenPtr pScreen); - -Bool -vesaSetShadow (ScreenPtr pScreen); - - -void -vesaListModes(void); - -Bool -vesaInitialize(KdCardInfo *card, VesaCardPrivPtr priv); - -Bool -vesaCardInit(KdCardInfo *card); - -int -vesaDepth (VesaModePtr mode); - -Bool -vesaModeGood (KdScreenInfo *screen, - VesaModePtr a); - -int -vesaSizeError (KdScreenInfo *screen, - VesaModePtr a); - -Bool -vesaModeBetter (KdScreenInfo *screen, - VesaModePtr a, - VesaModePtr b); - -VesaModePtr -vesaSelectMode (KdScreenInfo *screen); - -Bool -vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv); - -Bool -vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr); - -Bool -vesaScreenInit(KdScreenInfo *screen); - -PixmapPtr -vesaGetPixmap (ScreenPtr pScreen); - -Bool -vesaMapFramebuffer (KdScreenInfo *screen); - -void -vesaUnmapFramebuffer (KdScreenInfo *screen); - -Bool -vesaInitScreen(ScreenPtr pScreen); - -Bool -vesaFinishInitScreen(ScreenPtr pScreen); - -Bool -vesaCreateResources (ScreenPtr pScreen); - -Bool -vesaSetMode (ScreenPtr pScreen, - VesaModePtr mode); - -Bool -vesaEnable(ScreenPtr pScreen); - -Bool -vesaDPMS (ScreenPtr pScreen, int mode); - -void -vesaDisable(ScreenPtr pScreen); - -void -vesaPreserve(KdCardInfo *card); - -void -vesaRestore(KdCardInfo *card); - -void -vesaCardFini(KdCardInfo *card); - -void -vesaScreenFini(KdScreenInfo *screen); - -int -vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries); - -int -vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries); - -void -vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); - -void -vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); - -int -vesaProcessArgument (int argc, char **argv, int i); - -#ifdef RANDR -Bool -vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations); - -Bool -vesaRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize); -Bool -vesaRandRInit (ScreenPtr pScreen); - -#endif - -Bool -toshibaDPMS (ScreenPtr pScreen, int mode); - -#endif /* _VESA_H_ */ diff --git a/hw/kdrive/vesa/vesainit.c b/hw/kdrive/vesa/vesainit.c deleted file mode 100644 index 45092add0..000000000 --- a/hw/kdrive/vesa/vesainit.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.7 2001/09/05 07:12:43 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vesa.h" - -const KdCardFuncs vesaFuncs = { - vesaCardInit, /* cardinit */ - vesaScreenInit, /* scrinit */ - vesaInitScreen, /* initScreen */ - vesaFinishInitScreen, /* finishInitScreen */ - vesaCreateResources, /* createRes */ - vesaPreserve, /* preserve */ - vesaEnable, /* enable */ - vesaDPMS, /* dpms */ - vesaDisable, /* disable */ - vesaRestore, /* restore */ - vesaScreenFini, /* scrfini */ - vesaCardFini, /* cardfini */ - - 0, /* initCursor */ - 0, /* enableCursor */ - 0, /* disableCursor */ - 0, /* finiCursor */ - 0, /* recolorCursor */ - - 0, /* initAccel */ - 0, /* enableAccel */ - 0, /* syncAccel */ - 0, /* disableAccel */ - 0, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; - -void -InitCard(char *name) -{ - KdCardAttr attr; - KdCardInfoAdd((KdCardFuncs *) &vesaFuncs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput(&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/vesa/vga.c b/hw/kdrive/vesa/vga.c deleted file mode 100644 index 500746774..000000000 --- a/hw/kdrive/vesa/vga.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vga.c,v 1.1 2000/10/20 00:19:51 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vesa.h" - -static const VesaModeRec vgaModes[] = { - { - 6, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR, - 1, 1, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 640, 200, 80, - }, - { - 0xd, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, - 4, 4, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 320, 200, 40, - }, - { - 0xe, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, - 4, 4, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 640, 200, 80, - }, - { - 0x10, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, - 4, 4, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 640, 350, 80, - }, - { - 0x11, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR, - 1, 1, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 640, 480, 80, - }, - { - 0x12, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, - 4, 4, MEMORY_PLANAR, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 640, 480, 80, - }, - { - 0x13, 0, - MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR | MODE_LINEAR, - 8, 8, MEMORY_PSEUDO, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 320, 200, 320, - }, -}; - -#define NUM_VGA_MODE (sizeof vgaModes / sizeof vgaModes[0]) - -int -VgaGetNmode (Vm86InfoPtr vi) -{ - return NUM_VGA_MODE; -} - -int -VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode) -{ - if (nmode > NUM_VGA_MODE) - nmode = NUM_VGA_MODE; - memcpy (mode, vgaModes, nmode * sizeof (VesaModeRec)); - return nmode; -} - -int -VgaSetMode(Vm86InfoPtr vi, int mode) -{ - int code; - - vi->vms.regs.eax = mode & 0x7f; - code = Vm86DoInterrupt (vi, 0x10); - if(code < 0) - return -1; - return 0; -} - -int -VgaGetMode (Vm86InfoPtr vi, int *mode) -{ - *mode = Vm86Memory (vi, 0x449); - return 0; -} - -void -VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask) -{ - asm volatile ("outb %b0,%w1" : : "a" (2), "d" (0x3c4)); - asm volatile ("outb %b0,%w1" : : "a" (mask), "d" (0x3c5)); -} - -void -VgaSetReadPlaneMap(Vm86InfoPtr vi, int map) -{ - asm volatile ("outb %b0,%w1" : : "a" (4), "d" (0x3ce)); - asm volatile ("outb %b0,%w1" : : "a" (map), "d" (0x3cf)); -} - -int -VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries) -{ - U8 *palette_scratch; - int mark; - int palette_base; - int i, j, code; - - if(number == 0) - return 0; - - if(first < 0 || number < 0 || first + number > 256) { - ErrorF("Cannot set %d, %d palette entries\n", first, number); - return -1; - } - - mark = Vm86MarkMemory (vi); - palette_base = Vm86AllocateMemory (vi, 3 * 256); - - palette_scratch = &LM(vi, palette_base); - - vi->vms.regs.eax = 0x1012; - vi->vms.regs.ebx = first; - vi->vms.regs.ecx = number; - vi->vms.regs.es = POINTER_SEGMENT(palette_base); - vi->vms.regs.edx = POINTER_OFFSET(palette_base); - j = 0; - i = 0; - while (number--) - { - palette_scratch[j++] = entries[i++] >> 2; - palette_scratch[j++] = entries[i++] >> 2; - palette_scratch[j++] = entries[i++] >> 2; - i++; - } - code = Vm86DoInterrupt(vi, 0x10); - Vm86ReleaseMemory (vi, mark); - - if(code < 0) - return -1; - return 0; -} - -int -VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries) -{ - U8 *palette_scratch; - int mark; - int palette_base; - int i, j, code; - - if(number == 0) - return 0; - - if(first < 0 || number < 0 || first + number > 256) { - ErrorF("Cannot get %d, %d palette entries\n", first, number); - return -1; - } - - mark = Vm86MarkMemory (vi); - palette_base = Vm86AllocateMemory (vi, 3 * 256); - - palette_scratch = &LM(vi, palette_base); - - vi->vms.regs.eax = 0x1017; - vi->vms.regs.ebx = first; - vi->vms.regs.ecx = number; - vi->vms.regs.es = POINTER_SEGMENT(palette_base); - vi->vms.regs.edx = POINTER_OFFSET(palette_base); - - code = VbeDoInterrupt10(vi); - if(code < 0) - return -1; - - j = 0; - i = 0; - while (number--) - { - entries[i++] = palette_scratch[j++] << 2; - entries[i++] = palette_scratch[j++] << 2; - entries[i++] = palette_scratch[j++] << 2; - entries[i++] = 0; - } - - Vm86ReleaseMemory (vi, mark); - - return 0; -} - -#define VGA_FB(vm) ((vm) < 8 ? 0xb8000 : 0xa0000) - -void * -VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size) -{ - *size = 0x10000 - bytes; - return &LM(vi,VGA_FB(vmode) + bytes); -} - -void * -VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *ret_phys) -{ - if (VGA_FB(vmode) == 0xa0000) - *size = 0x10000; - else - *size = 0x4000; - *ret_phys = VGA_FB(vmode); - return &LM(vi,VGA_FB(vmode)); -} - -void -VgaUnmapFramebuffer (Vm86InfoPtr vi) -{ -} diff --git a/hw/kdrive/vesa/vga.h b/hw/kdrive/vesa/vga.h deleted file mode 100644 index ca000904b..000000000 --- a/hw/kdrive/vesa/vga.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vga.h,v 1.1 2000/10/20 00:19:51 keithp Exp $ - * - * Copyright © 2000 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. - */ - -#ifndef _VGA_H_ -#define _VGA_H_ - -int -VgaGetNmode (Vm86InfoPtr vi); - -int -VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode); - -int -VgaSetMode(Vm86InfoPtr vi, int mode); - -int -VgaGetMode (Vm86InfoPtr vi, int *mode); - -void -VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask); - -void -VgaSetReadPlaneMap(Vm86InfoPtr vi, int map); - -int -VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries); - -int -VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries); - -void * -VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size); - -void * -VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *phys); - -void -VgaUnmapFramebuffer (Vm86InfoPtr vi); - -#endif /* _VGA_H_ */ diff --git a/hw/kdrive/vesa/vm86.c b/hw/kdrive/vesa/vm86.c deleted file mode 100644 index 85200fdad..000000000 --- a/hw/kdrive/vesa/vm86.c +++ /dev/null @@ -1,730 +0,0 @@ -/* - * $RCSId: xc/programs/Xserver/hw/kdrive/vesa/vm86.c,v 1.2 2002/02/19 00:18:05 keithp Exp $ - * - * Copyright © 2000 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. - */ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "vm86.h" - -#define PUSHW(vi, i) \ -{ vi->vms.regs.esp -= 2;\ - LMW(vi,MAKE_POINTER(vi->vms.regs.ss, vi->vms.regs.esp)) = i;} - -static int vm86old(struct vm86_struct *vms); -static int vm86_loop(Vm86InfoPtr vi); - -static const U8 rev_ints[32] = -{ 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0x80, -}; - -static const U8 retcode_data[2] = -{ 0xCD, 0xFF }; - -Vm86InfoPtr -Vm86Setup(int mapHoles) -{ - int devmem = -1, devzero = -1; - void *magicMem, *loMem, *hiMem; - void *hole1, *hole2; - U32 stack_base, ret_code; - Vm86InfoPtr vi = NULL; - - devmem = open("/dev/mem", O_RDWR); - if(devmem < 0) { - perror("open /dev/mem"); - goto fail; - } - - devzero = open("/dev/zero", O_RDWR); - if(devmem < 0) { - perror("open /dev/zero"); - goto fail; - } - - magicMem = MAP_FAILED; - loMem = MAP_FAILED; - hiMem = MAP_FAILED; - hole1 = MAP_FAILED; - hole2 = MAP_FAILED; - - - magicMem = mmap((void*)MAGICMEM_BASE, MAGICMEM_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, devmem, MAGICMEM_BASE); - - if(magicMem == MAP_FAILED) { - ErrorF("Couldn't map magic memory\n"); - goto unmapfail; - } - - if(mapHoles) { - hole1 = mmap((void*)HOLE1_BASE, HOLE1_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, devzero, HOLE1_BASE); - - if(hole1 == MAP_FAILED) { - ErrorF("Couldn't map first hole\n"); - goto unmapfail; - } - } - - loMem = mmap((void*)LOMEM_BASE, LOMEM_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, devzero, LOMEM_BASE); - if(loMem == MAP_FAILED) { - ErrorF("Couldn't map low memory\n"); - munmap(magicMem, MAGICMEM_SIZE); - goto unmapfail; - } - - if(mapHoles) { - hole2 = mmap((void*)HOLE2_BASE, HOLE2_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, devzero, HOLE2_BASE); - - if(hole2 == MAP_FAILED) { - ErrorF("Couldn't map first hole\n"); - goto unmapfail; - } - } - - hiMem = mmap((void*)HIMEM_BASE, HIMEM_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_SHARED | MAP_FIXED, - devmem, HIMEM_BASE); - if(hiMem == MAP_FAILED) { - ErrorF("Couldn't map high memory\n"); - goto unmapfail; - } - - vi = xalloc(sizeof(Vm86InfoRec)); - if (!vi) - goto unmapfail; - - vi->magicMem = magicMem; - vi->hole1 = hole1; - vi->loMem = loMem; - vi->hole2 = hole2; - vi->hiMem = hiMem; - vi->brk = LOMEM_BASE; - - stack_base = Vm86AllocateMemory(vi, STACK_SIZE); - if(stack_base == ALLOC_FAIL) - goto unmapfail; - ret_code = Vm86AllocateMemory(vi, sizeof(retcode_data)); - if(ret_code == ALLOC_FAIL) - goto unmapfail; - - vi->stack_base = stack_base; - vi->ret_code = ret_code; - - memset(&vi->vms, 0, sizeof(struct vm86_struct)); - vi->vms.flags = 0; - vi->vms.screen_bitmap = 0; - vi->vms.cpu_type = CPU_586; - memcpy(&vi->vms.int_revectored, rev_ints, sizeof(rev_ints)); - - iopl(3); - - if(devmem >= 0) - close(devmem); - if(devzero >= 0) - close(devzero); - - return vi; - -unmapfail: - if(magicMem != MAP_FAILED) munmap(magicMem, MAGICMEM_SIZE); - if(hole1 != MAP_FAILED) munmap(magicMem, HOLE1_SIZE); - if(loMem != MAP_FAILED) munmap(loMem, LOMEM_SIZE); - if(hole2 != MAP_FAILED) munmap(magicMem, HOLE2_SIZE); - if(hiMem != MAP_FAILED) munmap(hiMem, HIMEM_SIZE); -fail: - if(devmem >= 0) - close(devmem); - if(devzero >= 0) - close(devzero); - if(vi) - xfree(vi); - return NULL; -} - -void -Vm86Cleanup(Vm86InfoPtr vi) -{ - if(vi->magicMem != MAP_FAILED) munmap(vi->magicMem, MAGICMEM_SIZE); - if(vi->hole1 != MAP_FAILED) munmap(vi->magicMem, HOLE1_SIZE); - if(vi->loMem != MAP_FAILED) munmap(vi->loMem, LOMEM_SIZE); - if(vi->hole2 != MAP_FAILED) munmap(vi->magicMem, HOLE2_SIZE); - if(vi->hiMem != MAP_FAILED) munmap(vi->hiMem, HIMEM_SIZE); - xfree(vi); -} - -int -Vm86DoInterrupt(Vm86InfoPtr vi, int num) -{ - U16 seg, off; - int code; - - if(num < 0 || num>256) { - ErrorF("Interrupt %d doesn't exist\n"); - return -1; - } - seg = MMW(vi,num * 4 + 2); - off = MMW(vi,num * 4); - if(MAKE_POINTER(seg, off) < ROM_BASE || - MAKE_POINTER(seg, off) >= ROM_BASE + ROM_SIZE) { - ErrorF("Interrupt pointer doesn't point at ROM\n"); - return -1; - } - memcpy(&(LM(vi,vi->ret_code)), retcode_data, sizeof(retcode_data)); - vi->vms.regs.eflags = IF_MASK | IOPL_MASK; - vi->vms.regs.ss = POINTER_SEGMENT(vi->stack_base); - vi->vms.regs.esp = STACK_SIZE; - PUSHW(vi, IF_MASK | IOPL_MASK); - PUSHW(vi, POINTER_SEGMENT(vi->ret_code)); - PUSHW(vi, POINTER_OFFSET(vi->ret_code)); - vi->vms.regs.cs = seg; - vi->vms.regs.eip = off; - OsBlockSignals (); - code = vm86_loop(vi); - OsReleaseSignals (); - if(code < 0) { - ErrorF("vm86 failed (errno %d)\n", errno); - return -1; - } else if(code != 0) { - ErrorF("vm86 returned 0x%04X\n", code); - return -1; - } else - return 0; -} - -#define DEBUG_VBE 0 -#if DEBUG_VBE -#define DBG(x) ErrorF x; usleep(10*1000) -#else -#define DBG(x) -#endif - -static inline U8 -vm86_inb(U16 port) -{ - U8 value; - - if (port != 0x3da) - { - DBG(("inb 0x%04x", port)); - } - asm volatile ("inb %w1,%b0" : "=a" (value) : "d" (port)); - if (port != 0x3da) - { - DBG((" = 0x%02x\n", value)); - } - return value; -} - -static inline U16 -vm86_inw(U16 port) -{ - U16 value; - DBG(("inw 0x%04x", port)); - asm volatile ("inw %w1,%w0" : "=a" (value) : "d" (port)); - DBG((" = 0x%04x\n", value)); - return value; -} - -static inline U32 -vm86_inl(U16 port) -{ - U32 value; - DBG(("inl 0x%04x", port)); - asm volatile ("inl %w1,%0" : "=a" (value) : "d" (port)); - DBG((" = 0x%08x\n", value)); - return value; -} - -static inline void -vm86_outb(U16 port, U8 value) -{ -#if 0 - static U8 CR; - - if (port == 0x3d4) - CR = value; - if (port == 0x3d5 && CR == 0xa4) - { - DBG(("outb 0x%04x = 0x%02x (skipped)\n", port, value)); - return; - } -#endif - DBG(("outb 0x%04x = 0x%02x\n", port, value)); - asm volatile ("outb %b0,%w1" : : "a" (value), "d" (port)); -} - -static inline void -vm86_outw(U16 port, U16 value) -{ - DBG(("outw 0x%04x = 0x%04x\n", port, value)); - asm volatile ("outw %w0,%w1" : : "a" (value), "d" (port)); -} - -static inline void -vm86_outl(U16 port, U32 value) -{ - DBG(("outl 0x%04x = 0x%08x\n", port, value)); - asm volatile ("outl %0,%w1" : : "a" (value), "d" (port)); -} - -#define SEG_CS 1 -#define SEG_DS 2 -#define SEG_ES 3 -#define SEG_SS 4 -#define SEG_GS 5 -#define SEG_FS 6 -#define REP 1 -#define REPNZ 2 -#define SET_8(_x, _y) (_x) = ((_x) & ~0xFF) | ((_y) & 0xFF); -#define SET_16(_x, _y) (_x) = ((_x) & ~0xFFFF) | ((_y) & 0xFFFF); -#define INC_IP(_i) SET_16(regs->eip, (regs->eip + _i)) -#define AGAIN INC_IP(1); goto again; - -static int -vm86_emulate(Vm86InfoPtr vi) -{ - struct vm86_regs *regs = &vi->vms.regs; - U8 opcode; - int size; - int pref_seg = 0, pref_rep = 0, pref_66 = 0, pref_67 = 0; - - again: - if(!Vm86IsMemory(vi, MAKE_POINTER(regs->cs, regs->eip))) { - ErrorF("Trying to execute unmapped memory\n"); - return -1; - } - opcode = Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip)); - switch(opcode) { - case 0x2E: pref_seg = SEG_CS; AGAIN; - case 0x3E: pref_seg = SEG_DS; AGAIN; - case 0x26: pref_seg = SEG_ES; AGAIN; - case 0x36: pref_seg = SEG_SS; AGAIN; - case 0x65: pref_seg = SEG_GS; AGAIN; - case 0x64: pref_seg = SEG_FS; AGAIN; - case 0x66: pref_66 = 1; AGAIN; - case 0x67: pref_67 = 1; AGAIN; - case 0xF2: pref_rep = REPNZ; AGAIN; - case 0xF3: pref_rep = REP; AGAIN; - - case 0xEC: /* IN AL, DX */ - SET_8(regs->eax, vm86_inb(regs->edx & 0xFFFF)); - INC_IP(1); - break; - case 0xED: /* IN AX, DX */ - if(pref_66) - regs->eax = vm86_inl(regs->edx & 0xFFFF); - else - SET_16(regs->eax, vm86_inw(regs->edx & 0xFFFF)); - INC_IP(1); - break; - case 0xE4: /* IN AL, imm8 */ - SET_8(regs->eax, - vm86_inb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)))); - INC_IP(2); - break; - case 0xE5: /* IN AX, imm8 */ - if(pref_66) - regs->eax = - vm86_inl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))); - else - SET_16(regs->eax, - vm86_inw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)))); - INC_IP(2); - break; - case 0x6C: /* INSB */ - case 0x6D: /* INSW */ - if(opcode == 0x6C) { - Vm86WriteMemory(vi, MAKE_POINTER(regs->es, regs->edi), - vm86_inb(regs->edx & 0xFFFF)); - size = 1; - } else if(pref_66) { - Vm86WriteMemoryL(vi, MAKE_POINTER(regs->es, regs->edi), - vm86_inl(regs->edx & 0xFFFF)); - size = 4; - } else { - Vm86WriteMemoryW(vi, MAKE_POINTER(regs->es, regs->edi), - vm86_inw(regs->edx & 0xFFFF)); - size = 2; - } - if(regs->eflags & (1<<10)) - regs->edi -= size; - else - regs->edi += size; - if(pref_rep) { - if(pref_66) { - regs->ecx--; - if(regs->ecx != 0) - goto again; - } else { - SET_16(regs->ecx, regs->ecx - 1); - if((regs->ecx & 0xFFFF) != 0) - goto again; - } - } - INC_IP(1); - break; - - case 0xEE: /* OUT DX, AL */ - vm86_outb(regs->edx & 0xFFFF, regs->eax & 0xFF); - INC_IP(1); - break; - case 0xEF: /* OUT DX, AX */ - if(pref_66) - vm86_outl(regs->edx & 0xFFFF, regs->eax); - else - vm86_outw(regs->edx & 0xFFFF, regs->eax & 0xFFFF); - INC_IP(1); - break; - case 0xE6: /* OUT imm8, AL */ - vm86_outb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), - regs->eax & 0xFF); - INC_IP(2); - break; - case 0xE7: /* OUT imm8, AX */ - if(pref_66) - vm86_outl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), - regs->eax); - else - vm86_outw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), - regs->eax & 0xFFFF); - INC_IP(2); - break; - case 0x6E: /* OUTSB */ - case 0x6F: /* OUTSW */ - if(opcode == 0x6E) { - vm86_outb(regs->edx & 0xFFFF, - Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); - size = 1; - } else if(pref_66) { - vm86_outl(regs->edx & 0xFFFF, - Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); - size = 4; - } else { - vm86_outw(regs->edx & 0xFFFF, - Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); - size = 2; - } - if(regs->eflags & (1<<10)) - regs->edi -= size; - else - regs->edi += size; - if(pref_rep) { - if(pref_66) { - regs->ecx--; - if(regs->ecx != 0) - goto again; - } else { - SET_16(regs->ecx, regs->ecx - 1); - if((regs->ecx & 0xFFFF) != 0) - goto again; - } - } - INC_IP(1); - break; - - case 0x0F: - ErrorF("Hit 0F trap in VM86 code\n"); - return -1; - case 0xF0: - ErrorF("Hit lock prefix in VM86 code\n"); - return -1; - case 0xF4: - ErrorF("Hit HLT in VM86 code\n"); - return -1; - - default: - ErrorF("Unhandled GP fault in VM86 code (opcode = 0x%02X)\n", - opcode); - return -1; - } - return 0; -} -#undef SEG_CS -#undef SEG_DS -#undef SEG_ES -#undef SEG_SS -#undef SEG_GS -#undef SEG_FS -#undef REP -#undef REPNZ -#undef SET_8 -#undef SET_16 -#undef INC_IP -#undef AGAIN - -static int -vm86_loop(Vm86InfoPtr vi) -{ - int code; - - while(1) { - code = vm86old(&vi->vms); - switch(VM86_TYPE(code)) { - case VM86_SIGNAL: - continue; - case VM86_UNKNOWN: - code = vm86_emulate(vi); - if(code < 0) { - Vm86Debug(vi); - return -1; - } - break; - case VM86_INTx: - if(VM86_ARG(code) == 0xFF) - return 0; - else { - PUSHW(vi, vi->vms.regs.eflags) - PUSHW(vi, vi->vms.regs.cs); - PUSHW(vi, vi->vms.regs.eip); - vi->vms.regs.cs = MMW(vi,VM86_ARG(code) * 4 + 2); - vi->vms.regs.eip = MMW(vi,VM86_ARG(code) * 4); - } - break; - case VM86_STI: - ErrorF("VM86 code enabled interrupts\n"); - Vm86Debug(vi); - return -1; - default: - ErrorF("Unexpected result code 0x%X from vm86\n", code); - Vm86Debug(vi); - return -1; - } - } -} - -int -Vm86IsMemory(Vm86InfoPtr vi, U32 i) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - return 1; - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - return 1; - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - return 1; - else - return 0; -} - -U8 -Vm86Memory(Vm86InfoPtr vi, U32 i) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - return MM(vi, i); - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - return LM(vi, i); - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - return HM(vi, i); - else { - ErrorF("Reading unmapped memory at 0x%08X\n", i); - return 0; - } -} - -U16 -Vm86MemoryW(Vm86InfoPtr vi, U32 i) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - return MMW(vi, i); - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - return LMW(vi, i); - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - return HMW(vi, i); - else { - ErrorF("Reading unmapped memory at 0x%08X\n", i); - return 0; - } -} - -U32 -Vm86MemoryL(Vm86InfoPtr vi, U32 i) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - return MML(vi, i); - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - return LML(vi, i); - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - return HML(vi, i); - else { - ErrorF("Reading unmapped memory at 0x%08X\n", i); - return 0; - } -} - -void -Vm86WriteMemory(Vm86InfoPtr vi, U32 i, U8 val) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - MM(vi, i) = val; - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - LM(vi, i) = val; - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - HM(vi, i) = val; - else { - ErrorF("Writing unmapped memory at 0x%08X\n", i); - } -} - -void -Vm86WriteMemoryW(Vm86InfoPtr vi, U32 i, U16 val) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - MMW(vi, i) = val; - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - LMW(vi, i) = val; - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - HMW(vi, i) = val; - else { - ErrorF("Writing unmapped memory at 0x%08X\n", i); - } -} - -void -Vm86WriteMemoryL(Vm86InfoPtr vi, U32 i, U32 val) -{ - if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) - MML(vi, i) = val; - else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) - LML(vi, i) = val; - else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) - HML(vi, i) = val; - else { - ErrorF("Writing unmapped memory at 0x%08X\n", i); - } -} - -int -Vm86AllocateMemory(Vm86InfoPtr vi, int n) -{ - int ret; - if(n<0) { - ErrorF("Asked to allocate negative amount of memory\n"); - return vi->brk; - } - - n = (n + 15) & ~15; - if(vi->brk + n > LOMEM_BASE + LOMEM_SIZE) { - ErrorF("Out of low memory\n"); - exit(2); - } - ret = vi->brk; - vi->brk += n; - return ret; -} - -int -Vm86MarkMemory (Vm86InfoPtr vi) -{ - return vi->brk; -} - -void -Vm86ReleaseMemory (Vm86InfoPtr vi, int mark) -{ - vi->brk = mark; -} - -static int -vm86old(struct vm86_struct *vm) -{ - int res; - - asm volatile ( - "pushl %%ebx\n\t" - "movl %2, %%ebx\n\t" - "movl %1,%%eax\n\t" - "int $0x80\n\t" - "popl %%ebx" - : "=a" (res) : "n" (113), "r" (vm)); - if(res < 0) { - errno = -res; - res = -1; - } else - errno = 0; - return res; -} - -void -Vm86Debug(Vm86InfoPtr vi) -{ - struct vm86_regs *regs = &vi->vms.regs; - int i; - - ErrorF("eax=0x%08lX ebx=0x%08lX ecx=0x%08lX edx=0x%08lX\n", - regs->eax, regs->ebx, regs->ecx, regs->edx); - ErrorF("esi=0x%08lX edi=0x%08lX ebp=0x%08lX\n", - regs->esi, regs->edi, regs->ebp); - ErrorF("eip=0x%08lX esp=0x%08lX eflags=0x%08lX\n", - regs->eip, regs->esp, regs->eflags); - ErrorF("cs=0x%04lX ds=0x%04lX es=0x%04lX fs=0x%04lX gs=0x%04lX\n", - regs->cs, regs->ds, regs->es, regs->fs, regs->gs); - for(i=-7; i<8; i++) { - ErrorF(" %s%02X", - i==0?"->":"", - Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip + i))); - } - ErrorF("\n"); -} - -#ifdef NOT_IN_X_SERVER -static void -ErrorF(char *f, ...) -{ - va_list args; - va_start(args, f); - vfprintf(stderr, f, args); - va_end(args); -} -#endif diff --git a/hw/kdrive/vesa/vm86.h b/hw/kdrive/vesa/vm86.h deleted file mode 100644 index dce777b39..000000000 --- a/hw/kdrive/vesa/vm86.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * $RCSId: $ - * - * Copyright © 2000 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. - */ -/* -Copyright (c) 2000 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef _VM86_H_ -#define _VM86_H_ - -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <sys/vm86.h> -#include <sys/io.h> - -#ifdef NOT_IN_X_SERVER -#include <stdio.h> -#include <stdarg.h> -#include <malloc.h> -static void ErrorF(char*, ...); -#define xalloc(a) malloc(a) -#define xcalloc(a,b) calloc(a,b) -#define xfree(a) free(a) -#else -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xos.h> -#include "os.h" -#endif - -typedef unsigned char U8; -typedef unsigned short U16; -typedef unsigned int U32; - -/* The whole addressable memory */ -#define SYSMEM_BASE 0x00000 -#define SYSMEM_SIZE 0x100000 - -/* Interrupt vectors and BIOS data area */ -/* This is allocated privately from /dev/mem */ -#define MAGICMEM_BASE 0x00000 -#define MAGICMEM_SIZE 0x01000 - -/* The low memory, allocated privately from /dev/zero */ -/* 64KB should be enough for anyone, as they used to say */ -#define LOMEM_BASE 0x10000 -#define LOMEM_SIZE 0x10000 - -/* The video memory and BIOS ROM, allocated shared from /dev/mem */ -#define HIMEM_BASE 0xA0000 -#define HIMEM_SIZE (SYSMEM_BASE + SYSMEM_SIZE - HIMEM_BASE) - -#define HOLE1_BASE (MAGICMEM_BASE + MAGICMEM_SIZE) -#define HOLE1_SIZE (LOMEM_BASE - HOLE1_BASE) - -#define HOLE2_BASE (LOMEM_BASE + LOMEM_SIZE) -#define HOLE2_SIZE (HIMEM_BASE - HOLE2_BASE) - -/* The BIOS ROM */ -#define ROM_BASE 0xC0000 -#define ROM_SIZE 0x30000 - -#define STACK_SIZE 0x1000 - -#define POINTER_SEGMENT(ptr) (((unsigned int)ptr)>>4) -#define POINTER_OFFSET(ptr) (((unsigned int)ptr)&0x000F) -#define MAKE_POINTER(seg, off) (((((unsigned int)(seg))<<4) + (unsigned int)(off))) -#define MAKE_POINTER_1(lw) MAKE_POINTER(((lw)&0xFFFF0000)/0x10000, (lw)&0xFFFF) -#define ALLOC_FAIL ((U32)-1) - -typedef struct _Vm86InfoRec { - void *magicMem, *loMem, *hiMem; - void *hole1, *hole2; - U32 brk; - struct vm86_struct vms; - U32 ret_code, stack_base; -} Vm86InfoRec, *Vm86InfoPtr; - -#define LM(vi,i) (((char*)vi->loMem)[i-LOMEM_BASE]) -#define LMW(vi,i) (*(U16*)(&LM(vi,i))) -#define LML(vi,i) (*(U32*)(&LM(vi,i))) -#define MM(vi,i) (((char*)vi->magicMem)[i-MAGICMEM_BASE]) -#define MMW(vi,i) (*(U16*)(&MM(vi,i))) -#define MML(vi,i) (*(U32*)(&MM(vi,i))) -#define HM(vi,i) (((char*)vi->hiMem)[i-HIMEM_BASE]) -#define HMW(vi,i) (*(U16*)(&MM(vi,i))) -#define HML(vi,i) (*(U32*)(&MM(vi,i))) - -Vm86InfoPtr -Vm86Setup(int); - -void -Vm86Cleanup(Vm86InfoPtr vi); - -int -Vm86DoInterrupt(Vm86InfoPtr vi, int num); - -int -Vm86IsMemory(Vm86InfoPtr vi, U32 i); - -U8 -Vm86Memory(Vm86InfoPtr, U32); - -U16 -Vm86MemoryW(Vm86InfoPtr, U32); - -U32 -Vm86MemoryL(Vm86InfoPtr, U32); - -void -Vm86WriteMemory(Vm86InfoPtr, U32, U8); - -void -Vm86WriteMemoryW(Vm86InfoPtr, U32, U16); - -void -Vm86WriteMemoryL(Vm86InfoPtr, U32, U32); - -int -Vm86AllocateMemory(Vm86InfoPtr, int); - -int -Vm86MarkMemory (Vm86InfoPtr vi); - -void -Vm86ReleaseMemory (Vm86InfoPtr vi, int mark); - -void -Vm86Debug(Vm86InfoPtr vi); - -#endif /* _VM86_H_ */ diff --git a/hw/kdrive/vxworks/Imakefile b/hw/kdrive/vxworks/Imakefile deleted file mode 100644 index fea4f3416..000000000 --- a/hw/kdrive/vxworks/Imakefile +++ /dev/null @@ -1,15 +0,0 @@ -XCOMM $RCSId: $ -#include <Server.tmpl> - -SRCS = vxworks.c vxkbd.c vxkmouse.c - -OBJS = vxworks.o vxkbd.o vxkmouse.o - -INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \ - -I../../../fb -I../../../mi -I../../../include -I../../../os \ - -I$(EXTINCSRC) -I$(XINCLUDESRC) - -NormalLibraryObjectRule() -NormalLibraryTarget(vxworks,$(OBJS)) - -DependTarget() diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c deleted file mode 100644 index 4bcca02b1..000000000 --- a/hw/kdrive/vxworks/vxkbd.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Id: vxkbd.c,v 1.1 1999/11/24 08:35:24 keithp Exp $ - * - * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. - * - * Author: Keith Packard - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include "kkeymap.h" -#include <X11/keysym.h> -#include <inputstr.h> - -#define VXWORKS_WIDTH 2 - -KeySym VxWorksKeymap[] = { -/*7 f1 */ XK_F1, NoSymbol, -/*8 escape */ XK_Escape, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, -/*13 tab */ XK_Tab, NoSymbol, -/*14 ` */ XK_grave, XK_asciitilde, -/*15 f2 */ XK_F2, NoSymbol, - NoSymbol, NoSymbol, -/*17 lctrl */ XK_Control_L, NoSymbol, -/*18 lshift */ XK_Shift_L, NoSymbol, - NoSymbol, NoSymbol, -/*20 lock */ XK_Caps_Lock, NoSymbol, -/*21 q */ XK_Q, NoSymbol, -/*22 1 */ XK_1, XK_exclam, -/*23 f3 */ XK_F3, NoSymbol, - NoSymbol, NoSymbol, -/*25 lalt */ XK_Meta_L, XK_Alt_L, -/*26 z */ XK_Z, NoSymbol, -/*27 s */ XK_S, NoSymbol, -/*28 a */ XK_A, NoSymbol, -/*29 w */ XK_W, NoSymbol, -/*30 2 */ XK_2, XK_at, -/*31 f4 */ XK_F4, NoSymbol, - NoSymbol, NoSymbol, -/*33 c */ XK_C, NoSymbol, -/*34 x */ XK_X, NoSymbol, -/*35 d */ XK_D, NoSymbol, -/*36 e */ XK_E, NoSymbol, -/*37 4 */ XK_4, XK_dollar, -/*38 3 */ XK_3, XK_numbersign, -/*39 f5 */ XK_F5, NoSymbol, - NoSymbol, NoSymbol, -/*41 space */ XK_space, NoSymbol, -/*42 v */ XK_V, NoSymbol, -/*43 f */ XK_F, NoSymbol, -/*44 t */ XK_T, NoSymbol, -/*45 r */ XK_R, NoSymbol, -/*46 5 */ XK_5, XK_percent, -/*47 f6 */ XK_F6, NoSymbol, - NoSymbol, NoSymbol, -/*49 n */ XK_N, NoSymbol, -/*50 b */ XK_B, NoSymbol, -/*51 h */ XK_H, NoSymbol, -/*52 g */ XK_G, NoSymbol, -/*53 y */ XK_Y, NoSymbol, -/*54 6 */ XK_6, XK_asciicircum, -/*55 f7 */ XK_F7, NoSymbol, - NoSymbol, NoSymbol, -/*57 ralt */ XK_Meta_R, XK_Alt_R, -/*58 m */ XK_M, NoSymbol, -/*59 j */ XK_J, NoSymbol, -/*60 u */ XK_U, NoSymbol, -/*61 7 */ XK_7, XK_ampersand, -/*62 8 */ XK_8, XK_asterisk, -/*63 f8 */ XK_F8, NoSymbol, - NoSymbol, NoSymbol, -/*65 , */ XK_comma, XK_less, -/*66 k */ XK_K, NoSymbol, -/*67 i */ XK_I, NoSymbol, -/*68 o */ XK_O, NoSymbol, -/*69 0 */ XK_0, XK_parenright, -/*70 9 */ XK_9, XK_parenleft, -/*71 f9 */ XK_F9, NoSymbol, - NoSymbol, NoSymbol, -/*73 . */ XK_period, XK_greater, -/*74 / */ XK_slash, XK_question, -/*75 l */ XK_L, NoSymbol, -/*76 ; */ XK_semicolon, XK_colon, -/*77 p */ XK_P, NoSymbol, -/*78 - */ XK_minus, XK_underscore, -/*79 f10 */ XK_F10, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, -/*82 ' */ XK_apostrophe, XK_quotedbl, - NoSymbol, NoSymbol, -/*84 [ */ XK_bracketleft, XK_braceleft, -/*85 = */ XK_equal, XK_plus, -/*86 f11 */ XK_F11, NoSymbol, -/*87 sysrq */ XK_Sys_Req, XK_Print, -/*88 rctrl */ XK_Control_R, NoSymbol, -/*89 rshift */ XK_Shift_R, NoSymbol, -/*90 enter */ XK_Return, NoSymbol, -/*91 ] */ XK_bracketright, XK_braceright, -/*92 \ */ XK_backslash, XK_bar, - NoSymbol, NoSymbol, -/*94 f12 */ XK_F12, NoSymbol, -/*95 scrolllock*/ XK_Scroll_Lock, NoSymbol, -/*96 down */ XK_Down, NoSymbol, -/*97 left */ XK_Left, NoSymbol, -/*98 pause */ XK_Break, XK_Pause, -/*99 up */ XK_Up, NoSymbol, -/*100 delete */ XK_Delete, NoSymbol, -/*101 end */ XK_End, NoSymbol, -/*102 bs */ XK_BackSpace, NoSymbol, -/*103 insert */ XK_Insert, NoSymbol, - NoSymbol, NoSymbol, -/*105 np 1 */ XK_KP_End, XK_KP_1, -/*106 right */ XK_Right, NoSymbol, -/*107 np 4 */ XK_KP_Left, XK_KP_4, -/*108 np 7 */ XK_KP_Home, XK_KP_7, -/*109 pgdn */ XK_Page_Down, NoSymbol, -/*110 home */ XK_Home, NoSymbol, -/*111 pgup */ XK_Page_Up, NoSymbol, -/*112 np 0 */ XK_KP_Insert, XK_KP_0, -/*113 np . */ XK_KP_Delete, XK_KP_Decimal, -/*114 np 2 */ XK_KP_Down, XK_KP_2, -/*115 np 5 */ XK_KP_5, NoSymbol, -/*116 np 6 */ XK_KP_Right, XK_KP_6, -/*117 np 8 */ XK_KP_Up, XK_KP_8, -/*118 numlock */ XK_Num_Lock, NoSymbol, -/*119 np / */ XK_KP_Divide, NoSymbol, - NoSymbol, NoSymbol, -/*121 np enter */ XK_KP_Enter, NoSymbol, -/*122 np 3 */ XK_KP_Page_Down, XK_KP_3, - NoSymbol, NoSymbol, -/*124 np + */ XK_KP_Add, NoSymbol, -/*125 np 9 */ XK_KP_Page_Up, XK_KP_9, -/*126 np * */ XK_KP_Multiply, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, -/*132 np - */ XK_KP_Subtract, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, - NoSymbol, NoSymbol, -/*139 lwin */ XK_Super_L, NoSymbol, -/*140 rwin */ XK_Super_R, NoSymbol, -/*141 menu */ XK_Menu, NoSymbol, -}; - -void -VxWorksKeyboardLoad (void) -{ - KeySym *k; - - kdMinScanCode = 7; - kdKeymapWidth = VXWORKS_WIDTH; - kdMaxScanCode = 141; - memcpy (kdKeymap, VxWorksKeymap, sizeof (VxWorksKeymap)); -} - -static int kbdFd = -1; - -#include <errno.h> -#include <event.h> -#include <kbd_ioctl.h> - -extern KeybdCtrl defaultKeyboardControl; - -static void -VxWorksSetAutorepeat (unsigned char *repeats, Bool on) -{ - int i; - unsigned char mask; - int scan_code; - int key_code; - unsigned char realkc; - - if (on) - { - realkc = 1; - ioctl (kbdFd, KBD_ALL_REPEAT, &realkc); - for (scan_code = 7; scan_code <= 141; scan_code++) - { - key_code = scan_code + 1; - i = key_code >> 3; - mask = 1 << (key_code & 7); - if ((repeats[i] & mask) == 0) - { - realkc = scan_code; - ioctl (kbdFd, KBD_NO_REPEAT, &realkc); - } - } - } - else - { - realkc = 0; - ioctl (kbdFd, KBD_ALL_REPEAT, &realkc); - } -} - -int -VxWorksKeyboardInit (void) -{ - - kbdFd = open ("/dev/kbd", O_RDONLY, 0); - if (kbdFd < 0) - ErrorF ("keyboard open failure %d\n", errno); - VxWorksSetAutorepeat (defaultKeyboardControl.autoRepeats, TRUE); - return -1; -} - -void -VxWorksKeyboardFini (int fd) -{ - if (kbdFd >= 0) - { - close (kbdFd); - kbdFd = -1; - } -} - -void -VxWorksKeyboardRead (int fd) -{ -} - -void -VxWorksKeyboardLeds (int leds) -{ - DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice (); - KeybdCtrl *ctrl = &pKeyboard->kbdfeed->ctrl; - led_ioctl_info led_info; - int i; - - VxWorksSetAutorepeat (ctrl->autoRepeats, ctrl->autoRepeat); - for (i = 0; i < 3; i++) - { - led_info.bit_n = 1 << i; - led_info.OFF_or_ON = (leds & (1 << i)) != 0; - led_info.reversed = 0; - ioctl (kbdFd, KBD_SET_LED, &led_info); - } -} - -void -VxWorksKeyboardBell (int volume, int frequency, int duration) -{ -} - -KdKeyboardFuncs VxWorksKeyboardFuncs = { - VxWorksKeyboardLoad, - VxWorksKeyboardInit, - VxWorksKeyboardRead, - VxWorksKeyboardLeds, - VxWorksKeyboardBell, - VxWorksKeyboardFini, - 3, -}; diff --git a/hw/kdrive/vxworks/vxmouse.c b/hw/kdrive/vxworks/vxmouse.c deleted file mode 100644 index 75ed39bd0..000000000 --- a/hw/kdrive/vxworks/vxmouse.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Id: vxmouse.c,v 1.1 1999/11/24 08:35:24 keithp Exp $ - * - * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. - * - * Author: Keith Packard - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" -#include "Xpoll.h" -#include <event.h> -#include <smem.h> - -static unsigned long mouseState; - -#define BUTTON1 0x01 -#define BUTTON2 0x02 -#define BUTTON3 0x04 - -#include <errno.h> - -static int mouseFd = -1; - -static eventqueue *eventQueue; - -void -VxMouseRead (int mousePort) -{ - Event ev; - int dx, dy; - unsigned long flags; - unsigned long mask; - int n; - - while (eventQueue->head != eventQueue->tail) - { - ev = *eventQueue->head; - if (eventQueue->head >= &eventQueue->events[eventQueue->size-1]) - eventQueue->head = &eventQueue->events[0]; - else - eventQueue->head++; - switch (ev.e_type) { - case E_BUTTON: - switch (ev.e_device) { - case E_MOUSE: - switch (ev.e_key) { - case BUTTON1: - mask = KD_BUTTON_1; - break; - case BUTTON2: - mask = KD_BUTTON_2; - break; - case BUTTON3: - mask = KD_BUTTON_3; - break; - default: - mask = 0; - break; - } - if (ev.e_direction == E_KBUP) - mouseState &= ~mask; - else - mouseState |= mask; - KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA, 0, 0); - break; - case E_DKB: - KdEnqueueKeyboardEvent (ev.e_key, ev.e_direction == E_KBUP); - break; - } - break; - case E_MMOTION: - KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA, - ev.e_x, ev.e_y); - break; - } - } -} - -int -VxMouseInit (void) -{ - int mousePort; - unsigned long ev_size; - - mouseState = 0; - mousePort = open ("/dev/xdev", O_RDONLY, 0); - if (mousePort < 0) - ErrorF ("event port open failure %d\n", errno); - mouseFd = open ("/dev/mouse", O_RDONLY, 0); - if (mouseFd < 0) - ErrorF ("mouse open failure %d\n", errno); - if (eventQueue == 0) - { - ioctl (mousePort, EVENT_QUEUE_SMSIZE, &ev_size); - eventQueue = (eventqueue *) smem_get ("event", ev_size, (SM_READ|SM_WRITE)); - } - return mousePort; -} - -void -VxMouseFini (int mousePort) -{ - if (mousePort >= 0) - close (mousePort); - if (mouseFd >= 0) - { - close (mouseFd); - mouseFd = -1; - } -} - -KdMouseFuncs VxWorksMouseFuncs = { - VxMouseInit, - VxMouseRead, - VxMouseFini -}; diff --git a/hw/kdrive/vxworks/vxworks.c b/hw/kdrive/vxworks/vxworks.c deleted file mode 100644 index 9bfc9e278..000000000 --- a/hw/kdrive/vxworks/vxworks.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Id: vxworks.c,v 1.1 1999/11/24 08:35:24 keithp Exp $ - * - * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. - * - * Author: Keith Packard - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "kdrive.h" -#include <X11/keysym.h> - -int -VxWorksInit (void) -{ - return 1; -} - -void -VxWorksEnable (void) -{ -} - -Bool -VxWorksSpecialKey (KeySym sym) -{ - switch (sym) { - case XK_Sys_Req: - download(1, "setup", 0); - return TRUE; - case XK_Break: - download(1, "launcher", 0); - return TRUE; - case XK_Delete: - dispatchException |= DE_REBOOT; - return TRUE; - case XK_BackSpace: - dispatchException |= DE_RESET; - return TRUE; - } - return FALSE; -} - -void -VxWorksDisable (void) -{ -} - -void -VxWorksFini (void) -{ -} - -KdOsFuncs VxWorksFuncs = { - VxWorksInit, - VxWorksEnable, - VxWorksSpecialKey, - VxWorksDisable, - VxWorksFini, -}; - -void -OsVendorInit (void) -{ - KdOsInit (&VxWorksFuncs); -} |