Merge "sdm: power off external display during GVM LPM"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 3cb763d..e3eda5b 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -5,6 +5,9 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.graphics.composer@2.2-service)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.graphics.composer@2.2-service.rc)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/hw/android.hardware.graphics.composer@2.2-impl.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.graphics.composer@2.3-service)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.graphics.composer@2.3-service.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/hw/android.hardware.graphics.composer@2.3-impl.so)
 
 
 # Clean old target objs
diff --git a/config/display-product.mk b/config/display-product.mk
index 9366c89..fbab002 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -1,7 +1,7 @@
 # Display product definitions
 PRODUCT_PACKAGES += \
-    android.hardware.graphics.composer@2.3-impl \
-    android.hardware.graphics.composer@2.3-service \
+    android.hardware.graphics.composer@2.4-impl \
+    android.hardware.graphics.composer@2.4-service \
     android.hardware.graphics.mapper@3.0-impl-qti-display \
     android.hardware.graphics.mapper@4.0-impl-qti-display \
     vendor.qti.hardware.display.allocator-service \
@@ -15,6 +15,7 @@
     memtrack.$(TARGET_BOARD_PLATFORM) \
     libqdMetaData.vendor \
     libdisplayconfig.vendor \
+    libdisplayconfig.qti.vendor \
     vendor.display.config@1.0.vendor \
     vendor.display.config@1.1.vendor \
     vendor.display.config@1.2.vendor \
@@ -26,6 +27,7 @@
     vendor.display.config@1.8.vendor \
     vendor.display.config@1.9.vendor \
     vendor.display.config@1.10.vendor \
+    vendor.display.config@2.0.vendor \
     vendor.qti.hardware.display.mapper@3.0 \
     vendor.qti.hardware.display.mapper@4.0.vendor \
     modetest
diff --git a/config/talos.mk b/config/talos.mk
index 93c1cf9..3c5bace 100644
--- a/config/talos.mk
+++ b/config/talos.mk
@@ -1,8 +1,8 @@
 #Display related packages and configuration
 
 PRODUCT_PACKAGES += \
-    android.hardware.graphics.composer@2.3-impl \
-    android.hardware.graphics.composer@2.3-service \
+    android.hardware.graphics.composer@2.4-impl \
+    android.hardware.graphics.composer@2.4-service \
     android.hardware.graphics.mapper@2.0-impl-qti-display \
     vendor.qti.hardware.display.allocator-service \
     android.hardware.memtrack@1.0-impl \
diff --git a/gralloc/QtiMapper.cpp b/gralloc/QtiMapper.cpp
index 468a865..d8dd675 100644
--- a/gralloc/QtiMapper.cpp
+++ b/gralloc/QtiMapper.cpp
@@ -185,7 +185,8 @@
 
   auto hnd = PRIV_HANDLE_CONST(buffer);
   auto *out_data = reinterpret_cast<void *>(hnd->base);
-  hidl_cb(err, out_data, gralloc::GetBpp(hnd->format), hnd->width);
+  hidl_cb(err, out_data, gralloc::GetBpp(hnd->format),
+          (hnd->width) * (gralloc::GetBpp(hnd->format)));
   return Void();
 }
 
diff --git a/include/display_properties.h b/include/display_properties.h
index 06ab31d..cd3fbf2 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2018 - 2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2018 - 2020 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
@@ -130,5 +130,7 @@
 #define DISABLE_PARALLEL_CACHE               DISPLAY_PROP("disable_parallel_cache")
 #define ENABLE_FORCE_SPLIT                   DISPLAY_PROP("enable_force_split")
 #define DEFER_FPS_FRAME_COUNT                DISPLAY_PROP("defer_fps_frame_count")
+#define DISABLE_IDLE_TIME_VIDEO              DISPLAY_PROP("disable_idle_time_video")
+#define DISABLE_IDLE_TIME_HDR                DISPLAY_PROP("disable_idle_time_hdr")
 
 #endif  // __DISPLAY_PROPERTIES_H__
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 25af21e..26e89a9 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -90,6 +90,7 @@
   if (hw_panel_info_.mode == kModeCommand) {
     event_list_ = {HWEvent::VSYNC,
                    HWEvent::EXIT,
+                   HWEvent::IDLE_NOTIFY,
                    HWEvent::SHOW_BLANK_EVENT,
                    HWEvent::THERMAL_LEVEL,
                    HWEvent::IDLE_POWER_COLLAPSE,
@@ -330,6 +331,8 @@
       return error;
     }
 
+    DisplayBase::ReconfigureDisplay();
+
     if (mode == kModeVideo) {
       ControlPartialUpdate(false /* enable */, &pending);
     } else if (mode == kModeCommand) {
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index 95d5845..37250c3 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -724,6 +724,13 @@
   GetHWDisplayPortAndMode();
   GetHWPanelMaxBrightness();
 
+  if (current_mode.flags & DRM_MODE_FLAG_CMD_MODE_PANEL) {
+    hw_panel_info_.mode = kModeCommand;
+  }
+  if (current_mode.flags & DRM_MODE_FLAG_VID_MODE_PANEL) {
+    hw_panel_info_.mode = kModeVideo;
+  }
+
   DLOGI_IF(kTagDisplay, "%s, Panel Interface = %s, Panel Mode = %s, Is Primary = %d", device_name_,
         interface_str_.c_str(), hw_panel_info_.mode == kModeVideo ? "Video" : "Command",
         hw_panel_info_.is_primary_panel);
@@ -834,13 +841,34 @@
     return kErrorParameters;
   }
 
+  uint32_t mode_flag = 0;
+  uint32_t curr_mode_flag = 0;
   drmModeModeInfo to_set = connector_info_.modes[index].mode;
+  drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_].mode;
   uint64_t current_bit_clk = connector_info_.modes[current_mode_index_].bit_clk_rate;
+
+  if (to_set.flags & DRM_MODE_FLAG_CMD_MODE_PANEL) {
+    mode_flag = DRM_MODE_FLAG_CMD_MODE_PANEL;
+  } else if (to_set.flags & DRM_MODE_FLAG_VID_MODE_PANEL) {
+    mode_flag = DRM_MODE_FLAG_VID_MODE_PANEL;
+  }
+
+  if (current_mode.flags & DRM_MODE_FLAG_CMD_MODE_PANEL) {
+    curr_mode_flag = DRM_MODE_FLAG_CMD_MODE_PANEL;
+  } else if (current_mode.flags & DRM_MODE_FLAG_VID_MODE_PANEL) {
+    curr_mode_flag = DRM_MODE_FLAG_VID_MODE_PANEL;
+  }
+
+  if (curr_mode_flag != mode_flag) {
+    panel_mode_changed_ = mode_flag;
+  }
+
   for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
     if ((to_set.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
         (to_set.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
         (to_set.vrefresh == connector_info_.modes[mode_index].mode.vrefresh) &&
-        (current_bit_clk == connector_info_.modes[mode_index].bit_clk_rate)) {
+        (current_bit_clk == connector_info_.modes[mode_index].bit_clk_rate) &&
+	(mode_flag & connector_info_.modes[mode_index].mode.flags)) {
       index = mode_index;
       break;
     }
@@ -853,14 +881,15 @@
   DLOGI_IF(
       kTagDisplay,
       "Display attributes[%d]: WxH: %dx%d, DPI: %fx%f, FPS: %d, LM_SPLIT: %d, V_BACK_PORCH: %d,"
-      " V_FRONT_PORCH: %d, V_PULSE_WIDTH: %d, V_TOTAL: %d, H_TOTAL: %d, CLK: %dKHZ, TOPOLOGY: %d",
-      index, display_attributes_[index].x_pixels, display_attributes_[index].y_pixels,
-      display_attributes_[index].x_dpi, display_attributes_[index].y_dpi,
-      display_attributes_[index].fps, display_attributes_[index].is_device_split,
-      display_attributes_[index].v_back_porch, display_attributes_[index].v_front_porch,
-      display_attributes_[index].v_pulse_width, display_attributes_[index].v_total,
-      display_attributes_[index].h_total, display_attributes_[index].clock_khz,
-      display_attributes_[index].topology);
+      " V_FRONT_PORCH: %d, V_PULSE_WIDTH: %d, V_TOTAL: %d, H_TOTAL: %d, CLK: %dKHZ,"
+      "TOPOLOGY: %d, PanelMode %s", index, display_attributes_[index].x_pixels,
+      display_attributes_[index].y_pixels, display_attributes_[index].x_dpi,
+      display_attributes_[index].y_dpi, display_attributes_[index].fps,
+      display_attributes_[index].is_device_split, display_attributes_[index].v_back_porch,
+      display_attributes_[index].v_front_porch, display_attributes_[index].v_pulse_width,
+      display_attributes_[index].v_total, display_attributes_[index].h_total,
+      display_attributes_[index].clock_khz, display_attributes_[index].topology,
+      (mode_flag & DRM_MODE_FLAG_VID_MODE_PANEL) ? "Video" : "Command");
 
   return kErrorNone;
 }
@@ -1187,6 +1216,21 @@
     drm_atomic_intf_->Perform(DRMOps::CRTC_SET_SECURITY_LEVEL, token_.crtc_id, crtc_security_level);
   }
 
