
svgalib v1.0

Note: The version number does not have any significance with regard to
      stability/completeness. 
      The demo and test programs are now in the demos/ directory.

0.  Introduction
1.  Installation
2.  Overview of supported SVGA chipsets and modes
3.  Description of svgalib functions additional to VGAlib v1.2
4.  How to use svgalib
5.  Structure of chipset driver modules
6.  Changes
7.  Known bugs
8.  Goals
9.  References



0.  Introduction

This is a low level graphics library for Linux, based on VGAlib 1.2 by
Tommy Frandsen. VGAlib supported a number of standard VGA graphics modes, as
well as Tseng ET4000 high resolution 256-color modes. I added support for my
Cirrus 542x based card, including 15/16/24 bit color modes, and merged in the
Trident code from Toomas Losin's tvgalib. It also provides ET4000
hicolor/truecolor DAC support.

It supports transparent virtual console switching, that is, you can switch
consoles to and from text and graphics mode consoles using alt-[function
key]. Also, svgalib corrects most of VGAlib's textmode corruption behaviour
by catching SIGSEGV, SIGFPE and SIGILL, and ensuring that a program is running
in the currently visible virtual console before setting a graphics mode.

When the library is first used by a program at run-time, the chipset is
detected and the appropriate driver is used. This means that a graphics
program will work on any card that is supported by svgalib, if the mode it
uses is supported by the chipset driver for that card. The library is
upwardly compatible with VGAlib.

The set of drawing functions provided by svgalib itself is limited (unchanged
from VGAlib) and unoptimized; you can however use vga_setpage and graph_mem
(which points to the 64K VGA framebuffer) in a program or graphics library.
A fast external framebuffer graphics library for linear and banked 1, 2, 3
and 4 bytes per pixel modes is included.

One obvious application of the library is a picture viewer. I have made a
simple GIF/JPEG viewer that also supports hicolor/truecolor; it should be
available as spicXX.tar.z (sunsite.unc.edu, /pub/Linux/apps/graphics).

I have added a simple VGA textmode font restoration utility (restorefont) 
which may help if you suffer from XFree86 textmode font corruption. It can
also be used to change the textmode font. It's in the utils/ directory,
along with a README and some other textmode utilities: restoretextmode (which
saves/restores textmode registers), restorepalette, and the script textmode.
If you run the savetextmode script to save textmode information to /tmp,
you'll be able to restore textmode by running the textmode script.

If you have an ET4000 card, you should read the README in the et4000/
directory. You will probably want to replace the ET4000 registers. Editing
config.h is a good idea in any case.

Directories:
.		svgalib sources.
demos/		Demo and test programs.
utils/		Textmode/font utilities.
gl/		External framebuffer graphics library sources.
support/	DOS-based utility for dumping VGA registers.
et4000/		Notes, utilities and sample registers for ET4000.
mouse/		Source for mouse functions.
jump/		Configuration files for building DLL shared library.
sharedlib/	Shared library image and stubs.

I welcome any questions, comments, suggestions, bug-reports, etc.

Harm Hanemaayer
hhanemaa@cs.ruu.nl



1. Installation

Running 'make install' should take care of proper installation. Shared library
stubs and images are included in the distribution. Edit the Makefile to change
installation paths and to select the parts that should be installed, and edit
libvga.config to set the monitor and mouse type.

If you have an ET4000 card, read the et4000/README and copy the appropriate
register file to et4000.regs. Remember to set the DAC type.

The default behaviour is the following:

Shared libraries are installed in /lib and /usr/local/lib, header files
in /usr/local/include (any old header files in /usr/include are removed).

The et4000 registers (et4000.regs) are installed as
/usr/local/lib/libvga.et4000, but only if this file does not exit yet.
The same goes for the configuration file, libvga.config.

Textmode utilities are installed in /usr/local/bin. These are restorefont,
runx, restorepalette, dumpreg, restoretextmode, textmode, savetextmode,
and fix132x43.

If you change the Makefile to install the static libraries, static libraries
are compiled, and installed in /usr/local/include. Note that you do not need
to do this; the shared library is enough.

If you now run 'make', the demo programs are created in the demos/
directory.

