Merge "hwc: Display view frame needs to be set before using it."
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 19e948a..7a1efa4 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -175,9 +175,6 @@
 {
     *bufferType = BUFFER_TYPE_VIDEO;
 
-    if (inputFormat == HAL_PIXEL_FORMAT_RGB_888)
-        return;
-
     if (inputFormat <= HAL_PIXEL_FORMAT_sRGB_X_8888) {
         // RGB formats
         *bufferType = BUFFER_TYPE_UI;
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index 52e9cc4..d88db9d 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -19,11 +19,6 @@
 #define GR_H_
 
 #include <stdint.h>
-#ifdef HAVE_ANDROID_OS      // just want PAGE_SIZE define
-# include <asm/page.h>
-#else
-# include <sys/user.h>
-#endif
 #include <limits.h>
 #include <sys/cdefs.h>
 #include <hardware/gralloc.h>
diff --git a/libhwcomposer/Android.mk b/libhwcomposer/Android.mk
index 68da8a0..7dadfe4 100644
--- a/libhwcomposer/Android.mk
+++ b/libhwcomposer/Android.mk
@@ -11,7 +11,12 @@
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libEGL liboverlay \
                                  libexternal libqdutils libhardware_legacy \
                                  libdl libmemalloc libqservice libsync \
-                                 libbinder libmedia libskia libvirtual
+                                 libbinder libmedia libvirtual
+
+ifeq ($(TARGET_USES_QCOM_BSP),true)
+LOCAL_SHARED_LIBRARIES += libskia
+endif #TARGET_USES_QCOM_BSP
+
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdhwcomposer\"
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := hwc.cpp          \
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index dc9a813..92aeca2 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -27,6 +27,8 @@
 #include "cb_utils.h"
 #include "cb_swap_rect.h"
 #include "math.h"
+#include "sync/sync.h"
+
 using namespace qdutils;
 namespace qhwc {
 
@@ -230,9 +232,11 @@
         // Mark all layers to be drawn by copybit
         for (int i = ctx->listStats[dpy].numAppLayers-1; i >= 0 ; i--) {
             layerProp[i].mFlags |= HWC_COPYBIT;
+#ifdef QCOM_BSP
             if (ctx->mMDP.version == qdutils::MDP_V3_0_4)
                 list->hwLayers[i].compositionType = HWC_BLIT;
             else
+#endif
                 list->hwLayers[i].compositionType = HWC_OVERLAY;
         }
     }
diff --git a/libhwcomposer/hwc_dump_layers.cpp b/libhwcomposer/hwc_dump_layers.cpp
index 6d084f3..c8ebac9 100644
--- a/libhwcomposer/hwc_dump_layers.cpp
+++ b/libhwcomposer/hwc_dump_layers.cpp
@@ -36,8 +36,10 @@
 #include <cutils/log.h>
 #include <sys/stat.h>
 #include <comptype.h>
+#ifdef QCOM_BSP
 #include <SkBitmap.h>
 #include <SkImageEncoder.h>
+#endif
 #ifdef STDC_FORMAT_MACROS
 #include <inttypes.h>
 #endif
@@ -308,7 +310,7 @@
     }
 
     getHalPixelFormatStr(hnd->format, pixFormatStr);
-
+#ifdef QCOM_BSP
     if (needDumpPng && hnd->base) {
         bool bResult = false;
         char dumpFilename[PATH_MAX];
@@ -347,7 +349,7 @@
         }
         delete tempSkBmp; // Calls SkBitmap::freePixels() internally.
     }
-
+#endif
     if (needDumpRaw && hnd->base) {
         char dumpFilename[PATH_MAX];
         bool bResult = false;
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 1e3e87c..ceb09ea 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -52,6 +52,7 @@
 using namespace overlay::utils;
 namespace ovutils = overlay::utils;
 
+#ifdef QCOM_BSP
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -71,6 +72,7 @@
 #ifdef __cplusplus
 }
 #endif