+  if (reset_output_fence_offset_ && !validate) {
+    // Change back the fence_offset
+    drm_atomic_intf_->Perform(DRMOps::CRTC_SET_OUTPUT_FENCE_OFFSET, token_.crtc_id, 0);
+    reset_output_fence_offset_ = false;
+  }
+
+  // Set panel mode
+  if (panel_mode_changed_ & DRM_MODE_FLAG_VID_MODE_PANEL) {
+    if (!validate) {
+      // Switch to video mode, corresponding change the fence_offset
+      drm_atomic_intf_->Perform(DRMOps::CRTC_SET_OUTPUT_FENCE_OFFSET, token_.crtc_id, 1);
+    }
+    SetFullROI();
+  }
+
   if (hw_layers->hw_avr_info.update) {
     sde_drm::DRMQsyncMode mode = sde_drm::DRMQsyncMode::NONE;
     if (hw_layers->hw_avr_info.mode == kContinuousMode) {
@@ -1217,6 +1261,7 @@
       if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
           (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
           (current_bit_clk == connector_info_.modes[mode_index].bit_clk_rate) &&
+          (current_mode.flags == connector_info_.modes[mode_index].mode.flags) &&
           (vrefresh_ == connector_info_.modes[mode_index].mode.vrefresh)) {
         current_mode = connector_info_.modes[mode_index].mode;
         break;
@@ -1229,6 +1274,7 @@
       if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
           (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
           (current_mode.vrefresh == connector_info_.modes[mode_index].mode.vrefresh) &&
+          (current_mode.flags == connector_info_.modes[mode_index].mode.flags) &&
           (bit_clk_rate_ == connector_info_.modes[mode_index].bit_clk_rate)) {
         current_mode = connector_info_.modes[mode_index].mode;
         break;
@@ -1253,7 +1299,7 @@
   }
 
   // Set CRTC mode, only if display config changes
-  if (vrefresh_ || update_mode_) {
+  if (vrefresh_ || update_mode_ || panel_mode_changed_) {
     drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id, &current_mode);
   }
 
@@ -1319,6 +1365,7 @@
   if (ret) {
     DLOGE("failed with error %d for %s", ret, device_name_);
     vrefresh_ = 0;
+    panel_mode_changed_ = 0;
     err = kErrorHardware;
   }
 
@@ -1400,6 +1447,7 @@
   if (ret) {
     DLOGE("%s failed with error %d crtc %d", __FUNCTION__, ret, token_.crtc_id);
     vrefresh_ = 0;
+    panel_mode_changed_ = 0;
     CloseFd(&release_fence);
     CloseFd(&retire_fence);
     release_fence_ = -1;
@@ -1457,6 +1505,15 @@
     bit_clk_rate_ = 0;
   }
 
+   if (panel_mode_changed_ & DRM_MODE_FLAG_CMD_MODE_PANEL) {
+    panel_mode_changed_ = 0;
+    synchronous_commit_ = false;
+  } else if (panel_mode_changed_ & DRM_MODE_FLAG_VID_MODE_PANEL) {
+    panel_mode_changed_ = 0;
+    synchronous_commit_ = false;
+    reset_output_fence_offset_ = true;
+  }
+
   first_cycle_ = false;
   update_mode_ = false;
   hw_layers->updates_mask = 0;
@@ -1663,6 +1720,30 @@
 }
 
 DisplayError HWDeviceDRM::SetDisplayMode(const HWDisplayMode hw_display_mode) {
+  uint32_t mode_flag;
+
+  if (hw_display_mode == kModeCommand) {
+    mode_flag = DRM_MODE_FLAG_CMD_MODE_PANEL;
+    DLOGI("switch panel mode to command");
+  } else if (hw_display_mode == kModeVideo) {
+    mode_flag = DRM_MODE_FLAG_VID_MODE_PANEL;
+    DLOGI("switch panel mode to video");
+  }
+
+  drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_].mode;
+  for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
+    if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
+        (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
+        (current_mode.vrefresh == connector_info_.modes[mode_index].mode.vrefresh) &&
+        (mode_flag & connector_info_.modes[mode_index].mode.flags)) {
+      current_mode_index_ = mode_index;
+      PopulateHWPanelInfo();
+      panel_mode_changed_ = mode_flag;
+      synchronous_commit_ = true;
+      return kErrorNone;
+    }
+  }
+
   return kErrorNotSupported;
 }
 
@@ -1680,6 +1761,7 @@
     if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
         (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
         (current_bit_clk == connector_info_.modes[mode_index].bit_clk_rate) &&
+        (current_mode.flags == connector_info_.modes[mode_index].mode.flags) &&
         (refresh_rate == connector_info_.modes[mode_index].mode.vrefresh)) {
       vrefresh_ = refresh_rate;
       DLOGV_IF(kTagDriverConfig, "Set refresh rate to %d", refresh_rate);
@@ -2051,7 +2133,7 @@
 
 void HWDeviceDRM::SetFullROI() {
   // Reset the CRTC ROI and connector ROI only for the panel that supports partial update
-  if (!hw_panel_info_.partial_update) {
+  if (!hw_panel_info_.partial_update && !panel_mode_changed_) {
     return;
   }
   uint32_t index = current_mode_index_;
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index fe3dbc1..f718efb 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -223,6 +223,8 @@
   bool synchronous_commit_ = false;
   uint32_t topology_control_ = 0;
   uint32_t vrefresh_ = 0;
+  uint32_t panel_mode_changed_ = 0;
+  bool reset_output_fence_offset_ = false;
   uint64_t bit_clk_rate_ = 0;
   bool update_mode_ = false;
   DRMPowerMode last_power_mode_ = DRMPowerMode::OFF;
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp
index e0ebad4..06b4b99 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.cpp
+++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp
@@ -118,6 +118,18 @@
   return kErrorNone;
 }
 
+DisplayError HWPeripheralDRM::SetDisplayMode(const HWDisplayMode hw_display_mode) {
+  DisplayError error = HWDeviceDRM::SetDisplayMode(hw_display_mode);
+  if (error != kErrorNone) {
+    return error;
+  }
+
+  // update bit clk rates.
+  hw_panel_info_.bitclk_rates = bitclk_rates_;
+
+  return kErrorNone;
+}
+
 DisplayError HWPeripheralDRM::Validate(HWLayers *hw_layers) {
   HWLayersInfo &hw_layer_info = hw_layers->info;
   SetDestScalarData(hw_layer_info, true);
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.h b/sdm/libs/core/drm/hw_peripheral_drm.h
index 5df95dd..5a8993d 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.h
+++ b/sdm/libs/core/drm/hw_peripheral_drm.h
@@ -61,6 +61,7 @@
   virtual DisplayError SetDynamicDSIClock(uint64_t bit_clk_rate);
   virtual DisplayError GetDynamicDSIClock(uint64_t *bit_clk_rate);
   virtual DisplayError SetDisplayAttributes(uint32_t index);
+  virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
   virtual DisplayError TeardownConcurrentWriteback(void);
   virtual DisplayError SetPanelBrightness(int level);
   virtual DisplayError GetPanelBrightness(int *level);
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index b011642..bdaeeb2 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_SHARED_LIBRARIES        := libsdmcore libqservice libbinder libhardware libhardware_legacy \
                                  libutils libcutils libsync libqdutils libqdMetaData \
                                  libdisplaydebug libsdmutils libc++ liblog libgrallocutils libui \
-                                 libgpu_tonemapper libhidlbase libhidltransport \
+                                 libgpu_tonemapper libhidlbase libhidltransport libdisplayconfig.qti \
                                  android.hardware.graphics.mapper@2.0 \
                                  android.hardware.graphics.mapper@2.1 \
                                  android.hardware.graphics.mapper@3.0 \
@@ -29,6 +29,7 @@
                                  android.hardware.graphics.allocator@3.0 \
                                  android.hardware.graphics.composer@2.2 \
                                  android.hardware.graphics.composer@2.3 \
+                                 android.hardware.graphics.composer@2.4 \
                                  vendor.display.config@1.0 \
                                  vendor.display.config@1.1 \
                                  vendor.display.config@1.2 \
@@ -40,7 +41,8 @@
                                  vendor.display.config@1.8 \
                                  vendor.display.config@1.9 \
                                  vendor.display.config@1.10 \
-                                 vendor.display.config@1.11
+                                 vendor.display.config@1.11 \
+                                 vendor.display.config@2.0
 
 ifeq ($(TARGET_BOARD_AUTO), true)
 LOCAL_CFLAGS                  += -DCONFIG_BASEID_FROM_PROP
diff --git a/sdm/libs/hwc2/android.hardware.graphics.composer-qti-display.xml b/sdm/libs/hwc2/android.hardware.graphics.composer-qti-display.xml
index 1fda637..66c85ab 100644
--- a/sdm/libs/hwc2/android.hardware.graphics.composer-qti-display.xml
+++ b/sdm/libs/hwc2/android.hardware.graphics.composer-qti-display.xml
@@ -30,7 +30,7 @@
     <hal format="hidl">
         <name>android.hardware.graphics.composer</name>
         <transport>hwbinder</transport>
-        <version>2.3</version>
+        <version>2.4</version>
         <interface>
             <name>IComposer</name>
             <instance>default</instance>
@@ -39,7 +39,7 @@
     <hal format="hidl">
         <name>vendor.display.config</name>
         <transport>hwbinder</transport>
-        <version>1.11</version>
+        <version>2.0</version>
         <interface>
             <name>IDisplayConfig</name>
             <instance>default</instance>
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 94fac19..f79ae24 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -1446,7 +1446,7 @@
         DLOGE("QService command = %d: input_parcel needed.", command);
         break;
       }
-      status = setIdleTimeout(UINT32(input_parcel->readInt32()));
+      status = SetIdleTimeout(UINT32(input_parcel->readInt32()));
       break;
 
     case qService::IQService::SET_FRAME_DUMP_CONFIG:
@@ -1481,7 +1481,7 @@
         int disp_id = INT(input_parcel->readInt32());
         HWCDisplay::DisplayStatus disp_status =
               static_cast<HWCDisplay::DisplayStatus>(input_parcel->readInt32());
-        status = SetSecondaryDisplayStatus(disp_id, disp_status);
+        status = SetDisplayStatus(disp_id, disp_status);
         output_parcel->writeInt32(status);
       }
       break;
@@ -1504,7 +1504,7 @@
           break;
         }
         int32_t input = input_parcel->readInt32();
