Mercurial > sdl-ios-xcode
comparison src/video/fbcon/SDL_fbmatrox.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 |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
27 #include "matrox_mmio.h" | 27 #include "matrox_mmio.h" |
28 | 28 |
29 | 29 |
30 /* Wait for vertical retrace - taken from the XFree86 Matrox driver */ | 30 /* Wait for vertical retrace - taken from the XFree86 Matrox driver */ |
31 static void | 31 static void |
32 WaitVBL (_THIS) | 32 WaitVBL(_THIS) |
33 { | 33 { |
34 int count; | 34 int count; |
35 | 35 |
36 /* find start of retrace */ | 36 /* find start of retrace */ |
37 mga_waitidle (); | 37 mga_waitidle(); |
38 while ((mga_in8 (0x1FDA) & 0x08)); | 38 while ((mga_in8(0x1FDA) & 0x08)); |
39 while (!(mga_in8 (0x1FDA) & 0x08)); | 39 while (!(mga_in8(0x1FDA) & 0x08)); |
40 /* wait until we're past the start */ | 40 /* wait until we're past the start */ |
41 count = mga_in32 (0x1E20) + 2; | 41 count = mga_in32(0x1E20) + 2; |
42 while (mga_in32 (0x1E20) < count); | 42 while (mga_in32(0x1E20) < count); |
43 } | 43 } |
44 static void | 44 static void |
45 WaitIdle (_THIS) | 45 WaitIdle(_THIS) |
46 { | 46 { |
47 mga_waitidle (); | 47 mga_waitidle(); |
48 } | 48 } |
49 | 49 |
50 /* Sets video mem colorkey and accelerated blit function */ | 50 /* Sets video mem colorkey and accelerated blit function */ |
51 static int | 51 static int |
52 SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) | 52 SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) |
53 { | 53 { |
54 return (0); | 54 return (0); |
55 } | 55 } |
56 | 56 |
57 /* Sets per surface hardware alpha value */ | 57 /* Sets per surface hardware alpha value */ |
58 #if 0 | 58 #if 0 |
59 static int | 59 static int |
60 SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 value) | 60 SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value) |
61 { | 61 { |
62 return (0); | 62 return (0); |
63 } | 63 } |
64 #endif | 64 #endif |
65 | 65 |
66 static int | 66 static int |
67 FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) | 67 FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) |
68 { | 68 { |
69 int dstX, dstY; | 69 int dstX, dstY; |
70 Uint32 fxbndry; | 70 Uint32 fxbndry; |
71 Uint32 ydstlen; | 71 Uint32 ydstlen; |
72 Uint32 fillop; | 72 Uint32 fillop; |
74 /* Don't blit to the display surface when switched away */ | 74 /* Don't blit to the display surface when switched away */ |
75 if (switched_away) { | 75 if (switched_away) { |
76 return -2; /* no hardware access */ | 76 return -2; /* no hardware access */ |
77 } | 77 } |
78 if (dst == this->screen) { | 78 if (dst == this->screen) { |
79 SDL_mutexP (hw_lock); | 79 SDL_mutexP(hw_lock); |
80 } | 80 } |
81 | 81 |
82 switch (dst->format->BytesPerPixel) { | 82 switch (dst->format->BytesPerPixel) { |
83 case 1: | 83 case 1: |
84 color |= (color << 8); | 84 color |= (color << 8); |
86 color |= (color << 16); | 86 color |= (color << 16); |
87 break; | 87 break; |
88 } | 88 } |
89 | 89 |
90 /* Set up the X/Y base coordinates */ | 90 /* Set up the X/Y base coordinates */ |
91 FB_dst_to_xy (this, dst, &dstX, &dstY); | 91 FB_dst_to_xy(this, dst, &dstX, &dstY); |
92 | 92 |
93 /* Adjust for the current rectangle */ | 93 /* Adjust for the current rectangle */ |
94 dstX += rect->x; | 94 dstX += rect->x; |
95 dstY += rect->y; | 95 dstY += rect->y; |
96 | 96 |
103 /* Set up for color fill operation */ | 103 /* Set up for color fill operation */ |
104 fillop = MGADWG_TRAP | MGADWG_SOLID | | 104 fillop = MGADWG_TRAP | MGADWG_SOLID | |
105 MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO; | 105 MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO; |
106 | 106 |
107 /* Execute the operations! */ | 107 /* Execute the operations! */ |
108 mga_wait (5); | 108 mga_wait(5); |
109 mga_out32 (MGAREG_DWGCTL, fillop | MGADWG_REPLACE); | 109 mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE); |
110 mga_out32 (MGAREG_FCOL, color); | 110 mga_out32(MGAREG_FCOL, color); |
111 mga_out32 (MGAREG_FXBNDRY, fxbndry); | 111 mga_out32(MGAREG_FXBNDRY, fxbndry); |
112 mga_out32 (MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen); | 112 mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen); |
113 | 113 |
114 FB_AddBusySurface (dst); | 114 FB_AddBusySurface(dst); |
115 | 115 |
116 if (dst == this->screen) { | 116 if (dst == this->screen) { |
117 SDL_mutexV (hw_lock); | 117 SDL_mutexV(hw_lock); |
118 } | 118 } |
119 return (0); | 119 return (0); |
120 } | 120 } |
121 | 121 |
122 static int | 122 static int |
123 HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, | 123 HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, |
124 SDL_Surface * dst, SDL_Rect * dstrect) | 124 SDL_Surface * dst, SDL_Rect * dstrect) |
125 { | 125 { |
126 SDL_VideoDevice *this = current_video; | 126 SDL_VideoDevice *this = current_video; |
127 int pitch, w, h; | 127 int pitch, w, h; |
128 int srcX, srcY; | 128 int srcX, srcY; |
129 int dstX, dstY; | 129 int dstX, dstY; |
132 int skip; | 132 int skip; |
133 Uint32 blitop; | 133 Uint32 blitop; |
134 | 134 |
135 /* FIXME: For now, only blit to display surface */ | 135 /* FIXME: For now, only blit to display surface */ |
136 if (dst->pitch != SDL_VideoSurface->pitch) { | 136 if (dst->pitch != SDL_VideoSurface->pitch) { |
137 return (src->map->sw_blit (src, srcrect, dst, dstrect)); | 137 return (src->map->sw_blit(src, srcrect, dst, dstrect)); |
138 } | 138 } |
139 | 139 |
140 /* Don't blit to the display surface when switched away */ | 140 /* Don't blit to the display surface when switched away */ |
141 if (switched_away) { | 141 if (switched_away) { |
142 return -2; /* no hardware access */ | 142 return -2; /* no hardware access */ |
143 } | 143 } |
144 if (dst == this->screen) { | 144 if (dst == this->screen) { |
145 SDL_mutexP (hw_lock); | 145 SDL_mutexP(hw_lock); |
146 } | 146 } |
147 | 147 |
148 /* Calculate source and destination base coordinates (in pixels) */ | 148 /* Calculate source and destination base coordinates (in pixels) */ |
149 w = dstrect->w; | 149 w = dstrect->w; |
150 h = dstrect->h; | 150 h = dstrect->h; |
151 FB_dst_to_xy (this, src, &srcX, &srcY); | 151 FB_dst_to_xy(this, src, &srcX, &srcY); |
152 FB_dst_to_xy (this, dst, &dstX, &dstY); | 152 FB_dst_to_xy(this, dst, &dstX, &dstY); |
153 | 153 |
154 /* Adjust for the current blit rectangles */ | 154 /* Adjust for the current blit rectangles */ |
155 srcX += srcrect->x; | 155 srcX += srcrect->x; |
156 srcY += srcrect->y; | 156 srcY += srcrect->y; |
157 dstX += dstrect->x; | 157 dstX += dstrect->x; |
195 colorkey |= (colorkey << 8); | 195 colorkey |= (colorkey << 8); |
196 case 2: | 196 case 2: |
197 colorkey |= (colorkey << 16); | 197 colorkey |= (colorkey << 16); |
198 break; | 198 break; |
199 } | 199 } |
200 mga_wait (2); | 200 mga_wait(2); |
201 mga_out32 (MGAREG_FCOL, colorkey); | 201 mga_out32(MGAREG_FCOL, colorkey); |
202 mga_out32 (MGAREG_BCOL, 0xFFFFFFFF); | 202 mga_out32(MGAREG_BCOL, 0xFFFFFFFF); |
203 } else { | 203 } else { |
204 blitop = MGADWG_BFCOL | MGADWG_BITBLT | | 204 blitop = MGADWG_BFCOL | MGADWG_BITBLT | |
205 MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16); | 205 MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16); |
206 } | 206 } |
207 mga_wait (7); | 207 mga_wait(7); |
208 mga_out32 (MGAREG_SGN, sign); | 208 mga_out32(MGAREG_SGN, sign); |
209 mga_out32 (MGAREG_AR3, start); | 209 mga_out32(MGAREG_AR3, start); |
210 mga_out32 (MGAREG_AR0, stop); | 210 mga_out32(MGAREG_AR0, stop); |
211 mga_out32 (MGAREG_AR5, skip); | 211 mga_out32(MGAREG_AR5, skip); |
212 mga_out32 (MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16))); | 212 mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16))); |
213 mga_out32 (MGAREG_YDSTLEN, (dstY << 16) | h); | 213 mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h); |
214 mga_out32 (MGAREG_DWGCTL + MGAREG_EXEC, blitop); | 214 mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop); |
215 | 215 |
216 FB_AddBusySurface (src); | 216 FB_AddBusySurface(src); |
217 FB_AddBusySurface (dst); | 217 FB_AddBusySurface(dst); |
218 | 218 |
219 if (dst == this->screen) { | 219 if (dst == this->screen) { |
220 SDL_mutexV (hw_lock); | 220 SDL_mutexV(hw_lock); |
221 } | 221 } |
222 return (0); | 222 return (0); |
223 } | 223 } |
224 | 224 |
225 static int | 225 static int |
226 CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) | 226 CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) |
227 { | 227 { |
228 int accelerated; | 228 int accelerated; |
229 | 229 |
230 /* Set initial acceleration on */ | 230 /* Set initial acceleration on */ |
231 src->flags |= SDL_HWACCEL; | 231 src->flags |= SDL_HWACCEL; |
249 } | 249 } |
250 return (accelerated); | 250 return (accelerated); |
251 } | 251 } |
252 | 252 |
253 void | 253 void |
254 FB_MatroxAccel (_THIS, __u32 card) | 254 FB_MatroxAccel(_THIS, __u32 card) |
255 { | 255 { |
256 /* We have hardware accelerated surface functions */ | 256 /* We have hardware accelerated surface functions */ |
257 this->CheckHWBlit = CheckHWBlit; | 257 this->CheckHWBlit = CheckHWBlit; |
258 wait_vbl = WaitVBL; | 258 wait_vbl = WaitVBL; |
259 wait_idle = WaitIdle; | 259 wait_idle = WaitIdle; |