fb_core.c

来自「SMDK2440 boot code, base on vivi」· C语言 代码 · 共 155 行

C
155
字号
#include <config.h>#include <vstring.h>#include <types.h>#include <command.h>#include <fb_core.h>#define INCLUDE_VIVI_LOGO_DATA#include <vivi_logo.h>#define CONFIG_FB_LOGO_CENTER#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C2440)extern void s3c2410fb_init(struct vivi_fb **fb);#endif#ifdef CONFIG_ARCH_PXA250extern void pxa250fb_init(struct vivi_fb **fb);#endif//#ifdef CONFIG_ARCH_S3C2440//extern void s3c2440fb_init(struct vivi_fb **fb);//#endifstatic struct vivi_fb *fb = NULL;#define MIN__(x,y) ((x) > (y) ? (y) : (x))static void fb_show_logo(struct vivi_fb *fb){	int i,j;	unsigned char *cur_line;	int byte_per_pixel = (fb->bpp + 7) / 8;	int center_offset = 0;	int x_end = MIN__(VIVI_LOGO_W, fb->xres);	int y_end = MIN__(VIVI_LOGO_H, fb->yres);#ifdef CONFIG_FB_LOGO_CENTER	int y_offset = 0;	int x_offset = 0;	x_offset = (fb->xres - x_end + 1) / 2;	y_offset = (fb->yres - y_end + 1) / 2;	center_offset = y_offset * fb->line_length;	center_offset += x_offset * byte_per_pixel;#endif	if (!fb || !fb->mem || fb->bpp != 16)		return;	/* clear background */	memset(fb->mem, 0, fb->yres * fb->line_length);	for (i=0; i < y_end; i++) {		cur_line = (unsigned char*)(fb->mem + i * fb->line_length 				+ center_offset);		for (j=0; j < x_end; j++) {			*(unsigned short*)cur_line = 					vivi_logo_cmap[vivi_logo_data[i*VIVI_LOGO_W+j]];			cur_line += byte_per_pixel;		}	}}#ifdef CONFIG_FB_TESTCMDstatic void command_lcd_help(int argc, const char **argv){	printk("%s %s\t\t- %s\n",		"lcd", "rgb", "test RGB pattern");}static void command_lcd_rgb(int argc, const char **argv){	unsigned short *tmp_fb = (unsigned short *)fb->mem;	unsigned long LCD_length;	int i;	if (!fb->mem || fb->bpp != 16)		return;	LCD_length = fb->xres * fb->yres / 3;	for (i=0; i< LCD_length; i++) {		*(tmp_fb + i) = 0xF800; // red		*(tmp_fb + i + LCD_length) = 0x07e0; // green		*(tmp_fb + i + LCD_length * 2) = 0x001f; // blue	}}void command_lcd(int argc, const char **argv){	if (fb == NULL) {		printk("Error: Can not find LCD information\n");		return;	}	if (argc == 1) {		printk("invalid 'lcd' command: too few arguments\n");		command_lcd_help(0, NULL);		return;	}	if (strncmp("rgb", argv[1], 4) == 0) {		command_lcd_rgb(argc, argv);		return;	}	command_lcd_help(0, NULL);}static user_command_t lcd_cmd = {	"lcd",	command_lcd,	NULL,};#endifvoid fb_init(void){#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C2440)	s3c2410fb_init( &fb );#endif#ifdef CONFIG_ARCH_S3C24A0	s3c24a0fb_init( &fb );#endif#ifdef CONFIG_ARCH_PXA250	pxa250fb_init( &fb );#endif//#ifdef CONFIG_ARCH_S3C2440//	s3c2440fb_init( &fb );//#endif#if defined(CONFIG_PXA27X_I730) || defined(CONFIG_PXA27X_I819)		pxa27xfb_init( &fb );#endif#ifdef CONFIG_ARCH_MMSP2	mmsp2fb_init( &fb );#endif	if (!fb) {		printk("There is not FrameBuffer H/W initializer.\n");		return;	}	if (fb->line_length < (fb->xres * ((fb->bpp + 7) / 8))) {		fb->line_length = fb->xres * ((fb->bpp + 7) / 8);	}	fb_show_logo(fb);#ifdef CONFIG_FB_TESTCMD	add_command(&lcd_cmd);#endif}

⌨️ 快捷键说明

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