sdm: hwc_session: Make display members polymorphic

- Make display members polymorphic to prevent reading types and
unnecessary code.
- Add a perform() API to HWCDisplay to handle functionality specific to
derived classes.
- Remove the unused CoreEventHandler

Change-Id: I50f001691f8202eae88056db0ae121861bb28179
diff --git a/sdm/include/core/core_interface.h b/sdm/include/core/core_interface.h
index e1b38fa..26f6e2f 100644
--- a/sdm/include/core/core_interface.h
+++ b/sdm/include/core/core_interface.h
@@ -76,43 +76,6 @@
 */
 class DebugHandler;
 
-
-/*! @brief Event data associated with hotplug event.
-
-  @sa CoreEventHandler::Hotplug
-*/
-struct CoreEventHotplug {
-  bool connected;   //!< True when device is connected.
-
-  CoreEventHotplug() : connected(false) { }
-};
-
-/*! @brief Display core event handler implemented by the client.
-
-  @details This class declares prototype for display core event handler methods which must be
-  implemented by the client. Display core will use these methods to notify events to the client.
-  Client must post heavy-weight event handling to a separate thread and unblock display core thread
-  instantly.
-
-  @sa CoreInterface::CreateCore
-*/
-class CoreEventHandler {
- public:
-  /*! @brief Event handler for Hotplug event.
-
-    @details Event generated when a display device is connected or disconnected. Applicable to
-    detachable displays only.
-
-    @param[in] \link CoreEventHotplug \endlink
-
-    @return \link DisplayError \endlink
-  */
-  virtual DisplayError Hotplug(const CoreEventHotplug &hotplug) = 0;
-
- protected:
-  virtual ~CoreEventHandler() { }
-};
-
 /*! @brief Display core interface.
 
   @details This class defines display core interfaces. It contains methods which client shall use
@@ -131,7 +94,6 @@
     object of display core is created and handle to this object is returned via output parameter.
     This interface shall be called only once.
 
-    @param[in] event_handler \link CoreEventHandler \endlink
     @param[in] debug_handler \link DebugHandler \endlink
     @param[in] buffer_allocator \link BufferAllocator \endlink
     @param[in] buffer_sync_handler \link BufferSyncHandler \endlink
@@ -142,8 +104,7 @@
 
     @sa DestroyCore
   */
