annotate src/video/fbcon/SDL_fbriva.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
rev   line source
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
2 SDL - Simple DirectMedia Layer
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
5 This library is free software; you can redistribute it and/or
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
7 License as published by the Free Software Foundation; either
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
10 This library is distributed in the hope that it will be useful,
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
13 Lesser General Public License for more details.
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
19 Sam Lantinga
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
20 slouken@libsdl.org
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1022
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_video.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
25 #include "../SDL_blit.h"
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "SDL_fbriva.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include "riva_mmio.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "riva_regs.h"
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 static int FifoEmptyCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 static int FifoFreeCount = 0;
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 /* Wait for vertical retrace */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
35 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
36 WaitVBL(_THIS)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
38 volatile Uint8 *port = (Uint8 *) (mapped_io + PCIO_OFFSET + 0x3DA);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
40 while ((*port & 0x08));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
41 while (!(*port & 0x08));
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
43 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
44 NV3WaitIdle(_THIS)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
46 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
47 while ((Rop->FifoFree < FifoEmptyCount) ||
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
48 (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01));
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
50 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
51 NV4WaitIdle(_THIS)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
53 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
54 while ((Rop->FifoFree < FifoEmptyCount) ||
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
55 (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01));
133
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
58 #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
59 /* Sets video mem colorkey and accelerated blit function */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
60 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
61 SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
63 return (0);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 }
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 /* Sets per surface hardware alpha value */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
67 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
68 SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
70 return (0);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 }
1022
3d4f1930ed02 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
72 #endif /* Not yet implemented */
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
74 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
75 FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
77 int dstX, dstY;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
78 int dstW, dstH;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
79 RivaBitmap *Bitmap = (RivaBitmap *) (mapped_io + BITMAP_OFFSET);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
81 /* Don't blit to the display surface when switched away */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
82 if (switched_away) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
83 return -2; /* no hardware access */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
84 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
85 if (dst == this->screen) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
86 SDL_mutexP(hw_lock);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
87 }
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
89 /* Set up the X/Y base coordinates */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
90 dstW = rect->w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
91 dstH = rect->h;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
92 FB_dst_to_xy(this, dst, &dstX, &dstY);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
94 /* Adjust for the current rectangle */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
95 dstX += rect->x;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
96 dstY += rect->y;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
98 RIVA_FIFO_FREE(Bitmap, 1);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
99 Bitmap->Color1A = color;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
101 RIVA_FIFO_FREE(Bitmap, 2);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
102 Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
103 Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
105 FB_AddBusySurface(dst);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
107 if (dst == this->screen) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
108 SDL_mutexV(hw_lock);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
109 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
110 return (0);
133
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
113 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
114 HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
115 SDL_Surface * dst, SDL_Rect * dstrect)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
117 SDL_VideoDevice *this = current_video;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
118 int srcX, srcY;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
119 int dstX, dstY;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
120 int dstW, dstH;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
121 RivaScreenBlt *Blt = (RivaScreenBlt *) (mapped_io + BLT_OFFSET);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
123 /* FIXME: For now, only blit to display surface */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
124 if (dst->pitch != SDL_VideoSurface->pitch) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
125 return (src->map->sw_blit(src, srcrect, dst, dstrect));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
126 }
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
128 /* Don't blit to the display surface when switched away */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
129 if (switched_away) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
130 return -2; /* no hardware access */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
131 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
132 if (dst == this->screen) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
133 SDL_mutexP(hw_lock);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
134 }
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
136 /* Calculate source and destination base coordinates (in pixels) */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
137 dstW = dstrect->w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
138 dstH = dstrect->h;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
139 FB_dst_to_xy(this, src, &srcX, &srcY);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
140 FB_dst_to_xy(this, dst, &dstX, &dstY);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
142 /* Adjust for the current blit rectangles */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
143 srcX += srcrect->x;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
144 srcY += srcrect->y;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
145 dstX += dstrect->x;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
146 dstY += dstrect->y;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
148 RIVA_FIFO_FREE(Blt, 3);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
149 Blt->TopLeftSrc = (srcY << 16) | srcX;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
150 Blt->TopLeftDst = (dstY << 16) | dstX;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
151 Blt->WidthHeight = (dstH << 16) | dstW;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
153 FB_AddBusySurface(src);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
154 FB_AddBusySurface(dst);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
156 if (dst == this->screen) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
157 SDL_mutexV(hw_lock);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
158 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
159 return (0);
133
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
162 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
163 CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
165 int accelerated;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
167 /* Set initial acceleration on */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
168 src->flags |= SDL_HWACCEL;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
170 /* Set the surface attributes */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
171 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
172 if (!this->info.blit_hw_A) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
173 src->flags &= ~SDL_HWACCEL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
174 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
175 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
176 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
177 if (!this->info.blit_hw_CC) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
178 src->flags &= ~SDL_HWACCEL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
179 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
180 }
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
182 /* Check to see if final surface blit is accelerated */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
183 accelerated = !!(src->flags & SDL_HWACCEL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
184 if (accelerated) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
185 src->map->hw_blit = HWAccelBlit;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
186 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
187 return (accelerated);
133
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
190 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
191 FB_RivaAccel(_THIS, __u32 card)
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
193 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
195 /* We have hardware accelerated surface functions */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
196 this->CheckHWBlit = CheckHWBlit;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
197 wait_vbl = WaitVBL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
198 switch (card) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
199 case FB_ACCEL_NV3:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
200 wait_idle = NV3WaitIdle;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
201 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
202 case FB_ACCEL_NV4:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
203 wait_idle = NV4WaitIdle;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
204 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
205 default:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
206 /* Hmm... FIXME */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
207 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
208 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
209 FifoEmptyCount = Rop->FifoFree;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
211 /* The Riva has an accelerated color fill */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
212 this->info.blit_fill = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
213 this->FillHWRect = FillHWRect;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
215 /* The Riva has accelerated normal and colorkey blits. */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
216 this->info.blit_hw = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
217 #if 0 /* Not yet implemented? */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
218 this->info.blit_hw_CC = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
219 this->SetHWColorKey = SetHWColorKey;
133
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
222 #if 0 /* Not yet implemented? */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
223 /* The Riva has an accelerated alpha blit */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
224 this->info.blit_hw_A = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
225 this->SetHWAlpha = SetHWAlpha;
133
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 #endif
5d4bafca35cd Added support for hardware accelerated NVidia driver on framebuffer console
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
228
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
229 /* vi: set ts=4 sw=4 expandtab: */