comparison src/video/fbcon/SDL_fbriva.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 7a36f01acf71
children e1da92da346c
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
30 30
31 static int FifoEmptyCount = 0; 31 static int FifoEmptyCount = 0;
32 static int FifoFreeCount = 0; 32 static int FifoFreeCount = 0;
33 33
34 /* Wait for vertical retrace */ 34 /* Wait for vertical retrace */
35 static void WaitVBL(_THIS) 35 static void
36 { 36 WaitVBL(_THIS)
37 volatile Uint8 *port = (Uint8 *)(mapped_io + PCIO_OFFSET + 0x3DA); 37 {
38 38 volatile Uint8 *port = (Uint8 *) (mapped_io + PCIO_OFFSET + 0x3DA);
39 while ( (*port & 0x08) ) 39
40 ; 40 while ((*port & 0x08));
41 while ( !(*port & 0x08) ) 41 while (!(*port & 0x08));
42 ; 42 }
43 } 43 static void
44 static void NV3WaitIdle(_THIS) 44 NV3WaitIdle(_THIS)
45 { 45 {
46 RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET); 46 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
47 while ( (Rop->FifoFree < FifoEmptyCount) || 47 while ((Rop->FifoFree < FifoEmptyCount) ||
48 (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01) ) 48 (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01));
49 ; 49 }
50 } 50 static void
51 static void NV4WaitIdle(_THIS) 51 NV4WaitIdle(_THIS)
52 { 52 {
53 RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET); 53 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
54 while ( (Rop->FifoFree < FifoEmptyCount) || 54 while ((Rop->FifoFree < FifoEmptyCount) ||
55 (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01) ) 55 (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01));
56 ; 56 }
57 } 57
58 58 #if 0 /* Not yet implemented? */
59 #if 0 /* Not yet implemented? */
60 /* Sets video mem colorkey and accelerated blit function */ 59 /* Sets video mem colorkey and accelerated blit function */
61 static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) 60 static int
62 { 61 SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
63 return(0); 62 {
63 return (0);
64 } 64 }
65 65
66 /* Sets per surface hardware alpha value */ 66 /* Sets per surface hardware alpha value */
67 static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value) 67 static int
68 { 68 SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value)
69 return(0); 69 {
70 return (0);
70 } 71 }
71 #endif /* Not yet implemented */ 72 #endif /* Not yet implemented */
72 73
73 static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) 74 static int
74 { 75 FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
75 int dstX, dstY; 76 {
76 int dstW, dstH; 77 int dstX, dstY;
77 RivaBitmap *Bitmap = (RivaBitmap *)(mapped_io + BITMAP_OFFSET); 78 int dstW, dstH;
78 79 RivaBitmap *Bitmap = (RivaBitmap *) (mapped_io + BITMAP_OFFSET);
79 /* Don't blit to the display surface when switched away */ 80
80 if ( switched_away ) { 81 /* Don't blit to the display surface when switched away */
81 return -2; /* no hardware access */ 82 if (switched_away) {
82 } 83 return -2; /* no hardware access */
83 if ( dst == this->screen ) { 84 }
84 SDL_mutexP(hw_lock); 85 if (dst == this->screen) {
85 } 86 SDL_mutexP(hw_lock);
86 87 }
87 /* Set up the X/Y base coordinates */ 88
88 dstW = rect->w; 89 /* Set up the X/Y base coordinates */
89 dstH = rect->h; 90 dstW = rect->w;
90 FB_dst_to_xy(this, dst, &dstX, &dstY); 91 dstH = rect->h;
91 92 FB_dst_to_xy(this, dst, &dstX, &dstY);
92 /* Adjust for the current rectangle */ 93
93 dstX += rect->x; 94 /* Adjust for the current rectangle */
94 dstY += rect->y; 95 dstX += rect->x;
95 96 dstY += rect->y;
96 RIVA_FIFO_FREE(Bitmap, 1); 97
97 Bitmap->Color1A = color; 98 RIVA_FIFO_FREE(Bitmap, 1);
98 99 Bitmap->Color1A = color;
99 RIVA_FIFO_FREE(Bitmap, 2); 100
100 Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY; 101 RIVA_FIFO_FREE(Bitmap, 2);
101 Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH; 102 Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY;
102 103 Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;
103 FB_AddBusySurface(dst); 104
104 105 FB_AddBusySurface(dst);
105 if ( dst == this->screen ) { 106
106 SDL_mutexV(hw_lock); 107 if (dst == this->screen) {
107 } 108 SDL_mutexV(hw_lock);
108 return(0); 109 }
109 } 110 return (0);
110 111 }
111 static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, 112
112 SDL_Surface *dst, SDL_Rect *dstrect) 113 static int
113 { 114 HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
114 SDL_VideoDevice *this = current_video; 115 SDL_Surface * dst, SDL_Rect * dstrect)
115 int srcX, srcY; 116 {
116 int dstX, dstY; 117 SDL_VideoDevice *this = current_video;
117 int dstW, dstH; 118 int srcX, srcY;
118 RivaScreenBlt *Blt = (RivaScreenBlt *)(mapped_io + BLT_OFFSET); 119 int dstX, dstY;
119 120 int dstW, dstH;
120 /* FIXME: For now, only blit to display surface */ 121 RivaScreenBlt *Blt = (RivaScreenBlt *) (mapped_io + BLT_OFFSET);
121 if ( dst->pitch != SDL_VideoSurface->pitch ) { 122
122 return(src->map->sw_blit(src, srcrect, dst, dstrect)); 123 /* FIXME: For now, only blit to display surface */
123 } 124 if (dst->pitch != SDL_VideoSurface->pitch) {
124 125 return (src->map->sw_blit(src, srcrect, dst, dstrect));
125 /* Don't blit to the display surface when switched away */ 126 }
126 if ( switched_away ) { 127
127 return -2; /* no hardware access */ 128 /* Don't blit to the display surface when switched away */
128 } 129 if (switched_away) {
129 if ( dst == this->screen ) { 130 return -2; /* no hardware access */
130 SDL_mutexP(hw_lock); 131 }
131 } 132 if (dst == this->screen) {
132 133 SDL_mutexP(hw_lock);
133 /* Calculate source and destination base coordinates (in pixels) */ 134 }
134 dstW = dstrect->w; 135
135 dstH = dstrect->h; 136 /* Calculate source and destination base coordinates (in pixels) */
136 FB_dst_to_xy(this, src, &srcX, &srcY); 137 dstW = dstrect->w;
137 FB_dst_to_xy(this, dst, &dstX, &dstY); 138 dstH = dstrect->h;
138 139 FB_dst_to_xy(this, src, &srcX, &srcY);
139 /* Adjust for the current blit rectangles */ 140 FB_dst_to_xy(this, dst, &dstX, &dstY);
140 srcX += srcrect->x; 141
141 srcY += srcrect->y; 142 /* Adjust for the current blit rectangles */
142 dstX += dstrect->x; 143 srcX += srcrect->x;
143 dstY += dstrect->y; 144 srcY += srcrect->y;
144 145 dstX += dstrect->x;
145 RIVA_FIFO_FREE(Blt, 3); 146 dstY += dstrect->y;
146 Blt->TopLeftSrc = (srcY << 16) | srcX; 147
147 Blt->TopLeftDst = (dstY << 16) | dstX; 148 RIVA_FIFO_FREE(Blt, 3);
148 Blt->WidthHeight = (dstH << 16) | dstW; 149 Blt->TopLeftSrc = (srcY << 16) | srcX;
149 150 Blt->TopLeftDst = (dstY << 16) | dstX;
150 FB_AddBusySurface(src); 151 Blt->WidthHeight = (dstH << 16) | dstW;
151 FB_AddBusySurface(dst); 152
152 153 FB_AddBusySurface(src);
153 if ( dst == this->screen ) { 154 FB_AddBusySurface(dst);
154 SDL_mutexV(hw_lock); 155
155 } 156 if (dst == this->screen) {
156 return(0); 157 SDL_mutexV(hw_lock);
157 } 158 }
158 159 return (0);
159 static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst) 160 }
160 { 161
161 int accelerated; 162 static int
162 163 CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
163 /* Set initial acceleration on */ 164 {
164 src->flags |= SDL_HWACCEL; 165 int accelerated;
165 166
166 /* Set the surface attributes */ 167 /* Set initial acceleration on */
167 if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 168 src->flags |= SDL_HWACCEL;
168 if ( ! this->info.blit_hw_A ) { 169
169 src->flags &= ~SDL_HWACCEL; 170 /* Set the surface attributes */
170 } 171 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
171 } 172 if (!this->info.blit_hw_A) {
172 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { 173 src->flags &= ~SDL_HWACCEL;
173 if ( ! this->info.blit_hw_CC ) { 174 }
174 src->flags &= ~SDL_HWACCEL; 175 }
175 } 176 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
176 } 177 if (!this->info.blit_hw_CC) {
177 178 src->flags &= ~SDL_HWACCEL;
178 /* Check to see if final surface blit is accelerated */ 179 }
179 accelerated = !!(src->flags & SDL_HWACCEL); 180 }
180 if ( accelerated ) { 181
181 src->map->hw_blit = HWAccelBlit; 182 /* Check to see if final surface blit is accelerated */
182 } 183 accelerated = !!(src->flags & SDL_HWACCEL);
183 return(accelerated); 184 if (accelerated) {
184 } 185 src->map->hw_blit = HWAccelBlit;
185 186 }
186 void FB_RivaAccel(_THIS, __u32 card) 187 return (accelerated);
187 { 188 }
188 RivaRop *Rop = (RivaRop *)(mapped_io + ROP_OFFSET); 189
189 190 void
190 /* We have hardware accelerated surface functions */ 191 FB_RivaAccel(_THIS, __u32 card)
191 this->CheckHWBlit = CheckHWBlit; 192 {
192 wait_vbl = WaitVBL; 193 RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
193 switch (card) { 194
194 case FB_ACCEL_NV3: 195 /* We have hardware accelerated surface functions */
195 wait_idle = NV3WaitIdle; 196 this->CheckHWBlit = CheckHWBlit;
196 break; 197 wait_vbl = WaitVBL;
197 case FB_ACCEL_NV4: 198 switch (card) {
198 wait_idle = NV4WaitIdle; 199 case FB_ACCEL_NV3:
199 break; 200 wait_idle = NV3WaitIdle;
200 default: 201 break;
201 /* Hmm... FIXME */ 202 case FB_ACCEL_NV4:
202 break; 203 wait_idle = NV4WaitIdle;
203 } 204 break;
204 FifoEmptyCount = Rop->FifoFree; 205 default:
205 206 /* Hmm... FIXME */
206 /* The Riva has an accelerated color fill */ 207 break;
207 this->info.blit_fill = 1; 208 }
208 this->FillHWRect = FillHWRect; 209 FifoEmptyCount = Rop->FifoFree;
209 210
210 /* The Riva has accelerated normal and colorkey blits. */ 211 /* The Riva has an accelerated color fill */
211 this->info.blit_hw = 1; 212 this->info.blit_fill = 1;
212 #if 0 /* Not yet implemented? */ 213 this->FillHWRect = FillHWRect;
213 this->info.blit_hw_CC = 1; 214
214 this->SetHWColorKey = SetHWColorKey; 215 /* The Riva has accelerated normal and colorkey blits. */
216 this->info.blit_hw = 1;
217 #if 0 /* Not yet implemented? */
218 this->info.blit_hw_CC = 1;
219 this->SetHWColorKey = SetHWColorKey;
215 #endif 220 #endif
216 221
217 #if 0 /* Not yet implemented? */ 222 #if 0 /* Not yet implemented? */
218 /* The Riva has an accelerated alpha blit */ 223 /* The Riva has an accelerated alpha blit */
219 this->info.blit_hw_A = 1; 224 this->info.blit_hw_A = 1;
220 this->SetHWAlpha = SetHWAlpha; 225 this->SetHWAlpha = SetHWAlpha;
221 #endif 226 #endif
222 } 227 }
228
229 /* vi: set ts=4 sw=4 expandtab: */