aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/matrox/matroxfb_accel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/matrox/matroxfb_accel.c')
-rw-r--r--drivers/video/matrox/matroxfb_accel.c129
1 files changed, 70 insertions, 59 deletions
diff --git a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c
index 9c3aeee1cc4f..8335a6fe303e 100644
--- a/drivers/video/matrox/matroxfb_accel.c
+++ b/drivers/video/matrox/matroxfb_accel.c
@@ -81,7 +81,7 @@
81#include "matroxfb_Ti3026.h" 81#include "matroxfb_Ti3026.h"
82#include "matroxfb_misc.h" 82#include "matroxfb_misc.h"
83 83
84#define curr_ydstorg(x) ACCESS_FBINFO2(x, curr.ydstorg.pixels) 84#define curr_ydstorg(x) ((x)->curr.ydstorg.pixels)
85 85
86#define mga_ydstlen(y,l) mga_outl(M_YDSTLEN | M_EXEC, ((y) << 16) | (l)) 86#define mga_ydstlen(y,l) mga_outl(M_YDSTLEN | M_EXEC, ((y) << 16) | (l))
87 87
@@ -107,7 +107,8 @@ static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* imag
107static void matroxfb_cfb4_fillrect(struct fb_info* info, const struct fb_fillrect* rect); 107static void matroxfb_cfb4_fillrect(struct fb_info* info, const struct fb_fillrect* rect);
108static void matroxfb_cfb4_copyarea(struct fb_info* info, const struct fb_copyarea* area); 108static void matroxfb_cfb4_copyarea(struct fb_info* info, const struct fb_copyarea* area);
109 109
110void matrox_cfbX_init(WPMINFO2) { 110void matrox_cfbX_init(struct matrox_fb_info *minfo)
111{
111 u_int32_t maccess; 112 u_int32_t maccess;
112 u_int32_t mpitch; 113 u_int32_t mpitch;
113 u_int32_t mopmode; 114 u_int32_t mopmode;
@@ -115,59 +116,59 @@ void matrox_cfbX_init(WPMINFO2) {
115 116
116 DBG(__func__) 117 DBG(__func__)
117 118
118 mpitch = ACCESS_FBINFO(fbcon).var.xres_virtual; 119 mpitch = minfo->fbcon.var.xres_virtual;
119 120
120 ACCESS_FBINFO(fbops).fb_copyarea = cfb_copyarea; 121 minfo->fbops.fb_copyarea = cfb_copyarea;
121 ACCESS_FBINFO(fbops).fb_fillrect = cfb_fillrect; 122 minfo->fbops.fb_fillrect = cfb_fillrect;
122 ACCESS_FBINFO(fbops).fb_imageblit = cfb_imageblit; 123 minfo->fbops.fb_imageblit = cfb_imageblit;
123 ACCESS_FBINFO(fbops).fb_cursor = NULL; 124 minfo->fbops.fb_cursor = NULL;
124 125
125 accel = (ACCESS_FBINFO(fbcon).var.accel_flags & FB_ACCELF_TEXT) == FB_ACCELF_TEXT; 126 accel = (minfo->fbcon.var.accel_flags & FB_ACCELF_TEXT) == FB_ACCELF_TEXT;
126 127
127 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) { 128 switch (minfo->fbcon.var.bits_per_pixel) {
128 case 4: maccess = 0x00000000; /* accelerate as 8bpp video */ 129 case 4: maccess = 0x00000000; /* accelerate as 8bpp video */
129 mpitch = (mpitch >> 1) | 0x8000; /* disable linearization */ 130 mpitch = (mpitch >> 1) | 0x8000; /* disable linearization */
130 mopmode = M_OPMODE_4BPP; 131 mopmode = M_OPMODE_4BPP;
131 matrox_cfb4_pal(ACCESS_FBINFO(cmap)); 132 matrox_cfb4_pal(minfo->cmap);
132 if (accel && !(mpitch & 1)) { 133 if (accel && !(mpitch & 1)) {
133 ACCESS_FBINFO(fbops).fb_copyarea = matroxfb_cfb4_copyarea; 134 minfo->fbops.fb_copyarea = matroxfb_cfb4_copyarea;
134 ACCESS_FBINFO(fbops).fb_fillrect = matroxfb_cfb4_fillrect; 135 minfo->fbops.fb_fillrect = matroxfb_cfb4_fillrect;
135 } 136 }
136 break; 137 break;
137 case 8: maccess = 0x00000000; 138 case 8: maccess = 0x00000000;
138 mopmode = M_OPMODE_8BPP; 139 mopmode = M_OPMODE_8BPP;
139 matrox_cfb8_pal(ACCESS_FBINFO(cmap)); 140 matrox_cfb8_pal(minfo->cmap);
140 if (accel) { 141 if (accel) {
141 ACCESS_FBINFO(fbops).fb_copyarea = matroxfb_copyarea; 142 minfo->fbops.fb_copyarea = matroxfb_copyarea;
142 ACCESS_FBINFO(fbops).fb_fillrect = matroxfb_fillrect; 143 minfo->fbops.fb_fillrect = matroxfb_fillrect;
143 ACCESS_FBINFO(fbops).fb_imageblit = matroxfb_imageblit; 144 minfo->fbops.fb_imageblit = matroxfb_imageblit;
144 } 145 }
145 break; 146 break;
146 case 16: if (ACCESS_FBINFO(fbcon).var.green.length == 5) 147 case 16: if (minfo->fbcon.var.green.length == 5)
147 maccess = 0xC0000001; 148 maccess = 0xC0000001;
148 else 149 else
149 maccess = 0x40000001; 150 maccess = 0x40000001;
150 mopmode = M_OPMODE_16BPP; 151 mopmode = M_OPMODE_16BPP;
151 if (accel) { 152 if (accel) {
152 ACCESS_FBINFO(fbops).fb_copyarea = matroxfb_copyarea; 153 minfo->fbops.fb_copyarea = matroxfb_copyarea;
153 ACCESS_FBINFO(fbops).fb_fillrect = matroxfb_fillrect; 154 minfo->fbops.fb_fillrect = matroxfb_fillrect;
154 ACCESS_FBINFO(fbops).fb_imageblit = matroxfb_imageblit; 155 minfo->fbops.fb_imageblit = matroxfb_imageblit;
155 } 156 }
156 break; 157 break;
157 case 24: maccess = 0x00000003; 158 case 24: maccess = 0x00000003;
158 mopmode = M_OPMODE_24BPP; 159 mopmode = M_OPMODE_24BPP;
159 if (accel) { 160 if (accel) {
160 ACCESS_FBINFO(fbops).fb_copyarea = matroxfb_copyarea; 161 minfo->fbops.fb_copyarea = matroxfb_copyarea;
161 ACCESS_FBINFO(fbops).fb_fillrect = matroxfb_fillrect; 162 minfo->fbops.fb_fillrect = matroxfb_fillrect;
162 ACCESS_FBINFO(fbops).fb_imageblit = matroxfb_imageblit; 163 minfo->fbops.fb_imageblit = matroxfb_imageblit;
163 } 164 }
164 break; 165 break;
165 case 32: maccess = 0x00000002; 166 case 32: maccess = 0x00000002;
166 mopmode = M_OPMODE_32BPP; 167 mopmode = M_OPMODE_32BPP;
167 if (accel) { 168 if (accel) {
168 ACCESS_FBINFO(fbops).fb_copyarea = matroxfb_copyarea; 169 minfo->fbops.fb_copyarea = matroxfb_copyarea;
169 ACCESS_FBINFO(fbops).fb_fillrect = matroxfb_fillrect; 170 minfo->fbops.fb_fillrect = matroxfb_fillrect;
170 ACCESS_FBINFO(fbops).fb_imageblit = matroxfb_imageblit; 171 minfo->fbops.fb_imageblit = matroxfb_imageblit;
171 } 172 }
172 break; 173 break;
173 default: maccess = 0x00000000; 174 default: maccess = 0x00000000;
@@ -176,10 +177,10 @@ void matrox_cfbX_init(WPMINFO2) {
176 } 177 }
177 mga_fifo(8); 178 mga_fifo(8);
178 mga_outl(M_PITCH, mpitch); 179 mga_outl(M_PITCH, mpitch);
179 mga_outl(M_YDSTORG, curr_ydstorg(MINFO)); 180 mga_outl(M_YDSTORG, curr_ydstorg(minfo));
180 if (ACCESS_FBINFO(capable.plnwt)) 181 if (minfo->capable.plnwt)
181 mga_outl(M_PLNWT, -1); 182 mga_outl(M_PLNWT, -1);
182 if (ACCESS_FBINFO(capable.srcorg)) { 183 if (minfo->capable.srcorg) {
183 mga_outl(M_SRCORG, 0); 184 mga_outl(M_SRCORG, 0);
184 mga_outl(M_DSTORG, 0); 185 mga_outl(M_DSTORG, 0);
185 } 186 }
@@ -188,14 +189,16 @@ void matrox_cfbX_init(WPMINFO2) {
188 mga_outl(M_YTOP, 0); 189 mga_outl(M_YTOP, 0);
189 mga_outl(M_YBOT, 0x01FFFFFF); 190 mga_outl(M_YBOT, 0x01FFFFFF);
190 mga_outl(M_MACCESS, maccess); 191 mga_outl(M_MACCESS, maccess);
191 ACCESS_FBINFO(accel.m_dwg_rect) = M_DWG_TRAP | M_DWG_SOLID | M_DWG_ARZERO | M_DWG_SGNZERO | M_DWG_SHIFTZERO; 192 minfo->accel.m_dwg_rect = M_DWG_TRAP | M_DWG_SOLID | M_DWG_ARZERO | M_DWG_SGNZERO | M_DWG_SHIFTZERO;
192 if (isMilleniumII(MINFO)) ACCESS_FBINFO(accel.m_dwg_rect) |= M_DWG_TRANSC; 193 if (isMilleniumII(minfo)) minfo->accel.m_dwg_rect |= M_DWG_TRANSC;
193 ACCESS_FBINFO(accel.m_opmode) = mopmode; 194 minfo->accel.m_opmode = mopmode;
194} 195}
195 196
196EXPORT_SYMBOL(matrox_cfbX_init); 197EXPORT_SYMBOL(matrox_cfbX_init);
197 198
198static void matrox_accel_bmove(WPMINFO int vxres, int sy, int sx, int dy, int dx, int height, int width) { 199static void matrox_accel_bmove(struct matrox_fb_info *minfo, int vxres, int sy,
200 int sx, int dy, int dx, int height, int width)
201{
199 int start, end; 202 int start, end;
200 CRITFLAGS 203 CRITFLAGS
201 204
@@ -209,7 +212,7 @@ static void matrox_accel_bmove(WPMINFO int vxres, int sy, int sx, int dy, int dx
209 M_DWG_BFCOL | M_DWG_REPLACE); 212 M_DWG_BFCOL | M_DWG_REPLACE);
210 mga_outl(M_AR5, vxres); 213 mga_outl(M_AR5, vxres);
211 width--; 214 width--;
212 start = sy*vxres+sx+curr_ydstorg(MINFO); 215 start = sy*vxres+sx+curr_ydstorg(minfo);
213 end = start+width; 216 end = start+width;
214 } else { 217 } else {
215 mga_fifo(3); 218 mga_fifo(3);
@@ -217,7 +220,7 @@ static void matrox_accel_bmove(WPMINFO int vxres, int sy, int sx, int dy, int dx
217 mga_outl(M_SGN, 5); 220 mga_outl(M_SGN, 5);
218 mga_outl(M_AR5, -vxres); 221 mga_outl(M_AR5, -vxres);
219 width--; 222 width--;
220 end = (sy+height-1)*vxres+sx+curr_ydstorg(MINFO); 223 end = (sy+height-1)*vxres+sx+curr_ydstorg(minfo);
221 start = end+width; 224 start = end+width;
222 dy += height-1; 225 dy += height-1;
223 } 226 }
@@ -231,7 +234,10 @@ static void matrox_accel_bmove(WPMINFO int vxres, int sy, int sx, int dy, int dx
231 CRITEND 234 CRITEND
232} 235}
233 236
234static void matrox_accel_bmove_lin(WPMINFO int vxres, int sy, int sx, int dy, int dx, int height, int width) { 237static void matrox_accel_bmove_lin(struct matrox_fb_info *minfo, int vxres,
238 int sy, int sx, int dy, int dx, int height,
239 int width)
240{
235 int start, end; 241 int start, end;
236 CRITFLAGS 242 CRITFLAGS
237 243
@@ -245,7 +251,7 @@ static void matrox_accel_bmove_lin(WPMINFO int vxres, int sy, int sx, int dy, in
245 M_DWG_BFCOL | M_DWG_REPLACE); 251 M_DWG_BFCOL | M_DWG_REPLACE);
246 mga_outl(M_AR5, vxres); 252 mga_outl(M_AR5, vxres);
247 width--; 253 width--;
248 start = sy*vxres+sx+curr_ydstorg(MINFO); 254 start = sy*vxres+sx+curr_ydstorg(minfo);
249 end = start+width; 255 end = start+width;
250 } else { 256 } else {
251 mga_fifo(3); 257 mga_fifo(3);
@@ -253,7 +259,7 @@ static void matrox_accel_bmove_lin(WPMINFO int vxres, int sy, int sx, int dy, in
253 mga_outl(M_SGN, 5); 259 mga_outl(M_SGN, 5);
254 mga_outl(M_AR5, -vxres); 260 mga_outl(M_AR5, -vxres);
255 width--; 261 width--;
256 end = (sy+height-1)*vxres+sx+curr_ydstorg(MINFO); 262 end = (sy+height-1)*vxres+sx+curr_ydstorg(minfo);
257 start = end+width; 263 start = end+width;
258 dy += height-1; 264 dy += height-1;
259 } 265 }
@@ -269,22 +275,23 @@ static void matrox_accel_bmove_lin(WPMINFO int vxres, int sy, int sx, int dy, in
269} 275}
270 276
271static void matroxfb_cfb4_copyarea(struct fb_info* info, const struct fb_copyarea* area) { 277static void matroxfb_cfb4_copyarea(struct fb_info* info, const struct fb_copyarea* area) {
272 MINFO_FROM_INFO(info); 278 struct matrox_fb_info *minfo = info2minfo(info);
273 279
274 if ((area->sx | area->dx | area->width) & 1) 280 if ((area->sx | area->dx | area->width) & 1)
275 cfb_copyarea(info, area); 281 cfb_copyarea(info, area);
276 else 282 else
277 matrox_accel_bmove_lin(PMINFO ACCESS_FBINFO(fbcon.var.xres_virtual) >> 1, area->sy, area->sx >> 1, area->dy, area->dx >> 1, area->height, area->width >> 1); 283 matrox_accel_bmove_lin(minfo, minfo->fbcon.var.xres_virtual >> 1, area->sy, area->sx >> 1, area->dy, area->dx >> 1, area->height, area->width >> 1);
278} 284}
279 285
280static void matroxfb_copyarea(struct fb_info* info, const struct fb_copyarea* area) { 286static void matroxfb_copyarea(struct fb_info* info, const struct fb_copyarea* area) {
281 MINFO_FROM_INFO(info); 287 struct matrox_fb_info *minfo = info2minfo(info);
282 288
283 matrox_accel_bmove(PMINFO ACCESS_FBINFO(fbcon.var.xres_virtual), area->sy, area->sx, area->dy, area->dx, area->height, area->width); 289 matrox_accel_bmove(minfo, minfo->fbcon.var.xres_virtual, area->sy, area->sx, area->dy, area->dx, area->height, area->width);
284} 290}
285 291
286static void matroxfb_accel_clear(WPMINFO u_int32_t color, int sy, int sx, int height, 292static void matroxfb_accel_clear(struct matrox_fb_info *minfo, u_int32_t color,
287 int width) { 293 int sy, int sx, int height, int width)
294{
288 CRITFLAGS 295 CRITFLAGS
289 296
290 DBG(__func__) 297 DBG(__func__)
@@ -292,7 +299,7 @@ static void matroxfb_accel_clear(WPMINFO u_int32_t color, int sy, int sx, int he
292 CRITBEGIN 299 CRITBEGIN
293 300
294 mga_fifo(5); 301 mga_fifo(5);
295 mga_outl(M_DWGCTL, ACCESS_FBINFO(accel.m_dwg_rect) | M_DWG_REPLACE); 302 mga_outl(M_DWGCTL, minfo->accel.m_dwg_rect | M_DWG_REPLACE);
296 mga_outl(M_FCOL, color); 303 mga_outl(M_FCOL, color);
297 mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx); 304 mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx);
298 mga_ydstlen(sy, height); 305 mga_ydstlen(sy, height);
@@ -302,16 +309,18 @@ static void matroxfb_accel_clear(WPMINFO u_int32_t color, int sy, int sx, int he
302} 309}
303 310
304static void matroxfb_fillrect(struct fb_info* info, const struct fb_fillrect* rect) { 311static void matroxfb_fillrect(struct fb_info* info, const struct fb_fillrect* rect) {
305 MINFO_FROM_INFO(info); 312 struct matrox_fb_info *minfo = info2minfo(info);
306 313
307 switch (rect->rop) { 314 switch (rect->rop) {
308 case ROP_COPY: 315 case ROP_COPY:
309 matroxfb_accel_clear(PMINFO ((u_int32_t*)info->pseudo_palette)[rect->color], rect->dy, rect->dx, rect->height, rect->width); 316 matroxfb_accel_clear(minfo, ((u_int32_t *)info->pseudo_palette)[rect->color], rect->dy, rect->dx, rect->height, rect->width);
310 break; 317 break;
311 } 318 }
312} 319}
313 320
314static void matroxfb_cfb4_clear(WPMINFO u_int32_t bgx, int sy, int sx, int height, int width) { 321static void matroxfb_cfb4_clear(struct matrox_fb_info *minfo, u_int32_t bgx,
322 int sy, int sx, int height, int width)
323{
315 int whattodo; 324 int whattodo;
316 CRITFLAGS 325 CRITFLAGS
317 326
@@ -333,16 +342,16 @@ static void matroxfb_cfb4_clear(WPMINFO u_int32_t bgx, int sy, int sx, int heigh
333 sx >>= 1; 342 sx >>= 1;
334 if (width) { 343 if (width) {
335 mga_fifo(5); 344 mga_fifo(5);
336 mga_outl(M_DWGCTL, ACCESS_FBINFO(accel.m_dwg_rect) | M_DWG_REPLACE2); 345 mga_outl(M_DWGCTL, minfo->accel.m_dwg_rect | M_DWG_REPLACE2);
337 mga_outl(M_FCOL, bgx); 346 mga_outl(M_FCOL, bgx);
338 mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx); 347 mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx);
339 mga_outl(M_YDST, sy * ACCESS_FBINFO(fbcon).var.xres_virtual >> 6); 348 mga_outl(M_YDST, sy * minfo->fbcon.var.xres_virtual >> 6);
340 mga_outl(M_LEN | M_EXEC, height); 349 mga_outl(M_LEN | M_EXEC, height);
341 WaitTillIdle(); 350 WaitTillIdle();
342 } 351 }
343 if (whattodo) { 352 if (whattodo) {
344 u_int32_t step = ACCESS_FBINFO(fbcon).var.xres_virtual >> 1; 353 u_int32_t step = minfo->fbcon.var.xres_virtual >> 1;
345 vaddr_t vbase = ACCESS_FBINFO(video.vbase); 354 vaddr_t vbase = minfo->video.vbase;
346 if (whattodo & 1) { 355 if (whattodo & 1) {
347 unsigned int uaddr = sy * step + sx - 1; 356 unsigned int uaddr = sy * step + sx - 1;
348 u_int32_t loop; 357 u_int32_t loop;
@@ -367,17 +376,19 @@ static void matroxfb_cfb4_clear(WPMINFO u_int32_t bgx, int sy, int sx, int heigh
367} 376}
368 377
369static void matroxfb_cfb4_fillrect(struct fb_info* info, const struct fb_fillrect* rect) { 378static void matroxfb_cfb4_fillrect(struct fb_info* info, const struct fb_fillrect* rect) {
370 MINFO_FROM_INFO(info); 379 struct matrox_fb_info *minfo = info2minfo(info);
371 380
372 switch (rect->rop) { 381 switch (rect->rop) {
373 case ROP_COPY: 382 case ROP_COPY:
374 matroxfb_cfb4_clear(PMINFO ((u_int32_t*)info->pseudo_palette)[rect->color], rect->dy, rect->dx, rect->height, rect->width); 383 matroxfb_cfb4_clear(minfo, ((u_int32_t *)info->pseudo_palette)[rect->color], rect->dy, rect->dx, rect->height, rect->width);
375 break; 384 break;
376 } 385 }
377} 386}
378 387
379static void matroxfb_1bpp_imageblit(WPMINFO u_int32_t fgx, u_int32_t bgx, 388static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx,
380 const u_int8_t* chardata, int width, int height, int yy, int xx) { 389 u_int32_t bgx, const u_int8_t *chardata,
390 int width, int height, int yy, int xx)
391{
381 u_int32_t step; 392 u_int32_t step;
382 u_int32_t ydstlen; 393 u_int32_t ydstlen;
383 u_int32_t xlen; 394 u_int32_t xlen;
@@ -412,7 +423,7 @@ static void matroxfb_1bpp_imageblit(WPMINFO u_int32_t fgx, u_int32_t bgx,
412 mga_outl(M_FCOL, fgx); 423 mga_outl(M_FCOL, fgx);
413 mga_outl(M_BCOL, bgx); 424 mga_outl(M_BCOL, bgx);
414 fxbndry = ((xx + width - 1) << 16) | xx; 425 fxbndry = ((xx + width - 1) << 16) | xx;
415 mmio = ACCESS_FBINFO(mmio.vbase); 426 mmio = minfo->mmio.vbase;
416 427
417 mga_fifo(6); 428 mga_fifo(6);
418 mga_writel(mmio, M_FXBNDRY, fxbndry); 429 mga_writel(mmio, M_FXBNDRY, fxbndry);
@@ -467,7 +478,7 @@ static void matroxfb_1bpp_imageblit(WPMINFO u_int32_t fgx, u_int32_t bgx,
467 478
468 479
469static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) { 480static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) {
470 MINFO_FROM_INFO(info); 481 struct matrox_fb_info *minfo = info2minfo(info);
471 482
472 DBG_HEAVY(__func__); 483 DBG_HEAVY(__func__);
473 484
@@ -476,7 +487,7 @@ static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* imag
476 487
477 fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color]; 488 fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color];
478 bgx = ((u_int32_t*)info->pseudo_palette)[image->bg_color]; 489 bgx = ((u_int32_t*)info->pseudo_palette)[image->bg_color];
479 matroxfb_1bpp_imageblit(PMINFO fgx, bgx, image->data, image->width, image->height, image->dy, image->dx); 490 matroxfb_1bpp_imageblit(minfo, fgx, bgx, image->data, image->width, image->height, image->dy, image->dx);
480 } else { 491 } else {
481 /* Danger! image->depth is useless: logo painting code always 492 /* Danger! image->depth is useless: logo painting code always
482 passes framebuffer color depth here, although logo data are 493 passes framebuffer color depth here, although logo data are