Merge "hwc2: Trigger refresh if prepare fails" into display.lnx.5.1
diff --git a/gralloc/QtiMapperExtensions.cpp b/gralloc/QtiMapperExtensions.cpp
index 8b6f4c9..afe3efa 100644
--- a/gralloc/QtiMapperExtensions.cpp
+++ b/gralloc/QtiMapperExtensions.cpp
@@ -339,6 +339,18 @@
   return Void();
 }
 
+Return<void> QtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage, int32_t flags,
+                                                  int32_t width, int32_t height,
+                                                  getFormatLayout_cb hidl_cb) {
+  ALOGD_IF(DEBUG, "%s: Input parameters - wxh: %dx%d usage: 0x%" PRIu64 " format: %d flags: %d",
+           __FUNCTION__, width, height, usage, format, flags);
+  auto err = Error::NONE;
+  hidl_vec<PlaneLayout> plane_info;
+  uint64_t size = 0;
+  hidl_cb(err, size, plane_info);
+  return Void();
+}
+
 }  // namespace implementation
 }  // namespace V1_0
 }  // namespace mapperextensions
diff --git a/gralloc/QtiMapperExtensions.h b/gralloc/QtiMapperExtensions.h
index 45bb93e..e266e66 100644
--- a/gralloc/QtiMapperExtensions.h
+++ b/gralloc/QtiMapperExtensions.h
@@ -86,6 +86,8 @@
   Return<void> getId(void *buffer, getId_cb _hidl_cb) override;
   Return<void> getUsageFlags(void *buffer, getUsageFlags_cb _hidl_cb) override;
   Return<void> getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb _hidl_cb) override;
+  Return<void> getFormatLayout(int32_t format, uint64_t usage, int32_t flags, int32_t width,
+                               int32_t height, getFormatLayout_cb hidl_cb) override;
 };
 
 }  // namespace implementation
diff --git a/include/display_properties.h b/include/display_properties.h
index 470542f..b595090 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -122,8 +122,9 @@
 #define ENABLE_QDCM_DIAG                     DISPLAY_PROP("enable_qdcm_diag")
 
 #define ZERO_SWAP_INTERVAL                   "vendor.debug.egl.swapinterval"
-#define ENABLE_DROP_REFRESH                  DISPLAY_PROP("enable_drop_refresh")
+#define ENABLE_OPTIMIZE_REFRESH              DISPLAY_PROP("enable_optimize_refresh")
 #define ENABLE_ASYNC_POWERMODE               DISPLAY_PROP("enable_async_powermode")
 #define DISABLE_UI_3D_TONEMAP                DISPLAY_PROP("disable_ui_3d_tonemap")
+#define DISABLE_PARALLEL_CACHE               DISPLAY_PROP("disable_parallel_cache")
 
 #endif  // __DISPLAY_PROPERTIES_H__
diff --git a/sdm/include/core/display_interface.h b/sdm/include/core/display_interface.h
index bfd4d64..021112e 100644
--- a/sdm/include/core/display_interface.h
+++ b/sdm/include/core/display_interface.h
@@ -521,6 +521,14 @@
   */
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate) = 0;
 
+  /*! @brief Method to get the refresh rate of a display.
+
+    @param[in] refresh_rate refresh rate of the display.
+
+    @return \link DisplayError \endlink
+  */
+  virtual DisplayError GetRefreshRate(uint32_t *refresh_rate) = 0;
+
   /*! @brief Method to query whether scanning is support for the HDMI display.
 
     @return \link DisplayError \endlink
@@ -846,6 +854,12 @@
   */
   virtual DisplayError SetPanelLuminanceAttributes(float min_lum, float max_lum) = 0;
 
+  /*! @brief Method to query if there is a need to validate.
+
+      @return \link boolean \endlink
+  */
+  virtual bool CanSkipValidate() = 0;
+
  protected:
   virtual ~DisplayInterface() { }
 };
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index 7c2fad6..b49c425 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -275,6 +275,8 @@
       uint32_t fast_path : 1;    //!< Preference for fast/slow path draw-cycle, set by client.
 
       uint32_t config_changed : 1;  //!< This flag indicates Display config must be validated.
+
+      uint32_t mask_present : 1;  //!< Set if layer stack has mask layers.
     };
 
     uint32_t flags = 0;               //!< For initialization purpose only.