You can remove previously installed files (not the et4000 registers and
config file) with 'make uninstall'.

Note that if you change and recompile the (static) library and install it
(you can use 'make installstaticlib installheaders' for this), programs may
still get linked to the (old) shared library version. Try temporarily
removing the stubs in /usr/local/lib, or specifying libvga.a on the
commandline instead of -lvga.



2.  Overview of supported SVGA chipsets and modes

Supported chipsets:

	VGA and compatibles

		320x200x256, and the series of 16-color and tweaked modes
		supported by VGAlib, as well as 720x348x2.

	Cirrus Logic GD542x

		640x480x256, 800x600x256, 1024x768x256, 640x480x32K, 
		640x480x64K, 800x600x32K, 800x600x64K, 1024x768x32K,
		1024x768x64K, 640x480x16M, 320x200x32K, 320x200x64K,
		320x200x16M. The last mode has a logical scanline width
		of 960 bytes, but the VESA BIOS uses 1024. Also,
		800x600x16M at 50 Hz; and 800x600x16, 1024x768x16,
		1280x1024x16. Some bitblt functions are supported.

	Tseng ET4000

		Derived from VGAlib; not the same register values.
		ET4000 register values are not compatible; see et4000/README.
		Make sure the colors are right in hicolor mode; the vgatest
		program should draw the same color bars for 256 and hicolor
		modes (the DAC type is defined in et4000.regs or the dynamic
		registers file).
		The ET4000/W32 has been reported to work as an AT&T DAC
		equipped ET4000.
		If the high resolution modes don't work, you can try
		dumping the registers in DOS using the program in the
		et4000 directory and putting them in a file
		(/usr/local/lib/libvga.et4000 is parsed at runtime if DYNAMIC
		is defined in config.h).

		640x480x256, 800x600x256, 1024x768x256,
		640x480x32K, 800x600x32K, 640x480x16M, etc.

	Trident TVGA 8900C/9000 (and possibly also 8800CS/8900A/B)

		Derived from tvgalib by Toomas Losin.

		640x480x256, 800x600x256, 1024x768x256 (I and NI)
		Might be useful to add 16-color modes (for those equipped
		with a 512K TVGA9000).

	Oak Technologies OTI-037/67/77

		May work if somebody provides the register dumps (especially
		the extended registers) using XFree86 v2.0 (see	Changes)
		(worked for 640x480x256).

		640x480x256 for now.



