[PARISC] stifb: Fix framebuffer console at 32bpp

Fix stifb framebuffer console at 32bpp on a HCRX-24 card
by properly setting DIRECTCOLOR. Also a few nice cleanups
to the code.

Signed-off-by: Helge Deller <deller@parisc-linux.org>
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>

authored by

Helge Deller and committed by
Kyle McMartin
daaeb6f8 5d6d1640

+23 -21
+23 -21
drivers/video/stifb.c
··· 3 3 * Low level Frame buffer driver for HP workstations with 4 4 * STI (standard text interface) video firmware. 5 5 * 6 - * Copyright (C) 2001-2004 Helge Deller <deller@gmx.de> 6 + * Copyright (C) 2001-2005 Helge Deller <deller@gmx.de> 7 7 * Portions Copyright (C) 2001 Thomas Bogendoerfer <tsbogend@alpha.franken.de> 8 8 * 9 9 * Based on: ··· 78 78 79 79 #define NGLEDEVDEPROM_CRT_REGION 1 80 80 81 + #define NR_PALETTE 256 82 + 81 83 typedef struct { 82 84 __s32 video_config_reg; 83 85 __s32 misc_video_start; ··· 109 107 ngle_rom_t ngle_rom; 110 108 struct sti_struct *sti; 111 109 int deviceSpecificConfig; 112 - u32 pseudo_palette[256]; 110 + u32 pseudo_palette[16]; 113 111 }; 114 112 115 113 static int __initdata stifb_bpp_pref[MAX_STI_ROMS]; ··· 349 347 #define IS_888_DEVICE(fb) \ 350 348 (!(IS_24_DEVICE(fb))) 351 349 352 - #define GET_FIFO_SLOTS(fb, cnt, numslots) \ 353 - { while (cnt < numslots) \ 350 + #define GET_FIFO_SLOTS(fb, cnt, numslots) \ 351 + { while (cnt < numslots) \ 354 352 cnt = READ_WORD(fb, REG_34); \ 355 - cnt -= numslots; \ 353 + cnt -= numslots; \ 356 354 } 357 355 358 356 #define IndexedDcd 0 /* Pixel data is indexed (pseudo) color */ ··· 992 990 struct stifb_info *fb = (struct stifb_info *) info; 993 991 u32 color; 994 992 995 - if (regno >= 256) /* no. of hw registers */ 993 + if (regno >= NR_PALETTE) 996 994 return 1; 997 995 998 996 red >>= 8; ··· 1002 1000 DEBUG_OFF(); 1003 1001 1004 1002 START_IMAGE_COLORMAP_ACCESS(fb); 1005 - 1006 - if (fb->info.var.grayscale) { 1003 + 1004 + if (unlikely(fb->info.var.grayscale)) { 1007 1005 /* gray = 0.30*R + 0.59*G + 0.11*B */ 1008 1006 color = ((red * 77) + 1009 1007 (green * 151) + ··· 1014 1012 (blue)); 1015 1013 } 1016 1014 1017 - if (info->var.bits_per_pixel == 32) { 1018 - ((u32 *)(info->pseudo_palette))[regno] = 1019 - (red << info->var.red.offset) | 1020 - (green << info->var.green.offset) | 1021 - (blue << info->var.blue.offset); 1022 - } else { 1023 - ((u32 *)(info->pseudo_palette))[regno] = regno; 1015 + if (fb->info.fix.visual == FB_VISUAL_DIRECTCOLOR) { 1016 + struct fb_var_screeninfo *var = &fb->info.var; 1017 + if (regno < 16) 1018 + ((u32 *)fb->info.pseudo_palette)[regno] = 1019 + regno << var->red.offset | 1020 + regno << var->green.offset | 1021 + regno << var->blue.offset; 1024 1022 } 1025 1023 1026 1024 WRITE_IMAGE_COLOR(fb, regno, color); 1027 - 1025 + 1028 1026 if (fb->id == S9000_ID_HCRX) { 1029 1027 NgleLutBltCtl lutBltCtl; 1030 1028 ··· 1063 1061 case S9000_ID_HCRX: 1064 1062 HYPER_ENABLE_DISABLE_DISPLAY(fb, enable); 1065 1063 break; 1066 - case S9000_ID_A1659A:; /* fall through */ 1067 - case S9000_ID_TIMBER:; 1068 - case CRX24_OVERLAY_PLANES:; 1064 + case S9000_ID_A1659A: /* fall through */ 1065 + case S9000_ID_TIMBER: 1066 + case CRX24_OVERLAY_PLANES: 1069 1067 default: 1070 1068 ENABLE_DISABLE_DISPLAY(fb, enable); 1071 1069 break; ··· 1310 1308 break; 1311 1309 case 32: 1312 1310 fix->type = FB_TYPE_PACKED_PIXELS; 1313 - fix->visual = FB_VISUAL_TRUECOLOR; 1311 + fix->visual = FB_VISUAL_DIRECTCOLOR; 1314 1312 var->red.length = var->green.length = var->blue.length = var->transp.length = 8; 1315 1313 var->blue.offset = 0; 1316 1314 var->green.offset = 8; ··· 1332 1330 info->pseudo_palette = &fb->pseudo_palette; 1333 1331 1334 1332 /* This has to been done !!! */ 1335 - fb_alloc_cmap(&info->cmap, 256, 0); 1333 + fb_alloc_cmap(&info->cmap, NR_PALETTE, 0); 1336 1334 stifb_init_display(fb); 1337 1335 1338 1336 if (!request_mem_region(fix->smem_start, fix->smem_len, "stifb fb")) {