-  static DisplayError CreateCore(CoreEventHandler *event_handler, DebugHandler *debug_handler,
-                                 BufferAllocator *buffer_allocator,
+  static DisplayError CreateCore(DebugHandler *debug_handler, BufferAllocator *buffer_allocator,
                                  BufferSyncHandler *buffer_sync_handler, CoreInterface **interface,
                                  uint32_t version = SDM_VERSION_TAG);
 
diff --git a/sdm/libs/core/core_impl.cpp b/sdm/libs/core/core_impl.cpp
index d253b2e..5cb1c95 100644
--- a/sdm/libs/core/core_impl.cpp
+++ b/sdm/libs/core/core_impl.cpp
@@ -37,12 +37,11 @@
 
 namespace sdm {
 
-CoreImpl::CoreImpl(CoreEventHandler *event_handler, BufferAllocator *buffer_allocator,
+CoreImpl::CoreImpl(BufferAllocator *buffer_allocator,
                    BufferSyncHandler *buffer_sync_handler)
-  : event_handler_(event_handler), buffer_allocator_(buffer_allocator),
-    buffer_sync_handler_(buffer_sync_handler), hw_resource_(NULL), hw_info_intf_(NULL),
-    rotator_intf_(NULL), extension_lib_(NULL), extension_intf_(NULL),
-    create_extension_intf_(NULL), destroy_extension_intf_(NULL) {
+  : buffer_allocator_(buffer_allocator), buffer_sync_handler_(buffer_sync_handler),
+    hw_resource_(NULL), hw_info_intf_(NULL), rotator_intf_(NULL), extension_lib_(NULL),
+    extension_intf_(NULL), create_extension_intf_(NULL), destroy_extension_intf_(NULL) {
 }
 
 DisplayError CoreImpl::Init() {
diff --git a/sdm/libs/core/core_impl.h b/sdm/libs/core/core_impl.h
index bad241c..32fa078 100644
--- a/sdm/libs/core/core_impl.h
+++ b/sdm/libs/core/core_impl.h
@@ -44,8 +44,7 @@
   // This class implements display core interface revision 1.0.
   static const uint16_t kRevision = SET_REVISION(1, 0);
 
-  CoreImpl(CoreEventHandler *event_handler, BufferAllocator *buffer_allocator,
-           BufferSyncHandler *buffer_sync_handler);
+  CoreImpl(BufferAllocator *buffer_allocator, BufferSyncHandler *buffer_sync_handler);
   virtual ~CoreImpl() { }
 
   // This method returns the interface revision for the current display core object.
@@ -61,7 +60,6 @@
 
  protected:
   Locker locker_;
-  CoreEventHandler *event_handler_;
   BufferAllocator *buffer_allocator_;
   BufferSyncHandler *buffer_sync_handler_;
   HWResourceInfo *hw_resource_;
diff --git a/sdm/libs/core/core_interface.cpp b/sdm/libs/core/core_interface.cpp
index 34eceff..177e7bf 100644
--- a/sdm/libs/core/core_interface.cpp
+++ b/sdm/libs/core/core_interface.cpp
@@ -52,13 +52,13 @@
 } g_core;
 
 // TODO(user): Have a single structure handle carries all the interface pointers.
-DisplayError CoreInterface::CreateCore(CoreEventHandler *event_handler, DebugHandler *debug_handler,
+DisplayError CoreInterface::CreateCore(DebugHandler *debug_handler,
                                        BufferAllocator *buffer_allocator,
                                        BufferSyncHandler *buffer_sync_handler,
                                        CoreInterface **interface, uint32_t client_version) {
   SCOPE_LOCK(g_core.locker);
 
-  if (!event_handler || !debug_handler || !buffer_allocator || !buffer_sync_handler || !interface) {
+  if (!debug_handler || !buffer_allocator || !buffer_sync_handler || !interface) {
     return kErrorParameters;
   }
 
@@ -81,7 +81,7 @@
 
   // Create appropriate CoreImpl object based on client version.
   if (GET_REVISION(client_version) == CoreImpl::kRevision) {
-    core_impl = new CoreImpl(event_handler, buffer_allocator, buffer_sync_handler);
+    core_impl = new CoreImpl(buffer_allocator, buffer_sync_handler);
   } else {
     return kErrorNotSupported;
   }
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index ef24854..8dce4c4 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -45,7 +45,7 @@
 HWCDisplay::HWCDisplay(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DisplayType type,
                        int id)
   : core_intf_(core_intf), hwc_procs_(hwc_procs), type_(type), id_(id), display_intf_(NULL),
-    flush_(false), output_buffer_(NULL), dump_frame_count_(0), dump_frame_index_(0),
+    flush_(false), dump_frame_count_(0), dump_frame_index_(0),
     dump_input_layers_(false), swap_interval_zero_(false), framebuffer_config_(NULL),
     display_paused_(false), use_metadata_refresh_rate_(false), metadata_refresh_rate_(0) {
 }
@@ -213,10 +213,6 @@
   return index;
 }
 
-int HWCDisplay::SetActiveConfig(hwc_display_contents_1_t *content_list) {
-  return 0;
-}
-
 int HWCDisplay::SetActiveConfig(int index) {
   DisplayError error = kErrorNone;
 
diff --git a/sdm/libs/hwc/hwc_display.h b/sdm/libs/hwc/hwc_display.h
index 2df0928..6c602dc 100644
--- a/sdm/libs/hwc/hwc_display.h
+++ b/sdm/libs/hwc/hwc_display.h
@@ -42,7 +42,6 @@
   virtual int GetDisplayAttributes(uint32_t config, const uint32_t *attributes, int32_t *values);
   virtual int GetActiveConfig();
   virtual int SetActiveConfig(int index);
-  virtual int SetActiveConfig(hwc_display_contents_1_t *content_list);
   virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
   virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type);
   virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
@@ -51,6 +50,8 @@
   virtual void GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels);
   virtual void GetPanelResolution(uint32_t *x_pixels, uint32_t *y_pixels);
   virtual int SetDisplayStatus(uint32_t display_status);
+  virtual int Perform(uint32_t operation, ...);
+  virtual ~HWCDisplay() { }
 
  protected:
   enum DisplayStatus {
@@ -88,7 +89,6 @@
   };
 
   HWCDisplay(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DisplayType type, int id);
-  virtual ~HWCDisplay() { }
 
   // DisplayEventHandler methods
   virtual DisplayError VSync(const DisplayEventVSync &vsync);
@@ -131,7 +131,6 @@
   LayerStack layer_stack_;
   LayerStackCache layer_stack_cache_;
   bool flush_;
-  LayerBuffer *output_buffer_;
   uint32_t dump_frame_count_;
   uint32_t dump_frame_index_;
   bool dump_input_layers_;
@@ -143,6 +142,10 @@
   uint32_t metadata_refresh_rate_;
 };
 
+inline int HWCDisplay::Perform(uint32_t operation, ...) {
+  return 0;
+}
+
 }  // namespace sdm
 
 #endif  // __HWC_DISPLAY_H__
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index 53110ca..3769d69 100644
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -28,6 +28,7 @@
 */
 
 #include <utils/constants.h>
+#include <stdarg.h>
 
 #include "hwc_display_primary.h"
 #include "hwc_debugger.h"
@@ -76,16 +77,6 @@
   return 0;
 }
 
-DisplayError HWCDisplayPrimary::SetDisplayMode(uint32_t mode) {
-  DisplayError error = kErrorNone;
-
-  if (display_intf_) {
-    error = display_intf_->SetDisplayMode(mode);
-  }
-
-  return error;
-}
-
 int HWCDisplayPrimary::SetActiveConfig(uint32_t index) {
   DisplayError error = kErrorNone;
 
@@ -106,6 +97,39 @@
   return error;
 }
 
+int HWCDisplayPrimary::Perform(uint32_t operation, ...) {
+  va_list args;
+  va_start(args, operation);
+  int val = va_arg(args, uint32_t);
+  va_end(args);
+  switch (operation) {
+    case SET_METADATA_DYN_REFRESH_RATE:
+      SetMetaDataRefreshRateFlag(val);
+      break;
+    case SET_BINDER_DYN_REFRESH_RATE:
+      SetRefreshRate(val);
+      break;
+    case SET_DISPLAY_MODE:
+      SetDisplayMode(val);
+      break;
+    default:
+      DLOGW("Invalid operation %d", operation);
+      return -EINVAL;
+  }
+
+  return 0;
+}
+
+DisplayError HWCDisplayPrimary::SetDisplayMode(uint32_t mode) {
+  DisplayError error = kErrorNone;
+
+  if (display_intf_) {
+    error = display_intf_->SetDisplayMode(mode);
+  }
+
+  return error;
+}
+
 void HWCDisplayPrimary::SetMetaDataRefreshRateFlag(bool enable) {
   use_metadata_refresh_rate_ = enable;
 }
diff --git a/sdm/libs/hwc/hwc_display_primary.h b/sdm/libs/hwc/hwc_display_primary.h
index e862508..b65457b 100644
--- a/sdm/libs/hwc/hwc_display_primary.h
+++ b/sdm/libs/hwc/hwc_display_primary.h
@@ -30,14 +30,22 @@
 namespace sdm {
 
 class HWCDisplayPrimary : public HWCDisplay {
- public:
+public:
+  enum {
+    SET_METADATA_DYN_REFRESH_RATE,
+    SET_BINDER_DYN_REFRESH_RATE,
+    SET_DISPLAY_MODE,
+  };
+
   explicit HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
   virtual int Prepare(hwc_display_contents_1_t *content_list);
   virtual int Commit(hwc_display_contents_1_t *content_list);
-  virtual DisplayError SetDisplayMode(uint32_t mode);
   virtual int SetActiveConfig(uint32_t index);
   virtual int SetRefreshRate(uint32_t refresh_rate);
-  virtual void SetMetaDataRefreshRateFlag(bool enable);
+  virtual int Perform(uint32_t operation, ...);
+private:
+  void SetMetaDataRefreshRateFlag(bool enable);
+  virtual DisplayError SetDisplayMode(uint32_t mode);
 };
 
 }  // namespace sdm
diff --git a/sdm/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp
index d36a171..4d01d28 100644
--- a/sdm/libs/hwc/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -29,6 +29,7 @@
 
 #include <utils/constants.h>
 #include <sync/sync.h>
+#include <stdarg.h>
 
 #include "hwc_display_virtual.h"
 #include "hwc_debugger.h"
@@ -37,9 +38,27 @@
 
 namespace sdm {
 
+static int GetWidthFromMetaData(const private_handle_t* handle) {
+  MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+  if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+    return metadata->bufferDim.sliceWidth;
+  }
+
+  return handle->width;
+}
+
+static int GetHeightFromMetaData(const private_handle_t* handle) {
+  MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+  if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+    return metadata->bufferDim.sliceHeight;
+  }
+
+  return handle->height;
+}
+
 HWCDisplayVirtual::HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
   : HWCDisplay(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL),
-    dump_output_layer_(false) {
+    dump_output_layer_(false), output_buffer_(NULL) {
 }
 
 int HWCDisplayVirtual::Init() {
@@ -132,7 +151,15 @@
   return 0;
 }
 
-int HWCDisplayVirtual::SetActiveConfig(hwc_display_contents_1_t *content_list) {
+int HWCDisplayVirtual::Perform(uint32_t operation, ...) {
+  if(operation != SET_OUTPUT_SLICE_FROM_METADATA) {
+    return -EINVAL;
+  }
+
+  va_list args;
+  va_start(args, operation);
+  hwc_display_contents_1_t *content_list = va_arg(args, hwc_display_contents_1_t *);
+  va_end(args);
   const private_handle_t *output_handle =
         static_cast<const private_handle_t *>(content_list->outbuf);
   DisplayError error = kErrorNone;
@@ -144,8 +171,8 @@
       return -EINVAL;
     }
 
-    int active_width = GetWidth(output_handle);
-    int active_height = GetHeight(output_handle);
+    int active_width = GetWidthFromMetaData(output_handle);
+    int active_height = GetHeightFromMetaData(output_handle);
 
     if ((active_width != INT(output_buffer_->width)) ||
         (active_height!= INT(output_buffer_->height)) ||
@@ -186,8 +213,8 @@
       return -EINVAL;
     }
 
-    output_buffer_->width = GetWidth(output_handle);
-    output_buffer_->height = GetHeight(output_handle);
+    output_buffer_->width = GetWidthFromMetaData(output_handle);
+    output_buffer_->height = GetHeightFromMetaData(output_handle);
     output_buffer_->flags.secure = 0;
     output_buffer_->flags.video = 0;
 
@@ -256,23 +283,5 @@
   DLOGI("output_layer_dump_enable %d", dump_output_layer_);
 }
 
-int HWCDisplayVirtual::GetWidth(const private_handle_t* handle) {
-  MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
-  if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
-    return metadata->bufferDim.sliceWidth;
-  }
-
-  return handle->width;
-}
-
-int HWCDisplayVirtual::GetHeight(const private_handle_t* handle) {
-  MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
-  if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
-    return metadata->bufferDim.sliceHeight;
-  }
-
-  return handle->height;
-}
-
 }  // namespace sdm
 
diff --git a/sdm/libs/hwc/hwc_display_virtual.h b/sdm/libs/hwc/hwc_display_virtual.h
index 74285d7..40088fb 100644
--- a/sdm/libs/hwc/hwc_display_virtual.h
+++ b/sdm/libs/hwc/hwc_display_virtual.h
@@ -33,23 +33,32 @@
 
 class HWCDisplayVirtual : public HWCDisplay {
  public:
+  enum {
+    SET_OUTPUT_SLICE_FROM_METADATA,
+  };
+
   explicit HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
   virtual int Init();
   virtual int Deinit();
   virtual int Prepare(hwc_display_contents_1_t *content_list);
   virtual int Commit(hwc_display_contents_1_t *content_list);
-  virtual int SetActiveConfig(hwc_display_contents_1_t *content_list);
   virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type);
+  virtual int Perform(uint32_t operation, ...);
+
+  static bool ValidateContentList(hwc_display_contents_1_t *content_list);
 
  private:
   int SetOutputBuffer(hwc_display_contents_1_t *content_list);
   void DumpOutputBuffer(hwc_display_contents_1_t *content_list);
-  int GetWidth(const private_handle_t* handle);
-  int GetHeight(const private_handle_t* handle);
 
   bool dump_output_layer_;
+  LayerBuffer *output_buffer_;
 };
 