-        status = toggleScreenUpdate(input == 1);
+        status = ToggleScreenUpdate(input == 1);
         output_parcel->writeInt32(status);
       }
       break;
@@ -1630,7 +1630,7 @@
           break;
         }
         uint32_t camera_status = UINT32(input_parcel->readInt32());
-        status = setCameraLaunchStatus(camera_status);
+        status = SetCameraLaunchStatus(camera_status);
       }
       break;
 
@@ -3448,7 +3448,7 @@
   auto enable = input_parcel->readInt32();
   auto synchronous = input_parcel->readInt32();
 
-  return static_cast<android::status_t>(controlIdlePowerCollapse(enable, synchronous));
+  return static_cast<android::status_t>(ControlIdlePowerCollapse(enable, synchronous));
 }
 
 hwc2_display_t HWCSession::GetActiveBuiltinDisplay() {
diff --git a/sdm/libs/hwc2/hwc_session.h b/sdm/libs/hwc2/hwc_session.h
index f056290..af5c3d2 100644
--- a/sdm/libs/hwc2/hwc_session.h
+++ b/sdm/libs/hwc2/hwc_session.h
@@ -20,8 +20,8 @@
 #ifndef __HWC_SESSION_H__
 #define __HWC_SESSION_H__
 
-#include <vendor/display/config/1.11/IDisplayConfig.h>
-
+#include <cutils/native_handle.h>
+#include <config/device_interface.h>
 #include <core/core_interface.h>
 #include <utils/locker.h>
 #include <qd_utils.h>
@@ -29,6 +29,7 @@
 #include <vector>
 #include <utility>
 #include <map>
+#include <string>
 
 #include "hwc_callbacks.h"
 #include "hwc_layers.h"
@@ -45,9 +46,6 @@
 
 namespace sdm {
 
-using vendor::display::config::V1_11::IDisplayConfig;
-using vendor::display::config::V1_10::IDisplayCWBCallback;
-
 using ::android::hardware::Return;
 using ::android::hardware::hidl_string;
 using android::hardware::hidl_handle;
@@ -55,6 +53,8 @@
 
 int32_t GetDataspaceFromColorMode(ColorMode mode);
 
+typedef DisplayConfig::DisplayType DispType;
+
 // Create a singleton uevent listener thread valid for life of hardware composer process.
 // This thread blocks on uevents poll inside uevent library implementation. This poll exits
 // only when there is a valid uevent, it can not be interrupted otherwise. Tieing life cycle
@@ -84,8 +84,8 @@
 constexpr int32_t kDataspaceSaturationPropertyElements = 9;
 constexpr int32_t kPropertyMax = 256;
 
-class HWCSession : hwc2_device_t, HWCUEventListener, IDisplayConfig, public qClient::BnQClient,
-                   public HWCDisplayEventHandler {
+class HWCSession : hwc2_device_t, HWCUEventListener, public qClient::BnQClient,
+                   public HWCDisplayEventHandler, public DisplayConfig::ClientContext {
  public:
   struct HWCModuleMethods : public hw_module_methods_t {
     HWCModuleMethods() { hw_module_methods_t::open = HWCSession::Open; }
@@ -219,6 +219,10 @@
                     hwc_vsync_period_change_constraints_t *vsync_period_change_constraints,
                     hwc_vsync_period_change_timeline_t *out_timeline);
 
+  virtual int RegisterClientContext(std::shared_ptr<DisplayConfig::ConfigCallback> callback,
+                                    DisplayConfig::ConfigInterface **intf);
+  virtual void UnRegisterClientContext(DisplayConfig::ConfigInterface *intf);
+
   // HWCDisplayEventHandler
   virtual void DisplayPowerReset();
 
@@ -232,6 +236,62 @@
   static Locker display_config_locker_;
 
  private:
+
+  class DisplayConfigImpl: public DisplayConfig::ConfigInterface {
+   public:
+    explicit DisplayConfigImpl(std::weak_ptr<DisplayConfig::ConfigCallback> callback,
+                               HWCSession *hwc_session);
+
+   private:
+    virtual int IsDisplayConnected(DispType dpy, bool *connected);
+    virtual int SetDisplayStatus(DispType dpy, DisplayConfig::ExternalStatus status);
+    virtual int ConfigureDynRefreshRate(DisplayConfig::DynRefreshRateOp op, uint32_t refresh_rate);
+    virtual int GetConfigCount(DispType dpy, uint32_t *count);
+    virtual int GetActiveConfig(DispType dpy, uint32_t *config);
+    virtual int SetActiveConfig(DispType dpy, uint32_t config);
+    virtual int GetDisplayAttributes(uint32_t config_index, DispType dpy,
+                                     DisplayConfig::Attributes *attributes);
+    virtual int SetPanelBrightness(uint32_t level);
+    virtual int GetPanelBrightness(uint32_t *level);
+    virtual int MinHdcpEncryptionLevelChanged(DispType dpy, uint32_t min_enc_level);
+    virtual int RefreshScreen();
+    virtual int ControlPartialUpdate(DispType dpy, bool enable);
+    virtual int ToggleScreenUpdate(bool on);
+    virtual int SetIdleTimeout(uint32_t value);
+    virtual int GetHDRCapabilities(DispType dpy, DisplayConfig::HDRCapsParams *caps);
+    virtual int SetCameraLaunchStatus(uint32_t on);
+    virtual int DisplayBWTransactionPending(bool *status);
+    virtual int SetDisplayAnimating(uint64_t display_id, bool animating);
+    virtual int ControlIdlePowerCollapse(bool enable, bool synchronous);
+    virtual int GetWriteBackCapabilities(bool *is_wb_ubwc_supported);
+    virtual int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
+                                    uint32_t v_start, uint32_t v_end, uint32_t factor_in,
+                                    uint32_t factor_out);
+    virtual int UpdateVSyncSourceOnPowerModeOff();
+    virtual int UpdateVSyncSourceOnPowerModeDoze();
+    virtual int SetPowerMode(uint32_t disp_id, DisplayConfig::PowerMode power_mode);
+    virtual int IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported);
+    virtual int IsHDRSupported(uint32_t disp_id, bool *supported);
+    virtual int IsWCGSupported(uint32_t disp_id, bool *supported);
+    virtual int SetLayerAsMask(uint32_t disp_id, uint64_t layer_id);
+    virtual int GetDebugProperty(const std::string prop_name, std::string value) {return -EINVAL;}
+    virtual int GetDebugProperty(const std::string prop_name, std::string *value);
+    virtual int GetActiveBuiltinDisplayAttributes(DisplayConfig::Attributes *attr);
+    virtual int SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum, float max_lum);
+    virtual int IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin);
+    virtual int GetSupportedDSIBitClks(uint32_t disp_id,
+                                       std::vector<uint64_t> bit_clks) {return -EINVAL;}
+    virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks);
+    virtual int GetDSIClk(uint32_t disp_id, uint64_t *bit_clk);
+    virtual int SetDSIClk(uint32_t disp_id, uint64_t bit_clk);
+    virtual int SetCWBOutputBuffer(uint32_t disp_id, const DisplayConfig::Rect rect,
+                                   bool post_processed, const native_handle_t *buffer);
+    virtual int SetQsyncMode(uint32_t disp_id, DisplayConfig::QsyncMode mode);
+
+    std::weak_ptr<DisplayConfig::ConfigCallback> callback_;
+    HWCSession *hwc_session_ = nullptr;
+  };
+
   struct DisplayMapInfo {
     hwc2_display_t client_id = HWCCallbacks::kNumDisplays;        // mapped sf id for this display
     int32_t sdm_id = -1;                                         // sdm id for this display
@@ -272,14 +332,21 @@
   void DestroyPluggableDisplay(DisplayMapInfo *map_info);
   void DestroyNonPluggableDisplay(DisplayMapInfo *map_info);
   int GetVsyncPeriod(int disp);
-  int32_t GetConfigCount(int disp_id, uint32_t *count);
-  int32_t GetActiveConfigIndex(int disp_id, uint32_t *config);
-  int32_t SetActiveConfigIndex(int disp_id, uint32_t config);
-  int32_t ControlPartialUpdate(int dpy, bool enable);
-  int32_t DisplayBWTransactionPending(bool *status);
-  int32_t SetSecondaryDisplayStatus(int disp_id, HWCDisplay::DisplayStatus status);
-  int32_t MinHdcpEncryptionLevelChanged(int disp_id, uint32_t min_enc_level);
-  int32_t IsWbUbwcSupported(int *value);
+  int GetConfigCount(int disp_id, uint32_t *count);
+  int GetActiveConfigIndex(int disp_id, uint32_t *config);
+  int SetActiveConfigIndex(int disp_id, uint32_t config);
+  int ControlPartialUpdate(int dpy, bool enable);
+  int DisplayBWTransactionPending(bool *status);
+  int SetDisplayStatus(int disp_id, HWCDisplay::DisplayStatus status);
+  int MinHdcpEncryptionLevelChanged(int disp_id, uint32_t min_enc_level);
+  int IsWbUbwcSupported(bool *value);
+  int SetIdleTimeout(uint32_t value);
+  int ToggleScreenUpdate(bool on);
+  int SetCameraLaunchStatus(uint32_t on);
+  int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
+                          uint32_t v_start, uint32_t v_end, uint32_t factor_in,
+                          uint32_t factor_out);
+  int ControlIdlePowerCollapse(bool enable, bool synchronous);
   int32_t SetDynamicDSIClock(int64_t disp_id, uint32_t bitrate);
   bool HasHDRSupport(HWCDisplay *hwc_display);
   int32_t getDisplayBrightness(uint32_t display, float *brightness);
