⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc68x328fb.c

📁 S3C44B0X下的LCD (framebuffer)驱动资料与相关代码
💻 C
📖 第 1 页 / 共 2 页
字号:
     *  Pan or Wrap the Display     *     *  This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag     */static int mc68x328fb_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 mc68x328fb_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, mc68x328fb_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 mc68x328fb_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, mc68x328fb_setcolreg, info);    else	fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);    return 0;}int __init mc68x328fb_setup(char *options){    char *this_opt;    fb_info.fontname[0] = '\0';    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 mc68x328fb_init(void){	/*	 *  initialize the default mode from the LCD controller registers	 */	mc68x328fb_default.xres = LXMAX;	mc68x328fb_default.yres = LYMAX+1;	mc68x328fb_default.xres_virtual = mc68x328fb_default.xres;	mc68x328fb_default.yres_virtual = mc68x328fb_default.yres;	mc68x328fb_default.bits_per_pixel = 1 + (LPICF & 0x01);	videomemory = LSSA;	videomemorysize = (mc68x328fb_default.xres+7) / 8 *		mc68x328fb_default.yres * mc68x328fb_default.bits_per_pixel;    strcpy(fb_info.modename, mc68x328fb_name);    fb_info.changevar = NULL;    fb_info.node = -1;    fb_info.fbops = &mc68x328fb_ops;    fb_info.disp = &disp;    fb_info.switch_con = &vfbcon_switch;    fb_info.updatevar = &vfbcon_updatevar;    fb_info.blank = &vfbcon_blank;    fb_info.flags = FBINFO_FLAG_DEFAULT;    mc68x328fb_set_var(&mc68x328fb_default, -1, &fb_info);    if (register_framebuffer(&fb_info) < 0) {	return -EINVAL;    }    printk(KERN_INFO "fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.node),		mc68x328fb_name);	printk(KERN_INFO "fb%d: %dx%dx%d at 0x%08lx\n", GET_FB_IDX(fb_info.node),		mc68x328fb_default.xres, mc68x328fb_default.yres,		1 << mc68x328fb_default.bits_per_pixel, videomemory);    return 0;}static int vfbcon_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, mc68x328fb_getcolreg, info);    currcon = con;    /* Install new colormap */    do_install_cmap(con, info);    return 0;}    /*     *  Update the `var' structure (called by fbcon.c)     */static int vfbcon_updatevar(int con, struct fb_info *info){    /* Nothing */    return 0;}    /*     *  Blank the display.     */static void vfbcon_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 mc68x328fb_encode_fix(struct fb_fix_screeninfo *fix,			   struct fb_var_screeninfo *var){    memset(fix, 0, sizeof(struct fb_fix_screeninfo));    strcpy(fix->id, mc68x328fb_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 = MC68X328FB_MONO_VISUAL;	    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 mc68x328fb_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 mc68x328fb_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, mc68x328fb_setcolreg, info);    else	fb_set_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), 1,		    mc68x328fb_setcolreg, info);}#ifdef MODULEMODULE_LICENSE("GPL");int init_module(void){    return mc68x328fb_init();}void cleanup_module(void){    unregister_framebuffer(&fb_info);}#endif /* MODULE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -