Merge "sdm: Reset the H/W layers of display"
diff --git a/sdm/include/core/sdm_types.h b/sdm/include/core/sdm_types.h
index 367ab38..fae1153 100644
--- a/sdm/include/core/sdm_types.h
+++ b/sdm/include/core/sdm_types.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2015, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2017, 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
@@ -54,6 +54,7 @@
   kErrorTimeOut,          //!< The operation has timed out to prevent client from waiting forever.
   kErrorShutDown,         //!< Driver is processing shutdown sequence
   kErrorPerfValidation,   //!< Bandwidth or Clock requirement validation failure.
+  kErrorNoAppLayers,      //!< No App layer(s) in the draw cycle.
 };
 
 /*! @brief This structure is defined for client and library compatibility check purpose only. This
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 3378559..c6501bf 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -156,8 +156,8 @@
            hw_layers_info.gpu_target_index, display_type_);
 
   if (!hw_layers_info.app_layer_count) {
-    DLOGE("Layer count is zero");
-    return kErrorParameters;
+    DLOGW("Layer count is zero");
+    return kErrorNoAppLayers;
   }
 
   if (hw_layers_info.gpu_target_index) {
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index b0d2c7c..9484b35 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -716,13 +716,13 @@
     if (error != kErrorNone) {
       if (error == kErrorShutDown) {
         shutdown_pending_ = true;
-      } else if (error != kErrorPermission) {
+      } else if ((error != kErrorPermission) && (error != kErrorNoAppLayers)) {
         DLOGE("Prepare failed. Error = %d", error);
         // To prevent surfaceflinger infinite wait, flush the previous frame during Commit()
         // so that previous buffer and fences are released, and override the error.
         flush_ = true;
       } else {
-        DLOGI("Prepare failed for Display = %d Error = %d", type_, error);
+        DLOGV("Prepare failed for Display = %d Error = %d", type_, error);
       }
       return 0;
     }
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index 8b0a6f2..ba351b5 100644
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2017, 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
@@ -208,14 +208,7 @@
   }
 
   if (content_list->numHwLayers <= 1) {
-    DisplayConfigFixedInfo display_config;
-    display_intf_->GetConfig(&display_config);
-    if (display_config.is_cmdmode) {
-      DLOGV("Skipping null commit on cmd mode panel");
-    } else {
-      flush_ = true;
-    }
-    return 0;
+    flush_ = true;
   }
 
   status = PrepareLayerStack(content_list);
@@ -233,6 +226,7 @@
   display_intf_->GetConfig(&display_config);
   if (content_list->numHwLayers <= 1 && display_config.is_cmdmode) {
     DLOGV("Skipping null commit on cmd mode panel");
+    flush_ = false;
     return 0;
   }