From: James S. <jsi...@us...> - 2002-03-27 20:58:15
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/video In directory usw-pr-cvs1:/tmp/cvs-serv30025 Modified Files: fm2fb.c hitfb.c hpfb.c q40fb.c Log Message: More cleanup of the frmaebuffer code. Index: fm2fb.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/fm2fb.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- fm2fb.c 28 Feb 2002 18:28:58 -0000 1.9 +++ fm2fb.c 27 Mar 2002 20:58:09 -0000 1.10 @@ -4,7 +4,6 @@ * * Copyright (C) 1998 Steffen A. Mork (mo...@ls...) * Copyright (C) 1999 Geert Uytterhoeven - * Copyright (C) 2001 James Simmons * * Written for 2.0.x by Steffen A. Mork * Ported to 2.1.x by Geert Uytterhoeven @@ -134,8 +133,12 @@ static u32 pseudo_palette[17]; static struct fb_fix_screeninfo fb_fix __initdata = { - NULL, (unsigned long) NULL, FRAMEMASTER_REG, FB_TYPE_PACKED_PIXELS, 0, - FB_VISUAL_TRUECOLOR, 0, 0, 0, 768<<2, (unsigned long)NULL, 8, FB_ACCEL_NONE + smem_len: FRAMEMASTER_REG, + type: FB_TYPE_PACKED_PIXELS, + visual: FB_VISUAL_TRUECOLOR, + line_length: (768 << 2), + mmio_len: (8), + accel: FB_ACCEL_NONE, }; static int fm2fb_mode __initdata = -1; @@ -262,6 +265,8 @@ fb_info.pseudo_palette = pseudo_palette; fb_info.fix = fb_fix; fb_info.flags = FBINFO_FLAG_DEFAULT; + + fb_alloc_cmap(&fb_info.cmap, 16, 0); if (register_framebuffer(&fb_info) < 0) return -EINVAL; Index: hitfb.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/hitfb.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- hitfb.c 29 Oct 2001 22:58:43 -0000 1.6 +++ hitfb.c 27 Mar 2002 20:58:09 -0000 1.7 @@ -21,6 +21,7 @@ #include <linux/delay.h> #include <linux/nubus.h> #include <linux/init.h> +#include <linux/fb.h> #include <asm/machvec.h> #include <asm/uaccess.h> @@ -28,151 +29,175 @@ #include <asm/io.h> #include <asm/hd64461.h> -#include <linux/fb.h> - -static struct fb_fix_screeninfo hitfb_fix __initdata = { - "Hitachi HD64461",(unsigned long) NULL, 1024*1024, FB_TYPE_PACKED_PIXELS, 0, - FB_VISUAL_TRUECOLOR, 0, 0, 0, 0, (unsigned long) NULL, 0, FB_ACCEL_NONE}; - static struct fb_var_screeninfo hitfb_var __initdata = { - 0, 0, 0, 0, 0, 0, 0, 0, - {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, - 0, FB_ACTIVATE_NOW, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, FB_VMODE_NONINTERLACED + activate: FB_ACTIVATE_NOW, + height: -1, + width: -1, + vmode: FB_VMODE_NONINTERLACED, }; -static void hitfb_detect(void) -{ - unsigned short lcdclor, ldr3, ldvntr; - - hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000; - hitfb_fix.smem_len = (MACH_HP680 || MACH_HP690) ? 1024*1024 : 512*1024; - - lcdclor = inw(HD64461_LCDCLOR); - ldvntr = inw(HD64461_LDVNTR); - ldr3 = inw(HD64461_LDR3); +static struct fb_fix_screeninfo hitfb_fix __initdata = { + id: "Hitachi HD64461", + type: FB_TYPE_PACKED_PIXELS, + visual: FB_VISUAL_TRUECOLOR, + accel_flags: FB_ACCEL_NONE, +}; - switch (ldr3 & 15) { - default: - case 4: - hitfb_var.bits_per_pixel = 8; - hitfb_var.xres = lcdclor; - break; - case 8: - hitfb_var.bits_per_pixel = 16; - hitfb_var.xres = lcdclor/2; - break; - } - hitfb_var.yres = ldvntr+1; -} +static u16 pseudo_palette[17]; +struct fb_info fb_info; static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { - var->xres = par->x; - var->yres = par->y; - var->xres_virtual = var->xres; - var->yres_virtual = var->yres; - var->bits_per_pixel = par->bpp; + var->xres_virtual = var->xres; + var->yres_virtual = var->yres; - switch (var->bits_per_pixel) { - case 8: - var->red.offset = 0; - var->red.length = 8; - var->green.offset = 0; - var->green.length = 8; - var->blue.offset = 0; - var->blue.length = 8; - var->transp.offset = 0; - var->transp.length = 0; - break; - case 16: /* RGB 565 */ - var->red.offset = 11; - var->red.length = 5; - var->green.offset = 5; - var->green.length = 6; - var->blue.offset = 0; - var->blue.length = 5; - var->transp.offset = 0; - var->transp.length = 0; - break; - } - var->red.msb_right = 0; - var->green.msb_right = 0; - var->blue.msb_right = 0; - var->transp.msb_right = 0; - return 0; + switch (var->bits_per_pixel) { + case 8: + var->red.offset = 0; + var->red.length = 8; + var->green.offset = 0; + var->green.length = 8; + var->blue.offset = 0; + var->blue.length = 8; + var->transp.offset = 0; + var->transp.length = 0; + break; + case 16: /* RGB 565 */ + var->red.offset = 11; + var->red.length = 5; + var->green.offset = 5; + var->green.length = 6; + var->blue.offset = 0; + var->blue.length = 5; + var->transp.offset = 0; + var->transp.length = 0; + break; + } + return 0; } -static void hitfb_set_par(struct fb_info *info) +static int hitfb_set_par(struct fb_info *info) { - info->fix.smem_start = fb_info.hit_videobase; - info->fix.smem_len = fb_info.hit_videosize; - info->fix.visual = (info->var.bits_per_pixel == 8) ? - FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; + info->fix.visual = (info->var.bits_per_pixel == 8) ? + FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; - switch(info->var.bits_per_pixel) { - default: - case 8: - info->fix.line_length = info->var.xres; - break; - case 16: - info->fix.line_length = info->var.xres*2; - break; - } + switch(info->var.bits_per_pixel) { + default: + case 8: + info->fix.line_length = info->var.xres; + break; + case 16: + info->fix.line_length = info->var.xres*2; + break; + } + return 0; } static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { - if (regno > 255) - return 1; + if (regno > 255) + return 1; - outw(regno<<8, HD64461_CPTWAR); - outw(red>>10, HD64461_CPTWDR); - outw(green>>10, HD64461_CPTWDR); - outw(blue>>10, HD64461_CPTWDR); + outw(regno << 8, HD64461_CPTWAR); + outw(red >> 10, HD64461_CPTWDR); + outw(green >> 10, HD64461_CPTWDR); + outw(blue >> 10, HD64461_CPTWDR); - if(regno<16) { - if (info->var.bits_per_pixel == 16) { - info->pseudo_palette[regno] = ((red & 0xf800)) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); + if (regno < 16) { + switch(info->var.bits_per_pixel) { +#ifdef FBCON_HAS_CFB16 + case 16: + ((u16 *)(info->pseudo_palette))[regno] = + ((red & 0xf800) ) | + ((green & 0xfc00) >> 5) | + ((blue & 0xf800) >> 11); + break; +#endif + } } - } - return 0; + return 0; } static struct fb_ops hitfb_ops = { - owner: THIS_MODULE, - fb_check_var: hitfb_check_var, - fb_set_par: hitfb_set_par, - fb_setcolreg: hitfb_setcolreg, - fb_fillrect: cfb_fillrect, - fb_copyarea: cfb_copyarea, - fb_imageblit: cfb_imageblit, + owner: THIS_MODULE, + fb_check_var: hitfb_check_var, + fb_set_par: hitfb_set_par, + fb_setcolreg: hitfb_setcolreg, + fb_fillrect: cfb_fillrect, + fb_copyarea: cfb_copyarea, + fb_imageblit: cfb_imageblit, }; int __init hitfb_init(void) { - fb_info.node = -1; - fb_info.flags = FBINFO_FLAG_DEFAULT; - fb_info.fbops = &hitfb_ops; - hitfb_detect(); - fb_info.screen_base = (void *) hitfb_fix.smem_start; + unsigned short lcdclor, ldr3, ldvntr; + + hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000; + hitfb_fix.smem_len = (MACH_HP680 || MACH_HP690) ? 1024*1024 : 512*1024; + + lcdclor = inw(HD64461_LCDCLOR); + ldvntr = inw(HD64461_LDVNTR); + ldr3 = inw(HD64461_LDR3); + + switch (ldr3&15) { + default: + case 4: + hitfb_var.bits_per_pixel = 8; + hitfb_var.xres = lcdclor; + break; + case 8: + hitfb_var.bits_per_pixel = 16; + hitfb_var.xres = lcdclor/2; + break; + } + hitfb_var.yres = ldvntr+1; + + fb_info.node = NODEV; + fb_info.fbops = &hitfb_ops; + fb_info.var = hitfb_var; + fb_info.fix = hitfb_fix; + fb_info.pseudo_palette = pseudo_palette; + fb_info.flags = FBINFO_FLAG_DEFAULT; + fb_info.screen_base = (void *) hitfb_fix.smem_start; + + size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16; + fb_alloc_cmap(&fb_info.cmap, size, 0); + + gen_get_var(&fb_info.var, -1, &fb_info); - if(register_framebuffer(&fb_info) < 0) return -EINVAL; + if (register_framebuffer(&fb_info) < 0) + return -EINVAL; - printk(KERN_INFO "fb%d: %s frame buffer device\n", - GET_FB_IDX(fb_info.node), fb_info.fix.id); - return 0; + printk(KERN_INFO "fb%d: %s frame buffer device\n", + GET_FB_IDX(fb_info.node), fb_info.fix.id); + return 0; } -static void __exit hitfb_exit(void) + +void hitfb_cleanup(struct fb_info *info) { - unregister_framebuffer(&fb_info); + unregister_framebuffer(info); } -module_init(hitfb_init); -module_exit(hitfb_exit); +#ifdef MODULE MODULE_LICENSE("GPL"); +int init_module(void) +{ + return hitfb_init(); +} + +void cleanup_module(void) +{ + hitfb_cleanup(void); +} +#endif + +/* + * Local variables: + * c-basic-offset: 4 + * End: + */ Index: hpfb.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/hpfb.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- hpfb.c 28 Feb 2002 18:28:58 -0000 1.9 +++ hpfb.c 27 Mar 2002 20:58:09 -0000 1.10 @@ -41,26 +41,27 @@ #define WMOVE 0x409c static struct fb_fix_screeninfo hpfb_fix __initdata = { - "HP300 Topcat", (unsigned long) NULL, 1024*768, FB_TYPE_PACKED_PIXELS, 0, - FB_VISUAL_PSEUDOCOLOR, 0, 0, 0, 1024, (unsigned long) NULL, 0, FB_ACCEL_NONE}; + id: "HP300 Topcat", + smem_len: 1024*768, + type: FB_TYPE_PACKED_PIXELS, + visual: FB_VISUAL_PSEUDOCOLOR, + line_length: 1024, + accel: FB_ACCEL_NONE, static struct fb_var_screeninfo hpfb_defined = { - 1024,768,1024,768, /* W,H, W, H (virtual) load xres,xres_virtual*/ - 0,0, /* virtual -> visible no offset */ - 1, /* depth -> load bits_per_pixel */ - 0, /* greyscale ? */ - {0,2,0}, /* R */ - {0,2,0}, /* G */ - {0,2,0}, /* B */ - {0,0,0}, /* transparency */ - 0, /* standard pixel format */ - FB_ACTIVATE_NOW, - 274,195, /* 14" monitor */ - FB_ACCEL_NONE, - 0L,0L,0L,0L,0L, - 0L,0L,0, /* No sync info */ - FB_VMODE_NONINTERLACED, - {0,0,0,0,0,0} + xres: 1024, + yres: 768, + xres_virtual: 1024, + yres_virtual: 786, + bits_per_pixel: 1, + red: {0,2,0}, /* R */ + green: {0,2,0}, /* G */ + blue: {0,2,0}, /* B */ + activate: FB_ACTIVATE_NOW, + height: 274, + width: 195, /* 14" monitor */ + accel_flags: FB_ACCEL_NONE, + vmode: FB_VMODE_NONINTERLACED, }; /* @@ -100,7 +101,7 @@ static struct fb_ops hpfb_ops = { owner: THIS_MODULE, fb_setcolreg: hpfb_setcolreg, - fb_fillrect: cfb_fillrect, + fb_fillrect: cfb_fillrect, fb_copyarea: hpfb_copyarea, fb_imageblit: cfb_imageblit, }; @@ -154,6 +155,8 @@ fb_info.var = hpfb_defined; fb_info.fix = hpfb_fix; fb_info.screen_base = hpfb_fix.smem_start; + + fb_alloc_cmap(&fb_info.cmap, 256, 0); if (register_framebuffer(&fb_info) < 0) return 1; Index: q40fb.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/q40fb.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- q40fb.c 28 Feb 2002 18:31:50 -0000 1.7 +++ q40fb.c 27 Mar 2002 20:58:09 -0000 1.8 @@ -34,16 +34,27 @@ static struct fb_info fb_info; static struct fb_fix_screeninfo q40fb_fix __initdata = { - "Q40", (unsigned long) NULL, 1024*1024, FB_TYPE_PACKED_PIXELS, 0, - FB_VISUAL_TRUECOLOR, 0, 0, 0, 1024*2, (unsigned long) NULL, 0, FB_ACCEL_NONE + id: "Q40", + smem_len: 1024*1024, + type: FB_TYPE_PACKED_PIXELS, + visual: FB_VISUAL_TRUECOLOR, + line_length: 1024*2, + accel_flags: FB_ACCEL_NONE, }; static struct fb_var_screeninfo q40fb_var __initdata = { - /* 1024x512, 16 bpp */ - 1024, 512, 1024, 512, 0, 0, 16, 0, - {6, 5, 0}, {11, 5, 0}, {0, 6, 0}, {0, 0, 0}, - 0, FB_ACTIVATE_NOW, 230, 300, 0, 0, 0, 0, 0, 0, 0, 0, - 0, FB_VMODE_NONINTERLACED + xres: 1024, + yres: 512, + xres_virtual: 1024, + yres_virtual: 512, + bits_per_pixel: 16, + red: {6, 5, 0}, + green: {11, 5, 0}, + blue: {0, 6, 0}, + activate: FB_ACTIVATE_NOW, + height: 230, + width: 300, + vmode: FB_VMODE_NONINTERLACED, }; /* frame buffer operations */ @@ -54,11 +65,11 @@ struct fb_info *info); static struct fb_ops q40fb_ops = { - owner: THIS_MODULE, - fb_setcolreg: q40fb_setcolreg, - fb_fillrect: cfb_fillrect, - fb_copyarea: cfb_copyarea, - fb_imageblit: cfb_imageblit, + owner: THIS_MODULE, + fb_setcolreg: q40fb_setcolreg, + fb_fillrect: cfb_fillrect, + fb_copyarea: cfb_copyarea, + fb_imageblit: cfb_imageblit, }; static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green, @@ -99,6 +110,8 @@ fb_info.pseudo_palette = pseudo_palette; fb_info.screen_base = (char *) q40fb_fix.smem_start; + fb_alloc_cmap(&fb_info.cmap, 16, 0); + master_outb(3, DISPLAY_CONTROL_REG); if (register_framebuffer(&fb_info) < 0) { |