Added support for hardware accelerated NVidia driver on framebuffer console
authorSam Lantinga <slouken@libsdl.org>
Tue, 31 Jul 2001 20:08:51 +0000
changeset 1335d4bafca35cd
parent 132 2604a7be65af
child 134 f1550e1c4916
Added support for hardware accelerated NVidia driver on framebuffer console
Still missing colorkey and alpha blit support
src/video/fbcon/Makefile.am
src/video/fbcon/SDL_fbriva.c
src/video/fbcon/SDL_fbriva.h
src/video/fbcon/SDL_fbvideo.c
src/video/fbcon/riva_mmio.h
src/video/fbcon/riva_regs.h
     1.1 --- a/src/video/fbcon/Makefile.am	Tue Jul 31 06:08:11 2001 +0000
     1.2 +++ b/src/video/fbcon/Makefile.am	Tue Jul 31 20:08:51 2001 +0000
     1.3 @@ -18,8 +18,12 @@
     1.4  	SDL_fbmatrox.h		\
     1.5  	SDL_fbmouse.c		\
     1.6  	SDL_fbmouse_c.h		\
     1.7 +	SDL_fbriva.c		\
     1.8 +	SDL_fbriva.h		\
     1.9  	SDL_fbvideo.c		\
    1.10  	3dfx_mmio.h		\
    1.11  	3dfx_regs.h		\
    1.12  	matrox_mmio.h		\
    1.13 -	matrox_regs.h
    1.14 +	matrox_regs.h		\
    1.15 +	riva_mmio.h		\
    1.16 +	riva_regs.h
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/fbcon/SDL_fbriva.c	Tue Jul 31 20:08:51 2001 +0000
     2.3 @@ -0,0 +1,230 @@
     2.4 +/*
     2.5 +	SDL - Simple DirectMedia Layer
     2.6 +	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     2.7 +
     2.8 +	This library is free software; you can redistribute it and/or
     2.9 +	modify it under the terms of the GNU Library General Public
    2.10 +	License as published by the Free Software Foundation; either
    2.11 +	version 2 of the License, or (at your option) any later version.
    2.12 +
    2.13 +	This library is distributed in the hope that it will be useful,
    2.14 +	but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +	Library General Public License for more details.
    2.17 +
    2.18 +	You should have received a copy of the GNU Library General Public
    2.19 +	License along with this library; if not, write to the Free
    2.20 +	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.21 +
    2.22 +	Sam Lantinga
    2.23 +	slouken@devolution.com
    2.24 +*/
    2.25 +
    2.26 +#ifdef SAVE_RCSID
    2.27 +static char rcsid =
    2.28 + "@(#) $Id$";
    2.29 +#endif
    2.30 +
    2.31 +#include "SDL_types.h"
    2.32 +#include "SDL_video.h"
    2.33 +#include "SDL_blit.h"
    2.34 +#include "SDL_fbriva.h"
    2.35 +#include "riva_mmio.h"
    2.36 +#include "riva_regs.h"
    2.37 +
    2.38 +#define PGRAPH_OFFSET	0x00400000
    2.39 +#define FIFO_OFFSET	0x00800000
    2.40 +#define ROP_OFFSET	FIFO_OFFSET+0x00000000
    2.41 +#define CLIP_OFFSET	FIFO_OFFSET+0x00002000
    2.42 +#define PATT_OFFSET	FIFO_OFFSET+0x00004000
    2.43 +#define PIXMAP_OFFSET	FIFO_OFFSET+0x00006000
    2.44 +#define BLT_OFFSET	FIFO_OFFSET+0x00008000
    2.45 +#define BITMAP_OFFSET	FIFO_OFFSET+0x0000A000
    2.46 +#define LINE_OFFSET	FIFO_OFFSET+0x0000C000
    2.47 +#define TRI03_OFFSET	FIFO_OFFSET+0x0000E000
    2.48 +#define PCIO_OFFSET	0x00601000
    2.49 +
    2.50 +static int FifoEmptyCount = 0;
    2.51 +static int FifoFreeCount = 0;
    2.52 +
    2.53 +/* Wait for vertical retrace */
    2.54 +static void WaitVBL(_THIS)
    2.55 +{
    2.56 +	volatile Uint8 *port = (Uint8 *)(mapped_io + PCIO_OFFSET + 0x3DA);
    2.57 +
    2.58 +	while (  (*port & 0x08) )
    2.59 +		;
    2.60 +	while ( !(*port & 0x08) )
    2.61 +		;
    2.62 +}
    2.63 +static void NV3WaitIdle(_THIS)
    2.64 +{
    2.65 +	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
    2.66 +	while ( (Rop->FifoFree < FifoEmptyCount) ||
    2.67 +	        (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01) )
    2.68 +		;
    2.69 +}
    2.70 +static void NV4WaitIdle(_THIS)
    2.71 +{
    2.72 +	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
    2.73 +	while ( (Rop->FifoFree < FifoEmptyCount) ||
    2.74 +	        (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01) )
    2.75 +		;
    2.76 +}
    2.77 +
    2.78 +/* Sets video mem colorkey and accelerated blit function */
    2.79 +static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
    2.80 +{
    2.81 +	return(0);
    2.82 +}
    2.83 +
    2.84 +/* Sets per surface hardware alpha value */
    2.85 +static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
    2.86 +{
    2.87 +	return(0);
    2.88 +}
    2.89 +
    2.90 +static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
    2.91 +{
    2.92 +	int dstX, dstY;
    2.93 +	int dstW, dstH;
    2.94 +	RivaBitmap *Bitmap = (RivaBitmap *)(mapped_io + BITMAP_OFFSET);
    2.95 +
    2.96 +	/* Don't blit to the display surface when switched away */
    2.97 +	if ( dst == this->screen ) {
    2.98 +		SDL_mutexP(hw_lock);
    2.99 +	}
   2.100 +
   2.101 +	/* Set up the X/Y base coordinates */
   2.102 +	dstW = rect->w;
   2.103 +	dstH = rect->h;
   2.104 +	FB_dst_to_xy(this, dst, &dstX, &dstY);
   2.105 +
   2.106 +	/* Adjust for the current rectangle */
   2.107 +	dstX += rect->x;
   2.108 +	dstY += rect->y;
   2.109 +
   2.110 +	RIVA_FIFO_FREE(Bitmap, 1);
   2.111 +	Bitmap->Color1A = color;
   2.112 +
   2.113 +	RIVA_FIFO_FREE(Bitmap, 2);
   2.114 +	Bitmap->UnclippedRectangle[0].TopLeft     = (dstX << 16) | dstY; 
   2.115 +	Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;
   2.116 +
   2.117 +	FB_AddBusySurface(dst);
   2.118 +
   2.119 +	if ( dst == this->screen ) {
   2.120 +		SDL_mutexV(hw_lock);
   2.121 +	}
   2.122 +	return(0);
   2.123 +}
   2.124 +
   2.125 +static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
   2.126 +                       SDL_Surface *dst, SDL_Rect *dstrect)
   2.127 +{
   2.128 +	SDL_VideoDevice *this = current_video;
   2.129 +	int srcX, srcY;
   2.130 +	int dstX, dstY;
   2.131 +	int dstW, dstH;
   2.132 +	RivaScreenBlt *Blt = (RivaScreenBlt *)(mapped_io + BLT_OFFSET);
   2.133 +
   2.134 +	/* FIXME: For now, only blit to display surface */
   2.135 +	if ( dst->pitch != SDL_VideoSurface->pitch ) {
   2.136 +		return(src->map->sw_blit(src, srcrect, dst, dstrect));
   2.137 +	}
   2.138 +
   2.139 +	/* Don't blit to the display surface when switched away */
   2.140 +	if ( dst == this->screen ) {
   2.141 +		SDL_mutexP(hw_lock);
   2.142 +	}
   2.143 +
   2.144 +	/* Calculate source and destination base coordinates (in pixels) */
   2.145 +	dstW = dstrect->w;
   2.146 +	dstH = dstrect->h;
   2.147 +	FB_dst_to_xy(this, src, &srcX, &srcY);
   2.148 +	FB_dst_to_xy(this, dst, &dstX, &dstY);
   2.149 +
   2.150 +	/* Adjust for the current blit rectangles */
   2.151 +	srcX += srcrect->x;
   2.152 +	srcY += srcrect->y;
   2.153 +	dstX += dstrect->x;
   2.154 +	dstY += dstrect->y;
   2.155 +
   2.156 +	RIVA_FIFO_FREE(Blt, 3);
   2.157 +	Blt->TopLeftSrc  = (srcY << 16) | srcX;
   2.158 +	Blt->TopLeftDst  = (dstY << 16) | dstX;
   2.159 +	Blt->WidthHeight = (dstH  << 16) | dstW;
   2.160 +
   2.161 +	FB_AddBusySurface(src);
   2.162 +	FB_AddBusySurface(dst);
   2.163 +
   2.164 +	if ( dst == this->screen ) {
   2.165 +		SDL_mutexV(hw_lock);
   2.166 +	}
   2.167 +	return(0);
   2.168 +}
   2.169 +
   2.170 +static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
   2.171 +{
   2.172 +	int accelerated;
   2.173 +
   2.174 +	/* Set initial acceleration on */
   2.175 +	src->flags |= SDL_HWACCEL;
   2.176 +
   2.177 +	/* Set the surface attributes */
   2.178 +	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
   2.179 +		if ( ! this->info.blit_hw_A ) {
   2.180 +			src->flags &= ~SDL_HWACCEL;
   2.181 +		}
   2.182 +	}
   2.183 +	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
   2.184 +		if ( ! this->info.blit_hw_CC ) {
   2.185 +			src->flags &= ~SDL_HWACCEL;
   2.186 +		}
   2.187 +	}
   2.188 +
   2.189 +	/* Check to see if final surface blit is accelerated */
   2.190 +	accelerated = !!(src->flags & SDL_HWACCEL);
   2.191 +	if ( accelerated ) {
   2.192 +		src->map->hw_blit = HWAccelBlit;
   2.193 +	}
   2.194 +	return(accelerated);
   2.195 +}
   2.196 +
   2.197 +void FB_RivaAccel(_THIS, __u32 card)
   2.198 +{
   2.199 +	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
   2.200 +
   2.201 +	/* We have hardware accelerated surface functions */
   2.202 +	this->CheckHWBlit = CheckHWBlit;
   2.203 +	wait_vbl = WaitVBL;
   2.204 +	switch (card) {
   2.205 +	    case FB_ACCEL_NV3:
   2.206 +		wait_idle = NV3WaitIdle;
   2.207 +		break;
   2.208 +	    case FB_ACCEL_NV4:
   2.209 +		wait_idle = NV4WaitIdle;
   2.210 +		break;
   2.211 +	    default:
   2.212 +		/* Hmm... FIXME */
   2.213 +		break;
   2.214 +	}
   2.215 +	FifoEmptyCount = Rop->FifoFree;
   2.216 +
   2.217 +	/* The Riva has an accelerated color fill */
   2.218 +	this->info.blit_fill = 1;
   2.219 +	this->FillHWRect = FillHWRect;
   2.220 +
   2.221 +	/* The Riva has accelerated normal and colorkey blits. */
   2.222 +	this->info.blit_hw = 1;
   2.223 +#if 0 /* Not yet implemented? */
   2.224 +	this->info.blit_hw_CC = 1;
   2.225 +	this->SetHWColorKey = SetHWColorKey;
   2.226 +#endif
   2.227 +
   2.228 +#if 0 /* Not yet implemented? */
   2.229 +	/* The Riva has an accelerated alpha blit */
   2.230 +	this->info.blit_hw_A = 1;
   2.231 +	this->SetHWAlpha = SetHWAlpha;
   2.232 +#endif
   2.233 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/fbcon/SDL_fbriva.h	Tue Jul 31 20:08:51 2001 +0000
     3.3 @@ -0,0 +1,33 @@
     3.4 +/*
     3.5 +	SDL - Simple DirectMedia Layer
     3.6 +	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     3.7 +
     3.8 +	This library is free software; you can redistribute it and/or
     3.9 +	modify it under the terms of the GNU Library General Public
    3.10 +	License as published by the Free Software Foundation; either
    3.11 +	version 2 of the License, or (at your option) any later version.
    3.12 +
    3.13 +	This library is distributed in the hope that it will be useful,
    3.14 +	but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +	Library General Public License for more details.
    3.17 +
    3.18 +	You should have received a copy of the GNU Library General Public
    3.19 +	License along with this library; if not, write to the Free
    3.20 +	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.21 +
    3.22 +	Sam Lantinga
    3.23 +	slouken@devolution.com
    3.24 +*/
    3.25 +
    3.26 +#ifdef SAVE_RCSID
    3.27 +static char rcsid =
    3.28 + "@(#) $Id$";
    3.29 +#endif
    3.30 +
    3.31 +/* Riva hardware acceleration for the SDL framebuffer console driver */
    3.32 +
    3.33 +#include "SDL_fbvideo.h"
    3.34 +
    3.35 +/* Set up the driver for Riva acceleration */
    3.36 +extern void FB_RivaAccel(_THIS, __u32 card);
     4.1 --- a/src/video/fbcon/SDL_fbvideo.c	Tue Jul 31 06:08:11 2001 +0000
     4.2 +++ b/src/video/fbcon/SDL_fbvideo.c	Tue Jul 31 20:08:51 2001 +0000
     4.3 @@ -49,6 +49,8 @@
     4.4  #include "SDL_fbevents_c.h"
     4.5  #include "SDL_fb3dfx.h"
     4.6  #include "SDL_fbmatrox.h"
     4.7 +#include "SDL_fbriva.h"
     4.8 +
     4.9  
    4.10  #if defined(i386) && defined(FB_TYPE_VGA_PLANES)
    4.11  #define VGA16_FBCON_SUPPORT
    4.12 @@ -505,6 +507,13 @@
    4.13  #endif
    4.14  			FB_3DfxAccel(this, finfo.accel);
    4.15  			break;
    4.16 +		    case FB_ACCEL_NV3:
    4.17 +		    case FB_ACCEL_NV4:
    4.18 +#ifdef FBACCEL_DEBUG
    4.19 +			printf("NVidia hardware accelerator!\n");
    4.20 +#endif
    4.21 +			FB_RivaAccel(this, finfo.accel);
    4.22 +			break;
    4.23  		    default:
    4.24  #ifdef FBACCEL_DEBUG
    4.25  			printf("Unknown hardware accelerator.\n");
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/fbcon/riva_mmio.h	Tue Jul 31 20:08:51 2001 +0000
     5.3 @@ -0,0 +1,449 @@
     5.4 +/***************************************************************************\
     5.5 +|*                                                                           *|
     5.6 +|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
     5.7 +|*                                                                           *|
     5.8 +|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
     5.9 +|*     international laws.  Users and possessors of this source code are     *|
    5.10 +|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
    5.11 +|*     use this code in individual and commercial software.                  *|
    5.12 +|*                                                                           *|
    5.13 +|*     Any use of this source code must include,  in the user documenta-     *|
    5.14 +|*     tion and  internal comments to the code,  notices to the end user     *|
    5.15 +|*     as follows:                                                           *|
    5.16 +|*                                                                           *|
    5.17 +|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
    5.18 +|*                                                                           *|
    5.19 +|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
    5.20 +|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
    5.21 +|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
    5.22 +|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
    5.23 +|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
    5.24 +|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
    5.25 +|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
    5.26 +|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
    5.27 +|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
    5.28 +|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
    5.29 +|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
    5.30 +|*                                                                           *|
    5.31 +|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
    5.32 +|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
    5.33 +|*     consisting  of "commercial  computer  software"  and  "commercial     *|
    5.34 +|*     computer  software  documentation,"  as such  terms  are  used in     *|
    5.35 +|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
    5.36 +|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
    5.37 +|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
    5.38 +|*     all U.S. Government End Users  acquire the source code  with only     *|
    5.39 +|*     those rights set forth herein.                                        *|
    5.40 +|*                                                                           *|
    5.41 +\***************************************************************************/
    5.42 +
    5.43 +#ifndef __RIVA_HW_H__
    5.44 +#define __RIVA_HW_H__
    5.45 +#define RIVA_SW_VERSION 0x00010003
    5.46 +
    5.47 +/*
    5.48 + * Typedefs to force certain sized values.
    5.49 + */
    5.50 +typedef Uint8  U008;
    5.51 +typedef Uint16 U016;
    5.52 +typedef Uint32 U032;
    5.53 +
    5.54 +/*
    5.55 + * HW access macros.
    5.56 + */
    5.57 +#define NV_WR08(p,i,d)  (((U008 *)(p))[i]=(d))
    5.58 +#define NV_RD08(p,i)    (((U008 *)(p))[i])
    5.59 +#define NV_WR16(p,i,d)  (((U016 *)(p))[(i)/2]=(d))
    5.60 +#define NV_RD16(p,i)    (((U016 *)(p))[(i)/2])
    5.61 +#define NV_WR32(p,i,d)  (((U032 *)(p))[(i)/4]=(d))
    5.62 +#define NV_RD32(p,i)    (((U032 *)(p))[(i)/4])
    5.63 +#define VGA_WR08(p,i,d) NV_WR08(p,i,d)
    5.64 +#define VGA_RD08(p,i)   NV_RD08(p,i)
    5.65 +
    5.66 +/*
    5.67 + * Define supported architectures.
    5.68 + */
    5.69 +#define NV_ARCH_03  0x03
    5.70 +#define NV_ARCH_04  0x04
    5.71 +#define NV_ARCH_10  0x10
    5.72 +/***************************************************************************\
    5.73 +*                                                                           *
    5.74 +*                             FIFO registers.                               *
    5.75 +*                                                                           *
    5.76 +\***************************************************************************/
    5.77 +
    5.78 +/*
    5.79 + * Raster OPeration. Windows style ROP3.
    5.80 + */
    5.81 +typedef volatile struct
    5.82 +{
    5.83 +    U032 reserved00[4];
    5.84 +    U016 FifoFree;
    5.85 +    U016 Nop;
    5.86 +    U032 reserved01[0x0BB];
    5.87 +    U032 Rop3;
    5.88 +} RivaRop;
    5.89 +/*
    5.90 + * 8X8 Monochrome pattern.
    5.91 + */
    5.92 +typedef volatile struct
    5.93 +{
    5.94 +    U032 reserved00[4];
    5.95 +    U016 FifoFree;
    5.96 +    U016 Nop;
    5.97 +    U032 reserved01[0x0BD];
    5.98 +    U032 Shape;
    5.99 +    U032 reserved03[0x001];
   5.100 +    U032 Color0;
   5.101 +    U032 Color1;
   5.102 +    U032 Monochrome[2];
   5.103 +} RivaPattern;
   5.104 +/*
   5.105 + * Scissor clip rectangle.
   5.106 + */
   5.107 +typedef volatile struct
   5.108 +{
   5.109 +    U032 reserved00[4];
   5.110 +    U016 FifoFree;
   5.111 +    U016 Nop;
   5.112 +    U032 reserved01[0x0BB];
   5.113 +    U032 TopLeft;
   5.114 +    U032 WidthHeight;
   5.115 +} RivaClip;
   5.116 +/*
   5.117 + * 2D filled rectangle.
   5.118 + */
   5.119 +typedef volatile struct
   5.120 +{
   5.121 +    U032 reserved00[4];
   5.122 +    U016 FifoFree;
   5.123 +    U016 Nop[1];
   5.124 +    U032 reserved01[0x0BC];
   5.125 +    U032 Color;
   5.126 +    U032 reserved03[0x03E];
   5.127 +    U032 TopLeft;
   5.128 +    U032 WidthHeight;
   5.129 +} RivaRectangle;
   5.130 +/*
   5.131 + * 2D screen-screen BLT.
   5.132 + */
   5.133 +typedef volatile struct
   5.134 +{
   5.135 +    U032 reserved00[4];
   5.136 +    U016 FifoFree;
   5.137 +    U016 Nop;
   5.138 +    U032 reserved01[0x0BB];
   5.139 +    U032 TopLeftSrc;
   5.140 +    U032 TopLeftDst;
   5.141 +    U032 WidthHeight;
   5.142 +} RivaScreenBlt;
   5.143 +/*
   5.144 + * 2D pixel BLT.
   5.145 + */
   5.146 +typedef volatile struct
   5.147 +{
   5.148 +    U032 reserved00[4];
   5.149 +    U016 FifoFree;
   5.150 +    U016 Nop[1];
   5.151 +    U032 reserved01[0x0BC];
   5.152 +    U032 TopLeft;
   5.153 +    U032 WidthHeight;
   5.154 +    U032 WidthHeightIn;
   5.155 +    U032 reserved02[0x03C];
   5.156 +    U032 Pixels;
   5.157 +} RivaPixmap;
   5.158 +/*
   5.159 + * Filled rectangle combined with monochrome expand.  Useful for glyphs.
   5.160 + */
   5.161 +typedef volatile struct
   5.162 +{
   5.163 +    U032 reserved00[4];
   5.164 +    U016 FifoFree;
   5.165 +    U016 Nop;
   5.166 +    U032 reserved01[0x0BB];
   5.167 +    U032 reserved03[(0x040)-1];
   5.168 +    U032 Color1A;
   5.169 +    struct
   5.170 +    {
   5.171 +        U032 TopLeft;
   5.172 +        U032 WidthHeight;
   5.173 +    } UnclippedRectangle[64];
   5.174 +    U032 reserved04[(0x080)-3];
   5.175 +    struct
   5.176 +    {
   5.177 +        U032 TopLeft;
   5.178 +        U032 BottomRight;
   5.179 +    } ClipB;
   5.180 +    U032 Color1B;
   5.181 +    struct
   5.182 +    {
   5.183 +        U032 TopLeft;
   5.184 +        U032 BottomRight;
   5.185 +    } ClippedRectangle[64];
   5.186 +    U032 reserved05[(0x080)-5];
   5.187 +    struct
   5.188 +    {
   5.189 +        U032 TopLeft;
   5.190 +        U032 BottomRight;
   5.191 +    } ClipC;
   5.192 +    U032 Color1C;
   5.193 +    U032 WidthHeightC;
   5.194 +    U032 PointC;
   5.195 +    U032 MonochromeData1C;
   5.196 +    U032 reserved06[(0x080)+121];
   5.197 +    struct
   5.198 +    {
   5.199 +        U032 TopLeft;
   5.200 +        U032 BottomRight;
   5.201 +    } ClipD;
   5.202 +    U032 Color1D;
   5.203 +    U032 WidthHeightInD;
   5.204 +    U032 WidthHeightOutD;
   5.205 +    U032 PointD;
   5.206 +    U032 MonochromeData1D;
   5.207 +    U032 reserved07[(0x080)+120];
   5.208 +    struct
   5.209 +    {
   5.210 +        U032 TopLeft;
   5.211 +        U032 BottomRight;
   5.212 +    } ClipE;
   5.213 +    U032 Color0E;
   5.214 +    U032 Color1E;
   5.215 +    U032 WidthHeightInE;
   5.216 +    U032 WidthHeightOutE;
   5.217 +    U032 PointE;
   5.218 +    U032 MonochromeData01E;
   5.219 +} RivaBitmap;
   5.220 +/*
   5.221 + * 3D textured, Z buffered triangle.
   5.222 + */
   5.223 +typedef volatile struct
   5.224 +{
   5.225 +    U032 reserved00[4];
   5.226 +    U016 FifoFree;
   5.227 +    U016 Nop;
   5.228 +    U032 reserved01[0x0BC];
   5.229 +    U032 TextureOffset;
   5.230 +    U032 TextureFormat;
   5.231 +    U032 TextureFilter;
   5.232 +    U032 FogColor;
   5.233 +/* This is a problem on LynxOS */
   5.234 +#ifdef Control
   5.235 +#undef Control
   5.236 +#endif
   5.237 +    U032 Control;
   5.238 +    U032 AlphaTest;
   5.239 +    U032 reserved02[0x339];
   5.240 +    U032 FogAndIndex;
   5.241 +    U032 Color;
   5.242 +    float ScreenX;
   5.243 +    float ScreenY;
   5.244 +    float ScreenZ;
   5.245 +    float EyeM;
   5.246 +    float TextureS;
   5.247 +    float TextureT;
   5.248 +} RivaTexturedTriangle03;
   5.249 +typedef volatile struct
   5.250 +{
   5.251 +    U032 reserved00[4];
   5.252 +    U016 FifoFree;
   5.253 +    U016 Nop;
   5.254 +    U032 reserved01[0x0BB];
   5.255 +    U032 ColorKey;
   5.256 +    U032 TextureOffset;
   5.257 +    U032 TextureFormat;
   5.258 +    U032 TextureFilter;
   5.259 +    U032 Blend;
   5.260 +/* This is a problem on LynxOS */
   5.261 +#ifdef Control
   5.262 +#undef Control
   5.263 +#endif
   5.264 +    U032 Control;
   5.265 +    U032 FogColor;
   5.266 +    U032 reserved02[0x39];
   5.267 +    struct
   5.268 +    {
   5.269 +        float ScreenX;
   5.270 +        float ScreenY;
   5.271 +        float ScreenZ;
   5.272 +        float EyeM;
   5.273 +        U032 Color;
   5.274 +        U032 Specular;
   5.275 +        float TextureS;
   5.276 +        float TextureT;
   5.277 +    } Vertex[16];
   5.278 +    U032 DrawTriangle3D;
   5.279 +} RivaTexturedTriangle05;
   5.280 +/*
   5.281 + * 2D line.
   5.282 + */
   5.283 +typedef volatile struct
   5.284 +{
   5.285 +    U032 reserved00[4];
   5.286 +    U016 FifoFree;
   5.287 +    U016 Nop[1];
   5.288 +    U032 reserved01[0x0BC];
   5.289 +    U032 Color;             /* source color               0304-0307*/
   5.290 +    U032 Reserved02[0x03e];
   5.291 +    struct {                /* start aliased methods in array   0400-    */
   5.292 +        U032 point0;        /* y_x S16_S16 in pixels            0-   3*/
   5.293 +        U032 point1;        /* y_x S16_S16 in pixels            4-   7*/
   5.294 +    } Lin[16];              /* end of aliased methods in array      -047f*/
   5.295 +    struct {                /* start aliased methods in array   0480-    */
   5.296 +        U032 point0X;       /* in pixels, 0 at left                0-   3*/
   5.297 +        U032 point0Y;       /* in pixels, 0 at top                 4-   7*/
   5.298 +        U032 point1X;       /* in pixels, 0 at left                8-   b*/
   5.299 +        U032 point1Y;       /* in pixels, 0 at top                 c-   f*/
   5.300 +    } Lin32[8];             /* end of aliased methods in array      -04ff*/
   5.301 +    U032 PolyLin[32];       /* y_x S16_S16 in pixels         0500-057f*/
   5.302 +    struct {                /* start aliased methods in array   0580-    */
   5.303 +        U032 x;             /* in pixels, 0 at left                0-   3*/
   5.304 +        U032 y;             /* in pixels, 0 at top                 4-   7*/
   5.305 +    } PolyLin32[16];        /* end of aliased methods in array      -05ff*/
   5.306 +    struct {                /* start aliased methods in array   0600-    */
   5.307 +        U032 color;         /* source color                     0-   3*/
   5.308 +        U032 point;         /* y_x S16_S16 in pixels            4-   7*/
   5.309 +    } ColorPolyLin[16];     /* end of aliased methods in array      -067f*/
   5.310 +} RivaLine;
   5.311 +/*
   5.312 + * 2D/3D surfaces
   5.313 + */
   5.314 +typedef volatile struct
   5.315 +{
   5.316 +    U032 reserved00[4];
   5.317 +    U016 FifoFree;
   5.318 +    U016 Nop;
   5.319 +    U032 reserved01[0x0BE];
   5.320 +    U032 Offset;
   5.321 +} RivaSurface;
   5.322 +typedef volatile struct
   5.323 +{
   5.324 +    U032 reserved00[4];
   5.325 +    U016 FifoFree;
   5.326 +    U016 Nop;
   5.327 +    U032 reserved01[0x0BD];
   5.328 +    U032 Pitch;
   5.329 +    U032 RenderBufferOffset;
   5.330 +    U032 ZBufferOffset;
   5.331 +} RivaSurface3D;
   5.332 +    
   5.333 +/***************************************************************************\
   5.334 +*                                                                           *
   5.335 +*                        Virtualized RIVA H/W interface.                    *
   5.336 +*                                                                           *
   5.337 +\***************************************************************************/
   5.338 +
   5.339 +struct _riva_hw_inst;
   5.340 +struct _riva_hw_state;
   5.341 +/*
   5.342 + * Virtialized chip interface. Makes RIVA 128 and TNT look alike.
   5.343 + */
   5.344 +typedef struct _riva_hw_inst
   5.345 +{
   5.346 +    /*
   5.347 +     * Chip specific settings.
   5.348 +     */
   5.349 +    U032 Architecture;
   5.350 +    U032 Version;
   5.351 +    U032 CrystalFreqKHz;
   5.352 +    U032 RamAmountKBytes;
   5.353 +    U032 MaxVClockFreqKHz;
   5.354 +    U032 RamBandwidthKBytesPerSec;
   5.355 +    U032 EnableIRQ;
   5.356 +    U032 IO;
   5.357 +    U032 VBlankBit;
   5.358 +    U032 FifoFreeCount;
   5.359 +    U032 FifoEmptyCount;
   5.360 +    /*
   5.361 +     * Non-FIFO registers.
   5.362 +     */
   5.363 +    volatile U032 *PCRTC;
   5.364 +    volatile U032 *PRAMDAC;
   5.365 +    volatile U032 *PFB;
   5.366 +    volatile U032 *PFIFO;
   5.367 +    volatile U032 *PGRAPH;
   5.368 +    volatile U032 *PEXTDEV;
   5.369 +    volatile U032 *PTIMER;
   5.370 +    volatile U032 *PMC;
   5.371 +    volatile U032 *PRAMIN;
   5.372 +    volatile U032 *FIFO;
   5.373 +    volatile U032 *CURSOR;
   5.374 +    volatile U032 *CURSORPOS;
   5.375 +    volatile U032 *VBLANKENABLE;
   5.376 +    volatile U032 *VBLANK;
   5.377 +    volatile U008 *PCIO;
   5.378 +    volatile U008 *PVIO;
   5.379 +    volatile U008 *PDIO;
   5.380 +    /*
   5.381 +     * Common chip functions.
   5.382 +     */
   5.383 +    int  (*Busy)(struct _riva_hw_inst *);
   5.384 +    void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int,int,int,int,int,int,int,int,int);
   5.385 +    void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
   5.386 +    void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
   5.387 +    void (*SetStartAddress)(struct _riva_hw_inst *,U032);
   5.388 +    void (*SetSurfaces2D)(struct _riva_hw_inst *,U032,U032);
   5.389 +    void (*SetSurfaces3D)(struct _riva_hw_inst *,U032,U032);
   5.390 +    int  (*ShowHideCursor)(struct _riva_hw_inst *,int);
   5.391 +    void (*LockUnlock)(struct _riva_hw_inst *, int);
   5.392 +    /*
   5.393 +     * Current extended mode settings.
   5.394 +     */
   5.395 +    struct _riva_hw_state *CurrentState;
   5.396 +    /*
   5.397 +     * FIFO registers.
   5.398 +     */
   5.399 +    RivaRop                 *Rop;
   5.400 +    RivaPattern             *Patt;
   5.401 +    RivaClip                *Clip;
   5.402 +    RivaPixmap              *Pixmap;
   5.403 +    RivaScreenBlt           *Blt;
   5.404 +    RivaBitmap              *Bitmap;
   5.405 +    RivaLine                *Line;
   5.406 +    RivaTexturedTriangle03  *Tri03;
   5.407 +    RivaTexturedTriangle05  *Tri05;
   5.408 +} RIVA_HW_INST;
   5.409 +/*
   5.410 + * Extended mode state information.
   5.411 + */
   5.412 +typedef struct _riva_hw_state
   5.413 +{
   5.414 +    U032 bpp;
   5.415 +    U032 width;
   5.416 +    U032 height;
   5.417 +    U032 repaint0;
   5.418 +    U032 repaint1;
   5.419 +    U032 screen;
   5.420 +    U032 pixel;
   5.421 +    U032 horiz;
   5.422 +    U032 arbitration0;
   5.423 +    U032 arbitration1;
   5.424 +    U032 vpll;
   5.425 +    U032 pllsel;
   5.426 +    U032 general;
   5.427 +    U032 config;
   5.428 +    U032 cursor0;
   5.429 +    U032 cursor1;
   5.430 +    U032 cursor2;
   5.431 +    U032 offset0;
   5.432 +    U032 offset1;
   5.433 +    U032 offset2;
   5.434 +    U032 offset3;
   5.435 +    U032 pitch0;
   5.436 +    U032 pitch1;
   5.437 +    U032 pitch2;
   5.438 +    U032 pitch3;
   5.439 +} RIVA_HW_STATE;
   5.440 +
   5.441 +/*
   5.442 + * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
   5.443 + */
   5.444 +
   5.445 +#define RIVA_FIFO_FREE(hwptr,cnt)                                  \
   5.446 +{                                                                  \
   5.447 +   while (FifoFreeCount < (cnt))                                   \
   5.448 +	FifoFreeCount = hwptr->FifoFree >> 2;                      \
   5.449 +   FifoFreeCount -= (cnt);                                         \
   5.450 +}
   5.451 +#endif /* __RIVA_HW_H__ */
   5.452 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/fbcon/riva_regs.h	Tue Jul 31 20:08:51 2001 +0000
     6.3 @@ -0,0 +1,47 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Library General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Library General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Library General Public
    6.19 +    License along with this library; if not, write to the Free
    6.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.21 +
    6.22 +    Sam Lantinga
    6.23 +    slouken@devolution.com
    6.24 +*/
    6.25 +
    6.26 +#ifdef SAVE_RCSID
    6.27 +static char rcsid =
    6.28 + "@(#) $Id$";
    6.29 +#endif
    6.30 +
    6.31 +#ifndef _RIVA_REGS_H
    6.32 +#define _RIVA_REGS_H
    6.33 +
    6.34 +/* This information comes from the XFree86 NVidia hardware driver */
    6.35 +
    6.36 +/* mapped_io register offsets */
    6.37 +#define PGRAPH_OFFSET	0x00400000
    6.38 +#define FIFO_OFFSET	0x00800000
    6.39 +#define ROP_OFFSET	FIFO_OFFSET+0x00000000
    6.40 +#define CLIP_OFFSET	FIFO_OFFSET+0x00002000
    6.41 +#define PATT_OFFSET	FIFO_OFFSET+0x00004000
    6.42 +#define PIXMAP_OFFSET	FIFO_OFFSET+0x00006000
    6.43 +#define BLT_OFFSET	FIFO_OFFSET+0x00008000
    6.44 +#define BITMAP_OFFSET	FIFO_OFFSET+0x0000A000
    6.45 +#define LINE_OFFSET	FIFO_OFFSET+0x0000C000
    6.46 +#define TRI03_OFFSET	FIFO_OFFSET+0x0000E000
    6.47 +#define PCIO_OFFSET	0x00601000
    6.48 +
    6.49 +#endif /* _RIVA_REGS_H */
    6.50 +