3.  Additional VGAlib functions

	vga_init()
		Initialize library; detects chipset and gives up supervisor
		rights. Recommended first line of any program that uses
		svgalib; vga_setchipset can be used before it to avoid
		detection.

	vga_modeinfo *vga_getmodeinfo( int mode )
		Returns pointer to mode information structure for a mode.
		width			Width of mode in pixels.
		height			Height of mode.
		bytesperpixel		Bytes per pixel (framebuffer-wise).
					This is 1, 2 or 3, and 0 for planar
					VGA modes.
		linewidth		Logical scanline width in bytes.
		colors			2, 16, 256, 32768, 65536 or 16M
		maxlogicalwidth 	Maximum logical scanline width (bytes).
		startaddressrange 	Mask of changeable bits of start
					address (in pixels).
		maxpixels		Maximum number of pixels that will
					fit in a logical screen (depends on
					video memory).
		haveblit		Indicates whether bitblit functions
					are available.
					Bit 0: Bitblit
					Bit 1: Fillblit
					Bit 2: Imageblit
		flags			Miscellaneous flags.
					Bit 0: Setreadpage/setwritepage
					       available.
					Bit 1: Mode is interlaced.
					Bit 2: Mode is mode-X like (planar
					       256 colors).
					Bit 3: Dynamically loaded mode.
					Bit 4: Can set to linear addressing.
					Bit 5: Linear addressing enabled.

	int vga_getcurrentmode()
		Returns the current mode.

	int vga_getdefaultmode()
		Returns the default graphics mode number from the
		GSVGAMODE environment variable; -1 if undefined. The
		environment variable can either be a mode number or a mode
		name.

	int vga_getcurrentchipset()
		Returns the current SVGA chipset.

	void vga_setmousesupport( int stat )
		Set mouse support; 0 disabled (default), 1 enabled. If
		enabled, the mouse is set up for screen resolution after a
		mode set. You can use the function to set up the mouse in
		vgamouse.h instead for more flexibility.

	void vga_runinbackground( int stat )
		Enable/disable background running of a graphics program
		(1 = enable). Normally, the program is suspended while
		not in the current virtual console. A program can only
		safely run in the background if it doesn't do any video
		access during this time.

	int vga_oktowrite()
		Indicates whether the program is in the console currently
		visible on the screen, that is, whether it is OK to write
		to video memory (if running in the background has been allowed
		with the function above). Note that this is not entirely
		safe, since a console switch interrupt may occur during a
		video operation.

	int vga_getkey()
		Read a character from the keyboard without waiting; returns
		-1 if no key pressed.

	void vga_lockvc()
		Disables virtual console switching for safety. Recommended
		when doing register I/O or low-level device handling. Used
		by mouse functions.

	void vga_unlockvc()
		Re-enables virtual console switching.

	void vga_setpage( int page )
		Set 64K SVGA page number.

	unsigned char *graph_mem;
		Pointer to 64K VGA frame buffer window. Can be used by
		graphics library on top of VGAlib.

	unsigned char *vga_getgraphmem()
		Returns graph_mem.

	void vga_waitretrace();
		Wait for vertical retrace. Use to synchronize animation with
		monitor refresh.

	int vga_claimvideomemory( int m ) {
		Declare the amount of video memory in bytes that is to
		be saved when temporarily switching to textmode. Returns
		nonzero if the amount is not available. Defaults to one
		screen when a mode is set. Use this if you are using more
		than one screen of video memory.

	void vga_setchipset( int chipset )
		Force chipset (when chipset detection fails).
		vga_setchipset(VGA) can be useful if the chipset specific
		stuff or the SVGA detection stuff gives problems.

	void vga_setchipsetandfeatures( int chipset, int par1, int par2 )
		Force chipset, and optional parameters like the exact
		chipset type and the amount of video memory installed.
		[Only for debugging.]

	void vga_setlogicalwidth( int l )
		Set the logical scanline width to l bytes. Must be a
		multiple of 8. Only changes the VGA register, drawing
		functions don't take it into account.

	void vga_setdisplaystart( int a )
		Set the display start address to a, where the address is the
		number of pixels offset from the start of video memory. Can
		be used for page-flipping and virtual desktop scrolling.
		Does not work properly for 16 color modes.

	void vga_setrgbcolor( int r, int g, int b )
		Set the current color to RGB values r, g, and b, each in
		the range 0-255. Does not make sense in 256-color modes.

	void vga_setmodeX()
		Try to enable Mode X-like memory organization (only for
		256 color modes using up to 256K of memory like 320x200x256
		and 640x400x256; 320x240x256 etc. are Mode X-like by default).

	void vga_copytoplanar256( unsigned char *virtual, int pitch,
	int voffset, int vpitch, int w, int h )
		Copy part of linear virtual screen in system memory to Mode
		X video memory. pitch is the logical width of the virtual
		screen; voffset is the address offset into video memory;
		vpitch is the logical scanline length of the screen; (w, h)
		is the size of the area to copy in pixels (width must be
		multiple of 4).

	void vga_copytoplanar16( unsigned char *virtual, int pitch,
	int voffset, int vpitch, int w, int h )
		Similar function for 16 color modes (untested); assumes
		pixels stored in consecutive bytes ranging from 0 to 15 in
		the virtuals screen.

	void vga_setlinearaddressing();
		Switch to linear addressing mode. Only valid on Cirrus,
		with less than 16Mb of memory (maps at 14Mb).
		vga_getgraphmem returns the linear framebuffer address
		(fixed at 0x40000000; letting the kernel give the address
		wastes 2Mb). vga_ drawing functions are not supported;
		vgagl does support it (gl_setcontextvga).


	The following functions are only defined if the corresponding flag
	in the haveblit field of the mode info structure is set. They are
	not meant as graphics primitives, but more as an interface to the
	blitter in the Cirrus 5426. Note: the maximum height is 1024 for
	the Cirrus routines.

	void vga_bitblt( int srcaddr, int destaddr, int w, int h,
	int pitch )
		Bitblit (copy rectangular area in video memory), addresses
		are offsets into video memory (up to 2M). The pitch is the
		logical width of the screen.

	void vga_fillblt( int destaddr, int w, int h, int pitch, int color )
		Fill a rectangular area in video memory with a single color.

	void vga_imageblt( void *srcaddr, int destaddr, int w, int h, int
	pitch )
		Write a rectangular bitmap from system memory to video
		memory.



4.  How to use svgalib (and vgagl)

The function vga_getdefaultmode() checks the environment variable GSVGAMODE
for a default mode, and returns the corresponding mode number. The
environment string can either be a mode number (compatible with (S)VGAlib
Ghostscript), or a mode name as in (G640x480x2, G640x480x16, G640x480x256,
G640x480x32K, G640x480x64K, G640x480x16M). As an example, to set the default
graphics mode to 640x480, 256 colors, use: export GSVGAMODE=G640x480x256
on the bash command line. If a program needs just a linear VGA/SVGA resolution
(as required by vgagl), only modes where bytesperpixel in the vga_modeinfo
structure is greater or equal to 1 should be accepted (this is 0 for tweaked
planar 256-color VGA modes).

Use vga_setmode(graphicsmode) to set a graphics mode. Use vga_setmode(TEXT) to
restore textmode before program exit.

Programs that use svgalib must include vga.h; if they also use the external
graphics library vgagl, vgagl.h must also be included. Linking must be done
with -lvga (and -lvgagl *before* -lvga, if vgagl is used). You can save binary
space by removing the chipset drivers in config.h if you only use standard VGA
(only for static binaries; better link with the shared library).

Functions in the vgagl library have the prefix "gl_". To initialize vgagl,
the graphics context must be set. Example:

	vga_setmode(G320x200x256);
	gl_setcontextvga(G320x200x256);

In this example, the context is set to the physical screen. The context can
be saved (only the screen type, not the contents) into a variable, e.g.

	GraphicsContext physicalscreen;

	gl_getcontext(&physicalscreen).

To define a virtual screen in system memory, use gl_setcontextvgavirtual:

	gl_setcontextvgavirtual(G320x200x256)

which allocates space for a screen identical to 320x200x256 graphics mode,
and makes this virtual screen the current graphics context.

The virtual screen can now be copied to the physical screen as follows:

	gl_copyscreen(&physicalscreen);



5.  Structure of the chipset drivers

	Note: This may not be entirely up to date with Hartmut's changes.

	The chipset specific registers saving function (saveregs) is only
	used to save the textmode registers at initialization.

	The chipset specific registers restoring function (setregs) is only
	used to return to textmode, and when setting a VGA mode after an
	SVGA mode.

	The registers for each mode are stored like the ET4000 modes in
	VGAlib 1.2, i.e. the extended registers at the end. The following
	functions must be provided in a driver:

	saveregs( unsigned char regs[] )
		Saves the chipset-specific registers in regs, starting at
		array index EXT (after the VGA registers).

	setregs( unsigned char regs[] )
		Sets the chipset-specific registers stored in regs from
		index EXT.

	modeavailable( int mode )
		Returns nonzero if mode is available (should check video
		memory).

	getmodeinfo( vga_modeinfo *modeinfo )
		Fills in chipset specific field of mode information
		structure: maxlogicalwidth, startaddressrange (mask of
		significant bits), and maxpixels (video memory divided by
		the number of bytes per pixel). haveblit indicates whether
		bitblt functions are available.

	setmode( int mode, int previous_mode )
		Sets all registers for a mode; returns nonzero if mode not
		available. __vga_setregs can be called to set the VGA
		registers.

	unlock()
		Unlocks chipset-specific registers.

	lock()
		Lock (protect) chipset-specific registers. Currently not
		called.

	test()
		Identify chipset; initialize (check memory and type) and
		return nonzero if detected.

	setpage( int page )
		Set 64K page number to be mapped at 0xa0000.

	init( int force, int par1, ... )
		Initialize memory and type; called by test. If force is 1,
		the chiptype or the amount of memory can be forced (this
		is pretty useless).

	The following functions are not required; they provide for things
	like page flipping and hardware scrolling virtual desktops.

	setdisplaystart( int addresss )
		Sets the display start address in video memory in pixels.

	setlogicalwidth( int width )
		Sets the logical scanline length in bytes. Usually a
		multiple of 8.

	The function getchipset() in vga.c must call the test routine for
	the chipset. The chipsetfunctionslist must be have a pointer
	to the chipsetfunctions table for the chipset (which is the only
	global symbol in a chipset driver). Also, vga.h contains a magic
	number for each chipset.



6.  Changes

Changes in v1.00:

[The version number doesn't say anything about stability/completeness etc.]
A number of bug fixes related to Mode X (display start, console switching,
planar 320x200x256 allowed with vga_setmodeX()).
Added vga_copytoplanar256 for Mode X-like modes. Added smooth scrolling demo
program. Demo programs moved to demos/.
Cirrus linear addressing works (if you have less than 16Mb of memory); see
demos/testlinear. Added ET3000 driver. Trident 8900 reboot problem should
be fixed.
Shared library 1.0.9

Changes in v0.99:

ET4000 patches by Hartmut Schirmer: ET4000 register dumps now have extra
registers, so old register dumps won't work; register dump program (tseng3,
moved to et4000/ directory) supports VESA modes. Microsoft mouse handling
bug fixed. Shared library 1.0.8.

Changes in v0.98:

Some minor bugfixes, low-level mouse handling rewritten (was very slow).
Added vga_runinbackground and vga_oktowrite as a kludge to allow a graphics
program to run in the background (not entirely safe). Disabled ET4000 clock
detection (wasn't used yet).
Shared library version 1.0.7.

Changes in v0.97:

Fixed Cirrus 1024x768x256 non-interlaced. Other modes use default (lowest)
frequencies. Fixed bad virtual screen bug in vgagl (copyscreen).
Incorporates patches from Hartmut Schirmer (et4000 clock frequency
determination). Shared library 1.0.6.

Changes in v0.96:

Corrected et4000/et4000.default. Cirrus 1024x768x256 non-interlaced.
Hopefully fixed Cirrus monitor settings. Cirrus blitting works again. Fixes
in vgagl truecolor framebuffer support. Shared library 1.0.5.

Changes in v0.95:

Avoid writing to some reserved registers on ET4000 and Trident (fixes dual
monitor setups) (David Monro). Cirrus 1024x768x256 was doing scary things if
the svgalib monitor type was set to allow non-interlaced. Added Cirrus
1024x768x16 non-interlaced and 1280x1024x16 interlaced. Shared library
1.0.4.

Changes in v0.94:

Added 132x43 textmode tweaking utility. Put utilities in utils/.
restoretextmode was not saving/restoring extended registers anymore. Shared
library 1.0.3. Hack to prevent standard VGA modes from failing to work after
having run XFree86 on Cirrus. gl_setcontextwidth fixed.

Changes in v0.93:

Oops, version 0.92 was not quite up to date. Shared library is 1.0.2. We'll
get libvga.so.1.0.99 before the end of the year at this rate :-).
gl_copybox truly fixed.

Changes in v0.92:

Fixed broken configuration file reading; some minor changes.
Shared library is now version 1.0.1. Source is flawed.

Changes in v0.91:

Various fixes. Dumpreg should work better in X now. The default dynamically
defined ET4000 registers are now in /usr/local/lib/libvga.et4000.
Added vga_getgraphmem.
Shared library support (requires tools 2.8 to build). This greatly reduces
executable size and is good for binary compatibility.
__svgalib_graph_mem is now shadowed in a read-only user-visible global
variable (graph_mem) for easier shared library building.
Fixed console switching bug when a textmode is set in between the setting
of graphics modes.

Oak 640x480x256 should work now.

vgalgl updates. Added 4 bytes per pixel virtual screen support.

Added vga_init. This will detect and initialize the driver, and give up
supervisor rights, having obtained I/O permissions. This is the recommended
first line of any program that uses svgalib.

Should do chmod a+s on restorefont.

EGA support from egalib by Kapil Paranjabe integrated into svgalib. This
is currently untested.

Mouse support (can also be used independently). Added vga_lockvc and
vga_unlockvc; vga_getkey (read keyboard without waiting). Using the mouse
means no console switching for now.

Initial untested S3 driver. Goal is to provide support for truecolor modes
on the 801/805/928, in SVGA mode. Properly uses monitor type variable.
[doesn't work]

Configuration file for mouse/monitor type. Monitor type not used by drivers
yet, except Cirrus.


Changes in v0.9:

Extensive changes and restructuring, by Hartmut Schirmer. Dynamic
(run-time) register loading from a configuration file for ET4000 cards,
providing binary compatibility. High resolution 16-color modes (for ET4000
at least). More stable virtual console switching.

copybox, and gl_setpalettecolor bugs fixed in vgagl.

Fixed setting of standard VGA mode after SVGA mode.


Changes in v0.82:

Virtual console switching cleanup.

The dumpreg program now also shows extended registers.

Added Oak driver, but extended registers have not been filled in. Somebody
should run XFree86 with the Oak driver, dump the extended registers with the
dumpreg program (make sure the Oak driver is enabled in config.h), and put
them in oak.c. With some luck it'll work.


Changes in v0.81:

Restorefont (write option) was broken again due to bug in vga.c; gl/text.c
was missing in v0.8. Added vga_disabledriverreport.


Changes in v0.8:

Fixed major bug in vga_getmodeinfo in vgadrv.c. This may have caused
spic to fail on unsupported SVGA cards in 320x200x256.

vga.c split, and other changes (Hartmut Schirmer). Note that mode numbers
beyond 1024x768x256 have changed. Standard VGA modes 720x350x16 and
720x480x16 added.

Virtual console switching improved (bank/linewidth/displaystart preserved).


Changes in v0.7:

Trident textmode restoration and SVGA modes should work now on 1M cards
(thanks to Scott Heavner).

Bug fixes in vgagl.


Changes in v0.6:

Trident driver bug fixed; detection cleaned up. 800x600 and 1024x768 on 1Mb
cards don't work correctly.

Added Cirrus 800x600x16M NI (at 50 Hz), and program to set the Cirrus memory
clock to a higher value (setmclk.c).

Added framebuffer graphics library for one, two and three byte-per-pixel
modes. Documentation improved.

vga_setrgbcolor added.

ET4000 Hicolor fixes (thanks to Savio Lam), and other fixes (Scott Heavner).


Changes in v0.5:

Fixed palette register timing bug (caused occasional corruption of textmode
palette).

Added function that checks the environment variable GSVGAMODE for a 
default mode (vga_getdefaultmode). The environment string can either be a
mode number (compatible with VGAlib Ghostscript), or a mode name as
in (G640x480x2, G640x480x16, G640x480x256, G640x480x32K, G640x480x64K,
G640x480x16M, PROMPT (ignore)).


Changes in v0.4:

restorefont.c as distributed in v0.3 missed a case line in a switch
statement which made it useless.

Each VGA register write in the library was producing silly debugging code
(I forgot to restore the macro definition), making everything significantly
larger than neccessary.

Added vga_getchipset function. vgatest now only lists modes that are
available.

The ET4000 driver has been improved, including Hicolor DAC detection 
(thanks to David Monro and Daniel Jackson).

Cirrus driver:
Fixed 5420/2/4 bug, cleaned up detection, changed the 800x600 timings, and 
added missing modes 1024x768x256/32K/64K, as well as 320x200x15/16/24bit.
Also, there's support for some of the accelerated features of the Cirrus
5426, the driver provides bitblt (move box), fillblt (fill box), and
imageblt (write bitmap from system memory) functions.

Display start address can now be meaningfully changed in 16-color and planar
256 color VGA modes for page-flipping (address is expressed as number of
pixels).

Fixed the vga_flip() functionality; if you press escape during
vga_getch() the console is switched to textmode until another key is
pressed. [note: this has been obsoleted by console switching]
The default amount of video memory saved in SVGA modes is the size
of one screen. If the program uses more (if it uses page-flipping, for
example), you must indicate it with the vga_claimvideomemory function. This
prevents 2048 or 1024K being saved when only a few hundred K is required.

svgalib now waits until the virtual console it is running in becomes active
before setting the first graphics mode.

Implemented transparent virtual console switching (which uses vga_flip).



7.  Bugs

	Using a 132 column textmode may cause graphics modes to fail. Try
	using something like 80x28.

	The console switching doesn't preserve some registers that may be
	used to draw in planar VGA modes.

	Wild console switching can cause the text screen to be corrupted,
	especially when switching between two graphics consoles.

	On ET4000, having run XFree86 may cause high resolution modes to
	fail (this is more XFree86's fault).

	The Trident probing routine in the XFree86 server may cause standard
	VGA modes to fail after exiting X on a Cirrus. Try putting a 'Chipset'
	line in your Xconfig to avoid the Trident probe, or use the link kit
	to build a server without the Trident driver. Saving and restoring
	the textmode registers with savetextmode/textmode (restoretextmode)
	should also work. [Note: svgalib now resets the particular extended
	register, but only if the Cirrus driver is used (i.e. the chipset
	is not forced to VGA)]

	Some Paradise VGA cards may not work even in standard VGA modes. Can
	anyone confirm this?

	Sometimes the console input shows strange behaviour (e.g. the bash
	history function doesn't work) after running a graphics program.

	Also, sometimes piping data into a graphics program doesn't work
	properly.

	The tseng3 program doesn't recognize any modes on some ET4000 cards.
	Also ET4000 cards with a Acumos/Cirrus DAC may only work correctly
	in 64K color mode.


8.  Goals

	I think the ability to use a VGA/SVGA graphics resolution in one
	virtual	console, and being able to switch to any other virtual console
	and back makes a fairly useful implementation of graphics modes in
	the Linux console.

	Programs that use svgalib must be setuid root. I don't know how
	desirable it is to have this changed; direct port access can hardly
	be done without. Root priviledges can now be given up right after
	initialization. I noticed some unimplemented stuff in the kernel
	header files that may be useful, although doing all register I/O via
	the kernel would incur a significant context-switching overhead.

	It is important that textmode is restored properly and reliably; it
	is fairly reliable at the moment, but fast console switching back
	and forth between two consoles running graphics can give problems.
	Wild virtual console switching also sometimes corrupts the contents
	of the textmode screen buffer (not the textmode registers or font).

	Currently, programs that are in graphics mode are suspended while
	not in the current virtual console. Would it be a good idea to let
	them run in the background, virtualizing framebuffer actions (this
	should not be too hard for linear banked SVGA modes)? It would be
	nice to have, say, a raytracer with a real-time display run in the
	background.



9.  References

	VGAlib v1.2: tsx-11.mit.edu, directory pub/linux/sources/libs:
	vgalib12.tar.Z
	tvgalib-1.0.tar.Z is in the same directory.
	SLS has long been distributing an old version of VGAlib.
	svgalibXX.tgz may be found on sunsite.unc.edu, /pub/Linux/libs,
	spic in apps/graphics/viewers. Also in that directory is seejpeg,
	which shows the picture as it is being built up.
	In the directory is also a svgalib port of the Berkeley MPEG decoder
	(mpeg_play), mpeg-linux.tgz. 
	Also on sunsite is egalib, which is a VGAlib compatible library
	for EGA equipped systems.

	zgv v1.2 is a GIF/JPEG viewer with a nice file selector that uses
	VGAlib (svgalib is compatible with vgalib), on tsx-11.mit.edu,
	/pub/linux/[binaries|sources]. 

	In the info directory of the SIMTEL MSDOS collection, there is a
	package called vgadoc2 which is a collection of VGA/SVGA register
	information.

	The XFree86 driver sources distributed with the link-kit may be
	helpful.

	LIBGRX, the extensive framebuffer library by Csaba Biegl distributed
	with DJGPP, will probably be ported to Linux. Contact Hartmut Schirmer
	(phc27@rz.uni-kiel.d400.de, subject prefix "HARTMUT:").

	The vgalib ghostscript device driver sources can be found on
	sunsite, /pub/Linux/apps/graphics.
	Ghostscript patches from Slackware: ftp.cdrom.com, /pub/linux/misc.
	gnuplot patches are on sunsite.