diff --git a/sdm/include/private/strategy_interface.h b/sdm/include/private/strategy_interface.h
index 3f1b9ab..31fda2a 100644
--- a/sdm/include/private/strategy_interface.h
+++ b/sdm/include/private/strategy_interface.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -57,6 +57,7 @@
   /* Sets the list of color modes supported on a display */
   virtual DisplayError SetColorModesInfo(const std::vector<PrimariesTransfer> &colormodes_cs) = 0;
   virtual DisplayError SetBlendSpace(const PrimariesTransfer &blend_space) = 0;
+  virtual bool CanSkipValidate() = 0;
 
   virtual ~StrategyInterface() { }
 };
diff --git a/sdm/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp
index 4780370..c886097 100644
--- a/sdm/libs/core/comp_manager.cpp
+++ b/sdm/libs/core/comp_manager.cpp
@@ -645,4 +645,11 @@
   max_sde_builtin_layers_ = (disabled && (powered_on_displays_.size() <= 1)) ? kMaxSDELayers : 2;
 }
 
+bool CompManager::CanSkipValidate(Handle display_ctx) {
+  DisplayCompositionContext *display_comp_ctx =
+      reinterpret_cast<DisplayCompositionContext *>(display_ctx);
+
+  return display_comp_ctx->strategy->CanSkipValidate();
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/comp_manager.h b/sdm/libs/core/comp_manager.h
index 6cfa2fe..8a7434d 100644
--- a/sdm/libs/core/comp_manager.h
+++ b/sdm/libs/core/comp_manager.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -85,6 +85,7 @@
   void SetSafeMode(bool enable) { safe_mode_ = enable; }
   bool IsSafeMode() { return safe_mode_; }
   void GenerateROI(Handle display_ctx, HWLayers *hw_layers);
+  bool CanSkipValidate(Handle display_ctx);
 
  private:
   static const int kMaxThermalLevel = 3;
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index ea48884..0745d9b 100755
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -1884,4 +1884,8 @@
   return false;
 }
 
+bool DisplayBase::CanSkipValidate() {
+  return comp_manager_->CanSkipValidate(display_comp_ctx_);
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
old mode 100755
new mode 100644
index 6cdf6ff..f33acd5
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -149,6 +149,8 @@
   virtual bool IsSupportSsppTonemap();
   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
                                                     uint8_t *out_data);
+  virtual bool CanSkipValidate();
+  virtual DisplayError GetRefreshRate(uint32_t *refresh_rate) { return kErrorNotSupported; }
 
  protected:
   const char *kBt2020Pq = "bt2020_pq";
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 3c9d01f..73b9a9d 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -720,4 +720,9 @@
   return same_roi;
 }
 
+DisplayError DisplayBuiltIn::GetRefreshRate(uint32_t *refresh_rate) {
+  *refresh_rate = current_refresh_rate_;
+  return kErrorNone;
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index 371787d..cf74f22 100644
--- a/sdm/libs/core/display_builtin.h
+++ b/sdm/libs/core/display_builtin.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -68,6 +68,7 @@
   virtual DisplayError SetDisplayMode(uint32_t mode);
   virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate);
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate);
+  virtual DisplayError GetRefreshRate(uint32_t *refresh_rate);
   virtual DisplayError SetPanelBrightness(int level);
   virtual DisplayError GetPanelBrightness(int *level);
   virtual DisplayError HandleSecureEvent(SecureEvent secure_event, LayerStack *layer_stack);
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index 2d9a8c8..517b06d 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -1432,6 +1432,7 @@
 
 DisplayError HWDeviceDRM::Flush(HWLayers *hw_layers) {
   ClearSolidfillStages();
+  SetFullROI();
   int ret = NullCommit(secure_display_active_ /* synchronous */, false /* retain_planes*/);
   if (ret) {
     DLOGE("failed with error %d", ret);
@@ -1747,6 +1748,10 @@
 }
 
 DisplayError HWDeviceDRM::SetMixerAttributes(const HWMixerAttributes &mixer_attributes) {
+  if (IsResolutionSwitchEnabled()) {
+    return kErrorNotSupported;
+  }
+
   if (!hw_resource_.hw_dest_scalar_info.count) {
     return kErrorNotSupported;
   }
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
index 42688d9..8b7740d 100644
--- a/sdm/libs/core/strategy.cpp
+++ b/sdm/libs/core/strategy.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -275,4 +275,11 @@
   return kErrorNotSupported;
 }
 
+bool Strategy::CanSkipValidate() {
+  if (strategy_intf_) {
+    return strategy_intf_->CanSkipValidate();
+  }
+  return true;
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/strategy.h b/sdm/libs/core/strategy.h
index a89febd..292b88c 100644
--- a/sdm/libs/core/strategy.h
+++ b/sdm/libs/core/strategy.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2019, 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 met:
@@ -56,6 +56,7 @@
   DisplayError SetColorModesInfo(const std::vector<PrimariesTransfer> &colormodes_cs);
   DisplayError SetBlendSpace(const PrimariesTransfer &blend_space);
   void GenerateROI(HWLayersInfo *hw_layers_info, const PUConstraints &pu_constraints);
+  bool CanSkipValidate();
 
  private:
   void GenerateROI();
diff --git a/sdm/libs/hwc2/display_null.h b/sdm/libs/hwc2/display_null.h
index 4390f4e..926e03a 100644
--- a/sdm/libs/hwc2/display_null.h
+++ b/sdm/libs/hwc2/display_null.h
@@ -62,6 +62,7 @@
                                                     uint8_t *out_data);
   virtual string Dump() { return ""; }
   virtual bool IsSupportSsppTonemap() { return false; }
+  virtual bool CanSkipValidate() { return true; }
 
   MAKE_NO_OP(TeardownConcurrentWriteback(void))
   MAKE_NO_OP(Commit(LayerStack *))
@@ -91,6 +92,7 @@
   MAKE_NO_OP(GetDefaultColorMode(string *))
   MAKE_NO_OP(SetCursorPosition(int, int))
   MAKE_NO_OP(SetRefreshRate(uint32_t, bool))
+  MAKE_NO_OP(GetRefreshRate(uint32_t *))
   MAKE_NO_OP(GetPanelBrightness(int *))
   MAKE_NO_OP(SetVSyncState(bool))
   MAKE_NO_OP(SetMixerResolution(uint32_t, uint32_t))
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index bb021da..d9835dd 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -170,6 +170,10 @@
 }
 
 HWC2::Error HWCColorMode::ApplyCurrentColorModeWithRenderIntent(bool hdr_present) {
+  // If panel does not support color modes, do not set color mode.
+  if (color_mode_map_.size() <= 1) {
+    return HWC2::Error::None;
+  }
   if (!apply_mode_) {
     if ((hdr_present && curr_dynamic_range_ == kHdrType) ||
       (!hdr_present && curr_dynamic_range_ == kSdrType))
@@ -773,6 +777,8 @@
       layer->update_mask.set(kClientCompRequest);
     }
 
+    layer_stack_.flags.mask_present |= layer->input_buffer.flags.mask_layer;
+
     layer_stack_.layers.push_back(layer);
   }
 
@@ -1553,10 +1559,11 @@
       // release fences and discard fences from driver
       if (swap_interval_zero_ || layer->flags.single_buffer) {
         close(layer_buffer->release_fence_fd);
-      } else if (layer->composition != kCompositionGPU) {
-        hwc_layer->PushBackReleaseFence(layer_buffer->release_fence_fd);
       } else {
-        hwc_layer->PushBackReleaseFence(-1);
+        // It may so happen that layer gets marked to GPU & app layer gets queued
+        // to MDP for composition. In those scenarios, release fence of buffer should
+        // have mdp and gpu sync points merged.
+        hwc_layer->PushBackReleaseFence(layer_buffer->release_fence_fd);
       }
     } else {
       // In case of flush or display paused, we don't return an error to f/w, so it will
@@ -2253,6 +2260,10 @@
     }
   }
 
+  if (!layer_set_.empty() && !display_intf_->CanSkipValidate()) {
+    return false;
+  }
+
   return true;
 }
 
diff --git a/sdm/libs/hwc2/hwc_display_builtin.cpp b/sdm/libs/hwc2/hwc_display_builtin.cpp
index 56ea552..34c6485 100644
--- a/sdm/libs/hwc2/hwc_display_builtin.cpp
+++ b/sdm/libs/hwc2/hwc_display_builtin.cpp
@@ -47,6 +47,50 @@
 
 namespace sdm {
 
+DisplayError HWCDisplayBuiltIn::PMICInterface::Init() {
+  std::string str_lcd_bias("/sys/class/lcd_bias/secure_mode");
+  fd_lcd_bias_ = ::open(str_lcd_bias.c_str(), O_WRONLY);
+  if (fd_lcd_bias_ < 0) {
+    DLOGW("File '%s' could not be opened. errno = %d, desc = %s", str_lcd_bias.c_str(), errno,
+          strerror(errno));
+    return kErrorHardware;
+  }
+
+  std::string str_leds_wled("/sys/class/leds/wled/secure_mode");
+  fd_wled_ = ::open(str_leds_wled.c_str(), O_WRONLY);
+  if (fd_wled_ < 0) {
+    DLOGW("File '%s' could not be opened. errno = %d, desc = %s", str_leds_wled.c_str(), errno,
+          strerror(errno));
+    return kErrorHardware;
+  }
+
+  return kErrorNone;
+}
+
+void HWCDisplayBuiltIn::PMICInterface::Deinit() {
+  ::close(fd_lcd_bias_);
+  ::close(fd_wled_);
+}
+
+DisplayError HWCDisplayBuiltIn::PMICInterface::Notify(SecureEvent event) {
+  std::string str_event = (event == kSecureDisplayStart) ? std::to_string(1) : std::to_string(0);
+  ssize_t err = ::pwrite(fd_lcd_bias_, str_event.c_str(), str_event.length(), 0);
+  if (err <= 0) {
+    DLOGW("Write failed for lcd_bias, Error = %s", strerror(errno));
+    return kErrorHardware;
+  }
+
+  err = ::pwrite(fd_wled_, str_event.c_str(), str_event.length(), 0);
+  if (err <= 0) {
+    DLOGW("Write failed for wled, Error = %s", strerror(errno));
+    return kErrorHardware;
+  }
+
+  DLOGI("Successfully notifed about secure display %s to PMIC driver",
+        (event == kSecureDisplayStart) ? "start": "end");
+  return kErrorNone;
+}
+
 int HWCDisplayBuiltIn::Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
                               HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler,
                               qService::QService *qservice, hwc2_display_t id, int32_t sdm_id,
@@ -122,16 +166,29 @@
   HWCDebugHandler::Get()->GetProperty(ENABLE_DEFAULT_COLOR_MODE,
                                       &default_mode_status_);
 
-  int drop_refresh = 0;
-  HWCDebugHandler::Get()->GetProperty(ENABLE_DROP_REFRESH, &drop_refresh);
-  enable_drop_refresh_ = (drop_refresh == 1);
-  if (enable_drop_refresh_) {
+  int optimize_refresh = 0;
+  HWCDebugHandler::Get()->GetProperty(ENABLE_OPTIMIZE_REFRESH, &optimize_refresh);
+  enable_optimize_refresh_ = (optimize_refresh == 1);
+  if (enable_optimize_refresh_) {
     DLOGI("Drop redundant drawcycles %d", id_);
   }
+  pmic_intf_ = new PMICInterface();
+  pmic_intf_->Init();
 
   return status;
 }
 
+int HWCDisplayBuiltIn::Deinit() {
+  int status = HWCDisplay::Deinit();
+  if (status) {
+    return status;
+  }
+  pmic_intf_->Deinit();
+  delete pmic_intf_;
+
+  return 0;
+}
+
 HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
   auto status = HWC2::Error::None;
   DisplayError error = kErrorNone;
@@ -185,10 +242,23 @@
   }
 
   uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
-  bool final_rate = force_refresh_rate_ ? true : false;
-  error = display_intf_->SetRefreshRate(refresh_rate, final_rate);
+  error = display_intf_->SetRefreshRate(refresh_rate, force_refresh_rate_);
+
+  // Get the refresh rate set.
+  display_intf_->GetRefreshRate(&refresh_rate);
+  bool vsync_source = (callbacks_->GetVsyncSource() == id_);
+
   if (error == kErrorNone) {
-    // On success, set current refresh rate to new refresh rate
+    if (vsync_source && (current_refresh_rate_ < refresh_rate)) {
+      DTRACE_BEGIN("HWC2::Vsync::Enable");
+      // Display is ramping up from idle.
+      // Client realizes need for resync upon change in config.
+      // Since we know config has changed, triggering vsync proactively
+      // can help in reducing pipeline delays to enable events.
+      SetVsyncEnabled(HWC2::Vsync::Enable);
+      DTRACE_END();
+    }
+    // On success, set current refresh rate to new refresh rate.
     current_refresh_rate_ = refresh_rate;
   }
 
@@ -226,7 +296,7 @@
   }
 
   bool vsync_source = (callbacks_->GetVsyncSource() == id_);
-  bool skip_commit = enable_drop_refresh_ && !pending_commit_ && !buffers_latched &&
+  bool skip_commit = enable_optimize_refresh_ && !pending_commit_ && !buffers_latched &&
                      !pending_refresh_ && !vsync_source;
   pending_refresh_ = false;
 
@@ -254,7 +324,7 @@
     if (status == HWC2::Error::None) {
       HandleFrameOutput();
       SolidFillCommit();
-      status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
+      status = PostCommitLayerStack(out_retire_fence);
     }
   }
 
@@ -578,6 +648,11 @@
       DLOGE("Set secure event failed");
       return err;
     }
+    if (secure_event == kSecureDisplayStart) {
+      pmic_intf_->Notify(kSecureDisplayStart);
+    } else {
+      pmic_notification_pending_ = true;
+    }
 
     DLOGI("SecureDisplay state changed from %d to %d for display %d",
           active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay),
@@ -882,4 +957,19 @@
   return HWC2::Error::None;
 }
 
+HWC2::Error HWCDisplayBuiltIn::PostCommitLayerStack(int32_t *out_retire_fence) {
+  if (pmic_notification_pending_) {
+    // Wait for current commit to complete
+    if (*out_retire_fence >= 0) {
+      int ret = sync_wait(*out_retire_fence, 1000);
+      if (ret < 0) {
+        DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
+      }
+    }
+    pmic_intf_->Notify(kSecureDisplayEnd);
+    pmic_notification_pending_ = false;
+  }
+  return HWCDisplay::PostCommitLayerStack(out_retire_fence);
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/hwc2/hwc_display_builtin.h b/sdm/libs/hwc2/hwc_display_builtin.h
index 4db214f..eeeb9c3 100644
--- a/sdm/libs/hwc2/hwc_display_builtin.h
+++ b/sdm/libs/hwc2/hwc_display_builtin.h
@@ -55,6 +55,7 @@
                     HWCDisplay **hwc_display);
   static void Destroy(HWCDisplay *hwc_display);
   virtual int Init();
+  virtual int Deinit();
   virtual HWC2::Error Validate(uint32_t *out_num_types, uint32_t *out_num_requests);
   virtual HWC2::Error Present(int32_t *out_retire_fence);
   virtual HWC2::Error CommitLayerStack();
@@ -95,6 +96,7 @@
     fast_path_composition_ = enable && !readback_buffer_queued_;
   }
   virtual HWC2::Error UpdatePowerMode(HWC2::PowerMode mode);
+  virtual HWC2::Error PostCommitLayerStack(int32_t *out_retire_fence);
 
  private:
   HWCDisplayBuiltIn(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
@@ -113,6 +115,18 @@
   bool CanSkipCommit();
   DisplayError SetMixerResolution(uint32_t width, uint32_t height);
   DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
+  class PMICInterface {
+   public:
+    PMICInterface() { }
+    ~PMICInterface() { }
+    DisplayError Init();
+    void Deinit();
+    DisplayError Notify(SecureEvent event);
+
+   private:
+    int fd_lcd_bias_ = -1;
+    int fd_wled_ = -1;
+  };
 
   BufferAllocator *buffer_allocator_ = nullptr;
   CPUHint *cpu_hint_ = nullptr;
@@ -129,12 +143,15 @@
   void *output_buffer_base_ = nullptr;
   int default_mode_status_ = 0;
   bool pending_refresh_ = true;
-  bool enable_drop_refresh_ = false;
+  bool enable_optimize_refresh_ = false;
   bool hdr_present_ = false;
 
   // Members for 1 frame capture in a client provided buffer
   bool frame_capture_buffer_queued_ = false;
   int frame_capture_status_ = -EAGAIN;
+  // PMIC interface to notify secure display start/end
+  PMICInterface *pmic_intf_ = nullptr;
+  bool pmic_notification_pending_ = false;
 };
 
 }  // namespace sdm