Merge "sde: Implementation of hierarchical h/w device architecture"
diff --git a/Android.mk b/Android.mk
index 5070911..6baef4a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,4 +1,4 @@
-ifeq ($(call is-board-platform-in-list, thulium),true)
+ifeq ($(call is-board-platform-in-list, msm8996),true)
     TARGET_USES_SDE = true
 else
     TARGET_USES_SDE = false
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 1d0a40a..4f342db 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -143,6 +143,9 @@
         case HAL_PIXEL_FORMAT_RAW_SENSOR:
             aligned_w = ALIGN(width, 32);
             break;
+        case HAL_PIXEL_FORMAT_RAW10:
+            aligned_w = ALIGN(width * 10 /8, 16);
+            break;
         case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
             aligned_w = ALIGN(width, 128);
             break;
@@ -451,6 +454,9 @@
         case HAL_PIXEL_FORMAT_RAW_SENSOR:
             size = alignedw * alignedh * 2;
             break;
+        case HAL_PIXEL_FORMAT_RAW10:
+            size = ALIGN(alignedw * alignedh, 4096);
+            break;
 
             // adreno formats
         case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:  // NV21
@@ -656,6 +662,7 @@
         case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
         case HAL_PIXEL_FORMAT_NV21_ZSL:
         case HAL_PIXEL_FORMAT_RAW_SENSOR:
+        case HAL_PIXEL_FORMAT_RAW10:
             ystride = cstride = width;
             ycbcr->y  = (void*)hnd->base;
             ycbcr->cr = (void*)(hnd->base + ystride * height);
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 3026d99..df7f160 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -530,7 +530,7 @@
         }
         break;
     case HWC_DISPLAY_EXTERNAL:
-        if(mode == HWC_POWER_MODE_OFF) {
+        if(mode == HWC_POWER_MODE_OFF and ctx->dpyAttr[dpy].connected) {
             if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
                 ALOGE("%s: displayCommit failed for external", __FUNCTION__);
                 ret = -1;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 7244562..5a9caec 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -453,6 +453,7 @@
     if(hnd && fbhnd && (hnd->size == fbhnd->size) &&
     (hnd->width == fbhnd->width) && (hnd->height == fbhnd->height)){
        if(tmpLayer->transform  ||
+        (list->flags & HWC_GEOMETRY_CHANGED) ||
        (!(hnd->format == HAL_PIXEL_FORMAT_RGBA_8888 ||
        hnd->format == HAL_PIXEL_FORMAT_RGBX_8888))  ||
                    (needsScaling(tmpLayer) == true)) {
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index fb69fdd..ad7be76 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -461,6 +461,13 @@
     if(mdpHw.hasMinCropWidthLimitation() and (crop_w < 5 or crop_h < 5))
         return false;
 
+    /* crop_w and crop_h should be even for yuv layer, so fallback to GPU for
+     * those cases
+     */
+    if(isYuvBuffer(hnd) && (crop_w < 2 || crop_h < 2)) {
+        return false;
+    }
+
     if((w_scale > 1.0f) || (h_scale > 1.0f)) {
         const uint32_t maxMDPDownscale = mdpHw.getMaxMDPDownscale();
         const float w_dscale = w_scale;
@@ -525,6 +532,14 @@
         ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round",
                 __FUNCTION__);
         ret = false;
+    } else if((qdutils::MDPVersion::getInstance().is8x26() ||
+               qdutils::MDPVersion::getInstance().is8x16() ||
+               qdutils::MDPVersion::getInstance().is8x39()) &&
+              !mDpy && isSecondaryAnimating(ctx) &&
+              isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL)) {
+        ALOGD_IF(isDebug(),"%s: Display animation in progress",
+                 __FUNCTION__);
+        ret = false;
     } else if(qdutils::MDPVersion::getInstance().getTotalPipes() < 8) {
        /* TODO: freeing up all the resources only for the targets having total
                 number of pipes < 8. Need to analyze number of VIG pipes used
@@ -818,6 +833,14 @@
         return false;
     }
 
+    if(!mDpy && isSecondaryAnimating(ctx) &&
+       (isYuvPresent(ctx,HWC_DISPLAY_EXTERNAL) ||
+       isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL)) ) {
+        ALOGD_IF(isDebug(),"%s: Display animation in progress",
+                 __FUNCTION__);
+        return false;
+    }
+
     // if secondary is configuring or Padding round, fall back to video only
     // composition and release all assigned non VIG pipes from primary.
     if(isSecondaryConfiguring(ctx)) {
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 27243c4..a3cb196 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -2700,32 +2700,31 @@
 
 void processBootAnimCompleted(hwc_context_t *ctx) {
     char value[PROPERTY_VALUE_MAX];
-    int boot_finished = 0, ret = -1;
+    int ret = -1;
     int (*applyMode)(int) = NULL;
     void *modeHandle = NULL;
 
-    // Reading property set on boot finish in SF
-    property_get("service.bootanim.exit", value, "0");
-    boot_finished = atoi(value);
-    if (!boot_finished)
-        return;
+    // Applying default mode after bootanimation is finished
+    property_get("init.svc.bootanim", value, "running");
 
-    modeHandle = dlopen("libmm-qdcm.so", RTLD_NOW);
-    if (modeHandle) {
-        *(void **)&applyMode = dlsym(modeHandle, "applyDefaults");
-        if (applyMode) {
-            ret = applyMode(HWC_DISPLAY_PRIMARY);
-            if (ret)
-                ALOGD("%s: Not able to apply default mode", __FUNCTION__);
+    if (!strncmp(value,"stopped",strlen("stopped"))) {
+        modeHandle = dlopen("libmm-qdcm.so", RTLD_NOW);
+        if (modeHandle) {
+            *(void **)&applyMode = dlsym(modeHandle, "applyDefaults");
+            if (applyMode) {
+                ret = applyMode(HWC_DISPLAY_PRIMARY);
+                if (ret)
+                    ALOGD("%s: Not able to apply default mode", __FUNCTION__);
+            } else {
+                ALOGE("%s: No symbol applyDefaults found", __FUNCTION__);
+            }
+            dlclose(modeHandle);
         } else {
-            ALOGE("%s: No symbol applyDefaults found", __FUNCTION__);
+            ALOGE("%s: Not able to load libmm-qdcm.so", __FUNCTION__);
         }
-        dlclose(modeHandle);
-    } else {
-        ALOGE("%s: Not able to load libmm-qdcm.so", __FUNCTION__);
-    }
 
-    ctx->mBootAnimCompleted = true;
+        ctx->mBootAnimCompleted = true;
+    }
 }
 
 void BwcPM::setBwc(const hwc_context_t *ctx, const int& dpy,
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index f290dc8..af43514 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -728,6 +728,16 @@
             ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected);
 }
 
+static inline bool isSecondaryAnimating(hwc_context_t* ctx) {
+    return (ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected &&
+            (!ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isPause) &&
+            ctx->listStats[HWC_DISPLAY_EXTERNAL].isDisplayAnimating)
+            ||
+           (ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected &&
+            (!ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isPause) &&
+            ctx->listStats[HWC_DISPLAY_VIRTUAL].isDisplayAnimating);
+}
+
 /* Return Virtual Display connection status */
 static inline bool isVDConnected(hwc_context_t* ctx) {
     return ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected;
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 0c31dd3..828f4fc 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -175,12 +175,15 @@
                 mOVInfo.src_rect.w = utils::aligndown(mOVInfo.src_rect.w, 4);
         }
     } else {
+        // On 8974 and 8x26, there is a limitation of 1-pixel down-scaling
         if (mdpVersion >= MDSS_V5) {
-            // Check for 1-pixel down-scaling
-            if (mOVInfo.src_rect.w - mOVInfo.dst_rect.w == 1)
-                mOVInfo.src_rect.w -= 1;
-            if (mOVInfo.src_rect.h - mOVInfo.dst_rect.h == 1)
-                mOVInfo.src_rect.h -= 1;
+            if(qdutils::MDPVersion::getInstance().is8x74v2() ||
+                    qdutils::MDPVersion::getInstance().is8x26()) {
+                if (mOVInfo.src_rect.w - mOVInfo.dst_rect.w == 1)
+                    mOVInfo.src_rect.w -= 1;
+                if (mOVInfo.src_rect.h - mOVInfo.dst_rect.h == 1)
+                    mOVInfo.src_rect.h -= 1;
+            }
         }
     }
 
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index e045918..a6a1b85 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -256,6 +256,7 @@
                 ALOGI("PartialUpdate disabled by property");
         }
         fclose(panelInfoNodeFP);
+        free(readLine);
     } else {
         ALOGE("Failed to open msm_fb_panel_info node");
     }