From 0c213a2916e581fc38b26fd85a9c39eb9405d875 Mon Sep 17 00:00:00 2001
From: Troy Kisky <troy.kisky@boundarydevices.com>
Date: Sun, 3 Sep 2017 13:53:45 -0700
Subject: [PATCH] cfb_console: add drv_video_init2 for fbp support

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 drivers/video/cfb_console.c | 19 +++++++++++++------
 include/stdio_dev.h         |  2 ++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 4c668d388a4..d5c6639c899 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -2026,7 +2026,6 @@ static int cfg_video_init(void)
 {
 	unsigned char color8;
 
-	pGD = video_hw_init();
 	if (pGD == NULL)
 		return -1;
 
@@ -2107,6 +2106,9 @@ static int cfg_video_init(void)
 	}
 	eorx = fgx ^ bgx;
 
+	/* Initialize the console */
+	old_col = console_col = 0;
+	old_row = console_row = 0;
 	if (!CONFIG_IS_ENABLED(NO_FB_CLEAR))
 		video_clear();
 
@@ -2115,6 +2117,7 @@ static int cfg_video_init(void)
 		video_console_address = video_fb_address;
 #ifndef CONFIG_VIDEO_SKIP_VERSION
 		video_drawstring(VIDEO_FONT_WIDTH, 0, (uchar *)version_string);
+		old_row = console_row = 1;
 #endif
 	}
 #endif
@@ -2124,10 +2127,6 @@ static int cfg_video_init(void)
 	video_console_address = video_logo();
 #endif
 
-	/* Initialize the console */
-	console_col = 0;
-	console_row = 0;
-
 	if (cfb_do_flush_cache)
 		flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
 
@@ -2155,7 +2154,7 @@ int drv_video_init(void)
 		return 0;
 
 	/* Init video chip - returns with framebuffer cleared */
-	if (cfg_video_init() == -1)
+	if (!drv_video_init2(video_hw_init()))
 		return 0;
 
 	if (board_cfb_skip())
@@ -2199,6 +2198,14 @@ int drv_video_init(void)
 	return 1;
 }
 
+int drv_video_init2(struct graphic_device *fb)
+{
+	pGD = fb;
+	if (cfg_video_init() == -1)
+		return 0;
+	return 1;
+}
+
 void video_position_cursor(unsigned col, unsigned row)
 {
 	console_col = min(col, CONSOLE_COLS - 1);
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index cd0cd601bff..eb41e87828d 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -96,6 +96,8 @@ int	drv_lcd_init (void);
 #endif
 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
 int	drv_video_init (void);
+struct graphic_device;
+int	drv_video_init2(struct graphic_device *fb);
 #endif
 #ifdef CONFIG_KEYBOARD
 int	drv_keyboard_init (void);
-- 
GitLab