+inline bool HWCDisplayVirtual::ValidateContentList(hwc_display_contents_1_t *content_list) {
+  return (content_list && content_list->numHwLayers > 0 && content_list->outbuf);
+}
+
 }  // namespace sdm
 
 #endif  // __HWC_DISPLAY_VIRTUAL_H__
diff --git a/sdm/libs/hwc/hwc_session.cpp b/sdm/libs/hwc/hwc_session.cpp
index 81db3a8..8014ae5 100644
--- a/sdm/libs/hwc/hwc_session.cpp
+++ b/sdm/libs/hwc/hwc_session.cpp
@@ -45,6 +45,8 @@
 #include "hwc_buffer_sync_handler.h"
 #include "hwc_session.h"
 #include "hwc_debugger.h"
+#include "hwc_display_primary.h"
+#include "hwc_display_virtual.h"
 
 #define __CLASS__ "HWCSession"
 
@@ -73,8 +75,8 @@
 bool HWCSession::reset_panel_ = false;
 
 HWCSession::HWCSession(const hw_module_t *module) : core_intf_(NULL), hwc_procs_(NULL),
-            display_primary_(NULL), display_external_(NULL), display_virtual_(NULL),
             uevent_thread_exit_(false), uevent_thread_name_("HWC_UeventThread") {
+  memset(&hwc_display_, 0, sizeof(hwc_display_));
   hwc_composer_device_1_t::common.tag = HARDWARE_DEVICE_TAG;
   hwc_composer_device_1_t::common.version = HWC_DEVICE_API_VERSION_1_4;
   hwc_composer_device_1_t::common.module = const_cast<hw_module_t*>(module);
@@ -120,7 +122,7 @@
     return -ENOMEM;
   }
 
