Give more screen control to vboot_draw_screen

New devices have Depthcharge render vboot screens by calling
vboot_draw_screen. Thus, display initialization and backlight control should
not be duplicated. This patch prevents VbDisplayScreen from initializing
display and controlling backlight when vboot is rendering screens using GBB.

BUG=chrome-os-partner:43706,chromium:502066
BRANCH=tot
TEST=Tested on Glados

Change-Id: I50cd2decb7065af96779601b12f0fbf2554ff6ed
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312749
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index f8417b9..8dbf2f2 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -311,10 +311,15 @@
 	return retval;
 }
 
-VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen,
-			  int force, VbNvContext *vncptr)
+/*
+ * This is the deprecated display screen function. This should be called only
+ * if bmpblk.bin is found in GBB. New devices store graphics data in cbfs
+ * and screens are rendered by Depthcharge (chromium:502066).
+ */
+static VbError_t VbDisplayScreenLegacy(VbCommonParams *cparams, uint32_t screen,
+				       int force, VbNvContext *vncptr,
+				       uint32_t locale)
 {
-	uint32_t locale;
 	VbError_t retval;
 
 	/* Initialize display if necessary */
@@ -334,9 +339,6 @@
 	/* Request the screen */
 	disp_current_screen = screen;
 
-	/* Read the locale last saved */
-	VbNvGet(vncptr, VBNV_LOCALIZATION_INDEX, &locale);
-
 	/* Look in the GBB first */
 	if (VBERROR_SUCCESS == VbDisplayScreenFromGBB(cparams, screen,
 						      vncptr, locale))
@@ -346,6 +348,21 @@
 	return VbExDisplayScreen(screen, locale);
 }
 
+VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen,
+			  int force, VbNvContext *vncptr)
+{
+	uint32_t locale;
+	GoogleBinaryBlockHeader *gbb = cparams->gbb;
+
+	/* Read the locale last saved */
+	VbNvGet(vncptr, VBNV_LOCALIZATION_INDEX, &locale);
+
+	if (gbb->bmpfv_size == 0)
+		return VbExDisplayScreen(screen, locale);
+
+	return VbDisplayScreenLegacy(cparams, screen, force, vncptr, locale);
+}
+
 static void Uint8ToString(char *buf, uint8_t val)
 {
 	const char *trans = "0123456789abcdef";