Merge "hwc2: Delete hwc layers in display de-init"
diff --git a/common.mk b/common.mk
index 2318165..c003fde 100644
--- a/common.mk
+++ b/common.mk
@@ -1,5 +1,8 @@
 #Common headers
 display_top := $(call my-dir)
+display_config_version := $(shell \
+    if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/config/1.1" ];\
+    then echo DISPLAY_CONFIG_1_1; fi)
 
 #Common C flags
 common_flags := -DDEBUG_CALC_FPS -Wno-missing-field-initializers
@@ -10,6 +13,10 @@
     LOCAL_CLANG := false
 endif
 
+ifeq ($(display_config_version), DISPLAY_CONFIG_1_1)
+    common_flags += -DDISPLAY_CONFIG_1_1
+endif
+
 ifeq ($(TARGET_USES_COLOR_METADATA), true)
     common_flags += -DUSE_COLOR_METADATA
 endif
@@ -36,6 +43,10 @@
     common_flags += -DUSER_DEBUG
 endif
 
+ifeq ($(LLVM_SA), true)
+    common_flags += --compile-and-analyze --analyzer-perf --analyzer-Werror
+endif
+
 common_includes := system/core/base/include
 CHECK_VERSION_LE = $(shell if [ $(1) -le $(2) ] ; then echo true ; else echo false ; fi)
 PLATFORM_SDK_NOUGAT = 25
diff --git a/libdisplayconfig/Android.mk b/libdisplayconfig/Android.mk
index fae7f85..a107ea6 100644
--- a/libdisplayconfig/Android.mk
+++ b/libdisplayconfig/Android.mk
@@ -9,4 +9,8 @@
 LOCAL_SHARED_LIBRARIES        := libhidlbase libhidltransport libutils \
                                  vendor.display.config@1.0 android.hidl.base@1.0
 
+ifeq ($(LLVM_SA), true)
+    LOCAL_CFLAGS += --compile-and-analyze --analyzer-perf --analyzer-Werror
+endif
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/liblight/Android.mk b/liblight/Android.mk
index 2f2e1ca..197a1a4 100644
--- a/liblight/Android.mk
+++ b/liblight/Android.mk
@@ -24,6 +24,9 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_SHARED_LIBRARIES := liblog libcutils libsdm-disp-vndapis
 LOCAL_CFLAGS := -DLOG_TAG=\"qdlights\"
+ifeq ($(LLVM_SA), true)
+    LOCAL_CFLAGS += --compile-and-analyze --analyzer-perf --analyzer-Werror
+endif
 LOCAL_CLANG  := true
 LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM)
 LOCAL_MODULE_TAGS := optional
