Merge "gralloc: Add adreno_utils header"
diff --git a/libhdmi/hdmi.cpp b/libhdmi/hdmi.cpp
index 1aee664..7d709cb 100644
--- a/libhdmi/hdmi.cpp
+++ b/libhdmi/hdmi.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2012-2015, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are
  * retained for attribution purposes only.
@@ -109,11 +109,6 @@
         //Get the best mode and set
         mActiveConfig = getBestConfig();
     }
-    // Set the mode corresponding to the active index
-    mCurrentMode = mEDIDModes[mActiveConfig];
-    setAttributes();
-    // set system property
-    property_set("hw.hdmiON", "1");
 
     // Read the system property to determine if downscale feature is enabled.
     char value[PROPERTY_VALUE_MAX];
@@ -123,6 +118,12 @@
         mMDPDownscaleEnabled = true;
     }
 
+    // Set the mode corresponding to the active index
+    mCurrentMode = mEDIDModes[mActiveConfig];
+    setAttributes();
+    // set system property
+    property_set("hw.hdmiON", "1");
+
     // XXX: A debug property can be used to enable resolution change for
     // testing purposes: debug.hwc.enable_resolution_change
     mEnableResolutionChange = false;
@@ -148,7 +149,7 @@
 
 HDMIDisplay::HDMIDisplay():mFd(-1),
     mCurrentMode(-1), mModeCount(0), mPrimaryWidth(0), mPrimaryHeight(0),
-    mUnderscanSupported(false)
+    mUnderscanSupported(false), mMDPDownscaleEnabled(false)
 {
     memset(&mVInfo, 0, sizeof(mVInfo));
 
@@ -159,10 +160,12 @@
     }
 
     mFbNum = overlay::Overlay::getInstance()->getFbForDpy(mDisplayId);
-    // disable HPD at start, it will be enabled later
+    // Disable HPD at start if HDMI is external, it will be enabled later
     // when the display powers on
     // This helps for framework reboot or adb shell stop/start
-    writeHPDOption(0);
+    if (mDisplayId) {
+        writeHPDOption(0);
+    }
 
     // for HDMI - retreive all the modes supported by the driver
     if(mFbNum != -1) {
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 2bf421f..fd3bb69 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2012-2015, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are retained
  * for attribution purposes only.
@@ -255,7 +255,7 @@
     hwc_context_t* ctx = (hwc_context_t*)(dev);
     const int dpy = HWC_DISPLAY_PRIMARY;
     bool fbComp = false;
-    if (LIKELY(list && list->numHwLayers > 1) &&
+    if (LIKELY(list && list->numHwLayers > 1) && ctx->dpyAttr[dpy].connected &&
             (ctx->dpyAttr[dpy].isActive ||
              ctx->mHDMIDisplay->isHDMIPrimaryDisplay())
             && !ctx->dpyAttr[dpy].isPause) {
@@ -814,7 +814,8 @@
     if (hotPluggable) {
         ret = ctx->mHDMIDisplay->getAttrForConfig(config, xres, yres, refresh);
         if(ret < 0) {
-            ALOGE("%s Error getting attributes for config %d", config);
+            ALOGE("%s Error getting attributes for config %d",
+                    __FUNCTION__, config);
             return ret;
         }
     }
diff --git a/libhwcomposer/hwc_virtual.cpp b/libhwcomposer/hwc_virtual.cpp
index 61e88c8..06418bf 100644
--- a/libhwcomposer/hwc_virtual.cpp
+++ b/libhwcomposer/hwc_virtual.cpp
@@ -91,9 +91,9 @@
             ctx->dpyAttr[dpy].vsync_period
                               = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period;
             init(ctx);
-            // XXX: for architectures with limited resources we would normally
-            // allow one padding round to free up resources but this breaks
-            // certain use cases.
+            // Do one padding round for cases where primary has all pipes
+            // The virtual composition falls back to GPU in such cases.
+            ctx->isPaddingRound = true;
         }
         if(!ctx->dpyAttr[dpy].isPause) {
             ctx->dpyAttr[dpy].isConfiguring = false;
diff --git a/libmemtrack/kgsl.c b/libmemtrack/kgsl.c
index b120246..6dc9774 100644
--- a/libmemtrack/kgsl.c
+++ b/libmemtrack/kgsl.c
@@ -107,7 +107,7 @@
 
         if (type == MEMTRACK_TYPE_GL && strcmp(line_type, "gpumem") == 0) {
 
-            if (flags[6] == 'Y')
+            if (flags[5] == 'Y')
                 accounted_size += size;
             else
                 unaccounted_size += size;