hwc: Configure framebuffer before other layers.

If framebuffer needs to be configured, configure it before all the
other layers in mdp composition. This helps in cases where we are
out of SMPs and framebuffer configuration fails owing to that.
Framebuffer being the fallback path, should always get highest
priority when reserving SMP blocks

Change-Id: Ie7a6903d1b9fb98b308689c81522571449bf2e8e
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 1f97db4..2158611 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -140,12 +140,12 @@
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
         if(fbLayer->handle) {
             setListStats(ctx, list, dpy);
-            int fbZOrder = ctx->mMDPComp[dpy]->prepare(ctx, list);
-            if(fbZOrder >= 0)
-                ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZOrder);
-
+            if(ctx->mMDPComp[dpy]->prepare(ctx, list) < 0) {
+                const int fbZ = 0;
+                ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZ);
+            }
             if (ctx->mMDP.version < qdutils::MDP_V4_0) {
-                if((fbZOrder >= 0) && ctx->mCopyBit[dpy])
+                if(ctx->mCopyBit[dpy])
                     ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
             }
         }
@@ -168,9 +168,10 @@
             if(fbLayer->handle) {
                 ctx->mExtDispConfiguring = false;
                 setListStats(ctx, list, dpy);
-                int fbZOrder = ctx->mMDPComp[dpy]->prepare(ctx, list);
-                if(fbZOrder >= 0)
-                    ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZOrder);
+                if(ctx->mMDPComp[dpy]->prepare(ctx, list) < 0) {
+                    const int fbZ = 0;
+                    ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZ);
+                }
 
                 /* Temporarily commenting out C2D until we support partial
                    copybit composition for mixed mode MDP