diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2011-07-27 16:38:15 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:17 -0700 |
commit | fd00e682c0ccd38ced77a91af4442d38d8cb2e09 (patch) | |
tree | 514d5a09acccd0be6a4389dec35f38280b6b4f3b | |
parent | 1eb652f3abce5058406161829af3ba0260f10443 (diff) |
Implement shared display support.
This change fills up the stubs in lib/vbexport/display.c to
provide support on both ARM (where LCD driver is used) and
X86 (where the CFB driver is used) platforms.
BUG=chrome-os-partner:4552
TEST=manual
On X86 (alex with a Dediprog programmer connected to it), run the
following commands:
. emerge-x86-alex vboot_reference-firmware chromeos-u-boot chromeos-coreboot
dd if=/build/x86-alex/coreboot/coreboot.rom of=/tmp/coreboot seek=3584 bs=1K
sudo flashrom -p dediprog -w /tmp/coreboot
. Reboot the machine, observe it come up to boot> prompt, start
ChromeOS (using the `boot' cli command).
On ARM (tegra2_kaen)
. emerge-tegra2_kaen vboot_reference-firmware chromeos-u-boot chromeos-bootimage
. program the resulting image into Kaen, restart it, observe the
machine come up.
. install the new OS image on the machine, restart it, observe
the machine come up.
. request recovery reboot using crossystem, restart the machine,
observe it come up in recovery request mode.
This test case actually failed: the system did show the
recovery request screen, but then proceeded to boot from the
plugged in USB stick (it was supposed to wait for the stick to
be removed/reinserted)
Change-Id: I75310de3f93464645cc9e61237f65d7d19b71873
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/4886
Reviewed-by: Stefan Reinauer <reinauer@google.com>
-rw-r--r-- | common/cmd_bmp.c | 4 | ||||
-rw-r--r-- | common/cmd_vboot_twostop.c | 6 | ||||
-rw-r--r-- | common/lcd.c | 27 | ||||
-rw-r--r-- | drivers/video/cfb_console.c | 29 | ||||
-rw-r--r-- | include/chromeos/common.h | 3 | ||||
-rw-r--r-- | include/configs/coreboot.h | 7 | ||||
-rw-r--r-- | include/lcd.h | 6 | ||||
-rw-r--r-- | include/video.h | 6 | ||||
-rw-r--r-- | lib/vbexport/display.c | 134 |
9 files changed, 138 insertions, 84 deletions
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 23fc82fe4b..d5fa9595f9 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -237,12 +237,8 @@ static int bmp_display(ulong addr, int x, int y) } #if defined(CONFIG_LCD) - extern int lcd_display_bitmap (ulong, int, int); - ret = lcd_display_bitmap ((unsigned long)bmp, x, y); #elif defined(CONFIG_VIDEO) - extern int video_display_bitmap (ulong, int, int); - ret = video_display_bitmap ((unsigned long)bmp, x, y); #else # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c index a1ed311d00..337993225e 100644 --- a/common/cmd_vboot_twostop.c +++ b/common/cmd_vboot_twostop.c @@ -707,11 +707,7 @@ int do_vboot_twostop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * In normal mode, we don't need to load graphics driver and clear * screen. */ -#ifdef CONFIG_LCD - lcd_clear(); -#else - printf("Would call lcd_clear, but the LCD driver isn't being used.\n"); -#endif + display_clear(); /* * A processor reset jumps to the reset entry point (which is the diff --git a/common/lcd.c b/common/lcd.c index 53093bb267..ce93ba3c99 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -1049,5 +1049,32 @@ static void *lcd_logo (void) #endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */ } +/*---------------- functions required by vboot wrapper -----------------*/ +void lcd_position_cursor (unsigned col, unsigned row) +{ + console_col = min(col, CONSOLE_COLS - 1); + console_row = min(row, CONSOLE_ROWS - 1); +} + +int lcd_get_pixel_width (void) +{ + return panel_info.vl_col; +} + +int lcd_get_pixel_height (void) +{ + return panel_info.vl_row; +} + +int lcd_get_screen_rows (void) +{ + return CONSOLE_ROWS; +} + +int lcd_get_screen_columns (void) +{ + return CONSOLE_COLS; +} + /************************************************************************/ /************************************************************************/ diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index be07dd1131..6b0b766321 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -1680,3 +1680,32 @@ int drv_video_init (void) /* Return success */ return 1; } + +/****************** functions required by vboot wrapper *******************/ + +void video_position_cursor (unsigned col, unsigned row) +{ + console_col = min(col, CONSOLE_COLS - 1); + console_row = min(row, CONSOLE_ROWS - 1); +} + +int video_get_pixel_width(void) +{ + return VIDEO_VISIBLE_COLS; +} + +int video_get_pixel_height(void) +{ + return VIDEO_VISIBLE_ROWS; +} + +int video_get_screen_rows (void) +{ + return CONSOLE_ROWS; +} + +int video_get_screen_columns (void) +{ + return CONSOLE_COLS; +} + diff --git a/include/chromeos/common.h b/include/chromeos/common.h index b959bbeaa7..95924b0c9b 100644 --- a/include/chromeos/common.h +++ b/include/chromeos/common.h @@ -20,4 +20,7 @@ #define VBDEBUG(fmt, args...) #endif +/* this function is implemented along with vboot_api */ +int display_clear(void); + #endif /* CHROMEOS_COMMON_H_ */ diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h index 697fbb96d4..847d1d8c00 100644 --- a/include/configs/coreboot.h +++ b/include/configs/coreboot.h @@ -303,9 +303,6 @@ * Network device support */ #define CONFIG_NET_MULTI -/* this will have to be enabled to get the bitmaps to work... -#define CONFIG_LCD 1 -*/ #define CONFIG_CHROMEOS_HWID "COREBOOT U-BOOT 0000" #define CONFIG_OFFSET_GBB 0x000d0000 @@ -314,7 +311,7 @@ #define CONFIG_LENGTH_FMAP 0x00000400 #define CONFIG_LCD_vl_col 1366 #define CONFIG_LCD_vl_row 768 - -#define CONFIG_LZMA +#define CONFIG_LZMA 1 +#define CONFIG_SPLASH_SCREEN 1 #endif /* __CONFIG_H */ diff --git a/include/lcd.h b/include/lcd.h index 5be67c6216..5634af003a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -219,6 +219,12 @@ void lcd_putc (const char c); void lcd_puts (const char *s); void lcd_printf (const char *fmt, ...); int lcd_clear (void); +int lcd_get_pixel_width (void); +int lcd_get_pixel_height(void); +int lcd_get_screen_rows (void); +int lcd_get_screen_columns (void); +int lcd_display_bitmap (ulong, int, int); +void lcd_position_cursor (unsigned col, unsigned row); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); diff --git a/include/video.h b/include/video.h index efcc682a29..8b3799b0b0 100644 --- a/include/video.h +++ b/include/video.h @@ -15,5 +15,11 @@ int video_init (void *videobase); void video_putc (const char c); void video_puts (const char *s); void video_printf (const char *fmt, ...); +void video_position_cursor (unsigned col, unsigned row); +int video_display_bitmap (ulong, int, int); +int video_get_screen_rows (void); +int video_get_screen_columns (void); +int video_get_pixel_width (void); +int video_get_pixel_height(void); #endif diff --git a/lib/vbexport/display.c b/lib/vbexport/display.c index 4f72cedf82..cdf8862783 100644 --- a/lib/vbexport/display.c +++ b/lib/vbexport/display.c @@ -9,42 +9,59 @@ */ #include <common.h> -#include <fdt_decode.h> +#ifdef CONFIG_LCD #include <lcd.h> +#endif +#ifdef CONFIG_CFB_CONSOLE +#include <video.h> +#endif #include <chromeos/common.h> #include <lzma/LzmaTypes.h> #include <lzma/LzmaDec.h> #include <lzma/LzmaTools.h> -/* Import the header files from vboot_reference */ -#include <vboot_api.h> - #define PRINT_MAX_ROW 20 #define PRINT_MAX_COL 80 DECLARE_GLOBAL_DATA_PTR; -/* Defined in common/lcd.c */ -extern int lcd_display_bitmap (ulong, int, int); - -VbError_t VbExDisplayInit(uint32_t *width, uint32_t *height) -{ -#ifdef CONFIG_OF_CONTROL - struct fdt_lcd config; - - /* Get LCD details from FDT */ - if (fdt_decode_lcd(gd->blob, &config)) { - VBDEBUG("No LCD information in device tree.\n"); - return 1; - } +struct display_callbacks { + int (*dc_get_pixel_width) (void); + int (*dc_get_pixel_height) (void); + int (*dc_get_screen_columns) (void); + int (*dc_get_screen_rows) (void); + void (*dc_position_cursor) (unsigned col, unsigned row); + void (*dc_puts) (const char *s); + int (*dc_display_bitmap) (ulong, int, int); + int (*dc_display_clear) (void); +}; + +static struct display_callbacks display_callbacks_ = { +#ifdef CONFIG_LCD + .dc_get_pixel_width = lcd_get_pixel_width, + .dc_get_pixel_height = lcd_get_pixel_height, + .dc_get_screen_columns = lcd_get_screen_columns, + .dc_get_screen_rows = lcd_get_screen_rows, + .dc_position_cursor = lcd_position_cursor, + .dc_puts = lcd_puts, + .dc_display_bitmap = lcd_display_bitmap, + .dc_display_clear = lcd_clear, - *width = config.width; - *height = config.height; #else - *width = CONFIG_LCD_vl_col; - *height = CONFIG_LCD_vl_row; + .dc_get_pixel_width = video_get_pixel_width, + .dc_get_pixel_height = video_get_pixel_height, + .dc_get_screen_columns = video_get_screen_columns, + .dc_get_screen_rows = video_get_screen_rows, + .dc_position_cursor = video_position_cursor, + .dc_puts = video_puts, + .dc_display_bitmap = video_display_bitmap, #endif +}; +VbError_t VbExDisplayInit(uint32_t *width, uint32_t *height) +{ + *width = display_callbacks_.dc_get_pixel_width(); + *height = display_callbacks_.dc_get_pixel_height(); return VBERROR_SUCCESS; } @@ -54,50 +71,37 @@ VbError_t VbExDisplayBacklight(uint8_t enable) return VBERROR_SUCCESS; } -#ifdef CONFIG_LCD /* Print the message on the center of LCD. */ static void print_on_center(const char *message) { - char result[PRINT_MAX_ROW * (PRINT_MAX_COL + 1) + 1] = "\0"; - int i, j, left_space, right_space; + int i, room_before_text; + int screen_size = display_callbacks_.dc_get_screen_columns() * + display_callbacks_.dc_get_screen_rows(); + int text_length = strlen(message); - for (i = 0; i < PRINT_MAX_ROW / 2 - 1; i++) { - for (j = 0; j < PRINT_MAX_COL; j++) - strcat(result, "."); - strcat(result, "\n"); - } + room_before_text = (screen_size - text_length) / 2; - left_space = (PRINT_MAX_COL - strlen(message)) / 2; - for (i = 0; i < left_space; i++) - strcat(result, "."); - strcat(result, message); + display_callbacks_.dc_position_cursor(0, 0); - right_space = PRINT_MAX_COL - strlen(message) - left_space; - for (i = 0; i < right_space; i++) - strcat(result, "."); - strcat(result, "\n"); + for (i = 0; i < room_before_text; i++) + display_callbacks_.dc_puts("."); - for (i = 0; i < PRINT_MAX_ROW - PRINT_MAX_ROW / 2; i++) { - for (j = 0; j < PRINT_MAX_COL; j++) - strcat(result, "."); - strcat(result, "\n"); - } + display_callbacks_.dc_puts(message); - VbExDisplayDebugInfo(result); + for (i = i + text_length; i < screen_size; i++) + display_callbacks_.dc_puts("."); } -#endif VbError_t VbExDisplayScreen(uint32_t screen_type) { -#ifdef CONFIG_LCD /* * Show the debug messages for development. It is a backup method * when GBB does not contain a full set of bitmaps. */ switch (screen_type) { case VB_SCREEN_BLANK: - /* clear the lcd screen */ - lcd_clear(); + /* clear the screen */ + display_clear(); break; case VB_SCREEN_DEVELOPER_WARNING: print_on_center("developer mode warning"); @@ -120,13 +124,8 @@ VbError_t VbExDisplayScreen(uint32_t screen_type) return 1; } return VBERROR_SUCCESS; -#else - printf("VbExDisplayScreen needs lcd support which isn't configured.\n"); - return 1; -#endif } -#ifdef CONFIG_LCD static uint8_t *uncompress_lzma(uint8_t *in_addr, SizeT in_size, SizeT out_size) { @@ -141,12 +140,10 @@ static uint8_t *uncompress_lzma(uint8_t *in_addr, SizeT in_size, } return out_addr; } -#endif VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo *info, const void *buffer) { -#ifdef CONFIG_LCD int ret; uint8_t *raw_data; @@ -171,7 +168,7 @@ VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo *info, return 1; } - ret = lcd_display_bitmap((ulong)raw_data, x, y); + ret = display_callbacks_.dc_display_bitmap((ulong)raw_data, x, y); if (info->compression == COMPRESS_LZMA1) VbExFree(raw_data); @@ -182,24 +179,21 @@ VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo *info, } return VBERROR_SUCCESS; -#else - printf("VbExDisplayImage needs lcd support which isn't configured.\n"); - return 1; -#endif } VbError_t VbExDisplayDebugInfo(const char *info_str) { -#ifdef CONFIG_LCD - /* Show the debug message on the upper left corner */ - console_col = 0; - console_row = 0; - lcd_puts(info_str); - + display_callbacks_.dc_position_cursor(0, 0); + display_callbacks_.dc_puts(info_str); return VBERROR_SUCCESS; -#else - printf("VbExDisplayDebugInfo needs lcd support which isn't " - "configured.\n"); - return 1; -#endif +} + +/* this function is not technically part of the vboot interface */ +int display_clear(void) +{ + if (display_callbacks_.dc_display_clear) + return display_callbacks_.dc_display_clear(); + + printf ("%s: not implemented!\n", __FUNCTION__); + return -1; } |