From: <ke...@us...> - 2003-11-02 00:17:09
|
Update of /cvsroot/linux-vax/kernel-2.4/drivers/video In directory sc8-pr-cvs1:/tmp/cvs-serv30350/drivers/video Modified Files: Config.in Makefile fbcon-mfb.c fbmem.c Added Files: smgfb.c Log Message: Kaj-Michael Lang: Driver for SMG framebuffer --- NEW FILE: smgfb.c --- /* * A driver for the KA42 mono framebuffer. * Ideas from vmono and other fb drivers, address, size and command info from NetBSD. * Thanks to all of them. * * Copyright 2003 Kaj-Michael Lang <mi...@ta...> * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/fb.h> #include <video/fbcon.h> #include <video/fbcon-mfb.h> #include <asm/io.h> #define smg_DRV_VERSION "0.01" /* * Where are we, and what is our size * */ #define smg_FB_PHYS_ADDR 0x30000000 #define smg_FB_SIZE 0x20000 #define smg_X_SIZE 1024 #define smg_Y_SIZE 864 /* * Cursors stuff, from netbsd. * */ #define smg_CUR_BASE 0x200f0000 #define smg_CUR_SIZE 0x08 #define smg_CUR_CMD 00 #define smg_CUR_XPOS 04 #define smg_CUR_YPOS 08 #define smg_CUR_XMIN_1 12 #define smg_CUR_XMAX_1 16 #define smg_CUR_YMIN_1 20 #define smg_CUR_YMAX_1 24 #define smg_CUR_XMIN_2 28 #define smg_CUR_XMAX_2 32 #define smg_CUR_YMIN_2 36 #define smg_CUR_YMAX_2 40 #define smg_CUR_LOAD 44 #define smg_CUR_CMD_TEST 0x8000 #define smg_CUR_CMD_HSHI 0x4000 #define smg_CUR_CMD_VBHI 0x2000 #define smg_CUR_CMD_LODSA 0x1000 #define smg_CUR_CMD_FORG2 0x0800 #define smg_CUR_CMD_ENRG2 0x0400 #define smg_CUR_CMD_FORG1 0x0200 #define smg_CUR_CMD_ENRG1 0x0100 #define smg_CUR_CMD_XHWID 0x0080 #define smg_CUR_CMD_XHCL1 0x0040 #define smg_CUR_CMD_XHCLP 0x0020 #define smg_CUR_CMD_XHAIR 0x0010 #define smg_CUR_CMD_FOPB 0x0008 #define smg_CUR_CMD_ENPB 0x0004 #define smg_CUR_CMD_FOPA 0x0002 #define smg_CUR_CMD_ENPA 0x0001 struct smg_par { int xres; int yres; int bpp; }; /* Pointer to our memory */ char *smgfb_mem; /* Cursor information, do we need more than this ?? */ struct smg_cur_info { char *mem; int x; int y; }; static int currcon=0; static struct display disp; static struct fb_info fb_info; static struct fb_fix_screeninfo fb_fix; static struct fb_var_screeninfo fb_var; static struct smg_cur_info smg_cur_info; static int smgfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info); static int smgfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info); static int smgfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info); static int smgfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info); static int smgfb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info); static int smgfb_blank(int blank, struct fb_info *info); static int smgfb_con_switch(int con, struct fb_info *info); static int smgfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *fbinfo); static int smgfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *fbinfo); static struct fb_ops smg_ops = { owner: THIS_MODULE, fb_open: NULL, fb_release: NULL, fb_get_fix: smgfb_get_fix, fb_get_var: smgfb_get_var, fb_set_var: smgfb_set_var, fb_get_cmap: smgfb_get_cmap, fb_set_cmap: smgfb_set_cmap, fb_ioctl: NULL, }; static int smgfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) { memcpy(fix, &fb_fix, sizeof(fb_fix)); return 0; } static int smgfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { memcpy(var, &fb_var, sizeof(fb_var)); return 0; } static int smgfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { return 0; } static int smgfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { return fb_get_cmap(cmap, kspc, smgfb_getcolreg, info); } static int smgfb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { return fb_set_cmap(cmap, kspc, smgfb_setcolreg, info); } static int smgfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *fbinfo) { /* Do the same as hgafb */ printk("smgfb: setcolreg\n"); if (regno > 1) return 1; return 0; } static int smgfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *fbinfo) { /* Do the same as hgafb */ printk("smgfb: getcolreg\n"); if (regno == 0) { *red = *green = *blue = 0x0000; *transp = 0; } else if (regno == 1) { *red = *green = *blue = 0xaaaa; *transp = 0; } else return 1; return 0; } static int smgfb_blank(int blank, struct fb_info *info) { memset(smgfb_mem, 0, smg_FB_SIZE); return 1; } static int smgfb_con_switch(int con, struct fb_info *info) { currcon=con; return 0; } static void smg_cursorcmd(int cmd_addr, char cmd) { smg_cur_info.mem[cmd_addr]=cmd; } /* * Initialization code */ static int __init smgfb_probe(volatile unsigned char *smg_fb_mem) { /* Assume we have a smg.. for now.. */ printk("smgfb: found smg\n"); return 1; } static void __init smgfb_reset(void) { printk("smgfb: reset\n"); /* What here ? */ } static int __init smgfb_map_cursor() { printk("smgfb: Trying to map hw cursor\n"); smg_cur_info.mem = ioremap(smg_CUR_BASE, smg_CUR_SIZE ); if (smg_cur_info.mem== NULL) return 1; return 0; } static int __init smgfb_map_fbmem() { printk("smgfb: Trying to map framebuffer\n"); smgfb_mem = ioremap(smg_FB_PHYS_ADDR, smg_FB_SIZE ); if (smgfb_mem == NULL) return 1; return 0; } int __init smgfb_init(void) { printk("smgfb: VAXstation mono framebuffer driver, version %s\n", smg_DRV_VERSION); if (smgfb_map_fbmem() != 0) { printk("smgfb: Unable to map framebuffer!\n"); return -ENODEV; } else { /* <blink /> */ memset(smgfb_mem, 0, smg_FB_SIZE); memset(smgfb_mem, 255, smg_FB_SIZE); memset(smgfb_mem, 0, smg_FB_SIZE); } /* Just map the hw cursor, need to implement support someday... */ if (smgfb_map_cursor(&fb_info) != 0) { printk("smgfb: Unable to map hardware cursor, disabling hardware cursor support.\n"); } else { printk("smgfb: Mapped hardware cursor\n"); } if (smgfb_probe(smgfb_mem) == 0) return -ENODEV; smgfb_reset(); memset(&fb_fix, 0, sizeof(struct fb_fix_screeninfo)); strcpy(fb_fix.id, "smg"); fb_fix.type = FB_TYPE_PACKED_PIXELS; fb_fix.type_aux = 0; fb_fix.visual = FB_VISUAL_MONO10; fb_fix.line_length = 128; fb_fix.smem_start = *smgfb_mem; fb_fix.smem_len = smg_FB_SIZE; fb_fix.mmio_start = smg_FB_PHYS_ADDR; fb_fix.mmio_len = smg_FB_SIZE; fb_fix.xpanstep = 0; fb_fix.ypanstep = 0; fb_fix.ywrapstep = 0; fb_fix.accel = FB_ACCEL_NONE; fb_var.yres=smg_Y_SIZE; fb_var.xres=smg_X_SIZE; fb_var.yres_virtual=smg_Y_SIZE; fb_var.xres_virtual=smg_X_SIZE; fb_var.bits_per_pixel=1; fb_var.grayscale=0; fb_var.nonstd=0; fb_var.activate=0; fb_var.height=-1; fb_var.width=-1; fb_var.accel_flags=0; disp.var=fb_var; disp.cmap.start = 0; disp.cmap.len = 0; disp.cmap.red = disp.cmap.green = disp.cmap.blue = disp.cmap.transp = NULL; disp.visual = fb_fix.visual; disp.type = fb_fix.type; disp.type_aux = fb_fix.type_aux; disp.ypanstep = 0; disp.ywrapstep = 0; disp.line_length = fb_fix.line_length; disp.can_soft_blank = 0; disp.inverse = 0; #ifdef FBCON_HAS_MFB disp.dispsw = &fbcon_mfb; #else disp.dispsw = &fbcon_dummy; #endif disp.scrollmode = SCROLL_YREDRAW; disp.var.activate = FB_ACTIVATE_NOW; disp.screen_base = (char *)smgfb_mem; strcpy(fb_info.modename, fb_fix.id); fb_info.node = -1; fb_info.fbops = &smg_ops; fb_info.disp = &disp; fb_info.fontname[0] = '\0'; fb_info.changevar = NULL; fb_info.switch_con = smgfb_con_switch; fb_info.updatevar = fbgen_update_var; fb_info.blank = fbgen_blank; fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.screen_base = (char *)smgfb_mem; if (register_framebuffer(&fb_info) < 0) { printk("smgfb: unable to register framebuffer!\n"); return -ENODEV; } printk(KERN_INFO "fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.node), fb_info.modename); MOD_INC_USE_COUNT; return 0; } int __init smgfb_setup(char *options) { return 0; } #ifdef MODULE int init_module(void) { return smgfb_init(); } void cleanup_module(void) { smgfb_cleanup(&fb_info); } MODULE_AUTHOR("Kaj-Michael Lang (mi...@ta...)"); MODULE_DESCRIPTION("FBDev driver for VAXstation b/w framebuffer"); MODULE_LICENSE("GPL"); #endif /* MODULE */ Index: Config.in =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/video/Config.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Config.in 27 Sep 2003 13:11:58 -0000 1.8 +++ Config.in 2 Nov 2003 00:17:06 -0000 1.9 @@ -227,6 +227,7 @@ fi if [ "$ARCH" = "vax" -a "$CONFIG_EXPERIMENTAL" = "y" ]; then bool ' VXT2000 monochrome framebuffer support (EXPERIMENTAL)' CONFIG_FB_VMONO + bool ' VS3100 monochrome framebuffer support (EXPERIMENTAL)' CONFIG_FB_SMG fi if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then tristate ' Virtual Frame Buffer support (ONLY FOR TESTING!) (EXPERIMENTAL)' CONFIG_FB_VIRTUAL Index: Makefile =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/video/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile 27 Sep 2003 13:11:58 -0000 1.8 +++ Makefile 2 Nov 2003 00:17:06 -0000 1.9 @@ -87,6 +87,7 @@ obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_AU1100) += au1100fb.o fbgen.o obj-$(CONFIG_FB_VMONO) += vmonofb.o fbgen.o +obj-$(CONFIG_FB_SMG) += smgfb.o fbgen.o subdir-$(CONFIG_STI_CONSOLE) += sti ifeq ($(CONFIG_STI_CONSOLE),y) Index: fbcon-mfb.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/video/fbcon-mfb.c,v retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -r1.1.1.2 -r1.3 --- fbcon-mfb.c 20 Sep 2003 19:08:40 -0000 1.1.1.2 +++ fbcon-mfb.c 2 Nov 2003 00:17:06 -0000 1.3 @@ -19,6 +19,16 @@ #include <video/fbcon-mfb.h> +#ifdef CONFIG_FB_SMG +static inline u8 swap_byte(u8 in) +{ + in = ((in & 0xf0) >> 4) | ((in & 0x0f) << 4); + in = ((in & 0xcc) >> 2) | ((in & 0x33) << 2); + in = ((in & 0xaa) >> 1) | ((in & 0x55) << 1); + return in; +} +#endif + /* * Monochrome */ @@ -97,7 +107,11 @@ underl = attr_underline(p,c); for (rows = fontheight(p); rows--; dest += p->next_line) { +#ifdef CONFIG_FB_SMG + d = swap_byte(*cdat++); +#else d = *cdat++; +#endif if (underl && !rows) d = 0xff; else if (bold) @@ -127,7 +141,11 @@ dest = dest0++; cdat = p->fontdata+c*fontheight(p); for (rows = fontheight(p); rows--; dest += p->next_line) { - d = *cdat++; +#ifdef CONFIG_FB_SMG + d = swap_byte(*cdat++); +#else + d = *cdat++; +#endif if (underl && !rows) d = 0xff; else if (bold) Index: fbmem.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/video/fbmem.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- fbmem.c 27 Sep 2003 13:11:58 -0000 1.9 +++ fbmem.c 2 Nov 2003 00:17:06 -0000 1.10 @@ -144,6 +144,8 @@ extern int sstfb_setup(char*); extern int vmonofb_init(void); extern int vmonofb_setup(char*); +extern int smgfb_init(void); +extern int smgfb_setup(char*); static struct { const char *name; @@ -329,6 +331,9 @@ #endif #ifdef CONFIG_FB_VMONO { "vmono", vmonofb_init, vmonofb_setup }, +#endif +#ifdef CONFIG_FB_SMG + { "smg", smgfb_init, smgfb_setup }, #endif /* |