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

📄 cfb_console.c

📁 uboot详细解读可用启动引导LINUX2.6内核
💻 C
📖 第 1 页 / 共 3 页
字号:
			c = *s;			cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;			for (rows = VIDEO_FONT_HEIGHT, dest = dest0;			     rows--;			     dest += VIDEO_LINE_LEN) {				u8 bits = *cdat++;				((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 6] & eorx) ^ bgx);				((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 4 & 3] & eorx) ^ bgx);				((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 2 & 3] & eorx) ^ bgx);				((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table16 [bits & 3] & eorx) ^ bgx);			}			dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;			s++;		}		break;	case GDF_32BIT_X888RGB:		while (count--) {			c = *s;			cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;			for (rows = VIDEO_FONT_HEIGHT, dest = dest0;			     rows--;			     dest += VIDEO_LINE_LEN) {				u8 bits = *cdat++;				((u32 *) dest)[0] = SWAP32 ((video_font_draw_table32 [bits >> 4][0] & eorx) ^ bgx);				((u32 *) dest)[1] = SWAP32 ((video_font_draw_table32 [bits >> 4][1] & eorx) ^ bgx);				((u32 *) dest)[2] = SWAP32 ((video_font_draw_table32 [bits >> 4][2] & eorx) ^ bgx);				((u32 *) dest)[3] = SWAP32 ((video_font_draw_table32 [bits >> 4][3] & eorx) ^ bgx);				((u32 *) dest)[4] = SWAP32 ((video_font_draw_table32 [bits & 15][0] & eorx) ^ bgx);				((u32 *) dest)[5] = SWAP32 ((video_font_draw_table32 [bits & 15][1] & eorx) ^ bgx);				((u32 *) dest)[6] = SWAP32 ((video_font_draw_table32 [bits & 15][2] & eorx) ^ bgx);				((u32 *) dest)[7] = SWAP32 ((video_font_draw_table32 [bits & 15][3] & eorx) ^ bgx);			}			dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;			s++;		}		break;	case GDF_24BIT_888RGB:		while (count--) {			c = *s;			cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;			for (rows = VIDEO_FONT_HEIGHT, dest = dest0;			     rows--;			     dest += VIDEO_LINE_LEN) {				u8 bits = *cdat++;				((u32 *) dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx;				((u32 *) dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx;				((u32 *) dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx;				((u32 *) dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx;				((u32 *) dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx;				((u32 *) dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx;			}			dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;			s++;		}		break;	}}/*****************************************************************************/static inline void video_drawstring (int xx, int yy, unsigned char *s){	video_drawchars (xx, yy, s, strlen ((char *)s));}/*****************************************************************************/static void video_putchar (int xx, int yy, unsigned char c){	video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1);}/*****************************************************************************/#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)static void video_set_cursor (void){	/* swap drawing colors */	eorx = fgx;	fgx = bgx;	bgx = eorx;	eorx = fgx ^ bgx;	/* draw cursor */	video_putchar (console_col * VIDEO_FONT_WIDTH,		       console_row * VIDEO_FONT_HEIGHT,		       ' ');	/* restore drawing colors */	eorx = fgx;	fgx = bgx;	bgx = eorx;	eorx = fgx ^ bgx;}#endif/*****************************************************************************/#ifdef CONFIG_CONSOLE_CURSORvoid console_cursor (int state){	static int last_state = 0;#ifdef CONFIG_CONSOLE_TIME	struct rtc_time tm;	char info[16];	/* time update only if cursor is on (faster scroll) */	if (state) {		rtc_get (&tm);		sprintf (info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,			 tm.tm_sec);		video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,				  VIDEO_INFO_Y, (uchar *)info);		sprintf (info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,			 tm.tm_year);		video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,				  VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, (uchar *)info);	}#endif	if (state && (last_state != state)) {		video_set_cursor ();	}	if (!state && (last_state != state)) {		/* clear cursor */		video_putchar (console_col * VIDEO_FONT_WIDTH,			       console_row * VIDEO_FONT_HEIGHT,			       ' ');	}	last_state = state;}#endif/*****************************************************************************/#ifndef VIDEO_HW_RECTFILLstatic void memsetl (int *p, int c, int v){	while (c--)		*(p++) = v;}#endif/*****************************************************************************/#ifndef VIDEO_HW_BITBLTstatic void memcpyl (int *d, int *s, int c){	while (c--)		*(d++) = *(s++);}#endif/*****************************************************************************/static void console_scrollup (void){	/* copy up rows ignoring the first one */#ifdef VIDEO_HW_BITBLT	video_hw_bitblt (VIDEO_PIXEL_SIZE,	/* bytes per pixel */			 0,	/* source pos x */			 VIDEO_LOGO_HEIGHT + VIDEO_FONT_HEIGHT, /* source pos y */			 0,	/* dest pos x */			 VIDEO_LOGO_HEIGHT,	/* dest pos y */			 VIDEO_VISIBLE_COLS,	/* frame width */			 VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT	/* frame height */		);#else	memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,		 CONSOLE_SCROLL_SIZE >> 2);#endif	/* clear the last one */#ifdef VIDEO_HW_RECTFILL	video_hw_rectfill (VIDEO_PIXEL_SIZE,	/* bytes per pixel */			   0,	/* dest pos x */			   VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT,	/* dest pos y */			   VIDEO_VISIBLE_COLS,	/* frame width */			   VIDEO_FONT_HEIGHT,	/* frame height */			   CONSOLE_BG_COL	/* fill color */		);#else	memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);#endif}/*****************************************************************************/static void console_back (void){	CURSOR_OFF console_col--;	if (console_col < 0) {		console_col = CONSOLE_COLS - 1;		console_row--;		if (console_row < 0)			console_row = 0;	}	video_putchar (console_col * VIDEO_FONT_WIDTH,		       console_row * VIDEO_FONT_HEIGHT,		       ' ');}/*****************************************************************************/static void console_newline (void){	/* Check if last character in the line was just drawn. If so, cursor was	   overwriten and need not to be cleared. Cursor clearing without this	   check causes overwriting the 1st character of the line if line lenght	   is >= CONSOLE_COLS	 */	if (console_col < CONSOLE_COLS)		CURSOR_OFF	console_row++;	console_col = 0;	/* Check if we need to scroll the terminal */	if (console_row >= CONSOLE_ROWS) {		/* Scroll everything up */		console_scrollup ();		/* Decrement row number */		console_row--;	}}static void console_cr (void){	CURSOR_OFF console_col = 0;}/*****************************************************************************/void video_putc (const char c){	static int nl = 1;	switch (c) {	case 13:		/* back to first column */		console_cr ();		break;	case '\n':		/* next line */		if (console_col || (!console_col && nl))			console_newline ();		nl = 1;		break;	case 9:		/* tab 8 */		CURSOR_OFF console_col |= 0x0008;		console_col &= ~0x0007;		if (console_col >= CONSOLE_COLS)			console_newline ();		break;	case 8:		/* backspace */		console_back ();		break;	default:		/* draw the char */		video_putchar (console_col * VIDEO_FONT_WIDTH,			       console_row * VIDEO_FONT_HEIGHT,			       c);		console_col++;		/* check for newline */		if (console_col >= CONSOLE_COLS) {			console_newline ();			nl = 0;		}	}CURSOR_SET}/*****************************************************************************/void video_puts (const char *s){	int count = strlen (s);	while (count--)		video_putc (*s++);}/*****************************************************************************/#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)#define FILL_8BIT_332RGB(r,g,b)	{			\	*fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6);	\	fb ++;						\}#define FILL_15BIT_555RGB(r,g,b) {			\	*(unsigned short *)fb = SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3))); \	fb += 2;					\}#define FILL_16BIT_565RGB(r,g,b) {			\	*(unsigned short *)fb = SWAP16((unsigned short)((((r)>>3)<<11) | (((g)>>2)<<5) | ((b)>>3))); \	fb += 2;					\}#define FILL_32BIT_X888RGB(r,g,b) {			\	*(unsigned long *)fb = SWAP32((unsigned long)(((r<<16) | (g<<8) | b))); \	fb += 4;					\}#ifdef VIDEO_FB_LITTLE_ENDIAN#define FILL_24BIT_888RGB(r,g,b) {			\	fb[0] = b;					\	fb[1] = g;					\	fb[2] = r;					\	fb += 3;					\}#else#define FILL_24BIT_888RGB(r,g,b) {			\	fb[0] = r;					\	fb[1] = g;					\	fb[2] = b;					\	fb += 3;					\}#endif#if defined(VIDEO_FB_16BPP_PIXEL_SWAP)static void inline fill_555rgb_pswap(uchar *fb, int x,				     u8 r, u8 g, u8 b){	ushort *dst = (ushort *)fb;	ushort color = (ushort)(((r >> 3) << 10) |				((g >> 3) << 5) |				(b >> 3));	if (x & 1)		*(--dst) = color;	else		*(++dst) = color;}#endif/* * Display the BMP file located at address bmp_image. * Only uncompressed */int video_display_bitmap (ulong bmp_image, int x, int y){	ushort xcount, ycount;	uchar *fb;	bmp_image_t *bmp = (bmp_image_t *) bmp_image;	uchar *bmap;	ushort padded_line;	unsigned long width, height, bpp;	unsigned colors;	unsigned long compression;	bmp_color_table_entry_t cte;#ifdef CONFIG_VIDEO_BMP_GZIP	unsigned char *dst = NULL;	ulong len;#endif	WATCHDOG_RESET ();	if (!((bmp->header.signature[0] == 'B') &&	      (bmp->header.signature[1] == 'M'))) {#ifdef CONFIG_VIDEO_BMP_GZIP		/*		 * Could be a gzipped bmp image, try to decrompress...		 */		len = CFG_VIDEO_LOGO_MAX_SIZE;		dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);		if (dst == NULL) {			printf("Error: malloc in gunzip failed!\n");			return(1);		}		if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {			printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);			free(dst);			return 1;		}		if (len == CFG_VIDEO_LOGO_MAX_SIZE) {			printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");		}		/*		 * Set addr to decompressed image		 */		bmp = (bmp_image_t *)dst;		if (!((bmp->header.signature[0] == 'B') &&		      (bmp->header.signature[1] == 'M'))) {			printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);			free(dst);			return 1;		}#else		printf ("Error: no valid bmp image at %lx\n", bmp_image);		return 1;#endif /* CONFIG_VIDEO_BMP_GZIP */	}	width = le32_to_cpu (bmp->header.width);	height = le32_to_cpu (bmp->header.height);	bpp = le16_to_cpu (bmp->header.bit_count);	colors = le32_to_cpu (bmp->header.colors_used);	compression = le32_to_cpu (bmp->header.compression);	debug ("Display-bmp: %d x %d  with %d colors\n",	       width, height, colors);	if (compression != BMP_BI_RGB) {		printf ("Error: compression type %ld not supported\n",			compression);#ifdef CONFIG_VIDEO_BMP_GZIP		if (dst)			free(dst);#endif		return 1;	}	padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;	if ((x + width) > VIDEO_VISIBLE_COLS)		width = VIDEO_VISIBLE_COLS - x;	if ((y + height) > VIDEO_VISIBLE_ROWS)		height = VIDEO_VISIBLE_ROWS - y;	bmap = (uchar *) bmp + le32_to_cpu (bmp->header.data_offset);	fb = (uchar *) (video_fb_address +			((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +			x * VIDEO_PIXEL_SIZE);	/* We handle only 8bpp or 24 bpp bitmap */	switch (le16_to_cpu (bmp->header.bit_count)) {	case 8:		padded_line -= width;		if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {			/* Copy colormap					     */			for (xcount = 0; xcount < colors; ++xcount) {				cte = bmp->color_table[xcount];				video_set_lut (xcount, cte.red, cte.green, cte.blue);			}		}		ycount = height;		switch (VIDEO_DATA_FORMAT) {

⌨️ 快捷键说明

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