@@ -288,62 +355,6 @@
   // service methods
   void StartServices();
 
-  // Methods from ::android::hardware::display::config::V1_0::IDisplayConfig follow.
-  Return<void> isDisplayConnected(IDisplayConfig::DisplayType dpy,
-                                  isDisplayConnected_cb _hidl_cb) override;
-  Return<int32_t> setSecondayDisplayStatus(IDisplayConfig::DisplayType dpy,
-                                  IDisplayConfig::DisplayExternalStatus status) override;
-  Return<int32_t> configureDynRefeshRate(IDisplayConfig::DisplayDynRefreshRateOp op,
-                                  uint32_t refreshRate) override;
-  Return<void> getConfigCount(IDisplayConfig::DisplayType dpy,
-                              getConfigCount_cb _hidl_cb) override;
-  Return<void> getActiveConfig(IDisplayConfig::DisplayType dpy,
-                               getActiveConfig_cb _hidl_cb) override;
-  Return<int32_t> setActiveConfig(IDisplayConfig::DisplayType dpy, uint32_t config) override;
-  Return<void> getDisplayAttributes(uint32_t configIndex, IDisplayConfig::DisplayType dpy,
-                                    getDisplayAttributes_cb _hidl_cb) override;
-  Return<int32_t> setPanelBrightness(uint32_t level) override;
-  Return<void> getPanelBrightness(getPanelBrightness_cb _hidl_cb) override;
-  Return<int32_t> minHdcpEncryptionLevelChanged(IDisplayConfig::DisplayType dpy,
-                                                uint32_t min_enc_level) override;
-  Return<int32_t> refreshScreen() override;
-  Return<int32_t> controlPartialUpdate(IDisplayConfig::DisplayType dpy, bool enable) override;
-  Return<int32_t> toggleScreenUpdate(bool on) override;
-  Return<int32_t> setIdleTimeout(uint32_t value) override;
-  Return<void> getHDRCapabilities(IDisplayConfig::DisplayType dpy,
-                                  getHDRCapabilities_cb _hidl_cb) override;
-  Return<int32_t> setCameraLaunchStatus(uint32_t on) override;
-  Return<void> displayBWTransactionPending(displayBWTransactionPending_cb _hidl_cb) override;
-  Return<int32_t> setDisplayAnimating(uint64_t display_id, bool animating) override;
-  Return<int32_t> setDisplayIndex(IDisplayConfig::DisplayTypeExt disp_type,
-                                  uint32_t base, uint32_t count) override;
-  Return<int32_t> controlIdlePowerCollapse(bool enable, bool synchronous) override;
-  Return<void> getWriteBackCapabilities(getWriteBackCapabilities_cb _hidl_cb) override;
-  Return<int32_t> SetDisplayDppsAdROI(uint32_t dispaly_id, uint32_t h_start, uint32_t h_end,
-                                      uint32_t v_start, uint32_t v_end, uint32_t factor_in,
-                                      uint32_t factor_out) override;
-  Return<int32_t> updateVSyncSourceOnPowerModeOff() override;
-  Return<int32_t> updateVSyncSourceOnPowerModeDoze() override;
-  Return<int32_t> setPowerMode(uint32_t disp_id, PowerMode power_mode) override;
-  Return<bool> isPowerModeOverrideSupported(uint32_t disp_id) override;
-  Return<bool> isHDRSupported(uint32_t disp_id) override;
-  Return<bool> isWCGSupported(uint32_t disp_id) override;
-  Return<int32_t> setLayerAsMask(uint32_t disp_id, uint64_t layer_id) override;
-  Return<void> getDebugProperty(const hidl_string &prop_name,
-                                getDebugProperty_cb _hidl_cb) override;
-  Return<void> getActiveBuiltinDisplayAttributes(getDisplayAttributes_cb _hidl_cb) override;
-  Return<int32_t> setPanelLuminanceAttributes(uint32_t disp_id, float min_lum,
-                                              float max_lum) override;
-  Return<bool> isBuiltInDisplay(uint32_t disp_id) override;
-  Return<void> getSupportedDSIBitClks(uint32_t disp_id,
-                                      getSupportedDSIBitClks_cb _hidl_cb) override;
-  Return<uint64_t> getDSIClk(uint32_t disp_id) override;
-  Return<int32_t> setDSIClk(uint32_t disp_id, uint64_t bit_clk) override;
-  Return<int32_t> setCWBOutputBuffer(const ::android::sp<IDisplayCWBCallback> &callback,
-                                     uint32_t disp_id, const Rect &rect, bool post_processed,
-                                     const hidl_handle& buffer) override;
-  Return<int32_t> setQsyncMode(uint32_t disp_id, IDisplayConfig::QsyncMode mode) override;
-
   // 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 abd2786..99cfd45 100644
--- a/sdm/libs/hwc2/hwc_session_services.cpp
+++ b/sdm/libs/hwc2/hwc_session_services.cpp
@@ -32,6 +32,8 @@
 #include <sync/sync.h>
 #include <vector>
 #include <string>
+#include <errno.h>
+#include <math.h>
 
 #include "hwc_buffer_sync_handler.h"
 #include "hwc_session.h"
