annotate src/video/fbcon/SDL_fbriva.c @ 133:5d4bafca35cd

Added support for hardware accelerated NVidia driver on framebuffer console Still missing colorkey and alpha blit support
author Sam Lantinga <slouken@libsdl.org>
date Tue, 31 Jul 2001 20:08:51 +0000
parents
children f1550e1c4916
rev   line source
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
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
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
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@devolution.com
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 #define PGRAPH_OFFSET 0x00400000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #define FIFO_OFFSET 0x00800000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #define ROP_OFFSET FIFO_OFFSET+0x00000000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #define CLIP_OFFSET FIFO_OFFSET+0x00002000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #define PATT_OFFSET FIFO_OFFSET+0x00004000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #define PIXMAP_OFFSET FIFO_OFFSET+0x00006000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #define BLT_OFFSET FIFO_OFFSET+0x00008000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #define BITMAP_OFFSET FIFO_OFFSET+0x0000A000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #define LINE_OFFSET FIFO_OFFSET+0x0000C000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #define TRI03_OFFSET FIFO_OFFSET+0x0000E000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #define PCIO_OFFSET 0x00601000
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 static int FifoEmptyCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 static int FifoFreeCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 /* Wait for vertical retrace */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 static void WaitVBL(_THIS)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 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
54
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 while ( (*port & 0x08) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 ;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 while ( !(*port & 0x08) )
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 ;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 static void NV3WaitIdle(_THIS)
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 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
63 while ( (Rop->FifoFree < FifoEmptyCount) ||
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 (*(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
65 ;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 static void NV4WaitIdle(_THIS)
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 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
70 while ( (Rop->FifoFree < FifoEmptyCount) ||
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 (*(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
72 ;
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
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 /* 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
76 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
77 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 return(0);
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
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 /* 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
82 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
83 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 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
88 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 int dstX, dstY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 int dstW, dstH;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 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
92
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 /* 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
94 if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 SDL_mutexP(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
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 /* 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
99 dstW = rect->w;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 dstH = rect->h;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 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
102
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 /* Adjust for the current rectangle */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 dstX += rect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 dstY += rect->y;
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 RIVA_FIFO_FREE(Bitmap, 1);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 Bitmap->Color1A = color;
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 RIVA_FIFO_FREE(Bitmap, 2);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 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
112 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
113
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 FB_AddBusySurface(dst);
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 if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 SDL_mutexV(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 }
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 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
123 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
124 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 SDL_VideoDevice *this = current_video;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 int srcX, srcY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 int dstX, dstY;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 int dstW, dstH;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 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
130
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 /* 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
132 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
133 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
134 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 /* 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
137 if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 SDL_mutexP(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 /* 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
142 dstW = dstrect->w;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 dstH = dstrect->h;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 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
145 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
146
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 /* 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
148 srcX += srcrect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 srcY += srcrect->y;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 dstX += dstrect->x;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 dstY += dstrect->y;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 RIVA_FIFO_FREE(Blt, 3);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 Blt->TopLeftSrc = (srcY << 16) | srcX;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 Blt->TopLeftDst = (dstY << 16) | dstX;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 Blt->WidthHeight = (dstH << 16) | dstW;
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 FB_AddBusySurface(src);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 FB_AddBusySurface(dst);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 if ( dst == this->screen ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 SDL_mutexV(hw_lock);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 return(0);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 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
168 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 int accelerated;
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 /* Set initial acceleration on */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 src->flags |= SDL_HWACCEL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 /* Set the surface attributes */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 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
176 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
177 src->flags &= ~SDL_HWACCEL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 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
181 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
182 src->flags &= ~SDL_HWACCEL;
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
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* 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
187 accelerated = !!(src->flags & SDL_HWACCEL);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 if ( accelerated ) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 src->map->hw_blit = HWAccelBlit;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 return(accelerated);
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 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
195 {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 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
197
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 /* 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
199 this->CheckHWBlit = CheckHWBlit;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 wait_vbl = WaitVBL;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 switch (card) {
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 case FB_ACCEL_NV3:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 wait_idle = NV3WaitIdle;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 case FB_ACCEL_NV4:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 wait_idle = NV4WaitIdle;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 default:
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 /* Hmm... FIXME */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 break;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 }
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 FifoEmptyCount = Rop->FifoFree;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 /* 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
215 this->info.blit_fill = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 this->FillHWRect = FillHWRect;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 /* 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
219 this->info.blit_hw = 1;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 #if 0 /* Not yet implemented? */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 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
222 this->SetHWColorKey = SetHWColorKey;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 #endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 #if 0 /* Not yet implemented? */
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 /* 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
227 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
228 this->SetHWAlpha = SetHWAlpha;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 #endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 }