+#endif
 
 namespace qhwc {
 
@@ -268,13 +270,14 @@
 
     // Initialize gpu perfomance hint related parameters
     property_get("sys.hwc.gpu_perf_mode", value, "0");
+#ifdef QCOM_BSP
     ctx->mGPUHintInfo.mGpuPerfModeEnable = atoi(value)? true : false;
 
     ctx->mGPUHintInfo.mEGLDisplay = NULL;
     ctx->mGPUHintInfo.mEGLContext = NULL;
     ctx->mGPUHintInfo.mPrevCompositionGLES = false;
     ctx->mGPUHintInfo.mCurrGPUPerfMode = EGL_GPU_LEVEL_0;
-
+#endif
     ALOGI("Initializing Qualcomm Hardware Composer");
     ALOGI("MDP version: %d", ctx->mMDP.version);
 }
@@ -1331,7 +1334,9 @@
 
     for(uint32_t i = 0; i < list->numHwLayers; i++) {
         if(list->hwLayers[i].compositionType == HWC_OVERLAY ||
+#ifdef QCOM_BSP
            list->hwLayers[i].compositionType == HWC_BLIT ||
+#endif
            list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) {
             //Populate releaseFenceFds.
             if(UNLIKELY(swapzero)) {
@@ -1341,12 +1346,15 @@
                 // if animation is in progress.
                 list->hwLayers[i].releaseFenceFd = -1;
             } else if(list->hwLayers[i].releaseFenceFd < 0 ) {
+#ifdef QCOM_BSP
                 //If rotator has not already populated this field
                 if(list->hwLayers[i].compositionType == HWC_BLIT) {
                     //For Blit, the app layers should be released when the Blit is
                     //complete. This fd was passed from copybit->draw
                     list->hwLayers[i].releaseFenceFd = dup(fd);
-                } else {
+                } else
+#endif
+                {
                     list->hwLayers[i].releaseFenceFd = dup(releaseFd);
                 }
             }
@@ -2017,8 +2025,10 @@
 
 void setGPUHint(hwc_context_t* ctx, hwc_display_contents_1_t* list) {
     struct gpu_hint_info *gpuHint = &ctx->mGPUHintInfo;
-    if(!gpuHint->mGpuPerfModeEnable)
+    if(!gpuHint->mGpuPerfModeEnable || !ctx || !list)
         return;
+
+#ifdef QCOM_BSP
     /* Set the GPU hint flag to high for MIXED/GPU composition only for
        first frame after MDP -> GPU/MIXED mode transition. Set the GPU
        hint to default if the previous composition is GPU or current GPU
@@ -2074,6 +2084,7 @@
         }
         gpuHint->mPrevCompositionGLES = false;
     }
+#endif
 }
 
 void BwcPM::setBwc(const hwc_rect_t& crop,
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 5a8b067..d36c975 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -386,7 +386,8 @@
 #endif
 
     if(!mdp_wrapper::validateAndSet(fbFd, list)) {
-        if(list.processed_overlays < list.num_overlays) {
+        /* No dump for failure due to insufficient resource */
+        if(errno != E2BIG) {
             mdp_wrapper::dump("Bad ov dump: ",
                 *list.overlay_list[list.processed_overlays]);
         }
diff --git a/liboverlay/overlayRotator.h b/liboverlay/overlayRotator.h
index be0c8bd..53c54e6 100644
--- a/liboverlay/overlayRotator.h
+++ b/liboverlay/overlayRotator.h
@@ -35,6 +35,7 @@
 #include "mdpWrapper.h"
 #include "overlayUtils.h"
 #include "overlayMem.h"
+#include "sync/sync.h"
 
 namespace overlay {
 
diff --git a/libvirtual/virtual.cpp b/libvirtual/virtual.cpp
index ca64fad..5453e3a 100644
--- a/libvirtual/virtual.cpp
+++ b/libvirtual/virtual.cpp
@@ -177,13 +177,13 @@
         uint32_t priW = mHwcContext->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
         uint32_t priH = mHwcContext->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
 
+        initResolution(extW, extH);
+
         // Dynamic Resolution Change depends on MDP downscaling.
         // MDP downscale property will be ignored to exercise DRC use case.
         // If DRC is in progress, ext WxH will have non-zero values.
         bool isDRC = (extW > 0) && (extH > 0);
 
-        initResolution(extW, extH);
-
         if(!qdutils::MDPVersion::getInstance().is8x26()
                 && (mHwcContext->mMDPDownscaleEnabled || isDRC)) {