diff --git a/libqdutils/qd_utils.cpp b/libqdutils/qd_utils.cpp
index 2cce39c..c55354d 100644
--- a/libqdutils/qd_utils.cpp
+++ b/libqdutils/qd_utils.cpp
@@ -264,10 +264,12 @@
 
     while (getline(&line, &len, configFile) != -1) {
         if (!parseLine(line, tokens, maxCount, &tokenCount)) {
-            if (!strncmp(tokens[0], "bpp", strlen("bpp"))) {
+            if (tokens[0] != NULL) {
+              if (!strncmp(tokens[0], "bpp", strlen("bpp"))) {
                 *panelBpp = static_cast<uint32_t>(atoi(tokens[1]));
-            } else  if (!strncmp(tokens[0], "pattern", strlen("pattern"))) {
+              } else  if (!strncmp(tokens[0], "pattern", strlen("pattern"))) {
                 *patternType = static_cast<uint32_t>(atoi(tokens[1]));
+              }
             }
         }
     }
diff --git a/sdm/include/core/sdm_types.h b/sdm/include/core/sdm_types.h
index 72ad6b2..0d3bf33 100644
--- a/sdm/include/core/sdm_types.h
+++ b/sdm/include/core/sdm_types.h
@@ -57,6 +57,7 @@
   kErrorNoAppLayers,      //!< No App layer(s) in the draw cycle.
   kErrorRotatorValidation,  //!< Rotator configuration validation failure.
   kErrorNotValidated,     //!< Draw cycle has not been validated.
+  kErrorCriticalResource,   //!< Critical resource allocation has failed.
 };
 
 /*! @brief This structure is defined for client and library compatibility check purpose only. This
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
index 173dc4f..9f6a5d6 100644
--- a/sdm/include/private/hw_info_types.h
+++ b/sdm/include/private/hw_info_types.h
@@ -524,9 +524,9 @@
 
   std::vector<Layer> hw_layers = {};  // Layers which need to be programmed on the HW
 
-  uint32_t index[kMaxSDELayers] = {};   // Indexes of the layers from the layer stack which need to
-                                        // be programmed on hardware.
-  uint32_t roi_index[kMaxSDELayers] = {0};  // Stores the ROI index where the layers are visible.
+  std::vector<uint32_t> index;   // Indexes of the layers from the layer stack which need to
+                                 // be programmed on hardware.
+  std::vector<uint32_t> roi_index;  // Stores the ROI index where the layers are visible.
 
   int sync_handle = -1;         // Release fence id for current draw cycle.
   int set_idle_time_ms = -1;    // Set idle time to the new specified value.
diff --git a/sdm/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp
index 4d25497..400b6b9 100644
--- a/sdm/libs/core/comp_manager.cpp
+++ b/sdm/libs/core/comp_manager.cpp
@@ -488,6 +488,9 @@
 DisplayError CompManager::SetDetailEnhancerData(Handle display_ctx,
                                                 const DisplayDetailEnhancerData &de_data) {
   SCOPE_LOCK(locker_);
+  if (!hw_res_info_.hw_dest_scalar_info.count) {
+    return kErrorResources;
+  }
 
   DisplayCompositionContext *display_comp_ctx =
                              reinterpret_cast<DisplayCompositionContext *>(display_ctx);
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index ee2fe44..51aa012 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -598,7 +598,7 @@
   DumpImpl::AppendString(buffer, length, newline);
 
   for (uint32_t i = 0; i < num_hw_layers; i++) {
-    uint32_t layer_index = hw_layers_.info.index[i];
+    uint32_t layer_index = hw_layers_.info.index.at(i);
     // sdm-layer from client layer stack
     Layer *sdm_layer = hw_layers_.info.stack->layers.at(layer_index);
     // hw-layer from hw layers info
@@ -619,14 +619,15 @@
       HWRotateInfo &rotate = hw_rotator_session.hw_rotate_info[count];
       LayerRect &src_roi = rotate.src_roi;
       LayerRect &dst_roi = rotate.dst_roi;
-      const char *rotate_split[2] = { "Rot-1", "Rot-2" };
+      char rot[8] = { 0 };
       int pipe_id = 0;
 
       if (hw_rotator_session.mode == kRotatorOffline) {
         snprintf(writeback_id, sizeof(writeback_id), "%d", rotate.writeback_id);
         pipe_id = rotate.pipe_id;
       }
-      DumpImpl::AppendString(buffer, length, format, idx, comp_type, rotate_split[count],
+      snprintf(rot, sizeof(rot), "Rot-%d", count + 1);
+      DumpImpl::AppendString(buffer, length, format, idx, comp_type, rot,
                              writeback_id, pipe_id, input_buffer->width,
                              input_buffer->height, buffer_format, INT(src_roi.left),
                              INT(src_roi.top), INT(src_roi.right), INT(src_roi.bottom),
@@ -1318,7 +1319,7 @@
   uint32_t hw_layers_count = UINT32(hw_layers_.info.hw_layers.size());
 
   for (uint32_t i = 0; i < hw_layers_count; i++) {
-    Layer *sdm_layer = layer_stack->layers.at(hw_layers_.info.index[i]);
+    Layer *sdm_layer = layer_stack->layers.at(hw_layers_.info.index.at(i));
     Layer &hw_layer = hw_layers_.info.hw_layers.at(i);
 
     hw_layer.input_buffer.planes[0].fd = sdm_layer->input_buffer.planes[0].fd;
@@ -1338,7 +1339,7 @@
   std::vector<uint32_t> fence_dup_flag;
 
   for (uint32_t i = 0; i < hw_layers_count; i++) {
-    uint32_t sdm_layer_index = hw_layers_.info.index[i];
+    uint32_t sdm_layer_index = hw_layers_.info.index.at(i);
     Layer *sdm_layer = layer_stack->layers.at(sdm_layer_index);
     Layer &hw_layer = hw_layers_.info.hw_layers.at(i);
 
diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
index bbc4a78..8466f8b 100644
--- a/sdm/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -68,6 +68,24 @@
     }
   }
 
+  if (hw_panel_info_.mode == kModeCommand) {
+    event_list_ = { HWEvent::VSYNC,
+                    HWEvent::EXIT,
+                    HWEvent::SHOW_BLANK_EVENT,
+                    HWEvent::THERMAL_LEVEL,
+                    HWEvent::IDLE_POWER_COLLAPSE,
+                    HWEvent::PINGPONG_TIMEOUT,
+                    HWEvent::PANEL_DEAD };
+  } else {
+    event_list_ = { HWEvent::VSYNC,
+                    HWEvent::EXIT,
+                    HWEvent::IDLE_NOTIFY,
+                    HWEvent::SHOW_BLANK_EVENT,
+                    HWEvent::THERMAL_LEVEL,
+                    HWEvent::PINGPONG_TIMEOUT,
+                    HWEvent::PANEL_DEAD };
+  }
+
   avr_prop_disabled_ = Debug::IsAVRDisabled();
 
   error = HWEventsInterface::Create(INT(display_type_), this, event_list_, hw_intf_,
diff --git a/sdm/libs/core/display_primary.h b/sdm/libs/core/display_primary.h
index ac4160e..44ae2b4 100644
--- a/sdm/libs/core/display_primary.h
+++ b/sdm/libs/core/display_primary.h
@@ -68,13 +68,7 @@
   bool NeedsAVREnable();
   void ResetPanel();
 
-  std::vector<HWEvent> event_list_ = { HWEvent::VSYNC, HWEvent::EXIT,
-                                       HWEvent::IDLE_NOTIFY,
-                                       HWEvent::SHOW_BLANK_EVENT,
-                                       HWEvent::THERMAL_LEVEL,
-                                       HWEvent::IDLE_POWER_COLLAPSE,
-                                       HWEvent::PINGPONG_TIMEOUT,
-                                       HWEvent::PANEL_DEAD };
+  std::vector<HWEvent> event_list_;
   bool avr_prop_disabled_ = false;
   bool switch_to_cmd_ = false;
   bool handle_idle_timeout_ = false;
diff --git a/sdm/libs/core/drm/hw_color_manager_drm.cpp b/sdm/libs/core/drm/hw_color_manager_drm.cpp
index 95c25cd..7563647 100644
--- a/sdm/libs/core/drm/hw_color_manager_drm.cpp
+++ b/sdm/libs/core/drm/hw_color_manager_drm.cpp
@@ -861,7 +861,7 @@
       break;
     default:
       DLOGE("Invalid gamut mode %d", sde_gamut->mode);
-      free(mdp_gamut);
+      delete mdp_gamut;
       return kErrorParameters;
   }
 
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index 96ad8a3..c1e14ee 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -863,7 +863,7 @@
         }
 
         uint32_t config = 0;
-        SetSrcConfig(layer.input_buffer, &config);
+        SetSrcConfig(layer.input_buffer, hw_rotator_session->mode, &config);
         drm_atomic_intf_->Perform(DRMOps::PLANE_SET_SRC_CONFIG, pipe_id, config);;
         drm_atomic_intf_->Perform(DRMOps::PLANE_SET_FB_ID, pipe_id, fb_id);
         drm_atomic_intf_->Perform(DRMOps::PLANE_SET_CRTC, pipe_id, token_.crtc_id);
@@ -1132,9 +1132,13 @@
 }
 
 
-void HWDeviceDRM::SetSrcConfig(const LayerBuffer &input_buffer, uint32_t *config) {
-  if (input_buffer.flags.interlace) {
-    *config |= (0x01 << UINT32(DRMSrcConfig::DEINTERLACE));
+void HWDeviceDRM::SetSrcConfig(const LayerBuffer &input_buffer, const HWRotatorMode &mode,
+                               uint32_t *config) {
+  // In offline rotation case, rotator will handle deinterlacing.
+  if (mode != kRotatorOffline) {
+    if (input_buffer.flags.interlace) {
+      *config |= (0x01 << UINT32(DRMSrcConfig::DEINTERLACE));
+    }
   }
 }
 
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index e0b7fc1..e02d936 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -121,7 +121,7 @@
   void SetSolidfillStages();
   void AddSolidfillStage(const HWSolidfillStage &sf, uint32_t plane_alpha);
   void SetBlending(const LayerBlending &source, sde_drm::DRMBlendType *target);
-  void SetSrcConfig(const LayerBuffer &input_buffer, uint32_t *config);
+  void SetSrcConfig(const LayerBuffer &input_buffer, const HWRotatorMode &mode, uint32_t *config);
   void SelectCscType(const LayerBuffer &input_buffer, sde_drm::DRMCscType *type);
   void SetRect(const LayerRect &source, sde_drm::DRMRect *target);
   void SetRotation(LayerTransform transform, const HWRotatorMode &mode, uint32_t* rot_bit_mask);
diff --git a/sdm/libs/core/drm/hw_events_drm.cpp b/sdm/libs/core/drm/hw_events_drm.cpp
index 7d71f29..7a3d385 100644
--- a/sdm/libs/core/drm/hw_events_drm.cpp
+++ b/sdm/libs/core/drm/hw_events_drm.cpp
@@ -96,9 +96,6 @@
         poll_fds_[i].events = POLLIN | POLLPRI | POLLERR;
         idle_notify_index_ = i;
       } break;
-      case HWEvent::CEC_READ_MESSAGE:
-      case HWEvent::SHOW_BLANK_EVENT:
-      case HWEvent::THERMAL_LEVEL:
       case HWEvent::IDLE_POWER_COLLAPSE: {
         poll_fds_[i].fd = drmOpen("msm_drm", nullptr);
         if (poll_fds_[i].fd < 0) {
@@ -108,8 +105,6 @@
         poll_fds_[i].events = POLLIN | POLLPRI | POLLERR;
         idle_pc_index_ = i;
       } break;
-      case HWEvent::PINGPONG_TIMEOUT:
-        break;
       case HWEvent::PANEL_DEAD: {
         poll_fds_[i].fd = drmOpen("msm_drm", nullptr);
         if (poll_fds_[i].fd < 0) {
@@ -119,6 +114,11 @@
         poll_fds_[i].events = POLLIN | POLLPRI | POLLERR;
         panel_dead_index_ = i;
       } break;
+      case HWEvent::CEC_READ_MESSAGE:
+      case HWEvent::SHOW_BLANK_EVENT:
+      case HWEvent::THERMAL_LEVEL:
+      case HWEvent::PINGPONG_TIMEOUT:
+        break;
     }
   }
 
@@ -263,15 +263,15 @@
         poll_fds_[i].fd = -1;
         break;
       case HWEvent::IDLE_NOTIFY:
-      case HWEvent::CEC_READ_MESSAGE:
-      case HWEvent::SHOW_BLANK_EVENT:
-      case HWEvent::THERMAL_LEVEL:
       case HWEvent::IDLE_POWER_COLLAPSE:
-        break;
       case HWEvent::PANEL_DEAD:
         drmClose(poll_fds_[i].fd);
         poll_fds_[i].fd = -1;
         break;
+      case HWEvent::CEC_READ_MESSAGE:
+      case HWEvent::SHOW_BLANK_EVENT:
+      case HWEvent::THERMAL_LEVEL:
+        break;
       default:
         return kErrorNotSupported;
     }
diff --git a/sdm/libs/core/drm/hw_info_drm.cpp b/sdm/libs/core/drm/hw_info_drm.cpp
index 88e4efa..55bc003 100644
--- a/sdm/libs/core/drm/hw_info_drm.cpp
+++ b/sdm/libs/core/drm/hw_info_drm.cpp
@@ -194,7 +194,11 @@
   hw_resource->has_hdr = true;
 
   hw_resource->hw_version = SDEVERSION(4, 0, 1);
-  hw_resource->hw_revision = 0;
+  // TODO(user): On FB driver hw_revision comprises of major version, minor version and hw_revision.
+  // On DRM driver, hw_revision is deprecated and hw_version comprises major version, minor version
+  // and hw_revision information. Since QDCM uses hw_revision variable populate hw_revision with
+  // hw_version. Remove hw_revision variable when FB code is deperecated.
+  hw_resource->hw_revision = SDEVERSION(4, 0, 1);
 
   // TODO(user): Deprecate
   hw_resource->max_mixer_width = 2560;
@@ -293,6 +297,11 @@
   hw_resource->max_bandwidth_high = info.max_bandwidth_high / kKiloUnit;
   hw_resource->max_sde_clk = info.max_sde_clk;
   hw_resource->hw_version = info.hw_version;
+  // TODO(user): On FB driver hw_revision comprises of major version, minor version and hw_revision.
+  // On DRM driver, hw_revision is deprecated and hw_version comprises major version, minor version
+  // and hw_revision information. Since QDCM uses hw_revision variable populate hw_revision with
+  // hw_version. Remove hw_revision variable when FB code is deperecated.
+  hw_resource->hw_revision = info.hw_version;
 
   std::vector<LayerBufferFormat> sdm_format;
   for (auto &it : info.comp_ratio_rt_map) {
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp
index 667cd88..e78c862 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.cpp
+++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp
@@ -60,6 +60,9 @@
   drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
   if (connector_info_.topology == DRMTopology::UNKNOWN) {
     connector_info_.topology = DRMTopology::DUAL_LM;
+    if (connector_info_.modes[current_mode_index_].hdisplay <= 1080) {
+      connector_info_.topology = DRMTopology::SINGLE_LM;
+    }
   }
 
   InitializeConfigs();
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index eb0d17b..cac1454 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -813,9 +813,11 @@
     const uint32_t max_count = 10;
     char *tokens[max_count] = { NULL };
     if (!ParseLine(line.c_str(), "=\n", tokens, max_count, &token_count)) {
-      if (!strncmp(tokens[0], "panel_name", strlen("panel_name"))) {
-        snprintf(panel_info->panel_name, sizeof(panel_info->panel_name), "%s", tokens[1]);
-        break;
+      if (tokens[0] != NULL) {
+        if (!strncmp(tokens[0], "panel_name", strlen("panel_name"))) {
+           snprintf(panel_info->panel_name, sizeof(panel_info->panel_name), "%s", tokens[1]);
+           break;
+        }
       }
     }
   }
diff --git a/sdm/libs/core/fb/hw_info.cpp b/sdm/libs/core/fb/hw_info.cpp
index f2a13e3..2cdae06 100644
--- a/sdm/libs/core/fb/hw_info.cpp
+++ b/sdm/libs/core/fb/hw_info.cpp
@@ -411,10 +411,12 @@
          string caps;
          while (Sys::getline_(caps_fs, caps)) {
            if (!ParseString(caps.c_str(), tokens, max_count, ":, =\n", &token_count)) {
-             if (!strncmp(tokens[0], "downscale_compression", strlen("downscale_compression"))) {
-               hw_resource->hw_rot_info.downscale_compression = UINT8(atoi(tokens[1]));
-             } else if (!strncmp(tokens[0], "min_downscale", strlen("min_downscale"))) {
-               hw_resource->hw_rot_info.min_downscale = FLOAT(atof(tokens[1]));
+             if (tokens[0] != NULL) {
+               if (!strncmp(tokens[0], "downscale_compression", strlen("downscale_compression"))) {
+                 hw_resource->hw_rot_info.downscale_compression = UINT8(atoi(tokens[1]));
+               } else if (!strncmp(tokens[0], "min_downscale", strlen("min_downscale"))) {
+                 hw_resource->hw_rot_info.min_downscale = FLOAT(atof(tokens[1]));
+               }
              }
            }
          }
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
index 85c648e..d682070 100644
--- a/sdm/libs/core/strategy.cpp
+++ b/sdm/libs/core/strategy.cpp
@@ -144,9 +144,9 @@
   LayerRect dst_domain = (LayerRect){0.0f, 0.0f, layer_mixer_width, layer_mixer_height};
 
   Layer layer = *gpu_target_layer;
-  hw_layers_info_->index[0] = hw_layers_info_->gpu_target_index;
+  hw_layers_info_->index.push_back(hw_layers_info_->gpu_target_index);
+  hw_layers_info_->roi_index.push_back(0);
   MapRect(src_domain, dst_domain, layer.dst_rect, &layer.dst_rect);
-  hw_layers_info_->hw_layers.clear();
   hw_layers_info_->hw_layers.push_back(layer);
 
   return kErrorNone;
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index 9db57ab..bd33aff 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -21,6 +21,10 @@
                                  libsdmutils libc++ liblog libgrallocutils libui libgpu_tonemapper \
                                  libhidlbase libhidltransport vendor.display.config@1.0_vendor
 
+ifeq ($(display_config_version), DISPLAY_CONFIG_1_1)
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.1_vendor
+endif
+
 LOCAL_SRC_FILES               := hwc_session.cpp \
                                  hwc_session_services.cpp \
                                  hwc_display.cpp \
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 77075af..7928235 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -460,6 +460,7 @@
   metadata_refresh_rate_ = 0;
   auto working_primaries = ColorPrimaries_BT709_5;
   bool secure_display_active = false;
+  layer_stack_.flags.animating = animating_;
 
   // Add one layer for fb target
   // TODO(user): Add blit target layers
diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h
index b3257f9..1fe43af 100644
--- a/sdm/libs/hwc2/hwc_display.h
+++ b/sdm/libs/hwc2/hwc_display.h
@@ -210,6 +210,10 @@
                                          float* out_max_luminance,
                                          float* out_max_average_luminance,
                                          float* out_min_luminance);
+  virtual HWC2::Error SetDisplayAnimating(bool animating) {
+    animating_ = animating;
+    return HWC2::Error::None;
+  }
 
  protected:
   // Maximum number of layers supported by display manager.
@@ -299,6 +303,7 @@
   DisplayClass display_class_;
   uint32_t geometry_changes_ = GeometryChanges::kNone;
   bool skip_validate_ = false;
+  bool animating_ = false;
 };
 
 inline int HWCDisplay::Perform(uint32_t operation, ...) {
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 624105b..e0ac992 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -271,6 +271,8 @@
 
     int status = hwc_session->Init();
     if (status != 0) {
+      delete hwc_session;
+      hwc_session = NULL;
       return status;
     }
 
diff --git a/sdm/libs/hwc2/hwc_session.h b/sdm/libs/hwc2/hwc_session.h
index fe69515..84abd7b 100644
--- a/sdm/libs/hwc2/hwc_session.h
+++ b/sdm/libs/hwc2/hwc_session.h
@@ -20,7 +20,12 @@
 #ifndef __HWC_SESSION_H__
 #define __HWC_SESSION_H__
 
+#ifdef DISPLAY_CONFIG_1_1
+#include <vendor/display/config/1.1/IDisplayConfig.h>
+#else
 #include <vendor/display/config/1.0/IDisplayConfig.h>
+#endif
+
 #include <core/core_interface.h>
 #include <utils/locker.h>
 
@@ -35,7 +40,11 @@
 
 namespace sdm {
 
+#ifdef DISPLAY_CONFIG_1_1
+using vendor::display::config::V1_1::IDisplayConfig;
+#else
 using ::vendor::display::config::V1_0::IDisplayConfig;
+#endif
 using ::android::hardware::Return;
 
 // Create a singleton uevent listener thread valid for life of hardware composer process.
@@ -211,6 +220,11 @@
   Return<int32_t> setCameraLaunchStatus(uint32_t on) override;
   Return<void> displayBWTransactionPending(displayBWTransactionPending_cb _hidl_cb) override;
 
+  // Methods from ::android::hardware::display::config::V1_1::IDisplayConfig follow.
+#ifdef DISPLAY_CONFIG_1_1
+  Return<int32_t> setDisplayAnimating(uint64_t display_id, bool animating) override;
+#endif
+
   // QClient methods
   virtual android::status_t notifyCallback(uint32_t command, const android::Parcel *input_parcel,
                                            android::Parcel *output_parcel);
diff --git a/sdm/libs/hwc2/hwc_session_services.cpp b/sdm/libs/hwc2/hwc_session_services.cpp
index 64ac57c..0fbba4d 100644
--- a/sdm/libs/hwc2/hwc_session_services.cpp
+++ b/sdm/libs/hwc2/hwc_session_services.cpp
@@ -506,4 +506,14 @@
   return Void();
 }
 
+#ifdef DISPLAY_CONFIG_1_1
+// Methods from ::vendor::hardware::display::config::V1_1::IDisplayConfig follow.
+Return<int32_t> HWCSession::setDisplayAnimating(uint64_t display_id, bool animating ) {
+  SEQUENCE_WAIT_SCOPE_LOCK(locker_[display_id]);
+  return CallDisplayFunction(static_cast<hwc2_device_t *>(this), display_id,
+                             &HWCDisplay::SetDisplayAnimating, animating);
+}
+#endif
+
+
 }  // namespace sdm