@@ -41,26 +43,24 @@
 
 namespace sdm {
 
-using ::android::hardware::Void;
-
 void HWCSession::StartServices() {
-  android::status_t status = IDisplayConfig::registerAsService();
-  if (status != android::OK) {
-    DLOGW("Could not register IDisplayConfig as service (%d).", status);
+  int error = DisplayConfig::DeviceInterface::RegisterDevice(this);
+  if (error) {
+    DLOGW("Could not register IDisplayConfig as service (%d).", error);
   } else {
     DLOGI("IDisplayConfig service registration completed.");
   }
 }
 
-int MapDisplayType(IDisplayConfig::DisplayType dpy) {
+int MapDisplayType(DispType dpy) {
   switch (dpy) {
-    case IDisplayConfig::DisplayType::DISPLAY_PRIMARY:
+    case DispType::kPrimary:
       return qdutils::DISPLAY_PRIMARY;
 
-    case IDisplayConfig::DisplayType::DISPLAY_EXTERNAL:
+    case DispType::kExternal:
       return qdutils::DISPLAY_EXTERNAL;
 
-    case IDisplayConfig::DisplayType::DISPLAY_VIRTUAL:
+    case DispType::kVirtual:
       return qdutils::DISPLAY_VIRTUAL;
 
     default:
@@ -70,18 +70,18 @@
   return -EINVAL;
 }
 
-HWCDisplay::DisplayStatus MapExternalStatus(IDisplayConfig::DisplayExternalStatus status) {
+HWCDisplay::DisplayStatus MapExternalStatus(DisplayConfig::ExternalStatus status) {
   switch (status) {
-    case IDisplayConfig::DisplayExternalStatus::EXTERNAL_OFFLINE:
+    case DisplayConfig::ExternalStatus::kOffline:
       return HWCDisplay::kDisplayStatusOffline;
 
-    case IDisplayConfig::DisplayExternalStatus::EXTERNAL_ONLINE:
+    case DisplayConfig::ExternalStatus::kOnline:
       return HWCDisplay::kDisplayStatusOnline;
 
-    case IDisplayConfig::DisplayExternalStatus::EXTERNAL_PAUSE:
+    case DisplayConfig::ExternalStatus::kPause:
       return HWCDisplay::kDisplayStatusPause;
 
-    case IDisplayConfig::DisplayExternalStatus::EXTERNAL_RESUME:
+    case DisplayConfig::ExternalStatus::kResume:
       return HWCDisplay::kDisplayStatusResume;
 
     default:
@@ -91,27 +91,47 @@
   return HWCDisplay::kDisplayStatusInvalid;
 }
 
-// Methods from ::vendor::hardware::display::config::V1_0::IDisplayConfig follow.
-Return<void> HWCSession::isDisplayConnected(IDisplayConfig::DisplayType dpy,
-                                            isDisplayConnected_cb _hidl_cb) {
-  int32_t error = -EINVAL;
-  bool connected = false;
+int HWCSession::RegisterClientContext(std::shared_ptr<DisplayConfig::ConfigCallback> callback,
+                                      DisplayConfig::ConfigInterface **intf) {
+  if (!intf) {
+    DLOGE("Invalid DisplayConfigIntf location");
+    return -EINVAL;
+  }
+
+  std::weak_ptr<DisplayConfig::ConfigCallback> wp_callback = callback;
+  DisplayConfigImpl *impl = new DisplayConfigImpl(wp_callback, this);
+  *intf = impl;
+
+  return 0;
+}
+
+void HWCSession::UnRegisterClientContext(DisplayConfig::ConfigInterface *intf) {
+  delete static_cast<DisplayConfigImpl *>(intf);
+}
+
+HWCSession::DisplayConfigImpl::DisplayConfigImpl(
+                               std::weak_ptr<DisplayConfig::ConfigCallback> callback,
+                               HWCSession *hwc_session) {
+  callback_ = callback;
+  hwc_session_ = hwc_session;
+}
+
+int HWCSession::DisplayConfigImpl::IsDisplayConnected(DispType dpy, bool *connected) {
   int disp_id = MapDisplayType(dpy);
-  int disp_idx = GetDisplayIndex(disp_id);
+  int disp_idx = hwc_session_->GetDisplayIndex(disp_id);
 
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
+    return -EINVAL;
   } else {
-    SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_idx]);
-    connected = hwc_display_[disp_idx];
-    error = 0;
+    SEQUENCE_WAIT_SCOPE_LOCK(hwc_session_->locker_[disp_idx]);
+    *connected = hwc_session_->hwc_display_[disp_idx];
   }
-  _hidl_cb(error, connected);
 
-  return Void();
+  return 0;
 }
 
-int32_t HWCSession::SetSecondaryDisplayStatus(int disp_id, HWCDisplay::DisplayStatus status) {
+int HWCSession::SetDisplayStatus(int disp_id, HWCDisplay::DisplayStatus status) {
   int disp_idx = GetDisplayIndex(disp_id);
   int err = -EINVAL;
   if (disp_idx == -1) {
@@ -151,15 +171,15 @@
   return err;
 }
 
-Return<int32_t> HWCSession::setSecondayDisplayStatus(IDisplayConfig::DisplayType dpy,
-                                                  IDisplayConfig::DisplayExternalStatus status) {
-  return SetSecondaryDisplayStatus(MapDisplayType(dpy), MapExternalStatus(status));
+int HWCSession::DisplayConfigImpl::SetDisplayStatus(DispType dpy,
+                                                    DisplayConfig::ExternalStatus status) {
+  return hwc_session_->SetDisplayStatus(MapDisplayType(dpy), MapExternalStatus(status));
 }
 
-Return<int32_t> HWCSession::configureDynRefeshRate(IDisplayConfig::DisplayDynRefreshRateOp op,
-                                                   uint32_t refreshRate) {
-  SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
-  HWCDisplay *hwc_display = hwc_display_[HWC_DISPLAY_PRIMARY];
+int HWCSession::DisplayConfigImpl::ConfigureDynRefreshRate(DisplayConfig::DynRefreshRateOp op,
+                                                           uint32_t refresh_rate) {
+  SEQUENCE_WAIT_SCOPE_LOCK(hwc_session_->locker_[HWC_DISPLAY_PRIMARY]);
+  HWCDisplay *hwc_display = hwc_session_->hwc_display_[HWC_DISPLAY_PRIMARY];
 
   if (!hwc_display) {
     DLOGW("Display = %d is not connected.", HWC_DISPLAY_PRIMARY);
@@ -167,14 +187,14 @@
   }
 
   switch (op) {
-    case IDisplayConfig::DisplayDynRefreshRateOp::DISABLE_METADATA_DYN_REFRESH_RATE:
+    case DisplayConfig::DynRefreshRateOp::kDisableMetadata:
       return hwc_display->Perform(HWCDisplayBuiltIn::SET_METADATA_DYN_REFRESH_RATE, false);
 
-    case IDisplayConfig::DisplayDynRefreshRateOp::ENABLE_METADATA_DYN_REFRESH_RATE:
+    case DisplayConfig::DynRefreshRateOp::kEnableMetadata:
       return hwc_display->Perform(HWCDisplayBuiltIn::SET_METADATA_DYN_REFRESH_RATE, true);
 
-    case IDisplayConfig::DisplayDynRefreshRateOp::SET_BINDER_DYN_REFRESH_RATE:
-      return hwc_display->Perform(HWCDisplayBuiltIn::SET_BINDER_DYN_REFRESH_RATE, refreshRate);
+    case DisplayConfig::DynRefreshRateOp::kSetBinder:
+      return hwc_display->Perform(HWCDisplayBuiltIn::SET_BINDER_DYN_REFRESH_RATE, refresh_rate);
 
     default:
       DLOGW("Invalid operation %d", op);
@@ -184,7 +204,7 @@
   return 0;
 }
 
-int32_t HWCSession::GetConfigCount(int disp_id, uint32_t *count) {
+int HWCSession::GetConfigCount(int disp_id, uint32_t *count) {
   int disp_idx = GetDisplayIndex(disp_id);
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
@@ -200,17 +220,11 @@
   return -EINVAL;
 }
 
-Return<void> HWCSession::getConfigCount(IDisplayConfig::DisplayType dpy,
-                                        getConfigCount_cb _hidl_cb) {
-  uint32_t count = 0;
-  int32_t error = GetConfigCount(MapDisplayType(dpy), &count);
-
-  _hidl_cb(error, count);
-
-  return Void();
+int HWCSession::DisplayConfigImpl::GetConfigCount(DispType dpy, uint32_t *count) {
+  return hwc_session_->GetConfigCount(MapDisplayType(dpy), count);
 }
 
-int32_t HWCSession::GetActiveConfigIndex(int disp_id, uint32_t *config) {
+int HWCSession::GetActiveConfigIndex(int disp_id, uint32_t *config) {
   int disp_idx = GetDisplayIndex(disp_id);
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
@@ -226,17 +240,11 @@
   return -EINVAL;
 }
 
-Return<void> HWCSession::getActiveConfig(IDisplayConfig::DisplayType dpy,
-                                         getActiveConfig_cb _hidl_cb) {
-  uint32_t config = 0;
-  int32_t error = GetActiveConfigIndex(MapDisplayType(dpy), &config);
-
-  _hidl_cb(error, config);
-
-  return Void();
+int HWCSession::DisplayConfigImpl::GetActiveConfig(DispType dpy, uint32_t *config) {
+  return hwc_session_->GetActiveConfigIndex(MapDisplayType(dpy), config);
 }
 
-int32_t HWCSession::SetActiveConfigIndex(int disp_id, uint32_t config) {
+int HWCSession::SetActiveConfigIndex(int disp_id, uint32_t config) {
   int disp_idx = GetDisplayIndex(disp_id);
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
@@ -244,7 +252,7 @@
   }
 
   SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_idx]);
-  int32_t error = -EINVAL;
+  int error = -EINVAL;
   if (hwc_display_[disp_idx]) {
     error = hwc_display_[disp_idx]->SetActiveDisplayConfig(config);
     if (!error) {
@@ -255,69 +263,69 @@
   return error;
 }
 
-Return<int32_t> HWCSession::setActiveConfig(IDisplayConfig::DisplayType dpy, uint32_t config) {
-  return SetActiveConfigIndex(MapDisplayType(dpy), config);
+int HWCSession::DisplayConfigImpl::SetActiveConfig(DispType dpy, uint32_t config) {
+  return hwc_session_->SetActiveConfigIndex(MapDisplayType(dpy), config);
 }
 
-Return<void> HWCSession::getDisplayAttributes(uint32_t configIndex,
-                                              IDisplayConfig::DisplayType dpy,
-                                              getDisplayAttributes_cb _hidl_cb) {
-  int32_t error = -EINVAL;
-  IDisplayConfig::DisplayAttributes display_attributes = {};
+int HWCSession::DisplayConfigImpl::GetDisplayAttributes(uint32_t config_index, DispType dpy,
+                                                        DisplayConfig::Attributes *attributes) {
+  int error = -EINVAL;
+
   int disp_id = MapDisplayType(dpy);
-  int disp_idx = GetDisplayIndex(disp_id);
+  int disp_idx = hwc_session_->GetDisplayIndex(disp_id);
 
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
   } else {
-    SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_idx]);
-    if (hwc_display_[disp_idx]) {
+    SEQUENCE_WAIT_SCOPE_LOCK(hwc_session_->locker_[disp_idx]);
+    if (hwc_session_->hwc_display_[disp_idx]) {
       DisplayConfigVariableInfo var_info;
-      error = hwc_display_[disp_idx]->GetDisplayAttributesForConfig(INT(configIndex), &var_info);
+      error = hwc_session_->hwc_display_[disp_idx]->GetDisplayAttributesForConfig(INT(config_index),
+                                                                                  &var_info);
       if (!error) {
-        display_attributes.vsyncPeriod = var_info.vsync_period_ns;
-        display_attributes.xRes = var_info.x_pixels;
-        display_attributes.yRes = var_info.y_pixels;
-        display_attributes.xDpi = var_info.x_dpi;
-        display_attributes.yDpi = var_info.y_dpi;
-        display_attributes.panelType = IDisplayConfig::DisplayPortType::DISPLAY_PORT_DEFAULT;
-        display_attributes.isYuv = var_info.is_yuv;
+        attributes->vsync_period = var_info.vsync_period_ns;
+        attributes->x_res = var_info.x_pixels;
+        attributes->y_res = var_info.y_pixels;
+        attributes->x_dpi = var_info.x_dpi;
+        attributes->y_dpi = var_info.y_dpi;
+        attributes->panel_type = DisplayConfig::DisplayPortType::kDefault;
+        attributes->is_yuv = var_info.is_yuv;
       }
     }
   }
-  _hidl_cb(error, display_attributes);
 
-  return Void();
+  return error;
 }
 
-Return<int32_t> HWCSession::setPanelBrightness(uint32_t level) {
+int HWCSession::DisplayConfigImpl::SetPanelBrightness(uint32_t level) {
   if (!(0 <= level && level <= 255)) {
     return -EINVAL;
   }
 
-  hwc2_device_t *device = static_cast<hwc2_device_t *>(this);
+  hwc2_device_t *device = static_cast<hwc2_device_t *>(hwc_session_);
   if (level == 0) {
-    return INT32(SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY, -1.0f));
+    return INT32(hwc_session_->SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY, -1.0f));
   } else {
-    return INT32(SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY, (level - 1)/254.0f));
+    return INT32(hwc_session_->SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY,
+                                                    (level - 1)/254.0f));
   }
 }
 
-Return<void> HWCSession::getPanelBrightness(getPanelBrightness_cb _hidl_cb) {
+int HWCSession::DisplayConfigImpl::GetPanelBrightness(uint32_t *level) {
   float brightness = -1.0f;
   int32_t error = -EINVAL;
 
-  error = getDisplayBrightness(HWC_DISPLAY_PRIMARY, &brightness);
+  error = hwc_session_->getDisplayBrightness(HWC_DISPLAY_PRIMARY, &brightness);
   if (brightness == -1.0f) {
-    _hidl_cb(error, 0);
+    *level = 0;
   } else {
-    _hidl_cb(error, static_cast<uint32_t>(254.0f*brightness + 1));
+    *level = static_cast<uint32_t>(254.0f*brightness + 1);
   }
 
-  return Void();
+  return error;
 }
 
-int32_t HWCSession::MinHdcpEncryptionLevelChanged(int disp_id, uint32_t min_enc_level) {
+int HWCSession::MinHdcpEncryptionLevelChanged(int disp_id, uint32_t min_enc_level) {
   DLOGI("Display %d", disp_id);
 
   int disp_idx = GetDisplayIndex(disp_id);
@@ -338,19 +346,18 @@
   return -EINVAL;
 }
 
-Return<int32_t> HWCSession::minHdcpEncryptionLevelChanged(IDisplayConfig::DisplayType dpy,
-                                                          uint32_t min_enc_level) {
-  return MinHdcpEncryptionLevelChanged(MapDisplayType(dpy), min_enc_level);
+int HWCSession::DisplayConfigImpl::MinHdcpEncryptionLevelChanged(DispType dpy,
+                                                                 uint32_t min_enc_level) {
+  return hwc_session_->MinHdcpEncryptionLevelChanged(MapDisplayType(dpy), min_enc_level);
 }
 
-Return<int32_t> HWCSession::refreshScreen() {
-  SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
-  Refresh(HWC_DISPLAY_PRIMARY);
-
+int HWCSession::DisplayConfigImpl::RefreshScreen() {
+  SEQUENCE_WAIT_SCOPE_LOCK(hwc_session_->locker_[HWC_DISPLAY_PRIMARY]);
+  hwc_session_->Refresh(HWC_DISPLAY_PRIMARY);
   return 0;
 }
 
-int32_t HWCSession::ControlPartialUpdate(int disp_id, bool enable) {
+int HWCSession::ControlPartialUpdate(int disp_id, bool enable) {
   int disp_idx = GetDisplayIndex(disp_id);
   if (disp_idx == -1) {
     DLOGE("Invalid display = %d", disp_id);
@@ -386,16 +393,16 @@
   Refresh(HWC_DISPLAY_PRIMARY);
 
   // Wait until partial update control is complete
-  int32_t error = locker_[disp_idx].WaitFinite(kCommitDoneTimeoutMs);
+  int error = locker_[disp_idx].WaitFinite(kCommitDoneTimeoutMs);
 
   return error;
 }
 
-Return<int32_t> HWCSession::controlPartialUpdate(IDisplayConfig::DisplayType dpy, bool enable) {
-  return ControlPartialUpdate(MapDisplayType(dpy), enable);
+int HWCSession::DisplayConfigImpl::ControlPartialUpdate(DispType dpy, bool enable) {
+  return hwc_session_->ControlPartialUpdate(MapDisplayType(dpy), enable);
 }
 
-Return<int32_t> HWCSession::toggleScreenUpdate(bool on) {
+int HWCSession::ToggleScreenUpdate(bool on) {
   SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
 
   int32_t error = -EINVAL;
@@ -409,7 +416,11 @@
   return error;
 }
 
-Return<int32_t> HWCSession::setIdleTimeout(uint32_t value) {
+int HWCSession::DisplayConfigImpl::ToggleScreenUpdate(bool on) {
+  return hwc_session_->ToggleScreenUpdate(on);
+}
+
+int HWCSession::SetIdleTimeout(uint32_t value) {
   SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
 
   if (hwc_display_[HWC_DISPLAY_PRIMARY]) {
@@ -421,26 +432,24 @@
   return -ENODEV;
 }
 
-Return<void> HWCSession::getHDRCapabilities(IDisplayConfig::DisplayType dpy,
-                                            getHDRCapabilities_cb _hidl_cb) {
-  int32_t error = -EINVAL;
-  IDisplayConfig::DisplayHDRCapabilities hdr_caps = {};
+int HWCSession::DisplayConfigImpl::SetIdleTimeout(uint32_t value) {
+  return hwc_session_->SetIdleTimeout(value);
+}
+
+int HWCSession::DisplayConfigImpl::GetHDRCapabilities(DispType dpy,
+                                                      DisplayConfig::HDRCapsParams *caps) {
+  int error = -EINVAL;
 
   do {
-    if (!_hidl_cb) {
-      DLOGE("_hidl_cb callback not provided.");
-      break;
-    }
-
     int disp_id = MapDisplayType(dpy);
-    int disp_idx = GetDisplayIndex(disp_id);
+    int disp_idx = hwc_session_->GetDisplayIndex(disp_id);
     if (disp_idx == -1) {
       DLOGE("Invalid display = %d", disp_id);
       break;
     }
 
-    SCOPE_LOCK(locker_[disp_id]);
-    HWCDisplay *hwc_display = hwc_display_[disp_idx];
+    SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+    HWCDisplay *hwc_display = hwc_session_->hwc_display_[disp_idx];
     if (!hwc_display) {
       DLOGW("Display = %d is not connected.", disp_idx);
       error = -ENODEV;
@@ -463,21 +472,19 @@
     }
 
     // query hdr caps
-    hdr_caps.supportedHdrTypes.resize(out_num_types);
+    caps->supported_hdr_types.resize(out_num_types);
 
-    if (hwc_display->GetHdrCapabilities(&out_num_types, hdr_caps.supportedHdrTypes.data(),
+    if (hwc_display->GetHdrCapabilities(&out_num_types, caps->supported_hdr_types.data(),
                                         &out_max_luminance, &out_max_average_luminance,
                                         &out_min_luminance) == HWC2::Error::None) {
       error = 0;
     }
   } while (false);
 
-  _hidl_cb(error, hdr_caps);
-
-  return Void();
+  return error;
 }
 
-Return<int32_t> HWCSession::setCameraLaunchStatus(uint32_t on) {
+int HWCSession::SetCameraLaunchStatus(uint32_t on) {
   hwc2_display_t active_builtin_disp_id = GetActiveBuiltinDisplay();
   if (active_builtin_disp_id >= HWCCallbacks::kNumDisplays) {
     DLOGE("No active displays");
@@ -515,7 +522,11 @@
   return 0;
 }
 
-int32_t HWCSession::DisplayBWTransactionPending(bool *status) {
+int HWCSession::DisplayConfigImpl::SetCameraLaunchStatus(uint32_t on) {
+  return hwc_session_->SetCameraLaunchStatus(on);
+}
+
+int HWCSession::DisplayBWTransactionPending(bool *status) {
   SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
 
   if (hwc_display_[HWC_DISPLAY_PRIMARY]) {
@@ -531,32 +542,16 @@
   return -ENODEV;
 }
 
-Return<void> HWCSession::displayBWTransactionPending(displayBWTransactionPending_cb _hidl_cb) {
-  bool status = true;
-
-  if (!_hidl_cb) {
-      DLOGE("_hidl_cb callback not provided.");
-      return Void();
-  }
-
-  int32_t error = DisplayBWTransactionPending(&status);
-
-  _hidl_cb(error, status);
-
-  return Void();
+int HWCSession::DisplayConfigImpl::DisplayBWTransactionPending(bool *status) {
+  return hwc_session_->DisplayBWTransactionPending(status);
 }
 
-Return<int32_t> HWCSession::setDisplayAnimating(uint64_t display_id, bool animating ) {
-  return CallDisplayFunction(static_cast<hwc2_device_t *>(this), display_id,
-                             &HWCDisplay::SetDisplayAnimating, animating);
+int HWCSession::DisplayConfigImpl::SetDisplayAnimating(uint64_t display_id, bool animating) {
+  return hwc_session_->CallDisplayFunction(static_cast<hwc2_device_t *>(hwc_session_), display_id,
+                                           &HWCDisplay::SetDisplayAnimating, animating);
 }
 
-Return<int32_t> HWCSession::setDisplayIndex(IDisplayConfig::DisplayTypeExt disp_type,
-                                            uint32_t base, uint32_t count) {
-  return -1;
-}
-
-Return<int32_t> HWCSession::controlIdlePowerCollapse(bool enable, bool synchronous) {
+int HWCSession::ControlIdlePowerCollapse(bool enable, bool synchronous) {
   hwc2_display_t active_builtin_disp_id = GetActiveBuiltinDisplay();
   if (active_builtin_disp_id >= HWCCallbacks::kNumDisplays) {
     DLOGE("No active displays");
@@ -573,7 +568,7 @@
           return (err == kErrorNotSupported) ? 0 : -EINVAL;
         }
         Refresh(active_builtin_disp_id);
-        int32_t error = locker_[active_builtin_disp_id].WaitFinite(kCommitDoneTimeoutMs);
+        int error = locker_[active_builtin_disp_id].WaitFinite(kCommitDoneTimeoutMs);
         if (error == ETIMEDOUT) {
           DLOGE("Timed out!! Next frame commit done event not received!!");
           return error;
@@ -599,7 +594,11 @@
   return -ENODEV;
 }
 
-int32_t HWCSession::IsWbUbwcSupported(int *value) {
+int HWCSession::DisplayConfigImpl::ControlIdlePowerCollapse(bool enable, bool synchronous) {
+  return hwc_session_->ControlIdlePowerCollapse(enable, synchronous);
+}
+
+int HWCSession::IsWbUbwcSupported(bool *value) {
   HWDisplaysInfo hw_displays_info = {};
   DisplayError error = core_intf_->GetDisplaysStatus(&hw_displays_info);
   if (error != kErrorNone) {
@@ -616,118 +615,128 @@
   return error;
 }
 
-Return<void> HWCSession::getWriteBackCapabilities(getWriteBackCapabilities_cb _hidl_cb) {
-  int value = 0;
-  IDisplayConfig::WriteBackCapabilities wb_caps = {};
-  int32_t error = IsWbUbwcSupported(&value);
-  wb_caps.isWbUbwcSupported = value;
-  _hidl_cb(error, wb_caps);
-
-  return Void();
+int HWCSession::DisplayConfigImpl::GetWriteBackCapabilities(bool *isWbUbwcSupported) {
+  return hwc_session_->IsWbUbwcSupported(isWbUbwcSupported);
 }
 
-Return<int32_t> HWCSession::SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start,
-                                                uint32_t h_end, uint32_t v_start, uint32_t v_end,
-                                                uint32_t factor_in, uint32_t factor_out) {
+int HWCSession::SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start,
+                                    uint32_t h_end, uint32_t v_start, uint32_t v_end,
+                                    uint32_t factor_in, uint32_t factor_out) {
   return CallDisplayFunction(static_cast<hwc2_device_t *>(this), display_id,
                              &HWCDisplay::SetDisplayDppsAdROI, h_start, h_end, v_start, v_end,
                              factor_in, factor_out);
 }
 
-Return<int32_t> HWCSession::updateVSyncSourceOnPowerModeOff() {
+int HWCSession::DisplayConfigImpl::SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start,
+                                                       uint32_t h_end, uint32_t v_start,
+                                                       uint32_t v_end, uint32_t factor_in,
+                                                       uint32_t factor_out) {
+  return hwc_session_->SetDisplayDppsAdROI(display_id, h_start, h_end, v_start, v_end,
+                                           factor_in, factor_out);
+}
+
+int HWCSession::DisplayConfigImpl::UpdateVSyncSourceOnPowerModeOff() {
   return 0;
 }
 
-Return<int32_t> HWCSession::updateVSyncSourceOnPowerModeDoze() {
+int HWCSession::DisplayConfigImpl::UpdateVSyncSourceOnPowerModeDoze() {
   return 0;
 }
 
-Return<bool> HWCSession::isPowerModeOverrideSupported(uint32_t disp_id) {
-  if (!async_powermode_ || (disp_id > HWCCallbacks::kNumRealDisplays)) {
-    return false;
+int HWCSession::DisplayConfigImpl::IsPowerModeOverrideSupported(uint32_t disp_id,
+                                                                bool *supported) {
+  if (!hwc_session_->async_powermode_ || (disp_id > HWCCallbacks::kNumRealDisplays)) {
+    *supported = false;
+  } else {
+    *supported = true;
   }
 
-  return true;
+  return 0;
 }
 
-Return<int32_t> HWCSession::setPowerMode(uint32_t disp_id, PowerMode power_mode) {
-  SCOPE_LOCK(display_config_locker_);
+int HWCSession::DisplayConfigImpl::SetPowerMode(uint32_t disp_id,
+                                                DisplayConfig::PowerMode power_mode) {
+  SCOPE_LOCK(hwc_session_->display_config_locker_);
 
-  if (!isPowerModeOverrideSupported(disp_id)) {
+  bool supported = false;
+  IsPowerModeOverrideSupported(disp_id, &supported);
+  if (!supported) {
     return 0;
   }
 
   DLOGI("disp_id: %d power_mode: %d", disp_id, power_mode);
   HWCDisplay::HWCLayerStack stack = {};
-  hwc2_display_t dummy_disp_id = map_hwc_display_.at(disp_id);
+  hwc2_display_t dummy_disp_id = hwc_session_->map_hwc_display_.at(disp_id);
 
   {
     // Power state transition start.
-    Locker::ScopeLock lock_power(power_state_[disp_id]);
-    Locker::ScopeLock lock_primary(locker_[disp_id]);
-    Locker::ScopeLock lock_dummy(locker_[dummy_disp_id]);
+    Locker::ScopeLock lock_power(hwc_session_->power_state_[disp_id]);
+    Locker::ScopeLock lock_primary(hwc_session_->locker_[disp_id]);
+    Locker::ScopeLock lock_dummy(hwc_session_->locker_[dummy_disp_id]);
 
-    power_state_transition_[disp_id] = true;
+    hwc_session_->power_state_transition_[disp_id] = true;
     // Pass on the complete stack to dummy display.
-    hwc_display_[disp_id]->GetLayerStack(&stack);
+    hwc_session_->hwc_display_[disp_id]->GetLayerStack(&stack);
     // Update the same stack onto dummy display.
-    hwc_display_[dummy_disp_id]->SetLayerStack(&stack);
+    hwc_session_->hwc_display_[dummy_disp_id]->SetLayerStack(&stack);
   }
 
   {
-    SCOPE_LOCK(locker_[disp_id]);
+    SCOPE_LOCK(hwc_session_->locker_[disp_id]);
     auto mode = static_cast<HWC2::PowerMode>(power_mode);
-    hwc_display_[disp_id]->SetPowerMode(mode, false /* teardown */);
+    hwc_session_->hwc_display_[disp_id]->SetPowerMode(mode, false /* teardown */);
   }
 
   {
     // Power state transition end.
-    Locker::ScopeLock lock_power(power_state_[disp_id]);
-    Locker::ScopeLock lock_primary(locker_[disp_id]);
-    Locker::ScopeLock lock_dummy(locker_[dummy_disp_id]);
+    Locker::ScopeLock lock_power(hwc_session_->power_state_[disp_id]);
+    Locker::ScopeLock lock_primary(hwc_session_->locker_[disp_id]);
+    Locker::ScopeLock lock_dummy(hwc_session_->locker_[dummy_disp_id]);
     // Pass on the layer stack to real display.
-    hwc_display_[dummy_disp_id]->GetLayerStack(&stack);
+    hwc_session_->hwc_display_[dummy_disp_id]->GetLayerStack(&stack);
     // Update the same stack onto real display.
-    hwc_display_[disp_id]->SetLayerStack(&stack);
+    hwc_session_->hwc_display_[disp_id]->SetLayerStack(&stack);
     // Read display has got layerstack. Update the fences.
-    hwc_display_[disp_id]->PostPowerMode();
+    hwc_session_->hwc_display_[disp_id]->PostPowerMode();
 
-    power_state_transition_[disp_id] = false;
+    hwc_session_->power_state_transition_[disp_id] = false;
   }
 
   return 0;
 }
 
-Return<bool> HWCSession::isHDRSupported(uint32_t disp_id) {
+int HWCSession::DisplayConfigImpl::IsHDRSupported(uint32_t disp_id, bool *supported) {
   if (disp_id < 0 || disp_id >= HWCCallbacks::kNumDisplays) {
     DLOGE("Not valid display");
-    return false;
+    return -EINVAL;
   }
-  SCOPE_LOCK(locker_[disp_id]);
+  SCOPE_LOCK(hwc_session_->locker_[disp_id]);
 
-  if (is_hdr_display_.size() <= disp_id) {
+  if (hwc_session_->is_hdr_display_.size() <= disp_id) {
     DLOGW("is_hdr_display_ is not initialized for display %d!! Reporting it as HDR not supported",
           disp_id);
-    return false;
+    *supported = false;
+    return 0;
   }
 
-  return static_cast<bool>(is_hdr_display_[disp_id]);
+  *supported = static_cast<bool>(hwc_session_->is_hdr_display_[disp_id]);
+  return 0;
 }
 
-Return<bool> HWCSession::isWCGSupported(uint32_t disp_id) {
+int HWCSession::DisplayConfigImpl::IsWCGSupported(uint32_t disp_id, bool *supported) {
   // todo(user): Query wcg from sdm. For now assume them same.
-  return isHDRSupported(disp_id);
+  return IsHDRSupported(disp_id, supported);
 }
 
-Return<int32_t> HWCSession::setLayerAsMask(uint32_t disp_id, uint64_t layer_id) {
-  SCOPE_LOCK(locker_[disp_id]);
-  HWCDisplay *hwc_display = hwc_display_[disp_id];
+int HWCSession::DisplayConfigImpl::SetLayerAsMask(uint32_t disp_id, uint64_t layer_id) {
+  SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+  HWCDisplay *hwc_display = hwc_session_->hwc_display_[disp_id];
   if (!hwc_display) {
     DLOGW("Display = %d is not connected.", disp_id);
     return -EINVAL;
   }
 
-  if (disable_mask_layer_hint_) {
+  if (hwc_session_->disable_mask_layer_hint_) {
     DLOGW("Mask layer hint is disabled!");
     return -EINVAL;
   }
@@ -742,153 +751,148 @@
   return 0;
 }
 
-Return<void> HWCSession::getDebugProperty(const hidl_string &prop_name,
-                                          getDebugProperty_cb _hidl_cb) {
+int HWCSession::DisplayConfigImpl::GetDebugProperty(const std::string prop_name,
+                                                    std::string *value) {
   std::string vendor_prop_name = DISP_PROP_PREFIX;
-  char value[64] = {};
-  hidl_string result = "";
-  int32_t error = -EINVAL;
+  int error = -EINVAL;
+  char val[64] = {};
 
   vendor_prop_name += prop_name.c_str();
-  if (HWCDebugHandler::Get()->GetProperty(vendor_prop_name.c_str(), value) == kErrorNone) {
-    result = value;
+  if (HWCDebugHandler::Get()->GetProperty(vendor_prop_name.c_str(), val) == kErrorNone) {
+    *value = val;
     error = 0;
   }
 
-  _hidl_cb(result, error);
-
-  return Void();
+  return error;
 }
 
-Return<void> HWCSession::getActiveBuiltinDisplayAttributes(
-                                          getDisplayAttributes_cb _hidl_cb) {
-  int32_t error = -EINVAL;
-  IDisplayConfig::DisplayAttributes display_attributes = {};
-  hwc2_display_t disp_id = GetActiveBuiltinDisplay();
+int HWCSession::DisplayConfigImpl::GetActiveBuiltinDisplayAttributes(
+                                          DisplayConfig::Attributes *attr) {
+  int error = -EINVAL;
+  hwc2_display_t disp_id = hwc_session_->GetActiveBuiltinDisplay();
 
   if (disp_id >= HWCCallbacks::kNumDisplays) {
     DLOGE("Invalid display = %d", disp_id);
   } else {
-    if (hwc_display_[disp_id]) {
+    if (hwc_session_->hwc_display_[disp_id]) {
       uint32_t config_index = 0;
-      HWC2::Error ret = hwc_display_[disp_id]->GetActiveConfig(&config_index);
+      HWC2::Error ret = hwc_session_->hwc_display_[disp_id]->GetActiveConfig(&config_index);
       if (ret != HWC2::Error::None) {
         goto err;
       }
       DisplayConfigVariableInfo var_info;
-      error = hwc_display_[disp_id]->GetDisplayAttributesForConfig(INT(config_index), &var_info);
+      error = hwc_session_->hwc_display_[disp_id]->GetDisplayAttributesForConfig(INT(config_index),
+                                                                                 &var_info);
       if (!error) {
-        display_attributes.vsyncPeriod = var_info.vsync_period_ns;
-        display_attributes.xRes = var_info.x_pixels;
-        display_attributes.yRes = var_info.y_pixels;
-        display_attributes.xDpi = var_info.x_dpi;
-        display_attributes.yDpi = var_info.y_dpi;
-        display_attributes.panelType = IDisplayConfig::DisplayPortType::DISPLAY_PORT_DEFAULT;
-        display_attributes.isYuv = var_info.is_yuv;
+        attr->vsync_period = var_info.vsync_period_ns;
+        attr->x_res = var_info.x_pixels;
+        attr->y_res = var_info.y_pixels;
+        attr->x_dpi = var_info.x_dpi;
+        attr->y_dpi = var_info.y_dpi;
+        attr->panel_type = DisplayConfig::DisplayPortType::kDefault;
+        attr->is_yuv = var_info.is_yuv;
       }
     }
   }
 
 err:
-  _hidl_cb(error, display_attributes);
-
-  return Void();
+  return error;
 }
 
-Return<int32_t> HWCSession::setPanelLuminanceAttributes(uint32_t disp_id, float pan_min_lum,
-                                                        float pan_max_lum) {
+int HWCSession::DisplayConfigImpl::SetPanelLuminanceAttributes(uint32_t disp_id, float pan_min_lum,
+                                                               float pan_max_lum) {
   // currently doing only for virtual display
   if (disp_id != qdutils::DISPLAY_VIRTUAL) {
     return -EINVAL;
   }
 
-  std::lock_guard<std::mutex> obj(mutex_lum_);
-  set_min_lum_ = pan_min_lum;
-  set_max_lum_ = pan_max_lum;
-  DLOGI("set max_lum %f, min_lum %f", set_max_lum_, set_min_lum_);
+  std::lock_guard<std::mutex> obj(hwc_session_->mutex_lum_);
+  hwc_session_->set_min_lum_ = pan_min_lum;
+  hwc_session_->set_max_lum_ = pan_max_lum;
+  DLOGI("set max_lum %f, min_lum %f", pan_max_lum, pan_min_lum);
 
   return 0;
 }
 
-Return<bool> HWCSession::isBuiltInDisplay(uint32_t disp_id) {
-  if ((map_info_primary_.client_id == disp_id) && (map_info_primary_.disp_type == kBuiltIn))
-    return true;
-
-  for (auto &info : map_info_builtin_) {
-    if (disp_id == info.client_id) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
-Return<void> HWCSession::getSupportedDSIBitClks(uint32_t disp_id,
-                                                getSupportedDSIBitClks_cb _hidl_cb) {
-  SCOPE_LOCK(locker_[disp_id]);
-  if (!hwc_display_[disp_id]) {
-    return Void();
-  }
-
-  std::vector<uint64_t> bit_clks;
-  hwc_display_[disp_id]->GetSupportedDSIClock(&bit_clks);
-
-  hidl_vec<uint64_t> hidl_bit_clks = bit_clks;
-  _hidl_cb(hidl_bit_clks);
-
-  return Void();
-}
-
-Return<uint64_t> HWCSession::getDSIClk(uint32_t disp_id) {
-  SCOPE_LOCK(locker_[disp_id]);
-  if (!hwc_display_[disp_id]) {
+int HWCSession::DisplayConfigImpl::IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin) {
+  if ((hwc_session_->map_info_primary_.client_id == disp_id) &&
+      (hwc_session_->map_info_primary_.disp_type == kBuiltIn)) {
+    *is_builtin = true;
     return 0;
   }
 
-  uint64_t bit_clk = 0;
-  hwc_display_[disp_id]->GetDynamicDSIClock(&bit_clk);
+  for (auto &info : hwc_session_->map_info_builtin_) {
+    if (disp_id == info.client_id) {
+      *is_builtin = true;
+      return 0;
+    }
+  }
 
-  return bit_clk;
+  *is_builtin = false;
+  return 0;
 }
 
-Return<int32_t> HWCSession::setDSIClk(uint32_t disp_id, uint64_t bit_clk) {
-  SCOPE_LOCK(locker_[disp_id]);
-  if (!hwc_display_[disp_id]) {
+int HWCSession::DisplayConfigImpl::GetSupportedDSIBitClks(uint32_t disp_id,
+                                                          std::vector<uint64_t> *bit_clks) {
+  SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+  if (!hwc_session_->hwc_display_[disp_id]) {
+    return -EINVAL;
+  }
+
+  hwc_session_->hwc_display_[disp_id]->GetSupportedDSIClock(bit_clks);
+  return 0;
+}
+
+int HWCSession::DisplayConfigImpl::GetDSIClk(uint32_t disp_id, uint64_t *bit_clk) {
+  SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+  if (!hwc_session_->hwc_display_[disp_id]) {
+    return -EINVAL;
+  }
+
+  hwc_session_->hwc_display_[disp_id]->GetDynamicDSIClock(bit_clk);
+
+  return 0;
+}
+
+int HWCSession::DisplayConfigImpl::SetDSIClk(uint32_t disp_id, uint64_t bit_clk) {
+  SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+  if (!hwc_session_->hwc_display_[disp_id]) {
     return -1;
   }
 
-  return hwc_display_[disp_id]->SetDynamicDSIClock(bit_clk);
+  return hwc_session_->hwc_display_[disp_id]->SetDynamicDSIClock(bit_clk);
 }
 
-Return<int32_t> HWCSession::setCWBOutputBuffer(const ::android::sp<IDisplayCWBCallback> &callback,
-                                               uint32_t disp_id, const Rect &rect,
-                                               bool post_processed, const hidl_handle& buffer) {
+int HWCSession::DisplayConfigImpl::SetCWBOutputBuffer(uint32_t disp_id,
+                                                      const DisplayConfig::Rect rect,
+                                                      bool post_processed,
+                                                      const native_handle_t *buffer) {
   return -1;
 }
 
-Return<int32_t> HWCSession::setQsyncMode(uint32_t disp_id, IDisplayConfig::QsyncMode mode) {
-  SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_id]);
-  if (!hwc_display_[disp_id]) {
+int HWCSession::DisplayConfigImpl::SetQsyncMode(uint32_t disp_id, DisplayConfig::QsyncMode mode) {
+  SEQUENCE_WAIT_SCOPE_LOCK(hwc_session_->locker_[disp_id]);
+  if (!hwc_session_->hwc_display_[disp_id]) {
     return -1;
   }
 
   QSyncMode qsync_mode = kQSyncModeNone;
   switch (mode) {
-    case IDisplayConfig::QsyncMode::NONE:
+    case DisplayConfig::QsyncMode::kNone:
       qsync_mode = kQSyncModeNone;
       break;
-    case IDisplayConfig::QsyncMode::WAIT_FOR_FENCES_ONE_FRAME:
+    case DisplayConfig::QsyncMode::kWaitForFencesOneFrame:
       qsync_mode = kQsyncModeOneShot;
       break;
-    case IDisplayConfig::QsyncMode::WAIT_FOR_FENCES_EACH_FRAME:
+    case DisplayConfig::QsyncMode::kWaitForFencesEachFrame:
       qsync_mode = kQsyncModeOneShotContinuous;
       break;
-    case IDisplayConfig::QsyncMode::WAIT_FOR_COMMIT_EACH_FRAME:
+    case DisplayConfig::QsyncMode::kWaitForCommitEachFrame:
       qsync_mode = kQSyncModeContinuous;
       break;
   }
 
-  hwc_display_[disp_id]->SetQSyncMode(qsync_mode);
+  hwc_session_->hwc_display_[disp_id]->SetQSyncMode(qsync_mode);
   return 0;
 }