-  DisplayError error = CoreInterface::CreateCore(this, HWCDebugHandler::Get(), buffer_allocator_,
+  DisplayError error = CoreInterface::CreateCore(HWCDebugHandler::Get(), buffer_allocator_,
                                                  buffer_sync_handler_, &core_intf_);
   if (error != kErrorNone) {
     DLOGE("Display core initialization failed. Error = %d", error);
@@ -128,31 +130,34 @@
   }
 
   // Create and power on primary display
-  display_primary_ = new HWCDisplayPrimary(core_intf_, &hwc_procs_);
-  if (!display_primary_) {
+  hwc_display_[HWC_DISPLAY_PRIMARY] = new HWCDisplayPrimary(core_intf_, &hwc_procs_);
+  if (!hwc_display_[HWC_DISPLAY_PRIMARY]) {
     CoreInterface::DestroyCore();
     return -ENOMEM;
   }
 
-  status = display_primary_->Init();
+  status = hwc_display_[HWC_DISPLAY_PRIMARY]->Init();
   if (status) {
     CoreInterface::DestroyCore();
-    delete display_primary_;
+    delete hwc_display_[HWC_DISPLAY_PRIMARY];
+    hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
     return status;
   }
 
-  status = display_primary_->SetPowerMode(HWC_POWER_MODE_NORMAL);
+  status = hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(HWC_POWER_MODE_NORMAL);
   if (status) {
-    display_primary_->Deinit();
-    delete display_primary_;
+    hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
+    delete hwc_display_[HWC_DISPLAY_PRIMARY];
+    hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
     CoreInterface::DestroyCore();
     return status;
   }
 
   if (pthread_create(&uevent_thread_, NULL, &HWCUeventThread, this) < 0) {
     DLOGE("Failed to start = %s, error = %s", uevent_thread_name_);
-    display_primary_->Deinit();
-    delete display_primary_;
+    hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
+    delete hwc_display_[HWC_DISPLAY_PRIMARY];
+    hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
     CoreInterface::DestroyCore();
     return -errno;
   }
@@ -163,9 +168,10 @@
 }
 
 int HWCSession::Deinit() {
-  display_primary_->SetPowerMode(HWC_POWER_MODE_OFF);
-  display_primary_->Deinit();
-  delete display_primary_;
+  hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(HWC_POWER_MODE_OFF);
+  hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
+  delete hwc_display_[HWC_DISPLAY_PRIMARY];
+  hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
   uevent_thread_exit_ = true;
   pthread_join(uevent_thread_, NULL);
 
@@ -233,34 +239,21 @@
     hwc_session->ResetPanel();
   }
 
-  for (ssize_t i = (num_displays-1); i >= 0; i--) {
-    hwc_display_contents_1_t *content_list = displays[i];
-
-    switch (i) {
-    case HWC_DISPLAY_PRIMARY:
-      hwc_session->display_primary_->Prepare(content_list);
-      break;
-    case HWC_DISPLAY_EXTERNAL:
-      if (hwc_session->display_external_) {
-        hwc_session->display_external_->Prepare(content_list);
+  for (ssize_t dpy = (num_displays - 1); dpy >= 0; dpy--) {
+    hwc_display_contents_1_t *content_list = displays[dpy];
+    if(dpy == HWC_DISPLAY_VIRTUAL) {
+      if (hwc_session->hwc_display_[HWC_DISPLAY_EXTERNAL]) {
+        continue;
       }
-      break;
-    case HWC_DISPLAY_VIRTUAL:
-      if (hwc_session->display_external_) {
-        break;
-      }
-      if (hwc_session->ValidateContentList(content_list)) {
+      if (HWCDisplayVirtual::ValidateContentList(content_list)) {
         hwc_session->CreateVirtualDisplay(content_list);
       } else {
         hwc_session->DestroyVirtualDisplay();
       }
+    }
 
-      if (hwc_session->display_virtual_) {
-        hwc_session->display_virtual_->Prepare(content_list);
-      }
-      break;
-    default:
-      break;
+    if (hwc_session->hwc_display_[dpy]) {
+      hwc_session->hwc_display_[dpy]->Prepare(content_list);
     }
   }
 
@@ -280,20 +273,10 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
 
-  for (size_t i = 0; i < num_displays; i++) {
-    hwc_display_contents_1_t *content_list = displays[i];
-
-    switch (i) {
-    case HWC_DISPLAY_PRIMARY:
-      hwc_session->display_primary_->Commit(content_list);
-      break;
-    case HWC_DISPLAY_EXTERNAL:
-      if (hwc_session->display_external_) {
-        hwc_session->display_external_->Commit(content_list);
-      }
-      break;
-    case HWC_DISPLAY_VIRTUAL:
-      if (hwc_session->display_external_) {
+  for (size_t dpy = 0; dpy < num_displays; dpy++) {
+    hwc_display_contents_1_t *content_list = displays[dpy];
+    if(dpy == HWC_DISPLAY_VIRTUAL) {
+      if (hwc_session->hwc_display_[HWC_DISPLAY_EXTERNAL]) {
         if (content_list) {
           for (size_t i = 0; i < content_list->numHwLayers; i++) {
             if (content_list->hwLayers[i].acquireFenceFd >= 0) {
@@ -308,12 +291,10 @@
           content_list->retireFenceFd = -1;
         }
       }
-      if (hwc_session->display_virtual_) {
-        hwc_session->display_virtual_->Commit(content_list);
-      }
-      break;
-    default:
-      break;
+    }
+
+    if (hwc_session->hwc_display_[dpy]) {
+      hwc_session->hwc_display_[dpy]->Commit(content_list);
     }
   }
 
@@ -330,20 +311,8 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int status = -EINVAL;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->display_primary_->EventControl(event, enable);
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      status = hwc_session->display_external_->EventControl(event, enable);
-    }
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    break;
-  default:
-    status = -EINVAL;
+  if(hwc_session->hwc_display_[disp]) {
+    status = hwc_session->hwc_display_[disp]->EventControl(event, enable);
   }
 
   return status;
@@ -358,24 +327,13 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int status = -EINVAL;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->display_primary_->SetPowerMode(mode);
-  // Set the power mode for virtual display while setting power mode for primary, as surfaceflinger
-  // does not invoke SetPowerMode() for virtual display.
-  case HWC_DISPLAY_VIRTUAL:
-    if (hwc_session->display_virtual_) {
-      status = hwc_session->display_virtual_->SetPowerMode(mode);
-    }
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      status = hwc_session->display_external_->SetPowerMode(mode);
-    }
-    break;
-  default:
-    status = -EINVAL;
+  if(hwc_session->hwc_display_[disp]) {
+    status = hwc_session->hwc_display_[disp]->SetPowerMode(mode);
+  }
+  if(disp == HWC_DISPLAY_PRIMARY && hwc_session->hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+    // Set the power mode for virtual display while setting power mode for primary, as SF
+    // does not invoke SetPowerMode() for virtual display.
+    status = hwc_session->hwc_display_[HWC_DISPLAY_VIRTUAL]->SetPowerMode(mode);
   }
 
   return status;
@@ -420,23 +378,8 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int status = -EINVAL;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->display_primary_->GetDisplayConfigs(configs, num_configs);
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      status = hwc_session->display_external_->GetDisplayConfigs(configs, num_configs);
-    }
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    if (hwc_session->display_virtual_) {
-      status = hwc_session->display_virtual_->GetDisplayConfigs(configs, num_configs);
-    }
-    break;
-  default:
-    status = -EINVAL;
+  if(hwc_session->hwc_display_[disp]) {
+    status = hwc_session->hwc_display_[disp]->GetDisplayConfigs(configs, num_configs);
   }
 
   return status;
@@ -452,23 +395,8 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int status = -EINVAL;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->display_primary_->GetDisplayAttributes(config, attributes, values);
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      status = hwc_session->display_external_->GetDisplayAttributes(config, attributes, values);
-    }
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    if (hwc_session->display_virtual_) {
-      status = hwc_session->display_virtual_->GetDisplayAttributes(config, attributes, values);
-    }
-    break;
-  default:
-    status = -EINVAL;
+  if(hwc_session->hwc_display_[disp]) {
+    status = hwc_session->hwc_display_[disp]->GetDisplayAttributes(config, attributes, values);
   }
 
   return status;
@@ -483,23 +411,8 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int active_config = -1;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    active_config = hwc_session->display_primary_->GetActiveConfig();
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      active_config = hwc_session->display_external_->GetActiveConfig();
-    }
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    if (hwc_session->display_virtual_) {
-      active_config = hwc_session->display_virtual_->GetActiveConfig();
-    }
-    break;
-  default:
-    active_config = -1;
+  if(hwc_session->hwc_display_[disp]) {
+    active_config = hwc_session->hwc_display_[disp]->GetActiveConfig();
   }
 
   return active_config;
@@ -514,72 +427,57 @@
 
   HWCSession *hwc_session = static_cast<HWCSession *>(device);
   int status = -EINVAL;
-
-  switch (disp) {
-  case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->display_primary_->SetActiveConfig(index);
-    break;
-  case HWC_DISPLAY_EXTERNAL:
-    if (hwc_session->display_external_) {
-      // TODO(user): Uncomment it. HDMI does not support resolution change currently.
-      status = 0;  // hwc_session->display_external_->SetActiveConfig(index);
-    }
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    break;
-  default:
-    status = -EINVAL;
+  if(hwc_session->hwc_display_[disp]) {
+    status = hwc_session->hwc_display_[disp]->SetActiveConfig(index);
   }
 
   return status;
 }
 
-bool HWCSession::ValidateContentList(hwc_display_contents_1_t *content_list) {
-  return (content_list && content_list->numHwLayers > 0 && content_list->outbuf);
-}
-
 int HWCSession::CreateVirtualDisplay(hwc_display_contents_1_t *content_list) {
   int status = 0;
 
-  if (!display_virtual_) {
+  if (!hwc_display_[HWC_DISPLAY_VIRTUAL]) {
     // Create virtual display device
-    display_virtual_ = new HWCDisplayVirtual(core_intf_, &hwc_procs_);
-    if (!display_virtual_) {
+    hwc_display_[HWC_DISPLAY_VIRTUAL] = new HWCDisplayVirtual(core_intf_, &hwc_procs_);
+    if (!hwc_display_[HWC_DISPLAY_VIRTUAL]) {
       // This is not catastrophic. Leave a warning message for now.
       DLOGW("Virtual Display creation failed");
       return -ENOMEM;
     }
 
-    status = display_virtual_->Init();
+    status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Init();
     if (status) {
       goto CleanupOnError;
     }
 
-    status = display_virtual_->SetPowerMode(HWC_POWER_MODE_NORMAL);
+    status = hwc_display_[HWC_DISPLAY_VIRTUAL]->SetPowerMode(HWC_POWER_MODE_NORMAL);
     if (status) {
       goto CleanupOnError;
     }
   }
 
-  if (display_virtual_) {
+  if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
     SetFrameBufferResolution(HWC_DISPLAY_VIRTUAL, content_list);
-    status = display_virtual_->SetActiveConfig(content_list);
+    status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Perform(
+        HWCDisplayVirtual::SET_OUTPUT_SLICE_FROM_METADATA, content_list);
   }
 
   return status;
 
 CleanupOnError:
-  return DestroyVirtualDisplay();
+  DestroyVirtualDisplay();
+  return status;
 }
 
 int HWCSession::DestroyVirtualDisplay() {
   int status = 0;
 
-  if (display_virtual_) {
-    status = display_virtual_->Deinit();
+  if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+    status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Deinit();
     if (!status) {
-      delete display_virtual_;
-      display_virtual_ = NULL;
+      delete hwc_display_[HWC_DISPLAY_VIRTUAL];
+      hwc_display_[HWC_DISPLAY_VIRTUAL] = NULL;
       // Signal the HotPlug thread to continue with the external display connection
       locker_.Signal();
     }
@@ -588,10 +486,6 @@
   return status;
 }
 
-DisplayError HWCSession::Hotplug(const CoreEventHotplug &hotplug) {
-  return kErrorNone;
-}
-
 android::status_t HWCSession::notifyCallback(uint32_t command, const android::Parcel *input_parcel,
                                              android::Parcel */*output_parcel*/) {
   SEQUENCE_WAIT_SCOPE_LOCK(locker_);
@@ -608,9 +502,9 @@
     break;
 
   case qService::IQService::SET_IDLE_TIMEOUT:
-    if (display_primary_) {
+    if (hwc_display_[HWC_DISPLAY_PRIMARY]) {
       uint32_t timeout = UINT32(input_parcel->readInt32());
-      display_primary_->SetIdleTimeoutMs(timeout);
+      hwc_display_[HWC_DISPLAY_PRIMARY]->SetIdleTimeoutMs(timeout);
     }
     break;
 
@@ -647,62 +541,43 @@
 android::status_t HWCSession::SetSecondaryDisplayStatus(const android::Parcel *input_parcel) {
   uint32_t display_id = UINT32(input_parcel->readInt32());
   uint32_t display_status = UINT32(input_parcel->readInt32());
-  HWCDisplay *display = NULL;
 
   DLOGI("Display %d Status %d", display_id, display_status);
-  switch (display_id) {
-  case HWC_DISPLAY_EXTERNAL:
-    display = display_external_;
-    break;
-  case HWC_DISPLAY_VIRTUAL:
-    display = display_virtual_;
-    break;
-  default:
+  if(display_id < HWC_DISPLAY_EXTERNAL || display_id > HWC_DISPLAY_VIRTUAL) {
     DLOGW("Not supported for display %d", display_id);
     return -EINVAL;
   }
 
-  return display->SetDisplayStatus(display_status);
+  return hwc_display_[display_id]->SetDisplayStatus(display_status);
 }
 
 android::status_t HWCSession::ConfigureRefreshRate(const android::Parcel *input_parcel) {
   uint32_t operation = UINT32(input_parcel->readInt32());
-
   switch (operation) {
-  case qdutils::DISABLE_METADATA_DYN_REFRESH_RATE:
-    display_primary_->SetMetaDataRefreshRateFlag(false);
-    break;
-
-  case qdutils::ENABLE_METADATA_DYN_REFRESH_RATE:
-    display_primary_->SetMetaDataRefreshRateFlag(true);
-    break;
-
-  case qdutils::SET_BINDER_DYN_REFRESH_RATE:
-  {
-    uint32_t refresh_rate = UINT32(input_parcel->readInt32());
-
-    display_primary_->SetRefreshRate(refresh_rate);
-    break;
-  }
-
-  default:
-    DLOGW("Invalid operation %d", operation);
-    return -EINVAL;
+    case qdutils::DISABLE_METADATA_DYN_REFRESH_RATE:
+      return hwc_display_[HWC_DISPLAY_PRIMARY]->Perform(
+          HWCDisplayPrimary::SET_METADATA_DYN_REFRESH_RATE, false);
+    case qdutils::ENABLE_METADATA_DYN_REFRESH_RATE:
+      return hwc_display_[HWC_DISPLAY_PRIMARY]->Perform(
+          HWCDisplayPrimary::SET_METADATA_DYN_REFRESH_RATE, true);
+    case qdutils::SET_BINDER_DYN_REFRESH_RATE:
+      {
+        uint32_t refresh_rate = UINT32(input_parcel->readInt32());
+        return hwc_display_[HWC_DISPLAY_PRIMARY]->Perform(
+            HWCDisplayPrimary::SET_BINDER_DYN_REFRESH_RATE,
+            refresh_rate);
+      }
+    default:
+      DLOGW("Invalid operation %d", operation);
+      return -EINVAL;
   }
 
   return 0;
 }
 
 android::status_t HWCSession::SetDisplayMode(const android::Parcel *input_parcel) {
-  DisplayError error = kErrorNone;
   uint32_t mode = UINT32(input_parcel->readInt32());
-
-  error = display_primary_->SetDisplayMode(mode);
-  if (error != kErrorNone) {
-    return -EINVAL;
-  }
-
-  return 0;
+  return hwc_display_[HWC_DISPLAY_PRIMARY]->Perform(HWCDisplayPrimary::SET_DISPLAY_MODE, mode);
 }
 
 android::status_t HWCSession::SetMaxMixerStages(const android::Parcel *input_parcel) {
@@ -711,8 +586,8 @@
   uint32_t max_mixer_stages = UINT32(input_parcel->readInt32());
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_PRIMARY)) {
-    if (display_primary_) {
-      error = display_primary_->SetMaxMixerStages(max_mixer_stages);
+    if (hwc_display_[HWC_DISPLAY_PRIMARY]) {
+      error = hwc_display_[HWC_DISPLAY_PRIMARY]->SetMaxMixerStages(max_mixer_stages);
       if (error != kErrorNone) {
         return -EINVAL;
       }
@@ -720,8 +595,8 @@
   }
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_EXTERNAL)) {
-    if (display_external_) {
-      error = display_external_->SetMaxMixerStages(max_mixer_stages);
+    if (hwc_display_[HWC_DISPLAY_EXTERNAL]) {
+      error = hwc_display_[HWC_DISPLAY_EXTERNAL]->SetMaxMixerStages(max_mixer_stages);
       if (error != kErrorNone) {
         return -EINVAL;
       }
@@ -729,8 +604,8 @@
   }
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_VIRTUAL)) {
-    if (display_virtual_) {
-      error = display_virtual_->SetMaxMixerStages(max_mixer_stages);
+    if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+      error = hwc_display_[HWC_DISPLAY_VIRTUAL]->SetMaxMixerStages(max_mixer_stages);
       if (error != kErrorNone) {
         return -EINVAL;
       }
@@ -746,20 +621,20 @@
   uint32_t bit_mask_layer_type = UINT32(input_parcel->readInt32());
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_PRIMARY)) {
-    if (display_primary_) {
-      display_primary_->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
+    if (hwc_display_[HWC_DISPLAY_PRIMARY]) {
+      hwc_display_[HWC_DISPLAY_PRIMARY]->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
     }
   }
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_EXTERNAL)) {
-    if (display_external_) {
-      display_external_->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
+    if (hwc_display_[HWC_DISPLAY_EXTERNAL]) {
+      hwc_display_[HWC_DISPLAY_EXTERNAL]->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
     }
   }
 
   if (IS_BIT_SET(bit_mask_display_type, HWC_DISPLAY_VIRTUAL)) {
-    if (display_virtual_) {
-      display_virtual_->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
+    if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+      hwc_display_[HWC_DISPLAY_VIRTUAL]->SetFrameDumpConfig(frame_dump_count, bit_mask_layer_type);
     }
   }
 }
@@ -865,19 +740,19 @@
   int status = -EINVAL;
 
   DLOGI("Powering off primary");
-  status = display_primary_->SetPowerMode(HWC_POWER_MODE_OFF);
+  status = hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(HWC_POWER_MODE_OFF);
   if (status) {
     DLOGE("power-off on primary failed with error = %d", status);
   }
 
   DLOGI("Restoring power mode on primary");
-  uint32_t mode = display_primary_->GetLastPowerMode();
-  status = display_primary_->SetPowerMode(mode);
+  uint32_t mode = hwc_display_[HWC_DISPLAY_PRIMARY]->GetLastPowerMode();
+  status = hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(mode);
   if (status) {
     DLOGE("Setting power mode = %d on primary failed with error = %d", mode, status);
   }
 
-  status = display_primary_->EventControl(HWC_EVENT_VSYNC, 1);
+  status = hwc_display_[HWC_DISPLAY_PRIMARY]->EventControl(HWC_EVENT_VSYNC, 1);
   if (status) {
     DLOGE("enabling vsync failed for primary with error = %d", status);
   }
@@ -893,7 +768,7 @@
 
   if (connected) {
     SEQUENCE_WAIT_SCOPE_LOCK(locker_);
-    if (display_virtual_) {
+    if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
       // Wait for the virtual display to tear down
       int status = locker_.WaitFinite(kExternalConnectionTimeoutMs);
       if (status != 0) {
@@ -901,32 +776,32 @@
         return -1;
       }
     }
-    if (display_external_) {
+    if (hwc_display_[HWC_DISPLAY_EXTERNAL]) {
      DLOGE("HDMI already connected");
      return -1;
     }
     // Create hdmi display
-    display_external_ = new HWCDisplayExternal(core_intf_, &hwc_procs_);
-    if (!display_external_) {
+    hwc_display_[HWC_DISPLAY_EXTERNAL] = new HWCDisplayExternal(core_intf_, &hwc_procs_);
+    if (!hwc_display_[HWC_DISPLAY_EXTERNAL]) {
       return -1;
     }
-    int status = display_external_->Init();
+    int status = hwc_display_[HWC_DISPLAY_EXTERNAL]->Init();
     if (status) {
-      delete display_external_;
-      display_external_ = NULL;
+      delete hwc_display_[HWC_DISPLAY_EXTERNAL];
+      hwc_display_[HWC_DISPLAY_EXTERNAL] = NULL;
       return -1;
     }
     SetFrameBufferResolution(HWC_DISPLAY_EXTERNAL, NULL);
   } else {
     SEQUENCE_WAIT_SCOPE_LOCK(locker_);
-    if (!display_external_) {
+    if (!hwc_display_[HWC_DISPLAY_EXTERNAL]) {
      DLOGE("HDMI not connected");
      return -1;
     }
-    display_external_->SetPowerMode(HWC_POWER_MODE_OFF);
-    display_external_->Deinit();
-    delete display_external_;
-    display_external_ = NULL;
+    hwc_display_[HWC_DISPLAY_EXTERNAL]->SetPowerMode(HWC_POWER_MODE_OFF);
+    hwc_display_[HWC_DISPLAY_EXTERNAL]->Deinit();
+    delete hwc_display_[HWC_DISPLAY_EXTERNAL];
+    hwc_display_[HWC_DISPLAY_EXTERNAL] = NULL;
   }
 
   // notify client and trigger a screen refresh
@@ -944,13 +819,13 @@
   switch (disp) {
   case HWC_DISPLAY_PRIMARY:
   {
-    display_primary_->GetPanelResolution(&primary_width, &primary_height);
+    hwc_display_[HWC_DISPLAY_PRIMARY]->GetPanelResolution(&primary_width, &primary_height);
     if (property_get("debug.hwc.fbsize", property, NULL) > 0) {
       char *yptr = strcasestr(property, "x");
       primary_width = atoi(property);
       primary_height = atoi(yptr + 1);
     }
-    display_primary_->SetFrameBufferResolution(primary_width, primary_height);
+    hwc_display_[HWC_DISPLAY_PRIMARY]->SetFrameBufferResolution(primary_width, primary_height);
     break;
   }
 
@@ -958,11 +833,11 @@
   {
     uint32_t external_width = 0;
     uint32_t external_height = 0;
-    display_external_->GetPanelResolution(&external_width, &external_height);
+    hwc_display_[HWC_DISPLAY_EXTERNAL]->GetPanelResolution(&external_width, &external_height);
 
     if (property_get("sys.hwc.mdp_downscale_enabled", property, "false") &&
         !strcmp(property, "true")) {
-      display_primary_->GetFrameBufferResolution(&primary_width, &primary_height);
+      hwc_display_[HWC_DISPLAY_PRIMARY]->GetFrameBufferResolution(&primary_width, &primary_height);
       uint32_t primary_area = primary_width * primary_height;
       uint32_t external_area = external_width * external_height;
 
@@ -974,20 +849,20 @@
                                &external_width, &external_height);
       }
     }
-    display_external_->SetFrameBufferResolution(external_width, external_height);
+    hwc_display_[HWC_DISPLAY_EXTERNAL]->SetFrameBufferResolution(external_width, external_height);
     break;
   }
 
   case HWC_DISPLAY_VIRTUAL:
   {
-    if (ValidateContentList(content_list)) {
+    if (HWCDisplayVirtual::ValidateContentList(content_list)) {
       const private_handle_t *output_handle =
               static_cast<const private_handle_t *>(content_list->outbuf);
       int virtual_width = 0;
       int virtual_height = 0;
       getBufferSizeAndDimensions(output_handle->width, output_handle->height, output_handle->format,
                                  virtual_width, virtual_height);
-      display_virtual_->SetFrameBufferResolution(virtual_width, virtual_height);
+      hwc_display_[HWC_DISPLAY_VIRTUAL]->SetFrameBufferResolution(virtual_width, virtual_height);
     }
     break;
   }
diff --git a/sdm/libs/hwc/hwc_session.h b/sdm/libs/hwc/hwc_session.h
index 15b762c..6d4a07a 100644
--- a/sdm/libs/hwc/hwc_session.h
+++ b/sdm/libs/hwc/hwc_session.h
@@ -36,7 +36,7 @@
 
 namespace sdm {
 
-class HWCSession : hwc_composer_device_1_t, CoreEventHandler, public qClient::BnQClient {
+class HWCSession : hwc_composer_device_1_t, public qClient::BnQClient {
  public:
   struct HWCModuleMethods : public hw_module_methods_t {
     HWCModuleMethods() {
@@ -76,13 +76,9 @@
   int GetEventValue(const char *uevent_data, int length, const char *event_info);
   int HotPlugHandler(bool connected);
   void ResetPanel();
-  bool ValidateContentList(hwc_display_contents_1_t *content_list);
   int CreateVirtualDisplay(hwc_display_contents_1_t *content_list);
   int DestroyVirtualDisplay();
 
-  // CoreEventHandler methods
-  virtual DisplayError Hotplug(const CoreEventHotplug &hotplug);
-
   // QClient methods
   virtual android::status_t notifyCallback(uint32_t command, const android::Parcel *input_parcel,
                                            android::Parcel *output_parcel);
@@ -99,9 +95,7 @@
   static Locker locker_;
   CoreInterface *core_intf_;
   hwc_procs_t const *hwc_procs_;
-  HWCDisplayPrimary *display_primary_;
-  HWCDisplayExternal *display_external_;
-  HWCDisplayVirtual *display_virtual_;
+  HWCDisplay *hwc_display_[HWC_NUM_DISPLAY_TYPES];
   pthread_t uevent_thread_;
   bool uevent_thread_exit_;
   static bool reset_panel_;