aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/pm3fb.c
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2007-10-16 04:28:32 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:14 -0400
commit0ddf78491ddad301ddcd151de8108146e20398e7 (patch)
treec6547eba4e9539fa4aa24aa85c60ff00b8fb35c7 /drivers/video/pm3fb.c
parentc79ba28cc0c55d1539a4b29d32c3620460a5ee52 (diff)
pm3fb: improvements and cleanups
This patch contains improvements: - it adds ROP_XOR in pm3fb_fillrect() - it conforms closer to coding style - it removes redundant parentheses and setting bits with 0 value - it checks if hardware acceleration is disabled in pm3fb_imageblit - it adds module description Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/pm3fb.c')
-rw-r--r--drivers/video/pm3fb.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index fb91b641aefe..88af0721f305 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -135,7 +135,7 @@ static void pm3fb_clear_colormap(struct pm3_par *par,
135 135
136} 136}
137 137
138/* Calculating various clock parameter */ 138/* Calculating various clock parameters */
139static void pm3fb_calculate_clock(unsigned long reqclock, 139static void pm3fb_calculate_clock(unsigned long reqclock,
140 unsigned char *prescale, 140 unsigned char *prescale,
141 unsigned char *feedback, 141 unsigned char *feedback,
@@ -166,7 +166,7 @@ static void pm3fb_calculate_clock(unsigned long reqclock,
166 166
167static inline int pm3fb_depth(const struct fb_var_screeninfo *var) 167static inline int pm3fb_depth(const struct fb_var_screeninfo *var)
168{ 168{
169 if ( var->bits_per_pixel == 16 ) 169 if (var->bits_per_pixel == 16)
170 return var->red.length + var->green.length 170 return var->red.length + var->green.length
171 + var->blue.length; 171 + var->blue.length;
172 172
@@ -351,7 +351,7 @@ static void pm3fb_init_engine(struct fb_info *info)
351 351
352 PM3_WRITE_REG(par, PM3dXDom, 0x0); 352 PM3_WRITE_REG(par, PM3dXDom, 0x0);
353 PM3_WRITE_REG(par, PM3dXSub, 0x0); 353 PM3_WRITE_REG(par, PM3dXSub, 0x0);
354 PM3_WRITE_REG(par, PM3dY, (1 << 16)); 354 PM3_WRITE_REG(par, PM3dY, 1 << 16);
355 PM3_WRITE_REG(par, PM3StartXDom, 0x0); 355 PM3_WRITE_REG(par, PM3StartXDom, 0x0);
356 PM3_WRITE_REG(par, PM3StartXSub, 0x0); 356 PM3_WRITE_REG(par, PM3StartXSub, 0x0);
357 PM3_WRITE_REG(par, PM3StartY, 0x0); 357 PM3_WRITE_REG(par, PM3StartY, 0x0);
@@ -372,16 +372,21 @@ static void pm3fb_fillrect (struct fb_info *info,
372 struct pm3_par *par = info->par; 372 struct pm3_par *par = info->par;
373 struct fb_fillrect modded; 373 struct fb_fillrect modded;
374 int vxres, vyres; 374 int vxres, vyres;
375 int rop;
375 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? 376 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ?
376 ((u32*)info->pseudo_palette)[region->color] : region->color; 377 ((u32*)info->pseudo_palette)[region->color] : region->color;
377 378
378 if (info->state != FBINFO_STATE_RUNNING) 379 if (info->state != FBINFO_STATE_RUNNING)
379 return; 380 return;
380 if ((info->flags & FBINFO_HWACCEL_DISABLED) || 381 if (info->flags & FBINFO_HWACCEL_DISABLED) {
381 region->rop != ROP_COPY ) {
382 cfb_fillrect(info, region); 382 cfb_fillrect(info, region);
383 return; 383 return;
384 } 384 }
385 if (region->rop == ROP_COPY )
386 rop = PM3Config2D_ForegroundROP(0x3); /* GXcopy */
387 else
388 rop = PM3Config2D_ForegroundROP(0x6) | /* GXxor */
389 PM3Config2D_FBDestReadEnable;
385 390
386 vxres = info->var.xres_virtual; 391 vxres = info->var.xres_virtual;
387 vyres = info->var.yres_virtual; 392 vyres = info->var.yres_virtual;
@@ -407,22 +412,22 @@ static void pm3fb_fillrect (struct fb_info *info,
407 PM3_WRITE_REG(par, PM3Config2D, 412 PM3_WRITE_REG(par, PM3Config2D,
408 PM3Config2D_UseConstantSource | 413 PM3Config2D_UseConstantSource |
409 PM3Config2D_ForegroundROPEnable | 414 PM3Config2D_ForegroundROPEnable |
410 (PM3Config2D_ForegroundROP(0x3)) | 415 rop |
411 PM3Config2D_FBWriteEnable); 416 PM3Config2D_FBWriteEnable);
412 417
413 PM3_WRITE_REG(par, PM3ForegroundColor, color); 418 PM3_WRITE_REG(par, PM3ForegroundColor, color);
414 419
415 PM3_WRITE_REG(par, PM3RectanglePosition, 420 PM3_WRITE_REG(par, PM3RectanglePosition,
416 (PM3RectanglePosition_XOffset(modded.dx)) | 421 PM3RectanglePosition_XOffset(modded.dx) |
417 (PM3RectanglePosition_YOffset(modded.dy))); 422 PM3RectanglePosition_YOffset(modded.dy));
418 423
419 PM3_WRITE_REG(par, PM3Render2D, 424 PM3_WRITE_REG(par, PM3Render2D,
420 PM3Render2D_XPositive | 425 PM3Render2D_XPositive |
421 PM3Render2D_YPositive | 426 PM3Render2D_YPositive |
422 PM3Render2D_Operation_Normal | 427 PM3Render2D_Operation_Normal |
423 PM3Render2D_SpanOperation | 428 PM3Render2D_SpanOperation |
424 (PM3Render2D_Width(modded.width)) | 429 PM3Render2D_Width(modded.width) |
425 (PM3Render2D_Height(modded.height))); 430 PM3Render2D_Height(modded.height));
426} 431}
427 432
428static void pm3fb_copyarea(struct fb_info *info, 433static void pm3fb_copyarea(struct fb_info *info,
@@ -470,7 +475,7 @@ static void pm3fb_copyarea(struct fb_info *info,
470 PM3Config2D_UserScissorEnable | 475 PM3Config2D_UserScissorEnable |
471 PM3Config2D_ForegroundROPEnable | 476 PM3Config2D_ForegroundROPEnable |
472 PM3Config2D_Blocking | 477 PM3Config2D_Blocking |
473 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ 478 PM3Config2D_ForegroundROP(0x3) | /* Ox3 is GXcopy */
474 PM3Config2D_FBWriteEnable); 479 PM3Config2D_FBWriteEnable);
475 480
476 PM3_WRITE_REG(par, PM3ScissorMinXY, 481 PM3_WRITE_REG(par, PM3ScissorMinXY,
@@ -484,8 +489,8 @@ static void pm3fb_copyarea(struct fb_info *info,
484 PM3FBSourceReadBufferOffset_YOffset(o_y)); 489 PM3FBSourceReadBufferOffset_YOffset(o_y));
485 490
486 PM3_WRITE_REG(par, PM3RectanglePosition, 491 PM3_WRITE_REG(par, PM3RectanglePosition,
487 (PM3RectanglePosition_XOffset(modded.dx - x_align)) | 492 PM3RectanglePosition_XOffset(modded.dx - x_align) |
488 (PM3RectanglePosition_YOffset(modded.dy))); 493 PM3RectanglePosition_YOffset(modded.dy));
489 494
490 PM3_WRITE_REG(par, PM3Render2D, 495 PM3_WRITE_REG(par, PM3Render2D,
491 ((modded.sx > modded.dx) ? PM3Render2D_XPositive : 0) | 496 ((modded.sx > modded.dx) ? PM3Render2D_XPositive : 0) |
@@ -493,8 +498,8 @@ static void pm3fb_copyarea(struct fb_info *info,
493 PM3Render2D_Operation_Normal | 498 PM3Render2D_Operation_Normal |
494 PM3Render2D_SpanOperation | 499 PM3Render2D_SpanOperation |
495 PM3Render2D_FBSourceReadEnable | 500 PM3Render2D_FBSourceReadEnable |
496 (PM3Render2D_Width(modded.width + x_align)) | 501 PM3Render2D_Width(modded.width + x_align) |
497 (PM3Render2D_Height(modded.height))); 502 PM3Render2D_Height(modded.height));
498} 503}
499 504
500static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image) 505static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image)
@@ -504,6 +509,12 @@ static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image)
504 u32 fgx, bgx; 509 u32 fgx, bgx;
505 const u32 *src = (const u32*)image->data; 510 const u32 *src = (const u32*)image->data;
506 511
512 if (info->state != FBINFO_STATE_RUNNING)
513 return;
514 if (info->flags & FBINFO_HWACCEL_DISABLED) {
515 cfb_imageblit(info, image);
516 return;
517 }
507 switch (info->fix.visual) { 518 switch (info->fix.visual) {
508 case FB_VISUAL_PSEUDOCOLOR: 519 case FB_VISUAL_PSEUDOCOLOR:
509 fgx = image->fg_color; 520 fgx = image->fg_color;
@@ -537,7 +548,7 @@ static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image)
537 PM3Config2D_UserScissorEnable | 548 PM3Config2D_UserScissorEnable |
538 PM3Config2D_UseConstantSource | 549 PM3Config2D_UseConstantSource |
539 PM3Config2D_ForegroundROPEnable | 550 PM3Config2D_ForegroundROPEnable |
540 (PM3Config2D_ForegroundROP(0x3)) | 551 PM3Config2D_ForegroundROP(0x3) |
541 PM3Config2D_OpaqueSpan | 552 PM3Config2D_OpaqueSpan |
542 PM3Config2D_FBWriteEnable); 553 PM3Config2D_FBWriteEnable);
543 PM3_WRITE_REG(par, PM3ScissorMinXY, 554 PM3_WRITE_REG(par, PM3ScissorMinXY,
@@ -546,15 +557,15 @@ static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image)
546 (((image->dy + image->height) & 0x0fff) << 16) | 557 (((image->dy + image->height) & 0x0fff) << 16) |
547 ((image->dx + image->width) & 0x0fff)); 558 ((image->dx + image->width) & 0x0fff));
548 PM3_WRITE_REG(par, PM3RectanglePosition, 559 PM3_WRITE_REG(par, PM3RectanglePosition,
549 (PM3RectanglePosition_XOffset(image->dx)) | 560 PM3RectanglePosition_XOffset(image->dx) |
550 (PM3RectanglePosition_YOffset(image->dy))); 561 PM3RectanglePosition_YOffset(image->dy));
551 PM3_WRITE_REG(par, PM3Render2D, 562 PM3_WRITE_REG(par, PM3Render2D,
552 PM3Render2D_XPositive | 563 PM3Render2D_XPositive |
553 PM3Render2D_YPositive | 564 PM3Render2D_YPositive |
554 PM3Render2D_Operation_SyncOnBitMask | 565 PM3Render2D_Operation_SyncOnBitMask |
555 PM3Render2D_SpanOperation | 566 PM3Render2D_SpanOperation |
556 (PM3Render2D_Width(image->width)) | 567 PM3Render2D_Width(image->width) |
557 (PM3Render2D_Height(image->height))); 568 PM3Render2D_Height(image->height));
558 569
559 570
560 while (height--) { 571 while (height--) {
@@ -783,7 +794,7 @@ static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
783 unsigned bpp = var->red.length + var->green.length 794 unsigned bpp = var->red.length + var->green.length
784 + var->blue.length + var->transp.length; 795 + var->blue.length + var->transp.length;
785 796
786 if ( bpp != var->bits_per_pixel ) { 797 if (bpp != var->bits_per_pixel) {
787 /* set predefined mode for bits_per_pixel settings */ 798 /* set predefined mode for bits_per_pixel settings */
788 799
789 switch(var->bits_per_pixel) { 800 switch(var->bits_per_pixel) {
@@ -838,7 +849,7 @@ static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
838 } 849 }
839 850
840 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */ 851 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */
841 lpitch = var->xres * ((var->bits_per_pixel + 7)>>3); 852 lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3);
842 853
843 if (var->xres < 200 || var->xres > 2048) { 854 if (var->xres < 200 || var->xres > 2048) {
844 DPRINTK("width not supported: %u\n", var->xres); 855 DPRINTK("width not supported: %u\n", var->xres);
@@ -890,15 +901,12 @@ static int pm3fb_set_par(struct fb_info *info)
890 901
891 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) 902 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
892 par->video |= PM3VideoControl_LINE_DOUBLE_ON; 903 par->video |= PM3VideoControl_LINE_DOUBLE_ON;
893 else
894 par->video |= PM3VideoControl_LINE_DOUBLE_OFF;
895 904
896 if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) 905 if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
897 par->video |= PM3VideoControl_ENABLE; 906 par->video |= PM3VideoControl_ENABLE;
898 else { 907 else
899 par->video &= ~PM3VideoControl_ENABLE;
900 DPRINTK("PM3Video disabled\n"); 908 DPRINTK("PM3Video disabled\n");
901 } 909
902 switch (bpp) { 910 switch (bpp) {
903 case 8: 911 case 8:
904 par->video |= PM3VideoControl_PIXELSIZE_8BIT; 912 par->video |= PM3VideoControl_PIXELSIZE_8BIT;
@@ -916,8 +924,7 @@ static int pm3fb_set_par(struct fb_info *info)
916 924
917 info->fix.visual = 925 info->fix.visual =
918 (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; 926 (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
919 info->fix.line_length = ((info->var.xres_virtual + 7) & ~7) 927 info->fix.line_length = ((info->var.xres_virtual + 7) >> 3) * bpp;
920 * bpp / 8;
921 928
922/* pm3fb_clear_memory(info, 0);*/ 929/* pm3fb_clear_memory(info, 0);*/
923 pm3fb_clear_colormap(par, 0, 0, 0); 930 pm3fb_clear_colormap(par, 0, 0, 0);
@@ -1035,7 +1042,7 @@ static int pm3fb_blank(int blank_mode, struct fb_info *info)
1035 video |= PM3VideoControl_ENABLE; 1042 video |= PM3VideoControl_ENABLE;
1036 break; 1043 break;
1037 case FB_BLANK_NORMAL: 1044 case FB_BLANK_NORMAL:
1038 video &= ~(PM3VideoControl_ENABLE); 1045 video &= ~PM3VideoControl_ENABLE;
1039 break; 1046 break;
1040 case FB_BLANK_HSYNC_SUSPEND: 1047 case FB_BLANK_HSYNC_SUSPEND:
1041 video &= ~(PM3VideoControl_HSYNC_MASK | 1048 video &= ~(PM3VideoControl_HSYNC_MASK |
@@ -1367,4 +1374,5 @@ static void __exit pm3fb_exit(void)
1367module_init(pm3fb_init); 1374module_init(pm3fb_init);
1368module_exit(pm3fb_exit); 1375module_exit(pm3fb_exit);
1369 1376
1377MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
1370MODULE_LICENSE("GPL"); 1378MODULE_LICENSE("GPL");