Copy FB before performing the first mode set

Prior to [0], we set_mode_major() would not actual do a mode set.  Instead
it would merely make sure that all the per-crtc scanouts had bos, and
"DPMS On" any active connectors.

[0] b763960d06e77727d88de153a44038fdd2d58ff8
  Perform the actual modeset in set_mode_major.

Now, that we actually perform a mode set in set_mode_major, this means
we will do a mode set when OMAPEnterVT() calls xf86SetDesiredModes().
Thus, we must make sure our root window has valid contents before we
call the initial OMAPEnterVT() in ScreenInit().  In particular, for a
smooth transition from fbcon to X, we do the fb copy first, before entering VT.  Since
we do this copy, we can safely just assume we are in blit mode.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

BUG=chromium:344889
TEST=boot, observe no flicker during splash screen (chrome ball).

Change-Id: I076bf57c06aeb2491521e0a6d945ad39aa4efaf3
Reviewed-on: https://chromium-review.googlesource.com/187193
Reviewed-by: David Sodman <dsodman@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
(cherry picked from commit 3f2fc2d5625a8238d2bd1e9fc6ba8b61190ffbd7)
Reviewed-on: https://chromium-review.googlesource.com/188845
Commit-Queue: Heng-ruey Hsu <henryhsu@chromium.org>
Tested-by: Heng-ruey Hsu <henryhsu@chromium.org>
diff --git a/src/omap_driver.c b/src/omap_driver.c
index ee04b76..9dfb7c5 100644
--- a/src/omap_driver.c
+++ b/src/omap_driver.c
@@ -562,10 +562,26 @@
 
 	TRACE_ENTER();
 
-	/* Allocate and map memory areas we need */
+	/* Allocate a bo for the root window pixmap */
 	if (!OMAPMapMem(pScrn))
 		return FALSE;
 
+	/* For a smooth transition from console to X, copy the current fbcon
+	 * contents to the root window.
+	 */
+	drmmode_copy_fb(pScrn);
+
+	/* The root window pixmap bo (pOMAP->scanout) has valid contents now,
+	 * so we start out claiming we're in blit mode.
+	 * The root window is displayed when we do:
+	 *   OMAPEnterVT() ->
+	 *    xf86SetDesiredModes() ->
+	 *     drmmode_set_mode_major() ->
+	 *      drmmode_set_crtc() ->
+	 *       drmModeSetCrtc()
+	 */
+	pOMAP->flip_mode = OMAP_FLIP_DISABLED;
+
 	xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 
 	/* need to point to new screen on server regeneration */
@@ -611,9 +627,6 @@
 		goto fail;
 	}
 
-	/* flip_mode is currently invalid */
-	pOMAP->flip_mode = OMAP_FLIP_INVALID;
-
 	/* Initialize some generic 2D drawing functions: */
 	if (!fbScreenInit(pScreen, omap_bo_map(pOMAP->scanout),
 			pScrn->virtualX, pScrn->virtualY,
@@ -735,17 +748,6 @@
 
 	drmmode_screen_init(pScrn);
 
-	/* We need to copy the framebuffer into the screen before using it as
-	 * scanout as that will cause a moment of uninitialized framebuffer to
-	 * be drawn to the video out.
-	 */
-	drmmode_copy_fb(pScrn);
-
-	/* The main scanout buffer (pOMAP->scanout) has valid contents now, so
-	 * we start out claiming we're in blit mode.
-	 */
-	drmmode_set_blit_mode(pScrn);
-
 	TRACE_EXIT();
 	return TRUE;