📄 vfb_small.c
字号:
*/static int vfb_small_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info){ if (var->vmode & FB_VMODE_YWRAP) { if (var->yoffset < 0 || var->yoffset >= fb_display[con].var.yres_virtual || var->xoffset) return -EINVAL; } else { if (var->xoffset+fb_display[con].var.xres > fb_display[con].var.xres_virtual || var->yoffset+fb_display[con].var.yres > fb_display[con].var.yres_virtual) return -EINVAL; } fb_display[con].var.xoffset = var->xoffset; fb_display[con].var.yoffset = var->yoffset; if (var->vmode & FB_VMODE_YWRAP) fb_display[con].var.vmode |= FB_VMODE_YWRAP; else fb_display[con].var.vmode &= ~FB_VMODE_YWRAP; return 0;} /* * Get the Colormap */static int vfb_small_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ if (con == currcon) /* current console? */ return fb_get_cmap(cmap, kspc, vfb_small_getcolreg, info); else if (fb_display[con].cmap.len) /* non default colormap? */ fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); else fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), cmap, kspc ? 0 : 2); return 0;} /* * Set the Colormap */static int vfb_small_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ int err; 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))) return err; } if (con == currcon) /* current console? */ return fb_set_cmap(cmap, kspc, vfb_small_setcolreg, info); else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); return 0;}int __init vfb_small_setup(char *options){ char *this_opt; fb_info.fontname[0] = '\0'; vfb_small_enable = 1; if (!options || !*options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { if (!strncmp(this_opt, "font:", 5)) strcpy(fb_info.fontname, this_opt+5); } return 0;} /* * Initialisation */int __init vfb_small_init(void){ if (!vfb_small_enable) return -ENXIO; if (!(videomemory = (u_long)vmalloc(videomemorysize))) return -ENOMEM; strcpy(fb_info.modename, vfb_small_name); fb_info.changevar = NULL; fb_info.node = -1; fb_info.fbops = &vfb_small_ops; fb_info.disp = &disp; fb_info.switch_con = &vfb_smallcon_switch; fb_info.updatevar = &vfb_smallcon_updatevar; fb_info.blank = &vfb_smallcon_blank; fb_info.flags = FBINFO_FLAG_DEFAULT; vfb_small_set_var(&vfb_small_default, -1, &fb_info); if (register_framebuffer(&fb_info) < 0) { vfree((void *)videomemory); return -EINVAL; } printk(KERN_INFO "fb%d: Virtual frame buffer device, using %ldK of video memory\n", GET_FB_IDX(fb_info.node), videomemorysize>>10); return 0;}static int vfb_smallcon_switch(int con, struct fb_info *info){ /* Do we have to save the colormap? */ if (fb_display[currcon].cmap.len) fb_get_cmap(&fb_display[currcon].cmap, 1, vfb_small_getcolreg, info); currcon = con; /* Install new colormap */ do_install_cmap(con, info); return 0;} /* * Update the `var' structure (called by fbcon.c) */static int vfb_smallcon_updatevar(int con, struct fb_info *info){ /* Nothing */ return 0;} /* * Blank the display. */static void vfb_smallcon_blank(int blank, struct fb_info *info){ /* Nothing */}static u_long get_line_length(int xres_virtual, int bpp){ u_long length; length = xres_virtual*bpp; length = (length+31)&-32; length >>= 3; return(length);}static void vfb_small_encode_fix(struct fb_fix_screeninfo *fix, struct fb_var_screeninfo *var){ memset(fix, 0, sizeof(struct fb_fix_screeninfo)); strcpy(fix->id, vfb_small_name); fix->smem_start = videomemory; fix->smem_len = videomemorysize; fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; switch (var->bits_per_pixel) { case 1: fix->visual = FB_VISUAL_MONO01; break; case 2: case 4: case 8: fix->visual = FB_VISUAL_PSEUDOCOLOR; break; case 16: case 24: case 32: fix->visual = FB_VISUAL_TRUECOLOR; break; } fix->ywrapstep = 1; fix->xpanstep = 1; fix->ypanstep = 1; fix->line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);}static void set_color_bitfields(struct fb_var_screeninfo *var){ switch (var->bits_per_pixel) { case 1: 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 = 0; var->red.length = 5; var->green.offset = 5; var->green.length = 6; var->blue.offset = 11; var->blue.length = 5; var->transp.offset = 0; var->transp.length = 0; break; case 24: /* RGB 888 */ var->red.offset = 0; var->red.length = 8; var->green.offset = 8; var->green.length = 8; var->blue.offset = 16; var->blue.length = 8; var->transp.offset = 0; var->transp.length = 0; break; case 32: /* RGBA 8888 */ var->red.offset = 0; var->red.length = 8; var->green.offset = 8; var->green.length = 8; var->blue.offset = 16; var->blue.length = 8; var->transp.offset = 24; var->transp.length = 8; break; } var->red.msb_right = 0; var->green.msb_right = 0; var->blue.msb_right = 0; var->transp.msb_right = 0;} /* * Read a single color register and split it into * colors/transparent. Return != 0 for invalid regno. */static int vfb_small_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *info){ if (regno > 255) return 1; *red = (palette[regno].red<<8) | palette[regno].red; *green = (palette[regno].green<<8) | palette[regno].green; *blue = (palette[regno].blue<<8) | palette[regno].blue; *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 vfb_small_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info){ if (regno > 255) return 1; red >>= 8; green >>= 8; blue >>= 8; palette[regno].red = red; palette[regno].green = green; palette[regno].blue = blue; return 0;}static void do_install_cmap(int con, struct fb_info *info){ if (con != currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, vfb_small_setcolreg, info); else fb_set_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), 1, vfb_small_setcolreg, info);}#ifdef MODULEMODULE_LICENSE("GPL");int init_module(void){ return vfb_small_init();}void cleanup_module(void){ unregister_framebuffer(&fb_info); vfree((void *)videomemory);}#endif /* MODULE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -