Merge "sdm: Add interface to disable PU for one frame"
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 2a5d099..e9cdc73 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -99,14 +99,10 @@
 
 //------------- MDPCapabilityInfo-----------------------//
 MDPCapabilityInfo :: MDPCapabilityInfo() {
-  isMacroTileSupported = false;
   qdutils::querySDEInfo(HAS_MACRO_TILE, &isMacroTileSupported);
+  qdutils::querySDEInfo(HAS_UBWC, &isUBwcSupported);
 }
 
-int MDPCapabilityInfo :: isMacroTilingSupportedByMDP(){
-    return isMacroTileSupported;
- }
-
 //------------- AdrenoMemInfo-----------------------//
 AdrenoMemInfo::AdrenoMemInfo()
 {
@@ -932,20 +928,23 @@
 
 static bool isUBwcSupported(int format)
 {
-    // Existing HAL formats with UBWC support
-    switch(format)
-    {
-        case HAL_PIXEL_FORMAT_BGR_565:
-        case HAL_PIXEL_FORMAT_RGBA_8888:
-        case HAL_PIXEL_FORMAT_RGBX_8888:
-        case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
-        case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
-        case HAL_PIXEL_FORMAT_RGBA_1010102:
-        case HAL_PIXEL_FORMAT_RGBX_1010102:
-            return true;
-        default:
-            return false;
+    if (MDPCapabilityInfo::getInstance().isUBwcSupportedByMDP()) {
+        // Existing HAL formats with UBWC support
+        switch(format)
+        {
+            case HAL_PIXEL_FORMAT_BGR_565:
+            case HAL_PIXEL_FORMAT_RGBA_8888:
+            case HAL_PIXEL_FORMAT_RGBX_8888:
+            case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
+            case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
+            case HAL_PIXEL_FORMAT_RGBA_1010102:
+            case HAL_PIXEL_FORMAT_RGBX_1010102:
+                return true;
+            default:
+                break;
+        }
     }
+    return false;
 }
 
 bool isUBwcEnabled(int format, int usage)
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index e7d449e..5fe1bdb 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -201,7 +201,9 @@
 
 class MDPCapabilityInfo : public android::Singleton <MDPCapabilityInfo>
 {
-    int isMacroTileSupported;
+    int isMacroTileSupported = 0;
+    int isUBwcSupported = 0;
+
     public:
         MDPCapabilityInfo();
         /*
@@ -210,8 +212,14 @@
         * @return  1 : supported
         *          0 : not supported
         */
-        int isMacroTilingSupportedByMDP();
-
+        int isMacroTilingSupportedByMDP() { return isMacroTileSupported; }
+        /*
+        * Function to return whether MDP supports UBWC feature
+        *
+        * @return  1 : supported
+        *          0 : not supported
+        */
+        int isUBwcSupportedByMDP() { return isUBwcSupported; }
 };
 
 #endif /* GR_H_ */
diff --git a/libmemtrack/kgsl.c b/libmemtrack/kgsl.c
index 4ad94ce..5a6b075 100644
--- a/libmemtrack/kgsl.c
+++ b/libmemtrack/kgsl.c
@@ -83,7 +83,7 @@
      * count the entry as accounted else count the entry as unaccounted.
      */
     while (1) {
-        unsigned long size;
+        unsigned long size, mapsize;
         char line_type[7];
         char flags[8];
         char line_usage[19];
@@ -94,20 +94,21 @@
         }
 
         /* Format:
-         *  gpuaddr useraddr     size    id flags       type            usage sglen
-         * 545ba000 545ba000     4096     1 -----pY     gpumem      arraybuffer     1
+         *  gpuaddr useraddr     size    id flags       type            usage sglen mapsize
+         * 545ba000 545ba000     4096     1 -----pY     gpumem      arraybuffer     1  4096
          */
-        ret = sscanf(line, "%*x %*x %lu %*d %7s %6s %18s %*d\n",
-                     &size, flags, line_type, line_usage);
-        if (ret != 4) {
+        ret = sscanf(line, "%*x %*x %lu %*d %7s %6s %18s %*d %lu\n",
+                     &size, flags, line_type, line_usage, &mapsize);
+        if (ret != 5) {
             continue;
         }
 
         if (type == MEMTRACK_TYPE_GL && strcmp(line_type, "gpumem") == 0) {
 
-            if (flags[6] == 'Y')
-                accounted_size += size;
-            else
+            if (flags[6] == 'Y') {
+                accounted_size += mapsize;
+		unaccounted_size += size - mapsize;
+	    } else
                 unaccounted_size += size;
 
         } else if (type == MEMTRACK_TYPE_GRAPHICS && strcmp(line_type, "ion") == 0) {
diff --git a/libqdutils/qd_utils.cpp b/libqdutils/qd_utils.cpp
index 254df30..6453b58 100644
--- a/libqdutils/qd_utils.cpp
+++ b/libqdutils/qd_utils.cpp
@@ -62,6 +62,10 @@
         featureName = "tile_format";
         break;
 
+    case HAS_UBWC:
+        featureName = "ubwc";
+        break;
+
     default:
         ALOGE("Invalid query type %d", type);
         return -EINVAL;
diff --git a/libqdutils/qd_utils.h b/libqdutils/qd_utils.h
index 2b9ca74..0392e05 100644
--- a/libqdutils/qd_utils.h
+++ b/libqdutils/qd_utils.h
@@ -48,6 +48,7 @@
 
 enum HWQueryType {
     HAS_MACRO_TILE = 0,
+    HAS_UBWC = 1,
 };
 
 enum {