From daaeb6f8d3afdfa58ffeffb7ba168ccbd5969858 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Tue, 10 Jan 2006 20:48:04 -0500 Subject: [PATCH] [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 Signed-off-by: Kyle McMartin --- drivers/video/stifb.c | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c index 83cd76ca0265..3f050a770a15 100644 --- a/drivers/video/stifb.c +++ b/drivers/video/stifb.c @@ -3,7 +3,7 @@ * Low level Frame buffer driver for HP workstations with * STI (standard text interface) video firmware. * - * Copyright (C) 2001-2004 Helge Deller + * Copyright (C) 2001-2005 Helge Deller * Portions Copyright (C) 2001 Thomas Bogendoerfer * * Based on: @@ -78,6 +78,8 @@ #define NGLEDEVDEPROM_CRT_REGION 1 +#define NR_PALETTE 256 + typedef struct { __s32 video_config_reg; __s32 misc_video_start; @@ -107,7 +109,7 @@ struct stifb_info { ngle_rom_t ngle_rom; struct sti_struct *sti; int deviceSpecificConfig; - u32 pseudo_palette[256]; + u32 pseudo_palette[16]; }; static int __initdata stifb_bpp_pref[MAX_STI_ROMS]; @@ -347,10 +349,10 @@ ARTIST_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) #define IS_888_DEVICE(fb) \ (!(IS_24_DEVICE(fb))) -#define GET_FIFO_SLOTS(fb, cnt, numslots) \ -{ while (cnt < numslots) \ +#define GET_FIFO_SLOTS(fb, cnt, numslots) \ +{ while (cnt < numslots) \ cnt = READ_WORD(fb, REG_34); \ - cnt -= numslots; \ + cnt -= numslots; \ } #define IndexedDcd 0 /* Pixel data is indexed (pseudo) color */ @@ -990,7 +992,7 @@ stifb_setcolreg(u_int regno, u_int red, u_int green, struct stifb_info *fb = (struct stifb_info *) info; u32 color; - if (regno >= 256) /* no. of hw registers */ + if (regno >= NR_PALETTE) return 1; red >>= 8; @@ -1000,8 +1002,8 @@ stifb_setcolreg(u_int regno, u_int red, u_int green, DEBUG_OFF(); START_IMAGE_COLORMAP_ACCESS(fb); - - if (fb->info.var.grayscale) { + + if (unlikely(fb->info.var.grayscale)) { /* gray = 0.30*R + 0.59*G + 0.11*B */ color = ((red * 77) + (green * 151) + @@ -1012,17 +1014,17 @@ stifb_setcolreg(u_int regno, u_int red, u_int green, (blue)); } - if (info->var.bits_per_pixel == 32) { - ((u32 *)(info->pseudo_palette))[regno] = - (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset); - } else { - ((u32 *)(info->pseudo_palette))[regno] = regno; + if (fb->info.fix.visual == FB_VISUAL_DIRECTCOLOR) { + struct fb_var_screeninfo *var = &fb->info.var; + if (regno < 16) + ((u32 *)fb->info.pseudo_palette)[regno] = + regno << var->red.offset | + regno << var->green.offset | + regno << var->blue.offset; } WRITE_IMAGE_COLOR(fb, regno, color); - + if (fb->id == S9000_ID_HCRX) { NgleLutBltCtl lutBltCtl; @@ -1061,9 +1063,9 @@ stifb_blank(int blank_mode, struct fb_info *info) case S9000_ID_HCRX: HYPER_ENABLE_DISABLE_DISPLAY(fb, enable); break; - case S9000_ID_A1659A:; /* fall through */ - case S9000_ID_TIMBER:; - case CRX24_OVERLAY_PLANES:; + case S9000_ID_A1659A: /* fall through */ + case S9000_ID_TIMBER: + case CRX24_OVERLAY_PLANES: default: ENABLE_DISABLE_DISPLAY(fb, enable); break; @@ -1308,7 +1310,7 @@ stifb_init_fb(struct sti_struct *sti, int bpp_pref) break; case 32: fix->type = FB_TYPE_PACKED_PIXELS; - fix->visual = FB_VISUAL_TRUECOLOR; + fix->visual = FB_VISUAL_DIRECTCOLOR; var->red.length = var->green.length = var->blue.length = var->transp.length = 8; var->blue.offset = 0; var->green.offset = 8; @@ -1330,7 +1332,7 @@ stifb_init_fb(struct sti_struct *sti, int bpp_pref) info->pseudo_palette = &fb->pseudo_palette; /* This has to been done !!! */ - fb_alloc_cmap(&info->cmap, 256, 0); + fb_alloc_cmap(&info->cmap, NR_PALETTE, 0); stifb_init_display(fb); if (!request_mem_region(fix->smem_start, fix->smem_len, "stifb fb")) {