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

📄 s3triofb.c

📁 S3C44B0X下的LCD (framebuffer)驱动资料与相关代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    mem_out8(0x50, s3trio_base+0x1008000 + 0x03D4);    /* disable HW cursor */    mem_out8(0x39, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0xa0, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x45, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x4e, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x4f, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0, s3trio_base+0x1008000 + 0x03D5);    /* init HW cursor */    CursorBase = (u_long *)(s3trio_base + 2*1024*1024 - 0x400);	for (i = 0; i < 8; i++) {		*(CursorBase  +(i*4)) = 0xffffff00;		*(CursorBase+1+(i*4)) = 0xffff0000;		*(CursorBase+2+(i*4)) = 0xffff0000;		*(CursorBase+3+(i*4)) = 0xffff0000;	}	for (i = 8; i < 64; i++) {		*(CursorBase  +(i*4)) = 0xffff0000;		*(CursorBase+1+(i*4)) = 0xffff0000;		*(CursorBase+2+(i*4)) = 0xffff0000;		*(CursorBase+3+(i*4)) = 0xffff0000;	}    mem_out8(0x4c, s3trio_base+0x1008000 + 0x03D4);    mem_out8(((2*1024 - 1)&0xf00)>>8, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x4d, s3trio_base+0x1008000 + 0x03D4);    mem_out8((2*1024 - 1) & 0xff, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x45, s3trio_base+0x1008000 + 0x03D4);    mem_in8(s3trio_base+0x1008000 + 0x03D4);    mem_out8(0x4a, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0x80, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x80, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x80, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x4b, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0x00, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x00, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x00, s3trio_base+0x1008000 + 0x03D5);    mem_out8(0x45, s3trio_base+0x1008000 + 0x03D4);    mem_out8(0, s3trio_base+0x1008000 + 0x03D5);    /* setup default color table */	for(i = 0; i < 16; i++) {		int j = color_table[i];		palette[i].red=default_red[j];		palette[i].green=default_grn[j];		palette[i].blue=default_blu[j];	}    s3trio_setcolreg(255, 56, 100, 160, 0, NULL /* not used */);    s3trio_setcolreg(254, 0, 0, 0, 0, NULL /* not used */);    memset((char *)s3trio_base, 0, 640*480);#if 0    Trio_RectFill(0, 0, 90, 90, 7, 1);#endif    fb_fix.visual = FB_VISUAL_PSEUDOCOLOR ;    fb_var.xoffset = fb_var.yoffset = 0;    fb_var.bits_per_pixel = 8;    fb_var.grayscale = 0;    fb_var.red.offset = fb_var.green.offset = fb_var.blue.offset = 0;    fb_var.red.length = fb_var.green.length = fb_var.blue.length = 8;    fb_var.red.msb_right = fb_var.green.msb_right = fb_var.blue.msb_right = 0;    fb_var.transp.offset = fb_var.transp.length = fb_var.transp.msb_right = 0;    fb_var.nonstd = 0;    fb_var.activate = 0;    fb_var.height = fb_var.width = -1;    fb_var.accel_flags = FB_ACCELF_TEXT;#warning FIXME: always obey fb_var.accel_flags    fb_var.pixclock = 1;    fb_var.left_margin = fb_var.right_margin = 0;    fb_var.upper_margin = fb_var.lower_margin = 0;    fb_var.hsync_len = fb_var.vsync_len = 0;    fb_var.sync = 0;    fb_var.vmode = FB_VMODE_NONINTERLACED;    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.screen_base = s3trio_base;    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 = 1;    disp.inverse = 0;#ifdef FBCON_HAS_CFB8    if (fb_var.accel_flags & FB_ACCELF_TEXT)	disp.dispsw = &fbcon_trio8;    else	disp.dispsw = &fbcon_cfb8;#else    disp.dispsw = &fbcon_dummy;#endif    disp.scrollmode = fb_var.accel_flags & FB_ACCELF_TEXT ? 0 : SCROLL_YREDRAW;    strcpy(fb_info.modename, "Trio64");    fb_info.node = -1;    fb_info.fbops = &s3trio_ops;#if 0    fb_info.fbvar_num = 1;    fb_info.fbvar = &fb_var;#endif    fb_info.disp = &disp;    fb_info.fontname[0] = '\0';    fb_info.changevar = NULL;    fb_info.switch_con = &s3triofbcon_switch;    fb_info.updatevar = &s3triofbcon_updatevar;    fb_info.blank = &s3triofbcon_blank;#if 0    fb_info.setcmap = &s3triofbcon_setcmap;#endif#ifdef CONFIG_FB_COMPAT_XPMAC    if (!console_fb_info) {	display_info.height = fb_var.yres;	display_info.width = fb_var.xres;	display_info.depth = 8;	display_info.pitch = fb_fix.line_length;	display_info.mode = 0;	strncpy(display_info.name, dp->name, sizeof(display_info.name));	display_info.fb_address = (unsigned long)fb_fix.smem_start;	display_info.disp_reg_address = address + 0x1008000;	display_info.cmap_adr_address = address + 0x1008000 + 0x3c8;	display_info.cmap_data_address = address + 0x1008000 + 0x3c9;	console_fb_info = &fb_info;    }#endif /* CONFIG_FB_COMPAT_XPMAC) */    fb_info.flags = FBINFO_FLAG_DEFAULT;    if (register_framebuffer(&fb_info) < 0)	return;    printk("fb%d: S3 Trio frame buffer device on %s\n",	   GET_FB_IDX(fb_info.node), dp->name);}static int s3triofbcon_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, s3trio_getcolreg, info);    currcon = con;    /* Install new colormap */    do_install_cmap(con,info);    return 0;}    /*     *  Update the `var' structure (called by fbcon.c)     */static int s3triofbcon_updatevar(int con, struct fb_info *info){    /* Nothing */    return 0;}    /*     *  Blank the display.     */static void s3triofbcon_blank(int blank, struct fb_info *info){    unsigned char x;    mem_out8(0x1, s3trio_base+0x1008000 + 0x03c4);    x = mem_in8(s3trio_base+0x1008000 + 0x03c5);    mem_out8((x & (~0x20)) | (blank << 5), s3trio_base+0x1008000 + 0x03c5);}    /*     *  Set the colormap     */#if 0static int s3triofbcon_setcmap(struct fb_cmap *cmap, int con){    return(s3trio_set_cmap(cmap, 1, con, &fb_info));}#endif    /*     *  Read a single color register and split it into     *  colors/transparent. Return != 0 for invalid regno.     */static int s3trio_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. Return != 0 for invalid regno.     */static int s3trio_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;    mem_out8(regno,s3trio_base+0x1008000 + 0x3c8);    mem_out8((red & 0xff) >> 2,s3trio_base+0x1008000 + 0x3c9);    mem_out8((green & 0xff) >> 2,s3trio_base+0x1008000 + 0x3c9);    mem_out8((blue & 0xff) >> 2,s3trio_base+0x1008000 + 0x3c9);    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, s3trio_setcolreg, &fb_info);    else	fb_set_cmap(fb_default_cmap(fb_display[con].var.bits_per_pixel), 1,		    s3trio_setcolreg, &fb_info);}static void Trio_WaitQueue(u_short fifo) {	u_short status;        do        {		status = mem_in16(s3trio_base + 0x1000000 + 0x9AE8);	}  while (!(status & fifo));}static void Trio_WaitBlit(void) {	u_short status;        do        {		status = mem_in16(s3trio_base + 0x1000000 + 0x9AE8);	}  while (status & 0x200);}static void Trio_BitBLT(u_short curx, u_short cury, u_short destx,			u_short desty, u_short width, u_short height,			u_short mode) {	u_short blitcmd = 0xc011;	/* Set drawing direction */        /* -Y, X maj, -X (default) */	if (curx > destx)		blitcmd |= 0x0020;  /* Drawing direction +X */	else {		curx  += (width - 1);		destx += (width - 1);	}	if (cury > desty)		blitcmd |= 0x0080;  /* Drawing direction +Y */	else {		cury  += (height - 1);		desty += (height - 1);	}	Trio_WaitQueue(0x0400);	outw(0xa000,  0xBEE8);	outw(0x60 | mode,  0xBAE8);	outw(curx,  0x86E8);	outw(cury,  0x82E8);	outw(destx,  0x8EE8);	outw(desty,  0x8AE8);	outw(height - 1,  0xBEE8);	outw(width - 1,  0x96E8);	outw(blitcmd,  0x9AE8);}static void Trio_RectFill(u_short x, u_short y, u_short width, u_short height,			  u_short mode, u_short color) {	u_short blitcmd = 0x40b1;	Trio_WaitQueue(0x0400);	outw(0xa000,  0xBEE8);	outw((0x20 | mode),  0xBAE8);	outw(0xe000,  0xBEE8);	outw(color,  0xA6E8);	outw(x,  0x86E8);	outw(y,  0x82E8);	outw((height - 1), 0xBEE8);	outw((width - 1), 0x96E8);	outw(blitcmd,  0x9AE8);}static void Trio_MoveCursor(u_short x, u_short y) {	mem_out8(0x39, s3trio_base + 0x1008000 + 0x3d4);	mem_out8(0xa0, s3trio_base + 0x1008000 + 0x3d5);	mem_out8(0x46, s3trio_base + 0x1008000 + 0x3d4);	mem_out8((x & 0x0700) >> 8, s3trio_base + 0x1008000 + 0x3d5);	mem_out8(0x47, s3trio_base + 0x1008000 + 0x3d4);	mem_out8(x & 0x00ff, s3trio_base + 0x1008000 + 0x3d5);	mem_out8(0x48, s3trio_base + 0x1008000 + 0x3d4);	mem_out8((y & 0x0700) >> 8, s3trio_base + 0x1008000 + 0x3d5);	mem_out8(0x49, s3trio_base + 0x1008000 + 0x3d4);	mem_out8(y & 0x00ff, s3trio_base + 0x1008000 + 0x3d5);}    /*     *  Text console acceleration     */#ifdef FBCON_HAS_CFB8static void fbcon_trio8_bmove(struct display *p, int sy, int sx, int dy,			      int dx, int height, int width){    sx *= 8; dx *= 8; width *= 8;    Trio_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);}static void fbcon_trio8_clear(struct vc_data *conp, struct display *p, int sy,			      int sx, int height, int width){    unsigned char bg;    sx *= 8; width *= 8;    bg = attr_bgcol_ec(p,conp);    Trio_RectFill((u_short)sx,		   (u_short)(sy*fontheight(p)),		   (u_short)width,		   (u_short)(height*fontheight(p)),		   (u_short)S3_NEW,		   (u_short)bg);}static void fbcon_trio8_putc(struct vc_data *conp, struct display *p, int c,			     int yy, int xx){    Trio_WaitBlit();    fbcon_cfb8_putc(conp, p, c, yy, xx);}static void fbcon_trio8_putcs(struct vc_data *conp, struct display *p,			      const unsigned short *s, int count, int yy, int xx){    Trio_WaitBlit();    fbcon_cfb8_putcs(conp, p, s, count, yy, xx);}static void fbcon_trio8_revc(struct display *p, int xx, int yy){    Trio_WaitBlit();    fbcon_cfb8_revc(p, xx, yy);}static struct display_switch fbcon_trio8 = {   setup:		fbcon_cfb8_setup,   bmove:		fbcon_trio8_bmove,   clear:		fbcon_trio8_clear,   putc:		fbcon_trio8_putc,   putcs:		fbcon_trio8_putcs,   revc:		fbcon_trio8_revc,   clear_margins:	fbcon_cfb8_clear_margins,   fontwidthmask:	FONTWIDTH(8)};#endif#ifdef MODULEmodule_init(s3triofb_init);MODULE_LICENSE("GPL");#endifmodule_exit(s3triofb_exit);

⌨️ 快捷键说明

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