diff options
author | dawes <dawes> | 2000-11-08 02:53:41 +0000 |
---|---|---|
committer | dawes <dawes> | 2000-11-08 02:53:41 +0000 |
commit | 23d67f1befe18a4aba21b7cae48f3d293cfed1ee (patch) | |
tree | 2cdf6024b3a671041104d5d95b909f6cfe1b751d | |
parent | f93d27aa9ffc3e26ebb937ccd8dfe3319315c70c (diff) |
Import of XFree86 4.0.1eX_4_0_1e
219 files changed, 28072 insertions, 2397 deletions
diff --git a/xc/config/cf/Imake.cf b/xc/config/cf/Imake.cf index 95d2cd7a5..8a975c1be 100644 --- a/xc/config/cf/Imake.cf +++ b/xc/config/cf/Imake.cf @@ -17,7 +17,14 @@ XCOMM $TOG: Imake.cf /main/30 1998/04/28 13:55:25 barstow $ * * 4. Create a .cf file with the name given by MacroFile. */ -XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.61 2000/09/19 12:46:03 eich Exp $ +XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.63 2000/11/06 19:24:00 dawes Exp $ + +#if defined(__APPLE__) +# undef __APPLE__ +# define MacroIncludeFile <darwin.cf> +# define MacroFile darwin.cf +# define DarwinArchitecture +#endif #if defined(clipper) || defined(__clipper__) # undef clipper @@ -133,6 +140,10 @@ XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.61 2000/09/19 12:46:03 eich Exp $ # endif # undef mc68000 # endif +# ifdef __powerpc__ +# define PpcArchitecture +# undef __powerpc__ +# endif #endif /* OpenBSD */ #ifdef __NetBSD__ @@ -169,6 +180,10 @@ XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.61 2000/09/19 12:46:03 eich Exp $ # define VaxArchitecture # undef __vax__ # endif +# ifdef __powerpc__ +# define PpcArchitecture +# undef __powerpc__ +# endif #endif /* NetBSD */ #ifdef __FreeBSD__ diff --git a/xc/config/cf/Imake.rules b/xc/config/cf/Imake.rules index 2c7afc516..3073d8060 100644 --- a/xc/config/cf/Imake.rules +++ b/xc/config/cf/Imake.rules @@ -5,7 +5,7 @@ XCOMM XCOMM XCOMM XCOMM -XCOMM rules: $XFree86: xc/config/cf/Imake.rules,v 3.79 2000/10/24 22:45:00 dawes Exp $ +XCOMM rules: $XFree86: xc/config/cf/Imake.rules,v 3.81 2000/11/02 02:51:05 dawes Exp $ /* * MACHINE-INDEPENDENT RULES; DO NOT MODIFY @@ -538,6 +538,7 @@ includes:: srclist @@\ all:: $(BUILDBINDIR)/binary binary @@\ @@\ $(BUILDBINDIR)/binary: binary @@\ + MakeDir($(BUILDBINDIR)) @@\ RemoveFile($@) @@\ cd $(BUILDBINDIR) && $(LN) $(BUILDBINTOP)/$(CURRENT_DIR)/binary . #endif /* LinkBuildBinary */ @@ -1319,7 +1320,7 @@ clean:: @@\ install.man:: file.suffix.html @@\ @SUF=`expr suffix \: '\(.\)'`; \ @@\ for i in aliases; do (set -x; \ @@\ - RemoveFile($(DESTDIR)$(DOCHTMLDIR)/$$i.suffix.html); \ @@\ + RemoveFile($(DESTDIR)$(DOCHTMLDIR)/$$i.$$SUF.html); \ @@\ (cd $(DESTDIR)$(DOCHTMLDIR); \ @@\ $(LN) file.$$SUF.html $$i.$$SUF.html)); \ @@\ done @@ -1585,7 +1586,7 @@ install:: @@\ sed -e 's:^.::' -e 's:[^/.][^/]*:..:'g`; \ @@\ cd Concat($(DESTDIR),opath); \ @@\ if [ -f lfile -a ! -h lfile ]; then \ @@\ - cp -p lfile Concat($(DESTDIR),npath/cfile; \ @@\ + cp -p lfile Concat($(DESTDIR),npath/cfile); \ @@\ fi; \ @@\ $(RM) -r lfile; \ @@\ $(LN) Concat($${RELPATH},npath/cfile) lfile; \ @@\ diff --git a/xc/config/cf/Imakefile b/xc/config/cf/Imakefile index 5d189e281..7440c8583 100644 --- a/xc/config/cf/Imakefile +++ b/xc/config/cf/Imakefile @@ -1,5 +1,5 @@ XCOMM $XConsortium: Imakefile /main/38 1996/11/07 14:43:46 kaleb $ -XCOMM $XFree86: xc/config/cf/Imakefile,v 3.23 2000/08/09 23:40:08 dawes Exp $ +XCOMM $XFree86: xc/config/cf/Imakefile,v 3.24 2000/11/02 02:51:06 dawes Exp $ XCOMM Some compilers generate fatal errors if an -L directory does XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use. @@ -122,6 +122,7 @@ usl.cf \ lynx.cf \ x386.cf \ QNX4.cf \ +darwin.cf \ xfree86.cf INSTFILES = $(RULEFILES) $(TMPLFILES) $(DEFFILES) $(CFFILES) $(LOCALFILES) diff --git a/xc/config/cf/OpenBSD.cf b/xc/config/cf/OpenBSD.cf index 2750309e1..be0215d2c 100644 --- a/xc/config/cf/OpenBSD.cf +++ b/xc/config/cf/OpenBSD.cf @@ -1,4 +1,4 @@ -XCOMM platform: $XFree86: xc/config/cf/OpenBSD.cf,v 3.39 2000/08/01 23:38:45 dawes Exp $ +XCOMM platform: $XFree86: xc/config/cf/OpenBSD.cf,v 3.40 2000/11/06 19:24:00 dawes Exp $ XCOMM #ifndef OSName @@ -19,6 +19,22 @@ XCOMM #endif XCOMM operating system: OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion) +#ifdef Ports + +#define BinDir /usr/local/bin +#define UsrLibDir /usr/local/lib +#define ManDirectoryRoot /usr/local/man +#define LdPreLib -L/usr/X11R6/lib -L/usr/local/lib +#define XpmLibDir /usr/X11R6/lib +#define XpmIncDir /usr/X11R6/include +#define ConfigDir /usr/X11R6/lib/X11/config +#define IncRoot /usr/local/include +#define TopXInclude -I/usr/X11R6/include +#define ImakeCmd imake -DPorts +#define DocDir /usr/local/share/doc + +#endif + /* * C library features */ @@ -39,7 +55,11 @@ XCOMM operating system: OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVe #define HasKrbIV YES #endif #define HasDlopen YES -#define DlLibrary /**/ +#ifndef PpcArchitecture +# define DlLibrary /**/ +#else +# define DlLibrary -ldl +#endif #define HasUsableFileMmap YES #define HasNCurses YES @@ -59,7 +79,7 @@ XCOMM operating system: OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVe /* * Multi-thread safe libs */ -#if OSMajorVersion == 2 && OSMinorVersion >= 6 || OSMajorVersion >= 3 +#if !defined(PpcArchitecture) && (OSMajorVersion == 2 && OSMinorVersion >= 6 || OSMajorVersion >= 3) # define HasPosixThreads YES # define ThreadedX YES # define SystemMTDefines -D_REENTRANT @@ -69,12 +89,12 @@ XCOMM operating system: OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVe # define BuildThreadStubLibrary YES # define NeedUIThrStubs YES # define ThreadsCompileFlags -pthread -# define ThreadsLibraries -lc_r +# define ThreadsLibraries -lc_r # endif #endif #if OSMajorVersion == 2 && OSMinorVersion > 6 || OSMajorVersion >= 3 -# define HasThreadSafeAPI YES +# define HasThreadSafeAPI YES #endif /* @@ -104,50 +124,68 @@ XCOMM operating system: OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVe #if defined(UseInstalled) #define DefaultCCOptions /**/ #else -#define DefaultCCOptions -ansi -Dasm=__asm GccWarningOptions +# ifdef PpcArchitecture +# define DefaultCCOptions -ansi -fsigned-char -Dasm=__asm GccWarningOptions +# else +# define DefaultCCOptions -ansi -Dasm=__asm GccWarningOptions +# endif #endif #define GccGasOption -DGCCUSESGAS #define AsmDefines -DUSE_GAS #ifdef i386Architecture -# ifndef DefaultGcc2i386Opt -# if (OSMajorVersion == 2 && OSMinorVersion >= 3) || OSMajorVersion > 2 - /* The GCC strength-reduce bug is fixed for OpenBSD 2.3 and later */ -# define DefaultGcc2i386Opt -O2 +# ifndef DefaultGcc2i386Opt +# if (OSMajorVersion == 2 && OSMinorVersion >= 3) || OSMajorVersion > 2 + /* The GCC strength-reduce bug is fixed for OpenBSD 2.3 and later */ +# define DefaultGcc2i386Opt -O2 +# endif # endif -# endif -# define OptimizedCDebugFlags DefaultGcc2i386Opt -# define ServerOSDefines XFree86ServerOSDefines -DDDXTIME -# define ServerExtraSysLibs -li386 -# define LdPostLib /**/ -#else -# define OptimizedCDebugFlags -O2 -# if defined(SparcArchitecture) || defined(AlphaArchitecture) +# define OptimizedCDebugFlags DefaultGcc2i386Opt +# define ServerOSDefines XFree86ServerOSDefines -DDDXTIME +# define ServerExtraSysLibs -li386 +# define LdPostLib /**/ +# define ServerExtraDefines GccGasOption XFree86ServerDefines +# ifndef XFree86ConsoleDefines +# define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT +# endif +#endif + +#ifdef SparcArchitecture +# define OptimizedCDebugFlags -O2 # define ServerOSDefines -DDDXOSINIT -# else -# define ServerOSDefines /**/ -# endif +# define ServerExtraDefines XFree86ServerDefines +#endif + +#ifdef AlphaArchitecture +# define OptimizedCDebugFlags -O2 +# define ServerOSDefines -DDDXOSINIT +# define ServerExtraDefines GccGasOption -D_XSERVER64 #endif -#if defined(i386Architecture) || defined(ArcArchitecture) -# define ServerExtraDefines GccGasOption XFree86ServerDefines -# ifndef XFree86ConsoleDefines -# if defined(ArcArchitecture) -# define XFree86ConsoleDefines -DPCCONS_SUPPORT -# else -# define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT + +#ifdef ArcArchitecture +# define ServerExtraDefines GccGasOption XFree86ServerDefines +# ifndef XFree86ConsoleDefines +# define XFree86ConsoleDefines -DPCCONS_SUPPORT # endif -# endif -#else -# if defined(SparcArchitecture) -# define ServerExtraDefines XFree86ServerDefines -# else -# if defined(AlphaArchitecture) -# define ServerExtraDefines GccGasOption -D_XSERVER64 -# else -# define ServerExtraDefines GccGasOption +#endif + +#ifdef PpcArchitecture +# define OptimizedCDebugFlags -O2 +# define ServerOSDefines XFree86ServerOSDefines -DDDXTIME -DDDXOSINIT +# define ServerExtraDefines GccGasOption XFree86ServerDefines +# define XkbServerDefines -DXKB_ALWAYS_USES_SOFT_REPEAT +# ifndef XFree86ConsoleDefines +# define XFree86ConsoleDefines -DWSCONS_SUPPORT # endif -# endif +#endif /* Ppc */ + +#ifndef ServerOSDefines +# define ServerOSDefines /**/ +#endif + +#ifndef ServerExtraDefines +# define ServerExtraDefines GccGasOption #endif #define StandardDefines -DCSRG_BASED @@ -302,6 +340,14 @@ install:: fonts.alias @@\ #endif /* InstallFontAliasesNoComment */ /* + * OpenBSD specific Imake Config files + */ +#ifndef LocalConfigFiles +#define LocalConfigFiles \ + OpenBSDLib.rules +#endif + +/* * Architecture specific sections - put all architecture dependent * options and setting here into the correct section */ @@ -550,17 +596,34 @@ install:: fonts.alias @@\ */ #ifdef PpcArchitecture -/* #define GccWarningOptions -Wall -Wpointer-artith */ +# define UseElfFormat YES -# include <xf86.rules> -# ifndef BuildServer -# define BuildServer NO -# endif +# if XFree86Devel +# define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wnested-externs +# else +# define GccWarningOptions -Wall -Wpointer-arith +# endif -# define HasSharedLibraries NO -# define UseElfFormat YES -# define BuildDynamicLoading NO +# if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 8) +# ifndef DoLoadableServer +# define DoLoadableServer YES +# endif +# define DevelDrivers cirrus ati + /* Support for USB Mices */ +# define UsbMouseSupport YES +# include <xfree86.cf> +# else /* 2.7 and earlier */ +# include <xf86.rules> +# ifndef BuildServer +# define BuildServer YES +# endif + +# define HasSharedLibraries NO +# define BuildDynamicLoading NO +# endif #endif /* PpcArchitecture */ /* @@ -650,5 +713,8 @@ install:: fonts.alias @@\ #endif /* This must come last */ -#include <bsdLib.rules> - +#if OSMajorVersion == 2 && OSMinorVersion >= 8 || OSMajorVersion > 2 +# include <OpenBSDLib.rules> +#else +# include <bsdLib.rules> +#endif diff --git a/xc/config/cf/OpenBSDLib.rules b/xc/config/cf/OpenBSDLib.rules new file mode 100644 index 000000000..9037183f2 --- /dev/null +++ b/xc/config/cf/OpenBSDLib.rules @@ -0,0 +1,162 @@ +XCOMM $OpenBSD: OpenBSDLib.rules,v 1.1 2000/10/09 20:43:58 matthieu Exp $ + + + + +/* + * OpenBSD shared library rules + */ + +XCOMM $XFree86: xc/config/cf/OpenBSDLib.rules,v 1.1 2000/11/06 19:24:00 dawes Exp $ + +#ifndef UseElfFormat +#define UseElfFormat NO +#endif + +#ifndef HasSharedLibraries +#define HasSharedLibraries YES +#endif +#ifndef ForceNormalLib +#define ForceNormalLib YES +#endif + +#ifndef BaseShLibReqs +#define BaseShLibReqs /* -lc implied by $(CC) */ +#endif + +#ifndef SharedDataSeparation +#define SharedDataSeparation NO +#endif +#ifndef SharedCodeDef +#define SharedCodeDef /**/ +#endif +#ifndef SharedLibraryDef +#define SharedLibraryDef /**/ +#endif +#ifndef ShLibIncludeFile +#define ShLibIncludeFile <bsdLib.tmpl> +#endif +#ifndef SharedLibraryLoadFlags +#define SharedLibraryLoadFlags -shared PositionIndependentCFlags -Wl,-rpath,$(USRLIBDIR) +#endif +#ifndef PositionIndependentCFlags +#define PositionIndependentCFlags -fPIC +#endif +#ifndef PositionIndependentCplusplusFlags +#define PositionIndependentCplusplusFlags -fPIC +#endif +#if UseElfFormat +#ifndef ExtraLoadFlags +#ifdef UseInstalled +#define ExtraLoadFlags -Wl,-rpath,$(USRLIBDIRPATH) +#else +#define ExtraLoadFlags -Wl,-rpath,$(USRLIBDIRPATH) -Wl,-rpath-link,$(BUILDLIBDIR) +#endif +#endif +#endif +/* + * InstallSharedLibrary - generate rules to install the shared library. + * NOTE: file must be executable, hence "INSTBINFLAGS" + */ +#ifndef InstallSharedLibrary +#define InstallSharedLibrary(libname,rev,dest) @@\ +install:: Concat(lib,libname.so.rev) @@\ + MakeDir($(DESTDIR)dest) @@\ + $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest +#endif /* InstallSharedLibrary */ + +/* + * InstallSharedLibraryData - generate rules to install the shared library data + */ +#ifndef InstallSharedLibraryData +#define InstallSharedLibraryData(libname,rev,dest) +#endif /* InstallSharedLibraryData */ + + +/* + * SharedLibraryTarget - generate rules to create a shared library; + * build it into a different name so that we do not hose people by having + * the library gone for long periods. + */ +#ifndef SharedLibraryTarget +#ifdef UseInstalled +#define LinkBuildSonameLibrary(lib) true +#else +#define LinkBuildSonameLibrary(lib) (RemoveFile($(BUILDLIBDIR)/lib); \ + cd $(BUILDLIBDIR); $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/lib .) +#endif + +#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ +AllTarget(Concat(lib,libname.so.rev)) @@\ + @@\ +Concat(lib,libname.so.rev): solist @@\ + $(RM) $@~ @@\ + set -x; \ @@\ + (cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) -Wl,-soname,$@\ @@\ + solist $(REQUIREDLIBS) BaseShLibReqs); @@\ + LinkBuildSonameLibrary($@) @@\ + $(RM) $@ @@\ + $(MV) $@~ $@ @@\ + @@\ +clean:: @@\ + $(RM) Concat(lib,libname.so.rev) + +#endif /* SharedLibraryTarget */ + + +/* + * SharedDepLibraryTarget - generate rules to create a shared library. + */ +#ifndef SharedDepLibraryTarget +#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up) @@\ +AllTarget(Concat(lib,libname.so.rev)) @@\ + @@\ +Concat(lib,libname.so.rev): deplist $(EXTRALIBRARYDEPS) @@\ + $(RM) $@~ @@\ + (cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\ + $(RM) $@ @@\ + $(MV) $@~ $@ @@\ + LinkBuildLibrary($@) @@\ + @@\ +clean:: @@\ + $(RM) Concat(lib,libname.so.rev) + +#endif /* SharedDepLibraryTarget */ + +#ifndef SharedDepModuleTarget +#define SharedDepModuleTarget(name,deps,solist) @@\ +AllTarget(name) @@\ + @@\ +name: deps @@\ + $(RM) $@~ @@\ + $(CC) -o $@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) @@\ + $(RM) $@ @@\ + $(MV) $@~ $@ @@\ + @@\ +clean:: @@\ + $(RM) name + +#endif /* SharedDepModuleTarget */ + +/* + * SharedLibraryDataTarget - generate rules to create shlib data file; + */ +#ifndef SharedLibraryDataTarget +#define SharedLibraryDataTarget(libname,rev,salist) +#endif /* SharedLibraryTarget */ + +/* + * DynamicModuleTarget - build a module to be dynamically loaded + */ +#ifdef DynamicModuleTarget +#undef DynamicModuleTarget +#define DynamicModuleTarget(module,modlist) @@\ +AllTarget(module) @@\ + @@\ +module: modlist @@\ + RemoveFile($@) @@\ + $(CC) -o $@ $(SHLIBLDFLAGS) modlist @@\ + @@\ +clean:: @@\ + RemoveFile(module) +#endif /* DynamicModuleTarget */ diff --git a/xc/config/cf/X11.rules b/xc/config/cf/X11.rules index 97745c14e..cc959fe8d 100644 --- a/xc/config/cf/X11.rules +++ b/xc/config/cf/X11.rules @@ -1,7 +1,7 @@ XCOMM $TOG: X11.rules /main/4 1997/04/30 15:23:24 kaleb $ -XCOMM $XFree86: xc/config/cf/X11.rules,v 1.4 1997/09/09 11:56:20 hohndel Exp $ +XCOMM $XFree86: xc/config/cf/X11.rules,v 1.5 2000/11/06 19:24:00 dawes Exp $ /* Note whether we are the top level project. */ #ifndef SeenTopLevelProject @@ -67,14 +67,18 @@ XCOMM $XFree86: xc/config/cf/X11.rules,v 1.4 1997/09/09 11:56:20 hohndel Exp $ #endif #define LdPostLibs LdPostLib XLdPostLibs -#if ImportX11 -# define TopXInclude -I$(TOP)/imports/x11/include -#elif !UseInstalledX11 -# define TopXInclude -I$(TOP)/exports/include -#elif defined(X11ProjectRoot) -# define TopXInclude -I$(XPROJECTROOT)/include +#ifndef TopXInclude +# if ImportX11 +# define TopXInclude -I$(TOP)/imports/x11/include +# elif !UseInstalledX11 +# define TopXInclude -I$(TOP)/exports/include #else -# define TopXInclude /**/ +# ifdef X11ProjectRoot +# define TopXInclude -I$(XPROJECTROOT)/include +# else +# define TopXInclude /**/ +# endif +# endif #endif #ifdef TopIncludes # undef TopIncludes diff --git a/xc/config/cf/X11.tmpl b/xc/config/cf/X11.tmpl index 3ade6a7f7..bfaa77f72 100644 --- a/xc/config/cf/X11.tmpl +++ b/xc/config/cf/X11.tmpl @@ -5,7 +5,7 @@ XCOMM XCOMM XCOMM XCOMM -XCOMM $XFree86: xc/config/cf/X11.tmpl,v 1.78 2000/10/24 18:07:33 dawes Exp $ +XCOMM $XFree86: xc/config/cf/X11.tmpl,v 1.79 2000/11/02 20:39:05 dawes Exp $ /*************************************************************************** * * @@ -535,6 +535,9 @@ FCHOWN_DEFINES = -DHAS_FCHOWN #ifndef MesaSrcDir #define MesaSrcDir $(TOP)/extras/Mesa #endif +#ifndef OglSampleSrcDir +#define OglSampleSrcDir $(TOP)/extras/ogl-sample +#endif #ifndef ShmDefines #if HasShm #define ShmDefines -DMITSHM @@ -1195,6 +1198,7 @@ XCOMM X Window System make variables; these need to be coordinated with rules FTSOURCEDIR = FreeTypeSrcDir XTTSOURCEDIR = XTrueTypeSrcDir MESASRCDIR = MesaSrcDir + OGLSAMPLESRCDIR = OglSampleSrcDir PSWRAPSRC = $(XTOP)/config/pswrap TRANSCOMMSRC = $(LIBSRC)/xtrans TRANS_INCLUDES = -I$(TRANSCOMMSRC) diff --git a/xc/config/cf/darwin.cf b/xc/config/cf/darwin.cf new file mode 100644 index 000000000..f3f507cac --- /dev/null +++ b/xc/config/cf/darwin.cf @@ -0,0 +1,104 @@ +XCOMM $XFree86: xc/config/cf/darwin.cf,v 1.1 2000/11/02 02:51:06 dawes Exp $ + +/* Darwin / MacOS-X configuration by John Carmack <johnc@idsoftware.com> */ + +/* imake determines the default values by parsing uname */ +#define OSName DefaultOSName +#define OSMajorVersion DefaultOSMajorVersion +#define OSMinorVersion DefaultOSMinorVersion +#define OSTeenyVersion 0 + +#define HasSnprintf YES +#define HasPutenv YES +#define HasBSD44Sockets YES +#define BuildGlxExt NO +#ifndef HasShm +# define HasShm YES +#endif + +/* + * This enables some settings for developers. + */ +#define XFree86Devel NO + +/* we don't need -lm */ +#define MathLibrary /**/ + +/* we don't have a termcap library */ +#define TermcapLibrary /**/ + +/* we don't have a dbm library */ +#define DBMLibrary /**/ + +/* our cpp isn't in /lib/cpp */ +#define CppCmd /usr/bin/cpp + +/* we have a gcc compatible compiler, but its not called gcc */ +#define CcCmd /usr/bin/cc + +/* if -c isn't passed, there are problems with the cfb libs when + * they include an object file without any symbols + */ +#define RanlibCmd ranlib -c + +/* uncommenting this line will get -g instead of -O, which builds + * a lot faster and gets debug info + */ +#if 0 +#define DefaultCDebugFlags -g +#endif + +/* default flags to pass to cc */ +#if XFree86Devel +# define DefaultCCOptions -Wall -Wpointer-arith -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wredundant-decls -Wnested-externs +#else +# define DefaultCCOptions -Wall -Wpointer-arith +#endif + +/* a lot of xfree86 code needs __powerpc__ to avoid doing outport asm + * + * __DARWIN__ will be used for platform specific #ifdefs that can't + * be handled by existing X defines + * + * there is an unfortunate symbol collision with the appkit for TIFFFaxBlackCodes + * + * We need to define BSD44SOCKETS to get unix domain socket namelen calculated right + */ +#define StandardDefines -D__powerpc__ -D__DARWIN__ + +/* programs/rgb/rgb.h and others needs this */ +#define HasNdbm YES + +/* set this to NO to just build the client libs, which should work without + * having to write any platform specific code. + */ +#define BuildServer YES + +/* our custom X server */ +#define XDarwinServer YES + +/* pex? bah. I'm not going to bother getting the device + * dependent part of this working. If I get the time, i'll + * get glx working instead. + */ +#define BuildPexExt NO + +/* no direct graphics extension */ +#define BuildXF86DGA NO + +/* no extra tablets and weird input devices */ +#define BuildXInputExt NO + +/* no Display Power Management extension */ +#define BuildDPMSExt NO + +/* no Render extension */ +#define BuildRender NO + +#define BuildXvExt NO + +/* include all the xfree rules */ +/* I haven't tracked down why this is needed, but it is... */ +#include <xfree86.cf> diff --git a/xc/config/cf/xf86.rules b/xc/config/cf/xf86.rules index 98c11ac2f..b277d40c6 100644 --- a/xc/config/cf/xf86.rules +++ b/xc/config/cf/xf86.rules @@ -1,5 +1,5 @@ XCOMM $XConsortium: xf86.rules /main/9 1996/10/31 14:54:26 kaleb $ -XCOMM $XFree86: xc/config/cf/xf86.rules,v 3.31 2000/03/31 22:55:15 dawes Exp $ +XCOMM $XFree86: xc/config/cf/xf86.rules,v 3.32 2000/10/30 23:02:06 tsi Exp $ /* * These rules are needed to build the XFree86 X Servers @@ -111,7 +111,10 @@ list: $(ICONFIGFILES) @@\ DRIVERS="drivers"; \ @@\ if [ x"$$DRIVERS" != x ]; then \ @@\ for i in $$DRIVERS; do \ @@\ - echo $$i/$${i}_drv.o >> list; \ @@\ + DRIVER="$$i/*_drv.o"; \ @@\ + for j in $$DRIVER; do \ @@\ + echo $$j >> list; \ @@\ + done; \ @@\ done; \ @@\ else \ @@\ echo "" > list; \ @@\ diff --git a/xc/config/cf/xf86site.def b/xc/config/cf/xf86site.def index e61f074ec..137400d77 100644 --- a/xc/config/cf/xf86site.def +++ b/xc/config/cf/xf86site.def @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/config/cf/xf86site.def,v 3.164 2000/10/24 18:07:34 dawes Exp $ +XCOMM $XFree86: xc/config/cf/xf86site.def,v 3.165 2000/11/02 16:48:05 tsi Exp $ /******************************************************************************/ /* * This file is to provide a quick method for most people to change the @@ -254,9 +254,9 @@ XCOMM $XFree86: xc/config/cf/xf86site.def,v 3.164 2000/10/24 18:07:34 dawes Exp #define XF86CardDrivers mga glint nv tga s3virge sis rendition \ neomagic i740 tdfx \ cirrus tseng trident chips apm \ - GlideDriver fbdev \ - ati i128 r128 AgpGartDrivers cyrix \ - vga XF86OSCardDrivers XF86ExtraCardDrivers + GlideDriver fbdev i128 \ + ati AgpGartDrivers DevelDrivers cyrix \ + vesa vga XF86OSCardDrivers XF86ExtraCardDrivers */ /* diff --git a/xc/config/cf/xfree86.cf b/xc/config/cf/xfree86.cf index 396efa14b..9f07a6e3e 100644 --- a/xc/config/cf/xfree86.cf +++ b/xc/config/cf/xfree86.cf @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/config/cf/xfree86.cf,v 3.318 2000/10/20 14:58:56 alanh Exp $ +XCOMM $XFree86: xc/config/cf/xfree86.cf,v 3.324 2000/11/06 19:24:00 dawes Exp $ /* * This configuration file contains all of the configuration * information for the XFree86 based X Servers. @@ -30,6 +30,9 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ #ifndef XConfigDir #define XConfigDir $(LIBDIR) #endif +#ifndef XLogFile +#define XLogFile XFree86 +#endif /* * Default settings for which X Servers to build. @@ -40,10 +43,10 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ #if 1 #define XInputDrivers mouse digitaledge dynapro elographics \ microtouch mutouch spaceorb summa \ - wacom void + wacom void citron #else #define XInputDrivers mouse digitaledge dynapro elo2300 \ - elographics magellan \ + elographics magellan citron \ microtouch mutouch spaceorb summa wacom void #endif #endif @@ -174,7 +177,7 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ neomagic i740 tdfx \ cirrus tseng trident chips apm \ GlideDriver fbdev i128 \ - r128 ati AgpGartDrivers DevelDrivers cyrix \ + ati AgpGartDrivers DevelDrivers cyrix \ vesa vga XF86OSCardDrivers XF86ExtraCardDrivers # endif #endif @@ -360,13 +363,13 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ /* Pure PCI drivers should go first */ # ifndef XF86CardDrivers # define XF86CardDrivers mga tdfx glint s3virge rendition tga \ - r128 DevelDrivers vga \ + nv DevelDrivers vga \ XF86OSCardDrivers XF86ExtraCardDrivers # endif #endif /* - * For Motorola 68k and PPC (currently Linux & LynxOS) + * For Motorola 68k and PPC (currently Linux, LynxOS and Net/OpenBSD) */ #if defined(PpcArchitecture) || defined(Mc68020Architecture) # ifndef XF86Server @@ -444,7 +447,7 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ /* Pure PCI drivers should go first */ # ifndef XF86CardDrivers -# define XF86CardDrivers r128 mga glint s3virge sis \ +# define XF86CardDrivers mga glint s3virge sis \ trident chips fbdev \ DevelDrivers vga \ XF86OSCardDrivers XF86ExtraCardDrivers diff --git a/xc/config/imake/imakemdep.h b/xc/config/imake/imakemdep.h index a048d07e0..abff45764 100644 --- a/xc/config/imake/imakemdep.h +++ b/xc/config/imake/imakemdep.h @@ -20,7 +20,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/config/imake/imakemdep.h,v 3.43 2000/09/19 12:46:04 eich Exp $ */ +/* $XFree86: xc/config/imake/imakemdep.h,v 3.44 2000/11/02 02:51:08 dawes Exp $ */ /* @@ -227,6 +227,11 @@ in this Software without prior written authorization from The Open Group. #define FIXUP_CPP_WHITESPACE #endif +#if defined(__APPLE__) +#define DEFAULT_CPP "/usr/bin/cpp" +#endif + + #if defined(Lynx) /* On LynxOS 2.4.0 imake gets built with the old "legacy" * /bin/cc which has a rather pedantic builtin preprocessor. @@ -656,6 +661,11 @@ char *cpp_argv[ARGUMENTS] = { #if defined(MIPS) "-DMIPS", #endif + +#if defined(__APPLE__) + "-D__DARWIN__", +#endif + #endif }; @@ -700,6 +710,12 @@ char *cpp_argv[ARGUMENTS] = { # define DEFAULT_OS_MINOR_REV "v %*d.%1s" # define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]" # define DEFAULT_OS_NAME "srvm %[^\n]" +#elif defined(__APPLE__) +/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */ +# define DEFAULT_OS_MAJOR_REV "r %[0-9]" +# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]" +# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]" /* this will just get 0 */ +# define DEFAULT_OS_NAME "s %[^\n]" #elif defined(__osf__) /* uname -r returns "Wx.y", e.g. "V3.2" or "T4.0" */ # define DEFAULT_OS_MAJOR_REV "r %*[^0-9]%[0-9]" @@ -1093,6 +1109,17 @@ struct symtab predefs[] = { # ifdef __s390__ {"__s390__", "1"}, # endif +#if defined(__ppc__) + {"__ppc__", "1"}, +#endif +#if defined(__BIG_ENDIAN__) + {"__BIG_ENDIAN__", "1"}, +#endif +#if defined(__LITTLE_ENDIAN__) + {"__LITTLE_ENDIAN__", "1"}, +#endif + + /* add any additional symbols before this line */ {NULL, NULL} }; diff --git a/xc/config/util/xmkmf.cpp b/xc/config/util/xmkmf.cpp index d32a834d8..20546b916 100644 --- a/xc/config/util/xmkmf.cpp +++ b/xc/config/util/xmkmf.cpp @@ -1,5 +1,6 @@ XCOMM!/bin/sh +XCOMM $XFree86: xc/config/util/xmkmf.cpp,v 1.3 2000/11/06 21:57:10 dawes Exp $ XCOMM XCOMM make a Makefile from an Imakefile from inside or outside the sources XCOMM @@ -11,13 +12,24 @@ configdirspec=CONFIGDIRSPEC topdir= curdir=. do_all= +imake_defines= -case "$1" in --a) - do_all="yes" - shift - ;; -esac +while [ $# -gt 0 ] +do + case "$1" in + -D*) + imake_defines="$imake_defines $1" + shift + ;; + -a) + do_all="yes" + shift + ;; + *) + break + ;; + esac +done case $# in 0) ;; @@ -41,10 +53,10 @@ else args="-I$topdir/config/cf -DTOPDIR=$topdir -DCURDIR=$curdir" fi -echo imake $args +echo imake $imake_defines $args case "$do_all" in yes) - imake $args && + imake $imake_defines $args && echo "make Makefiles" && make Makefiles && echo "make includes" && @@ -53,6 +65,6 @@ yes) make depend ;; *) - imake $args + imake $imake_defines $args ;; esac diff --git a/xc/extras/ogl-sample/README.XF86 b/xc/extras/ogl-sample/README.XF86 new file mode 100644 index 000000000..54334cff0 --- /dev/null +++ b/xc/extras/ogl-sample/README.XF86 @@ -0,0 +1,14 @@ + +This is an import of selected parts of SGI's ogl-sample distribution, +which is available from their CVS repository at :pserver:cvs@oss.sgi.com/cvs. + +Currently only the GLw components have been imported. Others may be +imported at a later date. + +When importing, use the vendor tag OGL_SAMPLE, and tag OGL_SAMPLE-yyyymmdd, +where yyyymmdd indicates the date of the snapshot from the ogl-sample +CVS repository. + + + +$XFree86: xc/extras/ogl-sample/README.XF86,v 1.2 2000/11/06 21:57:10 dawes Exp $ diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/Distfile b/xc/extras/ogl-sample/main/doc/man/manglw/Distfile new file mode 100755 index 000000000..8a5002e2d --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/Distfile @@ -0,0 +1,13 @@ +# +# $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +# $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/doc/man/manglw/Attic/Distfile,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +# + +DISTDIR_SI = /xc/doc/man/GL/glw + +DISTFILES_SI = \ + glwcreatemdrawingarea.3gl \ + glwdrawingarea.3gl \ + glwdrawingareamakecurrent.3gl \ + glwdrawingareaswapbuffers.3gl \ + $(NULL) diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/GNUmakefile b/xc/extras/ogl-sample/main/doc/man/manglw/GNUmakefile new file mode 100755 index 000000000..39baa7fb4 --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/GNUmakefile @@ -0,0 +1,85 @@ +#!gmake +# +# License Applicability. Except to the extent portions of this file are +# made subject to an alternative license as permitted in the SGI Free +# Software License B, Version 1.1 (the "License"), the contents of this +# file are subject only to the provisions of the License. You may not use +# this file except in compliance with the License. You may obtain a copy +# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +# +# http://oss.sgi.com/projects/FreeB +# +# Note that, as provided in the License, the Software is distributed on an +# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +# PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +# +# Original Code. The Original Code is: OpenGL Sample Implementation, +# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +# Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +# Copyright in any portions created by third parties is as indicated +# elsewhere herein. All Rights Reserved. +# +# Additional Notice Provisions: The application programming interfaces +# established by SGI in conjunction with the Original Code are The +# OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +# April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +# 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +# Window System(R) (Version 1.3), released October 19, 1998. This software +# was created using the OpenGL(R) version 1.2.1 Sample Implementation +# published by SGI, but has not been independently verified as being +# compliant with the OpenGL(R) version 1.2.1 Specification. +# +# $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +# $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/doc/man/manglw/Attic/GNUmakefile,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ + +COMMONPREF = standard +include $(ROOT)/usr/include/make/commondefs + +DEPTH = .. +LANGOPT = c +PREFIX = GLw +IDB_PATH = /usr/share/catman/g_man/cat3/glw + +MANPREF = man +include $(DEPTH)/mandefs + +APIFILE = $(ROOT)/usr/include/GL/gl.h + +VERSION = Version 1.0 +DATE = Aug 1998 +MMFLAGS = -rs2 + +LEGALSUF1 = gl# +LEGALSUF2 = gl# +LEGALSUF3 = gl# +LEGALSUF4 = gl# +LEGALSUF5 = gl# + +LOCALPRINTLISTFILTER = | sed -e '/^intro\.p$$/d' | (echo intro.p ; cat ) + +default: + $(MAKE) manpages + +headers headers_install libs libs_install apps: + +distsi: default + $(MAKE) $(COMMONPREF)$@ + +distoss: + $(MAKE) $(COMMONPREF)$@ + +manpages: $(patsubst %.gl,%.3gl,$(wildcard *.gl)) + +install: manpages + for file in *.3gl; do \ + install -D -m 644 $$file ${ROOT}/usr/man/man3/`basename $$file .3gl`.3gl ; \ + done + +clobber: + rm -f *.3gl + +include $(DEPTH)/manrules +include $(COMMONRULES) diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/glwcreatemdrawingarea.gl b/xc/extras/ogl-sample/main/doc/man/manglw/glwcreatemdrawingarea.gl new file mode 100755 index 000000000..ab839f737 --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/glwcreatemdrawingarea.gl @@ -0,0 +1,50 @@ +.\" ** +.\" ** (c) Copyright 1993, 1994, 1995, 1996 Silicon Graphics, Inc. +.\" ** +.\" ** (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. +.\" ** All Rights Reserved. +.\" ** +.\" ** (c) Copyright 1987, 1988, 1989, by Hewlett-Packard Company +.\" ** +.\" ** (c) Copyright 1987, 1988 by Digital Equipment Corporation, +.\" ** Maynard, MA. All Rights Reserved. +.\" ** +.\" ** +.TH GLwCreateMDrawingArea 3X "" "" "" "" +.SH NAME +\fBGLwCreateMDrawingArea \(em Create a Motif/OpenGL Drawing Widget.\fP +.iX "GLwCreateMDrawingArea" +.iX "creation functions" +.sp 1 +.SH SYNOPSIS +\fB#include <X11/GLw/GLwMDrawA.h>\fP +.br +Widget \fBGLwCreateMDrawingArea\fP( Widget \fIparent\fP, + String \fIname\fP, + ArgList \fIarglist\fP, + Cardinal \fIargcount\fP ) +.fi +\fP +.SH DESCRIPTION +\fBGLwCreateMDrawingArea\fP creates an instance of a GLwMDrawingArea +widget and returns the associated widget ID. +.sp 1 +.IP "\fIparent\fP" .95i +Specifies the parent widget ID +.IP "\fIname\fP" .95i +Specifies the name of the created widget +.IP "\fIarglist\fP" .95i +Specifies the argument list +.IP "\fIargcount\fP" .95i +Specifies the number of attribute/value pairs in the argument list +(\fIarglist\fP) +.sp 1 +.PP +For a complete definition of GLwMDrawingArea and its associated resources, see +\fBGLwDrawingArea(3X)\fP. +.sp 1 +.SH RETURN VALUE +Returns the GLwMDrawingArea widget ID. +.sp 1 +.SH SEE ALSO +\fBGLwDrawingArea(3X)\fP. diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingarea.gl b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingarea.gl new file mode 100755 index 000000000..f25a4f5c6 --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingarea.gl @@ -0,0 +1,485 @@ +.\" ** +.\" ** (c) Copyright 1993, 1994, 1995, 1996 Silicon Graphics, Inc. +.\" ** +.\" ** (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. +.\" ** All Rights Reserved. +.\" ** +.\" ** (c) Copyright 1987, 1988, 1989, by Hewlett-Packard Company +.\" ** +.\" ** (c) Copyright 1987, 1988 by Digital Equipment Corporation, +.\" ** Maynard, MA. All Rights Reserved. +.\" ** +.\" ** +.TH GLwDrawingArea 3X "" "" "" "" +.SH NAME +\fBGLwDrawingArea, GLwMDrawingArea \(em OpenGL drawing widgets.\fP +.iX "GLwDrawingArea" "GLwMDrawingArea" +.iX "widget class" "OpenGL" "Draw" +.sp 1 +.SH SYNOPSIS +\fB#include <X11/GLw/GLwDrawA.h> +.br +\fBld ... -lGLw -lGL -l<anywidgetlibrary> -lXext -lXt -lX11 -lm +.sp +\fB#include <X11/GLw/GLwMDrawA.h> +.br +\fBld ... -lGLw -lGL -lXm -lXext -lXt -lX11 -lm +.sp 1 +.SH DESCRIPTION +\fBGLwDrawingArea\fP and \fBGLwMDrawingArea\fP are widgets suitable +for OpenGL drawing. They +provide a window with the appropriate visual and colormaps needed for +OpenGL, based on supplied parameters. GLwDrawingArea and +GLwMDrawingArea also provide +callbacks for redraw, resize, input, and initialization. +.PP +GLwDrawingArea is not a part of any widget set, but depends only on Xt. +GLwDrawingArea can be used with any widget set. GLwMDrawingArea +is identical to +GLwDrawingArea except that it is a subclass of the Motif\(Tm widget +class XmPrimitive and +has resources and defaults suitable for use with Motif. For example, +GLwMDrawingArea provides the default Motif background and foreground colors +for resources, and deals better with keyboard traversal. Although the +GLwDrawingArea widget can be used in a Motif program, it is recommended that +GLwMDrawingArea be used instead. +.PP +Since both GLwDrawingArea and GLwMDrawingArea +widgets behave almost identically, the +remainder of this manual page will refer only to GLwDrawingArea, except when +the behaviors differ. Unless explicitly stated, all statements +about GLwDrawingArea also apply to GLwMDrawingArea. +.PP +Among the information provided when creating a GLwDrawingArea is +information necessary to determine the visual. This may be provided +in three ways, all of them through resources. A specific visualInfo +structure may be passed in. (This visualInfo must have been obtained +elsewhere; it is the application designer's responsibility to make +sure that it is compatible with the OpenGL rendering done by the +application). Alternatively, an attribute list may be provided. This +attribute list is formatted identically to that used for direct open +GL programming. Finally, each attribute can be specified as an +individual resource. The latter method is the simplest, and is the +only method that works from resource files. +.PP +In addition to allocating the visual, the GLwDrawingArea will also +allocate the colormap unless one is provided by the application. (If +one is provided it is the application writer's responsibility to +guarantee compatibility between the colormap and the visual). If +an application creates multiple GLwDrawingAreas with the same visual, +the same colormap will be used. (However the colormap +will not be shared among separate applications). +.PP +Creating the widget does not actually create the window until it is +realized, and consequently, the application should not perform any +OpenGL operations +to the window immediately after creation. Instead the application +must wait until after it has realized the window. Alternatively, the +\fBginit\fP callback may be used to indicate when the window has been +created. Upon receiving this callback, the application can perform +all OpenGL initialization for the window, and can subsequently perform +other operations on it. The initialization is discussed in more +detail below. +.PP +Applications select which GLwDrawingArea they are accessing using either +\fBglXMakeCurrent\fP or the convenience function +\fBGLwDrawingAreaMakeCurrent\fP which uses a widget instead of a +display and window. If there is only one GLwDrawingArea this need +only be called once, however if there is more than one GLwDrawingArea +it should be called at the start of each callback. +Callbacks in this case include not only +callbacks provided by the widget itself, but any other callback that +leads to GL activity such as a timeout or a workproc. +.PP +If an application is using double buffering, it may call +\fBGLwDrawingAreaSwapBuffers\fP instead of \fBglXSwapBuffers\fP. This +allows the use of the widget instead of the display and window. +.ne 5 +.SS "GLwDrawingArea Classes" +GLwDrawingArea inherits behavior and resources from the \fBCore\fP class. +.br +The class pointer is \fBglwDrawingAreaWidgetClass\fP. +.br +The class name is \fBGLwDrawingArea\fP. +.PP +.ne 5 +.SS "GLwMDrawingArea Classes" +GLwMDrawingArea inherits behavior and resources from the +\fBXmPrimitive\fP and \fBCore\fP classes. +.br +The class pointer is \fBglwMDrawingAreaWidgetClass\fP. +.br +The class name is \fBGLwMDrawingArea\fP. +.sp 1 +.SS "New Resources" +The following tables define a set of widget resources used by the programmer +to specify data. The programmer can also set the resource values for the +inherited classes to set attributes for this widget. To reference a +resource by name or by class in a .Xdefaults file, remove the \fBGLwN\fP or +\fBGLwC\fP prefix and use the remaining letters. +There are two tables included. The first table includes resources +that correspond directly to the attributes used by \fBglXChooseVisual\fP. +As with \fBglXChooseVisual\fP, all Boolean resources default to FALSE +and all integer resources default to 0, except redSize, greenSize and +blueSize which default to 1. These resources can all be +set only at creation time, and are used to determine the visual. If +either the \fIGLwNattribList\fP or \fIGLwNvisualInfo\fP resource is +set, these resources are ignored. The specific meaning of these +resources is discussed in the \fBglXChooseVisual\fP manual page and +will not be discussed here. +.sp 1 +.ne 18 +.TS +center allbox; +lBp8 lBp8 lBp8 lBp8 +lp8 lp8 lp8 lp8. +Name Class Type OpenGL attribute +GLwNbufferSize GLwCBufferSize int GLX_BUFFER_SIZE +GLwNlevel GLwCLevel int GLX_LEVEL +GLwNrgba GLwCRgba Boolean GLX_RGBA +GLwNdoublebuffer GLwCDoublebuffer Boolean GLX_DOUBLEBUFFER +GLwNstereo GLwCStereo Boolean GLX_STEREO +GLwNauxBuffers GLwCAuxBuffers Boolean GLX_AUX_BUFFERS +GLwNredSize GLwCColorSize int GLX_RED_SIZE +GLwNgreenSize GLwCColorSize int GLX_GREEN_SIZE +GLwNblueSize GLwCColorSize int GLX_BLUE_SIZE +GLwNalphaSize GLwCAlphaSize int GLX_ALPHA_SIZE +GLwNdepthSize GLwCDepthSize int GLX_DEPTH_SIZE +GLwNstencilSize GLwCStencilSize int GLX_STENCIL_SIZE +GLwNaccumRedSize GLwCAccumColorSize int GLX_ACCUM_RED_SIZE +GLwNaccumGreenSize GLwCAccumColorSize int GLX_ACCUM_GREEN_SIZE +GLwNaccumBlueSize GLwCAccumColorSize int GLX_ACCUM_BLUE_SIZE +GLwNaccumAlphaSize GLwCAccumAlphaSize int GLX_ACCUM_ALPHA_SIZE +.TE +.sp 1 +.PP +The following table lists other resources of the GLwDrawingArea +widget. each of these will be described subsequently. +The codes in the access column indicate if the given resource can be +set at creation time (\fBC\fP), +set by using \fBXtSetValues\fP (\fBS\fP), +retrieved by using \fBXtGetValues\fP (\fBG\fP), or is not applicable +(\fBN/A\fP). +.sp 1 +.ne 12 +.TS +center; +lp8B lp8B lp8B lp8B lp8B +lp8 lp8 lp8 lp8 lp8. +Name Class Type Def Acc +_ +GLwNallocateBackground GLwCAllocateColors Boolean F CG +GLwNallocateOtherColors GLwCAllocateColors Boolean F CG +GLwNattribList GLwCAttribList int * NULL CG +GLwNexposeCallback GLwCCallback XtCallbackList NULL C +GLwNginitCallback GLwCCallback XtCallbackList NULL C +GLwNinputCallback GLwCCallback XtCallbackList NULL C +GLwNinstallBackground GLwCInstallBackground Boolean T CG +GLwNinstallColormap GLwCInstallColormap Boolean T CG +GLwNresizeCallback GLwCCallback XtCallbackList NULL C +GLwNvisualInfo GLwCVisualInfo XVisualInfo* NULL CG +.TE +.sp 1 +.IP "\fBGLwNallocateBackground\fP" +If TRUE, the background pixel and pixmap will be allocated if +appropriate using the newly calculated colormap and visual. If FALSE, +they will retain values calculated using the parent's colormap and +visual. Applications which wish to have X clear their background for +them will usually set this to TRUE. Applications clearing their own +background will often set this to FALSE, although they may set this to +TRUE if they query the background for their own use. One reason to +leave this resource FALSE is that if color index mode is in use this +avoid using up a pixel from the newly allocated colormap. Also, on +hardware that supports only one colormap, the application may need to +do more careful color allocation to avoid flashing between the OpenGL +colormap and the default X colormap. +(Note that because of the way Xt works, the background colors +are originally calculated using the default colormap; if this resource +is set they can be recalculated correctly. If a colormap was +explicitly supplied to the widget rather than being dynamically +calculated, these resources are always calculated using that colormap.) +.IP "\fBGLwNallocateOtherColors\fP" +This is similar to \fBGLwNallocateBackground\fP, but allocates other +colors normally allocated by widgets. Although the GLwDrawingArea +and GLwMDrawingArea widget do not make use of these colors the +application may choose to query them. For the non-Motif +GLwDrawingArea widget there are no other colors allocated, so this +resource is a no-op. For the Motif GLwMDrawingArea are widget, the +XmPrimitive resources \fBXmNforeground\fP, \fBXmNhighlightColor\fP, +and \fBXmNhighlightPixmap\fP are calculated. +.IP "\fBGLwNattribList\fP" +Contains the list of attributes suitable for a call to +\fBglXChooseVisual\fP. If this resource is NULL, it is calculated +based on the attribute resources. If it is not NULL, the attribute +resources are ignored. +.IP "\fBGLwNexposeCallback\fP" +Specifies the list of callbacks that is +called when the widget receives an exposure event. +The callback reason is \fBGLwCR_EXPOSE\fP. +The callback structure also includes the exposure event. The +application will generally want to redraw the scene. +.IP "\fBGLwNginitCallback\fP" +Specifies the list of callbacks that is +called when the widget is first realized. Since no OpenGL operations can +be done before the widget is realized, this callback can be used to +perform any appropriate OpenGL initialization such as creating a context. +The callback reason is \fBGLwCR_GINIT\fP. +.IP "\fBGLwNinputCallback\fP" +Specifies the list of callbacks that is +called when the widget receives a keyboard +or mouse event. By default, the input callback is called on each key +press and key release, on each mouse button press and release, and +whenever the mouse is moved while a button is pressed. However this +can be changed by providing a different translation table. +The callback structure also includes the input event. +The callback reason is \fBGLwCR_INPUT\fP. +.IP "" +The input callback is provided as a programming convenience, as it +provides a convenient way to catch all input events. However, a more +modular program can often be obtained by providing specific actions and +translations in the application rather than using a single catch all +callback. Use of explicit translations can also provide for more +customization. +.IP "\fBGLwNinstallBackground\fP" +If set to TRUE, the background is installed on the window. If set to +FALSE, the window has no background. This resource has no effect +unless \fBGLwNallocateBackground\fP is also TRUE. +.IP "\fBGLwNinstallColormap\fP" +If set to TRUE, the widget will call \fIXSetWMColormapWindows\fP to +tell the window manager to install the colormap when the window's +shell has focus. If set to FALSE, this will not be called. For +applications with multiple GLwDrawingAreas sharing a single colormap, +it is most efficient to set this resource to TRUE for exactly one +GLwDrawingArea with each colormap. If an application needs +additional control over the order of colormaps, this resource can be +set to FALSE, with the application calling \fIXSetWMColormapWindows\fP +explicitly. +.IP "\fBGLwNresizeCallback\fP" +Specifies the list of callbacks that is +called when the GLwDrawingArea is resized. +The callback reason is \fBGLwCR_RESIZE\fP. +.IP "\fBGLwNvisualInfo\fP" +Contains a pointer to the window's visual info structure. If NULL, +the visualInfo is calculated at widget creation time based on the +\fIGLwNattributeList\fP resource (which is itself calculated from the +various resources). If \fBGLwNvisualInfo\fP is not NULL the +\fIGLwNattributList\fP and the attribute resources are ignored. +.sp 1 +.SS "Inherited Resources" +Both GLwDrawingArea and GLwMDrawingArea inherit behavior and resources +from the core superclass. Other than the behavior of the colormap and +background resources described previously, all defaults are the same as +for core. +.PP +In addition, the Motif version GLwMDrawingArea also inherits from XmPrimitive. +The behavior of the color resources has been described previously. +The \fITraversalOn\fP resource is disabled for this widget, but if +keyboard input is required it should be enabled. (Also, the +application should call \fBXmProcessTraversal(widget, XmTRAVERSE_CURRENT)\fP +whenever mouse button 1 is clicked in the widget. This is similar to +the requirements of the Motif Drawing area.) Because Motif gets +confused by having multiple visuals in one top level shell, +\fBXmNhighlightOnEnter\fP has been disabled, and +\fBXmNhighlightThickness\fP has been set to 0. +.SS "Callback Information" +A pointer to the following structure is passed to each callback: +.sp 1 +.ne 6 +.nf +.ta .25i 1.3i +\fBtypedef struct\fP +{ + \fBint\fP \fIreason\fP; + \fBXEvent\fP \fI*event\fP; + \fBDimension\fP \fIwidth, height\fP; +} \fBGLwDrawingAreaCallbackStruct\fP; +.fi +.sp 1 +.IP "\fIreason\fP" .75i +Indicates why the callback was invoked. Appropriate values are +stated in the above resource descriptions. For Motif programmers, the +values \fBGLwCR_EXPOSE\fP, \fBGLwCR_RESIZE\fP, and \fBGLwCR_INPUT\fP +are equal to \fBXmCR_EXPOSE\fP, \fBXmCR_RESIZE\fP, and +\fBXmCR_INPUT\fP respectively. \fBGLwCR_GINIT\fP does not have a +Motif equivalent. +.IP "\fIevent\fP" .75i +Points to the \fBXEvent\fP that triggered the callback. +This is NULL for \fBGLwNginitCallback and \fBGLwNresizeCallback\fP. +.IP "\fIwidth\fP and \fIheight\fP" .75i +Are set to the width and height of the window. +.br +.ne 10 +.sp 1 \"Adds space before the SS +.SS "Translations" +GLwDrawingArea has the translations listed below. +\fB +.nf +.ta 1.5i +.ne 5 +<KeyDown>: glwInput() +<KeyUp>: glwInput() +<BtnDown>: glwInput() +<BtnUp>: glwInput() +<BtnMotion>: glwInput() +.fi +.PP +GLwMDrawingArea has the following additional translation: +\fB +.nf +.ta 1.5i +<Key>osfHelp: PrimitiveHelp() +.fi +.PP +An application wishing to catch other events than these defaults can +do so by installing a different translation table. +\fP +.sp 1 \"Adds space before the SS +.SS "Action Routines" +The GLwDrawingArea has the following action routine: +.IP "\fBglwInput()\fP:" +Called whenever one of the above translations specifies that input has +occurred. Its sole purpose is to call the input callback. +.sp 1 +.SH INITIALIZATION +.PP +When the widget is initially created (e.g. through +\fBXtCreateWidget(3X)\fP) the associated window is not actually +created. Instead, window creation is delayed until the widget is +realized. However, \fBglXchooseVisual\fP is called immediately, so +information based on its results is available. +.PP +Between the time the widget is created and it is realized, +the following apply: +.TP +\(bu +No OpenGL operations can be done to the window +.TP +\(bu +No resize callbacks are generated. +.TP +\(bu +The normal window is available (XtWindow returns NULL). +.TP +\(bu +\fBGLwDrawingAreaMakeCurrent\fP (and \fBglXMakeCurrent\fP) should not +be called. +.PP +When the widget is realized, the following actions take place: +.PP +.TP +\(bu +The window is created. +.TP +\(bu +The \fBginit\fP callback is called. The user may use this callback to +perform any needed OpenGL initialization to the window. +.sp 1 +.SH NOTES +.PP +When using the input callback to receive keyboard input, the keycode +in the event must be converted to a KeySym. Use +\fBXLookupKeysym(3X)\fP or \fBXLookupString(3X)\fP to do the +conversion. Keyboard input can also be dealt using translations, in +which case no such conversion is required. +.PP +Motif programmers should keep in mind that OSF uses virtual +bindings and replaces some of the key bindings. As a common example, +if the ESC key is to be used to exit the program (as it often is in GL +programs), the translation should specify <key>osfCancel instead of +<key>Escape. +.PP +Motif programmers may also create a GLwMDrawingArea widget with the Motif +style \fBGLwCreateMDrawingArea\fP. +.sp 1 +.ne 10 +.SH EXAMPLE +Here are some code fragments that create a GLwDrawingArea widget, and manage +the appropriate callbacks. +.sp +.nf +\f(CW + #include <stdlib.h> + #include <X11/GLw/GLwDrawA.h> + static GLXContext glx_context; /* assume only one context */ + . . . + + main() + { + Arg args[10]; + int n; + + Widget parent; /* The parent of the gl widget */ + Widget glw; /* The GLwDrawingArea widget */ + . . . + + /* Create the widget using RGB mode. This can also be set + * in an X Defaults file + */ + n = 0; + XtSetArg(args[n], GLwNrgba, True); n++; + glw = XtCreateManagedWidget("glw", glwDrawingAreaWidgetClass, + parent, args, n); + XtAddCallback(glw, GLwNexposeCallback, exposeCB, NULL); + XtAddCallback(glw, GLwNresizeCallback, resizeCB, NULL); + XtAddCallback(glw, GLwNginitCallback, ginitCB, NULL); + /* Also add input callback if needed */ + . . . + } + + static void + exposeCB(Widget w, XtPointer client_data, + GLwDrawingAreaCallbackStruct *call_data) + { + GLwDrawingAreaMakeCurrent(w, glx_context); + /* redraw the display */ + } + + static void + resizeCB(Widget w, XtPointer client_data, + GLwDrawingAreaCallbackStruct *call_data) + { + GLwDrawingAreaMakeCurrent(w, glx_context); + /* perform any resize actions */ + } + + static void + ginitCB(Widget w, XtPointer client_data, + GLwDrawingAreaCallbackStruct *call_data) + { + Arg args[1]; + XVisualInfo *vi; + + XtSetArg(args[0], GLwNvisualInfo, &vi); + XtGetValues(w, args, 1); + + /* create a visual context */ + glx_context = glXCreateContext(XtDisplay(w), vi, + NULL, GL_FALSE); + GLwDrawingAreaMakeCurrent(w, glx_context); + /* Perform any necessary graphics initialization.*/ + } +\fP +.fi +.P +The Motif program need only differ by including +\fBGLwMDrawingArea.h\fP instead of \fBGLwDrawingArea.h\fP and by creating a widget of type +\fBGLwMDrawingAreaWidgetClass\fP instead of \fBGLwDrawingAreaWidgetClass\fP. As an +alternative, the Motif program could use \fBGLwCreateMDraw(3X)\fP instead. +.sp 1 +.SH WARNINGS +.PP +If a GLwDrawingArea widget is created as a child of an already realized +widget, the GLwDrawingArea widget will be created immediately, without giving +the user an opportunity to add the \fBginit\fP callback. In such a +case, initialization should be done immediately after creating the +widget rather than by using the callback. +.PP +If the non-Motif GLwDrawingArea widget is used in a Motif program and +keyboard traversal is attempted, the behavior is undefined if the user +traverses into the GLwDrawingArea widget. +.SH SEE ALSO +\fBglXChooseVisual(3G)\fP, \fBGLwDrawingAreaMakeCurrent(3X)\fP, +\fBglXMakeCurrent(3G)\fP, \fBGLwDrawingAreaSwapBuffers(3X)\fP +\fBGLwCreateMDraw(3X)\fP, \fBCore(3X)\fP, \fBXmPrimitive(3X)\fP, +\fBVirtualBindings(3X)\fP, \fBXSetWMColormapWindows(3X11)\fP +and the OpenGL spec. diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareamakecurrent.gl b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareamakecurrent.gl new file mode 100755 index 000000000..de51e4d51 --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareamakecurrent.gl @@ -0,0 +1,30 @@ +.\" ** +.\" ** (c) Copyright 1993, 1994, 1995, 1996 Silicon Graphics, Inc. +.\" ** +.\" ** (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. +.\" ** All Rights Reserved. +.\" ** +.\" ** (c) Copyright 1987, 1988, 1989, by Hewlett-Packard Company +.\" ** +.\" ** (c) Copyright 1987, 1988 by Digital Equipment Corporation, +.\" ** Maynard, MA. All Rights Reserved. +.\" ** +.\" ** +.TH GLwDrawingAreaMakeCurrent 3X "" "" "" "" +.SH NAME +\fBGLwDrawingAreaMakeCurrent \(em Make the current GLwDrawingArea current.\fP +.iX "GLwDrawingAreaMakeCurrent" +.iX "GLwDrawingArea" +.sp 1 +.SH SYNOPSIS +\fB#include <X11/GLw/GLwDraw.h>\fP +.br +void \fBGLwDrawingAreaMakeCurrent\fP( Widget \fIw\fP, + GLXContext \fIctx\fP ) +.fi +.SH DESCRIPTION +\fBGLwDrawingAreaMakeCurrent\fP is a front end to \fBglXMakeCurrent\fP, +however instead of passing in a Display and a Window, a Widget is +passed in. +.SH SEE ALSO +\fBGLwMDrawingArea(3X)\fP, \fBglXMakeCurrent(3G)\fP. diff --git a/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareaswapbuffers.gl b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareaswapbuffers.gl new file mode 100755 index 000000000..c7a28b411 --- /dev/null +++ b/xc/extras/ogl-sample/main/doc/man/manglw/glwdrawingareaswapbuffers.gl @@ -0,0 +1,30 @@ +.\" ** +.\" ** (c) Copyright 1993, 1994, 1995, 1996 Silicon Graphics, Inc. +.\" ** +.\" ** (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. +.\" ** All Rights Reserved. +.\" ** +.\" ** (c) Copyright 1987, 1988, 1989, by Hewlett-Packard Company +.\" ** +.\" ** (c) Copyright 1987, 1988 by Digital Equipment Corporation, +.\" ** Maynard, MA. All Rights Reserved. +.\" ** +.\" ** +.TH GLwDrawingAreaSwapBuffers 3X "" "" "" "" +.SH NAME +\fBGLwDrawingAreaSwapBuffers \(em Swap buffers in a GLwDrawingArea.\fP +.iX "GLwDrawingAreaSwapBuffers" +.iX "GLwDrawingArea" +.sp 1 +.SH SYNOPSIS +\fB#include <X11/GLw/GLwDraw.h>\fP +.br +void \fBGLwDrawingAreaSwapBuffers\fP( Widget \fIw\fP ) +.br +.fi +.SH DESCRIPTION +\fBGLwDrawingAreaSwapBuffers\fP is a front end to \fBglXSwapBuffers\fP, +however instead of passing in a Display and a Window, a Widget is +passed in. +.SH SEE ALSO +\fBGLwMDrawingArea(3X)\fP, \fBglXSwapBuffers(3G)\fP. diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/Distfile b/xc/extras/ogl-sample/main/gfx/lib/glw/Distfile new file mode 100755 index 000000000..926d3f6f2 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/Distfile @@ -0,0 +1,15 @@ +# +# $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +# $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/Distfile,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +# + +DISTFILES_SI = \ + GLwDrawA.h /xc/include/GL/GLwDrawA.h \ + GLwMDrawA.h /xc/include/GL/GLwMDrawA.h \ + Imakefile /xc/lib/GL/glw/Imakefile \ + GLwDrawAP.h /xc/lib/GL/glw/GLwDrawAP.h \ + GLwMDrawAP.h /xc/lib/GL/glw/GLwMDrawAP.h \ + GLwDAUtil.c /xc/lib/GL/glw/GLwDAUtil.c \ + GLwDrawA.c /xc/lib/GL/glw/GLwDrawA.c \ + GLwMDrawA.c /xc/lib/GL/glw/GLwMDrawA.c \ + $(NULL) diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDAUtil.c b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDAUtil.c new file mode 100755 index 000000000..e506f7926 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDAUtil.c @@ -0,0 +1,77 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* utility routines for GLX. + * Since these routines are used both in the Motif and X versions of + * the widget, they cannot peek directly into the structure + * + * $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwDAUtil.c,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ + */ + +/* $XFree86: xc/extras/ogl-sample/main/gfx/lib/glw/GLwDAUtil.c,v 1.2 2000/11/02 20:39:06 dawes Exp $ */ + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <GL/glx.h> +#include <GL/gl.h> + +/* + * By default only a static library is created because most of the UNIX + * loaders, if not all, complain about unresolved symbols even if the + * application doesn't use the modules in which such symbols are referenced. + * However, if your system supports libraries with weak symbols (e.g. + * Solaris, FreeBSD and Linux) it is possible to fool the loader using these + * weak symbols. + */ +#ifdef USE_XM_STUBS +#pragma weak _XmPrimitiveHighlightPixmapDefault = _Xm_Stub_Pointer_ +#pragma weak _XmHighlightColorDefault = _Xm_Stub_Pointer_ +#pragma weak _XmForegroundColorDefault = _Xm_Stub_Pointer_ +#pragma weak _XmBackgroundColorDefault = _Xm_Stub_Pointer_ +#pragma weak _XmStrings = _Xm_Stub_Pointer_ +#pragma weak xmPrimitiveClassRec = _Xm_Stub_Pointer_ + +static XtPointer _Xm_Stub_Pointer_ = NULL; +#endif + +void GLwDrawingAreaMakeCurrent (Widget w, GLXContext ctx) +{ + glXMakeCurrent (XtDisplay(w), XtWindow(w), ctx); +} + +void GLwDrawingAreaSwapBuffers (Widget w) +{ + glXSwapBuffers (XtDisplay(w), XtWindow(w)); +} diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.c b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.c new file mode 100755 index 000000000..4e917b7e4 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.c @@ -0,0 +1,738 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwDrawA.c,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +#include <stdio.h> +#include <GL/glx.h> +#include <GL/gl.h> +#ifdef __GLX_MOTIF +#include "GLwMDrawAP.h" +#else /* not __GLX_MOTIF */ +#include "GLwDrawAP.h" +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#endif /* __GLX_MOTIF */ +#include <assert.h> + +#ifdef __GLX_MOTIF +/* The MOTIF version differs only in the inclusion of the primitive + * widget class and in a vew variable and type name differences. + * Rather than put ifdefs all over the place, we just use a few defines + * to make it use motif types and names + */ +#define GLwDrawingAreaWidget GLwMDrawingAreaWidget +#define GLwDrawingAreaClassRec GLwMDrawingAreaClassRec +#define glwDrawingAreaClassRec glwMDrawingAreaClassRec +#define glwDrawingAreaWidgetClass glwMDrawingAreaWidgetClass +#define GLwDrawingAreaRec GLwMDrawingAreaRec +#endif /* __GLX_MOTIF */ + +/* forward definitions */ +/* resource default procs */ +static void createColormap(GLwDrawingAreaWidget w, + int offset, XrmValue *value); + +/* widget methods */ +static void Initialize(GLwDrawingAreaWidget req, GLwDrawingAreaWidget new, + ArgList args, Cardinal *num_args); +static void Realize(Widget w, Mask *valueMask, + XSetWindowAttributes *attributes); +static void Redraw(GLwDrawingAreaWidget w, XEvent *event, Region region); +static void Resize(GLwDrawingAreaWidget glw); +static void Destroy(GLwDrawingAreaWidget glw); + +#define offset(field) XtOffset(GLwDrawingAreaWidget, glwDrawingArea.field) + +static char defaultTranslations[] = +#ifdef __GLX_MOTIF + "<Key>osfHelp:PrimitiveHelp() \n" +#endif + "<KeyDown>: glwInput() \n\ + <KeyUp>: glwInput() \n\ + <BtnDown>: glwInput() \n\ + <BtnUp>: glwInput() \n\ + <BtnMotion>: glwInput() "; + +static void glwInput(GLwDrawingAreaWidget glw, XEvent *event, + String *, Cardinal *); + +static XtActionsRec actions[] = { + { "glwInput", (XtActionProc) glwInput }, /* key or mouse input */ +}; + +/* + * There is a bit of unusual handling of the resources here. + * Because Xt insists on allocating the colormap resource when it is + * processing the core resources (even if we redeclare the colormap + * resource here, we need to do a little trick. When Xt first allocates + * the colormap, we allow it to allocate the default one, since we have + * not yet determined the appropriate visual (which is determined from + * resources parsed after the colormap). We also let it allocate colors + * in that default colormap. + * + * In the initialize proc we calculate the actual visual. Then, we + * reobtain the colormap resource using XtGetApplicationResources in + * the initialize proc. If requested, we also reallocate colors in + * that colormap using the same method. + */ + +static XtResource resources[] = { + /* The GLX attributes. Add any new attributes here */ + + {GLwNbufferSize, GLwCBufferSize, XtRInt, sizeof (int), + offset(bufferSize), XtRImmediate, (XtPointer) 0}, + + {GLwNlevel, GLwCLevel, XtRInt, sizeof (int), + offset(level), XtRImmediate, (XtPointer) 0}, + + {GLwNrgba, GLwCRgba, XtRBoolean, sizeof (Boolean), + offset(rgba), XtRImmediate, (XtPointer) FALSE}, + + {GLwNdoublebuffer, GLwCDoublebuffer, XtRBoolean, sizeof (Boolean), + offset(doublebuffer), XtRImmediate, (XtPointer) FALSE}, + + {GLwNstereo, GLwCStereo, XtRBoolean, sizeof (Boolean), + offset(stereo), XtRImmediate, (XtPointer) FALSE}, + + {GLwNauxBuffers, GLwCAuxBuffers, XtRInt, sizeof (int), + offset(auxBuffers), XtRImmediate, (XtPointer) 0}, + + {GLwNredSize, GLwCColorSize, XtRInt, sizeof (int), + offset(redSize), XtRImmediate, (XtPointer) 1}, + + {GLwNgreenSize, GLwCColorSize, XtRInt, sizeof (int), + offset(greenSize), XtRImmediate, (XtPointer) 1}, + + {GLwNblueSize, GLwCColorSize, XtRInt, sizeof (int), + offset(blueSize), XtRImmediate, (XtPointer) 1}, + + {GLwNalphaSize, GLwCAlphaSize, XtRInt, sizeof (int), + offset(alphaSize), XtRImmediate, (XtPointer) 0}, + + {GLwNdepthSize, GLwCDepthSize, XtRInt, sizeof (int), + offset(depthSize), XtRImmediate, (XtPointer) 0}, + + {GLwNstencilSize, GLwCStencilSize, XtRInt, sizeof (int), + offset(stencilSize), XtRImmediate, (XtPointer) 0}, + + {GLwNaccumRedSize, GLwCAccumColorSize, XtRInt, sizeof (int), + offset(accumRedSize), XtRImmediate, (XtPointer) 0}, + + {GLwNaccumGreenSize, GLwCAccumColorSize, XtRInt, sizeof (int), + offset(accumGreenSize), XtRImmediate, (XtPointer) 0}, + + {GLwNaccumBlueSize, GLwCAccumColorSize, XtRInt, sizeof (int), + offset(accumBlueSize), XtRImmediate, (XtPointer) 0}, + + {GLwNaccumAlphaSize, GLwCAccumAlphaSize, XtRInt, sizeof (int), + offset(accumAlphaSize), XtRImmediate, (XtPointer) 0}, + + /* the attribute list */ + {GLwNattribList, GLwCAttribList, XtRPointer, sizeof(int *), + offset(attribList), XtRImmediate, (XtPointer) NULL}, + + /* the visual info */ + {GLwNvisualInfo, GLwCVisualInfo, GLwRVisualInfo, sizeof (XVisualInfo *), + offset(visualInfo), XtRImmediate, (XtPointer) NULL}, + +/* miscellaneous resources */ + {GLwNinstallColormap, GLwCInstallColormap, XtRBoolean, sizeof (Boolean), + offset(installColormap), XtRImmediate, (XtPointer) TRUE}, + + {GLwNallocateBackground, GLwCAllocateColors, XtRBoolean, sizeof (Boolean), + offset(allocateBackground), XtRImmediate, (XtPointer) FALSE}, + + {GLwNallocateOtherColors, GLwCAllocateColors, XtRBoolean, sizeof (Boolean), + offset(allocateOtherColors), XtRImmediate, (XtPointer) FALSE}, + + {GLwNinstallBackground, GLwCInstallBackground, XtRBoolean, sizeof (Boolean), + offset(installBackground), XtRImmediate, (XtPointer) TRUE}, + + {GLwNginitCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList), + offset(ginitCallback), XtRImmediate, (XtPointer) NULL}, + + {GLwNinputCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList), + offset(inputCallback), XtRImmediate, (XtPointer) NULL}, + + {GLwNresizeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList), + offset(resizeCallback), XtRImmediate, (XtPointer) NULL}, + + {GLwNexposeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList), + offset(exposeCallback), XtRImmediate, (XtPointer) NULL}, + +#ifdef __GLX_MOTIF + /* Changes to Motif primitive resources */ + {XmNtraversalOn, XmCTraversalOn, XmRBoolean, sizeof (Boolean), + XtOffset (GLwDrawingAreaWidget, primitive.traversal_on), XmRImmediate, + (XtPointer) FALSE}, + + /* highlighting is normally disabled, as when Motif tries to disable + * highlighting, it tries to reset the color back to the parent's + * background (usually Motif blue). Unfortunately, that is in a + * different colormap, and doesn't work too well. + */ + {XmNhighlightOnEnter, XmCHighlightOnEnter, XmRBoolean, sizeof (Boolean), + XtOffset (GLwDrawingAreaWidget, primitive.highlight_on_enter), + XmRImmediate, (XtPointer) FALSE}, + + {XmNhighlightThickness, XmCHighlightThickness, XmRHorizontalDimension, + sizeof (Dimension), + XtOffset (GLwDrawingAreaWidget, primitive.highlight_thickness), + XmRImmediate, (XtPointer) 0}, + +#endif /* __GLX_MOTIF */ +}; + +/* The following resources are reobtained using XtGetApplicationResources + * in the initialize proc. + */ +/* The colormap */ +static XtResource initializeResources[] = { + /* reobtain the colormap with the new visual */ + {XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap), + XtOffset(GLwDrawingAreaWidget, core.colormap), + XtRCallProc,(XtPointer) createColormap}, +}; + +/* reallocate any colors we need in the new colormap */ + +/* The background is obtained only if the allocateBackground resource is TRUE*/ +static XtResource backgroundResources[] = { +#ifdef __GLX_MOTIF + { + XmNbackground, XmCBackground, XmRPixel, + sizeof (Pixel), XtOffset(GLwDrawingAreaWidget, core.background_pixel), + XmRCallProc, (XtPointer) _XmBackgroundColorDefault + }, + { + XmNbackgroundPixmap, XmCPixmap, XmRXmBackgroundPixmap, + sizeof (Pixmap), XtOffset(GLwDrawingAreaWidget, core.background_pixmap), + XmRImmediate, (XtPointer) XmUNSPECIFIED_PIXMAP + }, + +#else /* ! __GLX_MOTIF */ + {XtNbackground, XtCBackground, XtRPixel,sizeof(Pixel), + XtOffset(GLwDrawingAreaWidget,core.background_pixel), + XtRString, (XtPointer)"XtDefaultBackground"}, + {XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap), + XtOffset(GLwDrawingAreaWidget,core.background_pixmap), + XtRImmediate, (XtPointer)XtUnspecifiedPixmap}, +#endif /* __GLX_MOTIF */ +}; + +/* The other colors such as the foreground are allocated only if + * allocateOtherColors are set. These resources only exist in Motif. + */ + +#ifdef __GLX_MOTIF +static XtResource otherColorResources[] = { + { + XmNforeground, XmCForeground, XmRPixel, + sizeof (Pixel), XtOffset(GLwDrawingAreaWidget, primitive.foreground), + XmRCallProc, (XtPointer) _XmForegroundColorDefault + }, + + { + XmNhighlightColor, XmCHighlightColor, XmRPixel, sizeof (Pixel), + XtOffset(GLwDrawingAreaWidget, primitive.highlight_color), + XmRCallProc, (XtPointer) _XmHighlightColorDefault + }, + + { + XmNhighlightPixmap, XmCHighlightPixmap, XmRPrimHighlightPixmap, + sizeof (Pixmap), + XtOffset(GLwDrawingAreaWidget, primitive.highlight_pixmap), + XmRCallProc, (XtPointer) _XmPrimitiveHighlightPixmapDefault + }, +}; +#endif /* __GLX_MOTIF */ + +struct attribInfo +{ + int offset; + int attribute; +}; + +static struct attribInfo intAttribs[] = +{ + { offset(bufferSize), GLX_BUFFER_SIZE }, + { offset(level), GLX_LEVEL }, + { offset(auxBuffers), GLX_AUX_BUFFERS }, + { offset(redSize), GLX_RED_SIZE }, + { offset(greenSize), GLX_GREEN_SIZE }, + { offset(blueSize), GLX_BLUE_SIZE }, + { offset(alphaSize), GLX_ALPHA_SIZE }, + { offset(depthSize), GLX_DEPTH_SIZE }, + { offset(stencilSize), GLX_STENCIL_SIZE }, + { offset(accumRedSize), GLX_ACCUM_RED_SIZE }, + { offset(accumGreenSize), GLX_ACCUM_GREEN_SIZE }, + { offset(accumBlueSize), GLX_ACCUM_BLUE_SIZE }, + { offset(accumAlphaSize), GLX_ACCUM_ALPHA_SIZE }, + { 0, None }, +}; + +static struct attribInfo booleanAttribs[] = +{ + { offset(rgba), GLX_RGBA }, + { offset(doublebuffer), GLX_DOUBLEBUFFER }, + { offset(stereo), GLX_STEREO }, + { 0, None }, +}; + +#undef offset + + +GLwDrawingAreaClassRec glwDrawingAreaClassRec = +{ + { /* core fields */ +#ifdef __GLX_MOTIF + /* superclass */ (WidgetClass) &xmPrimitiveClassRec, + /* class_name */ "GLwMDrawingArea", +#else /* not __GLX_MOTIF */ + /* superclass */ (WidgetClass) &widgetClassRec, + /* class_name */ "GLwDrawingArea", +#endif /* __GLX_MOTIF */ + /* widget_size */ sizeof(GLwDrawingAreaRec), + /* class_initialize */ NULL, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ (XtInitProc) Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ TRUE, + /* destroy */ (XtWidgetProc) Destroy, + /* resize */ (XtWidgetProc) Resize, + /* expose */ (XtExposeProc) Redraw, + /* set_values */ NULL, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback_private */ NULL, + /* tm_table */ defaultTranslations, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, +#ifdef __GLX_MOTIF /* primitive resources */ + { + /* border_highlight */ XmInheritBorderHighlight, + /* border_unhighlight */ XmInheritBorderUnhighlight, + /* translations */ XtInheritTranslations, + /* arm_and_activate */ NULL, + /* get_resources */ NULL, + /* num get_resources */ 0, + /* extension */ NULL, + } +#endif /* __GLX_MOTIF */ +}; + +WidgetClass glwDrawingAreaWidgetClass = (WidgetClass)&glwDrawingAreaClassRec; + +static void error(Widget w, char *string) +{ + char buf[100]; +#ifdef __GLX_MOTIF + sprintf (buf, "GLwMDrawingArea: %s\n", string); +#else + sprintf (buf, "GLwDrawingArea: %s\n", string); +#endif + XtAppError(XtWidgetToApplicationContext(w), buf); +} + +static void warning(Widget w, char *string) +{ + char buf[100]; +#ifdef __GLX_MOTIF + sprintf (buf, "GLwMDraw: %s\n", string); +#else + sprintf (buf, "GLwDraw: %s\n", string); +#endif + XtAppWarning(XtWidgetToApplicationContext(w), buf); +} + +/* resource initialization methods */ +/* Initialize the attribList based on the attributes */ +static void createAttribList(GLwDrawingAreaWidget w) +{ + int listLength; + register struct attribInfo *ap; + int *ip; + + /* first find out how long a list we need */ + listLength=1; /* include the terminating NULL */ + for (ap = booleanAttribs; ap->attribute; ap++) + { + if (*(Boolean *)(((char *)w)+ap->offset)) + listLength++; /* one word for a boolean */ + } + for (ap = intAttribs; ap->attribute; ap++) + { + if (*(int *)(((char *)w)+ap->offset)) + listLength+=2; /* one word for an int */ + } + w->glwDrawingArea.attribList = (int *)XtMalloc(listLength*sizeof(int)); + ip = w->glwDrawingArea.attribList; + for (ap = booleanAttribs; ap->attribute; ap++) + { + if (*(Boolean *)(((char *)w)+ap->offset)) + *ip++ = ap->attribute; + } + for (ap = intAttribs; ap->attribute; ap++) + { + if (*(int *)(((char *)w)+ap->offset)) + { + *ip++ = ap->attribute; + *ip++ = *(int *)(((char *)w)+ap->offset); + } + } + *ip = None; +} + +/* Initialize the visualInfo based on the attribute list */ +static void createVisualInfo(GLwDrawingAreaWidget w) +{ + static XVisualInfo *visualInfo; + + assert(w->glwDrawingArea.attribList); + w->glwDrawingArea.visualInfo = glXChooseVisual(XtDisplay(w), + XScreenNumberOfScreen(XtScreen(w)), + w->glwDrawingArea.attribList); + if (!w->glwDrawingArea.visualInfo) + error((Widget)w,"requested visual not supported"); +} + +/* Initialize the colormap based on the visual info. + * This routine maintains a cache of visual-infos to colormaps. If two + * widgets share the same visual info, they share the same colormap. + * This function is called by the callProc of the colormap resource entry. + */ +static void createColormap(GLwDrawingAreaWidget w, + int offset, XrmValue *value) +{ + static struct cmapCache + { + Visual *visual; + Colormap cmap; + int screen; + } *cmapCache; + static int cacheEntries=0; + static int cacheMalloced=0; + + register int i; + + assert(w->glwDrawingArea.visualInfo); + + /* see if we can find it in the cache */ + for (i=0; i<cacheEntries; i++) + if (cmapCache[i].visual == w->glwDrawingArea.visualInfo->visual && + cmapCache[i].screen == w->glwDrawingArea.visualInfo->screen) + { + value->addr = (XtPointer) (&cmapCache[i].cmap); + return; + } + /* not in the cache, create a new entry */ + if (cacheEntries >= cacheMalloced) + { + /* need to malloc a new one. Since we are likely to have only a + * few colormaps, we allocate one the first time, and double + * each subsequent time. + */ + if (cacheMalloced == 0) + { + cacheMalloced = 1; + cmapCache = (struct cmapCache *)XtMalloc(sizeof(struct cmapCache)); + } + else + { + cacheMalloced <<= 1; + cmapCache = (struct cmapCache *)XtRealloc((char *) cmapCache, + sizeof(struct cmapCache)* + cacheMalloced); + } + } + + cmapCache[cacheEntries].cmap = XCreateColormap (XtDisplay(w), + RootWindow(XtDisplay(w), + w->glwDrawingArea.visualInfo->screen), + w->glwDrawingArea.visualInfo->visual, + AllocNone); + cmapCache[cacheEntries].visual = w->glwDrawingArea.visualInfo->visual; + cmapCache[cacheEntries].screen = w->glwDrawingArea.visualInfo->screen; + value->addr = (XtPointer) (&cmapCache[cacheEntries++].cmap); +} + +static void +Initialize (GLwDrawingAreaWidget req, GLwDrawingAreaWidget new, + ArgList args, Cardinal *num_args) +{ + + if (req->core.width == 0) + new->core.width = 100; + if (req->core.height == 0) + new->core.width = 100; + + /* create the attribute list if needed */ + if (new->glwDrawingArea.attribList == NULL) + { + new->glwDrawingArea.myList = TRUE; + createAttribList(new); + } + else + new->glwDrawingArea.myList = FALSE; + + /* determine the visual info if needed */ + if (new->glwDrawingArea.visualInfo == NULL) + { + new->glwDrawingArea.myVisual = TRUE; + createVisualInfo(new); + } + else + new->glwDrawingArea.myVisual = FALSE; + + new->core.depth = new->glwDrawingArea.visualInfo->depth; + + /* Reobtain the colormap and colors in it using XtGetApplicationResources*/ + XtGetApplicationResources((Widget) new, new, + initializeResources, + XtNumber(initializeResources), + args, *num_args); + + /* obtain the color resources if appropriate */ + if (req->glwDrawingArea.allocateBackground) + XtGetApplicationResources((Widget) new, new, + backgroundResources, + XtNumber(backgroundResources), + args, *num_args); + +#ifdef __GLX_MOTIF + if (req->glwDrawingArea.allocateOtherColors) + XtGetApplicationResources((Widget) new, new, + otherColorResources, + XtNumber(otherColorResources), + args, *num_args); +#endif /* __GLX_MOTIF */ + +} + +static void +Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes) +{ + register GLwDrawingAreaWidget glw = (GLwDrawingAreaWidget)w; + GLwDrawingAreaCallbackStruct cb; + + /* if we haven't requested that the background be both installed and + * allocated, don't install it. + */ + if (!(glw->glwDrawingArea.installBackground && + glw->glwDrawingArea.allocateBackground)) + *valueMask &= ~CWBackPixel; + + XtCreateWindow (w, (unsigned int)InputOutput, + glw->glwDrawingArea.visualInfo->visual, + *valueMask, attributes); + + /* if appropriate, call XSetWMColormapWindows to install the colormap */ + if (glw->glwDrawingArea.installColormap) + { + Widget parentShell = XtParent(w); + Status status; + Window *windowsReturn; + int countReturn; + + while (parentShell && !XtIsShell(parentShell)) + parentShell = XtParent(parentShell); + if (parentShell && XtWindow(parentShell)) + { + /* check to see if there is already a property */ + status = XGetWMColormapWindows(XtDisplay(parentShell), + XtWindow(parentShell), + &windowsReturn, &countReturn); + + /* if no property, just create one */ + if (!status) + { + Window windows[2]; + windows[0] = XtWindow(w); + windows[1] = XtWindow(parentShell); + XSetWMColormapWindows(XtDisplay(parentShell), + XtWindow(parentShell), + windows, 2); + } + /* there was a property, add myself to the beginning */ + else + { + Window *windows = (Window *)XtMalloc((sizeof(Window))* + (countReturn+1)); + register int i; + windows[0] = XtWindow(w); + for (i=0; i<countReturn; i++) + windows[i+1] = windowsReturn[i]; + XSetWMColormapWindows(XtDisplay(parentShell), + XtWindow(parentShell), + windows, countReturn+1); + XtFree((char *) windows); + XFree((char *) windowsReturn); + } + } + else + warning((Widget)w, + "Could not set colormap property on parent shell"); + } + cb.reason = GLwCR_GINIT; + cb.event = NULL; + cb.width = glw->core.width; + cb.height = glw->core.height; + XtCallCallbackList((Widget) glw, glw->glwDrawingArea.ginitCallback, &cb); +} + +static void +Redraw(GLwDrawingAreaWidget w, XEvent *event, Region region) +{ + GLwDrawingAreaCallbackStruct cb; + XtCallbackList cblist; + + cb.reason = GLwCR_EXPOSE; + cb.event = event; + cb.width = w->core.width; + cb.height = w->core.height; + XtCallCallbackList ((Widget) w, w->glwDrawingArea.exposeCallback, &cb); +} + +static void +Resize(GLwDrawingAreaWidget glw) +{ + GLwDrawingAreaCallbackStruct cb; + + /* if we get a resize event before being realized, we can't handle it */ + if (!XtIsRealized((Widget)glw)) + return; + cb.reason = GLwCR_RESIZE; + cb.event = NULL; + cb.width = glw->core.width; + cb.height = glw->core.height; + XtCallCallbackList ((Widget) glw, glw->glwDrawingArea.resizeCallback, &cb); +} + +static void +Destroy(GLwDrawingAreaWidget glw) +{ + if (glw->glwDrawingArea.myList && glw->glwDrawingArea.attribList) + XtFree ((XtPointer)glw->glwDrawingArea.attribList); + if (glw->glwDrawingArea.myVisual && glw->glwDrawingArea.visualInfo) + XFree ((XtPointer)glw->glwDrawingArea.visualInfo); + + /* if my colormap was installed, remove it */ + if (glw->glwDrawingArea.installColormap) + { + Widget parentShell = XtParent(glw); + Status status; + Window *windowsReturn; + int countReturn; + register int i; + + /* find the parent shell */ + while (parentShell && !XtIsShell(parentShell)) + parentShell = XtParent(parentShell); + + if (parentShell && XtWindow(parentShell)) + { + /* make sure there is a property */ + status = XGetWMColormapWindows(XtDisplay(parentShell), + XtWindow(parentShell), + &windowsReturn, &countReturn); + + /* if no property, just return. If there was a property, + * continue + */ + if (status) + { + /* search for a match */ + for (i=0; i<countReturn; i++) + { + if (windowsReturn[i] == XtWindow(glw)) + { + /* we found a match, now copu the rest down */ + for (i++; i<countReturn; i++) + { + windowsReturn[i-1] = windowsReturn[i]; + } + XSetWMColormapWindows(XtDisplay(parentShell), + XtWindow(parentShell), + windowsReturn, countReturn-1); + break; /* from outer for */ + } + } + XFree((char *) windowsReturn); + } + } + } +} + +/* Action routine for keyboard and mouse events */ +/* ARGSUSED */ +static void glwInput (GLwDrawingAreaWidget glw, XEvent *event, + String * params, Cardinal * numParams) +{ + GLwDrawingAreaCallbackStruct cb; + + cb.reason = GLwCR_INPUT; + cb.event = event; + cb.width = glw->core.width; + cb.height = glw->core.height; + XtCallCallbackList ((Widget) glw, glw->glwDrawingArea.inputCallback, &cb); +} + +#ifdef __GLX_MOTIF +/* Provide a Motif-style create routine */ +Widget GLwCreateMDrawingArea(Widget parent, char *name, + ArgList arglist, Cardinal argcount) +{ + return (XtCreateWidget (name, glwMDrawingAreaWidgetClass, parent, arglist, + argcount)); +} +#endif diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.h b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.h new file mode 100755 index 000000000..b2052beb5 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.h @@ -0,0 +1,228 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwDrawA.h,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +/* +** This file has been slightly modified from the original by Carlos A. M. dos +** Santos <casantos@cpmet.ufpel.tche.br> for integration into XFree86 source +** tree and for generating both Motif(TM) 1.2 and 2.x versions of the widgets +** in the same library. +*/ +/* $XFree86: xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawA.h,v 1.2 2000/11/02 20:39:07 dawes Exp $ */ + +#ifndef _GLwDrawA_h +#define _GLwDrawA_h + +#ifdef __GLX_MOTIF +# ifndef __GLX_INCLUDE_XM_H /* Defined during library compilation */ +# include <Xm/Xm.h> /* We need to know about XmVERSION early */ +# endif +#endif + +#include <GL/glx.h> +#include <GL/gl.h> + +/**************************************************************** + * + * GLwDrawingArea widgets + * + ****************************************************************/ + +/* Resources: + + Name Class RepType Default Value + ---- ----- ------- ------------- + attribList AttribList int * NULL + visualInfo VisualInfo VisualInfo NULL + installColormap InstallColormap Boolean TRUE + allocateBackground AllocateColors Boolean FALSE + allocateOtherColors AllocateColors Boolean FALSE + installBackground InstallBackground Boolean TRUE + exposeCallback Callback Pointer NULL + ginitCallback Callback Pointer NULL + inputCallback Callback Pointer NULL + resizeCallback Callback Pointer NULL + +*** The following resources all correspond to the GLX configuration +*** attributes and are used to create the attribList if it is NULL + bufferSize BufferSize int 0 + level Level int 0 + rgba Rgba Boolean FALSE + doublebuffer Doublebuffer Boolean FALSE + stereo Stereo Boolean FALSE + auxBuffers AuxBuffers int 0 + redSize ColorSize int 1 + greenSize ColorSize int 1 + blueSize ColorSize int 1 + alphaSize AlphaSize int 0 + depthSize DepthSize int 0 + stencilSize StencilSize int 0 + accumRedSize AccumColorSize int 0 + accumGreenSize AccumColorSize int 0 + accumBlueSize AccumColorSize int 0 + accumAlphaSize AccumAlphaSize int 0 +*/ + +#define GLwNattribList "attribList" +#define GLwCAttribList "AttribList" +#define GLwNvisualInfo "visualInfo" +#define GLwCVisualInfo "VisualInfo" +#define GLwRVisualInfo "VisualInfo" + +#define GLwNinstallColormap "installColormap" +#define GLwCInstallColormap "InstallColormap" +#define GLwNallocateBackground "allocateBackground" +#define GLwNallocateOtherColors "allocateOtherColors" +#define GLwCAllocateColors "AllocateColors" +#define GLwNinstallBackground "installBackground" +#define GLwCInstallBackground "InstallBackground" + +#define GLwCCallback "Callback" +#define GLwNexposeCallback "exposeCallback" +#define GLwNginitCallback "ginitCallback" +#define GLwNresizeCallback "resizeCallback" +#define GLwNinputCallback "inputCallback" + +#define GLwNbufferSize "bufferSize" +#define GLwCBufferSize "BufferSize" +#define GLwNlevel "level" +#define GLwCLevel "Level" +#define GLwNrgba "rgba" +#define GLwCRgba "Rgba" +#define GLwNdoublebuffer "doublebuffer" +#define GLwCDoublebuffer "Doublebuffer" +#define GLwNstereo "stereo" +#define GLwCStereo "Stereo" +#define GLwNauxBuffers "auxBuffers" +#define GLwCAuxBuffers "AuxBuffers" +#define GLwNredSize "redSize" +#define GLwNgreenSize "greenSize" +#define GLwNblueSize "blueSize" +#define GLwCColorSize "ColorSize" +#define GLwNalphaSize "alphaSize" +#define GLwCAlphaSize "AlphaSize" +#define GLwNdepthSize "depthSize" +#define GLwCDepthSize "DepthSize" +#define GLwNstencilSize "stencilSize" +#define GLwCStencilSize "StencilSize" +#define GLwNaccumRedSize "accumRedSize" +#define GLwNaccumGreenSize "accumGreenSize" +#define GLwNaccumBlueSize "accumBlueSize" +#define GLwCAccumColorSize "AccumColorSize" +#define GLwNaccumAlphaSize "accumAlphaSize" +#define GLwCAccumAlphaSize "AccumAlphaSize" + +#ifdef __GLX_MOTIF + +#if XmVERSION == 1 +/* +# define _GLwMDrawingAreaClassRec _GLwM1DrawingAreaClassRec +# define _GLwMDrawingAreaRec _GLwM1DrawingAreaRec +*/ +# define glwMDrawingAreaWidgetClass glwM1DrawingAreaWidgetClass +# define GLwCreateMDrawingArea GLwCreateM1DrawingArea +#elif XmVERSION == 2 +/* +# define _GLwMDrawingAreaClassRec _GLwM2DrawingAreaClassRec +# define _GLwMDrawingAreaRec _GLwM2DrawingAreaRec +*/ +# define glwMDrawingAreaWidgetClass glwM2DrawingAreaWidgetClass +# define GLwCreateMDrawingArea GLwCreateM2DrawingArea +#else +#error "Sorry, unknown Motif version." +#endif /* XmVERSION */ + +typedef struct _GLwMDrawingAreaClassRec *GLwMDrawingAreaWidgetClass; +typedef struct _GLwMDrawingAreaRec *GLwMDrawingAreaWidget; + +extern WidgetClass glwMDrawingAreaWidgetClass; + +#else /* not __GLX_MOTIF */ + +typedef struct _GLwDrawingAreaClassRec *GLwDrawingAreaWidgetClass; +typedef struct _GLwDrawingAreaRec *GLwDrawingAreaWidget; + +extern WidgetClass glwDrawingAreaWidgetClass; + +#endif /* __GLX_MOTIF */ + +/* Callback reasons */ +#ifdef __GLX_MOTIF +#define GLwCR_EXPOSE XmCR_EXPOSE +#define GLwCR_RESIZE XmCR_RESIZE +#define GLwCR_INPUT XmCR_INPUT +#else /* not __GLX_MOTIF */ +/* The same values as Motif, but don't use Motif constants */ +#define GLwCR_EXPOSE 38 +#define GLwCR_RESIZE 39 +#define GLwCR_INPUT 40 +#endif /* __GLX_MOTIF */ + +#define GLwCR_GINIT 32135 /* Arbitrary number that should neverr clash*/ + +typedef struct +{ + int reason; + XEvent *event; + Dimension width, height; /* for resize callback */ +} GLwDrawingAreaCallbackStruct; + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/* front ends to glXMakeCurrent and glXSwapBuffers */ +extern void GLwDrawingAreaMakeCurrent (Widget w, GLXContext ctx); +extern void GLwDrawingAreaSwapBuffers (Widget w); + +#ifdef __GLX_MOTIF +#ifdef _NO_PROTO +extern Widget GLwCreateMDrawingArea (); +#else /* _NO_PROTO */ + +extern Widget GLwCreateMDrawingArea (Widget parent, char *name, + ArgList arglist, Cardinal argcount); +#endif /* _NO_PROTO */ + +#endif /* __GLX_MOTIF */ + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif /* _GLwDrawA_h */ diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawAP.h b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawAP.h new file mode 100755 index 000000000..91189a345 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawAP.h @@ -0,0 +1,131 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwDrawAP.h,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +/* +** This file has been slightly modified from the original by Carlos A. M. dos +** Santos <casantos@cpmet.ufpel.tche.br> for integration into XFree86 source +** tree and for generating both Motif(TM) 1.2 and 2.x versions of the widgets +** in the same library. +*/ +/* $XFree86: xc/extras/ogl-sample/main/gfx/lib/glw/GLwDrawAP.h,v 1.2 2000/11/02 20:39:07 dawes Exp $ */ + +#ifndef _GLwDrawAP_h +#define _GLwDrawAP_h + +#ifdef __GLX_MOTIF +# ifndef __GLX_INCLUDE_PRIMITIVE_P_H /* Used during library compilation */ +# include <Xm/PrimitiveP.h> +# endif +# include <GL/GLwMDrawA.h> /* includes IntrinsicP.h */ +#else +# include <X11/IntrinsicP.h> +# include <GL/GLwDrawA.h> +#endif + +typedef struct _GLwDrawingAreaClassPart +{ + char* extension; +} GLwDrawingAreaClassPart; + +#ifdef __GLX_MOTIF +typedef struct _GLwMDrawingAreaClassRec { + CoreClassPart core_class; + XmPrimitiveClassPart primitive_class; + GLwDrawingAreaClassPart glwDrawingArea_class; +} GLwMDrawingAreaClassRec; + +extern GLwMDrawingAreaClassRec glwMDrawingAreaClassRec; + +#else /* not __GLX_MOTIF */ + +typedef struct _GLwDrawingAreaClassRec { + CoreClassPart core_class; + GLwDrawingAreaClassPart glwDrawingArea_class; +} GLwDrawingAreaClassRec; + +extern GLwDrawingAreaClassRec glwDrawingAreaClassRec; +#endif /* __GLX_MOTIF */ + +typedef struct { + /* resources */ + int * attribList; + XVisualInfo * visualInfo; + Boolean myList; /* TRUE if we malloced the attribList*/ + Boolean myVisual; /* TRUE if we created the visualInfo*/ + Boolean installColormap; + Boolean allocateBackground; + Boolean allocateOtherColors; + Boolean installBackground; + XtCallbackList ginitCallback; + XtCallbackList resizeCallback; + XtCallbackList exposeCallback; + XtCallbackList inputCallback; + /* specific attributes; add as we get new attributes */ + int bufferSize; + int level; + Boolean rgba; + Boolean doublebuffer; + Boolean stereo; + int auxBuffers; + int redSize; + int greenSize; + int blueSize; + int alphaSize; + int depthSize; + int stencilSize; + int accumRedSize; + int accumGreenSize; + int accumBlueSize; + int accumAlphaSize; +} GLwDrawingAreaPart; + +#ifdef __GLX_MOTIF +typedef struct _GLwMDrawingAreaRec { + CorePart core; + XmPrimitivePart primitive; + GLwDrawingAreaPart glwDrawingArea; +} GLwMDrawingAreaRec; +#else /* not __GLX_MOTIF */ +typedef struct _GLwDrawingAreaRec { + CorePart core; + GLwDrawingAreaPart glwDrawingArea; +} GLwDrawingAreaRec; +#endif /* __GLX_MOTIF */ + +#endif /* _GLwDrawP_h */ diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.c b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.c new file mode 100755 index 000000000..7cd5c1a23 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.c @@ -0,0 +1,43 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwMDrawA.c,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +#ifndef __GLX_MOTIF +#define __GLX_MOTIF 1 +#endif +#include "GLwDrawA.c" diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.h b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.h new file mode 100755 index 000000000..a275aec47 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.h @@ -0,0 +1,51 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwMDrawA.h,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +/* +** This file has been slightly modified from the original by Carlos A. M. dos +** Santos <casantos@cpmet.ufpel.tche.br> for integration into XFree86 source +** tree and for generating both Motif(TM) 1.2 and 2.x versions of the widgets +** in the same library. +*/ +/* $XFree86: xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawA.h,v 1.2 2000/11/02 20:39:07 dawes Exp $ */ + +#ifndef __GLX_MOTIF +#define __GLX_MOTIF 1 +#endif +#include <GL/GLwDrawA.h> diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawAP.h b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawAP.h new file mode 100755 index 000000000..b36bb7b93 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawAP.h @@ -0,0 +1,51 @@ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +*/ +/* +** $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GLwMDrawAP.h,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ +*/ + +/* +** This file has been slightly modified from the original by Carlos A. M. dos +** Santos <casantos@cpmet.ufpel.tche.br> for integration into XFree86 source +** tree and for generating both Motif(TM) 1.2 and 2.x versions of the widgets +** in the same library. +*/ +/* $XFree86: xc/extras/ogl-sample/main/gfx/lib/glw/GLwMDrawAP.h,v 1.2 2000/11/02 20:39:07 dawes Exp $ */ + +#ifndef __GLX_MOTIF +#define __GLX_MOTIF 1 +#endif +#include <GL/GLwDrawAP.h> diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/GNUmakefile b/xc/extras/ogl-sample/main/gfx/lib/glw/GNUmakefile new file mode 100755 index 000000000..4dc3eb204 --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/GNUmakefile @@ -0,0 +1,76 @@ +#!gmake +# +# License Applicability. Except to the extent portions of this file are +# made subject to an alternative license as permitted in the SGI Free +# Software License B, Version 1.1 (the "License"), the contents of this +# file are subject only to the provisions of the License. You may not use +# this file except in compliance with the License. You may obtain a copy +# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +# +# http://oss.sgi.com/projects/FreeB +# +# Note that, as provided in the License, the Software is distributed on an +# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +# PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +# +# Original Code. The Original Code is: OpenGL Sample Implementation, +# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +# Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +# Copyright in any portions created by third parties is as indicated +# elsewhere herein. All Rights Reserved. +# +# Additional Notice Provisions: The application programming interfaces +# established by SGI in conjunction with the Original Code are The +# OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +# April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +# 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +# Window System(R) (Version 1.3), released October 19, 1998. This software +# was created using the OpenGL(R) version 1.2.1 Sample Implementation +# published by SGI, but has not been independently verified as being +# compliant with the OpenGL(R) version 1.2.1 Specification. +# +# $Date: 2000/11/08 02:53:56 $ $Revision: 1.1.1.1 $ +# $Header: /home/ajax/dri-backup/xc/xc/extras/ogl-sample/main/gfx/lib/glw/Attic/GNUmakefile,v 1.1.1.1 2000/11/08 02:53:56 dawes Exp $ + +include $(ROOT)/usr/include/make/commondefs + +TARGET = libGLw.a + +TARGETS = $(TARGET) + +CFILES = \ + GLwDrawA.c \ + $(NULL) + +MOTIF_CFILES = \ + GLwMDrawA.c \ + GLwDAUtil.c \ + $(NULL) + +ifeq ($(HAVE_MOTIF),1) +LCDEFS += -D__GLX_MOTIF=1 +CFILES += $(MOTIF_CFILES) +ifeq ($(OS),Linux) +# assume motif is in / rather than $ROOT +LCINCS += -I/usr/X11R6/include +endif +endif + +INSTALLFLAGS += -srcdst + +default libs: $(TARGET) + +headers headers_install apps: + +libs_install install: default + $(INSTALL) -F $(ROOT)/usr/include/X11/GLw GLwDrawA.h + $(INSTALL) -F $(ROOT)/usr/include/X11/GLw GLwMDrawA.h + $(INSTALL) -F $(LIB_LOCATION) $(TARGET); + +$(TARGET): $(OBJECTS) + $(AR) crl $@ $(OBJECTS); + +include $(COMMONRULES) diff --git a/xc/extras/ogl-sample/main/gfx/lib/glw/Imakefile b/xc/extras/ogl-sample/main/gfx/lib/glw/Imakefile new file mode 100755 index 000000000..9d8c9000e --- /dev/null +++ b/xc/extras/ogl-sample/main/gfx/lib/glw/Imakefile @@ -0,0 +1,50 @@ +XCOMM License Applicability. Except to the extent portions of this file are +XCOMM made subject to an alternative license as permitted in the SGI Free +XCOMM Software License B, Version 1.1 (the "License"), the contents of this +XCOMM file are subject only to the provisions of the License. You may not use +XCOMM this file except in compliance with the License. You may obtain a copy +XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +XCOMM +XCOMM http://oss.sgi.com/projects/FreeB +XCOMM +XCOMM Note that, as provided in the License, the Software is distributed on an +XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +XCOMM +XCOMM Original Code. The Original Code is: OpenGL Sample Implementation, +XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +XCOMM Copyright in any portions created by third parties is as indicated +XCOMM elsewhere herein. All Rights Reserved. +XCOMM +XCOMM Additional Notice Provisions: The application programming interfaces +XCOMM established by SGI in conjunction with the Original Code are The +XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software +XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation +XCOMM published by SGI, but has not been independently verified as being +XCOMM compliant with the OpenGL(R) version 1.2.1 Specification. +XCOMM + +#include <Library.tmpl> + +OBJS = \ + GLwDAUtil.o \ + GLwDrawA.o \ + GLwMDrawA.o + +INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/include/GL + +NormalLibraryObjectRule() + +NormalLibraryTarget(GLw, $(OBJS)) + +DependTarget() +CleanTarget() diff --git a/xc/include/XF86keysym.h b/xc/include/XF86keysym.h index 9b6773641..4e86e81f7 100644 --- a/xc/include/XF86keysym.h +++ b/xc/include/XF86keysym.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/include/XF86keysym.h,v 1.5 2000/07/07 00:44:58 dawes Exp $ */ +/* $XFree86: xc/include/XF86keysym.h,v 1.6 2000/11/02 02:51:09 dawes Exp $ */ /* * XFree86 vendor specific keysyms. @@ -57,8 +57,10 @@ #define XF86XK_Forward 0x1008FF27 #define XF86XK_Stop 0x1008FF28 #define XF86XK_Refresh 0x1008FF29 +#define XF86XK_PowerOff 0x1008FF1A +#define XF86XK_WakeUp 0x1008FF1B -/* Note, 0x1008FF2A - 0x1008FF2F are free and should be used next */ +/* Note, 0x1008FF2C - 0x1008FF2F are free and should be used next */ /* Some more ... */ #define XF86XK_Favorites 0x1008FF30 diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile index cf9c82b86..3b04b1580 100644 --- a/xc/lib/GL/mesa/src/drv/r128/Imakefile +++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.7 2000/10/20 12:57:23 alanh Exp $ +XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.8 2000/11/02 21:31:03 tsi Exp $ #include <Threads.tmpl> @@ -30,7 +30,7 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL -I$(XF86OSSRC) \ -I$(XF86COMSRC) \ -I$(SERVERSRC)/GL/dri \ - -I$(XF86DRIVERSRC)/r128 \ + -I$(XF86DRIVERSRC)/ati \ -I../../../include \ -I../.. \ -I../../X \ diff --git a/xc/lib/GLw/GLwM1DrawA.c b/xc/lib/GLw/GLwM1DrawA.c new file mode 100644 index 000000000..ac6b38f8c --- /dev/null +++ b/xc/lib/GLw/GLwM1DrawA.c @@ -0,0 +1,55 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* $XFree86: xc/lib/GLw/GLwM1DrawA.c,v 1.1 2000/11/02 20:39:07 dawes Exp $ */ + +#define __GLX_MOTIF 1 + +#define XmVERSION 1 +#define XmREVISION 2 +#define XmVersion (XmVERSION * 1000 + XmREVISION) +#define XmVERSION_STRING "GLwDrawingArea fake M*tif 1.X" +#define XmUPDATE_LEVEL 0 + +/* Include our fake Motif headers */ +#include "GLwXm/Xm.h" +#include "GLwXm/PrimitiveP.h" + +#define __GLX_INCLUDE_XM_H +#define __GLX_INCLUDE_PRIMITIVE_P_H + +#include "GLwDrawA.c" diff --git a/xc/lib/GLw/GLwM2DrawA.c b/xc/lib/GLw/GLwM2DrawA.c new file mode 100644 index 000000000..eb313514c --- /dev/null +++ b/xc/lib/GLw/GLwM2DrawA.c @@ -0,0 +1,55 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* $XFree86: xc/lib/GLw/GLwM2DrawA.c,v 1.1 2000/11/02 20:39:07 dawes Exp $ */ + +#define __GLX_MOTIF 2 + +#define XmVERSION 2 +#define XmREVISION 0 +#define XmVersion (XmVERSION * 1000 + XmREVISION) +#define XmVERSION_STRING "GLwDrawingArea fake M*tif 2.X" +#define XmUPDATE_LEVEL 0 + +/* Include our fake Motif headers */ +#include "GLwXm/Xm.h" +#include "GLwXm/PrimitiveP.h" + +#define __GLX_INCLUDE_XM_H +#define __GLX_INCLUDE_PRIMITIVE_P_H + +#include "GLwDrawA.c" diff --git a/xc/lib/GLw/GLwXm/PrimitiveP.h b/xc/lib/GLw/GLwXm/PrimitiveP.h new file mode 100644 index 000000000..ccd03fa2d --- /dev/null +++ b/xc/lib/GLw/GLwXm/PrimitiveP.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * 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 XFREE86 PROJECT 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. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* $XFree86: xc/lib/GLw/GLwXm/PrimitiveP.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */ + +/* + * This file is a fake Motif(TM) header intended to allow the compilation of + * libGLw without having a real Motif. Do not use this file to compile any + * application because it declares only a small subset of the API! + */ + +#ifndef GLWXM_PRIMITIVE_P_H +#define GLWXM_PRIMITIVE_P_H + +#include "GLwXm/XmP.h" + +/* primitive instance part */ +typedef struct { + Pixel foreground; + Dimension shadow_thickness; + Pixel top_shadow_color; + Pixmap top_shadow_pixmap; + Pixel bottom_shadow_color; + Pixmap bottom_shadow_pixmap; + Dimension highlight_thickness; + Pixel highlight_color; + Pixmap highlight_pixmap; + XtCallbackList help_callback; + XtPointer user_data; + Boolean traversal_on; + Boolean highlight_on_enter; + Boolean have_traversal; + unsigned char unit_type; + XmNavigationType navigation_type; + Boolean highlight_drawn; + Boolean highlighted; + GC highlight_GC; + GC top_shadow_GC; + GC bottom_shadow_GC; +#if XmVERSION > 1 + XtCallbackList convert_callback; + XtCallbackList popup_handler_callback; + XmDirection layout_direction; +#endif +} XmPrimitivePart; + +/* primitive class part */ +typedef struct { + XtWidgetProc border_highlight; + XtWidgetProc border_unhighlight; + String translations; + XtActionProc arm_and_activate; + XmSyntheticResource *syn_resources; + int num_syn_resources; + XtPointer extension; +} XmPrimitiveClassPart; + +/* class record */ +typedef struct _XmPrimitiveClassRec { + CoreClassPart core_class; + XmPrimitiveClassPart primitive_class; +} XmPrimitiveClassRec; + +/* declare class record */ +extern XmPrimitiveClassRec xmPrimitiveClassRec; + +#endif /* GLWXM_PRIMITIVE_P_H */ diff --git a/xc/lib/GLw/GLwXm/Xm.h b/xc/lib/GLw/GLwXm/Xm.h new file mode 100644 index 000000000..0020048b8 --- /dev/null +++ b/xc/lib/GLw/GLwXm/Xm.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * 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 XFREE86 PROJECT 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. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* $XFree86: xc/lib/GLw/GLwXm/Xm.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */ + +/* + * This file is a fake Motif(TM) header intended to allow the compilation of + * libGLw without having a real Motif. Do not use this file to compile any + * application because it declares only a small subset of the API! + */ + +#ifndef GLWXM_H +#define GLWXM_H + +#include <X11/Intrinsic.h> +#include <X11/Shell.h> +#include <X11/Xatom.h> +#include "GLwXm/XmStrDefs.h" + +enum { + XmATTACH_NONE, + XmATTACH_FORM, + XmATTACH_OPPOSITE_FORM, + XmATTACH_WIDGET, + XmATTACH_OPPOSITE_WIDGET, + XmATTACH_POSITION, + XmATTACH_SELF +}; + +enum { + XmCR_NONE, + XmCR_HELP, + XmCR_VALUE_CHANGED, + XmCR_INCREMENT, + XmCR_DECREMENT, + XmCR_PAGE_INCREMENT, + XmCR_PAGE_DECREMENT, + XmCR_TO_TOP, + XmCR_TO_BOTTOM, + XmCR_DRAG, + XmCR_ACTIVATE, + XmCR_ARM, + XmCR_DISARM, + XmCR_DUMMY13, + XmCR_DUMMY14, + XmCR_DUMMY15, + XmCR_MAP, + XmCR_UNMAP, + XmCR_FOCUS, + XmCR_LOSING_FOCUS, + XmCR_MODIFYING_TEXT_VALUE, + XmCR_MOVING_INSERT_CURSOR, + XmCR_EXECUTE, + XmCR_SINGLE_SELECT, + XmCR_MULTIPLE_SELECT, + XmCR_EXTENDED_SELECT, + XmCR_BROWSE_SELECT, + XmCR_DEFAULT_ACTION, + XmCR_CLIPBOARD_DATA_REQUEST, + XmCR_CLIPBOARD_DATA_DELETE, + XmCR_CASCADING, + XmCR_OK, + XmCR_CANCEL, + XmCR_DUMMY33, + XmCR_APPLY, + XmCR_NO_MATCH, + XmCR_COMMAND_ENTERED, + XmCR_COMMAND_CHANGED, + XmCR_EXPOSE, + XmCR_RESIZE, + XmCR_INPUT, + XmCR_GAIN_PRIMARY, + XmCR_LOSE_PRIMARY, + XmCR_CREATE, + XmCR_TEAR_OFF_ACTIVATE, + XmCR_TEAR_OFF_DEACTIVATE, + XmCR_OBSCURED_TRAVERSAL, +#if XmVERSION < 2 + XmCR_PROTOCOLS +#else + XmCR_FOCUS_MOVED, + XmCR_DUMMY48, + XmCR_DUMMY49, + XmCR_DUMMY50, + XmCR_DUMMY51, + XmCR_DUMMY52, + XmCR_DUMMY53, + XmCR_REPOST, + XmCR_COLLAPSED, + XmCR_EXPANDED, + XmCR_SELECT, + XmCR_DRAG_START, + XmCR_NO_FONT, + XmCR_NO_RENDITION, + XmCR_POST, + XmCR_SPIN_NEXT, + XmCR_SPIN_PRIOR, + XmCR_SPIN_FIRST, + XmCR_SPIN_LAST, + XmCR_PAGE_SCROLLER_INCREMENT, + XmCR_PAGE_SCROLLER_DECREMENT, + XmCR_MAJOR_TAB, + XmCR_MINOR_TAB, + XmCR_PROTOCOLS = 6666 +#endif +}; + +typedef unsigned char XmDirection; + +typedef struct { + int reason; + XEvent *event; + Window window; +} XmDrawingAreaCallbackStruct; + +#define XmUNSPECIFIED_PIXMAP 2 + +typedef unsigned char XmNavigationType; + +#endif /* GLWXM_H */ diff --git a/xc/lib/GLw/GLwXm/XmP.h b/xc/lib/GLw/GLwXm/XmP.h new file mode 100644 index 000000000..6e7228805 --- /dev/null +++ b/xc/lib/GLw/GLwXm/XmP.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * 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 XFREE86 PROJECT 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. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* $XFree86: xc/lib/GLw/GLwXm/XmP.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */ + +/* + * This file is a fake Motif(TM) header intended to allow the compilation of + * libGLw without having a real Motif. Do not use this file to compile any + * application because it declares only a small subset of the API! + */ + +#ifndef GLWXM_P_H +#define GLWXM_P_H + +#include "GLwXm/Xm.h" +#include <X11/IntrinsicP.h> + +#define XmInheritBorderHighlight ((XtWidgetProc) _XtInherit) +#define XmInheritBorderUnhighlight ((XtWidgetProc) _XtInherit) + +void _XmBackgroundColorDefault(Widget widget, int offset, XrmValue *value); +void _XmForegroundColorDefault(Widget widget, int offset, XrmValue *value); +void _XmHighlightColorDefault(Widget widget, int offset, XrmValue *value); +void _XmPrimitiveHighlightPixmapDefault(Widget widget, int offset, + XrmValue *value); + +typedef enum { + XmSYNTHETIC_NONE, + XmSYNTHETIC_LOAD +} XmImportOperator; + +typedef void (*XmExportProc)(Widget, int, XtArgVal *); + +typedef XmImportOperator (*XmImportProc)(Widget, int, XtArgVal*); + +typedef struct _XmSyntheticResource { + String resource_name; + Cardinal resource_size; + Cardinal resource_offset; + XmExportProc export_proc; + XmImportProc import_proc; +} XmSyntheticResource; + +#endif /* GLWXM_P_H */ diff --git a/xc/lib/GLw/GLwXm/XmStrDefs.h b/xc/lib/GLw/GLwXm/XmStrDefs.h new file mode 100644 index 000000000..8fe7e67fa --- /dev/null +++ b/xc/lib/GLw/GLwXm/XmStrDefs.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * 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 XFREE86 PROJECT 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. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* $XFree86: xc/lib/GLw/GLwXm/XmStrDefs.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */ + +/* + * This file is a fake Motif(TM) header intended to allow the compilation of + * libGLw without having a real Motif. Do not use this file to compile any + * application because it declares only a small subset of the API! + */ + +#ifndef GLWXM_STRDEFS_H +#define GLWXM_STRDEFS_H + +#ifndef _XmConst +#define _XmConst /**/ +#endif + +#ifdef XMSTRINGDEFINES + +#define XmCBackgroundPixmap "BackgroundPixmap" +#define XmRBackgroundPixmap "BackgroundPixmap" +#define XmRBooleanDimension "BooleanDimension" +#define XmNbottomAttachment "bottomAttachment" +#define XmNbottomWidget "bottomWidget" +#define XmCForegroundThreshold "ForegroundThreshold" +#define XmNforegroundThreshold "foregroundThreshold" +#define XmCHighlightColor "HighlightColor" +#define XmNhighlightColor "highlightColor" +#define XmCHighlightOnEnter "HighlightOnEnter" +#define XmNhighlightOnEnter "highlightOnEnter" +#define XmCHighlightThickness "HighlightThickness" +#define XmNhighlightThickness "highlightThickness" +#define XmCHighlightPixmap "HighlightPixmap" +#define XmNhighlightPixmap "highlightPixmap" +#define XmRHighlightPixmap "HighlightPixmap" +#define XmRHorizontalDimension "HorizontalDimension" +#define XmNleftAttachment "leftAttachment" +#define XmNrightAttachment "rightAttachment" +#define XmRStringDirection "StringDirection" +#define XmNtopAttachment "topAttachment" +#define XmCTraversalOn "TraversalOn" +#define XmNtraversalOn "traversalOn" +#define XmRXmBackgroundPixmap "XmBackgroundPixmap" + +#else /* XMSTRINGDEFINES */ + +extern _XmConst char _XmStrings[]; + +#define XmCBackgroundPixmap ((char *)&_XmStrings[299]) +#define XmRBackgroundPixmap ((char *)&_XmStrings[10844]) +#define XmRBooleanDimension ((char *)&_XmStrings[10872]) +#define XmNbottomAttachment ((char *)&_XmStrings[5017]) +#define XmNbottomWidget ((char *)&_XmStrings[5099]) +#define XmCHighlightColor ((char *)&_XmStrings[1844]) +#define XmNhighlightColor ((char *)&_XmStrings[6996]) +#define XmCHighlightOnEnter ((char *)&_XmStrings[1859]) +#define XmNhighlightOnEnter ((char *)&_XmStrings[7011]) +#define XmCHighlightThickness ((char *)&_XmStrings[1892]) +#define XmNhighlightThickness ((char *)&_XmStrings[7044]) +#define XmCForegroundThreshold ((char *)&_XmStrings[1808]) +#define XmNforegroundThreshold ((char *)&_XmStrings[6914]) +#define XmCHighlightPixmap ((char *)&_XmStrings[1876]) +#define XmNhighlightPixmap ((char *)&_XmStrings[7028]) +#define XmRHighlightPixmap ((char *)&_XmStrings[11299]) +#define XmRHorizontalDimension ((char *)&_XmStrings[11315]) +#define XmNleftAttachment ((char *)&_XmStrings[7523]) +#define XmNrightAttachment ((char *)&_XmStrings[9077]) +#define XmRStringDirection ((char *)&_XmStrings[11981]) +#define XmNtopAttachment ((char *)&_XmStrings[10165]) +#define XmCTraversalOn ((char *)&_XmStrings[4318]) +#define XmNtraversalOn ((char *)&_XmStrings[10361]) +#define XmRXmBackgroundPixmap ((char *)&_XmStrings[12210]) + +#endif /* XMSTRINGDEFINES */ + +/* copy Xt constant definitions */ +#include <X11/StringDefs.h> + +#define XmCBackground XtCBackground +#define XmNbackground XtNbackground +#define XmNbackgroundPixmap XtNbackgroundPixmap +#define XmCBoolean XtCBoolean +#define XmRBoolean XtRBoolean +#define XmRCallProc XtRCallProc +#define XmCForeground XtCForeground +#define XmNforeground XtNforeground +#define XmRImmediate XtRImmediate +#define XmRPixel XtRPixel +#define XmCPixmap XtCPixmap +#define XmNpixmap XtNpixmap +#define XmRPixmap XtRPixmap +#define XmRPrimHighlightPixmap XmRHighlightPixmap +#define XmRString XtRString +#define XmRStringArray XtRStringArray +#define XmRStringTable XtRStringTable + +#endif /* GLWXM_STRDEFS_H */ diff --git a/xc/lib/GLw/Imakefile b/xc/lib/GLw/Imakefile new file mode 100644 index 000000000..790b242df --- /dev/null +++ b/xc/lib/GLw/Imakefile @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * 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 XFREE86 PROJECT 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. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +XCOMM $XFree86: xc/lib/GLw/Imakefile,v 1.2 2000/11/02 21:20:10 dawes Exp $ + +XCOMM +XCOMM Imakefile for GLw library - lots of modifications for XFree86 by +XCOMM Carlos A. M. dos Santos <casantos@cpmet.ufpel.tche.br> +XCOMM + +XCOMM Uncomment this and set the correct values if your Motif installation +XCOMM is out of the standard X tree and your Imake configuration is not +XCOMM correct (unfortunatelly, a common mistake). + +XCOMM MOTIF_INCLUDES = -I/usr/local/include +XCOMM MOTIF_LDFLAGS = -L/usr/local/lib + +#define DoNormalLib NormalLibGLw +#define DoSharedLib SharedLibGLw +#define DoDebugLib DebugLibGLw +#define DoProfileLib ProfileLibGLw + +#define HasSharedData NO +#define LibName GLw +#define SoRev SOGLWREV +#define IncSubdir GL + +REQUIREDLIBS = $(LDPRELIBS) $(XLIB) + +DEFINES = + +#if GLwUseXmStubs +SHAREDCODEDEF = SharedCodeDef -DUSE_XM_STUBS +#endif + +GLWSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glw + +INCLUDES = $(MOTIF_INCLUDES) -I. + +LOCAL_LDFLAGS = $(MOTIF_LDFLAGS) + +LINTLIBS = $(LINTXLIB) $(LINTXTOOL) + +HEADERS = GLwDrawA.h GLwDrawAP.h GLwMDrawA.h GLwMDrawAP.h +SRCS = GLwDrawA.c GLwM1DrawA.c GLwM2DrawA.c GLwDAUtil.c +OBJS = GLwDrawA.o GLwM1DrawA.o GLwM2DrawA.o GLwDAUtil.o + +#include <Library.tmpl> + +LinkSourceFile(GLwDAUtil.c,$(GLWSRCDIR)) +LinkSourceFile(GLwDrawA.c,$(GLWSRCDIR)) +LinkSourceFile(GLwMDrawA.c,$(GLWSRCDIR)) +LinkSourceFile(GLwDrawA.h,$(GLWSRCDIR)) +LinkSourceFile(GLwDrawAP.h,$(GLWSRCDIR)) +LinkSourceFile(GLwMDrawA.h,$(GLWSRCDIR)) +LinkSourceFile(GLwMDrawAP.h,$(GLWSRCDIR)) + +DependTarget() diff --git a/xc/lib/GLw/README.html b/xc/lib/GLw/README.html new file mode 100644 index 000000000..02b599b6a --- /dev/null +++ b/xc/lib/GLw/README.html @@ -0,0 +1,242 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<HTML> +<HEAD> +<TITLE>GL widgets for Xt/Motif - XFree86 implementation</TITLE> +<META NAME="generator" CONTENT="Only VIM and me."> +</HEAD> +<BODY BGCOLOR="#FFFFFF"> + +<!-- $XFree86: xc/lib/GLw/README.html,v 1.2 2000/11/06 21:57:10 dawes Exp $ --> + +<H1 ALIGN=CENTER>GL widgets for Xt/Motif</H1> +<H2 ALIGN=CENTER>XFree86 implementation</H1> +<P ALIGN=CENTER>by Carlos A. M. dos Santos<BR>casantos@cpmet.ufpel.tche.br</P> + +<HR NOSHADE> + +<H3>1. Introduction</H3> +<P> +This directory contains the source code for SGI's OpenGL Xt/Motif(TM) widgets, +slightly modified to generate both Motif 1.x and 2.x versions of +the widget even if Motif is not available, as in the XFree86 distribution of +the X Window System. This code is based on that distributed by Silicon +Graphics as part of it's OpenGL Sample Implementation, not on the modified version +distributed with Mesa. + + +<H3>2. Installation</H3> +<P> +This code is intended to be compiled as part of the normal XFree86 building +process, under the xc/lib/GLw directory. To compile the library out of the X +source tree, follow instructions below. + +<H3>2.1. Requirements</H3> +<P> +Gzip and tar are needed to extract the files from the distribution <A +HREF="http://www.inf.ufrgs.br/~casantos/libGLw/GLw.tar.gz">archive</A>. Tar is +a standard UNIX utility but if you don't have it use GNU tar, available in +source form at <A +HREF="ftp://ftp.gnu.org/pub/gnu/">ftp://ftp.gnu.org/pub/gnu/</A>. Gzip is not +a standard UNIX utility, though available in many systems. You may obtain it +(also source form) at the same FTP server as GNU tar. + +<P> +You need xmkmf and imake too. Depending on your operating system you may need +to install some kind of X Window System development kit, so check the vendor +documentation first. I was told that some UNIX systems don't have imake: +report this as a bug (to your vendor, not me). + +<P> +Of course you will need a C compiler. + +<H3>2.2. Steps</H3> +<P> +<OL> + <LI>Extract the source code from the distribution archive. + <P> + <CODE> + gzip -dc GLw.tar.gz | tar xf - + </CODE> + <P> + <LI>Go to the surce code directory and generate the makefile. + <P> + <CODE> + cd GLw<BR> + xmkmf + </CODE> + <P>For LessTif, use "mxmkmf" instead of "xmkmf". Imake support + is much better in recent versions of LessTif (since late july 2000). + If your Motif or OpenGL libraries and/or include files are installed in + non-standard locations (some UNIX vendors seem to be very creative :-) + then edit the file named Imakefile, remove the leading XCOMM of the + lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the + appropriate values. + <P> + <LI>Compile the code with + <P> + <CODE> + make includes<BR> + make standalone + </CODE> + <P> + <LI>Install the library and manual pages with + <P> + <CODE> + make install<BR> + make install.man + </CODE> + <P> + <LI>Optionally, you may compile two test programs: xmdemo and xtdemo. You need OpenGL + (or Mesa) for both and Motif (or LessTif) for xmdemo. There are four + extra make targers for these programs: demos, stand-demos, stand-xmdemo + and stand-xtdemo. You may use them with: + <P> + <CODE> + make stand-demos<BR> + ./xmdemo + ./xtdemo + </CODE> +</OL> + +<H3>2.3. Creating a shared library</H3> +<P> +By default only a static library is created because most of the UNIX loaders, +if not all, complain about unresolved symbols even if the application doesn't +use the modules in which such symbols are referenced. However, if your system +supports libraries with weak symbols (e.g. Solaris, FreeBSD and Linux) it is +possible to fool the loader. All you have to do is edit the Imakefile, +changing "#define SharedLibGLw" and "#define GLwUseXmStubs" to YES, then +repeat the compilation process starting from step 2 in the previous section. + +<H3>2.4. Problems</H3> +<P> +If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look +at <A HREF="http://www.xfree86.org">http://www.xfree86.org</A> for +instructions on how to subscribe. In desperation, send an email to <A +HREF="mailto:casantos@cpmet.ufpel.tche.br">casantos@cpmet.ufpel.tche.br</A>. + +<P> +PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR OPERATING +SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR WHATEVER ELSE! + + +<H3>3. Copyrights</H3> +<P> +Most of the code is covered by the following license terms: +<BLOCKQUOTE> +<P> +License Applicability. Except to the extent portions of this file are +made subject to an alternative license as permitted in the SGI Free +Software License B, Version 1.1 (the "License"), the contents of this +file are subject only to the provisions of the License. You may not use +this file except in compliance with the License. You may obtain a copy +of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +<P> +<A +HREF="http://oss.sgi.com/projects/FreeB">http://oss.sgi.com/projects/FreeB</A> +<P> +Note that, as provided in the License, the Software is distributed on an +"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +<P> +Original Code. The Original Code is: OpenGL Sample Implementation, +Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +Inc. The Original Code is Copyright © 1991-2000 Silicon Graphics, Inc. +Copyright in any portions created by third parties is as indicated +elsewhere herein. All Rights Reserved. +<P> +Additional Notice Provisions: The application programming interfaces +established by SGI in conjunction with the Original Code are The +OpenGL® Graphics System: A Specification (Version 1.2.1), released +April 1, 1999; The OpenGL® Graphics System Utility Library (Version +1.3), released November 4, 1998; and OpenGL® Graphics with the X +Window System® (Version 1.3), released October 19, 1998. This software +was created using the OpenGL® version 1.2.1 Sample Implementation +published by SGI, but has not been independently verified as being +compliant with the OpenGL® version 1.2.1 Specification. +</BLOCKQUOTE> + +<P> +The demonstration programs are covered by the following license terms: + +<BLOCKQUOTE> +<P> +Copyright © Mark J. Kilgard, 1995, 1996. + +<P> +NOTICE: This source code distribution contains source code contained in +the book "Programming OpenGL for the X Window System" (ISBN: +0-201-48359-9) published by Addison-Wesley. The programs and associated +files contained in the distribution were developed by Mark J. Kilgard and +are Copyright 1994, 1995, 1996 by Mark J. Kilgard (unless otherwise +noted). The programs are not in the public domain, but they are freely +distributable without licensing fees. These programs are provided without +guarantee or warrantee expressed or implied. +</BLOCKQUOTE> + +<P> +The files contained in directory GLwXm are fake Motif headers, covered by +the XFree86 license, they permit us to generate both Motif 1.x and 2.x +versions of the widget without having Motif. Notice that they are NOT part of +a standard Motif distribution and shall not be used to compile any other code. + + +<H3>4. Thanks</H3> + +<P> +Many thanks to Silicon Graphics and Mark J. Kilgard for making their +software free. + + +<H3>5. No thanks</H3> + +<BLOCKQUOTE> +<P> +<STRONG> +THIS SECTION CONTAINS MY PERSONAL OPINIONS AND +DOESN'T REPRESENT AN OFFICIAL POSITION OF THE XFree86 PROJECT. +</STRONG> +</BLOCKQUOTE> + +<P> +The first incarnation of this version of libGLw used eight header files from +<A HREF="http://www.lesstif.org/">LessTif</A>, four for each Motif version. +LessTif is covered by the GNU Library General Public License (LGPL) whose +terms are not compatible with the XFree86 licensing policy. Since the +copyright holder of LessTif is the <A HREF="http://www.fsf.org/">Free Software +Foundation</A> (FSF), I asked Richard Stallman, president of FSF and so called +"leader of the Free Software movement", permission to redistribute a copy of +those eight headers under XFree86 terms, still maintaining the FSF copyright. + +<P> +Observe that I was not asking him to change the license of LessTif as a whole, +but only to allow me to distribute copies of some header files containing +function prototypes, variable declarations and data type definitions. Even so, +Stallman said no because the files contained "more than 6000 lines of code". +Which code? The LessTif headers are mostly copies of the Motif ones and don't +contain any original GNU "code"! I can't still imagine a reason for Stallman's +negative answer except for paranoia. He seems to ignore what Motif is and +that LessTif's API is simply a copy of Motif's one. + +<P> +After spending some time, I made my own headers, that became much smaller than +the previous ones because I included only a subset of the Motif API and merged +everything into four files: 417 lines instead 6000. Humm, perhaps I should be +grateful to Sallman too :-). + + +<H3>6. Trademarks</H3> + +<P> +<UL> + <LI>OpenGL is a trademark of Silicon Graphics, Inc. + <LI>Motif is a trademark of the Open Group. +</UL> + +<HR NOSHADE> + +</BODY> +</HTML> diff --git a/xc/lib/GLw/README.txt b/xc/lib/GLw/README.txt new file mode 100644 index 000000000..f3eb83f3f --- /dev/null +++ b/xc/lib/GLw/README.txt @@ -0,0 +1,199 @@ + GL widgets for Xt/Motif + + XFree86 implementation + + by Carlos A. M. dos Santos + casantos@cpmet.ufpel.tche.br + + ------------------------------------------------------------------------ + +1. Introduction + +This directory contains the source code for SGI's OpenGL Xt/Motif(TM) +widgets, slightly modified to generate both Motif 1.x and 2.x versions of +the widget even if Motif is not available, as in the XFree86 distribution of +the X Window System. This code is based on that distributed by Silicon +Graphics as part of it's OpenGL Sample Implementation, not on the modified +version distributed with Mesa. + +2. Installation + +This code is intended to be compiled as part of the normal XFree86 building +process, under the xc/lib/GLw directory. To compile the library out of the X +source tree, follow instructions below. + +2.1. Requirements + +Gzip and tar are needed to extract the files from the distribution archive. +Tar is a standard UNIX utility but if you don't have it use GNU tar, +available in source form at ftp://ftp.gnu.org/pub/gnu/. Gzip is not a +standard UNIX utility, though available in many systems. You may obtain it +(also source form) at the same FTP server as GNU tar. + +You need xmkmf and imake too. Depending on your operating system you may +need to install some kind of X Window System development kit, so check the +vendor documentation first. I was told that some UNIX systems don't have +imake: report this as a bug (to your vendor, not me). + +Of course you will need a C compiler. + +2.2. Steps + + 1. Extract the source code from the distribution archive. + + gzip -dc GLw.tar.gz | tar xf - + + 2. Go to the surce code directory and generate the makefile. + + cd GLw + xmkmf + + For LessTif, use "mxmkmf" instead of "xmkmf". Imake support is much + better in recent versions of LessTif (since late july 2000). If your + Motif or OpenGL libraries and/or include files are installed in + non-standard locations (some UNIX vendors seem to be very creative :-) + then edit the file named Imakefile, remove the leading XCOMM of the + lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the + appropriate values. + + 3. Compile the code with + + make includes + make standalone + + 4. Install the library and manual pages with + + make install + make install.man + + 5. Optionally, you may compile two test programs: xmdemo and xtdemo. You + need OpenGL (or Mesa) for both and Motif (or LessTif) for xmdemo. There + are four extra make targers for these programs: demos, stand-demos, + stand-xmdemo and stand-xtdemo. You may use them with: + + make stand-demos + ./xmdemo ./xtdemo + +2.3. Creating a shared library + +By default only a static library is created because most of the UNIX +loaders, if not all, complain about unresolved symbols even if the +application doesn't use the modules in which such symbols are referenced. +However, if your system supports libraries with weak symbols (e.g. Solaris, +FreeBSD and Linux) it is possible to fool the loader. All you have to do is +edit the Imakefile, changing "#define SharedLibGLw" and "#define +GLwUseXmStubs" to YES, then repeat the compilation process starting from +step 2 in the previous section. + +2.4. Problems + +If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look +at http://www.xfree86.org for instructions on how to subscribe. In +desperation, send an email to casantos@cpmet.ufpel.tche.br. + +PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR +OPERATING SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR +WHATEVER ELSE! + +3. Copyrights + +Most of the code is covered by the following license terms: + + License Applicability. Except to the extent portions of this file + are made subject to an alternative license as permitted in the SGI + Free Software License B, Version 1.1 (the "License"), the contents + of this file are subject only to the provisions of the License. + You may not use this file except in compliance with the License. + You may obtain a copy of the License at Silicon Graphics, Inc., + attn: Legal Services, 1600 Amphitheatre Parkway, Mountain View, CA + 94043-1351, or at: + + http://oss.sgi.com/projects/FreeB + + Note that, as provided in the License, the Software is distributed + on an "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND + CONDITIONS DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED + WARRANTIES AND CONDITIONS OF MERCHANTABILITY, SATISFACTORY + QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. + + Original Code. The Original Code is: OpenGL Sample Implementation, + Version 1.2.1, released January 26, 2000, developed by Silicon + Graphics, Inc. The Original Code is Copyright © 1991-2000 Silicon + Graphics, Inc. Copyright in any portions created by third parties + is as indicated elsewhere herein. All Rights Reserved. + + Additional Notice Provisions: The application programming + interfaces established by SGI in conjunction with the Original + Code are The OpenGL® Graphics System: A Specification (Version + 1.2.1), released April 1, 1999; The OpenGL® Graphics System + Utility Library (Version 1.3), released November 4, 1998; and + OpenGL® Graphics with the X Window System® (Version 1.3), released + October 19, 1998. This software was created using the OpenGL® + version 1.2.1 Sample Implementation published by SGI, but has not + been independently verified as being compliant with the OpenGL® + version 1.2.1 Specification. + +The demonstration programs are covered by the following license terms: + + Copyright © Mark J. Kilgard, 1995, 1996. + + NOTICE: This source code distribution contains source code + contained in the book "Programming OpenGL for the X Window System" + (ISBN: 0-201-48359-9) published by Addison-Wesley. The programs + and associated files contained in the distribution were developed + by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark J. + Kilgard (unless otherwise noted). The programs are not in the + public domain, but they are freely distributable without licensing + fees. These programs are provided without guarantee or warrantee + expressed or implied. + +The files contained in directory GLwXm are fake Motif headers, covered by +the XFree86 license, they permit us to generate both Motif 1.x and 2.x +versions of the widget without having Motif. Notice that they are NOT part +of a standard Motif distribution and shall not be used to compile any other +code. + +4. Thanks + +Many thanks to Silicon Graphics and Mark J. Kilgard for making their +software free. + +5. No thanks + + THIS SECTION CONTAINS MY PERSONAL OPINIONS AND DOESN'T REPRESENT + AN OFFICIAL POSITION OF THE XFree86 PROJECT. + +The first incarnation of this version of libGLw used eight header files from +LessTif, four for each Motif version. LessTif is covered by the GNU Library +General Public License (LGPL) whose terms are not compatible with the +XFree86 licensing policy. Since the copyright holder of LessTif is the Free +Software Foundation (FSF), I asked Richard Stallman, president of FSF and so +called "leader of the Free Software movement", permission to redistribute a +copy of those eight headers under XFree86 terms, still maintaining the FSF +copyright. + +Observe that I was not asking him to change the license of LessTif as a +whole, but only to allow me to distribute copies of some header files +containing function prototypes, variable declarations and data type +definitions. Even so, Stallman said no because the files contained "more +than 6000 lines of code". Which code? The LessTif headers are mostly copies +of the Motif ones and don't contain any original GNU "code"! I can't still +imagine a reason for Stallman's negative answer except for paranoia. He +seems to ignore what Motif is and that LessTif's API is simply a copy of +Motif's one. + +After spending some time, I made my own headers, that became much smaller +than the previous ones because I included only a subset of the Motif API and +merged everything into four files: 417 lines instead 6000. Humm, perhaps I +should be grateful to Sallman too :-). + +6. Trademarks + + * OpenGL is a trademark of Silicon Graphics, Inc. + * Motif is a trademark of the Open Group. + + ------------------------------------------------------------------------ + + + +$XFree86: xc/lib/GLw/README.txt,v 1.2 2000/11/06 21:57:10 dawes Exp $ diff --git a/xc/lib/Imakefile b/xc/lib/Imakefile index 9c943f8d9..63d35fb18 100644 --- a/xc/lib/Imakefile +++ b/xc/lib/Imakefile @@ -1,5 +1,5 @@ XCOMM $TOG: Imakefile /main/39 1997/02/26 18:09:44 kaleb $ -XCOMM $XFree86: xc/lib/Imakefile,v 3.40 2000/10/05 18:05:25 keithp Exp $ +XCOMM $XFree86: xc/lib/Imakefile,v 3.41 2000/11/02 20:39:07 dawes Exp $ #define IHaveSubdirs #define PassCDebugFlags @@ -57,6 +57,7 @@ XINERAMADIR=Xinerama #if BuildGLXLibrary GLXLIBDIR = GL +GLWLIBDIR = GLw #endif #if BuildDPSLibrary @@ -109,7 +110,7 @@ LINTSUBDIRS = Xau Xdmcp $(THRSTUBLIBDIR) X11 oldX ICE SM Xext Xt \ $(SSLIBDIR) $(XF86MISCLIBDIR) $(XF86VMLIBDIR) $(XF86DGALIBDIR) \ $(XF86RUSHLIBDIR) Xmu Xpm Xaw $(XAW6LIBDIR) XIE Xi Xtst FS \ PEX5 $(XKBLIBDIR) $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) \ - Xp $(XVLIBDIR) $(GLXLIBDIR) $(DPSLIBDIR) \ + Xp $(XVLIBDIR) $(GLXLIBDIR) $(GLWLIBDIR) $(DPSLIBDIR) \ $(DPSTKLIBDIR) $(PSRESLIBDIR) $(XINERAMADIR) \ $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) $(XFTLIBDIR) #else @@ -119,7 +120,7 @@ XEXTDIR = Xext LINTSUBDIRS = Xau Xdmcp X11 $(XINERAMADIR) $(XEXTDIR) $(XKBLIBDIR) \ $(XKBUILIBDIR) $(LBXUTILDIR) $(XF86EXTLIBS) $(XVLIBDIR) \ - $(GLXLIBDIR) $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) \ + $(GLXLIBDIR) $(GLWLIBDIR) $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) \ $(XFTLIBDIR) #endif diff --git a/xc/lib/X11/XKeysymDB b/xc/lib/X11/XKeysymDB index 96f68d846..f2518d2cd 100644 --- a/xc/lib/X11/XKeysymDB +++ b/xc/lib/X11/XKeysymDB @@ -11,7 +11,7 @@ ! suitability of this software for any purpose. It is provided "as is" ! without express or implied warranty. ! -! $XFree86: xc/lib/X11/XKeysymDB,v 3.5 2000/07/07 00:45:00 dawes Exp $ +! $XFree86: xc/lib/X11/XKeysymDB,v 3.6 2000/11/02 02:51:10 dawes Exp $ hpmute_acute :100000A8 hpmute_grave :100000A9 @@ -225,7 +225,9 @@ XF86Back :1008FF26 XF86Forward :1008FF27 XF86Stop :1008FF28 XF86Refresh :1008FF29 -! 1008FF2A - 1008FF2F are yet to be assigned +XF86PowerOff :1008FF2A +XF86WakeUp :1008FF2B +! 1008FF2C - 1008FF2F are yet to be assigned XF86Favorites :1008FF30 XF86AudioPause :1008FF31 XF86AudioMedia :1008FF32 diff --git a/xc/lib/X11/lcUniConv/iso8859_9e.h b/xc/lib/X11/lcUniConv/iso8859_9e.h index b2ff2eb6e..8f4f2afbc 100644 --- a/xc/lib/X11/lcUniConv/iso8859_9e.h +++ b/xc/lib/X11/lcUniConv/iso8859_9e.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9e.h,v 1.1 2000/10/27 20:26:07 dawes Exp $ */ +/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9e.h,v 1.2 2000/11/02 19:10:45 dawes Exp $ */ /* * ISO-8859-9E @@ -7,29 +7,29 @@ static const unsigned short iso8859_9e_2uni[96] = { /* 0xa0 */ 0x00a0, 0x017d, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x012c, 0x00a7, - 0x016c, 0x00a9, 0x01e6, 0x00ab, 0x014a, 0x00ad, 0x00ae, 0x019f, + 0x016c, 0x00a9, 0x01e6, 0x00ab, 0x014a, 0x00ad, 0x00ae, 0x01d1, /* 0xb0 */ - 0x00b0, 0x017e, 0x00b2, 0x00b3, 0x01d1, 0x00b5, 0x012d, 0x00b7, - 0x016d, 0x00b9, 0x01e7, 0x00bb, 0x014b, 0x01d2, 0x0178, 0x0275, + 0x00b0, 0x017e, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x012d, 0x00b7, + 0x016d, 0x00b9, 0x01e7, 0x00bb, 0x014b, 0x00bd, 0x0178, 0x01d2, /* 0xc0 */ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x018f, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, /* 0xd0 */ 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00dd, - 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, + 0x019f, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, /* 0xe0 */ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x0259, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, /* 0xf0 */ 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00fd, - 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, + 0x0275, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, }; static int iso8859_9e_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) { unsigned char c = *s; - if (c >= 0xd0) + if (c >= 0xa0) *pwc = (wchar_t) iso8859_9e_2uni[c-0xa0]; else *pwc = (wchar_t) c; @@ -39,16 +39,16 @@ iso8859_9e_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) static const unsigned char iso8859_9e_page00[96] = { 0xa0, 0x00, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */ 0x00, 0xa9, 0x00, 0xab, 0x00, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ - 0xb0, 0x00, 0xb2, 0xb3, 0x00, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */ - 0x00, 0xb9, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ + 0xb0, 0x00, 0xb2, 0xb3, 0xb4, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0xb9, 0x00, 0xbb, 0x00, 0xbd, 0x00, 0x00, /* 0xb8-0xbf */ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x00, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xd7, 0x00, 0xdf, /* 0xd8-0xdf */ + 0x00, 0xd9, 0xda, 0xdb, 0xdc, 0xd7, 0x00, 0xdf, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0x00, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xf7, 0x00, 0xff, /* 0xf8-0xff */ + 0x00, 0xf9, 0xfa, 0xfb, 0xfc, 0xf7, 0x00, 0xff, /* 0xf8-0xff */ }; static const unsigned char iso8859_9e_page01[136] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, /* 0x18-0x1f */ @@ -67,10 +67,10 @@ static const unsigned char iso8859_9e_page01[136] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, /* 0x98-0x9f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, /* 0x98-0x9f */ }; static const unsigned char iso8859_9e_page01_d[24] = { - 0x00, 0xb4, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x00, 0xaf, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0xe0-0xe7 */ }; @@ -89,8 +89,10 @@ iso8859_9e_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) c = iso8859_9e_page01[wc-0x0118]; else if (wc >= 0x01d0 && wc < 0x01e8) c = iso8859_9e_page01_d[wc-0x01d0]; + else if (wc == 0x0259) + c = 0xe6; else if (wc == 0x0275) - c = 0xbf; + c = 0xf8; else if (wc == 0x20ac) c = 0xa4; if (c != 0) { diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1251.h b/xc/lib/X11/lcUniConv/microsoft_cp1251.h index 89c1031ee..c817df5f4 100644 --- a/xc/lib/X11/lcUniConv/microsoft_cp1251.h +++ b/xc/lib/X11/lcUniConv/microsoft_cp1251.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1251.h,v 1.1 2000/10/27 20:26:08 dawes Exp $ */ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1251.h,v 1.2 2000/11/02 19:10:46 dawes Exp $ */ /* * MICROSOFT-CP1251 @@ -35,10 +35,10 @@ static int microsoft_cp1251_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) { unsigned char c = *s; - if (c < 0xa0) + if (c < 0x80) *pwc = (wchar_t) c; else - *pwc = (wchar_t) microsoft_cp1251_2uni[c-0xa0]; + *pwc = (wchar_t) microsoft_cp1251_2uni[c-0x80]; return 1; } diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1255.h b/xc/lib/X11/lcUniConv/microsoft_cp1255.h index 4bc403563..7c13553df 100644 --- a/xc/lib/X11/lcUniConv/microsoft_cp1255.h +++ b/xc/lib/X11/lcUniConv/microsoft_cp1255.h @@ -1,75 +1,80 @@ -/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1255.h,v 1.1 2000/10/27 20:26:09 dawes Exp $ */ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1255.h,v 1.2 2000/11/02 19:10:46 dawes Exp $ */ /* - * MICROSOFT-CP1251 + * MICROSOFT-CP1255 */ static const unsigned short microsoft_cp1255_2uni[128] = { /* 0x80 */ - 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, - 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f, + 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, + 0x02c6, 0x2030, 0xfffd, 0x2039, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x90 */ - 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0x98, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f, + 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x02dc, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0xa0 */ - 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, - 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20aa, 0x00a5, 0x00a6, 0x00a7, + 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, /* 0xb0 */ - 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, - 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, + 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, /* 0xc0 */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, - 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + 0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, + 0x05b8, 0x05b9, 0xfffd, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf, /* 0xd0 */ - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, - 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3, + 0x05f4, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0xe0 */ - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, - 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, + 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, /* 0xf0 */ - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, - 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, + 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, + 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd, }; static int microsoft_cp1255_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) { unsigned char c = *s; - if (c < 0xa0) + if (c >= 0x80) { + unsigned short wc = microsoft_cp1255_2uni[c-0x80]; + if (wc != 0xfffd) { + *pwc = (wchar_t) wc; + return 1; + } + } + else { *pwc = (wchar_t) c; - else - *pwc = (wchar_t) microsoft_cp1255_2uni[c-0xa0]; - return 1; + return 1; + } + return RET_ILSEQ; } -static const unsigned char microsoft_cp1255_page00[32] = { - 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ - 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ - 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ - 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +static const unsigned char microsoft_cp1255_page00[88] = { + 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */ }; -static const unsigned char microsoft_cp1255_page04[152] = { - 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ - 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */ - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ - 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ - 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ +static const unsigned char microsoft_cp1255_page05[72] = { + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xb0-0xb7 */ + 0xc8, 0xc9, 0x00, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xb8-0xbf */ + 0xd0, 0xd1, 0xd2, 0xd3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */ + 0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ + 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ }; -static const unsigned char microsoft_cp1255_page20[48] = { +static const unsigned char microsoft_cp1255_page20[56] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ @@ -77,36 +82,37 @@ static const unsigned char microsoft_cp1255_page20[48] = { 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static const unsigned char microsoft_cp1255_page21[24] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ - 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ -}; -static const unsigned char microsoft_cp1255_page22[1] = { - 0xb0, /* 0x16-0x16 */ -}; static int microsoft_cp1255_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) { unsigned char c = 0; - if (wc < 0x0080) { + if (wc < 0x00a0) { *r = wc; return 1; } - else if (wc >= 0x00a0 && wc < 0x00bc) + else if (wc >= 0x00a0 && wc < 0x00f8) c = microsoft_cp1255_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0492) - c = microsoft_cp1255_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x203b) - c = microsoft_cp1255_page20[wc-0x2010]; - else if (wc == 0x20ac) + else if (wc == 0x0192) + c = 0x83; + else if (wc == 0x02c6) c = 0x88; - else if (wc >= 0x2110 && wc < 0x2123) - c = microsoft_cp1255_page21[wc-0x2110]; + else if (wc == 0x02dc) + c = 0x98; + else if (wc >= 0x05b0 && wc < 0x05f5) + c = microsoft_cp1255_page05[wc-0x05b0]; + else if (wc >= 0x2008 && wc < 0x203b) + c = microsoft_cp1255_page20[wc-0x2008]; + else if (wc == 0x20aa) + c = 0xa4; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; if (c != 0) { *r = c; return 1; } return RET_ILSEQ; } + diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1256.h b/xc/lib/X11/lcUniConv/microsoft_cp1256.h index 847f292b8..8a7f08e2d 100644 --- a/xc/lib/X11/lcUniConv/microsoft_cp1256.h +++ b/xc/lib/X11/lcUniConv/microsoft_cp1256.h @@ -1,75 +1,98 @@ -/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1256.h,v 1.1 2000/10/27 20:26:09 dawes Exp $ */ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1256.h,v 1.2 2000/11/02 19:10:46 dawes Exp $ */ /* - * MICROSOFT-CP1251 + * MICROSOFT-CP1256 */ static const unsigned short microsoft_cp1256_2uni[128] = { /* 0x80 */ - 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, - 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f, + 0x20ac, 0x067e, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, + 0x02c6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, /* 0x90 */ - 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0x98, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f, + 0x06af, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x06a9, 0x2122, 0x0691, 0x203a, 0x0153, 0x200c, 0x200d, 0x06ba, /* 0xa0 */ - 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, - 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + 0x00a0, 0x060c, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, + 0x00a8, 0x00a9, 0x06be, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, /* 0xb0 */ - 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, - 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, + 0x00b8, 0x00b9, 0x061b, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x061f, /* 0xc0 */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, - 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + 0x06c1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, + 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0xd0 */ - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, - 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00d7, + 0x0637, 0x0638, 0x0639, 0x063a, 0x0640, 0x0641, 0x0642, 0x0643, /* 0xe0 */ - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, - 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + 0x00e0, 0x0644, 0x00e2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00e7, + 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0649, 0x064a, 0x00ee, 0x00ef, /* 0xf0 */ - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, - 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, + 0x064b, 0x064c, 0x064d, 0x064e, 0x00f4, 0x064f, 0x0650, 0x00f7, + 0x0651, 0x00f9, 0x0652, 0x00fb, 0x00fc, 0x200e, 0x200f, 0x06d2, }; static int microsoft_cp1256_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) { unsigned char c = *s; - if (c < 0xa0) + if (c >= 0x80) { + unsigned short wc = microsoft_cp1256_2uni[c-0x80]; + if (wc != 0xfffd) { + *pwc = (wchar_t) wc; + return 1; + } + } + else { *pwc = (wchar_t) c; - else - *pwc = (wchar_t) microsoft_cp1256_2uni[c-0xa0]; - return 1; + return 1; + } + return RET_ILSEQ; } -static const unsigned char microsoft_cp1256_page00[32] = { - 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ - 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ - 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ - 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +static const unsigned char microsoft_cp1256_page00[96] = { + 0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0xe0, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, 0xe7, /* 0xe0-0xe7 */ + 0xe8, 0xe9, 0xea, 0xeb, 0x00, 0x00, 0xee, 0xef, /* 0xe8-0xef */ + 0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0xf7, /* 0xf0-0xf7 */ + 0x00, 0xf9, 0x00, 0xfb, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; -static const unsigned char microsoft_cp1256_page04[152] = { - 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ - 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */ - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ - 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ - 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */ +static const unsigned char microsoft_cp1256_page06[208] = { + 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */ + 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */ + 0xc8, 0xc9, 0x00, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd8, /* 0x30-0x37 */ + 0xd9, 0xda, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0xdc, 0xdd, 0xde, 0xdf, 0xe1, 0xe3, 0xe4, 0xe5, /* 0x40-0x47 */ + 0xe6, 0xec, 0xed, 0xf0, 0xf1, 0xf2, 0xf3, 0xf5, /* 0x48-0x4f */ + 0xf6, 0xf8, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x00, /* 0x80-0x87 */ + 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0xa8-0xaf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xaa, 0x00, /* 0xb8-0xbf */ + 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ }; -static const unsigned char microsoft_cp1256_page20[48] = { +static const unsigned char microsoft_cp1256_page20[56] = { + 0x00, 0x00, 0x00, 0x00, 0x9d, 0x9e, 0xfd, 0xfe, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ @@ -77,36 +100,37 @@ static const unsigned char microsoft_cp1256_page20[48] = { 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static const unsigned char microsoft_cp1256_page21[24] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ - 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ -}; -static const unsigned char microsoft_cp1256_page22[1] = { - 0xb0, /* 0x16-0x16 */ -}; static int microsoft_cp1256_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) { unsigned char c = 0; - if (wc < 0x0080) { + if (wc < 0x00a0) { *r = wc; return 1; } - else if (wc >= 0x00a0 && wc < 0x00bc) + else if (wc >= 0x00a0 && wc < 0x00ff) c = microsoft_cp1256_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0492) - c = microsoft_cp1256_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x203b) - c = microsoft_cp1256_page20[wc-0x2010]; - else if (wc == 0x20ac) + else if (wc == 0x0152) + c = 0x8c; + else if (wc == 0x0153) + c = 0x9c; + else if (wc == 0x0192) + c = 0x83; + else if (wc == 0x02c6) c = 0x88; - else if (wc >= 0x2110 && wc < 0x2123) - c = microsoft_cp1256_page21[wc-0x2110]; + else if (wc >= 0x0608 && wc < 0x06d3) + c = microsoft_cp1256_page06[wc-0x0608]; + else if (wc >= 0x2008 && wc < 0x203b) + c = microsoft_cp1256_page20[wc-0x2008]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; if (c != 0) { *r = c; return 1; } return RET_ILSEQ; } + diff --git a/xc/lib/Xmu/CvtStdSel.c b/xc/lib/Xmu/CvtStdSel.c index 7b282d527..2b05340f2 100644 --- a/xc/lib/Xmu/CvtStdSel.c +++ b/xc/lib/Xmu/CvtStdSel.c @@ -21,7 +21,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/lib/Xmu/CvtStdSel.c,v 3.13 1999/03/21 07:34:36 dawes Exp $ */ +/* $XFree86: xc/lib/Xmu/CvtStdSel.c,v 3.14 2000/11/06 19:24:02 dawes Exp $ */ /* * This file contains routines to handle common selection targets. @@ -83,6 +83,9 @@ in this Software without prior written authorization from The Open Group. #ifdef ultrix #define USE_UNAME #endif +#ifdef CSRG_BASED +#define USE_UNAME +#endif #endif /*X_OS_FILE*/ #ifdef USE_UNAME #ifdef ultrix @@ -154,7 +157,7 @@ get_os_name(void) #ifdef sun return XtNewString("SunOS"); #else -# if !defined(SYSV) && defined(unix) +# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix)) return XtNewString("BSD"); # else return NULL; diff --git a/xc/lib/Xt/Display.c b/xc/lib/Xt/Display.c index f83817e8b..3647fb492 100644 --- a/xc/lib/Xt/Display.c +++ b/xc/lib/Xt/Display.c @@ -32,7 +32,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* $XFree86: xc/lib/Xt/Display.c,v 3.8 1998/10/03 09:06:51 dawes Exp $ */ +/* $XFree86: xc/lib/Xt/Display.c,v 3.9 2000/11/02 02:51:10 dawes Exp $ */ /* @@ -144,7 +144,14 @@ static void XtDeleteFromAppContext(d, app) app->count--; } app->rebuild_fdlist = TRUE; +#ifndef USE_POLL + if ((ConnectionNumber(d) + 1) == app->fds.nfds) + app->fds.nfds--; + else /* Unnecessary, just to be fool-proof */ + FD_CLR(ConnectionNumber(d), &app->fds.rmask); +#else app->fds.nfds--; +#endif } static XtPerDisplay NewPerDisplay(dpy) diff --git a/xc/nls/locale.alias b/xc/nls/locale.alias index 27cb896d9..f4320901d 100644 --- a/xc/nls/locale.alias +++ b/xc/nls/locale.alias @@ -5,7 +5,7 @@ XCOMM Each alias name is described within one line. XCOMM The first word is the alias name (simplified locale name) XCOMM the second word is full locale name. XCOMM -XCOMM $XFree86: xc/nls/locale.alias,v 1.27 2000/10/27 18:30:49 dawes Exp $ +XCOMM $XFree86: xc/nls/locale.alias,v 1.29 2000/11/06 19:24:02 dawes Exp $ XCOMM #ifdef R63_COMPAT XCOMM These entries are in the old format (no ':') @@ -319,17 +319,19 @@ lo_LA.mulelao1 lo_LA.MULELAO-1 XCOMM most locales in FreeBSD 2.1.[56] do not work, allow use of FreeBSD's XCOMM generic latin-1 locale name. N.B. "lt" is a bad code to use for a XCOMM generic Latin-1 locale anyway because it is the country code for -XCOMM Lithuania, which by default uses Latin-4. +XCOMM Lithuania, which by default uses Latin-7 (ISO-8859-13). lt_LN.ISO_8859-1 lt_LN.ISO8859-1 #endif -lt lt_LT.ISO8859-4 -lt_LT lt_LT.ISO8859-4 +lt lt_LT.ISO8859-13 +lt_LT lt_LT.ISO8859-13 lt_LT.iso88594 lt_LT.ISO8859-4 lt_LT.ISO_8859-4 lt_LT.ISO8859-4 -lt_LT.iso885915 lt_LT.ISO8859-15 -lv lv_LV.ISO8859-4 -lv_LV lv_LV.ISO8859-4 +lt_LT.iso885913 lt_LT.ISO8859-13 +lt_LT.ISO_8859-13 lt_LT.ISO8859-13 +lv lv_LV.ISO8859-13 +lv_LV lv_LV.ISO8859-13 lv_LV.iso88594 lv_LV.ISO8859-4 +lv_LV.iso885913 lv_LV.ISO8859-13 mk mk_MK.ISO8859-5 mk_MK mk_MK.ISO8859-5 mk_MK.iso88595 mk_MK.ISO8859-5 @@ -676,10 +678,7 @@ XCOMM Sun Solaris 2.6 has erroneously specified Estonian as a Latin-1 XCOMM language; however this is clearly incorrect according to ISO8859. #endif XCOMM According to Estonian local standards, ISO8859-4 is not recommended -XCOMM charset. The older EVS8:1993 standard specifies slightly modified -XCOMM (icelandic letters are replaced with scaron and zcaron) ISO8859-1 -XCOMM as a base charset. The newer (but not yet official as of january 2000) -XCOMM EVS8:1999 defines ISO8859-15 to be the base charset. +XCOMM charset. EVS8:2000 specifies ISO8859-15 as base charset. et: et_EE.ISO8859-15 et_EE: et_EE.ISO8859-15 et_EE.iso88594: et_EE.ISO8859-4 @@ -839,7 +838,7 @@ lo_LA.mulelao1: lo_LA.MULELAO-1 XCOMM most locales in FreeBSD 2.1.[56] do not work, allow use of FreeBSD's XCOMM generic latin-1 locale name. N.B. "lt" is a bad code to use for a XCOMM generic Latin-1 locale anyway because it is the country code for -XCOMM Lithuania, which by default uses Latin-4. +XCOMM Lithuania, which by default uses Latin-7 (ISO-8859-13). lt_LN.ISO_8859-1: lt_LN.ISO8859-1 #endif lt: lt_LT.ISO8859-13 @@ -847,6 +846,7 @@ lt_LT: lt_LT.ISO8859-13 lt_LT.iso88594: lt_LT.ISO8859-4 lt_LT.ISO_8859-4: lt_LT.ISO8859-4 lt_LT.iso885913: lt_LT.ISO8859-13 +lt_LT.ISO_8859-13: lt_LT.ISO8859-13 lv: lv_LV.ISO8859-13 lv_LV: lv_LV.ISO8859-13 lv_LV.iso88594: lv_LV.ISO8859-4 @@ -1166,8 +1166,8 @@ Italian_Switzerland.1252: it_CH.iso8859-1 Italian_Italy.1252: it_IT.iso8859-1 Japanese_Japan.932: ja_JP.SJIS Korean_Korea.949: ko_KR.EUC -Lithuanian_Lithuania.1257 lt_LT.iso8859-4 -Latvian_Latvia.1257: lv_LV.iso8859-4 +Lithuanian_Lithuania.1257: lt_LT.iso8859-13 +Latvian_Latvia.1257: lv_LV.iso8859-13 Dutch_Belgium.1252: nl_BE.iso8859-1 Dutch_Netherlands.1252: nl_NL.iso8859-1 Norwegian (Nynorsk)_Norway.1252: no_NO.iso8859-1 diff --git a/xc/nls/locale.dir b/xc/nls/locale.dir index 0b14e0a01..e70fbde53 100644 --- a/xc/nls/locale.dir +++ b/xc/nls/locale.dir @@ -4,7 +4,7 @@ XCOMM This file contains locale database file name XCOMM The first word is the locale database file name and XCOMM the second word is full locale name. XCOMM -XCOMM $XFree86: xc/nls/locale.dir,v 1.15 2000/10/27 18:30:50 dawes Exp $ +XCOMM $XFree86: xc/nls/locale.dir,v 1.16 2000/11/06 19:24:02 dawes Exp $ XCOMM #ifdef R63_COMPAT XCOMM These entries are in the old format (no ':') @@ -136,9 +136,9 @@ iso8859-15/XLC_LOCALE kw_GB.ISO8859-15 ibm-cp1133/XLC_LOCALE lo_LA.IBM-CP1133 mulelao-1/XLC_LOCALE lo_LA.MULELAO-1 iso8859-1/XLC_LOCALE lt_LN.ISO8859-1 -iso8859-1/XLC_LOCALE lt_LT.ISO8859-4 +iso8859-4/XLC_LOCALE lt_LT.ISO8859-4 iso8859-13/XLC_LOCALE lt_LT.ISO8859-13 -iso8859-1/XLC_LOCALE lv_LV.ISO8859-4 +iso8859-4/XLC_LOCALE lv_LV.ISO8859-4 iso8859-13/XLC_LOCALE lv_LV.ISO8859-13 iso8859-13/XLC_LOCALE mi_NZ.ISO8859-13 iso8859-5/XLC_LOCALE mk_MK.ISO8859-5 @@ -470,9 +470,9 @@ iso8859-14/XLC_LOCALE: kw_GB.ISO8859-14 iso8859-15/XLC_LOCALE: kw_GB.ISO8859-15 ibm-cp1133/XLC_LOCALE: lo_LA.IBM-CP1133 mulelao-1/XLC_LOCALE: lo_LA.MULELAO-1 -iso8859-1/XLC_LOCALE: lt_LT.ISO8859-4 +iso8859-4/XLC_LOCALE: lt_LT.ISO8859-4 iso8859-13/XLC_LOCALE: lt_LT.ISO8859-13 -iso8859-1/XLC_LOCALE: lv_LV.ISO8859-4 +iso8859-4/XLC_LOCALE: lv_LV.ISO8859-4 iso8859-13/XLC_LOCALE: lv_LV.ISO8859-13 iso8859-13/XLC_LOCALE: mi_NZ.ISO8859-13 iso8859-5/XLC_LOCALE: mk_MK.ISO8859-5 diff --git a/xc/programs/Xserver/GL/dri/dri.h b/xc/programs/Xserver/GL/dri/dri.h index e50b6119f..427b30389 100644 --- a/xc/programs/Xserver/GL/dri/dri.h +++ b/xc/programs/Xserver/GL/dri/dri.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.12 2000/06/23 19:29:41 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.13 2000/11/02 16:33:25 tsi Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -110,14 +110,14 @@ typedef struct { void* writeContextStore); void (*InitBuffers)(WindowPtr pWin, RegionPtr prgn, - CARD32 index); + CARD32 indx); void (*MoveBuffers)(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc, - CARD32 index); + CARD32 indx); void (*TransitionTo3d)(ScreenPtr pScreen); void (*TransitionTo2d)(ScreenPtr pScreen); - void (*SetDrawableIndex)(WindowPtr pWin, CARD32 index); + void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx); /* wrapped functions */ DRIWrappedFuncsRec wrap; @@ -193,7 +193,7 @@ extern Bool DRIDrawablePrivDelete(pointer pResource, extern Bool DRIGetDrawableInfo(ScreenPtr pScreen, DrawablePtr pDrawable, - unsigned int* index, + unsigned int* indx, unsigned int* stamp, int* X, int* Y, diff --git a/xc/programs/Xserver/Imakefile b/xc/programs/Xserver/Imakefile index 6ab52168c..38c29e738 100644 --- a/xc/programs/Xserver/Imakefile +++ b/xc/programs/Xserver/Imakefile @@ -2,7 +2,7 @@ XCOMM $TOG: Imakefile /main/249 1997/12/11 11:18:14 kaleb $ /* * Server Master Makefile */ -XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.199 2000/10/26 17:57:50 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.201 2000/11/03 18:46:03 eich Exp $ #ifndef InstallXserverSetUID #define InstallXserverSetUID NO @@ -622,6 +622,9 @@ XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c) #if XF86DDC XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc) #endif +#if XF86VBE +XF86VBELIB = $(XF86OSSRC)/vbe/vbe.o +#endif #if XF86RAC XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac) #endif @@ -635,14 +638,14 @@ XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver) XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \ $(XF86XAALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \ - $(XF8_32WIDLIB) $(XF8_32BPPLIB) \ + $(XF8_32WIDLIB) $(XF8_32BPPLIB) $(XF86VBELIB) \ $(XF8_16BPPLIB) $(XF24_32BPPLIB) \ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB) XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o XF86IDRVLIBS = $(XF86IDRIVERLIB) XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci) XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) $(XF86PARSLIB) \ - $(XF86OSLIB) $(XF86INT10LIB) $(XF86DDCLIB) + $(XF86OSLIB) $(XF86INT10LIB) #else XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86PARSLIB) $(XF86OSLIB) #endif @@ -1104,8 +1107,29 @@ ServerTarget(XWin,$(XWINDIRS),$(XWINOBJS), \ #define ServerToInstall XWin #endif #endif /* XWinServer */ - - + +#if XDarwinServer +XCOMM +XCOMM X Darwin server for Mac OS X / Darwin +XCOMM +MFBDIR = mfb /* mfb is needed for font stuff, even though we don't support a 1bpp screen */ +CFB8DIR = cfb +CFB16DIR = cfb16 +CFB32DIR = cfb32 +DDXDIR1 = hw/darwin +DARWINDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DDXDIR1) $(DEPDIRS) +DARWINOBJS = +DARWINLIBS = PreFbLibs hw/darwin/libdarwin.a $(CFB16) $(CFB32) $(CFB8) PostFbLibs ../../lib/font/libXfont.a ../../lib/font/stubs/libfntstubs.a + +XCOMM we need extra link flags for IOKit stuff +EXTRA_LOAD_FLAGS = -framework IOKit +SetUIDServerTarget(Xdarwin,$(DARWINDIRS),$(DARWINOBJS),$(DARWINLIBS),$(SYSLIBS)) + +#define ServerToInstall Xdarwin + +#endif /* XDarwinServer */ + + CFBDIRS = $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) MIEXTDIRS = $(SHADOWDIR) IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR) diff --git a/xc/programs/Xserver/Xprint/attributes.c b/xc/programs/Xserver/Xprint/attributes.c index 3104d6af1..e56ff951c 100644 --- a/xc/programs/Xserver/Xprint/attributes.c +++ b/xc/programs/Xserver/Xprint/attributes.c @@ -44,7 +44,7 @@ copyright holders. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.10 2000/08/10 17:40:30 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.11 2000/11/02 02:51:14 dawes Exp $ */ #include <Xproto.h> #include <string.h> @@ -1206,7 +1206,7 @@ ReplaceAllKeywords( #define toascii( c ) ((unsigned)(c) & 0x007f) #endif -#if defined(CSRG_BASED) || defined(linux) || defined(__CYGWIN__) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL)) || defined(__EMX__) || defined(ISC) || defined(Lynx) || defined(__QNX__) +#if defined(CSRG_BASED) || defined(linux) || defined(__CYGWIN__) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL)) || defined(__EMX__) || defined(ISC) || defined(Lynx) || defined(__QNX__) || defined(__DARWIN__) #define iswspace(c) (isascii(c) && isspace(toascii(c))) #endif diff --git a/xc/programs/Xserver/afb/afbfillsp.c b/xc/programs/Xserver/afb/afbfillsp.c index 419d6bc69..3c21be7e3 100644 --- a/xc/programs/Xserver/afb/afbfillsp.c +++ b/xc/programs/Xserver/afb/afbfillsp.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/afb/afbfillsp.c,v 3.1 1998/03/20 21:04:54 hohndel Exp $ */ +/* $XFree86: xc/programs/Xserver/afb/afbfillsp.c,v 3.2 2000/10/29 14:24:10 tsi Exp $ */ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ /*********************************************************** @@ -57,6 +57,8 @@ SOFTWARE. #include "scrnintstr.h" #include "windowstr.h" #include "afb.h" + +#define STRICT_ANSI_SHIFT #include "maskbits.h" #include "mergerop.h" diff --git a/xc/programs/Xserver/afb/afbtile.c b/xc/programs/Xserver/afb/afbtile.c index dfbdab041..2daecd56c 100644 --- a/xc/programs/Xserver/afb/afbtile.c +++ b/xc/programs/Xserver/afb/afbtile.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/afb/afbtile.c,v 3.0 1996/08/18 01:45:57 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/afb/afbtile.c,v 3.1 2000/10/29 14:24:11 tsi Exp $ */ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ /*********************************************************** @@ -57,6 +57,8 @@ SOFTWARE. #include "scrnintstr.h" #include "afb.h" + +#define STRICT_ANSI_SHIFT #include "maskbits.h" #include "mergerop.h" diff --git a/xc/programs/Xserver/dix/swaprep.c b/xc/programs/Xserver/dix/swaprep.c index 8fe758e8b..247a40ada 100644 --- a/xc/programs/Xserver/dix/swaprep.c +++ b/xc/programs/Xserver/dix/swaprep.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.4 1999/08/31 08:39:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.5 2000/11/03 00:06:35 mvojkovi Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -1312,57 +1312,47 @@ SKeymapNotifyEvent(from, to) } void -SwapConnSetupInfo(pInfo, pInfoTBase) - char *pInfo; - char *pInfoTBase; +SwapConnSetupInfo( + char *pInfo, + char *pInfoT +) { int i, j, k; - ScreenPtr pScreen; - DepthPtr pDepth; - char *pInfoT; xConnSetup *pConnSetup = (xConnSetup *)pInfo; - int numScreens; + xDepth *depth; + xWindowRoot *root; - pInfoT = pInfoTBase; SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT); pInfo += sizeof(xConnSetup); pInfoT += sizeof(xConnSetup); /* Copy the vendor string */ i = (pConnSetup->nbytesVendor + 3) & ~3; - memmove(pInfoT, pInfo, i); + memcpy(pInfoT, pInfo, i); pInfo += i; pInfoT += i; /* The Pixmap formats don't need to be swapped, just copied. */ - i = sizeof(xPixmapFormat) * screenInfo.numPixmapFormats; - memmove(pInfoT, pInfo, i); + i = sizeof(xPixmapFormat) * pConnSetup->numFormats; + memcpy(pInfoT, pInfo, i); pInfo += i; pInfoT += i; -#ifndef PANORAMIX - numScreens = screenInfo.numScreens; -#else - if (noPanoramiXExtension) - numScreens = screenInfo.numScreens; - else - numScreens = pConnSetup->numRoots; -#endif - - for(i = 0; i < numScreens; i++) + for(i = 0; i < pConnSetup->numRoots; i++) { - pScreen = screenInfo.screens[i]; - SwapWinRoot((xWindowRoot *)pInfo, (xWindowRoot *)pInfoT); + root = (xWindowRoot*)pInfo; + SwapWinRoot(root, (xWindowRoot *)pInfoT); pInfo += sizeof(xWindowRoot); pInfoT += sizeof(xWindowRoot); - pDepth = pScreen->allowedDepths; - for(j = 0; j < pScreen->numDepths; j++, pDepth++) + + for(j = 0; j < root->nDepths; j++) { - ((xDepth *)pInfoT)->depth = ((xDepth *)pInfo)->depth; - cpswaps(((xDepth *)pInfo)->nVisuals, ((xDepth *)pInfoT)->nVisuals); + depth = (xDepth*)pInfo; + ((xDepth *)pInfoT)->depth = depth->depth; + cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals); pInfo += sizeof(xDepth); pInfoT += sizeof(xDepth); - for(k = 0; k < pDepth->numVids; k++) + for(k = 0; k < depth->nVisuals; k++) { SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT); pInfo += sizeof(xVisualType); diff --git a/xc/programs/Xserver/fb/fb.h b/xc/programs/Xserver/fb/fb.h index b3abc63bb..63bf38b9a 100644 --- a/xc/programs/Xserver/fb/fb.h +++ b/xc/programs/Xserver/fb/fb.h @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/fb/fb.h,v 1.21 2000/10/23 21:16:45 tsi Exp $ + * $XFree86: xc/programs/Xserver/fb/fb.h,v 1.22 2000/11/02 16:33:26 tsi Exp $ * * Copyright © 1998 Keith Packard * @@ -734,8 +734,8 @@ fbBresSolid8(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -748,8 +748,8 @@ fbBresDash8 (DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -806,8 +806,8 @@ fbBresSolid16(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -820,8 +820,8 @@ fbBresDash16(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -879,8 +879,8 @@ fbBresSolid24(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -893,8 +893,8 @@ fbBresDash24(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -952,8 +952,8 @@ fbBresSolid32(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -966,8 +966,8 @@ fbBresDash32(DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -1310,10 +1310,10 @@ fbFill (DrawablePtr pDrawable, void fbSolidBoxClipped (DrawablePtr pDrawable, RegionPtr pClip, - int x1, - int y1, - int x2, - int y2, + int xa, + int ya, + int xb, + int yb, FbBits and, FbBits xor); @@ -1619,7 +1619,7 @@ fbPushPixels (GCPtr pGC, */ Bool -fbCloseScreen (int index, ScreenPtr pScreen); +fbCloseScreen (int indx, ScreenPtr pScreen); Bool fbRealizeFont(ScreenPtr pScreen, FontPtr pFont); @@ -1674,8 +1674,8 @@ typedef void FbBres (DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -1706,8 +1706,8 @@ fbBres (DrawablePtr pDrawable, int signdx, int signdy, int axis, - int x1, - int y1, + int x, + int y, int e, int e1, int e3, @@ -1716,10 +1716,10 @@ fbBres (DrawablePtr pDrawable, void fbSegment (DrawablePtr pDrawable, GCPtr pGC, - int x1, - int y1, - int x2, - int y2, + int xa, + int ya, + int xb, + int yb, Bool drawLast, int *dashOffset); diff --git a/xc/programs/Xserver/hw/xfree86/CHANGELOG b/xc/programs/Xserver/hw/xfree86/CHANGELOG index c9f27ee5d..ce5a91c17 100644 --- a/xc/programs/Xserver/hw/xfree86/CHANGELOG +++ b/xc/programs/Xserver/hw/xfree86/CHANGELOG @@ -1,18 +1,159 @@ +XFree86 4.0.1e (6 November 2000) + 911. Fix the ksc5601.1987-0 encoding file (#4226, 4228, Pablo Saratxaga). + 910. Update xdm/sessreg to write ":0" type entried in utmp on OpenBSD + (#4225, Matthieu Herrb). + 909. Fix for Xmu under NetBSD, which doesn't #define "unix" anymore (#4225, + Matthieu Herrb). + 908. Preliminary support for OpenBSD/powerpc (#4225, Tsubai Masanari, + Matthieu Herrb). + 907. Support for native WSCONS driver on NetBSD and OpenBSD (#4225, + Tsubai Masanari). + 906. Support for new OpenBSD 2.8 shared libs scheme (#4225, Matthieu Herrb). + 905. Support for the OpenBSD ports tree (#4225, Marc Espie). + 904. Update the list of layouts in the xfree86.lst file (#4224, Ivan Pascal). + 903. Add an XKB map for Serbian (#4224, Milos Rancic). + 903. New revision of the Bulgarian XKB map (#4224, Anton Zinoviev). + 902. Change the Alt key definitions in the "group switcher" descriptions + to not override the base Alt key mappings (#4223, Ivan Pascal). + 901. Change XKB Mode_switch behavior description to not clear "locked + group" (#4223, Ivan Pascal). + 900. Create a root window property "XFree86_DDC_EDID2_RAWDATA" when + suitable data is available (#4222, Andrew C. Aitchison). + 899. Fix some typos/errors in the Latvian and Lithuanian entries in + the locale.alias and locale.dir files (#4221, Nerijus Baliunas). + 898. Fix two more bugs in xkbcomp: handling of 'keycode aliases', and + copying of strings when copying structures (#4208, Ivan Pascal). + 897. Added render extension support to tseng driver (Egbert Eich). + 896. Fixed clock code in neomagic driver (Egbert Eich). + 899. xf86Configure now uses the imake variable xf86ConfigFile (Egbert Eich). + 898. xf86cfg has a new option for a server path (Egbert Eich). + 897. xf86cfg can now handle more than one command line argument (Egbert Eich). + 895. Added a delay to dac code in neomagic driver (Egbert Eich). + 894. Changed shadowfb to use delayed updates in neomagic + driver (Egbert Eich). + 893. Rewrote ddc code in nv driver (Egbert Eich). + 892. Rewrote ddc code in neomagic driver (Egbert Eich). + 891. Fixed problems with enter/leave/closeScreen in nv + driver (Egbert Eich). + 890. Fixed a bug in the fixed modelines in trident driver (Egbert Eich). + 889. Added reinitialization of blitter on enterVT in trident + driver (Egbert Eich). + 888. Fixed a typo which caused wrong register to be set in trident + driver (Egbert Eich). + 887. Added loader symbol handling to tseng driver (Egbert Eich). + 886. Changed tseng driver to use fb instead of cfb (Egbert Eich). + 885. Changed chips driver to use fb instead of cfb (Egbert Eich). + 884. Added render extension support to chips driver (Egbert Eich). + 883. Added render extension support to neomagic driver (Egbert Eich). + 882. Added render extension support to nv driver (Egbert Eich). + 881. Modified helper_mem.c to map everything between video bios and + system bios on PC-like platforms (Egbert Eich). + 880. Modified Linux mapVidMem() to map memory on page boundaries + (Egbert Eich). + 879. Changed BIOS_SIZE (Sys BIOS) from 0x10000 to 0xffff to make + int10 work un DGUX (Takis Psarogiannakopoulos). + 878. Fixed a bug in the argument list of the call to xf86ReadPciBIOS() + from int10/pci.c (Egbert Eich). + 877. Added simple sanity check to catch situation where DDC reads + all 0 and therefore trivially has the correct checksum (Egbert Eich). + 876. Changed i2c code to allow for longer rise/fall times on longer + cables (Egbert Eich). + 875. Removed limit on default visual for 4bpp (Egbert Eich). + 874. Added macros to build nv driver on AXP (Jay Estabrook). + 873. Changed -configure to use primary card as first card (Egbert Eich). + 872. Changed generic vga driver to not unmap memory when switched away. + 871. Fixed problem that caused APM support to be disabled on server + reset (Egbert Eich). + 870. Added support for newer sparse AXP systems (Egbert Eich). + 869. Added support for MGA G100 PCI (Egbert Eich). + 868. Add missing exported libXext Shm functions to loader (Alan Hourihane). + 867. Change Rage 128 DRM driver name to what the r128 kernel module + expects (Kevin Martin). + 866. Fix newly merged "ati" driver probe to allow "r128" and "radeon" + driver names in the XF86Config file for backwards compatibility + (Kevin Martin). + 865. Use vgaHW module to fix font save/restore in i128 driver (Robin Cutshaw). + 864. Fixed (hopefully) a Xinerama problem with BE clients (Mark Vojkovich). + 863. Modifications to GLw to allow it to build without Motif, and + integrate it into the regular build process (#4142, + Carlos A. M. dos Santos, David Dawes). + 862. Import the GLw parts of SGI's ogl-sample (snapshot from 20001102) + under xc/extras/ogl-sample. + 861. Add support for SubSection in the Vendor Section of the config file + (Stuart Anderson) + 860. Fix a typo introduced in a recent update to the 'no' xkb symbols + file (#4218, Pablo Saratxaga, 4219, Harald Nordgĺrd-Hansen). + 859. Parser symbol update (#4217, Paulo Cesar Pereira de Andrade). + 858. Updates to iso8859-9e, microsoft_cp1251 charset handling, and + add real support for microsoft_cp1255 and microsoft_cp1256 (#4214, 4215, + Pablo Saratxaga). + 857. Fix Sparc build problems linking xf86cfb with libloader that were + related to various interdependencies (#4212, David S. Miller). + 856. Allow generic XVideo adaptors (like v4l) to be initialised for + the G400 crtc2 (#4211, Antti Tapaninen). + 855. Update mga driver to check the chipset much earlier to prevent + server hang when using g400 dual head + millennium 2, and some + G200 PCI/warp cleanups (#4211, Antti Tapaninen). + 854. Updates to the Macedonian xkb symbols (#4210, 4220, Damjan Georgievski). + 853. Combine the ATI, Rage128 and Radeon drivers into one with multiple + sub-modules (Marc La France). + 852. Make BIOS accesses in the Rage128 and Radeon drivers independent of + endianess and alignment (Marc La France). + 851. Fix the claiming of XF86Config device sections by drivers, and change + MatchDevices() to only return unclaimed sections (Marc La France). + 850. Fixed build problem in s3virge when XvExtension is not set (Stuart + Anderson) + 849. Add a message at the top of the server/log output for pre-release + versions stating that they are unsupported (David Dawes). + 848. Fix two problems in Imake.rules: have LinkBuildBinary create the + used directory if it doesn't exist, and fix a missing ')' in + the LinkConfFileLong (#A.187, Ivan Zakharyaschev). + 847. Fix a libXt bug that affects multidisplay applications when Xt is + built to use select(2) rather than poll(2) (#A.181, Antony Uspensky). + 846. Add a -utime option to xclock that allows the digital clock to + display the number of seconds since the Epoch (based on A.173, + Kelsey Hudson). + 845. Add symbols mappings for extra keys on the BTC 9000 keyboard (#A.167, + Stefano Cavallari). + 844. Fix twm's icon manager so that it is functional before an EnterNotify + event is received in twm's event loop (#A.156, Jason Zwolak). + 843. Update comments about standards for Estonian support, and add an + entry for the Estonian keyboard layout to the xfree86.lst file + (#A.155). + 842. Fix for G400 crtc2 blank screen color (#4205, Antti Tapaninen). + 841. Modify the mga/HALlib support to allow it to be selected at + run-time. This allows a driver built with HALlib to be used with + older hardware (like the Millennium, Millennium 2) (#4204, + Antii Tapaninen). + 840. Add config/imake support for Darwin (#4200, Torrey T. Lyons). + 839. Add a driver for the citron touch screen (#4199, Peter Kunzmann). + 838. Fix Html man page install problem (Robin Cutshaw). + 837. Fix transparency problem with blits, add DDC2 for i128-II chipset + in i128 driver (Robin Cutshaw). + 836. Allow loader to be build if HasShm == NO (Marcus Brinkmann). + 835. Allow the log file to be set in the config files (Stuart Anderson). + 834. Fix Rage128/Radeon drivers to free correct scratch buffer on LeaveVT + (Alan Hourihane). + 833. Xterm patch #148 (#4213, Thomas Dickey). + 832. Split ATI driver into two modules in preparation for merging in the + r128 and radeon drivers (Marc La France). + 831. Update the XFree86 -configure code to put the default font path + in the Files section of the config file it generates (#4202, + Paulo Cesar Pereira de Andrade). + 830. Add write-combine support for IA-64 (Mark Vojkovich). + XFree86 4.0.1d (27 October 2000) 829. Add code to the xf86config utility to get the list of XKB selections from the appropriate XKB files rather than having them hard-coded. Also allow XkbOptions to be set (#4209, Ivan Pascal). - 828. Fix two more bugs in xkbcomp: handling of 'keycode aliases', and - copying of strings when copying structures (#4208, Ivan Pascal). + 828. - 827. Xterm patch #147 (#4207, Thomas Dickey). 826. Move the initialisation of pScrn->EnableDisableFBAccess into InitOutput(), which fixes an infinite loop problem that can show up on server resets (#4206, Joe Moss). 825. Make xf86cfg use the same config file search path as the X server (#4203, Paulo Cesar Pereira de Andrade). - 824. Update the XFree86 -configure code to put the default font path - in the Files section of the config file it generates (#4202, - Paulo Cesar Pereira de Andrade). + 824. - 823. Fix a bug in the vesa driver when finding the linear address for the card, some compile time warnings, faster code for handling colormap changes, and add DGA support (#4201, Paulo Cesar Pereira de Andrade). @@ -22,7 +163,7 @@ XFree86 4.0.1d (27 October 2000) scheme) (#A.172, Damir Anicic, #4196, 4197, David Bateman). 820. Pablo Saratxaga's i18n updates for XFree86 that are used in Mandrake 7.2. Includes various new and fixed xkb files, locale name additions and - updates, and new support for varios charset encodings (#4195, + updates, and new support for various charset encodings (#4195, Pablo Saratxaga). 819. Improve Xaw 7 compatibility with version 6 in the form widget geometry management code. This should fix some problems seen with ghostview @@ -59,7 +200,7 @@ XFree86 4.0.1d (27 October 2000) and make the twm config file reader 8-bit clean (#4165, 4168, 4180, Tomohiro Kubota). 802. Fix a tseng driver problem related to the usable amount of video memory - (#4164, Randy McCaskill). + (#4164, A.182, Randy McCaskill). 801. Add support for the new Render extension to the nv driver, and turn on fb support by default in the nv driver (#4161, Jarno Paananen). 800. Fix a typo that prevents DPS from being built statically (#4160, @@ -76,7 +217,7 @@ XFree86 4.0.1d (27 October 2000) 794. Add two new XKB group switches (Alt+Shift and Menu key) (#4151, Ivan Pascal). 793. Fix HTML man page links when the man page suffix has more than one - character (#4150, Bruno Haible). + character (#4150, Bruno Haible, A.149, Serguei Ostrovskii). 792. Remove the old UTF-1 locale (it's not filesystems safe, deprecated for years, withdrawn from ISO standards, and nobody uses it) (#4147, 4149, Bruno Haible). @@ -11356,4 +11497,4 @@ XFree86 3.0a (28 April 1994) XFree86 3.0 (26 April 1994) -$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1359 2000/10/27 18:30:57 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1381 2000/11/06 19:24:02 dawes Exp $ diff --git a/xc/programs/Xserver/hw/xfree86/common/Imakefile b/xc/programs/Xserver/hw/xfree86/common/Imakefile index a6c5643d6..9ac94f282 100644 --- a/xc/programs/Xserver/hw/xfree86/common/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/common/Imakefile @@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/34 1996/10/27 11:05:08 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.121 2000/09/19 12:46:12 eich Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.123 2000/11/03 18:46:05 eich Exp $ @@ -53,7 +53,7 @@ XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.121 2000/09/ #endif MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\" -LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XFree86.\" +LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XLogFile.\" #if DoLoadableServer EXT_MODULES_DEFINES = $(GLX_DEFINES) @@ -182,6 +182,8 @@ PROJECTROOT = ProjectRoot XCONFIGDEFINES = -DPROJECTROOT='"$(PROJECTROOT)"' \ -DDRIVERS='"$(DRIVERS)"' \ -DIDRIVERS='"$(IDRIVERS)"' +XF86CONFIGFILE = XConfigFile +XCONFIGUREDEFINES = -DXF86CONFIGFILE='"$(XF86CONFIGFILE)"' DEFINES = $(CONSDEFINES) $(KBDDEFINES) $(EXT_DEFINES) $(OSDEFINES) @@ -192,6 +194,7 @@ SpecialCObjectRule(xf86Init,$(ICONFIGFILES),$(OSNAMEDEF) $(BUILDERMSG) $(BUGMSG) SpecialCObjectRule(xf86Events,$(ICONFIGFILES),$(EXT_DEFINES)) SpecialCObjectRule(xf86Globals,$(ICONFIGFILES),$(EXT_DEFINES) $(MODPATHDEFINES) $(LOGDEFINES)) SpecialCObjectRule(xf86Config,$(ICONFIGFILES),$(XCONFIGDEFINES)) +SpecialCObjectRule(xf86Configure,$(ICONFIGFILES),$(XCONFIGUREDEFINES)) #if NeedXF86Beta SpecialCObjectRule($(BETAOBJ),NullParameter,$(EXP_DEFINES)) diff --git a/xc/programs/Xserver/hw/xfree86/common/compiler.h b/xc/programs/Xserver/hw/xfree86/common/compiler.h index 5d6f24ce2..2d3b1465e 100644 --- a/xc/programs/Xserver/hw/xfree86/common/compiler.h +++ b/xc/programs/Xserver/hw/xfree86/common/compiler.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.71 2000/10/20 12:57:25 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.73 2000/11/06 19:24:05 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -355,6 +355,7 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11) #endif } +/* to flush the I-cache before jumping to code which just got loaded */ #define PAL_imb 134 #define istream_mem_barrier() \ __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") @@ -828,7 +829,7 @@ static __inline__ unsigned long ldw_u(unsigned short * r11) #define write_mem_barrier() /* NOP */ #endif /* __arm32__ */ -#elif (defined(Lynx) || defined(linux)) && defined(__powerpc__) +#elif (defined(Lynx) || defined(linux) || defined(__OpenBSD__)) && defined(__powerpc__) #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) @@ -847,7 +848,7 @@ xf86ReadMmio8(void *base, const unsigned long offset) "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -860,7 +861,7 @@ xf86ReadMmio16Be(void *base, const unsigned long offset) "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -873,7 +874,7 @@ xf86ReadMmio16Le(void *base, const unsigned long offset) "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -886,7 +887,7 @@ xf86ReadMmio32Be(void *base, const unsigned long offset) "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -899,7 +900,7 @@ xf86ReadMmio32Le(void *base, const unsigned long offset) "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -909,7 +910,7 @@ xf86WriteMmioNB8(void *base, const unsigned long offset, { __asm__ __volatile__( "stbx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } @@ -919,7 +920,7 @@ xf86WriteMmioNB16Le(void *base, const unsigned long offset, { __asm__ __volatile__( "sthbrx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } @@ -929,7 +930,7 @@ xf86WriteMmioNB16Be(void *base, const unsigned long offset, { __asm__ __volatile__( "sthx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } @@ -939,7 +940,7 @@ xf86WriteMmioNB32Le(void *base, const unsigned long offset, { __asm__ __volatile__( "stwbrx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } @@ -949,7 +950,7 @@ xf86WriteMmioNB32Be(void *base, const unsigned long offset, { __asm__ __volatile__( "stwx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86.h b/xc/programs/Xserver/hw/xfree86/common/xf86.h index 0a646408e..17f49691d 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.142 2000/09/19 12:46:12 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.143 2000/10/30 23:02:10 tsi Exp $ */ /* * Copyright (c) 1997 by The XFree86 Project, Inc. @@ -235,6 +235,7 @@ const char *xf86GetServerName(void); Bool xf86ServerIsExiting(void); Bool xf86ServerIsResetting(void); Bool xf86ServerIsInitialising(void); +Bool xf86ServerIsOnlyDetecting(void); Bool xf86ServerIsOnlyProbing(void); Bool xf86CaughtSignal(void); Bool xf86GetVidModeAllowNonLocal(void); @@ -245,6 +246,7 @@ Bool xf86GetAllowMouseOpenFail(void); Bool xf86IsPc98(void); pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name); pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name); +pointer xf86LoadOneModule(char *name, pointer optlist); void xf86UnloadSubModule(pointer mod); Bool xf86LoaderCheckSymbol(const char *name); void xf86LoaderReqSymLists(const char **, ...); diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c index 3de78801d..9f1c08caa 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.54 2000/10/11 22:52:52 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.55 2000/11/02 16:46:17 tsi Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. */ @@ -418,6 +418,7 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev) pEnt->devices = xnfrealloc(pEnt->devices, pEnt->numInstances * sizeof(GDevPtr)); pEnt->devices[pEnt->numInstances - 1] = dev; + dev->claimed = TRUE; } /* diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c index 383b00039..49e5b540a 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.233 2000/10/24 18:07:50 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.234 2000/11/06 19:24:06 dawes Exp $ */ /* @@ -992,6 +992,20 @@ configInputKbd(IDevPtr inputp) xf86Info.kbdEvents = xf86XqueEvents; xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n"); #endif +#ifdef WSCONS_SUPPORT + } else if (xf86NameCmp(s, "wskbd") == 0) { + int xf86WSKbdProc(DeviceIntPtr, int); + + xf86Info.kbdProc = xf86WSKbdProc; + xf86Info.kbdEvents = xf86KbdEvents; + s = xf86SetStrOption(inputp->commonOptions, "Device", NULL); + xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n"); + xf86Info.kbdFd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + if (xf86Info.kbdFd == -1) { + xf86ConfigError("cannot open \"%s\"", s); + return FALSE; + } +#endif } else { xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s); return FALSE; diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c b/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c index 18f02534a..b7c196f5e 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.41 2000/10/20 14:58:59 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.43 2000/11/03 18:46:06 eich Exp $ */ /* * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales. * @@ -116,6 +116,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int { int i, j; pciVideoPtr pVideo = NULL; + Bool isPrimary = FALSE; if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1) return NULL; @@ -130,6 +131,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int (DevToConfig[i].pVideo->device == pVideo->device) && (DevToConfig[i].pVideo->func == pVideo->func)) return NULL; + isPrimary = xf86IsPrimaryPci(pVideo); break; case BUS_ISA: /* @@ -138,6 +140,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int */ if (!xf86IsPrimaryIsa()) return NULL; + isPrimary = TRUE; for (i = 0; i < nDevToConfig; i++) if (!DevToConfig[i].pVideo) return NULL; @@ -158,6 +161,13 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int i = nDevToConfig++; DevToConfig = xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); +#if 1 + if (i > 0 && isPrimary) { + memmove(DevToConfig + 1,DevToConfig, + (nDevToConfig - 1) * sizeof(DevToConfigRec)); + i = 0; + } +#endif memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); # define NewDevice DevToConfig[i] @@ -549,12 +559,12 @@ configureFilesSection (void) parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) #ifdef XFree86LOADER - if (xf86ModulePath && xf86ModPathFrom == X_CMDLINE) + if (xf86ModulePath) ptr->file_modulepath = strdup(xf86ModulePath); #endif - if (xf86fpFlag && defaultFontPath) + if (defaultFontPath) ptr->file_fontpath = strdup(defaultFontPath); - if (xf86coFlag && rgbPath) + if (rgbPath) ptr->file_rgbpath = strdup(rgbPath); return ptr; @@ -700,19 +710,20 @@ DoConfigure() #ifdef __EMX__ #define PATH_MAX 2048 #endif + const char* configfile = XF86CONFIGFILE".new"; char homebuf[PATH_MAX]; /* getenv might return R/O memory, as with OS/2 */ strncpy(homebuf,home,PATH_MAX-1); homebuf[PATH_MAX-1] = '\0'; home = homebuf; - + ErrorF("CONFIGFILE %s\n",configfile); if (!(filename = (char *)ALLOCATE_LOCAL(strlen(home) + - strlen("XF86Config.new") + 3))) + strlen(configfile) + 3))) if (home[0] == '/' && home[1] == '\0') home[0] = '\0'; - sprintf(filename, "%s/XF86Config.new", home); + sprintf(filename, "%s/%s", home,configfile); } xf86writeConfigFile(filename, xf86config); diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c index 05b90b876..459fb28c9 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.98 2000/10/17 16:53:16 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.100 2000/11/06 19:24:06 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -1168,9 +1168,10 @@ xf86VTSwitch() xf86EnableInputHandler(ih); } else { - if (xf86OSPMClose) - xf86OSPMClose(); - + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; + for (i = 0; i < xf86NumScreens; i++) { /* * zero all access functions to @@ -1346,3 +1347,38 @@ XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex, #endif /* XTESTEXT1 */ +#ifdef WSCONS_SUPPORT + +/* XXX Currently XKB is mandatory. */ + +void +xf86PostWSKbdEvent(struct wscons_event *event) +{ + int type = event->type; + int value = event->value; + Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE); + KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key; + xEvent kevent; + KeySym *keysym; + int keycode; + + /* + * Now map the scancodes to real X-keycodes ... + */ + keycode = value + MIN_KEYCODE; + keysym = keyc->curKeySyms.map + + keyc->curKeySyms.mapWidth * (keycode - keyc->curKeySyms.minKeyCode); + + /* + * check for an autorepeat-event + */ + if ((down && KeyPressed(keycode)) && + (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode])) + return; + + xf86Info.lastEventTime = kevent.u.keyButtonPointer.time + = event->time.tv_sec * 1000 + event->time.tv_nsec / 1000000; + + ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); +} +#endif /* WSCONS_SUPPORT */ diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c index b49b3028c..789eedbac 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.97 2000/10/27 18:31:01 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.100 2000/11/03 18:46:06 eich Exp $ */ /* * Copyright (c) 1997-1998 by The XFree86 Project, Inc. @@ -768,10 +768,12 @@ xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual) /* Check if the visual is valid for the depth */ if (scrp->depth == 1 && scrp->defaultVisual != StaticGray) bad = TRUE; +#if 0 else if (scrp->depth == 4 && (scrp->defaultVisual == TrueColor || scrp->defaultVisual == DirectColor)) bad = TRUE; +#endif else if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->defaultVisual != TrueColor && scrp->defaultVisual != DirectColor) @@ -1446,17 +1448,12 @@ xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips) int -xf86MatchDevice(const char *drivername, GDevPtr **driversectlist) +xf86MatchDevice(const char *drivername, GDevPtr **sectlist) { - static char * drivernames[MAXDRIVERS]; - static GDevPtr * devices[MAXDRIVERS]; - static int count[MAXDRIVERS]; - GDevPtr gdp; + GDevPtr gdp, *pgdp = NULL; confScreenPtr screensecptr; int i,j; - *driversectlist = NULL; - if (xf86DoProbe) return 1; if (xf86DoConfigure && xf86DoConfigurePass1) return 1; @@ -1465,48 +1462,18 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist) * This is a very important function that matches the device sections * as they show up in the config file with the drivers that the server * loads at run time. - + * * ChipProbe can call - * int xf86MatchDevice(char * drivername, GDevPtr * driversectlist) + * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist) * with its driver name. The function allocates an array of GDevPtr and - * returns this via driversectlist and returns the number of elements in + * returns this via sectlist and returns the number of elements in * this list as return value. 0 means none found, -1 means fatal error. * * It can figure out which of the Device sections to use for which card * (using things like the Card statement, etc). For single headed servers * there will of course be just one such Device section. - * - * If there's no Device section with matching name, then xf86MatchDevice() - * returns the first Device section without a Driver statement. This will - * again work out ok in a single headed environment. - */ - /* - * in order to be able to access the results of these queries again, we - * keep two parallel static arrays, one holding the name of the driver, - * the other holding the coresponding Device section pointers. - * So first, we need to check if the query has already been answered - * and simply return that old answer if this is the case. */ i = 0; - while (drivernames[i] && i < MAXDRIVERS) { - if (xf86NameCmp(drivername,drivernames[i]) == 0) { - /* - * we already had that one - */ - *driversectlist = devices[i]; - return count[i]; - } - i++; - } - - if (i == MAXDRIVERS) - return -1; - - /* - * if we get here, this is a new name - */ - drivernames[i] = xstrdup(drivername); - count[i] = 0; /* * first we need to loop over all the Screens sections to get to all @@ -1520,10 +1487,8 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist) /* * we have a matching driver that wasn't claimed, yet */ - screensecptr->device->claimed = TRUE; - devices[i] = xnfrealloc(devices[i], - (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = screensecptr->device; + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = screensecptr->device; } } @@ -1534,50 +1499,23 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist) if (gdp->driver && !gdp->claimed && !xf86NameCmp(gdp->driver,drivername)) { /* we have a matching driver that wasn't claimed yet */ - gdp->claimed = TRUE; - devices[i] = - xnfrealloc(devices[i], (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = gdp; + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = gdp; } j++; } -#if 0 - /* - * XXX The parser won't let devices with no Driver name through, so - * this can be removed. - */ - if (count[i] == 0) { - /* - * we haven't found a single one, let's try to find one that - * wasn't claimed and has no driver given - */ - for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) { - screensecptr = xf86ConfigLayout.screens[j].screen; - if ((screensecptr->device->driver == NULL) - && (! screensecptr->device->claimed)) { - /* - * we have a device section without driver that wasn't claimed - */ - screensecptr->device->claimed = TRUE; - devices[i] = xnfrealloc(devices[i], - (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = screensecptr->device; - } - } - } -#endif /* * make the array NULL terminated and return its address */ - if( count[i] ) - devices[i][count[i]] = NULL; - else - devices[i] = NULL; - - *driversectlist = devices[i]; + if (i) + pgdp[i] = NULL; - return count[i]; + if (sectlist) + *sectlist = pgdp; + else + xfree(pgdp); + return i; } struct Inst { @@ -2246,6 +2184,13 @@ xf86ServerIsInitialising() Bool +xf86ServerIsOnlyDetecting(void) +{ + return xf86DoProbe || xf86DoConfigure; +} + + +Bool xf86ServerIsOnlyProbing(void) { return xf86ProbeOnly; @@ -2337,6 +2282,47 @@ xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name) #endif } +/* + * xf86LoadOneModule loads a single module. + */ +pointer +xf86LoadOneModule(char *name, pointer opt) +{ +#ifdef XFree86LOADER + int errmaj, errmin; +#endif + char *Name; + pointer mod; + + if (!name) + return NULL; + +#ifndef NORMALISE_MODULE_NAME + Name = xstrdup(name); +#else + /* Normalise the module name */ + Name = xf86NormalizeName(name); +#endif + + /* Skip empty names */ + if (Name == NULL) + return NULL; + if (*Name == '\0') { + xfree(Name); + return NULL; + } + +#ifdef XFree86LOADER + mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin); + if (!mod) + LoaderErrorMsg(NULL, Name, errmaj, errmin); +#else + mod = (pointer)1; +#endif + xfree(Name); + return mod; +} + void xf86UnloadSubModule(pointer mod) { diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c index b4f982d47..19b9c198c 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.167 2000/10/27 18:31:02 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.170 2000/11/03 18:46:07 eich Exp $ */ /* * Copyright 1991-1999 by The XFree86 Project, Inc. @@ -733,9 +733,16 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) */ xf86OpenConsole(); + /* + should we reopen it here? We need to deal with an already opened + device. We could leave this to the OS layer. For now we simply + close it here + */ + if (xf86OSPMClose) + xf86OSPMClose(); if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) xf86MsgVerb(3,X_INFO,"APM registered successfully\n"); - + /* Make sure full I/O access is enabled */ xf86EnableIO(); } @@ -1049,7 +1056,8 @@ ddxGiveUp() xf86CloseConsole(); if (xf86OSPMClose) xf86OSPMClose(); - + xf86OSPMClose = NULL; + xf86CloseLog(); /* If an unexpected signal was caught, dump a core for debugging */ @@ -1537,19 +1545,28 @@ ddxUseMsg() #ifndef OSVENDOR #define OSVENDOR "" #endif +#ifndef PRE_RELEASE +#define PRE_RELEASE (XF86_VERSION_BETA || XF86_VERSION_ALPHA) +#endif static void xf86PrintBanner() { +#if PRE_RELEASE + ErrorF("\n" + "This is a pre-release version of XFree86, and is not supported in any\n" + "way. Bugs may be reported to XFree86@XFree86.Org and patches submitted\n" + "to fixes@XFree86.Org. Before reporting bugs in pre-release versions,\n" + "please check the latest version in the XFree86 CVS repository\n" + "(http://www.XFree86.Org/cvs)\n"); +#endif ErrorF("\nXFree86 Version%s/ X Window System\n", XF86_VERSION); ErrorF("(protocol Version %d, revision %d, vendor release %d)\n", X_PROTOCOL, X_PROTOCOL_REVISION, VENDOR_RELEASE ); ErrorF("Release Date: %s\n", XF86_DATE); - ErrorF("\tIf the server is older than 6-12 months, or if your card is " - "newer\n" - "\tthan the above date, look for a newer version before " - "reporting\n" - "\tproblems. (see http://www.XFree86.Org/FAQ)\n"); + ErrorF("\tIf the server is older than 6-12 months, or if your card is\n" + "\tnewer than the above date, look for a newer version before\n" + "\treporting problems. (See http://www.XFree86.Org/FAQ)\n"); ErrorF("Operating System:%s%s\n", OSNAME, OSVENDOR); #if defined(BUILDERSTRING) ErrorF("%s \n",BUILDERSTRING); @@ -1638,39 +1655,6 @@ xf86LoadModules(char **list, pointer *optlist) return !failed; } -/* - * xf86LoadOneModule loads a single module. - */ -pointer -xf86LoadOneModule(char *name, pointer opt) -{ - int errmaj, errmin; - char *Name; - pointer mod; - - if (!name) - return NULL; - -#ifndef NORMALISE_MODULE_NAME - Name = xstrdup(name); -#else - /* Normalise the module name */ - Name = xf86NormalizeName(name); -#endif - - /* Skip empty names */ - if (Name == NULL || *Name == '\0') - return NULL; - - if (!(mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin))){ - LoaderErrorMsg(NULL, Name, errmaj, errmin); - xfree(Name); - return FALSE; - } - xfree(Name); - return mod; -} - #endif /* Pixmap format stuff */ diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c index d8642b65b..4b2e731a4 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.40 2000/08/10 17:40:34 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.41 2000/11/06 19:24:06 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -411,3 +411,36 @@ GetTimeInMillis() } #endif /* !AMOEBA && !(sun || SVR4) && !MINIX */ +#ifdef WSCONS_SUPPORT + +#define NUMEVENTS 64 + +static void +wsconssig(fd, closure) + int fd; + void *closure; +{ + static struct wscons_event events[NUMEVENTS]; + int n, i; + + n = read(fd, events, sizeof events); + if (n <= 0) + return; + n /= sizeof(struct wscons_event); + for (i = 0; i < n; i++) + xf86PostWSKbdEvent(&events[i]); +} + +int +xf86WSKbdProc(pKeyboard, what) + DeviceIntPtr pKeyboard; /* Keyboard to manipulate */ + int what; /* What to do to it */ +{ + switch (what) { + case DEVICE_INIT: + xf86FlushInput(xf86Info.kbdFd); + xf86InstallSIGIOHandler(xf86Info.kbdFd, wsconssig, pKeyboard); + } + return xf86KbdProc(pKeyboard, what); +} +#endif /* WSCONS_SUPPORT */ diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PM.c b/xc/programs/Xserver/hw/xfree86/common/xf86PM.c index f260270e9..5ac6dbd7f 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86PM.c +++ b/xc/programs/Xserver/hw/xfree86/common/xf86PM.c @@ -1,6 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PM.c,v 3.2 2000/02/12 23:59:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PM.c,v 3.3 2000/11/03 18:46:07 eich Exp $ */ -#define NOT_YET #include "X.h" #include "xf86.h" @@ -34,9 +33,10 @@ eventName(pmEvent event) static void DoApmEvent(pmEvent event) { - /* we leave that as a global for now. I don't know if this might - * cause problems in the future. It is a global server variable - * therefore it needs to be in a server info structure + /* + * we leave that as a global function for now. I don't know if + * this might cause problems in the future. It is a global server + * variable therefore it needs to be in a server info structure */ static Bool suspended; int i; @@ -49,7 +49,6 @@ DoApmEvent(pmEvent event) case XF86_APM_USER_SUSPEND: /* should we do this ? */ if (!suspended) { -#ifdef NOT_YET for (i = 0; i < xf86NumScreens; i++) { xf86EnableAccess(xf86Screens[i]); if (xf86Screens[i]->EnableDisableFBAccess) @@ -65,7 +64,6 @@ DoApmEvent(pmEvent event) } xf86AccessLeave(); xf86AccessLeaveState(); -#endif suspended = TRUE; } break; @@ -75,7 +73,6 @@ DoApmEvent(pmEvent event) case XF86_APM_STANDBY_FAILED: case XF86_APM_SUSPEND_FAILED: if (suspended) { -#ifdef NOT_YET xf86AccessEnter(); xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { @@ -92,7 +89,6 @@ DoApmEvent(pmEvent event) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); -#endif suspended = FALSE; } break; diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h index 39b6472e7..4fddde903 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.75 2000/10/23 21:16:45 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.76 2000/11/02 22:15:46 robin Exp $ */ /* * PCI Probe * @@ -1011,8 +1011,8 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_VENDOR_NUMNINE, { {PCI_CHIP_I128, "Imagine 128",0}, {PCI_CHIP_I128_2, "Imagine 128 II",0}, - {PCI_CHIP_I128_T2R, "Imagine 128 T2R",0}, - {PCI_CHIP_I128_T2R4, "Imagine 128 T2R4",0}, + {PCI_CHIP_I128_T2R, "Imagine 128 Rev 3D T2R",0}, + {PCI_CHIP_I128_T2R4, "Imagine 128 Rev IV T2R4",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_UMC, { diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h index 00cece3a9..03ee01a07 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.67 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.68 2000/10/30 23:02:11 tsi Exp $ */ /* * Copyright (c) 1997 by The XFree86 Project, Inc. @@ -165,7 +165,6 @@ void OsVendorVErrorF(const char *f, va_list args); /* xf86Init.c */ Bool xf86LoadModules(char **list, pointer *optlist); -pointer xf86LoadOneModule(char *name, pointer optlist); /* xf86Io.c */ diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h index 4e8ca8fbf..20e254988 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.20 2000/09/19 12:46:13 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.21 2000/11/06 19:24:07 dawes Exp $ */ /* * Copyright (c) 1997,1998 by The XFree86 Project, Inc. @@ -166,6 +166,7 @@ typedef struct { #define CODRV01X 2 #define SYSCONS 8 #define PCVT 16 +#define WSCONS 32 #endif /* Values of xf86Info.mouseFlags */ diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h index bae9ca4b0..bc0996c56 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.18 2000/08/04 16:13:26 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.19 2000/11/02 16:33:27 tsi Exp $ */ #ifndef _XVDIX_H_ #define _XVDIX_H_ @@ -68,7 +68,7 @@ typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn, 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)(ScrnInfoPtr pScrn, pointer data, Bool exit); +typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit); typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data); typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, @@ -79,7 +79,7 @@ typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion, typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, 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, + int image, unsigned char* buf, short width, short height, Bool Sync, RegionPtr clipBoxes, pointer data ); typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, short drw_x, short drw_y, RegionPtr clipBoxes, pointer data ); diff --git a/xc/programs/Xserver/hw/xfree86/common/xisb.c b/xc/programs/Xserver/hw/xfree86/common/xisb.c index 7c5711aa6..4132c7abf 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xisb.c +++ b/xc/programs/Xserver/hw/xfree86/common/xisb.c @@ -24,7 +24,7 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xisb.c,v 1.4 1999/03/06 13:12:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xisb.c,v 1.5 2000/11/06 19:24:07 dawes Exp $ */ /* X Input Serial Buffer routines for use in any XInput driver that accesses @@ -127,7 +127,8 @@ XisbRead (XISBuffer *b) } } if (b->trace) - ErrorF ("read 0x%02x (%c)\n", b->buf[b->current], b->buf[b->current]); + ErrorF ("read 0x%02x (%c)\n", b->buf[b->current], + isprint(b->buf[b->current])?b->buf[b->current]:'.'); return (b->buf[b->current++]); } diff --git a/xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c b/xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c index 4ad9a88da..e7026fec6 100644 --- a/xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c +++ b/xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c @@ -3,7 +3,7 @@ * * Copyright 1999 by Andrew C Aitchison <A.C.Aitchison@dpmms.cam.ac.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c,v 1.3 2000/03/05 23:47:50 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c,v 1.4 2000/11/06 19:24:07 dawes Exp $ */ #include "misc.h" #include "xf86.h" @@ -28,7 +28,7 @@ xf86SetDDCproperties(ScrnInfoPtr pScrnInfo, xf86MonPtr DDC) int i, ret; #ifdef DEBUG - ErrorF("xf86SetXDDCprop(%p, %p)\n", pScrnInfo, DDC); + ErrorF("xf86SetDDCproperties(%p, %p)\n", pScrnInfo, DDC); #endif if (pScrnInfo==NULL || pScrnInfo->monitor==NULL || DDC==NULL) { @@ -60,19 +60,13 @@ xf86SetDDCproperties(ScrnInfoPtr pScrnInfo, xf86MonPtr DDC) ErrorF("xf86RegisterRootWindowProperty %p(%d,%d,%d,%d,%d,%p)\n", xf86RegisterRootWindowProperty, pScrnInfo->scrnIndex, - EDID1Atom, XA_STRING, 8, + EDID1Atom, XA_INTEGER, 8, 128, (unsigned char *)EDID1rawdata ); #endif ret = xf86RegisterRootWindowProperty(pScrnInfo->scrnIndex, EDID1Atom, XA_INTEGER, 8, -#if 1 128, (unsigned char *)EDID1rawdata -#else -#define EDID1_DUMMY_STRING "Dummy EDID1 property - please insert correct values" - strlen(EDID1_DUMMY_STRING), - EDID1_DUMMY_STRING -#endif ); #ifdef DEBUG ErrorF("xf86RegisterRootWindowProperty returns %d\n", ret ); @@ -80,15 +74,35 @@ xf86SetDDCproperties(ScrnInfoPtr pScrnInfo, xf86MonPtr DDC) } else if (DDC->ver.version == 2) { if ( (EDID2rawdata = xalloc(256*sizeof(CARD8)))==NULL ) { - xfree(EDID1rawdata); + xfree(EDID2rawdata); return FALSE; } + for (i=0; i<256; i++) { + EDID2rawdata[i] = DDC->rawData[i]; + } EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME), TRUE); - xf86DrvMsg(pScrnInfo->scrnIndex, X_PROBED, - "ignoring property %s for now - please fix\n", - EDID2_ATOM_NAME); +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty %p(%d,%d,%d,%d,%d,%p)\n", + xf86RegisterRootWindowProperty, + pScrnInfo->scrnIndex, + EDID2Atom, XA_INTEGER, 8, + 256, (unsigned char *)EDID2rawdata ); +#endif + ret = xf86RegisterRootWindowProperty(pScrnInfo->scrnIndex, + EDID2Atom, XA_INTEGER, 8, +#if 1 + 256, (unsigned char *)EDID1rawdata +#else +#define EDID2_DUMMY_STRING "Dummy EDID2 property - please insert correct values" + strlen(EDID2_DUMMY_STRING), + EDID2_DUMMY_STRING +#endif + ); +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty returns %d\n", ret ); +#endif } else { xf86DrvMsg(pScrnInfo->scrnIndex, X_PROBED, "unexpected EDID version %d revision %d\n", diff --git a/xc/programs/Xserver/hw/xfree86/ddc/edid.c b/xc/programs/Xserver/hw/xfree86/ddc/edid.c index 6b2a909e1..7a878abb5 100644 --- a/xc/programs/Xserver/hw/xfree86/ddc/edid.c +++ b/xc/programs/Xserver/hw/xfree86/ddc/edid.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.c,v 1.2 1999/01/14 13:04:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.c,v 1.3 2000/11/03 18:46:08 eich Exp $ */ /* edid.c: retrieve EDID record from raw DDC1 data stream: data * is contained in an array of unsigned int each unsigned int @@ -52,11 +52,21 @@ int checksum(unsigned char *block, int len) { int i, result = 0; - for (i=0;i<len;i++) + int not_null = 0; + + for (i=0;i<len;i++) { + not_null |= block[i]; result += block[i]; + } + #ifdef DEBUG if (result & 0xFF) ErrorF("DDC checksum not correct\n"); + if (!not_null) ErrorF("DDC read all Null\n"); #endif + + /* catch the trivial case where all bytes are 0 */ + if (!not_null) return 1; + return (result&0xFF); } diff --git a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c index c62264f19..187a938e1 100644 --- a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c +++ b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.17 2000/06/07 22:03:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.18 2000/11/03 18:46:08 eich Exp $ */ /* xf86DDC.c * @@ -315,6 +315,10 @@ DDCRead_DDC2(int scrnIndex, I2CBusPtr pBus, int start, int len) dev->SlaveAddr = 0xA0; dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ dev->StartTimeout = 550; + dev->BitTimeout = 40; + dev->ByteTimeout = 40; + dev->AcknTimeout = 40; + dev->pI2CBus = pBus; if (! xf86I2CDevInit(dev)) { xf86DrvMsg(X_PROBED,scrnIndex,"No DDC2 device\n"); diff --git a/xc/programs/Xserver/hw/xfree86/doc/Imakefile b/xc/programs/Xserver/hw/xfree86/doc/Imakefile index a3eca0397..272ebc4ce 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/doc/Imakefile @@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/33 1996/10/28 05:12:24 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.68 2000/06/17 17:44:20 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.69 2000/11/06 22:07:05 dawes Exp $ #include <Server.tmpl> #include <lnxdoc.rules> @@ -54,7 +54,7 @@ HWREADME = \ ReadmeFile(DECtga) \ /*ReadmeFile(epson)*/ \ /*ReadmeFile(fbdev)*/ \ - /*ReadmeFile(I128)*/ \ + ReadmeFile(I128) \ ReadmeFile(i740) \ ReadmeFile(i810) \ /*ReadmeFile(Mach32)*/ \ diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.DRI b/xc/programs/Xserver/hw/xfree86/doc/README.DRI index b43fabf6d..3873a53a1 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/README.DRI +++ b/xc/programs/Xserver/hw/xfree86/doc/README.DRI @@ -477,7 +477,7 @@ bleshooting. 10.1.1 Dependencies The Voodoo3 DRI driver requires a special versions of the 3dfx Glide library. -It can be downloaded from the DRI web site. +It can be downloaded from the DRI website. 10.1.2 Configuration @@ -507,7 +507,7 @@ The kernel module for the Voodoo3 is named tdfx.o and should be installed in /lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the Xserver if needed. -The DRI 3D driver for the Voodoo3 should be in /usr/X11R6/lib/mod- +The DRI 3D driver for the Voodoo3 hould be in /usr/X11R6/lib/mod- ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. 10.1.3 Troubleshooting @@ -541,7 +541,7 @@ ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. o SSystem has problems because of poorly set near and far clipping planes. The office.unc Performer model also suffers from this problem. - o The lowest mipmap level is sometimes mis-colored in trilinear- sampled + o The lowest mipmap level is sometimes miscolored in trilinear- sampled polygons. 10.2 3dfx Voodoo5 Series @@ -550,7 +550,7 @@ ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. The Voodoo5 DRI driver requires a special versions of the 3dfx Glide library, different than that used for Voodoo3 hardware. It can be downloaded from the -DRI web site. +DRI website. 10.2.2 Configuration @@ -585,7 +585,7 @@ The kernel module for the Voodoo5 is named tdfx.o and should be installed in /lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the Xserver if needed. -The DRI 3D driver for the Voodoo5 should be in /usr/X11R6/lib/mod- +The DRI 3D driver for the Voodoo5 hould be in /usr/X11R6/lib/mod- ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. The Voodoo5 supports 3D rendering in 16 and 32 bpp modes. When running in @@ -601,7 +601,7 @@ A software-based accumulation buffer is available in both 16 and 32bpp modes. 3dfx hardware. o Different versions of Glide are needed for Voodoo3 and Voodoo5. See the - DRI web site's resources page to download the right version of Glide. + DRI website's resources page to download the right version of Glide. 10.2.4 Performance @@ -928,7 +928,7 @@ forge.net/resources/resources.html o In the future there may be IHV and Linux vendor support resources for the DRI. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.7 2000/08/28 18:24:15 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.8 2000/09/24 13:51:26 alanh Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.7 2000/08/28 18:29:06 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.8 2000/11/06 22:07:05 dawes Exp $ diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp b/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp index 725866f79..b577262a7 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp +++ b/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp @@ -374,7 +374,7 @@ This will ensure that you use the new X libraries when you run X programs. To update your X locale information do the following: cd ~/DRI-CVS/build/xc/nls - xmkmf -a + ../config/util/xmkmf -a make make install @@ -486,7 +486,7 @@ At this point your X server should be up and running with hardware-acceler- ated direct rendering. Please read the DRI User Guide for information about trouble shooting and how to use the DRI-enabled X server for 3D applications. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.5 2000/08/28 18:24:15 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.6 2000/09/24 13:51:26 alanh Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp,v 3.2 2000/08/28 18:29:06 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp,v 3.3 2000/11/06 22:07:05 dawes Exp $ diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.I128 b/xc/programs/Xserver/hw/xfree86/doc/README.I128 index ba2627684..dd4d65e4a 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/README.I128 +++ b/xc/programs/Xserver/hw/xfree86/doc/README.I128 @@ -2,7 +2,7 @@ The XFree86 Project Inc. - 24 October 1998 + 3 November 2000 1. Supported hardware @@ -43,17 +43,17 @@ and should not specify a RAMDAC, clockchip or allow the setup program to probe for clocks. The driver will auto-detect the amount of video ram pre- sent. -The following Section "Device" options are supported by the MGA driver: +The following Section "Device" options are supported by the I128 driver: - o Option "dac_8_bit" + o Option "Dac6Bit" - Will enable 8-bit DAC support. + Will enable 6-bit DAC support. - o Option "no_accel" + o Option "NoAccel" Will disable all hardware acceleration. - o Option "sync_on_green" + o Option "SyncOnGreen" Will enable syncing on green for sync-on-green monitors (these are typi- cally fixed frequency workstation monitors). @@ -81,15 +81,23 @@ The following Section "Device" options are supported by the MGA driver: o Modeline "800x512d08" 54.375 800 800 840 848 512 512 514 515 HSkew 1 DoubleScan +Hsync +Vsync + o These lines are required for use with the SGI Multilink Adapter and the + SiliconGraphics Flat Panel display. + + o Modeline "1600x1024g" 108.0 1600 1616 1656 1704 1024 1027 1030 1056 + -Hsync -Vsync + + o Option "OverridePolarity" "1" + 5. Author(s) -Robin Cutshaw, robin@XFree86.Org +Robin Cutshaw, <robin@XFree86.Org> and special help from: - o Galen Brooks, galen@nine.com + o Galen Brooks, <galen@nine.com> - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.3 1999/08/28 10:43:32 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.5 2000/11/06 22:03:28 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.I128,v 1.6 2000/03/01 01:48:05 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.I128,v 1.7 2000/11/06 22:07:05 dawes Exp $ diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.chips b/xc/programs/Xserver/hw/xfree86/doc/README.chips index 6a752a173..6a47eb359 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/README.chips +++ b/xc/programs/Xserver/hw/xfree86/doc/README.chips @@ -369,6 +369,19 @@ Screen, Monitor, Device. improved. Because the rendering is all done into a virtual frame- buffer acceleration can not be used. + Option "NoTMED" + The new TMED DSTN dithering scheme available on recent HiQV + chipsets gives improved performance. However, some machines + appear to have this feature incorrectly setup. If you have snow + on your DSTN LCD, try using this option. This option is only rel- + evant for chipsets more recent than the ct65555 and only when + used with a DSTN LCD. + + Option "UseFB" + Force the new framebuffer (fb) code to be used in place of its + older counterpart (cfb). The sense of this option will probably + be reversed when fb becomes the default. + Option "Overlay" The HiQV chipsets contain a multimedia engine that allow a 16bpp window to be overlayed on the screen. This driver uses this capa- @@ -881,7 +894,7 @@ Contributors (In no particular order) We also thank the many people on the net who have contributed by reporting bugs and extensively testing this server. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.31 2000/06/14 01:43:49 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.32 2000/10/27 18:31:02 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.32 2000/06/17 17:44:21 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.33 2000/11/06 22:07:05 dawes Exp $ diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml index 3381a243b..2383f0dd3 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml +++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml @@ -1,9 +1,15 @@ -<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN"> +<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN"[ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> <article> <title>Information for Number Nine I128 Users <author>The XFree86 Project Inc. -<date>24 October 1998 +<date>3 November 2000 +<ident> +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.5 2000/11/06 22:03:28 dawes Exp $ +</ident> + <toc> <sect>Supported hardware @@ -45,15 +51,15 @@ used. One need not and should not specify a RAMDAC, clockchip or allow the setup program to probe for clocks. The driver will auto-detect the amount of video ram present. -The following Section "Device" options are supported by the MGA driver: +The following Section "Device" options are supported by the I128 driver: <itemize> -<item>Option "dac_8_bit" +<item>Option "Dac6Bit" <p> -Will enable 8-bit DAC support. -<item>Option "no_accel" +Will enable 6-bit DAC support. +<item>Option "NoAccel" <p> Will disable all hardware acceleration. -<item>Option "sync_on_green" +<item>Option "SyncOnGreen" <p> Will enable syncing on green for sync-on-green monitors (these are typically fixed frequency workstation monitors). @@ -72,19 +78,22 @@ Silicon Graphics Flat Panel display. <item>Modeline "800x512d08" 54.375 800 800 840 848 512 512 514 515 HSkew 1 DoubleScan +Hsync +Vsync </itemize> +<p> +<itemize> +<item>These lines are required for use with the SGI Multilink Adapter and the SiliconGraphics Flat Panel display. +<item>Modeline "1600x1024g" 108.0 1600 1616 1656 1704 1024 1027 1030 1056 -Hsync -Vsync +<item>Option "OverridePolarity" "1" +</itemize> + <sect>Author(s) <p> -Robin Cutshaw, <it>robin@XFree86.Org</it> +Robin Cutshaw, <email>robin@XFree86.Org</email> and special help from: <itemize> -<item>Galen Brooks, <it>galen@nine.com</it> +<item>Galen Brooks, <email>galen@nine.com</email> </itemize> -<verb> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.3 1999/08/28 10:43:32 dawes Exp $ -</verb> - </article> diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile b/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile index 7fab6a1ce..cfcac3fcf 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile @@ -3,7 +3,7 @@ XCOMM $XConsortium: Imakefile /main/16 1996/10/28 05:13:04 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.64 2000/06/17 02:16:49 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.65 2000/11/06 22:03:28 dawes Exp $ #include <Server.tmpl> #include <lnxdoc.rules> @@ -15,7 +15,7 @@ MANSGMLDEPENDS = mdefs.ent mouse.sgml fonts.sgml DRI.sgml DRIcomp.sgml \ isc.sgml LynxOS.sgml NetBSD.sgml OpenBSD.sgml OS2note.sgml \ apm.sgml ati.sgml chips.sgml cyrix.sgml DECtga.sgml \ - i740.sgml i810.sgml \ + I128.sgml i740.sgml i810.sgml \ r128.sgml rendition.sgml s3virge.sgml SiS.sgml #ifdef DEADDOCS @@ -61,8 +61,8 @@ LinuxDocReadmeTarget(DECtga) #ifdef OUTOFDATE LinuxDocReadmeTarget(epson) LinuxDocReadmeTarget(fbdev) -LinuxDocReadmeTarget(I128) #endif +LinuxDocReadmeTarget(I128) LinuxDocReadmeTarget(i740) LinuxDocReadmeTarget(i810) #ifdef OUTOFDATE diff --git a/xc/programs/Xserver/hw/xfree86/drivers/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/Imakefile index 4121f4aea..e2d18d1ef 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/Imakefile,v 1.17 2000/10/20 14:59:00 alanh Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/Imakefile,v 1.19 2000/11/02 21:29:29 tsi Exp $ #define IHaveModules #include <Server.tmpl> @@ -10,12 +10,12 @@ DRIVERS = XF86CardDrivers #ifndef OS2Architecture OBJS = `cat driver.list` #else -OBJS = al2101/?*.o mx/?*.o oak/?*.o realtek/?*.o sis/?*.o trident/?*.o \ - ali/?*.o apm/?*.o apollo/?*.o ark/?*.o ati/?*.o chips/?*.o \ - cirrus/?*.o cl64xx/?*.o compaq/?*.o et3000/?*.o glint/?*.o \ - gvga/?*.o hercules/?*.o hgc1280/?*.o mga/?*.o ncr/?*.o \ - nv/?*.o s3_pio/?*.o s3_newmmio/?*.o sigma/?*.o tseng/?*.o \ - vga/?*.o video7/?*.o wd/?*.o i740/?*.o r128/?*.o i128/?*.o vesa/?*.o +OBJS = apm/?*_drv.o ati/?*_drv.o chips/?*_drv.o cirrus/?*_drv.o \ + cyrix/?*_drv.o glint/?*_drv.o i128/?*_drv.o i740/?*_drv.o \ + i810/?*_drv.o imstt/?*_drv.o mga/?*_drv.o neomagic/?*_drv.o \ + nv/?*_drv.o rendition/?*_drv.o s3virge/?*_drv.o sis/?*_drv.o \ + tdfx/?*_drv.o tga/?*_drv.o trident/?*_drv.o tseng/?*_drv.o \ + vesa/?*_drv.o vga/?*_drv.o #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile index d3a62f8a4..e0c581566 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.23 2000/10/17 16:53:17 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.25 2000/11/02 16:55:26 tsi Exp $ XCOMM XCOMM Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca XCOMM @@ -29,8 +29,28 @@ CCOPTIONS = ATIDriverCCOptions #endif #if DoLoadableServer -MODSRCS = atiload.c atimodule.c -MODOBJS = atiload.o atimodule.o + +MODSRCS1 = atimodule.c +MODSRCS2 = atiload.c atimisc.c +MODSRCS3 = r128_misc.c +MODSRCS4 = radeon_misc.c + +MODOBJS1 = atimodule.o +MODOBJS2 = atiload.o atimisc.o +MODOBJS3 = r128_misc.o +MODOBJS4 = radeon_misc.o + +#endif + +#if BuildXF86DRI + +DRISRCS3 = r128_dri.c + +DRIOBJS3 = r128_dri.o + +DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include +DRIDEFINES = $(GLX_DEFINES) + #endif /* @@ -68,39 +88,59 @@ MODOBJS = atiload.o atimodule.o #if !ATIAvoidCPIO -CPIOSRCS = atibank.c atibios.c ativga.c ativgaio.c atiwonder.c atiwonderio.c -CPIOOBJS = atibank.o atibios.o ativga.o ativgaio.o atiwonder.o atiwonderio.o +CPIOSRCS1 = atibios.c ativgaio.c +CPIOSRCS2 = atibank.c ativga.c atiwonder.c atiwonderio.c + +CPIOOBJS1 = atibios.o ativgaio.o +CPIOOBJS2 = atibank.o ativga.o atiwonder.o atiwonderio.o #else -DEFINES = -DAVOID_CPIO +CPIODEFINES = -DAVOID_CPIO #endif -SRCS = ati.c atiadapter.c atiadjust.c atibus.c atichip.c aticlock.c \ - aticonfig.c aticonsole.c atidac.c atidga.c atidsp.c atiident.c \ - atilock.c atimach64.c atimach64io.c atimode.c atioption.c atipreinit.c \ - atiprint.c atiprobe.c atiscreen.c atiutil.c ativalid.c atividmem.c \ - $(MODSRCS) $(CPIOSRCS) +DEFINES = $(CPIODEFINES) $(DRIDEFINES) -OBJS = ati.o atiadapter.o atiadjust.o atibus.o atichip.o aticlock.o \ - aticonfig.o aticonsole.o atidac.o atidga.o atidsp.o atiident.o \ - atilock.o atimach64.o atimach64io.o atimode.o atioption.o atipreinit.o \ - atiprint.o atiprobe.o atiscreen.o atiutil.o ativalid.o atividmem.o \ - $(MODOBJS) $(CPIOOBJS) +SRCS1 = ati.c atiadapter.c atibus.c atichip.c atiident.c atioption.c \ + atiprobe.c atividmem.c $(MODSRCS1) $(CPIOSRCS1) \ + radeon_probe.c r128_probe.c +SRCS2 = atiadjust.c aticlock.c aticonfig.c aticonsole.c atidac.c atidga.c \ + atidsp.c atilock.c atimach64.c atimach64io.c atimode.c atipreinit.c \ + atiprint.c atiscreen.c atiutil.c ativalid.c $(MODSRCS2) $(CPIOSRCS2) +SRCS3 = r128_accel.c r128_cursor.c r128_dga.c r128_driver.c r128_video.c \ + $(MODSRCS3) $(DRISRCS3) +SRCS4 = radeon_accel.c radeon_cursor.c radeon_dga.c radeon_driver.c \ + radeon_video.c $(MODSRCS4) + +OBJS1 = ati.o atiadapter.o atibus.o atichip.o atiident.o atioption.o \ + atiprobe.o atividmem.o $(MODOBJS1) $(CPIOOBJS1) \ + radeon_probe.o r128_probe.o +OBJS2 = atiadjust.o aticlock.o aticonfig.o aticonsole.o atidac.o atidga.o \ + atidsp.o atilock.o atimach64.o atimach64io.o atimode.o atipreinit.o \ + atiprint.o atiscreen.o atiutil.o ativalid.o $(MODOBJS2) $(CPIOOBJS2) +OBJS3 = r128_accel.o r128_cursor.o r128_dga.o r128_driver.o r128_video.o \ + $(MODOBJS3) $(DRIOBJS3) +OBJS4 = radeon_accel.o radeon_cursor.o radeon_dga.o radeon_driver.o \ + radeon_video.o $(MODOBJS4) + +SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) +OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC) \ -I$(XF86OSSRC)/vbe -I$(XF86SRC)/int10 \ - -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86SRC)/rac \ - -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa \ + -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/rac -I$(XF86SRC)/ramdac \ + -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa -I$(XF86SRC)/xf24_32bpp \ -I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \ - -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \ - -I$(SERVERSRC)/Xext -I$(XINCLUDESRC) -I$(FONTINCSRC) \ - -I$(EXTINCSRC) -I$(SERVERSRC)/render + -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/render -I$(SERVERSRC)/Xext -I$(SERVERSRC)/include \ + $(DRIINCLUDES) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(XINCLUDESRC) #endif #if MakeHasPosixVariableSubstitutions @@ -109,19 +149,29 @@ SubdirLibraryRule($(OBJS)) ModuleObjectRule() -ObjectModuleTarget(ati,$(OBJS)) +ObjectModuleTarget(ati,$(OBJS1)) +ObjectModuleTarget(atimisc,$(OBJS2)) +ObjectModuleTarget(r128,$(OBJS3)) +ObjectModuleTarget(radeon,$(OBJS4)) InstallObjectModule(ati,$(MODULEDIR),drivers) +InstallObjectModule(atimisc,$(MODULEDIR),drivers) +InstallObjectModule(r128,$(MODULEDIR),drivers) +InstallObjectModule(radeon,$(MODULEDIR),drivers) -#if !defined(XF86DriverSDK) +#if 0 CppManTarget(ati,) InstallModuleManPage(ati) #endif +CppManTarget(r128,) +InstallModuleManPage(r128) + DependTarget() InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ati.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(ati.cpp,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ati.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiadapter.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiadapter.h,$(DRIVERSDKDIR)/drivers/ati) @@ -159,9 +209,11 @@ InstallDriverSDKNonExecFile(atimach64.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64io.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64io.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimisc.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimode.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimode.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimodule.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimodule.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimono.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atioption.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atioption.h,$(DRIVERSDKDIR)/drivers/ati) @@ -193,4 +245,57 @@ InstallDriverSDKNonExecFile(atiwonder.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiwonderio.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiwonderio.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128.cpp,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_accel.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_cursor.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dga.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dri.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dri.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dripriv.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_driver.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_misc.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_probe.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_probe.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_reg.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_sarea.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_version.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_video.c,$(DRIVERSDKDIR)/drivers/ati) + +InstallDriverSDKNonExecFile(radeon.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_accel.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_cursor.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_dga.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_driver.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_misc.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_probe.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_probe.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_reg.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_version.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_video.c,$(DRIVERSDKDIR)/drivers/ati) + InstallDriverSDKObjectModule(ati,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(atimisc,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(r128,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(radeon,$(DRIVERSDKMODULEDIR),drivers) + +/* Remove instances of ati2 module */ +#if DoLoadableServer + +#undef ATI2DriverModuleName +#if MakeDllModules +# define ATI2DriverModuleName ati2_drv.so +#else +# define ATI2DriverModuleName ati2_drv.o +#endif + +all:: + RemoveFile($(BUILDMODULEDIR)/drivers/ATI2DriverModuleName) + +install:: + RemoveFile($(DESTDIR)$(MODULEDIR)/drivers/ATI2DriverModuleName) + +install.sdk:: + RemoveFile($(DESTDIR)$(DRIVERSDKMODULEDIR)/drivers/ATI2DriverModuleName) + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c index d0f334fce..980a84adb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.6 2000/08/04 21:07:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.7 2000/11/02 16:55:27 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,9 @@ #include "atiident.h" #include "ativersion.h" +#include "r128_probe.h" +#include "radeon_probe.h" + const char *ATIChipsetNames[] = { "ati", @@ -78,6 +81,8 @@ ATIIdentify xf86PrintChipsets(ATI_NAME, "ATI driver (version " ATI_VERSION_NAME ") for chipsets", ATIPublicChipsetNames); + R128Identify(flags); + RADEONIdentify(flags); } /* diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c index 4886424eb..e9241d664 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.25 2000/08/31 19:03:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.26 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,7 +27,7 @@ * 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 + * 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: * diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c new file mode 100644 index 000000000..080ba715c --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c @@ -0,0 +1,81 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c,v 1.1 2000/10/30 23:02:12 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 XFree86LOADER + +#include "ati.h" +#include "ativersion.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo ATIVersionRec = +{ + ATI_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + ATI_VERSION_MAJOR, ATI_VERSION_MINOR, ATI_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * ATISetup -- + * + * This function is called every time the module is loaded. + */ +static pointer +ATISetup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called atimiscModuleData */ +XF86ModuleData atimiscModuleData = +{ + &ATIVersionRec, + ATISetup, + NULL +}; + +#endif /* XFree86LOADER */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c index 80cc29a5b..34f9723fd 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.9 2000/10/13 13:27:00 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.11 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,11 +24,52 @@ #ifdef XFree86LOADER #include "ati.h" -#include "atistruct.h" +#include "atimodule.h" #include "ativersion.h" /* Module loader interface */ +const char *ATISymbols[] = +{ + "ATIPreInit", + "ATIScreenInit", + "ATISwitchMode", + "ATIAdjustFrame", + "ATIEnterVT", + "ATILeaveVT", + "ATIFreeScreen", + "ATIValidMode", + NULL +}; + +const char *R128Symbols[] = +{ + "R128PreInit", + "R128ScreenInit", + "R128SwitchMode", + "R128AdjustFrame", + "R128EnterVT", + "R128LeaveVT", + "R128FreeScreen", + "R128ValidMode", + "R128Options", + NULL +}; + +const char *RADEONSymbols[] = +{ + "RADEONPreInit", + "RADEONScreenInit", + "RADEONSwitchMode", + "RADEONAdjustFrame", + "RADEONEnterVT", + "RADEONLeaveVT", + "RADEONFreeScreen", + "RADEONValidMode", + "RADEONOptions", + NULL +}; + static XF86ModuleVersionInfo ATIVersionRec = { ATI_DRIVER_NAME, @@ -64,12 +105,14 @@ ATISetup Inited = TRUE; xf86AddDriver(&ATI, Module, 0); - return (pointer)TRUE; + LoaderRefSymLists( + ATISymbols, + R128Symbols, + RADEONSymbols, + NULL); } - if (ErrorMajor) - *ErrorMajor = LDR_ONCEONLY; - return NULL; + return (pointer)1; } /* The following record must be called atiModuleData */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h index f09f04a78..8197d9c69 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.4 2000/08/04 21:07:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.6 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,11 +24,8 @@ #if defined(XFree86LOADER) && !defined(___ATIMODULE_H___) #define ___ATIMODULE_H___ 1 -#include "atipriv.h" -#include "atiproto.h" - -#include "xf86str.h" - -extern Bool ATILoadModules FunctionPrototype((ScrnInfoPtr, ATIPtr)); +extern const char *ATISymbols[]; +extern const char *R128Symbols[]; +extern const char *RADEONSymbols[]; #endif /* ___ATIMODULE_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c index d2b8c70c5..044e4a083 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.12 2000/10/11 22:52:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.13 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,6 +24,9 @@ #include "atioption.h" #include "atiutil.h" +#include "radeon_probe.h" +#include "r128_probe.h" + /* * Recognised XF86Config options. */ @@ -108,5 +111,13 @@ ATIAvailableOptions int BusId /* Ignored */ ) { + OptionInfoPtr pOptions; + + if ((pOptions = R128AvailableOptions(ChipId, BusId))) + return pOptions; + + if ((pOptions = RADEONAvailableOptions(ChipId, BusId))) + return pOptions; + return ATIPublicOptions; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c index c0b6719ea..773e67dba 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.31 2000/10/26 11:47:46 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.35 2000/11/03 03:42:27 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -30,6 +30,7 @@ #include "aticonsole.h" #include "atiident.h" #include "atimach64io.h" +#include "atimodule.h" #include "atipreinit.h" #include "atiprobe.h" #include "atiscreen.h" @@ -38,6 +39,11 @@ #include "atividmem.h" #include "atiwonderio.h" +#include "radeon_probe.h" +#include "radeon_version.h" +#include "r128_probe.h" +#include "r128_version.h" + /* * NOTES: * @@ -52,7 +58,7 @@ * largely ignored. */ -/* Used a temporary buffer */ +/* Used as a temporary buffer */ #define Identifier ((char *)(pATI->MMIOCache)) /* @@ -175,8 +181,7 @@ ATICheckSparseIOBases /* User might wish to override this decision */ xf86Msg(X_WARNING, - ATI_NAME ": Sparse I/O base 0x%04X not probed.\n", - IOBase); + ATI_NAME ": Sparse I/O base 0x%04X not probed.\n", IOBase); return Allowed; } } @@ -974,8 +979,9 @@ ATIProbe ScrnInfoPtr pScreenInfo; CARD32 PciReg; Bool ProbeSuccess = FALSE; + Bool DoRage128 = FALSE, DoRadeon = FALSE; int i, j, k; - int nGDev, nATIGDev = 0, nATIPtr = 0; + int nGDev, nATIGDev = -1, nATIPtr = 0; int Chipset; ATIChipType Chip; @@ -1009,6 +1015,12 @@ ATIProbe (_p)->iEntity = -2; \ } while (0) +#ifndef AVOID_CPIO + + (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); + +#endif /* AVOID_CPIO */ + if (!(flags & PROBE_DETECT)) { /* @@ -1018,64 +1030,63 @@ ATIProbe * "ChipID" not recognised by the driver. Those device sections that * specify a "ChipRev" without a "ChipID" are also weeded out. */ - if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) <= 0) - return FALSE; - - ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - -#ifndef AVOID_CPIO - - (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); - -#endif /* AVOID_CPIO */ - - for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) + nATIGDev = 0; + if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) > 0) { - pGDev = GDevs[i]; - Chipset = ATIIdentProbe(pGDev->chipset); - if (Chipset == -1) - continue; - - if ((pGDev->chipID > (int)((CARD16)(-1))) || - (pGDev->chipRev > (int)((CARD8)(-1)))) - continue; + ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - if (pGDev->chipID >= 0) + for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) { - if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) + pGDev = GDevs[i]; + Chipset = ATIIdentProbe(pGDev->chipset); + if (Chipset == -1) continue; - } - else - { - if (pGDev->chipRev >= 0) + + if ((pGDev->chipID > (int)((CARD16)(-1))) || + (pGDev->chipRev > (int)((CARD8)(-1)))) continue; - } - pATIGDev->pGDev = pGDev; - pATIGDev->Chipset = Chipset; - nATIGDev++; - pATIGDev++; + if (pGDev->chipID >= 0) + { + if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) + continue; + } + else + { + if (pGDev->chipRev >= 0) + continue; + } - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": Candidate \"Device\" section \"%s\".\n", - pGDev->identifier); + pATIGDev->pGDev = pGDev; + pATIGDev->Chipset = Chipset; + nATIGDev++; + pATIGDev++; + + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": Candidate \"Device\" section \"%s\".\n", + pGDev->identifier); #ifndef AVOID_CPIO - fChipsets[Chipset] = TRUE; + fChipsets[Chipset] = TRUE; #endif /* AVOID_CPIO */ - } + } - xfree(GDevs); + xfree(GDevs); - /* If no device sections remain, return now */ - if (!nATIGDev) - { - xfree(ATIGDevs); - return FALSE; + if (!nATIGDev) + { + xfree(ATIGDevs); + ATIGDevs = NULL; + } } + + if (xf86MatchDevice(R128_NAME, NULL) > 0) + DoRage128 = TRUE; + if (xf86MatchDevice(RADEON_NAME, NULL) > 0) + DoRadeon = TRUE; } #ifndef AVOID_CPIO @@ -1105,428 +1116,448 @@ ATIProbe * same I/O ports as 8514/A's or ATI sparse I/O devices without registering * them in PCI configuration space. */ - if (xf86PciVideoInfo) + if (nATIGDev) { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + if (xf86PciVideoInfo) { - if (pVideo->vendor != PCI_VENDOR_ATI) + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - pPCI = pVideo->thisCard; + if (pVideo->vendor != PCI_VENDOR_ATI) + { + pPCI = pVideo->thisCard; - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pVideo->size, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); + ATIScanPCIBases(&PCIPorts, &nPCIPort, + &pPCI->pci_base0, pVideo->size, + (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & + PCI_CMD_IO_ENABLE) ? 0 : Allowed); + } } } - } - /* Check non-video PCI devices for I/O bases */ - if (xf86PciInfo) - { - for (i = 0; (pPCI = xf86PciInfo[i++]); ) + /* Check non-video PCI devices for I/O bases */ + if (xf86PciInfo) { - if ((pPCI->pci_vendor != PCI_VENDOR_ATI) && - (pPCI->pci_base_class != PCI_CLASS_BRIDGE) && - !(pPCI->pci_header_type & - ~GetByte(PCI_HEADER_MULTIFUNCTION, 2))) + for (i = 0; (pPCI = xf86PciInfo[i++]); ) { - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pPCI->basesize, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); + if ((pPCI->pci_vendor != PCI_VENDOR_ATI) && + (pPCI->pci_base_class != PCI_CLASS_BRIDGE) && + !(pPCI->pci_header_type & + ~GetByte(PCI_HEADER_MULTIFUNCTION, 2))) + { + ATIScanPCIBases(&PCIPorts, &nPCIPort, + &pPCI->pci_base0, pPCI->basesize, + (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & + PCI_CMD_IO_ENABLE) ? 0 : Allowed); + } } } - } - - /* Generate ProbeFlags array from list of registered PCI I/O bases */ - (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags)); - for (i = 0; i < nPCIPort; i++) - { - CARD32 Base = PCIPorts[i].Base; - CARD16 Count = (1 << PCIPorts[i].Size) - 1; - CARD8 ProbeFlag = PCIPorts[i].Flag; - /* - * The following reduction of Count is based on the assumption that - * PCI-registered I/O port ranges do not overlap. - */ - for (j = 0; j < nPCIPort; j++) + /* Generate ProbeFlags array from list of registered PCI I/O bases */ + (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags)); + for (i = 0; i < nPCIPort; i++) { - CARD32 Base2 = PCIPorts[j].Base; + CARD32 Base = PCIPorts[i].Base; + CARD16 Count = (1 << PCIPorts[i].Size) - 1; + CARD8 ProbeFlag = PCIPorts[i].Flag; - if (Base < Base2) - while ((Base + Count) >= Base2) - Count >>= 1; - } + /* + * The following reduction of Count is based on the assumption that + * PCI-registered I/O port ranges do not overlap. + */ + for (j = 0; j < nPCIPort; j++) + { + CARD32 Base2 = PCIPorts[j].Base; - Base = LongPort(Base); - Count = LongPort((Count | IO_BYTE_SELECT) + 1); - while (Count--) - ProbeFlags[Base++] &= ProbeFlag; - } + if (Base < Base2) + while ((Base + Count) >= Base2) + Count >>= 1; + } - xfree(PCIPorts); + Base = LongPort(Base); + Count = LongPort((Count | IO_BYTE_SELECT) + 1); + while (Count--) + ProbeFlags[Base++] &= ProbeFlag; + } - /* - * A note on probe strategy. I/O and memory response by certain PCI - * devices has been disabled by the common layer at this point, including - * any devices this driver might be interested in. The following does - * sparse I/O probes, followed by block I/O probes. Block I/O probes are - * dictated by what is found to be of interest in PCI configuration space. - * All this will detect ATI adapters that do not implement this - * disablement, pre-PCI or not. - * - * PCI configuration space is then scanned again for ATI devices that - * failed to be detected the first time around. Each such device is probed - * for again, this time with I/O temporarily enabled through PCI. - */ - if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == DoProbe) - { - pATI = ATIVGAProbe(NULL); - if (pATI->Adapter == ATI_ADAPTER_NONE) + xfree(PCIPorts); + + /* + * A note on probe strategy. I/O and memory response by certain PCI + * devices has been disabled by the common layer at this point, + * including any devices this driver might be interested in. The + * following does sparse I/O probes, followed by block I/O probes. + * Block I/O probes are dictated by what is found to be of interest in + * PCI configuration space. All this will detect ATI adapters that do + * not implement this disablement, pre-PCI or not. + * + * PCI configuration space is then scanned again for ATI devices that + * failed to be detected the first time around. Each such device is + * probed for again, this time with I/O temporarily enabled through + * PCI. + */ + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == + DoProbe) { - xfree(pATI); + pATI = ATIVGAProbe(NULL); + if (pATI->Adapter == ATI_ADAPTER_NONE) + { + xfree(pATI); - xf86MsgVerb(X_INFO, 4, ATI_NAME ": Unshared VGA not detected.\n"); + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared VGA not detected.\n"); + } + else + { + /* + * Claim all MDA/HGA/CGA/EGA/VGA I/O ports. This might need to + * be more selective. + */ + ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, + DetectedVGA); + + pVGA = pATI; + strcpy(Identifier, "Unshared VGA"); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + } } else { - /* - * Claim all MDA/HGA/CGA/EGA/VGA I/O ports. This might need to be - * more selective. - */ - ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, - DetectedVGA); - - pVGA = pATI; - strcpy(Identifier, "Unshared VGA"); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); + xf86MsgVerb(X_INFO, 2, ATI_NAME ": Unshared VGA not probed.\n"); } - } - else - { - xf86MsgVerb(X_INFO, 2, ATI_NAME ": Unshared VGA not probed.\n"); - } - if (ATICheckSparseIOBases(NULL, ProbeFlags, 0x02E8U, 8, - fChipsets[ATI_CHIPSET_IBM8514] || - fChipsets[ATI_CHIPSET_MACH8] || - fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) - { - if ((pATI = ATI8514Probe(NULL))) + if (ATICheckSparseIOBases(NULL, ProbeFlags, 0x02E8U, 8, + fChipsets[ATI_CHIPSET_IBM8514] || + fChipsets[ATI_CHIPSET_MACH8] || + fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) { - strcpy(Identifier, "Unshared 8514/A"); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); + if ((pATI = ATI8514Probe(NULL))) + { + strcpy(Identifier, "Unshared 8514/A"); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(p8514 = pATI); + AddAdapter(p8514 = pATI); - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, - Detected8514A); + if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || + (pATI->Coprocessor != ATI_CHIP_NONE)) + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, + Detected8514A); - ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); + ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); + } + else + { + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared 8514/A not detected.\n"); + } } else { - xf86MsgVerb(X_INFO, 4, - ATI_NAME ": Unshared 8514/A not detected.\n"); - } - } - else - { - xf86MsgVerb(X_INFO, 2, ATI_NAME ": Unshared 8514/A not probed.\n"); - } - - for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) - { - if (ATICheckSparseIOBases(NULL, ProbeFlags, Mach64SparseIOBases[i], 4, - fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) - { xf86MsgVerb(X_INFO, 2, - ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not probed.\n", - Mach64SparseIOBases[i]); - continue; + ATI_NAME ": Unshared 8514/A not probed.\n"); } - pATI = ATIMach64Probe(NULL, Mach64SparseIOBases[i], SPARSE_IO, 0); - if (!pATI) + for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) { - xf86MsgVerb(X_INFO, 4, - ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not" - " detected.\n", Mach64SparseIOBases[i]); - continue; - } + if (ATICheckSparseIOBases(NULL, ProbeFlags, Mach64SparseIOBases[i], + 4, fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) + { + xf86MsgVerb(X_INFO, 2, + ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not" + " probed.\n", + Mach64SparseIOBases[i]); + continue; + } - sprintf(Identifier, "Unshared Mach64 at sparse PIO base 0x%04X", - Mach64SparseIOBases[i]); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); + pATI = ATIMach64Probe(NULL, Mach64SparseIOBases[i], SPARSE_IO, 0); + if (!pATI) + { + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not" + " detected.\n", Mach64SparseIOBases[i]); + continue; + } + + sprintf(Identifier, "Unshared Mach64 at sparse PIO base 0x%04X", + Mach64SparseIOBases[i]); + xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(pMach64[i] = pATI); + AddAdapter(pMach64[i] = pATI); - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, DetectedMach64); + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, + DetectedMach64); - ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, - DetectedMach64); + ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, + DetectedMach64); + } } #endif /* AVOID_CPIO */ if (xf86PciVideoInfo) { + if (nATIGDev) + { #ifdef AVOID_CPIO - /* PCI sparse I/O adapters can still be used through MMIO */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - IsATIBlockIOBase(pVideo->ioBase[1])) - continue; + /* PCI sparse I/O adapters can still be used through MMIO */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; - pPCI = pVideo->thisCard; - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + pPCI = pVideo->thisCard; + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - /* The CPIO base used by the adapter is of little concern here */ - pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); - if (!pATI) - continue; + /* + * The CPIO base used by the adapter is of little concern here. + */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (!pATI) + continue; - sprintf(Identifier, - "Unshared PCI sparse I/O Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected through Block 0 at 0x%08X.\n", - Identifier, pATI->Block0Base); - AddAdapter(pATI); - pATI->PCIInfo = pVideo; - } + sprintf(Identifier, + "Unshared PCI sparse I/O Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected through Block 0 at 0x%08X.\n", + Identifier, pATI->Block0Base); + AddAdapter(pATI); + pATI->PCIInfo = pVideo; + } #endif /* AVOID_CPIO */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - !IsATIBlockIOBase(pVideo->ioBase[1])) - continue; - - /* For now, ignore Rage128's */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if (Chip > ATI_CHIP_Mach64) - continue; + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + !IsATIBlockIOBase(pVideo->ioBase[1])) + continue; - pPCI = pVideo->thisCard; + /* For now, ignore Rage128's */ + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + if (Chip > ATI_CHIP_Mach64) + continue; - /* Possibly fix block I/O indicator in PCI configuration space */ - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - if (!(PciReg & 0x00000004U)) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg | 0x00000004U); + pPCI = pVideo->thisCard; - pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); - if (!pATI) - continue; + /* + * Possibly fix block I/O indicator in PCI configuration space. + */ + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + if (!(PciReg & 0x00000004U)) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg | 0x00000004U); + + pATI = + ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); + if (!pATI) + continue; - sprintf(Identifier, "Unshared PCI/AGP Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(pATI); + sprintf(Identifier, "Unshared PCI/AGP Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + AddAdapter(pATI); #ifndef AVOID_CPIO - /* This is probably not necessary */ - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(pVideo, &pVGA, pATI, p8514, - ProbeFlags, DetectedMach64); + /* This is probably not necessary */ + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIClaimVGA(pVideo, &pVGA, pATI, p8514, + ProbeFlags, DetectedMach64); #endif /* AVOID_CPIO */ - } + } #ifndef AVOID_CPIO - /* - * This is the second pass through PCI configuration space. Much of - * this is verbiage to deal with potential situations that are very - * unlikely to occur in practice. - * - * First, look for non-ATI shareable VGA's. For now, these must the - * primary device. - */ - if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == DoProbe) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + /* + * This is the second pass through PCI configuration space. Much + * of this is verbiage to deal with potential situations that are + * very unlikely to occur in practice. + * + * First, look for non-ATI shareable VGA's. For now, these must + * the primary device. + */ + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == + DoProbe) { - if ((pVideo->vendor == PCI_VENDOR_ATI) || - !xf86IsPrimaryPci(pVideo)) - continue; + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor == PCI_VENDOR_ATI) || + !xf86IsPrimaryPci(pVideo)) + continue; - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - xf86SetPciVideo(pVideo, MEM_IO); + xf86SetPciVideo(pVideo, MEM_IO); - pATI = ATIVGAProbe(NULL); - if (pATI->Adapter == ATI_ADAPTER_NONE) - { - xfree(pATI); - xf86Msg(X_WARNING, + pATI = ATIVGAProbe(NULL); + if (pATI->Adapter == ATI_ADAPTER_NONE) + { + xfree(pATI); + xf86Msg(X_WARNING, ATI_NAME ": PCI/AGP VGA compatible in slot" " %d:%d:%d could not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - } - else - { - sprintf(Identifier, - "Shared non-ATI VGA in PCI/AGP slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", - Identifier); - AddAdapter(pATI); - pATI->SharedVGA = TRUE; - pATI->BusType = ATI_BUS_PCI; - pATI->PCIInfo = pVideo; - } + } + else + { + sprintf(Identifier, + "Shared non-ATI VGA in PCI/AGP slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", + Identifier); + AddAdapter(pATI); + pATI->SharedVGA = TRUE; + pATI->BusType = ATI_BUS_PCI; + pATI->PCIInfo = pVideo; + } - xf86SetPciVideo(NULL, NONE); + xf86SetPciVideo(NULL, NONE); + } } - } - - /* Next, look for PCI Mach32's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType != PCI_CHIP_MACH32)) - continue; - switch (ATICheckSparseIOBases(pVideo, ProbeFlags, - 0x02E8U, 8, TRUE)) + /* Next, look for PCI Mach32's */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - case 0: - xf86Msg(X_WARNING, + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType != PCI_CHIP_MACH32)) + continue; + + switch (ATICheckSparseIOBases(pVideo, ProbeFlags, + 0x02E8U, 8, TRUE)) + { + case 0: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" " be enabled\n because it conflicts with a" " non-video PCI/AGP device.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - case Detected8514A: - if ((p8514->BusType >= ATI_BUS_PCI) && !p8514->PCIInfo) - p8514->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, + case Detected8514A: + if ((p8514->BusType >= ATI_BUS_PCI) && !p8514->PCIInfo) + p8514->PCIInfo = pVideo; + else + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" " another %s %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); - break; + break; - case DetectedMach64: - xf86Msg(X_WARNING, + case DetectedMach64: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with a" - " Mach64 at I/O base 0x02EC.\n", + " be enabled\n because it conflicts with a Mach64" + " at I/O base 0x02EC.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; + default: /* Must be DoProbe */ + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - xf86SetPciVideo(pVideo, MEM_IO); + xf86SetPciVideo(pVideo, MEM_IO); - if (!(pATI = ATI8514Probe(pVideo))) - xf86Msg(X_WARNING, + if (!(pATI = ATI8514Probe(pVideo))) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d could" " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - else - { - sprintf(Identifier, - "Shared 8514/A in PCI slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", - Identifier); - if (pATI->Adapter != ATI_ADAPTER_MACH32) - xf86Msg(X_WARNING, + else + { + sprintf(Identifier, + "Shared 8514/A in PCI slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + if (pATI->Adapter != ATI_ADAPTER_MACH32) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d" " could only be detected as an %s!\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[pATI->Adapter]); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIFindVGA(pVideo, &pVGA, &pATI, p8514, - ProbeFlags); - } + if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || + (pATI->Coprocessor != ATI_CHIP_NONE)) + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); + } - xf86SetPciVideo(NULL, NONE); - break; + xf86SetPciVideo(NULL, NONE); + break; + } } - } - /* Next, look for sparse I/O Mach64's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - IsATIBlockIOBase(pVideo->ioBase[1])) - continue; + /* Next, look for sparse I/O Mach64's */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; - pPCI = pVideo->thisCard; - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - j = PciReg & 0x03U; - if (j == 0x03U) - xf86Msg(X_WARNING, + pPCI = pVideo->thisCard; + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + j = PciReg & 0x03U; + if (j == 0x03U) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d cannot be" " enabled\n because it has neither a block, nor a" " sparse, I/O base.\n", pVideo->bus, pVideo->device, pVideo->func); - else switch(ATICheckSparseIOBases(pVideo, ProbeFlags, - Mach64SparseIOBases[j], 4, TRUE)) - { - case 0: - xf86Msg(X_WARNING, + else switch(ATICheckSparseIOBases(pVideo, ProbeFlags, + Mach64SparseIOBases[j], 4, TRUE)) + { + case 0: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" " be enabled\n because it conflicts with another" " non-video PCI device.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - case Detected8514A: - xf86Msg(X_WARNING, + case Detected8514A: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" " be enabled\n because it conflicts with an %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[p8514->Adapter]); - break; + break; - case DetectedMach64: - pATI = pMach64[j]; - if ((pATI->BusType >= ATI_BUS_PCI) && !pATI->PCIInfo) - pATI->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, + case DetectedMach64: + pATI = pMach64[j]; + if ((pATI->BusType >= ATI_BUS_PCI) && !pATI->PCIInfo) + pATI->PCIInfo = pVideo; + else + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" " another %s Mach64 at sparse I/O base" @@ -1534,105 +1565,108 @@ ATIProbe pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[pATI->BusType], Mach64SparseIOBases[j]); - break; + break; - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; + default: /* Must be DoProbe */ + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); - xf86SetPciVideo(pVideo, MEM_IO); + xf86SetPciVideo(pVideo, MEM_IO); - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], - SPARSE_IO, Chip); - if (!pATI) - xf86Msg(X_WARNING, + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], + SPARSE_IO, Chip); + if (!pATI) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d could" " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - else - { - sprintf(Identifier, - "Shared PCI Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s with sparse PIO base 0x%04X" - " detected.\n", Identifier, - Mach64SparseIOBases[j]); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - pATI->PCIInfo = pVideo; + else + { + sprintf(Identifier, + "Shared PCI Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s with sparse PIO base 0x%04X" + " detected.\n", Identifier, + Mach64SparseIOBases[j]); + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; + pATI->PCIInfo = pVideo; - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(pVideo, &pVGA, &pATI, p8514, - ProbeFlags); - } + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); + } - xf86SetPciVideo(NULL, NONE); - break; + xf86SetPciVideo(NULL, NONE); + break; + } } - } #else /* AVOID_CPIO */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - IsATIBlockIOBase(pVideo->ioBase[1])) - continue; - - /* Check if this one has already been detected */ - for (j = 0; j < nATIPtr; j++) + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - pATI = ATIPtrs[j]; - if (pATI->PCIInfo == pVideo) - goto SkipThisSlot; - } + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; - if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func)) - continue; + /* Check if this one has already been detected */ + for (j = 0; j < nATIPtr; j++) + { + pATI = ATIPtrs[j]; + if (pATI->PCIInfo == pVideo) + goto SkipThisSlot; + } - xf86SetPciVideo(pVideo, MEM_IO); + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + xf86SetPciVideo(pVideo, MEM_IO); - /* The adapter's CPIO base is of little concern here */ - pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); - if (pATI) - { - sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s with Block 0 base 0x%08X detected.\n", - Identifier, pATI->Block0Base); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - pATI->PCIInfo = pVideo; - } - else - { - xf86Msg(X_WARNING, + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + + /* The adapter's CPIO base is of little concern here */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (pATI) + { + sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s with Block 0 base 0x%08X detected.\n", + Identifier, pATI->Block0Base); + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; + pATI->PCIInfo = pVideo; + } + else + { + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" " detected!\n", pVideo->bus, pVideo->device, pVideo->func); - } - - xf86SetPciVideo(NULL, NONE); + } + xf86SetPciVideo(NULL, NONE); - SkipThisSlot:; - } + SkipThisSlot:; + } #endif /* AVOID_CPIO */ + } + /* Lastly, look for block I/O devices */ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { @@ -1641,9 +1675,32 @@ ATIProbe !IsATIBlockIOBase(pVideo->ioBase[1])) continue; - /* For now, ignore Rage128's */ + /* Check for Rage128's, Radeon's and later adapters */ Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); if (Chip > ATI_CHIP_Mach64) + { + switch (Chip) + { + case ATI_CHIP_RAGE128GL: + case ATI_CHIP_RAGE128VR: + case ATI_CHIP_RAGE128PROGL: + case ATI_CHIP_RAGE128PROVR: + case ATI_CHIP_RAGE128MOBILITY3: + case ATI_CHIP_RAGE128MOBILITY4: + DoRage128 = TRUE; + continue; + + case ATI_CHIP_RADEON: + DoRadeon = TRUE; + continue; + + case ATI_CHIP_HDTV: + default: + continue; + } + } + + if (!nATIGDev) continue; /* Check if this one has already been detected */ @@ -1684,9 +1741,8 @@ ATIProbe if (!pATI) { xf86Msg(X_WARNING, - ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not" - " be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); + ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not be" + " detected!\n", pVideo->bus, pVideo->device, pVideo->func); continue; } @@ -1703,7 +1759,7 @@ ATIProbe */ do { - if (!pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA)) + if (!nATIGDev || !pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA)) break; /* If it has not been assigned to a coprocessor, keep track of it */ @@ -1865,13 +1921,6 @@ NoVGAWonder:; #endif /* AVOID_CPIO */ - /* If no appropriate adapters have been detected, return now */ - if (!nATIPtr) - { - xfree(ATIGDevs); - return FALSE; - } - /* * Re-order list of detected devices so that the primary device is before * any other PCI device. @@ -1931,296 +1980,326 @@ NoVGAWonder:; xfree(pATI); } - - xfree(ATIPtrs); - return ProbeSuccess; } - - /* - * Assign detected devices to XF86Config Device sections. This is done by - * comparing certain Device section specifications against the - * corresponding adapter information. Begin with those specifications that - * are independent of the adapter's bus location. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) + else { - pGDev = pATIGDev->pGDev; - - for (j = 0; j < nATIPtr; j++) + /* + * Assign detected devices to XF86Config Device sections. This is done + * by comparing certain Device section specifications against the + * corresponding adapter information. Begin with those specifications + * that are independent of the adapter's bus location. + */ + for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) { - pATI = ATIPtrs[j]; + pGDev = pATIGDev->pGDev; - /* - * First check the Chipset specification. The placement of "break" - * and "continue" statements here is carefully chosen to produce - * the intended behaviour for each Chipset value. - */ - switch (pATIGDev->Chipset) + for (j = 0; j < nATIPtr; j++) { - case ATI_CHIPSET_ATI: - -#ifndef AVOID_CPIO + pATI = ATIPtrs[j]; - if (pATI->Adapter == ATI_ADAPTER_VGA) - continue; - if (pATI->Adapter != ATI_ADAPTER_8514A) - break; - /* Fall through */ + /* + * First check the Chipset specification. The placement of + * "break" and "continue" statements here is carefully chosen + * to produce the intended behaviour for each Chipset value. + */ + switch (pATIGDev->Chipset) + { + case ATI_CHIPSET_ATI: - case ATI_CHIPSET_ATIVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_VGA) - continue; - /* Fall through */ +#ifndef AVOID_CPIO - case ATI_CHIPSET_IBMVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - continue; - break; + if (pATI->Adapter == ATI_ADAPTER_VGA) + continue; + if (pATI->Adapter != ATI_ADAPTER_8514A) + break; + /* Fall through */ - case ATI_CHIPSET_VGAWONDER: - if (!pATI->CPIO_VGAWonder) - continue; - break; + case ATI_CHIPSET_ATIVGA: + if (pATI->VGAAdapter == ATI_ADAPTER_VGA) + continue; + /* Fall through */ - case ATI_CHIPSET_IBM8514: - if (pATI->Adapter == ATI_ADAPTER_8514A) + case ATI_CHIPSET_IBMVGA: + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + continue; break; - /* Fall through */ - case ATI_CHIPSET_MACH8: - if (pATI->Adapter == ATI_ADAPTER_MACH8) + case ATI_CHIPSET_VGAWONDER: + if (!pATI->CPIO_VGAWonder) + continue; break; - /* Fall through */ - case ATI_CHIPSET_MACH32: - if (pATI->Adapter == ATI_ADAPTER_MACH32) - break; - continue; + case ATI_CHIPSET_IBM8514: + if (pATI->Adapter == ATI_ADAPTER_8514A) + break; + /* Fall through */ -#endif /* AVOID_CPIO */ + case ATI_CHIPSET_MACH8: + if (pATI->Adapter == ATI_ADAPTER_MACH8) + break; + /* Fall through */ - case ATI_CHIPSET_MACH64: - if (pATI->Adapter == ATI_ADAPTER_MACH64) - break; - continue; + case ATI_CHIPSET_MACH32: + if (pATI->Adapter == ATI_ADAPTER_MACH32) + break; + continue; - default: - continue; - } +#endif /* AVOID_CPIO */ - /* - * The ChipID and ChipRev specifications are compared next. First, - * require these to be unspecified for anything other than Mach32 - * or Mach64 adapters. ChipRev is also required to be unspecified - * for Mach32's. ChipID is optional for Mach32's, and both - * specifications are optional for Mach64's. Lastly, allow both - * specifications to override their detected value in the case of - * Mach64 adapters whose ChipID is unrecognised. - */ - if (pGDev->chipID >= 0) - { - if (pATI->ChipType != pGDev->chipID) - { - if ((pATI->Adapter != ATI_ADAPTER_MACH64) || - (pATI->Chip != ATI_CHIP_Mach64)) + case ATI_CHIPSET_MACH64: + if (pATI->Adapter == ATI_ADAPTER_MACH64) + break; continue; - Chip = ATIChipID(pGDev->chipID, 0); - if ((Chip <= ATI_CHIP_264GTB) || (Chip == ATI_CHIP_Mach64)) + default: continue; } - if ((pGDev->chipRev >= 0) && (pATI->ChipRev != pGDev->chipRev)) - { - if (pATI->Adapter != ATI_ADAPTER_MACH64) - continue; - if (pATI->Chip != ATI_CHIP_Mach64) + /* + * The ChipID and ChipRev specifications are compared next. + * First, require these to be unspecified for anything other + * than Mach32 or Mach64 adapters. ChipRev is also required to + * be unspecified for Mach32's. ChipID is optional for + * Mach32's, and both specifications are optional for Mach64's. + * Lastly, allow both specifications to override their detected + * value in the case of Mach64 adapters whose ChipID is + * unrecognised. + */ + if (pGDev->chipID >= 0) + { + if (pATI->ChipType != pGDev->chipID) { - if (pATI->ChipRev == pATI->ChipRevision) + if ((pATI->Adapter != ATI_ADAPTER_MACH64) || + (pATI->Chip != ATI_CHIP_Mach64)) continue; - /* - * There are two foundry codes for UMC. Some adapters - * will advertise one in CONFIG_CHIP_ID and the other - * in PCI configuration space. For matching purposes, - * make both codes compare equal. - */ -# define UMC_IGNORE (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA) -# define UMC_NOCARE \ - GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \ - CFG_CHIP_REV) - - if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE) + Chip = ATIChipID(pGDev->chipID, 0); + if ((Chip <= ATI_CHIP_264GTB) || + (Chip == ATI_CHIP_Mach64)) continue; - - if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) && - (pATI->ChipFoundry != ATI_FOUNDRY_UMCA)) + } + if ((pGDev->chipRev >= 0) && + (pATI->ChipRev != pGDev->chipRev)) + { + if (pATI->Adapter != ATI_ADAPTER_MACH64) continue; - k = GetBits(pGDev->chipRev, - GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); - if ((k != ATI_FOUNDRY_UMC) && (k != ATI_FOUNDRY_UMCA)) - continue; + if (pATI->Chip != ATI_CHIP_Mach64) + { + if (pATI->ChipRev == pATI->ChipRevision) + continue; + + /* + * There are two foundry codes for UMC. Some + * adapters will advertise one in CONFIG_CHIP_ID + * and the other in PCI configuration space. For + * matching purposes, make both codes compare + * equal. + */ +# define UMC_IGNORE \ + (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA) +# define UMC_NOCARE \ + GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \ + CFG_CHIP_REV) + + if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE) + continue; + + if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) && + (pATI->ChipFoundry != ATI_FOUNDRY_UMCA)) + continue; + + k = GetBits(pGDev->chipRev, + GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); + if ((k != ATI_FOUNDRY_UMC) && + (k != ATI_FOUNDRY_UMCA)) + continue; + } } } - } - /* - * IOBase is next. This is the first specification that is - * potentially dependent on bus location. It is only allowed for - * Mach64 adapters, and is optional. - */ - if (pGDev->IOBase && (pATI->CPIOBase != pGDev->IOBase)) - continue; + /* + * IOBase is next. This is the first specification that is + * potentially dependent on bus location. It is only allowed + * for Mach64 adapters, and is optional. + */ + if (pGDev->IOBase && (pATI->CPIOBase != pGDev->IOBase)) + continue; - /* - * Compare BusID's. This specification is only allowed for PCI - * Mach32's or Mach64's and is optional. - */ - if (pGDev->busID && pGDev->busID[0]) - { - pVideo = pATI->PCIInfo; + /* + * Compare BusID's. This specification is only allowed for PCI + * Mach32's or Mach64's and is optional. + */ + if (pGDev->busID && pGDev->busID[0]) + { + pVideo = pATI->PCIInfo; #ifndef AVOID_CPIO - if (!pVideo) - continue; + if (!pVideo) + continue; #endif /* AVOID_CPIO */ - if (!xf86ComparePciBusString(pGDev->busID, - pVideo->bus, pVideo->device, pVideo->func)) - continue; - } + if (!xf86ComparePciBusString(pGDev->busID, + pVideo->bus, pVideo->device, pVideo->func)) + continue; + } - /* - * Ensure no two adapters are assigned to the same XF86Config - * Device section. - */ - if (pATIGDev->iATIPtr) - { - if (pATIGDev->iATIPtr < 0) - break; + /* + * Ensure no two adapters are assigned to the same XF86Config + * Device section. + */ + if (pATIGDev->iATIPtr) + { + if (pATIGDev->iATIPtr < 0) + break; - xf86Msg(X_ERROR, + xf86Msg(X_ERROR, ATI_NAME ": XF86Config Device section \"%s\" may not" " be assigned to more than one adapter.\n", pGDev->identifier); - pATIGDev->iATIPtr = -1; - break; - } + pATIGDev->iATIPtr = -1; + break; + } - /* Assign adapter */ - pATIGDev->iATIPtr = j + 1; + /* Assign adapter */ + pATIGDev->iATIPtr = j + 1; - /* - * For compatibility with previous releases, assign the first - * applicable adapter if there is only one Device section. - */ - if (nATIGDev == 1) - break; + /* + * For compatibility with previous releases, assign the first + * applicable adapter if there is only one Device section. + */ + if (nATIGDev == 1) + break; + } } - } - /* - * Ensure no two XF86Config Device sections are assigned to the same - * adapter. Then, generate screens for any that are left. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; + /* + * Ensure no two XF86Config Device sections are assigned to the same + * adapter. Then, generate screens for any that are left. + */ + for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) + { + pGDev = pATIGDev->pGDev; - j = pATIGDev->iATIPtr; - if (j <= 0) - continue; + j = pATIGDev->iATIPtr; + if (j <= 0) + continue; - for (k = i; ++k < nATIGDev; ) - { - if (j == ATIGDevs[k].iATIPtr) + for (k = i; ++k < nATIGDev; ) { - xf86Msg(X_ERROR, + if (j == ATIGDevs[k].iATIPtr) + { + xf86Msg(X_ERROR, ATI_NAME ": XF86Config Device sections \"%s\" and" " \"%s\" may not be assigned to the same adapter.\n", pGDev->identifier, ATIGDevs[k].pGDev->identifier); - pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; + pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; + } } - } - j = ATIGDevs[i].iATIPtr; - if (j <= 0) - continue; + j = ATIGDevs[i].iATIPtr; + if (j <= 0) + continue; - pATI = ATIPtrs[j - 1]; + pATI = ATIPtrs[j - 1]; - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s assigned to %sactive \"Device\" section \"%s\".\n", - Identifier, pGDev->active ? "" : "in", pGDev->identifier); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s assigned to %sactive \"Device\" section" + " \"%s\".\n", + Identifier, pGDev->active ? "" : "in", pGDev->identifier); - /* - * Attach adapter to XF86Config Device section and register its - * resources. - */ - if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset, - pGDev, pGDev->active, pATI) < 0) - { - xf86Msg(X_ERROR, ATI_NAME ": Could not claim bus slot for %s.\n", - Identifier); - continue; - } + /* + * Attach adapter to XF86Config Device section and register its + * resources. + */ + if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset, + pGDev, pGDev->active, pATI) < 0) + { + xf86Msg(X_ERROR, + ATI_NAME ": Could not claim bus slot for %s.\n", + Identifier); + continue; + } - if (!pGDev->active) - continue; + if (!pGDev->active) + continue; - /* Allocate screen */ - pScreenInfo = xf86AllocateScreen(pDriver, 0); + /* Allocate screen */ + pScreenInfo = xf86AllocateScreen(pDriver, 0); - /* Attach device to screen */ - xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); +#ifdef XFree86LOADER - ATIPtrs[j - 1] = NULL; + if (!xf86LoadSubModule(pScreenInfo, "atimisc")) + { + xf86Msg(X_ERROR, + ATI_NAME ": Failed to load \"atimisc\" module.\n"); + xf86DeleteScreen(pScreenInfo->scrnIndex, 0); + continue; + } - /* Fill in probe data */ - pScreenInfo->driverVersion = ATI_VERSION_CURRENT; - pScreenInfo->driverName = ATI_DRIVER_NAME; - pScreenInfo->name = ATI_NAME; - pScreenInfo->Probe = ATIProbe; - pScreenInfo->PreInit = ATIPreInit; - pScreenInfo->ScreenInit = ATIScreenInit; - pScreenInfo->SwitchMode = ATISwitchMode; - pScreenInfo->AdjustFrame = ATIAdjustFrame; - pScreenInfo->EnterVT = ATIEnterVT; - pScreenInfo->LeaveVT = ATILeaveVT; - pScreenInfo->FreeScreen = ATIFreeScreen; - pScreenInfo->ValidMode = ATIValidMode; + xf86LoaderReqSymLists(ATISymbols, NULL); +#endif - pScreenInfo->driverPrivate = pATI; + /* Attach device to screen */ + xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); - pATI->Chipset = pATIGDev->Chipset; + ATIPtrs[j - 1] = NULL; - ProbeSuccess = TRUE; - } + /* Fill in probe data */ + pScreenInfo->driverVersion = ATI_VERSION_CURRENT; + pScreenInfo->driverName = ATI_DRIVER_NAME; + pScreenInfo->name = ATI_NAME; + pScreenInfo->Probe = ATIProbe; + pScreenInfo->PreInit = ATIPreInit; + pScreenInfo->ScreenInit = ATIScreenInit; + pScreenInfo->SwitchMode = ATISwitchMode; + pScreenInfo->AdjustFrame = ATIAdjustFrame; + pScreenInfo->EnterVT = ATIEnterVT; + pScreenInfo->LeaveVT = ATILeaveVT; + pScreenInfo->FreeScreen = ATIFreeScreen; + pScreenInfo->ValidMode = ATIValidMode; - /* Deal with unassigned adapters */ - for (i = 0; i < nATIPtr; i++) - { - if (!(pATI = ATIPtrs[i])) - continue; + pScreenInfo->driverPrivate = pATI; + + pATI->Chipset = pATIGDev->Chipset; + + ProbeSuccess = TRUE; + } + + /* Deal with unassigned adapters */ + for (i = 0; i < nATIPtr; i++) + { + if (!(pATI = ATIPtrs[i])) + continue; #ifndef AVOID_CPIO - if (pATI->Adapter > ATI_ADAPTER_VGA) + if (pATI->Adapter > ATI_ADAPTER_VGA) #endif /* AVOID_CPIO */ - { - if (pATI->iEntity < 0) - (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); + { + if (pATI->iEntity < 0) + (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); + } + + xfree(pATI); } - xfree(pATI); + xfree(ATIGDevs); } + xfree(ATIPtrs); - xfree(ATIGDevs); + + /* Call Rage 128 driver probe */ + if (DoRage128 && R128Probe(pDriver, flags)) + ProbeSuccess = TRUE; + + /* Call Radeon driver probe */ + if (DoRadeon && RADEONProbe(pDriver, flags)) + ProbeSuccess = TRUE; return ProbeSuccess; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h index 40b92fbdc..4a31c46d2 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.24 2000/10/11 22:52:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.26 2000/11/02 16:55:29 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,14 +24,14 @@ #ifndef ___ATIVERSION_H___ #define ___ATIVERSION_H___ 1 -#define ATI_NAME "ATI" -#define ATI_DRIVER_NAME "ati" +#define ATI_NAME "ATI" +#define ATI_DRIVER_NAME "ati" -#define ATI_VERSION_NAME "6.0.7" +#define ATI_VERSION_NAME "6.2.0" -#define ATI_VERSION_MAJOR 6 -#define ATI_VERSION_MINOR 0 -#define ATI_VERSION_PATCH 7 +#define ATI_VERSION_MAJOR 6 +#define ATI_VERSION_MINOR 2 +#define ATI_VERSION_PATCH 0 #define ATI_VERSION_CURRENT \ ((ATI_VERSION_MAJOR << 20) | (ATI_VERSION_MINOR << 10) | ATI_VERSION_PATCH) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp new file mode 100644 index 000000000..2f5408b34 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp @@ -0,0 +1,70 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp,v 1.1 2000/11/02 16:55:29 tsi Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH R128 __drivermansuffix__ "Version 4.0.1" "XFree86" +.SH NAME +r128 \- ATI Rage 128 video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qr128\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B r128 +is an XFree86 driver for ATI Rage 128 based video cards. It contains +full support for 8, 15, 16 and 24 bit pixel depths, hardware +acceleration of drawing primitives, hardware cursor, video modes up to +1800x1440 @ 70Hz, doublescan modes (e.g., 320x200 and 320x240), gamma +correction at all pixel depths, a fully programming dot clock and robust +text mode restoration for VT switching. +.SH SUPPORTED HARDWARE +The +.B r128 +driver supports all ATI Rage 128 based video cards including the Rage +Fury AGP 32MB, the XPERT 128 AGP 16MB and the XPERT 99 AGP 8MB. +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The driver auto-detects all device information necessary to initialize +the card. However, if you have problems with auto-detection, you can +specify: +.PP +.RS 4 +VideoRam - in kilobytes +.br +MemBase - physical address of the linear framebuffer +.br +IOBase - physical address of the MMIO registers +.br +ChipID - PCI DEVICE ID +.RE +.PP +In addition, the following driver +.B Options +are supported: +.TP +.BI "Option \*qSWcursor\*q \*q" boolean \*q +Selects software cursor. The default is +.B off. +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Enables or disables all hardware acceleration. The default is to +.B enable +hardware acceleration. +.TP +.BI "Option \*qDac6Bit\*q \*q" boolean \*q +Enables or disables the use of 6 bits per color component when in 8 bpp +mode (emulates VGA mode). By default, all 8 bits per color component +are used. The default is +.B off. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +.nf +Rickard E. (Rik) Faith \fIfaith@precisioninsight.com\fP +Kevin E. Martin \fIkevin@precisioninsight.com\fP diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h new file mode 100644 index 000000000..cde3f03f6 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h @@ -0,0 +1,395 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h,v 1.1 2000/11/02 16:55:29 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_H_ +#define _R128_H_ + + /* Xv support */ +#include "xf86xv.h" +#include "Xv.h" + + /* vgahw module (for VC save/restore only) */ +#include "vgaHW.h" + +#include "fbdevhw.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xaalocal.h" +#include "xf86Cursor.h" + + + /* PCI support */ +#include "xf86PciInfo.h" +#include "xf86Pci.h" + + /* DDC support */ +#include "xf86DDC.h" + + /* VESA support */ +#include "vbe.h" + + /* DRI support */ +#ifdef XF86DRI +#include "GL/glxint.h" +#include "GL/glxtokens.h" +#include "xf86drm.h" +#include "xf86drmR128.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "r128_dri.h" +#include "r128_dripriv.h" +#include "r128_sarea.h" +#endif + +#ifdef RENDER +#include "picturestr.h" +#endif + +#define R128_DEBUG 0 /* Turn off debugging output */ +#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ +#define R128_MMIOSIZE 0x80000 + +#define R128_VBIOS_SIZE 0x00010000 + +#if R128_DEBUG +#define R128TRACE(x) \ + do { \ + ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ + ErrorF x; \ + } while (0); +#else +#define R128TRACE(x) +#endif + + +/* Other macros */ +#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) +#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate) + +typedef struct { /* All values in XCLKS */ + int ML; /* Memory Read Latency */ + int MB; /* Memory Burst Length */ + int Trcd; /* RAS to CAS delay */ + int Trp; /* RAS percentage */ + int Twr; /* Write Recovery */ + int CL; /* CAS Latency */ + int Tr2w; /* Read to Write Delay */ + int Rloop; /* Loop Latency */ + int Rloop_fudge; /* Add to ML to get Rloop */ + char *name; +} R128RAMRec, *R128RAMPtr; + +typedef struct { + /* Common registers */ + CARD32 ovr_clr; + CARD32 ovr_wid_left_right; + CARD32 ovr_wid_top_bottom; + CARD32 ov0_scale_cntl; + CARD32 mpp_tb_config; + CARD32 mpp_gp_config; + CARD32 subpic_cntl; + CARD32 viph_control; + CARD32 i2c_cntl_1; + CARD32 gen_int_cntl; + CARD32 cap0_trig_cntl; + CARD32 cap1_trig_cntl; + CARD32 bus_cntl; + + /* Other registers to save for VT switches */ + CARD32 dp_datatype; + CARD32 gen_reset_cntl; + CARD32 clock_cntl_index; + CARD32 amcgpio_en_reg; + CARD32 amcgpio_mask; + + /* CRTC registers */ + CARD32 crtc_gen_cntl; + CARD32 crtc_ext_cntl; + CARD32 dac_cntl; + CARD32 crtc_h_total_disp; + CARD32 crtc_h_sync_strt_wid; + CARD32 crtc_v_total_disp; + CARD32 crtc_v_sync_strt_wid; + CARD32 crtc_offset; + CARD32 crtc_offset_cntl; + CARD32 crtc_pitch; + + /* CRTC2 registers */ + CARD32 crtc2_gen_cntl; + + /* Flat panel registers */ + CARD32 fp_crtc_h_total_disp; + CARD32 fp_crtc_v_total_disp; + CARD32 fp_gen_cntl; + CARD32 fp_h_sync_strt_wid; + CARD32 fp_horz_stretch; + CARD32 fp_panel_cntl; + CARD32 fp_v_sync_strt_wid; + CARD32 fp_vert_stretch; + CARD32 lvds_gen_cntl; + CARD32 tmds_crc; + + /* Computed values for PLL */ + CARD32 dot_clock_freq; + CARD32 pll_output_freq; + int feedback_div; + int post_div; + + /* PLL registers */ + CARD32 ppll_ref_div; + CARD32 ppll_div_3; + CARD32 htotal_cntl; + + /* DDA register */ + CARD32 dda_config; + CARD32 dda_on_off; + + /* Pallet */ + Bool palette_valid; + CARD32 palette[256]; +} R128SaveRec, *R128SavePtr; + +typedef struct { + CARD16 reference_freq; + CARD16 reference_div; + CARD32 min_pll_freq; + CARD32 max_pll_freq; + CARD16 xclk; +} R128PLLRec, *R128PLLPtr; + +typedef struct { + int bitsPerPixel; + int depth; + int displayWidth; + int pixel_code; + int pixel_bytes; + DisplayModePtr mode; +} R128FBLayout; + +typedef struct { + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + int Chipset; + Bool Primary; + + Bool FBDev; + + unsigned long LinearAddr; /* Frame buffer physical address */ + unsigned long MMIOAddr; /* MMIO region physical address */ + unsigned long BIOSAddr; /* BIOS physical address */ + Bool BIOSFromPCI; /* BIOS is read from PCI space */ + + unsigned char *MMIO; /* Map of MMIO region */ + unsigned char *FB; /* Map of frame buffer */ + + CARD32 MemCntl; + CARD32 BusCntl; + unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + int Flags; /* Saved copy of mode flags */ + + Bool HasPanelRegs; /* Current chip can connect to a FP */ + Bool CRTOnly; /* Only use External CRT instead of FP */ + CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */ + int FPBIOSstart; /* Start of the flat panel info */ + + /* Computed values for FPs */ + int PanelXRes; + int PanelYRes; + int PanelPwrDly; + + R128PLLRec pll; + R128RAMPtr ram; + + R128SaveRec SavedReg; /* Original (text) mode */ + R128SaveRec ModeReg; /* Current mode */ + Bool (*CloseScreen)(int, ScreenPtr); + + Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ + + XAAInfoRecPtr accel; + Bool accelOn; + xf86CursorInfoPtr cursor; + unsigned long cursor_start; + unsigned long cursor_end; + + int fifo_slots; /* Free slots in the FIFO (64 max) */ + int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ + Bool dac6bits; /* Use 6 bit DAC? */ + + /* Computed values for Rage 128 */ + int pitch; + int datatype; + CARD32 dp_gui_master_cntl; + + /* Saved values for ScreenToScreenCopy */ + int xdir; + int ydir; + + /* ScanlineScreenToScreenColorExpand support */ + unsigned char *scratch_buffer[1]; + unsigned char *scratch_save; + int scanline_x; + int scanline_y; + int scanline_h; + int scanline_h_w; + int scanline_words; + int scanline_direct; + int scanline_bpp; /* Only used for ImageWrite */ + + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; + + R128FBLayout CurrentLayout; +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig *pVisualConfigs; + R128ConfigPrivPtr pVisualConfigsPriv; + + drmHandle fbHandle; + + drmSize registerSize; + drmHandle registerHandle; + + Bool IsPCI; /* Current card is a PCI card */ + + drmSize agpSize; + drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ + unsigned long agpOffset; + unsigned char *AGP; /* Map */ + int agpMode; + + Bool CCEInUse; /* CCE is currently active */ + int CCEMode; /* CCE mode that server/clients use */ + int CCEFifoSize; /* Size of the CCE command FIFO */ + Bool CCESecure; /* CCE security enabled */ + int CCEusecTimeout; /* CCE timeout in usecs */ + Bool CCE2D; /* CCE is used for X server 2D prims */ + + /* CCE ring buffer data */ + unsigned long ringStart; /* Offset into AGP space */ + drmHandle ringHandle; /* Handle from drmAddMap */ + drmSize ringMapSize; /* Size of map */ + int ringSize; /* Size of ring (in MB) */ + unsigned char *ring; /* Map */ + int ringSizeLog2QW; + + unsigned long ringReadOffset; /* Offset into AGP space */ + drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ + drmSize ringReadMapSize; /* Size of map */ + unsigned char *ringReadPtr; /* Map */ + + /* CCE vertex buffer data */ + unsigned long vbStart; /* Offset into AGP space */ + drmHandle vbHandle; /* Handle from drmAddMap */ + drmSize vbMapSize; /* Size of map */ + int vbSize; /* Size of vert bufs (in MB) */ + unsigned char *vb; /* Map */ + int vbBufSize; /* Size of individual vert buf */ + int vbNumBufs; /* Number of vert bufs */ + drmBufMapPtr vbBufs; /* Buffer map */ + + /* CCE indirect buffer data */ + unsigned long indStart; /* Offset into AGP space */ + drmHandle indHandle; /* Handle from drmAddMap */ + drmSize indMapSize; /* Size of map */ + int indSize; /* Size of indirect bufs (in MB) */ + unsigned char *ind; /* Map */ + + /* CCE AGP Texture data */ + unsigned long agpTexStart; /* Offset into AGP space */ + drmHandle agpTexHandle; /* Handle from drmAddMap */ + drmSize agpTexMapSize; /* Size of map */ + int agpTexSize; /* Size of AGP tex space (in MB) */ + unsigned char *agpTex; /* Map */ + int log2AGPTexGran; + + /* DRI screen private data */ + int fbX; + int fbY; + int backX; + int backY; + int depthX; + int depthY; + int textureX; + int textureY; + int textureSize; + int log2TexGran; +#endif + XF86VideoAdaptorPtr adaptor; +} R128InfoRec, *R128InfoPtr; + +#define R128WaitForFifo(pScrn, entries) \ +do { \ + if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ + info->fifo_slots -= entries; \ +} while (0) + +extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); +extern void R128WaitForIdle(ScrnInfoPtr pScrn); +extern void R128EngineReset(ScrnInfoPtr pScrn); +extern void R128EngineFlush(ScrnInfoPtr pScrn); + +extern int R128INPLL(ScrnInfoPtr pScrn, int addr); +extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); + +extern Bool R128AccelInit(ScreenPtr pScreen); +extern void R128EngineInit(ScrnInfoPtr pScrn); +extern Bool R128CursorInit(ScreenPtr pScreen); +extern Bool R128DGAInit(ScreenPtr pScreen); + +extern int R128MinBits(int val); + +extern void R128InitVideo(ScreenPtr pScreen); + +#ifdef XF86DRI +extern Bool R128DRIScreenInit(ScreenPtr pScreen); +extern void R128DRICloseScreen(ScreenPtr pScreen); +extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen); +extern void R128CCEStart(ScrnInfoPtr pScrn); +extern void R128CCEStop(ScrnInfoPtr pScrn); +extern void R128CCEResetRing(ScrnInfoPtr pScrn); +extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn); +#endif + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c new file mode 100644 index 000000000..7595b7fe4 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c @@ -0,0 +1,1084 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c,v 1.1 2000/11/02 16:55:30 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * Credits: + * + * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for + * providing source code to their 3.3.x Rage 128 driver. Portions of + * this file are based on the acceleration code for that driver. + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * Notes on unimplemented XAA optimizations: + * + * SetClipping: The Rage128 doesn't support the full 16bit registers needed + * for XAA clip rect support. + * SolidFillTrap: This will probably work if we can compute the correct + * Bresenham error values. + * TwoPointLine: The Rage 128 supports Bresenham lines instead. + * DashedLine with non-power-of-two pattern length: Apparently, there is + * no way to set the length of the pattern -- it is always + * assumed to be 8 or 32 (or 1024?). + * ScreenToScreenColorExpandFill: See p. 4-17 of the Technical Reference + * Manual where it states that monochrome expansion of frame + * buffer data is not supported. + * CPUToScreenColorExpandFill, direct: The implementation here uses a hybrid + * direct/indirect method. If we had more data registers, + * then we could do better. If XAA supported a trigger write + * address, the code would be simpler. + * (Alan Hourihane) Update. We now use purely indirect and clip the full + * rectangle. Seems as the direct method has some problems + * with this, although this indirect method is much faster + * than the old method of setting up the engine per scanline. + * This code was the basis of the Radeon work we did. + * Color8x8PatternFill: Apparently, an 8x8 color brush cannot take an 8x8 + * pattern from frame buffer memory. + * ImageWrites: See CPUToScreenColorExpandFill. + * + */ + +#define R128_IMAGEWRITE 0 /* Disable ImageWrites - faster in software */ +#define R128_TRAPEZOIDS 0 /* Trapezoids don't work */ + + /* X and server generic header files */ +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86fbman.h" + + /* Line support */ +#include "miline.h" + + /* XAA and cursor support */ +#include "xaa.h" +#include "xf86Cursor.h" + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" + +static struct { + int rop; + int pattern; +} R128_ROP[] = { + { R128_ROP3_ZERO, R128_ROP3_ZERO }, /* GXclear */ + { R128_ROP3_DSa, R128_ROP3_DPa }, /* Gxand */ + { R128_ROP3_SDna, R128_ROP3_PDna }, /* GXandReverse */ + { R128_ROP3_S, R128_ROP3_P }, /* GXcopy */ + { R128_ROP3_DSna, R128_ROP3_DPna }, /* GXandInverted */ + { R128_ROP3_D, R128_ROP3_D }, /* GXnoop */ + { R128_ROP3_DSx, R128_ROP3_DPx }, /* GXxor */ + { R128_ROP3_DSo, R128_ROP3_DPo }, /* GXor */ + { R128_ROP3_DSon, R128_ROP3_DPon }, /* GXnor */ + { R128_ROP3_DSxn, R128_ROP3_PDxn }, /* GXequiv */ + { R128_ROP3_Dn, R128_ROP3_Dn }, /* GXinvert */ + { R128_ROP3_SDno, R128_ROP3_PDno }, /* GXorReverse */ + { R128_ROP3_Sn, R128_ROP3_Pn }, /* GXcopyInverted */ + { R128_ROP3_DSno, R128_ROP3_DPno }, /* GXorInverted */ + { R128_ROP3_DSan, R128_ROP3_DPan }, /* GXnand */ + { R128_ROP3_ONE, R128_ROP3_ONE } /* GXset */ +}; + +/* Flush all dirty data in the Pixel Cache to memory. */ +void R128EngineFlush(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + OUTREGP(R128_PC_NGUI_CTLSTAT, R128_PC_FLUSH_ALL, ~R128_PC_FLUSH_ALL); + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) break; + } +} + +/* Reset graphics card to known state. */ +void R128EngineReset(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 clock_cntl_index; + CARD32 mclk_cntl; + CARD32 gen_reset_cntl; + + R128EngineFlush(pScrn); + + clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); + mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL); + + OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP); + + gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); + + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); + INREG(R128_GEN_RESET_CNTL); + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); + INREG(R128_GEN_RESET_CNTL); + + OUTPLL(R128_MCLK_CNTL, mclk_cntl); + OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index); + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl); + +#ifdef XF86DRI + if (R128CCE_USE_RING_BUFFER(info->CCEMode)) R128CCEResetRing(pScrn); +#endif +} + +/* The FIFO has 64 slots. This routines waits until at least `entries' of + these slots are empty. */ +void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + info->fifo_slots = INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; + if (info->fifo_slots >= entries) return; + } + R128TRACE(("FIFO timed out: %d entries, stat=0x%08x, probe=0x%08x\n", + INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, + INREG(R128_GUI_STAT), + INREG(R128_GUI_PROBE))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FIFO timed out, resetting engine...\n"); + R128EngineReset(pScrn); +#ifdef XF86DRI + if (info->CCE2D) R128CCEStart(pScrn); +#endif + } +} + +/* Wait for the graphics engine to be completely idle: the FIFO has + drained, the Pixel Cache is flushed, and the engine is idle. This is a + standard "sync" function that will make the hardware "quiescent". */ +void R128WaitForIdle(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + R128WaitForFifoFunction(pScrn, 64); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_GUI_STAT) & R128_GUI_ACTIVE)) { + R128EngineFlush(pScrn); + return; + } + } + R128TRACE(("Idle timed out: %d entries, stat=0x%08x, probe=0x%08x\n", + INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, + INREG(R128_GUI_STAT), + INREG(R128_GUI_PROBE))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Idle timed out, resetting engine...\n"); + R128EngineReset(pScrn); +#ifdef XF86DRI + if (info->CCE2D) R128CCEStart(pScrn); +#endif + } +} + +/* Setup for XAA SolidFill. */ +static void R128SetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].pattern)); + OUTREG(R128_DP_BRUSH_FRGD_CLR, color); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT + | R128_DST_Y_TOP_TO_BOTTOM)); +} + +/* Subsequent XAA SolidFillRect. + + Tests: xtest CH06/fllrctngl, xterm +*/ +static void R128SubsequentSolidFillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_WIDTH_HEIGHT, (w << 16) | h); +} + +/* Setup for XAA solid lines. */ +static void R128SetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].pattern)); + OUTREG(R128_DP_BRUSH_FRGD_CLR, color); + OUTREG(R128_DP_WRITE_MASK, planemask); +} + + +/* Subsequent XAA solid Bresenham line. + + Tests: xtest CH06/drwln, ico, Mark Vojkovich's linetest program + + [See http://www.xfree86.org/devel/archives/devel/1999-Jun/0102.shtml for + Mark Vojkovich's linetest program, posted 2Jun99 to devel@xfree86.org.] + + x11perf -line500 + 1024x768@76Hz 1024x768@76Hz + 8bpp 32bpp + not used: 39700.0/sec 34100.0/sec + used: 47600.0/sec 36800.0/sec +*/ +static void R128SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, + int x, int y, + int major, int minor, + int err, int len, int octant) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + + if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; + if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; + if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; + + R128WaitForFifo(pScrn, 6); + OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_BRES_ERR, err); + OUTREG(R128_DST_BRES_INC, minor); + OUTREG(R128_DST_BRES_DEC, -major); + OUTREG(R128_DST_BRES_LNTH, len); +} + +/* Subsequent XAA solid horizontal and vertical lines + + 1024x768@76Hz 8bpp + Without With + x11perf -hseg500 87600.0/sec 798000.0/sec + x11perf -vseg500 38100.0/sec 38000.0/sec +*/ +static void R128SubsequentSolidHorVertLine(ScrnInfoPtr pScrn, + int x, int y, int len, int dir ) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 1); + OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT + | R128_DST_Y_TOP_TO_BOTTOM)); + + if (dir == DEGREES_0) { + R128SubsequentSolidFillRect(pScrn, x, y, len, 1); + } else { + R128SubsequentSolidFillRect(pScrn, x, y, 1, len); + } +} + +/* Setup for XAA dashed lines. + + Tests: xtest CH05/stdshs, XFree86/drwln + + NOTE: Since we can only accelerate lines with power-of-2 patterns of + length <= 32, these x11perf numbers are not representative of the + speed-up on appropriately-sized patterns. + + 1024x768@76Hz 8bpp + Without With + x11perf -dseg100 218000.0/sec 222000.0/sec + x11perf -dline100 215000.0/sec 221000.0/sec + x11perf -ddline100 178000.0/sec 180000.0/sec +*/ +static void R128SetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask, + int length, unsigned char *pattern) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 pat = *(CARD32 *)pattern; + + switch (length) { + case 2: pat |= pat << 2; /* fall through */ + case 4: pat |= pat << 4; /* fall through */ + case 8: pat |= pat << 8; /* fall through */ + case 16: pat |= pat << 16; + } + + R128WaitForFifo(pScrn, 5); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? R128_GMC_BRUSH_32x1_MONO_FG_LA + : R128_GMC_BRUSH_32x1_MONO_FG_BG) + | R128_ROP[rop].pattern + | R128_GMC_BYTE_LSB_TO_MSB)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); + OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); + OUTREG(R128_BRUSH_DATA0, pat); +} + +/* Subsequent XAA dashed line. */ +static void R128SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, + int x, int y, + int major, int minor, + int err, int len, int octant, + int phase) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + + if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; + if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; + if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; + + R128WaitForFifo(pScrn, 7); + OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_BRUSH_Y_X, (phase << 16) | phase); + OUTREG(R128_DST_BRES_ERR, err); + OUTREG(R128_DST_BRES_INC, minor); + OUTREG(R128_DST_BRES_DEC, -major); + OUTREG(R128_DST_BRES_LNTH, len); +} + +#if R128_TRAPEZOIDS + /* This doesn't work. Except in the + lower-left quadrant, all of the pixel + errors appear to be because eL and eR + are not correct. Drawing from right to + left doesn't help. Be aware that the + non-_SUB registers set the sub-pixel + values to 0.5 (0x08), which isn't what + XAA wants. */ +/* Subsequent XAA SolidFillTrap. XAA always passes data that assumes we + fill from top to bottom, so dyL and dyR are always non-negative. */ +static void R128SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + int Lymajor = 0; + int Rymajor = 0; + int origdxL = dxL; + int origdxR = dxR; + + R128TRACE(("Trap %d %d; L %d %d %d %d; R %d %d %d %d\n", + y, h, + left, dxL, dyL, eL, + right, dxR, dyR, eR)); + + if (dxL < 0) dxL = -dxL; else flags |= (1 << 0) /* | (1 << 8) */; + if (dxR < 0) dxR = -dxR; else flags |= (1 << 6); + + R128WaitForFifo(pScrn, 11); + +#if 1 + OUTREG(R128_DP_CNTL, flags | (1 << 1) | (1 << 7)); + OUTREG(R128_DST_Y_SUB, ((y) << 4) | 0x0 ); + OUTREG(R128_DST_X_SUB, ((left) << 4)|0x0); + OUTREG(R128_TRAIL_BRES_ERR, eR-dxR); + OUTREG(R128_TRAIL_BRES_INC, dxR); + OUTREG(R128_TRAIL_BRES_DEC, -dyR); + OUTREG(R128_TRAIL_X_SUB, ((right) << 4) | 0x0); + OUTREG(R128_LEAD_BRES_ERR, eL-dxL); + OUTREG(R128_LEAD_BRES_INC, dxL); + OUTREG(R128_LEAD_BRES_DEC, -dyL); + OUTREG(R128_LEAD_BRES_LNTH_SUB, ((h) << 4) | 0x00); +#else + OUTREG(R128_DP_CNTL, flags | (1 << 1) ); + OUTREG(R128_DST_Y_SUB, (y << 4)); + OUTREG(R128_DST_X_SUB, (right << 4)); + OUTREG(R128_TRAIL_BRES_ERR, eL); + OUTREG(R128_TRAIL_BRES_INC, dxL); + OUTREG(R128_TRAIL_BRES_DEC, -dyL); + OUTREG(R128_TRAIL_X_SUB, (left << 4) | 0); + OUTREG(R128_LEAD_BRES_ERR, eR); + OUTREG(R128_LEAD_BRES_INC, dxR); + OUTREG(R128_LEAD_BRES_DEC, -dyR); + OUTREG(R128_LEAD_BRES_LNTH_SUB, h << 4); +#endif +} +#endif + +/* Setup for XAA screen-to-screen copy. + + Tests: xtest CH06/fllrctngl (also tests transparency). +*/ +static void R128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, + int xdir, int ydir, int rop, + unsigned int planemask, + int trans_color) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + info->xdir = xdir; + info->ydir = ydir; + R128WaitForFifo(pScrn, 3); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_DP_SRC_SOURCE_MEMORY)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_CNTL, ((xdir >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) + | (ydir >= 0 + ? R128_DST_Y_TOP_TO_BOTTOM + : 0))); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA screen-to-screen copy. */ +static void R128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (info->xdir < 0) xa += w - 1, xb += w - 1; + if (info->ydir < 0) ya += h - 1, yb += h - 1; + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_SRC_Y_X, (ya << 16) | xa); + OUTREG(R128_DST_Y_X, (yb << 16) | xb); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +/* Setup for XAA mono 8x8 pattern color expansion. Patterns with + transparency use `bg == -1'. This routine is only used if the XAA + pixmap cache is turned on. + + Tests: xtest XFree86/fllrctngl (no other test will test this routine with + both transparency and non-transparency) + + 1024x768@76Hz 8bpp + Without With + x11perf -srect100 38600.0/sec 85700.0/sec + x11perf -osrect100 38600.0/sec 85700.0/sec +*/ +static void R128SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int patternx, int patterny, + int fg, int bg, int rop, + unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 6); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? R128_GMC_BRUSH_8X8_MONO_FG_LA + : R128_GMC_BRUSH_8X8_MONO_FG_BG) + | R128_ROP[rop].pattern + | R128_GMC_BYTE_LSB_TO_MSB)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); + OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); + OUTREG(R128_BRUSH_DATA0, patternx); + OUTREG(R128_BRUSH_DATA1, patterny); +} + +/* Subsequent XAA 8x8 pattern color expansion. Because they are used in + the setup function, `patternx' and `patterny' are not used here. */ +static void R128SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int patternx, int patterny, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_BRUSH_Y_X, (patterny << 8) | patternx); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +#if 0 +/* Setup for XAA color 8x8 pattern fill. + + Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off) +*/ +static void R128SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, + int patx, int paty, + int rop, unsigned int planemask, + int trans_color) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128TRACE(("Color8x8 %d %d %d\n", trans_color, patx, paty)); + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_8x8_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_DP_SRC_SOURCE_MEMORY)); + OUTREG(R128_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA 8x8 pattern color expansion. */ +static void R128SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128TRACE(("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h)); + R128WaitForFifo(pScrn, 3); + OUTREG(R128_SRC_Y_X, (paty << 16) | patx); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} +#endif + +/* Setup for XAA indirect CPU-to-screen color expansion (indirect). + Because of how the scratch buffer is initialized, this is really a + mainstore-to-screen color expansion. Transparency is supported when `bg + == -1'. + + x11perf -ftext (pure indirect): + 1024x768@76Hz 1024x768@76Hz + 8bpp 32bpp + not used: 685000.0/sec 794000.0/sec + used: 1070000.0/sec 1080000.0/sec + + We could improve this indirect routine by about 10% if the hardware + could accept DWORD padded scanlines, or if XAA could provide bit-packed + data. We might also be able to move to a direct routine if there were + more HOST_DATA registers. + + Implementing the hybrid indirect/direct scheme improved performance in a + few areas: + + 1024x768@76 8bpp + Indirect Hybrid + x11perf -oddsrect10 50100.0/sec 71700.0/sec + x11perf -oddsrect100 4240.0/sec 6660.0/sec + x11perf -bigsrect10 50300.0/sec 71100.0/sec + x11perf -bigsrect100 4190.0/sec 6800.0/sec + x11perf -polytext 584000.0/sec 714000.0/sec + x11perf -polytext16 154000.0/sec 172000.0/sec + x11perf -seg1 1780000.0/sec 1880000.0/sec + x11perf -copyplane10 42900.0/sec 58300.0/sec + x11perf -copyplane100 4400.0/sec 6710.0/sec + x11perf -putimagexy10 5090.0/sec 6670.0/sec + x11perf -putimagexy100 424.0/sec 575.0/sec + + 1024x768@76 -depth 24 -fbbpp 32 + Indirect Hybrid + x11perf -oddsrect100 4240.0/sec 6670.0/sec + x11perf -bigsrect100 4190.0/sec 6800.0/sec + x11perf -polytext 585000.0/sec 719000.0/sec + x11perf -seg1 2960000.0/sec 2990000.0/sec + x11perf -copyplane100 4400.0/sec 6700.0/sec + x11perf -putimagexy100 138.0/sec 191.0/sec + +*/ +static void R128SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int + planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_DST_CLIPPING + | R128_GMC_BRUSH_NONE + | (bg == -1 + ? R128_GMC_SRC_DATATYPE_MONO_FG_LA + : R128_GMC_SRC_DATATYPE_MONO_FG_BG) + | R128_ROP[rop].rop + | R128_GMC_BYTE_LSB_TO_MSB + | R128_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_SRC_FRGD_CLR, fg); + OUTREG(R128_DP_SRC_BKGD_CLR, bg); +} + +/* Subsequent XAA indirect CPU-to-screen color expansion. This is only + called once for each rectangle. */ +static void R128SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int x1clip = x+skipleft; + int x2clip = x+w; + + info->scanline_h = h; + info->scanline_words = (w + 31) >> 5; + +#if 0 + /* Seems as though the Rage128's doesn't like blitting directly + * as we must be overwriting something too quickly, therefore we + * render to the buffer first and then blit */ + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else +#endif + { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + if (pScrn->bitsPerPixel == 24) { + x1clip *= 3; + x2clip *= 3; + } + + R128WaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(R128_SC_TOP_LEFT, (y << 16) | (x1clip & 0xffff)); + OUTREG(R128_SC_BOTTOM_RIGHT, ((y+h-1) << 16) | ((x2clip-1) & 0xffff)); + OUTREG(R128_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | ((w + 31) & ~31)); +} + +/* Subsequent XAA indirect CPU-to-screen color expandion. This is called + once for each scanline. */ +static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + R128WaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} + +/* Setup for XAA indirect image write. + + + 1024x768@76Hz 8bpp + Without With + x11perf -putimage10 37500.0/sec 39300.0/sec + x11perf -putimage100 2150.0/sec 1170.0/sec + x11perf -putimage500 108.0/sec 49.8/sec + */ +#if R128_IMAGEWRITE +static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int trans_color, + int bpp, + int depth) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + info->scanline_bpp = bpp; + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_DST_CLIPPING + | R128_GMC_BRUSH_1X8_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_GMC_BYTE_LSB_TO_MSB + | R128_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(R128_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA indirect image write. This is only called once for each + rectangle. */ +static void R128SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int x1clip = x+skipleft; + int x2clip = x+w; + + int shift = 0; /* 32bpp */ + + if (pScrn->bitsPerPixel == 8) shift = 3; + else if (pScrn->bitsPerPixel == 16) shift = 1; + + info->scanline_h = h; + info->scanline_words = (w * info->scanline_bpp + 31) >> 5; + +#if 0 + /* Seeing as the CPUToScreen doesn't like this, I've done this + * here too, as it uses pretty much the same path. */ + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else +#endif + { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + if (pScrn->bitsPerPixel == 24) { + x1clip *= 3; + x2clip *= 3; + } + + R128WaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(R128_SC_TOP_LEFT, (y << 16) | (x1clip & 0xffff)); + OUTREG(R128_SC_BOTTOM_RIGHT, ((y+h-1) << 16) | ((x2clip-1) & 0xffff)); + OUTREG(R128_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | ((w + shift) & ~shift)); +} + +/* Subsequent XAA indirect iamge write. This is called once for each + scanline. */ +static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + R128WaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} +#endif + +/* Initialize the acceleration hardware. */ +void R128EngineInit(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128TRACE(("EngineInit (%d/%d)\n", info->CurrentLayout.pixel_code, info->CurrentLayout.bitsPerPixel)); + + OUTREG(R128_SCALE_3D_CNTL, 0); + R128EngineReset(pScrn); + + switch (info->CurrentLayout.pixel_code) { + case 8: info->datatype = 2; break; + case 15: info->datatype = 3; break; + case 16: info->datatype = 4; break; + case 24: info->datatype = 5; break; + case 32: info->datatype = 6; break; + default: + R128TRACE(("Unknown depth/bpp = %d/%d (code = %d)\n", + info->CurrentLayout.depth, info->CurrentLayout.bitsPerPixel, + info->CurrentLayout.pixel_code)); + } + info->pitch = (info->CurrentLayout.displayWidth / 8) * (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1); + + R128TRACE(("Pitch for acceleration = %d\n", info->pitch)); + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DEFAULT_OFFSET, 0); + OUTREG(R128_DEFAULT_PITCH, info->pitch); + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_AUX_SC_CNTL, 0); + OUTREG(R128_DEFAULT_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX + | R128_DEFAULT_SC_BOTTOM_MAX)); + OUTREG(R128_SC_TOP_LEFT, 0); + OUTREG(R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX + | R128_DEFAULT_SC_BOTTOM_MAX)); + + info->dp_gui_master_cntl = ((info->datatype << R128_GMC_DST_DATATYPE_SHIFT) + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS); + R128WaitForFifo(pScrn, 1); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR)); + + R128WaitForFifo(pScrn, 8); + OUTREG(R128_DST_BRES_ERR, 0); + OUTREG(R128_DST_BRES_INC, 0); + OUTREG(R128_DST_BRES_DEC, 0); + OUTREG(R128_DP_BRUSH_FRGD_CLR, 0xffffffff); + OUTREG(R128_DP_BRUSH_BKGD_CLR, 0x00000000); + OUTREG(R128_DP_SRC_FRGD_CLR, 0xffffffff); + OUTREG(R128_DP_SRC_BKGD_CLR, 0x00000000); + OUTREG(R128_DP_WRITE_MASK, 0xffffffff); + + R128WaitForFifo(pScrn, 1); +#if X_BYTE_ORDER == X_BIG_ENDIAN + OUTREGP(R128_DP_DATATYPE, + R128_HOST_BIG_ENDIAN_EN, ~R128_HOST_BIG_ENDIAN_EN); +#else + OUTREGP(R128_DP_DATATYPE, 0, ~R128_HOST_BIG_ENDIAN_EN); +#endif + + R128WaitForIdle(pScrn); +} + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CCE to + draw 2D commands */ +static void R128CCEAccelInit(XAAInfoRecPtr a) +{ + a->Flags = 0; + + /* Sync */ + a->Sync = R128CCEWaitForIdle; + +} +#endif + +static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + R128InfoPtr info = R128PTR(pScrn); + + a->Flags = (PIXMAP_CACHE + | OFFSCREEN_PIXMAPS + | LINEAR_FRAMEBUFFER); + + /* Sync */ + a->Sync = R128WaitForIdle; + + /* Solid Filled Rectangle */ + a->PolyFillRectSolidFlags = 0; + a->SetupForSolidFill = R128SetupForSolidFill; + a->SubsequentSolidFillRect = R128SubsequentSolidFillRect; + + /* Screen-to-screen Copy */ + /* Transparency uses the wrong colors for + 24 bpp mode -- the transparent part is + correct, but the opaque color is wrong. + This can be seen with netscape's I-bar + cursor when editing in the URL location + box. */ + a->ScreenToScreenCopyFlags = ((pScrn->bitsPerPixel == 24) + ? NO_TRANSPARENCY + : 0); + a->SetupForScreenToScreenCopy = R128SetupForScreenToScreenCopy; + a->SubsequentScreenToScreenCopy = R128SubsequentScreenToScreenCopy; + + /* Mono 8x8 Pattern Fill (Color Expand) */ + a->SetupForMono8x8PatternFill = R128SetupForMono8x8PatternFill; + a->SubsequentMono8x8PatternFillRect = R128SubsequentMono8x8PatternFillRect; + a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST); + + /* Indirect CPU-To-Screen Color Expand */ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#else + a->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + a->NumScanlineColorExpandBuffers = 1; + a->ScanlineColorExpandBuffers = info->scratch_buffer; + info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + + (pScrn->virtualX + * info->CurrentLayout.pixel_bytes)); + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineCPUToScreenColorExpandFill + = R128SetupForScanlineCPUToScreenColorExpandFill; + a->SubsequentScanlineCPUToScreenColorExpandFill + = R128SubsequentScanlineCPUToScreenColorExpandFill; + a->SubsequentColorExpandScanline = R128SubsequentColorExpandScanline; + + /* Bresenham Solid Lines */ + a->SetupForSolidLine = R128SetupForSolidLine; + a->SubsequentSolidBresenhamLine = R128SubsequentSolidBresenhamLine; + a->SubsequentSolidHorVertLine = R128SubsequentSolidHorVertLine; + + /* Bresenham Dashed Lines*/ + a->SetupForDashedLine = R128SetupForDashedLine; + a->SubsequentDashedBresenhamLine = R128SubsequentDashedBresenhamLine; + a->DashPatternMaxLength = 32; + a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED + | LINE_PATTERN_POWER_OF_2_ONLY); + + /* ImageWrite */ +#if R128_IMAGEWRITE + a->NumScanlineImageWriteBuffers = 1; + a->ScanlineImageWriteBuffers = info->scratch_buffer; + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineImageWrite = R128SetupForScanlineImageWrite; + a->SubsequentScanlineImageWriteRect= R128SubsequentScanlineImageWriteRect; + a->SubsequentImageWriteScanline = R128SubsequentImageWriteScanline; + a->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD + /* Performance tests show that we shouldn't use GXcopy for + * uploads as a memcpy is faster */ + | NO_GXCOPY + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X + | SCANLINE_PAD_DWORD; +#endif +} + +/* Initialize XAA for supported acceleration and also initialize the + graphics hardware for acceleration. */ +Bool R128AccelInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + XAAInfoRecPtr a; + + if (!(a = info->accel = XAACreateInfoRec())) return FALSE; + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CCE to + draw 2D commands */ + if (info->CCE2D) R128CCEAccelInit(a); + else +#endif + R128MMIOAccelInit(pScrn, a); + + R128EngineInit(pScrn); + return XAAInit(pScreen, a); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c new file mode 100644 index 000000000..d77c64b5a --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c @@ -0,0 +1,289 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c,v 1.1 2000/11/02 16:55:31 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + + /* X and server generic header files */ +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86fbman.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xf86Cursor.h" + +#include "xf86xv.h" + + /* PCI support */ +#include "xf86PciInfo.h" +#include "xf86Pci.h" + + /* DDC support */ +#include "xf86DDC.h" + + /* DRI support */ +#ifdef XF86DRI +#include "GL/glxint.h" +#include "xf86drm.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "r128_dri.h" +#include "r128_dripriv.h" +#include "r128_sarea.h" +#endif + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" + +#if X_BYTE_ORDER == X_BIG_ENDIAN +#define P_SWAP32( a , b ) \ + ((char *)a)[0] = ((char *)b)[3]; \ + ((char *)a)[1] = ((char *)b)[2]; \ + ((char *)a)[2] = ((char *)b)[1]; \ + ((char *)a)[3] = ((char *)b)[0] + +#define P_SWAP16( a , b ) \ + ((char *)a)[0] = ((char *)b)[1]; \ + ((char *)a)[1] = ((char *)b)[0]; \ + ((char *)a)[2] = ((char *)b)[3]; \ + ((char *)a)[3] = ((char *)b)[2] +#endif + + +/* Set cursor foreground and background colors. */ +static void R128SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_CUR_CLR0, bg); + OUTREG(R128_CUR_CLR1, fg); +} + +/* Set cursor position to (x,y) with offset into cursor bitmap at + (xorigin,yorigin). */ +static void R128SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + xf86CursorInfoPtr cursor = info->cursor; + int xorigin = 0; + int yorigin = 0; + int total_y = pScrn->frameY1 - pScrn->frameY0; + + if (x < 0) xorigin = -x; + if (y < 0) yorigin = -y; + if (y > total_y) y = total_y; + if (info->Flags & V_DBLSCAN) y *= 2; + if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1; + if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1; + + OUTREG(R128_CUR_HORZ_VERT_OFF, R128_CUR_LOCK | (xorigin << 16) | yorigin); + OUTREG(R128_CUR_HORZ_VERT_POSN, (R128_CUR_LOCK + | ((xorigin ? 0 : x) << 16) + | (yorigin ? 0 : y))); + OUTREG(R128_CUR_OFFSET, info->cursor_start + yorigin * 16); +} + +/* Copy cursor image from `image' to video memory. R128SetCursorPosition + will be called after this, so we can ignore xorigin and yorigin. */ +static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *s = (CARD32 *)image; + CARD32 *d = (CARD32 *)(info->FB + info->cursor_start); + int y; + CARD32 save; + + save = INREG(R128_CRTC_GEN_CNTL); + OUTREG(R128_CRTC_GEN_CNTL, save & ~R128_CRTC_CUR_EN); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + switch(info->CurrentLayout.pixel_bytes) { + case 4: + case 3: + for (y = 0; y < 64; y++) { + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + } + break; + case 2: + for (y = 0; y < 64; y++) { + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + } + break; + default: + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + } +#else + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } +#endif + + /* Set the area after the cursor to be all transparent so that we + won't display corrupted cursors on the screen */ + for (y = 0; y < 64; y++) { + *d++ = 0xffffffff; /* The AND bits */ + *d++ = 0xffffffff; + *d++ = 0x00000000; /* The XOR bits */ + *d++ = 0x00000000; + } + + + OUTREG(R128_CRTC_GEN_CNTL, save); +} + +/* Hide hardware cursor. */ +static void R128HideCursor(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_GEN_CNTL, 0, ~R128_CRTC_CUR_EN); +} + +/* Show hardware cursor. */ +static void R128ShowCursor(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_GEN_CNTL, R128_CRTC_CUR_EN, ~R128_CRTC_CUR_EN); +} + +/* Determine if hardware cursor is in use. */ +static Bool R128UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + return info->cursor_start ? TRUE : FALSE; +} + +/* Initialize hardware cursor support. */ +Bool R128CursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + xf86CursorInfoPtr cursor; + FBAreaPtr fbarea; + int width; + int height; + int size; + + + if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; + + cursor->MaxWidth = 64; + cursor->MaxHeight = 64; + cursor->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST +#endif + | HARDWARE_CURSOR_INVERT_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK); + + cursor->SetCursorColors = R128SetCursorColors; + cursor->SetCursorPosition = R128SetCursorPosition; + cursor->LoadCursorImage = R128LoadCursorImage; + cursor->HideCursor = R128HideCursor; + cursor->ShowCursor = R128ShowCursor; + cursor->UseHWCursor = R128UseHWCursor; + + size = (cursor->MaxWidth/4) * cursor->MaxHeight; + width = pScrn->displayWidth; + height = (size*2 + 1023) / pScrn->displayWidth; + fbarea = xf86AllocateOffscreenArea(pScreen, + width, + height, + 16, + NULL, + NULL, + NULL); + + if (!fbarea) { + info->cursor_start = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Hardware cursor disabled" + " due to insufficient offscreen memory\n"); + } else { + info->cursor_start = R128_ALIGN((fbarea->box.x1 + + width * fbarea->box.y1) + * info->CurrentLayout.pixel_bytes, 16); + info->cursor_end = info->cursor_start + size; + } + + R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n", + info->cursor_start, info->cursor_end)); + + return xf86InitCursor(pScreen, cursor); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c new file mode 100644 index 000000000..695d49cdb --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c @@ -0,0 +1,358 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c,v 1.1 2000/11/02 16:55:32 tsi Exp $ */ +/* + * Authors: + * Ove Kĺven <ovek@transgaming.com>, + * borrowing some code from the Chips and MGA drivers. + */ + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" + + /* Driver data structures */ +#include "r128.h" +#include "r128_probe.h" + + /* DGA support */ +#include "dgaproc.h" + + +static Bool R128_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool R128_SetMode(ScrnInfoPtr, DGAModePtr); +static int R128_GetViewport(ScrnInfoPtr); +static void R128_SetViewport(ScrnInfoPtr, int, int, int); +static void R128_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void R128_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +#if 0 +static void R128_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); +#endif + +static +DGAFunctionRec R128_DGAFuncs = { + R128_OpenFramebuffer, + NULL, + R128_SetMode, + R128_SetViewport, + R128_GetViewport, + R128WaitForIdle, + R128_FillRect, + R128_BlitRect, +#if 0 + R128_BlitTransRect +#else + NULL +#endif +}; + + +static DGAModePtr +R128SetupDGAMode( + ScrnInfoPtr pScrn, + DGAModePtr modes, + int *num, + int bitsPerPixel, + int depth, + Bool pixmap, + int secondPitch, + unsigned long red, + unsigned long green, + unsigned long blue, + short visualClass +){ + R128InfoPtr info = R128PTR(pScrn); + DGAModePtr newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int otherPitch, Bpp = bitsPerPixel >> 3; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while(pMode) { + + otherPitch = secondPitch ? secondPitch : pMode->HDisplay; + + if(pMode->HDisplay != otherPitch) { + newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if(!newmodes) { + xfree(modes); + return NULL; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + *num; + (*num)++; + + currentMode->mode = pMode; + /* FIXME: is concurrent access really possible? */ + currentMode->flags = DGA_CONCURRENT_ACCESS; + if(pixmap) + currentMode->flags |= DGA_PIXMAP_AVAILABLE; + if(info->accel) + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if(pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if(pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = depth; + currentMode->bitsPerPixel = bitsPerPixel; + currentMode->red_mask = red; + currentMode->green_mask = green; + currentMode->blue_mask = blue; + currentMode->visualClass = visualClass; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 8; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = (unsigned char*)info->LinearAddr; + + if(oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; + currentMode->imageWidth = otherPitch; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + + pMode = pMode->next; + if(pMode == firstMode) + break; + } + + return modes; +} + + +Bool +R128DGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + DGAModePtr modes = NULL; + int num = 0; + + /* 8 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 8, 8, + (pScrn->bitsPerPixel == 8), + (pScrn->bitsPerPixel != 8) ? 0 : pScrn->displayWidth, + 0, 0, 0, PseudoColor); + + /* 15 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 15) ? 0 : pScrn->displayWidth, + 0x7c00, 0x03e0, 0x001f, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 15) ? 0 : pScrn->displayWidth, + 0x7c00, 0x03e0, 0x001f, DirectColor); + + /* 16 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 16) ? 0 : pScrn->displayWidth, + 0xf800, 0x07e0, 0x001f, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 16) ? 0 : pScrn->displayWidth, + 0xf800, 0x07e0, 0x001f, DirectColor); + + /* 24 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, + (pScrn->bitsPerPixel == 24), + (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, + (pScrn->bitsPerPixel == 24), + (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + /* 32 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + info->numDGAModes = num; + info->DGAModes = modes; + + return DGAInit(pScreen, &R128_DGAFuncs, modes, num); +} + + +static Bool +R128_SetMode( + ScrnInfoPtr pScrn, + DGAModePtr pMode +){ + static R128FBLayout SavedLayouts[MAXSCREENS]; + int indx = pScrn->pScreen->myNum; + R128InfoPtr info = R128PTR(pScrn); + + if(!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + if(info->DGAactive) + memcpy(&info->CurrentLayout, &SavedLayouts[indx], sizeof(R128FBLayout)); + + pScrn->currentMode = info->CurrentLayout.mode; + + R128SwitchMode(indx, pScrn->currentMode, 0); + R128AdjustFrame(indx, 0, 0, 0); + info->DGAactive = FALSE; + } else { + if(!info->DGAactive) { /* save the old parameters */ + memcpy(&SavedLayouts[indx], &info->CurrentLayout, sizeof(R128FBLayout)); + info->DGAactive = TRUE; + } + + info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel; + info->CurrentLayout.depth = pMode->depth; + info->CurrentLayout.displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16 + ? pMode->bitsPerPixel + : pMode->depth); + /* R128ModeInit() will set the mode field */ + + R128SwitchMode(indx, pMode->mode, 0); + } + + return TRUE; +} + + + +static int +R128_GetViewport( + ScrnInfoPtr pScrn +){ + R128InfoPtr info = R128PTR(pScrn); + + return info->DGAViewportStatus; +} + + +static void +R128_SetViewport( + ScrnInfoPtr pScrn, + int x, int y, + int flags +){ + R128InfoPtr info = R128PTR(pScrn); + + R128AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + info->DGAViewportStatus = 0; /* FIXME */ +} + + +static void +R128_FillRect ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color +){ + R128InfoPtr info = R128PTR(pScrn); + + if(info->accel) { + (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +static void +R128_BlitRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + R128InfoPtr info = R128PTR(pScrn); + + if(info->accel) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*info->accel->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, ~0, -1); + (*info->accel->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(info->accel); + } +} + + +#if 0 +static void +R128_BlitTransRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +){ + /* this one should be separate since the XAA function would + prohibit usage of ~0 as the key */ +} +#endif + + +static Bool +R128_OpenFramebuffer( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + R128InfoPtr info = R128PTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)info->LinearAddr; + *size = info->FbMapSize; + *offset = 0; + *flags = /* DGA_NEED_ROOT */ 0; /* don't need root, just /dev/mem access */ + + return TRUE; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c new file mode 100644 index 000000000..816dbebee --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c @@ -0,0 +1,1280 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c,v 1.2 2000/11/03 01:15:49 martin Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Rickard E. Faith <faith@precisioninsight.com> + * Daryll Strauss <daryll@precisioninsight.com> + * + */ + + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "xf86fbman.h" + + /* Backing store, software cursor, and + colormap initialization */ +#include "mibstore.h" +#include "mipointer.h" +#include "micmap.h" + + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" +#include "r128_version.h" + +#define R128_WATERMARK_L 16 +#define R128_WATERMARK_M 8 +#define R128_WATERMARK_N 8 +#define R128_WATERMARK_K 128 + +static int CCEFifoSlots = 0; + +#define R128CCEWaitForFifo(pScrn, entries) \ +do { \ + if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \ + CCEFifoSlots -= entries; \ +} while (0) + +/* Wait for at least `entries' slots are free. The actual number of + slots available is stored in info->CCEFifoSize. */ +static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; + if (CCEFifoSlots >= entries) return; + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } +} + +/* Wait until the CCE is completely idle: the FIFO has drained and the + CCE is idle. */ +void R128CCEWaitForIdle(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + if (R128CCE_USE_RING_BUFFER(info->CCEMode)) { + volatile CARD32 *r128RingReadPtr = + (volatile CARD32 *)(info->ringReadPtr); + R128SAREAPrivPtr pSAREAPriv; + + OUTREGP(R128_PM4_BUFFER_DL_WPTR, + R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (*r128RingReadPtr == pSAREAPriv->ringWrite) { + int pm4stat = INREG(R128_PM4_STAT); + if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize + && !(pm4stat & (R128_PM4_BUSY|R128_PM4_GUI_ACTIVE))) { + R128EngineFlush(pScrn); + return; + } + } + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } + } else { + R128CCEWaitForFifoFunction(pScrn, info->CCEFifoSize); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_PM4_STAT) + & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { + R128EngineFlush(pScrn); + return; + } + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } + } +} + +/* Reset the ring buffer status, if the engine was reset */ +void R128CCEResetRing(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SAREAPrivPtr pSAREAPriv; + volatile CARD32 *r128RingReadPtr; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr); + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); + + OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); + OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); + pSAREAPriv->ringWrite = 0; + *r128RingReadPtr = 0; + + /* Resetting the ring turns off the CCE */ + info->CCEInUse = FALSE; +} + +/* Start the CCE, but only if it is not already in use and the requested + mode is a CCE mode. The mode is stored in info->CCEMode. */ +void R128CCEStart(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + R128WaitForIdle(pScrn); + OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode | info->ringSizeLog2QW); + (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */ + OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); + info->CCEInUse = TRUE; +} + +/* Stop the CCE, but only if it is in use and the requested mode is not + the non-CCE mode. This function also flushes any outstanding + requests before switching modes.*/ +void R128CCEStop(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + R128CCEWaitForIdle(pScrn); + OUTREG(R128_PM4_MICRO_CNTL, 0); + OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); + R128EngineReset(pScrn); + info->CCEInUse = FALSE; +} + +/* Initialize the visual configs that are supported by the hardware. + These are combined with the visual configs that the indirect + rendering core supports, and the intersection is exported to the + client. */ +static Bool R128InitVisualConfigs(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = 0; + R128ConfigPrivPtr pR128Configs = 0; + R128ConfigPrivPtr *pR128ConfigPtrs = 0; + int i, accum, stencil; + + switch (info->CurrentLayout.pixel_code) { + case 8: /* 8bpp mode is not support */ + case 15: /* FIXME */ + case 24: /* FIXME */ + return FALSE; + +#define R128_USE_ACCUM 1 +#define R128_USE_STENCIL 1 + + case 16: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + if (R128_USE_STENCIL) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].alphaSize = 0; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0x00000000; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + pConfigs[i].depthSize = 16; + if (stencil) + pConfigs[i].stencilSize = 8; /* Simulated in software */ + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = GLX_NONE; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + break; + case 32: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + if (R128_USE_STENCIL) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].alphaSize = 8; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + pConfigs[i].alphaMask = 0xFF000000; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 16; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 24; + if (stencil) { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + } else { + pConfigs[i].depthSize = 32; + pConfigs[i].stencilSize = 0; + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = GLX_NONE; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + break; + } + + info->numVisualConfigs = numConfigs; + info->pVisualConfigs = pConfigs; + info->pVisualConfigsPriv = pR128Configs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs); + return TRUE; +} + +/* Create the Rage 128-specific context information */ +static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual, + drmContext hwContext, void *pVisualConfigPriv, + DRIContextType contextStore) +{ + /* Nothing yet */ + return TRUE; +} + +/* Destroy the Rage 128-specific context information */ +static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext, + DRIContextType contextStore) +{ + /* Nothing yet */ +} + +/* Called when the X server is woken up to allow the last client's + context to be saved and the X server's context to be loaded. This is + not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128EnterServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + if (info->accel) info->accel->NeedToSync = TRUE; + +#if 1 + if (!info->CCE2D) R128CCEStop(pScrn); +#else + if (info->CCE2D) R128CCEWaitForIdle(pScrn); + else R128CCEStop(pScrn); +#endif +} + +/* Called when the X server goes to sleep to allow the X server's + context to be saved and the last client's context to be loaded. This + is not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128LeaveServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + +#if 1 + if (!info->CCE2D) R128CCEStart(pScrn); +#else + if (info->CCE2D) R128CCEWaitForIdle(pScrn); + else R128CCEStart(pScrn); +#endif +} + +/* Contexts can be swapped by the X server if necessary. This callback + is currently only used to perform any functions necessary when + entering or leaving the X server, and in the future might not be + necessary. */ +static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ + R128EnterServer(pScreen); + } + if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ + R128LeaveServer(pScreen); + } +} + +/* Initialize the state of the back and depth buffers. */ +static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 indx) +{ + /* FIXME: This routine needs to have acceleration turned on */ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + BoxPtr pbox; + int nbox; + int depth; + + /* FIXME: Use accel when CCE 2D code is written */ + if (info->CCE2D) return; + + /* FIXME: This should be based on the __GLXvisualConfig info */ + switch (pScrn->bitsPerPixel) { + case 8: depth = 0x000000ff; break; + case 16: depth = 0x0000ffff; break; + case 24: depth = 0x00ffffff; break; + case 32: depth = 0xffffffff; break; + default: depth = 0x00000000; break; + } + + /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + pbox = REGION_RECTS(prgn); + nbox = REGION_NUM_RECTS(prgn); + + (*info->accel->SetupForSolidFill)(pScrn, 0, GXcopy, -1); + for (; nbox; nbox--, pbox++) { + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->fbX, + pbox->y1 + info->fbY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->backX, + pbox->y1 + info->backY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + } + + (*info->accel->SetupForSolidFill)(pScrn, depth, GXcopy, -1); + for (; nbox; nbox--, pbox++) + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->depthX, + pbox->y1 + info->depthY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + + info->accel->NeedToSync = TRUE; +} + +/* Copy the back and depth buffers when the X server moves a window. */ +static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr prgnSrc, CARD32 indx) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + /* FIXME: This routine needs to have acceleration turned on */ + /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + /* FIXME: Use accel when CCE 2D code is written */ + if (info->CCE2D) return; +} + +/* Initialize the AGP state. Request memory for use in AGP space, and + initialize the Rage 128 registers to point to that memory. */ +static Bool R128DRIAgpInit(R128InfoPtr info, ScreenPtr pScreen) +{ + unsigned char *R128MMIO = info->MMIO; + unsigned long mode; + unsigned int vendor, device; + int ret; + unsigned long cntl; + int s, l; + int flags; + + if (drmAgpAcquire(info->drmFD) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n"); + return FALSE; + } + + /* Modify the mode if the default mode is + not appropriate for this particular + combination of graphics card and AGP + chipset. */ + + mode = drmAgpGetMode(info->drmFD); /* Default mode */ + vendor = drmAgpVendorId(info->drmFD); + device = drmAgpDeviceId(info->drmFD); + + mode &= ~R128_AGP_MODE_MASK; + switch (info->agpMode) { + case 2: mode |= R128_AGP_2X_MODE; + case 1: default: mode |= R128_AGP_1X_MODE; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", + mode, vendor, device, + info->PciInfo->vendor, + info->PciInfo->chipType); + + if (drmAgpEnable(info->drmFD, mode) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n"); + drmAgpRelease(info->drmFD); + return FALSE; + } + + info->agpOffset = 0; + + if ((ret = drmAgpAlloc(info->drmFD, info->agpSize*1024*1024, 0, NULL, + &info->agpMemHandle)) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret); + drmAgpRelease(info->drmFD); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] %d kB allocated with handle 0x%08x\n", + info->agpSize*1024, info->agpMemHandle); + + if (drmAgpBind(info->drmFD, info->agpMemHandle, info->agpOffset) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n"); + drmAgpFree(info->drmFD, info->agpMemHandle); + drmAgpRelease(info->drmFD); + return FALSE; + } + + /* Initialize the CCE ring buffer data */ + info->ringStart = info->agpOffset; + info->ringMapSize = info->ringSize*1024*1024 + 4096; + info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1; + + info->ringReadOffset = info->ringStart + info->ringMapSize; + info->ringReadMapSize = 4096; + + /* Reserve space for the vertex buffer */ + info->vbStart = info->ringReadOffset + info->ringReadMapSize; + info->vbMapSize = info->vbSize*1024*1024; + + /* Reserve space for the indirect buffer */ + info->indStart = info->vbStart + info->vbMapSize; + info->indMapSize = info->indSize*1024*1024; + + /* Reserve the rest for AGP textures */ + info->agpTexStart = info->indStart + info->indMapSize; + s = (info->agpSize*1024*1024 - info->agpTexStart); + l = R128MinBits((s-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + info->agpTexMapSize = (s >> l) << l; + info->log2AGPTexGran = l; + + if (info->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + if (drmAddMap(info->drmFD, info->ringStart, info->ringMapSize, + DRM_AGP, flags, &info->ringHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring handle = 0x%08lx\n", info->ringHandle); + + if (drmMap(info->drmFD, info->ringHandle, info->ringMapSize, + (drmAddressPtr)&info->ring) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring mapped at 0x%08lx\n", + (unsigned long)info->ring); + + if (drmAddMap(info->drmFD, info->ringReadOffset, info->ringReadMapSize, + DRM_AGP, flags, &info->ringReadPtrHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring read ptr mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring read ptr handle = 0x%08lx\n", + info->ringReadPtrHandle); + + if (drmMap(info->drmFD, info->ringReadPtrHandle, info->ringReadMapSize, + (drmAddressPtr)&info->ringReadPtr) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map ring read ptr\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring read ptr mapped at 0x%08lx\n", + (unsigned long)info->ringReadPtr); + + if (drmAddMap(info->drmFD, info->vbStart, info->vbMapSize, + DRM_AGP, 0, &info->vbHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add vertex buffers mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] vertex buffers handle = 0x%08lx\n", info->vbHandle); + + if (drmMap(info->drmFD, info->vbHandle, info->vbMapSize, + (drmAddressPtr)&info->vb) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map vertex buffers\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Vertex buffers mapped at 0x%08lx\n", + (unsigned long)info->vb); + + if (drmAddMap(info->drmFD, info->indStart, info->indMapSize, + DRM_AGP, flags, &info->indHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add indirect buffers mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] indirect buffers handle = 0x%08lx\n", info->indHandle); + + if (drmMap(info->drmFD, info->indHandle, info->indMapSize, + (drmAddressPtr)&info->ind) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map indirect buffers\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Indirect buffers mapped at 0x%08lx\n", + (unsigned long)info->ind); + + if (drmAddMap(info->drmFD, info->agpTexStart, info->agpTexMapSize, + DRM_AGP, 0, &info->agpTexHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add AGP texture map mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP texture map handle = 0x%08lx\n", + info->agpTexHandle); + + if (drmMap(info->drmFD, info->agpTexHandle, info->agpTexMapSize, + (drmAddressPtr)&info->agpTex) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map AGP texture map\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP Texture map mapped at 0x%08lx\n", + (unsigned long)info->agpTex); + + /* Initialize Rage 128's AGP registers */ + cntl = INREG(R128_AGP_CNTL); + cntl &= ~R128_AGP_APER_SIZE_MASK; + switch (info->agpSize) { + case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; + case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; + case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; + case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; + case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; + case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; + case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; + default: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Illegal aperture size %d kB\n", + info->agpSize*1024); + return FALSE; + } + OUTREG(R128_AGP_BASE, info->ringHandle); /* Ring buf is at AGP offset 0 */ + OUTREG(R128_AGP_CNTL, cntl); + + return TRUE; +} + +/* Fake the vertex buffers for PCI cards. */ +static Bool R128DRIPciInit(R128InfoPtr info) +{ + info->vbStart = 0; + info->vbMapSize = info->vbSize*1024*1024; + + return TRUE; +} + +/* Add a map for the MMIO registers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIMapInit(R128InfoPtr info, ScreenPtr pScreen) +{ + int flags; + + if (info->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + /* Map registers */ + info->registerSize = R128_MMIOSIZE; + if (drmAddMap(info->drmFD, info->MMIOAddr, info->registerSize, + DRM_REGISTERS, flags, &info->registerHandle) < 0) { + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] register handle = 0x%08lx\n", info->registerHandle); + + return TRUE; +} + +/* Initialize the ring buffer state for use in the X server and any + DRI-based clients. */ +static void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + unsigned long addr; + + /* FIXME: When we use the CCE for the X server, we should move this + function (and the support functions above) to r128_accel.c */ + + /* The manual (p. 2) says this address is + in "VM space". This means it's an + offset from the start of AGP space. */ + OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000); + + OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); + OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); + + /* DL_RPTR_ADDR is a physical address. + This should be in the SAREA. */ + *(volatile long unsigned *)(info->ringReadPtr) = 0; + OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle)); + + /* Set watermark control */ + OUTREG(R128_PM4_BUFFER_WM_CNTL, + ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) + | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) + | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) + | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT)); + + addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's + in the examples... */ + +#if 0 + R128CCEWaitForIdle(pScrn); +#endif + + /* Turn on bus mastering */ + info->BusCntl &= ~R128_BUS_MASTER_DIS; + OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS); +} + +/* Initialize the kernel data structures. */ +static int R128DRIKernelInit(R128InfoPtr info) +{ + drmR128Init drmInfo; + + drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); + drmInfo.is_pci = info->IsPCI; + drmInfo.cce_mode = info->CCEMode; + drmInfo.cce_fifo_size = info->CCEFifoSize; + drmInfo.cce_secure = info->CCESecure; + drmInfo.ring_size = info->ringSize*1024*1024; + drmInfo.usec_timeout = info->CCEusecTimeout; + + drmInfo.fb_offset = info->LinearAddr; + drmInfo.agp_ring_offset = info->ringHandle; + drmInfo.agp_read_ptr_offset = info->ringReadPtrHandle; + drmInfo.agp_vertbufs_offset = info->vbHandle; + drmInfo.agp_indbufs_offset = info->indHandle; + drmInfo.agp_textures_offset = info->agpTexHandle; + drmInfo.mmio_offset = info->registerHandle; + + if (drmR128InitCCE(info->drmFD, &drmInfo) < 0) return FALSE; + + return TRUE; +} + +/* Add a map for the vertex buffers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIBufInit(R128InfoPtr info, ScreenPtr pScreen) +{ + /* Initialize vertex buffers */ + if ((info->vbNumBufs = drmAddBufs(info->drmFD, + info->vbMapSize / info->vbBufSize, + info->vbBufSize, + DRM_AGP_BUFFER, + info->vbStart)) <= 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Could not create vertex buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Added %d %d byte vertex buffers\n", + info->vbNumBufs, info->vbBufSize); + + if (drmMarkBufs(info->drmFD, 0.133333, 0.266666)) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to mark vertex buffers list\n"); + return FALSE; + } + + if (!(info->vbBufs = drmMapBufs(info->drmFD))) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to map vertex buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Mapped %d vertex buffers\n", + info->vbBufs->count); + + return TRUE; +} + +/* Load the microcode for the CCE */ +static void R128DRILoadMicrocode(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + unsigned long R128Microcode[] = { + /* CCE microcode (from ATI) */ + 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951, + 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0, + 596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2, + 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, + 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1, + 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200, + 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1, + 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1, + 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, + 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1, + 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1, + 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12, + 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16, + 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, + 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, + 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0, + 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1, + 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12, + 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3, + 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1, + 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, + 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1, + 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14, + 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1, + 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672, + 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, + 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, + 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1, + 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0, + 10240, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0 + }; + + R128WaitForIdle(pScrn); + + OUTREG(R128_PM4_MICROCODE_ADDR, 0); + for (i = 0; i < 256; i += 1) { + OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]); + OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]); + } +} + +/* Initialize the CCE state, and start the CCE (if used by the X server) */ +static void R128DRICCEInit(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + /* CCEMode is initialized in r128_driver.c */ + switch (info->CCEMode) { + case R128_PM4_NONPM4: info->CCEFifoSize = 0; break; + case R128_PM4_192PIO: info->CCEFifoSize = 192; break; + case R128_PM4_192BM: info->CCEFifoSize = 192; break; + case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break; + } + + if (info->CCE2D) { + /* Make sure the CCE is on for the X server */ + R128CCEStart(pScrn); + } else { + /* Make sure the CCE is off for the X server */ + OUTREG(R128_PM4_MICRO_CNTL, 0); + OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); + } +} + +/* Initialize the screen-specific data structures for the DRI and the + Rage 128. This is the main entry point to the device-specific + initialization code. It calls device-independent DRI functions to + create the DRI data structures and initialize the DRI state. */ +Bool R128DRIScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + DRIInfoPtr pDRIInfo; + R128DRIPtr pR128DRI; + int major, minor, patch; + drmVersionPtr version; + + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for known symbols in each module. */ + if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; + if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed (libdri.a too old)\n"); + return FALSE; + } + + /* Check the DRI version */ + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRI version = %d.%d.%d, expected 3.0.x). " + "Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + + switch (info->CurrentLayout.pixel_code) { + case 8: + /* These modes are not supported (yet). */ + case 15: + case 24: + return FALSE; + + /* Only 16 and 32 color depths are supports currently. */ + case 16: + case 32: + break; + } + + /* Create the DRI data structure, and fill it in before calling the + DRIScreenInit(). */ + if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; + + info->pDRIInfo = pDRIInfo; + pDRIInfo->drmDriverName = R128_DRIVER_NAME; + pDRIInfo->clientDriverName = R128_DRIVER_NAME; + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, + "PCI:%d:%d:%d", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR; + pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR; + pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH; + pDRIInfo->frameBufferPhysicalAddress = info->LinearAddr; + pDRIInfo->frameBufferSize = info->FbMapSize; + pDRIInfo->frameBufferStride = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES; + pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES + < R128_MAX_DRAWABLES + ? SAREA_MAX_DRAWABLES + : R128_MAX_DRAWABLES); + +#ifdef NOT_DONE + /* FIXME: Need to extend DRI protocol to pass this size back to + * client for SAREA mapping that includes a device private record + */ + pDRIInfo->SAREASize = + ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ + /* + shared memory device private rec */ +#else + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) { + ErrorF("Data does not fit in SAREA\n"); + return FALSE; + } + pDRIInfo->SAREASize = SAREA_MAX; +#endif + + if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) { + DRIDestroyInfoRec(info->pDRIInfo); + info->pDRIInfo = NULL; + return FALSE; + } + pDRIInfo->devPrivate = pR128DRI; + pDRIInfo->devPrivateSize = sizeof(R128DRIRec); + pDRIInfo->contextSize = sizeof(R128DRIContextRec); + + pDRIInfo->CreateContext = R128CreateContext; + pDRIInfo->DestroyContext = R128DestroyContext; + pDRIInfo->SwapContext = R128DRISwapContext; + pDRIInfo->InitBuffers = R128DRIInitBuffers; + pDRIInfo->MoveBuffers = R128DRIMoveBuffers; + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + + if (!DRIScreenInit(pScreen, pDRIInfo, &info->drmFD)) { + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = NULL; + DRIDestroyInfoRec(pDRIInfo); + pDRIInfo = NULL; + return FALSE; + } + + /* Check the r128 DRM version */ + version = drmGetVersion(info->drmFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRM version = %d.%d.%d, expected 1.0.x). " + "Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + drmFreeVersion(version); + R128DRICloseScreen(pScreen); + return FALSE; + } + drmFreeVersion(version); + } + + /* Initialize AGP */ + if (!info->IsPCI && !R128DRIAgpInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + /* Initialize PCI */ + if (info->IsPCI && !R128DRIPciInit(info)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* DRIScreenInit doesn't add all the + common mappings. Add additional + mappings here. */ + if (!R128DRIMapInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the ring buffer */ + if (!info->IsPCI) R128DRICCEInitRingBuffer(pScrn); + + /* Initialize the kernel data structures */ + if (!R128DRIKernelInit(info)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize vertex buffers list */ + if (!info->IsPCI && !R128DRIBufInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* FIXME: When are these mappings unmapped? */ + + if (!R128InitVisualConfigs(pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n"); + + /* Load the CCE Microcode */ + R128DRILoadMicrocode(pScrn); + + /* Reset the Graphics Engine */ + R128EngineReset(pScrn); + + return TRUE; +} + +/* Finish initializing the device-dependent DRI state, and call + DRIFinishScreenInit() to complete the device-independent DRI + initialization. */ +Bool R128DRIFinishScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + R128SAREAPrivPtr pSAREAPriv; + R128DRIPtr pR128DRI; + + /* Init and start the CCE */ + R128DRICCEInit(pScrn); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); + + info->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; + /* info->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ + + pR128DRI = (R128DRIPtr)info->pDRIInfo->devPrivate; + pR128DRI->registerHandle = info->registerHandle; + pR128DRI->registerSize = info->registerSize; + + pR128DRI->ringHandle = info->ringHandle; + pR128DRI->ringMapSize = info->ringMapSize; + pR128DRI->ringSize = info->ringSize*1024*1024; + + pR128DRI->ringReadPtrHandle = info->ringReadPtrHandle; + pR128DRI->ringReadMapSize = info->ringReadMapSize; + + pR128DRI->vbHandle = info->vbHandle; + pR128DRI->vbMapSize = info->vbMapSize; + pR128DRI->vbOffset = info->vbStart; + pR128DRI->vbBufSize = info->vbBufSize; + + pR128DRI->indHandle = info->indHandle; + pR128DRI->indMapSize = info->indMapSize; + + pR128DRI->agpTexHandle = info->agpTexHandle; + pR128DRI->agpTexMapSize = info->agpTexMapSize; + pR128DRI->log2AGPTexGran = info->log2AGPTexGran; + pR128DRI->agpTexOffset = info->agpTexStart; + + pR128DRI->deviceID = info->Chipset; + pR128DRI->width = pScrn->virtualX; + pR128DRI->height = pScrn->virtualY; + pR128DRI->depth = pScrn->depth; + pR128DRI->bpp = pScrn->bitsPerPixel; + + pR128DRI->fbX = info->fbX; + pR128DRI->fbY = info->fbY; + pR128DRI->backX = info->backX; + pR128DRI->backY = info->backY; + pR128DRI->depthX = info->depthX; + pR128DRI->depthY = info->depthY; + pR128DRI->textureX = info->textureX; + pR128DRI->textureY = info->textureY; + pR128DRI->textureSize = info->textureSize; + pR128DRI->log2TexGran = info->log2TexGran; + + pR128DRI->IsPCI = info->IsPCI; + + pR128DRI->CCEMode = info->CCEMode; + pR128DRI->CCEFifoSize = info->CCEFifoSize; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n", + pR128DRI->registerHandle, pR128DRI->registerSize); + return DRIFinishScreenInit(pScreen); +} + +/* The screen is being closed, so clean up any state and free any + resources used by the DRI. */ +void R128DRICloseScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + /* Stop the CCE if it is still in use */ + if (info->CCE2D) R128CCEStop(pScrn); + + /* De-allocate vertex buffers */ + if (info->vbBufs) { + drmUnmapBufs(info->vbBufs); + info->vbBufs = NULL; + } + + /* De-allocate all kernel resources */ + drmR128CleanupCCE(info->drmFD); + + /* De-allocate all AGP resources */ + if (info->agpTex) { + drmUnmap(info->agpTex, info->agpTexMapSize); + info->agpTex = NULL; + } + if (info->ind) { + drmUnmap(info->ind, info->indMapSize); + info->ind = NULL; + } + if (info->vb) { + drmUnmap(info->vb, info->vbMapSize); + info->vb = NULL; + } + if (info->ringReadPtr) { + drmUnmap(info->ringReadPtr, info->ringReadMapSize); + info->ringReadPtr = NULL; + } + if (info->ring) { + drmUnmap(info->ring, info->ringMapSize); + info->ring = NULL; + } + if (info->agpMemHandle) { + drmAgpUnbind(info->drmFD, info->agpMemHandle); + drmAgpFree(info->drmFD, info->agpMemHandle); + info->agpMemHandle = 0; + drmAgpRelease(info->drmFD); + } + + /* De-allocate all DRI resources */ + DRICloseScreen(pScreen); + + /* De-allocate all DRI data structures */ + if (info->pDRIInfo) { + if (info->pDRIInfo->devPrivate) { + xfree(info->pDRIInfo->devPrivate); + info->pDRIInfo->devPrivate = NULL; + } + DRIDestroyInfoRec(info->pDRIInfo); + info->pDRIInfo = NULL; + } + if (info->pVisualConfigs) { + xfree(info->pVisualConfigs); + info->pVisualConfigs = NULL; + } + if (info->pVisualConfigsPriv) { + xfree(info->pVisualConfigsPriv); + info->pVisualConfigsPriv = NULL; + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h new file mode 100644 index 000000000..d9cdda3aa --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h @@ -0,0 +1,115 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h,v 1.1 2000/11/02 16:55:33 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Rickard E. Faith <faith@precisioninsight.com> + * + */ + +#ifndef _R128_DRI_ +#define _R128_DRI_ + +#include <xf86drm.h> + +/* DRI Driver defaults */ +#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM +#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM +#define R128_DEFAULT_AGP_MODE 2 +#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */ +#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */ +#define R128_DEFAULT_VB_SIZE 1 /* MB (must be page aligned) */ +#define R128_DEFAULT_IND_SIZE 1 /* MB (must be page aligned) */ +#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */ + +#define R128_DEFAULT_VB_BUF_SIZE 16384 /* bytes */ +#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */ + +#define R128_AGP_MAX_MODE 2 + +#define R128CCE_USE_RING_BUFFER(m) \ +(((m) == R128_PM4_192BM) || \ + ((m) == R128_PM4_128BM_64INDBM) || \ + ((m) == R128_PM4_64BM_128INDBM) || \ + ((m) == R128_PM4_64BM_64VCBM_64INDBM)) + +typedef struct { + /* MMIO register data */ + drmHandle registerHandle; + drmSize registerSize; + + /* CCE ring buffer data */ + drmHandle ringHandle; + drmSize ringMapSize; + int ringSize; + + /* CCE ring read pointer data */ + drmHandle ringReadPtrHandle; + drmSize ringReadMapSize; + + /* CCE vertex buffer data */ + drmHandle vbHandle; + drmSize vbMapSize; + int vbOffset; + int vbBufSize; + + /* CCE indirect buffer data */ + drmHandle indHandle; + drmSize indMapSize; + + /* CCE AGP Texture data */ + drmHandle agpTexHandle; + drmSize agpTexMapSize; + int log2AGPTexGran; + int agpTexOffset; + + /* DRI screen private data */ + int deviceID; /* PCI device ID */ + int width; /* Width in pixels of display */ + int height; /* Height in scanlines of display */ + int depth; /* Depth of display (8, 15, 16, 24) */ + int bpp; /* Bit depth of display (8, 16, 24, 32) */ + + int fbX; /* Start of frame buffer */ + int fbY; + int backX; /* Start of shared back buffer */ + int backY; + int depthX; /* Start of shared depth buffer */ + int depthY; + int textureX; /* Start of texture data in frame buffer */ + int textureY; + int textureSize; + int log2TexGran; + + int IsPCI; /* Current card is a PCI card */ + + int CCEMode; /* CCE mode that server/clients use */ + int CCEFifoSize; /* Size of the CCE command FIFO */ +} R128DRIRec, *R128DRIPtr; + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h new file mode 100644 index 000000000..f26fe2bba --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h @@ -0,0 +1,53 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h,v 1.1 2000/11/02 16:55:34 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_DRIPRIV_H_ +#define _R128_DRIPRIV_H_ + +#define R128_MAX_DRAWABLES 256 + +extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, + void **configprivs); + +typedef struct { + /* Nothing here yet */ + int dummy; +} R128ConfigPrivRec, *R128ConfigPrivPtr; + +typedef struct { + /* Nothing here yet */ + int dummy; +} R128DRIContextRec, *R128DRIContextPtr; + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c new file mode 100644 index 000000000..008c1c553 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c @@ -0,0 +1,2839 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c,v 1.1 2000/11/02 16:55:35 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * Credits: + * + * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for + * providing source code to their 3.3.x Rage 128 driver. Portions of + * this file are based on the initialization code for that driver. + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * This server does not yet support these XFree86 4.0 features: + * DDC1 & DDC2 + * shadowfb + * overlay planes + * DGA + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "xf86fbman.h" +#include "xf86int10.h" + /* Backing store, software cursor, and + colormap initialization */ +#include "mibstore.h" +#include "mipointer.h" +#include "micmap.h" + +#define USE_FB /* not until overlays */ +#ifdef USE_FB +#include "fb.h" +#else + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" +#endif + /* Driver data structures */ +#include "r128.h" +#include "r128_probe.h" +#include "r128_reg.h" +#include "r128_version.h" + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + + + /* Forward definitions for driver functions */ +static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool R128SaveScreen(ScreenPtr pScreen, int mode); +static void R128Save(ScrnInfoPtr pScrn); +static void R128Restore(ScrnInfoPtr pScrn); +static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags); +static Bool R128EnterVTFBDev(int scrnIndex, int flags); +static void R128LeaveVTFBDev(int scrnIndex, int flags); + +typedef enum { + OPTION_NOACCEL, + OPTION_SW_CURSOR, + OPTION_DAC_6BIT, + OPTION_DAC_8BIT, +#ifdef XF86DRI + OPTION_IS_PCI, + OPTION_CCE_PIO, + OPTION_NO_SECURITY, + OPTION_USEC_TIMEOUT, + OPTION_AGP_MODE, + OPTION_AGP_SIZE, + OPTION_RING_SIZE, + OPTION_VERT_SIZE, + OPTION_VBUF_SIZE, + OPTION_USE_CCE_2D, +#endif +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + OPTION_CRT, +#endif + OPTION_PANEL_WIDTH, + OPTION_PANEL_HEIGHT, + OPTION_PROG_FP_REGS, + OPTION_FBDEV +} R128Opts; + +OptionInfoRec R128Options[] = { + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +#ifdef XF86DRI + { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE }, +#endif +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PROG_FP_REGS, "ProgramFPRegs", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +R128RAMRec R128RAM[] = { /* Memory Specifications + From RAGE 128 Software Development + Manual (Technical Reference Manual P/N + SDK-G04000 Rev 0.01), page 3-21. */ + { 4, 4, 3, 3, 1, 3, 1, 16, 12, "128-bit SDR SGRAM 1:1" }, + { 4, 8, 3, 3, 1, 3, 1, 17, 13, "64-bit SDR SGRAM 1:1" }, + { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SGRAM 2:1" }, + { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SGRAM" }, +}; + +static const char *vgahwSymbols[] = { + "vgaHWGetHWRec", + "vgaHWFreeHWRec", + "vgaHWLock", + "vgaHWUnlock", + "vgaHWSave", + "vgaHWRestore", + NULL +}; + +static const char *fbdevHWSymbols[] = { + "fbdevHWInit", + "fbdevHWUseBuildinMode", + + "fbdevHWGetDepth", + "fbdevHWGetVidmem", + + /* colormap */ + "fbdevHWLoadPalette", + + /* ScrnInfo hooks */ + "fbdevHWSwitchMode", + "fbdevHWAdjustFrame", + "fbdevHWEnterVT", + "fbdevHWLeaveVT", + "fbdevHWValidMode", + "fbdevHWRestore", + "fbdevHWModeInit", + "fbdevHWSave", + + "fbdevHWUnmapMMIO", + "fbdevHWUnmapVidmem", + "fbdevHWMapMMIO", + "fbdevHWMapVidmem", + + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +#ifdef XFree86LOADER +#ifdef USE_FB +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; +#else +static const char *cfbSymbols[] = { + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb32ScreenInit", + "cfb24_32ScreenInit", + NULL +}; +#endif + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAStippleScanlineFuncLSBFirst", + "XAAOverlayFBfuncs", + "XAACachePlanarMonoStipple", + "XAAScreenIndex", + NULL +}; + +static const char *xf8_32bppSymbols[] = { + "xf86Overlay8Plus32Init", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmGetInterruptFromBusID", + "drmMapBufs", + "drmMarkBufs", + "drmUnmapBufs", + "drmFreeVersion", + "drmGetVersion", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "DRIQueryVersion", + "GlxSetVisualConfigs", + NULL +}; +#endif + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + NULL +}; +#endif + +/* Allocate our private R128InfoRec. */ +static Bool R128GetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(R128InfoRec), 1); + return TRUE; +} + +/* Free our private R128InfoRec. */ +static void R128FreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn || !pScrn->driverPrivate) return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* Memory map the MMIO region. Used during pre-init and by R128MapMem, + below. */ +static Bool R128MapMMIO(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) { + info->MMIO = fbdevHWMapMMIO(pScrn); + } else { + info->MMIO = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, + info->PciTag, + info->MMIOAddr, + R128_MMIOSIZE); + } + + if (!info->MMIO) return FALSE; + return TRUE; +} + +/* Unmap the MMIO region. Used during pre-init and by R128UnmapMem, + below. */ +static Bool R128UnmapMMIO(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapMMIO(pScrn); + else { + xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, R128_MMIOSIZE); + } + info->MMIO = NULL; + return TRUE; +} + +/* Memory map the frame buffer. Used by R128MapMem, below. */ +static Bool R128MapFB(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) { + info->FB = fbdevHWMapVidmem(pScrn); + } else { + info->FB = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_FRAMEBUFFER, + info->PciTag, + info->LinearAddr, + info->FbMapSize); + } + + if (!info->FB) return FALSE; + return TRUE; +} + +/* Unmap the frame buffer. Used by R128UnmapMem, below. */ +static Bool R128UnmapFB(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapVidmem(pScrn); + else + xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); + info->FB = NULL; + return TRUE; +} + +/* Memory map the MMIO region and the frame buffer. */ +static Bool R128MapMem(ScrnInfoPtr pScrn) +{ + if (!R128MapMMIO(pScrn)) return FALSE; + if (!R128MapFB(pScrn)) { + R128UnmapMMIO(pScrn); + return FALSE; + } + return TRUE; +} + +/* Unmap the MMIO region and the frame buffer. */ +static Bool R128UnmapMem(ScrnInfoPtr pScrn) +{ + if (!R128UnmapMMIO(pScrn) || !R128UnmapFB(pScrn)) return FALSE; + return TRUE; +} + +/* Read PLL information */ +int R128INPLL(ScrnInfoPtr pScrn, int addr) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); + return INREG(R128_CLOCK_CNTL_DATA); +} + +#if 0 +/* Read PAL information (only used for debugging). */ +static int R128INPAL(int idx) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_PALETTE_INDEX, idx << 16); + return INREG(R128_PALETTE_DATA); +} +#endif + +/* Wait for vertical sync. */ +void R128WaitForVerticalSync(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + OUTREG(R128_GEN_INT_STATUS, R128_VSYNC_INT_AK); + for (i = 0; i < R128_TIMEOUT; i++) { + if (INREG(R128_GEN_INT_STATUS) & R128_VSYNC_INT) break; + } +} + +/* Blank screen. */ +static void R128Blank(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_EXT_CNTL, R128_CRTC_DISPLAY_DIS, ~R128_CRTC_DISPLAY_DIS); +} + +/* Unblank screen. */ +static void R128Unblank(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_EXT_CNTL, 0, ~R128_CRTC_DISPLAY_DIS); +} + +/* Compute log base 2 of val. */ +int R128MinBits(int val) +{ + int bits; + + if (!val) return 1; + for (bits = 0; val; val >>= 1, ++bits); + return bits; +} + +/* Compute n/d with rounding. */ +static int R128Div(int n, int d) +{ + return (n + (d / 2)) / d; +} + +/* Read the Video BIOS block and the FP registers (if applicable). */ +static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + int i; + int FPHeader = 0; + +#define R128ReadBIOS(offset, buffer, length) \ + (info->BIOSFromPCI ? \ + xf86ReadPciBIOS(offset, info->PciTag, 0, buffer, length) : \ + xf86ReadBIOS(info->BIOSAddr, offset, buffer, length)) + +#define R128_BIOS8(v) (info->VBIOS[v]) +#define R128_BIOS16(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8)) +#define R128_BIOS32(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8) | \ + (info->VBIOS[(v) + 2] << 16) | \ + (info->VBIOS[(v) + 3] << 24)) + + if (!(info->VBIOS = xalloc(R128_VBIOS_SIZE))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate space for hold Video BIOS!\n"); + return FALSE; + } + + info->BIOSFromPCI = TRUE; + R128ReadBIOS(0x0000, info->VBIOS, R128_VBIOS_SIZE); + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected in PCI space!\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Attempting to read Video BIOS from legacy ISA space!\n"); + info->BIOSFromPCI = FALSE; + info->BIOSAddr = 0x000c0000; + R128ReadBIOS(0x0000, info->VBIOS, R128_VBIOS_SIZE); + } + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + info->BIOSAddr = 0x00000000; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not found!\n"); + } + + if (info->HasPanelRegs) { + info->FPBIOSstart = 0; + + /* FIXME: There should be direct access to the start of the FP info + tables, but until we find out where that offset is stored, we + must search for the ATI signature string: "M3 ". */ + for (i = 4; i < R128_VBIOS_SIZE-8; i++) { + if (R128_BIOS8(i) == 'M' && + R128_BIOS8(i+1) == '3' && + R128_BIOS8(i+2) == ' ' && + R128_BIOS8(i+3) == ' ' && + R128_BIOS8(i+4) == ' ' && + R128_BIOS8(i+5) == ' ' && + R128_BIOS8(i+6) == ' ' && + R128_BIOS8(i+7) == ' ') { + FPHeader = i-2; + break; + } + } + + if (!FPHeader) return TRUE; + + /* Assume that only one panel is attached and supported */ + for (i = FPHeader+20; i < FPHeader+84; i += 2) { + if (R128_BIOS16(i) != 0) { + info->FPBIOSstart = R128_BIOS16(i); + break; + } + } + if (!info->FPBIOSstart) return TRUE; + + if (!info->PanelXRes) + info->PanelXRes = R128_BIOS16(info->FPBIOSstart+25); + if (!info->PanelYRes) + info->PanelYRes = R128_BIOS16(info->FPBIOSstart+27); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel size: %dx%d\n", + info->PanelXRes, info->PanelYRes); + + info->PanelPwrDly = R128_BIOS8(info->FPBIOSstart+56); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel ID: "); + for (i = 1; i <= 24; i++) + ErrorF("%c", R128_BIOS8(info->FPBIOSstart+i)); + ErrorF("\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Type: "); + i = R128_BIOS16(info->FPBIOSstart+29); + if (i & 1) ErrorF("Color, "); + else ErrorF("Monochrome, "); + if (i & 2) ErrorF("Dual(split), "); + else ErrorF("Single, "); + switch ((i >> 2) & 0x3f) { + case 0: ErrorF("STN"); break; + case 1: ErrorF("TFT"); break; + case 2: ErrorF("Active STN"); break; + case 3: ErrorF("EL"); break; + case 4: ErrorF("Plasma"); break; + default: ErrorF("UNKNOWN"); break; + } + ErrorF("\n"); + if (R128_BIOS8(info->FPBIOSstart+61) & 1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Interface: LVDS\n"); + } else { + /* FIXME: Add Non-LVDS flat pael support */ + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Non-LVDS panel interface detected! " + "This support is untested and may not " + "function properly\n"); + } + } + + return TRUE; +} + +/* Read PLL parameters from BIOS block. Default to typical values if there + is no BIOS. */ +static Bool R128GetPLLParameters(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + R128PLLPtr pll = &info->pll; + CARD16 bios_header; + CARD16 pll_info_block; + + + if (!info->VBIOS) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected, using default PLL parameters!\n"); + /* These probably aren't going to work for + the card you are using. Specifically, + reference freq can be 29.50MHz, + 28.63MHz, or 14.32MHz. YMMV. */ + pll->reference_freq = 2950; + pll->reference_div = 65; + pll->min_pll_freq = 12500; + pll->max_pll_freq = 25000; + pll->xclk = 10300; + } else { + bios_header = R128_BIOS16(0x48); + pll_info_block = R128_BIOS16(bios_header + 0x30); + R128TRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", + bios_header, pll_info_block)); + + pll->reference_freq = R128_BIOS16(pll_info_block + 0x0e); + pll->reference_div = R128_BIOS16(pll_info_block + 0x10); + pll->min_pll_freq = R128_BIOS32(pll_info_block + 0x12); + pll->max_pll_freq = R128_BIOS32(pll_info_block + 0x16); + pll->xclk = R128_BIOS16(pll_info_block + 0x08); + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PLL parameters: rf=%d rd=%d min=%d max=%d; xclk=%d\n", + pll->reference_freq, + pll->reference_div, + pll->min_pll_freq, + pll->max_pll_freq, + pll->xclk); + + return TRUE; +} + +/* This is called by R128PreInit to set up the default visual. */ +static Bool R128PreInitVisual(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, (Support24bppFb + | Support32bppFb + | SupportConvert32to24 + ))) + return FALSE; + + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by %s driver\n", + pScrn->depth, R128_DRIVER_NAME); + return FALSE; + } + + xf86PrintDepthBpp(pScrn); + + info->fifo_slots = 0; + info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); + info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; + info->CurrentLayout.depth = pScrn->depth; + info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 + ? pScrn->bitsPerPixel + : pScrn->depth); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", + pScrn->depth, + info->CurrentLayout.pixel_bytes, + info->CurrentLayout.pixel_bytes > 1 ? "s" : "", + info->pix24bpp); + + + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; + + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Default visual (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + return TRUE; + +} + +/* This is called by R128PreInit to handle all color weight issues. */ +static Bool R128PreInitWeight(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + /* Save flag for 6 bit DAC to use for + setting CRTC registers. Otherwise use + an 8 bit DAC, even if xf86SetWeight sets + pScrn->rgbBits to some value other than + 8. */ + info->dac6bits = FALSE; + if (pScrn->depth > 8) { + rgb defaultWeight = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + } else { + pScrn->rgbBits = 8; + if (xf86ReturnOptValBool(R128Options, OPTION_DAC_6BIT, FALSE)) { + pScrn->rgbBits = 6; + info->dac6bits = TRUE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d bits per RGB (%d bit DAC)\n", + pScrn->rgbBits, info->dac6bits ? 6 : 8); + + return TRUE; + +} + +/* This is called by R128PreInit to handle config file overrides for things + like chipset and memory regions. Also determine memory size and type. + If memory type ever needs an override, put it in this routine. */ +static Bool R128PreInitConfig(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + EntityInfoPtr pEnt = info->pEnt; + GDevPtr dev = pEnt->device; + int offset = 0; /* RAM Type */ + MessageType from; + + /* Chipset */ + from = X_PROBED; + if (dev->chipset && *dev->chipset) { + info->Chipset = xf86StringToToken(R128Chipsets, dev->chipset); + from = X_CONFIG; + } else if (dev->chipID >= 0) { + info->Chipset = dev->chipID; + from = X_CONFIG; + } else { + info->Chipset = info->PciInfo->chipType; + } + pScrn->chipset = (char *)xf86TokenToString(R128Chipsets, info->Chipset); + + if (!pScrn->chipset) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04x is not recognized\n", info->Chipset); + return FALSE; + } + + if (info->Chipset < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognized\n", pScrn->chipset); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, + "Chipset: \"%s\" (ChipID = 0x%04x)\n", + pScrn->chipset, + info->Chipset); + + /* Framebuffer */ + + from = X_PROBED; + info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; + if (dev->MemBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Linear address override, using 0x%08x instead of 0x%08x\n", + dev->MemBase, + info->LinearAddr); + info->LinearAddr = dev->MemBase; + from = X_CONFIG; + } else if (!info->LinearAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "No valid linear framebuffer address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "Linear framebuffer at 0x%08lx\n", info->LinearAddr); + + /* MMIO registers */ + from = X_PROBED; + info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; + if (dev->IOBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "MMIO address override, using 0x%08x instead of 0x%08x\n", + dev->IOBase, + info->MMIOAddr); + info->MMIOAddr = dev->IOBase; + from = X_CONFIG; + } else if (!info->MMIOAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid MMIO address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "MMIO registers at 0x%08lx\n", info->MMIOAddr); + + /* BIOS */ + from = X_PROBED; + info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; + if (dev->BiosBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BIOS address override, using 0x%08x instead of 0x%08x\n", + dev->BiosBase, + info->BIOSAddr); + info->BIOSAddr = dev->BiosBase; + from = X_CONFIG; + } + if (info->BIOSAddr) { + xf86DrvMsg(pScrn->scrnIndex, from, + "BIOS at 0x%08lx\n", info->BIOSAddr); + } + + /* Flat panel (part 1) */ + if (xf86GetOptValBool(R128Options, OPTION_PROG_FP_REGS, + &info->HasPanelRegs)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Turned flat panel register programming %s\n", + info->HasPanelRegs ? "on" : "off"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "\n\nWARNING: Forcing the driver to use/not use the flat panel registers\nmight damage your flat panel. Use at your *OWN* *RISK*.\n\n"); + } else { + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: info->HasPanelRegs = TRUE; break; + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RK: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->HasPanelRegs = FALSE; break; + } + } + + /* Read registers used to determine options */ + from = X_PROBED; + R128MapMMIO(pScrn); + R128MMIO = info->MMIO; + if (info->FBDev) + pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; + else + pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024; + info->MemCntl = INREG(R128_MEM_CNTL); + + info->BusCntl = INREG(R128_BUS_CNTL); + R128MMIO = NULL; + R128UnmapMMIO(pScrn); + + /* RAM */ + switch (info->MemCntl & 0x3) { + case 0: /* SDR SGRAM 1:1 */ + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RF: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */ + case PCI_CHIP_RAGE128RK: + case PCI_CHIP_RAGE128RL: + default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ + } + break; + case 1: offset = 2; break; /* 64-bit SDR SGRAM 2:1 */ + case 2: offset = 3; break; /* 64-bit DDR SGRAM */ + default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ + } + info->ram = &R128RAM[offset]; + + if (dev->videoRam) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Video RAM override, using %d kB instead of %d kB\n", + dev->videoRam, + pScrn->videoRam); + from = X_CONFIG; + pScrn->videoRam = dev->videoRam; + } + pScrn->videoRam &= ~1023; + info->FbMapSize = pScrn->videoRam * 1024; + xf86DrvMsg(pScrn->scrnIndex, from, + "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); + + /* Flat panel (part 2) */ + if (info->HasPanelRegs) { +#if 1 + info->CRTOnly = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); +#else + /* Panel CRT mode override */ + if ((info->CRTOnly = xf86ReturnOptValBool(R128Options, + OPTION_CRT, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using external CRT instead of " + "flat panel for display\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); + } +#endif + + /* Panel width/height overrides */ + info->PanelXRes = 0; + info->PanelYRes = 0; + if (xf86GetOptValInteger(R128Options, + OPTION_PANEL_WIDTH, &(info->PanelXRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel width: %d\n", info->PanelXRes); + } + if (xf86GetOptValInteger(R128Options, + OPTION_PANEL_HEIGHT, &(info->PanelYRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel height: %d\n", info->PanelYRes); + } + } else { + info->CRTOnly = FALSE; + } + +#ifdef XF86DRI + /* AGP/PCI */ + if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) { + info->IsPCI = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); + } else { + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break; + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->IsPCI = FALSE; break; + } + } +#endif + + return TRUE; +} + +static Bool R128PreInitDDC(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + vbeInfoPtr pVbe; + + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; + xf86LoaderReqSymLists(ddcSymbols, NULL); + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; +} + +/* This is called by R128PreInit to initialize gamma correction. */ +static Bool R128PreInitGamma(ScrnInfoPtr pScrn) +{ + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) return FALSE; + return TRUE; +} + +/* This is called by R128PreInit to validate modes and compute parameters + for all of the valid modes. */ +static Bool R128PreInitModes(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + ClockRangePtr clockRanges; + int modesFound; + char *mod = NULL; + const char *Sym = NULL; + + /* Get mode information */ + pScrn->progClock = TRUE; + clockRanges = xnfcalloc(sizeof(*clockRanges), 1); + clockRanges->next = NULL; + clockRanges->minClock = info->pll.min_pll_freq; + clockRanges->maxClock = info->pll.max_pll_freq * 10; + clockRanges->clockIndex = -1; + if (info->HasPanelRegs) { + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + } else { + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + } + + modesFound = xf86ValidateModes(pScrn, + pScrn->monitor->Modes, + pScrn->display->modes, + clockRanges, + NULL, /* linePitches */ + 8 * 64, /* minPitch */ + 8 * 1024, /* maxPitch */ + 64 * pScrn->bitsPerPixel, /* pitchInc */ + 128, /* minHeight */ + 2048, /* maxHeight */ + pScrn->virtualX, + pScrn->virtualY, + info->FbMapSize, + LOOKUP_BEST_REFRESH); + + if (modesFound < 1 && info->FBDev) { + fbdevHWUseBuildinMode(pScrn); + pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ + modesFound = 1; + } + + if (modesFound == -1) return FALSE; + xf86PruneDriverModes(pScrn); + if (!modesFound || !pScrn->modes) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + return FALSE; + } + xf86SetCrtcForModes(pScrn, 0); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + + /* Set DPI */ + xf86SetDpi(pScrn, 0, 0); + + /* Get ScreenInit function */ +#ifdef USE_FB + mod = "fb"; + Sym = "fbScreenInit"; +#else + switch (pScrn->bitsPerPixel) { + case 8: mod = "cfb"; Sym = "cfbScreenInit"; break; + case 16: mod = "cfb16"; Sym = "cfb16ScreenInit"; break; + case 24: + if (info->pix24bpp == 24) { + mod = "cfb24"; Sym = "cfb24ScreenInit"; + } else { + mod = "xf24_32bpp"; Sym = "cfb24_32ScreenInit"; + } + break; + case 32: mod = "cfb32"; Sym = "cfb32ScreenInit"; break; + } +#endif + if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; + xf86LoaderReqSymbols(Sym, NULL); +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif + + info->CurrentLayout.displayWidth = pScrn->displayWidth; + info->CurrentLayout.mode = pScrn->currentMode; + + return TRUE; +} + +/* This is called by R128PreInit to initialize the hardware cursor. */ +static Bool R128PreInitCursor(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { + if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; + } + return TRUE; +} + +/* This is called by R128PreInit to initialize hardware acceleration. */ +static Bool R128PreInitAccel(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; + } + return TRUE; +} + +static Bool R128PreInitInt10(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); +#if 1 + if (xf86LoadSubModule(pScrn, "int10")) { + xf86Int10InfoPtr pInt; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); + pInt = xf86InitInt10(info->pEnt->index); + xf86FreeInt10(pInt); + } +#endif + return TRUE; +} + +#ifdef XF86DRI +static Bool R128PreInitDRI(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->IsPCI) { + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CCE into PIO mode\n"); + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else { + info->CCEMode = R128_DEFAULT_CCE_BM_MODE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n"); + info->CCE2D = TRUE; + } else { + info->CCE2D = FALSE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CCE Security checks disabled!!! **********\n"); + info->CCESecure = FALSE; + } else { + info->CCESecure = TRUE; + } + + info->agpMode = R128_DEFAULT_AGP_MODE; + info->agpSize = R128_DEFAULT_AGP_SIZE; + info->ringSize = R128_DEFAULT_RING_SIZE; + info->vbSize = R128_DEFAULT_VB_SIZE; + info->indSize = R128_DEFAULT_IND_SIZE; + info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; + + info->vbBufSize = R128_DEFAULT_VB_BUF_SIZE; + + info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; + + if (!info->IsPCI) { + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_MODE, &(info->agpMode))) { + if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP Mode: %d\n", info->agpMode); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using AGP %dx mode\n", info->agpMode); + } + + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_SIZE, (int *)&(info->agpSize))) { + switch (info->agpSize) { + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP size: %d MB\n", info->agpSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_RING_SIZE, &(info->ringSize))) { + if (info->ringSize < 1 || info->ringSize >= (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal ring buffer size: %d MB\n", + info->ringSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_VERT_SIZE, &(info->vbSize))) { + if (info->vbSize < 1 || info->vbSize >= (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex buffers list size: %d MB\n", + info->vbSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_VBUF_SIZE, &(info->vbBufSize))) { + int numBufs = info->vbSize*1024*1024/info->vbBufSize; + if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal individual vertex buffer size: %d bytes\n", + info->vbBufSize); + return FALSE; + } + } + + if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize > + (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Buffers are too big for requested AGP space\n"); + return FALSE; + } + + info->agpTexSize = info->agpSize - (info->ringSize + + info->vbSize + + info->indSize); + } + + if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT, + &(info->CCEusecTimeout))) { + /* This option checked by the R128 DRM kernel module */ + } + + return TRUE; +} +#endif + +static void +R128ProbeDDC(ScrnInfoPtr pScrn, int indx) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,indx); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + +/* R128PreInit is called once at server startup. */ +Bool R128PreInit(ScrnInfoPtr pScrn, int flags) +{ + R128InfoPtr info; + + R128TRACE(("R128PreInit\n")); + +#ifdef XFree86LOADER + /* + * Tell the loader about symbols from other modules that this module might + * refer to. + */ + LoaderRefSymLists(vgahwSymbols, +#ifdef USE_FB + fbSymbols, +#else + cfbSymbols, +#endif + xaaSymbols, + xf8_32bppSymbols, + ramdacSymbols, +#ifdef XF86DRI + drmSymbols, + driSymbols, +#endif + fbdevHWSymbols, + vbeSymbols, + /* ddcsymbols, */ + /* i2csymbols, */ + /* shadowSymbols, */ + NULL); +#endif + + if (pScrn->numEntities != 1) return FALSE; + + if (!R128GetRec(pScrn)) return FALSE; + + info = R128PTR(pScrn); + + info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (info->pEnt->location.type != BUS_PCI) goto fail; + + if (flags & PROBE_DETECT) { + R128ProbeDDC(pScrn, info->pEnt->index); + return TRUE; + } + + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + xf86LoaderReqSymLists(vgahwSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) { + R128FreeRec(pScrn); + return FALSE; + } + + info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); + info->PciTag = pciTag(info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PCI bus %d card %d func %d\n", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + + if (!R128PreInitVisual(pScrn)) goto fail; + + /* We can't do this until we have a + pScrn->display. */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, R128Options); + + if (!R128PreInitWeight(pScrn)) goto fail; + + if (xf86ReturnOptValBool(R128Options, OPTION_FBDEV, FALSE)) { + info->FBDev = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using framebuffer device\n"); + } + + if (info->FBDev) { + /* check for linux framebuffer device */ + if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; + xf86LoaderReqSymLists(fbdevHWSymbols, NULL); + if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; + pScrn->SwitchMode = fbdevHWSwitchMode; + pScrn->AdjustFrame = fbdevHWAdjustFrame; + pScrn->EnterVT = R128EnterVTFBDev; + pScrn->LeaveVT = R128LeaveVTFBDev; + pScrn->ValidMode = fbdevHWValidMode; + } + + if (!info->FBDev) + if (!R128PreInitInt10(pScrn)) goto fail; + + if (!R128PreInitConfig(pScrn)) goto fail; + + if (!R128GetBIOSParameters(pScrn)) goto fail; + + if (!R128GetPLLParameters(pScrn)) goto fail; + + if (!R128PreInitDDC(pScrn)) goto fail; + + if (!R128PreInitGamma(pScrn)) goto fail; + + if (!R128PreInitModes(pScrn)) goto fail; + + if (!R128PreInitCursor(pScrn)) goto fail; + + if (!R128PreInitAccel(pScrn)) goto fail; + +#ifdef XF86DRI + if (!R128PreInitDRI(pScrn)) goto fail; +#endif + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + return TRUE; + + fail: + /* Pre-init failed. */ + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + vgaHWFreeHWRec(pScrn); + R128FreeRec(pScrn); + return FALSE; +} + +/* Load a palette. */ +static void R128LoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + int idx; + unsigned char r, g, b; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + if (info->CurrentLayout.depth == 15) { + /* 15bpp mode. This sends 32 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + g = colors[idx].green; + b = colors[idx].blue; + OUTPAL(idx * 8, r, g, b); + } + } + else if (info->CurrentLayout.depth == 16) { + /* 16bpp mode. This sends 64 values. */ + /* There are twice as many green values as + there are values for red and blue. So, + we take each red and blue pair, and + combine it with each of the two green + values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx / 2].red; + g = colors[idx].green; + b = colors[idx / 2].blue; + OUTPAL(idx * 4, r, g, b); + } + } + else { + /* 8bpp mode. This sends 256 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + b = colors[idx].blue; + g = colors[idx].green; + OUTPAL(idx, r, g, b); + } + } +} + +/* Called at the start of each server generation. */ +Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + BoxRec MemBox; + int y2; + + R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); + +#ifdef XF86DRI + /* Turn off the CCE for now. */ + info->CCEInUse = FALSE; +#endif + + if (!R128MapMem(pScrn)) return FALSE; + pScrn->fbOffset = 0; +#ifdef XF86DRI + info->fbX = 0; + info->fbY = 0; +#endif + + info->PaletteSavedOnVT = FALSE; + + R128Save(pScrn); + if (info->FBDev) { + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; + } else { + if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; + } + + R128SaveScreen(pScreen, SCREEN_SAVER_ON); + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* Visual setup */ + miClearVisualTypes(); + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, + pScrn->defaultVisual)) return FALSE; + miSetPixmapDepths (); + +#ifdef XF86DRI + /* Setup DRI after visuals have been + established, but before cfbScreenInit is + called. cfbScreenInit will eventually + call the driver's InitGLXVisuals call + back. */ + { + /* FIXME: When we move to dynamic allocation of back and depth + buffers, we will want to revisit the following check for 3 + times the virtual size of the screen below. */ + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE) && + (maxy > pScrn->virtualY * 3) +#if 0 + /* FIXME: Disable 3D support for FPs until it is tested */ + && !info->HasPanelRegs +#endif + ) { + info->directRenderingEnabled = R128DRIScreenInit(pScreen); + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Static buffer allocation failed -- " + "need at least %d kB video memory\n", + (pScrn->displayWidth * pScrn->virtualY * + info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024); + info->directRenderingEnabled = FALSE; + } + } +#endif + +#ifdef USE_FB + if (!fbScreenInit (pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel)) + return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif +#else + switch (pScrn->bitsPerPixel) { + case 8: + if (!cfbScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 16: + if (!cfb16ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 24: + if (info->pix24bpp == 24) { + if (!cfb24ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return FALSE; + } else { + if (!cfb24_32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return FALSE; + } + break; + case 32: + if (!cfb32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Invalid bpp (%d)\n", pScrn->bitsPerPixel); + return FALSE; + } +#endif + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr visual; + + for (visual = pScreen->visuals + pScreen->numVisuals; + visual >= pScreen->visuals; + visual--) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + R128DGAInit(pScreen); + + /* Memory manager setup */ + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + y2 = (info->FbMapSize + / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes)); + if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */ + MemBox.y2 = y2; + + /* The acceleration engine uses 14 bit + signed coordinates, so we can't have any + drawable caches beyond this region. */ + if (MemBox.y2 > 8191) MemBox.y2 = 8191; + + if (!xf86InitFBManager(pScreen, &MemBox)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + return FALSE; + } else { + int width, height; + FBAreaPtr fbarea; + + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + 2, 0, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved area from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); + } + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } + +#ifdef XF86DRI + /* Allocate frame buffer space for the + shared back and depth buffers as well + as for local textures. */ + if (info->directRenderingEnabled) { + FBAreaPtr fbarea; + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + int l; + + switch (info->CCEMode) { + case R128_DEFAULT_CCE_PIO_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in PIO mode\n"); + break; + case R128_DEFAULT_CCE_BM_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in BM mode\n"); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in UNKNOWN mode\n"); + break; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB AGP aperture\n", info->agpSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for the ring buffer\n", info->ringSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for vertex buffers\n", info->vbSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for indirect buffers\n", info->indSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for AGP textures\n", info->agpTexSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d byte vertex buffers\n", info->vbBufSize); + + /* Allocate the shared back buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved back buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->backX = fbarea->box.x1; + info->backY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); + info->backX = -1; + info->backY = -1; + } + + /* Allocate the shared depth buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->depthX = fbarea->box.x1; + info->depthY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); + info->depthX = -1; + info->depthY = -1; + } + + /* Allocate local texture space */ + if (((maxy - MemBox.y2 - 1) * width_bytes) > + (pScrn->virtualX * pScrn->virtualY * 2 * + info->CurrentLayout.pixel_bytes)) { + info->textureX = 0; + info->textureY = MemBox.y2 + 1; + info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes; + + l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + info->textureX, info->textureY, + pScrn->displayWidth, maxy); + } else if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY * 2, + 32, + NULL, NULL, NULL))) { + info->textureX = fbarea->box.x1; + info->textureY = fbarea->box.y1; + info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) * + (fbarea->box.x2 - fbarea->box.x1) * + info->CurrentLayout.pixel_bytes); + + l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve texture space in frame buffer\n"); + info->textureX = -1; + info->textureY = -1; + } + } +#endif + + /* Backing store setup */ + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + /* Set Silken Mouse */ + xf86SetSilkenMouse(pScreen); + + /* Acceleration setup */ + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { + if (R128AccelInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); + info->accelOn = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Acceleration initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + + /* Cursor setup */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Hardware cursor setup */ + if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { + if (R128CursorInit(pScreen)) { + int width, height; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using hardware cursor (scanline %d)\n", + info->cursor_start / pScrn->displayWidth); + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, + 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + + /* Colormap setup */ + if (!miCreateDefColormap(pScreen)) return FALSE; + if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8, + (info->FBDev ? fbdevHWLoadPalette : + R128LoadPalette), NULL, + CMAP_PALETTED_TRUECOLOR + | CMAP_RELOAD_ON_MODE_SWITCH +#if 0 /* This option messes up text mode! (eich@suse.de) */ + | CMAP_LOAD_EVEN_IF_OFFSCREEN +#endif + )) return FALSE; + + /* DPMS setup */ +#ifdef DPMSExtension + if (!info->HasPanelRegs || info->CRTOnly) + xf86DPMSInit(pScreen, R128DisplayPowerManagementSet, 0); +#endif + + R128InitVideo(pScreen); + + /* Provide SaveScreen */ + pScreen->SaveScreen = R128SaveScreen; + + /* Wrap CloseScreen */ + info->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = R128CloseScreen; + + /* Note unused options */ + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + +#ifdef XF86DRI + /* DRI finalization */ + if (info->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have + done their thing, complete the DRI + setup. */ + info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen); + } + if (info->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } +#endif + + return TRUE; +} + +/* Write common registers (initialized to 0). */ +static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_OVR_CLR, restore->ovr_clr); + OUTREG(R128_OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right); + OUTREG(R128_OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom); + OUTREG(R128_OV0_SCALE_CNTL, restore->ov0_scale_cntl); + OUTREG(R128_MPP_TB_CONFIG, restore->mpp_tb_config ); + OUTREG(R128_MPP_GP_CONFIG, restore->mpp_gp_config ); + OUTREG(R128_SUBPIC_CNTL, restore->subpic_cntl); + OUTREG(R128_VIPH_CONTROL, restore->viph_control); + OUTREG(R128_I2C_CNTL_1, restore->i2c_cntl_1); + OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl); + OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); + OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); + OUTREG(R128_BUS_CNTL, restore->bus_cntl); +} + +/* Write CRTC registers. */ +static void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_CRTC_GEN_CNTL, restore->crtc_gen_cntl); + + OUTREGP(R128_CRTC_EXT_CNTL, restore->crtc_ext_cntl, + R128_CRTC_VSYNC_DIS | R128_CRTC_HSYNC_DIS | R128_CRTC_DISPLAY_DIS); + + OUTREGP(R128_DAC_CNTL, restore->dac_cntl, + R128_DAC_RANGE_CNTL | R128_DAC_BLANKING); + + OUTREG(R128_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); + OUTREG(R128_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); + OUTREG(R128_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); + OUTREG(R128_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); + OUTREG(R128_CRTC_OFFSET, restore->crtc_offset); + OUTREG(R128_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); + OUTREG(R128_CRTC_PITCH, restore->crtc_pitch); +} + +/* Write flat panel registers */ +static void R128RestoreFPRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 tmp; + + OUTREG(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); + OUTREG(R128_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); + OUTREG(R128_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); + OUTREG(R128_FP_GEN_CNTL, restore->fp_gen_cntl); + OUTREG(R128_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); + OUTREG(R128_FP_HORZ_STRETCH, restore->fp_horz_stretch); + OUTREG(R128_FP_PANEL_CNTL, restore->fp_panel_cntl); + OUTREG(R128_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); + OUTREG(R128_FP_VERT_STRETCH, restore->fp_vert_stretch); + OUTREG(R128_TMDS_CRC, restore->tmds_crc); + + tmp = INREG(R128_LVDS_GEN_CNTL); + if ((tmp & (R128_LVDS_ON | R128_LVDS_BLON)) == + (restore->lvds_gen_cntl & (R128_LVDS_ON | R128_LVDS_BLON))) { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + if (restore->lvds_gen_cntl & (R128_LVDS_ON | R128_LVDS_BLON)) { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl & ~R128_LVDS_BLON); + usleep(R128PTR(pScrn)->PanelPwrDly * 1000); + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl | R128_LVDS_BLON); + usleep(R128PTR(pScrn)->PanelPwrDly * 1000); + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } + } +} + +static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) +{ + while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); +} + +static void R128PLLWriteUpdate(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTPLLP(pScrn, R128_PPLL_REF_DIV, R128_PPLL_ATOMIC_UPDATE_W, 0xffff); +} + +/* Write PLL registers. */ +static void R128RestorePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CLOCK_CNTL_INDEX, R128_PLL_DIV_SEL, 0xffff); + + OUTPLLP(pScrn, + R128_PPLL_CNTL, + R128_PPLL_RESET + | R128_PPLL_ATOMIC_UPDATE_EN + | R128_PPLL_VGA_ATOMIC_UPDATE_EN, + 0xffff); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLLP(pScrn, R128_PPLL_REF_DIV, + restore->ppll_ref_div, ~R128_PPLL_REF_DIV_MASK); + R128PLLWriteUpdate(pScrn); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLLP(pScrn, R128_PPLL_DIV_3, + restore->ppll_div_3, ~R128_PPLL_FB3_DIV_MASK); + R128PLLWriteUpdate(pScrn); + OUTPLLP(pScrn, R128_PPLL_DIV_3, + restore->ppll_div_3, ~R128_PPLL_POST3_DIV_MASK); + R128PLLWriteUpdate(pScrn); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLL(R128_HTOTAL_CNTL, restore->htotal_cntl); + R128PLLWriteUpdate(pScrn); + + OUTPLLP(pScrn, R128_PPLL_CNTL, 0, ~R128_PPLL_RESET); + + R128TRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", + restore->ppll_ref_div, + restore->ppll_div_3, + restore->htotal_cntl, + INPLL(pScrn, R128_PPLL_CNTL))); + R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", + restore->ppll_ref_div & R128_PPLL_REF_DIV_MASK, + restore->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, + (restore->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Write DDA registers. */ +static void R128RestoreDDARegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_DDA_CONFIG, restore->dda_config); + OUTREG(R128_DDA_ON_OFF, restore->dda_on_off); +} + +/* Write palette data. */ +static void R128RestorePalette(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + if (!restore->palette_valid) return; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + OUTPAL_START(0); + for (i = 0; i < 256; i++) OUTPAL_NEXT_CARD32(restore->palette[i]); +} + +/* Write out state to define a new video mode. */ +static void R128RestoreMode(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128RestoreMode(%p)\n", restore)); + R128RestoreCommonRegisters(pScrn, restore); + R128RestoreCrtcRegisters(pScrn, restore); + if (info->HasPanelRegs) + R128RestoreFPRegisters(pScrn, restore); + if (!info->HasPanelRegs || info->CRTOnly) + R128RestorePLLRegisters(pScrn, restore); + R128RestoreDDARegisters(pScrn, restore); + R128RestorePalette(pScrn, restore); +} + +/* Read common registers. */ +static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->ovr_clr = INREG(R128_OVR_CLR); + save->ovr_wid_left_right = INREG(R128_OVR_WID_LEFT_RIGHT); + save->ovr_wid_top_bottom = INREG(R128_OVR_WID_TOP_BOTTOM); + save->ov0_scale_cntl = INREG(R128_OV0_SCALE_CNTL); + save->mpp_tb_config = INREG(R128_MPP_TB_CONFIG); + save->mpp_gp_config = INREG(R128_MPP_GP_CONFIG); + save->subpic_cntl = INREG(R128_SUBPIC_CNTL); + save->viph_control = INREG(R128_VIPH_CONTROL); + save->i2c_cntl_1 = INREG(R128_I2C_CNTL_1); + save->gen_int_cntl = INREG(R128_GEN_INT_CNTL); + save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL); + save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL); + save->bus_cntl = INREG(R128_BUS_CNTL); +} + +/* Read CRTC registers. */ +static void R128SaveCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->crtc_gen_cntl = INREG(R128_CRTC_GEN_CNTL); + save->crtc_ext_cntl = INREG(R128_CRTC_EXT_CNTL); + save->dac_cntl = INREG(R128_DAC_CNTL); + save->crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP); + save->crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID); + save->crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP); + save->crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID); + save->crtc_offset = INREG(R128_CRTC_OFFSET); + save->crtc_offset_cntl = INREG(R128_CRTC_OFFSET_CNTL); + save->crtc_pitch = INREG(R128_CRTC_PITCH); +} + +/* Read flat panel registers */ +static void R128SaveFPRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->crtc2_gen_cntl = INREG(R128_CRTC2_GEN_CNTL); + save->fp_crtc_h_total_disp = INREG(R128_FP_CRTC_H_TOTAL_DISP); + save->fp_crtc_v_total_disp = INREG(R128_FP_CRTC_V_TOTAL_DISP); + save->fp_gen_cntl = INREG(R128_FP_GEN_CNTL); + save->fp_h_sync_strt_wid = INREG(R128_FP_H_SYNC_STRT_WID); + save->fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); + save->fp_panel_cntl = INREG(R128_FP_PANEL_CNTL); + save->fp_v_sync_strt_wid = INREG(R128_FP_V_SYNC_STRT_WID); + save->fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); + save->lvds_gen_cntl = INREG(R128_LVDS_GEN_CNTL); + save->tmds_crc = INREG(R128_TMDS_CRC); +} + +/* Read PLL registers. */ +static void R128SavePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + save->ppll_ref_div = INPLL(pScrn, R128_PPLL_REF_DIV); + save->ppll_div_3 = INPLL(pScrn, R128_PPLL_DIV_3); + save->htotal_cntl = INPLL(pScrn, R128_HTOTAL_CNTL); + + R128TRACE(("Read: 0x%08x 0x%08x 0x%08x\n", + save->ppll_ref_div, + save->ppll_div_3, + save->htotal_cntl)); + R128TRACE(("Read: rd=%d, fd=%d, pd=%d\n", + save->ppll_ref_div & R128_PPLL_REF_DIV_MASK, + save->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, + (save->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Read DDA registers. */ +static void R128SaveDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->dda_config = INREG(R128_DDA_CONFIG); + save->dda_on_off = INREG(R128_DDA_ON_OFF); +} + +/* Read palette data. */ +static void R128SavePalette(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + INPAL_START(0); + for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT(); + save->palette_valid = TRUE; +} + +/* Save state that defines current video mode. */ +static void R128SaveMode(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128TRACE(("R128SaveMode(%p)\n", save)); + + R128SaveCommonRegisters(pScrn, save); + R128SaveCrtcRegisters(pScrn, save); + if (R128PTR(pScrn)->HasPanelRegs) + R128SaveFPRegisters(pScrn, save); + R128SavePLLRegisters(pScrn, save); + R128SaveDDARegisters(pScrn, save); + R128SavePalette(pScrn, save); + + R128TRACE(("R128SaveMode returns %p\n", save)); +} + +/* Save everything needed to restore the original VC state. */ +static void R128Save(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SavePtr save = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + R128TRACE(("R128Save\n")); + if (info->FBDev) { + fbdevHWSave(pScrn); + return; + } + vgaHWUnlock(hwp); + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ + vgaHWLock(hwp); + + R128SaveMode(pScrn, save); + + save->dp_datatype = INREG(R128_DP_DATATYPE); + save->gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); + save->clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); + save->amcgpio_en_reg = INREG(R128_AMCGPIO_EN_REG); + save->amcgpio_mask = INREG(R128_AMCGPIO_MASK); +} + +/* Restore the original (text) mode. */ +static void R128Restore(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SavePtr restore = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + R128TRACE(("R128Restore\n")); + if (info->FBDev) { + fbdevHWRestore(pScrn); + return; + } + + R128Blank(pScrn); + OUTREG(R128_AMCGPIO_MASK, restore->amcgpio_mask); + OUTREG(R128_AMCGPIO_EN_REG, restore->amcgpio_en_reg); + OUTREG(R128_CLOCK_CNTL_INDEX, restore->clock_cntl_index); + OUTREG(R128_GEN_RESET_CNTL, restore->gen_reset_cntl); + OUTREG(R128_DP_DATATYPE, restore->dp_datatype); + + R128RestoreMode(pScrn, restore); + vgaHWUnlock(hwp); + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); + vgaHWLock(hwp); + + R128WaitForVerticalSync(pScrn); + R128Unblank(pScrn); +} + +/* Define common registers for requested video mode. */ +static void R128InitCommonRegisters(R128SavePtr save, R128InfoPtr info) +{ + save->ovr_clr = 0; + save->ovr_wid_left_right = 0; + save->ovr_wid_top_bottom = 0; + save->ov0_scale_cntl = 0; + save->mpp_tb_config = 0; + save->mpp_gp_config = 0; + save->subpic_cntl = 0; + save->viph_control = 0; + save->i2c_cntl_1 = 0; + save->gen_int_cntl = 0; + save->cap0_trig_cntl = 0; + save->cap1_trig_cntl = 0; + save->bus_cntl = info->BusCntl; + /* + * If bursts are enabled, turn on discards and aborts + */ + if (save->bus_cntl & (R128_BUS_WRT_BURST|R128_BUS_READ_BURST)) + save->bus_cntl |= R128_BUS_RD_DISCARD_EN | R128_BUS_RD_ABORT_EN; +} + +/* Define CRTC registers for requested video mode. */ +static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save, + DisplayModePtr mode, R128InfoPtr info) +{ + int format; + int hsync_start; + int hsync_wid; + int hsync_fudge; + int vsync_wid; + int bytpp; + int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; + int hsync_fudge_fp[] = { 0x12, 0x11, 0x09, 0x09, 0x05, 0x05 }; + int hsync_fudge_fp_crt[] = { 0x12, 0x10, 0x08, 0x08, 0x04, 0x04 }; + + switch (info->CurrentLayout.pixel_code) { + case 4: format = 1; bytpp = 0; break; + case 8: format = 2; bytpp = 1; break; + case 15: format = 3; bytpp = 2; break; /* 555 */ + case 16: format = 4; bytpp = 2; break; /* 565 */ + case 24: format = 5; bytpp = 3; break; /* RGB */ + case 32: format = 6; bytpp = 4; break; /* xRGB */ + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); + return FALSE; + } + R128TRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp)); + + if (info->HasPanelRegs) + if (info->CRTOnly) hsync_fudge = hsync_fudge_fp_crt[format-1]; + else hsync_fudge = hsync_fudge_fp[format-1]; + else hsync_fudge = hsync_fudge_default[format-1]; + + save->crtc_gen_cntl = (R128_CRTC_EXT_DISP_EN + | R128_CRTC_EN + | (format << 8) + | ((mode->Flags & V_DBLSCAN) + ? R128_CRTC_DBL_SCAN_EN + : 0) + | ((mode->Flags & V_INTERLACE) + ? R128_CRTC_INTERLACE_EN + : 0)); + + save->crtc_ext_cntl = R128_VGA_ATI_LINEAR | R128_XCRT_CNT_EN; + save->dac_cntl = (R128_DAC_MASK_ALL + | R128_DAC_VGA_ADR_EN + | (info->dac6bits ? 0 : R128_DAC_8BIT_EN)); + + save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) + | (((mode->CrtcHDisplay / 8) - 1) << 16)); + + hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; + if (!hsync_wid) hsync_wid = 1; + if (hsync_wid > 0x3f) hsync_wid = 0x3f; + + hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; + + save->crtc_h_sync_strt_wid = ((hsync_start & 0xfff) + | (hsync_wid << 16) + | ((mode->Flags & V_NHSYNC) + ? R128_CRTC_H_SYNC_POL + : 0)); + +#if 1 + /* This works for double scan mode. */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay - 1) << 16)); +#else + /* This is what cce/nbmode.c example code + does -- is this correct? */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay + * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) + << 16)); +#endif + + vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; + if (!vsync_wid) vsync_wid = 1; + if (vsync_wid > 0x1f) vsync_wid = 0x1f; + + save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) + | (vsync_wid << 16) + | ((mode->Flags & V_NVSYNC) + ? R128_CRTC_V_SYNC_POL + : 0)); + save->crtc_offset = 0; + save->crtc_offset_cntl = 0; + save->crtc_pitch = info->CurrentLayout.displayWidth / 8; + + R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", + save->crtc_pitch, pScrn->virtualX, info->CurrentLayout.displayWidth)); + return TRUE; +} + +/* Define CRTC registers for requested video mode. */ +static void R128InitFPRegisters(R128SavePtr orig, R128SavePtr save, + DisplayModePtr mode, R128InfoPtr info) +{ + int xres = mode->CrtcHDisplay; + int yres = mode->CrtcVDisplay; + float Hratio, Vratio; + + if (info->CRTOnly) { + save->crtc_ext_cntl |= R128_CRTC_CRT_ON; + save->crtc2_gen_cntl = 0; + save->fp_gen_cntl = orig->fp_gen_cntl; + save->fp_gen_cntl &= ~(R128_FP_FPON | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN); + save->fp_gen_cntl |= (R128_FP_SEL_CRTC2 | + R128_FP_CRTC_DONT_SHADOW_VPAR); + save->fp_panel_cntl = orig->fp_panel_cntl & ~R128_FP_DIGON; + save->lvds_gen_cntl = orig->lvds_gen_cntl & ~(R128_LVDS_ON | + R128_LVDS_BLON); + return; + } + + if (xres > info->PanelXRes) xres = info->PanelXRes; + if (yres > info->PanelYRes) yres = info->PanelYRes; + + Hratio = (float)xres/(float)info->PanelXRes; + Vratio = (float)yres/(float)info->PanelYRes; + + save->fp_horz_stretch = + (((((int)(Hratio * R128_HORZ_STRETCH_RATIO_MAX + 0.5)) + & R128_HORZ_STRETCH_RATIO_MASK) << R128_HORZ_STRETCH_RATIO_SHIFT) | + (orig->fp_horz_stretch & (R128_HORZ_PANEL_SIZE | + R128_HORZ_FP_LOOP_STRETCH | + R128_HORZ_STRETCH_RESERVED))); + save->fp_horz_stretch &= ~R128_HORZ_AUTO_RATIO_FIX_EN; + if (Hratio == 1.0) save->fp_horz_stretch &= ~(R128_HORZ_STRETCH_BLEND | + R128_HORZ_STRETCH_ENABLE); + else save->fp_horz_stretch |= (R128_HORZ_STRETCH_BLEND | + R128_HORZ_STRETCH_ENABLE); + + save->fp_vert_stretch = + (((((int)(Vratio * R128_VERT_STRETCH_RATIO_MAX + 0.5)) + & R128_VERT_STRETCH_RATIO_MASK) << R128_VERT_STRETCH_RATIO_SHIFT) | + (orig->fp_vert_stretch & (R128_VERT_PANEL_SIZE | + R128_VERT_STRETCH_RESERVED))); + save->fp_vert_stretch &= ~R128_VERT_AUTO_RATIO_EN; + if (Vratio == 1.0) save->fp_vert_stretch &= ~(R128_VERT_STRETCH_ENABLE | + R128_VERT_STRETCH_BLEND); + else save->fp_vert_stretch |= (R128_VERT_STRETCH_ENABLE | + R128_VERT_STRETCH_BLEND); + + save->fp_gen_cntl = (orig->fp_gen_cntl & ~(R128_FP_SEL_CRTC2 | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN)); + if (orig->fp_gen_cntl & R128_FP_DETECT_SENSE) { + save->fp_gen_cntl |= (R128_FP_CRTC_DONT_SHADOW_VPAR | + R128_FP_TDMS_EN); + } + + save->fp_panel_cntl = orig->fp_panel_cntl; + save->lvds_gen_cntl = orig->lvds_gen_cntl; + + save->tmds_crc = orig->tmds_crc; + + /* Disable CRT output by disabling CRT output and setting the CRT + DAC to use CRTC2, which we set to 0's. In the future, we will + want to use the dual CRTC capabilities of the R128 to allow both + the flat panel and external CRT to either simultaneously display + the same image or display two different images. */ + save->crtc_ext_cntl &= ~R128_CRTC_CRT_ON; + save->dac_cntl |= R128_DAC_CRT_SEL_CRTC2; + save->crtc2_gen_cntl = 0; + + /* WARNING: Be careful about turning on the flat panel */ +#if 1 + save->lvds_gen_cntl |= (R128_LVDS_ON | R128_LVDS_BLON); +#else + save->fp_panel_cntl |= (R128_FP_DIGON | R128_FP_BLON); + save->fp_gen_cntl |= (R128_FP_FPON); +#endif + + save->fp_crtc_h_total_disp = save->crtc_h_total_disp; + save->fp_crtc_v_total_disp = save->crtc_v_total_disp; + save->fp_h_sync_strt_wid = save->crtc_h_sync_strt_wid; + save->fp_v_sync_strt_wid = save->crtc_v_sync_strt_wid; +} + +/* Define PLL registers for requested video mode. */ +static void R128InitPLLRegisters(R128SavePtr save, R128PLLPtr pll, + double dot_clock) +{ + unsigned long freq = dot_clock * 100; + struct { + int divider; + int bitvalue; + } *post_div, + post_divs[] = { + /* From RAGE 128 VR/RAGE 128 GL Register + Reference Manual (Technical Reference + Manual P/N RRG-G04100-C Rev. 0.04), page + 3-17 (PLL_DIV_[3:0]). */ + { 1, 0 }, /* VCLK_SRC */ + { 2, 1 }, /* VCLK_SRC/2 */ + { 4, 2 }, /* VCLK_SRC/4 */ + { 8, 3 }, /* VCLK_SRC/8 */ + + { 3, 4 }, /* VCLK_SRC/3 */ + /* bitvalue = 5 is reserved */ + { 6, 6 }, /* VCLK_SRC/6 */ + { 12, 7 }, /* VCLK_SRC/12 */ + { 0, 0 } + }; + + if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; + if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; + + for (post_div = &post_divs[0]; post_div->divider; ++post_div) { + save->pll_output_freq = post_div->divider * freq; + if (save->pll_output_freq >= pll->min_pll_freq + && save->pll_output_freq <= pll->max_pll_freq) break; + } + + save->dot_clock_freq = freq; + save->feedback_div = R128Div(pll->reference_div * save->pll_output_freq, + pll->reference_freq); + save->post_div = post_div->divider; + + R128TRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", + save->dot_clock_freq, + save->pll_output_freq, + save->feedback_div, + save->post_div)); + + save->ppll_ref_div = pll->reference_div; + save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); + save->htotal_cntl = 0; +} + +/* Define DDA registers for requested video mode. */ +static Bool R128InitDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save, + R128PLLPtr pll, R128InfoPtr info) +{ + int DisplayFifoWidth = 128; + int DisplayFifoDepth = 32; + int XclkFreq; + int VclkFreq; + int XclksPerTransfer; + int XclksPerTransferPrecise; + int UseablePrecision; + int Roff; + int Ron; + + XclkFreq = pll->xclk; + + VclkFreq = R128Div(pll->reference_freq * save->feedback_div, + pll->reference_div * save->post_div); + + XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth, + VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); + + UseablePrecision = R128MinBits(XclksPerTransfer) + 1; + + XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth) + << (11 - UseablePrecision), + VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); + + Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); + + Ron = (4 * info->ram->MB + + 3 * MAX(info->ram->Trcd - 2, 0) + + 2 * info->ram->Trp + + info->ram->Twr + + info->ram->CL + + info->ram->Tr2w + + XclksPerTransfer) << (11 - UseablePrecision); + + if (Ron + info->ram->Rloop >= Roff) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", + Ron, info->ram->Rloop, Roff); + return FALSE; + } + + save->dda_config = (XclksPerTransferPrecise + | (UseablePrecision << 16) + | (info->ram->Rloop << 20)); + + save->dda_on_off = (Ron << 16) | Roff; + + R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", + XclkFreq, + VclkFreq, + XclksPerTransfer, + XclksPerTransferPrecise, + UseablePrecision)); + R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n", + Roff, Ron, info->ram->Rloop)); + + return TRUE; +} + + +/* Define initial palette for requested video mode. This doesn't do + anything for XFree86 4.0. */ +static void R128InitPalette(R128SavePtr save) +{ + save->palette_valid = FALSE; +} + +/* Define registers for a requested video mode. */ +static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + double dot_clock = mode->Clock/1000.0; + +#if R128_DEBUG + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->HDisplay, + mode->HSyncStart, + mode->HSyncEnd, + mode->HTotal, + + mode->VDisplay, + mode->VSyncStart, + mode->VSyncEnd, + mode->VTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->CrtcHDisplay, + mode->CrtcHSyncStart, + mode->CrtcHSyncEnd, + mode->CrtcHTotal, + + mode->CrtcVDisplay, + mode->CrtcVSyncStart, + mode->CrtcVSyncEnd, + mode->CrtcVTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); +#endif + + info->Flags = mode->Flags; + + R128InitCommonRegisters(save, info); + if (!R128InitCrtcRegisters(pScrn, save, mode, info)) return FALSE; + if (info->HasPanelRegs) + R128InitFPRegisters(&info->SavedReg, save, mode, info); + R128InitPLLRegisters(save, &info->pll, dot_clock); + if (!R128InitDDARegisters(pScrn, save, &info->pll, info)) + return FALSE; + if (!info->PaletteSavedOnVT) R128InitPalette(save); + + R128TRACE(("R128Init returns %p\n", save)); + return TRUE; +} + +/* Initialize a new mode. */ +static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE; + /* FIXME? DRILock/DRIUnlock here? */ + pScrn->vtSema = TRUE; + R128Blank(pScrn); + R128RestoreMode(pScrn, &info->ModeReg); + R128Unblank(pScrn); + + info->CurrentLayout.mode = mode; + + return TRUE; +} + +static Bool R128SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool unblank; + + unblank = xf86IsUnblank(mode); + if (unblank) + SetTimeSinceLastInputEvent(); + + if ((pScrn != NULL) && pScrn->vtSema) { + if (unblank) + R128Unblank(pScrn); + else + R128Blank(pScrn); + } + return TRUE; +} + +Bool R128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return R128ModeInit(xf86Screens[scrnIndex], mode); +} + +/* Used to disallow modes that are not supported by the hardware. */ +int R128ValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flag) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + if (info->HasPanelRegs) { + if (mode->Flags & V_INTERLACE) return MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN) return MODE_NO_DBLESCAN; + } + + if (info->HasPanelRegs && !info->CRTOnly && info->VBIOS) { + int i; + for (i = info->FPBIOSstart+64; R128_BIOS16(i) != 0; i += 2) { + int j = R128_BIOS16(i); + + if (mode->CrtcHDisplay == R128_BIOS16(j) && + mode->CrtcVDisplay == R128_BIOS16(j+2)) { + /* Assume we are using expanded mode */ + if (R128_BIOS16(j+5)) j = R128_BIOS16(j+5); + else j += 9; + + mode->Clock = (CARD32)R128_BIOS16(j) * 10; + + mode->HDisplay = mode->CrtcHDisplay = + ((R128_BIOS16(j+10) & 0x01ff)+1)*8; + mode->HSyncStart = mode->CrtcHSyncStart = + ((R128_BIOS16(j+12) & 0x01ff)+1)*8; + mode->HSyncEnd = mode->CrtcHSyncEnd = + mode->CrtcHSyncStart + (R128_BIOS8(j+14) & 0x1f); + mode->HTotal = mode->CrtcHTotal = + ((R128_BIOS16(j+8) & 0x01ff)+1)*8; + + mode->VDisplay = mode->CrtcVDisplay = + (R128_BIOS16(j+17) & 0x07ff)+1; + mode->VSyncStart = mode->CrtcVSyncStart = + (R128_BIOS16(j+19) & 0x07ff)+1; + mode->VSyncEnd = mode->CrtcVSyncEnd = + mode->CrtcVSyncStart + ((R128_BIOS16(j+19) >> 11) & 0x1f); + mode->VTotal = mode->CrtcVTotal = + (R128_BIOS16(j+15) & 0x07ff)+1; + + return MODE_OK; + } + } + return MODE_NOMODE; + } + + return MODE_OK; +} + +/* Adjust viewport into virtual desktop such that (0,0) in viewport space + is (x,y) in virtual space. */ +void R128AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int Base; + + Base = y * info->CurrentLayout.displayWidth + x; + + switch (info->CurrentLayout.pixel_code) { + case 15: + case 16: Base *= 2; break; + case 24: Base *= 3; break; + case 32: Base *= 4; break; + } + + Base &= ~7; /* 3 lower bits are always 0 */ + + if (info->CurrentLayout.pixel_code == 24) + Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */ + + OUTREG(R128_CRTC_OFFSET, Base); +} + +/* Called when VT switching back to the X server. Reinitialize the video + mode. */ +Bool R128EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128EnterVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + R128CCEStart(pScrn); + DRIUnlock(pScrn->pScreen); + } +#endif + if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; + if (info->accelOn) + R128EngineInit(pScrn); + + info->PaletteSavedOnVT = FALSE; + R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +/* Called when VT switching away from the X server. Restore the original + text mode. */ +void R128LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr save = &info->ModeReg; + + R128TRACE(("R128LeaveVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + DRILock(pScrn->pScreen, 0); + R128CCEStop(pScrn); + } +#endif + R128SavePalette(pScrn, save); + info->PaletteSavedOnVT = TRUE; + R128Restore(pScrn); +} + +static Bool +R128EnterVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr restore = &info->SavedReg; + fbdevHWEnterVT(scrnIndex,flags); + R128RestorePalette(pScrn,restore); + R128EngineInit(pScrn); + return TRUE; +} + +static void R128LeaveVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr save = &info->SavedReg; + R128SavePalette(pScrn,save); + fbdevHWLeaveVT(scrnIndex,flags); +} + +/* Called at the end of each server generation. Restore the original text + mode, unmap video memory, and unwrap and call the saved CloseScreen + function. */ +static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128CloseScreen\n")); + +#ifdef XF86DRI + /* Disable direct rendering */ + if (info->directRenderingEnabled) { + R128DRICloseScreen(pScreen); + info->directRenderingEnabled = FALSE; + } +#endif + + if (pScrn->vtSema) { + R128Restore(pScrn); + R128UnmapMem(pScrn); + } + + if (info->accel) XAADestroyInfoRec(info->accel); + info->accel = NULL; + + if (info->scratch_save) xfree(info->scratch_save); + info->scratch_save = NULL; + + if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); + info->cursor = NULL; + + if (info->DGAModes) xfree(info->DGAModes); + info->DGAModes = NULL; + + pScrn->vtSema = FALSE; + + pScreen->CloseScreen = info->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + +void R128FreeScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + R128TRACE(("R128FreeScreen\n")); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(pScrn); + R128FreeRec(pScrn); +} + +#ifdef DPMSExtension +/* Sets VESA Display Power Management Signaling (DPMS) Mode. */ +static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int mask = (R128_CRTC_DISPLAY_DIS + | R128_CRTC_HSYNC_DIS + | R128_CRTC_VSYNC_DIS); + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + OUTREGP(R128_CRTC_EXT_CNTL, 0, ~mask); + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On */ + OUTREGP(R128_CRTC_EXT_CNTL, + R128_CRTC_DISPLAY_DIS | R128_CRTC_HSYNC_DIS, ~mask); + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off */ + OUTREGP(R128_CRTC_EXT_CNTL, + R128_CRTC_DISPLAY_DIS | R128_CRTC_VSYNC_DIS, ~mask); + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + OUTREGP(R128_CRTC_EXT_CNTL, mask, ~mask); + break; + } +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c new file mode 100644 index 000000000..bbaf3e4d7 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c @@ -0,0 +1,84 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c,v 1.1 2000/11/02 16:55:36 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 XFree86LOADER + +#include "ativersion.h" + +#include "r128_version.h" + +#include "xf86.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo R128VersionRec = +{ + R128_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + R128_VERSION_MAJOR, R128_VERSION_MINOR, R128_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * R128Setup -- + * + * This function is called every time the module is loaded. + */ +static pointer +R128Setup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called r128ModuleData */ +XF86ModuleData r128ModuleData = +{ + &R128VersionRec, + R128Setup, + NULL +}; + +#endif /* XFree86LOADER */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c new file mode 100644 index 000000000..03fa17a4c --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c @@ -0,0 +1,195 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c,v 1.1 2000/11/02 16:55:37 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#include "atimodule.h" +#include "ativersion.h" + +#include "r128_probe.h" +#include "r128_version.h" + +#include "xf86PciInfo.h" + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86Resources.h" + +SymTabRec R128Chipsets[] = { + { PCI_CHIP_RAGE128RE, "ATI Rage 128 RE (PCI)" }, + { PCI_CHIP_RAGE128RF, "ATI Rage 128 RF (AGP)" }, + { PCI_CHIP_RAGE128RK, "ATI Rage 128 RK (PCI)" }, + { PCI_CHIP_RAGE128RL, "ATI Rage 128 RL (AGP)" }, + { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro PF (AGP)" }, + { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility LE (PCI)" }, + { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility LF (AGP)" }, + { PCI_CHIP_RAGE128MF, "ATI Rage 128 Mobility MF (AGP)" }, + { PCI_CHIP_RAGE128ML, "ATI Rage 128 Mobility ML (AGP)" }, + { -1, NULL } +}; + +PciChipsets R128PciChipsets[] = { + { PCI_CHIP_RAGE128RE, PCI_CHIP_RAGE128RE, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RF, PCI_CHIP_RAGE128RF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RK, PCI_CHIP_RAGE128RK, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RL, PCI_CHIP_RAGE128RL, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128PF, PCI_CHIP_RAGE128PF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128MF, PCI_CHIP_RAGE128MF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128ML, PCI_CHIP_RAGE128ML, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +/* Return the options for supported chipset 'n'; NULL otherwise */ +OptionInfoPtr +R128AvailableOptions(int chipid, int busid) +{ + int i; + + /* + * Return options defined in the r128 submodule which will have been + * loaded by this point. + */ + for (i = 0; R128PciChipsets[i].PCIid > 0; i++) { + if (chipid == R128PciChipsets[i].PCIid) + return R128Options; + } + return NULL; +} + +/* Return the string name for supported chipset 'n'; NULL otherwise. */ +void +R128Identify(int flags) +{ + xf86PrintChipsets(R128_NAME, + "Driver for ATI Rage 128 chipsets", + R128Chipsets); +} + +/* Return TRUE if chipset is present; FALSE otherwise. */ +Bool +R128Probe(DriverPtr drv, int flags) +{ + int numUsed; + int numDevSections, nATIGDev, nR128GDev; + int *usedChips; + GDevPtr *devSections, *ATIGDevs, *R128GDevs; + EntityInfoPtr pEnt; + Bool foundScreen = FALSE; + int i; + + if (!xf86GetPciVideoInfo()) return FALSE; + + /* Collect unclaimed device sections for both driver names */ + nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs); + nR128GDev = xf86MatchDevice(R128_NAME, &R128GDevs); + + if (!(numDevSections = nATIGDev + nR128GDev)) return FALSE; + + if (!ATIGDevs) { + if (!(devSections = R128GDevs)) + numDevSections = 1; + else + numDevSections = nR128GDev; + } if (!R128GDevs) { + devSections = ATIGDevs; + numDevSections = nATIGDev; + } else { + /* Combine into one list */ + devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr)); + (void)memcpy(devSections, + ATIGDevs, nATIGDev * sizeof(GDevPtr)); + (void)memcpy(devSections + nATIGDev, + R128GDevs, nR128GDev * sizeof(GDevPtr)); + devSections[numDevSections] = NULL; + xfree(ATIGDevs); + xfree(R128GDevs); + } + + numUsed = xf86MatchPciInstances(R128_NAME, + PCI_VENDOR_ATI, + R128Chipsets, + R128PciChipsets, + devSections, + numDevSections, + drv, + &usedChips); + + if (numUsed<=0) return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + pEnt = xf86GetEntityInfo(usedChips[i]); + + if (pEnt->active) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + +#ifdef XFree86LOADER + if (!xf86LoadSubModule(pScrn, "r128")) { + xf86Msg(X_ERROR, + R128_NAME ": Failed to load \"r128\" module.\n"); + xf86DeleteScreen(pScrn->scrnIndex, 0); + continue; + } + + xf86LoaderReqSymLists(R128Symbols, NULL); +#endif + + pScrn->driverVersion = R128_VERSION_CURRENT; + pScrn->driverName = R128_DRIVER_NAME; + pScrn->name = R128_NAME; + pScrn->Probe = R128Probe; + pScrn->PreInit = R128PreInit; + pScrn->ScreenInit = R128ScreenInit; + pScrn->SwitchMode = R128SwitchMode; + pScrn->AdjustFrame = R128AdjustFrame; + pScrn->EnterVT = R128EnterVT; + pScrn->LeaveVT = R128LeaveVT; + pScrn->FreeScreen = R128FreeScreen; + pScrn->ValidMode = R128ValidMode; + + foundScreen = TRUE; + + xf86ConfigActivePciEntity(pScrn, usedChips[i], R128PciChipsets, + 0, 0, 0, 0, 0); + } + xfree(pEnt); + } + + if (numUsed) xfree(usedChips); + xfree(devSections); + + return foundScreen; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h new file mode 100644 index 000000000..11d71749f --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h @@ -0,0 +1,73 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h,v 1.1 2000/11/02 16:55:37 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#ifndef _R128_PROBE_H_ +#define _R128_PROBE_H_ 1 + +#include "atiproto.h" + +#include "xf86str.h" + +/* r128_probe.c */ +extern OptionInfoPtr R128AvailableOptions + FunctionPrototype((int, int)); +extern void R128Identify + FunctionPrototype((int)); +extern Bool R128Probe + FunctionPrototype((DriverPtr, int)); + +extern SymTabRec R128Chipsets[]; +extern PciChipsets R128PciChipsets[]; + +/* r128_driver.c */ +extern Bool R128PreInit + FunctionPrototype((ScrnInfoPtr, int)); +extern Bool R128ScreenInit + FunctionPrototype((int, ScreenPtr, int, char **)); +extern Bool R128SwitchMode + FunctionPrototype((int, DisplayModePtr, int)); +extern void R128AdjustFrame + FunctionPrototype((int, int, int, int)); +extern Bool R128EnterVT + FunctionPrototype((int, int)); +extern void R128LeaveVT + FunctionPrototype((int, int)); +extern void R128FreeScreen + FunctionPrototype((int, int)); +extern int R128ValidMode + FunctionPrototype((int, DisplayModePtr, Bool, int)); + +extern OptionInfoRec R128Options[]; + +#endif /* _R128_PROBE_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h new file mode 100644 index 000000000..cc71a015e --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h @@ -0,0 +1,1459 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h,v 1.1 2000/11/02 16:55:37 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + +#ifndef _R128_REG_H_ +#define _R128_REG_H_ +#include <compiler.h> + + /* Memory mapped register access macros */ +#define INREG8(addr) MMIO_IN8(R128MMIO, addr) +#define INREG16(addr) MMIO_IN16(R128MMIO, addr) +#define INREG(addr) MMIO_IN32(R128MMIO, addr) +#define OUTREG8(addr, val) MMIO_OUT8(R128MMIO, addr, val) +#define OUTREG16(addr, val) MMIO_OUT16(R128MMIO, addr, val) +#define OUTREG(addr, val) MMIO_OUT32(R128MMIO, addr, val) + +#define ADDRREG(addr) ((volatile CARD32 *)(R128MMIO + (addr))) + + +#define OUTREGP(addr, val, mask) \ + do { \ + CARD32 tmp = INREG(addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTREG(addr, tmp); \ + } while (0) + +#define INPLL(pScrn, addr) R128INPLL(pScrn, addr) + +#define OUTPLL(addr, val) \ + do { \ + OUTREG8(R128_CLOCK_CNTL_INDEX, ((addr) & 0x1f) | R128_PLL_WR_EN); \ + OUTREG(R128_CLOCK_CNTL_DATA, val); \ + } while (0) + +#define OUTPLLP(pScrn, addr, val, mask) \ + do { \ + CARD32 tmp = INPLL(pScrn, addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTPLL(addr, tmp); \ + } while (0) + +#define OUTPAL_START(idx) \ + do { \ + OUTREG8(R128_PALETTE_INDEX, (idx)); \ + } while (0) + +#define OUTPAL_NEXT(r, g, b) \ + do { \ + OUTREG(R128_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ + } while (0) + +#define OUTPAL_NEXT_CARD32(v) \ + do { \ + OUTREG(R128_PALETTE_DATA, (v & 0x00ffffff)); \ + } while (0) + +#define OUTPAL(idx, r, g, b) \ + do { \ + OUTPAL_START((idx)); \ + OUTPAL_NEXT((r), (g), (b)); \ + } while (0) + +#define INPAL_START(idx) \ + do { \ + OUTREG(R128_PALETTE_INDEX, (idx) << 16); \ + } while (0) + +#define INPAL_NEXT() INREG(R128_PALETTE_DATA) + +#define PAL_SELECT(idx) \ + do { \ + if (idx) { \ + OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) | \ + R128_DAC_PALETTE_ACC_CTL); \ + } else { \ + OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) & \ + ~R128_DAC_PALETTE_ACC_CTL); \ + } \ + } while (0) + +#define R128_ADAPTER_ID 0x0f2c /* PCI */ +#define R128_AGP_APER_OFFSET 0x0178 +#define R128_AGP_BASE 0x0170 +#define R128_AGP_CNTL 0x0174 +# define R128_AGP_APER_SIZE_256MB (0x00 << 0) +# define R128_AGP_APER_SIZE_128MB (0x20 << 0) +# define R128_AGP_APER_SIZE_64MB (0x30 << 0) +# define R128_AGP_APER_SIZE_32MB (0x38 << 0) +# define R128_AGP_APER_SIZE_16MB (0x3c << 0) +# define R128_AGP_APER_SIZE_8MB (0x3e << 0) +# define R128_AGP_APER_SIZE_4MB (0x3f << 0) +# define R128_AGP_APER_SIZE_MASK (0x3f << 0) +#define R128_AGP_CNTL_B 0x0b44 +#define R128_AGP_COMMAND 0x0f58 /* PCI */ +#define R128_AGP_PLL_CNTL 0x0010 /* PLL */ +#define R128_AGP_STATUS 0x0f54 /* PCI */ +# define R128_AGP_1X_MODE 0x01 +# define R128_AGP_2X_MODE 0x02 +# define R128_AGP_4X_MODE 0x04 +# define R128_AGP_MODE_MASK 0x07 +#define R128_AMCGPIO_A_REG 0x01a0 +#define R128_AMCGPIO_EN_REG 0x01a8 +#define R128_AMCGPIO_MASK 0x0194 +#define R128_AMCGPIO_Y_REG 0x01a4 +#define R128_ATTRDR 0x03c1 /* VGA */ +#define R128_ATTRDW 0x03c0 /* VGA */ +#define R128_ATTRX 0x03c0 /* VGA */ +# define R128_AUX1_SC_EN (1 << 0) +# define R128_AUX1_SC_MODE_OR (0 << 1) +# define R128_AUX1_SC_MODE_NAND (1 << 1) +# define R128_AUX2_SC_EN (1 << 2) +# define R128_AUX2_SC_MODE_OR (0 << 3) +# define R128_AUX2_SC_MODE_NAND (1 << 3) +# define R128_AUX3_SC_EN (1 << 4) +# define R128_AUX3_SC_MODE_OR (0 << 5) +# define R128_AUX3_SC_MODE_NAND (1 << 5) +#define R128_AUX_SC_CNTL 0x1660 +#define R128_AUX1_SC_BOTTOM 0x1670 +#define R128_AUX1_SC_LEFT 0x1664 +#define R128_AUX1_SC_RIGHT 0x1668 +#define R128_AUX1_SC_TOP 0x166c +#define R128_AUX2_SC_BOTTOM 0x1680 +#define R128_AUX2_SC_LEFT 0x1674 +#define R128_AUX2_SC_RIGHT 0x1678 +#define R128_AUX2_SC_TOP 0x167c +#define R128_AUX3_SC_BOTTOM 0x1690 +#define R128_AUX3_SC_LEFT 0x1684 +#define R128_AUX3_SC_RIGHT 0x1688 +#define R128_AUX3_SC_TOP 0x168c +#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8 +#define R128_AUX_WINDOW_VERT_CNTL 0x02dc + +#define R128_BASE_CODE 0x0f0b +#define R128_BIOS_0_SCRATCH 0x0010 +#define R128_BIOS_1_SCRATCH 0x0014 +#define R128_BIOS_2_SCRATCH 0x0018 +#define R128_BIOS_3_SCRATCH 0x001c +#define R128_BIOS_ROM 0x0f30 /* PCI */ +#define R128_BIST 0x0f0f /* PCI */ +#define R128_BRUSH_DATA0 0x1480 +#define R128_BRUSH_DATA1 0x1484 +#define R128_BRUSH_DATA10 0x14a8 +#define R128_BRUSH_DATA11 0x14ac +#define R128_BRUSH_DATA12 0x14b0 +#define R128_BRUSH_DATA13 0x14b4 +#define R128_BRUSH_DATA14 0x14b8 +#define R128_BRUSH_DATA15 0x14bc +#define R128_BRUSH_DATA16 0x14c0 +#define R128_BRUSH_DATA17 0x14c4 +#define R128_BRUSH_DATA18 0x14c8 +#define R128_BRUSH_DATA19 0x14cc +#define R128_BRUSH_DATA2 0x1488 +#define R128_BRUSH_DATA20 0x14d0 +#define R128_BRUSH_DATA21 0x14d4 +#define R128_BRUSH_DATA22 0x14d8 +#define R128_BRUSH_DATA23 0x14dc +#define R128_BRUSH_DATA24 0x14e0 +#define R128_BRUSH_DATA25 0x14e4 +#define R128_BRUSH_DATA26 0x14e8 +#define R128_BRUSH_DATA27 0x14ec +#define R128_BRUSH_DATA28 0x14f0 +#define R128_BRUSH_DATA29 0x14f4 +#define R128_BRUSH_DATA3 0x148c +#define R128_BRUSH_DATA30 0x14f8 +#define R128_BRUSH_DATA31 0x14fc +#define R128_BRUSH_DATA32 0x1500 +#define R128_BRUSH_DATA33 0x1504 +#define R128_BRUSH_DATA34 0x1508 +#define R128_BRUSH_DATA35 0x150c +#define R128_BRUSH_DATA36 0x1510 +#define R128_BRUSH_DATA37 0x1514 +#define R128_BRUSH_DATA38 0x1518 +#define R128_BRUSH_DATA39 0x151c +#define R128_BRUSH_DATA4 0x1490 +#define R128_BRUSH_DATA40 0x1520 +#define R128_BRUSH_DATA41 0x1524 +#define R128_BRUSH_DATA42 0x1528 +#define R128_BRUSH_DATA43 0x152c +#define R128_BRUSH_DATA44 0x1530 +#define R128_BRUSH_DATA45 0x1534 +#define R128_BRUSH_DATA46 0x1538 +#define R128_BRUSH_DATA47 0x153c +#define R128_BRUSH_DATA48 0x1540 +#define R128_BRUSH_DATA49 0x1544 +#define R128_BRUSH_DATA5 0x1494 +#define R128_BRUSH_DATA50 0x1548 +#define R128_BRUSH_DATA51 0x154c +#define R128_BRUSH_DATA52 0x1550 +#define R128_BRUSH_DATA53 0x1554 +#define R128_BRUSH_DATA54 0x1558 +#define R128_BRUSH_DATA55 0x155c +#define R128_BRUSH_DATA56 0x1560 +#define R128_BRUSH_DATA57 0x1564 +#define R128_BRUSH_DATA58 0x1568 +#define R128_BRUSH_DATA59 0x156c +#define R128_BRUSH_DATA6 0x1498 +#define R128_BRUSH_DATA60 0x1570 +#define R128_BRUSH_DATA61 0x1574 +#define R128_BRUSH_DATA62 0x1578 +#define R128_BRUSH_DATA63 0x157c +#define R128_BRUSH_DATA7 0x149c +#define R128_BRUSH_DATA8 0x14a0 +#define R128_BRUSH_DATA9 0x14a4 +#define R128_BRUSH_SCALE 0x1470 +#define R128_BRUSH_Y_X 0x1474 +#define R128_BUS_CNTL 0x0030 +# define R128_BUS_MASTER_DIS (1 << 6) +# define R128_BUS_RD_DISCARD_EN (1 << 24) +# define R128_BUS_RD_ABORT_EN (1 << 25) +# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) +# define R128_BUS_WRT_BURST (1 << 29) +# define R128_BUS_READ_BURST (1 << 30) +#define R128_BUS_CNTL1 0x0034 +# define R128_BUS_WAIT_ON_LOCK_EN (1 << 4) + +#define R128_CACHE_CNTL 0x1724 +#define R128_CACHE_LINE 0x0f0c /* PCI */ +#define R128_CAP0_TRIG_CNTL 0x0950 /* ? */ +#define R128_CAP1_TRIG_CNTL 0x09c0 /* ? */ +#define R128_CAPABILITIES_ID 0x0f50 /* PCI */ +#define R128_CAPABILITIES_PTR 0x0f34 /* PCI */ +#define R128_CLK_PIN_CNTL 0x0001 /* PLL */ +#define R128_CLOCK_CNTL_DATA 0x000c +#define R128_CLOCK_CNTL_INDEX 0x0008 +# define R128_PLL_WR_EN (1 << 7) +# define R128_PLL_DIV_SEL (3 << 8) +#define R128_CLR_CMP_CLR_3D 0x1a24 +#define R128_CLR_CMP_CLR_DST 0x15c8 +#define R128_CLR_CMP_CLR_SRC 0x15c4 +#define R128_CLR_CMP_CNTL 0x15c0 +# define R128_SRC_CMP_EQ_COLOR (4 << 0) +# define R128_SRC_CMP_NEQ_COLOR (5 << 0) +# define R128_CLR_CMP_SRC_SOURCE (1 << 24) +#define R128_CLR_CMP_MASK 0x15cc +# define R128_CLR_CMP_MSK 0xffffffff +#define R128_CLR_CMP_MASK_3D 0x1A28 +#define R128_COMMAND 0x0f04 /* PCI */ +#define R128_COMPOSITE_SHADOW_ID 0x1a0c +#define R128_CONFIG_APER_0_BASE 0x0100 +#define R128_CONFIG_APER_1_BASE 0x0104 +#define R128_CONFIG_APER_SIZE 0x0108 +#define R128_CONFIG_BONDS 0x00e8 +#define R128_CONFIG_CNTL 0x00e0 +#define R128_CONFIG_MEMSIZE 0x00f8 +#define R128_CONFIG_MEMSIZE_EMBEDDED 0x0114 +#define R128_CONFIG_REG_1_BASE 0x010c +#define R128_CONFIG_REG_APER_SIZE 0x0110 +#define R128_CONFIG_XSTRAP 0x00e4 +#define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_COLOR_MASK 0x00ffffff +# define R128_CONSTANT_COLOR_ONE 0x00ffffff +# define R128_CONSTANT_COLOR_ZERO 0x00000000 +#define R128_CRC_CMDFIFO_ADDR 0x0740 +#define R128_CRC_CMDFIFO_DOUT 0x0744 +#define R128_CRTC_CRNT_FRAME 0x0214 +#define R128_CRTC_DEBUG 0x021c +#define R128_CRTC_EXT_CNTL 0x0054 +# define R128_CRTC_VGA_XOVERSCAN (1 << 0) +# define R128_VGA_ATI_LINEAR (1 << 3) +# define R128_XCRT_CNT_EN (1 << 6) +# define R128_CRTC_HSYNC_DIS (1 << 8) +# define R128_CRTC_VSYNC_DIS (1 << 9) +# define R128_CRTC_DISPLAY_DIS (1 << 10) +# define R128_CRTC_CRT_ON (1 << 15) +#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 +# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0) +# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1) +# define R128_CRTC_DISPLAY_DIS_BYTE (1 << 2) +#define R128_CRTC_GEN_CNTL 0x0050 +# define R128_CRTC_DBL_SCAN_EN (1 << 0) +# define R128_CRTC_INTERLACE_EN (1 << 1) +# define R128_CRTC_CSYNC_EN (1 << 4) +# define R128_CRTC_CUR_EN (1 << 16) +# define R128_CRTC_CUR_MODE_MASK (7 << 17) +# define R128_CRTC_ICON_EN (1 << 20) +# define R128_CRTC_EXT_DISP_EN (1 << 24) +# define R128_CRTC_EN (1 << 25) +# define R128_CRTC_DISP_REQ_EN_B (1 << 26) +#define R128_CRTC_GUI_TRIG_VLINE 0x0218 +#define R128_CRTC_H_SYNC_STRT_WID 0x0204 +# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0) +# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) +# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 +# define R128_CRTC_H_SYNC_WID (0x3f << 16) +# define R128_CRTC_H_SYNC_WID_SHIFT 16 +# define R128_CRTC_H_SYNC_POL (1 << 23) +#define R128_CRTC_H_TOTAL_DISP 0x0200 +# define R128_CRTC_H_TOTAL (0x01ff << 0) +# define R128_CRTC_H_TOTAL_SHIFT 0 +# define R128_CRTC_H_DISP (0x00ff << 16) +# define R128_CRTC_H_DISP_SHIFT 16 +#define R128_CRTC_OFFSET 0x0224 +#define R128_CRTC_OFFSET_CNTL 0x0228 +#define R128_CRTC_PITCH 0x022c +#define R128_CRTC_STATUS 0x005c +# define R128_CRTC_VBLANK_SAVE (1 << 1) +#define R128_CRTC_V_SYNC_STRT_WID 0x020c +# define R128_CRTC_V_SYNC_STRT (0x7ff << 0) +# define R128_CRTC_V_SYNC_STRT_SHIFT 0 +# define R128_CRTC_V_SYNC_WID (0x1f << 16) +# define R128_CRTC_V_SYNC_WID_SHIFT 16 +# define R128_CRTC_V_SYNC_POL (1 << 23) +#define R128_CRTC_V_TOTAL_DISP 0x0208 +# define R128_CRTC_V_TOTAL (0x07ff << 0) +# define R128_CRTC_V_TOTAL_SHIFT 0 +# define R128_CRTC_V_DISP (0x07ff << 16) +# define R128_CRTC_V_DISP_SHIFT 16 +#define R128_CRTC_VLINE_CRNT_VLINE 0x0210 +# define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16) +#define R128_CRTC2_CRNT_FRAME 0x0314 +#define R128_CRTC2_DEBUG 0x031c +#define R128_CRTC2_GEN_CNTL 0x03f8 +#define R128_CRTC2_GUI_TRIG_VLINE 0x0318 +#define R128_CRTC2_H_SYNC_STRT_WID 0x0304 +#define R128_CRTC2_H_TOTAL_DISP 0x0300 +#define R128_CRTC2_OFFSET 0x0324 +#define R128_CRTC2_OFFSET_CNTL 0x0328 +#define R128_CRTC2_PITCH 0x032c +#define R128_CRTC2_STATUS 0x03fc +#define R128_CRTC2_V_SYNC_STRT_WID 0x030c +#define R128_CRTC2_V_TOTAL_DISP 0x0308 +#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310 +#define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ +#define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ +#define R128_CUR_CLR0 0x026c +#define R128_CUR_CLR1 0x0270 +#define R128_CUR_HORZ_VERT_OFF 0x0268 +#define R128_CUR_HORZ_VERT_POSN 0x0264 +#define R128_CUR_OFFSET 0x0260 +# define R128_CUR_LOCK (1 << 31) + +#define R128_DAC_CNTL 0x0058 +# define R128_DAC_RANGE_CNTL (3 << 0) +# define R128_DAC_BLANKING (1 << 2) +# define R128_DAC_CRT_SEL_CRTC2 (1 << 4) +# define R128_DAC_PALETTE_ACC_CTL (1 << 5) +# define R128_DAC_8BIT_EN (1 << 8) +# define R128_DAC_VGA_ADR_EN (1 << 13) +# define R128_DAC_MASK_ALL (0xff << 24) +#define R128_DAC_CRC_SIG 0x02cc +#define R128_DAC_DATA 0x03c9 /* VGA */ +#define R128_DAC_MASK 0x03c6 /* VGA */ +#define R128_DAC_R_INDEX 0x03c7 /* VGA */ +#define R128_DAC_W_INDEX 0x03c8 /* VGA */ +#define R128_DDA_CONFIG 0x02e0 +#define R128_DDA_ON_OFF 0x02e4 +#define R128_DEFAULT_OFFSET 0x16e0 +#define R128_DEFAULT_PITCH 0x16e4 +#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 +# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) +# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) +#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820 +#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 +#define R128_DEVICE_ID 0x0f02 /* PCI */ +#define R128_DP_BRUSH_BKGD_CLR 0x1478 +#define R128_DP_BRUSH_FRGD_CLR 0x147c +#define R128_DP_CNTL 0x16c0 +# define R128_DST_X_LEFT_TO_RIGHT (1 << 0) +# define R128_DST_Y_TOP_TO_BOTTOM (1 << 1) +#define R128_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 +# define R128_DST_Y_MAJOR (1 << 2) +# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) +# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) +#define R128_DP_DATATYPE 0x16c4 +# define R128_HOST_BIG_ENDIAN_EN (1 << 29) +#define R128_DP_GUI_MASTER_CNTL 0x146c +# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) +# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) +# define R128_GMC_SRC_CLIPPING (1 << 2) +# define R128_GMC_DST_CLIPPING (1 << 3) +# define R128_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) +# define R128_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) +# define R128_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) +# define R128_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) +# define R128_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) +# define R128_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) +# define R128_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) +# define R128_GMC_BRUSH_8x8_COLOR (10 << 4) +# define R128_GMC_BRUSH_1X8_COLOR (12 << 4) +# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define R128_GMC_BRUSH_NONE (15 << 4) +# define R128_GMC_DST_8BPP_CI (2 << 8) +# define R128_GMC_DST_15BPP (3 << 8) +# define R128_GMC_DST_16BPP (4 << 8) +# define R128_GMC_DST_24BPP (5 << 8) +# define R128_GMC_DST_32BPP (6 << 8) +# define R128_GMC_DST_8BPP_RGB (7 << 8) +# define R128_GMC_DST_Y8 (8 << 8) +# define R128_GMC_DST_RGB8 (9 << 8) +# define R128_GMC_DST_VYUY (11 << 8) +# define R128_GMC_DST_YVYU (12 << 8) +# define R128_GMC_DST_AYUV444 (14 << 8) +# define R128_GMC_DST_ARGB4444 (15 << 8) +# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8) +# define R128_GMC_DST_DATATYPE_SHIFT 8 +# define R128_GMC_SRC_DATATYPE_MASK (3 << 12) +# define R128_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) +# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) +# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) +# define R128_GMC_BYTE_PIX_ORDER (1 << 14) +# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14) +# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14) +# define R128_GMC_CONVERSION_TEMP (1 << 15) +# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15) +# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15) +# define R128_GMC_ROP3_MASK (0xff << 16) +# define R128_DP_SRC_SOURCE_MASK (7 << 24) +# define R128_DP_SRC_SOURCE_MEMORY (2 << 24) +# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24) +# define R128_GMC_3D_FCN_EN (1 << 27) +# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) +# define R128_GMC_AUX_CLIP_DIS (1 << 29) +# define R128_GMC_WR_MSK_DIS (1 << 30) +# define R128_GMC_LD_BRUSH_Y_X (1 << 31) +# define R128_ROP3_ZERO 0x00000000 +# define R128_ROP3_DSa 0x00880000 +# define R128_ROP3_SDna 0x00440000 +# define R128_ROP3_S 0x00cc0000 +# define R128_ROP3_DSna 0x00220000 +# define R128_ROP3_D 0x00aa0000 +# define R128_ROP3_DSx 0x00660000 +# define R128_ROP3_DSo 0x00ee0000 +# define R128_ROP3_DSon 0x00110000 +# define R128_ROP3_DSxn 0x00990000 +# define R128_ROP3_Dn 0x00550000 +# define R128_ROP3_SDno 0x00dd0000 +# define R128_ROP3_Sn 0x00330000 +# define R128_ROP3_DSno 0x00bb0000 +# define R128_ROP3_DSan 0x00770000 +# define R128_ROP3_ONE 0x00ff0000 +# define R128_ROP3_DPa 0x00a00000 +# define R128_ROP3_PDna 0x00500000 +# define R128_ROP3_P 0x00f00000 +# define R128_ROP3_DPna 0x000a0000 +# define R128_ROP3_D 0x00aa0000 +# define R128_ROP3_DPx 0x005a0000 +# define R128_ROP3_DPo 0x00fa0000 +# define R128_ROP3_DPon 0x00050000 +# define R128_ROP3_PDxn 0x00a50000 +# define R128_ROP3_PDno 0x00f50000 +# define R128_ROP3_Pn 0x000f0000 +# define R128_ROP3_DPno 0x00af0000 +# define R128_ROP3_DPan 0x005f0000 + + +#define R128_DP_GUI_MASTER_CNTL_C 0x1c84 +#define R128_DP_MIX 0x16c8 +#define R128_DP_SRC_BKGD_CLR 0x15dc +#define R128_DP_SRC_FRGD_CLR 0x15d8 +#define R128_DP_WRITE_MASK 0x16cc +#define R128_DST_BRES_DEC 0x1630 +#define R128_DST_BRES_ERR 0x1628 +#define R128_DST_BRES_INC 0x162c +#define R128_DST_BRES_LNTH 0x1634 +#define R128_DST_BRES_LNTH_SUB 0x1638 +#define R128_DST_HEIGHT 0x1410 +#define R128_DST_HEIGHT_WIDTH 0x143c +#define R128_DST_HEIGHT_WIDTH_8 0x158c +#define R128_DST_HEIGHT_WIDTH_BW 0x15b4 +#define R128_DST_HEIGHT_Y 0x15a0 +#define R128_DST_OFFSET 0x1404 +#define R128_DST_PITCH 0x1408 +#define R128_DST_PITCH_OFFSET 0x142c +#define R128_DST_PITCH_OFFSET_C 0x1c80 +# define R128_PITCH_SHIFT 21 +#define R128_DST_WIDTH 0x140c +#define R128_DST_WIDTH_HEIGHT 0x1598 +#define R128_DST_WIDTH_X 0x1588 +#define R128_DST_WIDTH_X_INCY 0x159c +#define R128_DST_X 0x141c +#define R128_DST_X_SUB 0x15a4 +#define R128_DST_X_Y 0x1594 +#define R128_DST_Y 0x1420 +#define R128_DST_Y_SUB 0x15a8 +#define R128_DST_Y_X 0x1438 + +#define R128_EXT_MEM_CNTL 0x0144 + +#define R128_FCP_CNTL 0x0012 /* PLL */ +#define R128_FLUSH_1 0x1704 +#define R128_FLUSH_2 0x1708 +#define R128_FLUSH_3 0x170c +#define R128_FLUSH_4 0x1710 +#define R128_FLUSH_5 0x1714 +#define R128_FLUSH_6 0x1718 +#define R128_FLUSH_7 0x171c +#define R128_FOG_3D_TABLE_START 0x1810 +#define R128_FOG_3D_TABLE_END 0x1814 +#define R128_FOG_3D_TABLE_DENSITY 0x181c +#define R128_FOG_TABLE_INDEX 0x1a14 +#define R128_FOG_TABLE_DATA 0x1a18 +#define R128_FP_CRTC_H_TOTAL_DISP 0x0250 +#define R128_FP_CRTC_V_TOTAL_DISP 0x0254 +#define R128_FP_GEN_CNTL 0x0284 +# define R128_FP_FPON (1 << 0) +# define R128_FP_TDMS_EN (1 << 2) +# define R128_FP_DETECT_SENSE (1 << 8) +# define R128_FP_SEL_CRTC2 (1 << 13) +# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) +# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18) +# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20) +# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) +# define R128_FP_USE_SHADOW_EN (1 << 24) +#define R128_FP_H_SYNC_STRT_WID 0x02c4 +#define R128_FP_HORZ_STRETCH 0x028c +# define R128_HORZ_STRETCH_RATIO_MASK 0xffff +# define R128_HORZ_STRETCH_RATIO_SHIFT 0 +# define R128_HORZ_STRETCH_RATIO_MAX 4096 +# define R128_HORZ_PANEL_SIZE (0xff << 16) +# define R128_HORZ_PANEL_SHIFT 16 +# define R128_HORZ_STRETCH_PIXREP (0 << 25) +# define R128_HORZ_STRETCH_BLEND (1 << 25) +# define R128_HORZ_STRETCH_ENABLE (1 << 26) +# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27) +# define R128_HORZ_STRETCH_RESERVED (1 << 30) +# define R128_HORZ_AUTO_RATIO_FIX_EN (1 << 31) + +#define R128_FP_PANEL_CNTL 0x0288 +# define R128_FP_DIGON (1 << 0) +# define R128_FP_BLON (1 << 1) +#define R128_FP_V_SYNC_STRT_WID 0x02c8 +#define R128_FP_VERT_STRETCH 0x0290 +# define R128_VERT_PANEL_SIZE (0x7ff << 0) +# define R128_VERT_PANEL_SHIFT 0 +# define R128_VERT_STRETCH_RATIO_MASK 0x3ff +# define R128_VERT_STRETCH_RATIO_SHIFT 11 +# define R128_VERT_STRETCH_RATIO_MAX 1024 +# define R128_VERT_STRETCH_ENABLE (1 << 24) +# define R128_VERT_STRETCH_LINEREP (0 << 25) +# define R128_VERT_STRETCH_BLEND (1 << 25) +# define R128_VERT_AUTO_RATIO_EN (1 << 26) +# define R128_VERT_STRETCH_RESERVED 0xf8e00000 + +#define R128_GEN_INT_CNTL 0x0040 +#define R128_GEN_INT_STATUS 0x0044 +# define R128_VSYNC_INT_AK (1 << 2) +# define R128_VSYNC_INT (1 << 2) +#define R128_GEN_RESET_CNTL 0x00f0 +# define R128_SOFT_RESET_GUI (1 << 0) +# define R128_SOFT_RESET_VCLK (1 << 8) +# define R128_SOFT_RESET_PCLK (1 << 9) +# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11) +# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12) +#define R128_GENENB 0x03c3 /* VGA */ +#define R128_GENFC_RD 0x03ca /* VGA */ +#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */ +#define R128_GENMO_RD 0x03cc /* VGA */ +#define R128_GENMO_WT 0x03c2 /* VGA */ +#define R128_GENS0 0x03c2 /* VGA */ +#define R128_GENS1 0x03da /* VGA, 0x03ba */ +#define R128_GPIO_MONID 0x0068 +# define R128_GPIO_MONID_A_0 (1 << 0) +# define R128_GPIO_MONID_A_1 (1 << 1) +# define R128_GPIO_MONID_A_2 (1 << 2) +# define R128_GPIO_MONID_A_3 (1 << 3) +# define R128_GPIO_MONID_Y_0 (1 << 8) +# define R128_GPIO_MONID_Y_1 (1 << 9) +# define R128_GPIO_MONID_Y_2 (1 << 10) +# define R128_GPIO_MONID_Y_3 (1 << 11) +# define R128_GPIO_MONID_EN_0 (1 << 16) +# define R128_GPIO_MONID_EN_1 (1 << 17) +# define R128_GPIO_MONID_EN_2 (1 << 18) +# define R128_GPIO_MONID_EN_3 (1 << 19) +# define R128_GPIO_MONID_MASK_0 (1 << 24) +# define R128_GPIO_MONID_MASK_1 (1 << 25) +# define R128_GPIO_MONID_MASK_2 (1 << 26) +# define R128_GPIO_MONID_MASK_3 (1 << 27) +#define R128_GPIO_MONIDB 0x006c +#define R128_GRPH8_DATA 0x03cf /* VGA */ +#define R128_GRPH8_IDX 0x03ce /* VGA */ +#define R128_GUI_DEBUG0 0x16a0 +#define R128_GUI_DEBUG1 0x16a4 +#define R128_GUI_DEBUG2 0x16a8 +#define R128_GUI_DEBUG3 0x16ac +#define R128_GUI_DEBUG4 0x16b0 +#define R128_GUI_DEBUG5 0x16b4 +#define R128_GUI_DEBUG6 0x16b8 +#define R128_GUI_PROBE 0x16bc +#define R128_GUI_SCRATCH_REG0 0x15e0 +#define R128_GUI_SCRATCH_REG1 0x15e4 +#define R128_GUI_SCRATCH_REG2 0x15e8 +#define R128_GUI_SCRATCH_REG3 0x15ec +#define R128_GUI_SCRATCH_REG4 0x15f0 +#define R128_GUI_SCRATCH_REG5 0x15f4 +#define R128_GUI_STAT 0x1740 +# define R128_GUI_FIFOCNT_MASK 0x0fff +# define R128_GUI_ACTIVE (1 << 31) + +#define R128_HEADER 0x0f0e /* PCI */ +#define R128_HOST_DATA0 0x17c0 +#define R128_HOST_DATA1 0x17c4 +#define R128_HOST_DATA2 0x17c8 +#define R128_HOST_DATA3 0x17cc +#define R128_HOST_DATA4 0x17d0 +#define R128_HOST_DATA5 0x17d4 +#define R128_HOST_DATA6 0x17d8 +#define R128_HOST_DATA7 0x17dc +#define R128_HOST_DATA_LAST 0x17e0 +#define R128_HOST_PATH_CNTL 0x0130 +#define R128_HTOTAL_CNTL 0x0009 /* PLL */ +#define R128_HW_DEBUG 0x0128 +#define R128_HW_DEBUG2 0x011c + +#define R128_I2C_CNTL_1 0x0094 /* ? */ +#define R128_INTERRUPT_LINE 0x0f3c /* PCI */ +#define R128_INTERRUPT_PIN 0x0f3d /* PCI */ +#define R128_IO_BASE 0x0f14 /* PCI */ + +#define R128_LATENCY 0x0f0d /* PCI */ +#define R128_LEAD_BRES_DEC 0x1608 +#define R128_LEAD_BRES_ERR 0x1600 +#define R128_LEAD_BRES_INC 0x1604 +#define R128_LEAD_BRES_LNTH 0x161c +#define R128_LEAD_BRES_LNTH_SUB 0x1624 +#define R128_LVDS_GEN_CNTL 0x02d0 +# define R128_LVDS_ON (1 << 0) +# define R128_LVDS_BLON (1 << 19) +# define R128_LVDS_SEL_CRTC2 (1 << 23) +# define R128_HSYNC_DELAY_SHIFT 28 +# define R128_HSYNC_DELAY_MASK (0xf << 28) + +#define R128_MAX_LATENCY 0x0f3f /* PCI */ +#define R128_MCLK_CNTL 0x000f /* PLL */ +# define R128_FORCE_GCP (1 << 16) +# define R128_FORCE_PIPE3D_CP (1 << 17) +# define R128_FORCE_RCP (1 << 18) +#define R128_MDGPIO_A_REG 0x01ac +#define R128_MDGPIO_EN_REG 0x01b0 +#define R128_MDGPIO_MASK 0x0198 +#define R128_MDGPIO_Y_REG 0x01b4 +#define R128_MEM_ADDR_CONFIG 0x0148 +#define R128_MEM_BASE 0x0f10 /* PCI */ +#define R128_MEM_CNTL 0x0140 +#define R128_MEM_INIT_LAT_TIMER 0x0154 +#define R128_MEM_INTF_CNTL 0x014c +#define R128_MEM_SDRAM_MODE_REG 0x0158 +#define R128_MEM_STR_CNTL 0x0150 +#define R128_MEM_VGA_RP_SEL 0x003c +#define R128_MEM_VGA_WP_SEL 0x0038 +#define R128_MIN_GRANT 0x0f3e /* PCI */ +#define R128_MM_DATA 0x0004 +#define R128_MM_INDEX 0x0000 +#define R128_MPLL_CNTL 0x000e /* PLL */ +#define R128_MPP_TB_CONFIG 0x01c0 /* ? */ +#define R128_MPP_GP_CONFIG 0x01c8 /* ? */ + +#define R128_N_VIF_COUNT 0x0248 + +#define R128_OVR_CLR 0x0230 +#define R128_OVR_WID_LEFT_RIGHT 0x0234 +#define R128_OVR_WID_TOP_BOTTOM 0x0238 + +/* first overlay unit (there is only one) */ + +#define R128_OV0_Y_X_START 0x0400 +#define R128_OV0_Y_X_END 0x0404 +#define R128_OV0_EXCLUSIVE_HORZ 0x0408 +# define R128_EXCL_HORZ_START_MASK 0x000000ff +# define R128_EXCL_HORZ_END_MASK 0x0000ff00 +# define R128_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000 +# define R128_EXCL_HORZ_EXCLUSIVE_EN 0x80000000 +#define R128_OV0_EXCLUSIVE_VERT 0x040C +# define R128_EXCL_VERT_START_MASK 0x000003ff +# define R128_EXCL_VERT_END_MASK 0x03ff0000 +#define R128_OV0_REG_LOAD_CNTL 0x0410 +# define R128_REG_LD_CTL_LOCK 0x00000001L +# define R128_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L +# define R128_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L +# define R128_REG_LD_CTL_LOCK_READBACK 0x00000008L +#define R128_OV0_SCALE_CNTL 0x0420 +# define R128_SCALER_PIX_EXPAND 0x00000001L +# define R128_SCALER_Y2R_TEMP 0x00000002L +# define R128_SCALER_HORZ_PICK_NEAREST 0x00000003L +# define R128_SCALER_VERT_PICK_NEAREST 0x00000004L +# define R128_SCALER_SIGNED_UV 0x00000010L +# define R128_SCALER_GAMMA_SEL_MASK 0x00000060L +# define R128_SCALER_GAMMA_SEL_BRIGHT 0x00000000L +# define R128_SCALER_GAMMA_SEL_G22 0x00000020L +# define R128_SCALER_GAMMA_SEL_G18 0x00000040L +# define R128_SCALER_GAMMA_SEL_G14 0x00000060L +# define R128_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L +# define R128_SCALER_SURFAC_FORMAT 0x00000f00L +# define R128_SCALER_SOURCE_15BPP 0x00000300L +# define R128_SCALER_SOURCE_16BPP 0x00000400L +# define R128_SCALER_SOURCE_32BPP 0x00000600L +# define R128_SCALER_SOURCE_YUV9 0x00000900L +# define R128_SCALER_SOURCE_YUV12 0x00000A00L +# define R128_SCALER_SOURCE_VYUY422 0x00000B00L +# define R128_SCALER_SOURCE_YVYU422 0x00000C00L +# define R128_SCALER_SMART_SWITCH 0x00008000L +# define R128_SCALER_BURST_PER_PLANE 0x00ff0000L +# define R128_SCALER_DOUBLE_BUFFER 0x01000000L +# define R128_SCALER_DIS_LIMIT 0x08000000L +# define R128_SCALER_PRG_LOAD_START 0x10000000L +# define R128_SCALER_INT_EMU 0x20000000L +# define R128_SCALER_ENABLE 0x40000000L +# define R128_SCALER_SOFT_RESET 0x80000000L +#define R128_OV0_V_INC 0x0424 +#define R128_OV0_P1_V_ACCUM_INIT 0x0428 +# define R128_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L +# define R128_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L +#define R128_OV0_P23_V_ACCUM_INIT 0x042C +#define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430 +# define R128_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL +# define R128_P1_ACTIVE_LINES_M1 0x0fff0000L +#define R128_OV0_P23_BLANK_LINES_AT_TOP 0x0434 +# define R128_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL +# define R128_P23_ACTIVE_LINES_M1 0x07ff0000L +#define R128_OV0_VID_BUF0_BASE_ADRS 0x0440 +# define R128_VIF_BUF0_PITCH_SEL 0x00000001L +# define R128_VIF_BUF0_TILE_ADRS 0x00000002L +# define R128_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF1_BASE_ADRS 0x0444 +# define R128_VIF_BUF1_PITCH_SEL 0x00000001L +# define R128_VIF_BUF1_TILE_ADRS 0x00000002L +# define R128_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF2_BASE_ADRS 0x0448 +# define R128_VIF_BUF2_PITCH_SEL 0x00000001L +# define R128_VIF_BUF2_TILE_ADRS 0x00000002L +# define R128_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF3_BASE_ADRS 0x044C +#define R128_OV0_VID_BUF4_BASE_ADRS 0x0450 +#define R128_OV0_VID_BUF5_BASE_ADRS 0x0454 +#define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460 +#define R128_OV0_VID_BUF_PITCH1_VALUE 0x0464 +#define R128_OV0_AUTO_FLIP_CNTL 0x0470 +#define R128_OV0_DEINTERLACE_PATTERN 0x0474 +#define R128_OV0_H_INC 0x0480 +#define R128_OV0_STEP_BY 0x0484 +#define R128_OV0_P1_H_ACCUM_INIT 0x0488 +#define R128_OV0_P23_H_ACCUM_INIT 0x048C +#define R128_OV0_P1_X_START_END 0x0494 +#define R128_OV0_P2_X_START_END 0x0498 +#define R128_OV0_P3_X_START_END 0x049C +#define R128_OV0_FILTER_CNTL 0x04A0 +#define R128_OV0_FOUR_TAP_COEF_0 0x04B0 +#define R128_OV0_FOUR_TAP_COEF_1 0x04B4 +#define R128_OV0_FOUR_TAP_COEF_2 0x04B8 +#define R128_OV0_FOUR_TAP_COEF_3 0x04BC +#define R128_OV0_FOUR_TAP_COEF_4 0x04C0 +#define R128_OV0_COLOUR_CNTL 0x04E0 +#define R128_OV0_VIDEO_KEY_CLR 0x04E4 +#define R128_OV0_VIDEO_KEY_MSK 0x04E8 +#define R128_OV0_GRAPHICS_KEY_CLR 0x04EC +#define R128_OV0_GRAPHICS_KEY_MSK 0x04F0 +#define R128_OV0_KEY_CNTL 0x04F4 +# define R128_VIDEO_KEY_FN_MASK 0x00000007L +# define R128_VIDEO_KEY_FN_FALSE 0x00000000L +# define R128_VIDEO_KEY_FN_TRUE 0x00000001L +# define R128_VIDEO_KEY_FN_EQ 0x00000004L +# define R128_VIDEO_KEY_FN_NE 0x00000005L +# define R128_GRAPHIC_KEY_FN_MASK 0x00000070L +# define R128_GRAPHIC_KEY_FN_FALSE 0x00000000L +# define R128_GRAPHIC_KEY_FN_TRUE 0x00000010L +# define R128_GRAPHIC_KEY_FN_EQ 0x00000040L +# define R128_GRAPHIC_KEY_FN_NE 0x00000050L +# define R128_CMP_MIX_MASK 0x00000100L +# define R128_CMP_MIX_OR 0x00000000L +# define R128_CMP_MIX_AND 0x00000100L +#define R128_OV0_TEST 0x04F8 + + +#define R128_PALETTE_DATA 0x00b4 +#define R128_PALETTE_INDEX 0x00b0 +#define R128_PC_DEBUG_MODE 0x1760 +#define R128_PC_GUI_CTLSTAT 0x1748 +#define R128_PC_GUI_MODE 0x1744 +# define R128_PC_IGNORE_UNIFY (1 << 5) +#define R128_PC_MISC_CNTL 0x0188 +#define R128_PC_NGUI_CTLSTAT 0x0184 +# define R128_PC_FLUSH_GUI (3 << 0) +# define R128_PC_RI_GUI (1 << 2) +# define R128_PC_FLUSH_ALL 0x00ff +# define R128_PC_BUSY (1 << 31) +#define R128_PC_NGUI_MODE 0x0180 +#define R128_PCI_GART_PAGE 0x017c +#define R128_PLANE_3D_MASK_C 0x1d44 +#define R128_PLL_TEST_CNTL 0x0013 /* PLL */ +#define R128_PMI_CAP_ID 0x0f5c /* PCI */ +#define R128_PMI_DATA 0x0f63 /* PCI */ +#define R128_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ +#define R128_PMI_PMC_REG 0x0f5e /* PCI */ +#define R128_PMI_PMCSR_REG 0x0f60 /* PCI */ +#define R128_PMI_REGISTER 0x0f5c /* PCI */ +#define R128_PPLL_CNTL 0x0002 /* PLL */ +# define R128_PPLL_RESET (1 << 0) +# define R128_PPLL_SLEEP (1 << 1) +# define R128_PPLL_ATOMIC_UPDATE_EN (1 << 16) +# define R128_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) +#define R128_PPLL_DIV_0 0x0004 /* PLL */ +#define R128_PPLL_DIV_1 0x0005 /* PLL */ +#define R128_PPLL_DIV_2 0x0006 /* PLL */ +#define R128_PPLL_DIV_3 0x0007 /* PLL */ +# define R128_PPLL_FB3_DIV_MASK 0x07ff +# define R128_PPLL_POST3_DIV_MASK 0x00070000 +#define R128_PPLL_REF_DIV 0x0003 /* PLL */ +# define R128_PPLL_REF_DIV_MASK 0x03ff +# define R128_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ +# define R128_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ +#define R128_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ +#define R128_REG_BASE 0x0f18 /* PCI */ +#define R128_REGPROG_INF 0x0f09 /* PCI */ +#define R128_REVISION_ID 0x0f08 /* PCI */ + +#define R128_SC_BOTTOM 0x164c +#define R128_SC_BOTTOM_RIGHT 0x16f0 +#define R128_SC_BOTTOM_RIGHT_C 0x1c8c +#define R128_SC_LEFT 0x1640 +#define R128_SC_RIGHT 0x1644 +#define R128_SC_TOP 0x1648 +#define R128_SC_TOP_LEFT 0x16ec +#define R128_SC_TOP_LEFT_C 0x1c88 +#define R128_SEQ8_DATA 0x03c5 /* VGA */ +#define R128_SEQ8_IDX 0x03c4 /* VGA */ +#define R128_SNAPSHOT_F_COUNT 0x0244 +#define R128_SNAPSHOT_VH_COUNTS 0x0240 +#define R128_SNAPSHOT_VIF_COUNT 0x024c +#define R128_SRC_OFFSET 0x15ac +#define R128_SRC_PITCH 0x15b0 +#define R128_SRC_PITCH_OFFSET 0x1428 +#define R128_SRC_SC_BOTTOM 0x165c +#define R128_SRC_SC_BOTTOM_RIGHT 0x16f4 +#define R128_SRC_SC_RIGHT 0x1654 +#define R128_SRC_X 0x1414 +#define R128_SRC_X_Y 0x1590 +#define R128_SRC_Y 0x1418 +#define R128_SRC_Y_X 0x1434 +#define R128_STATUS 0x0f06 /* PCI */ +#define R128_SUBPIC_CNTL 0x0540 /* ? */ +#define R128_SUB_CLASS 0x0f0a /* PCI */ +#define R128_SURFACE_DELAY 0x0b00 +#define R128_SURFACE0_INFO 0x0b0c +#define R128_SURFACE0_LOWER_BOUND 0x0b04 +#define R128_SURFACE0_UPPER_BOUND 0x0b08 +#define R128_SURFACE1_INFO 0x0b1c +#define R128_SURFACE1_LOWER_BOUND 0x0b14 +#define R128_SURFACE1_UPPER_BOUND 0x0b18 +#define R128_SURFACE2_INFO 0x0b2c +#define R128_SURFACE2_LOWER_BOUND 0x0b24 +#define R128_SURFACE2_UPPER_BOUND 0x0b28 +#define R128_SURFACE3_INFO 0x0b3c +#define R128_SURFACE3_LOWER_BOUND 0x0b34 +#define R128_SURFACE3_UPPER_BOUND 0x0b38 +#define R128_SW_SEMAPHORE 0x013c + +#define R128_TEST_DEBUG_CNTL 0x0120 +#define R128_TEST_DEBUG_MUX 0x0124 +#define R128_TEST_DEBUG_OUT 0x012c +#define R128_TMDS_CRC 0x02a0 +#define R128_TRAIL_BRES_DEC 0x1614 +#define R128_TRAIL_BRES_ERR 0x160c +#define R128_TRAIL_BRES_INC 0x1610 +#define R128_TRAIL_X 0x1618 +#define R128_TRAIL_X_SUB 0x1620 + +#define R128_VCLK_ECP_CNTL 0x0008 /* PLL */ +#define R128_VENDOR_ID 0x0f00 /* PCI */ +#define R128_VGA_DDA_CONFIG 0x02e8 +#define R128_VGA_DDA_ON_OFF 0x02ec +#define R128_VID_BUFFER_CONTROL 0x0900 +#define R128_VIDEOMUX_CNTL 0x0190 +#define R128_VIPH_CONTROL 0x01D0 /* ? */ + +#define R128_WAIT_UNTIL 0x1720 + +#define R128_X_MPLL_REF_FB_DIV 0x000a /* PLL */ +#define R128_XCLK_CNTL 0x000d /* PLL */ +#define R128_XDLL_CNTL 0x000c /* PLL */ +#define R128_XPLL_CNTL 0x000b /* PLL */ + + /* Registers for CCE and Microcode Engine */ +#define R128_PM4_MICROCODE_ADDR 0x07d4 +#define R128_PM4_MICROCODE_RADDR 0x07d8 +#define R128_PM4_MICROCODE_DATAH 0x07dc +#define R128_PM4_MICROCODE_DATAL 0x07e0 + +#define R128_PM4_BUFFER_OFFSET 0x0700 +#define R128_PM4_BUFFER_CNTL 0x0704 +# define R128_PM4_NONPM4 (0 << 28) +# define R128_PM4_192PIO (1 << 28) +# define R128_PM4_192BM (2 << 28) +# define R128_PM4_128PIO_64INDBM (3 << 28) +# define R128_PM4_128BM_64INDBM (4 << 28) +# define R128_PM4_64PIO_128INDBM (5 << 28) +# define R128_PM4_64BM_128INDBM (6 << 28) +# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) +# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) +# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) +#define R128_PM4_BUFFER_WM_CNTL 0x0708 +# define R128_WMA_SHIFT 0 +# define R128_WMB_SHIFT 8 +# define R128_WMC_SHIFT 16 +# define R128_WB_WM_SHIFT 24 +#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c +#define R128_PM4_BUFFER_DL_RPTR 0x0710 +#define R128_PM4_BUFFER_DL_WPTR 0x0714 +# define R128_PM4_BUFFER_DL_DONE (1 << 31) +#define R128_PM4_BUFFER_DL_WPTR_DELAY 0x0718 +# define R128_PRE_WRITE_TIMER_SHIFT 0 +# define R128_PRE_WRITE_LIMIT_SHIFT 23 +#define R128_PM4_VC_FPU_SETUP 0x071c +# define R128_FRONT_DIR_CW (0 << 0) +# define R128_FRONT_DIR_CCW (1 << 0) +# define R128_FRONT_DIR_MASK (1 << 0) +# define R128_BACKFACE_CULL (0 << 1) +# define R128_BACKFACE_POINTS (1 << 1) +# define R128_BACKFACE_LINES (2 << 1) +# define R128_BACKFACE_SOLID (3 << 1) +# define R128_BACKFACE_MASK (3 << 1) +# define R128_FRONTFACE_CULL (0 << 3) +# define R128_FRONTFACE_POINTS (1 << 3) +# define R128_FRONTFACE_LINES (2 << 3) +# define R128_FRONTFACE_SOLID (3 << 3) +# define R128_FRONTFACE_MASK (3 << 3) +# define R128_FPU_COLOR_SOLID (0 << 5) +# define R128_FPU_COLOR_FLAT (1 << 5) +# define R128_FPU_COLOR_GOURAUD (2 << 5) +# define R128_FPU_COLOR_GOURAUD2 (3 << 5) +# define R128_FPU_COLOR_MASK (3 << 5) +# define R128_FPU_SUB_PIX_2BITS (0 << 7) +# define R128_FPU_SUB_PIX_4BITS (1 << 7) +# define R128_FPU_MODE_2D (0 << 8) +# define R128_FPU_MODE_3D (1 << 8) +# define R128_TRAP_BITS_DISABLE (1 << 9) +# define R128_EDGE_ANTIALIAS (1 << 10) +# define R128_SUPERSAMPLE (1 << 11) +# define R128_XFACTOR_2 (0 << 12) +# define R128_XFACTOR_4 (1 << 12) +# define R128_YFACTOR_2 (0 << 13) +# define R128_YFACTOR_4 (1 << 13) +# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14) +# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14) +# define R128_FPU_ROUND_TRUNCATE (0 << 15) +# define R128_FPU_ROUND_NEAREST (1 << 15) +# define R128_WM_SEL_8DW (0 << 16) +# define R128_WM_SEL_16DW (1 << 16) +# define R128_WM_SEL_32DW (2 << 16) +#define R128_PM4_VC_DEBUG_CONFIG 0x07a4 +#define R128_PM4_VC_STAT 0x07a8 +#define R128_PM4_VC_TIMESTAMP0 0x07b0 +#define R128_PM4_VC_TIMESTAMP1 0x07b4 +#define R128_PM4_STAT 0x07b8 +# define R128_PM4_FIFOCNT_MASK 0x0fff +# define R128_PM4_BUSY (1 << 16) +# define R128_PM4_GUI_ACTIVE (1 << 31) +#define R128_PM4_BUFFER_ADDR 0x07f0 +#define R128_PM4_MICRO_CNTL 0x07fc +# define R128_PM4_MICRO_FREERUN (1 << 30) +#define R128_PM4_FIFO_DATA_EVEN 0x1000 +#define R128_PM4_FIFO_DATA_ODD 0x1004 + +#define R128_SCALE_3D_CNTL 0x1a00 +# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) +# define R128_SCALE_DITHER_TABLE (1 << 1) +# define R128_TEX_CACHE_SIZE_FULL (0 << 2) +# define R128_TEX_CACHE_SIZE_HALF (1 << 2) +# define R128_DITHER_INIT_CURR (0 << 3) +# define R128_DITHER_INIT_RESET (1 << 3) +# define R128_ROUND_24BIT (1 << 4) +# define R128_TEX_CACHE_DISABLE (1 << 5) +# define R128_SCALE_3D_NOOP (0 << 6) +# define R128_SCALE_3D_SCALE (1 << 6) +# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define R128_SCALE_PIX_BLEND (0 << 8) +# define R128_SCALE_PIX_REPLICATE (1 << 8) +# define R128_TEX_CACHE_SPLIT (1 << 9) +# define R128_APPLE_YUV_MODE (1 << 10) +# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define R128_FOG_TABLE (1 << 14) +# define R128_SIGNED_DST_CLAMP (1 << 15) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16) +# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) +# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) +# define R128_COMPOSITE_SHADOW (1 << 29) +# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) +# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31) +# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31) +#define R128_SCALE_3D_DATATYPE 0x1a20 + +#define R128_SETUP_CNTL 0x1bc4 +# define R128_DONT_START_TRIANGLE (1 << 0) +# define R128_Z_BIAS (0 << 1) +# define R128_DONT_START_ANY_ON (1 << 2) +# define R128_COLOR_SOLID_COLOR (0 << 3) +# define R128_COLOR_FLAT_VERT_1 (1 << 3) +# define R128_COLOR_FLAT_VERT_2 (2 << 3) +# define R128_COLOR_FLAT_VERT_3 (3 << 3) +# define R128_COLOR_GOURAUD (4 << 3) +# define R128_PRIM_TYPE_TRI (0 << 7) +# define R128_PRIM_TYPE_LINE (1 << 7) +# define R128_PRIM_TYPE_POINT (2 << 7) +# define R128_PRIM_TYPE_POLY_EDGE (3 << 7) +# define R128_TEXTURE_ST_MULT_W (0 << 9) +# define R128_TEXTURE_ST_DIRECT (1 << 9) +# define R128_STARTING_VERTEX_1 (1 << 14) +# define R128_STARTING_VERTEX_2 (2 << 14) +# define R128_STARTING_VERTEX_3 (3 << 14) +# define R128_ENDING_VERTEX_1 (1 << 16) +# define R128_ENDING_VERTEX_2 (2 << 16) +# define R128_ENDING_VERTEX_3 (3 << 16) +# define R128_SU_POLY_LINE_LAST (0 << 18) +# define R128_SU_POLY_LINE_NOT_LAST (1 << 18) +# define R128_SUB_PIX_2BITS (0 << 19) +# define R128_SUB_PIX_4BITS (1 << 19) +# define R128_SET_UP_CONTINUE (1 << 31) + +#define R128_WINDOW_XY_OFFSET 0x1bcc +# define R128_WINDOW_Y_SHIFT 4 +# define R128_WINDOW_X_SHIFT 20 + +#define R128_Z_OFFSET_C 0x1c90 +#define R128_Z_PITCH_C 0x1c94 +#define R128_Z_STEN_CNTL_C 0x1c98 +# define R128_Z_PIX_WIDTH_16 (0 << 1) +# define R128_Z_PIX_WIDTH_24 (1 << 1) +# define R128_Z_PIX_WIDTH_32 (2 << 1) +# define R128_Z_PIX_WIDTH_MASK (3 << 1) +# define R128_Z_TEST_NEVER (0 << 4) +# define R128_Z_TEST_LESS (1 << 4) +# define R128_Z_TEST_LESSEQUAL (2 << 4) +# define R128_Z_TEST_EQUAL (3 << 4) +# define R128_Z_TEST_GREATEREQUAL (4 << 4) +# define R128_Z_TEST_GREATER (5 << 4) +# define R128_Z_TEST_NEQUAL (6 << 4) +# define R128_Z_TEST_ALWAYS (7 << 4) +# define R128_Z_TEST_MASK (7 << 4) +# define R128_STENCIL_TEST_NEVER (0 << 12) +# define R128_STENCIL_TEST_LESS (1 << 12) +# define R128_STENCIL_TEST_LESSEQUAL (2 << 12) +# define R128_STENCIL_TEST_EQUAL (3 << 12) +# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12) +# define R128_STENCIL_TEST_GREATER (5 << 12) +# define R128_STENCIL_TEST_NEQUAL (6 << 12) +# define R128_STENCIL_TEST_ALWAYS (7 << 12) +# define R128_STENCIL_S_FAIL_KEEP (0 << 16) +# define R128_STENCIL_S_FAIL_ZERO (1 << 16) +# define R128_STENCIL_S_FAIL_REPLACE (2 << 16) +# define R128_STENCIL_S_FAIL_INC (3 << 16) +# define R128_STENCIL_S_FAIL_DEC (4 << 16) +# define R128_STENCIL_S_FAIL_INV (5 << 16) +# define R128_STENCIL_ZPASS_KEEP (0 << 20) +# define R128_STENCIL_ZPASS_ZERO (1 << 20) +# define R128_STENCIL_ZPASS_REPLACE (2 << 20) +# define R128_STENCIL_ZPASS_INC (3 << 20) +# define R128_STENCIL_ZPASS_DEC (4 << 20) +# define R128_STENCIL_ZPASS_INV (5 << 20) +# define R128_STENCIL_ZFAIL_KEEP (0 << 24) +# define R128_STENCIL_ZFAIL_ZERO (1 << 24) +# define R128_STENCIL_ZFAIL_REPLACE (2 << 24) +# define R128_STENCIL_ZFAIL_INC (3 << 24) +# define R128_STENCIL_ZFAIL_DEC (4 << 24) +# define R128_STENCIL_ZFAIL_INV (5 << 24) +#define R128_TEX_CNTL_C 0x1c9c +# define R128_Z_ENABLE (1 << 0) +# define R128_Z_WRITE_ENABLE (1 << 1) +# define R128_STENCIL_ENABLE (1 << 3) +# define R128_SHADE_ENABLE (0 << 4) +# define R128_TEXMAP_ENABLE (1 << 4) +# define R128_SEC_TEXMAP_ENABLE (1 << 5) +# define R128_FOG_ENABLE (1 << 7) +# define R128_DITHER_ENABLE (1 << 8) +# define R128_ALPHA_ENABLE (1 << 9) +# define R128_ALPHA_TEST_ENABLE (1 << 10) +# define R128_SPEC_LIGHT_ENABLE (1 << 11) +# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) +# define R128_LIGHT_DIS (0 << 14) +# define R128_LIGHT_COPY (1 << 14) +# define R128_LIGHT_MODULATE (2 << 14) +# define R128_LIGHT_ADD (3 << 14) +# define R128_LIGHT_BLEND_CONSTANT (4 << 14) +# define R128_LIGHT_BLEND_TEXTURE (5 << 14) +# define R128_LIGHT_BLEND_VERTEX (6 << 14) +# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define R128_ALPHA_LIGHT_DIS (0 << 18) +# define R128_ALPHA_LIGHT_COPY (1 << 18) +# define R128_ALPHA_LIGHT_MODULATE (2 << 18) +# define R128_ALPHA_LIGHT_ADD (3 << 18) +# define R128_ANTI_ALIAS (1 << 21) +# define R128_TEX_CACHE_FLUSH (1 << 23) +# define R128_LOD_BIAS_SHIFT 24 +#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0 +# define R128_REF_ALPHA_MASK 0xff +# define R128_MISC_SCALE_3D_NOOP (0 << 8) +# define R128_MISC_SCALE_3D_SCALE (1 << 8) +# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define R128_MISC_SCALE_PIX_BLEND (0 << 10) +# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define R128_FOG_VERTEX (0 << 14) +# define R128_FOG_TABLE (1 << 14) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) +# define R128_ALPHA_BLEND_SRC_MASK (15 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) +# define R128_ALPHA_BLEND_DST_MASK (15 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_ALPHA_TEST_MASK (7 << 24) +#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 +#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 +#define R128_FOG_COLOR_C 0x1cac +# define R128_FOG_BLUE_SHIFT 0 +# define R128_FOG_GREEN_SHIFT 8 +# define R128_FOG_RED_SHIFT 16 +#define R128_PRIM_TEX_CNTL_C 0x1cb0 +# define R128_MIN_BLEND_NEAREST (0 << 1) +# define R128_MIN_BLEND_LINEAR (1 << 1) +# define R128_MIN_BLEND_MIPNEAREST (2 << 1) +# define R128_MIN_BLEND_MIPLINEAR (3 << 1) +# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1) +# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1) +# define R128_MIN_BLEND_MASK (7 << 1) +# define R128_MAG_BLEND_NEAREST (0 << 4) +# define R128_MAG_BLEND_LINEAR (1 << 4) +# define R128_MAG_BLEND_MASK (7 << 4) +# define R128_MIP_MAP_DISABLE (1 << 7) +# define R128_TEX_CLAMP_S_WRAP (0 << 8) +# define R128_TEX_CLAMP_S_MIRROR (1 << 8) +# define R128_TEX_CLAMP_S_CLAMP (2 << 8) +# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8) +# define R128_TEX_CLAMP_S_MASK (3 << 8) +# define R128_TEX_WRAP_S (1 << 10) +# define R128_TEX_CLAMP_T_WRAP (0 << 11) +# define R128_TEX_CLAMP_T_MIRROR (1 << 11) +# define R128_TEX_CLAMP_T_CLAMP (2 << 11) +# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11) +# define R128_TEX_CLAMP_T_MASK (3 << 11) +# define R128_TEX_WRAP_T (1 << 13) +# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14) +# define R128_DATATYPE_VQ (0 << 16) +# define R128_DATATYPE_CI4 (1 << 16) +# define R128_DATATYPE_CI8 (2 << 16) +# define R128_DATATYPE_ARGB1555 (3 << 16) +# define R128_DATATYPE_RGB565 (4 << 16) +# define R128_DATATYPE_RGB888 (5 << 16) +# define R128_DATATYPE_ARGB8888 (6 << 16) +# define R128_DATATYPE_RGB332 (7 << 16) +# define R128_DATATYPE_Y8 (8 << 16) +# define R128_DATATYPE_RGB8 (9 << 16) +# define R128_DATATYPE_CI16 (10 << 16) +# define R128_DATATYPE_YUV422 (11 << 16) +# define R128_DATATYPE_YUV422_2 (12 << 16) +# define R128_DATATYPE_AYUV444 (14 << 16) +# define R128_DATATYPE_ARGB4444 (15 << 16) +# define R128_PALLETE_EITHER (0 << 20) +# define R128_PALLETE_1 (1 << 20) +# define R128_PALLETE_2 (2 << 20) +# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) +#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 +# define R128_COMB_DIS (0 << 0) +# define R128_COMB_COPY (1 << 0) +# define R128_COMB_COPY_INP (2 << 0) +# define R128_COMB_MODULATE (3 << 0) +# define R128_COMB_MODULATE2X (4 << 0) +# define R128_COMB_MODULATE4X (5 << 0) +# define R128_COMB_ADD (6 << 0) +# define R128_COMB_ADD_SIGNED (7 << 0) +# define R128_COMB_BLEND_VERTEX (8 << 0) +# define R128_COMB_BLEND_TEXTURE (9 << 0) +# define R128_COMB_BLEND_CONST (10 << 0) +# define R128_COMB_BLEND_PREMULT (11 << 0) +# define R128_COMB_BLEND_PREV (12 << 0) +# define R128_COMB_BLEND_PREMULT_INV (13 << 0) +# define R128_COMB_ADD_SIGNED2X (14 << 0) +# define R128_COMB_BLEND_CONST_COLOR (15 << 0) +# define R128_COMB_MASK (15 << 0) +# define R128_COLOR_FACTOR_TEX (4 << 4) +# define R128_COLOR_FACTOR_NTEX (5 << 4) +# define R128_COLOR_FACTOR_ALPHA (6 << 4) +# define R128_COLOR_FACTOR_NALPHA (7 << 4) +# define R128_COLOR_FACTOR_MASK (15 << 4) +# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10) +# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10) +# define R128_INPUT_FACTOR_INT_COLOR (4 << 10) +# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10) +# define R128_INPUT_FACTOR_MASK (15 << 10) +# define R128_COMB_ALPHA_DIS (0 << 14) +# define R128_COMB_ALPHA_COPY (1 << 14) +# define R128_COMB_ALPHA_COPY_INP (2 << 14) +# define R128_COMB_ALPHA_MODULATE (3 << 14) +# define R128_COMB_ALPHA_MODULATE2X (4 << 14) +# define R128_COMB_ALPHA_MODULATE4X (5 << 14) +# define R128_COMB_ALPHA_ADD (6 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14) +# define R128_COMB_ALPHA_MASK (15 << 14) +# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18) +# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) +# define R128_ALPHA_FACTOR_MASK (15 << 18) +# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25) +# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25) +# define R128_INP_FACTOR_A_MASK (7 << 25) +#define R128_TEX_SIZE_PITCH_C 0x1cb8 +# define R128_TEX_PITCH_SHIFT 0 +# define R128_TEX_SIZE_SHIFT 4 +# define R128_TEX_HEIGHT_SHIFT 8 +# define R128_TEX_MIN_SIZE_SHIFT 12 +# define R128_SEC_TEX_PITCH_SHIFT 16 +# define R128_SEC_TEX_SIZE_SHIFT 20 +# define R128_SEC_TEX_HEIGHT_SHIFT 24 +# define R128_SEC_TEX_MIN_SIZE_SHIFT 28 +# define R128_TEX_PITCH_MASK (0x0f << 0) +# define R128_TEX_SIZE_MASK (0x0f << 4) +# define R128_TEX_HEIGHT_MASK (0x0f << 8) +# define R128_TEX_MIN_SIZE_MASK (0x0f << 12) +# define R128_SEC_TEX_PITCH_MASK (0x0f << 16) +# define R128_SEC_TEX_SIZE_MASK (0x0f << 20) +# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24) +# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) +# define R128_TEX_SIZE_PITCH_SHIFT 0 +# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16 +# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0) +# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) +#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc +#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0 +#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4 +#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8 +#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc +#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0 +#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4 +#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8 +#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc +#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0 +#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4 +# define R128_TEX_NO_TILE (0 << 30) +# define R128_TEX_TILED_BY_HOST (1 << 30) +# define R128_TEX_TILED_BY_STORAGE (2 << 30) +# define R128_TEX_TILED_BY_STORAGE2 (3 << 30) + +#define R128_SEC_TEX_CNTL_C 0x1d00 +# define R128_SEC_SELECT_PRIM_ST (0 << 0) +# define R128_SEC_SELECT_SEC_ST (1 << 0) +#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04 +# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) +# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) +# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) +#define R128_SEC_TEX_0_OFFSET_C 0x1d08 +#define R128_SEC_TEX_1_OFFSET_C 0x1d0c +#define R128_SEC_TEX_2_OFFSET_C 0x1d10 +#define R128_SEC_TEX_3_OFFSET_C 0x1d14 +#define R128_SEC_TEX_4_OFFSET_C 0x1d18 +#define R128_SEC_TEX_5_OFFSET_C 0x1d1c +#define R128_SEC_TEX_6_OFFSET_C 0x1d20 +#define R128_SEC_TEX_7_OFFSET_C 0x1d24 +#define R128_SEC_TEX_8_OFFSET_C 0x1d28 +#define R128_SEC_TEX_9_OFFSET_C 0x1d2c +#define R128_SEC_TEX_10_OFFSET_C 0x1d30 +#define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_BLUE_SHIFT 0 +# define R128_CONSTANT_GREEN_SHIFT 8 +# define R128_CONSTANT_RED_SHIFT 16 +# define R128_CONSTANT_ALPHA_SHIFT 24 +#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 +# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0 +# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8 +# define R128_PRIM_TEX_BORDER_RED_SHIFT 16 +# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0 +# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8 +# define R128_SEC_TEX_BORDER_RED_SHIFT 16 +# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_STEN_REF_MASK_C 0x1d40 +# define R128_STEN_REFERENCE_SHIFT 0 +# define R128_STEN_MASK_SHIFT 16 +# define R128_STEN_WRITE_MASK_SHIFT 24 +#define R128_PLANE_3D_MASK_C 0x1d44 +#define R128_TEX_CACHE_STAT_COUNT 0x1974 + + + /* Constants */ +#define R128_AGP_TEX_OFFSET 0x02000000 + +#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0 +#define R128_SWAP_AGE_REG R128_GUI_SCRATCH_REG1 + + /* CCE packet types */ +#define R128_CCE_PACKET0 0x00000000 +#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000 +#define R128_CCE_PACKET1 0x40000000 +#define R128_CCE_PACKET2 0x80000000 +#define R128_CCE_PACKET3_NOP 0xC0001000 +#define R128_CCE_PACKET3_PAINT 0xC0001100 +#define R128_CCE_PACKET3_BITBLT 0xC0001200 +#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300 +#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 +#define R128_CCE_PACKET3_POLYLINE 0xC0001500 +#define R128_CCE_PACKET3_SCALING 0xC0001600 +#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700 +#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800 +#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900 +#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00 +#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 +#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 +#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00 +#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 +#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100 +#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200 +#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 +#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 +#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 +#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600 +#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 +#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 +#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 +#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 +#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 +#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 +#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 +#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 +#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 +#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 +#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 +#define R128_CCE_PACKET3_PURGE 0xC0002D00 +#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 +# define R128_CCE_PACKET_MASK 0xC0000000 +# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 +# define R128_CCE_PACKET_MAX_DWORDS (1 << 14) +# define R128_CCE_PACKET0_REG_MASK 0x000007ff +# define R128_CCE_PACKET1_REG0_MASK 0x000007ff +# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define R128_CCE_VC_FRMT_RHW 0x00000001 +#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 +#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004 +#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 +#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010 +#define R128_CCE_VC_FRMT_SPEC_F 0x00000020 +#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040 +#define R128_CCE_VC_FRMT_S_T 0x00000080 +#define R128_CCE_VC_FRMT_S2_T2 0x00000100 +#define R128_CCE_VC_FRMT_RHW2 0x00000200 + +#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define R128_CCE_VC_CNTL_NUM_SHIFT 16 + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h new file mode 100644 index 000000000..d9d8d00e6 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h @@ -0,0 +1,76 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h,v 1.1 2000/11/02 16:55:38 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_SAREA_H_ +#define _R128_SAREA_H_ + +/* There are 2 heaps (local/AGP). Each region within a heap is a + minimum of 64k, and there are at most 64 of them per heap. */ +#define R128_LOCAL_TEX_HEAP 0 +#define R128_AGP_TEX_HEAP 1 +#define R128_NR_TEX_HEAPS 2 +#define R128_NR_TEX_REGIONS 64 +#define R128_LOG_TEX_GRANULARITY 16 + +typedef struct { + unsigned char next, prev; /* indices to form a circular LRU */ + unsigned char in_use; /* owned by a client, or free? */ + int age; /* tracked by clients to update local LRU's */ +} R128TexRegion; + +typedef struct { + /* Maintain an LRU of contiguous regions of texture space. If you + * think you own a region of texture memory, and it has an age + * different to the one you set, then you are mistaken and it has + * been stolen by another client. If global texAge hasn't changed, + * there is no need to walk the list. + * + * These regions can be used as a proxy for the fine-grained texture + * information of other clients - by maintaining them in the same + * lru which is used to age their own textures, clients have an + * approximate lru for the whole of global texture space, and can + * make informed decisions as to which areas to kick out. There is + * no need to choose whether to kick out your own texture or someone + * else's - simply eject them all in LRU order. + */ + /* Last elt is sentinal */ + R128TexRegion texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; + /* last time texture was uploaded */ + int texAge[R128_NR_TEX_HEAPS]; + + int ctxOwner; /* last context to upload state */ + + CARD32 ringWrite; /* current ring buffer write index */ +} R128SAREAPriv, *R128SAREAPrivPtr; + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h new file mode 100644 index 000000000..3c366c49a --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h @@ -0,0 +1,41 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h,v 1.1 2000/11/02 16:55:39 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 _R128_VERSION_H_ +#define _R128_VERSION_H_ 1 + +#define R128_NAME "R128" +#define R128_DRIVER_NAME "r128" + +#define R128_VERSION_NAME "4.0.1" + +#define R128_VERSION_MAJOR 4 +#define R128_VERSION_MINOR 0 +#define R128_VERSION_PATCH 1 + +#define R128_VERSION_CURRENT \ + ((R128_VERSION_MAJOR << 20) | \ + (R128_VERSION_MINOR << 10) | \ + (R128_VERSION_PATCH)) + +#endif /* _R128_VERSION_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c new file mode 100644 index 000000000..8c8977e8f --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c @@ -0,0 +1,796 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c,v 1.1 2000/11/02 16:55:39 tsi Exp $ */ +/* + * Copyright 2000 Stuart R. Anderson and Metro Link, 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Stuart R. Anderson <anderson@metrolink.com> + * + * Credits: + * + * This code is derived primarily from the GATOS Project run by Stea Greene. + * The initial version of this code was done by Vladimir Dergacheb. + * + * This code was simplified from the GATOS code primarily because I didn't + * have the right hardware handy to test anything beyond simple overlays, + * and because I wanted to complete it in a short time frame that I had + * available. + * + * My apologies to Vladimir as there is more good work in his code that + * should be brought forward. + */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "xf86xv.h" +#include "xf86Cursor.h" +#include "Xv.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" +#ifdef XF86DRI +#include "r128_dri.h" +#endif + +#include "r128.h" +#include "r128_reg.h" + +/* + * For Debug +#define OUTREG(addr, val) { xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"OUTREG(%s,%x)\n",#addr,val) ;MMIO_OUT32(R128MMIO, addr, val);} +*/ + +#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) + +#ifndef XvExtension +void R128InitVideo(ScreenPtr pScreen) {} +#else +static XF86VideoAdaptorPtr R128SetupImageVideo(ScreenPtr); +static int R128SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int R128GetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); + +static void R128StopVideo(ScrnInfoPtr, pointer, Bool); +static void R128QueryBestSize(ScrnInfoPtr, Bool, + short, short, short, short, unsigned int *, unsigned int *, pointer); +static int R128PutImage( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, pointer); +static int R128QueryImageAttributes(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +#define IMAGE_MAX_WIDTH 2048 +#define IMAGE_MAX_HEIGHT 2048 +#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) + +static Atom xvColorKey; + +typedef struct { + int videoStatus; + unsigned char brightness; + unsigned char contrast; + + RegionRec clip; + CARD32 colorKey; + CARD8 overlay_pixel_size; + CARD8 current_buffer; + int overlay_pad; + CARD32 overlay_id; + CARD32 overlay_width; + + CARD32 scale_cntl; + CARD32 video_format; + FBLinearPtr linear; + } R128PortPrivRec, *R128PortPrivPtr; + +void R128InitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + R128TRACE(("R128InitVideo called\n")); + + /* Determine if the card supports this */ + if (pScrn->bitsPerPixel != 8) + { + newAdaptor = R128SetupImageVideo(pScreen); + } + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 3 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {15, TrueColor}, + {16, TrueColor}, + {32, TrueColor} +}; + +#define NUM_ATTRIBUTES 1 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1<<24)-1, "XV_COLORKEY"}, +}; + +#define NUM_IMAGES 3 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_UYVY +}; + +static void +R128ResetVideo(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + R128TRACE(("R128ResetVideo called\n")); + + /* Initialize some of the HW here */ + OUTREG(R128_OV0_EXCLUSIVE_HORZ,0); /* disable exclusive mode */ + OUTREG(R128_OV0_VIDEO_KEY_MSK,0xffff); + OUTREG(R128_OV0_KEY_CNTL, R128_GRAPHIC_KEY_FN_NE); + OUTREG(R128_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + /* Only using one buffer for now + OUTREG(R128_OV0_AUTO_FLIP_CNTL,pAPriv->Port[0].auto_flip_cntl); + */ + switch(pScrn->depth){ + case 8: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xff); + break; + case 15: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0x7fff); + break; + case 16: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffff); + break; + case 24: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffffff); + break; + case 32: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffffffff); + break; + } + + OUTREG(R128_OV0_REG_LOAD_CNTL,0x0); + OUTREG(R128_OV0_DEINTERLACE_PATTERN,0xAAAAA); + OUTREG(R128_OV0_P1_V_ACCUM_INIT,(2<<20)|1); + OUTREG(R128_OV0_P23_V_ACCUM_INIT,(2<<20)|1); + OUTREG(R128_OV0_P1_H_ACCUM_INIT,(3<<28)); + OUTREG(R128_OV0_P23_H_ACCUM_INIT,(2<<28)); + OUTREG(R128_OV0_STEP_BY,1|(1<<8)); + OUTREG(R128_OV0_FILTER_CNTL,0xf); /* use hardcoded coeff's */ + OUTREG(R128_OV0_FILTER_CNTL,0x0); /* use programmable coeff's */ + OUTREG(R128_OV0_FOUR_TAP_COEF_0 , 0x00002000); + OUTREG(R128_OV0_FOUR_TAP_COEF_1 , 0x0D06200D); + OUTREG(R128_OV0_FOUR_TAP_COEF_2 , 0x0D0A1C0D); + OUTREG(R128_OV0_FOUR_TAP_COEF_3 , 0x0C0E1A0C); + OUTREG(R128_OV0_FOUR_TAP_COEF_4 , 0x0C14140C); + OUTREG(R128_OV0_COLOUR_CNTL,(1<<12)|(1<<20)); + OUTREG(R128_OV0_TEST,0); + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + OUTREG(R128_CAP0_TRIG_CNTL,0); +} + +static XF86VideoAdaptorPtr +R128SetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + XF86VideoAdaptorPtr adapt; + R128PortPrivPtr pPriv; + + R128TRACE(("R128SetupImageVideo called\n")); + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(R128PortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "R128 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (R128PortPrivPtr)(&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 = R128StopVideo; + adapt->SetPortAttribute = R128SetPortAttribute; + adapt->GetPortAttribute = R128GetPortAttribute; + adapt->QueryBestSize = R128QueryBestSize; + adapt->PutImage = R128PutImage; + adapt->QueryImageAttributes = R128QueryImageAttributes; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + info->adaptor = adapt; + + pPriv->colorKey = 0x01; /* a touch of blue */ + pPriv->video_format = R128_SCALER_SOURCE_VYUY422; + pPriv->scale_cntl = R128_SCALER_PRG_LOAD_START|R128_SCALER_DOUBLE_BUFFER; + pPriv->scale_cntl|= R128_SCALER_SMART_SWITCH|R128_SCALER_PIX_EXPAND; + pPriv->scale_cntl|= R128_SCALER_SMART_SWITCH; + + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + R128ResetVideo(pScrn); + + return adapt; +} + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + +static void +R128StopVideo(ScrnInfoPtr pScrn, pointer data, Bool Exit) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128StopVideo called\n")); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if (Exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + } + } +} + +static int +R128SetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128SetPortAttribute called\n")); + + if (attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(R128_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + R128TRACE(("Setting ColorKey to %d\n", pPriv->colorKey)); + return Success; + } + + return Success; +} + +static int +R128GetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +) +{ + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128GetPortAttribute called\n")); + + if (attribute == xvColorKey) { + R128TRACE(("Getting ColorKey %d\n", pPriv->colorKey)); + *value = pPriv->colorKey; + return Success; + } + + return Success; +} + +static void +R128QueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +) +{ + R128TRACE(("R128QueryBestSize called\n")); + *p_w = drw_w; + *p_h = drw_h; +} + +static void +R128DisplayVideo( + ScrnInfoPtr pScrn, + short width, short height, + int xa, int ya, int xb, int yb, + short src_w, short src_h, + short drw_w, short drw_h, + int fboffset +) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + int step_by, vert_inc, horz_inc; + + R128TRACE(("R128DisplayVideo called\n")); + + /* calculate step_by factor */ + step_by=src_w/(drw_w*2); + switch(step_by){ + case 0: + OUTREG(R128_OV0_STEP_BY,0x101); + step_by=1; + break; + case 1: + OUTREG(R128_OV0_STEP_BY,0x202); + step_by=2; + break; + case 2: + case 3: + OUTREG(R128_OV0_STEP_BY,0x303); + step_by=4; + break; + default: + OUTREG(R128_OV0_STEP_BY,0x404); + step_by=8; + break; + } + + vert_inc=(src_h<<12)/(drw_h); + horz_inc=(src_w<<12)/(drw_w*step_by); + + OUTREG(R128_OV0_Y_X_START,((xa))|(ya<<16)|(1<<31)); + OUTREG(R128_OV0_Y_X_END,((xb))|((yb)<<16)); + OUTREG(R128_OV0_H_INC,(horz_inc)|((horz_inc<<15))); + OUTREG(R128_OV0_V_INC,(vert_inc<<8)); + OUTREG(R128_OV0_P1_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(R128_OV0_P23_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(R128_OV0_VID_BUF_PITCH0_VALUE,width<<1); + OUTREG(R128_OV0_VID_BUF_PITCH1_VALUE,width<<1); + OUTREG(R128_OV0_P1_X_START_END,(src_w-1)|((xa&0xf)<<16)); + OUTREG(R128_OV0_P2_X_START_END,(src_w-1)|((xa&0xf)<<16)); + OUTREG(R128_OV0_P3_X_START_END,(src_w-1)|((xa&0xf)<<16)); + + OUTREG(R128_OV0_VID_BUF0_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(R128_OV0_VID_BUF1_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(R128_OV0_VID_BUF2_BASE_ADRS,(fboffset)&(~0xf)); + +#if 0 + /* Enable this when double buffering is implemented */ + OUTREG(R128_OV0_VID_BUF3_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(R128_OV0_VID_BUF4_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(R128_OV0_VID_BUF5_BASE_ADRS,(fboffset2)&(~0xf)); +#endif + + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|R128_SCALER_ENABLE|pPriv->video_format); +} + +static void +R128CopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w + ) +{ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +R128CopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w + ) +{ + CARD32 *dst = (CARD32*)dst1; + int i, j; + + dstPitch >>= 2; + w >>= 1; + + for(j = 0; j < h; j++) { + for(i = 0; i < w; i++) { + dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + dst += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + +static FBLinearPtr +R128AllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +) +{ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + R128TRACE(("R128AllocateMemory(%x,%d) called\n",linear,size)); + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 4, + PRIORITY_EXTREME); + + if(max_size < size) return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + } + + R128TRACE(("returning %x(%x)\n",new_linear,new_linear->offset)); + + return new_linear; +} + +static int +R128PutImage( + ScrnInfoPtr pScrn, + 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 +) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + INT32 xa, xb, ya, yb; + INT32 d_x,d_y,d_width,d_height; + int srcPitch = 0, srcPitch2 = 0; + int dstPitch = 0; + int offset,offset2 = 0,offset3 = 0,fboffset; + int top, left, npixels, nlines, size; + CARD32 video_format; + + R128TRACE(("R128PutImage called\n")); + + switch(id) { + case FOURCC_YV12: + case FOURCC_UYVY: + video_format=R128_SCALER_SOURCE_VYUY422; + break; + case FOURCC_YUY2: + video_format=R128_SCALER_SOURCE_YVYU422; + break; + default: + return BadValue; + } + + /* Clip */ + d_x=drw_x; + d_y=drw_y; + d_width=drw_w; + d_height=drw_h; + if(drw_x<0){ + drw_w+=drw_x; + drw_x=0; + } + if(drw_y<0){ + drw_h+=drw_y; + drw_y=0; + } + if(drw_x+drw_w>pScrn->pScreen->width){ + drw_w=pScrn->pScreen->width-drw_x; + } + if(drw_y+drw_h>pScrn->pScreen->height){ + drw_h=pScrn->pScreen->height-drw_y; + } + if((drw_w<=0)||(drw_h<=0)){ + /* this should not happen, + since we are outside of visible screen, + but just in case */ + return Success; + } + + xa = src_x; + xb = src_x + src_w; + ya = src_y; + yb = src_y + src_h; + + dstPitch = width*info->CurrentLayout.pixel_bytes; + srcPitch=width; + + switch(id) { + case FOURCC_YV12: + size = width * height * 2; /* 16bpp */ + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = width * height * 1.5; + break; + } + + if(!(pPriv->linear = R128AllocateMemory(pScrn, pPriv->linear,size))) + return BadAlloc; + + /* copy data */ + top = ya >> 16; + left = (xa >> 16) & ~1; + npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((yb + 0xffff) >> 16) - top; + srcPitch = (width << 1); + break; + } + nlines=src_h; + npixels=src_w; + if(npixels>width) npixels=width; + if(nlines>height) nlines=height; + + /* adjust source rectangle */ + src_x+=((drw_x-d_x)*src_w)/d_width; + src_y+=((drw_y-d_y)*src_h)/d_height; + + src_w=(src_w * drw_w)/d_width; + src_h=(src_h * drw_h)/d_height; + + offset=(src_x+src_y*width)*info->CurrentLayout.pixel_bytes; + fboffset=pPriv->linear->offset*info->CurrentLayout.pixel_bytes; + + if(!(INREG(R128_CRTC_STATUS)&2)){ + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"too fast"); + return Success; + } + + R128DisplayVideo(pScrn, width, height, + drw_x, drw_y, drw_x+drw_w, drw_y+drw_h, + src_w, src_h, drw_w, drw_h, fboffset); + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + + switch(id) { + case FOURCC_YV12: + R128CopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, info->FB+fboffset, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + R128CopyData(buf,info->FB+fboffset,srcPitch,dstPitch, + nlines,npixels); + break; + } + + pPriv->videoStatus = CLIENT_VIDEO_ON; + return Success; +} + +static int +R128QueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +) +{ + int size, tmp; + R128TRACE(("R128QueryImageAtrributes called\n")); + + 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: + *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; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h new file mode 100644 index 000000000..e9b8b37e0 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h @@ -0,0 +1,406 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h,v 1.1 2000/11/02 16:55:40 tsi Exp $ */ +/* + * + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + */ + +#ifndef _RADEON_H_ +#define _RADEON_H_ + + /* Xv support */ +#include "xf86xv.h" +#include "Xv.h" + + /* vgahw module (for VC save/restore only) */ +#include "vgaHW.h" + +#include "fbdevhw.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xaalocal.h" +#include "xf86Cursor.h" + + + /* PCI support */ +#include "xf86PciInfo.h" +#include "xf86Pci.h" + + /* DDC support */ +#include "xf86DDC.h" + + /* VESA support */ +#include "vbe.h" + + /* DRI support */ +#ifdef XF86DRI +#include "GL/glxint.h" +#include "xf86drm.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "r128_dri.h" +#include "r128_dripriv.h" +#include "r128_sarea.h" +#endif + +#ifdef RENDER +#include "picturestr.h" +#endif + +/* NOTE: Turn off DRI until it is working */ +#ifdef XF86DRI +#undef XF86DRI +#endif + +#define RADEON_DEBUG 0 /* Turn off debugging output */ +#define RADEON_TIMEOUT 2000000 /* Fall out of wait loops after this count */ +#define RADEON_MMIOSIZE 0x80000 +/* Atomic updates of PLL clock don't seem to always work and stick, thus + * the bit never resets. Here - we use our own check by reading back the + * register we've just wrote to make sure it's got the Right! value */ +#define RADEON_ATOMIC_UPDATE 0 /* Use PLL Atomic updates (seems broken) */ + +#define RADEON_VBIOS_SIZE 0x00010000 + +#if RADEON_DEBUG +#define RADEONTRACE(x) \ + do { \ + ErrorF("(**) %s(%d): ", RADEON_NAME, pScrn->scrnIndex); \ + ErrorF x; \ + } while (0); +#else +#define RADEONTRACE(x) +#endif + + +/* Other macros */ +#define RADEON_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define RADEON_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) +#define RADEONPTR(pScrn) ((RADEONInfoPtr)(pScrn)->driverPrivate) + +typedef struct { /* All values in XCLKS */ + int ML; /* Memory Read Latency */ + int MB; /* Memory Burst Length */ + int Trcd; /* RAS to CAS delay */ + int Trp; /* RAS percentage */ + int Twr; /* Write Recovery */ + int CL; /* CAS Latency */ + int Tr2w; /* Read to Write Delay */ + int Rloop; /* Loop Latency */ + int Rloop_fudge; /* Add to ML to get Rloop */ + char *name; +} RADEONRAMRec, *RADEONRAMPtr; + +typedef struct { + /* Common registers */ + CARD32 ovr_clr; + CARD32 ovr_wid_left_right; + CARD32 ovr_wid_top_bottom; + CARD32 ov0_scale_cntl; + CARD32 mpp_tb_config; + CARD32 mpp_gp_config; + CARD32 subpic_cntl; + CARD32 viph_control; + CARD32 i2c_cntl_1; + CARD32 gen_int_cntl; + CARD32 cap0_trig_cntl; + CARD32 cap1_trig_cntl; + CARD32 bus_cntl; + + /* Other registers to save for VT switches */ + CARD32 dp_datatype; + CARD32 rbbm_soft_reset; + CARD32 clock_cntl_index; + CARD32 amcgpio_en_reg; + CARD32 amcgpio_mask; + + /* CRTC registers */ + CARD32 crtc_gen_cntl; + CARD32 crtc_ext_cntl; + CARD32 dac_cntl; + CARD32 crtc_h_total_disp; + CARD32 crtc_h_sync_strt_wid; + CARD32 crtc_v_total_disp; + CARD32 crtc_v_sync_strt_wid; + CARD32 crtc_offset; + CARD32 crtc_offset_cntl; + CARD32 crtc_pitch; + + /* CRTC2 registers */ + CARD32 crtc2_gen_cntl; + + /* Flat panel registers */ + CARD32 fp_crtc_h_total_disp; + CARD32 fp_crtc_v_total_disp; + CARD32 fp_gen_cntl; + CARD32 fp_h_sync_strt_wid; + CARD32 fp_horz_stretch; + CARD32 fp_panel_cntl; + CARD32 fp_v_sync_strt_wid; + CARD32 fp_vert_stretch; + CARD32 lvds_gen_cntl; + CARD32 tmds_crc; + + /* Computed values for PLL */ + CARD32 dot_clock_freq; + CARD32 pll_output_freq; + int feedback_div; + int post_div; + + /* PLL registers */ + CARD32 ppll_ref_div; + CARD32 ppll_div_3; + CARD32 htotal_cntl; + + /* DDA register */ + CARD32 dda_config; + CARD32 dda_on_off; + + /* Pallet */ + Bool palette_valid; + CARD32 palette[256]; +} RADEONSaveRec, *RADEONSavePtr; + +typedef struct { + CARD16 reference_freq; + CARD16 reference_div; + CARD32 min_pll_freq; + CARD32 max_pll_freq; + CARD16 xclk; +} RADEONPLLRec, *RADEONPLLPtr; + +typedef struct { + int bitsPerPixel; + int depth; + int displayWidth; + int pixel_code; + int pixel_bytes; + DisplayModePtr mode; +} RADEONFBLayout; + +typedef struct { + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + int Chipset; + Bool Primary; + + Bool FBDev; + + unsigned long LinearAddr; /* Frame buffer physical address */ + unsigned long MMIOAddr; /* MMIO region physical address */ + unsigned long BIOSAddr; /* BIOS physical address */ + Bool BIOSFromPCI; /* BIOS is read from PCI space */ + + unsigned char *MMIO; /* Map of MMIO region */ + unsigned char *FB; /* Map of frame buffer */ + CARD8 *VBIOS; /* Video BIOS pointer */ + + CARD32 MemCntl; + CARD32 BusCntl; + unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + int Flags; /* Saved copy of mode flags */ + +#ifdef ENABLE_FLAT_PANEL + Bool HasPanelRegs; /* Current chip can connect to a FP */ + Bool CRTOnly; /* Only use External CRT instead of FP */ + int FPBIOSstart; /* Start of the flat panel info */ + + /* Computed values for FPs */ + int PanelXRes; + int PanelYRes; + int PanelPwrDly; +#endif + + RADEONPLLRec pll; + RADEONRAMPtr ram; + + RADEONSaveRec SavedReg; /* Original (text) mode */ + RADEONSaveRec ModeReg; /* Current mode */ + Bool (*CloseScreen)(int, ScreenPtr); + + Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ + + XAAInfoRecPtr accel; + Bool accelOn; + xf86CursorInfoPtr cursor; + unsigned long cursor_start; + unsigned long cursor_end; + + int fifo_slots; /* Free slots in the FIFO (64 max) */ + int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ + Bool dac6bits; /* Use 6 bit DAC? */ + + /* Computed values for Radeon */ + int pitch; + int datatype; + CARD32 dp_gui_master_cntl; + + /* Saved values for ScreenToScreenCopy */ + int xdir; + int ydir; + + /* ScanlineScreenToScreenColorExpand support */ + unsigned char *scratch_buffer[1]; + unsigned char *scratch_save; + int scanline_x; + int scanline_y; + int scanline_h; + int scanline_h_w; + int scanline_words; + int scanline_direct; + int scanline_bpp; /* Only used for ImageWrite */ + + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; + + RADEONFBLayout CurrentLayout; +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig *pVisualConfigs; + RADEONConfigPrivPtr pVisualConfigsPriv; + + drmHandle fbHandle; + + drmSize registerSize; + drmHandle registerHandle; + + Bool IsPCI; /* Current card is a PCI card */ + + drmSize agpSize; + drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ + unsigned long agpOffset; + unsigned char *AGP; /* Map */ + int agpMode; + + Bool CPInUse; /* CP is currently active */ + int CPMode; /* CP mode that server/clients use */ + int CPFifoSize; /* Size of the CP command FIFO */ + Bool CPSecure; /* CP security enabled */ + int CPusecTimeout; /* CP timeout in usecs */ + Bool CP2D; /* CP is used for X server 2D prims */ + + /* CP ring buffer data */ + unsigned long ringStart; /* Offset into AGP space */ + drmHandle ringHandle; /* Handle from drmAddMap */ + drmSize ringMapSize; /* Size of map */ + int ringSize; /* Size of ring (in MB) */ + unsigned char *ring; /* Map */ + int ringSizeLog2QW; + + unsigned long ringReadOffset; /* Offset into AGP space */ + drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ + drmSize ringReadMapSize; /* Size of map */ + unsigned char *ringReadPtr; /* Map */ + + /* CP vertex buffer data */ + unsigned long vbStart; /* Offset into AGP space */ + drmHandle vbHandle; /* Handle from drmAddMap */ + drmSize vbMapSize; /* Size of map */ + int vbSize; /* Size of vert bufs (in MB) */ + unsigned char *vb; /* Map */ + int vbBufSize; /* Size of individual vert buf */ + int vbNumBufs; /* Number of vert bufs */ + drmBufMapPtr vbBufs; /* Buffer map */ + + /* CP indirect buffer data */ + unsigned long indStart; /* Offset into AGP space */ + drmHandle indHandle; /* Handle from drmAddMap */ + drmSize indMapSize; /* Size of map */ + int indSize; /* Size of indirect bufs (in MB) */ + unsigned char *ind; /* Map */ + + /* CP AGP Texture data */ + unsigned long agpTexStart; /* Offset into AGP space */ + drmHandle agpTexHandle; /* Handle from drmAddMap */ + drmSize agpTexMapSize; /* Size of map */ + int agpTexSize; /* Size of AGP tex space (in MB) */ + unsigned char *agpTex; /* Map */ + int log2AGPTexGran; + + /* DRI screen private data */ + int fbX; + int fbY; + int backX; + int backY; + int depthX; + int depthY; + int textureX; + int textureY; + int textureSize; + int log2TexGran; +#endif + XF86VideoAdaptorPtr adaptor; +} RADEONInfoRec, *RADEONInfoPtr; + +#define RADEONWaitForFifo(pScrn, entries) \ +do { \ + if (info->fifo_slots < entries) \ + RADEONWaitForFifoFunction(pScrn, entries); \ + info->fifo_slots -= entries; \ +} while (0) + +extern void RADEONWaitForFifoFunction(ScrnInfoPtr pScrn, int entries); +extern void RADEONWaitForIdle(ScrnInfoPtr pScrn); +extern void RADEONEngineReset(ScrnInfoPtr pScrn); +extern void RADEONEngineFlush(ScrnInfoPtr pScrn); + +extern unsigned RADEONINPLL(ScrnInfoPtr pScrn, int addr); +extern void RADEONWaitForVerticalSync(ScrnInfoPtr pScrn); + +extern Bool RADEONAccelInit(ScreenPtr pScreen); +extern void RADEONEngineInit(ScrnInfoPtr pScrn); +extern Bool RADEONCursorInit(ScreenPtr pScreen); +extern Bool RADEONDGAInit(ScreenPtr pScreen); + +extern int RADEONMinBits(int val); + +extern void RADEONInitVideo(ScreenPtr); + +#ifdef XF86DRI +extern Bool RADEONDRIScreenInit(ScreenPtr pScreen); +extern void RADEONDRICloseScreen(ScreenPtr pScreen); +extern Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen); +extern void RADEONCPStart(ScrnInfoPtr pScrn); +extern void RADEONCPStop(ScrnInfoPtr pScrn); +extern void RADEONCPResetRing(ScrnInfoPtr pScrn); +extern void RADEONCPWaitForIdle(ScrnInfoPtr pScrn); +#endif + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c new file mode 100644 index 000000000..985137eb3 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c @@ -0,0 +1,972 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c,v 1.2 2000/11/03 09:52:54 alanh Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * Credits: + * + * Thanks to Ani Joshi <ajoshi@shell.unixbox.com> for providing source + * code to his Radeon driver. Portions of this file are based on the + * initialization code for that driver. + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * Notes on unimplemented XAA optimizations: + * + * SetClipping: This has been removed as XAA expects 16bit registers + * for full clipping. + * TwoPointLine: The Radeon supports this. Not Bresenham. + * DashedLine with non-power-of-two pattern length: Apparently, there is + * no way to set the length of the pattern -- it is always + * assumed to be 8 or 32 (or 1024?). + * ScreenToScreenColorExpandFill: See p. 4-17 of the Technical Reference + * Manual where it states that monochrome expansion of frame + * buffer data is not supported. + * CPUToScreenColorExpandFill, direct: The implementation here uses a hybrid + * direct/indirect method. If we had more data registers, + * then we could do better. If XAA supported a trigger write + * address, the code would be simpler. + * Color8x8PatternFill: Apparently, an 8x8 color brush cannot take an 8x8 + * pattern from frame buffer memory. + * ImageWrites: Same as CPUToScreenColorExpandFill + * + */ + +#define RADEON_IMAGEWRITE 0 /* Turned off by default - slower in accel */ + + /* X and server generic header files */ +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86fbman.h" + + /* Line support */ +#include "miline.h" + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_reg.h" + +static struct { + int rop; + int pattern; +} RADEON_ROP[] = { + { RADEON_ROP3_ZERO, RADEON_ROP3_ZERO }, /* GXclear */ + { RADEON_ROP3_DSa, RADEON_ROP3_DPa }, /* Gxand */ + { RADEON_ROP3_SDna, RADEON_ROP3_PDna }, /* GXandReverse */ + { RADEON_ROP3_S, RADEON_ROP3_P }, /* GXcopy */ + { RADEON_ROP3_DSna, RADEON_ROP3_DPna }, /* GXandInverted */ + { RADEON_ROP3_D, RADEON_ROP3_D }, /* GXnoop */ + { RADEON_ROP3_DSx, RADEON_ROP3_DPx }, /* GXxor */ + { RADEON_ROP3_DSo, RADEON_ROP3_DPo }, /* GXor */ + { RADEON_ROP3_DSon, RADEON_ROP3_DPon }, /* GXnor */ + { RADEON_ROP3_DSxn, RADEON_ROP3_PDxn }, /* GXequiv */ + { RADEON_ROP3_Dn, RADEON_ROP3_Dn }, /* GXinvert */ + { RADEON_ROP3_SDno, RADEON_ROP3_PDno }, /* GXorReverse */ + { RADEON_ROP3_Sn, RADEON_ROP3_Pn }, /* GXcopyInverted */ + { RADEON_ROP3_DSno, RADEON_ROP3_DPno }, /* GXorInverted */ + { RADEON_ROP3_DSan, RADEON_ROP3_DPan }, /* GXnand */ + { RADEON_ROP3_ONE, RADEON_ROP3_ONE } /* GXset */ +}; + +/* Flush all dirty data in the Pixel Cache to memory. */ +void RADEONEngineFlush(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + OUTREGP(RADEON_RB2D_DSTCACHE_CTLSTAT, RADEON_RB2D_DC_FLUSH_ALL, + ~RADEON_RB2D_DC_FLUSH_ALL); + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (!(INREG(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY)) break; + } +} + +/* Reset graphics card to known state. */ +void RADEONEngineReset(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 clock_cntl_index; + CARD32 mclk_cntl; + CARD32 rbbm_soft_reset; + + RADEONEngineFlush(pScrn); + + clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); + mclk_cntl = INPLL(pScrn, RADEON_MCLK_CNTL); + + OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | 0x003f0000)); + + rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); + + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset | + RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB | + RADEON_SOFT_RESET_HDP); + INREG(RADEON_RBBM_SOFT_RESET); + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset & + ~(RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB | + RADEON_SOFT_RESET_HDP)); + INREG(RADEON_RBBM_SOFT_RESET); + + OUTPLL(RADEON_MCLK_CNTL, mclk_cntl); + OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); + +#ifdef XF86DRI + if (RADEONCP_USE_RING_BUFFER(info->CPMode)) RADEONCPResetRing(pScrn); +#endif +} + +/* The FIFO has 64 slots. This routines waits until at least `entries' of + these slots are empty. */ +void RADEONWaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < RADEON_TIMEOUT; i++) { + info->fifo_slots = + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK; + if (info->fifo_slots >= entries) return; + } + RADEONTRACE(("FIFO timed out: %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FIFO timed out, resetting engine...\n"); + RADEONEngineReset(pScrn); +#ifdef XF86DRI + if (info->CP2D) RADEONCPStart(pScrn); +#endif + } +} + +/* Wait for the graphics engine to be completely idle: the FIFO has + drained, the Pixel Cache is flushed, and the engine is idle. This is a + standard "sync" function that will make the hardware "quiescent". */ +void RADEONWaitForIdle(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + RADEONTRACE(("WaitForIdle (entering): %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + + RADEONWaitForFifoFunction(pScrn, 64); + + for (;;) { + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (!(INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_ACTIVE)) { + RADEONEngineFlush(pScrn); + return; + } + } + RADEONTRACE(("Idle timed out: %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Idle timed out, resetting engine...\n"); + RADEONEngineReset(pScrn); +#ifdef XF86DRI + if (info->CP2D) RADEONCPStart(pScrn); +#endif + } +} + +/* Setup for XAA SolidFill. */ +static void RADEONSetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern)); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, color); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT + | RADEON_DST_Y_TOP_TO_BOTTOM)); +} + +/* Subsequent XAA SolidFillRect. + + Tests: xtest CH06/fllrctngl, xterm +*/ +static void RADEONSubsequentSolidFillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 2); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_WIDTH_HEIGHT, (w << 16) | h); +} + +/* Setup for XAA solid lines. */ +static void RADEONSetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern)); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, color); + OUTREG(RADEON_DP_WRITE_MASK, planemask); +} + + +/* Subsequent XAA solid TwoPointLine line. + + Tests: xtest CH06/drwln, ico, Mark Vojkovich's linetest program + + [See http://www.xfree86.org/devel/archives/devel/1999-Jun/0102.shtml for + Mark Vojkovich's linetest program, posted 2Jun99 to devel@xfree86.org.] +*/ +static void RADEONSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, + int xa, int ya, int xb, int yb, + int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int direction = 0; + + if (xa < xb) direction |= RADEON_DST_X_DIR_LEFT_TO_RIGHT; + if (ya < yb) direction |= RADEON_DST_Y_DIR_TOP_TO_BOTTOM; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DST_Y_X, (ya << 16) | xa); + if (!(flags & OMIT_LAST)) + OUTREG(RADEON_DP_CNTL_XDIR_YDIR_YMAJOR, direction); + OUTREG(RADEON_DST_LINE_START, (ya << 16) | xa); + OUTREG(RADEON_DST_LINE_END, (yb << 16) | xb); +} + +/* Subsequent XAA solid horizontal and vertical lines */ +static void RADEONSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, + int x, int y, int len, int dir ) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT + | RADEON_DST_Y_TOP_TO_BOTTOM)); + + if (dir == DEGREES_0) { + RADEONSubsequentSolidFillRect(pScrn, x, y, len, 1); + } else { + RADEONSubsequentSolidFillRect(pScrn, x, y, 1, len); + } +} + +/* Setup for XAA dashed lines. + + Tests: xtest CH05/stdshs, XFree86/drwln + + NOTE: Since we can only accelerate lines with power-of-2 patterns of + length <= 32. +*/ +static void RADEONSetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask, + int length, unsigned char *pattern) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 pat = *(CARD32 *)pattern; + + switch (length) { + case 2: pat |= pat << 2; /* fall through */ + case 4: pat |= pat << 4; /* fall through */ + case 8: pat |= pat << 8; /* fall through */ + case 16: pat |= pat << 16; + } + + RADEONWaitForFifo(pScrn, 5); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? RADEON_GMC_BRUSH_32x1_MONO_FG_LA + : RADEON_GMC_BRUSH_32x1_MONO_FG_BG) + | RADEON_ROP[rop].pattern + | RADEON_GMC_BYTE_LSB_TO_MSB)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, fg); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, bg); + OUTREG(RADEON_BRUSH_DATA0, pat); +} + +/* Subsequent XAA dashed line. */ +static void RADEONSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int flags, + int phase) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int direction = 0; + + if (xa < xb) direction |= RADEON_DST_X_DIR_LEFT_TO_RIGHT; + if (ya < yb) direction |= RADEON_DST_Y_DIR_TOP_TO_BOTTOM; + + RADEONWaitForFifo(pScrn, 5); + if (!(flags & OMIT_LAST)) + OUTREG(RADEON_DP_CNTL_XDIR_YDIR_YMAJOR, direction); + OUTREG(RADEON_DST_Y_X, (ya << 16) | xa); + OUTREG(RADEON_BRUSH_Y_X, (phase << 16) | phase); + OUTREG(RADEON_DST_LINE_START, (ya << 16) | xa); + OUTREG(RADEON_DST_LINE_END, (yb << 16) | xb); +} + +/* Setup for XAA screen-to-screen copy. + + Tests: xtest CH06/fllrctngl (also tests transparency). +*/ +static void RADEONSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, + int xdir, int ydir, int rop, + unsigned int planemask, + int trans_color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->xdir = xdir; + info->ydir = ydir; + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_NONE + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].rop + | RADEON_DP_SRC_SOURCE_MEMORY)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_CNTL, ((xdir >= 0 + ? RADEON_DST_X_LEFT_TO_RIGHT + : 0) + | (ydir >= 0 + ? RADEON_DST_Y_TOP_TO_BOTTOM + : 0))); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA screen-to-screen copy. */ +static void RADEONSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + if (info->xdir < 0) xa += w - 1, xb += w - 1; + if (info->ydir < 0) ya += h - 1, yb += h - 1; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_SRC_Y_X, (ya << 16) | xa); + OUTREG(RADEON_DST_Y_X, (yb << 16) | xb); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +/* Setup for XAA mono 8x8 pattern color expansion. Patterns with + transparency use `bg == -1'. This routine is only used if the XAA + pixmap cache is turned on. + + Tests: xtest XFree86/fllrctngl (no other test will test this routine with + both transparency and non-transparency) +*/ +static void RADEONSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int patternx, int patterny, + int fg, int bg, int rop, + unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 6); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? RADEON_GMC_BRUSH_8X8_MONO_FG_LA + : RADEON_GMC_BRUSH_8X8_MONO_FG_BG) + | RADEON_ROP[rop].pattern + | RADEON_GMC_BYTE_LSB_TO_MSB)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, fg); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, bg); + OUTREG(RADEON_BRUSH_DATA0, patternx); + OUTREG(RADEON_BRUSH_DATA1, patterny); +} + +/* Subsequent XAA 8x8 pattern color expansion. Because they are used in + the setup function, `patternx' and `patterny' are not used here. */ +static void RADEONSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int patternx, int patterny, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_BRUSH_Y_X, (patterny << 8) | patternx); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +#if 0 +/* Setup for XAA color 8x8 pattern fill. + + Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off) +*/ +static void RADEONSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, + int patx, int paty, + int rop, unsigned int planemask, + int trans_color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + ErrorF("Color8x8 %d %d %d\n", trans_color, patx, paty); + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_8x8_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern + | RADEON_DP_SRC_SOURCE_MEMORY)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_SRC_Y_X, (paty << 16) | patx); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA 8x8 pattern color expansion. */ +static void RADEONSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + ErrorF("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h); + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_BRUSH_Y_X, (paty << 16) | patx); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} +#endif + +/* Setup for XAA indirect CPU-to-screen color expansion (indirect). + Because of how the scratch buffer is initialized, this is really a + mainstore-to-screen color expansion. Transparency is supported when `bg + == -1'. + Implementing the hybrid indirect/direct scheme improved performance in a + few areas: +*/ +static void RADEONSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int + planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_DST_CLIPPING + | RADEON_GMC_BRUSH_NONE + | (bg == -1 + ? RADEON_GMC_SRC_DATATYPE_MONO_FG_LA + : RADEON_GMC_SRC_DATATYPE_MONO_FG_BG) + | RADEON_ROP[rop].rop + | RADEON_GMC_BYTE_LSB_TO_MSB + | RADEON_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_SRC_FRGD_CLR, fg); + OUTREG(RADEON_DP_SRC_BKGD_CLR, bg); +} + +/* Subsequent XAA indirect CPU-to-screen color expansion. This is only + called once for each rectangle. */ +static void RADEONSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr + pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->scanline_h = h; + info->scanline_words = (w + 31) >> 5; + + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(RADEON_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + RADEONWaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(RADEON_SC_TOP_LEFT, (y << 16) | ((x+skipleft) & 0xffff)); + /* MMmm, we don't need the -1 on both y+h or x+w, why ? */ + OUTREG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | ((x+w) & 0xffff)); + OUTREG(RADEON_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | ((w + 31) & ~31)); +} + +/* Subsequent XAA indirect CPU-to-screen color expandion. This is called + once for each scanline. */ +static void RADEONSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + RADEONWaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} + +#if RADEON_IMAGEWRITE +/* Setup for XAA indirect image write. */ +static void RADEONSetupForScanlineImageWrite(ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int trans_color, + int bpp, + int depth) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->scanline_bpp = bpp; + + RADEONWaitForFifo(pScrn, 2); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_DST_CLIPPING + | RADEON_GMC_BRUSH_NONE + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].rop + | RADEON_GMC_BYTE_LSB_TO_MSB + | RADEON_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA indirect image write. This is only called once for each + rectangle. */ +static void RADEONSubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int shift = 0; /* 32bpp */ + + if (pScrn->bitsPerPixel == 8) shift = 3; + else if (pScrn->bitsPerPixel == 16) shift = 1; + + info->scanline_h = h; + info->scanline_words = (w * info->scanline_bpp + 31) >> 5; + + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(RADEON_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + RADEONWaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(RADEON_SC_TOP_LEFT, (y << 16) | ((x+skipleft) & 0xffff)); + /* MMmm, we don't need the -1 on both y+h or x+w, why ? */ + OUTREG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | ((x+w) & 0xffff)); + OUTREG(RADEON_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | ((w + shift) & ~shift)); +} + +/* Subsequent XAA indirect image write. This is called once for each + scanline. */ +static void RADEONSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + RADEONWaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} +#endif + +/* Initialize the acceleration hardware. */ +void RADEONEngineInit(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int pitch64; + + RADEONTRACE(("EngineInit (%d/%d)\n", + info->CurrentLayout.pixel_code, + info->CurrentLayout.bitsPerPixel)); + + OUTREG(RADEON_SCALE_3D_CNTL, 0); + RADEONEngineReset(pScrn); + + RADEONWaitForFifo(pScrn, 1); + /* turn of all automatic flushing - we'll do it all */ + OUTREG(RADEON_RB2D_DSTCACHE_MODE, 0); + + switch (info->CurrentLayout.pixel_code) { + case 8: info->datatype = 2; break; + case 15: info->datatype = 3; break; + case 16: info->datatype = 4; break; + case 24: info->datatype = 5; break; + case 32: info->datatype = 6; break; + default: + RADEONTRACE(("Unknown depth/bpp = %d/%d (code = %d)\n", + info->CurrentLayout.depth, + info->CurrentLayout.bitsPerPixel, + info->CurrentLayout.pixel_code)); + } + info->pitch = ((info->CurrentLayout.displayWidth / 8) * + (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1)); + + RADEONTRACE(("Pitch for acceleration = %d\n", info->pitch)); + + pitch64 = ((pScrn->displayWidth * (pScrn->bitsPerPixel / 8) + 0x3f)) >> 6; + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DEFAULT_OFFSET, (INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000) | + (pitch64 << 22)); + + RADEONWaitForFifo(pScrn, 1); +#if X_BYTE_ORDER == X_BIG_ENDIAN + OUTREGP(RADEON_DP_DATATYPE, + RADEON_HOST_BIG_ENDIAN_EN, ~RADEON_HOST_BIG_ENDIAN_EN); +#else + OUTREGP(RADEON_DP_DATATYPE, 0, ~RADEON_HOST_BIG_ENDIAN_EN); +#endif + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX + | RADEON_DEFAULT_SC_BOTTOM_MAX)); + info->dp_gui_master_cntl = + ((info->datatype << RADEON_GMC_DST_DATATYPE_SHIFT) + | RADEON_GMC_CLR_CMP_CNTL_DIS); + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR)); + + RADEONWaitForFifo(pScrn, 7); + OUTREG(RADEON_DST_LINE_START, 0); + OUTREG(RADEON_DST_LINE_END, 0); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, 0x00000000); + OUTREG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff); + OUTREG(RADEON_DP_SRC_BKGD_CLR, 0x00000000); + OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff); + + RADEONWaitForIdle(pScrn); +} + +#ifdef XF86DRI +/* FIXME: When direct rendering is enabled, we should use the CP to + draw 2D commands */ +static void RADEONCPAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + a->Flags = 0; + + /* Sync */ +#if 1 + a->Sync = RADEONWaitForIdle; +#else + a->Sync = RADEONCCEWaitForIdle; +#endif + +} +#endif + +static void RADEONMMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + a->Flags = (PIXMAP_CACHE + | OFFSCREEN_PIXMAPS + | LINEAR_FRAMEBUFFER); + + /* Sync */ + a->Sync = RADEONWaitForIdle; + + /* Solid Filled Rectangle */ + a->PolyFillRectSolidFlags = 0; + a->SetupForSolidFill = RADEONSetupForSolidFill; + a->SubsequentSolidFillRect = RADEONSubsequentSolidFillRect; + + /* Screen-to-screen Copy */ + a->ScreenToScreenCopyFlags = 0; + a->SetupForScreenToScreenCopy = RADEONSetupForScreenToScreenCopy; + a->SubsequentScreenToScreenCopy = RADEONSubsequentScreenToScreenCopy; + + /* Mono 8x8 Pattern Fill (Color Expand) */ + a->SetupForMono8x8PatternFill + = RADEONSetupForMono8x8PatternFill; + a->SubsequentMono8x8PatternFillRect + = RADEONSubsequentMono8x8PatternFillRect; + a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST); + + /* Indirect CPU-To-Screen Color Expand */ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's drwarc */ + | ROP_NEEDS_SOURCE + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#else + a->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's drwarc */ + | ROP_NEEDS_SOURCE + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + a->NumScanlineColorExpandBuffers = 1; + a->ScanlineColorExpandBuffers = info->scratch_buffer; + info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + + (pScrn->virtualX + * info->CurrentLayout.pixel_bytes)); + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineCPUToScreenColorExpandFill + = RADEONSetupForScanlineCPUToScreenColorExpandFill; + a->SubsequentScanlineCPUToScreenColorExpandFill + = RADEONSubsequentScanlineCPUToScreenColorExpandFill; + a->SubsequentColorExpandScanline = RADEONSubsequentColorExpandScanline; + + a->SetupForSolidLine = RADEONSetupForSolidLine; + a->SubsequentSolidTwoPointLine = RADEONSubsequentSolidTwoPointLine; + a->SubsequentSolidHorVertLine = RADEONSubsequentSolidHorVertLine; + + a->SetupForDashedLine = RADEONSetupForDashedLine; + a->SubsequentDashedTwoPointLine = RADEONSubsequentDashedTwoPointLine; + a->DashPatternMaxLength = 32; + a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED + | LINE_PATTERN_POWER_OF_2_ONLY); + +#if RADEON_IMAGEWRITE + /* ImageWrite */ + a->NumScanlineImageWriteBuffers = 1; + a->ScanlineImageWriteBuffers = info->scratch_buffer; + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineImageWrite = RADEONSetupForScanlineImageWrite; + a->SubsequentScanlineImageWriteRect + = RADEONSubsequentScanlineImageWriteRect; + a->SubsequentImageWriteScanline = RADEONSubsequentImageWriteScanline; + a->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD + /* Performance tests show that we shouldn't use GXcopy for + * uploads as a memcpy is faster */ + | NO_GXCOPY + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's ptimg */ + | ROP_NEEDS_SOURCE + | SCANLINE_PAD_DWORD + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + +#if 0 + /* Color 8x8 Pattern Fill */ + a->SetupForColor8x8PatternFill + = RADEONSetupForColor8x8PatternFill; + a->SubsequentColor8x8PatternFillRect + = RADEONSubsequentColor8x8PatternFillRect; + a->Color8x8PatternFillFlags = + HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST; +#endif +} + +/* Initialize XAA for supported acceleration and also initialize the + graphics hardware for acceleration. */ +Bool RADEONAccelInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + XAAInfoRecPtr a; + + if (!(a = info->accel = XAACreateInfoRec())) return FALSE; + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CP to + draw 2D commands */ + if (info->CP2D) RADEONCPAccelInit(pScrn, a); + else +#endif + RADEONMMIOAccelInit(pScrn, a); + + RADEONEngineInit(pScrn); + return XAAInit(pScreen, a); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c new file mode 100644 index 000000000..54f8b43d1 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c @@ -0,0 +1,266 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c,v 1.1 2000/11/02 16:55:41 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + + /* X and server generic header files */ +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86fbman.h" + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_reg.h" + +#if X_BYTE_ORDER == X_BIG_ENDIAN +#define P_SWAP32( a , b ) \ + ((char *)a)[0] = ((char *)b)[3]; \ + ((char *)a)[1] = ((char *)b)[2]; \ + ((char *)a)[2] = ((char *)b)[1]; \ + ((char *)a)[3] = ((char *)b)[0] + +#define P_SWAP16( a , b ) \ + ((char *)a)[0] = ((char *)b)[1]; \ + ((char *)a)[1] = ((char *)b)[0]; \ + ((char *)a)[2] = ((char *)b)[3]; \ + ((char *)a)[3] = ((char *)b)[2] +#endif + + +/* Set cursor foreground and background colors. */ +static void RADEONSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_CUR_CLR0, bg); + OUTREG(RADEON_CUR_CLR1, fg); +} + +/* Set cursor position to (x,y) with offset into cursor bitmap at + (xorigin,yorigin). */ +static void RADEONSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + xf86CursorInfoPtr cursor = info->cursor; + int xorigin = 0; + int yorigin = 0; + int total_y = pScrn->frameY1 - pScrn->frameY0; + + if (x < 0) xorigin = -x; + if (y < 0) yorigin = -y; + if (y > total_y) y = total_y; + if (info->Flags & V_DBLSCAN) y *= 2; + if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1; + if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1; + + OUTREG(RADEON_CUR_HORZ_VERT_OFF, (RADEON_CUR_LOCK + | (xorigin << 16) + | yorigin)); + OUTREG(RADEON_CUR_HORZ_VERT_POSN, (RADEON_CUR_LOCK + | ((xorigin ? 0 : x) << 16) + | (yorigin ? 0 : y))); + OUTREG(RADEON_CUR_OFFSET, info->cursor_start + yorigin * 16); +} + +/* Copy cursor image from `image' to video memory. RADEONSetCursorPosition + will be called after this, so we can ignore xorigin and yorigin. */ +static void RADEONLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *s = (CARD32 *)image; + CARD32 *d = (CARD32 *)(info->FB + info->cursor_start); + int y; + CARD32 save; + + save = INREG(RADEON_CRTC_GEN_CNTL); + OUTREG(RADEON_CRTC_GEN_CNTL, save & ~RADEON_CRTC_CUR_EN); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + switch(info->CurrentLayout.pixel_bytes) { + case 4: + case 3: + for (y = 0; y < 64; y++) { + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + } + break; + case 2: + for (y = 0; y < 64; y++) { + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + } + break; + default: + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + } +#else + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } +#endif + + /* Set the area after the cursor to be all transparent so that we + won't display corrupted cursors on the screen */ + for (y = 0; y < 64; y++) { + *d++ = 0xffffffff; /* The AND bits */ + *d++ = 0xffffffff; + *d++ = 0x00000000; /* The XOR bits */ + *d++ = 0x00000000; + } + + OUTREG(RADEON_CRTC_GEN_CNTL, save); +} + +/* Hide hardware cursor. */ +static void RADEONHideCursor(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_GEN_CNTL, 0, ~RADEON_CRTC_CUR_EN); +} + +/* Show hardware cursor. */ +static void RADEONShowCursor(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_CUR_EN, ~RADEON_CRTC_CUR_EN); +} + +/* Determine if hardware cursor is in use. */ +static Bool RADEONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + return info->cursor_start ? TRUE : FALSE; +} + +/* Initialize hardware cursor support. */ +Bool RADEONCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + xf86CursorInfoPtr cursor; + FBAreaPtr fbarea; + int width; + int height; + int size; + + + if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; + + cursor->MaxWidth = 64; + cursor->MaxHeight = 64; + cursor->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST +#endif + | HARDWARE_CURSOR_INVERT_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK); + + cursor->SetCursorColors = RADEONSetCursorColors; + cursor->SetCursorPosition = RADEONSetCursorPosition; + cursor->LoadCursorImage = RADEONLoadCursorImage; + cursor->HideCursor = RADEONHideCursor; + cursor->ShowCursor = RADEONShowCursor; + cursor->UseHWCursor = RADEONUseHWCursor; + + size = (cursor->MaxWidth/4) * cursor->MaxHeight; + width = pScrn->displayWidth; + height = (size*2 + 1023) / pScrn->displayWidth; + fbarea = xf86AllocateOffscreenArea(pScreen, + width, + height, + 16, + NULL, + NULL, + NULL); + + if (!fbarea) { + info->cursor_start = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Hardware cursor disabled" + " due to insufficient offscreen memory\n"); + } else { + info->cursor_start = RADEON_ALIGN((fbarea->box.x1 + + width * fbarea->box.y1) + * info->CurrentLayout.pixel_bytes, + 16); + info->cursor_end = info->cursor_start + size; + } + + RADEONTRACE(("RADEONCursorInit (0x%08x-0x%08x)\n", + info->cursor_start, info->cursor_end)); + + return xf86InitCursor(pScreen, cursor); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c new file mode 100644 index 000000000..d466d0b67 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c @@ -0,0 +1,355 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c,v 1.2 2000/11/03 09:52:55 alanh Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Credits: + * + * Thanks to Ove Kĺven <ovek@transgaming.com> for writing the Rage 128 + * DGA support. Portions of this file are based on the initialization + * code for that driver. + * + */ + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_probe.h" + + /* DGA support */ +#include "dgaproc.h" + + +static Bool RADEON_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool RADEON_SetMode(ScrnInfoPtr, DGAModePtr); +static int RADEON_GetViewport(ScrnInfoPtr); +static void RADEON_SetViewport(ScrnInfoPtr, int, int, int); +static void RADEON_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void RADEON_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +#if 0 +static void RADEON_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); +#endif + +static +DGAFunctionRec RADEON_DGAFuncs = { + RADEON_OpenFramebuffer, + NULL, + RADEON_SetMode, + RADEON_SetViewport, + RADEON_GetViewport, + RADEONWaitForIdle, + RADEON_FillRect, + RADEON_BlitRect, +#if 0 + RADEON_BlitTransRect +#else + NULL +#endif +}; + + +static DGAModePtr RADEONSetupDGAMode(ScrnInfoPtr pScrn, + DGAModePtr modes, + int *num, + int bitsPerPixel, + int depth, + Bool pixmap, + int secondPitch, + unsigned long red, + unsigned long green, + unsigned long blue, + short visualClass) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + DGAModePtr newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int otherPitch, Bpp = bitsPerPixel >> 3; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while (pMode) { + otherPitch = secondPitch ? secondPitch : pMode->HDisplay; + + if (pMode->HDisplay != otherPitch) { + newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if (!newmodes) { + xfree(modes); + return NULL; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + *num; + (*num)++; + + currentMode->mode = pMode; + /* FIXME: is concurrent access really possible? */ + currentMode->flags = DGA_CONCURRENT_ACCESS; + if (pixmap) + currentMode->flags |= DGA_PIXMAP_AVAILABLE; + if (info->accel) + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if (pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = depth; + currentMode->bitsPerPixel = bitsPerPixel; + currentMode->red_mask = red; + currentMode->green_mask = green; + currentMode->blue_mask = blue; + currentMode->visualClass = visualClass; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 8; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = (unsigned char*)info->LinearAddr; + + if (oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = (((pMode->HDisplay * Bpp) + 3) + & ~3L); + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = (currentMode->imageHeight - + currentMode->viewportHeight); + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; + currentMode->imageWidth = otherPitch; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = (currentMode->imageWidth - + currentMode->viewportWidth); + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = (currentMode->imageHeight - + currentMode->viewportHeight); + } + + pMode = pMode->next; + if (pMode == firstMode) + break; + } + + return modes; +} + +Bool RADEONDGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + DGAModePtr modes = NULL; + int num = 0; + + /* 8 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 8, 8, + (pScrn->bitsPerPixel == 8), + ((pScrn->bitsPerPixel != 8) + ? 0 : pScrn->displayWidth), + 0, 0, 0, PseudoColor); + + /* 15 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 15) + ? 0 : pScrn->displayWidth), + 0x7c00, 0x03e0, 0x001f, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 15) + ? 0 : pScrn->displayWidth), + 0x7c00, 0x03e0, 0x001f, DirectColor); + + /* 16 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 16) + ? 0 : pScrn->displayWidth), + 0xf800, 0x07e0, 0x001f, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 16) + ? 0 : pScrn->displayWidth), + 0xf800, 0x07e0, 0x001f, DirectColor); + + /* 32 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + ((pScrn->bitsPerPixel != 32) + ? 0 : pScrn->displayWidth), + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + ((pScrn->bitsPerPixel != 32) + ? 0 : pScrn->displayWidth), + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + info->numDGAModes = num; + info->DGAModes = modes; + + return DGAInit(pScreen, &RADEON_DGAFuncs, modes, num); +} + +static Bool RADEON_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) +{ + static RADEONFBLayout SavedLayouts[MAXSCREENS]; + int indx = pScrn->pScreen->myNum; + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + if (info->DGAactive) + memcpy(&info->CurrentLayout, &SavedLayouts[indx], + sizeof(RADEONFBLayout)); + + pScrn->currentMode = info->CurrentLayout.mode; + + RADEONSwitchMode(indx, pScrn->currentMode, 0); + RADEONAdjustFrame(indx, 0, 0, 0); + info->DGAactive = FALSE; + } else { + if (!info->DGAactive) { /* save the old parameters */ + memcpy(&SavedLayouts[indx], &info->CurrentLayout, + sizeof(RADEONFBLayout)); + info->DGAactive = TRUE; + } + + info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel; + info->CurrentLayout.depth = pMode->depth; + info->CurrentLayout.displayWidth = (pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3)); + info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16 + ? pMode->bitsPerPixel + : pMode->depth); + /* RADEONModeInit() will set the mode field */ + + RADEONSwitchMode(indx, pMode->mode, 0); + } + + return TRUE; +} + +static int RADEON_GetViewport(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + return info->DGAViewportStatus; +} + +static void RADEON_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + info->DGAViewportStatus = 0; /* FIXME */ +} + +static void RADEON_FillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->accel) { + (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +static void RADEON_BlitRect(ScrnInfoPtr pScrn, + int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->accel) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*info->accel->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, + GXcopy, ~0, -1); + (*info->accel->SubsequentScreenToScreenCopy)(pScrn, srcx, srcy, + dstx, dsty, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +#if 0 +static void RADEON_BlitTransRect(ScrnInfoPtr pScrn, + int srcx, int srcy, int w, int h, + int dstx, int dsty, unsigned long color) +{ + /* this one should be separate since the XAA function would prohibit + usage of ~0 as the key */ +} +#endif + +static Bool RADEON_OpenFramebuffer(ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, int *offset, int *flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)info->LinearAddr; + *size = info->FbMapSize; + *offset = 0; + *flags = 0; /* DGA_NEED_ROOT; -- don't need root, just /dev/mem access */ + + return TRUE; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c new file mode 100644 index 000000000..0fa24a9b7 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c @@ -0,0 +1,2953 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v 1.2 2000/11/03 09:52:55 alanh Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markhom, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + * Credits: + * + * Thanks to Ani Joshi <ajoshi@shell.unixbox.com> for providing source + * code to his Radeon driver. Portions of this file are based on the + * initialization code for that driver. + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * This server does not yet support these XFree86 4.0 features: + * !!!! FIXME !!!! + * DDC1 & DDC2 + * shadowfb + * overlay planes + * + * Modified by Marc Aurele La France (tsi@xfree86.org) for ATI driver merge. + */ + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "xf86fbman.h" +#include "xf86int10.h" + /* Backing store, software cursor, and + colormap initialization */ +#include "mibstore.h" +#include "mipointer.h" +#include "micmap.h" + +#define USE_FB /* not until overlays */ +#ifdef USE_FB +#include "fb.h" +#else + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" +#endif + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_probe.h" +#include "radeon_reg.h" +#include "radeon_version.h" + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + + + /* Forward definitions for driver functions */ +static Bool RADEONCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool RADEONSaveScreen(ScreenPtr pScreen, int mode); +static void RADEONSave(ScrnInfoPtr pScrn); +static void RADEONRestore(ScrnInfoPtr pScrn); +static Bool RADEONModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, + int flags); +static Bool RADEONEnterVTFBDev(int scrnIndex, int flags); +static void RADEONLeaveVTFBDev(int scrnIndex, int flags); + +typedef enum { + OPTION_NOACCEL, + OPTION_SW_CURSOR, + OPTION_DAC_6BIT, + OPTION_DAC_8BIT, +#ifdef XF86DRI + OPTION_IS_PCI, + OPTION_CP_PIO, + OPTION_NO_SECURITY, + OPTION_USEC_TIMEOUT, + OPTION_AGP_MODE, + OPTION_AGP_SIZE, + OPTION_RING_SIZE, + OPTION_VERT_SIZE, + OPTION_VBUF_SIZE, + OPTION_USE_CP_2D, +#endif +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + OPTION_CRT, +#endif + OPTION_PANEL_WIDTH, + OPTION_PANEL_HEIGHT, +#endif + OPTION_FBDEV +} RADEONOpts; + +OptionInfoRec RADEONOptions[] = { + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +#ifdef XF86DRI + { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CP_PIO, "CPPIOMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NO_SECURITY, "CPNoSecurity", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEC_TIMEOUT, "CPusecTimeout", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_USE_CP_2D, "UseCPfor2D", OPTV_BOOLEAN, {0}, FALSE }, +#endif +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, +#endif + { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +RADEONRAMRec RADEONRAM[] = { /* Memory Specifications + From Radeon Manual */ + { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SDRAM" }, + { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SDRAM" }, +}; + +static const char *vgahwSymbols[] = { + "vgaHWGetHWRec", + "vgaHWFreeHWRec", + "vgaHWLock", + "vgaHWUnlock", + "vgaHWSave", + "vgaHWRestore", + NULL +}; + +static const char *fbdevHWSymbols[] = { + "fbdevHWInit", + "fbdevHWUseBuildinMode", + + "fbdevHWGetDepth", + "fbdevHWGetVidmem", + + /* colormap */ + "fbdevHWLoadPalette", + + /* ScrnInfo hooks */ + "fbdevHWSwitchMode", + "fbdevHWAdjustFrame", + "fbdevHWEnterVT", + "fbdevHWLeaveVT", + "fbdevHWValidMode", + "fbdevHWRestore", + "fbdevHWModeInit", + "fbdevHWSave", + + "fbdevHWUnmapMMIO", + "fbdevHWUnmapVidmem", + "fbdevHWMapMMIO", + "fbdevHWMapVidmem", + + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +#ifdef XFree86LOADER +#ifdef USE_FB +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; +#else +static const char *cfbSymbols[] = { + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb32ScreenInit", + "cfb24_32ScreenInit", + NULL +}; +#endif + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAStippleScanlineFuncLSBFirst", + "XAAOverlayFBfuncs", + "XAACachePlanarMonoStipple", + "XAAScreenIndex", + NULL +}; + +static const char *xf8_32bppSymbols[] = { + "xf86Overlay8Plus32Init", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmGetInterruptFromBusID", + "drmMapBufs", + "drmMarkBufs", + "drmUnmapBufs", + "drmFreeVersion", + "drmGetVersion", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "DRIQueryVersion", + "GlxSetVisualConfigs", + NULL +}; +#endif + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + NULL +}; +#endif + +/* Allocate our private RADEONInfoRec. */ +static Bool RADEONGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(RADEONInfoRec), 1); + return TRUE; +} + +/* Free our private RADEONInfoRec. */ +static void RADEONFreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn || !pScrn->driverPrivate) return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* Memory map the MMIO region. Used during pre-init and by RADEONMapMem, + below. */ +static Bool RADEONMapMMIO(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) { + info->MMIO = fbdevHWMapMMIO(pScrn); + } else { + info->MMIO = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, + info->PciTag, + info->MMIOAddr, + RADEON_MMIOSIZE); + } + + if (!info->MMIO) return FALSE; + return TRUE; +} + +/* Unmap the MMIO region. Used during pre-init and by RADEONUnmapMem, + below. */ +static Bool RADEONUnmapMMIO(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapMMIO(pScrn); + else { + xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, RADEON_MMIOSIZE); + } + info->MMIO = NULL; + return TRUE; +} + +/* Memory map the frame buffer. Used by RADEONMapMem, below. */ +static Bool RADEONMapFB(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) { + info->FB = fbdevHWMapVidmem(pScrn); + } else { + info->FB = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_FRAMEBUFFER, + info->PciTag, + info->LinearAddr, + info->FbMapSize); + } + + if (!info->FB) return FALSE; + return TRUE; +} + +/* Unmap the frame buffer. Used by RADEONUnmapMem, below. */ +static Bool RADEONUnmapFB(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapVidmem(pScrn); + else + xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); + info->FB = NULL; + return TRUE; +} + +/* Memory map the MMIO region and the frame buffer. */ +static Bool RADEONMapMem(ScrnInfoPtr pScrn) +{ + if (!RADEONMapMMIO(pScrn)) return FALSE; + if (!RADEONMapFB(pScrn)) { + RADEONUnmapMMIO(pScrn); + return FALSE; + } + return TRUE; +} + +/* Unmap the MMIO region and the frame buffer. */ +static Bool RADEONUnmapMem(ScrnInfoPtr pScrn) +{ + if (!RADEONUnmapMMIO(pScrn) || !RADEONUnmapFB(pScrn)) return FALSE; + return TRUE; +} + +/* Read PLL information */ +unsigned RADEONINPLL(ScrnInfoPtr pScrn, int addr) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + +#if !RADEON_ATOMIC_UPDATE + while ( (INREG8(RADEON_CLOCK_CNTL_INDEX) & 0x9f) != addr) { +#endif + OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x1f); +#if !RADEON_ATOMIC_UPDATE + } +#endif + return INREG(RADEON_CLOCK_CNTL_DATA); +} + +#if 0 +/* Read PAL information (only used for debugging). */ +static int RADEONINPAL(int idx) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_PALETTE_INDEX, idx << 16); + return INREG(RADEON_PALETTE_DATA); +} +#endif + +/* Wait for vertical sync. */ +void RADEONWaitForVerticalSync(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + OUTREG(RADEON_GEN_INT_STATUS, RADEON_VSYNC_INT_AK); + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (INREG(RADEON_GEN_INT_STATUS) & RADEON_VSYNC_INT) break; + } +} + +/* Blank screen. */ +static void RADEONBlank(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS, + ~(RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS)); +} + +/* Unblank screen. */ +static void RADEONUnblank(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_EXT_CNTL, 0, + ~(RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS)); +} + +/* Compute log base 2 of val. */ +int RADEONMinBits(int val) +{ + int bits; + + if (!val) return 1; + for (bits = 0; val; val >>= 1, ++bits); + return bits; +} + +/* Compute n/d with rounding. */ +static int RADEONDiv(int n, int d) +{ + return (n + (d / 2)) / d; +} + +/* Read the Video BIOS block and the FP registers (if applicable). */ +static Bool RADEONGetBIOSParameters(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); +#ifdef ENABLE_FLAT_PANEL + int i; + int FPHeader = 0; +#endif + +#define RADEONReadBIOS(offset, buffer, length) \ + (info->BIOSFromPCI ? \ + xf86ReadPciBIOS(offset, info->PciTag, 0, buffer, length) : \ + xf86ReadBIOS(info->BIOSAddr, offset, buffer, length)) + +#define RADEON_BIOS8(v) (info->VBIOS[v]) +#define RADEON_BIOS16(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8)) +#define RADEON_BIOS32(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8) | \ + (info->VBIOS[(v) + 2] << 16) | \ + (info->VBIOS[(v) + 3] << 24)) + + if (!(info->VBIOS = xalloc(RADEON_VBIOS_SIZE))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate space for hold Video BIOS!\n"); + return FALSE; + } + + info->BIOSFromPCI = TRUE; + RADEONReadBIOS(0x0000, info->VBIOS, RADEON_VBIOS_SIZE); + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected in PCI space!\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Attempting to read Video BIOS from legacy ISA space!\n"); + info->BIOSFromPCI = FALSE; + info->BIOSAddr = 0x000c0000; + RADEONReadBIOS(0x0000, info->VBIOS, RADEON_VBIOS_SIZE); + } + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + info->BIOSAddr = 0x00000000; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not found!\n"); + } + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) { + info->FPBIOSstart = 0; + + /* FIXME: There should be direct access to the start of the FP info + tables, but until we find out where that offset is stored, we + must search for the ATI signature string: "M3 ". */ + for (i = 4; i < RADEON_VBIOS_SIZE-8; i++) { + if (RADEON_BIOS8(i) == 'M' && + RADEON_BIOS8(i+1) == '3' && + RADEON_BIOS8(i+2) == ' ' && + RADEON_BIOS8(i+3) == ' ' && + RADEON_BIOS8(i+4) == ' ' && + RADEON_BIOS8(i+5) == ' ' && + RADEON_BIOS8(i+6) == ' ' && + RADEON_BIOS8(i+7) == ' ') { + FPHeader = i-2; + break; + } + } + + if (!FPHeader) return TRUE; + + /* Assume that only one panel is attached and supported */ + for (i = FPHeader+20; i < FPHeader+84; i += 2) { + if (RADEON_BIOS16(i) != 0) { + info->FPBIOSstart = RADEON_BIOS16(i); + break; + } + } + if (!info->FPBIOSstart) return TRUE; + + if (!info->PanelXRes) + info->PanelXRes = RADEON_BIOS16(info->FPBIOSstart+25); + if (!info->PanelYRes) + info->PanelYRes = RADEON_BIOS16(info->FPBIOSstart+27); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel size: %dx%d\n", + info->PanelXRes, info->PanelYRes); + + info->PanelPwrDly = RADEON_BIOS8(info->FPBIOSstart+56); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel ID: "); + for (i = 1; i <= 24; i++) + ErrorF("%c", RADEON_BIOS8(info->FPBIOSstart+i)); + ErrorF("\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Type: "); + i = RADEON_BIOS16(info->FPBIOSstart+29); + if (i & 1) ErrorF("Color, "); + else ErrorF("Monochrome, "); + if (i & 2) ErrorF("Dual(split), "); + else ErrorF("Single, "); + switch ((i >> 2) & 0x3f) { + case 0: ErrorF("STN"); break; + case 1: ErrorF("TFT"); break; + case 2: ErrorF("Active STN"); break; + case 3: ErrorF("EL"); break; + case 4: ErrorF("Plasma"); break; + default: ErrorF("UNKNOWN"); break; + } + ErrorF("\n"); + if (RADEON_BIOS8(info->FPBIOSstart+61) & 1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Interface: LVDS\n"); + } else { + /* FIXME: Add Non-LVDS flat pael support */ + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Non-LVDS panel interface detected! " + "This support is untested and may not " + "function properly\n"); + } + } +#endif + + return TRUE; +} + +/* Read PLL parameters from BIOS block. Default to typical values if there + is no BIOS. */ +static Bool RADEONGetPLLParameters(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPLLPtr pll = &info->pll; + CARD16 bios_header; + CARD16 pll_info_block; + + if (!info->VBIOS) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected, using default PLL parameters!\n"); + /* These probably aren't going to work for + the card you are using. Specifically, + reference freq can be 29.50MHz, + 28.63MHz, or 14.32MHz. YMMV. */ + pll->reference_freq = 2950; + pll->reference_div = 65; + pll->min_pll_freq = 12500; + pll->max_pll_freq = 35000; + pll->xclk = 10300; + } else { + bios_header = RADEON_BIOS16(0x48); + pll_info_block = RADEON_BIOS16(bios_header + 0x30); + RADEONTRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", + bios_header, pll_info_block)); + + pll->reference_freq = RADEON_BIOS16(pll_info_block + 0x0e); + pll->reference_div = RADEON_BIOS16(pll_info_block + 0x10); + pll->min_pll_freq = RADEON_BIOS32(pll_info_block + 0x12); + pll->max_pll_freq = RADEON_BIOS32(pll_info_block + 0x16); + pll->xclk = RADEON_BIOS16(pll_info_block + 0x08); + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PLL parameters: rf=%d rd=%d min=%d max=%d; xclk=%d\n", + pll->reference_freq, + pll->reference_div, + pll->min_pll_freq, + pll->max_pll_freq, + pll->xclk); + + return TRUE; +} + +/* This is called by RADEONPreInit to set up the default visual. */ +static Bool RADEONPreInitVisual(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support32bppFb)) + return FALSE; + + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by %s driver\n", + pScrn->depth, RADEON_DRIVER_NAME); + return FALSE; + } + + xf86PrintDepthBpp(pScrn); + + info->fifo_slots = 0; + info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); + info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; + info->CurrentLayout.depth = pScrn->depth; + info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 + ? pScrn->bitsPerPixel + : pScrn->depth); + + if (info->pix24bpp == 24) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Radeon does NOT support 24bpp\n"); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", + pScrn->depth, + info->CurrentLayout.pixel_bytes, + info->CurrentLayout.pixel_bytes > 1 ? "s" : "", + info->pix24bpp); + + + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; + + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Default visual (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + return TRUE; + +} + +/* This is called by RADEONPreInit to handle all color weight issues. */ +static Bool RADEONPreInitWeight(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + /* Save flag for 6 bit DAC to use for + setting CRTC registers. Otherwise use + an 8 bit DAC, even if xf86SetWeight sets + pScrn->rgbBits to some value other than + 8. */ + info->dac6bits = FALSE; + if (pScrn->depth > 8) { + rgb defaultWeight = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + } else { + pScrn->rgbBits = 8; + if (xf86ReturnOptValBool(RADEONOptions, OPTION_DAC_6BIT, FALSE)) { + pScrn->rgbBits = 6; + info->dac6bits = TRUE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d bits per RGB (%d bit DAC)\n", + pScrn->rgbBits, info->dac6bits ? 6 : 8); + + return TRUE; + +} + +/* This is called by RADEONPreInit to handle config file overrides for things + like chipset and memory regions. Also determine memory size and type. + If memory type ever needs an override, put it in this routine. */ +static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + EntityInfoPtr pEnt = info->pEnt; + GDevPtr dev = pEnt->device; + int offset = 0; /* RAM Type */ + MessageType from; + unsigned char *RADEONMMIO; + + /* Chipset */ + from = X_PROBED; + if (dev->chipset && *dev->chipset) { + info->Chipset = xf86StringToToken(RADEONChipsets, dev->chipset); + from = X_CONFIG; + } else if (dev->chipID >= 0) { + info->Chipset = dev->chipID; + from = X_CONFIG; + } else { + info->Chipset = info->PciInfo->chipType; + } + pScrn->chipset = (char *)xf86TokenToString(RADEONChipsets, info->Chipset); + + if (!pScrn->chipset) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04x is not recognized\n", info->Chipset); + return FALSE; + } + + if (info->Chipset < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognized\n", pScrn->chipset); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, + "Chipset: \"%s\" (ChipID = 0x%04x)\n", + pScrn->chipset, + info->Chipset); + + /* Framebuffer */ + + from = X_PROBED; + info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; + if (dev->MemBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Linear address override, using 0x%08x instead of 0x%08x\n", + dev->MemBase, + info->LinearAddr); + info->LinearAddr = dev->MemBase; + from = X_CONFIG; + } else if (!info->LinearAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "No valid linear framebuffer address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "Linear framebuffer at 0x%08lx\n", info->LinearAddr); + + /* MMIO registers */ + from = X_PROBED; + info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; + if (dev->IOBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "MMIO address override, using 0x%08x instead of 0x%08x\n", + dev->IOBase, + info->MMIOAddr); + info->MMIOAddr = dev->IOBase; + from = X_CONFIG; + } else if (!info->MMIOAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid MMIO address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "MMIO registers at 0x%08lx\n", info->MMIOAddr); + + /* BIOS */ + from = X_PROBED; + info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; + if (dev->BiosBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BIOS address override, using 0x%08x instead of 0x%08x\n", + dev->BiosBase, + info->BIOSAddr); + info->BIOSAddr = dev->BiosBase; + from = X_CONFIG; + } + if (info->BIOSAddr) { + xf86DrvMsg(pScrn->scrnIndex, from, + "BIOS at 0x%08lx\n", info->BIOSAddr); + } + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Flat panel (part 1) */ + /* FIXME: Make this an option */ + switch (info->Chipset) { +#if 0 + case PCI_CHIP_RADEON_XX: info->HasPanelRegs = TRUE; break; +#endif + case PCI_CHIP_RADEON_QD: + case PCI_CHIP_RADEON_QE: + case PCI_CHIP_RADEON_QF: + case PCI_CHIP_RADEON_QG: + default: info->HasPanelRegs = FALSE; break; + } +#endif + + /* Read registers used to determine options */ + from = X_PROBED; + RADEONMapMMIO(pScrn); + RADEONMMIO = info->MMIO; + if (info->FBDev) + pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; + else + pScrn->videoRam = INREG(RADEON_CONFIG_MEMSIZE) / 1024; + info->MemCntl = INREG(RADEON_SDRAM_MODE_REG); + info->BusCntl = INREG(RADEON_BUS_CNTL); + RADEONMMIO = NULL; + RADEONUnmapMMIO(pScrn); + + /* RAM */ + switch (info->MemCntl >> 30) { + case 0: offset = 0; break; /* 64-bit SDR SDRAM */ + case 1: offset = 1; break; /* 64-bit DDR SDRAM */ + default: offset = 0; + } + info->ram = &RADEONRAM[offset]; + + if (dev->videoRam) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Video RAM override, using %d kB instead of %d kB\n", + dev->videoRam, + pScrn->videoRam); + from = X_CONFIG; + pScrn->videoRam = dev->videoRam; + } + pScrn->videoRam &= ~1023; + info->FbMapSize = pScrn->videoRam * 1024; + xf86DrvMsg(pScrn->scrnIndex, from, + "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Flat panel (part 2) */ + if (info->HasPanelRegs) { +#if 1 + info->CRTOnly = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); +#else + /* Panel CRT mode override */ + if ((info->CRTOnly = xf86ReturnOptValBool(RADEONOptions, + OPTION_CRT, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using external CRT instead of " + "flat panel for display\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); + } +#endif + + /* Panel width/height overrides */ + info->PanelXRes = 0; + info->PanelYRes = 0; + if (xf86GetOptValInteger(RADEONOptions, + OPTION_PANEL_WIDTH, &(info->PanelXRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel width: %d\n", info->PanelXRes); + } + if (xf86GetOptValInteger(RADEONOptions, + OPTION_PANEL_HEIGHT, &(info->PanelYRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel height: %d\n", info->PanelYRes); + } + } else { + info->CRTOnly = FALSE; + } +#endif + +#ifdef XF86DRI + /* AGP/PCI */ + if (xf86ReturnOptValBool(RADEONOptions, OPTION_IS_PCI, FALSE)) { + info->IsPCI = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); + } else { + switch (info->Chipset) { +#if 0 + case PCI_CHIP_RADEON_XX: info->IsPCI = TRUE; break; +#endif + case PCI_CHIP_RADEON_QD: + case PCI_CHIP_RADEON_QE: + case PCI_CHIP_RADEON_QF: + case PCI_CHIP_RADEON_QG: + default: info->IsPCI = FALSE; break; + } + } +#endif + + return TRUE; +} + +static Bool RADEONPreInitDDC(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + vbeInfoPtr pVbe; + + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; + xf86LoaderReqSymLists(ddcSymbols, NULL); + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; +} + +/* This is called by RADEONPreInit to initialize gamma correction. */ +static Bool RADEONPreInitGamma(ScrnInfoPtr pScrn) +{ + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) return FALSE; + return TRUE; +} + +/* This is called by RADEONPreInit to validate modes and compute parameters + for all of the valid modes. */ +static Bool RADEONPreInitModes(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + ClockRangePtr clockRanges; + int modesFound; + char *mod = NULL; + const char *Sym = NULL; + + /* Get mode information */ + pScrn->progClock = TRUE; + clockRanges = xnfcalloc(sizeof(*clockRanges), 1); + clockRanges->next = NULL; + clockRanges->minClock = info->pll.min_pll_freq; + clockRanges->maxClock = info->pll.max_pll_freq * 10; + clockRanges->clockIndex = -1; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) { + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + } else { + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + } +#else + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; +#endif + + modesFound = xf86ValidateModes(pScrn, + pScrn->monitor->Modes, + pScrn->display->modes, + clockRanges, + NULL, /* linePitches */ + 8 * 64, /* minPitch */ + 8 * 1024, /* maxPitch */ + 64 * pScrn->bitsPerPixel, /* pitchInc */ + 128, /* minHeight */ + 2048, /* maxHeight */ + pScrn->virtualX, + pScrn->virtualY, + info->FbMapSize, + LOOKUP_BEST_REFRESH); + + if (modesFound < 1 && info->FBDev) { + fbdevHWUseBuildinMode(pScrn); + pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ + modesFound = 1; + } + + if (modesFound == -1) return FALSE; + xf86PruneDriverModes(pScrn); + if (!modesFound || !pScrn->modes) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + return FALSE; + } + xf86SetCrtcForModes(pScrn, 0); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + + /* Set DPI */ + xf86SetDpi(pScrn, 0, 0); + + /* Get ScreenInit function */ +#ifdef USE_FB + mod = "fb"; + Sym = "fbScreenInit"; +#else + switch (pScrn->bitsPerPixel) { + case 8: mod = "cfb"; Sym = "cfbScreenInit"; break; + case 16: mod = "cfb16"; Sym = "cfb16ScreenInit"; break; + case 32: mod = "cfb32"; Sym = "cfb32ScreenInit"; break; + } +#endif + if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; + xf86LoaderReqSymbols(Sym, NULL); + +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif + + info->CurrentLayout.displayWidth = pScrn->displayWidth; + info->CurrentLayout.mode = pScrn->currentMode; + + return TRUE; +} + +/* This is called by RADEONPreInit to initialize the hardware cursor. */ +static Bool RADEONPreInitCursor(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_SW_CURSOR, FALSE)) { + if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; + } + return TRUE; +} + +/* This is called by RADEONPreInit to initialize hardware acceleration. */ +static Bool RADEONPreInitAccel(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE)) { + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; + } + return TRUE; +} + +static Bool RADEONPreInitInt10(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); +#if 1 + if (xf86LoadSubModule(pScrn, "int10")) { + xf86Int10InfoPtr pInt; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); + pInt = xf86InitInt10(info->pEnt->index); + xf86FreeInt10(pInt); + } +#endif + return TRUE; +} + +#ifdef XF86DRI +static Bool RADEONPreInitDRI(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->IsPCI) { + info->CPMode = RADEON_DEFAULT_CP_PIO_MODE; + } else if (xf86ReturnOptValBool(RADEONOptions, OPTION_CP_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CP into PIO mode\n"); + info->CPMode = RADEON_DEFAULT_CP_PIO_MODE; + } else { + info->CPMode = RADEON_DEFAULT_CP_BM_MODE; + } + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_USE_CP_2D, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CP for 2D\n"); + info->CP2D = TRUE; + } else { + info->CP2D = FALSE; + } + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CP Security checks disabled!!! **********\n"); + info->CPSecure = FALSE; + } else { + info->CPSecure = TRUE; + } + + info->agpMode = RADEON_DEFAULT_AGP_MODE; + info->agpSize = RADEON_DEFAULT_AGP_SIZE; + info->ringSize = RADEON_DEFAULT_RING_SIZE; + info->vbSize = RADEON_DEFAULT_VB_SIZE; + info->indSize = RADEON_DEFAULT_IND_SIZE; + info->agpTexSize = RADEON_DEFAULT_AGP_TEX_SIZE; + + info->vbBufSize = RADEON_DEFAULT_VB_BUF_SIZE; + + info->CPusecTimeout = RADEON_DEFAULT_CP_TIMEOUT; + + if (!info->IsPCI) { + if (xf86GetOptValInteger(RADEONOptions, + OPTION_AGP_MODE, &(info->agpMode))) { + if (info->agpMode < 1 || info->agpMode > RADEON_AGP_MAX_MODE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP Mode: %d\n", info->agpMode); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using AGP %dx mode\n", info->agpMode); + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_AGP_SIZE, (int *)&(info->agpSize))) { + switch (info->agpSize) { + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP size: %d MB\n", info->agpSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_RING_SIZE, &(info->ringSize))) { + if (info->ringSize < 1 || info->ringSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal ring buffer size: %d MB\n", + info->ringSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_VERT_SIZE, &(info->vbSize))) { + if (info->vbSize < 1 || info->vbSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex buffers list size: %d MB\n", + info->vbSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_VBUF_SIZE, &(info->vbBufSize))) { + int numBufs = info->vbSize*1024*1024/info->vbBufSize; + if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal individual vertex buffer size: %d bytes\n", + info->vbBufSize); + return FALSE; + } + } + + if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize > + info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Buffers are too big for requested AGP space\n"); + return FALSE; + } + + info->agpTexSize = info->agpSize - (info->ringSize + + info->vbSize + + info->indSize); + } + + if (xf86GetOptValInteger(RADEONOptions, OPTION_USEC_TIMEOUT, + &(info->CPusecTimeout))) { + /* This option checked by the RADEON DRM kernel module */ + } + + return TRUE; +} +#endif + +static void +RADEONProbeDDC(ScrnInfoPtr pScrn, int indx) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,indx); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + +/* RADEONPreInit is called once at server startup. */ +Bool RADEONPreInit(ScrnInfoPtr pScrn, int flags) +{ + RADEONInfoPtr info; + +#ifdef XFree86LOADER + /* + * Tell the loader about symbols from other modules that this module might + * refer to. + */ + LoaderRefSymLists(vgahwSymbols, +#ifdef USE_FB + fbSymbols, +#else + cfbSymbols, +#endif + xaaSymbols, + xf8_32bppSymbols, + ramdacSymbols, +#ifdef XF86DRI + drmSymbols, + driSymbols, +#endif + fbdevHWSymbols, + vbeSymbols, + /* ddcsymbols, */ + /* i2csymbols, */ + /* shadowSymbols, */ + NULL); +#endif + + RADEONTRACE(("RADEONPreInit\n")); + if (pScrn->numEntities != 1) return FALSE; + + if (!RADEONGetRec(pScrn)) return FALSE; + + info = RADEONPTR(pScrn); + + info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (info->pEnt->location.type != BUS_PCI) goto fail; + + if (flags & PROBE_DETECT) { + RADEONProbeDDC(pScrn, info->pEnt->index); + return TRUE; + } + + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + xf86LoaderReqSymLists(vgahwSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) { + RADEONFreeRec(pScrn); + return FALSE; + } + + info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); + info->PciTag = pciTag(info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PCI bus %d card %d func %d\n", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + + if (!RADEONPreInitVisual(pScrn)) goto fail; + + /* We can't do this until we have a + pScrn->display. */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, RADEONOptions); + + if (!RADEONPreInitWeight(pScrn)) goto fail; + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_FBDEV, FALSE)) { + info->FBDev = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using framebuffer device\n"); + } + + if (info->FBDev) { + /* check for linux framebuffer device */ + if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; + xf86LoaderReqSymLists(fbdevHWSymbols, NULL); + if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; + pScrn->SwitchMode = fbdevHWSwitchMode; + pScrn->AdjustFrame = fbdevHWAdjustFrame; + pScrn->EnterVT = RADEONEnterVTFBDev; + pScrn->LeaveVT = RADEONLeaveVTFBDev; + pScrn->ValidMode = fbdevHWValidMode; + } + + if (!info->FBDev) + if (!RADEONPreInitInt10(pScrn)) goto fail; + + if (!RADEONPreInitConfig(pScrn)) goto fail; + + if (!RADEONGetBIOSParameters(pScrn)) goto fail; + + if (!RADEONGetPLLParameters(pScrn)) goto fail; + + if (!RADEONPreInitDDC(pScrn)) goto fail; + + if (!RADEONPreInitGamma(pScrn)) goto fail; + + if (!RADEONPreInitModes(pScrn)) goto fail; + + if (!RADEONPreInitCursor(pScrn)) goto fail; + + if (!RADEONPreInitAccel(pScrn)) goto fail; + +#ifdef XF86DRI + if (!RADEONPreInitDRI(pScrn)) goto fail; +#endif + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + return TRUE; + + fail: + /* Pre-init failed. */ + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + vgaHWFreeHWRec(pScrn); + RADEONFreeRec(pScrn); + return FALSE; +} + +/* Load a palette. */ +static void RADEONLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + int idx; + unsigned char r, g, b; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + if (info->CurrentLayout.depth == 15) { + /* 15bpp mode. This sends 32 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + g = colors[idx].green; + b = colors[idx].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 8, r, g, b); + } + } + else if (info->CurrentLayout.depth == 16) { + /* 16bpp mode. This sends 64 values. */ + /* There are twice as many green values as + there are values for red and blue. So, + we take each red and blue pair, and + combine it with each of the two green + values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx / 2].red; + g = colors[idx].green; + b = colors[idx / 2].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 4, r, g, b); + + /* AH - Added to write extra green data - How come this isn't + * needed on R128 ? We didn't load the extra green data in the + * other routine */ + if (idx <= 31) { + r = colors[idx].red; + g = colors[(idx * 2) + 1].green; + b = colors[idx].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 8, r, g, b); + } + } + } + else { + /* 8bpp mode. This sends 256 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + b = colors[idx].blue; + g = colors[idx].green; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx, r, g, b); + } + } +} + +/* Called at the start of each server generation. */ +Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + BoxRec MemBox; + int y2; + + RADEONTRACE(("RADEONScreenInit %x %d\n", + pScrn->memPhysBase, pScrn->fbOffset)); + +#ifdef XF86DRI + /* Turn off the CP for now. */ + info->CPInUse = FALSE; +#endif + + if (!RADEONMapMem(pScrn)) return FALSE; + pScrn->fbOffset = 0; +#ifdef XF86DRI + info->fbX = 0; + info->fbY = 0; +#endif + + info->PaletteSavedOnVT = FALSE; + + RADEONSave(pScrn); + if (info->FBDev) { + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; + } else { + if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE; + } + + RADEONSaveScreen(pScreen, SCREEN_SAVER_ON); + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* Visual setup */ + miClearVisualTypes(); + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, + pScrn->defaultVisual)) return FALSE; + miSetPixmapDepths (); + +#ifdef XF86DRI + /* Setup DRI after visuals have been + established, but before cfbScreenInit is + called. cfbScreenInit will eventually + call the driver's InitGLXVisuals call + back. */ + { + /* FIXME: When we move to dynamic allocation of back and depth + buffers, we will want to revisit the following check for 3 + times the virtual size of the screen below. */ + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE) && + (maxy > pScrn->virtualY * 3) +#ifdef ENABLE_FLAT_PANEL + /* FIXME: Disable 3D support for FPs until it is tested */ + && !info->HasPanelRegs +#endif + ) { + info->directRenderingEnabled = RADEONDRIScreenInit(pScreen); + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Static buffer allocation failed -- " + "need at least %d kB video memory\n", + (pScrn->displayWidth * pScrn->virtualY * + info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024); + info->directRenderingEnabled = FALSE; + } + } +#endif + +#ifdef USE_FB + if (!fbScreenInit (pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel)) + return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif +#else + switch (pScrn->bitsPerPixel) { + case 8: + if (!cfbScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 16: + if (!cfb16ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 32: + if (!cfb32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Invalid bpp (%d)\n", pScrn->bitsPerPixel); + return FALSE; + } +#endif + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr visual; + + for (visual = pScreen->visuals + pScreen->numVisuals; + visual >= pScreen->visuals; + visual--) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + RADEONDGAInit(pScreen); + + /* Memory manager setup */ + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + y2 = (info->FbMapSize + / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes)); + if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */ + MemBox.y2 = y2; + + /* The acceleration engine uses 14 bit + signed coordinates, so we can't have any + drawable caches beyond this region. */ + if (MemBox.y2 > 8191) MemBox.y2 = 8191; + + if (!xf86InitFBManager(pScreen, &MemBox)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + return FALSE; + } else { + int width, height; + FBAreaPtr fbarea; + + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + 2, 0, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved area from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); + } + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } + +#ifdef XF86DRI + /* Allocate frame buffer space for the + shared back and depth buffers as well + as for local textures. */ + if (info->directRenderingEnabled) { + FBAreaPtr fbarea; + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + int l; + + switch (info->CPMode) { + case RADEON_DEFAULT_CP_PIO_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in PIO mode\n"); + break; + case RADEON_DEFAULT_CP_BM_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in BM mode\n"); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in UNKNOWN mode\n"); + break; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB AGP aperture\n", info->agpSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for the ring buffer\n", info->ringSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for vertex buffers\n", info->vbSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for indirect buffers\n", info->indSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for AGP textures\n", info->agpTexSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d byte vertex buffers\n", info->vbBufSize); + + /* Allocate the shared back buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved back buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->backX = fbarea->box.x1; + info->backY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); + info->backX = -1; + info->backY = -1; + } + + /* Allocate the shared depth buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->depthX = fbarea->box.x1; + info->depthY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); + info->depthX = -1; + info->depthY = -1; + } + + /* Allocate local texture space */ + if (((maxy - MemBox.y2 - 1) * width_bytes) > + (pScrn->virtualX * pScrn->virtualY * 2 * + info->CurrentLayout.pixel_bytes)) { + info->textureX = 0; + info->textureY = MemBox.y2 + 1; + info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes; + + l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); + if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + info->textureX, info->textureY, + pScrn->displayWidth, maxy); + } else if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY * 2, + 32, + NULL, NULL, NULL))) { + info->textureX = fbarea->box.x1; + info->textureY = fbarea->box.y1; + info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) * + (fbarea->box.x2 - fbarea->box.x1) * + info->CurrentLayout.pixel_bytes); + + l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); + if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve texture space in frame buffer\n"); + info->textureX = -1; + info->textureY = -1; + } + } +#endif + + /* Backing store setup */ + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + /* Set Silken Mouse */ + xf86SetSilkenMouse(pScreen); + + /* Acceleration setup */ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE)) { + if (RADEONAccelInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); + info->accelOn = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Acceleration initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + + /* Cursor setup */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Hardware cursor setup */ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_SW_CURSOR, FALSE)) { + if (RADEONCursorInit(pScreen)) { + int width, height; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using hardware cursor (scanline %d)\n", + info->cursor_start / pScrn->displayWidth); + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, + 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + + /* Colormap setup */ + if (!miCreateDefColormap(pScreen)) return FALSE; + if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8, + (info->FBDev ? fbdevHWLoadPalette : + RADEONLoadPalette), NULL, + CMAP_PALETTED_TRUECOLOR + | CMAP_RELOAD_ON_MODE_SWITCH +#if 0 /* This option messes up text mode! (eich@suse.de) */ + | CMAP_LOAD_EVEN_IF_OFFSCREEN +#endif + )) return FALSE; + + /* DPMS setup */ +#ifdef DPMSExtension +#ifdef ENABLE_FLAT_PANEL + if (!info->HasPanelRegs || info->CRTOnly) + xf86DPMSInit(pScreen, RADEONDisplayPowerManagementSet, 0); +#else + xf86DPMSInit(pScreen, RADEONDisplayPowerManagementSet, 0); +#endif +#endif + + RADEONInitVideo(pScreen); + + /* Provide SaveScreen */ + pScreen->SaveScreen = RADEONSaveScreen; + + /* Wrap CloseScreen */ + info->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = RADEONCloseScreen; + + /* Note unused options */ + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + +#ifdef XF86DRI + /* DRI finalization */ + if (info->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have + done their thing, complete the DRI + setup. */ + info->directRenderingEnabled = RADEONDRIFinishScreenInit(pScreen); + } + if (info->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } +#endif + + return TRUE; +} + +/* Write common registers (initialized to 0). */ +static void RADEONRestoreCommonRegisters(ScrnInfoPtr pScrn, + RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_OVR_CLR, restore->ovr_clr); + OUTREG(RADEON_OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right); + OUTREG(RADEON_OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom); + OUTREG(RADEON_OV0_SCALE_CNTL, restore->ov0_scale_cntl); + OUTREG(RADEON_MPP_TB_CONFIG, restore->mpp_tb_config ); + OUTREG(RADEON_MPP_GP_CONFIG, restore->mpp_gp_config ); + OUTREG(RADEON_SUBPIC_CNTL, restore->subpic_cntl); + OUTREG(RADEON_VIPH_CONTROL, restore->viph_control); + OUTREG(RADEON_I2C_CNTL_1, restore->i2c_cntl_1); + OUTREG(RADEON_GEN_INT_CNTL, restore->gen_int_cntl); + OUTREG(RADEON_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); + OUTREG(RADEON_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); + OUTREG(RADEON_BUS_CNTL, restore->bus_cntl); +} + +/* Write CRTC registers. */ +static void RADEONRestoreCrtcRegisters(ScrnInfoPtr pScrn, + RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_CRTC_GEN_CNTL, restore->crtc_gen_cntl); + + OUTREGP(RADEON_CRTC_EXT_CNTL, restore->crtc_ext_cntl, + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS | + RADEON_CRTC_DISPLAY_DIS); + + OUTREGP(RADEON_DAC_CNTL, restore->dac_cntl, + RADEON_DAC_RANGE_CNTL | + RADEON_DAC_BLANKING); + + OUTREG(RADEON_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); + OUTREG(RADEON_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); + OUTREG(RADEON_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); + OUTREG(RADEON_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); + OUTREG(RADEON_CRTC_OFFSET, restore->crtc_offset); + OUTREG(RADEON_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); + OUTREG(RADEON_CRTC_PITCH, restore->crtc_pitch); +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Write flat panel registers */ +static void RADEONRestoreFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 tmp; + + OUTREG(RADEON_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); + OUTREG(RADEON_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); + OUTREG(RADEON_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); + OUTREG(RADEON_FP_GEN_CNTL, restore->fp_gen_cntl); + OUTREG(RADEON_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); + OUTREG(RADEON_FP_HORZ_STRETCH, restore->fp_horz_stretch); + OUTREG(RADEON_FP_PANEL_CNTL, restore->fp_panel_cntl); + OUTREG(RADEON_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); + OUTREG(RADEON_FP_VERT_STRETCH, restore->fp_vert_stretch); + OUTREG(RADEON_TMDS_CRC, restore->tmds_crc); + + tmp = INREG(RADEON_LVDS_GEN_CNTL); + if ((tmp & (RADEON_LVDS_ON | RADEON_LVDS_BLON)) == + (restore->lvds_gen_cntl & (RADEON_LVDS_ON | RADEON_LVDS_BLON))) { + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + if (restore->lvds_gen_cntl & (RADEON_LVDS_ON | RADEON_LVDS_BLON)) { + OUTREG(RADEON_LVDS_GEN_CNTL, + restore->lvds_gen_cntl & ~RADEON_LVDS_BLON); + usleep(RADEONPTR(pScrn)->PanelPwrDly * 1000); + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + OUTREG(RADEON_LVDS_GEN_CNTL, + restore->lvds_gen_cntl | RADEON_LVDS_BLON); + usleep(RADEONPTR(pScrn)->PanelPwrDly * 1000); + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } + } +} +#endif + +#if RADEON_ATOMIC_UPDATE +static void RADEONPLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) +{ + while (INPLL(pScrn, RADEON_PPLL_REF_DIV) & RADEON_PPLL_ATOMIC_UPDATE_R); +} + +static void RADEONPLLWriteUpdate(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTPLLP(pScrn, RADEON_PPLL_REF_DIV, RADEON_PPLL_ATOMIC_UPDATE_W, 0xffff); +} +#endif + +/* Write PLL registers. */ +static void RADEONRestorePLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + +#if !RADEON_ATOMIC_UPDATE + while ( (INREG(RADEON_CLOCK_CNTL_INDEX) & RADEON_PLL_DIV_SEL) != + RADEON_PLL_DIV_SEL) { +#endif + OUTREGP(RADEON_CLOCK_CNTL_INDEX, RADEON_PLL_DIV_SEL, 0xffff); +#if !RADEON_ATOMIC_UPDATE + } +#endif + +#if RADEON_ATOMIC_UPDATE + OUTPLLP(pScrn, + RADEON_PPLL_CNTL, + RADEON_PPLL_RESET + | RADEON_PPLL_ATOMIC_UPDATE_EN + | RADEON_PPLL_VGA_ATOMIC_UPDATE_EN, + 0xffff); +#else + OUTPLLP(pScrn, + RADEON_PPLL_CNTL, + RADEON_PPLL_RESET, + 0xffff); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_REF_DIV) & RADEON_PPLL_REF_DIV_MASK) != + (restore->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_REF_DIV, + restore->ppll_ref_div, ~RADEON_PPLL_REF_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_DIV_3) & RADEON_PPLL_FB3_DIV_MASK) != + (restore->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_DIV_3, + restore->ppll_div_3, ~RADEON_PPLL_FB3_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_DIV_3) & RADEON_PPLL_POST3_DIV_MASK) != + (restore->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_DIV_3, + restore->ppll_div_3, ~RADEON_PPLL_POST3_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + OUTPLL(RADEON_HTOTAL_CNTL, restore->htotal_cntl); +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + + OUTPLLP(pScrn, RADEON_PPLL_CNTL, 0, ~RADEON_PPLL_RESET); + + RADEONTRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", + restore->ppll_ref_div, + restore->ppll_div_3, + restore->htotal_cntl, + INPLL(pScrn, RADEON_PPLL_CNTL))); + RADEONTRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", + restore->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK, + restore->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK, + (restore->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Write DDA registers. */ +static void RADEONRestoreDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_DDA_CONFIG, restore->dda_config); + OUTREG(RADEON_DDA_ON_OFF, restore->dda_on_off); +} + +/* Write palette data. */ +static void RADEONRestorePalette(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + if (!restore->palette_valid) return; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + OUTPAL_START(0); + for (i = 0; i < 256; i++) { + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL_NEXT_CARD32(restore->palette[i]); + } +} + +/* Write out state to define a new video mode. */ +static void RADEONRestoreMode(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ +#ifdef ENABLE_FLAT_PANEL + RADEONInfoPtr info = RADEONPTR(pScrn); +#endif + + RADEONTRACE(("RADEONRestoreMode(%p)\n", restore)); + RADEONRestoreCommonRegisters(pScrn, restore); + RADEONRestoreCrtcRegisters(pScrn, restore); +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + RADEONRestoreFPRegisters(pScrn, restore); + if (!info->HasPanelRegs || info->CRTOnly) + RADEONRestorePLLRegisters(pScrn, restore); +#else + RADEONRestorePLLRegisters(pScrn, restore); +#endif + RADEONRestoreDDARegisters(pScrn, restore); + RADEONRestorePalette(pScrn, restore); +} + +/* Read common registers. */ +static void RADEONSaveCommonRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->ovr_clr = INREG(RADEON_OVR_CLR); + save->ovr_wid_left_right = INREG(RADEON_OVR_WID_LEFT_RIGHT); + save->ovr_wid_top_bottom = INREG(RADEON_OVR_WID_TOP_BOTTOM); + save->ov0_scale_cntl = INREG(RADEON_OV0_SCALE_CNTL); + save->mpp_tb_config = INREG(RADEON_MPP_TB_CONFIG); + save->mpp_gp_config = INREG(RADEON_MPP_GP_CONFIG); + save->subpic_cntl = INREG(RADEON_SUBPIC_CNTL); + save->viph_control = INREG(RADEON_VIPH_CONTROL); + save->i2c_cntl_1 = INREG(RADEON_I2C_CNTL_1); + save->gen_int_cntl = INREG(RADEON_GEN_INT_CNTL); + save->cap0_trig_cntl = INREG(RADEON_CAP0_TRIG_CNTL); + save->cap1_trig_cntl = INREG(RADEON_CAP1_TRIG_CNTL); + save->bus_cntl = INREG(RADEON_BUS_CNTL); +} + +/* Read CRTC registers. */ +static void RADEONSaveCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->crtc_gen_cntl = INREG(RADEON_CRTC_GEN_CNTL); + save->crtc_ext_cntl = INREG(RADEON_CRTC_EXT_CNTL); + save->dac_cntl = INREG(RADEON_DAC_CNTL); + save->crtc_h_total_disp = INREG(RADEON_CRTC_H_TOTAL_DISP); + save->crtc_h_sync_strt_wid = INREG(RADEON_CRTC_H_SYNC_STRT_WID); + save->crtc_v_total_disp = INREG(RADEON_CRTC_V_TOTAL_DISP); + save->crtc_v_sync_strt_wid = INREG(RADEON_CRTC_V_SYNC_STRT_WID); + save->crtc_offset = INREG(RADEON_CRTC_OFFSET); + save->crtc_offset_cntl = INREG(RADEON_CRTC_OFFSET_CNTL); + save->crtc_pitch = INREG(RADEON_CRTC_PITCH); +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Read flat panel registers */ +static void RADEONSaveFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->crtc2_gen_cntl = INREG(RADEON_CRTC2_GEN_CNTL); + save->fp_crtc_h_total_disp = INREG(RADEON_FP_CRTC_H_TOTAL_DISP); + save->fp_crtc_v_total_disp = INREG(RADEON_FP_CRTC_V_TOTAL_DISP); + save->fp_gen_cntl = INREG(RADEON_FP_GEN_CNTL); + save->fp_h_sync_strt_wid = INREG(RADEON_FP_H_SYNC_STRT_WID); + save->fp_horz_stretch = INREG(RADEON_FP_HORZ_STRETCH); + save->fp_panel_cntl = INREG(RADEON_FP_PANEL_CNTL); + save->fp_v_sync_strt_wid = INREG(RADEON_FP_V_SYNC_STRT_WID); + save->fp_vert_stretch = INREG(RADEON_FP_VERT_STRETCH); + save->lvds_gen_cntl = INREG(RADEON_LVDS_GEN_CNTL); + save->tmds_crc = INREG(RADEON_TMDS_CRC); +} +#endif + +/* Read PLL registers. */ +static void RADEONSavePLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + save->ppll_ref_div = INPLL(pScrn, RADEON_PPLL_REF_DIV); + save->ppll_div_3 = INPLL(pScrn, RADEON_PPLL_DIV_3); + save->htotal_cntl = INPLL(pScrn, RADEON_HTOTAL_CNTL); + + RADEONTRACE(("Read: 0x%08x 0x%08x 0x%08x\n", + save->ppll_ref_div, + save->ppll_div_3, + save->htotal_cntl)); + RADEONTRACE(("Read: rd=%d, fd=%d, pd=%d\n", + save->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK, + save->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK, + (save->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Read DDA registers. */ +static void RADEONSaveDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->dda_config = INREG(RADEON_DDA_CONFIG); + save->dda_on_off = INREG(RADEON_DDA_ON_OFF); +} + +/* Read palette data. */ +static void RADEONSavePalette(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + INPAL_START(0); + for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT(); + save->palette_valid = TRUE; +} + +/* Save state that defines current video mode. */ +static void RADEONSaveMode(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONTRACE(("RADEONSaveMode(%p)\n", save)); + + RADEONSaveCommonRegisters(pScrn, save); + RADEONSaveCrtcRegisters(pScrn, save); +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (RADEONPTR(pScrn)->HasPanelRegs) + RADEONSaveFPRegisters(pScrn, save); +#endif + RADEONSavePLLRegisters(pScrn, save); + RADEONSaveDDARegisters(pScrn, save); + RADEONSavePalette(pScrn, save); + + RADEONTRACE(("RADEONSaveMode returns %p\n", save)); +} + +/* Save everything needed to restore the original VC state. */ +static void RADEONSave(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONSavePtr save = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + RADEONTRACE(("RADEONSave\n")); + if (info->FBDev) { + fbdevHWSave(pScrn); + return; + } + vgaHWUnlock(hwp); + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ + vgaHWLock(hwp); + + RADEONSaveMode(pScrn, save); + + save->dp_datatype = INREG(RADEON_DP_DATATYPE); + save->rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); + save->clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); + save->amcgpio_en_reg = INREG(RADEON_AMCGPIO_EN_REG); + save->amcgpio_mask = INREG(RADEON_AMCGPIO_MASK); +} + +/* Restore the original (text) mode. */ +static void RADEONRestore(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONSavePtr restore = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + RADEONTRACE(("RADEONRestore\n")); + if (info->FBDev) { + fbdevHWRestore(pScrn); + return; + } + + RADEONBlank(pScrn); + + OUTREG(RADEON_AMCGPIO_MASK, restore->amcgpio_mask); + OUTREG(RADEON_AMCGPIO_EN_REG, restore->amcgpio_en_reg); + OUTREG(RADEON_CLOCK_CNTL_INDEX, restore->clock_cntl_index); + OUTREG(RADEON_RBBM_SOFT_RESET, restore->rbbm_soft_reset); + OUTREG(RADEON_DP_DATATYPE, restore->dp_datatype); + + RADEONRestoreMode(pScrn, restore); + vgaHWUnlock(hwp); + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); + vgaHWLock(hwp); + +#if 0 + RADEONWaitForVerticalSync(pScrn); +#endif + RADEONUnblank(pScrn); +} + +/* Define common registers for requested video mode. */ +static void RADEONInitCommonRegisters(RADEONSavePtr save, RADEONInfoPtr info) +{ + save->ovr_clr = 0; + save->ovr_wid_left_right = 0; + save->ovr_wid_top_bottom = 0; + save->ov0_scale_cntl = 0; + save->mpp_tb_config = 0; + save->mpp_gp_config = 0; + save->subpic_cntl = 0; + save->viph_control = 0; + save->i2c_cntl_1 = 0; + save->rbbm_soft_reset = 0; + save->cap0_trig_cntl = 0; + save->cap1_trig_cntl = 0; + save->bus_cntl = info->BusCntl; + /* + * If bursts are enabled, turn on discards + * Radeon doesn't have write bursts + */ + if (save->bus_cntl & (RADEON_BUS_READ_BURST)) + save->bus_cntl |= RADEON_BUS_RD_DISCARD_EN; +} + +/* Define CRTC registers for requested video mode. */ +static Bool RADEONInitCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, + DisplayModePtr mode, RADEONInfoPtr info) +{ + int format; + int hsync_start; + int hsync_wid; + int hsync_fudge; + int vsync_wid; + int bytpp; + int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + int hsync_fudge_fp[] = { 0x12, 0x11, 0x09, 0x09, 0x05, 0x05 }; + int hsync_fudge_fp_crt[] = { 0x12, 0x10, 0x08, 0x08, 0x04, 0x04 }; +#endif + + switch (info->CurrentLayout.pixel_code) { + case 4: format = 1; bytpp = 0; break; + case 8: format = 2; bytpp = 1; break; + case 15: format = 3; bytpp = 2; break; /* 555 */ + case 16: format = 4; bytpp = 2; break; /* 565 */ + case 24: format = 5; bytpp = 3; break; /* RGB */ + case 32: format = 6; bytpp = 4; break; /* xRGB */ + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); + return FALSE; + } + RADEONTRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp)); + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + if (info->CRTOnly) hsync_fudge = hsync_fudge_fp_crt[format-1]; + else hsync_fudge = hsync_fudge_fp[format-1]; + else hsync_fudge = hsync_fudge_default[format-1]; +#else + hsync_fudge = hsync_fudge_default[format-1]; +#endif + + save->crtc_gen_cntl = (RADEON_CRTC_EXT_DISP_EN + | RADEON_CRTC_EN + | (format << 8) + | ((mode->Flags & V_DBLSCAN) + ? RADEON_CRTC_DBL_SCAN_EN + : 0) + | ((mode->Flags & V_INTERLACE) + ? RADEON_CRTC_INTERLACE_EN + : 0)); + + save->crtc_ext_cntl = RADEON_VGA_ATI_LINEAR | RADEON_XCRT_CNT_EN; + save->dac_cntl = (RADEON_DAC_MASK_ALL + | RADEON_DAC_VGA_ADR_EN + | (info->dac6bits ? 0 : RADEON_DAC_8BIT_EN)); + + save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) + | (((mode->CrtcHDisplay / 8) - 1) << 16)); + + hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; + if (!hsync_wid) hsync_wid = 1; + if (hsync_wid > 0x3f) hsync_wid = 0x3f; + + hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; + + save->crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) + | (hsync_wid << 16) + | ((mode->Flags & V_NHSYNC) + ? RADEON_CRTC_H_SYNC_POL + : 0)); + +#if 1 + /* This works for double scan mode. */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay - 1) << 16)); +#else + /* This is what cce/nbmode.c example code + does -- is this correct? */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay + * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) + << 16)); +#endif + + vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; + if (!vsync_wid) vsync_wid = 1; + if (vsync_wid > 0x1f) vsync_wid = 0x1f; + + save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) + | (vsync_wid << 16) + | ((mode->Flags & V_NVSYNC) + ? RADEON_CRTC_V_SYNC_POL + : 0)); + save->crtc_offset = 0; + save->crtc_offset_cntl = 0; + + save->crtc_pitch = ((pScrn->displayWidth * pScrn->bitsPerPixel) + + ((pScrn->bitsPerPixel * 8) -1)) / + (pScrn->bitsPerPixel * 8); + save->crtc_pitch |= save->crtc_pitch << 16; + + RADEONTRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", + save->crtc_pitch, pScrn->virtualX, + info->CurrentLayout.displayWidth)); + return TRUE; +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Define CRTC registers for requested video mode. */ +static void RADEONInitFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr orig, + RADEONSavePtr save, DisplayModePtr mode, + RADEONInfoPtr info) +{ + int xres = mode->CrtcHDisplay; + int yres = mode->CrtcVDisplay; + float Hratio, Vratio; + + if (info->CRTOnly) { + save->crtc_ext_cntl |= RADEON_CRTC_CRT_ON; + save->crtc2_gen_cntl = 0; + save->fp_gen_cntl = orig->fp_gen_cntl; + save->fp_gen_cntl &= ~(RADEON_FP_FPON | + RADEON_FP_CRTC_USE_SHADOW_VEND | + RADEON_FP_CRTC_HORZ_DIV2_EN | + RADEON_FP_CRTC_HOR_CRT_DIV2_DIS | + RADEON_FP_USE_SHADOW_EN); + save->fp_gen_cntl |= (RADEON_FP_SEL_CRTC2 | + RADEON_FP_CRTC_DONT_SHADOW_VPAR); + save->fp_panel_cntl = orig->fp_panel_cntl & ~RADEON_FP_DIGON; + save->lvds_gen_cntl = orig->lvds_gen_cntl & ~(RADEON_LVDS_ON | + RADEON_LVDS_BLON); + return; + } + + if (xres > info->PanelXRes) xres = info->PanelXRes; + if (yres > info->PanelYRes) yres = info->PanelYRes; + + Hratio = (float)xres/(float)info->PanelXRes; + Vratio = (float)yres/(float)info->PanelYRes; + + save->fp_horz_stretch = + (((((int)(Hratio * RADEON_HORZ_STRETCH_RATIO_MAX + 0.5)) + & RADEON_HORZ_STRETCH_RATIO_MASK) + << RADEON_HORZ_STRETCH_RATIO_SHIFT) | + (orig->fp_horz_stretch & (RADEON_HORZ_PANEL_SIZE | + RADEON_HORZ_FP_LOOP_STRETCH | + RADEON_HORZ_STRETCH_RESERVED))); + save->fp_horz_stretch &= ~RADEON_HORZ_AUTO_RATIO_FIX_EN; + if (Hratio == 1.0) save->fp_horz_stretch &= ~(RADEON_HORZ_STRETCH_BLEND | + RADEON_HORZ_STRETCH_ENABLE); + else save->fp_horz_stretch |= (RADEON_HORZ_STRETCH_BLEND | + RADEON_HORZ_STRETCH_ENABLE); + + save->fp_vert_stretch = + (((((int)(Vratio * RADEON_VERT_STRETCH_RATIO_MAX + 0.5)) + & RADEON_VERT_STRETCH_RATIO_MASK) + << RADEON_VERT_STRETCH_RATIO_SHIFT) | + (orig->fp_vert_stretch & (RADEON_VERT_PANEL_SIZE | + RADEON_VERT_STRETCH_RESERVED))); + save->fp_vert_stretch &= ~RADEON_VERT_AUTO_RATIO_EN; + if (Vratio == 1.0) save->fp_vert_stretch &= ~(RADEON_VERT_STRETCH_ENABLE | + RADEON_VERT_STRETCH_BLEND); + else save->fp_vert_stretch |= (RADEON_VERT_STRETCH_ENABLE | + RADEON_VERT_STRETCH_BLEND); + + save->fp_gen_cntl = (orig->fp_gen_cntl & ~(RADEON_FP_SEL_CRTC2 | + RADEON_FP_CRTC_USE_SHADOW_VEND | + RADEON_FP_CRTC_HORZ_DIV2_EN | + RADEON_FP_CRTC_HOR_CRT_DIV2_DIS | + RADEON_FP_USE_SHADOW_EN)); + if (orig->fp_gen_cntl & RADEON_FP_DETECT_SENSE) { + save->fp_gen_cntl |= (RADEON_FP_CRTC_DONT_SHADOW_VPAR | + RADEON_FP_TDMS_EN); + } + + save->fp_panel_cntl = orig->fp_panel_cntl; + save->lvds_gen_cntl = orig->lvds_gen_cntl; + + save->tmds_crc = orig->tmds_crc; + + /* Disable CRT output by disabling CRT output and setting the CRT + DAC to use CRTC2, which we set to 0's. In the future, we will + want to use the dual CRTC capabilities of the RADEON to allow both + the flat panel and external CRT to either simultaneously display + the same image or display two different images. */ + save->crtc_ext_cntl &= ~RADEON_CRTC_CRT_ON; + save->dac_cntl |= RADEON_DAC_CRT_SEL_CRTC2; + save->crtc2_gen_cntl = 0; + + /* WARNING: Be careful about turning on the flat panel */ +#if 1 + save->lvds_gen_cntl |= (RADEON_LVDS_ON | RADEON_LVDS_BLON); +#else + save->fp_panel_cntl |= (RADEON_FP_DIGON | RADEON_FP_BLON); + save->fp_gen_cntl |= (RADEON_FP_FPON); +#endif + + save->fp_crtc_h_total_disp = save->crtc_h_total_disp; + save->fp_crtc_v_total_disp = save->crtc_v_total_disp; + save->fp_h_sync_strt_wid = save->crtc_h_sync_strt_wid; + save->fp_v_sync_strt_wid = save->crtc_v_sync_strt_wid; +} +#endif + +/* Define PLL registers for requested video mode. */ +static void RADEONInitPLLRegisters(RADEONSavePtr save, RADEONPLLPtr pll, + double dot_clock) +{ + unsigned long freq = dot_clock * 100; + struct { + int divider; + int bitvalue; + } *post_div, + post_divs[] = { + /* From RAGE 128 VR/RAGE 128 GL Register + Reference Manual (Technical Reference + Manual P/N RRG-G04100-C Rev. 0.04), page + 3-17 (PLL_DIV_[3:0]). */ + { 1, 0 }, /* VCLK_SRC */ + { 2, 1 }, /* VCLK_SRC/2 */ + { 4, 2 }, /* VCLK_SRC/4 */ + { 8, 3 }, /* VCLK_SRC/8 */ + { 3, 4 }, /* VCLK_SRC/3 */ + { 16, 5 }, /* VCLK_SRC/16 */ + { 6, 6 }, /* VCLK_SRC/6 */ + { 12, 7 }, /* VCLK_SRC/12 */ + { 0, 0 } + }; + + if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; + if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; + + for (post_div = &post_divs[0]; post_div->divider; ++post_div) { + save->pll_output_freq = post_div->divider * freq; + if (save->pll_output_freq >= pll->min_pll_freq + && save->pll_output_freq <= pll->max_pll_freq) break; + } + + save->dot_clock_freq = freq; + save->feedback_div = RADEONDiv(pll->reference_div + * save->pll_output_freq, + pll->reference_freq); + save->post_div = post_div->divider; + + RADEONTRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", + save->dot_clock_freq, + save->pll_output_freq, + save->feedback_div, + save->post_div)); + + save->ppll_ref_div = pll->reference_div; + save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); + save->htotal_cntl = 0; +} + +/* Define DDA registers for requested video mode. */ +static Bool RADEONInitDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, + RADEONPLLPtr pll, RADEONInfoPtr info) +{ + int DisplayFifoWidth = 128; + int DisplayFifoDepth = 32; + int XclkFreq; + int VclkFreq; + int XclksPerTransfer; + int XclksPerTransferPrecise; + int UseablePrecision; + int Roff; + int Ron; + + XclkFreq = pll->xclk; + + VclkFreq = RADEONDiv(pll->reference_freq * save->feedback_div, + pll->reference_div * save->post_div); + + XclksPerTransfer = RADEONDiv(XclkFreq * DisplayFifoWidth, + VclkFreq * + (info->CurrentLayout.pixel_bytes * 8)); + + UseablePrecision = RADEONMinBits(XclksPerTransfer) + 1; + + XclksPerTransferPrecise = RADEONDiv((XclkFreq * DisplayFifoWidth) + << (11 - UseablePrecision), + VclkFreq * + (info->CurrentLayout.pixel_bytes * 8)); + + Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); + + Ron = (4 * info->ram->MB + + 3 * MAX(info->ram->Trcd - 2, 0) + + 2 * info->ram->Trp + + info->ram->Twr + + info->ram->CL + + info->ram->Tr2w + + XclksPerTransfer) << (11 - UseablePrecision); + + if (Ron + info->ram->Rloop >= Roff) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", + Ron, info->ram->Rloop, Roff); + return FALSE; + } + + save->dda_config = (XclksPerTransferPrecise + | (UseablePrecision << 16) + | (info->ram->Rloop << 20)); + + save->dda_on_off = (Ron << 16) | Roff; + + RADEONTRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", + XclkFreq, + VclkFreq, + XclksPerTransfer, + XclksPerTransferPrecise, + UseablePrecision)); + RADEONTRACE(("Roff = %d, Ron = %d, Rloop = %d\n", + Roff, Ron, info->ram->Rloop)); + + return TRUE; +} + + +/* Define initial palette for requested video mode. This doesn't do + anything for XFree86 4.0. */ +static void RADEONInitPalette(RADEONSavePtr save) +{ + save->palette_valid = FALSE; +} + +/* Define registers for a requested video mode. */ +static Bool RADEONInit(ScrnInfoPtr pScrn, DisplayModePtr mode, + RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + double dot_clock = mode->Clock/1000.0; + +#if RADEON_DEBUG + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->HDisplay, + mode->HSyncStart, + mode->HSyncEnd, + mode->HTotal, + + mode->VDisplay, + mode->VSyncStart, + mode->VSyncEnd, + mode->VTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->CrtcHDisplay, + mode->CrtcHSyncStart, + mode->CrtcHSyncEnd, + mode->CrtcHTotal, + + mode->CrtcVDisplay, + mode->CrtcVSyncStart, + mode->CrtcVSyncEnd, + mode->CrtcVTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); +#endif + + info->Flags = mode->Flags; + + RADEONInitCommonRegisters(save, info); + if (!RADEONInitCrtcRegisters(pScrn, save, mode, info)) return FALSE; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + RADEONInitFPRegisters(pScrn, &info->SavedReg, save, mode, info); +#endif + RADEONInitPLLRegisters(save, &info->pll, dot_clock); + if (!RADEONInitDDARegisters(pScrn, save, &info->pll, info)) + return FALSE; + if (!info->PaletteSavedOnVT) RADEONInitPalette(save); + + RADEONTRACE(("RADEONInit returns %p\n", save)); + return TRUE; +} + +/* Initialize a new mode. */ +static Bool RADEONModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!RADEONInit(pScrn, mode, &info->ModeReg)) return FALSE; + /* FIXME? DRILock/DRIUnlock here? */ + pScrn->vtSema = TRUE; + RADEONBlank(pScrn); + RADEONRestoreMode(pScrn, &info->ModeReg); + RADEONUnblank(pScrn); + + info->CurrentLayout.mode = mode; + + return TRUE; +} + +static Bool RADEONSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool unblank; + + unblank = xf86IsUnblank(mode); + if (unblank) + SetTimeSinceLastInputEvent(); + + if ((pScrn != NULL) && pScrn->vtSema) { + if (unblank) + RADEONUnblank(pScrn); + else + RADEONBlank(pScrn); + } + return TRUE; +} + +Bool RADEONSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return RADEONModeInit(xf86Screens[scrnIndex], mode); +} + +/* Used to disallow modes that are not supported by the hardware. */ +int RADEONValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flag) +{ +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->HasPanelRegs) { + if (mode->Flags & V_INTERLACE) return MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN) return MODE_NO_DBLESCAN; + } + + if (info->HasPanelRegs && !info->CRTOnly && info->VBIOS) { + int i; + for (i = info->FPBIOSstart+64; RADEON_BIOS16(i) != 0; i += 2) { + int j = RADEON_BIOS16(i); + + if (mode->CrtcHDisplay == RADEON_BIOS16(j) && + mode->CrtcVDisplay == RADEON_BIOS16(j+2)) { + /* Assume we are using expanded mode */ + if (RADEON_BIOS16(j+5)) j = RADEON_BIOS16(j+5); + else j += 9; + + mode->Clock = (CARD32)RADEON_BIOS16(j) * 10; + + mode->HDisplay = mode->CrtcHDisplay = + ((RADEON_BIOS16(j+10) & 0x01ff)+1)*8; + mode->HSyncStart = mode->CrtcHSyncStart = + ((RADEON_BIOS16(j+12) & 0x01ff)+1)*8; + mode->HSyncEnd = mode->CrtcHSyncEnd = + mode->CrtcHSyncStart + (RADEON_BIOS8(j+14) & 0x1f); + mode->HTotal = mode->CrtcHTotal = + ((RADEON_BIOS16(j+8) & 0x01ff)+1)*8; + + mode->VDisplay = mode->CrtcVDisplay = + (RADEON_BIOS16(j+17) & 0x07ff)+1; + mode->VSyncStart = mode->CrtcVSyncStart = + (RADEON_BIOS16(j+19) & 0x07ff)+1; + mode->VSyncEnd = mode->CrtcVSyncEnd = + mode->CrtcVSyncStart + ((RADEON_BIOS16(j+19) >> 11)&0x1f); + mode->VTotal = mode->CrtcVTotal = + (RADEON_BIOS16(j+15) & 0x07ff)+1; + + return MODE_OK; + } + } + return MODE_NOMODE; + } +#endif + + return MODE_OK; +} + +/* Adjust viewport into virtual desktop such that (0,0) in viewport space + is (x,y) in virtual space. */ +void RADEONAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int Base; + + Base = y * info->CurrentLayout.displayWidth + x; + + switch (info->CurrentLayout.pixel_code) { + case 15: + case 16: Base *= 2; break; + case 24: Base *= 3; break; + case 32: Base *= 4; break; + } + + Base &= ~7; /* 3 lower bits are always 0 */ + + OUTREG(RADEON_CRTC_OFFSET, Base); +} + +/* Called when VT switching back to the X server. Reinitialize the video + mode. */ +Bool RADEONEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONTRACE(("RADEONEnterVT\n")); +#ifdef XF86DRI + if (RADEONPTR(pScrn)->directRenderingEnabled) { + RADEONCPStart(pScrn); + DRIUnlock(pScrn->pScreen); + } +#endif + if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE; + if (info->accelOn) + RADEONEngineInit(pScrn); + + info->PaletteSavedOnVT = FALSE; + RADEONAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +/* Called when VT switching away from the X server. Restore the original + text mode. */ +void RADEONLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr save = &info->ModeReg; + + RADEONTRACE(("RADEONLeaveVT\n")); +#ifdef XF86DRI + if (RADEONPTR(pScrn)->directRenderingEnabled) { + DRILock(pScrn->pScreen, 0); + RADEONCPStop(pScrn); + } +#endif + RADEONSavePalette(pScrn, save); + info->PaletteSavedOnVT = TRUE; + RADEONRestore(pScrn); +} + +static Bool +RADEONEnterVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr restore = &info->SavedReg; + fbdevHWEnterVT(scrnIndex,flags); + RADEONRestorePalette(pScrn,restore); + RADEONEngineInit(pScrn); + return TRUE; +} + +static void RADEONLeaveVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr save = &info->SavedReg; + RADEONSavePalette(pScrn,save); + fbdevHWLeaveVT(scrnIndex,flags); +} + +/* Called at the end of each server generation. Restore the original text + mode, unmap video memory, and unwrap and call the saved CloseScreen + function. */ +static Bool RADEONCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONTRACE(("RADEONCloseScreen\n")); + +#ifdef XF86DRI + /* Disable direct rendering */ + if (info->directRenderingEnabled) { + RADEONDRICloseScreen(pScreen); + info->directRenderingEnabled = FALSE; + } +#endif + + if (pScrn->vtSema) { + RADEONRestore(pScrn); + RADEONUnmapMem(pScrn); + } + + if (info->accel) XAADestroyInfoRec(info->accel); + info->accel = NULL; + + if (info->scratch_save) xfree(info->scratch_save); + info->scratch_save = NULL; + + if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); + info->cursor = NULL; + + if (info->DGAModes) xfree(info->DGAModes); + info->DGAModes = NULL; + + pScrn->vtSema = FALSE; + + pScreen->CloseScreen = info->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + +void RADEONFreeScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + RADEONTRACE(("RADEONFreeScreen\n")); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(pScrn); + RADEONFreeRec(pScrn); +} + +#ifdef DPMSExtension +/* Sets VESA Display Power Management Signaling (DPMS) Mode. */ +static void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int mask = (RADEON_CRTC_DISPLAY_DIS + | RADEON_CRTC_HSYNC_DIS + | RADEON_CRTC_VSYNC_DIS); + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + OUTREGP(RADEON_CRTC_EXT_CNTL, 0, ~mask); + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On */ + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | RADEON_CRTC_HSYNC_DIS, ~mask); + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off */ + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | RADEON_CRTC_VSYNC_DIS, ~mask); + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + OUTREGP(RADEON_CRTC_EXT_CNTL, mask, ~mask); + break; + } +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c new file mode 100644 index 000000000..50cf084f1 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c @@ -0,0 +1,85 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c,v 1.1 2000/11/02 16:55:43 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 XFree86LOADER + +#include "ati.h" +#include "ativersion.h" + +#include "radeon_version.h" + +#include "xf86.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo RADEONVersionRec = +{ + RADEON_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + RADEON_VERSION_MAJOR, RADEON_VERSION_MINOR, RADEON_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * RADEONSetup -- + * + * This function is called every time the module is loaded. + */ +static pointer +RADEONSetup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called radeonModuleData */ +XF86ModuleData radeonModuleData = +{ + &RADEONVersionRec, + RADEONSetup, + NULL +}; + +#endif /* XFree86LOADER */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c new file mode 100644 index 000000000..e4200f689 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c @@ -0,0 +1,185 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c,v 1.1 2000/11/02 16:55:44 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario + * and 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Rickard E. Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#include "atimodule.h" +#include "ativersion.h" + +#include "radeon_probe.h" +#include "radeon_version.h" + +#include "xf86PciInfo.h" + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86Resources.h" + +SymTabRec RADEONChipsets[] = { + { PCI_CHIP_RADEON_QD, "ATI Radeon QD (AGP)" }, + { PCI_CHIP_RADEON_QE, "ATI Radeon QE (AGP)" }, + { PCI_CHIP_RADEON_QF, "ATI Radeon QF (AGP)" }, + { PCI_CHIP_RADEON_QG, "ATI Radeon QG (AGP)" }, + { -1, NULL } +}; + +PciChipsets RADEONPciChipsets[] = { + { PCI_CHIP_RADEON_QD, PCI_CHIP_RADEON_QD, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QE, PCI_CHIP_RADEON_QE, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QF, PCI_CHIP_RADEON_QF, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QG, PCI_CHIP_RADEON_QG, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +/* Return the options for supported chipset 'n'; NULL otherwise */ +OptionInfoPtr +RADEONAvailableOptions(int chipid, int busid) +{ + int i; + + /* + * Return options defined in the radeon submodule which will have been + * loaded by this point. + */ + for (i = 0; RADEONPciChipsets[i].PCIid > 0; i++) { + if (chipid == RADEONPciChipsets[i].PCIid) + return RADEONOptions; + } + return NULL; +} + +/* Return the string name for supported chipset 'n'; NULL otherwise. */ +void +RADEONIdentify(int flags) +{ + xf86PrintChipsets(RADEON_NAME, + "Driver for ATI Radeon chipsets", + RADEONChipsets); +} + +/* Return TRUE if chipset is present; FALSE otherwise. */ +Bool +RADEONProbe(DriverPtr drv, int flags) +{ + int numUsed; + int numDevSections, nATIGDev, nRadeonGDev; + int *usedChips; + GDevPtr *devSections, *ATIGDevs, *RadeonGDevs; + EntityInfoPtr pEnt; + Bool foundScreen = FALSE; + int i; + + if (!xf86GetPciVideoInfo()) return FALSE; + + /* Collect unclaimed device sections for both driver names */ + nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs); + nRadeonGDev = xf86MatchDevice(RADEON_NAME, &RadeonGDevs); + + if (!(numDevSections = nATIGDev + nRadeonGDev)) return FALSE; + + if (!ATIGDevs) { + if (!(devSections = RadeonGDevs)) + numDevSections = 1; + else + numDevSections = nRadeonGDev; + } if (!RadeonGDevs) { + devSections = ATIGDevs; + numDevSections = nATIGDev; + } else { + /* Combine into one list */ + devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr)); + (void)memcpy(devSections, + ATIGDevs, nATIGDev * sizeof(GDevPtr)); + (void)memcpy(devSections + nATIGDev, + RadeonGDevs, nRadeonGDev * sizeof(GDevPtr)); + devSections[numDevSections] = NULL; + xfree(ATIGDevs); + xfree(RadeonGDevs); + } + + numUsed = xf86MatchPciInstances(RADEON_NAME, + PCI_VENDOR_ATI, + RADEONChipsets, + RADEONPciChipsets, + devSections, + numDevSections, + drv, + &usedChips); + + if (numUsed<=0) return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + pEnt = xf86GetEntityInfo(usedChips[i]); + + if (pEnt->active) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + +#ifdef XFree86LOADER + if (!xf86LoadSubModule(pScrn, "radeon")) { + xf86Msg(X_ERROR, + RADEON_NAME ": Failed to load \"radeon\" module.\n"); + xf86DeleteScreen(pScrn->scrnIndex, 0); + continue; + } + + xf86LoaderReqSymLists(RADEONSymbols, NULL); +#endif + + pScrn->driverVersion = RADEON_VERSION_CURRENT; + pScrn->driverName = RADEON_DRIVER_NAME; + pScrn->name = RADEON_NAME; + pScrn->Probe = RADEONProbe; + pScrn->PreInit = RADEONPreInit; + pScrn->ScreenInit = RADEONScreenInit; + pScrn->SwitchMode = RADEONSwitchMode; + pScrn->AdjustFrame = RADEONAdjustFrame; + pScrn->EnterVT = RADEONEnterVT; + pScrn->LeaveVT = RADEONLeaveVT; + pScrn->FreeScreen = RADEONFreeScreen; + pScrn->ValidMode = RADEONValidMode; + + foundScreen = TRUE; + + xf86ConfigActivePciEntity(pScrn, usedChips[i], RADEONPciChipsets, + 0, 0, 0, 0, 0); + } + xfree(pEnt); + } + + if (numUsed) xfree(usedChips); + xfree(devSections); + + return foundScreen; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h new file mode 100644 index 000000000..9cb8bf007 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h @@ -0,0 +1,73 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h,v 1.1 2000/11/02 16:55:45 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#ifndef _RADEON_PROBE_H_ +#define _RADEON_PROBE_H_ 1 + +#include "atiproto.h" + +#include "xf86str.h" + +/* radeon_probe.c */ +extern OptionInfoPtr RADEONAvailableOptions + FunctionPrototype((int, int)); +extern void RADEONIdentify + FunctionPrototype((int)); +extern Bool RADEONProbe + FunctionPrototype((DriverPtr, int)); + +extern SymTabRec RADEONChipsets[]; +extern PciChipsets RADEONPciChipsets[]; + +/* radeon_driver.c */ +extern Bool RADEONPreInit + FunctionPrototype((ScrnInfoPtr, int)); +extern Bool RADEONScreenInit + FunctionPrototype((int, ScreenPtr, int, char **)); +extern Bool RADEONSwitchMode + FunctionPrototype((int, DisplayModePtr, int)); +extern void RADEONAdjustFrame + FunctionPrototype((int, int, int, int)); +extern Bool RADEONEnterVT + FunctionPrototype((int, int)); +extern void RADEONLeaveVT + FunctionPrototype((int, int)); +extern void RADEONFreeScreen + FunctionPrototype((int, int)); +extern int RADEONValidMode + FunctionPrototype((int, DisplayModePtr, Bool, int)); + +extern OptionInfoRec RADEONOptions[]; + +#endif /* _RADEON_PROBE_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h new file mode 100644 index 000000000..e3afbe77d --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h @@ -0,0 +1,1476 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.1 2000/11/02 16:55:46 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario + * and VA Linux Systems, Inc., Sunnyvale, California. + * + * 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 on + * 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 (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 + * ATI, VA LINUX SYSTEMS AND/OR THEIR 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. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * !!!! FIXME !!!! + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + +/* !!!! FIXME !!!! NOTE: THIS FILE HAS BEEN CONVERTED FROM r128_reg.h + * AND CONTAINS REGISTERS AND REGISTER DEFINITIONS THAT ARE NOT CORRECT + * ON THE RADEON. A FULL AUDIT OF THIS CODE IS NEEDED! */ + +#ifndef _RADEON_REG_H_ +#define _RADEON_REG_H_ +#include <compiler.h> + + /* Memory mapped register access macros */ +#define INREG8(addr) MMIO_IN8(RADEONMMIO, addr) +#define INREG16(addr) MMIO_IN16(RADEONMMIO, addr) +#define INREG(addr) MMIO_IN32(RADEONMMIO, addr) +#define OUTREG8(addr, val) MMIO_OUT8(RADEONMMIO, addr, val) +#define OUTREG16(addr, val) MMIO_OUT16(RADEONMMIO, addr, val) +#define OUTREG(addr, val) MMIO_OUT32(RADEONMMIO, addr, val) + +#define ADDRREG(addr) ((volatile CARD32 *)(RADEONMMIO + (addr))) + + +#define OUTREGP(addr, val, mask) \ + do { \ + CARD32 tmp = INREG(addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTREG(addr, tmp); \ + } while (0) + +#define INPLL(pScrn, addr) RADEONINPLL(pScrn, addr) + +#if !RADEON_ATOMIC_UPDATE +#define OUTPLL(addr, val) \ + do { \ + while ( (INREG(RADEON_CLOCK_CNTL_INDEX) & 0x9f) != \ + (addr | RADEON_PLL_WR_EN)) { \ + OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x1f) | \ + RADEON_PLL_WR_EN)); \ + } \ + OUTREG(RADEON_CLOCK_CNTL_DATA, val); \ + } while (0) +#else +#define OUTPLL(addr, val) \ + do { \ + OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x1f) | \ + RADEON_PLL_WR_EN)); \ + OUTREG(RADEON_CLOCK_CNTL_DATA, val); \ + } while (0) +#endif + +#define OUTPLLP(pScrn, addr, val, mask) \ + do { \ + CARD32 tmp = INPLL(pScrn, addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTPLL(addr, tmp); \ + } while (0) + +#define OUTPAL_START(idx) \ + do { \ + OUTREG8(RADEON_PALETTE_INDEX, (idx)); \ + } while (0) + +#define OUTPAL_NEXT(r, g, b) \ + do { \ + OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ + } while (0) + +#define OUTPAL_NEXT_CARD32(v) \ + do { \ + OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \ + } while (0) + +#define OUTPAL(idx, r, g, b) \ + do { \ + OUTPAL_START((idx)); \ + OUTPAL_NEXT((r), (g), (b)); \ + } while (0) + +#define INPAL_START(idx) \ + do { \ + OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \ + } while (0) + +#define INPAL_NEXT() INREG(RADEON_PALETTE_DATA) + +#define PAL_SELECT(idx) \ + do { \ + if (idx) { \ + OUTREG(RADEON_DAC_CNTL, INREG(RADEON_DAC_CNTL) | \ + RADEON_DAC_PALETTE_ACC_CTL); \ + } else { \ + OUTREG(RADEON_DAC_CNTL, INREG(RADEON_DAC_CNTL) & \ + ~RADEON_DAC_PALETTE_ACC_CTL); \ + } \ + } while (0) + +#define RADEON_ADAPTER_ID 0x0f2c /* PCI */ +#define RADEON_AGP_BASE 0x0170 +#define RADEON_AGP_CNTL 0x0174 +# define RADEON_AGP_APER_SIZE_256MB (0x00 << 0) +# define RADEON_AGP_APER_SIZE_128MB (0x20 << 0) +# define RADEON_AGP_APER_SIZE_64MB (0x30 << 0) +# define RADEON_AGP_APER_SIZE_32MB (0x38 << 0) +# define RADEON_AGP_APER_SIZE_16MB (0x3c << 0) +# define RADEON_AGP_APER_SIZE_8MB (0x3e << 0) +# define RADEON_AGP_APER_SIZE_4MB (0x3f << 0) +# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0) +#define RADEON_AGP_COMMAND 0x0f60 /* PCI */ +#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */ +#define RADEON_AGP_STATUS 0x0f5c /* PCI */ +# define RADEON_AGP_1X_MODE 0x01 +# define RADEON_AGP_2X_MODE 0x02 +# define RADEON_AGP_4X_MODE 0x04 +# define RADEON_AGP_MODE_MASK 0x07 +#define RADEON_AMCGPIO_A_REG 0x01a0 +#define RADEON_AMCGPIO_EN_REG 0x01a8 +#define RADEON_AMCGPIO_MASK 0x0194 +#define RADEON_AMCGPIO_Y_REG 0x01a4 +#define RADEON_ATTRDR 0x03c1 /* VGA */ +#define RADEON_ATTRDW 0x03c0 /* VGA */ +#define RADEON_ATTRX 0x03c0 /* VGA */ +# define RADEON_AUX1_SC_EN (1 << 0) +# define RADEON_AUX1_SC_MODE_OR (0 << 1) +# define RADEON_AUX1_SC_MODE_NAND (1 << 1) +# define RADEON_AUX2_SC_EN (1 << 2) +# define RADEON_AUX2_SC_MODE_OR (0 << 3) +# define RADEON_AUX2_SC_MODE_NAND (1 << 3) +# define RADEON_AUX3_SC_EN (1 << 4) +# define RADEON_AUX3_SC_MODE_OR (0 << 5) +# define RADEON_AUX3_SC_MODE_NAND (1 << 5) +#define RADEON_AUX_SC_CNTL 0x1660 +#define RADEON_AUX1_SC_BOTTOM 0x1670 +#define RADEON_AUX1_SC_LEFT 0x1664 +#define RADEON_AUX1_SC_RIGHT 0x1668 +#define RADEON_AUX1_SC_TOP 0x166c +#define RADEON_AUX2_SC_BOTTOM 0x1680 +#define RADEON_AUX2_SC_LEFT 0x1674 +#define RADEON_AUX2_SC_RIGHT 0x1678 +#define RADEON_AUX2_SC_TOP 0x167c +#define RADEON_AUX3_SC_BOTTOM 0x1690 +#define RADEON_AUX3_SC_LEFT 0x1684 +#define RADEON_AUX3_SC_RIGHT 0x1688 +#define RADEON_AUX3_SC_TOP 0x168c +#define RADEON_AUX_WINDOW_HORZ_CNTL 0x02d8 +#define RADEON_AUX_WINDOW_VERT_CNTL 0x02dc + +#define RADEON_BASE_CODE 0x0f0b +#define RADEON_BIOS_0_SCRATCH 0x0010 +#define RADEON_BIOS_1_SCRATCH 0x0014 +#define RADEON_BIOS_2_SCRATCH 0x0018 +#define RADEON_BIOS_3_SCRATCH 0x001c +#define RADEON_BIOS_ROM 0x0f30 /* PCI */ +#define RADEON_BIST 0x0f0f /* PCI */ +#define RADEON_BRUSH_DATA0 0x1480 +#define RADEON_BRUSH_DATA1 0x1484 +#define RADEON_BRUSH_DATA10 0x14a8 +#define RADEON_BRUSH_DATA11 0x14ac +#define RADEON_BRUSH_DATA12 0x14b0 +#define RADEON_BRUSH_DATA13 0x14b4 +#define RADEON_BRUSH_DATA14 0x14b8 +#define RADEON_BRUSH_DATA15 0x14bc +#define RADEON_BRUSH_DATA16 0x14c0 +#define RADEON_BRUSH_DATA17 0x14c4 +#define RADEON_BRUSH_DATA18 0x14c8 +#define RADEON_BRUSH_DATA19 0x14cc +#define RADEON_BRUSH_DATA2 0x1488 +#define RADEON_BRUSH_DATA20 0x14d0 +#define RADEON_BRUSH_DATA21 0x14d4 +#define RADEON_BRUSH_DATA22 0x14d8 +#define RADEON_BRUSH_DATA23 0x14dc +#define RADEON_BRUSH_DATA24 0x14e0 +#define RADEON_BRUSH_DATA25 0x14e4 +#define RADEON_BRUSH_DATA26 0x14e8 +#define RADEON_BRUSH_DATA27 0x14ec +#define RADEON_BRUSH_DATA28 0x14f0 +#define RADEON_BRUSH_DATA29 0x14f4 +#define RADEON_BRUSH_DATA3 0x148c +#define RADEON_BRUSH_DATA30 0x14f8 +#define RADEON_BRUSH_DATA31 0x14fc +#define RADEON_BRUSH_DATA32 0x1500 +#define RADEON_BRUSH_DATA33 0x1504 +#define RADEON_BRUSH_DATA34 0x1508 +#define RADEON_BRUSH_DATA35 0x150c +#define RADEON_BRUSH_DATA36 0x1510 +#define RADEON_BRUSH_DATA37 0x1514 +#define RADEON_BRUSH_DATA38 0x1518 +#define RADEON_BRUSH_DATA39 0x151c +#define RADEON_BRUSH_DATA4 0x1490 +#define RADEON_BRUSH_DATA40 0x1520 +#define RADEON_BRUSH_DATA41 0x1524 +#define RADEON_BRUSH_DATA42 0x1528 +#define RADEON_BRUSH_DATA43 0x152c +#define RADEON_BRUSH_DATA44 0x1530 +#define RADEON_BRUSH_DATA45 0x1534 +#define RADEON_BRUSH_DATA46 0x1538 +#define RADEON_BRUSH_DATA47 0x153c +#define RADEON_BRUSH_DATA48 0x1540 +#define RADEON_BRUSH_DATA49 0x1544 +#define RADEON_BRUSH_DATA5 0x1494 +#define RADEON_BRUSH_DATA50 0x1548 +#define RADEON_BRUSH_DATA51 0x154c +#define RADEON_BRUSH_DATA52 0x1550 +#define RADEON_BRUSH_DATA53 0x1554 +#define RADEON_BRUSH_DATA54 0x1558 +#define RADEON_BRUSH_DATA55 0x155c +#define RADEON_BRUSH_DATA56 0x1560 +#define RADEON_BRUSH_DATA57 0x1564 +#define RADEON_BRUSH_DATA58 0x1568 +#define RADEON_BRUSH_DATA59 0x156c +#define RADEON_BRUSH_DATA6 0x1498 +#define RADEON_BRUSH_DATA60 0x1570 +#define RADEON_BRUSH_DATA61 0x1574 +#define RADEON_BRUSH_DATA62 0x1578 +#define RADEON_BRUSH_DATA63 0x157c +#define RADEON_BRUSH_DATA7 0x149c +#define RADEON_BRUSH_DATA8 0x14a0 +#define RADEON_BRUSH_DATA9 0x14a4 +#define RADEON_BRUSH_SCALE 0x1470 +#define RADEON_BRUSH_Y_X 0x1474 +#define RADEON_BUS_CNTL 0x0030 +# define RADEON_BUS_MASTER_DIS (1 << 6) +# define RADEON_BUS_RD_DISCARD_EN (1 << 24) +# define RADEON_BUS_RD_ABORT_EN (1 << 25) +# define RADEON_BUS_MSTR_DISCONNECT_EN (1 << 28) +# define RADEON_BUS_WRT_BURST (1 << 29) +# define RADEON_BUS_READ_BURST (1 << 30) +#define RADEON_BUS_CNTL1 0x0034 +# define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4) + +#define RADEON_CACHE_CNTL 0x1724 +#define RADEON_CACHE_LINE 0x0f0c /* PCI */ +#define RADEON_CAP0_TRIG_CNTL 0x0950 /* ? */ +#define RADEON_CAP1_TRIG_CNTL 0x09c0 /* ? */ +#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */ +#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */ +#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */ +#define RADEON_CLOCK_CNTL_DATA 0x000c +#define RADEON_CLOCK_CNTL_INDEX 0x0008 +# define RADEON_PLL_WR_EN (1 << 7) +# define RADEON_PLL_DIV_SEL (3 << 8) +#define RADEON_CLR_CMP_CLR_3D 0x1a24 +#define RADEON_CLR_CMP_CLR_DST 0x15c8 +#define RADEON_CLR_CMP_CLR_SRC 0x15c4 +#define RADEON_CLR_CMP_CNTL 0x15c0 +# define RADEON_SRC_CMP_EQ_COLOR (4 << 0) +# define RADEON_SRC_CMP_NEQ_COLOR (5 << 0) +# define RADEON_CLR_CMP_SRC_SOURCE (1 << 24) +#define RADEON_CLR_CMP_MASK 0x15cc +# define RADEON_CLR_CMP_MSK 0xffffffff +#define RADEON_CLR_CMP_MASK_3D 0x1A28 +#define RADEON_COMMAND 0x0f04 /* PCI */ +#define RADEON_COMPOSITE_SHADOW_ID 0x1a0c +#define RADEON_CONFIG_APER_0_BASE 0x0100 +#define RADEON_CONFIG_APER_1_BASE 0x0104 +#define RADEON_CONFIG_APER_SIZE 0x0108 +#define RADEON_CONFIG_BONDS 0x00e8 +#define RADEON_CONFIG_CNTL 0x00e0 +#define RADEON_CONFIG_MEMSIZE 0x00f8 +#define RADEON_CONFIG_MEMSIZE_EMBEDDED 0x0114 +#define RADEON_CONFIG_REG_1_BASE 0x010c +#define RADEON_CONFIG_REG_APER_SIZE 0x0110 +#define RADEON_CONFIG_XSTRAP 0x00e4 +#define RADEON_CONSTANT_COLOR_C 0x1d34 +# define RADEON_CONSTANT_COLOR_MASK 0x00ffffff +# define RADEON_CONSTANT_COLOR_ONE 0x00ffffff +# define RADEON_CONSTANT_COLOR_ZERO 0x00000000 +#define RADEON_CRC_CMDFIFO_ADDR 0x0740 +#define RADEON_CRC_CMDFIFO_DOUT 0x0744 +#define RADEON_CRTC_CRNT_FRAME 0x0214 +#define RADEON_CRTC_DEBUG 0x021c +#define RADEON_CRTC_EXT_CNTL 0x0054 +# define RADEON_CRTC_VGA_XOVERSCAN (1 << 0) +# define RADEON_VGA_ATI_LINEAR (1 << 3) +# define RADEON_XCRT_CNT_EN (1 << 6) +# define RADEON_CRTC_HSYNC_DIS (1 << 8) +# define RADEON_CRTC_VSYNC_DIS (1 << 9) +# define RADEON_CRTC_DISPLAY_DIS (1 << 10) +# define RADEON_CRTC_CRT_ON (1 << 15) +#define RADEON_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 +# define RADEON_CRTC_HSYNC_DIS_BYTE (1 << 0) +# define RADEON_CRTC_VSYNC_DIS_BYTE (1 << 1) +# define RADEON_CRTC_DISPLAY_DIS_BYTE (1 << 2) +#define RADEON_CRTC_GEN_CNTL 0x0050 +# define RADEON_CRTC_DBL_SCAN_EN (1 << 0) +# define RADEON_CRTC_INTERLACE_EN (1 << 1) +# define RADEON_CRTC_CSYNC_EN (1 << 4) +# define RADEON_CRTC_CUR_EN (1 << 16) +# define RADEON_CRTC_CUR_MODE_MASK (7 << 17) +# define RADEON_CRTC_ICON_EN (1 << 20) +# define RADEON_CRTC_EXT_DISP_EN (1 << 24) +# define RADEON_CRTC_EN (1 << 25) +# define RADEON_CRTC_DISP_REQ_EN_B (1 << 26) +#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218 +#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204 +# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0) +# define RADEON_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) +# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 +# define RADEON_CRTC_H_SYNC_WID (0x3f << 16) +# define RADEON_CRTC_H_SYNC_WID_SHIFT 16 +# define RADEON_CRTC_H_SYNC_POL (1 << 23) +#define RADEON_CRTC_H_TOTAL_DISP 0x0200 +# define RADEON_CRTC_H_TOTAL (0x01ff << 0) +# define RADEON_CRTC_H_TOTAL_SHIFT 0 +# define RADEON_CRTC_H_DISP (0x00ff << 16) +# define RADEON_CRTC_H_DISP_SHIFT 16 +#define RADEON_CRTC_OFFSET 0x0224 +#define RADEON_CRTC_OFFSET_CNTL 0x0228 +#define RADEON_CRTC_PITCH 0x022c +#define RADEON_CRTC_STATUS 0x005c +# define RADEON_CRTC_VBLANK_SAVE (1 << 1) +#define RADEON_CRTC_V_SYNC_STRT_WID 0x020c +# define RADEON_CRTC_V_SYNC_STRT (0x7ff << 0) +# define RADEON_CRTC_V_SYNC_STRT_SHIFT 0 +# define RADEON_CRTC_V_SYNC_WID (0x1f << 16) +# define RADEON_CRTC_V_SYNC_WID_SHIFT 16 +# define RADEON_CRTC_V_SYNC_POL (1 << 23) +#define RADEON_CRTC_V_TOTAL_DISP 0x0208 +# define RADEON_CRTC_V_TOTAL (0x07ff << 0) +# define RADEON_CRTC_V_TOTAL_SHIFT 0 +# define RADEON_CRTC_V_DISP (0x07ff << 16) +# define RADEON_CRTC_V_DISP_SHIFT 16 +#define RADEON_CRTC_VLINE_CRNT_VLINE 0x0210 +# define RADEON_CRTC_CRNT_VLINE_MASK (0x7ff << 16) +#define RADEON_CRTC2_CRNT_FRAME 0x0314 +#define RADEON_CRTC2_DEBUG 0x031c +#define RADEON_CRTC2_GEN_CNTL 0x03f8 +#define RADEON_CRTC2_GUI_TRIG_VLINE 0x0318 +#define RADEON_CRTC2_H_SYNC_STRT_WID 0x0304 +#define RADEON_CRTC2_H_TOTAL_DISP 0x0300 +#define RADEON_CRTC2_OFFSET 0x0324 +#define RADEON_CRTC2_OFFSET_CNTL 0x0328 +#define RADEON_CRTC2_PITCH 0x032c +#define RADEON_CRTC2_STATUS 0x03fc +#define RADEON_CRTC2_V_SYNC_STRT_WID 0x030c +#define RADEON_CRTC2_V_TOTAL_DISP 0x0308 +#define RADEON_CRTC2_VLINE_CRNT_VLINE 0x0310 +#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ +#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ +#define RADEON_CUR_CLR0 0x026c +#define RADEON_CUR_CLR1 0x0270 +#define RADEON_CUR_HORZ_VERT_OFF 0x0268 +#define RADEON_CUR_HORZ_VERT_POSN 0x0264 +#define RADEON_CUR_OFFSET 0x0260 +# define RADEON_CUR_LOCK (1 << 31) + +#define RADEON_DAC_CNTL 0x0058 +# define RADEON_DAC_RANGE_CNTL (3 << 0) +# define RADEON_DAC_BLANKING (1 << 2) +# define RADEON_DAC_CRT_SEL_CRTC2 (1 << 4) +# define RADEON_DAC_PALETTE_ACC_CTL (1 << 5) +# define RADEON_DAC_8BIT_EN (1 << 8) +# define RADEON_DAC_VGA_ADR_EN (1 << 13) +# define RADEON_DAC_MASK_ALL (0xff << 24) +#define RADEON_DAC_CRC_SIG 0x02cc +#define RADEON_DAC_DATA 0x03c9 /* VGA */ +#define RADEON_DAC_MASK 0x03c6 /* VGA */ +#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */ +#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */ +#define RADEON_DDA_CONFIG 0x02e0 +#define RADEON_DDA_ON_OFF 0x02e4 +#define RADEON_DEFAULT_OFFSET 0x16e0 +#define RADEON_DEFAULT_PITCH 0x16e4 +#define RADEON_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 +# define RADEON_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) +# define RADEON_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) +#define RADEON_DESTINATION_3D_CLR_CMP_VAL 0x1820 +#define RADEON_DESTINATION_3D_CLR_CMP_MSK 0x1824 +#define RADEON_DEVICE_ID 0x0f02 /* PCI */ +#define RADEON_DISP_MISC_CNTL 0x0d00 +# define RADEON_SOFT_RESET_GRPH_PP (1 << 0) +#define RADEON_DP_BRUSH_BKGD_CLR 0x1478 +#define RADEON_DP_BRUSH_FRGD_CLR 0x147c +#define RADEON_DP_CNTL 0x16c0 +# define RADEON_DST_X_LEFT_TO_RIGHT (1 << 0) +# define RADEON_DST_Y_TOP_TO_BOTTOM (1 << 1) +#define RADEON_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 +# define RADEON_DST_Y_MAJOR (1 << 2) +# define RADEON_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) +# define RADEON_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) +#define RADEON_DP_DATATYPE 0x16c4 +# define RADEON_HOST_BIG_ENDIAN_EN (1 << 29) +#define RADEON_DP_GUI_MASTER_CNTL 0x146c +# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) +# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) +# define RADEON_GMC_SRC_CLIPPING (1 << 2) +# define RADEON_GMC_DST_CLIPPING (1 << 3) +# define RADEON_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) +# define RADEON_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) +# define RADEON_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) +# define RADEON_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) +# define RADEON_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) +# define RADEON_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) +# define RADEON_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) +# define RADEON_GMC_BRUSH_8x8_COLOR (10 << 4) +# define RADEON_GMC_BRUSH_1X8_COLOR (12 << 4) +# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define RADEON_GMC_BRUSH_NONE (15 << 4) +# define RADEON_GMC_DST_8BPP_CI (2 << 8) +# define RADEON_GMC_DST_15BPP (3 << 8) +# define RADEON_GMC_DST_16BPP (4 << 8) +# define RADEON_GMC_DST_24BPP (5 << 8) +# define RADEON_GMC_DST_32BPP (6 << 8) +# define RADEON_GMC_DST_8BPP_RGB (7 << 8) +# define RADEON_GMC_DST_Y8 (8 << 8) +# define RADEON_GMC_DST_RGB8 (9 << 8) +# define RADEON_GMC_DST_VYUY (11 << 8) +# define RADEON_GMC_DST_YVYU (12 << 8) +# define RADEON_GMC_DST_AYUV444 (14 << 8) +# define RADEON_GMC_DST_ARGB4444 (15 << 8) +# define RADEON_GMC_DST_DATATYPE_MASK (0x0f << 8) +# define RADEON_GMC_DST_DATATYPE_SHIFT 8 +# define RADEON_GMC_SRC_DATATYPE_MASK (3 << 12) +# define RADEON_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) +# define RADEON_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) +# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12) +# define RADEON_GMC_BYTE_PIX_ORDER (1 << 14) +# define RADEON_GMC_BYTE_MSB_TO_LSB (0 << 14) +# define RADEON_GMC_BYTE_LSB_TO_MSB (1 << 14) +# define RADEON_GMC_CONVERSION_TEMP (1 << 15) +# define RADEON_GMC_CONVERSION_TEMP_6500 (0 << 15) +# define RADEON_GMC_CONVERSION_TEMP_9300 (1 << 15) +# define RADEON_GMC_ROP3_MASK (0xff << 16) +# define RADEON_DP_SRC_SOURCE_MASK (7 << 24) +# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24) +# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24) +# define RADEON_GMC_3D_FCN_EN (1 << 27) +# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28) +# define RADEON_GMC_AUX_CLIP_DIS (1 << 29) +# define RADEON_GMC_WR_MSK_DIS (1 << 30) +# define RADEON_GMC_LD_BRUSH_Y_X (1 << 31) +# define RADEON_ROP3_ZERO 0x00000000 +# define RADEON_ROP3_DSa 0x00880000 +# define RADEON_ROP3_SDna 0x00440000 +# define RADEON_ROP3_S 0x00cc0000 +# define RADEON_ROP3_DSna 0x00220000 +# define RADEON_ROP3_D 0x00aa0000 +# define RADEON_ROP3_DSx 0x00660000 +# define RADEON_ROP3_DSo 0x00ee0000 +# define RADEON_ROP3_DSon 0x00110000 +# define RADEON_ROP3_DSxn 0x00990000 +# define RADEON_ROP3_Dn 0x00550000 +# define RADEON_ROP3_SDno 0x00dd0000 +# define RADEON_ROP3_Sn 0x00330000 +# define RADEON_ROP3_DSno 0x00bb0000 +# define RADEON_ROP3_DSan 0x00770000 +# define RADEON_ROP3_ONE 0x00ff0000 +# define RADEON_ROP3_DPa 0x00a00000 +# define RADEON_ROP3_PDna 0x00500000 +# define RADEON_ROP3_P 0x00f00000 +# define RADEON_ROP3_DPna 0x000a0000 +# define RADEON_ROP3_D 0x00aa0000 +# define RADEON_ROP3_DPx 0x005a0000 +# define RADEON_ROP3_DPo 0x00fa0000 +# define RADEON_ROP3_DPon 0x00050000 +# define RADEON_ROP3_PDxn 0x00a50000 +# define RADEON_ROP3_PDno 0x00f50000 +# define RADEON_ROP3_Pn 0x000f0000 +# define RADEON_ROP3_DPno 0x00af0000 +# define RADEON_ROP3_DPan 0x005f0000 + + +#define RADEON_DP_GUI_MASTER_CNTL_C 0x1c84 +#define RADEON_DP_MIX 0x16c8 +#define RADEON_DP_SRC_BKGD_CLR 0x15dc +#define RADEON_DP_SRC_FRGD_CLR 0x15d8 +#define RADEON_DP_WRITE_MASK 0x16cc +#define RADEON_DST_BRES_DEC 0x1630 +#define RADEON_DST_BRES_ERR 0x1628 +#define RADEON_DST_BRES_INC 0x162c +#define RADEON_DST_BRES_LNTH 0x1634 +#define RADEON_DST_BRES_LNTH_SUB 0x1638 +#define RADEON_DST_HEIGHT 0x1410 +#define RADEON_DST_HEIGHT_WIDTH 0x143c +#define RADEON_DST_HEIGHT_WIDTH_8 0x158c +#define RADEON_DST_HEIGHT_WIDTH_BW 0x15b4 +#define RADEON_DST_HEIGHT_Y 0x15a0 +#define RADEON_DST_LINE_START 0x1600 +#define RADEON_DST_LINE_END 0x1604 +#define RADEON_DST_OFFSET 0x1404 +#define RADEON_DST_PITCH 0x1408 +#define RADEON_DST_PITCH_OFFSET 0x142c +#define RADEON_DST_PITCH_OFFSET_C 0x1c80 +# define RADEON_PITCH_SHIFT 21 +#define RADEON_DST_WIDTH 0x140c +#define RADEON_DST_WIDTH_HEIGHT 0x1598 +#define RADEON_DST_WIDTH_X 0x1588 +#define RADEON_DST_WIDTH_X_INCY 0x159c +#define RADEON_DST_X 0x141c +#define RADEON_DST_X_SUB 0x15a4 +#define RADEON_DST_X_Y 0x1594 +#define RADEON_DST_Y 0x1420 +#define RADEON_DST_Y_SUB 0x15a8 +#define RADEON_DST_Y_X 0x1438 + +#define RADEON_FCP_CNTL 0x0012 /* PLL */ +#define RADEON_FLUSH_1 0x1704 +#define RADEON_FLUSH_2 0x1708 +#define RADEON_FLUSH_3 0x170c +#define RADEON_FLUSH_4 0x1710 +#define RADEON_FLUSH_5 0x1714 +#define RADEON_FLUSH_6 0x1718 +#define RADEON_FLUSH_7 0x171c +#define RADEON_FOG_3D_TABLE_START 0x1810 +#define RADEON_FOG_3D_TABLE_END 0x1814 +#define RADEON_FOG_3D_TABLE_DENSITY 0x181c +#define RADEON_FOG_TABLE_INDEX 0x1a14 +#define RADEON_FOG_TABLE_DATA 0x1a18 +#define RADEON_FP_CRTC_H_TOTAL_DISP 0x0250 +#define RADEON_FP_CRTC_V_TOTAL_DISP 0x0254 +#define RADEON_FP_GEN_CNTL 0x0284 +# define RADEON_FP_FPON (1 << 0) +# define RADEON_FP_TDMS_EN (1 << 2) +# define RADEON_FP_DETECT_SENSE (1 << 8) +# define RADEON_FP_SEL_CRTC2 (1 << 13) +# define RADEON_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) +# define RADEON_FP_CRTC_USE_SHADOW_VEND (1 << 18) +# define RADEON_FP_CRTC_HORZ_DIV2_EN (1 << 20) +# define RADEON_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) +# define RADEON_FP_USE_SHADOW_EN (1 << 24) +#define RADEON_FP_H_SYNC_STRT_WID 0x02c4 +#define RADEON_FP_HORZ_STRETCH 0x028c +# define RADEON_HORZ_STRETCH_RATIO_MASK 0xffff +# define RADEON_HORZ_STRETCH_RATIO_SHIFT 0 +# define RADEON_HORZ_STRETCH_RATIO_MAX 4096 +# define RADEON_HORZ_PANEL_SIZE (0xff << 16) +# define RADEON_HORZ_PANEL_SHIFT 16 +# define RADEON_HORZ_STRETCH_PIXREP (0 << 25) +# define RADEON_HORZ_STRETCH_BLEND (1 << 25) +# define RADEON_HORZ_STRETCH_ENABLE (1 << 26) +# define RADEON_HORZ_FP_LOOP_STRETCH (0x7 << 27) +# define RADEON_HORZ_STRETCH_RESERVED (1 << 30) +# define RADEON_HORZ_AUTO_RATIO_FIX_EN (1 << 31) + +#define RADEON_FP_PANEL_CNTL 0x0288 +# define RADEON_FP_DIGON (1 << 0) +# define RADEON_FP_BLON (1 << 1) +#define RADEON_FP_V_SYNC_STRT_WID 0x02c8 +#define RADEON_FP_VERT_STRETCH 0x0290 +# define RADEON_VERT_PANEL_SIZE (0x7ff << 0) +# define RADEON_VERT_PANEL_SHIFT 0 +# define RADEON_VERT_STRETCH_RATIO_MASK 0x3ff +# define RADEON_VERT_STRETCH_RATIO_SHIFT 11 +# define RADEON_VERT_STRETCH_RATIO_MAX 1024 +# define RADEON_VERT_STRETCH_ENABLE (1 << 24) +# define RADEON_VERT_STRETCH_LINEREP (0 << 25) +# define RADEON_VERT_STRETCH_BLEND (1 << 25) +# define RADEON_VERT_AUTO_RATIO_EN (1 << 26) +# define RADEON_VERT_STRETCH_RESERVED 0xf8e00000 + +#define RADEON_GEN_INT_CNTL 0x0040 +#define RADEON_GEN_INT_STATUS 0x0044 +# define RADEON_VSYNC_INT_AK (1 << 2) +# define RADEON_VSYNC_INT (1 << 2) +#define RADEON_RBBM_SOFT_RESET 0x00f0 +# define RADEON_SOFT_RESET_CP (1 << 0) +# define RADEON_SOFT_RESET_HI (1 << 1) +# define RADEON_SOFT_RESET_SE (1 << 2) +# define RADEON_SOFT_RESET_RE (1 << 3) +# define RADEON_SOFT_RESET_PP (1 << 4) +# define RADEON_SOFT_RESET_E2 (1 << 5) +# define RADEON_SOFT_RESET_RB (1 << 6) +# define RADEON_SOFT_RESET_HDP (1 << 7) +#define RADEON_GENENB 0x03c3 /* VGA */ +#define RADEON_GENFC_RD 0x03ca /* VGA */ +#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */ +#define RADEON_GENMO_RD 0x03cc /* VGA */ +#define RADEON_GENMO_WT 0x03c2 /* VGA */ +#define RADEON_GENS0 0x03c2 /* VGA */ +#define RADEON_GENS1 0x03da /* VGA, 0x03ba */ +#define RADEON_GPIO_MONID 0x0068 +# define RADEON_GPIO_MONID_A_0 (1 << 0) +# define RADEON_GPIO_MONID_A_1 (1 << 1) +# define RADEON_GPIO_MONID_A_2 (1 << 2) +# define RADEON_GPIO_MONID_A_3 (1 << 3) +# define RADEON_GPIO_MONID_Y_0 (1 << 8) +# define RADEON_GPIO_MONID_Y_1 (1 << 9) +# define RADEON_GPIO_MONID_Y_2 (1 << 10) +# define RADEON_GPIO_MONID_Y_3 (1 << 11) +# define RADEON_GPIO_MONID_EN_0 (1 << 16) +# define RADEON_GPIO_MONID_EN_1 (1 << 17) +# define RADEON_GPIO_MONID_EN_2 (1 << 18) +# define RADEON_GPIO_MONID_EN_3 (1 << 19) +# define RADEON_GPIO_MONID_MASK_0 (1 << 24) +# define RADEON_GPIO_MONID_MASK_1 (1 << 25) +# define RADEON_GPIO_MONID_MASK_2 (1 << 26) +# define RADEON_GPIO_MONID_MASK_3 (1 << 27) +#define RADEON_GPIO_MONIDB 0x006c +#define RADEON_GRPH8_DATA 0x03cf /* VGA */ +#define RADEON_GRPH8_IDX 0x03ce /* VGA */ +#define RADEON_GUI_DEBUG0 0x16a0 +#define RADEON_GUI_DEBUG1 0x16a4 +#define RADEON_GUI_DEBUG2 0x16a8 +#define RADEON_GUI_DEBUG3 0x16ac +#define RADEON_GUI_DEBUG4 0x16b0 +#define RADEON_GUI_DEBUG5 0x16b4 +#define RADEON_GUI_DEBUG6 0x16b8 +#define RADEON_GUI_SCRATCH_REG0 0x15e0 +#define RADEON_GUI_SCRATCH_REG1 0x15e4 +#define RADEON_GUI_SCRATCH_REG2 0x15e8 +#define RADEON_GUI_SCRATCH_REG3 0x15ec +#define RADEON_GUI_SCRATCH_REG4 0x15f0 +#define RADEON_GUI_SCRATCH_REG5 0x15f4 +#define RADEON_HEADER 0x0f0e /* PCI */ +#define RADEON_HOST_DATA0 0x17c0 +#define RADEON_HOST_DATA1 0x17c4 +#define RADEON_HOST_DATA2 0x17c8 +#define RADEON_HOST_DATA3 0x17cc +#define RADEON_HOST_DATA4 0x17d0 +#define RADEON_HOST_DATA5 0x17d4 +#define RADEON_HOST_DATA6 0x17d8 +#define RADEON_HOST_DATA7 0x17dc +#define RADEON_HOST_DATA_LAST 0x17e0 +#define RADEON_HOST_PATH_CNTL 0x0130 +#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */ +#define RADEON_HW_DEBUG 0x0128 +#define RADEON_HW_DEBUG2 0x011c + +#define RADEON_I2C_CNTL_1 0x0094 /* ? */ +#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */ +#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */ +#define RADEON_IO_BASE 0x0f14 /* PCI */ + +#define RADEON_LATENCY 0x0f0d /* PCI */ +#define RADEON_LEAD_BRES_DEC 0x1608 +#define RADEON_LEAD_BRES_LNTH 0x161c +#define RADEON_LEAD_BRES_LNTH_SUB 0x1624 +#define RADEON_LVDS_GEN_CNTL 0x02d0 +# define RADEON_LVDS_ON (1 << 0) +# define RADEON_LVDS_BLON (1 << 19) +# define RADEON_LVDS_SEL_CRTC2 (1 << 23) +# define RADEON_HSYNC_DELAY_SHIFT 28 +# define RADEON_HSYNC_DELAY_MASK (0xf << 28) + +#define RADEON_MAX_LATENCY 0x0f3f /* PCI */ +#define RADEON_MC_AGP_LOCATION 0x014c +#define RADEON_MC_FB_LOCATION 0x0148 +#define RADEON_MCLK_CNTL 0x0012 /* PLL */ +# define RADEON_FORCE_GCP (1 << 16) +# define RADEON_FORCE_PIPE3D_CP (1 << 17) +# define RADEON_FORCE_RCP (1 << 18) +#define RADEON_MDGPIO_A_REG 0x01ac +#define RADEON_MDGPIO_EN_REG 0x01b0 +#define RADEON_MDGPIO_MASK 0x0198 +#define RADEON_MDGPIO_Y_REG 0x01b4 +#define RADEON_MEM_ADDR_CONFIG 0x0148 +#define RADEON_MEM_BASE 0x0f10 /* PCI */ +#define RADEON_MEM_CNTL 0x0140 +#define RADEON_MEM_INIT_LAT_TIMER 0x0154 +#define RADEON_MEM_INTF_CNTL 0x014c +#define RADEON_MEM_SDRAM_MODE_REG 0x0158 +#define RADEON_MEM_STR_CNTL 0x0150 +#define RADEON_MEM_VGA_RP_SEL 0x003c +#define RADEON_MEM_VGA_WP_SEL 0x0038 +#define RADEON_MIN_GRANT 0x0f3e /* PCI */ +#define RADEON_MM_DATA 0x0004 +#define RADEON_MM_INDEX 0x0000 +#define RADEON_MPLL_CNTL 0x000e /* PLL */ +#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */ +#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */ + +#define RADEON_N_VIF_COUNT 0x0248 + +#define RADEON_OV0_SCALE_CNTL 0x0420 /* ? */ +#define RADEON_OVR_CLR 0x0230 +#define RADEON_OVR_WID_LEFT_RIGHT 0x0234 +#define RADEON_OVR_WID_TOP_BOTTOM 0x0238 + +/* first overlay unit (there is only one) */ + +#define RADEON_OV0_Y_X_START 0x0400 +#define RADEON_OV0_Y_X_END 0x0404 +#define RADEON_OV0_EXCLUSIVE_HORZ 0x0408 +# define RADEON_EXCL_HORZ_START_MASK 0x000000ff +# define RADEON_EXCL_HORZ_END_MASK 0x0000ff00 +# define RADEON_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000 +# define RADEON_EXCL_HORZ_EXCLUSIVE_EN 0x80000000 +#define RADEON_OV0_EXCLUSIVE_VERT 0x040C +# define RADEON_EXCL_VERT_START_MASK 0x000003ff +# define RADEON_EXCL_VERT_END_MASK 0x03ff0000 +#define RADEON_OV0_REG_LOAD_CNTL 0x0410 +# define RADEON_REG_LD_CTL_LOCK 0x00000001L +# define RADEON_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L +# define RADEON_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L +# define RADEON_REG_LD_CTL_LOCK_READBACK 0x00000008L +#define RADEON_OV0_SCALE_CNTL 0x0420 +# define RADEON_SCALER_PIX_EXPAND 0x00000001L +# define RADEON_SCALER_Y2R_TEMP 0x00000002L +# define RADEON_SCALER_HORZ_PICK_NEAREST 0x00000003L +# define RADEON_SCALER_VERT_PICK_NEAREST 0x00000004L +# define RADEON_SCALER_SIGNED_UV 0x00000010L +# define RADEON_SCALER_GAMMA_SEL_MASK 0x00000060L +# define RADEON_SCALER_GAMMA_SEL_BRIGHT 0x00000000L +# define RADEON_SCALER_GAMMA_SEL_G22 0x00000020L +# define RADEON_SCALER_GAMMA_SEL_G18 0x00000040L +# define RADEON_SCALER_GAMMA_SEL_G14 0x00000060L +# define RADEON_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L +# define RADEON_SCALER_SURFAC_FORMAT 0x00000f00L +# define RADEON_SCALER_SOURCE_15BPP 0x00000300L +# define RADEON_SCALER_SOURCE_16BPP 0x00000400L +# define RADEON_SCALER_SOURCE_32BPP 0x00000600L +# define RADEON_SCALER_SOURCE_YUV9 0x00000900L +# define RADEON_SCALER_SOURCE_YUV12 0x00000A00L +# define RADEON_SCALER_SOURCE_VYUY422 0x00000B00L +# define RADEON_SCALER_SOURCE_YVYU422 0x00000C00L +# define RADEON_SCALER_SMART_SWITCH 0x00008000L +# define RADEON_SCALER_BURST_PER_PLANE 0x00ff0000L +# define RADEON_SCALER_DOUBLE_BUFFER 0x01000000L +# define RADEON_SCALER_DIS_LIMIT 0x08000000L +# define RADEON_SCALER_PRG_LOAD_START 0x10000000L +# define RADEON_SCALER_INT_EMU 0x20000000L +# define RADEON_SCALER_ENABLE 0x40000000L +# define RADEON_SCALER_SOFT_RESET 0x80000000L +#define RADEON_OV0_V_INC 0x0424 +#define RADEON_OV0_P1_V_ACCUM_INIT 0x0428 +# define RADEON_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L +# define RADEON_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L +#define RADEON_OV0_P23_V_ACCUM_INIT 0x042C +#define RADEON_OV0_P1_BLANK_LINES_AT_TOP 0x0430 +# define RADEON_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL +# define RADEON_P1_ACTIVE_LINES_M1 0x0fff0000L +#define RADEON_OV0_P23_BLANK_LINES_AT_TOP 0x0434 +# define RADEON_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL +# define RADEON_P23_ACTIVE_LINES_M1 0x07ff0000L +#define RADEON_OV0_VID_BUF0_BASE_ADRS 0x0440 +# define RADEON_VIF_BUF0_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF0_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF1_BASE_ADRS 0x0444 +# define RADEON_VIF_BUF1_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF1_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF2_BASE_ADRS 0x0448 +# define RADEON_VIF_BUF2_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF2_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF3_BASE_ADRS 0x044C +#define RADEON_OV0_VID_BUF4_BASE_ADRS 0x0450 +#define RADEON_OV0_VID_BUF5_BASE_ADRS 0x0454 +#define RADEON_OV0_VID_BUF_PITCH0_VALUE 0x0460 +#define RADEON_OV0_VID_BUF_PITCH1_VALUE 0x0464 +#define RADEON_OV0_AUTO_FLIP_CNTL 0x0470 +#define RADEON_OV0_DEINTERLACE_PATTERN 0x0474 +#define RADEON_OV0_H_INC 0x0480 +#define RADEON_OV0_STEP_BY 0x0484 +#define RADEON_OV0_P1_H_ACCUM_INIT 0x0488 +#define RADEON_OV0_P23_H_ACCUM_INIT 0x048C +#define RADEON_OV0_P1_X_START_END 0x0494 +#define RADEON_OV0_P2_X_START_END 0x0498 +#define RADEON_OV0_P3_X_START_END 0x049C +#define RADEON_OV0_FILTER_CNTL 0x04A0 +#define RADEON_OV0_FOUR_TAP_COEF_0 0x04B0 +#define RADEON_OV0_FOUR_TAP_COEF_1 0x04B4 +#define RADEON_OV0_FOUR_TAP_COEF_2 0x04B8 +#define RADEON_OV0_FOUR_TAP_COEF_3 0x04BC +#define RADEON_OV0_FOUR_TAP_COEF_4 0x04C0 +#define RADEON_OV0_COLOUR_CNTL 0x04E0 +#define RADEON_OV0_VIDEO_KEY_CLR 0x04E4 +#define RADEON_OV0_VIDEO_KEY_MSK 0x04E8 +#define RADEON_OV0_GRAPHICS_KEY_CLR 0x04EC +#define RADEON_OV0_GRAPHICS_KEY_MSK 0x04F0 +#define RADEON_OV0_KEY_CNTL 0x04F4 +# define RADEON_VIDEO_KEY_FN_MASK 0x00000007L +# define RADEON_VIDEO_KEY_FN_FALSE 0x00000000L +# define RADEON_VIDEO_KEY_FN_TRUE 0x00000001L +# define RADEON_VIDEO_KEY_FN_EQ 0x00000004L +# define RADEON_VIDEO_KEY_FN_NE 0x00000005L +# define RADEON_GRAPHIC_KEY_FN_MASK 0x00000070L +# define RADEON_GRAPHIC_KEY_FN_FALSE 0x00000000L +# define RADEON_GRAPHIC_KEY_FN_TRUE 0x00000010L +# define RADEON_GRAPHIC_KEY_FN_EQ 0x00000040L +# define RADEON_GRAPHIC_KEY_FN_NE 0x00000050L +# define RADEON_CMP_MIX_MASK 0x00000100L +# define RADEON_CMP_MIX_OR 0x00000000L +# define RADEON_CMP_MIX_AND 0x00000100L +#define RADEON_OV0_TEST 0x04F8 + +#define RADEON_PALETTE_DATA 0x00b4 +#define RADEON_PALETTE_30_DATA 0x00b8 +#define RADEON_PALETTE_INDEX 0x00b0 +#define RADEON_PCI_GART_PAGE 0x017c +#define RADEON_PLANE_3D_MASK_C 0x1d44 +#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */ +#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */ +#define RADEON_PMI_DATA 0x0f63 /* PCI */ +#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ +#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */ +#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */ +#define RADEON_PMI_REGISTER 0x0f5c /* PCI */ +#define RADEON_PPLL_CNTL 0x0002 /* PLL */ +# define RADEON_PPLL_RESET (1 << 0) +# define RADEON_PPLL_SLEEP (1 << 1) +# define RADEON_PPLL_ATOMIC_UPDATE_EN (1 << 16) +# define RADEON_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) +# define RADEON_PPLL_ATOMIC_UPDATE_VSYNC (1 << 18) +#define RADEON_PPLL_DIV_0 0x0004 /* PLL */ +#define RADEON_PPLL_DIV_1 0x0005 /* PLL */ +#define RADEON_PPLL_DIV_2 0x0006 /* PLL */ +#define RADEON_PPLL_DIV_3 0x0007 /* PLL */ +# define RADEON_PPLL_FB3_DIV_MASK 0x07ff +# define RADEON_PPLL_POST3_DIV_MASK 0x00070000 +#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */ +# define RADEON_PPLL_REF_DIV_MASK 0x03ff +# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ +# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ +#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ +#define RADEON_RBBM_SOFT_RESET 0x00f0 +#define RADEON_RBBM_STATUS 0x0e40 +# define RADEON_RBBM_FIFOCNT_MASK 0x007f +# define RADEON_RBBM_ACTIVE (1 << 31) +#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c +# define RADEON_RB2D_DC_FLUSH_ALL 0xf +# define RADEON_RB2D_DC_BUSY (1 << 31) +#define RADEON_RB2D_DSTCACHE_MODE 0x3428 +#define RADEON_REG_BASE 0x0f18 /* PCI */ +#define RADEON_REGPROG_INF 0x0f09 /* PCI */ +#define RADEON_REVISION_ID 0x0f08 /* PCI */ + +#define RADEON_SC_BOTTOM 0x164c +#define RADEON_SC_BOTTOM_RIGHT 0x16f0 +#define RADEON_SC_BOTTOM_RIGHT_C 0x1c8c +#define RADEON_SC_LEFT 0x1640 +#define RADEON_SC_RIGHT 0x1644 +#define RADEON_SC_TOP 0x1648 +#define RADEON_SC_TOP_LEFT 0x16ec +#define RADEON_SC_TOP_LEFT_C 0x1c88 +#define RADEON_SDRAM_MODE_REG 0x0158 +#define RADEON_SEQ8_DATA 0x03c5 /* VGA */ +#define RADEON_SEQ8_IDX 0x03c4 /* VGA */ +#define RADEON_SNAPSHOT_F_COUNT 0x0244 +#define RADEON_SNAPSHOT_VH_COUNTS 0x0240 +#define RADEON_SNAPSHOT_VIF_COUNT 0x024c +#define RADEON_SRC_OFFSET 0x15ac +#define RADEON_SRC_PITCH 0x15b0 +#define RADEON_SRC_PITCH_OFFSET 0x1428 +#define RADEON_SRC_SC_BOTTOM 0x165c +#define RADEON_SRC_SC_BOTTOM_RIGHT 0x16f4 +#define RADEON_SRC_SC_RIGHT 0x1654 +#define RADEON_SRC_X 0x1414 +#define RADEON_SRC_X_Y 0x1590 +#define RADEON_SRC_Y 0x1418 +#define RADEON_SRC_Y_X 0x1434 +#define RADEON_STATUS 0x0f06 /* PCI */ +#define RADEON_SUBPIC_CNTL 0x0540 /* ? */ +#define RADEON_SUB_CLASS 0x0f0a /* PCI */ +#define RADEON_SURFACE_DELAY 0x0b00 +#define RADEON_SURFACE0_INFO 0x0b0c +#define RADEON_SURFACE0_LOWER_BOUND 0x0b04 +#define RADEON_SURFACE0_UPPER_BOUND 0x0b08 +#define RADEON_SURFACE1_INFO 0x0b1c +#define RADEON_SURFACE1_LOWER_BOUND 0x0b14 +#define RADEON_SURFACE1_UPPER_BOUND 0x0b18 +#define RADEON_SURFACE2_INFO 0x0b2c +#define RADEON_SURFACE2_LOWER_BOUND 0x0b24 +#define RADEON_SURFACE2_UPPER_BOUND 0x0b28 +#define RADEON_SURFACE3_INFO 0x0b3c +#define RADEON_SURFACE3_LOWER_BOUND 0x0b34 +#define RADEON_SURFACE3_UPPER_BOUND 0x0b38 +#define RADEON_SW_SEMAPHORE 0x013c + +#define RADEON_TEST_DEBUG_CNTL 0x0120 +#define RADEON_TEST_DEBUG_MUX 0x0124 +#define RADEON_TEST_DEBUG_OUT 0x012c +#define RADEON_TMDS_CRC 0x02a0 +#define RADEON_TRAIL_BRES_DEC 0x1614 +#define RADEON_TRAIL_BRES_ERR 0x160c +#define RADEON_TRAIL_BRES_INC 0x1610 +#define RADEON_TRAIL_X 0x1618 +#define RADEON_TRAIL_X_SUB 0x1620 + +#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */ +#define RADEON_VENDOR_ID 0x0f00 /* PCI */ +#define RADEON_VGA_DDA_CONFIG 0x02e8 +#define RADEON_VGA_DDA_ON_OFF 0x02ec +#define RADEON_VID_BUFFER_CONTROL 0x0900 +#define RADEON_VIDEOMUX_CNTL 0x0190 +#define RADEON_VIPH_CONTROL 0x0c40 /* ? */ + +#define RADEON_WAIT_UNTIL 0x1720 + +#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */ +#define RADEON_XCLK_CNTL 0x000d /* PLL */ +#define RADEON_XDLL_CNTL 0x000c /* PLL */ +#define RADEON_XPLL_CNTL 0x000b /* PLL */ + + /* Registers for CCE and Microcode Engine */ +#define RADEON_CP_ME_RAM_ADDR 0x07d4 +#define RADEON_CP_ME_RAM_RADDR 0x07d8 +#define RADEON_CP_ME_RAM_DATAH 0x07dc +#define RADEON_CP_ME_RAM_DATAL 0x07e0 + +#define RADEON_CP_RB_BASE 0x0700 +#define RADEON_CP_RB_CNTL 0x0704 +#define RADEON_CP_RB_RPTR_ADDR 0x070c +#define RADEON_CP_RB_RPTR 0x0710 +#define RADEON_CP_RB_WPTR 0x0714 +# define RADEON_PM4_BUFFER_DL_DONE (1 << 31) + +#define RADEON_CP_IB_BASE 0x0738 +#define RADEON_CP_IB_BUFSZ 0x073c + +#define RADEON_CP_CSQ_CNTL 0x0740 +# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28) +# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28) +# define RADEON_CSQ_PRIBM_INDDIS (2 << 28) +# define RADEON_CSQ_PRIPIO_INDBM (3 << 28) +# define RADEON_CSQ_PRIBM_INDBM (4 << 28) +# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28) +#define RADEON_CP_RB_WPTR_DELAY 0x0718 +# define RADEON_PRE_WRITE_TIMER_SHIFT 0 +# define RADEON_PRE_WRITE_LIMIT_SHIFT 23 + +#define RADEON_AIC_CNTL 0x01d0 +# define RADEON_PCIGART_TRANSLATE_EN (1 << 0) + +#define RADEON_PM4_VC_FPU_SETUP 0x071c +# define RADEON_FRONT_DIR_CW (0 << 0) +# define RADEON_FRONT_DIR_CCW (1 << 0) +# define RADEON_FRONT_DIR_MASK (1 << 0) +# define RADEON_BACKFACE_CULL (0 << 1) +# define RADEON_BACKFACE_POINTS (1 << 1) +# define RADEON_BACKFACE_LINES (2 << 1) +# define RADEON_BACKFACE_SOLID (3 << 1) +# define RADEON_BACKFACE_MASK (3 << 1) +# define RADEON_FRONTFACE_CULL (0 << 3) +# define RADEON_FRONTFACE_POINTS (1 << 3) +# define RADEON_FRONTFACE_LINES (2 << 3) +# define RADEON_FRONTFACE_SOLID (3 << 3) +# define RADEON_FRONTFACE_MASK (3 << 3) +# define RADEON_FPU_COLOR_SOLID (0 << 5) +# define RADEON_FPU_COLOR_FLAT (1 << 5) +# define RADEON_FPU_COLOR_GOURAUD (2 << 5) +# define RADEON_FPU_COLOR_GOURAUD2 (3 << 5) +# define RADEON_FPU_COLOR_MASK (3 << 5) +# define RADEON_FPU_SUB_PIX_2BITS (0 << 7) +# define RADEON_FPU_SUB_PIX_4BITS (1 << 7) +# define RADEON_FPU_MODE_2D (0 << 8) +# define RADEON_FPU_MODE_3D (1 << 8) +# define RADEON_TRAP_BITS_DISABLE (1 << 9) +# define RADEON_EDGE_ANTIALIAS (1 << 10) +# define RADEON_SUPERSAMPLE (1 << 11) +# define RADEON_XFACTOR_2 (0 << 12) +# define RADEON_XFACTOR_4 (1 << 12) +# define RADEON_YFACTOR_2 (0 << 13) +# define RADEON_YFACTOR_4 (1 << 13) +# define RADEON_FLAT_SHADE_VERTEX_D3D (0 << 14) +# define RADEON_FLAT_SHADE_VERTEX_OGL (1 << 14) +# define RADEON_FPU_ROUND_TRUNCATE (0 << 15) +# define RADEON_FPU_ROUND_NEAREST (1 << 15) +# define RADEON_WM_SEL_8DW (0 << 16) +# define RADEON_WM_SEL_16DW (1 << 16) +# define RADEON_WM_SEL_32DW (2 << 16) +#define RADEON_PM4_VC_DEBUG_CONFIG 0x07a4 +#define RADEON_PM4_VC_STAT 0x07a8 +#define RADEON_PM4_VC_TIMESTAMP0 0x07b0 +#define RADEON_PM4_VC_TIMESTAMP1 0x07b4 +#define RADEON_PM4_STAT 0x07b8 +# define RADEON_PM4_FIFOCNT_MASK 0x0fff +# define RADEON_PM4_BUSY (1 << 16) +# define RADEON_PM4_GUI_ACTIVE (1 << 31) +#define RADEON_PM4_BUFFER_ADDR 0x07f0 +#define RADEON_CP_ME_CNTL 0x07d0 +# define RADEON_CP_ME_FREERUN (1 << 30) +#define RADEON_PM4_FIFO_DATA_EVEN 0x1000 +#define RADEON_PM4_FIFO_DATA_ODD 0x1004 + +#define RADEON_SCALE_3D_CNTL 0x1a00 +# define RADEON_SCALE_DITHER_ERR_DIFF (0 << 1) +# define RADEON_SCALE_DITHER_TABLE (1 << 1) +# define RADEON_TEX_CACHE_SIZE_FULL (0 << 2) +# define RADEON_TEX_CACHE_SIZE_HALF (1 << 2) +# define RADEON_DITHER_INIT_CURR (0 << 3) +# define RADEON_DITHER_INIT_RESET (1 << 3) +# define RADEON_ROUND_24BIT (1 << 4) +# define RADEON_TEX_CACHE_DISABLE (1 << 5) +# define RADEON_SCALE_3D_NOOP (0 << 6) +# define RADEON_SCALE_3D_SCALE (1 << 6) +# define RADEON_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define RADEON_SCALE_PIX_BLEND (0 << 8) +# define RADEON_SCALE_PIX_REPLICATE (1 << 8) +# define RADEON_TEX_CACHE_SPLIT (1 << 9) +# define RADEON_APPLE_YUV_MODE (1 << 10) +# define RADEON_TEX_CACHE_PALLETE_MODE (1 << 11) +# define RADEON_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define RADEON_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define RADEON_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define RADEON_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define RADEON_FOG_TABLE (1 << 14) +# define RADEON_SIGNED_DST_CLAMP (1 << 15) +# define RADEON_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define RADEON_ALPHA_BLEND_SRC_ONE (1 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define RADEON_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +# define RADEON_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) +# define RADEON_ALPHA_BLEND_SRC_SAT (10 << 16) +# define RADEON_ALPHA_BLEND_SRC_BLEND (11 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVBLEND (12 << 16) +# define RADEON_ALPHA_BLEND_DST_ZERO (0 << 20) +# define RADEON_ALPHA_BLEND_DST_ONE (1 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define RADEON_ALPHA_BLEND_DST_DSTALPHA (6 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) +# define RADEON_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) +# define RADEON_ALPHA_TEST_NEVER (0 << 24) +# define RADEON_ALPHA_TEST_LESS (1 << 24) +# define RADEON_ALPHA_TEST_LESSEQUAL (2 << 24) +# define RADEON_ALPHA_TEST_EQUAL (3 << 24) +# define RADEON_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define RADEON_ALPHA_TEST_GREATER (5 << 24) +# define RADEON_ALPHA_TEST_NEQUAL (6 << 24) +# define RADEON_ALPHA_TEST_ALWAYS (7 << 24) +# define RADEON_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) +# define RADEON_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) +# define RADEON_COMPOSITE_SHADOW (1 << 29) +# define RADEON_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) +# define RADEON_TEX_CACHE_LINE_SIZE_8QW (0 << 31) +# define RADEON_TEX_CACHE_LINE_SIZE_4QW (1 << 31) +#define RADEON_SCALE_3D_DATATYPE 0x1a20 + +#define RADEON_SETUP_CNTL 0x1bc4 +# define RADEON_DONT_START_TRIANGLE (1 << 0) +# define RADEON_Z_BIAS (0 << 1) +# define RADEON_DONT_START_ANY_ON (1 << 2) +# define RADEON_COLOR_SOLID_COLOR (0 << 3) +# define RADEON_COLOR_FLAT_VERT_1 (1 << 3) +# define RADEON_COLOR_FLAT_VERT_2 (2 << 3) +# define RADEON_COLOR_FLAT_VERT_3 (3 << 3) +# define RADEON_COLOR_GOURAUD (4 << 3) +# define RADEON_PRIM_TYPE_TRI (0 << 7) +# define RADEON_PRIM_TYPE_LINE (1 << 7) +# define RADEON_PRIM_TYPE_POINT (2 << 7) +# define RADEON_PRIM_TYPE_POLY_EDGE (3 << 7) +# define RADEON_TEXTURE_ST_MULT_W (0 << 9) +# define RADEON_TEXTURE_ST_DIRECT (1 << 9) +# define RADEON_STARTING_VERTEX_1 (1 << 14) +# define RADEON_STARTING_VERTEX_2 (2 << 14) +# define RADEON_STARTING_VERTEX_3 (3 << 14) +# define RADEON_ENDING_VERTEX_1 (1 << 16) +# define RADEON_ENDING_VERTEX_2 (2 << 16) +# define RADEON_ENDING_VERTEX_3 (3 << 16) +# define RADEON_SU_POLY_LINE_LAST (0 << 18) +# define RADEON_SU_POLY_LINE_NOT_LAST (1 << 18) +# define RADEON_SUB_PIX_2BITS (0 << 19) +# define RADEON_SUB_PIX_4BITS (1 << 19) +# define RADEON_SET_UP_CONTINUE (1 << 31) + +#define RADEON_WINDOW_XY_OFFSET 0x1bcc +# define RADEON_WINDOW_Y_SHIFT 4 +# define RADEON_WINDOW_X_SHIFT 20 + +#define RADEON_Z_OFFSET_C 0x1c90 +#define RADEON_Z_PITCH_C 0x1c94 +#define RADEON_Z_STEN_CNTL_C 0x1c98 +# define RADEON_Z_PIX_WIDTH_16 (0 << 1) +# define RADEON_Z_PIX_WIDTH_24 (1 << 1) +# define RADEON_Z_PIX_WIDTH_32 (2 << 1) +# define RADEON_Z_PIX_WIDTH_MASK (3 << 1) +# define RADEON_Z_TEST_NEVER (0 << 4) +# define RADEON_Z_TEST_LESS (1 << 4) +# define RADEON_Z_TEST_LESSEQUAL (2 << 4) +# define RADEON_Z_TEST_EQUAL (3 << 4) +# define RADEON_Z_TEST_GREATEREQUAL (4 << 4) +# define RADEON_Z_TEST_GREATER (5 << 4) +# define RADEON_Z_TEST_NEQUAL (6 << 4) +# define RADEON_Z_TEST_ALWAYS (7 << 4) +# define RADEON_Z_TEST_MASK (7 << 4) +# define RADEON_STENCIL_TEST_NEVER (0 << 12) +# define RADEON_STENCIL_TEST_LESS (1 << 12) +# define RADEON_STENCIL_TEST_LESSEQUAL (2 << 12) +# define RADEON_STENCIL_TEST_EQUAL (3 << 12) +# define RADEON_STENCIL_TEST_GREATEREQUAL (4 << 12) +# define RADEON_STENCIL_TEST_GREATER (5 << 12) +# define RADEON_STENCIL_TEST_NEQUAL (6 << 12) +# define RADEON_STENCIL_TEST_ALWAYS (7 << 12) +# define RADEON_STENCIL_S_FAIL_KEEP (0 << 16) +# define RADEON_STENCIL_S_FAIL_ZERO (1 << 16) +# define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16) +# define RADEON_STENCIL_S_FAIL_INC (3 << 16) +# define RADEON_STENCIL_S_FAIL_DEC (4 << 16) +# define RADEON_STENCIL_S_FAIL_INV (5 << 16) +# define RADEON_STENCIL_ZPASS_KEEP (0 << 20) +# define RADEON_STENCIL_ZPASS_ZERO (1 << 20) +# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20) +# define RADEON_STENCIL_ZPASS_INC (3 << 20) +# define RADEON_STENCIL_ZPASS_DEC (4 << 20) +# define RADEON_STENCIL_ZPASS_INV (5 << 20) +# define RADEON_STENCIL_ZFAIL_KEEP (0 << 24) +# define RADEON_STENCIL_ZFAIL_ZERO (1 << 24) +# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24) +# define RADEON_STENCIL_ZFAIL_INC (3 << 24) +# define RADEON_STENCIL_ZFAIL_DEC (4 << 24) +# define RADEON_STENCIL_ZFAIL_INV (5 << 24) +#define RADEON_TEX_CNTL_C 0x1c9c +# define RADEON_Z_ENABLE (1 << 0) +# define RADEON_Z_WRITE_ENABLE (1 << 1) +# define RADEON_STENCIL_ENABLE (1 << 3) +# define RADEON_SHADE_ENABLE (0 << 4) +# define RADEON_TEXMAP_ENABLE (1 << 4) +# define RADEON_SEC_TEXMAP_ENABLE (1 << 5) +# define RADEON_FOG_ENABLE (1 << 7) +# define RADEON_DITHER_ENABLE (1 << 8) +# define RADEON_ALPHA_ENABLE (1 << 9) +# define RADEON_ALPHA_TEST_ENABLE (1 << 10) +# define RADEON_SPEC_LIGHT_ENABLE (1 << 11) +# define RADEON_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define RADEON_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define RADEON_ALPHA_IN_TEX_LSB_A (1 << 13) +# define RADEON_LIGHT_DIS (0 << 14) +# define RADEON_LIGHT_COPY (1 << 14) +# define RADEON_LIGHT_MODULATE (2 << 14) +# define RADEON_LIGHT_ADD (3 << 14) +# define RADEON_LIGHT_BLEND_CONSTANT (4 << 14) +# define RADEON_LIGHT_BLEND_TEXTURE (5 << 14) +# define RADEON_LIGHT_BLEND_VERTEX (6 << 14) +# define RADEON_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define RADEON_ALPHA_LIGHT_DIS (0 << 18) +# define RADEON_ALPHA_LIGHT_COPY (1 << 18) +# define RADEON_ALPHA_LIGHT_MODULATE (2 << 18) +# define RADEON_ALPHA_LIGHT_ADD (3 << 18) +# define RADEON_ANTI_ALIAS (1 << 21) +# define RADEON_TEX_CACHE_FLUSH (1 << 23) +# define RADEON_LOD_BIAS_SHIFT 24 +#define RADEON_MISC_3D_STATE_CNTL_REG 0x1ca0 +# define RADEON_REF_ALPHA_MASK 0xff +# define RADEON_MISC_SCALE_3D_NOOP (0 << 8) +# define RADEON_MISC_SCALE_3D_SCALE (1 << 8) +# define RADEON_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define RADEON_MISC_SCALE_PIX_BLEND (0 << 10) +# define RADEON_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define RADEON_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define RADEON_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define RADEON_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define RADEON_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define RADEON_FOG_VERTEX (0 << 14) +# define RADEON_FOG_TABLE (1 << 14) +# define RADEON_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define RADEON_ALPHA_BLEND_SRC_ONE (1 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define RADEON_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) +# define RADEON_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) +# define RADEON_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) +# define RADEON_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) +# define RADEON_ALPHA_BLEND_SRC_MASK (15 << 16) +# define RADEON_ALPHA_BLEND_DST_ZERO (0 << 20) +# define RADEON_ALPHA_BLEND_DST_ONE (1 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define RADEON_ALPHA_BLEND_DST_DESTALPHA (6 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) +# define RADEON_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) +# define RADEON_ALPHA_BLEND_DST_MASK (15 << 20) +# define RADEON_ALPHA_TEST_NEVER (0 << 24) +# define RADEON_ALPHA_TEST_LESS (1 << 24) +# define RADEON_ALPHA_TEST_LESSEQUAL (2 << 24) +# define RADEON_ALPHA_TEST_EQUAL (3 << 24) +# define RADEON_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define RADEON_ALPHA_TEST_GREATER (5 << 24) +# define RADEON_ALPHA_TEST_NEQUAL (6 << 24) +# define RADEON_ALPHA_TEST_ALWAYS (7 << 24) +# define RADEON_ALPHA_TEST_MASK (7 << 24) +#define RADEON_TEXTURE_CLR_CMP_CLR_C 0x1ca4 +#define RADEON_TEXTURE_CLR_CMP_MSK_C 0x1ca8 +#define RADEON_FOG_COLOR_C 0x1cac +# define RADEON_FOG_BLUE_SHIFT 0 +# define RADEON_FOG_GREEN_SHIFT 8 +# define RADEON_FOG_RED_SHIFT 16 +#define RADEON_PRIM_TEX_CNTL_C 0x1cb0 +# define RADEON_MIN_BLEND_NEAREST (0 << 1) +# define RADEON_MIN_BLEND_LINEAR (1 << 1) +# define RADEON_MIN_BLEND_MIPNEAREST (2 << 1) +# define RADEON_MIN_BLEND_MIPLINEAR (3 << 1) +# define RADEON_MIN_BLEND_LINEARMIPNEAREST (4 << 1) +# define RADEON_MIN_BLEND_LINEARMIPLINEAR (5 << 1) +# define RADEON_MIN_BLEND_MASK (7 << 1) +# define RADEON_MAG_BLEND_NEAREST (0 << 4) +# define RADEON_MAG_BLEND_LINEAR (1 << 4) +# define RADEON_MAG_BLEND_MASK (7 << 4) +# define RADEON_MIP_MAP_DISABLE (1 << 7) +# define RADEON_TEX_CLAMP_S_WRAP (0 << 8) +# define RADEON_TEX_CLAMP_S_MIRROR (1 << 8) +# define RADEON_TEX_CLAMP_S_CLAMP (2 << 8) +# define RADEON_TEX_CLAMP_S_BORDER_COLOR (3 << 8) +# define RADEON_TEX_CLAMP_S_MASK (3 << 8) +# define RADEON_TEX_WRAP_S (1 << 10) +# define RADEON_TEX_CLAMP_T_WRAP (0 << 11) +# define RADEON_TEX_CLAMP_T_MIRROR (1 << 11) +# define RADEON_TEX_CLAMP_T_CLAMP (2 << 11) +# define RADEON_TEX_CLAMP_T_BORDER_COLOR (3 << 11) +# define RADEON_TEX_CLAMP_T_MASK (3 << 11) +# define RADEON_TEX_WRAP_T (1 << 13) +# define RADEON_TEX_PERSPECTIVE_DISABLE (1 << 14) +# define RADEON_DATATYPE_VQ (0 << 16) +# define RADEON_DATATYPE_CI4 (1 << 16) +# define RADEON_DATATYPE_CI8 (2 << 16) +# define RADEON_DATATYPE_ARGB1555 (3 << 16) +# define RADEON_DATATYPE_RGB565 (4 << 16) +# define RADEON_DATATYPE_RGB888 (5 << 16) +# define RADEON_DATATYPE_ARGB8888 (6 << 16) +# define RADEON_DATATYPE_RGB332 (7 << 16) +# define RADEON_DATATYPE_Y8 (8 << 16) +# define RADEON_DATATYPE_RGB8 (9 << 16) +# define RADEON_DATATYPE_CI16 (10 << 16) +# define RADEON_DATATYPE_YUV422 (11 << 16) +# define RADEON_DATATYPE_YUV422_2 (12 << 16) +# define RADEON_DATATYPE_AYUV444 (14 << 16) +# define RADEON_DATATYPE_ARGB4444 (15 << 16) +# define RADEON_PALLETE_EITHER (0 << 20) +# define RADEON_PALLETE_1 (1 << 20) +# define RADEON_PALLETE_2 (2 << 20) +# define RADEON_PSEUDOCOLOR_DT_RGB565 (0 << 24) +# define RADEON_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) +# define RADEON_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) +#define RADEON_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 +# define RADEON_COMB_DIS (0 << 0) +# define RADEON_COMB_COPY (1 << 0) +# define RADEON_COMB_COPY_INP (2 << 0) +# define RADEON_COMB_MODULATE (3 << 0) +# define RADEON_COMB_MODULATE2X (4 << 0) +# define RADEON_COMB_MODULATE4X (5 << 0) +# define RADEON_COMB_ADD (6 << 0) +# define RADEON_COMB_ADD_SIGNED (7 << 0) +# define RADEON_COMB_BLEND_VERTEX (8 << 0) +# define RADEON_COMB_BLEND_TEXTURE (9 << 0) +# define RADEON_COMB_BLEND_CONST (10 << 0) +# define RADEON_COMB_BLEND_PREMULT (11 << 0) +# define RADEON_COMB_BLEND_PREV (12 << 0) +# define RADEON_COMB_BLEND_PREMULT_INV (13 << 0) +# define RADEON_COMB_ADD_SIGNED2X (14 << 0) +# define RADEON_COMB_BLEND_CONST_COLOR (15 << 0) +# define RADEON_COMB_MASK (15 << 0) +# define RADEON_COLOR_FACTOR_TEX (4 << 4) +# define RADEON_COLOR_FACTOR_NTEX (5 << 4) +# define RADEON_COLOR_FACTOR_ALPHA (6 << 4) +# define RADEON_COLOR_FACTOR_NALPHA (7 << 4) +# define RADEON_COLOR_FACTOR_MASK (15 << 4) +# define RADEON_INPUT_FACTOR_CONST_COLOR (2 << 10) +# define RADEON_INPUT_FACTOR_CONST_ALPHA (3 << 10) +# define RADEON_INPUT_FACTOR_INT_COLOR (4 << 10) +# define RADEON_INPUT_FACTOR_INT_ALPHA (5 << 10) +# define RADEON_INPUT_FACTOR_MASK (15 << 10) +# define RADEON_COMB_ALPHA_DIS (0 << 14) +# define RADEON_COMB_ALPHA_COPY (1 << 14) +# define RADEON_COMB_ALPHA_COPY_INP (2 << 14) +# define RADEON_COMB_ALPHA_MODULATE (3 << 14) +# define RADEON_COMB_ALPHA_MODULATE2X (4 << 14) +# define RADEON_COMB_ALPHA_MODULATE4X (5 << 14) +# define RADEON_COMB_ALPHA_ADD (6 << 14) +# define RADEON_COMB_ALPHA_ADD_SIGNED (7 << 14) +# define RADEON_COMB_ALPHA_ADD_SIGNED2X (14 << 14) +# define RADEON_COMB_ALPHA_MASK (15 << 14) +# define RADEON_ALPHA_FACTOR_TEX_ALPHA (6 << 18) +# define RADEON_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) +# define RADEON_ALPHA_FACTOR_MASK (15 << 18) +# define RADEON_INP_FACTOR_A_CONST_ALPHA (1 << 25) +# define RADEON_INP_FACTOR_A_INT_ALPHA (2 << 25) +# define RADEON_INP_FACTOR_A_MASK (7 << 25) +#define RADEON_TEX_SIZE_PITCH_C 0x1cb8 +# define RADEON_TEX_PITCH_SHIFT 0 +# define RADEON_TEX_SIZE_SHIFT 4 +# define RADEON_TEX_HEIGHT_SHIFT 8 +# define RADEON_TEX_MIN_SIZE_SHIFT 12 +# define RADEON_SEC_TEX_PITCH_SHIFT 16 +# define RADEON_SEC_TEX_SIZE_SHIFT 20 +# define RADEON_SEC_TEX_HEIGHT_SHIFT 24 +# define RADEON_SEC_TEX_MIN_SIZE_SHIFT 28 +# define RADEON_TEX_PITCH_MASK (0x0f << 0) +# define RADEON_TEX_SIZE_MASK (0x0f << 4) +# define RADEON_TEX_HEIGHT_MASK (0x0f << 8) +# define RADEON_TEX_MIN_SIZE_MASK (0x0f << 12) +# define RADEON_SEC_TEX_PITCH_MASK (0x0f << 16) +# define RADEON_SEC_TEX_SIZE_MASK (0x0f << 20) +# define RADEON_SEC_TEX_HEIGHT_MASK (0x0f << 24) +# define RADEON_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) +# define RADEON_TEX_SIZE_PITCH_SHIFT 0 +# define RADEON_SEC_TEX_SIZE_PITCH_SHIFT 16 +# define RADEON_TEX_SIZE_PITCH_MASK (0xffff << 0) +# define RADEON_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) +#define RADEON_PRIM_TEX_0_OFFSET_C 0x1cbc +#define RADEON_PRIM_TEX_1_OFFSET_C 0x1cc0 +#define RADEON_PRIM_TEX_2_OFFSET_C 0x1cc4 +#define RADEON_PRIM_TEX_3_OFFSET_C 0x1cc8 +#define RADEON_PRIM_TEX_4_OFFSET_C 0x1ccc +#define RADEON_PRIM_TEX_5_OFFSET_C 0x1cd0 +#define RADEON_PRIM_TEX_6_OFFSET_C 0x1cd4 +#define RADEON_PRIM_TEX_7_OFFSET_C 0x1cd8 +#define RADEON_PRIM_TEX_8_OFFSET_C 0x1cdc +#define RADEON_PRIM_TEX_9_OFFSET_C 0x1ce0 +#define RADEON_PRIM_TEX_10_OFFSET_C 0x1ce4 +# define RADEON_TEX_NO_TILE (0 << 30) +# define RADEON_TEX_TILED_BY_HOST (1 << 30) +# define RADEON_TEX_TILED_BY_STORAGE (2 << 30) +# define RADEON_TEX_TILED_BY_STORAGE2 (3 << 30) + +#define RADEON_SEC_TEX_CNTL_C 0x1d00 +# define RADEON_SEC_SELECT_PRIM_ST (0 << 0) +# define RADEON_SEC_SELECT_SEC_ST (1 << 0) +#define RADEON_SEC_TEX_COMBINE_CNTL_C 0x1d04 +# define RADEON_INPUT_FACTOR_PREV_COLOR (8 << 10) +# define RADEON_INPUT_FACTOR_PREV_ALPHA (9 << 10) +# define RADEON_INP_FACTOR_A_PREV_ALPHA (4 << 25) +#define RADEON_SEC_TEX_0_OFFSET_C 0x1d08 +#define RADEON_SEC_TEX_1_OFFSET_C 0x1d0c +#define RADEON_SEC_TEX_2_OFFSET_C 0x1d10 +#define RADEON_SEC_TEX_3_OFFSET_C 0x1d14 +#define RADEON_SEC_TEX_4_OFFSET_C 0x1d18 +#define RADEON_SEC_TEX_5_OFFSET_C 0x1d1c +#define RADEON_SEC_TEX_6_OFFSET_C 0x1d20 +#define RADEON_SEC_TEX_7_OFFSET_C 0x1d24 +#define RADEON_SEC_TEX_8_OFFSET_C 0x1d28 +#define RADEON_SEC_TEX_9_OFFSET_C 0x1d2c +#define RADEON_SEC_TEX_10_OFFSET_C 0x1d30 +#define RADEON_CONSTANT_COLOR_C 0x1d34 +# define RADEON_CONSTANT_BLUE_SHIFT 0 +# define RADEON_CONSTANT_GREEN_SHIFT 8 +# define RADEON_CONSTANT_RED_SHIFT 16 +# define RADEON_CONSTANT_ALPHA_SHIFT 24 +#define RADEON_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 +# define RADEON_PRIM_TEX_BORDER_BLUE_SHIFT 0 +# define RADEON_PRIM_TEX_BORDER_GREEN_SHIFT 8 +# define RADEON_PRIM_TEX_BORDER_RED_SHIFT 16 +# define RADEON_PRIM_TEX_BORDER_ALPHA_SHIFT 24 +#define RADEON_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +# define RADEON_SEC_TEX_BORDER_BLUE_SHIFT 0 +# define RADEON_SEC_TEX_BORDER_GREEN_SHIFT 8 +# define RADEON_SEC_TEX_BORDER_RED_SHIFT 16 +# define RADEON_SEC_TEX_BORDER_ALPHA_SHIFT 24 +#define RADEON_STEN_REF_MASK_C 0x1d40 +# define RADEON_STEN_REFERENCE_SHIFT 0 +# define RADEON_STEN_MASK_SHIFT 16 +# define RADEON_STEN_WRITE_MASK_SHIFT 24 +#define RADEON_PLANE_3D_MASK_C 0x1d44 +#define RADEON_TEX_CACHE_STAT_COUNT 0x1974 + + + /* Constants */ +#define RADEON_AGP_TEX_OFFSET 0x02000000 + +#define RADEON_VB_AGE_REG RADEON_GUI_SCRATCH_REG0 +#define RADEON_SWAP_AGE_REG RADEON_GUI_SCRATCH_REG1 + + /* CCE packet types */ +#define RADEON_CCE_PACKET0 0x00000000 +#define RADEON_CCE_PACKET0_ONE_REG_WR 0x00008000 +#define RADEON_CCE_PACKET1 0x40000000 +#define RADEON_CCE_PACKET2 0x80000000 +#define RADEON_CCE_PACKET3_NOP 0xC0001000 +#define RADEON_CCE_PACKET3_PAINT 0xC0001100 +#define RADEON_CCE_PACKET3_BITBLT 0xC0001200 +#define RADEON_CCE_PACKET3_SMALLTEXT 0xC0001300 +#define RADEON_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 +#define RADEON_CCE_PACKET3_POLYLINE 0xC0001500 +#define RADEON_CCE_PACKET3_SCALING 0xC0001600 +#define RADEON_CCE_PACKET3_TRANS_SCALING 0xC0001700 +#define RADEON_CCE_PACKET3_POLYSCANLINES 0xC0001800 +#define RADEON_CCE_PACKET3_NEXT_CHAR 0xC0001900 +#define RADEON_CCE_PACKET3_PAINT_MULTI 0xC0001A00 +#define RADEON_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 +#define RADEON_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 +#define RADEON_CCE_PACKET3_SET_SCISSORS 0xC0001E00 +#define RADEON_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 +#define RADEON_CCE_PACKET3_CNTL_PAINT 0xC0009100 +#define RADEON_CCE_PACKET3_CNTL_BITBLT 0xC0009200 +#define RADEON_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 +#define RADEON_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 +#define RADEON_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 +#define RADEON_CCE_PACKET3_CNTL_SCALING 0xC0009600 +#define RADEON_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 +#define RADEON_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 +#define RADEON_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 +#define RADEON_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 +#define RADEON_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 +#define RADEON_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 +#define RADEON_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 +#define RADEON_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 +#define RADEON_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 +#define RADEON_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 +#define RADEON_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 +#define RADEON_CCE_PACKET3_PURGE 0xC0002D00 +#define RADEON_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 +# define RADEON_CCE_PACKET_MASK 0xC0000000 +# define RADEON_CCE_PACKET_COUNT_MASK 0x3fff0000 +# define RADEON_CCE_PACKET_MAX_DWORDS (1 << 14) +# define RADEON_CCE_PACKET0_REG_MASK 0x000007ff +# define RADEON_CCE_PACKET1_REG0_MASK 0x000007ff +# define RADEON_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define RADEON_CCE_VC_FRMT_RHW 0x00000001 +#define RADEON_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 +#define RADEON_CCE_VC_FRMT_DIFFUSE_A 0x00000004 +#define RADEON_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 +#define RADEON_CCE_VC_FRMT_SPEC_BGR 0x00000010 +#define RADEON_CCE_VC_FRMT_SPEC_F 0x00000020 +#define RADEON_CCE_VC_FRMT_SPEC_FRGB 0x00000040 +#define RADEON_CCE_VC_FRMT_S_T 0x00000080 +#define RADEON_CCE_VC_FRMT_S2_T2 0x00000100 +#define RADEON_CCE_VC_FRMT_RHW2 0x00000200 + +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define RADEON_CCE_VC_CNTL_NUM_SHIFT 16 + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h new file mode 100644 index 000000000..e06aead72 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h @@ -0,0 +1,41 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h,v 1.1 2000/11/02 16:55:46 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 _RADEON_VERSION_H_ +#define _RADEON_VERSION_H_ 1 + +#define RADEON_NAME "RADEON" +#define RADEON_DRIVER_NAME "radeon" + +#define RADEON_VERSION_NAME "4.0.1" + +#define RADEON_VERSION_MAJOR 4 +#define RADEON_VERSION_MINOR 0 +#define RADEON_VERSION_PATCH 1 + +#define RADEON_VERSION_CURRENT \ + ((RADEON_VERSION_MAJOR << 20) | \ + (RADEON_VERSION_MINOR << 10) | \ + (RADEON_VERSION_PATCH)) + +#endif /* _RADEON_VERSION_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c new file mode 100644 index 000000000..8f629fd73 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c @@ -0,0 +1,798 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c,v 1.1 2000/11/02 16:55:47 tsi Exp $ */ +/* + * Copyright 2000 Stuart R. Anderson and Metro Link, 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 on + * 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 (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 + * ATI, PRECISION INSIGHT AND/OR THEIR 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. + */ + +/* + * Authors: + * Stuart R. Anderson <anderson@metrolink.com> + * + * Credits: + * + * This code is derived primarily from the GATOS Project run by Stea Greene. + * The initial version of this code was done by Vladimir Dergacheb. + * + * This code was simplified from the GATOS code primarily because I didn't + * have the right hardware handy to test anything beyond simple overlays, + * and because I wanted to complete it in a short time frame that I had + * available. + * + * My apologies to Vladimir as there is more good work in his code that + * should be brought forward. + * + * RADEON ALERT ! + * This is an extremely quick port to the Radeon, it hasn't been tested + * thoroughly, although it appears to work. + */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "xf86xv.h" +#include "xf86Cursor.h" +#include "Xv.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" + +#include "radeon.h" +#include "radeon_reg.h" + +/* + * For Debug +#define OUTREG(addr, val) { xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"OUTREG(%s,%x)\n",#addr,val) ;MMIO_OUT32(RADEONMMIO, addr, val);} +*/ + +#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) + +#ifndef XvExtension +void RADEONInitVideo(ScreenPtr pScreen) {} +#else +static XF86VideoAdaptorPtr RADEONSetupImageVideo(ScreenPtr); +static int RADEONSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int RADEONGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); + +static void RADEONStopVideo(ScrnInfoPtr, pointer, Bool); +static void RADEONQueryBestSize(ScrnInfoPtr, Bool, + short, short, short, short, unsigned int *, unsigned int *, pointer); +static int RADEONPutImage( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, pointer); +static int RADEONQueryImageAttributes(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +#define IMAGE_MAX_WIDTH 2048 +#define IMAGE_MAX_HEIGHT 2048 +#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) + +static Atom xvColorKey; + +typedef struct { + int videoStatus; + unsigned char brightness; + unsigned char contrast; + + RegionRec clip; + CARD32 colorKey; + CARD8 overlay_pixel_size; + CARD8 current_buffer; + int overlay_pad; + CARD32 overlay_id; + CARD32 overlay_width; + + CARD32 scale_cntl; + CARD32 video_format; + FBLinearPtr linear; + } RADEONPortPrivRec, *RADEONPortPrivPtr; + +void RADEONInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + RADEONTRACE(("RADEONInitVideo called\n")); + + /* Determine if the card supports this */ + if (pScrn->bitsPerPixel != 8) + { + newAdaptor = RADEONSetupImageVideo(pScreen); + } + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 3 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {15, TrueColor}, + {16, TrueColor}, + {32, TrueColor} +}; + +#define NUM_ATTRIBUTES 1 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1<<24)-1, "XV_COLORKEY"}, +}; + +#define NUM_IMAGES 3 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_UYVY +}; + +static void +RADEONResetVideo(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + RADEONTRACE(("RADEONResetVideo called\n")); + + /* Initialize some of the HW here */ + OUTREG(RADEON_OV0_EXCLUSIVE_HORZ,0); /* disable exclusive mode */ + OUTREG(RADEON_OV0_VIDEO_KEY_MSK,0xffff); + OUTREG(RADEON_OV0_KEY_CNTL, RADEON_GRAPHIC_KEY_FN_NE); + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + /* Only using one buffer for now + OUTREG(RADEON_OV0_AUTO_FLIP_CNTL,pAPriv->Port[0].auto_flip_cntl); + */ + switch(pScrn->depth){ + case 8: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xff); + break; + case 15: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0x7fff); + break; + case 16: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffff); + break; + case 24: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffffff); + break; + case 32: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffffffff); + break; + } + + OUTREG(RADEON_OV0_REG_LOAD_CNTL,0x0); + OUTREG(RADEON_OV0_DEINTERLACE_PATTERN,0xAAAAA); + OUTREG(RADEON_OV0_P1_V_ACCUM_INIT,(2<<20)|1); + OUTREG(RADEON_OV0_P23_V_ACCUM_INIT,(2<<20)|1); + OUTREG(RADEON_OV0_P1_H_ACCUM_INIT,(3<<28)); + OUTREG(RADEON_OV0_P23_H_ACCUM_INIT,(2<<28)); + OUTREG(RADEON_OV0_STEP_BY,1|(1<<8)); + OUTREG(RADEON_OV0_FILTER_CNTL,0xf); /* use hardcoded coeff's */ + OUTREG(RADEON_OV0_FILTER_CNTL,0x0); /* use programmable coeff's */ + OUTREG(RADEON_OV0_FOUR_TAP_COEF_0 , 0x00002000); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_1 , 0x0D06200D); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_2 , 0x0D0A1C0D); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_3 , 0x0C0E1A0C); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_4 , 0x0C14140C); + OUTREG(RADEON_OV0_COLOUR_CNTL,(1<<12)|(1<<20)); + OUTREG(RADEON_OV0_TEST,0); + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + OUTREG(RADEON_CAP0_TRIG_CNTL,0); +} + +static XF86VideoAdaptorPtr +RADEONSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + XF86VideoAdaptorPtr adapt; + RADEONPortPrivPtr pPriv; + + RADEONTRACE(("RADEONSetupImageVideo called\n")); + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(RADEONPortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "RADEON Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (RADEONPortPrivPtr)(&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 = RADEONStopVideo; + adapt->SetPortAttribute = RADEONSetPortAttribute; + adapt->GetPortAttribute = RADEONGetPortAttribute; + adapt->QueryBestSize = RADEONQueryBestSize; + adapt->PutImage = RADEONPutImage; + adapt->QueryImageAttributes = RADEONQueryImageAttributes; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + info->adaptor = adapt; + + pPriv->colorKey = 0x01; /* a touch of blue */ + pPriv->video_format = RADEON_SCALER_SOURCE_VYUY422; + pPriv->scale_cntl = RADEON_SCALER_PRG_LOAD_START|RADEON_SCALER_DOUBLE_BUFFER; + pPriv->scale_cntl|= RADEON_SCALER_SMART_SWITCH|RADEON_SCALER_PIX_EXPAND; + pPriv->scale_cntl|= RADEON_SCALER_SMART_SWITCH; + + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + RADEONResetVideo(pScrn); + + return adapt; +} + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + +static void +RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool Exit) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONStopVideo called\n")); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if (Exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + } + } +} + +static int +RADEONSetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONSetPortAttribute called\n")); + + if (attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + RADEONTRACE(("Setting ColorKey to %d\n", pPriv->colorKey)); + return Success; + } + + return Success; +} + +static int +RADEONGetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +) +{ + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONGetPortAttribute called\n")); + + if (attribute == xvColorKey) { + RADEONTRACE(("Getting ColorKey %d\n", pPriv->colorKey)); + *value = pPriv->colorKey; + return Success; + } + + return Success; +} + +static void +RADEONQueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +) +{ + RADEONTRACE(("RADEONQueryBestSize called\n")); + *p_w = drw_w; + *p_h = drw_h; +} + +static void +RADEONDisplayVideo( + ScrnInfoPtr pScrn, + short width, short height, + int xa, int ya, int xb, int yb, + short src_w, short src_h, + short drw_w, short drw_h, + int fboffset +) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + int step_by, vert_inc, horz_inc; + + RADEONTRACE(("RADEONDisplayVideo called\n")); + + /* calculate step_by factor */ + step_by=src_w/(drw_w*2); + switch(step_by){ + case 0: + OUTREG(RADEON_OV0_STEP_BY,0x101); + step_by=1; + break; + case 1: + OUTREG(RADEON_OV0_STEP_BY,0x202); + step_by=2; + break; + case 2: + case 3: + OUTREG(RADEON_OV0_STEP_BY,0x303); + step_by=4; + break; + default: + OUTREG(RADEON_OV0_STEP_BY,0x404); + step_by=8; + break; + } + + vert_inc=(src_h<<12)/(drw_h); + horz_inc=(src_w<<12)/(drw_w*step_by); + + OUTREG(RADEON_OV0_Y_X_START,((xa))|(ya<<16)|(1<<31)); + OUTREG(RADEON_OV0_Y_X_END,((xb))|((yb)<<16)); + OUTREG(RADEON_OV0_H_INC,(horz_inc)|((horz_inc<<15))); + OUTREG(RADEON_OV0_V_INC,(vert_inc<<8)); + OUTREG(RADEON_OV0_P1_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(RADEON_OV0_P23_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(RADEON_OV0_VID_BUF_PITCH0_VALUE,width<<1); + OUTREG(RADEON_OV0_VID_BUF_PITCH1_VALUE,width<<1); + OUTREG(RADEON_OV0_P1_X_START_END,(src_w-1)|((xa&0xf)<<16)); + OUTREG(RADEON_OV0_P2_X_START_END,(src_w-1)|((xa&0xf)<<16)); + OUTREG(RADEON_OV0_P3_X_START_END,(src_w-1)|((xa&0xf)<<16)); + + OUTREG(RADEON_OV0_VID_BUF0_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF1_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF2_BASE_ADRS,(fboffset)&(~0xf)); + +#if 0 + /* Enable this when double buffering is implemented */ + OUTREG(RADEON_OV0_VID_BUF3_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF4_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF5_BASE_ADRS,(fboffset2)&(~0xf)); +#endif + + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|RADEON_SCALER_ENABLE|pPriv->video_format); +} + +static void +RADEONCopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w + ) +{ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +RADEONCopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w + ) +{ + CARD32 *dst = (CARD32*)dst1; + int i, j; + + dstPitch >>= 2; + w >>= 1; + + for(j = 0; j < h; j++) { + for(i = 0; i < w; i++) { + dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + dst += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + +static FBLinearPtr +RADEONAllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +) +{ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + RADEONTRACE(("RADEONAllocateMemory(%x,%d) called\n",linear,size)); + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 4, + PRIORITY_EXTREME); + + if(max_size < size) return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + } + + RADEONTRACE(("returning %x(%x)\n",new_linear,new_linear->offset)); + + return new_linear; +} + +static int +RADEONPutImage( + ScrnInfoPtr pScrn, + 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 +) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + INT32 xa, xb, ya, yb; + INT32 d_x,d_y,d_width,d_height; + int srcPitch = 0, srcPitch2 = 0; + int dstPitch = 0; + int offset,offset2 = 0,offset3 = 0,fboffset; + int top, left, npixels, nlines, size; + CARD32 video_format; + + RADEONTRACE(("RADEONPutImage called\n")); + + switch(id) { + case FOURCC_YV12: + case FOURCC_UYVY: + video_format=RADEON_SCALER_SOURCE_VYUY422; + break; + case FOURCC_YUY2: + video_format=RADEON_SCALER_SOURCE_YVYU422; + break; + default: + return BadValue; + } + + /* Clip */ + d_x=drw_x; + d_y=drw_y; + d_width=drw_w; + d_height=drw_h; + if(drw_x<0){ + drw_w+=drw_x; + drw_x=0; + } + if(drw_y<0){ + drw_h+=drw_y; + drw_y=0; + } + if(drw_x+drw_w>pScrn->pScreen->width){ + drw_w=pScrn->pScreen->width-drw_x; + } + if(drw_y+drw_h>pScrn->pScreen->height){ + drw_h=pScrn->pScreen->height-drw_y; + } + if((drw_w<=0)||(drw_h<=0)){ + /* this should not happen, + since we are outside of visible screen, + but just in case */ + return Success; + } + + xa = src_x; + xb = src_x + src_w; + ya = src_y; + yb = src_y + src_h; + + dstPitch = width*info->CurrentLayout.pixel_bytes; + srcPitch=width; + + switch(id) { + case FOURCC_YV12: + size = width * height * 2; /* 16bpp */ + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = width * height * 1.5; + break; + } + + if(!(pPriv->linear = RADEONAllocateMemory(pScrn, pPriv->linear,size))) + return BadAlloc; + + /* copy data */ + top = ya >> 16; + left = (xa >> 16) & ~1; + npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((yb + 0xffff) >> 16) - top; + srcPitch = (width << 1); + break; + } + nlines=src_h; + npixels=src_w; + if(npixels>width) npixels=width; + if(nlines>height) nlines=height; + + /* adjust source rectangle */ + src_x+=((drw_x-d_x)*src_w)/d_width; + src_y+=((drw_y-d_y)*src_h)/d_height; + + src_w=(src_w * drw_w)/d_width; + src_h=(src_h * drw_h)/d_height; + + offset=(src_x+src_y*width)*info->CurrentLayout.pixel_bytes; + fboffset=pPriv->linear->offset*info->CurrentLayout.pixel_bytes; + + if(!(INREG(RADEON_CRTC_STATUS)&2)){ + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"too fast"); + return Success; + } + + RADEONDisplayVideo(pScrn, width, height, + drw_x, drw_y, drw_x+drw_w, drw_y+drw_h, + src_w, src_h, drw_w, drw_h, fboffset); + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + + switch(id) { + case FOURCC_YV12: + RADEONCopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, info->FB+fboffset, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + RADEONCopyData(buf,info->FB+fboffset,srcPitch,dstPitch, + nlines,npixels); + break; + } + + pPriv->videoStatus = CLIENT_VIDEO_ON; + return Success; +} + +static int +RADEONQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +) +{ + int size, tmp; + RADEONTRACE(("RADEONQueryImageAtrributes called\n")); + + 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: + *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; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile index e460edc38..b52639771 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile @@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/13 1996/10/27 11:49:09 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.26 2000/10/23 12:10:10 alanh Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.27 2000/11/03 18:46:08 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -21,13 +21,13 @@ DEFINES = -DPSZ=8 INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC)/fbdevhw\ - -I$(XF86SRC)/vgafb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ - -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb -I$(SERVERSRC)/cfb \ - -I$(SERVERSRC)/mfb -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ - -I$(SERVERSRC)/Xext -I$(XINCLUDESRC) -I$(XF86SRC)/xaa \ - -I$(FONTINCSRC) -I$(XF86SRC)/ramdac -I$(XF86SRC)/rac \ - -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86SRC)/xf24_32bpp \ - -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xf8_16bpp -I$(XF86SRC)/int10 \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ + -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \ + -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/Xext \ + -I$(XINCLUDESRC) -I$(XF86SRC)/xaa -I$(FONTINCSRC) \ + -I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \ + -I$(XF86SRC)/i2c -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb \ + -I$(XF86SRC)/xf8_16bpp -I$(XF86SRC)/int10 \ -I$(XF86OSSRC)/vbe -I$(EXTINCSRC) -I$(SERVERSRC)/render #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c index 8cea2ce6f..d22accc44 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.97 2000/10/27 18:31:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.99 2000/11/03 22:05:46 tsi Exp $ */ /* * Copyright 1993 by Jon Block <block@frc.com> @@ -105,17 +105,7 @@ /* All drivers using the mi colormap manipulation need this */ #include "micmap.h" -/* Using fb so this is needed */ #include "fb.h" - -/* If using cfb, cfb.h is required. */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" #include "cfb8_16.h" @@ -136,6 +126,10 @@ /* Needed for replacement LoadPalette function for Gamma Correction */ #include "xf86cmap.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* Driver specific headers */ #include "ct_driver.h" @@ -564,8 +558,7 @@ typedef enum { OPTION_FP_CLOCK_32, OPTION_SET_MCLK, OPTION_ROTATE, - OPTION_NO_TMED, - OPTION_USE_FB + OPTION_NO_TMED } CHIPSOpts; static OptionInfoRec Chips655xxOptions[] = { @@ -592,7 +585,6 @@ static OptionInfoRec Chips655xxOptions[] = { { OPTION_FP_CLOCK_8, "FPClock8", OPTV_FREQ, {0}, FALSE }, { OPTION_FP_CLOCK_16, "FPClock16", OPTV_FREQ, {0}, FALSE }, { OPTION_FP_CLOCK_24, "FPClock24", OPTV_FREQ, {0}, FALSE }, - { OPTION_USE_FB, "UseFB", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -608,7 +600,6 @@ static OptionInfoRec ChipsWingineOptions[] = { { OPTION_SHOWCACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_USE_FB, "UseFB", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -638,7 +629,6 @@ static OptionInfoRec ChipsHiQVOptions[] = { { OPTION_FP_CLOCK_32, "FPClock32", OPTV_FREQ, {0}, FALSE }, { OPTION_SET_MCLK, "SetMclk", OPTV_FREQ, {0}, FALSE }, { OPTION_NO_TMED, "NoTMED", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_USE_FB, "UseFB", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -667,13 +657,8 @@ static const char *vgahwSymbols[] = { static const char *fbSymbols[] = { "xf1bppScreenInit", "xf4bppScreenInit", - "cfbScreenInit", - "cfb16ScreenInit", "cfb8_16ScreenInit", - "cfb24ScreenInit", - "cfb24_32ScreenInit", - "cfb32ScreenInit", - "fbScreenInit", + "fb_ScreenInit", NULL }; @@ -1118,13 +1103,6 @@ CHIPSPreInit(ScrnInfoPtr pScrn, int flags) else res = chipsPreInit655xx(pScrn, flags); - /* See whether the user wants to use the new framebuffer code */ - if (xf86ReturnOptValBool(cPtr->Options, OPTION_USE_FB, FALSE)) { - cPtr->Flags |= ChipsUseNewFB; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using \"New Framebuffer\"\n"); - } - if (cPtr->UseFullMMIO) chipsUnmapMem(pScrn); @@ -1205,69 +1183,40 @@ CHIPSPreInit(ScrnInfoPtr pScrn, int flags) /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: - mod = "xf1bpp"; - reqSym = "xf1bppScreenInit"; + if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf1bppScreenInit", NULL); break; case 4: - mod = "xf4bpp"; - reqSym = "xf4bppScreenInit"; + if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf4bppScreenInit", NULL); break; + case 16: + if (cPtr->Flags & ChipsOverlay8plus16) { + if (xf86LoadSubModule(pScrn, "xf8_16bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("cfb8_16bppScreenInit", NULL); + break; + } default: - if (cPtr->Flags & ChipsUseNewFB) - switch (pScrn->bitsPerPixel) { - case 16: - reqSym = "xf4bppScreenInit"; - if (cPtr->Flags & ChipsOverlay8plus16) { - mod = "xf8_16bpp"; - reqSym = "cfb8_16ScreenInit"; - break; - } else - reqSym = "fbScreenInit"; - /* fall through */ - case 8: - case 24: - case 32: - mod = "fb"; - break; - } - else - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - if (cPtr->Flags & ChipsOverlay8plus16) { - mod = "xf8_16bpp"; - reqSym = "cfb8_16ScreenInit"; - } else { - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - } - break; - case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - reqSym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - reqSym = "cfb24_32ScreenInit"; - } - break; - case 32: - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - break; - } - } - - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - CHIPSFreeRec(pScrn); - return FALSE; + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + break; } - - xf86LoaderReqSymbols(reqSym, NULL); - + if (cPtr->Flags & ChipsAccelSupport) { if (!xf86LoadSubModule(pScrn, "xaa")) { CHIPSFreeRec(pScrn); @@ -1378,17 +1327,8 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags) } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -2226,17 +2166,8 @@ chipsPreInitWingine(ScrnInfoPtr pScrn, int flags) } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -2700,17 +2631,8 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags) } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -3588,24 +3510,14 @@ CHIPSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (!miSetVisualTypes(8, PseudoColorMask | GrayScaleMask, pScrn->rgbBits, PseudoColor)) return FALSE; - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - TrueColor)) - return FALSE; - } else if ((pScrn->depth > 8) && (!(cPtr->Flags & ChipsGammaSupport))) { - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. To deal with this, call - * miSetVisualTypes for each visual supported. - */ - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; } + ErrorF("bla\n"); + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -3643,77 +3555,24 @@ CHIPSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->xDpi, pScrn->yDpi, displayWidth); break; + case 16: + if (cPtr->Flags & ChipsOverlay8plus16) { + ret = cfb8_16ScreenInit(pScreen, (unsigned char *)FBStart + + cPtr->FbOffset16, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth, displayWidth); + break; + } default: - if (cPtr->Flags & ChipsUseNewFB) - switch (pScrn->bitsPerPixel) { - case 16: - if (cPtr->Flags & ChipsOverlay8plus16) { - ret = cfb8_16ScreenInit(pScreen, (unsigned char *)FBStart - + cPtr->FbOffset16, FBStart, width, - height, pScrn->xDpi, pScrn->yDpi, - displayWidth, displayWidth); - break; - } - case 8: - case 24: - case 32: - ret = fbScreenInit(pScreen, FBStart, + ret = fbScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth,pScrn->bitsPerPixel); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in CHIPSScreenInit\n", - pScrn->bitsPerPixel); - ret = FALSE; - break; - } - else - switch (pScrn->bitsPerPixel) { - case 8: - ret = cfbScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 16: - if (cPtr->Flags & ChipsOverlay8plus16) - ret = cfb8_16ScreenInit(pScreen, (unsigned char *)FBStart - + cPtr->FbOffset16, FBStart, width, - height, pScrn->xDpi, pScrn->yDpi, - displayWidth, displayWidth); - else - ret = cfb16ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 32: - ret = cfb32ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in CHIPSScreenInit\n", - pScrn->bitsPerPixel); - ret = FALSE; - break; - } +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif + break; } if (!ret) @@ -4187,6 +4046,9 @@ chipsDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, CHIPSPtr cPtr = CHIPSPTR(pScrn); unsigned char dpmsreg, seqreg, lcdoff, tmp; + if (!pScrn->vtSema) + return; + xf86EnableAccess(pScrn); switch (PowerManagementMode) { case DPMSModeOn: @@ -6271,7 +6133,7 @@ chipsRestoreExtendedRegs(ScrnInfoPtr pScrn, CHIPSRegPtr Regs) if ((i == 0x03) && (cPtr->Chipset != CHIPS_CT69030)) { /* restore the non clock bits */ tmp = cPtr->readFR(cPtr, 0x03); - cPtr->writeFR(cPtr, 0x01, ((Regs->FR[0x03] & 0xC3) | + cPtr->writeFR(cPtr, 0x03, ((Regs->FR[0x03] & 0xC3) | (tmp & ~0xC3))); continue; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c index 10f2a7c13..fa65fcdc3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c,v 1.9 2000/10/27 22:30:29 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c,v 1.13 2000/11/06 02:56:03 robin Exp $ */ /* All drivers should typically include these */ @@ -41,6 +41,9 @@ /* Drivers that need to access the PCI config space directly need this */ #include "xf86Pci.h" +/* vgaHW module is only used to save/restore fonts by this driver */ +#include "vgaHW.h" + /* All drivers initialising the SW cursor need this */ #include "mipointer.h" @@ -171,6 +174,18 @@ XF86ModuleData i128ModuleData = { &i128VersRec, i128Setup, NULL }; * LoaderRefSymLists() function in the module specific Setup() function. */ +static const char *vgahwSymbols[] = { + "vgaHWFreeHWRec", + "vgaHWGetHWRec", + "vgaHWGetIOBase", + "vgaHWLock", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWSave", + "vgaHWUnlock", + NULL +}; + static const char *fbSymbols[] = { "fbScreenInit", NULL @@ -267,6 +282,7 @@ i128Setup(pointer module, pointer opts, int *errmaj, int *errmin) i2cSymbols, vbeSymbols, int10Symbols, + vgahwSymbols, NULL); /* @@ -545,6 +561,20 @@ I128PreInit(ScrnInfoPtr pScrn, int flags) pI128->Primary = xf86IsPrimaryPci(pI128->PciInfo); + /* The vgahw module should be allocated here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) + return FALSE; + + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* + * Allocate a vgaHWRec + */ + if (!vgaHWGetHWRec(pScrn)) + return FALSE; + + vgaHWGetIOBase(VGAHWPTR(pScrn)); + /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; @@ -793,8 +823,7 @@ I128PreInit(ScrnInfoPtr pScrn, int flags) if (!pI128->Primary) I128SoftReset(pScrn); - if ((pI128->Chipset == PCI_CHIP_I128_T2R) || - (pI128->Chipset == PCI_CHIP_I128_T2R4)) { + if (pI128->Chipset != PCI_CHIP_I128) { pI128->ddc1Read = NULL /*I128DDC1Read*/; pI128->i2cInit = I128I2CInit; } @@ -1074,8 +1103,8 @@ I128PreInit(ScrnInfoPtr pScrn, int flags) linePitches, minPitch, maxPitch, pitchAlignment * pI128->bitsPerPixel, 128, 2048, - pScrn->virtualX, - pScrn->virtualY, + pScrn->display->virtualX, + pScrn->display->virtualY, pI128->MemorySize, LOOKUP_BEST_REFRESH); @@ -1324,9 +1353,7 @@ I128MapMem(ScrnInfoPtr pScrn) static Bool I128UnmapMem(ScrnInfoPtr pScrn) { - I128Ptr pI128; - - pI128 = I128PTR(pScrn); + I128Ptr pI128 = I128PTR(pScrn); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Unmapping memory\n"); @@ -1358,6 +1385,12 @@ I128UnmapMem(ScrnInfoPtr pScrn) static void I128Save(ScrnInfoPtr pScrn) { + I128Ptr pI128 = I128PTR(pScrn); + vgaHWPtr vgaHWP = VGAHWPTR(pScrn); + + if (pI128->Primary) + vgaHWSave(pScrn, &vgaHWP->SavedReg, VGA_SR_ALL); + I128SaveState(pScrn); } @@ -1367,7 +1400,16 @@ I128Save(ScrnInfoPtr pScrn) static void I128Restore(ScrnInfoPtr pScrn) { + I128Ptr pI128 = I128PTR(pScrn); + vgaHWPtr vgaHWP = VGAHWPTR(pScrn); + I128RestoreState(pScrn); + + if (pI128->Primary) { + vgaHWProtect(pScrn, TRUE); + vgaHWRestore(pScrn, &vgaHWP->SavedReg, VGA_SR_ALL); + vgaHWProtect(pScrn, FALSE); + } } /* Usually mandatory */ @@ -1678,6 +1720,9 @@ I128FreeScreen(int scrnIndex, int flags) * This only gets called when a screen is being deleted. It does not * get called routinely at the end of a server generation. */ + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(xf86Screens[scrnIndex]); + I128FreeRec(xf86Screens[scrnIndex]); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c index 27ad796cc..46b4abafd 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c,v 1.4 2000/10/24 02:00:06 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c,v 1.6 2000/11/01 23:33:06 robin Exp $ */ /* * Copyright 1997-2000 by Robin Cutshaw <robin@XFree86.Org> @@ -104,7 +104,7 @@ I128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h) #if 0 if (pI128->Debug) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BB %d,%d %d,%d %d,%d\n", x1, y1, x2, y2, w, h); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BB %d,%d %d,%d %d,%d 0x%x/0x%x\n", x1, y1, x2, y2, w, h, pI128->cmd); #endif ENG_PIPELINE_READY(); @@ -428,7 +428,7 @@ I128AccelInit(ScreenPtr pScreen) infoPtr->Sync = I128EngineDone; /* screen to screen copy */ - infoPtr->ScreenToScreenCopyFlags = 0; + infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; if (pI128->Chipset == PCI_CHIP_I128_T2R) infoPtr->ScreenToScreenCopyFlags |= ONLY_LEFT_TO_RIGHT_BITBLT; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c index f8c8a804e..125e66f5f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c,v 1.4 2000/10/25 00:09:17 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c,v 1.5 2000/11/03 00:50:53 robin Exp $ */ /* * Copyright 1995-2000 by Robin Cutshaw <robin@XFree86.Org> * Copyright 1998 by Number Nine Visual Technology, Inc. @@ -39,8 +39,6 @@ void I128SavePalette(I128Ptr pI128); void I128RestorePalette(I128Ptr pI128); -#define VGA_SAVE_COUNT 4096*1024 - void I128SaveState(ScrnInfoPtr pScrn) @@ -59,6 +57,7 @@ I128SaveState(ScrnInfoPtr pScrn) } /* iobase is filled in during the device probe (as well as config 1&2)*/ + if ((pI128->io.id&0x7) > 0) { iR->vga_ctl = inl(iR->iobase + 0x30); } @@ -299,15 +298,10 @@ I128RestoreState(ScrnInfoPtr pScrn) } /* iobase is filled in during the device probe (as well as config 1&2)*/ + if (((pI128->io.id&0x7) > 0) || (pI128->Chipset == PCI_CHIP_I128_T2R) || (pI128->Chipset == PCI_CHIP_I128_T2R4)) { - int i; - unsigned char *vidmem = (unsigned char *)pI128->mem.mw0_ad; - - if (pI128->Primary) - for (i=0; i<VGA_SAVE_COUNT; i++) - vidmem[i] = pI128->vgamem[i]; outl(iR->iobase + 0x30, iR->vga_ctl); } @@ -508,18 +502,6 @@ I128Init(ScrnInfoPtr pScrn, DisplayModePtr mode) usleep(5000); outl(iR->iobase + 0x24, 0xA1089030); } - - if (!pI128->FontsSaved && pI128->Primary) { - int i; - unsigned char *vidmem = - (unsigned char *)pI128->mem.mw0_ad; - - pI128->vgamem = xnfalloc(VGA_SAVE_COUNT); - for (i=0; i<VGA_SAVE_COUNT; i++) - pI128->vgamem[i] = vidmem[i]; - pI128->FontsSaved = TRUE; - } - } ret = pI128->ProgramDAC(pScrn, mode); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c index 5ec08696f..0979a7281 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c,v 1.54 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c,v 1.55 2000/11/02 02:51:19 dawes Exp $ */ /* * Copyright 1994 by Robin Cutshaw <robin@XFree86.org> * @@ -50,12 +50,10 @@ #include "mga_bios.h" #include "mga_reg.h" #include "mga.h" +#include "mga_macros.h" #include "xf86DDC.h" -/* Set to 1 if you want to set MCLK from XF86Config - AT YOUR OWN RISK! */ -#define MCLK_FROM_XCONFIG 0 - /* * Only change these bits in the Option register. Make sure that the * vgaioen bit is never in this mask because it is controlled elsewhere @@ -269,7 +267,6 @@ MGATi3026CalcClock ( return f_pll; } -#ifndef USEMGAHAL /* * MGATi3026SetMCLK - Set the memory clock (MCLK) PLL. * @@ -353,7 +350,6 @@ MGATi3026SetMCLK( ScrnInfoPtr pScrn, long f_out ) ; } } -#endif /* * MGATi3026SetPCLK - Set the pixel (PCLK) and loop (LCLK) clocks. @@ -505,9 +501,7 @@ MGA3026Init(ScrnInfoPtr pScrn, DisplayModePtr mode) int i, BppShift, index_1d = 0; const unsigned char* initDAC; MGAPtr pMga = MGAPTR(pScrn); -#ifndef USEMGAHAL MGARamdacPtr MGAdac = &pMga->Dac; -#endif MGAFBLayout *pLayout = &pMga->CurrentLayout; MGARegPtr pReg = &pMga->ModeReg; vgaRegPtr pVga = &VGAHWPTR(pScrn)->ModeReg; @@ -720,9 +714,7 @@ MGA3026Init(ScrnInfoPtr pScrn, DisplayModePtr mode) but that's no big deal since we will Restore right after this function */ -#ifndef USEMGAHAL - MGATi3026SetMCLK( pScrn, MGAdac->MemoryClock ); -#endif + MGA_NOT_HAL(MGATi3026SetMCLK(pScrn, MGAdac->MemoryClock)); #ifdef DEBUG ErrorF("%6ld: %02X %02X %02X %02X %02X %02X %08lX\n", mode->Clock, @@ -760,7 +752,7 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, OPTION_MASK, mgaReg->Option); -#ifndef USEMGAHAL + MGA_NOT_HAL( /* select pixel clock PLL as clock source */ outTi3026(TVP3026_CLK_SEL, 0, mgaReg->DacRegs[3]); @@ -768,7 +760,7 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, outTi3026(TVP3026_PLL_ADDR, 0, 0x2A); outTi3026(TVP3026_LOAD_CLK_DATA, 0, 0); outTi3026(TVP3026_PIX_CLK_DATA, 0, 0); -#endif + ); /* MGA_NOT_HAL */ /* * This function handles restoring the generic VGA registers. @@ -782,7 +774,7 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, * goes here. */ -#ifndef USEMGAHAL + MGA_NOT_HAL( /* program pixel clock PLL */ outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 0; i < 3; i++) @@ -796,20 +788,20 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, /* set Q divider for loop clock PLL */ outTi3026(TVP3026_MCLK_CTL, 0, mgaReg->DacRegs[18]); -#endif + ); /* MGA_NOT_HAL */ /* program loop PLL */ outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 3; i < 6; i++) outTi3026(TVP3026_LOAD_CLK_DATA, 0, mgaReg->DacClk[i]); -#ifndef USEMGAHAL + MGA_NOT_HAL( if ((vgaReg->MiscOutReg & 0x08) && ((mgaReg->DacClk[3] & 0xC0) == 0xC0) ) { /* poll until loop PLL LOCK bit is set */ outTi3026(TVP3026_PLL_ADDR, 0, 0x3F); while ( ! (inTi3026(TVP3026_LOAD_CLK_DATA) & 0x40) ); } -#endif + ); /* MGA_NOT_HAL */ /* * restore other DAC registers @@ -862,7 +854,7 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, mgaReg->ExtVga[i] = INREG8(0x1FDF); } -#ifndef USEMGAHAL + MGA_NOT_HAL( outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 0; i < 3; i++) outTi3026(TVP3026_PIX_CLK_DATA, 0, mgaReg->DacClk[i] = @@ -872,7 +864,7 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, for (i = 3; i < 6; i++) outTi3026(TVP3026_LOAD_CLK_DATA, 0, mgaReg->DacClk[i] = inTi3026(TVP3026_LOAD_CLK_DATA)); -#endif + ); /* MGA_NOT_HAL */ for (i = 0; i < DACREGSIZE; i++) mgaReg->DacRegs[i] = inTi3026(MGADACregs[i]); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c index 620b2c7d0..5efb33ab6 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c @@ -2,7 +2,7 @@ * MGA-1064, MGA-G100, MGA-G200, MGA-G400 RAMDAC driver */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.40 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.41 2000/11/02 02:51:19 dawes Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -25,6 +25,7 @@ #include "mga_bios.h" #include "mga_reg.h" #include "mga.h" +#include "mga_macros.h" #include "xf86DDC.h" @@ -82,7 +83,6 @@ static Bool MGAGInit(ScrnInfoPtr, DisplayModePtr); static void MGAGLoadPalette(ScrnInfoPtr, int, int*, LOCO*, VisualPtr); static Bool MGAG_i2cInit(ScrnInfoPtr pScrn); -#ifndef USEMGAHAL /* * MGAGCalcClock - Calculate the PLL settings (m, n, p, s). * @@ -245,7 +245,6 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out ) pReg->DacRegs[ MGA1064_PIX_PLLC_N ] = n & 0x7F; pReg->DacRegs[ MGA1064_PIX_PLLC_P ] = (p & 0x07) | ((s & 0x03) << 3); } -#endif /* * MGAGInit @@ -253,7 +252,6 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out ) static Bool MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { -#ifndef USEMGAHAL /* * initial values of the DAC registers */ @@ -271,7 +269,6 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) }; int i, weight555 = FALSE; -#endif int hd, hs, he, ht, vd, vs, ve, vt, wd; int BppShift; MGAPtr pMga; @@ -286,7 +283,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) BppShift = pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]; -#ifndef USEMGAHAL + MGA_NOT_HAL( /* Allocate the DacRegs space if not done already */ if (pReg->DacRegs == NULL) { pReg->DacRegs = xnfcalloc(DACREGSIZE, 1); @@ -294,6 +291,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) for (i = 0; i < DACREGSIZE; i++) { pReg->DacRegs[i] = initDAC[i]; } + ); /* MGA_NOT_HAL */ switch(pMga->Chipset) { @@ -336,6 +334,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) } pReg->Option2 = 0x0000007; break; +#ifndef USEMGAHAL case PCI_CHIP_MGAG400: if(pMga->Dac.maxPixelClock == 360000) { /* G400 MAX */ if(pMga->OverclockMem) { @@ -394,8 +393,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) else pReg->Option = 0x4049cd21; break; +#endif } + MGA_NOT_HAL( /* must always have the pci retries on but rely on polling to keep them from occuring */ pReg->Option &= ~0x20000000; @@ -427,7 +428,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) default: FatalError("MGA: unsupported depth\n"); } -#endif + ); /* MGA_NOT_HAL */ /* * This will initialize all of the generic VGA registers. @@ -508,29 +509,23 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pVga->CRTC[21] = vd & 0xFF; pVga->CRTC[22] = (vt + 1) & 0xFF; -#ifndef USEMGAHAL - pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_LOW ] = - pMga->FbCursorOffset >> 10; - pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_HI ] = - pMga->FbCursorOffset >> 18; -#endif + MGA_NOT_HAL(pReg->DacRegs[MGA1064_CURSOR_BASE_ADR_LOW] = pMga->FbCursorOffset >> 10); + MGA_NOT_HAL(pReg->DacRegs[MGA1064_CURSOR_BASE_ADR_HI] = pMga->FbCursorOffset >> 18); if (pMga->SyncOnGreen) { -#ifndef USEMGAHAL - pReg->DacRegs[ MGA1064_GEN_CTL ] &= ~0x20; -#endif + MGA_NOT_HAL(pReg->DacRegs[MGA1064_GEN_CTL] &= ~0x20); pReg->ExtVga[3] |= 0x40; } /* select external clock */ pVga->MiscOutReg |= 0x0C; -#ifndef USEMGAHAL + MGA_NOT_HAL( if (mode->Flags & V_DBLSCAN) pVga->CRTC[9] |= 0x80; - MGAGSetPCLK( pScrn, mode->Clock ); -#endif + MGAGSetPCLK(pScrn, mode->Clock); + ); /* MGA_NOT_HAL */ /* This disables the VGA memory aperture */ pVga->MiscOutReg &= ~0x02; @@ -639,9 +634,9 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, { int i; MGAPtr pMga = MGAPTR(pScrn); -#ifndef USEMGAHAL CARD32 optionMask; + MGA_NOT_HAL( /* * Code is needed to get things back to bank zero. */ @@ -675,7 +670,8 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, if (pMga->Chipset == PCI_CHIP_MGAG400) pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK, mgaReg->Option3); -#endif + ); /* MGA_NOT_HAL */ + /* restore CRTCEXT regs */ for (i = 0; i < 6; i++) OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i); @@ -724,12 +720,12 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, MGAPtr pMga = MGAPTR(pScrn); if(pMga->SecondCrtc == TRUE) return; -#ifndef USEMGAHAL + MGA_NOT_HAL( /* Allocate the DacRegs space if not done already */ if (mgaReg->DacRegs == NULL) { mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1); } -#endif + ); /* MGA_NOT_HAL */ /* * Code is needed to get back to bank zero. @@ -743,7 +739,7 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0)); MGAGSavePalette(pScrn, vgaReg->DAC); -#ifndef USEMGAHAL + MGA_NOT_HAL( /* * The port I/O code necessary to read in the extended registers. */ @@ -755,7 +751,7 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2); if (pMga->Chipset == PCI_CHIP_MGAG400) mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3); -#endif + ); /* MGA_NOT_HAL */ for (i = 0; i < 6; i++) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c index 947fb1565..b8d46ade3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.9 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.10 2000/11/02 19:10:51 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -101,12 +101,10 @@ Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size) init.chipset = MGA_CARD_TYPE_G400; break; case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: init.chipset = MGA_CARD_TYPE_G200; break; - case PCI_CHIP_MGAG200_PCI: default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] Direct rendering not supported on this card/chipset\n"); return FALSE; } @@ -350,6 +348,18 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) int init_offset; int i; + switch(pMGA->Chipset) { + case PCI_CHIP_MGAG400: + case PCI_CHIP_MGAG200: +#if 0 + case PCI_CHIP_MGAG200_PCI: +#endif + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Direct rendering only supported with G200/G400 AGP\n"); + return FALSE; + } + /* Check that the GLX, DRI, and DRM modules have been loaded by testing * for canonical symbols in each module. */ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; @@ -373,15 +383,12 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) } } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] bpp: %d depth: %d\n", pScrn->bitsPerPixel, - pScrn->depth); - + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] bpp: %d depth: %d\n", pScrn->bitsPerPixel, pScrn->depth); if ((pScrn->bitsPerPixel / 8) != 2 && (pScrn->bitsPerPixel / 8) != 4) { xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Direct Rendering only supported in 16 and 32 bpp modes\n"); + "[drm] Direct rendering only supported in 16 and 32 bpp modes\n"); return FALSE; } @@ -607,12 +614,10 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) pMGADRI->chipset = MGA_CARD_TYPE_G400; break; case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: pMGADRI->chipset = MGA_CARD_TYPE_G200; break; - case PCI_CHIP_MGAG200_PCI: default: - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Direct rendering not supported on this card/chipset\n"); return FALSE; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c index 243c27e82..685721aaf 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c @@ -43,7 +43,7 @@ * Fixed 32bpp hires 8MB horizontal line glitch at middle right */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.173 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.178 2000/11/03 18:46:10 eich Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -173,8 +173,8 @@ static SymTabRec MGAChipsets[] = { { PCI_CHIP_MGA1064, "mga1064sg" }, { PCI_CHIP_MGA2164, "mga2164w" }, { PCI_CHIP_MGA2164_AGP, "mga2164w AGP" }, - { PCI_CHIP_MGAG100_PCI, "mgag100" }, { PCI_CHIP_MGAG100, "mgag100" }, + { PCI_CHIP_MGAG100_PCI, "mgag100 PCI" }, { PCI_CHIP_MGAG200, "mgag200" }, { PCI_CHIP_MGAG200_PCI, "mgag200 PCI" }, { PCI_CHIP_MGAG400, "mgag400" }, @@ -842,7 +842,6 @@ MGASoftReset(ScrnInfoPtr pScrn) { MGAPtr pMga = MGAPTR(pScrn); - ErrorF("SoftReset called!!!\n"); pMga->FbMapSize = 8192 * 1024; MGAMapMem(pScrn); @@ -1138,11 +1137,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) MGAEntPtr pMgaEnt = NULL; #ifdef USEMGAHAL MGAMODEINFO mgaModeInfo = {0}; - ULONG ulBOARDHANDLESize; - UCHAR ucMgaBase2; -#if 0 - ULONG ulOrgFBuffer; -#endif Bool digital = FALSE; Bool tv = FALSE; #endif @@ -1907,16 +1901,15 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->minClock = pMga->MinClock; clockRanges->maxClock = pMga->MaxClock; clockRanges->clockIndex = -1; /* programmable */ + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; #ifdef USEMGAHAL - clockRanges->interlaceAllowed = FALSE; - clockRanges->doubleScanAllowed = FALSE; -#else + MGA_HAL(clockRanges->interlaceAllowed = FALSE); + MGA_HAL(clockRanges->doubleScanAllowed = FALSE); +#endif if (pMga->SecondCrtc == TRUE) clockRanges->interlaceAllowed = FALSE; - else - clockRanges->interlaceAllowed = TRUE; - clockRanges->doubleScanAllowed = TRUE; -#endif + clockRanges->ClockMulFactor = 1; clockRanges->ClockDivFactor = 1; @@ -2010,37 +2003,18 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } #ifdef USEMGAHAL + MGA_HAL( if(pMga->SecondCrtc == FALSE) { - ulBOARDHANDLESize = MGAGetBOARDHANDLESize(); - pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + ulBOARDHANDLESize); + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); - /* Fill the client part */ pMga->pClientStruct->pMga = (MGAPtr) pMga; - - /* Determine the Frame buffer limit size */ - if((pMga->Chipset == PCI_CHIP_MGA1064 && pMga->ChipRev < 3) || - (pMga->Chipset == PCI_CHIP_MGA2064)) { - ucMgaBase2 = 0x14; - } else { - ucMgaBase2 = 0x10; - } -#if 0 - /* - * This is bad for cards where there is less physical memory than - * the PCI map size. - */ - ulOrgFBuffer = pciReadLong(pMga->PciTag,ucMgaBase2); - pciWriteLong(pMga->PciTag,ucMgaBase2,0xffffffff); - pMga->FbMapSize = pciReadLong(pMga->PciTag,ucMgaBase2); - pciWriteLong(pMga->PciTag,ucMgaBase2,ulOrgFBuffer); - pMga->FbMapSize = ~(pMga->FbMapSize & 0xfffffff0) + 1; -#endif - /* Open the matrox low level library */ + MGAMapMem(pScrn); MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); MGAUnmapMem(pScrn); pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + /* copy the board handles */ if(xf86IsEntityShared(pScrn->entityList[0])) { pMgaEnt->pClientStruct = pMga->pClientStruct; @@ -2048,13 +2022,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; } mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1; -#if 1 mgaModeInfo.ulDispWidth = pScrn->virtualX; mgaModeInfo.ulDispHeight = pScrn->virtualY; -#else - mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; - mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; -#endif mgaModeInfo.ulDeskWidth = pScrn->virtualX; mgaModeInfo.ulDeskHeight = pScrn->virtualY; mgaModeInfo.ulBpp = pScrn->bitsPerPixel; @@ -2070,13 +2039,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 | MGAMODEINFO_SECOND_CRTC; } -#if 1 mgaModeInfo.ulDispWidth = pScrn->virtualX; mgaModeInfo.ulDispHeight = pScrn->virtualY; -#else - mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; - mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; -#endif mgaModeInfo.ulDeskWidth = pScrn->virtualX; mgaModeInfo.ulDeskHeight = pScrn->virtualY; mgaModeInfo.ulBpp = pScrn->bitsPerPixel; @@ -2090,8 +2054,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) "MGAValidateMode from HALlib found the mode to be invalid\n"); return FALSE; } - pScrn->displayWidth = mgaModeInfo.ulFBPitch; + ); /* MGA_HAL */ #endif /* @@ -2103,10 +2067,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * are not pre-initialised at all. */ #ifdef USEMGAHAL - xf86SetCrtcForModes(pScrn, 0); + MGA_HAL(xf86SetCrtcForModes(pScrn, 0)); + MGA_NOT_HAL(xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V)); #else - xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); #endif + /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -2269,6 +2235,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24; pMga->CurrentLayout.mode = pScrn->currentMode; #ifdef USEMGAHAL + MGA_HAL( /* Close the library after preinit */ /* This needs to only happen after this board has completed preinit * both times @@ -2302,6 +2269,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) if (pMga->pMgaHwInfo) xfree(pMga->pMgaHwInfo); } + ); /* MGA_HAL */ #endif xf86SetPrimInitDone(pScrn->entityList[0]); @@ -2451,12 +2419,9 @@ MGASave(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; -#ifdef USEMGAHAL if(pMga->SecondCrtc == TRUE) return; - - if(pMga->pBoard != NULL) { - MGASaveVgaState(pMga->pBoard); - } +#ifdef USEMGAHAL + MGA_HAL(if (pMga->pBoard != NULL) MGASaveVgaState(pMga->pBoard)); #endif /* Only save text mode fonts/text for the primary card */ @@ -2469,8 +2434,8 @@ static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode) { const char *s; MGAPtr pMga = MGAPTR(pScrn); + pMga->pMgaModeInfo = (LPMGAMODEINFO) xalloc (sizeof(MGAMODEINFO)); - pMga->pMgaModeInfo->flOutput = 0; pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay; pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay; @@ -2568,6 +2533,7 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) mgaReg = &pMga->ModeReg; #ifdef USEMGAHAL + MGA_HAL( FillModeInfoStruct(pScrn,mode); if(pMga->SecondCrtc == TRUE) { @@ -2604,6 +2570,7 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MGAValidateVideoParameters from HALlib found the mode to be invalid. Error: %lx\n", status); return FALSE; } + ); /* MGA_HAL */ #endif #ifdef XF86DRI @@ -2613,21 +2580,25 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #endif #ifdef USEMGAHAL + MGA_HAL( /* Initialize the board */ if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MGASetMode returned an error. Make sure to validate the mode before.\n"); return FALSE; } + ); /* MGA_HAL */ #define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val) -#define outMGAdac(reg, val) \ - (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) +#define outMGAdac(reg, val) (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) + MGA_HAL( if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) { outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW, pMga->FbCursorOffset >> 10); outMGAdac(MGA1064_CURSOR_BASE_ADR_HI, pMga->FbCursorOffset >> 18); } + ); /* MGA_HAL */ + MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE)); #else (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); #endif @@ -2673,10 +2644,12 @@ MGARestore(ScrnInfoPtr pScrn) vgaHWProtect(pScrn, TRUE); if (pMga->Primary) { #ifdef USEMGAHAL + MGA_HAL( if(pMga->pBoard != NULL) { MGASetVgaMode(pMga->pBoard); MGARestoreVgaState(pMga->pBoard); } + ); /* MGA_HAL */ #endif (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE); } else { @@ -2699,7 +2672,7 @@ MGACrtc2FillStrip(ScrnInfoPtr pScrn) } else { xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); pMga->RestoreAccelState(pScrn); - pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF); + pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0x00000000); pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0, pScrn->displayWidth - pScrn->virtualX, pScrn->virtualY); @@ -2751,13 +2724,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pMgaEnt = pPriv->ptr; pMgaEnt->refCount++; #ifdef USEMGAHAL + MGA_HAL( if(pMgaEnt->refCount == 1) { - pMga->pBoard = - (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + - MGAGetBOARDHANDLESize()); + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); - /* Fill the client part */ pMga->pClientStruct->pMga = (MGAPtr) pMga; + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); @@ -2779,18 +2751,19 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pMga->pBoard = pMgaEnt->pBoard; pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo; } + ); /* MGA_HAL */ #endif } else { #ifdef USEMGAHAL - pMga->pBoard = - (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + - MGAGetBOARDHANDLESize()); + MGA_HAL( + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); - /* Fill the client part */ pMga->pClientStruct->pMga = (MGAPtr) pMga; + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + ); /* MGA_HAL */ #endif } @@ -3046,8 +3019,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScreen->SaveScreen = MGASaveScreenCrtc2; } else { pScreen->SaveScreen = MGASaveScreen; - MGAInitVideo(pScreen); } + MGAInitVideo(pScreen); /* Wrap the current CloseScreen function */ pMga->CloseScreen = pScreen->CloseScreen; @@ -3283,6 +3256,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) } #ifdef USEMGAHAL + MGA_HAL( if(xf86IsEntityShared(pScrn->entityList[0])) { if(pMgaEnt->refCount == 0) { /* Both boards have closed there screen */ @@ -3309,6 +3283,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) if (pMga->pMgaHwInfo) xfree(pMga->pMgaHwInfo); } + ); /* MGA_HAL */ #endif if (pMga->AccelInfoRec) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h index c2a47eaf1..4aa48527b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.16 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.17 2000/11/02 02:51:20 dawes Exp $ */ #ifndef _MGA_MACROS_H_ #define _MGA_MACROS_H_ @@ -17,7 +17,7 @@ #define REPLICATE(r) /* */ #endif -#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) +#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) #ifdef XF86DRI #define MGA_SYNC_XTAG 0x275f4200 @@ -49,8 +49,7 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ ( MAKEDMAINDEX(one) | \ (MAKEDMAINDEX(two) << 8) | \ (MAKEDMAINDEX(three) << 16) | \ - (MAKEDMAINDEX(four) << 24) ) - + (MAKEDMAINDEX(four) << 24) ) #if PSZ == 24 #define SET_PLANEMASK(p) /**/ @@ -63,7 +62,6 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ } #endif - #define SET_FOREGROUND(c) \ if((c) != pMga->FgColor) { \ pMga->FgColor = (c); \ @@ -93,5 +91,20 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ #define CHECK_DMA_QUIESCENT(pMGA, pScrn) #endif +#ifdef USEMGAHAL +#define HAL_CHIPSETS ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || \ + (pMga->Chipset == PCI_CHIP_MGAG200) || \ + (pMga->Chipset == PCI_CHIP_MGAG400)) +#define MGA_HAL(x) { \ + MGAPtr pMga = MGAPTR(pScrn); \ + if (HAL_CHIPSETS) { x; } \ +} +#define MGA_NOT_HAL(x) { \ + MGAPtr pMga = MGAPTR(pScrn); \ + if (!HAL_CHIPSETS) { x; } \ +} +#else +#define MGA_NOT_HAL(x) { x; } +#endif #endif /* _MGA_MACROS_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h index 12538fd3c..247acbdff 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h @@ -2,7 +2,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.12 2000/06/09 22:43:38 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.13 2000/11/01 21:55:09 mvojkovi Exp $ */ @@ -425,8 +425,10 @@ #define MGAREG_TEXTRANS 0x2c34 #define MGAREG_TEXTRANSHIGH 0x2c38 #define MGAREG_TEXFILTER 0x2c58 +#define MGAREG_ALPHASTART 0x2c70 +#define MGAREG_ALPHAXINC 0x2c74 +#define MGAREG_ALPHAYINC 0x2c78 #define MGAREG_ALPHACTRL 0x2c7c - #define MGAREG_DWGSYNC 0x2c4c diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c index d8dbe698e..2ffcc8788 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.78 2000/10/27 18:31:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.80 2000/11/03 18:46:11 eich Exp $ */ /* All drivers should typically include these */ @@ -153,6 +153,23 @@ MGASetupForCPUToScreenAlphaTexture ( ); extern Bool +MGASetupForCPUToScreenAlphaTextureFaked ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +); + + +extern Bool MGASetupForCPUToScreenTexture ( ScrnInfoPtr pScrn, int op, @@ -259,7 +276,7 @@ GetPowerOfTwo(int w) static int tex_padw, tex_padh; Bool -MGASetupForCPUToScreenAlphaTexture ( +MGASetupForCPUToScreenAlphaTextureFaked ( ScrnInfoPtr pScrn, int op, CARD16 red, @@ -339,6 +356,106 @@ MGASetupForCPUToScreenAlphaTexture ( } Bool +MGASetupForCPUToScreenAlphaTexture ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + CARD8 *dst; + MGAPtr pMga = MGAPTR(pScrn); + + if(op != PictOpOver) /* only one tested */ + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = (pitch * height) >> 1; + if(pScrn->bitsPerPixel == 32) + sizeNeeded >>= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + i = height; + dst = pMga->FbStart + offset; + while(i--) { + memcpy(dst, alphaPtr, width); + dst += pitch; + alphaPtr += alphaPitch; + } + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + + WAITFIFO(12); + OUTREG(MGAREG_DR4, red << 7); /* red start */ + OUTREG(MGAREG_DR6, 0); + OUTREG(MGAREG_DR7, 0); + OUTREG(MGAREG_DR8, green << 7); /* green start */ + OUTREG(MGAREG_DR10, 0); + OUTREG(MGAREG_DR11, 0); + OUTREG(MGAREG_DR12, blue << 7); /* blue start */ + OUTREG(MGAREG_DR14, 0); + OUTREG(MGAREG_DR15, 0); + OUTREG(MGAREG_ALPHASTART, alpha << 7); /* alpha start */ + OUTREG(MGAREG_ALPHAXINC, 0); + OUTREG(MGAREG_ALPHAYINC, 0); + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, 0x3A000107 | ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, 0x00000014); + OUTREG(MGAREG_DWGCTL, 0x000c7076); + OUTREG(MGAREG_TEXFILTER, 0x01e00020); + OUTREG(MGAREG_ALPHACTRL, 0x02000151); + + return TRUE; +} + + +Bool MGASetupForCPUToScreenTexture ( ScrnInfoPtr pScrn, int op, @@ -731,12 +848,18 @@ MGANAME(AccelInit)(ScreenPtr pScreen) #ifdef RENDER if(doRender && ((pScrn->bitsPerPixel == 32) || (pScrn->bitsPerPixel == 16))) { - infoPtr->SetupForCPUToScreenAlphaTexture = + if(pMga->Chipset == PCI_CHIP_MGAG400) { + infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE; + infoPtr->SetupForCPUToScreenAlphaTexture = MGASetupForCPUToScreenAlphaTexture; + } else { + infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | + XAA_RENDER_NO_SRC_ALPHA; + infoPtr->SetupForCPUToScreenAlphaTexture = + MGASetupForCPUToScreenAlphaTextureFaked; + } infoPtr->SubsequentCPUToScreenAlphaTexture = MGASubsequentCPUToScreenTexture; - infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | - XAA_RENDER_NO_SRC_ALPHA; infoPtr->CPUToScreenAlphaTextureFormats = MGAAlphaTextureFormats; infoPtr->SetupForCPUToScreenTexture = MGASetupForCPUToScreenTexture; @@ -903,8 +1026,8 @@ MGAStormEngineInit(ScrnInfoPtr pScrn) OUTREG(MGAREG_MACCESS, maccess); pMga->MAccess = maccess; pMga->PlaneMask = ~0; - if((pMga->Chipset != PCI_CHIP_MGAG100) - && (pMga->Chipset != PCI_CHIP_MGAG100_PCI)) + /* looks like this doesn't apply to mga g100 pci */ + if (pMga->Chipset != PCI_CHIP_MGAG100) OUTREG(MGAREG_PLNWT, pMga->PlaneMask); pMga->FgColor = 0; OUTREG(MGAREG_FCOL, pMga->FgColor); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c index 59a4da867..c6b5a59c4 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.18 2000/10/24 22:45:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.19 2000/11/02 19:10:53 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -74,11 +74,11 @@ void MGAInitVideo(ScreenPtr pScreen) int num_adaptors; if((pScrn->bitsPerPixel != 8) && !pMga->NoAccel && + (pMga->SecondCrtc == FALSE) && ((pMga->Chipset == PCI_CHIP_MGAG200) || (pMga->Chipset == PCI_CHIP_MGAG200_PCI) || (pMga->Chipset == PCI_CHIP_MGAG400))) { - if((pMga->Overlay8Plus24 || pMga->TexturedVideo) && (pScrn->bitsPerPixel != 24)) { @@ -90,11 +90,9 @@ void MGAInitVideo(ScreenPtr pScreen) newAdaptor = MGASetupImageVideoOverlay(pScreen); pMga->TexturedVideo = FALSE; } - if(!pMga->Overlay8Plus24) MGAInitOffscreenImages(pScreen); } - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c index 066d20991..5eb25defd 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c,v 1.4 2000/09/26 15:57:12 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c,v 1.5 2000/11/02 19:10:53 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -19,11 +19,10 @@ Bool mgaConfigureWarp(ScrnInfoPtr pScrn) { MGAPtr pMga = MGAPTR(pScrn); int wmisc; - - CHECK_DMA_QUIESCENT( pMga, pScrn ); + CHECK_DMA_QUIESCENT(pMga, pScrn); WAITFIFO(3); - + switch(pMga->Chipset) { case PCI_CHIP_MGAG400: OUTREG(MGAREG_WIADDR2, WIA_wmode_suspend); @@ -31,41 +30,34 @@ Bool mgaConfigureWarp(ScrnInfoPtr pScrn) OUTREG(MGAREG_WVRTXSZ, 0x00001807); OUTREG(MGAREG_WACCEPTSEQ, 0x18000000); break; - case PCI_CHIP_MGAG200: -#if 0 case PCI_CHIP_MGAG200_PCI: -#endif OUTREG(MGAREG_WIADDR, WIA_wmode_suspend); OUTREG(MGAREG_WGETMSB, 0x1606); - OUTREG(MGAREG_WVRTXSZ, 7); /* may be set on something else later on*/ + OUTREG(MGAREG_WVRTXSZ, 7); /* may be set on something else later on */ break; - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); return FALSE; } - + WAITFIFO(1); - OUTREG(MGAREG_WMISC, WM_wucodecache_enable | - WM_wmaster_enable | + OUTREG(MGAREG_WMISC, WM_wucodecache_enable | + WM_wmaster_enable | WM_wcacheflush_enable); wmisc = INREG(MGAREG_WMISC); - if(wmisc != (WM_wucodecache_enable | WM_wmaster_enable)) { + if (wmisc != (WM_wucodecache_enable | WM_wmaster_enable)) { FatalError("[mga] WARP engine wrongly configured (%d != %d)." - " Switch off your PC and try again.\n", wmisc, + " Switch off your PC and try again.\n", wmisc, WM_wmaster_enable | WM_wucodecache_enable); } - - return TRUE; + return TRUE; } static unsigned int mgaG400GetMicrocodeSize(MGAPtr pMGA) { #define CODESIZE(which) ((sizeof(which)/256 + 1)*256) - unsigned int microcode_size = 0; - + microcode_size = CODESIZE(WARP_G400_t2gz) + CODESIZE(WARP_G400_t2gza) + CODESIZE(WARP_G400_t2gzaf) + CODESIZE(WARP_G400_t2gzf) + CODESIZE(WARP_G400_t2gzs) + CODESIZE(WARP_G400_t2gzsa) + @@ -76,25 +68,24 @@ static unsigned int mgaG400GetMicrocodeSize(MGAPtr pMGA) CODESIZE(WARP_G400_tgzsaf) + CODESIZE(WARP_G400_tgzsf); microcode_size = ((microcode_size + 4096 - 1) / 4096) * 4096; return(microcode_size); - #undef CODESIZE } static unsigned int mgaG200GetMicrocodeSize(MGAPtr pMGA) { #define CODESIZE(which) ((sizeof(which)/256 + 1)*256) - unsigned int microcode_size; - + microcode_size = CODESIZE(WARP_G200_tgz) + CODESIZE(WARP_G200_tgza) + CODESIZE(WARP_G200_tgzaf) + CODESIZE(WARP_G200_tgzf) + CODESIZE(WARP_G200_tgzs) + CODESIZE(WARP_G200_tgzsa) + CODESIZE(WARP_G200_tgzsaf) + CODESIZE(WARP_G200_tgzsf); microcode_size = ((microcode_size + 4096 - 1) / 4096) * 4096; - return(microcode_size); + return(microcode_size); #undef CODESIZE } + static unsigned int mgaG400InstallMicrocode(MGAPtr pMGA, int agp_offset) { #define mgaWarpInstallCode(which, where) {\ @@ -105,16 +96,15 @@ static unsigned int mgaG400InstallMicrocode(MGAPtr pMGA, int agp_offset) pcbase += (sizeof(WARP_G400_ ## which) / 256 + 1) * 256; \ vcbase += (sizeof(WARP_G400_ ## which) / 256 + 1) * 256; \ } - MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; CARD8 *vcbase = pMGADRIServer->agp_map + agp_offset; - unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; + unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; unsigned int microcode_size = 0; - memset(pMGADRIServer->WarpIndex, 0, + memset(pMGADRIServer->WarpIndex, 0, sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES); - microcode_size = mgaG400GetMicrocodeSize(pMGA); + microcode_size = mgaG400GetMicrocodeSize(pMGA); mgaWarpInstallCode(tgz, MGA_WARP_TGZ); mgaWarpInstallCode(tgzf, MGA_WARP_TGZF); mgaWarpInstallCode(tgza, MGA_WARP_TGZA); @@ -131,9 +121,7 @@ static unsigned int mgaG400InstallMicrocode(MGAPtr pMGA, int agp_offset) mgaWarpInstallCode(t2gzsf, MGA_WARP_T2GZSF); mgaWarpInstallCode(t2gzsa, MGA_WARP_T2GZSA); mgaWarpInstallCode(t2gzsaf, MGA_WARP_T2GZSAF); - #undef mgaWarpInstallCode - return microcode_size; } @@ -147,16 +135,15 @@ static unsigned int mgaG200InstallMicrocode(MGAPtr pMGA, int agp_offset) pcbase += (sizeof(WARP_G200_ ## which) / 256 + 1) * 256; \ vcbase += (sizeof(WARP_G200_ ## which) / 256 + 1) * 256; \ } - MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; CARD8 *vcbase = pMGADRIServer->agp_map + agp_offset; - unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; + unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; unsigned int microcode_size = 0; - memset(pMGADRIServer->WarpIndex, 0, + memset(pMGADRIServer->WarpIndex, 0, sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES); - microcode_size = mgaG400GetMicrocodeSize(pMGA); + microcode_size = mgaG400GetMicrocodeSize(pMGA); mgaWarpInstallCode(tgz, MGA_WARP_TGZ); mgaWarpInstallCode(tgza, MGA_WARP_TGZA); mgaWarpInstallCode(tgzaf, MGA_WARP_TGZAF); @@ -165,9 +152,7 @@ static unsigned int mgaG200InstallMicrocode(MGAPtr pMGA, int agp_offset) mgaWarpInstallCode(tgzsa, MGA_WARP_TGZSA); mgaWarpInstallCode(tgzsaf, MGA_WARP_TGZSAF); mgaWarpInstallCode(tgzsf, MGA_WARP_TGZSF); - #undef mgaWarpInstallCode - return microcode_size; } @@ -176,25 +161,18 @@ unsigned int mgaGetMicrocodeSize(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); int retval; - + switch(pMGA->Chipset) { case PCI_CHIP_MGAG400: retval = mgaG400GetMicrocodeSize(pMGA); break; case PCI_CHIP_MGAG200: - retval = mgaG200GetMicrocodeSize(pMGA); - break; -#if 0 case PCI_CHIP_MGAG200_PCI: retval = mgaG200GetMicrocodeSize(pMGA); break; -#endif - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); retval = 0; } - return(retval); } @@ -203,26 +181,20 @@ unsigned int mgaInstallMicrocode(ScreenPtr pScreen, int agp_offset) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); int retval; - + switch(pMGA->Chipset) { case PCI_CHIP_MGAG400: retval = mgaG400InstallMicrocode(pMGA, agp_offset); break; case PCI_CHIP_MGAG200: - retval = mgaG200InstallMicrocode(pMGA, agp_offset); - break; -#if 0 case PCI_CHIP_MGAG200_PCI: - retval = mgaG200InstallMicrocode(pMGA); + retval = mgaG200InstallMicrocode(pMGA, agp_offset); break; -#endif - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); retval = 0; } - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "WARP Microcode Loaded\n"); - + + if (retval) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "WARP Microcode Loaded\n"); return retval; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile index dd81f50f7..ff5d1f682 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.9 2000/09/25 23:57:08 mvojkovi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.10 2000/11/03 18:46:11 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -17,6 +17,7 @@ INCLUDES = -I. -I../../include INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(XF86SRC)/vgafb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb -I$(SERVERSRC)/mfb \ + -I$(SERVERSRC)/miext/shadow \ -I$(XINCLUDESRC) -I$(XF86SRC)/xaa -I$(FONTINCSRC) \ -I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \ -I$(XF86SRC)/i2c -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xf24_32bpp \ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h index 477fbe95e..55b9cffd8 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h @@ -22,7 +22,7 @@ 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/xfree86/drivers/neomagic/neo.h,v 1.16 2000/09/26 15:57:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.17 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -48,6 +48,8 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xaalocal.h" /* XAA internals as we replace some of XAA */ #include "xf86Cursor.h" +#include "shadowfb.h" + #include "vbe.h" /* Drivers that need to access the PCI config space directly need this */ @@ -105,6 +107,7 @@ int NEOSetRead(ScreenPtr pScreen, int bank); extern Bool neo_I2CInit(ScrnInfoPtr pScrn); /* in neo_shadow.c */ +void neoShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage); void neoPointerMoved(int index, int x, int y); void neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void neoRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); @@ -239,6 +242,7 @@ typedef struct neoRec vbeInfoPtr pVbe; unsigned char * ShadowPtr; int ShadowPitch; + RefreshAreaFuncPtr refreshArea; void (*PointerMoved)(int index, int x, int y); int rotate; } NEORec, *NEOPtr; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c index 7bc864526..3cb0704d5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c @@ -22,7 +22,7 @@ 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/xfree86/drivers/neomagic/neo_cursor.c,v 1.6 2000/09/25 23:57:09 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c,v 1.7 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -200,52 +200,27 @@ _neoLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src, int xoff, int yoff) unsigned char *_dest, *_src; int _width, _fill; - if (!nPtr->noLinear) { - for (i = 0; i< nPtr->CursorInfo->MaxHeight - yoff; i++) { - _dest = ((unsigned char *)nPtr->NeoFbBase - + nAcl->CursorAddress - + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _width = (nPtr->CursorInfo->MaxWidth - - (xoff & 0x38)) >> 3; - _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _fill = (xoff & 0x38) >> 3; - - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - - _dest += (nPtr->CursorInfo->MaxWidth >> 3); - _src += (nPtr->CursorInfo->MaxWidth >> 3); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - } - memset(nPtr->NeoFbBase + nAcl->CursorAddress - + ((nPtr->CursorInfo->MaxWidth >> 2) * i), - 0, (nPtr->CursorInfo->MaxHeight - i) - * (nPtr->CursorInfo->MaxWidth >> 2)); - } else { - /* - * The cursor can only be in the last 16K of video memory, - * which fits in the last banking window. - */ - for (i = 0; i<nPtr->CursorInfo->MaxHeight; i++) { - _dest = ((unsigned char *)nPtr->NeoFbBase - + (nAcl->CursorAddress & 0xFFFF) - + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _width = (nPtr->CursorInfo->MaxWidth - - ((xoff & 0x38) >> 3)); - _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _fill = (xoff & 0x38) >> 3; - - NEOSetWrite(pScrn->pScreen, (int)(nAcl->CursorAddress >> 16)); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - - _dest += (nPtr->CursorInfo->MaxWidth >> 3); - _src += (nPtr->CursorInfo->MaxWidth >> 3); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - } + for (i = 0; i< nPtr->CursorInfo->MaxHeight - yoff; i++) { + _dest = ((unsigned char *)nPtr->NeoFbBase + + nAcl->CursorAddress + + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); + _width = (nPtr->CursorInfo->MaxWidth + - (xoff & 0x38)) >> 3; + _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); + _fill = (xoff & 0x38) >> 3; + + memcpy(_dest,_src,_width); + memset(_dest + _width, 0, _fill); + + _dest += (nPtr->CursorInfo->MaxWidth >> 3); + _src += (nPtr->CursorInfo->MaxWidth >> 3); + memcpy(_dest,_src,_width); + memset(_dest + _width, 0, _fill); } + memset(nPtr->NeoFbBase + nAcl->CursorAddress + + ((nPtr->CursorInfo->MaxWidth >> 2) * i), + 0, (nPtr->CursorInfo->MaxHeight - i) + * (nPtr->CursorInfo->MaxWidth >> 2)); /* set cursor address here or we loose the cursor on video mode change */ /* Load storage location. */ OUTREG(NEOREG_CURSMEMPOS, ((0x000f & (nAcl->CursorAddress >> 10)) << 8) | @@ -270,11 +245,7 @@ neoUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) NEOACLPtr nAcl = NEOACLPTR(xf86Screens[pScr->myNum]); NEOPtr nPtr = NEOPTR(xf86Screens[pScr->myNum]); - if(!nPtr->noLinear) { - return(nAcl->UseHWCursor && !nAcl->NoCursorMode); - } - - return (FALSE); + return(nAcl->UseHWCursor && !nAcl->NoCursorMode); } static unsigned char* @@ -323,7 +294,6 @@ NeoCursorInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; NEOPtr nPtr = NEOPTR(pScrn); xf86CursorInfoPtr infoPtr; - infoPtr = xf86CreateCursorInfoRec(); if(!infoPtr) return FALSE; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c index 519aeea03..3b93b220c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c @@ -22,7 +22,7 @@ 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/xfree86/drivers/neomagic/neo_driver.c,v 1.38 2000/10/24 22:45:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c,v 1.39 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -78,7 +78,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xf86RAC.h" /* Needed by the Shadow Framebuffer */ -#include "shadowfb.h" +#include "shadow.h" /* int10 */ #include "xf86int10.h" @@ -87,6 +87,10 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Needed for Device Data Channel (DDC) support */ #include "xf86DDC.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* * Driver data structures. */ @@ -131,7 +135,11 @@ static Bool neoUnmapMem(ScrnInfoPtr pScrn); static void neoProgramShadowRegs(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore); static void neoCalcVCLK(ScrnInfoPtr pScrn, long freq); -static void neo_ddc1(int scrnIndex); +static xf86MonPtr neo_ddc1(int scrnIndex); +static Bool neoDoDDC1(ScrnInfoPtr pScrn); +static Bool neoDoDDC2(ScrnInfoPtr pScrn); +static Bool neoDoDDCVBE(ScrnInfoPtr pScrn); +static void neoProbeDDC(ScrnInfoPtr pScrn, int index); static void NeoDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); static int neoFindMode(int xres, int yres, int depth); @@ -342,7 +350,10 @@ static const char *ramdacSymbols[] = { }; static const char *shadowSymbols[] = { + "shadowInit", +#if 0 "ShadowFBInit", +#endif NULL }; @@ -453,7 +464,6 @@ static OptionInfoPtr NEOAvailableOptions(int chipid, int busid) { - int vendor = ((chipid & 0xffff0000) >> 16); int chip = (chipid & 0x0000ffff); if (chip == PCI_CHIP_NM2070) @@ -607,9 +617,11 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) int w; int apertureSize; char *s; - Bool ddc_done = FALSE; - if (flags & PROBE_DETECT) return FALSE; + if (flags & PROBE_DETECT) { + neoProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index ); + return TRUE; + } /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) @@ -623,7 +635,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) if (!vgaHWGetHWRec(pScrn)) return FALSE; hwp = VGAHWPTR(pScrn); - + /* Allocate the NeoRec driverPrivate */ if (!NEOGetRec(pScrn)) { return FALSE; @@ -689,14 +701,10 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) } xf86ErrorF("\n"); - if (xf86LoadSubModule(pScrn, "vbe")) { - nPtr->pVbe = VBEInit(NULL,nPtr->pEnt->index); - } - vgaHWGetIOBase(hwp); nPtr->vgaIOBase = hwp->IOBase; vgaHWSetStdFuncs(hwp); - + /* Determine the panel type */ VGAwGR(0x09,0x26); type = VGArGR(0x21); @@ -767,7 +775,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) break; case NM2097: bppSupport = Support24bppFb | Support32bppFb | - SupportConvert32to24 | PreferConvert32to24; + SupportConvert32to24 | PreferConvert32to24; videoRam = 1152; maxClock = 80000; CursorMem = 1024; @@ -835,35 +843,15 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) pScrn->monitor = pScrn->confScreen->monitor; - if (!xf86LoadSubModule(pScrn, "ddc")) - return FALSE; - xf86LoaderReqSymLists(ddcSymbols, NULL); -#if 0 - VGAwGR(0x09,0x26); - neo_ddc1(pScrn->scrnIndex); - VGAwGR(0x09,0x00); + if (xf86LoadSubModule(pScrn, "ddc")) { + xf86LoaderReqSymLists(ddcSymbols, NULL); +#if 1 + if (!neoDoDDCVBE(pScrn)) + if (!neoDoDDC2(pScrn)) + neoDoDDC1(pScrn); #endif - if (!xf86LoadSubModule(pScrn, "i2c")) - return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - if (!neo_I2CInit(pScrn)) - return FALSE; - - VGAwGR(0x09,0x26); - - if (nPtr->pVbe) { - xf86MonPtr pMon; - if ((pMon = xf86PrintEDID(vbeDoEDID(nPtr->pVbe,NULL))) != NULL) - ddc_done = TRUE; - xf86SetDDCproperties(pScrn,pMon); } - if (ddc_done) - xf86SetDDCproperties( - pScrn,xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex,nPtr->I2C))); - - VGAwGR(0x09,0x00); - if (!xf86SetDepthBpp(pScrn, 8, 8, 8, bppSupport )) return FALSE; else { @@ -1040,7 +1028,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) nPtr->NeoLinearAddr = 0; } - if (nPtr->pEnt->device->IOBase) { + if (nPtr->pEnt->device->IOBase && !nPtr->noMMIO) { /* XXX Check this matches a PCI base address */ nPtr->NeoMMIOAddr = nPtr->pEnt->device->IOBase; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, @@ -1199,6 +1187,9 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) } xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif if (!nPtr->noLinear) { if (!xf86LoadSubModule(pScrn, "xaa")) @@ -1207,7 +1198,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) } if (nPtr->shadowFB) { - if (!xf86LoadSubModule(pScrn, "shadowfb")) { + if (!xf86LoadSubModule(pScrn, "shadow")) { RETURN; } xf86LoaderReqSymLists(shadowSymbols, NULL); @@ -1281,9 +1272,13 @@ NEOLoadPalette( for(i = 0; i < numColors; i++) { index = indices[i]; hwp->writeDacWriteAddr(hwp, index); + DACDelay(hwp); hwp->writeDacData(hwp, colors[index].red << shift); + DACDelay(hwp); hwp->writeDacData(hwp, colors[index].green << Gshift); + DACDelay(hwp); hwp->writeDacData(hwp, colors[index].blue << shift); + DACDelay(hwp); } } @@ -1329,18 +1324,6 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; vgaHWSaveScreen(pScreen,SCREEN_SAVER_ON); NEOAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - - /* - * The next step is to setup the screen's visuals, and initialise the - * framebuffer code. In cases where the framebuffer's default - * choices for things like visual layouts and bits per RGB are OK, - * this may be as simple as calling the framebuffer's ScreenInit() - * function. If not, the visuals will need to be setup before calling - * a fb ScreenInit() function and fixed up after. - * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. - */ /* * Reset visual list. @@ -1354,14 +1337,7 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; - /* - * Temporarily set the global defaultColorVisualClass to make - * cfbInitVisuals do what we want. - */ -#if 0 - savedDefaultVisualClass = xf86GetDefaultColorVisualClass(); - xf86SetDefaultColorVisualClass(pScrn->defaultVisual); -#endif + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -1390,7 +1366,10 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) width, height, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); - +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif if (!ret) return FALSE; @@ -1417,6 +1396,7 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) nPtr->NeoHWCursorShown = FALSE; nPtr->NeoHWCursorInitialized = FALSE; nAcl->UseHWCursor = FALSE; + nAcl->CursorAddress = -1; if (nPtr->noLinear) { miBankInfoPtr pBankInfo; @@ -1427,7 +1407,7 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; pBankInfo->pBankA = hwp->Base; - pBankInfo->pBankB = (unsigned char *)hwp->Base + 0x10000; + pBankInfo->pBankB = (unsigned char *)hwp->Base; pBankInfo->BankSize = 0x10000; pBankInfo->nBankDepth = pScrn->depth; @@ -1443,8 +1423,8 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using nonlinear mode\n"); - xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using software cursor\n"); - + xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using software cursor in " + "nonlinear mode\n"); miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); @@ -1453,7 +1433,6 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); } else { - nAcl->CursorAddress = -1; nAcl->cacheStart = -1; nAcl->cacheEnd = -1; xf86DrvMsg(pScrn->scrnIndex,X_INFO, @@ -1482,8 +1461,11 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } else xf86DrvMsg(scrnIndex, X_ERROR, "Too little space for H/W cursor.\n"); + xf86DrvMsg(pScrn->scrnIndex,X_INFO, + "Acceleration disabled when not using MMIO\n"); + /* Setup the acceleration primitives */ - if (!nPtr->noAccel) { + if (!nPtr->noAccel || nPtr->noMMIO) { nAcl->cacheStart = currentaddr - freespace; nAcl->cacheEnd = currentaddr; freespace = 0; @@ -1512,7 +1494,8 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Acceleration Initialized\n"); } - + if (!nPtr->noAccel && nPtr->noMMIO) + miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); @@ -1520,21 +1503,22 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); - if (nAcl->CursorAddress != -1) { - /* HW cursor functions */ - if (!NeoCursorInit(pScreen)) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - return FALSE; - } - nAcl->UseHWCursor = TRUE; - nPtr->NeoHWCursorInitialized = TRUE; - } else - nAcl->UseHWCursor = FALSE; } + if (nAcl->CursorAddress != -1) { + /* HW cursor functions */ + if (!NeoCursorInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + return FALSE; + } + nAcl->UseHWCursor = TRUE; + nPtr->NeoHWCursorInitialized = TRUE; + } else + nAcl->UseHWCursor = FALSE; + if (nPtr->shadowFB) { - RefreshAreaFuncPtr refreshArea = neoRefreshArea; + nPtr->refreshArea = neoRefreshArea; if(nPtr->rotate) { if (!nPtr->PointerMoved) { @@ -1543,14 +1527,17 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } switch(pScrn->bitsPerPixel) { - case 8: refreshArea = neoRefreshArea8; break; - case 16: refreshArea = neoRefreshArea16; break; - case 24: refreshArea = neoRefreshArea24; break; - case 32: refreshArea = neoRefreshArea32; break; + case 8: nPtr->refreshArea = neoRefreshArea8; break; + case 16: nPtr->refreshArea = neoRefreshArea16; break; + case 24: nPtr->refreshArea = neoRefreshArea24; break; + case 32: nPtr->refreshArea = neoRefreshArea32; break; } } - - ShadowFBInit(pScreen, refreshArea); +#if 0 + ShadowFBInit(pScreen, nPtr->refreshArea); +#else + shadowInit (pScreen, neoShadowUpdate, 0); +#endif } /* Initialise default colourmap */ @@ -1562,8 +1549,7 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) return FALSE; - if (pScrn->bitsPerPixel == 8) - racflag |= RAC_COLORMAP; + racflag |= RAC_COLORMAP; if (nPtr->NeoHWCursorInitialized) racflag |= RAC_CURSOR; @@ -1784,9 +1770,9 @@ neoMapMem(ScrnInfoPtr pScrn) xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, nPtr->NeoMMIOAddr, 0x200000L); + if (nPtr->NeoMMIOBase == NULL) + return FALSE; } - if (nPtr->NeoMMIOBase == NULL) - return FALSE; if (nPtr->pEnt->location.type == BUS_PCI) nPtr->NeoFbBase = @@ -1890,7 +1876,8 @@ neoSave(ScrnInfoPtr pScrn) || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) save->VCLK3NumeratorHigh = VGArGR(0x8F); save->VCLK3Denominator = VGArGR(0x9F); - + save->ProgramVCLK = TRUE; + if (save->reg == NULL) save->reg = (regSavePtr)xnfcalloc(sizeof(regSaveRec), 1); else @@ -2093,7 +2080,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore, vgaHWPtr hwp = VGAHWPTR(pScrn); unsigned char temp; int i; - + Bool clock_hi = FALSE; + vgaHWProtect(pScrn,TRUE); /* Blank the screen */ VGAwGR(0x09,0x26); @@ -2216,12 +2204,18 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore, VGAwGR(0x37, restore->PanelVertCenterReg5); VGAwGR(0x38, restore->PanelHorizCenterReg5); } - + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) + clock_hi = TRUE; + /* Program VCLK3 if needed. */ - if (restore->ProgramVCLK) { + if (restore->ProgramVCLK + && ((VGArGR(0x9B) != restore->VCLK3NumeratorLow) + || (VGArGR(0x9F) != restore->VCLK3Denominator) + || (clock_hi && ((VGArGR(0x8F) & ~0x0f) + != (restore->VCLK3NumeratorHigh & ~0x0F))))) { VGAwGR(0x9B, restore->VCLK3NumeratorLow); - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 - || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) { + if (clock_hi) { temp = VGArGR(0x8F); temp &= 0x0F; /* Save bits 3:0 */ temp |= (restore->VCLK3NumeratorHigh & ~0x0F); @@ -2537,7 +2531,7 @@ neoModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #define MAX_N 127 #define MAX_D 31 #define MAX_F 1 - +#define DEBUG static void neoCalcVCLK(ScrnInfoPtr pScrn, long freq) { @@ -2574,6 +2568,14 @@ neoCalcVCLK(ScrnInfoPtr pScrn, long freq) nPtr->NeoModeReg.VCLK3NumeratorLow = n_best | (f_best << 7); } nPtr->NeoModeReg.VCLK3Denominator = d_best; +#ifdef DEBUG + ErrorF("neoVCLK: f:%f NumLow=%i NumHi=%i Den=%i Df=%f\n", + f_target, + nPtr->NeoModeReg.VCLK3NumeratorLow, + nPtr->NeoModeReg.VCLK3NumeratorHigh, + nPtr->NeoModeReg.VCLK3Denominator, + f_best_diff); +#endif } /* @@ -2663,11 +2665,12 @@ neo_ddc1Read(ScrnInfoPtr pScrn) return (tmp); } -static void +static xf86MonPtr neo_ddc1(int scrnIndex) { vgaHWPtr hwp = VGAHWPTR(xf86Screens[scrnIndex]); unsigned int reg1, reg2, reg3; + xf86MonPtr ret; /* initialize chipset */ reg1 = VGArCR(0x21); @@ -2676,11 +2679,65 @@ neo_ddc1(int scrnIndex) VGAwCR(0x21,0x00); VGAwCR(0x1D,0x01); /* some Voodoo */ VGAwGR(0xA1,0x2F); - xf86SetDDCproperties(xf86Screens[scrnIndex],xf86PrintEDID( - xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeed,neo_ddc1Read))); + ret = xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeed,neo_ddc1Read); /* undo initialization */ VGAwCR(0x21,reg1); VGAwCR(0x1D,reg2); + return ret; +} + +static Bool +neoDoDDC1(ScrnInfoPtr pScrn) +{ + Bool ret = FALSE; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + VGAwGR(0x09,0x26); + ret = xf86SetDDCproperties(pScrn, + xf86PrintEDID(neo_ddc1(pScrn->scrnIndex))); + VGAwGR(0x09,0x00); + + return ret; +} + +static Bool +neoDoDDC2(ScrnInfoPtr pScrn) +{ + NEOPtr nPtr = NEOPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + Bool ret = FALSE; + + VGAwGR(0x09,0x26); + if (xf86LoadSubModule(pScrn, "i2c")) { + xf86LoaderReqSymLists(i2cSymbols, NULL); + if (neo_I2CInit(pScrn)) { + ret = xf86SetDDCproperties(pScrn,xf86PrintEDID(xf86DoEDID_DDC2( + pScrn->scrnIndex,nPtr->I2C))); + } + } + VGAwGR(0x09,0x00); + + return ret; +} + +static Bool +neoDoDDCVBE(ScrnInfoPtr pScrn) +{ + NEOPtr nPtr = NEOPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + vbeInfoPtr pVbe; + Bool ret = FALSE; + + VGAwGR(0x09,0x26); + if (xf86LoadSubModule(pScrn, "vbe")) { + if ((pVbe = VBEInit(NULL,nPtr->pEnt->index))) { + ret = xf86SetDDCproperties( + pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + vbeFree(pVbe); + } + } + VGAwGR(0x09,0x00); + return ret; } static int @@ -2725,3 +2782,14 @@ neoFindMode(int xres, int yres, int depth) return mode[size - 1].mode; } + +static void +neoProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c index e7f74f327..cd1925375 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c @@ -22,7 +22,7 @@ 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/xfree86/drivers/neomagic/neo_i2c.c,v 1.2 1999/06/27 14:08:10 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c,v 1.3 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -89,6 +89,9 @@ neo_I2CInit(ScrnInfoPtr pScrn) I2CPtr->scrnIndex = pScrn->scrnIndex; I2CPtr->I2CPutBits = neo_I2CPutBits; I2CPtr->I2CGetBits = neo_I2CGetBits; + /* increase these as the defaults are too low */ + I2CPtr->RiseFallTime = 2; + I2CPtr->HoldTime = 40; if (!xf86I2CBusInit(I2CPtr)) return FALSE; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c index 5d9e04983..1a7320b90 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c,v 1.1 2000/02/08 13:13:18 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c,v 1.2 2000/11/03 18:46:11 eich Exp $ */ /* Copyright (c) 1999, 2000 The XFree86 Project Inc. @@ -15,6 +15,15 @@ #include "servermd.h" #include "neo.h" +void +neoShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage) +{ + ScrnInfoPtr pScrn; + pScrn = xf86Screens[pScreen->myNum]; + + (NEOPTR(pScrn))->refreshArea (pScrn, REGION_NUM_RECTS(damage), + REGION_RECTS(damage)); +} void neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c index 2b5f8966b..819b329fe 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.7 2000/02/08 17:19:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.8 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" @@ -202,12 +202,12 @@ NV_ddc1Read(ScrnInfoPtr pScrn) unsigned char val; /* wait for Vsync */ - while(pNv->riva.PCIO[0x3da] & 0x08); - while(!(pNv->riva.PCIO[0x3da] & 0x08)); + while(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08); + while(!(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08)); /* Get the result */ - pNv->riva.PCIO[0x3d4] = 0x3e; - val = pNv->riva.PCIO[0x3d5]; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3e); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5); DEBUG(ErrorF("NV_ddc1Read(%p,...) returns %d\n", pScrn, val)); return (val & DDC_SDA_READ_MASK) != 0; @@ -220,8 +220,8 @@ NV_I2CGetBits(I2CBusPtr b, int *clock, int *data) unsigned char val; /* Get the result. */ - pNv->riva.PCIO[0x3d4] = 0x3e; - val = pNv->riva.PCIO[0x3d5]; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3e); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5); *clock = (val & DDC_SCL_READ_MASK) != 0; *data = (val & DDC_SDA_READ_MASK) != 0; @@ -235,8 +235,8 @@ NV_I2CPutBits(I2CBusPtr b, int clock, int data) NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]); unsigned char val; - pNv->riva.PCIO[0x3d4] = 0x3f; - val = pNv->riva.PCIO[0x3d5] & 0xf0; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3f); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5) & 0xf0; if (clock) val |= DDC_SCL_WRITE_MASK; else @@ -247,8 +247,8 @@ NV_I2CPutBits(I2CBusPtr b, int clock, int data) else val &= ~DDC_SDA_WRITE_MASK; - pNv->riva.PCIO[0x3d4] = 0x3f; - pNv->riva.PCIO[0x3d5] = val | 0x1; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3f); + VGA_WR08(pNv->riva.PCIO, 0x3d5, val | 0x1); DEBUG(ErrorF("NV_I2CPutBits(%p, %d, %d) val=0x%x\n", b, clock, data, val)); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c index 72e1d29e8..844dcb1fe 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.48 2000/10/24 22:45:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.49 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" @@ -555,10 +555,13 @@ static Bool NVEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NVPtr pNv = NVPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "NVEnterVT\n")); - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); if (!NVModeInit(pScrn, pScrn->currentMode)) return FALSE; NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); @@ -586,10 +589,14 @@ static void NVLeaveVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NVPtr pNv = NVPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "NVLeaveVT\n")); NVRestore(pScrn); - RivaEnterLeave(pScrn, FALSE); + pNv->riva.LockUnlock(&pNv->riva, 1); + vgaHWLock(hwp); } /* @@ -611,11 +618,12 @@ NVCloseScreen(int scrnIndex, ScreenPtr pScreen) if (pScrn->vtSema) { NVRestore(pScrn); + pNv->riva.LockUnlock(&pNv->riva, 1); vgaHWLock(hwp); - NVUnmapMem(pScrn); - vgaHWUnmapMem(pScrn); } + NVUnmapMem(pScrn); + vgaHWUnmapMem(pScrn); if (pNv->AccelInfoRec) XAADestroyInfoRec(pNv->AccelInfoRec); if (pNv->CursorInfoRec) @@ -702,11 +710,9 @@ NVdoDDC(ScrnInfoPtr pScrn) } } #endif - if (pNv->pInt) xf86FreeInt10(pNv->pInt); pNv->pInt = NULL; - if (!pNv->Primary) { /* XXX Need to write an NV mode ddc1SetSpeed */ if (pNv->DDC1SetSpeed == vgaHWddc1SetSpeed) { @@ -720,7 +726,8 @@ NVdoDDC(ScrnInfoPtr pScrn) NVSave(pScrn); /* Enable access to extended registers */ - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); /* It is now safe to talk to the card */ #if NVuseI2C @@ -755,14 +762,15 @@ NVdoDDC(ScrnInfoPtr pScrn) #endif /* NVuseI2C */ /* Read and output monitor info using DDC1 */ if (pNv->ddc1Read && pNv->DDC1SetSpeed) { +#if 0 MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, pNv->DDC1SetSpeed, pNv->ddc1Read ); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", MonInfo); xf86PrintEDID( MonInfo ); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n"); +#endif } - /* Restore previous state */ NVRestore(pScrn); @@ -823,7 +831,10 @@ NVPreInit(ScrnInfoPtr pScrn, int flags) pNv->Primary = xf86IsPrimaryPci(pNv->PciInfo); /* Initialize the card through int10 interface if needed */ - if ( !pNv->Primary && xf86LoadSubModule(pScrn, "int10")){ +#if 0 + if ( !pNv->Primary &&) +#endif + if (xf86LoadSubModule(pScrn, "int10")){ xf86LoaderReqSymLists(int10Symbols, NULL); @@ -1565,6 +1576,8 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } else { /* Save the current state */ + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); NVSave(pScrn); /* Initialise the first mode */ if (!NVModeInit(pScrn, pScrn->currentMode)) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h index 08332f02f..842d86db9 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h @@ -36,7 +36,7 @@ |* those rights set forth herein. *| |* *| \***************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h,v 1.5 2000/08/03 12:24:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h,v 1.6 2000/11/03 18:46:12 eich Exp $ */ #ifndef __NV_LOCAL_H__ #define __NV_LOCAL_H__ @@ -56,12 +56,14 @@ typedef unsigned int U032; /* * HW access macros. */ -#define NV_WR08(p,i,d) (((U008 *)(p))[i]=(d)) -#define NV_RD08(p,i) (((U008 *)(p))[i]) -#define NV_WR16(p,i,d) (((U016 *)(p))[(i)/2]=(d)) -#define NV_RD16(p,i) (((U016 *)(p))[(i)/2]) -#define NV_WR32(p,i,d) (((U032 *)(p))[(i)/4]=(d)) -#define NV_RD32(p,i) (((U032 *)(p))[(i)/4]) +#include "xf86_OSproc.h" +/* these assume memory-mapped I/O, and not normal I/O space */ +#define NV_WR08(p,i,d) MMIO_OUT8((volatile pointer)(p), (i), (d)) +#define NV_RD08(p,i) MMIO_IN8((volatile pointer)(p), (i)) +#define NV_WR16(p,i,d) MMIO_OUT16((volatile pointer)(p), (i), (d)) +#define NV_RD16(p,i) MMIO_IN16((volatile pointer)(p), (i)) +#define NV_WR32(p,i,d) MMIO_OUT32((volatile pointer)(p), (i), (d)) +#define NV_RD32(p,i) MMIO_IN32((volatile pointer)(p), (i)) #if 1 #define VGA_WR08(p,i,d) NV_WR08(p,i,d) #define VGA_RD08(p,i) NV_RD08(p,i) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c index ae7257e00..bb0df1af5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.6 2000/02/10 18:59:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.7 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" @@ -32,26 +32,6 @@ #include "nvvga.h" /* - * Lock and unlock VGA and SVGA registers. - */ -void RivaEnterLeave(ScrnInfoPtr pScrn, Bool enter) -{ - vgaHWPtr hwp = VGAHWPTR(pScrn); - NVPtr pNv = NVPTR(pScrn); - - if (enter) - { - vgaHWUnlock(hwp); - pNv->riva.LockUnlock(&pNv->riva, 0); - } - else - { - pNv->riva.LockUnlock(&pNv->riva, 1); - vgaHWLock(hwp); - } -} - -/* * Override VGA I/O routines. */ static void NVWriteCrtc(vgaHWPtr pVga, CARD8 index, CARD8 value) @@ -279,7 +259,8 @@ NVCommonSetup(ScrnInfoPtr pScrn) pNv->Dac.maxPixelClock = pNv->riva.MaxVClockFreqKHz; - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(VGAHWPTR(pScrn)); + pNv->riva.LockUnlock(&pNv->riva, 0); } void diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c index 0de053973..6939aa860 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c @@ -41,7 +41,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.17 2000/10/24 22:45:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.18 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" #include "xaalocal.h" @@ -69,6 +69,7 @@ NVSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) RIVA_FIFO_FREE(pNv->riva, Clip, 2); pNv->riva.Clip->TopLeft = (y1 << 16) | (x1 & 0xffff); pNv->riva.Clip->WidthHeight = (height << 16) | width; + mem_barrier(); } @@ -142,6 +143,7 @@ NVSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } /* @@ -160,10 +162,14 @@ NVSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, { NVPtr pNv = NVPTR(pScrn); +/* ErrorF("E SubseqSS\n"); */ RIVA_FIFO_FREE(pNv->riva, Blt, 3); pNv->riva.Blt->TopLeftSrc = (y1 << 16) | x1; pNv->riva.Blt->TopLeftDst = (y2 << 16) | x2; pNv->riva.Blt->WidthHeight = (h << 16) | w; + mem_barrier(); +/* ErrorF("L SubseqSS\n"); */ + } @@ -199,6 +205,7 @@ NVSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, bg = (bg == -1) ? 0 : bg | pNv->opaqueMonochrome; }; NVSetPattern(pNv, bg, fg, patternx, patterny); + mem_barrier(); RIVA_FIFO_FREE(pNv->riva, Bitmap, 1); pNv->riva.Bitmap->Color1A = fg; } @@ -213,6 +220,7 @@ NVSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } @@ -224,8 +232,9 @@ NVSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, void NVSync(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - +/* ErrorF("sync enter\n"); */ while (pNv->riva.Busy(&pNv->riva)); +/* ErrorF("sync leave\n"); */ } /* Color expansion */ @@ -458,6 +467,8 @@ NVSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) NVPtr pNv = NVPTR(pScrn); NVSetRopSolid(pNv, rop); + mem_barrier(); + RIVA_FIFO_FREE(pNv->riva, Line, 1); pNv->FgColor = color; } @@ -473,6 +484,7 @@ NVSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) pNv->riva.Line->Lin[0].point1 = ((y << 16) | (( x + len ) & 0xffff)); else pNv->riva.Line->Lin[0].point1 = (((y + len) << 16) | ( x & 0xffff)); + mem_barrier(); } static void @@ -491,6 +503,7 @@ NVSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, pNv->riva.Line->Lin[1].point0 = ((y2 << 16) | (x2 & 0xffff)); pNv->riva.Line->Lin[1].point1 = (((y2 + 1) << 16) | (x2 & 0xffff)); } + mem_barrier(); } #else @@ -553,6 +566,7 @@ NVSubsequentSolidHorVertLine( RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } #ifndef NV_USE_FB @@ -757,6 +771,7 @@ NVAccelInit(ScreenPtr pScreen) infoPtr->PolyPointMask = GCFunction | GCPlaneMask; NVDisableClipping(pScrn); + return(XAAInit(pScreen, infoPtr)); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h b/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h index 0b6683b59..752a797df 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h @@ -36,7 +36,7 @@ |* those rights set forth herein. *| |* *| \***************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.6 2000/02/08 17:19:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.7 2000/11/03 18:46:12 eich Exp $ */ #ifndef __RIVA_HW_H__ #define __RIVA_HW_H__ #define RIVA_SW_VERSION 0x00010003 @@ -425,8 +425,10 @@ int RivaGetConfig(RIVA_HW_INST *); #define RIVA_FIFO_FREE(hwinst,hwptr,cnt) \ { \ - while ((hwinst).FifoFreeCount < (cnt)) \ + while ((hwinst).FifoFreeCount < (cnt)) { \ + mem_barrier(); \ (hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2; \ + } \ (hwinst).FifoFreeCount -= (cnt); \ } #endif /* __RIVA_HW_H__ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h index 2c3aa87da..ddd93555a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.23 2000/10/23 12:10:15 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.24 2000/11/02 16:29:12 anderson Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -80,11 +80,9 @@ in this Software without prior written authorization from the XFree86 Project. #include "vbe.h" -#ifdef XvExtension #include "xf86xv.h" #include "Xv.h" #include "fourcc.h" -#endif #ifndef _S3V_VGAHWMMIO_H #define _S3V_VGAHWMMIO_H diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c index 27e7c84cc..6752f9633 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.63 2000/10/23 12:10:16 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.64 2000/11/03 18:46:13 eich Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -103,6 +103,8 @@ static void S3VDisplayPowerManagementSet(ScrnInfoPtr pScrn, int flags); #endif static Bool S3Vddc1(int scrnIndex); +static Bool S3Vddc2(int scrnIndex); + static unsigned int S3Vddc1Read(ScrnInfoPtr pScrn); static void S3VProbeDDC(ScrnInfoPtr pScrn, int index); @@ -985,16 +987,7 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags) && ((pMon = xf86PrintEDID(vbeDoEDID(ps3v->pVbe, NULL))) != NULL)) xf86SetDDCproperties(pScrn,pMon); else if (!S3Vddc1(pScrn->scrnIndex)) { - if ( xf86LoadSubModule(pScrn, "i2c") ) { - xf86LoaderReqSymLists(i2cSymbols,NULL); - if (S3V_I2CInit(pScrn)) { - CARD32 tmp = (INREG(DDC_REG)); - OUTREG(DDC_REG,(tmp | 0x13)); - xf86SetDDCproperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex,ps3v->I2C))); - OUTREG(DDC_REG,tmp); - } - } + S3Vddc2(pScrn->scrnIndex); } } if (ps3v->pVbe) @@ -3759,6 +3752,25 @@ S3Vddc1(int scrnIndex) return success; } +static Bool +S3Vddc2(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + S3VPtr ps3v = S3VPTR(pScrn); + + if ( xf86LoadSubModule(pScrn, "i2c") ) { + xf86LoaderReqSymLists(i2cSymbols,NULL); + if (S3V_I2CInit(pScrn)) { + CARD32 tmp = (INREG(DDC_REG)); + OUTREG(DDC_REG,(tmp | 0x13)); + xf86SetDDCproperties(pScrn,xf86PrintEDID( + xf86DoEDID_DDC2(pScrn->scrnIndex,ps3v->I2C))); + OUTREG(DDC_REG,tmp); + return TRUE; + } + } + return FALSE; +} static void S3VProbeDDC(ScrnInfoPtr pScrn, int index) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile index 553ed84f4..94e72cd9d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile,v 1.25 2000/09/03 05:13:27 keithp Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile,v 1.26 2000/11/03 18:46:13 eich Exp $ XCOMM XCOMM This is an Imakefile for the TRIDENT driver. XCOMM @@ -8,10 +8,12 @@ XCOMM SRCS = trident_driver.c trident_dac.c tridenthelper.c \ trident_accel.c trident_i2c.c trident_bank.c \ - image_accel.c blade_accel.c tvga_dac.c trident_dga.c + image_accel.c blade_accel.c tvga_dac.c trident_dga.c \ + trident_shadow.c OBJS = trident_driver.o trident_dac.o tridenthelper.o \ trident_accel.o trident_i2c.o trident_bank.o \ - image_accel.o blade_accel.o tvga_dac.o trident_dga.o + image_accel.o blade_accel.o tvga_dac.o trident_dga.o \ + trident_shadow.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -19,7 +21,7 @@ INCLUDES = -I. -I../../include INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/mi -I$(XF86SRC)/xaa -I$(SERVERSRC)/fb \ -I$(XF86SRC)/xf1bpp -I$(SERVERSRC)/miext/shadow \ - -I$(SERVERSRC)/render \ + -I$(SERVERSRC)/render -I$(XF86SRC)/shadowfb \ -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/mfb \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ @@ -55,6 +57,7 @@ InstallDriverSDKNonExecFile(trident_dac.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_dga.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_driver.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_i2c.c,$(DRIVERSDKDIR)/drivers/trident) +InstallDriverSDKNonExecFile(trident_shadow.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_regs.h,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(tridenthelper.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(tridentramdac.c,$(DRIVERSDKDIR)/drivers/trident) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c index e4cc22d85..04ad36259 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c @@ -23,7 +23,7 @@ * * Trident Blade3D accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c,v 1.7 2000/07/05 13:41:37 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c,v 1.8 2000/11/03 18:46:13 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -146,6 +146,7 @@ BladeAccelInit(ScreenPtr pScreen) pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = BladeInitializeAccelerator; BladeInitializeAccelerator(pScrn); infoPtr->Flags = PIXMAP_CACHE | diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c index 23c9a5e28..75b83482a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c @@ -23,7 +23,7 @@ * * Trident 3DImage' accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c,v 1.15 2000/10/11 15:42:05 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c,v 1.16 2000/11/03 18:46:13 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -143,6 +143,7 @@ ImageAccelInit(ScreenPtr pScreen) pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = ImageInitializeAccelerator; ImageInitializeAccelerator(pScrn); infoPtr->Flags = PIXMAP_CACHE | diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h index 8beaa9d40..b30f32fc6 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.27 2000/10/11 15:42:05 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.28 2000/11/03 18:46:13 eich Exp $ */ #ifndef _TRIDENT_H_ #define _TRIDENT_H_ @@ -33,6 +33,7 @@ #include "vgaHW.h" #include "xf86i2c.h" #include "xf86int10.h" +#include "shadowfb.h" typedef struct { unsigned char tridentRegs3x4[0x100]; @@ -91,6 +92,9 @@ typedef struct { int DGAViewportStatus; unsigned char * ShadowPtr; int ShadowPitch; + RefreshAreaFuncPtr RefreshArea; + void (*PointerMoved)(int index, int x, int y); + int Rotate; float frequency; unsigned char REGPCIReg; unsigned char REGNewMode1; @@ -129,6 +133,7 @@ typedef struct { unsigned int (*ddc1Read)(ScrnInfoPtr); CARD8* XAAScanlineColorExpandBuffers[2]; CARD8* XAAImageScanlineBuffer[1]; + void (*InitializeAccelerator)(ScrnInfoPtr); } TRIDENTRec, *TRIDENTPtr; typedef struct { @@ -193,6 +198,14 @@ int TVGA8900SetWrite(ScreenPtr pScreen, int bank); int TVGA8900SetReadWrite(ScreenPtr pScreen, int bank); void TridentFindClock(ScrnInfoPtr pScrn, int clock); float CalculateMCLK(ScrnInfoPtr pScrn); +void TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, + RegionPtr damage); +void TRIDENTPointerMoved(int index, int x, int y); +void TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); /* * Trident Chipset Definitions diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c index 5555e4c28..f0d8824c6 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c @@ -23,7 +23,7 @@ * * Trident accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c,v 1.15 2000/10/11 16:35:05 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c,v 1.16 2000/11/03 18:46:13 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -111,6 +111,7 @@ TridentAccelInit(ScreenPtr pScreen) pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = TridentInitializeAccelerator; TridentInitializeAccelerator(pScrn); if (!(pTrident->Chipset == TGUI9440AGi && pScrn->bitsPerPixel > 8)) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c index 6b53c1368..05f529f68 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c @@ -21,7 +21,7 @@ * * Author: Alan Hourihane, alanh@fairlite.demon.co.uk */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.27 2000/10/09 17:09:43 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.28 2000/11/03 18:46:14 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -237,7 +237,7 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pReg->tridentRegs3x4[0x5] = LCD[i].shadow_5; pReg->tridentRegs3x4[0x6] = LCD[i].shadow_6; xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1, - "Overriding Horizontal timings."); + "Overriding Horizontal timings.\n"); } } @@ -526,7 +526,7 @@ TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg) if (pTrident->Chipset >= BLADE3D) OUTW_3x4(RAMDACTiming); if (pTrident->IsCyber) { CARD8 tmp; - + OUTW_3CE(VertStretch); OUTW_3CE(HorStretch); OUTW_3CE(BiosMode); @@ -542,7 +542,7 @@ TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg) OUTW_3x4(0x7); OUTW_3x4(0x10); OUTW_3x4(0x11); - OUTW_3x4(0x96); + OUTW_3x4(0x16); SHADOW_RESTORE(tmp); OUTW_3x4(PreEndControl); OUTW_3x4(PreEndFetch); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c index 8dc7ef045..a8a574d1a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c @@ -28,7 +28,7 @@ * Massimiliano Ghilardi, max@Linuz.sns.it, some fixes to the * clockchip programming code. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.107 2000/09/20 00:09:32 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.108 2000/11/03 18:46:14 eich Exp $ */ #include "xf1bpp.h" #include "xf4bpp.h" @@ -100,6 +100,7 @@ static void TRIDENTDisableMMIO(ScrnInfoPtr pScrn); static void PC98TRIDENTInit(ScrnInfoPtr pScrn); static void PC98TRIDENTEnable(ScrnInfoPtr pScrn); static void PC98TRIDENTDisable(ScrnInfoPtr pScrn); + /* * This is intentionally screen-independent. It indicates the binding * choice made in the first PreInit. @@ -201,6 +202,7 @@ typedef enum { OPTION_SETMCLK, OPTION_MUX_THRESHOLD, OPTION_SHADOW_FB, + OPTION_ROTATE, OPTION_MMIO_ONLY, #if 0 /* obsolete */ @@ -218,6 +220,7 @@ static OptionInfoRec TRIDENTOptions[] = { { OPTION_SETMCLK, "SetMClk", OPTV_FREQ, {0}, FALSE }, { OPTION_MUX_THRESHOLD, "MUXThreshold", OPTV_INTEGER, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, #if 0 /* obsolete */ { OPTION_CYBER_SHADOW, "CyberShadow", OPTV_BOOLEAN, {0}, FALSE }, @@ -423,7 +426,7 @@ tridentLCD LCD[] = { /* 0 3 4 5 6 7 10 11 16 */ { 0,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb,0x08}, { 1,"800x600",40000,0x7f,0x99,0x69,0x99,0x72,0xf0,0x59,0x2d,0x5e,0x08}, { 2,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, - { 3,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, + { 3,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, /*0x96*/ { 4,"1280x1024",108000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, { 5,"1024x600",50500 ,0xa3,0x6,0x8f,0xa0,0xb,0x3e,0xea,0x8c,0xb,0x08}, { 0xff,"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } @@ -432,7 +435,7 @@ tridentLCD LCD[] = { /* 0 3 4 5 6 7 10 11 16 */ tridentLCD LCD[] = { { 1,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb,0x08}, { 3,"800x600",40000,0x7f,0x82,0x6b,0x1b,0x72,0xf8,0x58,0x8c,0x72,0x08}, - { 2,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x24,0x96,0x08}, + { 2,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x24,0x0a,0x08}, { 0,"1280x1024",108000,0xce,0x81,0xa6,0x9a,0x27,0x50,0x00,0x03,0x26,0xa8}, { 0xff,"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; @@ -571,6 +574,9 @@ TRIDENTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int TRIDENTPtr pTrident = TRIDENTPTR(pScrn); CARD8 DPMSCont, PMCont, temp; + if (!pScrn->vtSema) + return; + OUTB(0x3C4, 0x0E); temp = INB(0x3C5); OUTB(0x3C5, 0xC2); @@ -965,42 +971,6 @@ GetAccelPitchValues(ScrnInfoPtr pScrn) } static void -TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; - - Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); - - while(num--) { - width = (pbox->x2 - pbox->x1) * Bpp; - height = pbox->y2 - pbox->y1; - src = pTrident->ShadowPtr + (pbox->y1 * pTrident->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pTrident->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - - while(height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pTrident->ShadowPitch; - } - - pbox++; - } -} - -static void -TRIDENTShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage) -{ - ScrnInfoPtr pScrn; - pScrn = xf86Screens[pScreen->myNum]; - - TRIDENTRefreshArea (pScrn, REGION_NUM_RECTS(damage), REGION_RECTS(damage)); -} - -static void TRIDENTProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -1028,7 +998,8 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags) char *mod = NULL; const char *Sym = ""; Bool ddcLoaded = FALSE; - + char *s; + /* Allocate the TRIDENTRec driverPrivate */ if (!TRIDENTGetRec(pScrn)) { return FALSE; @@ -1235,10 +1206,50 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags) pTrident->MUXThreshold); } if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_SHADOW_FB, FALSE)) { - pTrident->ShadowFB = TRUE; - pTrident->NoAccel = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using \"Shadow Framebuffer\" - acceleration disabled\n"); + if (!pTrident->Linear) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring Option SHADOW_FB" + " in non-Linear Mode\n"); + else if (pScrn->depth < 8) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Tgnoring Option SHADOW_FB" + " when depth < 8"); + else { + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using \"Shadow Framebuffer\" - acceleration disabled\n"); + } + } + pTrident->Rotate = 0; + if ((s = xf86GetOptValString(TRIDENTOptions, OPTION_ROTATE))) { + if (!pTrident->Linear) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring Option ROTATE " + "in non-Linear Mode\n"); + else if (pScrn->depth < 8) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Tgnoring Option ROTATE " + "when depth < 8"); + else { + if(!xf86NameCmp(s, "CW")) { + /* accel is disabled below for shadowFB */ + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + pTrident->HWCursor = FALSE; + pTrident->Rotate = 1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Rotating screen clockwise - acceleration disabled\n"); + } else if(!xf86NameCmp(s, "CCW")) { + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + pTrident->HWCursor = FALSE; + pTrident->Rotate = -1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen" + "counter clockwise - acceleration disabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid" + "value for Option \"Rotate\"\n", s); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid options are \"CW\" or \"CCW\"\n"); + } + } } /* FIXME ACCELERATION */ @@ -2306,6 +2317,7 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) int ret; VisualPtr visual; unsigned char *FBStart; + int width, height, displayWidth; /* * First get the ScrnInfoRec @@ -2364,28 +2376,27 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Setup the visuals we support. */ - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. - */ + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; - if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } miSetPixmapDepths (); /* FIXME - we don't do shadowfb for < 4 */ + displayWidth = pScrn->displayWidth; + if (pTrident->Rotate) { + height = pScrn->virtualX; + width = pScrn->virtualY; + } else { + width = pScrn->virtualX; + height = pScrn->virtualY; + } + if(pTrident->ShadowFB) { - pTrident->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * pScrn->virtualX); - pTrident->ShadowPtr = xalloc(pTrident->ShadowPitch * pScrn->virtualY); - pScrn->displayWidth = pTrident->ShadowPitch / (pScrn->bitsPerPixel >> 3); + pTrident->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width); + pTrident->ShadowPtr = xalloc(pTrident->ShadowPitch * height); + displayWidth = pTrident->ShadowPitch / (pScrn->bitsPerPixel >> 3); FBStart = pTrident->ShadowPtr; } else { pTrident->ShadowFB = FALSE; @@ -2400,22 +2411,22 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) switch (pScrn->bitsPerPixel) { case 1: - ret = xf1bppScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); + ret = xf1bppScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth); break; case 4: - ret = xf4bppScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); + ret = xf4bppScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth); break; case 8: case 16: case 24: case 32: - ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth, pScrn->bitsPerPixel); + ret = fbScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -2520,12 +2531,36 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; if(pTrident->ShadowFB) { + if(pTrident->Rotate) { + if (!pTrident->PointerMoved) { + pTrident->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = TRIDENTPointerMoved; + } + switch (pScrn->bitsPerPixel) { +#if 1 + case 8: pTrident->RefreshArea = TRIDENTRefreshArea8; break; + case 16: pTrident->RefreshArea = TRIDENTRefreshArea16; break; + case 24: pTrident->RefreshArea = TRIDENTRefreshArea24; break; + case 32: pTrident->RefreshArea = TRIDENTRefreshArea32; break; +#else + case 8: shadowInit (pScreen, shadowUpdateRotate8, 0); break; + case 16: shadowInit (pScreen, shadowUpdateRotate16, 0); break; + case 24: shadowInit (pScreen, shadowUpdateRotate32, 0); break; +#endif + } + } else { + pTrident->RefreshArea = TRIDENTRefreshArea; #if 0 - RefreshAreaFuncPtr refreshArea = TRIDENTRefreshArea; - ShadowFBInit(pScreen, refreshArea); + shadowInit (pScreen, shadowUpdatePacked, 0); +#endif + } +#if 1 +#if 0 + ShadowFBInit(pScreen, pTrident->RefreshArea); #else shadowInit (pScreen, TRIDENTShadowUpdate, 0); #endif +#endif } #ifdef DPMSExtension @@ -2642,6 +2677,9 @@ TRIDENTEnterVT(int scrnIndex, int flags) if (!TRIDENTModeInit(pScrn, pScrn->currentMode)) return FALSE; + if (pTrident->InitializeAccelerator) + pTrident->InitializeAccelerator(pScrn); + return TRUE; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c new file mode 100644 index 000000000..a6defb300 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c @@ -0,0 +1,258 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c,v 1.1 2000/11/03 18:46:14 eich Exp $ */ + +/* + Copyright (c) 1999, 2000 The XFree86 Project Inc. + based on code written by Mark Vojkovich <markv@valinux.com> +*/ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "shadowfb.h" +#include "servermd.h" +#include "trident.h" + +void +TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; + + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + + while(num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pTrident->ShadowPtr + (pbox->y1 * pTrident->ShadowPitch) + + (pbox->x1 * Bpp); + dst = pTrident->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pTrident->ShadowPitch; + } + + pbox++; + } +} + +void +TRIDENTShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage) +{ + ScrnInfoPtr pScrn; + pScrn = xf86Screens[pScreen->myNum]; + + (TRIDENTPTR(pScrn))->RefreshArea (pScrn, REGION_NUM_RECTS(damage), + REGION_RECTS(damage)); +} + +void +TRIDENTPointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int newX, newY; + + if(pTrident->Rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + + (*pTrident->PointerMoved)(index, newX, newY); +} + +void +TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pTrident->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pTrident->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch * 2] << 16) | + (src[srcPitch * 3] << 24); + src += srcPitch * 4; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +void +TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch >> 1; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = (CARD16*)pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16*)pTrident->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16*)pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16*)pTrident->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch * 2; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +/* this one could be faster */ +void +TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = pTrident->FbBase + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pTrident->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pTrident->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch * 2] << 16) | + (src[(srcPitch * 2) + 1] << 24); + dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | + (src[(srcPitch * 3) + 1] << 16) | + (src[(srcPitch * 3) + 2] << 24); + dst += 3; + src += srcPitch * 4; + } + srcPtr += pTrident->Rotate * 3; + dstPtr += dstPitch; + } + + pbox++; + } +} + +void +TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch >> 2; + + while(num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(pTrident->Rotate == 1) { + dstPtr = (CARD32*)pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32*)pTrident->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32*)pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32*)pTrident->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile index 49ce1f5a5..dc9de4004 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile @@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/10 1996/09/28 17:29:32 rws $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile,v 1.18 2000/09/20 00:09:33 keithp Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile,v 1.19 2000/11/03 18:46:14 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -22,7 +22,7 @@ INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa \ -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ -I$(XF86SRC)/xf24_32bpp \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h index 709530014..30664b2da 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h,v 1.31 2000/10/17 16:53:17 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h,v 1.32 2000/11/03 18:46:15 eich Exp $ */ @@ -40,18 +40,7 @@ /* Needed for the 1 and 4 bpp framebuffers */ #include "xf1bpp.h" #include "xf4bpp.h" - -/* Drivers using cfb need this */ - -#define PSZ 8 -#include "cfb.h" -#undef PSZ - -/* Drivers supporting bpp 16, 24 or 32 with cfb need these */ - -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" +#include "fb.h" /* Drivers using the XAA interface ... */ #include "xaa.h" diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c index bd62f995d..2d365d9ba 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.74 2000/10/17 16:53:18 tsi Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.75 2000/11/03 18:46:15 eich Exp $ * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -43,17 +43,11 @@ /* All drivers implementing backing store need this */ #include "mibstore.h" -/* - * If using cfb, cfb.h is required. Select the others for the bpp values - * the driver supports. - */ -#define PSZ 8 /* needed for cfb.h */ -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" +#ifdef RENDER +#include "picturestr.h" +#endif + #include "xf86RAC.h" #include "xf86Resources.h" #include "xf86int10.h" @@ -226,6 +220,53 @@ static OptionInfoRec TsengOptions[] = {0}, FALSE} }; +static const char *int10Symbols[] = { + "xf86InitInt10", + "xf86FreeInt10", + NULL +}; + +static const char *vgaHWSymbols[] = { + "vgaHWMapMem", + "vgaHWUnmapMem", + "vgaHWGetHWRec", + "vgaHWGetIOBase", + "vgaHWHandleColormaps", + "vgaHWUnlock", + "vgaHWLock", + "vgaHWSaveScreen", + "vgaHWInit", + "vgaHWSave", + "vgaHWRestore", + "vgaHWBlankScreen", + "vgaHWSeqReset", + "vgaHWProtect", + NULL +}; + +static const char* fbSymbols[] = { + "xf1bppScreenInit", + "xf4bppScreenInit", + "fbScreenInit", + "fbScreenInit", + "fbPictureInit", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + NULL +}; + #ifdef XFree86LOADER static MODULESETUPPROTO(tsengSetup); @@ -264,6 +305,12 @@ tsengSetup(pointer module, pointer opts, int *errmaj, int *errmin) * Modules that this driver always requires can be loaded here * by calling LoadSubModule(). */ + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(vgaHWSymbols, fbSymbols, xaaSymbols, + ramdacSymbols, NULL); /* * The return value must be non-NULL on success even though there @@ -1460,7 +1507,6 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags) TsengPtr pTseng; MessageType from; int i; - char *mod = NULL; if (flags & PROBE_DETECT) return FALSE; @@ -1497,6 +1543,7 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags) #if 1 if (xf86LoadSubModule(pScrn, "int10")) { xf86Int10InfoPtr pInt; + xf86LoaderReqSymLists(int10Symbols, NULL); #if 1 xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); pInt = xf86InitInt10(pTseng->pEnt->index); @@ -1507,7 +1554,7 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags) if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - + xf86LoaderReqSymLists(vgaHWSymbols, NULL); /* * Allocate a vgaHWRec */ @@ -1658,17 +1705,8 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags) } } /* Set the default visual. */ - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* Tseng doesn't support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -1782,43 +1820,46 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags) /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: - mod = "xf1bpp"; + if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf1bppScreenInit", NULL); break; case 4: - mod = "xf4bpp"; - break; - case 8: - mod = "cfb"; - break; - case 16: - mod = "cfb16"; - break; - case 24: - if (pix24bpp == 24) - mod = "cfb24"; - else - mod = "xf24_32bpp"; - break; - case 32: - mod = "cfb32"; + if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf4bppScreenInit", NULL); break; + default: + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + break; } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - TsengFreeRec(pScrn); - return FALSE; - } + /* Load XAA if needed */ if (pTseng->UseAccel) if (!xf86LoadSubModule(pScrn, "xaa")) { TsengFreeRec(pScrn); return FALSE; } + xf86LoaderReqSymLists(xaaSymbols, NULL); /* Load ramdac if needed */ - if (pTseng->HWCursor) + if (pTseng->HWCursor) { if (!xf86LoadSubModule(pScrn, "ramdac")) { TsengFreeRec(pScrn); return FALSE; } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + } /* TsengLock(); */ return TRUE; @@ -1981,18 +2022,6 @@ TsengScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* XXX Fill the screen with black */ /* - * The next step is to setup the screen's visuals, and initialise the - * framebuffer code. In cases where the framebuffer's default - * choices for things like visual layouts and bits per RGB are OK, - * this may be as simple as calling the framebuffer's ScreenInit() - * function. If not, the visuals will need to be setup before calling - * a fb ScreenInit() function and fixed up after. - * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. - */ - - /* * Reset visual list. */ miClearVisualTypes(); @@ -2005,16 +2034,11 @@ TsengScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * miSetVisualTypes for each visual supported. */ - if (pScrn->depth > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + pScrn->defaultVisual)) + return FALSE; + + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -2034,36 +2058,15 @@ TsengScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth); break; - case 8: - ret = cfbScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 16: - ret = cfb16ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 32: - ret = cfb32ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in TsengScrnInit\n", - pScrn->bitsPerPixel); - ret = FALSE; + ret = fbScreenInit(pScreen, pTseng->FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit(pScreen, 0, 0); +#endif break; } if (!ret) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c index 558652a18..494075d00 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c @@ -26,7 +26,7 @@ * * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c,v 1.4 2000/10/27 18:31:04 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c,v 1.5 2000/10/29 14:24:12 tsi Exp $ */ #include "vesa.h" @@ -118,7 +118,7 @@ static IsaChipsets VESAISAchipsets[] = { }; typedef enum { - OPTION_SHADOW_FB, + OPTION_SHADOW_FB } VESAOpts; static OptionInfoRec VESAOptions[] = { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c b/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c index 9726b8219..9649216b3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.45 2000/08/04 16:13:37 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.46 2000/11/03 18:46:15 eich Exp $ */ /* * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. * @@ -776,10 +776,6 @@ GenericEnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) { vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); - /* Map VGA aperture */ - if (!vgaHWMapMem(pScreenInfo)) - return FALSE; - /* Unlock VGA registers */ vgaHWUnlock(pvgaHW); @@ -804,7 +800,6 @@ GenericLeaveGraphics(ScrnInfoPtr pScreenInfo) { GenericRestore(pScreenInfo); vgaHWLock(VGAHWPTR(pScreenInfo)); - vgaHWUnmapMem(pScreenInfo); } @@ -829,6 +824,7 @@ GenericCloseScreen(int scrnIndex, ScreenPtr pScreen) GenericLeaveGraphics(pScreenInfo); pScreenInfo->vtSema = FALSE; } + vgaHWUnmapMem(pScreenInfo); return Closed; } @@ -1066,6 +1062,9 @@ GenericScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Get driver private */ pGenericPriv = GenericGetRec(pScreenInfo); + /* Map VGA aperture */ + if (!vgaHWMapMem(pScreenInfo)) + return FALSE; /* Initialise graphics mode */ if (!GenericEnterGraphics(pScreen, pScreenInfo)) diff --git a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c index e82520f2e..b42160cb4 100644 --- a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c +++ b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c @@ -6,7 +6,7 @@ * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.7 2000/06/13 02:28:35 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.8 2000/11/03 18:46:15 eich Exp $ */ #if 1 #include "misc.h" @@ -35,8 +35,8 @@ typedef void *Pointer; #include "xf86i2c.h" -#define I2C_TIMEOUT(x) /* (x) */ /* Report timeouts */ -#define I2C_TRACE(x) /* (x) */ /* Report progress */ +#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */ +#define I2C_TRACE(x) /*(x)*/ /* Report progress */ /* Set which OSs have bad gettimeofday resolution. */ #if defined(SVR4) && !defined(sun) @@ -87,7 +87,7 @@ I2CUDelay(I2CBusPtr b, int usec) d_secs = (a_secs - b_secs); d_usecs = (a_usecs - b_usecs); diff = d_secs*1000000 + d_usecs; - } while (diff>0 && diff<usec); + } while (diff>0 && diff< (usec + 1)); } } #endif @@ -101,7 +101,7 @@ I2CUDelay(I2CBusPtr b, int usec) * there is no explicit test for conflits. */ -#define RISEFALLTIME 1 /* usec, actually 300 to 1000 ns according to the i2c specs */ +#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */ /* Some devices will hold SCL low to slow down the bus or until * ready for transmission. @@ -117,12 +117,12 @@ I2CRaiseSCL(I2CBusPtr b, int sda, int timeout) int i, scl; b->I2CPutBits(b, 1, sda); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); - for (i = timeout; i > 0; i -= RISEFALLTIME) { + for (i = timeout; i > 0; i -= b->RiseFallTime) { b->I2CGetBits(b, &scl, &sda); if (scl) break; - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); } if (i <= 0) { @@ -158,12 +158,12 @@ I2CStart(I2CBusPtr b, int timeout) int i, scl, sda; b->I2CPutBits(b, 1, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); - for (i = timeout; i > 0; i -= RISEFALLTIME) { + for (i = timeout; i > 0; i -= b->RiseFallTime) { b->I2CGetBits(b, &scl, &sda); if (scl) break; - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); } if (i <= 0) { @@ -194,7 +194,7 @@ I2CStop(I2CDevPtr d) I2CBusPtr b = d->pI2CBus; b->I2CPutBits(b, 0, 0); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); b->I2CPutBits(b, 1, 0); b->I2CUDelay(b, b->HoldTime); @@ -214,7 +214,7 @@ I2CWriteBit(I2CBusPtr b, int sda, int timeout) Bool r; b->I2CPutBits(b, 0, sda); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); r = I2CRaiseSCL(b, sda, timeout); b->I2CUDelay(b, b->HoldTime); @@ -273,7 +273,7 @@ I2CPutByte(I2CDevPtr d, I2CByte data) return FALSE; b->I2CPutBits(b, 0, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); r = I2CRaiseSCL(b, 1, b->HoldTime); @@ -324,7 +324,7 @@ I2CGetByte(I2CDevPtr d, I2CByte *data, Bool last) I2CBusPtr b = d->pI2CBus; b->I2CPutBits(b, 0, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); if (!I2CReadBit(b, &sda, d->ByteTimeout)) return FALSE; @@ -741,6 +741,7 @@ xf86CreateI2CBusRec(void) b->ByteTimeout = 5; b->AcknTimeout = 5; b->StartTimeout = 5; + b->RiseFallTime = RISEFALLTIME; } return b; diff --git a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h index 25c735058..217791033 100644 --- a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h +++ b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h @@ -2,7 +2,7 @@ * Copyright (C) 1998 Itai Nahshon, Michael Schimek */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.5 2000/04/14 12:16:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.6 2000/11/03 18:46:16 eich Exp $ */ #ifndef _XF86I2C_H #define _XF86I2C_H @@ -40,6 +40,7 @@ typedef struct _I2CBusRec { int ByteTimeout; /* usec */ int AcknTimeout; /* usec */ int StartTimeout; /* usec */ + int RiseFallTime; /* usec */ I2CDevPtr FirstDev; I2CBusPtr NextBus; diff --git a/xc/programs/Xserver/hw/xfree86/input/citron/Imakefile b/xc/programs/Xserver/hw/xfree86/input/citron/Imakefile new file mode 100644 index 000000000..6e0fcc6e9 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/input/citron/Imakefile @@ -0,0 +1,31 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/Imakefile,v 1.1 2000/11/02 02:51:20 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = citron.c +OBJS = citron.o + +DRIVER = citron + +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ + -I$(SERVERSRC)/include -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC) + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget($(DRIVER),$(OBJS)) + +InstallObjectModule($(DRIVER),$(MODULEDIR),input) + +#if !defined(XF86DriverSDK) +CppManTarget($(DRIVER),) +InstallModuleManPage($(DRIVER)) +#endif + +DependTarget() + +InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input) diff --git a/xc/programs/Xserver/hw/xfree86/input/citron/citron.c b/xc/programs/Xserver/hw/xfree86/input/citron/citron.c new file mode 100644 index 000000000..517c87500 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/input/citron/citron.c @@ -0,0 +1,2421 @@ +/* + * Copyright (c) 1998 Metro Link Incorporated + * + * 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, cpy, 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 X CONSORTIUM 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. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.c,v 1.4 2000/11/03 13:13:31 tsi Exp $ */ + +/* + * Based, in part, on code with the following copyright notice: + * + * Copyright 1999-2000 by Thomas Thanner, Citron GmbH, Germany. <support@citron.de> + * Copyright 1999-2000 by Peter Kunzmann, Citron GmbH, Germany. <support@citron.de> + * + * 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 Thomas Thanner and Citron GmbH not be used in advertising or + * publicity pertaining to distribution of the software without specific, written + * prior permission. Thomas Thanner and Citron GmbH makes no representations about + * the suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * THOMAS THANNER AND CITRON GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL THOMAS THANNER OR CITRON GMBH BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RSULTING 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. + * + */ + +/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Citron specific extensions: + * + * 1) Configuration file entries: + * a) "SleepTime" Touch idle time in seconds before sleep mode + * (reduced scanning) is entered. + * 0 = immediately; 65535=never; + * default=65535 + * b) "ActivePWM" PWM duty cycle during regular operation. + * default=255 + * c) "SleepPWM" PWM duty cycle during sleep mode. + * default=255 + * d) "ClickMode" Button click emulation mode; + * 1 = Enter Mode + * 2 = Dual Touch Mode + * 3 = Dual Exit Mode + * 4 = Z-Press Mode + * 5 = Z-Press Exit Mode + * default = 1 + * + * 2) Additional modes in SetMode() function: + * (These modes are only activated if the CIT_MODE_EXT macro is defined + * at compile time. Until now the mode values are not defined, yet) + * a) ClickMode_Enter set the button click emulation mode to 1 + * b) ClickMode_Dual set the button click emulation mode to 2 + * c) ClickMode_DualExit set the button click emulation mode to 3 + * d) ClickMode_ZPress set the button click emulation mode to 4 + * e) ClickMode_ZPressExit set the button click emulation mode to 5 + * + *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ +/* + --------------------------------------------------------------------------- + Revision history: + + Ver Date Description of changes Name + --------------------------------------------------------------------------- + 2.03 17.09.00 Reconnect when getting breaks changed, changes + when powering off the system and reconnecting + parser for commands from "xcit" added + "cit_ParseCommand" to set the variables not + only on the touch side but also in the priv rec pk + 2.04 19.10.00 reconnect enhanced pk + ============================================================================ + +*/ + + +#define _citron_C_ +#define PK 0 +#define INITT 0 /* Initialisation of touch in first loop */ + +/* ODD version number enables the debug macros */ +/* EVEN version number is for release */ +#define CITOUCH_VERSION 0x204 +char version[]="Touch Driver V2.04 (c) 1999-2000 Citron GmbH"; + + + +/***************************************************************************** + * Standard Headers + ****************************************************************************/ + +#include <misc.h> +#include <xf86.h> +#define NEED_XF86_TYPES +/*#include <xf86Version.h>*/ +#include <xf86_ansic.h> +/* #define XF86_OS_PRIVS for xf86SoundKbdBell */ +#include <xf86_OSproc.h> +#include <xf86Optrec.h> +#include <xf86Xinput.h> +#include <xisb.h> +#include <exevents.h> /* Needed for InitValuator/Proximity stuff*/ + + +/* I have to explicit declare this function, because I get an error if I compile */ +/* with "#define XF86_OS_PRIVS". I also have to put a "SYMVAR(xf86SoundKbdBell)" */ +/* statement into the "/loader/xf86sym.c file" to be able to access this function (PK) */ +extern void xf86SoundKbdBell(int loudness, int pitch, int duration); + +/* #define CI_TIM */ /* Enable timer */ +#define CIT_BEEP /* enable beep feature */ + +/***************************************************************************** + * Local Headers + ****************************************************************************/ +#include "citron.h" + +/***************************************************************************** + * Variables without includable headers + ****************************************************************************/ + +/***************************************************************************** + * defines + ****************************************************************************/ +#define CIT_DEF_MIN_X 0 +#define CIT_DEF_MAX_X 0xFFFF +#define CIT_DEF_MIN_Y 0 +#define CIT_DEF_MAX_Y 0xFFFF + +#define CIT_BUFFER_SIZE 1024 + + + +/****************************************************************************** + * debugging macro + *****************************************************************************/ +#ifdef DBG +#undef DBG +#endif +#ifdef DEBUG +#undef DEBUG +#endif + +static int debug_level = 0; +#if CITOUCH_VERSION & 0x0001 +#define DEBUG +#endif +#ifdef DEBUG +#define DBG(lvl, f) {if ((lvl) <= debug_level) f;} +#else +#define DBG(lvl, f) +#endif + +/* Debugging levels for various routines */ +#define PP 5 /* cit_ProcessPacket */ +#define RI 6 /* cit_ReadInput */ +#define GP 6 /* cit_GetPacket */ +#define DDS 5 /* DDS package */ +#define DC 5 /* cit_DriverComm */ + +#define XFREE86_V4 + +#ifdef XFREE86_V4 +#define WAIT(t) \ + err = xf86WaitForInput(-1, ((t) * 1000)); \ + if (err == -1) { \ + ErrorF("Citron select error\n"); \ + return !Success; \ + } +#else +#define WAIT(t) \ + timeout.tv_sec = 0; \ + timeout.tv_usec = (t) * 1000; \ + SYSCALL(err = select(0, NULL, NULL, NULL, &timeout)); \ + if (err == -1) { \ + ErrorF("Citron select error : %s\n", strerror(errno)); \ + return !Success; \ + } +#endif + + + + +/***************************************************************************** + * Local Variables + ****************************************************************************/ + + +static InputInfoPtr CitronPreInit(InputDriverPtr drv, IDevPtr dev, int flags); + + +InputDriverRec CITRON = { + 1, + "citron", + NULL, + CitronPreInit, + /*CitronUnInit*/ NULL, + NULL, + 0 +}; + +#ifdef XFree86LOADER + + +/* + *************************************************************************** + * + * Dynamic loading functions + * + *************************************************************************** + */ + + +static XF86ModuleVersionInfo VersionRec = +{ + "citron", /* name of module */ + MODULEVENDORSTRING, /* vendor specific string */ + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, /* Module-specific current version */ + 0, /* Module-specific major version */ + 1, /* Module-specific minor version */ + 1, /* Module-specific patch level */ + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} /* signature of the version info structure */ +}; + + +/* ************************************************************************ + * [SetupProc] -- + * + * called when the module subsection is found in XF86Config + * + * ************************************************************************/ + +static pointer +SetupProc( pointer module, + pointer options, + int *errmaj, + int *errmin ) +{ +/* xf86LoaderReqSymLists(reqSymbols, NULL); */ + xf86AddInputDriver(&CITRON, module, 0); + DBG(5, ErrorF ("%sSetupProc called\n", CI_INFO)); + + return (pointer) 1; +} + +/***************************************************************************** + * [TearDownProc] + ****************************************************************************/ +static void +TearDownProc (pointer p) +{ + DBG(5, ErrorF ("%sTearDownProc Called\n", CI_INFO)); +} + + +XF86ModuleData citronModuleData = { &VersionRec, SetupProc, TearDownProc}; + +#endif /* XFree86LOADER */ + + + + + +/* + * Be sure to set vmin appropriately for your device's protocol. You want to + * read a full packet before returning + */ +static const char *default_options[] = +{ + + "BaudRate", "19200", + "StopBits", "1", + "DataBits", "8", + "Parity", "None", + "Vmin", "3", + "Vtime", "1", + "FlowControl", "None", + "ClearDTR", "" +}; + + +/***************************************************************************** + * Function Definitions + ****************************************************************************/ + + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* [xf86CitronFeedback] */ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* Online driver parameter change */ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +static void +cit_SendtoTouch(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i,j; + unsigned char buf[MAX_BYTES_TO_TRANSFER*2+2]; + + DBG(DDS, ErrorF("%scit_SendtoTouch(numbytes=0x%02X, data[0]=%02x, data[1]=%02x, data[2]=%02x, data[3]=%02x, ...)\n", CI_INFO, priv->dds.numbytes, + priv->dds.data[0], priv->dds.data[1], priv->dds.data[2], priv->dds.data[3],)); + + j=0; + buf[j++] = CTS_STX; /* transmit start of packet */ + + for(i=0; i<priv->dds.numbytes; i++) + { + if (priv->dds.data[i] >= CTS_CTRLMIN && priv->dds.data[i] <= CTS_CTRLMAX) + { /* data has to be encoded */ + buf[j++] = CTS_ESC; + buf[j++] = priv->dds.data[i] | CTS_ENCODE; + } + else buf[j++] = priv->dds.data[i]; + } + buf[j++] = CTS_ETX; /* end of packet */ + + XisbWrite(priv->buffer, buf, j); + + + for(i=0; i<j; i++) + { + if(i%16 == 0) DBG(DDS, ErrorF("\n")); + DBG(DDS, ErrorF("%02x ",buf[i])); + } + + + DBG(DDS, ErrorF("\n")); +} + + +static void +cit_ParseCommand(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i; + + DBG(DDS, ErrorF("%scit_ParseCommand(numbytes=0x%02X, data= ", CI_INFO, priv->dds.numbytes)); + + for(i=0; i<priv->dds.numbytes; i++) + DBG(DDS, ErrorF("%02x ", priv->dds.data[i])); + + DBG(DDS,ErrorF("\n")); + + switch(priv->dds.data[0]&0xff) + { + case C_SETPWM: + priv->pwm_active = priv->dds.data[1]; + priv->pwm_sleep = priv->dds.data[2]; + DBG(DDS, ErrorF("%scit_ParseCommand(PWM Active:%d PWM Sleep:%d \n", CI_INFO, priv->pwm_active, priv->pwm_sleep)); + break; + + case C_SETSLEEPMODE: + if(priv->dds.data[1] == 0) + { + priv->sleep_time_act = priv->dds.data[2] | (priv->dds.data[3] << 8); + } + DBG(DDS, ErrorF("%scit_ParseCommand(Sleep Time act:%d \n", CI_INFO, priv->sleep_time_act)); + break; + + case C_SETDOZEMODE: + if(priv->dds.data[1] == 0) + { + priv->doze_time_act = priv->dds.data[2] | (priv->dds.data[3] << 8); + } + DBG(DDS, ErrorF("%scit_ParseCommand(Doze Time act:%d \n", CI_INFO, priv->doze_time_act)); + break; + + case C_SETAREAPRESSURE: + priv->button_threshold = priv->dds.data[1]; + DBG(DDS, ErrorF("%scit_ParseCommand(Button Threshold:%d \n", CI_INFO, priv->button_threshold)); + break; + } +} + + + +static void +cit_DriverComm(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i; + unsigned short tmp; + + DBG(DC, ErrorF("%scit_DriverComm(numbytes=0x%02X, data[1]=%02x, ...)\n", CI_INFO, priv->dds.numbytes, priv->dds.data[1])); + + i=1; + switch(priv->dds.data[i++]) /* command word */ + { + case D_SETCLICKMODE: + priv->click_mode = priv->dds.data[i++]; + ErrorF("%sClick Mode: %d\n", CI_INFO, priv->click_mode); + break; + + case D_BEEP: + priv->beep = priv->dds.data[i++]; + ErrorF("%sBeep: %s\n", CI_INFO, (priv->beep > 0) ? "activated":"not activated"); + break; + + case D_SETBEEP: + priv->press_vol = priv->dds.data[i++]; + ErrorF("%sBeep Pressure Volume: %d\n", CI_INFO, priv->press_vol); + tmp = priv->dds.data[i++]; + tmp += priv->dds.data[i++] << 8; + priv->press_pitch = tmp; + ErrorF("%sBeep Pressure Pitch: %d\n", CI_INFO, priv->press_pitch); + priv->press_dur = priv->dds.data[i++]; + ErrorF("%sBeep Pressure Duration: %d\n", CI_INFO, priv->press_dur); + priv->rel_vol = priv->dds.data[i++]; + ErrorF("%sBeep Release Volume: %d\n", CI_INFO, priv->rel_vol); + tmp = priv->dds.data[i++]; + tmp += priv->dds.data[i++] << 8; + priv->rel_pitch = tmp; + ErrorF("%sBeep Release Pitch: %d\n", CI_INFO, priv->rel_pitch); + priv->rel_dur = priv->dds.data[i++]; + ErrorF("%sBeep Release Duration: %d\n", CI_INFO, priv->rel_dur); + break; + + default: + ErrorF("%sNot known command: %d\n", CI_WARNING, priv->dds.data[1]); + + } +} + + +static void +xf86CitronPrint (int nr, LedCtrl *ctrl) +{ + DBG(8, ErrorF("%s------------------------------------------\n", CI_INFO)); + DBG(8, ErrorF("%sxf86CitronFeedback%d(dev, ctrl)\n", CI_INFO, nr)); + DBG(8, ErrorF("%s ctrl->led_values.......:%d [0x%08lX]\n", CI_INFO, ctrl->led_values, ctrl->led_values)); + DBG(8, ErrorF("%s ctrl->led_mask.........:%d [0x%08lX]\n", CI_INFO, ctrl->led_mask, ctrl->led_mask)); + DBG(8, ErrorF("%s ctrl->id...............:%d\n", CI_INFO, ctrl->id)); +} + + +static void +xf86CitronFeedback0 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + COMMAND *cmd; + + DBG(DDS, ErrorF("%sEntering xf86CitronFeedback0()...\n",CI_INFO)); + + cmd = (COMMAND *)&ctrl->led_values; + + DBG(DDS, ErrorF("%scmd->packet = %d\n", CI_INFO, cmd->packet)); + + + if(cmd->packet == 0) /* test if first packet has come (with number of bytes in first byte) */ + { + if(cmd->par[0] == 0) /* test if something is to do at all */ + return; + priv->dds.curbyte = 2; + priv->dds.numbytes = cmd->par[0]; + priv->dds.data[0] = cmd->par[1]; + priv->dds.data[1] = cmd->par[2]; + priv->dds.packet = 1; + } + else + { + if(priv->dds.packet == cmd->packet) + { + priv->dds.data[priv->dds.packet*3-1] = cmd->par[0]; + priv->dds.data[priv->dds.packet*3] = cmd->par[1]; + priv->dds.data[priv->dds.packet*3+1] = cmd->par[2]; + priv->dds.packet++; + priv->dds.curbyte += 3; + } + else + DBG(DDS, ErrorF("%sPacket error: should be %d is %d\n", CI_WARNING, priv->dds.packet, cmd->packet)); + + } + DBG(DDS, ErrorF("%snumbytes = %d curbyte=%d\n", CI_INFO, priv->dds.numbytes, priv->dds.curbyte)); + if(priv->dds.curbyte >= priv->dds.numbytes) + { + if(priv->dds.data[0] == DRIVCOMM) + cit_DriverComm(dev); /* process command in the driver */ + else + { + cit_ParseCommand(dev); /* First parse command and set parameters in priv rec */ + cit_SendtoTouch(dev); /* send message to the touch and execute command there */ + } + } + + DBG(DDS, ErrorF("%s 1 led_values = %08x\n", CI_INFO, ctrl->led_values)); + ctrl->led_values = 0x12345678; + DBG(DDS, ErrorF("%s 2 led_values = %08x\n", CI_INFO, ctrl->led_values)); + +} + + +static void +xf86CitronFeedback1 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + static int test = 0; + xf86CitronPrint (1, ctrl); + ctrl->led_values = 0x8765432; + ctrl->led_mask = test++; +} + +static void +xf86CitronFeedback2 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + xf86CitronPrint (2, ctrl); + ctrl->led_values = (unsigned long)GetTimeInMillis(); + ctrl->led_mask = (unsigned long)GetTimeInMillis()&0xff; +} + + + +#if(PK) +/* Hexdump a number of Words */ +/* len is number of words to dump */ +static void hexdump (void *ioaddr, int len) +{ + int i; + unsigned long *ptr = (unsigned long *)ioaddr; + + ErrorF(" ADDR 0-3 4-7 8-B C-F\n"); + ErrorF("---------+-----+----+----+----+----+----+----+----\n"); + + while (len > 0) + { + ErrorF ("%08X: ", (unsigned long)ptr); + + for (i=0;i < ( (len>4)?4:len);i++) + ErrorF (" %08x", *ptr++); + ErrorF ("\n"); + len -= 8; + } + + ErrorF("---------+-----+----+----+----+----+----+----+----\n"); +} +#endif + +#ifdef CIT_TIM +/***************************************************************************** + * [cit_StartTimer] + ****************************************************************************/ + +static void +cit_StartTimer(cit_PrivatePtr priv) +{ + priv->timer_ptr = TimerSet(priv->timer_ptr, 0, priv->timer_val1, + priv->timer_callback, (pointer)priv); + DBG(5, ErrorF ("%scit_StartTimer called PTR=%08x\n", CI_INFO, priv->timer_ptr)); +} + + +/***************************************************************************** + * [cit_CloseTimer] + ****************************************************************************/ +static void +cit_CloseTimer(cit_PrivatePtr priv) +{ + + DBG(5, ErrorF ("%scit_CloseTimer called PTR=%08x\n", CI_INFO, priv->timer_ptr)); + if(priv->timer_ptr) + { + TimerFree(priv->timer_ptr); + priv->timer_ptr = NULL; + } + else + DBG(5, ErrorF ("%scit_CloseTimer: Nothing to close\n", CI_WARNING)); +} + + + +/***************************************************************************** + * [cit_DualTouchTimer] + ****************************************************************************/ +static CARD32 +cit_DualTouchTimer(OsTimerPtr timer, CARD32 now, pointer arg) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) arg; + int sigstate; + + DBG(5, ErrorF ("%scit_DualTouchTimer called %d\n", CI_INFO, GetTimeInMillis())); + + priv->packet[0] = R_EXIT; /* build a exit message */ + priv->packet[1] = LOBYTE(priv->raw_x); + priv->packet[2] = HIBYTE(priv->raw_x); + priv->packet[3] = LOBYTE(priv->raw_y); + priv->packet[4] = HIBYTE(priv->raw_y); + priv->packeti = 5; + priv->fake_exit = TRUE; + sigstate = xf86BlockSIGIO (); + + + priv->local->read_input(priv->local); /* faking up an exit message */ + xf86UnblockSIGIO (sigstate); + + DBG(3, ErrorF ("%scit_DualTouchTimer: Faking Exit Message Sent\n", CI_INFO)); + + return (0); /* stop timer */ +} + +#endif + +/***************************************************************************** + * [CitronPreInit] + ****************************************************************************/ +static InputInfoPtr +CitronPreInit (InputDriverPtr drv, IDevPtr dev, int flags) +{ + LocalDevicePtr local = xf86AllocateInput(drv, 0); + cit_PrivatePtr priv = (cit_PrivatePtr) xcalloc (1, sizeof (cit_PrivateRec)); + char *s; +#if(INITT) + int errmaj, errmin; +#endif + + ErrorF ("%sCitronPreInit called - xcalloc=%d\n", CI_INFO, sizeof(cit_PrivateRec)); +/* DBG(2, ErrorF("\txf86Verbose=%d\n", xf86Verbose));*/ + if ((!local) || (!priv)) + { + ErrorF("%s\t- unable to allocate structures!\n", CI_ERROR); + goto SetupProc_fail; + } + + + /* this results in an xf86strdup that must be freed later */ + local->name = xf86SetStrOption(local->options, "DeviceName", "CiTouch"); + ErrorF("%sDevice name: %s\n", CI_INFO, local->name); + + local->type_name = XI_TOUCHSCREEN; + + /* + * Standard setup for the local device record + */ + local->device_control = DeviceControl; + local->read_input = ReadInput; + local->control_proc = ControlProc; + local->close_proc = CloseProc; + local->switch_mode = SwitchMode; + local->conversion_proc = ConvertProc; + local->dev = NULL; + local->private = priv; + local->private_flags = 0; + local->history_size = xf86SetIntOption(local->options, "HistorySize", 0); + local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; + local->conf_idev = dev; + + xf86CollectInputOptions(local, default_options, NULL); + +/* xf86OptionListReport(local->options); */ + + + + debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); + if(debug_level) + { +#ifdef DEBUG + ErrorF("%sDebug level set to %d\n", CI_CONFIG, debug_level); +#else + ErrorF("%sDebug not available\n", CI_INFO); +#endif + } + + +#if(INITT) + + + DBG(5, ErrorF ("%sOpenSerial will be called\n", CI_INFO)); + + local->fd = xf86OpenSerial (local->options); + if (local->fd == -1) + { + ErrorF ("%s\t- unable to open device %s\n", CI_ERROR, xf86FindOptionValue (local->options, "Device")); + goto SetupProc_fail; + } + + DBG(6, ErrorF("%s\t+ %s opened successfully.\n", CI_INFO, xf86FindOptionValue (local->options, "Device"))); +#endif + + /* + * Process the options for the IRT + */ + priv->screen_num = xf86SetIntOption(local->options, "ScreenNumber", 0); + ErrorF("%sAssociated screen: %d\n", CI_CONFIG, priv->screen_num); + priv->min_x = xf86SetIntOption(local->options, "MinX", CIT_DEF_MIN_X); + ErrorF("%sMinimum x position: %d\n", CI_CONFIG, priv->min_x); + priv->max_x = xf86SetIntOption(local->options, "MaxX", CIT_DEF_MAX_X); + ErrorF("%sMaximum x position: %d\n", CI_CONFIG, priv->max_x); + priv->min_y = xf86SetIntOption(local->options, "MinY", CIT_DEF_MIN_Y); + ErrorF("%sMinimum y position: %d\n", CI_CONFIG, priv->min_y); + priv->max_y = xf86SetIntOption(local->options, "MaxY", CIT_DEF_MAX_Y); + ErrorF("%sMaximum y position: %d\n", CI_CONFIG, priv->max_y); + priv->button_number = xf86SetIntOption(local->options, "ButtonNumber", 1); + ErrorF("%sButton Number: %d\n", CI_CONFIG, priv->button_number); + priv->button_threshold = xf86SetIntOption(local->options, "ButtonThreshold", 10); + ErrorF("%sButton Threshold: %d\n", CI_CONFIG, priv->button_threshold); + priv->sleep_mode = xf86SetIntOption(local->options, "SleepMode", 0); + ErrorF("%sSleep Mode: %d\n", CI_CONFIG, priv->sleep_mode); + priv->sleep_time_act = xf86SetIntOption(local->options, "SleepTime", 65535); + ErrorF("%sSleep Time: %d\n", CI_CONFIG, priv->sleep_time_act); + priv->sleep_time_scan = xf86SetIntOption(local->options, "SleepScan", 65535); + ErrorF("%sSleep Scan: %d\n", CI_CONFIG, priv->sleep_time_scan); + priv->pwm_active = xf86SetIntOption(local->options, "PWMActive", 255); + ErrorF("%sPWM Active: %d\n", CI_CONFIG, priv->pwm_active); + priv->pwm_sleep = xf86SetIntOption(local->options, "PWMSleep", 255); + ErrorF("%sPWM Sleep: %d\n", CI_CONFIG, priv->pwm_sleep); + priv->click_mode = xf86SetIntOption(local->options, "ClickMode", NO_CLICK_MODE); + ErrorF("%sClick Mode: %d\n", CI_CONFIG, priv->click_mode); + priv->origin = xf86SetIntOption(local->options, "Origin", 0); + ErrorF("%sOrigin: %d\n", CI_CONFIG, priv->origin); + priv->doze_mode = xf86SetIntOption(local->options, "DozeMode", 0); + ErrorF("%sDoze Mode: %d\n", CI_CONFIG, priv->doze_mode); + priv->doze_time_act = xf86SetIntOption(local->options, "DozeTime", 10); + ErrorF("%sDoze Time: %d\n", CI_CONFIG, priv->doze_time_act); + priv->doze_time_scan = xf86SetIntOption(local->options, "DozeScan", 25); + ErrorF("%sDoze Scan: %d\n", CI_CONFIG, priv->doze_time_scan); + priv->delta_x = xf86SetIntOption(local->options, "DeltaX", 0) & 0xff; + ErrorF("%sDelta X: %d\n", CI_CONFIG, priv->delta_x); + priv->delta_y = xf86SetIntOption(local->options, "DeltaY", 0) & 0xff; + ErrorF("%sDelta Y: %d\n", CI_CONFIG, priv->delta_y); + priv->beep = xf86SetIntOption(local->options, "Beep", 0); + ErrorF("%sBeep: %s\n", CI_CONFIG, (priv->beep > 0) ? "activated":"not activated"); + priv->press_vol = xf86SetIntOption(local->options, "PressVol", 100); + ErrorF("%sBeep Pressure Volume: %d\n", CI_CONFIG, priv->press_vol); + priv->press_pitch = xf86SetIntOption(local->options, "PressPitch", 880); + ErrorF("%sBeep Pressure Pitch: %d\n", CI_CONFIG, priv->press_pitch); + priv->press_dur = xf86SetIntOption(local->options, "PressDur", 15) & 0xff; + ErrorF("%sBeep Pressure Duration: %d\n", CI_CONFIG, priv->press_dur); + priv->rel_vol = xf86SetIntOption(local->options, "ReleaseVol", 100); + ErrorF("%sBeep Release Volume: %d\n", CI_CONFIG, priv->rel_vol); + priv->rel_pitch = xf86SetIntOption(local->options, "ReleasePitch", 1200); + ErrorF("%sBeep Release Pitch: %d\n", CI_CONFIG, priv->rel_pitch); + priv->rel_dur = xf86SetIntOption(local->options, "ReleaseDur", 10) & 0xff; + ErrorF("%sBeep Release Duration: %d\n", CI_CONFIG, priv->rel_dur); + priv->beam_timeout = xf86SetIntOption(local->options, "BeamTimeout", 30) & 0xffff; + ErrorF("%sBeam Timeout: %d\n", CI_CONFIG, priv->beam_timeout); + priv->touch_time = xf86SetIntOption(local->options, "TouchTime", 0) & 0xff; + ErrorF("%sTouch Time: %d\n", CI_CONFIG, priv->touch_time); + priv->enter_count = xf86SetIntOption(local->options, "EnterCount", 3); + ErrorF("%sEnter Count: %d\n", CI_CONFIG, priv->enter_count); + priv->max_dual_count = xf86SetIntOption(local->options, "DualCount", MAX_DUAL_TOUCH_COUNT); + ErrorF("%sDual Count: %d\n", CI_CONFIG, priv->max_dual_count); + +/* trace the min and max values */ + priv->raw_min_x = CIT_DEF_MAX_X; + priv->raw_max_x = 0; + priv->raw_min_y = CIT_DEF_MAX_Y; + priv->raw_max_y = 0; + +#ifdef CIT_TIM +/* preset timer values */ + priv->timer_ptr = NULL; + priv->timer_val1 = 0; + priv->timer_val2 = 0; + priv->timer_callback = NULL; +#endif + + priv->fake_exit = FALSE; + priv->enter_touched = 0; /* preset */ + priv->local = local; /* save local device pointer */ + + DBG(6, ErrorF("%s\t+ options read\n", CI_INFO)); + s = xf86FindOptionValue (local->options, "ReportingMode"); + if ((s) && (xf86NameCmp (s, "raw") == 0)) + priv->reporting_mode = TS_Raw; + else + priv->reporting_mode = TS_Scaled; + +#if(INITT) + /* + * Create an X Input Serial Buffer, because IRT is connected to a serial port + */ + priv->buffer = XisbNew (local->fd, CIT_BUFFER_SIZE); +#endif + priv->proximity = FALSE; + priv->button_down = FALSE; + priv->dual_touch_count = 0; + priv->dual_flg = 0; + priv->state = 0; + priv->lex_mode = cit_idle; + priv->last_x = 0; + priv->last_y = 0; + priv->query_state = 0; /* first query */ + + +#if(INITT) + DBG (8, XisbTrace (priv->buffer, 1)); + + + /* + * Verify that the IRT is attached and functional + */ + if (QueryHardware (local, &errmaj, &errmin) != Success) + { + ErrorF ("%s\t- Unable to query/initialize Citron hardware.\n", CI_INFO); + goto SetupProc_fail; + } +#endif + + xf86ProcessCommonOptions(local, local->options); + local->flags |= XI86_CONFIGURED; +#if(PK) + if (xf86FindOption (local->options, "DemandLoaded")) + { + DBG (5, ErrorF ("%s\tCitron module was demand loaded\n", CI_INFO)); + xf86AddLocalDevice (local, TRUE); + } + else + xf86AddLocalDevice (local, FALSE); +#endif + + if (local->fd >= 0) + { + RemoveEnabledDevice (local->fd); +#if(INITT) + if (priv->buffer) + { + XisbFree(priv->buffer); + priv->buffer = NULL; + } + xf86CloseSerial(local->fd); +#endif + } + + + /* return the LocalDevice */ + DBG(5, ErrorF ("%sCitronPreInit success\n", CI_INFO)); + return (local); + + + /* + * If something went wrong, cleanup and return NULL + */ + SetupProc_fail: +#if(INITT) + if ((local) && (local->fd)) + xf86CloseSerial (local->fd); +#endif + if ((local) && (local->name)) + xfree (local->name); + if (local) + xfree (local); +#if(INITT) + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); +#endif + if (priv) + xfree (priv); + ErrorF ("%sCitronPreInit returning NULL\n", CI_ERROR); + return (NULL); +} + + + +/***************************************************************************** + * [DeviceControl] + ****************************************************************************/ +static Bool +DeviceControl (DeviceIntPtr dev, int mode) +{ + Bool RetVal; + + DBG(5, ErrorF ("%sDeviceControl called; mode = %d\n", CI_INFO, mode)); + switch (mode) + { + case DEVICE_INIT: + DBG(6, ErrorF ("%s\tINIT\n", CI_INFO)); + DeviceInit (dev); + RetVal = Success; + break; + case DEVICE_ON: + DBG(6, ErrorF ("%s\tON\n", CI_INFO)); + RetVal = DeviceOn (dev); + break; + case DEVICE_OFF: + DBG(6, ErrorF ("%s\tOFF\n", CI_INFO)); + RetVal = DeviceOff (dev); + break; + case DEVICE_CLOSE: + DBG(6, ErrorF ("%s\tCLOSE\n", CI_INFO)); + RetVal = DeviceClose (dev); + break; + default: + ErrorF ("%sDeviceControl Mode (%d) not found\n", CI_ERROR, mode); + RetVal = BadValue; + } + return(RetVal); +} + +/***************************************************************************** + * [DeviceOn] + ****************************************************************************/ +static Bool +DeviceOn (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + int errmaj, errmin; + + DBG(5, ErrorF ("%sDeviceOn called\n", CI_INFO)); + + local->fd = xf86OpenSerial(local->options); + if (local->fd == -1) + { + xf86Msg(X_WARNING, "%s%s: cannot open input device\n", CI_ERROR, local->name); + goto DeviceOn_fail; + } + priv->buffer = XisbNew (local->fd, CIT_BUFFER_SIZE); + if (!priv->buffer) + goto DeviceOn_fail; + + xf86FlushInput(local->fd); + + if (QueryHardware (local, &errmaj, &errmin) != Success) + { + ErrorF ("%s\t- Unable to query/initialize Citron hardware.\n", CI_ERROR); + goto DeviceOn_fail; + } + + AddEnabledDevice (local->fd); + dev->public.on = TRUE; + return (Success); + + /* + * If something went wrong, cleanup + */ + DeviceOn_fail: + if ((local) && (local->fd)) + xf86CloseSerial (local->fd); + + if ((local) && (local->name)) + xfree (local->name); + if (local) + { + xfree (local); + local = NULL; + } + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); + if (priv) + { + xfree (priv); + priv = NULL; + } + ErrorF ("%sDeviceOn failed\n", CI_ERROR); + return (!Success); + + + +} + +/***************************************************************************** + * [DeviceOff] + ****************************************************************************/ +static Bool +DeviceOff (DeviceIntPtr dev) +{ + DBG(5, ErrorF ("%sDeviceOff called\n", CI_INFO)); + return DeviceClose(dev); +} + +/***************************************************************************** + * [DeviceClose] + ****************************************************************************/ +static Bool +DeviceClose (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + int c; + + DBG(5, ErrorF ("%sDeviceClose called\n",CI_INFO)); + + cit_Flush(priv->buffer); + + cit_SendCommand(priv->buffer, C_SOFTRESET, 0); +#ifdef CIT_TIM + cit_CloseTimer(priv); /* Close timer if started */ +#endif + XisbTrace(priv->buffer, 1); /* trace on */ + XisbBlockDuration (priv->buffer, 500000); + c = XisbRead (priv->buffer); + if(c == CTS_NAK) + { + DBG(6, ErrorF ("%sTouch Reset executed\n",CI_INFO)); + } + else + { + DBG(6, ErrorF ("%sTouch Reset not executed\n",CI_ERROR)); + } + + +/* Now free all allocated memory */ + if (local->fd >= 0) + { + RemoveEnabledDevice (local->fd); + if (priv->buffer) + { + XisbFree(priv->buffer); + priv->buffer = NULL; + } + xf86CloseSerial(local->fd); + local->fd = 0; + } + + dev->public.on = FALSE; + ErrorF("%sx-range = [%d..%d]\n", CI_INFO, priv->raw_min_x, priv->raw_max_x); + ErrorF("%sy-range = [%d..%d]\n", CI_INFO, priv->raw_min_y, priv->raw_max_y); + + return (Success); +} + + +/***************************************************************************** + * [DeviceInit] + ****************************************************************************/ +static Bool +DeviceInit (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + unsigned char map[] = + {0, 1}; + + DBG (5, ErrorF("%sDeviceInit called\n", CI_INFO)); + /* + * these have to be here instead of in the SetupProc, because when the + * SetupProc is run and server startup, screenInfo is not setup yet + */ + priv->screen_width = screenInfo.screens[priv->screen_num]->width; + priv->screen_height = screenInfo.screens[priv->screen_num]->height; + + DBG (5, ErrorF("%sScreen Number: %d Screen Width: %d Screen Height: %d\n", CI_INFO, + priv->screen_num, priv->screen_width, priv->screen_height)); + + /* + * Device reports button press for up to 1 button. + */ + if (InitButtonClassDeviceStruct (dev, 1, map) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ButtonClassDeviceStruct\n", CI_ERROR); + return !Success; + } + + /* + * Device reports motions on 2 axes in absolute coordinates. + * Axes min and max values are reported in raw coordinates. + * Resolution is computed roughly by the difference between + * max and min values scaled from the approximate size of the + * screen to fit one meter. + * Device may reports touch pressure on the 3rd axis. + */ + if (InitValuatorClassDeviceStruct (dev, 2, xf86GetMotionEvents, + local->history_size, Absolute) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ValuatorClassDeviceStruct\n", CI_ERROR); + return !Success; + } + else + { + InitValuatorAxisStruct (dev, 0, priv->min_x, priv->max_x, + CIT_DEF_MAX_X, + CIT_DEF_MIN_X /* min_res */ , + CIT_DEF_MAX_X /* max_res */ ); + InitValuatorAxisStruct (dev, 1, priv->min_y, priv->max_y, + CIT_DEF_MAX_Y, + CIT_DEF_MIN_Y /* min_res */ , + CIT_DEF_MAX_Y /* max_res */ ); + } + + if (InitProximityClassDeviceStruct (dev) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ProximityClassDeviceStruct\n", CI_ERROR); + return !Success; + } + + + /* + * Use the LedFeedbackClass to set some driver parameters + */ + + /* ID=0 --> Return driver version (RO) */ + + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback0) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=0\n"); + return !Success; + } + /* ID=1 --> ENTER_COUNT */ + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback1) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=1\n"); + return !Success; + } + + /* ID=2 --> */ + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback2) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=2\n"); + return !Success; + } + + + /* + * Allocate the motion events buffer. + */ + xf86MotionHistoryAllocate (local); + return (Success); +} + +/***************************************************************************** + * [ReadInput] + ****************************************************************************/ +static void +ReadInput (LocalDevicePtr local) +{ + int x, y; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(RI, ErrorF("%sReadInput called\n", CI_INFO)); + + /* + * set blocking to -1 on the first call because we know there is data to + * read. Xisb automatically clears it after one successful read so that + * succeeding reads are preceeded by a select with a 0 timeout to prevent + * read from blocking indefinately. + */ + if(!priv->fake_exit) + { + XisbBlockDuration (priv->buffer, -1); + DBG(RI, ErrorF("%sXisbBlockDuration = -1\n", CI_INFO)); + } + while ( +#ifdef CIT_TIM + priv->fake_exit || +#endif + (cit_GetPacket (priv) == Success)) + { + cit_ProcessPacket(priv); + + + + if (priv->reporting_mode == TS_Scaled) + { + x = xf86ScaleAxis (priv->raw_x, 0, priv->screen_width, priv->min_x, + priv->max_x); + y = xf86ScaleAxis (priv->raw_y, 0, priv->screen_height, priv->min_y, + priv->max_y); + DBG(RI, ErrorF("%s\tscaled coordinates: (%d, %d)\n", CI_INFO, x, y)); + } + else + { + x = priv->raw_x; + y = priv->raw_y; + } + + xf86XInputSetScreen (local, priv->screen_num, x, y); + + if ((priv->proximity == FALSE) && (priv->state & CIT_TOUCHED)) + { + priv->proximity = TRUE; + xf86PostProximityEvent (local->dev, 1, 0, 2, x, y); + DBG(RI, ErrorF("%s\tproximity(TRUE, x=%d, y=%d)\n", CI_INFO, x, y)); + } + + /* + * Send events. + * + * We *must* generate a motion before a button change if pointer + * location has changed as DIX assumes this. This is why we always + * emit a motion, regardless of the kind of packet processed. + * First test if coordinates have changed a predefined amount of pixels + */ + + if ( ((x >= (priv->last_x + priv->delta_x)) || + (x <= (priv->last_x - priv->delta_x)) || + (y >= (priv->last_y + priv->delta_y)) || + (y <= (priv->last_y - priv->delta_y))) || + ( ((x < priv->delta_x) || + (x > (priv->screen_width - priv->delta_x))) || + ((y < priv->delta_x) || + (y > (priv->screen_height - priv->delta_y)))) ) + { + xf86PostMotionEvent (local->dev, TRUE, 0, 2, x, y); + DBG(RI, ErrorF("%s\tPostMotionEvent(x=%d, y=%d, last_x=%d, last_y=%d)\n", CI_INFO, + x, y, priv->last_x, priv->last_y)); + + priv->last_x = x; /* save cooked data */ + priv->last_y = y; + } + + /* + * Emit a button press or release. + */ + + if ((priv->button_down == FALSE) && (priv->state & CIT_BUTTON)) + { + if(priv->enter_touched < priv->enter_count) + priv->enter_touched++; + + if(priv->enter_touched == priv->enter_count) + { + priv->enter_touched++; /* increment count one more time to prevent further enter events */ + xf86PostButtonEvent (local->dev, TRUE, + priv->button_number, 1, 0, 2, x, y); + cit_Beep(priv, 1); + + DBG(RI, ErrorF("%s\tPostButtonEvent(DOWN, x=%d, y=%d)\n", CI_INFO, x, y)); + + priv->button_down = TRUE; + } + } + + if ((priv->button_down == TRUE) && !(priv->state & CIT_BUTTON)) + { + xf86PostButtonEvent (local->dev, TRUE, + priv->button_number, 0, 0, 2, x, y); + cit_Beep(priv, 0); + priv->enter_touched = 0; /* reset coordinate report counter */ + DBG(RI, ErrorF("%s\tPostButtonEvent(UP, x=%d, y=%d)\n", CI_INFO, x, y)); + priv->button_down = FALSE; + } + /* + * the untouch should always come after the button release + */ + if ((priv->proximity == TRUE) && !(priv->state & CIT_TOUCHED)) + { + priv->proximity = FALSE; + xf86PostProximityEvent (local->dev, 0, 0, 2, x, y); + DBG(RI, ErrorF("%s\tproximity(FALSE, x=%d, y=%d)\n", CI_INFO, x, y)); + } + + + DBG (RI, ErrorF ("%sTouchScreen: x(%d), y(%d), %s\n", + CI_INFO, x, y, + (priv->state == CIT_TOUCHED) ? "Touched" : "Released")); + +#ifdef CIT_TIM + if(priv->fake_exit) + { + priv->fake_exit = FALSE; /* do not sent any further faked exit messages */ + return; + } +#endif + } + DBG(RI, ErrorF("%sExit ReadInput\n", CI_INFO)); +} + +/***************************************************************************** + * [ControlProc] + ****************************************************************************/ +static int +ControlProc (LocalDevicePtr local, xDeviceCtl * control) +{ + xDeviceTSCalibrationCtl *c = (xDeviceTSCalibrationCtl *) control; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(5, ErrorF("%sControlProc called\n", CI_INFO)); + + priv->min_x = c->min_x; + priv->max_x = c->max_x; + priv->min_y = c->min_y; + priv->max_y = c->max_y; + + + return (Success); +} + +/***************************************************************************** + * [CloseProc] + ****************************************************************************/ +static void +CloseProc (LocalDevicePtr local) +{ + DBG(5, ErrorF("%sCloseProc called\n", CI_INFO)); +} + +/***************************************************************************** + * [SwitchMode] + ****************************************************************************/ +static int +SwitchMode (ClientPtr client, DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + DBG(5, ErrorF("%sSwitchMode called; mode = %d\n", CI_INFO, mode)); + if ((mode == TS_Raw) || (mode == TS_Scaled)) + { + priv->reporting_mode = mode; + DBG(6, ErrorF("%s\treporting mode = %s\n", CI_INFO, mode==TS_Raw?"raw":"scaled")); + return (Success); + } + else if ((mode == SendCoreEvents) || (mode == DontSendCoreEvents)) + { + xf86XInputSetSendCoreEvents (local, (mode == SendCoreEvents)); + DBG(6, ErrorF("%s\tmode = %sSend Core Events\n", CI_INFO, mode==DontSendCoreEvents?"Don\'t ":"")); + return (Success); + } +#ifdef CIT_MODE_EXT + else if (mode == ClickMode_Enter) + { + priv->click_mode = CM_ENTER; + DBG(6, ErrorF("%s\tset click mode to ENTER\n", CI_INFO)); + return (Success); + } + else if (mode == ClickMode_Dual) + { + priv->click_mode = CM_DUAL; + DBG(6, ErrorF("%s\tset click mode to DUAL TOUCH\n", CI_INFO)); + return (Success); + } + else if (mode == ClickMode_ZPress) + { + priv->click_mode = CM_ZPRESS; + DBG(6, ErrorF("%s\tset click mode to Z-Press\n", CI_INFO)); + return (Success); + } +#endif + else + { + ErrorF("%sUnknown mode for Citron Touchscreen Switchmode Function: 0x%02x!\n", CI_ERROR, mode); + return (!Success); + } +} + +/***************************************************************************** + * [ConvertProc] + ****************************************************************************/ +static Bool +ConvertProc (LocalDevicePtr local, + int first, + int num, + int v0, + int v1, + int v2, + int v3, + int v4, + int v5, + int *x, + int *y) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(5, ErrorF("%sConvertProc called(first=%d, num=%d, v0=%d, v1=%d, v2=%d, v3=%d\n", + CI_INFO, first, num, v0, v1, v2, v3)); + if (priv->reporting_mode == TS_Raw) + { + *x = xf86ScaleAxis (v0, 0, priv->screen_width, priv->min_x, + priv->max_x); + *y = xf86ScaleAxis (v1, 0, priv->screen_height, priv->min_y, + priv->max_y); + } + else + { + *x = v0; + *y = v1; + } + DBG(6, ErrorF("%s\t+ x=%d, y=%d\n",CI_INFO, *x, *y)); + return (TRUE); +} + +/***************************************************************************** + * [QueryHardware] + ****************************************************************************/ +static Bool +QueryHardware (LocalDevicePtr local, int *errmaj, int *errmin) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + unsigned char x; + int i, cnt; + int err; /* for WAIT */ + int init = FALSE; + + /* Reset the IRT from any mode and wait for end of warmstart */ + DBG(5, ErrorF("%sQueryHardware called\n", CI_INFO)); + +/* Will not work with XFree86 4.0 */ +/* xf86SerialSendBreak (local->fd, 2); */ + cit_Flush(priv->buffer); + +/* Test if touch is already initialized */ + cit_SendCommand(priv->buffer, C_GETORIGIN, 0); + + /* wait max. 0.5 seconds for acknowledge */ + DBG(6, ErrorF("%s\t* waiting for acknowledge\n", CI_INFO)); +/* WAIT(50); */ + XisbBlockDuration (priv->buffer, 500000); + cnt = 0; + err = FALSE; + + while ((i=XisbRead(priv->buffer)) != -1) + { + DBG(7, ErrorF("%s\t* 0x%02X received - cnt %d\n",CI_INFO, i, cnt)); + { + switch (cnt) + { + + case 0: + if ((unsigned char)i != CTS_STX) + init = TRUE; + break; + + case 1: + if ((unsigned char)i != (CMD_REP_CONV & C_GETORIGIN)) + init = TRUE; + break; + + case 2: + if ((unsigned char)i > 3) + init = TRUE; + break; + + case 3: + if ((unsigned char)i != CTS_ETX) + init = TRUE; + break; + } + } + cnt++; + if(init) + break; + } + /* Touch is physically not connected or sio problem or break */ + cit_Flush(priv->buffer); /* flush the buffer and wait for break */ + if(cnt < 3) + { + WAIT(150); + /* if we have 0 in the buffer I assume we got a break */ + if (XisbRead(priv->buffer) == 0) + { + + DBG(6, ErrorF("%s+ BREAK detected - cnt=%d\n", CI_INFO, cnt)); + init = TRUE; + } + else /* if nothing is in the buffer I assume the touch is not connected */ + { + ErrorF("%sTouch not connected - please connect - cnt=%d\n", CI_ERROR, cnt); + return(Success); /* If success is returned we can later connect */ + } /* the touch again when it was reconnected without */ + } /* restarting X */ + + /* if init is true, we have to (re)initialize the touch */ + if (init) + { + ErrorF("%sTouch not initialized yet\n",CI_INFO); + + /* + * IRT signals end of startup by sending BREAKS with 100 ms length. + * wait a maximum of 2 seconds for at least 2 consecutive breaks + * to be sure the IRT is really initialized + */ + cit_Flush(priv->buffer); /* clear the buffer and wait for break */ + DBG(6, ErrorF("%s\t* waiting for BREAKS...\n", CI_INFO)); + for (i=0, cnt=0; (i<20) && (cnt<2); i++) + { +/* millisleep (105); */ + WAIT(120); /* wait a little bit longer than 100 ms */ + DBG(7, ErrorF("%s\t (loop %d)\n", CI_INFO, i)); + if (XisbRead(priv->buffer) == 0) + { + cnt++; + DBG(6, ErrorF("%s\t+ BREAK %d detected\n", CI_INFO, cnt)); + } + else + { + cnt = 0; + } + } + if (cnt < 2) + { + ErrorF("%sCannot reset Citron Infrared Touch!\n", CI_ERROR); +/* *errmaj = LDR_NOHARDWARE; */ + return (!Success); + } + /* Now initialize IRT to CTS Protocol */ + DBG(6, ErrorF("%s\t* initializing to CTS mode\n", CI_INFO)); + x = 0x0d; + for (i=0; i<2; i++) + { + XisbWrite(priv->buffer, &x, 1); +/* millisleep (50); */ + WAIT(50); + } + x = MODE_D; + XisbWrite(priv->buffer, &x, 1); + + /* wait max. 0.5 seconds for acknowledge */ + DBG(6, ErrorF("%s\t* waiting for acknowledge\n", CI_INFO)); + XisbBlockDuration (priv->buffer, 500000); + cnt = 0; + while ((i=XisbRead(priv->buffer)) != -1) + { + DBG(7, ErrorF("%s\t* 0x%02X received - waiting for CTS_XON\n",CI_INFO, i)); + if ((unsigned char)i == CTS_XON) + break; + if(cnt++ > 100) return (Success); /* emergency stop */ + } + if ((unsigned char)i != CTS_XON) + { + ErrorF("%sNo acknowledge from Citron Infrared Touch!\n", CI_ERROR); +/* *errmaj = LDR_NOHARDWARE; */ + return (!Success); + } + } + /* now we have the touch connected, do the initialization stuff */ + DBG(6, ErrorF("%s\t+ Touch connected!\n",CI_INFO)); + cit_Flush(priv->buffer); + + DBG(6, ErrorF("%s\t+ requesting pressure sensors report\n",CI_INFO)); + if (cit_GetPressureSensors(priv)!=Success) + { + ErrorF("%sNo pressure sensors report received from Citron Touchscreen!\n",CI_ERROR); + } + + DBG(5, ErrorF("%s ClickMode is %d\n",CI_INFO, priv->click_mode)); + if(priv->click_mode == NO_CLICK_MODE) /* no click mode set in XF86Config */ + { + priv->click_mode = (priv->pressure_sensors > 0) ? CM_ZPRESS : CM_ENTER; + DBG(5, ErrorF("%sClickMode set to %d\n",CI_INFO, priv->click_mode)); + } + + cit_SendCommand(priv->buffer, C_SETAREAFLAGS, 1, AOF_ADDEXIT + | AOF_ADDCOORD + | AOF_ACTIVE + | AOF_ADDPRESS); + + cit_SendCommand(priv->buffer, C_SETAREAMODE, 1, AOM_CONT); + + cit_SendCommand(priv->buffer, C_SETCONTTIME, 1, 20); + + cit_SendCommand(priv->buffer, C_SETDUALTOUCHING, 1, DT_ERROR); + + cit_SendCommand(priv->buffer, C_SETAREAPRESSURE, 1, LOBYTE(priv->button_threshold)); + + cit_SendCommand(priv->buffer, C_SETRESOLUTION, 4, + LOBYTE(CIT_DEF_MAX_X), + HIBYTE(CIT_DEF_MAX_X), + LOBYTE(CIT_DEF_MAX_Y), + HIBYTE(CIT_DEF_MAX_Y)); + + cit_SendCommand(priv->buffer, C_SETPWM, 2, + LOBYTE(priv->pwm_active), + LOBYTE(priv->pwm_sleep)); + + cit_SendCommand(priv->buffer, C_SETBEAMTIMEOUT, 2, + LOBYTE(priv->beam_timeout), + HIBYTE(priv->beam_timeout)); + + cit_SendCommand(priv->buffer, C_SETORIGIN, 1, LOBYTE(priv->origin)); + cit_SendCommand(priv->buffer, C_SETTOUCHTIME, 1, LOBYTE(priv->touch_time)); + + cit_SendCommand(priv->buffer, C_SETSLEEPMODE, 5, + LOBYTE(priv->sleep_mode), + LOBYTE(priv->sleep_time_act), + HIBYTE(priv->sleep_time_act), + LOBYTE(priv->sleep_time_scan), + HIBYTE(priv->sleep_time_scan)); + + cit_SendCommand(priv->buffer, C_SETDOZEMODE, 5, + LOBYTE(priv->doze_mode), + LOBYTE(priv->doze_time_act), + HIBYTE(priv->doze_time_act), + LOBYTE(priv->doze_time_scan), + HIBYTE(priv->doze_time_scan)); + + cit_SendCommand(priv->buffer, C_SETTRANSMISSION, 1, TM_TRANSMIT); + cit_SendCommand(priv->buffer, C_SETSCANNING, 1, 1); + + + if(priv->query_state == 0) /* do error reporting only 1 time */ + { + priv->query_state++; + + DBG(6, ErrorF("%s\t+ requesting initial errors report\n",CI_INFO)); + if (cit_GetInitialErrors(priv)!=Success) + { + ErrorF("%sNo initial error report received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + DBG(6, ErrorF("\t+ requesting defective beams report\n")); + if (cit_GetDefectiveBeams(priv)!=Success) + { + ErrorF("%sNo defective beams report received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + DBG(6, ErrorF("\t+ requesting touch revisions\n")); + if (cit_GetDesignator(priv)!=Success) + { + ErrorF("%sNo designator received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_SYSMGR)!=Success) + { + ErrorF("%sNo system manager module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_HARDWARE)!=Success) + { + ErrorF("%sNo hardware module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_PROCESS)!=Success) + { + ErrorF("%sNo process module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_PROTOCOL)!=Success) + { + ErrorF("%sNo protocol module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_HWPARAM)!=Success) + { + ErrorF("%sNo hardware parameter module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + } + + DBG(6, ErrorF("%s\t+ Touch initialized - %d\n",CI_INFO, priv->query_state)); + + return (Success); +} + + +/***************************************************************************** + * [cit_GetPacket] + ****************************************************************************/ +static Bool +cit_GetPacket (cit_PrivatePtr priv) +{ + int c; + int errmaj, errmin; + + DBG(GP, ErrorF("%scit_GetPacket called\n", CI_INFO)); + DBG(GP, ErrorF("%s\t* initial lex_mode =%d (%s)\n", CI_INFO, priv->lex_mode, + priv->lex_mode==cit_idle ?"idle": + priv->lex_mode==cit_getID ?"getID": + priv->lex_mode==cit_collect ?"collect": + priv->lex_mode==cit_escape ?"escape": + "???")); + while ((c = XisbRead (priv->buffer)) >= 0) + { +#if(0) + DBG(GP, ErrorF("%s c=%d\n",CI_INFO, c)); +#endif + if (c == CTS_STX) + { + DBG(GP, ErrorF("%s\t+ STX detected\n", CI_INFO)); + /* start of report received */ + if (priv->lex_mode != cit_idle) + DBG(7, ErrorF("%s\t- no ETX received before this STX!\n", CI_WARNING)); + priv->lex_mode = cit_getID; + DBG(GP, ErrorF("%s\t+ new lex_mode == getID\n", CI_INFO)); + } + else if (c == CTS_ETX) + { + DBG(GP, ErrorF("%s\t+ ETX detected\n", CI_INFO)); + /* end of command received */ + /* always IDLE after report completion */ + DBG(GP, ErrorF("%s\t+ new lex_mode == idle\n", CI_INFO)); + if (priv->lex_mode == cit_collect) + { + DBG(GP, ErrorF("%s\t+ Good report received\n", CI_INFO)); + priv->lex_mode = cit_idle; + return (Success); + } + DBG(GP, ErrorF("%s\t- unexpected ETX received!\n", CI_WARNING)); + priv->lex_mode = cit_idle; + } + else if (c == CTS_ESC) + { + DBG(GP, ErrorF("%s\t+ escape detected\n", CI_INFO)); + /* next character is encoded */ + if (priv->lex_mode != cit_collect) + { + DBG(GP, ErrorF("%s\t- unexpected control character received\n", CI_WARNING)); + } + else + { + priv->lex_mode = cit_escape; + DBG(GP, ErrorF("%s\t+ new lex_mode == escape\n", CI_INFO)); + } + } + else if ((c < CTS_CTRLMIN) || (c > CTS_CTRLMAX)) + { + /* regular report data received */ + if (priv->lex_mode == cit_getID) + { /* receive report ID */ + priv->packeti = 0; + priv->packet[priv->packeti++] = (unsigned char)c; + priv->lex_mode = cit_collect; + DBG(GP, ErrorF("%s\t+ identifier captured, new lex_mode == collect\n", CI_INFO)); + } + else if ((priv->lex_mode == cit_collect) || (priv->lex_mode == cit_escape)) + { /* receive command data */ + if (priv->lex_mode == cit_escape) + { /* decode encoded data byte */ + c &= CTS_DECODE; /* decode data */ + priv->lex_mode = cit_collect; + DBG(GP, ErrorF("%s\t+ decoded character = 0x%02X\n", CI_INFO, c)); + DBG(GP, ErrorF("%s\t+ new lex_mode = collect\n", CI_INFO)); + } + if (priv->packeti < CTS_PACKET_SIZE) + { /* add data bytes to buffer */ + priv->packet[priv->packeti++] = (unsigned char)c; + } + else + { + DBG(GP, ErrorF("%s\t- command buffer overrun\n", CI_ERROR)); + /* let's reinitialize the touch - maybe it sends breaks */ + cit_Flush(priv->buffer); + + } + } + else + { + /* this happens e.g. when the touch sends breaks, so we try to reconnect */ + DBG(GP, ErrorF("%s\t- unexpected non control received!\n", CI_WARNING)); + DBG(GP, ErrorF("%s\t- Device not connected - trying to reconnect ...\n", CI_WARNING)); + if (QueryHardware (priv->local, &errmaj, &errmin) != Success) + ErrorF ("%s\t- Unable to query/initialize Citron Touch hardware.\n", CI_ERROR); + else + ErrorF ("%s\t- Citron Touch reconnected\n", CI_INFO); + + } + } + else if (c != CTS_XON && c != CTS_XOFF) + { + DBG(GP, ErrorF("%s\t- unhandled control character received!\n", CI_WARNING)); + } + } + DBG(GP, ErrorF("%scit_GetPacket exit !Success\n", CI_INFO)); + return (!Success); +} + + +/***************************************************************************** + * [cit_Flush] + ****************************************************************************/ +static void +cit_Flush (XISBuffer *b) +{ + DBG(7, ErrorF("%scit_Flush called\n", CI_INFO)); + XisbBlockDuration(b, 0); + while (XisbRead(b) > 0); +} + + + +/***************************************************************************** + * [cit_Beep] + ****************************************************************************/ +static void +cit_Beep(cit_PrivatePtr priv, int press) +{ +#ifdef CIT_BEEP + if(priv->beep == 0) + return; + + /* ring release bell */ + if(press == 0) + + /* [0]: volume, [1]: pitch, [2]: duration */ + /* formula is: ((1193190 / freq) & 0xffff) | */ + /* (((unsigned long)duration * loudness / 50) << 16)) */ + /* .. whatever the inventor wants to intend by it, I don't know (PK) */ + + xf86SoundKbdBell(priv->rel_vol, priv->rel_pitch, priv->rel_dur); + + else + /* ring press bell */ + xf86SoundKbdBell(priv->press_vol,priv->press_pitch, priv->press_dur); + + DBG(7, ErrorF("%scit_Beep called - %s\n", CI_INFO, (press == 0) ? "release" : "press")); +#endif +} + + +/***************************************************************************** + * [cit_SendCommand] + ****************************************************************************/ +static void +cit_SendCommand (XISBuffer *b, unsigned char cmd, int cnt, ...) +{ + va_list ap; + unsigned char data, x; + + va_start(ap, cnt); + + DBG(7, ErrorF("%scit_SendCommand(cmd=0x%02X, cnt=%d, ...)\n", CI_INFO, cmd, cnt)); + x = CTS_STX; + XisbWrite(b, &x, 1); /* transmit start of packet */ + XisbWrite(b, &cmd, 1); /* transmit command code */ + x = CTS_ESC; + while (cnt-- > 0) + { /* encode and transmit optional parameters */ + data = va_arg(ap, int); + if (data >= CTS_CTRLMIN && data <= CTS_CTRLMAX) + { /* data has to be encoded */ + data |= CTS_ENCODE; + XisbWrite(b, &x, 1); /* mark coded data */ + } + XisbWrite(b, &data, 1); /* transmit data */ + } + x = CTS_ETX; + XisbWrite(b, &x, 1); /* transmit end of packet */ + va_end(ap); +} + + +/***************************************************************************** + * [cit_GetInitialErrors] + ****************************************************************************/ +static Bool cit_GetInitialErrors(cit_PrivatePtr priv) +{ + unsigned long errors; + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETERRORS, 1, GE_INITIAL); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti != 6) + { + DBG(5, ErrorF("%sWrong packet length (expected 6, received %d bytes)\n", CI_NOTICE, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETERRORS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETERRORS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GE_INITIAL) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GE_INITIAL, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + errors = 0x00000001UL * (unsigned long)priv->packet[2] + + 0x00000100UL * (unsigned long)priv->packet[3] + + 0x00010000UL * (unsigned long)priv->packet[4] + + 0x10000000UL * (unsigned long)priv->packet[5]; + DBG(6, ErrorF("%sinitial errors = 0x%08lX\n", CI_NOTICE, errors)); + if (errors == 0x00000000UL) + { + ErrorF("%sNo initialization errors detected.\n", CI_INFO); + } + if (errors & IE_SMCHKSUM) + { + ErrorF("%sSystem Manager Module checksum error!\n", CI_ERROR); + } + if (errors & IE_SMINIT) + { + ErrorF("%sSystem Manager Module initialization error!\n", CI_ERROR); + } + if (errors & IE_HWCHKSUM) + { + ErrorF("%sHardware Module checksum error!\n", CI_ERROR); + } + if (errors & IE_HWINIT) + { + ErrorF("%sHardware Module initialization error!\n", CI_ERROR); + } + if (errors & IE_HW_BEAMS) + { + ErrorF("%s broken beams during initialization detected!\n", CI_ERROR); + } + if (errors & IE_HW_PSU) + { + ErrorF("%s force sensors not operating!\n", CI_ERROR); + } + if (errors & IE_HW_CPU) + { + ErrorF("%s CPU integrity test failed!\n", CI_ERROR); + } + if (errors & IE_HW_IRAM) + { + ErrorF("%s internal RAM error!\n", CI_ERROR); + } + if (errors & IE_HW_XRAM) + { + ErrorF("%s external SRAM error!\n", CI_ERROR); + } + if (errors & IE_PCCHKSUM) + { + ErrorF("%sProcess Module checksum error!\n", CI_ERROR); + } + if (errors & IE_PCINIT) + { + ErrorF("%sProcess Module initialization error!\n", CI_ERROR); + } + if (errors & IE_PTCHKSUM) + { + ErrorF("%sProtocol Module checksum error!\n", CI_ERROR); + } + if (errors & IE_PTINIT) + { + ErrorF("%sProtocol Module initialization error!\n", CI_ERROR); + } + if (errors & IE_BICHK) + { + ErrorF("%sBurnIn Module checksum error!\n", CI_ERROR); + } + if (errors & IE_BIINIT) + { + ErrorF("%sBurnIn Module initialization error!\n", CI_ERROR); + } + if (errors & IE_FPGACHK) + { + ErrorF("%sFPGA configuration checksum error!\n", CI_ERROR); + } + if (errors & IE_HWPCHK) + { + ErrorF("%sHardware Parameter checksum error!\n", CI_ERROR); + } + return (Success); +} + + +/***************************************************************************** + * [cit_GetDefectiveBeams] + ****************************************************************************/ +static Bool cit_GetDefectiveBeams(cit_PrivatePtr priv) +{ + unsigned nx, ny; + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETERRORS, 1, GE_DEFECTBEAMS); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 6) + { + DBG(5, ErrorF("%sWrong packet length (expected >= 6, received %d bytes)\n", CI_NOTICE, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETERRORS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETERRORS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GE_DEFECTBEAMS) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GE_DEFECTBEAMS, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + nx = 0x0001U * (unsigned)priv->packet[2] + + 0x0100U * (unsigned)priv->packet[3]; + + ny = 0x0001U * (unsigned)priv->packet[4] + + 0x0100U * (unsigned)priv->packet[5]; + /* list defective X-beams */ + if (nx > 0) + { + ErrorF("%s%u defective X-Beams detected:\n", CI_ERROR, nx); + for (i=0; i<nx; i++) + { + ErrorF("%s\tX%02u\n", CI_ERROR, (unsigned)priv->packet[6+i]); + } + } + else + { + ErrorF("%sNo defective X-beams detected.\n", CI_INFO); + } + + /* list defective Y-beams */ + if (ny > 0) + { + ErrorF("%s%u defective Y-Beams detected:\n", CI_ERROR, ny); + for (i=0; i<ny; i++) + { + ErrorF("%s\tY%02u\n", CI_ERROR, (unsigned)priv->packet[6+nx+i]); + } + } + else + { + ErrorF("%sNo defective Y-beams detected.\n", CI_INFO); + } + return (Success); +} + + +/***************************************************************************** + * [cit_GetDesignator] + ****************************************************************************/ +static Bool cit_GetDesignator(cit_PrivatePtr priv) +{ + int i,n; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETREVISIONS, 1, GR_DESIGNATOR); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2+CTS_DESIGNATOR_LEN+CTS_ASSY_LEN) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2+CTS_DESIGNATOR_LEN+CTS_ASSY_LEN, + priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETREVISIONS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETREVISIONS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GR_DESIGNATOR) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GR_DESIGNATOR, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + ErrorF("%sDesignator \"", CI_INFO); + i = 2; + n = 0; + while (n++ < CTS_DESIGNATOR_LEN && priv->packet[i]!=0) + { + ErrorF("%c", priv->packet[i++]); + } + ErrorF("\"\n%sAssembly \"", CI_INFO); + i = 2 + CTS_DESIGNATOR_LEN; + n = 0; + while (n++ < CTS_ASSY_LEN && priv->packet[i]!=0) + { + ErrorF("%c", priv->packet[i++]); + } + ErrorF("\"\n"); + return (Success); +} + + +/***************************************************************************** + * [cit_GetRevision] + ****************************************************************************/ +static Bool cit_GetRevision(cit_PrivatePtr priv, int selection) +{ + int i,n; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETREVISIONS, 1, (unsigned char)selection); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + XisbBlockDuration(priv->buffer, 500000); + while (((res = cit_GetPacket(priv)) != Success) && (priv->lex_mode != cit_idle)); + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETREVISIONS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETREVISIONS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != selection) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + selection, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + DBG(5, ErrorF("%s%s module revision ", CI_INFO, + selection == GR_SYSMGR ? "SysMgr " : + selection == GR_HARDWARE ? "Hardware" : + selection == GR_PROCESS ? "Process " : + selection == GR_PROTOCOL ? "Protocol" : + selection == GR_HWPARAM ? "HWParam " : + "???")); + i = 2; + n = 0; + DBG(5, ErrorF("\"")); + while (n < priv->packeti && priv->packet[i]!=0) + { + DBG(5, ErrorF("%c", priv->packet[i])); + i++; + } + DBG(5, ErrorF("\"\n")); + return (Success); +} + + +/***************************************************************************** + * [cit_ProcessPacket] + ****************************************************************************/ +static void cit_ProcessPacket(cit_PrivatePtr priv) +{ + int i; + + DBG(PP, ErrorF("%scit_ProcessPacket called\n", CI_INFO)); + DBG(PP, ErrorF("%s\t+ enter state = 0x%04X, dual touch count=%d\n", CI_INFO, priv->state, priv->dual_touch_count)); + /* examine message identifier */ + + priv->dual_flg = TRUE; /* Dual Touch Error occurred */ +#ifdef CIT_TIM + priv->timer_val1 = 1000; /* Timer delay [ms]*/ + priv->timer_callback = (OsTimerCallback)cit_DualTouchTimer; /* timer callback routine */ + cit_StartTimer(priv); +#endif + + switch (priv->packet[0]) + { + case R_COORD: /* new touch coordinates received */ + if (priv->packeti < 5) + { + DBG(PP, ErrorF("%s\t- coordinate message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + + + if (priv->dual_touch_count > 0) + priv->dual_touch_count--; + + priv->raw_x = 0x0001U * priv->packet[1] + + 0x0100U * priv->packet[2]; + priv->raw_y = 0x0001U * priv->packet[3] + + 0x0100U * priv->packet[4]; + + priv->raw_min_x = min(priv->raw_min_x, priv->raw_x); + priv->raw_max_x = max(priv->raw_max_x, priv->raw_x); + priv->raw_min_y = min(priv->raw_min_y, priv->raw_y); + priv->raw_max_y = max(priv->raw_max_y, priv->raw_y); + + priv->state |= CIT_TOUCHED; + + DBG(PP, ErrorF("%s\t+ COORD message raw (%d,%d)\n", CI_INFO, priv->raw_x, priv->raw_y)); + break; + + case R_EXIT: /* touch area no longer interrupted */ + if (priv->packeti < 5) + { + DBG(PP, ErrorF("%s\t- exit message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + + priv->state &= ~(CIT_TOUCHED | CIT_PRESSED); + priv->dual_touch_count = 0; + priv->raw_x = 0x0001U * priv->packet[1] + + 0x0100U * priv->packet[2]; + priv->raw_y = 0x0001U * priv->packet[3] + + 0x0100U * priv->packet[4]; +#ifdef CIT_TIM + cit_CloseTimer(priv); /* close timer if exit message was received */ +#endif + DBG(PP, ErrorF("%s\t+ EXIT message (%d,%d)\n", CI_INFO, priv->raw_x, priv->raw_y)); + break; + + case R_DUALTOUCHERROR: + if (priv->dual_touch_count < priv->max_dual_count) + priv->dual_touch_count++; + DBG(PP, ErrorF("%s\t+ DUAL TOUCH ERROR message received\n", CI_INFO)); + break; + + case R_PRESSURE: /* pressure message received */ + if (priv->packeti < 2) + { + DBG(PP, ErrorF("%s\t- pressure message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + priv->state |= CIT_TOUCHED; + if (priv->packet[1] == PRESS_EXCEED) + priv->state |= CIT_PRESSED; + else if(priv->packet[1] == PRESS_BELOW) + { + priv->state &= ~CIT_PRESSED; + } + else + DBG(PP, ErrorF("%sPressure Message Error\n", CI_ERROR)); + + DBG(PP, ErrorF("%s\t+ pressure %s message\n", CI_INFO, priv->packet[1] ? "enter":"exit")); + break; + + default: + DBG(PP, ErrorF("%s\t* unhandled message:", CI_ERROR)); + for (i=0; i<priv->packeti; i++) + { + DBG(PP, ErrorF(" 0x%02X", priv->packet[i])); + } + DBG(PP, ErrorF("\n")); + } + /* generate button state */ + switch (priv->click_mode) + { + case CM_ZPRESS: + DBG(PP, ErrorF("%s\t+ ZPress, button ", CI_INFO)); + if (priv->state & CIT_PRESSED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + + break; + + case CM_ZPRESSEXIT: + DBG(PP, ErrorF("%s\t+ ZPressExit, button ", CI_INFO)); + if (priv->state & CIT_PRESSED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (!(priv->state & CIT_TOUCHED)) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + case CM_DUAL: + DBG(PP, ErrorF("%s\t+ Dual Touch, button ", CI_INFO)); + if ((priv->dual_touch_count == priv->max_dual_count) && (priv->state & CIT_TOUCHED)) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (priv->dual_touch_count == 0) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + case CM_DUALEXIT: + DBG(PP, ErrorF("%s\t+ Dual Exit, button ", CI_INFO)); + if ((priv->dual_touch_count == priv->max_dual_count) && (priv->state & CIT_TOUCHED)) + { + priv->dual_flg = TRUE; + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (!(priv->state & CIT_TOUCHED)) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + default: /* default to enter mode */ + DBG(PP, ErrorF("%s\t+ Enter Mode, button ", CI_INFO)); + if (priv->state & CIT_TOUCHED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + } + DBG(PP, ErrorF("\n")); + DBG(PP, ErrorF("%s\t+ Click Mode=%d\n", CI_INFO, priv->click_mode)); + DBG(PP+1, ErrorF("%s\t+ exit state = 0x%04X, dual touch count=%d\n", CI_INFO, priv->state, priv->dual_touch_count)); + DBG(PP+1, ErrorF("%s\t raw_x=%d, raw_y=%d\n", CI_INFO, priv->raw_x, priv->raw_y)); +} + + + +/***************************************************************************** + * [cit_GetPressureSensors] + ****************************************************************************/ +static Bool cit_GetPressureSensors(cit_PrivatePtr priv) +{ + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETHARDWARE, 1, GH_SENSORCOUNT); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2+CTS_SENSORCOUNT_LEN) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2+CTS_SENSORCOUNT_LEN, + priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETHARDWARE & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETHARDWARE & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GH_SENSORCOUNT) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GH_SENSORCOUNT, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + ErrorF("%sPressureSensors: \"%d\"\n", CI_INFO, priv->packet[2]); + priv->pressure_sensors = priv->packet[2]; + return (Success); +} + + diff --git a/xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp b/xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp new file mode 100644 index 000000000..444eae0dc --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp @@ -0,0 +1,631 @@ +.\" Copyright (c) 2000 Peter Kunzmann <support@@citron.de> +.\" +.\" This is free documentation; you can redistribute it and/or +.\" modify it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2 of +.\" the License, or (at your option) any later version. +.\" +.\" The GNU General Public License's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" This manual is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp,v 1.1 2000/11/02 02:51:21 dawes Exp $ +.\" +.TH CITRON 4 "Version 4.0.1" "XFREE86" +.SH NAME +citron \- Citron Infrared Touch Driver (CiTouch) +.SH SYNOPSIS +.B "Section ""InputDevice""" +.br +.BI " Identifier """ idevname """" +.br +.B " Driver ""citron""" +.br +.BI " Option ""Device"" """ devpath """" +.br +\ \ ... +.br +.B EndSection +.SH DESCRIPTION +.B citron +is a XFree86 input driver for +.I Citron Infrared Touch +devices. +.PP +The +.B citron +driver acts as a pointer input device, and may be used as the +X server's core pointer. It is connected via a "RS232" with the host. +.SH SUPPORTED HARDWARE +At the moment the following touches are supported. They are also +available as +.I ZPress +touches. + +.B IRT6I5-V2.x + 6.5 inch Infrared Touch + +.B IRT10I4-V4.x + 10.4 inch Infrared Touch + +.B IRT12I1-V2.x + 12.1 inch Infrared Touch + +.B IRT15I1-V1.x + 15.1 inch Infrared Touch + +.SH CONFIGURATION DETAILS +Please refer to XF86Config(5x) for general configuration +details and for options that can be used with all input drivers. This +section only covers configuration details specific to this driver. +For better understanding please read also the +.B CTS +and various +.B IRT +manuals which are available in "pdf" format from Citron web page +.B www.citron.de +or directly from Citron. + +.PP +.PP +The following driver +.B Options +are supported: +.TP 7 +.BI "Option ""Device"" """ devpath """ +Specify the device path for the citron touch. Valid devices are: +.PP +.RS 12 +/dev/ttyS0, /dev/ttyS1, .... +This option is mandatory. +.RE +.PP +.RS 7 +It's important to specify the right device Note: com1 -> /dev/ttyS0, com2 -> /dev/ttyS1 .... + +.RE +.TP 7 +.BI "Option ""ScreenNumber"" """ "screennumber" """ +sets the +.I screennumber +for the +.I citron +InputDevice. +.PP +.RS 7 +.I Default: +ScreenNumber: "0" + +.RE +.TP 7 +.BI "Option ""MinX, MinY"" """ value """ +These are the minimum X and Y values for the +.I citron +input device. +.PP +.RS 7 +Note: MinX, MinY must be less than MaxX, MaxY. +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +MinX: "0" MinY: "0" + + +.RE +.TP 7 +.BI "Option ""MaxX, MaxY"" """ value """ +These are the maximum X and Y values for the +.I citron +input device. +.PP +.RS 7 +Note: MaxX, MaxY must be greater than MinX, MinY. +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +MaxX: "65535" MaxY: "65535" + + +.RE +.TP 7 +.BI "Option ""ButtonNumber"" """ value """ +This value is responsible for the +.I button number +that is returned within the xf86PostButton event message +.PP +.RS 7 +.I Range: +"0" - "255" +.PP +.I Default: +"1" + +.RE +.TP 7 +.BI "Option ""ButtonThreshold"" """ value """ +This value is responsible for the +.I button threshold. +It changes the pressure sensitivity of the touch. A higher number +corresponds to a higher pressure. +.PP +.RS 7 +Note: This feature is only available with pressure sensitive hardware. +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"20" + +.RE +.TP 7 +.B Sleep-Mode +If the IRT is in +.I Doze-Mode +and Touch Zone is not interrupted for another +certain span of time, the so-called +.I Sleep-Mode +is activated. The +.I Sleep-Mode +decreases the scan rate of the beams even further than +the +.I Doze-Mode +does (see below). This way the life expectancy of the beams is +prolonged and the power consumption of the IRT is reduced. +As soon as an interruption of the Touch Zone is detected, the +.I Sleep-Mode +is deactivated and the Touch Zone will again be scanned with +the maximum speed. With the Sleep-Mode activated, +depending on the set scan rate the IRT's response time can be +considerably longer as in normal operation. If, for example, +a scan rate of 500 ms / scan is set, it may last up to a half +of a second until the IRT detects the interruption and deactivates +the +.I Sleep-Mode. + +.PP +.RE +.TP 7 +.BI "Option ""SleepMode"" """ mode """ +This value is responsible for the +.I sleep-mode +of the touch. +.RS 7 +Determines the behaviour of the Sleep-Mode. + +.B 0x00 + No message at either activation or deactivation + +.B 0x01 + Message at activation + +.B 0x02 + Message at deactivation + +.B 0x03 + Message at activation and deactivation + +.B 0x10 +GP_OUT output set according to the Sleep-Mode status + +.I Values: +"0" "1" "2" "3" "16" + +.I Default: +"0" + +.RE +.TP 7 +.BI "Option ""SleepTime"" """ time """ +This value is responsible for the +.I sleep-time +of the touch. It is the activation time in seconds +("0" = immediately activated, "65535" = always deactivated). +.RS 7 +.PP +.I Range: +"0" - "65535" [s] +.PP +.I Default: +"65535" => deactivated + +.RE +.TP 7 +.BI "Option ""SleepScan"" """ scan """ +This value is responsible for the +.I scan-time +of the touch. This is the time interval between two scan operations +while in Sleep-Mode. The time interval is set in steps +of milliseconds. +.RS 7 +.PP +.I Range: +"0" - "65535" [ms] +.PP +.I Default: +"500" + +.RE +.TP 7 +.BI "Option ""PWMActive"" """ value """ +This value determines the mark-to-space ratio of the +.I PWM +output while in normal operation (sleep-mode not active). +Higher values result in longer pulse widths. This output +signal can be used in conjunction with the +.I Citron AWBI +to do backlight-dimming via the touch. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"255" (max. brightness) + + +.RE +.TP 7 +.BI "Option ""PWMSleep"" """ value """ +This value determines the mark-to-space ratio of the +.I PWM +output while in sleep-mode (-> +.I SleepMode, SleepScan, SleepTime +) operation (sleep-mode active). +Higher values result in longer pulse widths. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"255" (max. brightness) + +.RE +.TP 7 +.BI "Option ""ClickMode"" """ mode """ +With mode one can select between 5 +.I ClickModes + +.I """1"" = ClickMode Enter + +With this mode every interruption of the infrared beams will +activate a ButtonPress event and after the interruption a +ButtonRelease event will be sent. + +.I """2"" = ClickMode Dual + +With this mode every interruption will sent a Proximity event and +every second interruption a ButtonPress event. With the release of +the interruption (while one interruption is still active) a +ButtonRelease event will be sent. + +.I """3"" = ClickMode Dual Exit + +With this mode every interruption will sent a ProximityIn event and +every second interruption a ButtonPress event. With the release of +the interruption (while one interruption is still active) no +ButtonRelease event will be sent. Only if all interruptions are released +a ButtonRelease followed by a ProximityOut event will be sent. + +.I """4"" = ClickMode ZPress + +With this mode every interruption will sent a ProximityIn event. Only if +a certain pressure is exceeded a ButtonPress event will occur. If the +pressure falls below a certain limit a ButtonRelease event will be sent. +After also the interruption is released a ProximityOut event is generated. + +.I """5"" = ClickMode ZPress Exit + +This mode is similat to "Clickmode Dual Exit". +The first interruption of the beams will sent a ProximityIn event. Only if +a certain pressure is exceeded a ButtonPress event will occur. If the +pressure falls below a certain limit no ButtonRelease event will be sent. +After the interruption is also released a ButtonRelease followed by +a ProximityOut event is generated. +.RS 7 +.PP +.I Range: +"1" - "5" +.PP +.I Default: +"1" (ClickMode Enter) + +.RE +.TP 7 +.BI "Option ""Origin"" """ value """ +This value sets the coordinates origin to one of the four corners of +the screen. +The following values are accepted: +"0" TOPLEFT: Origin set to the left-hand side top corner. +"1" TOPRIGHT: Origin set to the right-hand side top corner. +"2" BOTTOMRIGHT: Origin set to the right-hand side bottom corner. +"3" BOTTOMLEFT: Origin set to the left-hand side bottom corner. +.RS 7 +.PP +.I Range: +"0" - "3" +.PP +.I Default: +"0" (TOPLEFT) + +.RE +.TP 7 +.B "Doze-Mode" +If for a certain span of time the Touch Zone is not interrupted, +the so-called Doze-Mode is automatically activated. The activated +Doze-Mode slightly decreases the scan rate of the beams. This way +the power consumption of the IRT is reduced. As soon as an +interruption of the Touch Zone is detected, the Doze-Mode +is deactivated and the Touch Zone will again be scanned with +the maximum speed. + +.RE +.TP 7 +.BI "Option ""DozeMode"" """ mode """ +This value is responsible for the +.I doze-mode +of the touch. +.RS 7 +.PP +Determines the behaviour of the Doze-Mode. +.PP +0x00 No message at either activation or deactivation + +0x01 Message at activation + +0x02 Message at deactivation + +0x03 Message at activation and deactivation + +0x10 GP_OUT output set according to the Doze-Mode status + +If the GP_OUT output is already controlled by the +.I Sleep-Mode +it is no longer available as an output port anymore. +.PP +.I Values: +"0" "1" "2" "3" "16" +.PP +.I Default: +"0" + + + +.RE +.TP 7 +.BI "Option ""DozeTime"" """ time """ +This value is responsible for the +.I doze-time +of the touch. It is the activation time in seconds +("0" = immediately activated, "65535" = always deactivated). +.RS 7 +.PP +.I Range: +"0" - "65535" [s] +.PP +.I Default: +"65535" => deactivated + + +.RE +.TP 7 +.BI "Option ""DozeScan"" """ scan """ +This value is responsible for the +.I scan-time +of the touch. This is the time interval between two scan operations +while in Doze-Mode. The time interval is set in steps +of milliseconds. +.RS 7 +.PP +.I Range: +"0" - "65535" [ms] +.PP +.I Default: +"500" + +.RE +.TP 7 +.BI "Option ""DeltaX"" """ value """ +This value determines a virtual area at the left and right +side of the current cursor position where the cursor didn't move. +Within this area no "MotionNotify" event will be sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (no deltaX) + + +.RE +.TP 7 +.BI "Option ""DeltaY"" """ value """ +This value determines a virtual area at the top and bottom +of the current cursor position where the cursor didn't move. +Within this area no "MotionNotify" event will be sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (no deltaY) + +.RE +.TP 7 +.BI "Option ""Beep"" """ value """ +This value determines if a "ButtonPress" and/or a "ButtonRelease" +event should sound the buzzer. "0" deactivates the buzzer while +every other value will activate it. +.RS 7 +.PP +.I Range: +"0" - "1" +.PP +.I Default: +"0" (deactivated) + +.RE +.TP 7 +.BI "Option ""PressVol"" """ value """ +This value determines the volume of the buzzer (0-100%) +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "100" +.PP +.I Default: +"100" + + +.RE +.TP 7 +.BI "Option ""PressPitch"" """ value """ +This value determines the pitch of the tone +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "3000" +.PP +.I Default: +"880" + + + +.RE +.TP 7 +.BI "Option ""PressDur"" """ value """ +This value determines the duration of the tone in ms +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"15" + +.RE +.TP 7 +.BI "Option ""ReleaseVol"" """ value """ +This value determines the volume of the buzzer (0-100%) +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "100" +.PP +.I Default: +"100" + + +.RE +.TP 7 +.BI "Option ""ReleasePitch"" """ value """ +This value determines the pitch of the tone when +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "3000" +.PP +.I Default: +"1200" + + + +.RE +.TP 7 +.BI "Option ""ReleseDur"" """ value """ +This value determines the duration of the tone in ms when +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"10" + + + +.RE +.TP 7 +.BI "Option ""BeamTimeout"" """ value """ +Determines the time span in seconds, that has to elapse before a beam is +considered defective, blanked-out and excluded from the coordinates +evaluation. +.RS 7 +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +"30" (30 seconds) + + + + +.RE +.TP 7 +.BI "Option ""TouchTime"" """ value """ +Determines the minimum time span in steps of 10ms for a valid +interruption. In order for an interruption to be +reported to the host computer as valid, it needs to remain at +the same spot for at least the time span declared here. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (=6,5 ms) + + +.RE +.TP 7 +.BI "Option ""EnterCount"" """ count """ +Number of skipped "enter reports". Reports are sent approx. +every 20ms. +.RS 7 +.PP +.I Range: +"0" - "31" +.PP +.I Default: +"3" (3 skipped messages = 60ms) + + +.RE +.TP 7 +.BI "Option ""DualCount"" """ count """ +Number of skipped "dual touch error". Reports are sent approx. +every 20ms. This option is only available for "ZPress" and +"ZPress Exit" modes. +.RS 7 +.PP +.I Range: +"0" - "31" +.PP +.I Default: +"2" (2 skipped messages = 40ms) + + +.SH "SEE ALSO" +XFree86(1), XF86Config(5x), xf86config(1), Xserver(1), X(1). +.SH AUTHORS +2000 - written by Citron GmbH (support@citron.de) diff --git a/xc/programs/Xserver/hw/xfree86/input/citron/citron.h b/xc/programs/Xserver/hw/xfree86/input/citron/citron.h new file mode 100644 index 000000000..b43d45ce6 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/input/citron/citron.h @@ -0,0 +1,522 @@ +/* + * Copyright (c) 1998 Metro Link Incorporated + * + * 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 X CONSORTIUM 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. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.h,v 1.1 2000/11/02 02:51:21 dawes Exp $ */ + +/* + * Based, in part, on code with the following copyright notice: + * + * Copyright 1999-2000 by Thomas Thanner, Citron GmbH, Germany. <support@citron.de> + * + * 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 Thomas Thanner and Citron GmbH not be used in advertising or + * publicity pertaining to distribution of the software without specific, written + * prior permission. Thomas Thanner and Citron GmbH makes no representations about + * the suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * THOMAS THANNER AND CITRON GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL THOMAS THANNER OR CITRON GMBH 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 _citron_H_ +#define _citron_H_ + +/****************************************************************************** + * Definitions + * structs, typedefs, #defines, enums + *****************************************************************************/ + +/* CTS (Citron Touch Software) protocol constants */ +#define CTS_CTRLMIN 0x10 /* Lower end of the control character range */ +#define CTS_XON 0x11 /* Start serial transmission character */ +#define CTS_STX 0x12 /* Start of message delimiter */ +#define CTS_XOFF 0x13 /* Stop serial transmission character */ +#define CTS_ETX 0x14 /* End of message delimiter */ +#define CTS_NAK 0x15 /* Not Acknowledge, send by the IRT just before it resets itself */ +#define CTS_ESC 0x16 /* Escape character to encode non control characters with a value inside the control character range */ +#define CTS_CTRLMAX 0x16 /* Upper end of the control character range */ + +#define CTS_ENCODE 0x40 /* Use this constant to encode non control character with a value inside the control character range */ +#define CTS_DECODE (~0x40) /* Use this constant to decode previously encoded characters. These characters are marked by a leading CTS_ESC. */ + +#define CTS_MSG_MIN 0x18 /* First usable character for message and report identifiers */ +#define CTS_MSG_MAX 0x7F /* Last usable character for message and report identifiers */ + +#define CTS_DESIGNATOR_LEN 32 /* Length of the designator part in the HardwareRevision report */ +#define CTS_ASSY_LEN 16 /* Length of the ASSY part in the HardwareRevision report */ +#define CTS_OEMSTRING_LEN 256 /* Length of the OEM string */ +#define CTS_FPGA_LEN 28 /* Length of the FPGA version string */ +#define CTS_SENSORCOUNT_LEN 1 /* Length of sensorcount report */ + +#define CTS_MAX_HWASSY 32 /* Maximum number of hardware codeable assy numbers */ + +#define CTS_MAX_POLYEDGE 64 /* Maximum number of polygonal area edges */ + +#define CMD_REP_CONV 0x7f /* Use this bit mask to convert a command into a report identifier */ + +#define CTS_PACKET_SIZE (1+CTS_OEMSTRING_LEN) + +/* Area operating modes */ +#define AOM_OFF 0x00 /* No coordinate messages will be generated by this area */ +#define AOM_ENTER 0x01 /* Only the area entry point will be reported in a coordinate message */ +#define AOM_TRACK 0x02 /* Every movement inside the area will be reported in a coordinate message */ +#define AOM_CONT 0x03 /* If the area is touched, coordinate messages will be created in fixed time intervals */ + +/* Modification flags for the area operating mode */ +#define AOF_ADDEXIT 0x01 /* Exit messages will be generated for this area */ +#define AOF_ADDCOORD 0x02 /* The coordinate of the touch point will be reported in addition to the area number */ +#define AOF_ADDPRESS 0x04 /* Pressure messages will be generated for this area */ +#define AOF_PRESSALWAYS 0x08 /* This area requires a permanent pressure to generate coordinate messages */ +#define AOF_PRESSENTER 0x10 /* This area requires only pressure to generate the first coordinate message. */ +#define AOF_PRESSLOCAL 0x20 /* This area has a locally defined pressure sensitivity, If this flag is not set, the pressure sensivity of area0 is used. */ +#define AOF_EXTENDED 0x40 /* This area must be leaved, before any other area will generate coordinate messages */ +#define AOF_ACTIVE 0x80 /* This area is active. Only active areas will generate messages. */ + +/* group ClearArea command parameter values */ +#define CA_ALL 0x00 /* Clear all areas on all pages */ +#define CA_PAGE 0x01 /* Clear all areas of a certain page */ +#define CA_AREA 0x02 /* Clear a single area, however area0 cannot be cleared. area0 will only be reset to its power up default state. */ + +/* SetTransmission command parameter values */ +#define TM_TRANSMIT 0x01 /* Enable the transmission of messages (report will be transmitted always) */ +#define TM_NONE 0x00 /* Disable transmission of messages and disable the XON/XOFF protocol */ +#define TM_RXDFLOW 0x10 /* Enable the XON/XOFF protocol for the transmitter (IRT will send XON/XOFF to the host) */ +#define TM_TXDFLOW 0x20 /* Enable the XON/XOFF protocol for the receiver (host will sned XON/XOFF to the IRT) */ + +/* Sleep- and Doze-Mode command parameters */ +#define TS_QUIET 0x00 /* Disable the generation of TouchSaver messages */ +#define TS_ACTIMSG 0x01 /* Enable the generation of messages on sleep- or doze-mode activation */ +#define TS_PASIMSG 0x02 /* Enable the generation of messages on sleep- or doze-mode deactivation */ +#define TS_SETOUT 0x10 /* The /GP_OUT output of the IRT will reflect the sleep- or doze-mode state, if this flag is set. */ +#define TS_ACTIVE 0x80 /* This is a read only flag to decode the current sleep- or doze-mode state in SleepModeState and DozeModeState reports. */ + +/* SetDualTouching command parameters */ +#define DT_IGNORE 0x00 /* Multiple touches are ignored, no DualTouchError messages will be generated */ +#define DT_ERROR 0x01 /* Multiple touches will be reported by a DualTouchError message */ +#define DT_COORD 0x02 /* The coordinate of the second touch point will be reported in a separate coordinate message. More than 2 touch points will be reported by DualTouchError messages. */ + +/* SetOrigin command parameters */ +#define OR_TOPLEFT 0x00 /* The coordinate origin is in the top left corner of the touch */ +#define OR_TOPRIGHT 0x01 /* The coordinate origin is in the top right corner of the touch */ +#define OR_BOTTOMRIGHT 0x02 /* The coordinate origin is in the bottom right corner of the touch */ +#define OR_BOTTOMLEFT 0x03 /* The coordinate origin is in the bottom left corner of the touch */ + +/* GetSignalValues command parameters */ +#define GS_NOREPORT 0x00 /* Don't report the signal values */ +#define GS_SIGNAL 0x01 /* Report the beam values as used for coordinate generation */ +#define GS_REFERENCE 0x02 /* Report the reference beam values */ +#define GS_BROKEN 0x03 /* Report the results of the broken/not broken beam detection */ +#define GS_RESCAN 0x80 /* Add this flag to rescan the touch before generating the SignalValues report */ + +/* GetPressureValues command parameters */ +#define GP_NOREPORT 0x00 /* Don't report the pressure values */ +#define GP_SIGNAL 0x01 /* Report the signals of the active pressure sensors */ +#define GP_REFERENCE 0x02 /* Report the signals of the calibration sensors */ +#define GP_INTERNAL 0x04 /* Report the internal state of the pressure sensitive unit */ + +/* SetPort/GetPort command parameters */ +#define GP_OCOUT0 0x01 /* Get/Set the /OC_OUT0 port of the IRT */ +#define GP_BIJMP 0x02 /* Get the state of the BurnIn jumper on the IRT */ +#define GP_OCSSAVER 0x04 /* Get/Set the /OC_SSAVER port of the IRT */ +#define GP_OCIN0 0x08 /* Get the state of the /OC_IN0 port of the IRT */ + +/* GetRevisions command parameters */ +#define GR_SYSMGR 0x01 /* Get the version number of the System Manager module */ +#define GR_HARDWARE 0x02 /* Get the version number of the Hardware module */ +#define GR_PROCESS 0x04 /* Get the version number of the Process module */ +#define GR_PROTOCOL 0x08 /* Get the version number of the Protocol module */ +#define GR_HWPARAM 0x10 /* Get the version number of the Hardware Parameters module */ +#define GR_DESIGNATOR 0x20 /* Get the IRT designator and ASSY number */ +#define GR_BURNIN 0x40 /* Get the version number of the Burn-In module */ +#define GR_FPGA 0x80 /* Get the version number of the FPGA module */ + +/* GetErrors command parameters */ +#define GE_INITIAL 0x01 /* Report the errors detected during IRT startup */ +#define GE_DEFECTBEAMS 0x02 /* Report the beams that are marked defect and are therefore excluded from the coordinate calculations */ +#define GE_COMMUNICATION 0x04 /* Report communication errors on the serial link */ +#define GE_COMMAND 0x08 /* Report command errors (invalid parameters, unknown commands, ...) */ +#define GE_CLEAR 0x80 /* Add this flag to clear the errors after reporting */ + +/* GetHardware command parameters */ +#define GH_BEAMCOUNT 0x01 /* Report the number of x and y beams */ +#define GH_SENSORCOUNT 0x02 /* Report the number of pressure sensors */ +#define GH_PERIPHERALS 0x04 /* Report a bit vector that identifies all assembled peripherals on the IRT */ + +/* GetHWVersion command parameters */ +#define HV_SSNO 0x01 /* Report the silicon serial number */ +#define HV_ASSY 0x02 /* Report the hard wired assembly number */ +#define HV_FPGA 0x04 /* Report the FPGA version string */ + +/* InitialError decoding bit masks */ +#define IE_SMCHKSUM 0x00000001UL /* The system manager module has a checksum error */ +#define IE_SMINIT 0x00000002UL /* The system manager module reported an error during initialisation */ +#define IE_HWCHKSUM 0x00000004UL /* The hardware module has a checksum error */ +#define IE_HWINIT 0x00000008UL /* The hardware module reported an error during initialisation */ +#define IE_PCCHKSUM 0x00000010UL /* The process module has a checksum error */ +#define IE_PCINIT 0x00000020UL /* The process module reported an error during initialisation */ +#define IE_PTCHKSUM 0x00000040UL /* The protocol module has a checksum error */ +#define IE_PTINIT 0x00000080UL /* The protocol module reported an error during initialisation */ +#define IE_HW_BEAMS 0x00000100UL /* There were broken beams during hardware initialisation */ +#define IE_HW_PSU 0x00000200UL /* There pressure sensitive unit could not be initialised */ +#define IE_HW_CPU 0x00000400UL /* There was an error in the CPU core detected during startup */ +#define IE_HW_IRAM 0x00000800UL /* There was an error in the initial internal ram check */ +#define IE_HW_XRAM 0x00001000UL /* There was an error in the initial external ram check */ +#define IE_BICHK 0x00002000UL /* The burnin module has a checksum error */ +#define IE_BIINIT 0x00004000UL /* The burnin module reported an error during initialisation */ +#define IE_FPGACHK 0x00008000UL /* The fpga module has a checksum error */ +#define IE_HWPCHK 0x00010000UL /* The hardware parameter module has a checksum error */ + +/* CommunicationError decoding bit masks */ +#define CE_DC2GTDC4 0x00000001UL /* There were more CTS_STX received than CTS_ETX */ +#define CE_DC4GTDC2 0x00000002UL /* There were more CTS_ETX received than CTS_STX */ +#define CE_UNXNONCTRL 0x00000004UL /* Non control character received outside a CTS_STX/CTS_ETX sequence */ +#define CE_UNXCONTROL 0x00000008UL /* Unexpected control character received */ +#define CE_OVERFLOW 0x00000010UL /* The hardware receiver buffer had an overflow */ +#define CE_FRAMING 0x00000020UL /* There were characters with framing errors received */ +#define CE_PARITY 0x00000040UL /* There were characters with invalid parity received */ +#define CE_XOFFTO 0x00000080UL /* No XON was received within the defined timeout after a XOFF */ +#define CE_CMDOVER 0x00000100UL /* The command buffer had an overflow */ +#define CE_RCVROVER 0x00000200UL /* The receiver ring buffer had an overflow */ + +/* CommandError decoding bit masks */ +#define CE_UNKNOWN 0x00000001UL /* Unknown command received */ +#define CE_PARAMCNT 0x00000002UL /* Too much or too less parameters received */ +#define CE_RANGE 0x00000004UL /* One or more parameters were out of range */ + +/* Peripheral indentification bit masks */ +#define PERI_OCOUT0 0x00000001UL /* The /OC_OUT0 port is available */ +#define PERI_BURNIN 0x00000002UL /* The BurnIn jumper is available */ +#define PERI_GP_OUT 0x00000004UL /* The /GP_OUT port is available */ +#define PERI_OCPWM 0x00000008UL /* The /OC_PWM port is available */ +#define PERI_SPEAKER 0x00000010UL /* The speaker port is available */ +#define PERI_GP_IN 0x00000020UL /* The /GP_IN port is available */ +#define PERI_RUNLED 0x00000040UL /* The red blinking indication LED is available */ + +/* SaveSetup/ReadSetup command parameters */ +#define SUP_SERIAL 0x01 /* Save/Read the serial port setup */ +#define SUP_MACRO 0x02 /* Save/Read the macro definitions */ +#define SUP_AREAS 0x04 /* Save/Read the area definitions */ +#define SUP_PERI 0x08 /* Save/Read the peripheral settings */ +#define SUP_COORD 0x10 /* Save/Read the coordinate settings */ + +/* IRT initialisation modes for <f cts_Connect> */ + +#define MODE_A 0x7b /* Initialise the IRT to AFE-Mode A emulation */ +#define MODE_B 0x3c /* Initialise the IRT to Carroll emulation */ +#define MODE_C 0x6f /* Another entry point for Mode-D (for backwards compatibility) */ +#define MODE_D 0x81 /* Initialise the IRT to the CTS protocol */ + +/* Command is for the driver */ +#define DRIVCOMM 0x00 /* Command for driver */ + +/* Command Identifiers for the driver */ +#define D_SETCLICKMODE 0x00 +#define D_BEEP 0x01 +#define D_SETBEEP 0x02 + + +/* Message identifiers */ +#define R_DUALTOUCHERROR 0x18 /* Invalid multiple touches are detected */ +#define R_COORD 0x19 /* Regular coordinate report */ +#define R_EXIT 0x1a /* An area was leaved */ +#define R_PRESSURE 0x1b /* An area was pressed or released */ +#define PRESS_BELOW 0x00 /* Pressure below a certain threshold */ +#define PRESS_EXCEED 0x01 /* Pressure higher than a certain threshold */ + +#define R_SLEEPMODE 0x1c /* The sleep-mode was activated or deactivated */ +#define R_DOZEMODE 0x1d /* The doze-mode was activated or deactivated */ + +/* Special report identifiers */ +#define R_POLYAREADEF 0x2a +#define R_IDLE 0x34 +#define R_SCANTIMING 0x56 + +/* Command identifiers */ +#define C_SOFTRESET 0x80 +#define C_RESETCTS 0x81 +#define C_SAVESETUP 0x83 +#define C_DESTROYSETUP 0x84 +#define C_SETSCANTIMING 0x85 +#define C_GETSCANTIMING 0x86 + +#define C_CLEARAREA 0xa0 +#define C_DEFINEAREA 0xa1 +#define C_GETAREADEF 0xa2 +#define C_GETAREAPAGE 0xa3 +#define C_GETFREEAREASPACE 0xa4 +#define C_SELECTAREAPAGE 0xa5 +#define C_SETAREASTATE 0xa6 +#define C_SETAREAMODE 0xa7 +#define C_SETAREAFLAGS 0xa8 +#define C_SETAREAPRESSURE 0xa9 +#define C_DEFINEPOLYAREA 0xaa + +#define C_GETERRORS 0xb0 +#define C_GETHARDWARE 0xb1 +#define C_GETREVISIONS 0xb2 +#define C_GETSETUP 0xb3 +#define C_GETSINGLEMESSAGE 0xb4 +#define C_GETSINGLESCAN 0xb5 +#define C_GETSIGNALVALUES 0xb6 +#define C_GETPRESSUREVALUES 0xb7 +#define C_GETOEMSTRING 0xb8 +#define C_GETHWVERSIONS 0xb9 +#define C_BIGETFIRSTSESSION 0xba +#define C_BIGETNEXTSESSION 0xbb +#define C_BIGETRECORD 0xbc +#define C_BIERASEDATA 0xbd +#define C_BIGETTICKUNIT 0xbe + +#define C_GETBEAMMINMAX 0xc0 +#define C_GETBEAMTIMEOUT 0xc1 +#define C_GETCONTTIME 0xc2 +#define C_GETDUALTOUCHING 0xc3 +#define C_GETORIGIN 0xc4 +#define C_GETRESOLUTION 0xc5 +#define C_GETSCANNING 0xc6 +#define C_GETTRANSMISSION 0xc7 +#define C_SETBEAMMINMAX 0xc8 +#define C_SETBEAMTIMEOUT 0xc9 +#define C_SETCONTTIME 0xca +#define C_SETDUALTOUCHING 0xcb +#define C_SETORIGIN 0xcc +#define C_SETRESOLUTION 0xcd +#define C_SETSCANNING 0xce +#define C_SETTRANSMISSION 0xcf + +#define C_GETTOUCHTIME 0xd0 +#define C_SETTOUCHTIME 0xd1 + +#define C_CLEARMACRO 0xe0 +#define C_ENDMACRORECORD 0xe1 +#define C_EXECMACRO 0xe2 +#define C_GETFREEMACROSPACE 0xe3 +#define C_STARTMACRORECORD 0xe5 + +#define C_GETPORT 0xf0 +#define C_GETPWM 0xf1 +#define C_GETSOUND 0xf2 +#define C_GETSLEEPMODE 0xf3 +#define C_SETPORT 0xf4 +#define C_SETPWM 0xf5 +#define C_SETSOUND 0xf6 +#define C_SETSLEEPMODE 0xf7 +#define C_GETDOZEMODE 0xf8 +#define C_SETDOZEMODE 0xf9 + +/* touch states */ +#define CIT_TOUCHED 0x01 +#define CIT_PRESSED 0x02 +#define CIT_BUTTON 0x04 + +/* click modes */ +#define CM_ENTER 1 +#define CM_DUAL 2 +#define CM_DUALEXIT 3 +#define CM_ZPRESS 4 +#define CM_ZPRESSEXIT 5 + +#define MAX_DUAL_TOUCH_COUNT 2 + +#define NO_CLICK_MODE 255 /* no click mode set in xf86Config */ + +/* command structure for Feedback Functions */ +typedef struct { + unsigned char par[3]; /* byte parameter */ + char packet; /* packet number 00 - 7F */ +} COMMAND; + + +/* Data exchange with driver (Driver Data Structure) */ +#define MAX_BYTES_TO_TRANSFER 0x20 +#define LAST_PACKET 0x7f + +typedef struct { + short curbyte; /* current byte number */ + short numbytes; /* number of bytes to transmit */ + short packet; /* packet number */ + unsigned char data[MAX_BYTES_TO_TRANSFER]; /* pointer to data area */ +} CitronDDS; + + + + +/***************************************************************************** + * X-Header + ****************************************************************************/ + +#define X_CITOUCH " CiTouch: " +const char *CI_PROBED = {"(--)" X_CITOUCH}; /* Value was probed */ +const char *CI_CONFIG = {"(**)" X_CITOUCH}; /* Value was given in the config file */ +const char *CI_DEFAULT = {"(==)" X_CITOUCH}; /* Value is a default */ +const char *CI_CMDLINE = {"(++)" X_CITOUCH}; /* Value was given on the command line */ +const char *CI_NOTICE = {"(!!)" X_CITOUCH}; /* Notice */ +const char *CI_INFO = {"(II)" X_CITOUCH}; /* Informational message */ +const char *CI_WARNING = {"(WW)" X_CITOUCH}; /* Warning message */ +const char *CI_ERROR = {"(EE)" X_CITOUCH}; /* Error message */ +const char *CI_UNKNOWN = {"(?\?)" X_CITOUCH}; /* Unknown message */ + + + +/***************************************************************************** + * macros + ****************************************************************************/ +#define millisleep(ms) xf86usleep((ms) * 1000) + +#define HIBYTE(x) ( (unsigned char) ( (x) >> 8 ) ) +#define LOBYTE(x) ( (unsigned char) ( (x) & 0xff ) ) + + +/***************************************************************************** + * typedefs + ****************************************************************************/ +typedef enum +{ + cit_idle, cit_getID, cit_collect, cit_escape +} +cit_State; /* Citron Infrared Touch Driver State */ + +typedef struct _cit_privateRec +{ + int min_x; /* Minimum x reported by calibration */ + int max_x; /* Maximum x */ + int min_y; /* Minimum y reported by calibration */ + int max_y; /* Maximum y */ + int button_threshold; /* Z > button threshold = button click */ + int axes; + int dual_touch_count; /* counter for dual touch error events */ + int click_mode; /* one of the CM_ constants */ + int button_number; /* which button to report */ + int reporting_mode; /* TS_Raw or TS_Scaled */ + int screen_num; /* Screen associated with the device */ + int screen_width; /* Width of the associated X screen */ + int screen_height; /* Height of the screen */ + int packeti; /* index into packet */ + int raw_x; /* Raw Coordinates */ + int raw_y; + int sleep_mode; /* sleep mode: 0x00=no message, 0x01=m at activation, 0x02=m at deactivation, */ + /* 0x03= message at act. + deact., 0x10= GP_OUT set */ + int sleep_time_act; /* time until touchsaver gets activate */ + int sleep_time_scan; /* time interval between two scans */ + int pwm_sleep; /* PWM duty cycle during touch saver mode */ + int pwm_active; /* PWM duty cycle during regular operation */ + int state; +/* additional parameters */ + int last_x; /* last cooked data */ + int last_y; + int doze_mode; /* doze mode: 0x00=no message, 0x01=m at activation, 0x02=m at deactivation, */ + /* 0x03= message at act. + deact., 0x10= GP_OUT set */ + int doze_time_act; /* time until touchsaver gets activate */ + int doze_time_scan; /* time interval between scans */ + int origin; /* Coordinates origin */ + int delta_x; /* Delta x - if coordinate changed less than delta x no motion event */ + int delta_y; + int beep; /* 0= no beep, 1=beep enabled */ + int press_vol; /* volume of beep (press event) */ + int press_pitch; /* pitch of beep (press event) */ + int press_dur; /* length of beep in 10ms (press event) */ + int rel_vol; /* volume of beep (release event) */ + int rel_pitch; /* pitch of beep (release event) */ + int rel_dur; /* length of beep in 10ms (release event) */ + int beam_timeout; /* Beam timeout 0= no beam timeout */ + int touch_time; /* minimum time span for a valid interruption */ + int enter_touched; /* button is down due to an enter event */ + int enter_count; /* number of jumed coord reports before a ButtonPress event is sent */ + int max_dual_count; /* number of jumed dualtouch error reports before a ButtonPress event is sent */ + int dual_flg; /* Flag set if dualtouch error report is received , reset by counter */ + int raw_min_x; /* min x,y max x,y value accumulated over the whole session */ + int query_state; /* test if query was already started */ + int raw_max_x; + int raw_min_y; + int raw_max_y; + int pressure_sensors; /* number of pressure sensors */ + OsTimerPtr timer_ptr; /* Timer for general purposes */ + CARD32 timer_val1; /* Timer 1st delay */ + CARD32 timer_val2; /* Timer second delay */ + OsTimerCallback timer_callback; /* timer callback routine */ + int fake_exit; /* tell the ReadInput function there is a exit message (from timer) */ +/* end additional parameters */ + LocalDevicePtr local; /* Pointer to local device */ + Bool button_down; /* is the "button" currently down */ + Bool proximity; + cit_State lex_mode; + XISBuffer *buffer; + unsigned char packet[CTS_PACKET_SIZE]; /* packet being/just read */ + CitronDDS dds; /* Structure for Byte transfer to the driver via LedFeedbackControl */ +} +cit_PrivateRec, *cit_PrivatePtr; + +/****************************************************************************** + * Declarations + *****************************************************************************/ +/*extern void ModuleInit (pointer *, INT32 *);*/ +static MODULESETUPPROTO (SetupProc); +static void TearDownProc (pointer p); +/*static void *SetupProc (XF86OptionPtr, int *, int *);*/ +static Bool DeviceControl (DeviceIntPtr def, int mode); +static Bool DeviceOn (DeviceIntPtr); +static Bool DeviceOff (DeviceIntPtr); +static Bool DeviceClose (DeviceIntPtr); +static Bool DeviceInit (DeviceIntPtr); +static void ReadInput (LocalDevicePtr); +static int ControlProc (LocalDevicePtr, xDeviceCtl *); +static void CloseProc (LocalDevicePtr); +static int SwitchMode (ClientPtr, DeviceIntPtr, int); +static Bool ConvertProc (LocalDevicePtr, int, int, int, int, int, int, int, int, int *, int *); +static Bool QueryHardware (LocalDevicePtr, int *, int *); +static Bool cit_GetPacket (cit_PrivatePtr); +static void cit_Flush(XISBuffer *); +static void cit_SendCommand(XISBuffer *, unsigned char, int, ...); +static Bool cit_GetInitialErrors(cit_PrivatePtr); +static Bool cit_GetDefectiveBeams(cit_PrivatePtr); +static Bool cit_GetDesignator(cit_PrivatePtr); +static Bool cit_GetPressureSensors(cit_PrivatePtr); +static Bool cit_GetRevision(cit_PrivatePtr, int); +static void cit_ProcessPacket(cit_PrivatePtr); +static void cit_Beep(cit_PrivatePtr priv, int press); +#ifdef CIT_TIM +static void cit_StartTimer(cit_PrivatePtr priv); +static void cit_CloseTimer(cit_PrivatePtr priv); +static CARD32 cit_DualTouchTimer(OsTimerPtr timer, CARD32 now, pointer arg); +#endif + + + +/* + * DO NOT PUT ANYTHING AFTER THIS ENDIF + */ +#endif diff --git a/xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile b/xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile index 0a7bd34c5..eda7e8e40 100644 --- a/xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile,v 1.5 1999/08/14 10:50:00 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile,v 1.6 2000/11/06 19:24:07 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -12,11 +12,11 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) #ifdef LinuxArchitecture - ARCH_JSTK = ../os-support/linux/lnx_jstk.o + ARCH_JSTK = ../os-support/linux/lnx_jstk.o #endif #if defined(FreeBSDArchitecture) || defined(NetBSDArchitecture) || defined(OpenBSDArchitecture) - ARCH_JSTK = ../os-support/bsd/bsd_jstk.o + ARCH_JSTK = ../os-support/bsd/bsd_jstk.o #endif #if MakeHasPosixVariableSubstitutions diff --git a/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c b/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c index 560ecc683..3c5766155 100644 --- a/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c +++ b/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.8 2000/10/20 14:59:01 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.9 2000/11/03 18:46:16 eich Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -255,7 +255,7 @@ run_bios_int(int num, xf86Int10InfoPtr pInt) CARD32 eflags; #ifndef _PC /* check if bios vector is initialized */ - if (MEM_RW(pInt,(num<<2)+2) == 0xF000) { /* SYS_BIOS_SEG ?*/ + if (MEM_RW(pInt,(num<<2)+2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/ #ifdef PRINT_INT ErrorF("card BIOS not loaded\n"); #endif diff --git a/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c b/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c index ca61d6c9b..a138dc09f 100644 --- a/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c +++ b/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.11 2000/10/11 22:53:00 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.12 2000/11/03 18:46:16 eich Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -59,7 +59,7 @@ dprint(unsigned long start, unsigned long size) void setup_int_vect(xf86Int10InfoPtr pInt) { - const CARD16 cs = 0xF000; + const CARD16 cs = (SYS_BIOS >> 4); const CARD16 ip = 0x0; int i; @@ -127,11 +127,11 @@ void reset_int_vect(xf86Int10InfoPtr pInt) { MEM_WW(pInt,(0x10<<2),0xf065); - MEM_WW(pInt,((0x10<<2)+2),0xf000); + MEM_WW(pInt,((0x10<<2)+2),(SYS_BIOS >> 4)); MEM_WW(pInt,(0x42<<2),0xf065); - MEM_WW(pInt,((0x42<<2)+2),0xf000); + MEM_WW(pInt,((0x42<<2)+2),(SYS_BIOS >> 4)); MEM_WW(pInt,(0x6D<<2),0xf065); - MEM_WW(pInt,((0x6D<<2)+2),0xf000); + MEM_WW(pInt,((0x6D<<2)+2),(SYS_BIOS >> 4)); } void @@ -194,9 +194,17 @@ int10_read_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem) if ((size + (codeSeg << 4)) > SYS_SIZE) return FALSE; +#ifdef _PC + /* + * Read everything between V_BIOS start and SYS_BIOS: + * Some systems with built in graphics might jump here. + */ + size = SYS_BIOS - (codeSeg << 4); +#else /* We might already have the tail end */ if ((size + (codeSeg << 4)) > SYS_BIOS) size = SYS_BIOS - (codeSeg << 4); +#endif if (xf86ReadBIOS(codeSeg << 4,0,vbiosMem, size) < 0) { xf86DrvMsg(scrnIndex,X_ERROR,"Cannot read V_BIOS (2)\n"); diff --git a/xc/programs/Xserver/hw/xfree86/int10/pci.c b/xc/programs/Xserver/hw/xfree86/int10/pci.c index 6f1601000..49512cd28 100644 --- a/xc/programs/Xserver/hw/xfree86/int10/pci.c +++ b/xc/programs/Xserver/hw/xfree86/int10/pci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/pci.c,v 1.3 2000/10/26 11:47:47 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/pci.c,v 1.4 2000/11/03 18:46:16 eich Exp $ */ /* * XFree86 int10 module @@ -33,7 +33,7 @@ mapPciRom(xf86Int10InfoPtr pInt, unsigned char * address) tag = pciTag(pvp->bus,pvp->device,pvp->func); mem = ptr = xnfcalloc(0x10000, 1); - if (! xf86ReadPciBIOS(0,tag,offset,mem,0xFFFF) < 0) { + if (! xf86ReadPciBIOS(offset,tag,-1,mem,0xFFFF) < 0) { xfree(mem); #ifdef DEBUG ErrorF("mapPciRom: cannot read BIOS\n"); @@ -64,7 +64,7 @@ mapPciRom(xf86Int10InfoPtr pInt, unsigned char * address) image_length,indicator); #endif offset = offset + image_length; - if (xf86ReadPciBIOS(0,tag,offset,mem,0xFFFF) < 0) { + if (xf86ReadPciBIOS(offset,tag,-1,mem,0xFFFF) < 0) { xfree(mem); #ifdef DEBUG ErrorF("mapPciRom: cannot read BIOS\n"); @@ -80,7 +80,7 @@ mapPciRom(xf86Int10InfoPtr pInt, unsigned char * address) #endif scratch = (unsigned char *)xnfalloc(length); - if (xf86ReadPciBIOS(0,tag,offset,scratch,length) < 0) { + if (xf86ReadPciBIOS(offset,tag,-1,scratch,length) < 0) { xfree(mem); xfree(scratch); #ifdef DEBUG diff --git a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h index be7318c01..9f1008a75 100644 --- a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h +++ b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.9 2000/10/20 14:59:01 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.10 2000/11/03 18:46:16 eich Exp $ */ /* * XFree86 int10 module @@ -66,7 +66,11 @@ void xf86ExecX86int10(xf86Int10InfoPtr pInt); #define I_S_DEFAULT_INT_VECT 0xFF065 #define SYS_SIZE 0x100000 #define SYS_BIOS 0xF0000 +#if 0 #define BIOS_SIZE 0x10000 +#else /* a bug in DGUX requires this - let's try it */ +#define BIOS_SIZE (0x10000 - 1) +#endif #define LOW_PAGE_SIZE 0x600 #define V_RAM 0xA0000 #define VRAM_SIZE 0x20000 diff --git a/xc/programs/Xserver/hw/xfree86/loader/Imakefile b/xc/programs/Xserver/hw/xfree86/loader/Imakefile index 6dbcaa5b3..d34a84432 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/loader/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/loader/Imakefile,v 1.25 2000/10/20 14:59:02 alanh Exp $ */ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/loader/Imakefile,v 1.26 2000/11/02 19:10:53 dawes Exp $ */ @@ -39,6 +39,11 @@ SRCS1 = os2funcs.c OBJS1 = os2funcs.o #endif +#ifdef SparcArchitecture +SRCS1 = SparcMulDiv.S +OBJS1 = SparcMulDiv.o +#endif + SRCS = aoutloader.c coffloader.c $(DLSRC) elfloader.c hash.c loader.c \ loadmod.c loadfont.c loadext.c os.c dixsym.c misym.c xf86sym.c \ fontsym.c extsym.c $(SRCS1) @@ -58,4 +63,8 @@ SpecialCObjectRule(loadmod,NullParameter,$(MODULEDEFINES) $(EXT_DEFINES)) SpecialCObjectRule(xf86sym,NullParameter,$(EXT_DEFINES)) SpecialCObjectRule(dixsym,NullParameter,$(EXT_DEFINES)) +#ifdef SparcArchitecture +ObjectFromAsmSource(SparcMulDiv,NullParameter) +#endif + DependTarget() diff --git a/xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S b/xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S new file mode 100644 index 000000000..e7281593c --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S @@ -0,0 +1,87 @@ +/* + * Hardware integer division and multiplication routines for SPARC v8 and higher. + * + * Copyright (C) 1996 David S. Miller (davem@redhat.com) + * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz) + * + * 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 + * JAKUB JELINEK OR DAVID MILLER 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. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S,v 1.1 2000/11/02 19:10:54 dawes Exp $ */ + + .globl urem_sparcv89, umul_sparcv89, udiv_sparcv89 + .globl rem_sparcv89, mul_sparcv89, div_sparcv89 + + .align 32 +urem_sparcv89: + wr %g0, 0x0, %y + nop + nop + nop + udiv %o0, %o1, %o2 + umul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +umul_sparcv89: + umul %o0, %o1, %o0 + retl + rd %y, %o1 + + .align 32 +udiv_sparcv89: + wr %g0, 0x0, %y + nop + nop + retl + udiv %o0, %o1, %o0 + + .align 32 +rem_sparcv89: + sra %o0, 0x1f, %o4 + wr %o4, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o2 + bvs,a 1f + xnor %o2, %g0, %o2 +1: smul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +mul_sparcv89: + smul %o0, %o1, %o0 + retl + rd %y, %o1 + nop + + .align 32 +div_sparcv89: + sra %o0, 0x1f, %o2 + wr %o2, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o0 + bvs,a 1f + xnor %o0, %g0, %o0 +1: retl + nop diff --git a/xc/programs/Xserver/hw/xfree86/loader/dixsym.c b/xc/programs/Xserver/hw/xfree86/loader/dixsym.c index 4bcdea878..830f24e61 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/dixsym.c +++ b/xc/programs/Xserver/hw/xfree86/loader/dixsym.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.33 2000/09/20 02:05:11 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.34 2000/11/03 11:50:20 alanh Exp $ */ /* @@ -60,6 +60,9 @@ /* XXX This should be in a header somewhere */ extern void ClientSleepUntil(ClientPtr, TimeStamp, void(*)(ClientPtr, pointer), pointer); +extern int ShmCompletionCode; +extern int BadShmSegCode; +extern RESTYPE ShmSegType; /* DIX things */ @@ -311,6 +314,9 @@ LOOKUP dixLookupTab[] = { /* libXext.a */ SYMFUNC(ClientSleepUntil) + SYMVAR(ShmCompletionCode) + SYMVAR(BadShmSegCode) + SYMVAR(ShmSegType) /* librender.a */ #ifdef RENDER diff --git a/xc/programs/Xserver/hw/xfree86/loader/extsym.c b/xc/programs/Xserver/hw/xfree86/loader/extsym.c index 2715acd8d..46ad232f4 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/extsym.c +++ b/xc/programs/Xserver/hw/xfree86/loader/extsym.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.4 2000/03/30 18:20:58 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.5 2000/11/01 22:50:04 anderson Exp $ */ /* * @@ -31,9 +31,11 @@ #include "panoramiX.h" #endif +#ifdef HAS_SHM extern int ShmCompletionCode; extern int BadShmSegCode; extern RESTYPE ShmSegType, ShmPixType; +#endif #ifdef PANORAMIX extern Bool noPanoramiXExtension; @@ -50,9 +52,11 @@ extern int XineramaDeleteResource(pointer, XID); LOOKUP extLookupTab[] = { +#ifdef HAS_SHM SYMVAR(ShmCompletionCode) SYMVAR(BadShmSegCode) SYMVAR(ShmSegType) +#endif #ifdef PANORAMIX SYMFUNC(XineramaRegisterConnectionBlockCallback) diff --git a/xc/programs/Xserver/hw/xfree86/loader/loader.c b/xc/programs/Xserver/hw/xfree86/loader/loader.c index 44c279166..60acebe02 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/loader.c +++ b/xc/programs/Xserver/hw/xfree86/loader/loader.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.44 2000/10/02 02:32:15 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.46 2000/11/03 18:46:16 eich Exp $ */ /* * @@ -85,11 +85,75 @@ static char freeHandles[MAX_HANDLE] ; static int refCount[MAX_HANDLE] ; #endif -#ifdef __sparc__ -extern LOOKUP SparcLookupTab[]; +#if defined(__sparc__) && defined(__GNUC__) +# define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func }, +# define SYMFUNCDOT89(func) { "." #func, (funcptr)&func ## _sparcv89 }, +# define DEFFUNCDOT(func) \ +extern void __sparc_dot_ ## func (void) __asm__ ("." #func); \ +extern void func ## _sparcv89 (void); +DEFFUNCDOT(rem) +DEFFUNCDOT(urem) +DEFFUNCDOT(mul) +DEFFUNCDOT(umul) +DEFFUNCDOT(div) +DEFFUNCDOT(udiv) +static LOOKUP SparcV89LookupTab[] = { + SYMFUNCDOT89(rem) + SYMFUNCDOT89(urem) + SYMFUNCDOT89(mul) + SYMFUNCDOT89(umul) + SYMFUNCDOT89(div) + SYMFUNCDOT89(udiv) + { 0, 0 } +}; +static LOOKUP SparcLookupTab[] = { + SYMFUNCDOT(rem) + SYMFUNCDOT(urem) + SYMFUNCDOT(mul) + SYMFUNCDOT(umul) + SYMFUNCDOT(div) + SYMFUNCDOT(udiv) + { 0, 0 } +}; #ifdef linux -extern int sparcUseHWMulDiv(void); -extern LOOKUP SparcV89LookupTab[]; +#if defined(__GNUC__) && defined(__GLIBC__) +#define HWCAP_SPARC_MULDIV 8 +extern unsigned long int _dl_hwcap; +#endif + +static int +sparcUseHWMulDiv(void) +{ + FILE *f; + char buffer[1024]; + char *p; +#if defined(__GNUC__) && defined(__GLIBC__) + unsigned long *hwcap; + __asm(".weak _dl_hwcap"); + + hwcap = &_dl_hwcap; + __asm("" : "=r" (hwcap) : "0" (hwcap)); + if (hwcap) { + if (*hwcap & HWCAP_SPARC_MULDIV) + return 1; + else + return 0; + } +#endif + f = fopen("/proc/cpuinfo","r"); + if (!f) return 0; + while (fgets(buffer, 1024, f) != NULL) { + if (!strncmp (buffer, "type", 4)) { + p = strstr (buffer, "sun4"); + if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { + fclose(f); + return 1; + } + } + } + fclose(f); + return 0; +} #endif #endif @@ -404,6 +468,10 @@ _LoaderFileToMem(int fd, unsigned long offset,int size, char *label) FatalError("\n_LoaderFileToMem() read() failed: %s\n",strerror(errno)); #if defined(linux) && defined(__powerpc__) + /* + * Keep the instruction cache in sync with changes in the + * main memory. + */ { int i; for (i = 0; i < size; i += 16) diff --git a/xc/programs/Xserver/hw/xfree86/loader/loadmod.c b/xc/programs/Xserver/hw/xfree86/loader/loadmod.c index 4f33b016d..f1025f944 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/loadmod.c +++ b/xc/programs/Xserver/hw/xfree86/loader/loadmod.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.54 2000/10/20 12:57:26 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.56 2000/11/03 18:46:16 eich Exp $ */ /* * @@ -28,7 +28,7 @@ #include "os.h" /* For stat() and related stuff */ #define NO_OSLIB_PROTOTYPES -#define NO_COMPILER_H +/* #define NO_COMPILER_H */ #include "xf86_OSlib.h" #if defined(SVR4) #include <sys/stat.h> @@ -994,6 +994,13 @@ LoadModule (const char *module, const char *path, const char **subdirlist, TestFree (found); TestFree (name); TestFree (p); + + /* + * If you need to do something to keep the + * instruction cache in sync with the main + * memory before jumping to that code, you may + * do it here. + */ #ifdef __alpha__ istream_mem_barrier(); #endif diff --git a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c index 6b080d5d9..77523bee5 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c +++ b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.167 2000/10/24 22:45:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.170 2000/11/06 19:24:08 dawes Exp $ */ /* * @@ -124,38 +124,6 @@ extern unsigned int _inw(unsigned short port); extern unsigned int _inl(unsigned short port); #endif -#if defined(__sparc__) && defined(__GNUC__) -# define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func }, -# define SYMFUNCDOT89(func) { "." #func, (funcptr)&func ## _sparcv89 }, -# define DEFFUNCDOT(func) \ -extern void __sparc_dot_ ## func (void) __asm__ ("." #func); \ -extern void func ## _sparcv89 (void); -DEFFUNCDOT(rem) -DEFFUNCDOT(urem) -DEFFUNCDOT(mul) -DEFFUNCDOT(umul) -DEFFUNCDOT(div) -DEFFUNCDOT(udiv) -LOOKUP SparcV89LookupTab[] = { - SYMFUNCDOT89(rem) - SYMFUNCDOT89(urem) - SYMFUNCDOT89(mul) - SYMFUNCDOT89(umul) - SYMFUNCDOT89(div) - SYMFUNCDOT89(udiv) - { 0, 0 } -}; -LOOKUP SparcLookupTab[] = { - SYMFUNCDOT(rem) - SYMFUNCDOT(urem) - SYMFUNCDOT(mul) - SYMFUNCDOT(umul) - SYMFUNCDOT(div) - SYMFUNCDOT(udiv) - { 0, 0 } -}; -#endif - #if defined(__powerpc__) && (defined(Lynx) || defined(linux)) void eieio(); void _restf14(); @@ -436,6 +404,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86GetFlipPixels) SYMFUNC(xf86GetServerName) SYMFUNC(xf86ServerIsExiting) + SYMFUNC(xf86ServerIsOnlyDetecting) SYMFUNC(xf86ServerIsOnlyProbing) SYMFUNC(xf86ServerIsResetting) SYMFUNC(xf86CaughtSignal) @@ -449,6 +418,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86SetPriority) SYMFUNC(xf86LoadDrvSubModule) SYMFUNC(xf86LoadSubModule) + SYMFUNC(xf86LoadOneModule) SYMFUNC(xf86UnloadSubModule) SYMFUNC(xf86LoaderCheckSymbol) SYMFUNC(xf86LoaderReqSymLists) @@ -953,7 +923,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(outw) SYMFUNC(outl) #endif -#if defined(__powerpc__) +#if defined(__powerpc__) && !defined(__OpenBSD__) SYMFUNC(inb) SYMFUNC(inw) SYMFUNC(inl) @@ -1077,7 +1047,7 @@ LOOKUP xfree86LookupTab[] = { SYMVAR(res8514Shared) SYMVAR(PciAvoid) -#if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) +#if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) && !defined(__OpenBSD__) SYMVAR(ioBase) #endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile index 16f6058a5..9b30dd159 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.42 2000/08/10 17:40:34 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.43 2000/11/06 19:24:08 dawes Exp $ @@ -26,10 +26,6 @@ OS_SUBDIR = qnx4 OS_SUBDIR = nto #endif -#if defined(ArcArchitecture) -OS_SUBDIR = bsd -#endif - #if defined(SVR3Architecture) # if defined(i386ScoArchitecture) OS_SUBDIR = sco @@ -66,16 +62,13 @@ OS_SUBDIR = linux OS_SUBDIR = lynxos #endif -#if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) -# if defined(BSDOSArchitecture) -OS_SUBDIR = bsdi -# else +#if defined(FreeBSDArchitecture) || defined(NetBSDArchitecture) || \ + defined(OpenBSDArchitecture) OS_SUBDIR = bsd -# endif #endif -#if defined(NetBSDArchitecture) && defined(Arm32Architecture) -OS_SUBDIR = bsd +#if defined(BSDOSArchitecture) +OS_SUBDIR = bsdi #endif #if defined(i386MachArchitecture) || defined(OsfArchitecture) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile index 65642f566..874355c26 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile @@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/12 1996/10/27 11:06:35 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.45 2000/08/16 01:45:29 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.46 2000/11/06 19:24:08 dawes Exp $ #include <Server.tmpl> @@ -29,6 +29,9 @@ SHARED_CFLAGS = PositionIndependentCFlags IOPERMDEFINES = -DUSE_ARC_MMAP # elif defined(Arm32Architecture) IOPERMDEFINES = -DUSE_ARM32_MMAP +# elif defined(PpcArchitecture) + IOPERM_SRC = ioperm_noop.c + IOPERM_OBJ = ioperm_noop.o # else IOPERMDEFINES = -DUSE_I386_IOPL # endif @@ -65,7 +68,8 @@ SUBDIRS = libusb #endif -#if defined(NetBSDArchitecture) || defined(OpenBSDArchitecture) +#if (defined(NetBSDArchitecture) || defined(OpenBSDArchitecture)) \ + && defined(i386Architecture) APMSRC = bsd_apm.c APMOBJ = bsd_apm.o #else @@ -113,7 +117,7 @@ OBJS = bsd_init.o bsd_video.o bsd_io.o bsd_VTsw.o \ $(AXP_OBJ) $(KMODOBJ) $(AGP_OBJ) INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi -I$(APINCLUDES) \ + -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi $(APINCLUDES) \ $(LIBUSBINCLUDES) CONSDEFINES = XFree86ConsoleDefines @@ -122,7 +126,7 @@ RESDEFINES = -DUSESTDRES #if HasNetBSDApertureDriver APDIR = NetBSDApertureDir APDEFINES = -DHAS_APERTURE_DRV -APINCLUDES = $(APDIR)/include +APINCLUDES = -I$(APDIR)/include #endif DEFINES = $(CONSDEFINES) $(APDEFINES) $(IOPERMDEFINES) $(RESDEFINES) \ @@ -154,7 +158,8 @@ InstallDynamicModule(bsd_jstk.o,$(MODULEDIR),input) # endif #endif -#if !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture) +#if !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture) || \ + !defined(i386Architecture) LinkSourceFile(pm_noop.c,../shared) #endif LinkSourceFile(ioperm_noop.c,../shared) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c index ee075f113..a94be5ecb 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c,v 1.1 2000/03/05 16:59:17 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c,v 1.2 2000/11/06 19:24:08 dawes Exp $ */ /* Resource information code */ @@ -89,6 +89,44 @@ xf86AccResFromOS(resPtr ret) return ret; } +#elif defined(__powerpc__) + +resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END}; + +resPtr +xf86BusAccWindowsFromOS(void) +{ + resPtr ret = NULL; + resRange range; + + RANGE(range, 0, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + RANGE(range, 0, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + return ret; +} + +resPtr +xf86PciBusAccWindowsFromOS(void) +{ + resPtr ret = NULL; + resRange range; + + RANGE(range, 0, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + RANGE(range, 0, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + return ret; +} + +resPtr +xf86AccResFromOS(resPtr ret) +{ + return ret; +} + #else #error : Put your platform dependent code here!! diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c index f2d289367..73ad37281 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.13 1999/04/28 05:36:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.14 2000/11/06 19:24:08 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -84,6 +84,9 @@ static char *supported_drivers[] = { #ifdef PCVT_SUPPORT "pcvt", #endif +#ifdef WSCONS_SUPPORT + "wscons", +#endif }; @@ -109,6 +112,10 @@ static int xf86OpenSyscons(void); static int xf86OpenPcvt(void); #endif /* PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT +static int xf86OpenWScons(void); +#endif + /* * The sequence of the driver probes is important; start with the * driver that is best distinguishable, and end with the most generic @@ -125,6 +132,9 @@ static xf86ConsOpen_t xf86ConsTab[] = { #ifdef PCCONS_SUPPORT xf86OpenPccons, #endif +#ifdef WSCONS_SUPPORT + xf86OpenWScons, +#endif (xf86ConsOpen_t)NULL }; @@ -265,6 +275,12 @@ xf86OpenConsole() } break; #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + fprintf(stderr, "xf86OpenConsole\n"); + /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ + break; +#endif } } else @@ -549,6 +565,35 @@ xf86OpenPcvt() #endif /* PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + +static int +xf86OpenWScons() +{ + int fd = -1; + int mode = WSDISPLAYIO_MODE_MAPPED; + int i; + char ttyname[16]; + + /* XXX Is this ok? */ + for (i = 0; i < 8; i++) { + sprintf(ttyname, "/dev/ttyE%d", i); + if ((fd = open(ttyname, 2)) != -1) + break; + } + if (fd != -1) { + if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { + FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s\n", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + xf86Info.consType = WSCONS; + xf86Msg(X_PROBED, "Using wscons driver\n"); + } + return fd; +} + +#endif /* WSCONS_SUPPORT */ void xf86CloseConsole() @@ -584,6 +629,14 @@ xf86CloseConsole() ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); break; #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + { + int mode = WSDISPLAYIO_MODE_EMUL; + ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); + break; + } +#endif } if (xf86Info.screenFd != xf86Info.consoleFd) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c index b0ced38d2..3b78fb833 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.17 1999/09/04 13:04:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.18 2000/11/06 19:24:08 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Dawes <dawes@xfree86.org> @@ -159,6 +159,10 @@ xf86KbdOn() #endif break; #endif +#ifdef WSCONS_SUPPORT + case WSCONS: + return xf86Info.kbdFd; +#endif } return(xf86Info.consoleFd); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c index b5a9cb6f8..9f1b00077 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c,v 3.35 2000/08/11 17:27:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c,v 3.37 2000/11/06 19:24:08 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -167,18 +167,23 @@ static int devMemFd = -1; #endif #define DEV_MEM "/dev/mem" -static pointer mapVidMem(int, unsigned long, unsigned long); +static pointer mapVidMem(int, unsigned long, unsigned long, int); static void unmapVidMem(int, pointer, unsigned long); #ifdef __alpha__ -static pointer mapVidMemSparse(int, unsigned long, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); static void unmapVidMemSparse(int, pointer, unsigned long); #endif +#ifdef __powerpc__ +static pointer ppcMapVidMem(int, unsigned long, unsigned long); +static void ppcUnmapVidMem(int, pointer, unsigned long); +#endif #ifdef HAS_MTRR_SUPPORT static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); static void undoWC(int, pointer); static Bool cleanMTRR(void); #endif +#if !defined(__powerpc__) /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. @@ -267,12 +272,17 @@ checkDevMem(Bool warn) #endif } +#endif /* !__powerpc__ */ void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { +#if defined(__powerpc__) + pVidMem->linearSupported = TRUE; +#else checkDevMem(TRUE); pVidMem->linearSupported = useDevMem; +#endif #if defined(__alpha__) if (has_bwx()) { xf86Msg(X_INFO,"Machine type has 8/16 bit access\n"); @@ -286,6 +296,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) #elif defined(__arm32__) pVidMem->mapMem = armMapVidMem; pVidMem->unmapVidMem = armUnmapVidMem; +#elif defined(__powerpc__) + pVidMem->mapMem = ppcMapVidMem; + pVidMem->unmapMem = ppcUnmapVidMem; #else pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; @@ -302,8 +315,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->initialised = TRUE; } +#if !defined(__powerpc__) static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; @@ -385,8 +399,9 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); if ((long)ptr == -1) { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", - DEV_MEM, strerror(errno)); + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); return(-1); } #ifdef DEBUG @@ -395,9 +410,14 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, #endif (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap((caddr_t)ptr, mlen); + xf86Msg(X_INFO, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); return(Len); } +#endif /* !__powerpc__ */ + #ifdef __arm32__ /* XXX This needs to be updated for the ND */ @@ -530,7 +550,7 @@ xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) } static pointer -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { struct memAccess *memInfoP; @@ -558,7 +578,7 @@ armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) base = xf86MapInfoMap(memInfoP, Base, Size); return (base); } - return mapVidMem(ScreenNum, Base, Size); + return mapVidMem(ScreenNum, Base, Size, flags); } static void @@ -574,6 +594,63 @@ armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) } #endif /* __arm32__ */ +#if defined(__powerpc__) + +volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +{ + int fd = xf86Info.screenFd; + pointer base; + + fprintf(stderr, "mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd); + + base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + +static void +ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int rv; + int kmem; + + kmem = open("/dev/kmem", 2); + if (kmem == -1) { + FatalError("xf86ReadBIOS: open /dev/kmem\n"); + } + + + fprintf(stderr, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); + + if (Base < 0x80000000) { + fprintf(stderr, "No VGA\n"); + return 0; + } + + + lseek(kmem, Base + Offset, 0); + rv = read(kmem, Buf, Len); + close(kmem); + + return rv; +} + + +#endif /* __powerpc__ */ + #ifdef USE_I386_IOPL /***************************************************************************/ /* I/O Permissions section */ @@ -710,7 +787,8 @@ Bool xf86DisableInterrupts() { -#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) +#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) && \ + !defined(__powerpc__) #ifdef __GNUC__ __asm__ __volatile__("cli"); #else @@ -725,7 +803,8 @@ void xf86EnableInterrupts() { -#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) +#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) && \ + !defined(__powerpc__) #ifdef __GNUC__ __asm__ __volatile__("sti"); #else @@ -736,6 +815,24 @@ xf86EnableInterrupts() return; } +/************************************************************************/ +/* This is required for the loader */ +/************************************************************************/ +#if defined(__powerpc__) +void +ppc_flush_icache(char *addr) +{ + __asm__ volatile ( + "dcbf 0,%0;" + "sync;" + "icbi 0,%0;" + "sync;" + "isync;" + : : "r"(addr) : "memory"); +} +#endif + + #ifdef __NetBSD__ /***************************************************************************/ /* Set TV output mode */ @@ -1345,7 +1442,7 @@ sethae(u_int64_t hae) } static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { static Bool was_here = FALSE; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile index 764440fdc..c37b982df 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile @@ -3,7 +3,7 @@ XCOMM $XConsortium: Imakefile /main/16 1996/10/27 18:07:43 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.13 2000/06/13 02:28:36 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.14 2000/11/06 19:24:09 dawes Exp $ #include <Server.tmpl> @@ -30,6 +30,13 @@ XCOMM generic linux PCI driver (using /proc/bus/pci, requires kernel 2.2) PCIDRVRSRC = linuxPci.c PCIDRVROBJ = linuxPci.o +#elif defined(OpenBSDArchitecture) && defined(PpcArchitecture) + +XCOMM OpenBSD/powerpc + +PCIDRVRSRC = freebsdPci.c +PCIDRVROBJ = freebsdPci.o + #elif defined(PpcArchitecture) XCOMM PowerPC PCI drivers diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c index 9de4fa9c7..ffbcfa0bc 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.35 2000/10/17 16:53:19 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.37 2000/10/28 13:35:06 tsi Exp $ */ /* * Pci.c - New server PCI access functions * diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h index 6c3f44ed8..b73bb6446 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.14 2000/10/17 16:53:19 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.15 2000/11/06 19:24:09 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -139,6 +139,9 @@ #if (defined(__powerpc__) || defined(__mips__)) && defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM +#elif defined(__powerpc__) && defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM #elif defined(__powerpc__) # define ARCH_PCI_INIT ppcPciInit # if !defined(PowerMAX_OS) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c index 43f7cc7f9..b566246bd 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.1 2000/02/12 20:45:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.2 2000/11/06 19:24:09 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -79,6 +79,7 @@ pciBusInfo_t freebsdPci0 = { /* pciBusPriv */ NULL }; +#if !defined(__OpenBSD__) #if X_BYTE_ORDER == X_BIG_ENDIAN #ifdef __sparc__ #ifndef ASI_PL @@ -98,6 +99,11 @@ __ret; \ #else #define PCI_CPU(val) (val) #endif +#else /* ! OpenBSD */ +/* OpenBSD has already the bytes in the right order + for all architectures */ +#define PCI_CPU(val) (val) +#endif #define BUS(tag) (((tag)>>16)&0xff) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c index e3a0b7e5c..0967641d7 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.2 2000/04/04 19:25:19 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.3 2000/11/02 19:10:55 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -135,45 +135,4 @@ sparcPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits) val = (val & ~mask) | (bits & mask); syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val); } - -int sparcUseHWMulDiv(void); - -#if defined(__GNUC__) && defined(__GLIBC__) -#define HWCAP_SPARC_MULDIV 8 -extern unsigned long int _dl_hwcap; -#endif - -int -sparcUseHWMulDiv(void) -{ - FILE *f; - char buffer[1024]; - char *p; -#if defined(__GNUC__) && defined(__GLIBC__) - unsigned long *hwcap; - __asm(".weak _dl_hwcap"); - - hwcap = &_dl_hwcap; - __asm("" : "=r" (hwcap) : "0" (hwcap)); - if (hwcap) { - if (*hwcap & HWCAP_SPARC_MULDIV) - return 1; - else - return 0; - } -#endif - f = fopen("/proc/cpuinfo","r"); - if (!f) return 0; - while (fgets(buffer, 1024, f) != NULL) { - if (!strncmp (buffer, "type", 4)) { - p = strstr (buffer, "sun4"); - if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { - fclose(f); - return 1; - } - } - } - fclose(f); - return 0; -} #endif /* Linux */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c index 04a9ececc..29cce2f8a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.15 2000/10/17 16:53:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.16 2000/11/03 18:30:49 eich Exp $ */ /* * linux specific part of the int10 module * Copyright 1999 Egbert Eich @@ -67,7 +67,7 @@ xf86InitInt10(int entityIndex) char *base_high; int pagesize; legacyVGARec vga; - + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; if (int10skip(xf86Screens[screen],entityIndex)) return NULL; @@ -161,7 +161,6 @@ xf86InitInt10(int entityIndex) #endif if (xf86IsEntityPrimary(entityIndex)) { - int size; int cs = ((CARD16*)0)[(0x10<<1)+1]; CARD8 *bios_base = (unsigned char *)(cs << 4); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c new file mode 100644 index 000000000..50d338fde --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c @@ -0,0 +1,98 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#include <stdio.h> +#include "X.h" +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Axp.h" + +axpDevice lnxGetAXP(void); + +static AXP axpList[] = { + { "Tsunami", NULL, NULL, TSUNAMI }, + { "Eiger", NULL, NULL, TSUNAMI }, + {"Noname", NULL, NULL, LCA }, + { "AlphaBook1", NULL, NULL, LCA }, + {"EB66", NULL, NULL, LCA}, + {"EB64+",NULL,NULL, APECS}, + {"Noritake",NULL,NULL,APECS}, + {"XL",NULL,NULL,APECS}, + {"Avanti",NULL,NULL,APECS}, + {"Mikasa",NULL,"EV5",CIA}, + {"Mikasa",NULL,"EV56",CIA}, + {"Mikasa",NULL,NULL,APECS}, + {"EB164","EB164",NULL,APECS}, + {"EB164","PC164", NULL,CIA}, + {"EB164","RX164",NULL, POLARIS}, + {"EB164","LX164",NULL, PYXIS}, + {"Alcor",NULL,NULL,CIA}, + {"Takara",NULL,NULL,CIA}, + {"Sable",NULL, "EV5",T2_GAMMA}, + {"Sable",NULL,"EV56",T2_GAMMA}, + {"Sable",NULL,NULL,T2}, + {"Rawhide",NULL,NULL,MCPCIA}, + {"Jensen",NULL,NULL,JENSEN}, + {"Miata",NULL,NULL,PYXIS_CIA}, + {"Ruffian",NULL,NULL,PYXIS_CIA}, + {"Nautilus",NULL,NULL,IRONGATE}, + {NULL,NULL,NULL,NONE} +}; + + +axpDevice +lnxGetAXP(void) +{ + FILE *file; + int count = 0; + char res[256]; + char cpu[255]; + char systype[255]; + char sysvari[255]; + if (!(file = fopen("/proc/cpuinfo","r"))) + return SYS_NONE; + do { + if (!fgets(res,0xff,file)) return SYS_NONE; + switch (count) { + case 1: + sscanf(res, "cpu model : %s",cpu); +#ifdef DEBUG + ErrorF("CPU %s\n",cpu); +#endif + break; + case 5: + sscanf(res, "system type : %s",systype); +#ifdef DEBUG + ErrorF("system type : %s\n",systype); +#endif + break; + case 6: + sscanf(res, "system variation : %s",sysvari); +#ifdef DEBUG + ErrorF("system variation: %s\n",sysvari); +#endif + break; + } + count++; + } while (count < 8); + + fclose(file); + + count = 0; + + do { + if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) { + if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) { + count++; + continue; + }; + if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) { + count++; + continue; + } + return axpList[count].sys; + } + count++; + } while (1); +} + diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c index 0b570ba68..4553552b3 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.37 2000/10/17 16:53:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.38 2000/10/28 01:42:27 mvojkovi Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -80,13 +80,13 @@ extern void sethae(unsigned long hae); /* Video Memory Mapping section */ /***************************************************************************/ -static pointer mapVidMem(int, unsigned long, unsigned long); +static pointer mapVidMem(int, unsigned long, unsigned long, int); static void unmapVidMem(int, pointer, unsigned long); #if defined (__alpha__) -static pointer mapVidMemSparse(int, unsigned long, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); static void unmapVidMemSparse(int, pointer, unsigned long); # if defined(JENSEN_SUPPORT) -static pointer mapVidMemJensen(int, unsigned long, unsigned long); +static pointer mapVidMemJensen(int, unsigned long, unsigned long, int); static void unmapVidMemJensen(int, pointer, unsigned long); # endif #endif @@ -329,13 +329,28 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; - + int mapflags = MAP_SHARED; + #if defined(__ia64__) - if ((fd = open(DEV_MEM, O_RDWR | O_SYNC)) < 0) { +#ifndef MAP_WRITECOMBINED +#define MAP_WRITECOMBINED 0x00010000 +#endif +#ifndef MAP_NONCACHED +#define MAP_NONCACHED 0x00020000 +#endif + if(flags & VIDMEM_FRAMEBUFFER) + mapflags |= MAP_WRITECOMBINED; + else + mapflags |= MAP_NONCACHED; +#endif + +#if defined(__ia64_) + /* this will disappear when people upgrade their kernels */ + if ((fd = open(DEV_MEM, O_RDWR|O_SYNC)) < 0) { #else if ((fd = open(DEV_MEM, O_RDWR)) < 0) { #endif @@ -345,7 +360,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) /* This requires linux-0.99.pl10 or above */ base = mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE, - MAP_SHARED, fd, + mapflags, fd, (off_t)(off_t)Base + BUS_BASE); close(fd); if (base == MAP_FAILED) { @@ -520,7 +535,7 @@ static void writeSparse32(int Value, pointer Base, register unsigned long Offset); static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { int fd; static Bool was_here = FALSE; @@ -764,7 +779,7 @@ writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset); #define JENSEN_SHIFT(x) ((long)x<<SPARSE) static pointer -mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c index 7ffd9056c..e67b64621 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c @@ -21,7 +21,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.16 2000/04/17 16:30:13 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.17 2000/10/28 01:42:27 mvojkovi Exp $ */ #include "X.h" #include "input.h" @@ -91,7 +91,7 @@ smemCleanup(void) } static pointer -MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { static int once; int free_slot = -1; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile index 3fb7ba9fb..c8ea7c804 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 3.9 2000/08/10 17:40:36 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 3.10 2000/11/02 19:10:56 dawes Exp $ @@ -12,8 +12,8 @@ XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:24:12 rws $ XSRCS = BUSmemcpy.S IODelay.S SlowBcopy.S XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o #elif defined(SparcArchitecture) -XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c SparcMulDiv.S -XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o SparcMulDiv.o +XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c +XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o #else XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o @@ -39,9 +39,6 @@ ObjectFromAsmSource(BUSmemcpy,NullParameter) ObjectFromAsmSource(IODelay,NullParameter) ObjectFromAsmSource(SlowBcopy,NullParameter) #endif -#if defined(SparcArchitecture) -ObjectFromAsmSource(SparcMulDiv,NullParameter) -#endif DependTarget() diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c index fce28d654..7dc19880a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.13 2000/04/05 18:13:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.14 2000/10/28 01:42:28 mvojkovi Exp $ */ /* * (c) Copyright 1994,1999 by Holger Veit * <Holger.Veit@gmd.de> @@ -102,7 +102,7 @@ typedef struct { /* ARGSUSED */ static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { DIOParPkt par; ULONG plen; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c index fb71e4f33..69c485202 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.12 2000/07/11 01:46:37 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.13 2000/10/28 01:42:28 mvojkovi Exp $ */ /* * Copyright 1993-1999 by The XFree86 Project, Inc * @@ -153,7 +153,7 @@ xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) if (!vidMemInfo.initialised || !vidMemInfo.mapMem) return NULL; - vbase = vidMemInfo.mapMem(ScreenNum, Base, Size); + vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); if (!vbase || vbase == (pointer)-1) return NULL; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c new file mode 100644 index 000000000..24d31db59 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c @@ -0,0 +1,20 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#include "xf86Axp.h" + +axpParams xf86AXPParams[] = { + {SYS_NONE, 0, 0, 0}, + {TSUNAMI, 0, 0, 0}, + {LCA, 1<<24,0xf8000000, 1UL << 32}, + {APECS, 1<<24,0xf8000000, 1UL << 32}, + {T2, 0,0xFC000000, 1UL << 31}, + {T2_GAMMA, 0,0xFC000000, 1UL << 31}, + {CIA, 0,0xE0000000, 1UL << 34}, + {MCPCIA, 0,0xf8000000, 1UL << 31}, + {JENSEN, 0, 0xE000000, 1UL << 32}, + {POLARIS, 0, 0, 0}, + {PYXIS, 0, 0, 0}, + {PYXIS_CIA, 0,0xE0000000, 1UL << 34}, + {IRONGATE, 0, 0, 0} +}; + diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h new file mode 100644 index 000000000..23d6f8609 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h @@ -0,0 +1,39 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#ifndef _XF86_AXP_H_ +#define _XF86_AXP_H_ + +typedef enum { + SYS_NONE, + TSUNAMI, + LCA, + APECS, + T2, + T2_GAMMA, + CIA, + MCPCIA, + JENSEN, + POLARIS, + PYXIS, + PYXIS_CIA, + IRONGATE +} axpDevice; + +typedef struct + { char* sysName; + char* sysVari; + char* cpu; + axpDevice sys; } +AXP; + +typedef struct { + axpDevice id; + unsigned long hae_thresh; + unsigned long hae_mask; + unsigned long size; +} axpParams; + +extern axpParams xf86AXPParams[]; + +#endif + diff --git a/xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c b/xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c index 7bbbb8013..ab604e95a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.19 1999/05/15 14:31:23 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.20 2000/10/28 01:42:29 mvojkovi Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -138,7 +138,7 @@ linearVidMem() } static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h index 4bef78436..c3224aeeb 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h @@ -1,9 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h,v 1.4 2000/02/15 02:00:14 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h,v 1.5 2000/10/28 01:42:24 mvojkovi Exp $ */ #ifndef _XF86OSPRIV_H #define _XF86OSPRIV_H -typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long); +typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int); typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long); typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool, MessageType); diff --git a/xc/programs/Xserver/hw/xfree86/parser/Vendor.c b/xc/programs/Xserver/hw/xfree86/parser/Vendor.c index 8df2dfd96..fb010dcf2 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/Vendor.c +++ b/xc/programs/Xserver/hw/xfree86/parser/Vendor.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.6 2000/10/20 14:59:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.7 2000/11/02 19:58:20 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -35,12 +35,77 @@ extern LexRec val; +static xf86ConfigSymTabRec VendorSubTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorSubList + +XF86ConfVendSubPtr +xf86parseVendorSubSection (void) +{ + parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec) + + while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION) + { + switch (token) + { + case IDENTIFIER: + if (xf86getToken (NULL) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->vs_identifier = val.str; + break; + case OPTION: + { + char *name; + if ((token = xf86getToken (NULL)) != STRING) + Error (BAD_OPTION_MSG, NULL); + name = val.str; + if ((token = xf86getToken (NULL)) == STRING) + { + ptr->vs_option_lst = + xf86addNewOption (ptr->vs_option_lst, + name, val.str); + } + else + { + ptr->vs_option_lst = + xf86addNewOption (ptr->vs_option_lst, + name, NULL); + xf86unGetToken (token); + } + } + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Vendor subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + static xf86ConfigSymTabRec VendorTab[] = { {COMMENT, "###"}, {ENDSECTION, "endsection"}, {IDENTIFIER, "identifier"}, {OPTION, "option"}, + {SUBSECTION, "subsection"}, {-1, ""}, }; @@ -86,6 +151,14 @@ xf86parseVendorSection (void) } } break; + case SUBSECTION: + if (xf86getToken (NULL) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection, + XF86ConfVendSubPtr); + } + break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; @@ -111,6 +184,7 @@ xf86parseVendorSection (void) void xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) { + XF86ConfVendSubPtr pptr; XF86OptionPtr optr; while (ptr) @@ -128,6 +202,20 @@ xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) fprintf (cf, " \"%s\"", optr->opt_val); fprintf (cf, "\n"); } + for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"Vendor\"\n"); + if (pptr->vs_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", pptr->vs_identifier); + for (optr = pptr->vs_option_lst; optr; optr = optr->list.next) + { + fprintf (cf, "\tOption \"%s\"", optr->opt_name); + if (optr->opt_val) + fprintf (cf, " \"%s\"", optr->opt_val); + fprintf (cf, "\n"); + } + fprintf (cf, "\tEndSubSection\n"); + } fprintf (cf, "EndSection\n\n"); ptr = ptr->list.next; } @@ -143,6 +231,21 @@ xf86freeVendorList (XF86ConfVendorPtr p) xf86conffree (p); } +void +xf86freeVendorSubList (XF86ConfVendSubPtr ptr) +{ + XF86ConfVendSubPtr prev; + + while (ptr) + { + TestFree (ptr->vs_identifier); + xf86optionListFree (ptr->vs_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + XF86ConfVendorPtr xf86findVendor (const char *name, XF86ConfVendorPtr list) { diff --git a/xc/programs/Xserver/hw/xfree86/parser/configProcs.h b/xc/programs/Xserver/hw/xfree86/parser/configProcs.h index 55d8056d8..69db60c39 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/configProcs.h +++ b/xc/programs/Xserver/hw/xfree86/parser/configProcs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.13 2000/10/20 14:59:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.14 2000/11/02 19:58:20 anderson Exp $ */ /* Private procs. Public procs are in xf86Parser.h and xf86Optrec.h */ @@ -59,8 +59,10 @@ void xf86freeModeList(XF86ModePtr ptr); int xf86validateScreen(XF86ConfigPtr p); /* Vendor.c */ XF86ConfVendorPtr xf86parseVendorSection(void); +XF86ConfVendSubPtr xf86parseVendorSubSection (void); void xf86freeVendorList(XF86ConfVendorPtr p); void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr); +void xf86freeVendorSubList (XF86ConfVendSubPtr ptr); /* Video.c */ XF86ConfVideoPortPtr xf86parseVideoPortSubSection(void); XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void); diff --git a/xc/programs/Xserver/hw/xfree86/parser/read.c b/xc/programs/Xserver/hw/xfree86/parser/read.c index ee39b6e24..1be2b5760 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/read.c +++ b/xc/programs/Xserver/hw/xfree86/parser/read.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.13 2000/10/20 14:59:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.14 2000/11/02 19:10:58 dawes Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -41,7 +41,7 @@ static xf86ConfigSymTabRec TopLevelTab[] = {-1, ""}, }; -#define CLEANUP XF86freeConfig +#define CLEANUP xf86freeConfig XF86ConfigPtr xf86readConfigFile (void) @@ -201,7 +201,7 @@ xf86addListItem (GenericListPtr head, GenericListPtr new) } void -XF86freeConfig (XF86ConfigPtr p) +xf86freeConfig (XF86ConfigPtr p) { if (p == NULL) return; diff --git a/xc/programs/Xserver/hw/xfree86/parser/scan.c b/xc/programs/Xserver/hw/xfree86/parser/scan.c index 9b84aec0f..3590855c6 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/scan.c +++ b/xc/programs/Xserver/hw/xfree86/parser/scan.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.13 2000/10/20 14:59:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.14 2000/11/02 19:58:20 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -937,11 +937,12 @@ xf86nameCompare (const char *s1, const char *s2) { char c1, c2; - if (!s1 || *s1 == 0) + if (!s1 || *s1 == 0) { if (!s2 || *s2 == 0) return (0); else return (1); + } while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') s1++; diff --git a/xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h b/xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h index fcf770785..efe30393d 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h +++ b/xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.8 2000/10/20 14:59:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.9 2000/11/02 19:58:21 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -67,11 +67,14 @@ XF86OptionPtr xf86newOption(char *name, char *value); XF86OptionPtr xf86nextOption(XF86OptionPtr list); XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name); char *xf86findOptionValue(XF86OptionPtr list, const char *name); +int xf86findOptionBoolean (XF86OptionPtr, const char *, int); XF86OptionPtr xf86optionListCreate(const char **options, int count, int used); XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail); char *xf86configStrdup (const char *s); int xf86nameCompare (const char *s1, const char *s2); char *xf86uLongToString(unsigned long i); +void xf86debugListOptions(XF86OptionPtr); + diff --git a/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h b/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h index 27b476901..5a780e6cb 100644 --- a/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h +++ b/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.23 2000/10/24 22:45:10 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.25 2000/11/02 19:58:21 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -338,11 +338,21 @@ typedef struct } XF86ConfLayoutRec, *XF86ConfLayoutPtr; +typedef struct +{ + GenericListRec list; + char *vs_name; + char *vs_identifier; + XF86OptionPtr vs_option_lst; +} +XF86ConfVendSubRec, *XF86ConfVendSubPtr; + typedef struct { GenericListRec list; char *vnd_identifier; XF86OptionPtr vnd_option_lst; + XF86ConfVendSubPtr vnd_sub_lst; char *vnd_comment; } XF86ConfVendorRec, *XF86ConfVendorPtr; @@ -396,7 +406,7 @@ extern const char *xf86openConfigFile (const char *, const char *, const char *); extern XF86ConfigPtr xf86readConfigFile (void); extern void xf86closeConfigFile (void); -extern void XF86freeConfig (XF86ConfigPtr p); +extern void xf86freeConfig (XF86ConfigPtr p); extern int xf86writeConfigFile (const char *, XF86ConfigPtr); XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); diff --git a/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c b/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c index baa0298bb..2730ba091 100644 --- a/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c +++ b/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c,v 1.40 2000/08/11 17:27:17 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c,v 1.41 2000/11/03 18:46:17 eich Exp $ */ /* * @@ -1697,6 +1697,9 @@ vgaHWMapMem(ScrnInfoPtr scrp) * XXX This is not correct but we do it * for now. */ +#ifdef DEBUG + ErrorF("Mapping VGAMem\n"); +#endif hwp->Base = xf86MapVidMem(scr_index, VIDMEM_MMIO_32BIT, hwp->MapPhys, hwp->MapSize); return hwp->Base != NULL; @@ -1711,7 +1714,10 @@ vgaHWUnmapMem(ScrnInfoPtr scrp) if (hwp->Base == NULL) return; - + +#ifdef DEBUG + ErrorF("Unmapping VGAMem\n"); +#endif xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize); hwp->Base = NULL; } diff --git a/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h b/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h index e7a2b1da9..d2d408cb2 100644 --- a/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h +++ b/xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h,v 1.23 2000/02/15 18:01:21 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h,v 1.24 2000/11/02 16:33:27 tsi Exp $ */ /* @@ -97,8 +97,8 @@ typedef struct { typedef struct _vgaHWRec *vgaHWPtr; -typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 index, CARD8 value); -typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 index); +typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value); +typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx); typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value); typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp); typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp); diff --git a/xc/programs/Xserver/hw/xfree86/xf86Version.h b/xc/programs/Xserver/hw/xfree86/xf86Version.h index 59c7561c5..a1ffbf12c 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86Version.h +++ b/xc/programs/Xserver/hw/xfree86/xf86Version.h @@ -1,13 +1,13 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.447 2000/10/24 18:07:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.449 2000/11/06 18:21:56 dawes Exp $ */ -#define XF86_VERSION " 4.0.1d " +#define XF86_VERSION " 4.0.1e " /* The finer points in versions... */ #define XF86_VERSION_MAJOR 4 #define XF86_VERSION_MINOR 0 #define XF86_VERSION_SUBMINOR 1 #define XF86_VERSION_BETA 0 /* 0="", 1="A", 2="B", etc... */ -#define XF86_VERSION_ALPHA 4 /* 0="", 1="a", 2="b", etc... */ +#define XF86_VERSION_ALPHA 5 /* 0="", 1="a", 2="b", etc... */ #define XF86_VERSION_NUMERIC(major,minor,subminor,beta,alpha) \ ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha) @@ -18,6 +18,6 @@ XF86_VERSION_BETA, \ XF86_VERSION_ALPHA) -#define XF86_DATE "27 October 2000" +#define XF86_DATE "6 November 2000" /* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */ diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c index 4bfc62826..175f55302 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c,v 1.4 2000/10/27 18:31:05 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c,v 1.5 2000/10/29 14:24:13 tsi Exp $ */ #include "config.h" @@ -136,7 +136,7 @@ StartConfig(void) fprintf(stderr, "Cannot to open config file.\n"); exit(1); } - XF86Config_path = filename; + XF86Config_path = (char *)filename; if ((XF86Config = xf86readConfigFile()) == NULL) { fprintf(stderr, "Problem when parsing config file\n"); exit(1); diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h index c2593d62f..658072f28 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h,v 1.6 2000/10/20 14:59:05 alanh Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h,v 1.7 2000/11/03 18:46:17 eich Exp $ */ #include <X11/IntrinsicP.h> @@ -188,6 +188,7 @@ extern char *ident_string; extern XF86ConfigPtr XF86Config; extern char *XF86Config_path; extern char *XF86Module_path; +extern char *XFree86_path; extern char *XF86Font_path; extern char *XF86RGB_path; extern char *XFree86Dir; diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c index 59c49d142..af1a697f3 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c,v 1.8 2000/10/27 18:31:05 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c,v 1.9 2000/11/03 18:46:17 eich Exp $ */ #include <X11/IntrinsicP.h> @@ -109,6 +109,7 @@ XtAppContext appcon; char *XF86Config_path = NULL; char *XF86Module_path = NULL; +char *XFree86_path = NULL; char *XF86Font_path = NULL; char *XF86RGB_path = NULL; char *XkbConfig_path = NULL; @@ -200,26 +201,31 @@ main(int argc, char *argv[]) XFree86Dir = DefaultXFree86Dir; chdir(XFree86Dir); - - for (i = 1; i < argc; i++) + + for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-xf86config") == 0) { if (i + 1 < argc) - XF86Config_path = argv[i + 1]; - break; + XF86Config_path = argv[++i]; + continue; } else if (strcmp(argv[i], "-modulepath") == 0) { if (i + 1 < argc) - XF86Module_path = argv[i + 1]; - break; + XF86Module_path = argv[++i]; + continue; + } else if (strcmp(argv[i], "-serverpath") == 0) { + if (i + 1 < argc) + XFree86_path = argv[++i]; + continue; } else if (strcmp(argv[i], "-fontpath") == 0) { if (i + 1 < argc) - XF86Font_path = argv[i + 1]; - break; + XF86Font_path = argv[++i]; + continue; } else if (strcmp(argv[i], "-rgbpath") == 0) { if (i + 1 < argc) - XF86RGB_path = argv[i + 1]; - break; + XF86RGB_path = argv[++i]; + continue; } - + } + startedx = startx(); /* if (XF86Config_path == NULL) XF86Config_path = "/etc/X11/XF86Config-4";*/ diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c index 487a2a7ef..f3053ed1e 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c,v 1.3 2000/08/04 16:13:44 eich Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c,v 1.4 2000/11/03 18:46:18 eich Exp $ */ #include "config.h" @@ -58,9 +58,12 @@ startx(void) int c_pos; int len; - c_pos = XmuSnprintf(commandline, sizeof(commandline), - "XFree86 :8 -configure "); - + if (XFree86_path) + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/XFree86 :8 -configure ",XFree86_path); + else + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/bin/XFree86 :8 -configure ", XFree86Dir); if (XF86Module_path && ((len = sizeof(commandline) - c_pos) > 0)) c_pos += XmuSnprintf(commandline + c_pos,len, " -modulepath %s",XF86Module_path); @@ -92,8 +95,10 @@ startx(void) switch (xpid = fork()) { case 0: { char path[PATH_MAX]; - - XmuSnprintf(path, sizeof(path), "%s/bin/XFree86", XFree86Dir); + if (XFree86_path) + XmuSnprintf(path, sizeof(path), "%s/XFree86", XFree86_path); + else + XmuSnprintf(path, sizeof(path), "%s/bin/XFree86", XFree86Dir); execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail", "-xf86config", XF86Config_path, NULL); exit(-127); diff --git a/xc/programs/Xserver/hw/xfree86/xf86config/Cards b/xc/programs/Xserver/hw/xfree86/xf86config/Cards index df9e25f5a..46d238391 100644 --- a/xc/programs/Xserver/hw/xfree86/xf86config/Cards +++ b/xc/programs/Xserver/hw/xfree86/xf86config/Cards @@ -18,7 +18,7 @@ # The majority of entries are just a binding of a model name to a # chipset/server and untested. # -# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.70 2000/10/20 14:59:09 alanh Exp $ +# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.71 2000/11/02 21:45:14 robin Exp $ # VGA @@ -2404,35 +2404,29 @@ UNSUPPORTED # Number 9 I128 -NAME Number Nine Imagine I-128 (2-8MB) +NAME Number Nine Imagine I-128 CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED - -NAME Number Nine Imagine I-128 Series 2 (2-4MB) -CHIPSET I128 -SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Revolution 3D (T2R) +NAME Number Nine Imagine I-128 Series 2 CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Number Nine Revolution 3D AGP (4-8MB SGRAM) +NAME Number Nine Revolution 3D (T2R) CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Number Nine Imagine-128-T2R +NAME Number Nine Imagine-128 Revolution IV (T2R4) CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE # Matrox diff --git a/xc/programs/Xserver/include/servermd.h b/xc/programs/Xserver/include/servermd.h index b7283dcc4..0feba1b66 100644 --- a/xc/programs/Xserver/include/servermd.h +++ b/xc/programs/Xserver/include/servermd.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.40 2000/08/23 22:10:16 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.42 2000/11/06 19:24:09 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -149,14 +149,32 @@ SOFTWARE. #endif /* __arm32__ */ -#if (defined(Lynx) && defined(__powerpc__)) +#ifdef __DARWIN__ -/* For now this is for Xvfb only */ #define IMAGE_BYTE_ORDER MSBFirst #define BITMAP_BIT_ORDER MSBFirst #define GLYPHPADBYTES 4 #define GETLEFTBITS_ALIGNMENT 1 + +#define LARGE_INSTRUCTION_CACHE +#define FAST_CONSTANT_OFFSET_MODE +#define PLENTIFUL_REGISTERS +#define AVOID_MEMORY_READ +#define FAST_MEMCPY + +#endif /* __DARWIN__ */ + +#if defined(__powerpc__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +/* XXX Should this be for Lynx only? */ +#ifdef Lynx #define BITMAP_SCANLINE_UNIT 8 +#endif #define LARGE_INSTRUCTION_CACHE #define FAST_CONSTANT_OFFSET_MODE @@ -165,7 +183,7 @@ SOFTWARE. #define FAST_MEMCPY -#endif /* LynxOS PowerPC */ +#endif /* PowerPC */ #if (defined(sun) && !(defined(i386) && defined(SVR4))) || \ (defined(AMOEBA) && (defined(sparc) || defined(mc68000))) || \ @@ -413,22 +431,6 @@ SOFTWARE. #endif /* linux/m68k */ -#if defined (linux) && defined(__powerpc__) - -#define IMAGE_BYTE_ORDER MSBFirst -#define BITMAP_BIT_ORDER MSBFirst -#define GLYPHPADBYTES 4 -#define GETLEFTBITS_ALIGNMENT 1 - -#define LARGE_INSTRUCTION_CACHE -#define FAST_CONSTANT_OFFSET_MODE -#define PLENTIFUL_REGISTERS -#define AVOID_MEMORY_READ - -#define FAST_MEMCPY - -#endif /* Linux/PPC */ - #ifdef sgi #define IMAGE_BYTE_ORDER MSBFirst diff --git a/xc/programs/Xserver/render/picturestr.h b/xc/programs/Xserver/render/picturestr.h index b40eaa15b..6e43317f8 100644 --- a/xc/programs/Xserver/render/picturestr.h +++ b/xc/programs/Xserver/render/picturestr.h @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.6 2000/10/11 23:55:33 tsi Exp $ + * $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.7 2000/11/02 16:33:28 tsi Exp $ * * Copyright © 2000 SuSE, Inc. * @@ -188,9 +188,6 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); Bool miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); -Bool -fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); - PicturePtr CreatePicture (Picture pid, |