src/video/fbcon/SDL_fbriva.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 04 Jan 2005 19:04:14 +0000
changeset 1022 3d4f1930ed02
parent 769 b8d311d90021
child 1312 c9b51268668f
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
	SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
     3
    Copyright (C) 1997-2004 Sam Lantinga
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
	This library is free software; you can redistribute it and/or
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
	modify it under the terms of the GNU Library General Public
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
	License as published by the Free Software Foundation; either
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
	version 2 of the License, or (at your option) any later version.
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
	This library is distributed in the hope that it will be useful,
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
	but WITHOUT ANY WARRANTY; without even the implied warranty of
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
	Library General Public License for more details.
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
	You should have received a copy of the GNU Library General Public
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
	License along with this library; if not, write to the Free
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
	Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 134
diff changeset
    20
	slouken@libsdl.org
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#ifdef SAVE_RCSID
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
static char rcsid =
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
 "@(#) $Id$";
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "SDL_types.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "SDL_video.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include "SDL_blit.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#include "SDL_fbriva.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#include "riva_mmio.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#include "riva_regs.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
static int FifoEmptyCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
static int FifoFreeCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
/* Wait for vertical retrace */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
static void WaitVBL(_THIS)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
	volatile Uint8 *port = (Uint8 *)(mapped_io + PCIO_OFFSET + 0x3DA);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
	while (  (*port & 0x08) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
		;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
	while ( !(*port & 0x08) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
		;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
static void NV3WaitIdle(_THIS)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
	while ( (Rop->FifoFree < FifoEmptyCount) ||
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
	        (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
		;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
static void NV4WaitIdle(_THIS)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
	while ( (Rop->FifoFree < FifoEmptyCount) ||
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
	        (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
		;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
1022
3d4f1930ed02 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
    64
#if 0 /* Not yet implemented? */
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
/* Sets video mem colorkey and accelerated blit function */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
	return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
/* Sets per surface hardware alpha value */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
	return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
}
1022
3d4f1930ed02 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
    76
#endif /* Not yet implemented */
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
	int dstX, dstY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
	int dstW, dstH;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
	RivaBitmap *Bitmap = (RivaBitmap *)(mapped_io + BITMAP_OFFSET);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
	/* Don't blit to the display surface when switched away */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
	if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
		SDL_mutexP(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
	/* Set up the X/Y base coordinates */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
	dstW = rect->w;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
	dstH = rect->h;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
	FB_dst_to_xy(this, dst, &dstX, &dstY);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
	/* Adjust for the current rectangle */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
	dstX += rect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
	dstY += rect->y;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
	RIVA_FIFO_FREE(Bitmap, 1);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
	Bitmap->Color1A = color;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
	RIVA_FIFO_FREE(Bitmap, 2);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
	Bitmap->UnclippedRectangle[0].TopLeft     = (dstX << 16) | dstY; 
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
	Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
	FB_AddBusySurface(dst);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
	if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
		SDL_mutexV(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
	return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
                       SDL_Surface *dst, SDL_Rect *dstrect)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
	SDL_VideoDevice *this = current_video;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
	int srcX, srcY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
	int dstX, dstY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
	int dstW, dstH;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
	RivaScreenBlt *Blt = (RivaScreenBlt *)(mapped_io + BLT_OFFSET);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
	/* FIXME: For now, only blit to display surface */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
	if ( dst->pitch != SDL_VideoSurface->pitch ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
		return(src->map->sw_blit(src, srcrect, dst, dstrect));
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
	/* Don't blit to the display surface when switched away */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
	if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
		SDL_mutexP(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
	/* Calculate source and destination base coordinates (in pixels) */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
	dstW = dstrect->w;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
	dstH = dstrect->h;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
	FB_dst_to_xy(this, src, &srcX, &srcY);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
	FB_dst_to_xy(this, dst, &dstX, &dstY);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
	/* Adjust for the current blit rectangles */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
	srcX += srcrect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
	srcY += srcrect->y;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
	dstX += dstrect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
	dstY += dstrect->y;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
	RIVA_FIFO_FREE(Blt, 3);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
	Blt->TopLeftSrc  = (srcY << 16) | srcX;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
	Blt->TopLeftDst  = (dstY << 16) | dstX;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
	Blt->WidthHeight = (dstH  << 16) | dstW;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
	FB_AddBusySurface(src);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
	FB_AddBusySurface(dst);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
	if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
		SDL_mutexV(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
	return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
	int accelerated;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
	/* Set initial acceleration on */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
	src->flags |= SDL_HWACCEL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
	/* Set the surface attributes */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
		if ( ! this->info.blit_hw_A ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
			src->flags &= ~SDL_HWACCEL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
		}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
		if ( ! this->info.blit_hw_CC ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
			src->flags &= ~SDL_HWACCEL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
		}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
	/* Check to see if final surface blit is accelerated */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
	accelerated = !!(src->flags & SDL_HWACCEL);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
	if ( accelerated ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
		src->map->hw_blit = HWAccelBlit;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
	return(accelerated);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
void FB_RivaAccel(_THIS, __u32 card)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
{
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
	RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
	/* We have hardware accelerated surface functions */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
	this->CheckHWBlit = CheckHWBlit;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
	wait_vbl = WaitVBL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
	switch (card) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
	    case FB_ACCEL_NV3:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
		wait_idle = NV3WaitIdle;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
		break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
	    case FB_ACCEL_NV4:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
		wait_idle = NV4WaitIdle;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
		break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
	    default:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
		/* Hmm... FIXME */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
		break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
	}
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
	FifoEmptyCount = Rop->FifoFree;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
	/* The Riva has an accelerated color fill */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
	this->info.blit_fill = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
	this->FillHWRect = FillHWRect;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
	/* The Riva has accelerated normal and colorkey blits. */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
	this->info.blit_hw = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
#if 0 /* Not yet implemented? */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
	this->info.blit_hw_CC = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
	this->SetHWColorKey = SetHWColorKey;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
#endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
#if 0 /* Not yet implemented? */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
	/* The Riva has an accelerated alpha blit */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
	this->info.blit_hw_A = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
	this->SetHWAlpha = SetHWAlpha;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
#endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
}