Merge "sdm: Add support for panel resolution switch"
diff --git a/sdm/include/private/rotator_interface.h b/sdm/include/private/rotator_interface.h
index 9901d21..5432ac2 100644
--- a/sdm/include/private/rotator_interface.h
+++ b/sdm/include/private/rotator_interface.h
@@ -40,7 +40,7 @@
   virtual DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers) = 0;
   virtual DisplayError Commit(Handle display_ctx, HWLayers *hw_layers) = 0;
   virtual DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers) = 0;
-  virtual DisplayError Purge(Handle display_ctx, HWLayers *hw_layers) = 0;
+  virtual DisplayError Purge(Handle display_ctx) = 0;
 
  protected:
   virtual ~RotatorInterface() { }
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index d2f70ba..30aac4e 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -147,7 +147,7 @@
       } else {
         // Release all the previous rotator sessions.
         if (rotator_intf_) {
-          error = rotator_intf_->Purge(display_rotator_ctx_, &hw_layers_);
+          error = rotator_intf_->Purge(display_rotator_ctx_);
         }
       }
 
@@ -251,7 +251,17 @@
   hw_layers_.info.count = 0;
   error = hw_intf_->Flush();
   if (error == kErrorNone) {
+    // Release all the rotator sessions.
+    if (rotator_intf_) {
+      error = rotator_intf_->Purge(display_rotator_ctx_);
+      if (error != kErrorNone) {
+        DLOGE("Rotator purge failed for display %d", display_type_);
+        return error;
+      }
+    }
+
     comp_manager_->Purge(display_comp_ctx_);
+
     pending_commit_ = false;
   } else {
     DLOGW("Unable to flush display = %d", display_type_);
@@ -314,6 +324,15 @@
     hw_layers_.info.count = 0;
     error = hw_intf_->Flush();
     if (error == kErrorNone) {
+      // Release all the rotator sessions.
+      if (rotator_intf_) {
+        error = rotator_intf_->Purge(display_rotator_ctx_);
+        if (error != kErrorNone) {
+          DLOGE("Rotator purge failed for display %d", display_type_);
+          return error;
+        }
+      }
+
       comp_manager_->Purge(display_comp_ctx_);
 
       error = hw_intf_->PowerOff();
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index d12e5b7..dc01165 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -439,9 +439,11 @@
       int usage = GRALLOC_USAGE_HW_FB;
       int format = HAL_PIXEL_FORMAT_RGBA_8888;
       int ubwc_enabled = 0;
+      int flags = 0;
       HWCDebugHandler::Get()->GetProperty("debug.gralloc.enable_fb_ubwc", &ubwc_enabled);
       if (ubwc_enabled == 1) {
         usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+        flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
       }
 
       GetFrameBufferResolution(&x_pixels, &y_pixels);
@@ -450,6 +452,7 @@
                                                             usage, aligned_width, aligned_height);
       layer_buffer->width = aligned_width;
       layer_buffer->height = aligned_height;
+      layer_buffer->format = GetSDMFormat(format, flags);
       layer->frame_rate = fps;
     }
   }
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index 5bcfb98..d1a0e0a 100644
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -50,12 +50,6 @@
     return status;
   }
 
-  status = hwc_display_primary->SetPowerMode(HWC_POWER_MODE_NORMAL);
-  if (status) {
-    Destroy(hwc_display_primary);
-    return status;
-  }
-
   hwc_display_primary->GetPanelResolution(&primary_width, &primary_height);
   int width = 0, height = 0;
   HWCDebugHandler::Get()->GetProperty("sdm.fb_size_width", &width);