From: Paul M. <le...@us...> - 2002-06-27 21:13:10
|
Update of /cvsroot/linux-mips/linux/drivers/video In directory usw-pr-cvs1:/tmp/cvs-serv19440/drivers/video Modified Files: Config.in sfb.c Log Message: sfb rewrite part 1. get rid of all the platdep dependance, let platforms specify memory locations/sizes if they need to. also use the modedb for mode lookups. inverse/grayscale become boot options. support for obscure video modes to come later.. Index: Config.in =================================================================== RCS file: /cvsroot/linux-mips/linux/drivers/video/Config.in,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Config.in 18 Apr 2002 00:02:04 -0000 1.18 +++ Config.in 27 Jun 2002 21:13:06 -0000 1.19 @@ -113,7 +113,7 @@ hex ' Register Base Address' CONFIG_E1355_REG_BASE a8000000 hex ' Framebuffer Base Address' CONFIG_E1355_FB_BASE a8200000 fi - bool ' MediaQ Framebuffer support' CONFIG_FB_MQ200 + bool ' MediaQ Framebuffer support' CONFIG_FB_MQ200 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then if [ "$CONFIG_PCI" != "n" ]; then tristate ' Matrox acceleration (EXPERIMENTAL)' CONFIG_FB_MATROX @@ -165,6 +165,10 @@ fi tristate ' ITE IT8181 framebuffer support' CONFIG_FB_IT8181 tristate ' Simple Frame Buffer support' CONFIG_FB_SIMPLE + if [ "$CONFIG_FB_SIMPLE" != "n" ]; then + hex ' Video memory base address' CONFIG_FB_SIMPLE_MEMBASE a0000000 + hex ' Video memory size' CONFIG_FB_SIMPLE_MEMSIZE 0 + fi tristate ' Simple Frame Buffer with HPC device control (Experimental)' CONFIG_FB_HPCSFB fi if [ "$ARCH" = "sparc" -o "$ARCH" = "sparc64" ]; then Index: sfb.c =================================================================== RCS file: /cvsroot/linux-mips/linux/drivers/video/sfb.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sfb.c 7 Mar 2002 09:15:17 -0000 1.2 +++ sfb.c 27 Jun 2002 21:13:06 -0000 1.3 @@ -44,107 +44,16 @@ #include <video/fbcon-cfb24.h> #include <video/fbcon-cfb32.h> - -/* - * Linux VR uses SFB extensively, so params based on platform in that case - */ -#ifdef CONFIG_CPU_VR41XX -#include <asm/vr41xx-platdep.h> -#endif - -/* - * VIDEORAM_BASE Address of start of video ram (virtual address) - * VIDEORAM_SIZE Size of video ram (default is x * y * (bpp/8)) - * FB_X_RES Visible horizontal resolution in pixels - * FB_X_VIRTUAL_RES Horizontal resolution of framebuffer memory in pixels - * (default is FB_X_RES) - * FB_Y_RES Visible vertical resolution in pixels - * FB_Y_VIRTUAL_RES Vertical resolution of framebuffer memory in pixels - * (default FB_Y_RES) - * FB_BPP Bits per pixel - * FB_PALETTE The palette for a paletted device, whatever has been - * initialized before boot (since sfb can't change it) - * FB_IS_GREY 1 means greyscale device, otherwise 0 (default is 0) - * FB_IS_INVERSE 1 means 0 color value is white instead of black, - * otherwise 0 (default is 0) - * FB_IS_TRUECOLOR Define this as 1 to force truecolor for any mode - * less than 16bpp, this is useful for 8bpp truecolor - * devices (this defaults to 1 for 16bpp or greater) - * The last three are done with 1 / 0 instead of #define / #undef in order - * to facilitate a generic interface, if we should coose to do one in the - * future. - * - * Some example settings: - * - * #define VIDEORAM_BASE 0x12345678 - * #define VIDEORAM_SIZE (1024 * 1024) - * #define FB_X_RES 800 - * #define FB_X_VIRTUAL_RES 1024 - * #define FB_Y_RES 600 - * #define FB_Y_VIRTUAL_RES 1024 - * #define FB_BPP 8 - * #define FB_PALETTE { {0x12,0x34,0x56,0}, {0x78,0x9a,0xbc,0}, ... } - * #define FB_IS_GREY 0 - * #define FB_IS_INVERSE 0 - * #define FB_IS_TRUECOLOR 0 - */ - -/* - * Please put all hardware-specific defines (or includes) above this line, the - * frame buffer should be completely described by above parameters. - */ - -#ifndef VIDEORAM_BASE -#error "SFB frame buffer parameters have not been defined." -#endif - -#ifndef FB_X_VIRTUAL_RES -#define FB_X_VIRTUAL_RES FB_X_RES -#endif - -#ifndef FB_Y_VIRTUAL_RES -#define FB_Y_VIRTUAL_RES FB_Y_RES -#endif - -#ifndef VIDEORAM_SIZE -#define VIDEORAM_SIZE (FB_X_VIRTUAL_RES * FB_Y_VIRTUAL_RES * FB_BPP / 8) -#endif - -#ifndef FB_IS_GREY -#define FB_IS_GREY 0 -#endif - -#ifndef FB_IS_INVERSE -#define FB_IS_INVERSE 0 -#endif - -#ifndef FB_IS_TRUECOLOR -#if (FB_BPP >= 16) -#define FB_IS_TRUECOLOR 1 -#else -#define FB_IS_TRUECOLOR 0 -#endif -#endif - -#define arraysize(x) (sizeof(x)/sizeof(*(x))) - -const u_long videomemory = VIDEORAM_BASE, videomemorysize = VIDEORAM_SIZE; +static unsigned long videomemory = CONFIG_FB_SIMPLE_MEMBASE; +static unsigned long videomemorysize = CONFIG_FB_SIMPLE_MEMSIZE; static int currcon = 0; static struct display disp; static struct fb_info fb_info; -#if !FB_IS_GREY -#ifdef FB_PALETTE -static struct { u_char red, green, blue, pad; } palette[256] = FB_PALETTE; -#else static struct { u_char red, green, blue, pad; } palette[256]; -#endif -#endif -#if defined(FBCON_HAS_CFB8) && FB_IS_TRUECOLOR || defined(FBCON_HAS_CFB16) || \ - defined(FBCON_HAS_CFB24) || defined(FBCON_HAS_CFB32) static union { -#if defined(FBCON_HAS_CFB8) && FB_IS_TRUECOLOR +#if defined(FBCON_HAS_CFB8) u8 cfb8[16]; #endif #ifdef FBCON_HAS_CFB16 @@ -157,12 +66,14 @@ u32 cfb32[16]; #endif } fbcon_cmap; -#endif static char sfb_name[16] = "Simple FB"; +static char *mode_option __initdata = 0; +static int inverse = 0; +static int grayscale = 0; static struct fb_var_screeninfo sfb_default = { - FB_X_RES, FB_Y_RES, FB_X_VIRTUAL_RES, FB_Y_VIRTUAL_RES, 0, 0, FB_BPP, FB_IS_GREY, + 640, 480, 640, 480, 0, 0, 8, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, 0, FB_ACTIVATE_NOW, -1, -1, 0, 20000, 64, 64, 32, 32, 64, 2, 0, FB_VMODE_NONINTERLACED, {0,0,0,0,0,0} @@ -231,28 +142,6 @@ fb_ioctl: sfb_ioctl, }; - - /* - * Open/Release the frame buffer device - */ - -static int sfb_open(struct fb_info *info, int user) -{ - /* - * Nothing, only a usage count for the moment - */ - - MOD_INC_USE_COUNT; - return(0); -} - -static int sfb_release(struct fb_info *info, int user) -{ - MOD_DEC_USE_COUNT; - return(0); -} - - /* * Get the Fixed Part of the Display */ @@ -374,7 +263,7 @@ display->ywrapstep = fix.ywrapstep; display->line_length = fix.line_length; display->can_soft_blank = 0; - display->inverse = FB_IS_INVERSE; + display->inverse = inverse; display->scrollmode = SCROLL_YREDRAW; switch (var->bits_per_pixel) { #ifdef FBCON_HAS_MFB @@ -507,18 +396,6 @@ return 0; } - - /* - * Simple Frame Buffer Specific ioctls - */ - -static int sfb_ioctl(struct inode *inode, struct file *file, u_int cmd, - u_long arg, int con, struct fb_info *info) -{ - return -EINVAL; -} - - int __init sfb_setup(char *options) { char *this_opt; @@ -528,11 +405,21 @@ if (!options || !*options) return 0; - for (this_opt = strtok(options, ","); this_opt; - this_opt = strtok(NULL, ",")) { - if (!strncmp(this_opt, "font:", 5)) + while ((this_opt = strsep(&options, ",")) != NULL) { + if (!*this_opt) + continue; + if (!strncmp(this_opt, "inverse", 7)) { + inverse = 1; + fb_invert_cmaps(); + } else if (!strncmp(this_opt, "grayscale", 9)) { + grayscale = 1; + } else if (!strncmp(this_opt, "font:", 5)) { strcpy(fb_info.fontname, this_opt+5); + } else { + mode_option = this_opt; + } } + return 0; } @@ -543,6 +430,8 @@ int __init sfb_init(void) { + struct fb_var_screeninfo var; + strcpy(fb_info.modename, sfb_name); fb_info.changevar = NULL; fb_info.node = -1; @@ -553,7 +442,22 @@ fb_info.blank = &sfbcon_blank; fb_info.flags = FBINFO_FLAG_DEFAULT; - sfb_set_var(&sfb_default, -1, &fb_info); + memset(&var, 0, sizeof(var)); + + if (!mode_option || !fb_find_mode(&var, &fb_info, + mode_option, NULL, 0, NULL, 8)) + var = sfb_default; + + /* + * Calculate a sane default size if none is specified. + */ + if (!videomemorysize) { + videomemorysize = var.xres_virtual * + var.yres_virtual * + var.bits_per_pixel / 8; + } + + sfb_set_var(&var, -1, &fb_info); if (register_framebuffer(&fb_info) < 0) return -EINVAL; @@ -563,6 +467,17 @@ return 0; } +static void __exit sfb_exit(void) +{ + unregister_framebuffer(&fb_info); +} + +#ifdef MODULE +module_init(sfb_init); +#endif +module_exit(sfb_exit); + +MODULE_LICENSE("GPL"); static int sfbcon_switch(int con, struct fb_info *info) { @@ -701,13 +616,6 @@ var->transp.msb_right = 0; } - -#if FB_IS_TRUECOLOR -#define MAX_REGNO 15 -#else -#define MAX_REGNO ((1 << FB_BPP) - 1) -#endif - /* * Read a single color register and split it into * colors/transparent. Return != 0 for invalid regno. @@ -722,28 +630,29 @@ static int sfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *info) { - if (regno > MAX_REGNO) + if (regno > 255) return 1; -#if FB_IS_GREY - { + if (grayscale) { u_int grey; grey = regno * 255 / MAX_REGNO; -#if FB_IS_INVERSE - grey ^= 255; -#endif + + if (inverse) + grey ^= 255; + grey |= grey << 8; *red = grey; *green = grey; *blue = grey; + } else { + *red = (palette[regno].red << 8) | palette[regno].red; + *green = (palette[regno].green << 8) | palette[regno].green; + *blue = (palette[regno].blue << 8) | palette[regno].blue; } -#else /* either truecolor or palatted */ - *red = (palette[regno].red << 8) | palette[regno].red; - *green = (palette[regno].green << 8) | palette[regno].green; - *blue = (palette[regno].blue << 8) | palette[regno].blue; -#endif + *transp = 0; + return 0; } @@ -760,10 +669,9 @@ static int sfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { - if (regno > MAX_REGNO) + if (regno > 255) return 1; -#if FB_IS_TRUECOLOR red >>= 8; green >>= 8; blue >>= 8; @@ -773,36 +681,44 @@ * palette is read back, the actual hardware value is returned. Also, * maintain index to RGB map for fbcon (accessed through dispsw_data) */ -#if (FB_BPP == 8) - red &= 0xe0; - green &= 0xe0; - blue &= 0xc0; + switch (info->var.bits_per_pixel) { #if defined(FBCON_HAS_CFB8) - fbcon_cmap.cfb8[regno] = red | (green >> 3) | (blue >> 6); -#endif -#endif + case 8: + red &= 0xe0; + green &= 0xe0; + blue &= 0xc0; + fbcon_cmap.cfb8[regno] = red | (green >> 3) | (blue >> 6); -#if (FB_BPP == 16) - red &= 0xF8; - green &= 0xFC; - blue &= 0xF8; -#if defined(FBCON_HAS_CFB16) - fbcon_cmap.cfb16[regno] = (red << 8) | (green << 3) | (blue >> 3); + break; #endif +#if defined(FBCON_HAS_CFB16) + case 16: + red &= 0xF8; + green &= 0xFC; + blue &= 0xF8; + fbcon_cmap.cfb16[regno] = (red << 8) | (green << 3) | (blue >> 3); + + break; #endif +#if defined(FBCON_HAS_CFB24) + case 24: + fbcon_cmap.cfb24[regno] = (red << 16) | (green << 8) | blue; -#if (FB_BPP == 24) && defined(FBCON_HAS_CFB24) - fbcon_cmap.cfb24[regno] = (red << 16) | (green << 8) | blue; + break; #endif - -#if (FB_BPP == 32) && defined(FBCON_HAS_CFB32) - fbcon_cmap.cfb32[regno] = (red << 16) | (green << 8) | blue; +#if defined(FBCON_HAS_CFB32) + case 32: + fbcon_cmap.cfb32[regno] = (red << 16) | (green << 8) | blue; + + break; #endif + default: + break; + } palette[regno].red = red; palette[regno].green = green; palette[regno].blue = blue; -#endif /* FB_IS_TRUECOLOR */ return 0; } @@ -819,16 +735,3 @@ sfb_setcolreg, info); } - -#ifdef MODULE -int init_module(void) -{ - return sfb_init(); -} - -void cleanup_module(void) -{ - unregister_framebuffer(&fb_info); -} - -#endif /* MODULE */ |