From 645b0c01db0dcea19891cf9144313ecefccdffb9 Mon Sep 17 00:00:00 2001 From: lijuang Date: Fri, 14 Aug 2015 20:52:47 +0800 Subject: [PATCH] fbcon: add support for drawing diffrent color line Add support for drawing diffrent color line Change-Id: I86ca0aa425ae19cbeade5609cb27cc2b62b89a3e --- dev/fbcon/fbcon.c | 15 +++++++++------ include/dev/fbcon.h | 6 ++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dev/fbcon/fbcon.c b/dev/fbcon/fbcon.c index 4e817b337..3ac42f4a5 100644 --- a/dev/fbcon/fbcon.c +++ b/dev/fbcon/fbcon.c @@ -59,6 +59,7 @@ static struct fbcon_config *config = NULL; #define RGB565_YELLOW 0xffe0 #define RGB565_ORANGE 0xfd20 #define RGB565_RED 0xf800 +#define RGB565_GREEN 0x3666 #define RGB888_BLACK 0x000000 #define RGB888_WHITE 0xffffff @@ -68,6 +69,7 @@ static struct fbcon_config *config = NULL; #define RGB888_YELLOW 0xffff00 #define RGB888_ORANGE 0xffa500 #define RGB888_RED 0xff0000 +#define RGB888_GREEN 0x00ff00 #define FONT_WIDTH 5 #define FONT_HEIGHT 12 @@ -89,7 +91,7 @@ static struct fb_color fb_color_formats_555[] = { [FBCON_YELLOW_MSG] = {RGB565_YELLOW, RGB565_BLACK}, [FBCON_ORANGE_MSG] = {RGB565_ORANGE, RGB565_BLACK}, [FBCON_RED_MSG] = {RGB565_RED, RGB565_BLACK}, - [FBCON_LINE_COLOR] = {RGB565_WHITE, RGB565_WHITE}, + [FBCON_GREEN_MSG] = {RGB565_GREEN, RGB565_BLACK}, [FBCON_SELECT_MSG_BG_COLOR] = {RGB565_WHITE, RGB565_BLUE}}; static struct fb_color fb_color_formats_888[] = { @@ -100,7 +102,7 @@ static struct fb_color fb_color_formats_888[] = { [FBCON_YELLOW_MSG] = {RGB888_YELLOW, RGB888_BLACK}, [FBCON_ORANGE_MSG] = {RGB888_ORANGE, RGB888_BLACK}, [FBCON_RED_MSG] = {RGB888_RED, RGB888_BLACK}, - [FBCON_LINE_COLOR] = {RGB888_WHITE, RGB888_WHITE}, + [FBCON_GREEN_MSG] = {RGB888_GREEN, RGB888_BLACK}, [FBCON_SELECT_MSG_BG_COLOR] = {RGB888_WHITE, RGB888_BLUE}}; @@ -243,20 +245,21 @@ static void fbcon_scroll_up(void) fbcon_flush(); } -void fbcon_draw_line() +void fbcon_draw_line(uint32_t type) { char *pixels; - uint32_t bg_color, tmp_color; + uint32_t line_color, tmp_color; int i, j; - bg_color = fb_color_formats[FBCON_LINE_COLOR].bg; + /* set line's color via diffrent type */ + line_color = fb_color_formats[type].fg; pixels = config->base; pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width); pixels += cur_pos.x * ((config->bpp / 8) * (FONT_WIDTH + 1)); for (i = 0; i < (int)config->width; i++) { - tmp_color = bg_color; + tmp_color = line_color; for (j = 0; j < (int)(config->bpp / 8); j++) { *pixels = (unsigned char) tmp_color; tmp_color = tmp_color >> 8; diff --git a/include/dev/fbcon.h b/include/dev/fbcon.h index 123532c10..c77f02ec3 100644 --- a/include/dev/fbcon.h +++ b/include/dev/fbcon.h @@ -48,9 +48,7 @@ enum fbcon_msg_type { FBCON_YELLOW_MSG, FBCON_ORANGE_MSG, FBCON_RED_MSG, - - /* type for line color */ - FBCON_LINE_COLOR, + FBCON_GREEN_MSG, /* and the select message's background */ FBCON_SELECT_MSG_BG_COLOR, @@ -96,7 +94,7 @@ void fbcon_extract_to_screen(logo_img_header *header, void* address); void fbcon_putc_factor(char c, int type, unsigned scale_factor); void fbcon_draw_msg_background(unsigned y_start, unsigned y_end, uint32_t paint, int update); -void fbcon_draw_line(void); +void fbcon_draw_line(uint32_t type); uint32_t fbcon_get_current_line(void); uint32_t fbcon_get_current_bg(void); uint32_t fbcon_get_max_x(void);