📄 cyberfb.c
字号:
var->activate = 0; DPRINTK("EXIT\n"); return(0);}/* * Get the Colormap */static int cyberfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ DPRINTK("ENTER\n"); if (con == currcon) { /* current console? */ DPRINTK("EXIT - console is current console\n"); return(fb_get_cmap(cmap, kspc, Cyber_getcolreg, info)); } else if (fb_display[con].cmap.len) { /* non default colormap? */ DPRINTK("Use console cmap\n"); fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); } else { DPRINTK("Use default cmap\n"); fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), cmap, kspc ? 0 : 2); } DPRINTK("EXIT\n"); return(0);}/* * Set the Colormap */static int cyberfb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ int err; DPRINTK("ENTER\n"); if (!fb_display[con].cmap.len) { /* no colormap allocated? */ if ((err = fb_alloc_cmap(&fb_display[con].cmap, 1<<fb_display[con].var.bits_per_pixel, 0))) { DPRINTK("EXIT - fb_alloc_cmap failed\n"); return(err); } } if (con == currcon) { /* current console? */ DPRINTK("EXIT - Current console\n"); return(fb_set_cmap(cmap, kspc, Cyber_setcolreg, info)); } else { fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); } DPRINTK("EXIT\n"); return(0);}static struct fb_ops cyberfb_ops = { owner: THIS_MODULE, fb_get_fix: cyberfb_get_fix, fb_get_var: cyberfb_get_var, fb_set_var: cyberfb_set_var, fb_get_cmap: cyberfb_get_cmap, fb_set_cmap: cyberfb_set_cmap,};int __init cyberfb_setup(char *options){ char *this_opt; DPRINTK("ENTER\n"); fb_info.fontname[0] = '\0'; if (!options || !*options) { DPRINTK("EXIT - no options\n"); return 0; } while ((this_opt = strsep(&options, ",")) != NULL) { if (!*this_opt) continue; if (!strcmp(this_opt, "inverse")) { Cyberfb_inverse = 1; fb_invert_cmaps(); } else if (!strncmp(this_opt, "font:", 5)) { strcpy(fb_info.fontname, this_opt+5); } else if (!strcmp (this_opt, "cyber8")) { cyberfb_default = cyberfb_predefined[CYBER8_DEFMODE].var; cyberfb_usermode = 1; } else if (!strcmp (this_opt, "cyber16")) { cyberfb_default = cyberfb_predefined[CYBER16_DEFMODE].var; cyberfb_usermode = 1; } else get_video_mode(this_opt); } DPRINTK("default mode: xres=%d, yres=%d, bpp=%d\n", cyberfb_default.xres, cyberfb_default.yres, cyberfb_default.bits_per_pixel); DPRINTK("EXIT\n"); return 0;}/* * Initialization */int __init cyberfb_init(void){ unsigned long board_addr, board_size; struct cyberfb_par par; struct zorro_dev *z = NULL; DPRINTK("ENTER\n"); while ((z = zorro_find_device(ZORRO_PROD_PHASE5_CYBERVISION64, z))) { board_addr = z->resource.start; board_size = z->resource.end-z->resource.start+1; CyberMem_phys = board_addr + 0x01400000; CyberRegs_phys = CyberMem_phys + 0x00c00000; if (!request_mem_region(CyberRegs_phys, 0x10000, "S3 Trio64")) continue; if (!request_mem_region(CyberMem_phys, 0x400000, "RAM")) { release_mem_region(CyberRegs_phys, 0x10000); continue; } DPRINTK("board_addr=%08lx\n", board_addr); DPRINTK("board_size=%08lx\n", board_size); CyberBase = ioremap(board_addr, board_size); CyberRegs = CyberBase + 0x02000000; CyberMem = CyberBase + 0x01400000; DPRINTK("CyberBase=%08lx CyberRegs=%08lx CyberMem=%08lx\n", CyberBase, (long unsigned int)CyberRegs, CyberMem);#ifdef CYBERFBDEBUG DPRINTK("Register state just after mapping memory\n"); cv64_dump();#endif strcpy(fb_info.modename, cyberfb_name); fb_info.changevar = NULL; fb_info.node = -1; fb_info.fbops = &cyberfb_ops; fb_info.disp = &disp; fb_info.switch_con = &Cyberfb_switch; fb_info.updatevar = &Cyberfb_updatevar; fb_info.blank = &Cyberfb_blank; Cyber_init(); /* ++Andre: set cyberfb default mode */ if (!cyberfb_usermode) { cyberfb_default = cyberfb_predefined[CYBER8_DEFMODE].var; DPRINTK("Use default cyber8 mode\n"); } Cyber_decode_var(&cyberfb_default, &par); Cyber_encode_var(&cyberfb_default, &par); do_fb_set_var(&cyberfb_default, 1); cyberfb_get_var(&fb_display[0].var, -1, &fb_info); cyberfb_set_disp(-1, &fb_info); do_install_cmap(0, &fb_info); if (register_framebuffer(&fb_info) < 0) { DPRINTK("EXIT - register_framebuffer failed\n"); release_mem_region(CyberMem_phys, 0x400000); release_mem_region(CyberRegs_phys, 0x10000); return -EINVAL; } printk("fb%d: %s frame buffer device, using %ldK of video memory\n", GET_FB_IDX(fb_info.node), fb_info.modename, CyberSize>>10); /* TODO: This driver cannot be unloaded yet */ MOD_INC_USE_COUNT; DPRINTK("EXIT\n"); return 0; } return -ENXIO;}static int Cyberfb_switch(int con, struct fb_info *info){ DPRINTK("ENTER\n"); /* Do we have to save the colormap? */ if (fb_display[currcon].cmap.len) { fb_get_cmap(&fb_display[currcon].cmap, 1, Cyber_getcolreg, info); } do_fb_set_var(&fb_display[con].var, 1); currcon = con; /* Install new colormap */ do_install_cmap(con, info); DPRINTK("EXIT\n"); return(0);}/* * Update the `var' structure (called by fbcon.c) * * This call looks only at yoffset and the FB_VMODE_YWRAP flag in `var'. * Since it's called by a kernel driver, no range checking is done. */static int Cyberfb_updatevar(int con, struct fb_info *info){ DPRINTK("Enter - Exit\n"); return(0);}/* * Get a Video Mode */static int __init get_video_mode(const char *name){ int i; DPRINTK("ENTER\n"); for (i = 0; i < NUM_TOTAL_MODES; i++) { if (!strcmp(name, cyberfb_predefined[i].name)) { cyberfb_default = cyberfb_predefined[i].var; cyberfb_usermode = 1; DPRINTK("EXIT - Matched predefined mode\n"); return(i); } } return(0);}/* * Text console acceleration */#ifdef FBCON_HAS_CFB8static void fbcon_cyber8_bmove(struct display *p, int sy, int sx, int dy, int dx, int height, int width){ DPRINTK("ENTER\n"); sx *= 8; dx *= 8; width *= 8; Cyber_BitBLT((u_short)sx, (u_short)(sy*fontheight(p)), (u_short)dx, (u_short)(dy*fontheight(p)), (u_short)width, (u_short)(height*fontheight(p)), (u_short)S3_NEW); DPRINTK("EXIT\n");}static void fbcon_cyber8_clear(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width){ unsigned char bg; DPRINTK("ENTER\n"); sx *= 8; width *= 8; bg = attr_bgcol_ec(p,conp); Cyber_RectFill((u_short)sx, (u_short)(sy*fontheight(p)), (u_short)width, (u_short)(height*fontheight(p)), (u_short)S3_NEW, (u_short)bg); DPRINTK("EXIT\n");}static void fbcon_cyber8_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx){ DPRINTK("ENTER\n"); Cyber_WaitBlit(); fbcon_cfb8_putc(conp, p, c, yy, xx); DPRINTK("EXIT\n");}static void fbcon_cyber8_putcs(struct vc_data *conp, struct display *p, const unsigned short *s, int count, int yy, int xx){ DPRINTK("ENTER\n"); Cyber_WaitBlit(); fbcon_cfb8_putcs(conp, p, s, count, yy, xx); DPRINTK("EXIT\n");}static void fbcon_cyber8_revc(struct display *p, int xx, int yy){ DPRINTK("ENTER\n"); Cyber_WaitBlit(); fbcon_cfb8_revc(p, xx, yy); DPRINTK("EXIT\n");}static struct display_switch fbcon_cyber8 = { setup: fbcon_cfb8_setup, bmove: fbcon_cyber8_bmove, clear: fbcon_cyber8_clear, putc: fbcon_cyber8_putc, putcs: fbcon_cyber8_putcs, revc: fbcon_cyber8_revc, clear_margins: fbcon_cfb8_clear_margins, fontwidthmask: FONTWIDTH(8)};#endif#ifdef MODULEMODULE_LICENSE("GPL");int init_module(void){ return cyberfb_init();}void cleanup_module(void){ /* Not reached because the usecount will never be decremented to zero */ unregister_framebuffer(&fb_info); /* TODO: clean up ... */}#endif /* MODULE *//* * * Low level initialization routines for the CyberVision64 graphics card * * Most of the following code is from cvision_core.c * */#define MAXPIXELCLOCK 135000000 /* safety */#ifdef CV_AGGRESSIVE_TIMINGlong cv64_memclk = 55000000;#elselong cv64_memclk = 50000000;#endif/*********************/static unsigned char clocks[]={ 0x13, 0x61, 0x6b, 0x6d, 0x51, 0x69, 0x54, 0x69, 0x4f, 0x68, 0x6b, 0x6b, 0x18, 0x61, 0x7b, 0x6c, 0x51, 0x67, 0x24, 0x62, 0x56, 0x67, 0x77, 0x6a, 0x1d, 0x61, 0x53, 0x66, 0x6b, 0x68, 0x79, 0x69, 0x7c, 0x69, 0x7f, 0x69, 0x22, 0x61, 0x54, 0x65, 0x56, 0x65, 0x58, 0x65, 0x67, 0x66, 0x41, 0x63, 0x27, 0x61, 0x13, 0x41, 0x37, 0x62, 0x6b, 0x4d, 0x23, 0x43, 0x51, 0x49, 0x79, 0x66, 0x54, 0x49, 0x7d, 0x66, 0x34, 0x56, 0x4f, 0x63, 0x1f, 0x42, 0x6b, 0x4b, 0x7e, 0x4d, 0x18, 0x41, 0x2a, 0x43, 0x7b, 0x4c, 0x74, 0x4b, 0x51, 0x47, 0x65, 0x49, 0x24, 0x42, 0x68, 0x49, 0x56, 0x47, 0x75, 0x4a, 0x77, 0x4a, 0x31, 0x43, 0x1d, 0x41, 0x71, 0x49, 0x53, 0x46, 0x29, 0x42, 0x6b, 0x48, 0x1f, 0x41, 0x79, 0x49, 0x6f, 0x48, 0x7c, 0x49, 0x38, 0x43, 0x7f, 0x49, 0x5d, 0x46, 0x22, 0x41, 0x53, 0x45, 0x54, 0x45, 0x55, 0x45, 0x56, 0x45, 0x57, 0x45, 0x58, 0x45, 0x25, 0x41, 0x67, 0x46, 0x5b, 0x45, 0x41, 0x43, 0x78, 0x47, 0x27, 0x41, 0x51, 0x44, 0x13, 0x21, 0x7d, 0x47, 0x37, 0x42, 0x71, 0x46, 0x6b, 0x2d, 0x14, 0x21, 0x23, 0x23, 0x7d, 0x2f, 0x51, 0x29, 0x61, 0x2b, 0x79, 0x46, 0x1d, 0x22, 0x54, 0x29, 0x45, 0x27, 0x7d, 0x46, 0x7f, 0x46, 0x4f, 0x43, 0x2f, 0x41, 0x1f, 0x22, 0x6a, 0x2b, 0x6b, 0x2b, 0x5b, 0x29, 0x7e, 0x2d, 0x65, 0x44, 0x18, 0x21, 0x5e, 0x29, 0x2a, 0x23, 0x45, 0x26, 0x7b, 0x2c, 0x19, 0x21, 0x74, 0x2b, 0x75, 0x2b, 0x51, 0x27, 0x3f, 0x25, 0x65, 0x29, 0x40, 0x25, 0x24, 0x22, 0x41, 0x25, 0x68, 0x29, 0x42, 0x25, 0x56, 0x27, 0x7e, 0x2b, 0x75, 0x2a, 0x1c, 0x21, 0x77, 0x2a, 0x4f, 0x26, 0x31, 0x23, 0x6f, 0x29, 0x1d, 0x21, 0x32, 0x23, 0x71, 0x29, 0x72, 0x29, 0x53, 0x26, 0x69, 0x28, 0x29, 0x22, 0x75, 0x29, 0x6b, 0x28, 0x1f, 0x21, 0x1f, 0x21, 0x6d, 0x28, 0x79, 0x29, 0x2b, 0x22, 0x6f, 0x28, 0x59, 0x26, 0x7c, 0x29, 0x7d, 0x29, 0x38, 0x23, 0x21, 0x21, 0x7f, 0x29, 0x39, 0x23, 0x5d, 0x26, 0x75, 0x28, 0x22, 0x21, 0x77, 0x28, 0x53, 0x25, 0x6c, 0x27, 0x54, 0x25, 0x61, 0x26, 0x55, 0x25, 0x30, 0x22, 0x56, 0x25, 0x63, 0x26, 0x57, 0x25, 0x71, 0x27, 0x58, 0x25, 0x7f, 0x28, 0x25, 0x21, 0x74, 0x27, 0x67, 0x26, 0x40, 0x23, 0x5b, 0x25, 0x26, 0x21, 0x41, 0x23, 0x34, 0x22, 0x78, 0x27, 0x6b, 0x26, 0x27, 0x21, 0x35, 0x22, 0x51, 0x24, 0x7b, 0x27, 0x13, 0x1, 0x13, 0x1, 0x7d, 0x27, 0x4c, 0x9, 0x37, 0x22, 0x5b, 0xb, 0x71, 0x26, 0x5c, 0xb, 0x6b, 0xd, 0x47, 0x23, 0x14, 0x1, 0x4f, 0x9, 0x23, 0x3, 0x75, 0x26, 0x7d, 0xf, 0x1c, 0x2, 0x51, 0x9, 0x59, 0x24, 0x61, 0xb, 0x69, 0x25, 0x79, 0x26, 0x34, 0x5, 0x1d, 0x2, 0x6b, 0x25, 0x54, 0x9, 0x35, 0x5, 0x45, 0x7, 0x6d, 0x25, 0x7d, 0x26, 0x16, 0x1, 0x7f, 0x26, 0x77, 0xd, 0x4f, 0x23, 0x78, 0xd, 0x2f, 0x21, 0x27, 0x3, 0x1f, 0x2, 0x59, 0x9, 0x6a, 0xb, 0x73, 0x25, 0x6b, 0xb, 0x63, 0x24, 0x5b, 0x9, 0x20, 0x2, 0x7e, 0xd, 0x4b, 0x7, 0x65, 0x24, 0x43, 0x22, 0x18, 0x1, 0x6f, 0xb, 0x5e, 0x9, 0x70, 0xb, 0x2a, 0x3, 0x33, 0x4, 0x45, 0x6, 0x60, 0x9, 0x7b, 0xc, 0x19, 0x1, 0x19, 0x1, 0x7d, 0xc, 0x74, 0xb, 0x50, 0x7, 0x75, 0xb, 0x63, 0x9, 0x51, 0x7, 0x23, 0x2, 0x3f, 0x5, 0x1a, 0x1, 0x65, 0x9, 0x2d, 0x3, 0x40, 0x5, 0x0, 0x0,};/* Console colors */unsigned char cvconscolors[16][3] = { /* background, foreground, hilite */ /* R G B */ {0x30, 0x30, 0x30}, {0x00, 0x00, 0x00}, {0x80, 0x00, 0x00}, {0x00, 0x80, 0x00}, {0x00, 0x00, 0x80}, {0x80, 0x80, 0x00}, {0x00, 0x80, 0x80}, {0x80, 0x00, 0x80}, {0xff, 0xff, 0xff}, {0x40, 0x40, 0x40}, {0xff, 0x00, 0x00}, {0x00, 0xff, 0x00}, {0x00, 0x00, 0xff}, {0xff, 0xff, 0x00}, {0x00, 0xff, 0xff}, {0x00, 0x00, 0xff}};/* -------------------- Hardware specific routines ------------------------- *//* Read Attribute Controller Register=idx */inline unsigned char RAttr (volatile unsigned char *regs, short idx){ wb_64 (regs, ACT_ADDRESS_W, idx); mb(); udelay(100); return (rb_64(regs, ACT_ADDRESS_R));}/* Read Sequencer Register=idx */inline unsigned char RSeq (volatile unsigned char *regs, short idx){ wb_64 (regs, SEQ_ADDRESS, idx); mb(); return (rb_64(regs, SEQ_ADDRESS_R));}/* Read CRT Controller Register=idx */inline unsigned char RCrt (volatile unsigned char *regs, short idx){ wb_64 (regs, CRT_ADDRESS, idx); mb(); return (rb_64(regs, CRT_ADDRESS_R));}/* Read Graphics Controller Register=idx */inline unsigned char RGfx (volatile unsigned char *regs, short idx){ wb_64 (regs, GCT_ADDRESS, idx); mb(); return (rb_64(regs, GCT_ADDRESS_R));}/* * Special wakeup/passthrough registers on graphics boards */inline void cv64_write_port (unsigned short bits, volatile unsigned char *base){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -