📄 sun3fb.c
字号:
memcpy(fontname, p+5, i); fontname[i] = 0; } else if (!strncmp(p, "noblink", 7)) curblink = 0; while (*p && *p != ' ' && *p != ',') p++; if (*p != ',') break; p++; } return 0;}static int sun3fbcon_switch(int con, struct fb_info *info){ int x_margin, y_margin; struct fb_info_sbusfb *fb = sbusfbinfo(info); int lastconsole; /* Do we have to save the colormap? */ if (fb_display[currcon].cmap.len) fb_get_cmap(&fb_display[currcon].cmap, 1, sun3fb_getcolreg, info); if (info->display_fg) { lastconsole = info->display_fg->vc_num; if (lastconsole != con && (fontwidth(&fb_display[lastconsole]) != fontwidth(&fb_display[con]) || fontheight(&fb_display[lastconsole]) != fontheight(&fb_display[con]))) fb->cursor.mode |= CURSOR_SHAPE; } x_margin = (fb_display[con].var.xres_virtual - fb_display[con].var.xres) / 2; y_margin = (fb_display[con].var.yres_virtual - fb_display[con].var.yres) / 2; if (fb->margins) fb->margins(fb, &fb_display[con], x_margin, y_margin); if (fb->graphmode || fb->x_margin != x_margin || fb->y_margin != y_margin) { fb->x_margin = x_margin; fb->y_margin = y_margin; sun3fb_clear_margin(&fb_display[con], 0); } currcon = con; /* Install new colormap */ do_install_cmap(con, info); return 0;} /* * Update the `var' structure (called by fbcon.c) */static int sun3fbcon_updatevar(int con, struct fb_info *info){ /* Nothing */ return 0;} /* * Blank the display. */static void sun3fbcon_blank(int blank, struct fb_info *info){ struct fb_info_sbusfb *fb = sbusfbinfo(info); if (blank && fb->blank) return fb->blank(fb); else if (!blank && fb->unblank) return fb->unblank(fb);} /* * Read a single color register and split it into * colors/transparent. Return != 0 for invalid regno. */static int sun3fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *info){ struct fb_info_sbusfb *fb = sbusfbinfo(info); if (!fb->color_map || regno > 255) return 1; *red = (fb->color_map CM(regno, 0)<<8) | fb->color_map CM(regno, 0); *green = (fb->color_map CM(regno, 1)<<8) | fb->color_map CM(regno, 1); *blue = (fb->color_map CM(regno, 2)<<8) | fb->color_map CM(regno, 2); *transp = 0; return 0;} /* * Set a single color register. The values supplied are already * rounded down to the hardware's capabilities (according to the * entries in the var structure). Return != 0 for invalid regno. */static int sun3fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info){ struct fb_info_sbusfb *fb = sbusfbinfo(info); if (!fb->color_map || regno > 255) return 1; red >>= 8; green >>= 8; blue >>= 8; fb->color_map CM(regno, 0) = red; fb->color_map CM(regno, 1) = green; fb->color_map CM(regno, 2) = blue; return 0;}static void do_install_cmap(int con, struct fb_info *info){ struct fb_info_sbusfb *fb = sbusfbinfo(info); if (con != currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, sun3fb_setcolreg, info); else fb_set_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), 1, sun3fb_setcolreg, info); if (fb->loadcmap) (*fb->loadcmap)(fb, &fb_display[con], 0, 256);}static int sun3fb_set_font(struct display *p, int width, int height){ int w = p->var.xres_virtual, h = p->var.yres_virtual; int depth = p->var.bits_per_pixel; struct fb_info_sbusfb *fb = sbusfbinfod(p); int x_margin, y_margin; if (depth > 8) depth = 8; x_margin = (w % width) / 2; y_margin = (h % height) / 2; p->var.xres = w - 2*x_margin; p->var.yres = h - 2*y_margin; fb->cursor.mode |= CURSOR_SHAPE; if (fb->margins) fb->margins(fb, p, x_margin, y_margin); if (fb->x_margin != x_margin || fb->y_margin != y_margin) { fb->x_margin = x_margin; fb->y_margin = y_margin; sun3fb_clear_margin(p, 0); } return 1;}void sun3fb_palette(int enter){ int i; struct display *p; for (i = 0; i < MAX_NR_CONSOLES; i++) { p = &fb_display[i]; if (p->dispsw && p->dispsw->setup == sun3fb_disp_setup && p->fb_info->display_fg && p->fb_info->display_fg->vc_num == i) { struct fb_info_sbusfb *fb = sbusfbinfod(p); if (fb->restore_palette) { if (enter) fb->restore_palette(fb); else if (vt_cons[i]->vc_mode != KD_GRAPHICS) vc_cons[i].d->vc_sw->con_set_palette(vc_cons[i].d, color_table); } } }} /* * Initialisation */static int __init sun3fb_init_fb(int fbtype, unsigned long addr){ static struct linux_sbus_device sdb; struct fb_fix_screeninfo *fix; struct fb_var_screeninfo *var; struct display *disp; struct fb_info_sbusfb *fb; struct fbtype *type; int linebytes, w, h, depth; char *p = NULL; fb = kmalloc(sizeof(struct fb_info_sbusfb), GFP_ATOMIC); if (!fb) return -ENOMEM; memset(fb, 0, sizeof(struct fb_info_sbusfb)); fix = &fb->fix; var = &fb->var; disp = &fb->disp; type = &fb->type; sdb.reg_addrs[0].phys_addr = addr; fb->sbdp = &sdb; type->fb_type = fbtype; type->fb_height = h = 900; type->fb_width = w = 1152;sizechange: type->fb_depth = depth = (fbtype == FBTYPE_SUN2BW) ? 1 : 8; linebytes = w * depth / 8; type->fb_size = PAGE_ALIGN((linebytes) * h); fb->x_margin = (w & 7) / 2; fb->y_margin = (h & 15) / 2; var->xres_virtual = w; var->yres_virtual = h; var->xres = w - 2*fb->x_margin; var->yres = h - 2*fb->y_margin; var->bits_per_pixel = depth; var->height = var->width = -1; var->pixclock = 10000; var->vmode = FB_VMODE_NONINTERLACED; var->red.length = var->green.length = var->blue.length = 8; fix->line_length = linebytes; fix->smem_len = type->fb_size; fix->type = FB_TYPE_PACKED_PIXELS; fix->visual = FB_VISUAL_PSEUDOCOLOR; fb->info.node = -1; fb->info.fbops = &sun3fb_ops; fb->info.disp = disp; strcpy(fb->info.fontname, fontname); fb->info.changevar = NULL; fb->info.switch_con = &sun3fbcon_switch; fb->info.updatevar = &sun3fbcon_updatevar; fb->info.blank = &sun3fbcon_blank; fb->info.flags = FBINFO_FLAG_DEFAULT; fb->cursor.hwsize.fbx = 32; fb->cursor.hwsize.fby = 32; if (depth > 1 && !fb->color_map) { if((fb->color_map = kmalloc(256 * 3, GFP_ATOMIC))==NULL) return -ENOMEM; } switch(fbtype) {#ifdef CONFIG_FB_CGSIX case FBTYPE_SUNFAST_COLOR: p = cgsixfb_init(fb); break;#endif#ifdef CONFIG_FB_BWTWO case FBTYPE_SUN2BW: p = bwtwofb_init(fb); break;#endif } fix->smem_start = fb->disp.screen_base; if (!p) { kfree(fb); return -ENODEV; } if (p == SBUSFBINIT_SIZECHANGE) goto sizechange; disp->dispsw = &fb->dispsw; if (fb->setcursor) { fb->dispsw.cursor = sun3fb_cursor; if (curblink) { fb->cursor.blink_rate = DEFAULT_CURSOR_BLINK_RATE; init_timer(&fb->cursor.timer); fb->cursor.timer.expires = jiffies + fb->cursor.blink_rate; fb->cursor.timer.data = (unsigned long)fb; fb->cursor.timer.function = sun3fb_cursor_timer_handler; add_timer(&fb->cursor.timer); } } fb->cursor.mode = CURSOR_SHAPE; fb->dispsw.set_font = sun3fb_set_font; fb->setup = fb->dispsw.setup; fb->dispsw.setup = sun3fb_disp_setup; fb->dispsw.clear_margins = NULL; disp->var = *var; disp->visual = fix->visual; disp->type = fix->type; disp->type_aux = fix->type_aux; disp->line_length = fix->line_length; if (fb->blank) disp->can_soft_blank = 1; sun3fb_set_var(var, -1, &fb->info); if (register_framebuffer(&fb->info) < 0) { kfree(fb); return -EINVAL; } printk("fb%d: %s\n", GET_FB_IDX(fb->info.node), p); return 0;}int __init sun3fb_init(void){ extern int con_is_present(void); unsigned long addr; char p4id; if (!con_is_present()) return; printk("sun3fb_init()\n");#ifdef CONFIG_SUN3 addr = 0xfe20000; switch(*(romvec->pv_fbtype)) { case FBTYPE_SUN2BW: return sun3fb_init_fb(FBTYPE_SUN2BW, addr); case FBTYPE_SUN3COLOR: printk("cg3 detected but not supported\n"); return -EINVAL; }#else addr = SUN3X_VIDEO_BASE; p4id = *(char *)SUN3X_VIDEO_P4ID; p4id = (p4id == 0x45) ? p4id : (p4id & 0xf0); switch (p4id) { case 0x00: return sun3fb_init_fb(FBTYPE_SUN2BW, addr);#if 0 /* not yet */ case 0x40: sun3fb_init_fb(FBTYPE_SUN4COLOR, addr); break; case 0x45: sun3fb_init_fb(FBTYPE_SUN8COLOR, addr); break;#endif case 0x60: return sun3fb_init_fb(FBTYPE_SUNFAST_COLOR, addr); }#endif }MODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -