Merge "h/q/d: Add binder-api support to change refresh-rate."
diff --git a/displayengine/include/core/core_interface.h b/displayengine/include/core/core_interface.h
index 3328d64..45d9c8c 100644
--- a/displayengine/include/core/core_interface.h
+++ b/displayengine/include/core/core_interface.h
@@ -34,7 +34,7 @@
 
 #include <stdint.h>
 
-#include "device_interface.h"
+#include "display_interface.h"
 #include "display_types.h"
 
 /*! @brief Display core interface version.
@@ -150,16 +150,16 @@
     interface associated with this object is returned via output parameter which can be used to
     interact further with the display device.
 
-    @param[in] type \link DeviceType \endlink
-    @param[in] event_handler \link DeviceEventHandler \endlink
+    @param[in] type \link DisplayType \endlink
+    @param[in] event_handler \link DisplayEventHandler \endlink
     @param[out] interface \link DisplayInterface \endlink
 
     @return \link DisplayError \endlink
 
-    @sa DestroyDevice
+    @sa DestroyDisplay
   */
-  virtual DisplayError CreateDevice(DeviceType type, DeviceEventHandler *event_handler,
-                                    DeviceInterface **interface) = 0;
+  virtual DisplayError CreateDisplay(DisplayType type, DisplayEventHandler *event_handler,
+                                    DisplayInterface **interface) = 0;
 
   /*! @brief Method to destroy a display device.
 
@@ -169,9 +169,9 @@
 
     @return \link DisplayError \endlink
 
-    @sa CreateDevice
+    @sa CreateDisplay
   */
-  virtual DisplayError DestroyDevice(DeviceInterface *interface) = 0;
+  virtual DisplayError DestroyDisplay(DisplayInterface *interface) = 0;
 
  protected:
   virtual ~CoreInterface() { }
diff --git a/displayengine/include/core/device_interface.h b/displayengine/include/core/display_interface.h
similarity index 84%
rename from displayengine/include/core/device_interface.h
rename to displayengine/include/core/display_interface.h
index 01c5446..bb03921 100644
--- a/displayengine/include/core/device_interface.h
+++ b/displayengine/include/core/display_interface.h
@@ -22,7 +22,7 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*! @file device_interface.h
+/*! @file display_interface.h
   @brief Interface file for display device which represents a physical panel or an output buffer
   where contents can be rendered.
 
@@ -30,8 +30,8 @@
   the target device. Each display device represents a unique display target which may be either a
   physical panel or an output buffer..
 */
-#ifndef __DEVICE_INTERFACE_H__
-#define __DEVICE_INTERFACE_H__
+#ifndef __DISPLAY_INTERFACE_H__
+#define __DISPLAY_INTERFACE_H__
 
 #include <stdint.h>
 
@@ -42,10 +42,10 @@
 
 /*! @brief This enum represents display device types where contents can be rendered.
 
-  @sa CoreInterface::CreateDevice
-  @sa CoreInterface::IsDeviceSupported
+  @sa CoreInterface::CreateDisplay
+  @sa CoreInterface::IsDisplaySupported
 */
-enum DeviceType {
+enum DisplayType {
   kPrimary,         //!< Main physical display which is attached to the handheld device.
   kHDMI,            //!< HDMI physical display which is generally detachable.
   kVirtual,         //!< Contents would be rendered into the output buffer provided by the client
@@ -54,10 +54,10 @@
 
 /*! @brief This enum represents states of a display device.
 
-  @sa DisplayInterface::GetDeviceState
-  @sa DisplayInterface::SetDeviceState
+  @sa DisplayInterface::GetDisplayState
+  @sa DisplayInterface::SetDisplayState
 */
-enum DeviceState {
+enum DisplayState {
   kStateOff,        //!< Display is OFF. Contents are not rendered in this state. Client will not
                     //!< receive VSync events in this state. This is default state as well.
 
@@ -75,11 +75,11 @@
   @sa DisplayInterface::GetConfig
   @sa DisplayInterface::SetConfig
 */
-struct DeviceConfigFixedInfo {
+struct DisplayConfigFixedInfo {
   bool underscan;   //!< If display support CE underscan.
   bool secure;      //!< If this display is capable of handling secure content.
 
-  DeviceConfigFixedInfo() : underscan(false), secure(false) { }
+  DisplayConfigFixedInfo() : underscan(false), secure(false) { }
 };
 
 /*! @brief This structure defines configuration for variable properties of a display device.
@@ -87,7 +87,7 @@
   @sa DisplayInterface::GetConfig
   @sa DisplayInterface::SetConfig
 */
-struct DeviceConfigVariableInfo {
+struct DisplayConfigVariableInfo {
   uint32_t x_pixels;          //!< Total number of pixels in X-direction on the display panel.
   uint32_t y_pixels;          //!< Total number of pixels in Y-direction on the display panel.
   float x_dpi;                //!< Dots per inch in X-direction.
@@ -95,18 +95,18 @@
   float fps;                  //!< Frame rate per second.
   uint32_t vsync_period_ns;   //!< VSync period in nanoseconds.
 
-  DeviceConfigVariableInfo() : x_pixels(0), y_pixels(0), x_dpi(0.0f), y_dpi(0.0f),
+  DisplayConfigVariableInfo() : x_pixels(0), y_pixels(0), x_dpi(0.0f), y_dpi(0.0f),
                                fps(0.0f), vsync_period_ns(0) { }
 };
 
 /*! @brief Event data associated with VSync event.
 
-  @sa DeviceEventHandler::VSync
+  @sa DisplayEventHandler::VSync
 */
-struct DeviceEventVSync {
+struct DisplayEventVSync {
   int64_t timestamp;    //!< System monotonic clock timestamp in nanoseconds.
 
-  DeviceEventVSync() : timestamp(0) { }
+  DisplayEventVSync() : timestamp(0) { }
 };
 
 /*! @brief Display device event handler implemented by the client.
@@ -116,23 +116,23 @@
   Client must post heavy-weight event handling to a separate thread and unblock display engine
   thread instantly.
 
-  @sa CoreInterface::CreateDevice
+  @sa CoreInterface::CreateDisplay
 */
-class DeviceEventHandler {
+class DisplayEventHandler {
  public:
   /*! @brief Event handler for VSync event.
 
     @details This event is dispatched on every vertical synchronization. The event is disabled by
     default.
 
-    @param[in] vsync \link DeviceEventVSync \endlink
+    @param[in] vsync \link DisplayEventVSync \endlink
 
     @return \link DisplayError \endlink
 
-    @sa DeviceInterface::GetDeviceState
-    @sa DeviceInterface::SetDeviceState
+    @sa DisplayInterface::GetDisplayState
+    @sa DisplayInterface::SetDisplayState
   */
-  virtual DisplayError VSync(const DeviceEventVSync &vsync) = 0;
+  virtual DisplayError VSync(const DisplayEventVSync &vsync) = 0;
 
   /*! @brief Event handler for Refresh event.
 
@@ -142,13 +142,13 @@
 
     @return \link DisplayError \endlink
 
-    @sa DeviceInterface::Prepare
-    @sa DeviceInterface::Commit
+    @sa DisplayInterface::Prepare
+    @sa DisplayInterface::Commit
   */
   virtual DisplayError Refresh() = 0;
 
  protected:
-  virtual ~DeviceEventHandler() { }
+  virtual ~DisplayEventHandler() { }
 };
 
 /*! @brief Display device interface.
@@ -157,10 +157,10 @@
   to configure or submit layers for composition on the display device. This interface is created
   during display device creation and remains valid until destroyed.
 
-  @sa CoreInterface::CreateDevice
-  @sa CoreInterface::DestroyDevice
+  @sa CoreInterface::CreateDisplay
+  @sa CoreInterface::DestroyDisplay
 */
-class DeviceInterface {
+class DisplayInterface {
  public:
   /*! @brief Method to determine hardware capability to compose layers associated with given frame.
 
@@ -212,9 +212,9 @@
 
     @return \link DisplayError \endlink
 
-    @sa SetDeviceState
+    @sa SetDisplayState
   */
-  virtual DisplayError GetDeviceState(DeviceState *state) = 0;
+  virtual DisplayError GetDisplayState(DisplayState *state) = 0;
 
   /*! @brief Method to get number of configurations(variable properties) supported on the display
     device.
@@ -227,20 +227,20 @@
 
   /*! @brief Method to get configuration for fixed properties of the display device.
 
-    @param[out] fixed_info \link DeviceConfigFixedInfo \endlink
+    @param[out] fixed_info \link DisplayConfigFixedInfo \endlink
 
     @return \link DisplayError \endlink
   */
-  virtual DisplayError GetConfig(DeviceConfigFixedInfo *fixed_info) = 0;
+  virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info) = 0;
 
   /*! @brief Method to get configuration for variable properties of the display device.
 
     @param[in] mode index of the mode
-    @param[out] variable_info \link DeviceConfigVariableInfo \endlink
+    @param[out] variable_info \link DisplayConfigVariableInfo \endlink
 
     @return \link DisplayError \endlink
   */
-  virtual DisplayError GetConfig(DeviceConfigVariableInfo *variable_info, uint32_t mode) = 0;
+  virtual DisplayError GetConfig(DisplayConfigVariableInfo *variable_info, uint32_t mode) = 0;
 
   /*! @brief Method to get VSync event state. Default event state is disabled.
 
@@ -256,9 +256,9 @@
 
     @return \link DisplayError \endlink
 
-    @sa SetDeviceState
+    @sa SetDisplayState
   */
-  virtual DisplayError SetDeviceState(DeviceState state) = 0;
+  virtual DisplayError SetDisplayState(DisplayState state) = 0;
 
   /*! @brief Method to set configuration for variable properties of the display device.
 
@@ -277,10 +277,10 @@
   virtual DisplayError SetVSyncState(bool enable) = 0;
 
  protected:
-  virtual ~DeviceInterface() { }
+  virtual ~DisplayInterface() { }
 };
 
 }  // namespace sde
 
-#endif  // __DEVICE_INTERFACE_H__
+#endif  // __DISPLAY_INTERFACE_H__
 
diff --git a/displayengine/include/core/dump_interface.h b/displayengine/include/core/dump_interface.h
index 3a7d93d..acdc71f 100644
--- a/displayengine/include/core/dump_interface.h
+++ b/displayengine/include/core/dump_interface.h
@@ -53,7 +53,7 @@
 
     @return \link DisplayError \endlink
 
-    @warning Client shall ensure that this interface is not used while a device is being either
+    @warning Client shall ensure that this interface is not used while a display is being either
     created or destroyed through display core.
   */
   static DisplayError GetDump(char *buffer, uint32_t length);
diff --git a/displayengine/include/private/strategy_interface.h b/displayengine/include/private/strategy_interface.h
index 23dea8e..8a3b789 100644
--- a/displayengine/include/private/strategy_interface.h
+++ b/displayengine/include/private/strategy_interface.h
@@ -69,7 +69,7 @@
 */
 const int kMaxSDELayers = 16;
 
-/*! @brief This structure defines constraints and device properties that shall be considered for
+/*! @brief This structure defines constraints and display properties that shall be considered for
     deciding a composition strategy.
 
     @sa GetNextStrategy
diff --git a/displayengine/libs/core/Android.mk b/displayengine/libs/core/Android.mk
index 496c899..337cb73 100644
--- a/displayengine/libs/core/Android.mk
+++ b/displayengine/libs/core/Android.mk
@@ -2,7 +2,7 @@
 include hardware/qcom/display/displayengine/libs/common.mk
 include $(CLEAR_VARS)
 
-LOCAL_MODULE                  := libsdecore
+LOCAL_MODULE                  := libsde
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"SDE\"
@@ -10,10 +10,10 @@
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := core_interface.cpp \
                                  core_impl.cpp \
-                                 device_base.cpp \
-                                 device_primary.cpp \
-                                 device_hdmi.cpp \
-                                 device_virtual.cpp \
+                                 display_base.cpp \
+                                 display_primary.cpp \
+                                 display_hdmi.cpp \
+                                 display_virtual.cpp \
                                  comp_manager.cpp \
                                  strategy_default.cpp \
                                  res_manager.cpp \
diff --git a/displayengine/libs/core/comp_manager.cpp b/displayengine/libs/core/comp_manager.cpp
index 42a28c2..0d51bb0 100644
--- a/displayengine/libs/core/comp_manager.cpp
+++ b/displayengine/libs/core/comp_manager.cpp
@@ -87,48 +87,50 @@
   return kErrorNone;
 }
 
-DisplayError CompManager::RegisterDevice(DeviceType type, const HWDeviceAttributes &attributes,
-                                         Handle *device) {
+DisplayError CompManager::RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+                                          Handle *display_ctx) {
   SCOPE_LOCK(locker_);
 
   DisplayError error = kErrorNone;
 
-  CompManagerDevice *comp_mgr_device = new CompManagerDevice();
-  if (!comp_mgr_device) {
+  DisplayCompositionContext *display_comp_ctx = new DisplayCompositionContext();
+  if (!display_comp_ctx) {
     return kErrorMemory;
   }
 
-  error = res_mgr_.RegisterDevice(type, attributes, &comp_mgr_device->res_mgr_device);
+  error = res_mgr_.RegisterDisplay(type, attributes, &display_comp_ctx->display_resource_ctx);
   if (error != kErrorNone) {
-    delete comp_mgr_device;
+    delete display_comp_ctx;
     return error;
   }
   SET_BIT(registered_displays_, type);
-  comp_mgr_device->device_type = type;
-  *device = comp_mgr_device;
-  // New device has been added, so move the composition mode to safe mode until unless resources
-  // for the added display is configured properly.
+  display_comp_ctx->display_type = type;
+  *display_ctx = display_comp_ctx;
+  // New display device has been added, so move the composition mode to safe mode until unless
+  // resources for the added display is configured properly.
   safe_mode_ = true;
 
   return kErrorNone;
 }
 
-DisplayError CompManager::UnregisterDevice(Handle device) {
+DisplayError CompManager::UnregisterDisplay(Handle comp_handle) {
   SCOPE_LOCK(locker_);
 
-  CompManagerDevice *comp_mgr_device = reinterpret_cast<CompManagerDevice *>(device);
+  DisplayCompositionContext *display_comp_ctx =
+                             reinterpret_cast<DisplayCompositionContext *>(comp_handle);
 
-  res_mgr_.UnregisterDevice(comp_mgr_device->res_mgr_device);
-  CLEAR_BIT(registered_displays_, comp_mgr_device->device_type);
-  CLEAR_BIT(configured_displays_, comp_mgr_device->device_type);
-  delete comp_mgr_device;
+  res_mgr_.UnregisterDisplay(display_comp_ctx->display_resource_ctx);
+  CLEAR_BIT(registered_displays_, display_comp_ctx->display_type);
+  CLEAR_BIT(configured_displays_, display_comp_ctx->display_type);
+  delete display_comp_ctx;
 
   return kErrorNone;
 }
 
-void CompManager::PrepareStrategyConstraints(Handle device, HWLayers *hw_layers) {
-  CompManagerDevice *comp_mgr_device = reinterpret_cast<CompManagerDevice *>(device);
-  StrategyConstraints *constraints = &comp_mgr_device->constraints;
+void CompManager::PrepareStrategyConstraints(Handle comp_handle, HWLayers *hw_layers) {
+  DisplayCompositionContext *display_comp_ctx =
+                             reinterpret_cast<DisplayCompositionContext *>(comp_handle);
+  StrategyConstraints *constraints = &display_comp_ctx->constraints;
 
   constraints->safe_mode = safe_mode_;
   // If validation for the best available composition strategy with driver has failed, just
@@ -139,20 +141,21 @@
   }
 }
 
-DisplayError CompManager::Prepare(Handle device, HWLayers *hw_layers) {
+DisplayError CompManager::Prepare(Handle display_ctx, HWLayers *hw_layers) {
   SCOPE_LOCK(locker_);
 
-  CompManagerDevice *comp_mgr_device = reinterpret_cast<CompManagerDevice *>(device);
-  Handle &res_mgr_device = comp_mgr_device->res_mgr_device;
+  DisplayCompositionContext *display_comp_ctx =
+                             reinterpret_cast<DisplayCompositionContext *>(display_ctx);
+  Handle &display_resource_ctx = display_comp_ctx->display_resource_ctx;
 
   DisplayError error = kErrorNone;
 
-  PrepareStrategyConstraints(device, hw_layers);
+  PrepareStrategyConstraints(display_ctx, hw_layers);
 
   // Select a composition strategy, and try to allocate resources for it.
-  res_mgr_.Start(res_mgr_device);
+  res_mgr_.Start(display_resource_ctx);
   while (true) {
-    error = strategy_intf_->GetNextStrategy(&comp_mgr_device->constraints, &hw_layers->info);
+    error = strategy_intf_->GetNextStrategy(&display_comp_ctx->constraints, &hw_layers->info);
     if (UNLIKELY(error != kErrorNone)) {
       // Composition strategies exhausted. Resource Manager could not allocate resources even for
       // GPU composition. This will never happen.
@@ -160,7 +163,7 @@
       return error;
     }
 
-    error = res_mgr_.Acquire(res_mgr_device, hw_layers);
+    error = res_mgr_.Acquire(display_resource_ctx, hw_layers);
     if (error != kErrorNone) {
       // Not enough resources, try next strategy.
       continue;
@@ -169,33 +172,35 @@
       break;
     }
   }
-  res_mgr_.Stop(res_mgr_device);
+  res_mgr_.Stop(display_resource_ctx);
 
   return kErrorNone;
 }
 
-void CompManager::PostPrepare(Handle device, HWLayers *hw_layers) {
+void CompManager::PostPrepare(Handle display_ctx, HWLayers *hw_layers) {
   SCOPE_LOCK(locker_);
 }
 
-void CompManager::PostCommit(Handle device, HWLayers *hw_layers) {
+void CompManager::PostCommit(Handle display_ctx, HWLayers *hw_layers) {
   SCOPE_LOCK(locker_);
 
-  CompManagerDevice *comp_mgr_device = reinterpret_cast<CompManagerDevice *>(device);
-  SET_BIT(configured_displays_, comp_mgr_device->device_type);
+  DisplayCompositionContext *display_comp_ctx =
+                             reinterpret_cast<DisplayCompositionContext *>(display_ctx);
+  SET_BIT(configured_displays_, display_comp_ctx->display_type);
   if (configured_displays_ == registered_displays_) {
       safe_mode_ = false;
   }
 
-  res_mgr_.PostCommit(comp_mgr_device->res_mgr_device, hw_layers);
+  res_mgr_.PostCommit(display_comp_ctx->display_resource_ctx, hw_layers);
 }
 
-void CompManager::Purge(Handle device) {
+void CompManager::Purge(Handle display_ctx) {
   SCOPE_LOCK(locker_);
 
-  CompManagerDevice *comp_mgr_device = reinterpret_cast<CompManagerDevice *>(device);
+  DisplayCompositionContext *display_comp_ctx =
+                             reinterpret_cast<DisplayCompositionContext *>(display_ctx);
 
-  res_mgr_.Purge(comp_mgr_device->res_mgr_device);
+  res_mgr_.Purge(display_comp_ctx->display_resource_ctx);
 }
 
 void CompManager::AppendDump(char *buffer, uint32_t length) {
diff --git a/displayengine/libs/core/comp_manager.h b/displayengine/libs/core/comp_manager.h
index f9c9202..492500a 100644
--- a/displayengine/libs/core/comp_manager.h
+++ b/displayengine/libs/core/comp_manager.h
@@ -25,7 +25,7 @@
 #ifndef __COMP_MANAGER_H__
 #define __COMP_MANAGER_H__
 
-#include <core/device_interface.h>
+#include <core/display_interface.h>
 
 #include "hw_interface.h"
 #include "strategy_default.h"
@@ -39,23 +39,23 @@
   CompManager();
   DisplayError Init(const HWResourceInfo &hw_res_info_);
   DisplayError Deinit();
-  DisplayError RegisterDevice(DeviceType type, const HWDeviceAttributes &attributes,
-                              Handle *device);
-  DisplayError UnregisterDevice(Handle device);
-  DisplayError Prepare(Handle device, HWLayers *hw_layers);
-  void PostPrepare(Handle device, HWLayers *hw_layers);
-  void PostCommit(Handle device, HWLayers *hw_layers);
-  void Purge(Handle device);
+  DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+                               Handle *res_mgr_hnd);
+  DisplayError UnregisterDisplay(Handle res_mgr_hnd);
+  DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers);
+  void PostPrepare(Handle display_ctx, HWLayers *hw_layers);
+  void PostCommit(Handle display_ctx, HWLayers *hw_layers);
+  void Purge(Handle display_ctx);
 
   // DumpImpl method
   virtual void AppendDump(char *buffer, uint32_t length);
 
  private:
-  void PrepareStrategyConstraints(Handle device, HWLayers *hw_layers);
-  struct CompManagerDevice {
+  void PrepareStrategyConstraints(Handle display_ctx, HWLayers *hw_layers);
+  struct DisplayCompositionContext {
     StrategyConstraints constraints;
-    Handle res_mgr_device;
-    DeviceType device_type;
+    Handle display_resource_ctx;
+    DisplayType display_type;
   };
 
   Locker locker_;
diff --git a/displayengine/libs/core/core_impl.cpp b/displayengine/libs/core/core_impl.cpp
index 9a1fa12..a3dfde1 100644
--- a/displayengine/libs/core/core_impl.cpp
+++ b/displayengine/libs/core/core_impl.cpp
@@ -31,9 +31,9 @@
 #include <utils/constants.h>
 
 #include "core_impl.h"
-#include "device_primary.h"
-#include "device_hdmi.h"
-#include "device_virtual.h"
+#include "display_primary.h"
+#include "display_hdmi.h"
+#include "display_virtual.h"
 
 namespace sde {
 
@@ -84,57 +84,57 @@
   return kErrorNone;
 }
 
-DisplayError CoreImpl::CreateDevice(DeviceType type, DeviceEventHandler *event_handler,
-                                    DeviceInterface **intf) {
+DisplayError CoreImpl::CreateDisplay(DisplayType type, DisplayEventHandler *event_handler,
+                                    DisplayInterface **intf) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!event_handler || !intf)) {
     return kErrorParameters;
   }
 
-  DeviceBase *device_base = NULL;
+  DisplayBase *display_base = NULL;
   switch (type) {
   case kPrimary:
-    device_base = new DevicePrimary(event_handler, hw_intf_, &comp_mgr_);
+    display_base = new DisplayPrimary(event_handler, hw_intf_, &comp_mgr_);
     break;
 
-  case kHWHDMI:
-    device_base = new DeviceHDMI(event_handler, hw_intf_, &comp_mgr_);
+  case kHDMI:
+    display_base = new DisplayHDMI(event_handler, hw_intf_, &comp_mgr_);
     break;
 
   case kVirtual:
-    device_base = new DeviceVirtual(event_handler, hw_intf_, &comp_mgr_);
+    display_base = new DisplayVirtual(event_handler, hw_intf_, &comp_mgr_);
     break;
 
   default:
-    DLOGE("Spurious device type %d", type);
+    DLOGE("Spurious display type %d", type);
     return kErrorParameters;
   }
 
-  if (UNLIKELY(!device_base)) {
+  if (UNLIKELY(!display_base)) {
     return kErrorMemory;
   }
 
-  DisplayError error = device_base->Init();
+  DisplayError error = display_base->Init();
   if (UNLIKELY(error != kErrorNone)) {
-    delete device_base;
+    delete display_base;
     return error;
   }
 
-  *intf = device_base;
+  *intf = display_base;
   return kErrorNone;
 }
 
-DisplayError CoreImpl::DestroyDevice(DeviceInterface *intf) {
+DisplayError CoreImpl::DestroyDisplay(DisplayInterface *intf) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!intf)) {
     return kErrorParameters;
   }
 
-  DeviceBase *device_base = static_cast<DeviceBase *>(intf);
-  device_base->Deinit();
-  delete device_base;
+  DisplayBase *display_base = static_cast<DisplayBase *>(intf);
+  display_base->Deinit();
+  delete display_base;
 
   return kErrorNone;
 }
diff --git a/displayengine/libs/core/core_impl.h b/displayengine/libs/core/core_impl.h
index 16a01f2..ad86c60 100644
--- a/displayengine/libs/core/core_impl.h
+++ b/displayengine/libs/core/core_impl.h
@@ -52,9 +52,9 @@
   virtual DisplayError Deinit();
 
   // Methods from core interface
-  virtual DisplayError CreateDevice(DeviceType type, DeviceEventHandler *event_handler,
-                                    DeviceInterface **intf);
-  virtual DisplayError DestroyDevice(DeviceInterface *intf);
+  virtual DisplayError CreateDisplay(DisplayType type, DisplayEventHandler *event_handler,
+                                     DisplayInterface **intf);
+  virtual DisplayError DestroyDisplay(DisplayInterface *intf);
 
  protected:
   Locker locker_;
diff --git a/displayengine/libs/core/device_primary.cpp b/displayengine/libs/core/device_primary.cpp
deleted file mode 100644
index c5d45b8..0000000
--- a/displayengine/libs/core/device_primary.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DevicePrimary"
-#include <utils/debug.h>
-
-#include <utils/constants.h>
-
-#include "device_primary.h"
-
-namespace sde {
-
-DevicePrimary::DevicePrimary(DeviceEventHandler *event_handler, HWInterface *hw_intf,
-                             CompManager *comp_manager)
-  : DeviceBase(kPrimary, event_handler, kHWPrimary, hw_intf, comp_manager) {
-}
-
-}  // namespace sde
-
diff --git a/displayengine/libs/core/device_primary.h b/displayengine/libs/core/device_primary.h
deleted file mode 100644
index 771a6f7..0000000
--- a/displayengine/libs/core/device_primary.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __DEVICE_PRIMARY_H__
-#define __DEVICE_PRIMARY_H__
-
-#include "device_base.h"
-
-namespace sde {
-
-class DevicePrimary : public DeviceBase {
- public:
-  DevicePrimary(DeviceEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
-};
-
-}  // namespace sde
-
-#endif  // __DEVICE_PRIMARY_H__
-
diff --git a/displayengine/libs/core/device_virtual.h b/displayengine/libs/core/device_virtual.h
deleted file mode 100644
index e279f12..0000000
--- a/displayengine/libs/core/device_virtual.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __DEVICE_VIRTUAL_H__
-#define __DEVICE_VIRTUAL_H__
-
-#include "device_base.h"
-
-namespace sde {
-
-class DeviceVirtual : public DeviceBase {
- public:
-  DeviceVirtual(DeviceEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
-};
-
-}  // namespace sde
-
-#endif  // __DEVICE_VIRTUAL_H__
-
diff --git a/displayengine/libs/core/device_base.cpp b/displayengine/libs/core/display_base.cpp
similarity index 75%
rename from displayengine/libs/core/device_base.cpp
rename to displayengine/libs/core/display_base.cpp
index 6dc3ebd..5b2d0af 100644
--- a/displayengine/libs/core/device_base.cpp
+++ b/displayengine/libs/core/display_base.cpp
@@ -24,24 +24,24 @@
 
 // SDE_LOG_TAG definition must precede debug.h include.
 #define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DeviceBase"
+#define SDE_MODULE_NAME "DisplayBase"
 #include <utils/debug.h>
 
 #include <utils/constants.h>
 
-#include "device_base.h"
+#include "display_base.h"
 
 namespace sde {
 
-DeviceBase::DeviceBase(DeviceType device_type, DeviceEventHandler *event_handler,
-             HWBlockType hw_block_type, HWInterface *hw_intf, CompManager *comp_manager)
-  : device_type_(device_type), event_handler_(event_handler), hw_block_type_(hw_block_type),
+DisplayBase::DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
+                       HWBlockType hw_block_type, HWInterface *hw_intf, CompManager *comp_manager)
+  : display_type_(display_type), event_handler_(event_handler), hw_block_type_(hw_block_type),
     hw_intf_(hw_intf), comp_manager_(comp_manager), state_(kStateOff), hw_device_(0),
-    comp_mgr_device_(0), device_attributes_(NULL), num_modes_(0), active_mode_index_(0),
+    display_comp_ctx_(0), display_attributes_(NULL), num_modes_(0), active_mode_index_(0),
     pending_commit_(false), vsync_enable_(false) {
 }
 
-DisplayError DeviceBase::Init() {
+DisplayError DisplayBase::Init() {
   SCOPE_LOCK(locker_);
 
   DisplayError error = kErrorNone;
@@ -51,19 +51,19 @@
     return error;
   }
 
-  error = hw_intf_->GetNumDeviceAttributes(hw_device_, &num_modes_);
+  error = hw_intf_->GetNumDisplayAttributes(hw_device_, &num_modes_);
   if (UNLIKELY(error != kErrorNone)) {
     goto CleanupOnError;
   }
 
-  device_attributes_ = new HWDeviceAttributes[num_modes_];
-  if (!device_attributes_) {
+  display_attributes_ = new HWDisplayAttributes[num_modes_];
+  if (!display_attributes_) {
     error = kErrorMemory;
     goto CleanupOnError;
   }
 
   for (uint32_t i = 0; i < num_modes_; i++) {
-    error = hw_intf_->GetDeviceAttributes(hw_device_, &device_attributes_[i], i);
+    error = hw_intf_->GetDisplayAttributes(hw_device_, &display_attributes_[i], i);
     if (UNLIKELY(error != kErrorNone)) {
       goto CleanupOnError;
     }
@@ -71,8 +71,8 @@
 
   active_mode_index_ = 0;
 
-  error = comp_manager_->RegisterDevice(device_type_, device_attributes_[active_mode_index_],
-                                        &comp_mgr_device_);
+  error = comp_manager_->RegisterDisplay(display_type_, display_attributes_[active_mode_index_],
+                                        &display_comp_ctx_);
   if (UNLIKELY(error != kErrorNone)) {
     goto CleanupOnError;
   }
@@ -80,10 +80,10 @@
   return kErrorNone;
 
 CleanupOnError:
-  comp_manager_->UnregisterDevice(comp_mgr_device_);
+  comp_manager_->UnregisterDisplay(display_comp_ctx_);
 
-  if (device_attributes_) {
-    delete[] device_attributes_;
+  if (display_attributes_) {
+    delete[] display_attributes_;
   }
 
   hw_intf_->Close(hw_device_);
@@ -91,17 +91,17 @@
   return error;
 }
 
-DisplayError DeviceBase::Deinit() {
+DisplayError DisplayBase::Deinit() {
   SCOPE_LOCK(locker_);
 
-  comp_manager_->UnregisterDevice(comp_mgr_device_);
-  delete[] device_attributes_;
+  comp_manager_->UnregisterDisplay(display_comp_ctx_);
+  delete[] display_attributes_;
   hw_intf_->Close(hw_device_);
 
   return kErrorNone;
 }
 
-DisplayError DeviceBase::Prepare(LayerStack *layer_stack) {
+DisplayError DisplayBase::Prepare(LayerStack *layer_stack) {
   SCOPE_LOCK(locker_);
 
   DisplayError error = kErrorNone;
@@ -118,7 +118,7 @@
     hw_layers_.info.stack = layer_stack;
 
     while (true) {
-      error = comp_manager_->Prepare(comp_mgr_device_, &hw_layers_);
+      error = comp_manager_->Prepare(display_comp_ctx_, &hw_layers_);
       if (UNLIKELY(error != kErrorNone)) {
         break;
       }
@@ -126,7 +126,7 @@
       error = hw_intf_->Validate(hw_device_, &hw_layers_);
       if (LIKELY(error == kErrorNone)) {
         // Strategy is successful now, wait for Commit().
-        comp_manager_->PostPrepare(comp_mgr_device_, &hw_layers_);
+        comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_);
         pending_commit_ = true;
         break;
       }
@@ -136,7 +136,7 @@
   return error;
 }
 
-DisplayError DeviceBase::Commit(LayerStack *layer_stack) {
+DisplayError DisplayBase::Commit(LayerStack *layer_stack) {
   SCOPE_LOCK(locker_);
 
   DisplayError error = kErrorNone;
@@ -153,7 +153,7 @@
   if (LIKELY(state_ == kStateOn)) {
     error = hw_intf_->Commit(hw_device_, &hw_layers_);
     if (LIKELY(error == kErrorNone)) {
-      comp_manager_->PostCommit(comp_mgr_device_, &hw_layers_);
+      comp_manager_->PostCommit(display_comp_ctx_, &hw_layers_);
     } else {
       DLOGE("Unexpected error. Commit failed on driver.");
     }
@@ -164,7 +164,7 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::GetDeviceState(DeviceState *state) {
+DisplayError DisplayBase::GetDisplayState(DisplayState *state) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!state)) {
@@ -175,7 +175,7 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::GetNumVariableInfoConfigs(uint32_t *count) {
+DisplayError DisplayBase::GetNumVariableInfoConfigs(uint32_t *count) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!count)) {
@@ -187,7 +187,7 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::GetConfig(DeviceConfigFixedInfo *fixed_info) {
+DisplayError DisplayBase::GetConfig(DisplayConfigFixedInfo *fixed_info) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!fixed_info)) {
@@ -197,19 +197,19 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::GetConfig(DeviceConfigVariableInfo *variable_info, uint32_t mode) {
+DisplayError DisplayBase::GetConfig(DisplayConfigVariableInfo *variable_info, uint32_t mode) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!variable_info || mode >= num_modes_)) {
     return kErrorParameters;
   }
 
-  *variable_info = device_attributes_[mode];
+  *variable_info = display_attributes_[mode];
 
   return kErrorNone;
 }
 
-DisplayError DeviceBase::GetVSyncState(bool *enabled) {
+DisplayError DisplayBase::GetVSyncState(bool *enabled) {
   SCOPE_LOCK(locker_);
 
   if (UNLIKELY(!enabled)) {
@@ -219,7 +219,7 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::SetDeviceState(DeviceState state) {
+DisplayError DisplayBase::SetDisplayState(DisplayState state) {
   SCOPE_LOCK(locker_);
 
   DisplayError error = kErrorNone;
@@ -233,7 +233,7 @@
 
   switch (state) {
   case kStateOff:
-    comp_manager_->Purge(comp_mgr_device_);
+    comp_manager_->Purge(display_comp_ctx_);
     error = hw_intf_->PowerOff(hw_device_);
     break;
 
@@ -261,13 +261,13 @@
   return error;
 }
 
-DisplayError DeviceBase::SetConfig(uint32_t mode) {
+DisplayError DisplayBase::SetConfig(uint32_t mode) {
   SCOPE_LOCK(locker_);
 
   return kErrorNone;
 }
 
-DisplayError DeviceBase::SetVSyncState(bool enable) {
+DisplayError DisplayBase::SetVSyncState(bool enable) {
   SCOPE_LOCK(locker_);
   DisplayError error = kErrorNone;
   if (vsync_enable_ != enable) {
@@ -280,9 +280,9 @@
   return error;
 }
 
-DisplayError DeviceBase::VSync(int64_t timestamp) {
+DisplayError DisplayBase::VSync(int64_t timestamp) {
   if (vsync_enable_) {
-    DeviceEventVSync vsync;
+    DisplayEventVSync vsync;
     vsync.timestamp = timestamp;
     event_handler_->VSync(vsync);
   }
@@ -290,20 +290,20 @@
   return kErrorNone;
 }
 
-DisplayError DeviceBase::Blank(bool blank) {
+DisplayError DisplayBase::Blank(bool blank) {
   return kErrorNone;
 }
 
-void DeviceBase::AppendDump(char *buffer, uint32_t length) {
+void DisplayBase::AppendDump(char *buffer, uint32_t length) {
   SCOPE_LOCK(locker_);
 
   AppendString(buffer, length, "\n-----------------------");
-  AppendString(buffer, length, "\ndevice type: %u", device_type_);
+  AppendString(buffer, length, "\ndevice type: %u", display_type_);
   AppendString(buffer, length, "\nstate: %u, vsync on: %u", state_, INT(vsync_enable_));
   AppendString(buffer, length, "\nnum configs: %u, active config index: %u",
                                 num_modes_, active_mode_index_);
 
-  DeviceConfigVariableInfo &info = device_attributes_[active_mode_index_];
+  DisplayConfigVariableInfo &info = display_attributes_[active_mode_index_];
   AppendString(buffer, length, "\nres:%ux%u, dpi:%.2fx%.2f, fps:%.2f, vsync period: %u",
       info.x_pixels, info.y_pixels, info.x_dpi, info.y_dpi, info.fps, info.vsync_period_ns);
 
@@ -344,7 +344,8 @@
   }
 }
 
-void DeviceBase::AppendRect(char *buffer, uint32_t length, const char *rect_name, LayerRect *rect) {
+void DisplayBase::AppendRect(char *buffer, uint32_t length, const char *rect_name,
+                             LayerRect *rect) {
   AppendString(buffer, length, "%s %.1f, %.1f, %.1f, %.1f",
                                 rect_name, rect->left, rect->top, rect->right, rect->bottom);
 }
diff --git a/displayengine/libs/core/device_base.h b/displayengine/libs/core/display_base.h
similarity index 78%
rename from displayengine/libs/core/device_base.h
rename to displayengine/libs/core/display_base.h
index a2ef93b..5eaac37 100644
--- a/displayengine/libs/core/device_base.h
+++ b/displayengine/libs/core/display_base.h
@@ -22,10 +22,10 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __DEVICE_BASE_H__
-#define __DEVICE_BASE_H__
+#ifndef __DISPLAY_BASE_H__
+#define __DISPLAY_BASE_H__
 
-#include <core/device_interface.h>
+#include <core/display_interface.h>
 #include <private/strategy_interface.h>
 #include <utils/locker.h>
 
@@ -34,21 +34,21 @@
 
 namespace sde {
 
-class DeviceBase : public DeviceInterface, HWEventHandler, DumpImpl {
+class DisplayBase : public DisplayInterface, HWEventHandler, DumpImpl {
  public:
-  DeviceBase(DeviceType device_type, DeviceEventHandler *event_handler,
+  DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
              HWBlockType hw_block_type, HWInterface *hw_intf, CompManager *comp_manager);
-  virtual ~DeviceBase() { }
+  virtual ~DisplayBase() { }
   virtual DisplayError Init();
   virtual DisplayError Deinit();
   virtual DisplayError Prepare(LayerStack *layer_stack);
   virtual DisplayError Commit(LayerStack *layer_stack);
-  virtual DisplayError GetDeviceState(DeviceState *state);
+  virtual DisplayError GetDisplayState(DisplayState *state);
   virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count);
-  virtual DisplayError GetConfig(DeviceConfigFixedInfo *fixed_info);
-  virtual DisplayError GetConfig(DeviceConfigVariableInfo *variable_info, uint32_t mode);
+  virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info);
+  virtual DisplayError GetConfig(DisplayConfigVariableInfo *variable_info, uint32_t mode);
   virtual DisplayError GetVSyncState(bool *enabled);
-  virtual DisplayError SetDeviceState(DeviceState state);
+  virtual DisplayError SetDisplayState(DisplayState state);
   virtual DisplayError SetConfig(uint32_t mode);
   virtual DisplayError SetVSyncState(bool enable);
 
@@ -62,15 +62,15 @@
 
  protected:
   Locker locker_;
-  DeviceType device_type_;
-  DeviceEventHandler *event_handler_;
+  DisplayType display_type_;
+  DisplayEventHandler *event_handler_;
   HWBlockType hw_block_type_;
   HWInterface *hw_intf_;
   CompManager *comp_manager_;
-  DeviceState state_;
+  DisplayState state_;
   Handle hw_device_;
-  Handle comp_mgr_device_;
-  HWDeviceAttributes *device_attributes_;
+  Handle display_comp_ctx_;
+  HWDisplayAttributes *display_attributes_;
   uint32_t num_modes_;
   uint32_t active_mode_index_;
   HWLayers hw_layers_;
@@ -80,5 +80,5 @@
 
 }  // namespace sde
 
-#endif  // __DEVICE_BASE_H__
+#endif  // __DISPLAY_BASE_H__
 
diff --git a/displayengine/libs/core/device_hdmi.cpp b/displayengine/libs/core/display_hdmi.cpp
similarity index 86%
rename from displayengine/libs/core/device_hdmi.cpp
rename to displayengine/libs/core/display_hdmi.cpp
index a7c8c4f..b44bc87 100644
--- a/displayengine/libs/core/device_hdmi.cpp
+++ b/displayengine/libs/core/display_hdmi.cpp
@@ -24,18 +24,18 @@
 
 // SDE_LOG_TAG definition must precede debug.h include.
 #define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DeviceHDMI"
+#define SDE_MODULE_NAME "DisplayHDMI"
 #include <utils/debug.h>
 
 #include <utils/constants.h>
 
-#include "device_hdmi.h"
+#include "display_hdmi.h"
 
 namespace sde {
 
-DeviceHDMI::DeviceHDMI(DeviceEventHandler *event_handler, HWInterface *hw_intf,
-                       CompManager *comp_manager)
-  : DeviceBase(kHDMI, event_handler, kHWHDMI, hw_intf, comp_manager) {
+DisplayHDMI::DisplayHDMI(DisplayEventHandler *event_handler, HWInterface *hw_intf,
+                         CompManager *comp_manager)
+  : DisplayBase(kHDMI, event_handler, kHWHDMI, hw_intf, comp_manager) {
 }
 
 }  // namespace sde
diff --git a/displayengine/libs/core/device_hdmi.h b/displayengine/libs/core/display_hdmi.h
similarity index 86%
rename from displayengine/libs/core/device_hdmi.h
rename to displayengine/libs/core/display_hdmi.h
index 7d8cbc6..85f53fc 100644
--- a/displayengine/libs/core/device_hdmi.h
+++ b/displayengine/libs/core/display_hdmi.h
@@ -22,19 +22,19 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __DEVICE_HDMI_H__
-#define __DEVICE_HDMI_H__
+#ifndef __DISPLAY_HDMI_H__
+#define __DISPLAY_HDMI_H__
 
-#include "device_base.h"
+#include "display_base.h"
 
 namespace sde {
 
-class DeviceHDMI : public DeviceBase {
+class DisplayHDMI : public DisplayBase {
  public:
-  DeviceHDMI(DeviceEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
+  DisplayHDMI(DisplayEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
 };
 
 }  // namespace sde
 
-#endif  // __DEVICE_HDMI_H__
+#endif  // __DISPLAY_HDMI_H__
 
diff --git a/displayengine/libs/core/device_virtual.cpp b/displayengine/libs/core/display_primary.cpp
similarity index 85%
rename from displayengine/libs/core/device_virtual.cpp
rename to displayengine/libs/core/display_primary.cpp
index 4e18f93..96ff08a 100644
--- a/displayengine/libs/core/device_virtual.cpp
+++ b/displayengine/libs/core/display_primary.cpp
@@ -24,18 +24,18 @@
 
 // SDE_LOG_TAG definition must precede debug.h include.
 #define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DeviceVirtual"
+#define SDE_MODULE_NAME "DisplayPrimary"
 #include <utils/debug.h>
 
 #include <utils/constants.h>
 
-#include "device_virtual.h"
+#include "display_primary.h"
 
 namespace sde {
 
-DeviceVirtual::DeviceVirtual(DeviceEventHandler *event_handler, HWInterface *hw_intf,
-                             CompManager *comp_manager)
-  : DeviceBase(kVirtual, event_handler, kHWBlockMax, hw_intf, comp_manager) {
+DisplayPrimary::DisplayPrimary(DisplayEventHandler *event_handler, HWInterface *hw_intf,
+                               CompManager *comp_manager)
+  : DisplayBase(kPrimary, event_handler, kHWPrimary, hw_intf, comp_manager) {
 }
 
 }  // namespace sde
diff --git a/displayengine/libs/core/device_hdmi.h b/displayengine/libs/core/display_primary.h
similarity index 84%
copy from displayengine/libs/core/device_hdmi.h
copy to displayengine/libs/core/display_primary.h
index 7d8cbc6..183e964 100644
--- a/displayengine/libs/core/device_hdmi.h
+++ b/displayengine/libs/core/display_primary.h
@@ -22,19 +22,20 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __DEVICE_HDMI_H__
-#define __DEVICE_HDMI_H__
+#ifndef __DISPLAY_PRIMARY_H__
+#define __DISPLAY_PRIMARY_H__
 
-#include "device_base.h"
+#include "display_base.h"
 
 namespace sde {
 
-class DeviceHDMI : public DeviceBase {
+class DisplayPrimary : public DisplayBase {
  public:
-  DeviceHDMI(DeviceEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
+  DisplayPrimary(DisplayEventHandler *event_handler, HWInterface *hw_intf,
+                 CompManager *comp_manager);
 };
 
 }  // namespace sde
 
-#endif  // __DEVICE_HDMI_H__
+#endif  // __DISPLAY_PRIMARY_H__
 
diff --git a/displayengine/libs/core/device_virtual.cpp b/displayengine/libs/core/display_virtual.cpp
similarity index 85%
copy from displayengine/libs/core/device_virtual.cpp
copy to displayengine/libs/core/display_virtual.cpp
index 4e18f93..dc18146 100644
--- a/displayengine/libs/core/device_virtual.cpp
+++ b/displayengine/libs/core/display_virtual.cpp
@@ -24,18 +24,18 @@
 
 // SDE_LOG_TAG definition must precede debug.h include.
 #define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DeviceVirtual"
+#define SDE_MODULE_NAME "DisplayVirtual"
 #include <utils/debug.h>
 
 #include <utils/constants.h>
 
-#include "device_virtual.h"
+#include "display_virtual.h"
 
 namespace sde {
 
-DeviceVirtual::DeviceVirtual(DeviceEventHandler *event_handler, HWInterface *hw_intf,
-                             CompManager *comp_manager)
-  : DeviceBase(kVirtual, event_handler, kHWBlockMax, hw_intf, comp_manager) {
+DisplayVirtual::DisplayVirtual(DisplayEventHandler *event_handler, HWInterface *hw_intf,
+                               CompManager *comp_manager)
+  : DisplayBase(kVirtual, event_handler, kHWBlockMax, hw_intf, comp_manager) {
 }
 
 }  // namespace sde
diff --git a/displayengine/libs/core/device_hdmi.h b/displayengine/libs/core/display_virtual.h
similarity index 84%
copy from displayengine/libs/core/device_hdmi.h
copy to displayengine/libs/core/display_virtual.h
index 7d8cbc6..a8e29e7 100644
--- a/displayengine/libs/core/device_hdmi.h
+++ b/displayengine/libs/core/display_virtual.h
@@ -22,19 +22,20 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __DEVICE_HDMI_H__
-#define __DEVICE_HDMI_H__
+#ifndef __DISPLAY_VIRTUAL_H__
+#define __DISPLAY_VIRTUAL_H__
 
-#include "device_base.h"
+#include "display_base.h"
 
 namespace sde {
 
-class DeviceHDMI : public DeviceBase {
+class DisplayVirtual : public DisplayBase {
  public:
-  DeviceHDMI(DeviceEventHandler *event_handler, HWInterface *hw_intf, CompManager *comp_manager);
+  DisplayVirtual(DisplayEventHandler *event_handler, HWInterface *hw_intf,
+                 CompManager *comp_manager);
 };
 
 }  // namespace sde
 
-#endif  // __DEVICE_HDMI_H__
+#endif  // __DISPLAY_VIRTUAL_H__
 
diff --git a/displayengine/libs/core/hw_framebuffer.cpp b/displayengine/libs/core/hw_framebuffer.cpp
index 8dc3330..63adf8c 100644
--- a/displayengine/libs/core/hw_framebuffer.cpp
+++ b/displayengine/libs/core/hw_framebuffer.cpp
@@ -227,7 +227,7 @@
   return kErrorNone;
 }
 
-DisplayError HWFrameBuffer::GetNumDeviceAttributes(Handle device, uint32_t *count) {
+DisplayError HWFrameBuffer::GetNumDisplayAttributes(Handle device, uint32_t *count) {
   HWContext *hw_context = reinterpret_cast<HWContext *>(device);
 
   // TODO(user): Query modes
@@ -236,9 +236,9 @@
   return kErrorNone;
 }
 
-DisplayError HWFrameBuffer::GetDeviceAttributes(Handle device,
-                                                HWDeviceAttributes *device_attributes,
-                                                uint32_t mode) {
+DisplayError HWFrameBuffer::GetDisplayAttributes(Handle device,
+                                                 HWDisplayAttributes *display_attributes,
+                                                 uint32_t mode) {
   HWContext *hw_context = reinterpret_cast<HWContext *>(device);
   int &device_fd = hw_context->device_fd;
 
@@ -265,15 +265,16 @@
     var_screeninfo.height = INT((FLOAT(var_screeninfo.yres) * 25.4f)/160.0f + 0.5f);
   }
 
-  device_attributes->x_pixels = var_screeninfo.xres;
-  device_attributes->y_pixels = var_screeninfo.yres;
-  device_attributes->x_dpi = (FLOAT(var_screeninfo.xres) * 25.4f) / FLOAT(var_screeninfo.width);
-  device_attributes->y_dpi = (FLOAT(var_screeninfo.yres) * 25.4f) / FLOAT(var_screeninfo.height);
-  device_attributes->vsync_period_ns = UINT32(1000000000L / FLOAT(meta_data.data.panel_frame_rate));
+  display_attributes->x_pixels = var_screeninfo.xres;
+  display_attributes->y_pixels = var_screeninfo.yres;
+  display_attributes->x_dpi = (FLOAT(var_screeninfo.xres) * 25.4f) / FLOAT(var_screeninfo.width);
+  display_attributes->y_dpi = (FLOAT(var_screeninfo.yres) * 25.4f) / FLOAT(var_screeninfo.height);
+  display_attributes->vsync_period_ns =
+                 UINT32(1000000000L / FLOAT(meta_data.data.panel_frame_rate));
 
   // TODO(user): set panel information from sysfs
-  device_attributes->is_device_split = true;
-  device_attributes->split_left = device_attributes->x_pixels / 2;
+  display_attributes->is_device_split = true;
+  display_attributes->split_left = display_attributes->x_pixels / 2;
 
   return kErrorNone;
 }
diff --git a/displayengine/libs/core/hw_framebuffer.h b/displayengine/libs/core/hw_framebuffer.h
index 6b844af..d74d03e 100644
--- a/displayengine/libs/core/hw_framebuffer.h
+++ b/displayengine/libs/core/hw_framebuffer.h
@@ -43,9 +43,9 @@
   virtual DisplayError GetHWCapabilities(HWResourceInfo *hw_res_info);
   virtual DisplayError Open(HWBlockType type, Handle *device, HWEventHandler *eventhandler);
   virtual DisplayError Close(Handle device);
-  virtual DisplayError GetNumDeviceAttributes(Handle device, uint32_t *count);
-  virtual DisplayError GetDeviceAttributes(Handle device, HWDeviceAttributes *device_attributes,
-                                           uint32_t mode);
+  virtual DisplayError GetNumDisplayAttributes(Handle device, uint32_t *count);
+  virtual DisplayError GetDisplayAttributes(Handle device, HWDisplayAttributes *display_attributes,
+                                            uint32_t mode);
   virtual DisplayError PowerOn(Handle device);
   virtual DisplayError PowerOff(Handle device);
   virtual DisplayError Doze(Handle device);
diff --git a/displayengine/libs/core/hw_interface.h b/displayengine/libs/core/hw_interface.h
index bb2a8a9..a9bdb96 100644
--- a/displayengine/libs/core/hw_interface.h
+++ b/displayengine/libs/core/hw_interface.h
@@ -25,7 +25,7 @@
 #ifndef __HW_INTERFACE_H__
 #define __HW_INTERFACE_H__
 
-#include <core/device_interface.h>
+#include <core/display_interface.h>
 #include <private/strategy_interface.h>
 #include <utils/constants.h>
 
@@ -103,14 +103,14 @@
   HWLayerConfig config[kMaxSDELayers];
 };
 
-struct HWDeviceAttributes : DeviceConfigVariableInfo {
+struct HWDisplayAttributes : DisplayConfigVariableInfo {
   bool is_device_split;
   uint32_t split_left;
 
-  HWDeviceAttributes() : is_device_split(false), split_left(0) { }
+  HWDisplayAttributes() : is_device_split(false), split_left(0) { }
 };
 
-// HWEventHandler - Implemented in DeviceBase and HWInterface implementation
+// HWEventHandler - Implemented in DisplayBase and HWInterface implementation
 class HWEventHandler {
  public:
   virtual DisplayError VSync(int64_t timestamp) = 0;
@@ -126,9 +126,9 @@
   virtual DisplayError GetHWCapabilities(HWResourceInfo *hw_res_info) = 0;
   virtual DisplayError Open(HWBlockType type, Handle *device, HWEventHandler *eventhandler) = 0;
   virtual DisplayError Close(Handle device) = 0;
-  virtual DisplayError GetNumDeviceAttributes(Handle device, uint32_t *count) = 0;
-  virtual DisplayError GetDeviceAttributes(Handle device, HWDeviceAttributes *device_attributes,
-                                       uint32_t mode) = 0;
+  virtual DisplayError GetNumDisplayAttributes(Handle device, uint32_t *count) = 0;
+  virtual DisplayError GetDisplayAttributes(Handle device,
+                            HWDisplayAttributes *display_attributes, uint32_t mode) = 0;
   virtual DisplayError PowerOn(Handle device) = 0;
   virtual DisplayError PowerOff(Handle device) = 0;
   virtual DisplayError Doze(Handle device) = 0;
diff --git a/displayengine/libs/core/res_config.cpp b/displayengine/libs/core/res_config.cpp
index 0f71945..6e642ed 100644
--- a/displayengine/libs/core/res_config.cpp
+++ b/displayengine/libs/core/res_config.cpp
@@ -34,9 +34,9 @@
 
 namespace sde {
 
-DisplayError ResManager::Config(ResManagerDevice *res_mgr_device, HWLayers *hw_layers) {
-  HWBlockType hw_block_id = res_mgr_device->hw_block_id;
-  HWDeviceAttributes &device_attributes = res_mgr_device->device_attributes;
+DisplayError ResManager::Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers) {
+  HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
+  HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
   HWLayersInfo &layer_info = hw_layers->info;
 
   for (uint32_t i = 0; i < layer_info.count; i++) {
@@ -48,8 +48,8 @@
     }
 
     LayerRect scissor;
-    scissor.right = FLOAT(device_attributes.split_left);
-    scissor.bottom = FLOAT(device_attributes.y_pixels);
+    scissor.right = FLOAT(display_attributes.split_left);
+    scissor.bottom = FLOAT(display_attributes.y_pixels);
     LayerRect crop = layer.src_rect;
     LayerRect dst = layer.dst_rect;
     LayerRect cropRight = crop;
@@ -65,11 +65,11 @@
     if ((dstRight.right - dstRight.left) > kMaxInterfaceWidth ||
          crop_width > kMaxInterfaceWidth ||
         ((hw_block_id == kHWPrimary) && hw_res_info_.is_src_split &&
-         (crop_width > device_attributes.split_left))) {
-      scissor.left = FLOAT(device_attributes.split_left);
+         (crop_width > display_attributes.split_left))) {
+      scissor.left = FLOAT(display_attributes.split_left);
       scissor.top = 0.0f;
-      scissor.right = FLOAT(device_attributes.x_pixels);
-      scissor.bottom = FLOAT(device_attributes.y_pixels);
+      scissor.right = FLOAT(display_attributes.x_pixels);
+      scissor.bottom = FLOAT(display_attributes.y_pixels);
       CalculateCropRects(&cropRight, &dstRight, scissor, layer.transform);
       pipe_info->src_roi = cropRight;
       pipe_info->dst_roi = dstRight;
diff --git a/displayengine/libs/core/res_manager.cpp b/displayengine/libs/core/res_manager.cpp
index de73437..3f5bd32 100644
--- a/displayengine/libs/core/res_manager.cpp
+++ b/displayengine/libs/core/res_manager.cpp
@@ -92,8 +92,8 @@
   return kErrorNone;
 }
 
-DisplayError ResManager::RegisterDevice(DeviceType type, const HWDeviceAttributes &attributes,
-                                        Handle *device) {
+DisplayError ResManager::RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+                                        Handle *display_ctx) {
   DisplayError error = kErrorNone;
 
   HWBlockType hw_block_id = kHWBlockMax;
@@ -118,7 +118,7 @@
     break;
 
   default:
-    DLOGW("RegisterDevice, invalid type %d", type);
+    DLOGW("RegisterDisplay, invalid type %d", type);
     return kErrorParameters;
   }
 
@@ -126,37 +126,39 @@
     return kErrorResources;
   }
 
-  ResManagerDevice *res_mgr_device = new ResManagerDevice();
-  if (UNLIKELY(!res_mgr_device)) {
+  DisplayResourceContext *display_resource_ctx = new DisplayResourceContext();
+  if (UNLIKELY(!display_resource_ctx)) {
     return kErrorMemory;
   }
 
   hw_block_ctx_[hw_block_id].is_in_use = true;
 
-  res_mgr_device->device_attributes = attributes;
-  res_mgr_device->device_type = type;
-  res_mgr_device->hw_block_id = hw_block_id;
+  display_resource_ctx->display_attributes = attributes;
+  display_resource_ctx->display_type = type;
+  display_resource_ctx->hw_block_id = hw_block_id;
 
-  *device = res_mgr_device;
+  *display_ctx = display_resource_ctx;
 
   return kErrorNone;
 }
 
-DisplayError ResManager::UnregisterDevice(Handle device) {
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
+DisplayError ResManager::UnregisterDisplay(Handle display_ctx) {
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
 
-  Purge(device);
-  hw_block_ctx_[res_mgr_device->hw_block_id].is_in_use = false;
-  delete res_mgr_device;
+  Purge(display_ctx);
+  hw_block_ctx_[display_resource_ctx->hw_block_id].is_in_use = false;
+  delete display_resource_ctx;
 
   return kErrorNone;
 }
 
 
-DisplayError ResManager::Start(Handle device) {
+DisplayError ResManager::Start(Handle display_ctx) {
   locker_.Lock();
 
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
 
   if (frame_start_) {
     return kErrorNone;  // keep context locked.
@@ -164,10 +166,10 @@
 
   // First call in the cycle
   frame_start_ = true;
-  res_mgr_device->frame_count++;
+  display_resource_ctx->frame_count++;
 
   // Release the pipes not used in the previous cycle
-  HWBlockType hw_block_id = res_mgr_device->hw_block_id;
+  HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
   for (uint32_t i = 0; i < num_pipe_; i++) {
     if ((src_pipes_[i].hw_block_id == hw_block_id) &&
         (src_pipes_[i].state == kPipeStateToRelease)) {
@@ -177,16 +179,18 @@
   return kErrorNone;
 }
 
-DisplayError ResManager::Stop(Handle device) {
+DisplayError ResManager::Stop(Handle display_ctx) {
   locker_.Unlock();
 
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
 
   return kErrorNone;
 }
 
-DisplayError ResManager::Acquire(Handle device, HWLayers *hw_layers) {
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
+DisplayError ResManager::Acquire(Handle display_ctx, HWLayers *hw_layers) {
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
 
   DisplayError error = kErrorNone;
   const struct HWLayersInfo &layer_info = hw_layers->info;
@@ -199,14 +203,14 @@
     return kErrorResources;
   }
 
-  error = Config(res_mgr_device, hw_layers);
+  error = Config(display_resource_ctx, hw_layers);
   if (UNLIKELY(error != kErrorNone)) {
     return error;
   }
 
   uint32_t left_index = 0;
   bool need_scale = false;
-  HWBlockType hw_block_id = res_mgr_device->hw_block_id;
+  HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
 
   // Clear reserved marking
   for (uint32_t i = 0; i < num_pipe_; i++) {
@@ -274,10 +278,11 @@
   return kErrorResources;
 }
 
-void ResManager::PostCommit(Handle device, HWLayers *hw_layers) {
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
-  HWBlockType hw_block_id = res_mgr_device->hw_block_id;
-  uint64_t frame_count = res_mgr_device->frame_count;
+void ResManager::PostCommit(Handle display_ctx, HWLayers *hw_layers) {
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
+  HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
+  uint64_t frame_count = display_resource_ctx->frame_count;
 
   DLOGV("Resource for hw_block=%d frame_count=%d", hw_block_id, frame_count);
 
@@ -310,11 +315,12 @@
   frame_start_ = false;
 }
 
-void ResManager::Purge(Handle device) {
+void ResManager::Purge(Handle display_ctx) {
   SCOPE_LOCK(locker_);
 
-  ResManagerDevice *res_mgr_device = reinterpret_cast<ResManagerDevice *>(device);
-  HWBlockType hw_block_id = res_mgr_device->hw_block_id;
+  DisplayResourceContext *display_resource_ctx =
+                          reinterpret_cast<DisplayResourceContext *>(display_ctx);
+  HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
 
   for (uint32_t i = 0; i < num_pipe_; i++) {
     if (src_pipes_[i].hw_block_id == hw_block_id)
diff --git a/displayengine/libs/core/res_manager.h b/displayengine/libs/core/res_manager.h
index b2698c9..c4d425b 100644
--- a/displayengine/libs/core/res_manager.h
+++ b/displayengine/libs/core/res_manager.h
@@ -25,7 +25,7 @@
 #ifndef __RES_MANAGER_H__
 #define __RES_MANAGER_H__
 
-#include <core/device_interface.h>
+#include <core/display_interface.h>
 #include <utils/locker.h>
 
 #include "hw_interface.h"
@@ -38,14 +38,14 @@
   ResManager();
   DisplayError Init(const HWResourceInfo &hw_res_info);
   DisplayError Deinit();
-  DisplayError RegisterDevice(DeviceType type, const HWDeviceAttributes &attributes,
-                              Handle *device);
-  DisplayError UnregisterDevice(Handle device);
-  DisplayError Start(Handle device);
-  DisplayError Stop(Handle device);
-  DisplayError Acquire(Handle device, HWLayers *hw_layers);
-  void PostCommit(Handle device, HWLayers *hw_layers);
-  void Purge(Handle device);
+  DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+                              Handle *display_ctx);
+  DisplayError UnregisterDisplay(Handle display_ctx);
+  DisplayError Start(Handle display_ctx);
+  DisplayError Stop(Handle display_ctx);
+  DisplayError Acquire(Handle display_ctx, HWLayers *hw_layers);
+  void PostCommit(Handle display_ctx, HWLayers *hw_layers);
+  void Purge(Handle display_ctx);
 
   // DumpImpl method
   virtual void AppendDump(char *buffer, uint32_t length);
@@ -103,14 +103,14 @@
                    reserved(false) { }
   };
 
-  struct ResManagerDevice {
-    HWDeviceAttributes device_attributes;
-    DeviceType device_type;
+  struct DisplayResourceContext {
+    HWDisplayAttributes display_attributes;
+    DisplayType display_type;
     HWBlockType hw_block_id;
     uint64_t frame_count;
     int32_t session_id;  // applicable for virtual display sessions only
 
-    ResManagerDevice() : hw_block_id(kHWBlockMax), frame_count(0), session_id(-1) { }
+    DisplayResourceContext() : hw_block_id(kHWBlockMax), frame_count(0), session_id(-1) { }
   };
 
   struct HWBlockContext {
@@ -123,7 +123,7 @@
   uint32_t GetPipe(HWBlockType hw_block_id, bool is_yuv, bool need_scale, bool at_right,
                    bool use_non_dma_pipe);
   bool IsScalingNeeded(const HWPipeInfo *pipe_info);
-  DisplayError Config(ResManagerDevice *res_mgr_device, HWLayers *hw_layers);
+  DisplayError Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers);
   bool IsValidDimension(const Layer &layer, float *width_scale, float *height_scale);
   void CalculateCut(float *left_cut_ratio, float *top_cut_ratio, float *right_cut_ratio,
                     float *bottom_cut_ratio, const LayerTransform &transform);
diff --git a/displayengine/libs/core/strategy_default.h b/displayengine/libs/core/strategy_default.h
index c72bab9..c4e10f4 100644
--- a/displayengine/libs/core/strategy_default.h
+++ b/displayengine/libs/core/strategy_default.h
@@ -25,7 +25,7 @@
 #ifndef __STRATEGY_DEFAULT_H__
 #define __STRATEGY_DEFAULT_H__
 
-#include <core/device_interface.h>
+#include <core/display_interface.h>
 #include <private/strategy_interface.h>
 
 namespace sde {
diff --git a/displayengine/libs/hwc/Android.mk b/displayengine/libs/hwc/Android.mk
index be7e18c..c32337a 100644
--- a/displayengine/libs/hwc/Android.mk
+++ b/displayengine/libs/hwc/Android.mk
@@ -9,12 +9,12 @@
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"HWComposer\"
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libEGL libhardware_legacy \
                                  libdl libsync \
-                                 libbinder libmedia libskia libsdecore
+                                 libbinder libmedia libskia libsde
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := hwc_session.cpp \
-                                 hwc_sink.cpp \
-                                 hwc_sink_primary.cpp \
-                                 hwc_sink_external.cpp \
-                                 hwc_sink_virtual.cpp
+                                 hwc_display.cpp \
+                                 hwc_display_primary.cpp \
+                                 hwc_display_external.cpp \
+                                 hwc_display_virtual.cpp
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/displayengine/libs/hwc/hwc_sink.cpp b/displayengine/libs/hwc/hwc_display.cpp
similarity index 85%
rename from displayengine/libs/hwc/hwc_sink.cpp
rename to displayengine/libs/hwc/hwc_display.cpp
index 0fb4b8c..66ffcd8 100644
--- a/displayengine/libs/hwc/hwc_sink.cpp
+++ b/displayengine/libs/hwc/hwc_display.cpp
@@ -27,19 +27,20 @@
 #include <utils/constants.h>
 
 // HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSink"
+#define HWC_MODULE_NAME "HWCDisplay"
 #include "hwc_logger.h"
 
-#include "hwc_sink.h"
+#include "hwc_display.h"
 
 namespace sde {
 
-HWCSink::HWCSink(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DeviceType type, int id)
-  : core_intf_(core_intf), hwc_procs_(hwc_procs), type_(type), id_(id), device_intf_(NULL) {
+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) {
 }
 
-int HWCSink::Init() {
-  DisplayError error = core_intf_->CreateDevice(type_, this, &device_intf_);
+int HWCDisplay::Init() {
+  DisplayError error = core_intf_->CreateDisplay(type_, this, &display_intf_);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Display device create failed. Error = %d", error);
     return -EINVAL;
@@ -48,8 +49,8 @@
   return 0;
 }
 
-int HWCSink::Deinit() {
-  DisplayError error = core_intf_->DestroyDevice(device_intf_);
+int HWCDisplay::Deinit() {
+  DisplayError error = core_intf_->DestroyDisplay(display_intf_);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Display device destroy failed. Error = %d", error);
     return -EINVAL;
@@ -62,12 +63,12 @@
   return 0;
 }
 
-int HWCSink::EventControl(int event, int enable) {
+int HWCDisplay::EventControl(int event, int enable) {
   DisplayError error = kErrorNone;
 
   switch (event) {
   case HWC_EVENT_VSYNC:
-    error = device_intf_->SetVSyncState(enable);
+    error = display_intf_->SetVSyncState(enable);
     break;
 
   default:
@@ -82,13 +83,13 @@
   return 0;
 }
 
-int HWCSink::Blank(int blank) {
+int HWCDisplay::Blank(int blank) {
   DLOGI("Blank : %d, display : %d", blank, id_);
-  DeviceState state = blank ? kStateOff : kStateOn;
+  DisplayState state = blank ? kStateOff : kStateOn;
   return SetState(state);
 }
 
-int HWCSink::GetDisplayConfigs(uint32_t *configs, size_t *num_configs) {
+int HWCDisplay::GetDisplayConfigs(uint32_t *configs, size_t *num_configs) {
   if (*num_configs > 0) {
     configs[0] = 0;
     *num_configs = 1;
@@ -97,11 +98,11 @@
   return 0;
 }
 
-int HWCSink::GetDisplayAttributes(uint32_t config, const uint32_t *attributes, int32_t *values) {
+int HWCDisplay::GetDisplayAttributes(uint32_t config, const uint32_t *attributes, int32_t *values) {
   DisplayError error = kErrorNone;
 
-  DeviceConfigVariableInfo variable_config;
-  error = device_intf_->GetConfig(&variable_config, 0);
+  DisplayConfigVariableInfo variable_config;
+  error = display_intf_->GetConfig(&variable_config, 0);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("GetConfig variable info failed. Error = %d", error);
     return -EINVAL;
@@ -124,6 +125,9 @@
     case HWC_DISPLAY_DPI_Y:
       values[i] = INT32(variable_config.y_dpi * 1000.0f);
       break;
+    case HWC_DISPLAY_SECURE:
+      values[i] = INT32(true); // For backward compatibility. All Physical displays are secure
+      break;
     default:
       DLOGE("Spurious attribute type %d", attributes[i]);
       return -EINVAL;
@@ -133,8 +137,8 @@
   return 0;
 }
 
-int HWCSink::SetState(DeviceState state) {
-  DisplayError error = device_intf_->SetDeviceState(state);
+int HWCDisplay::SetState(DisplayState state) {
+  DisplayError error = display_intf_->SetDisplayState(state);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Set state failed. Error = %d", error);
     return -EINVAL;
@@ -143,7 +147,7 @@
   return 0;
 }
 
-DisplayError HWCSink::VSync(const DeviceEventVSync &vsync) {
+DisplayError HWCDisplay::VSync(const DisplayEventVSync &vsync) {
   if (*hwc_procs_) {
     (*hwc_procs_)->vsync(*hwc_procs_, id_, vsync.timestamp);
   }
@@ -151,7 +155,7 @@
   return kErrorNone;
 }
 
-DisplayError HWCSink::Refresh() {
+DisplayError HWCDisplay::Refresh() {
   if (*hwc_procs_) {
     (*hwc_procs_)->invalidate(*hwc_procs_);
   }
@@ -159,7 +163,7 @@
   return kErrorNone;
 }
 
-int HWCSink::AllocateLayerStack(hwc_display_contents_1_t *content_list) {
+int HWCDisplay::AllocateLayerStack(hwc_display_contents_1_t *content_list) {
   size_t num_hw_layers = content_list->numHwLayers;
 
   // Allocate memory for a) total number of layers b) buffer handle for each layer c) number of
@@ -220,7 +224,7 @@
   return 0;
 }
 
-int HWCSink::PrepareLayerStack(hwc_display_contents_1_t *content_list) {
+int HWCDisplay::PrepareLayerStack(hwc_display_contents_1_t *content_list) {
   size_t num_hw_layers = content_list->numHwLayers;
   if (UNLIKELY(num_hw_layers <= 1)) {
     return 0;
@@ -282,7 +286,7 @@
   // Configure layer stack
   layer_stack_.flags.geometry_changed = ((content_list->flags & HWC_GEOMETRY_CHANGED) > 0);
 
-  DisplayError error = device_intf_->Prepare(&layer_stack_);
+  DisplayError error = display_intf_->Prepare(&layer_stack_);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Prepare failed. Error = %d", error);
     return -EINVAL;
@@ -304,7 +308,7 @@
   return 0;
 }
 
-void HWCSink::CacheLayerStackInfo(hwc_display_contents_1_t *content_list) {
+void HWCDisplay::CacheLayerStackInfo(hwc_display_contents_1_t *content_list) {
   uint32_t layer_count = layer_stack_.layer_count;
 
   for (size_t i = 0; i < layer_count; i++) {
@@ -315,7 +319,7 @@
   layer_stack_cache_.layer_count = layer_count;
 }
 
-bool HWCSink::NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list) {
+bool HWCDisplay::NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list) {
   uint32_t layer_count = layer_stack_.layer_count;
 
   // Frame buffer needs to be refreshed for the following reasons:
@@ -343,7 +347,7 @@
   return false;
 }
 
-int HWCSink::CommitLayerStack(hwc_display_contents_1_t *content_list) {
+int HWCDisplay::CommitLayerStack(hwc_display_contents_1_t *content_list) {
   size_t num_hw_layers = content_list->numHwLayers;
   if (UNLIKELY(num_hw_layers <= 1)) {
     return 0;
@@ -356,7 +360,7 @@
     layer_buffer->acquire_fence_fd = hwc_layer.acquireFenceFd;
   }
 
-  DisplayError error = device_intf_->Commit(&layer_stack_);
+  DisplayError error = display_intf_->Commit(&layer_stack_);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Commit failed. Error = %d", error);
     return -EINVAL;
@@ -379,21 +383,21 @@
   return 0;
 }
 
-void HWCSink::SetRect(LayerRect *target, const hwc_rect_t &source) {
+void HWCDisplay::SetRect(LayerRect *target, const hwc_rect_t &source) {
   target->left = FLOAT(source.left);
   target->top = FLOAT(source.top);
   target->right = FLOAT(source.right);
   target->bottom = FLOAT(source.bottom);
 }
 
-void HWCSink::SetRect(LayerRect *target, const hwc_frect_t &source) {
+void HWCDisplay::SetRect(LayerRect *target, const hwc_frect_t &source) {
   target->left = source.left;
   target->top = source.top;
   target->right = source.right;
   target->bottom = source.bottom;
 }
 
-void HWCSink::SetComposition(LayerComposition *target, const int32_t &source) {
+void HWCDisplay::SetComposition(LayerComposition *target, const int32_t &source) {
   switch (source) {
   case HWC_FRAMEBUFFER_TARGET:
     *target = kCompositionGPUTarget;
@@ -404,7 +408,7 @@
   }
 }
 
-void HWCSink::SetComposition(int32_t *target, const LayerComposition &source) {
+void HWCDisplay::SetComposition(int32_t *target, const LayerComposition &source) {
   switch (source) {
   case kCompositionGPUTarget:
     *target = HWC_FRAMEBUFFER_TARGET;
@@ -418,7 +422,7 @@
   }
 }
 
-void HWCSink::SetBlending(LayerBlending *target, const int32_t &source) {
+void HWCDisplay::SetBlending(LayerBlending *target, const int32_t &source) {
   switch (source) {
   case HWC_BLENDING_PREMULT:
     *target = kBlendingPremultiplied;
@@ -432,7 +436,7 @@
   }
 }
 
-int HWCSink::SetFormat(LayerBufferFormat *target, const int &source) {
+int HWCDisplay::SetFormat(LayerBufferFormat *target, const int &source) {
   switch (source) {
   case HAL_PIXEL_FORMAT_RGBA_8888:
     *target = kFormatRGBA8888;
diff --git a/displayengine/libs/hwc/hwc_sink.h b/displayengine/libs/hwc/hwc_display.h
similarity index 89%
rename from displayengine/libs/hwc/hwc_sink.h
rename to displayengine/libs/hwc/hwc_display.h
index 551a77b..67356af 100644
--- a/displayengine/libs/hwc/hwc_sink.h
+++ b/displayengine/libs/hwc/hwc_display.h
@@ -22,15 +22,15 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __HWC_SINK_H__
-#define __HWC_SINK_H__
+#ifndef __HWC_DISPLAY_H__
+#define __HWC_DISPLAY_H__
 
 #include <hardware/hwcomposer.h>
 #include <core/core_interface.h>
 
 namespace sde {
 
-class HWCSink : public DeviceEventHandler {
+class HWCDisplay : public DisplayEventHandler {
  public:
   virtual int Init();
   virtual int Deinit();
@@ -40,7 +40,7 @@
   virtual int Blank(int blank);
   virtual int GetDisplayConfigs(uint32_t *configs, size_t *num_configs);
   virtual int GetDisplayAttributes(uint32_t config, const uint32_t *attributes, int32_t *values);
-  int SetState(DeviceState state);
+  int SetState(DisplayState state);
 
  protected:
   // Maximum number of layers supported by display engine.
@@ -55,11 +55,11 @@
     LayerStackMemory() : raw(NULL), size(0) { }
   };
 
-  HWCSink(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DeviceType type, int id);
-  virtual ~HWCSink() { }
+  HWCDisplay(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DisplayType type, int id);
+  virtual ~HWCDisplay() { }
 
-  // DeviceEventHandler methods
-  virtual DisplayError VSync(const DeviceEventVSync &vsync);
+  // DisplayEventHandler methods
+  virtual DisplayError VSync(const DisplayEventVSync &vsync);
   virtual DisplayError Refresh();
 
   virtual int AllocateLayerStack(hwc_display_contents_1_t *content_list);
@@ -75,9 +75,9 @@
   LayerStackMemory layer_stack_;
   CoreInterface *core_intf_;
   hwc_procs_t const **hwc_procs_;
-  DeviceType type_;
+  DisplayType type_;
   int id_;
-  DeviceInterface *device_intf_;
+  DisplayInterface *display_intf_;
 
  private:
   struct LayerCache {
@@ -102,5 +102,5 @@
 
 }  // namespace sde
 
-#endif  // __HWC_SINK_H__
+#endif  // __HWC_DISPLAY_H__
 
diff --git a/displayengine/libs/hwc/hwc_sink_external.cpp b/displayengine/libs/hwc/hwc_display_external.cpp
similarity index 77%
copy from displayengine/libs/hwc/hwc_sink_external.cpp
copy to displayengine/libs/hwc/hwc_display_external.cpp
index d506194..369d286 100644
--- a/displayengine/libs/hwc/hwc_sink_external.cpp
+++ b/displayengine/libs/hwc/hwc_display_external.cpp
@@ -25,38 +25,38 @@
 #include <utils/constants.h>
 
 // HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSinkExternal"
+#define HWC_MODULE_NAME "HWCDisplayExternal"
 #include "hwc_logger.h"
 
-#include "hwc_sink_external.h"
+#include "hwc_display_external.h"
 
 namespace sde {
 
-HWCSinkExternal::HWCSinkExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
-  : HWCSink(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
+HWCDisplayExternal::HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
+  : HWCDisplay(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
 }
 
-int HWCSinkExternal::Init() {
+int HWCDisplayExternal::Init() {
   return 0;
 }
 
-int HWCSinkExternal::Deinit() {
+int HWCDisplayExternal::Deinit() {
   return 0;
 }
 
-int HWCSinkExternal::Prepare(hwc_display_contents_1_t *content_list) {
+int HWCDisplayExternal::Prepare(hwc_display_contents_1_t *content_list) {
   return 0;
 }
 
-int HWCSinkExternal::Commit(hwc_display_contents_1_t *content_list) {
+int HWCDisplayExternal::Commit(hwc_display_contents_1_t *content_list) {
   return 0;
 }
 
-int HWCSinkExternal::PowerOn() {
+int HWCDisplayExternal::PowerOn() {
   return 0;
 }
 
-int HWCSinkExternal::PowerOff() {
+int HWCDisplayExternal::PowerOff() {
   return 0;
 }
 
diff --git a/displayengine/libs/hwc/hwc_sink_external.h b/displayengine/libs/hwc/hwc_display_external.h
similarity index 87%
rename from displayengine/libs/hwc/hwc_sink_external.h
rename to displayengine/libs/hwc/hwc_display_external.h
index c0eab7f..012c653 100644
--- a/displayengine/libs/hwc/hwc_sink_external.h
+++ b/displayengine/libs/hwc/hwc_display_external.h
@@ -22,16 +22,16 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __HWC_SINK_EXTERNAL_H__
-#define __HWC_SINK_EXTERNAL_H__
+#ifndef __HWC_DISPLAY_EXTERNAL_H__
+#define __HWC_DISPLAY_EXTERNAL_H__
 
-#include "hwc_sink.h"
+#include "hwc_display.h"
 
 namespace sde {
 
-class HWCSinkExternal : public HWCSink {
+class HWCDisplayExternal : public HWCDisplay {
  public:
-  explicit HWCSinkExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+  explicit HWCDisplayExternal(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);
@@ -42,5 +42,5 @@
 
 }  // namespace sde
 
-#endif  // __HWC_SINK_EXTERNAL_H__
+#endif  // __HWC_DISPLAY_EXTERNAL_H__
 
diff --git a/displayengine/libs/hwc/hwc_sink_primary.cpp b/displayengine/libs/hwc/hwc_display_primary.cpp
similarity index 77%
rename from displayengine/libs/hwc/hwc_sink_primary.cpp
rename to displayengine/libs/hwc/hwc_display_primary.cpp
index a9b74bf..d0c0734 100644
--- a/displayengine/libs/hwc/hwc_sink_primary.cpp
+++ b/displayengine/libs/hwc/hwc_display_primary.cpp
@@ -25,26 +25,26 @@
 #include <utils/constants.h>
 
 // HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSinkPrimary"
+#define HWC_MODULE_NAME "HWCDisplayPrimary"
 #include "hwc_logger.h"
 
-#include "hwc_sink_primary.h"
+#include "hwc_display_primary.h"
 
 namespace sde {
 
-HWCSinkPrimary::HWCSinkPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
-  : HWCSink(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY) {
+HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
+  : HWCDisplay(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY) {
 }
 
-int HWCSinkPrimary::Init() {
-  return HWCSink::Init();
+int HWCDisplayPrimary::Init() {
+  return HWCDisplay::Init();
 }
 
-int HWCSinkPrimary::Deinit() {
-  return HWCSink::Deinit();
+int HWCDisplayPrimary::Deinit() {
+  return HWCDisplay::Deinit();
 }
 
-int HWCSinkPrimary::Prepare(hwc_display_contents_1_t *content_list) {
+int HWCDisplayPrimary::Prepare(hwc_display_contents_1_t *content_list) {
   int status = 0;
 
   status = AllocateLayerStack(content_list);
@@ -60,10 +60,10 @@
   return 0;
 }
 
-int HWCSinkPrimary::Commit(hwc_display_contents_1_t *content_list) {
+int HWCDisplayPrimary::Commit(hwc_display_contents_1_t *content_list) {
   int status = 0;
 
-  status = HWCSink::CommitLayerStack(content_list);
+  status = HWCDisplay::CommitLayerStack(content_list);
   if (UNLIKELY(status)) {
     return status;
   }
@@ -73,11 +73,11 @@
   return 0;
 }
 
-int HWCSinkPrimary::PowerOn() {
+int HWCDisplayPrimary::PowerOn() {
   return SetState(kStateOn);
 }
 
-int HWCSinkPrimary::PowerOff() {
+int HWCDisplayPrimary::PowerOff() {
   return SetState(kStateOff);
 }
 
diff --git a/displayengine/libs/hwc/hwc_sink_virtual.h b/displayengine/libs/hwc/hwc_display_primary.h
similarity index 87%
copy from displayengine/libs/hwc/hwc_sink_virtual.h
copy to displayengine/libs/hwc/hwc_display_primary.h
index 381c1e3..cd8ae0f 100644
--- a/displayengine/libs/hwc/hwc_sink_virtual.h
+++ b/displayengine/libs/hwc/hwc_display_primary.h
@@ -22,16 +22,16 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __HWC_SINK_VIRTUAL_H__
-#define __HWC_SINK_VIRTUAL_H__
+#ifndef __HWC_DISPLAY_PRIMARY_H__
+#define __HWC_DISPLAY_PRIMARY_H__
 
-#include "hwc_sink.h"
+#include "hwc_display.h"
 
 namespace sde {
 
-class HWCSinkVirtual : public HWCSink {
+class HWCDisplayPrimary : public HWCDisplay {
  public:
-  explicit HWCSinkVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+  explicit HWCDisplayPrimary(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);
@@ -42,5 +42,5 @@
 
 }  // namespace sde
 
-#endif  // __HWC_SINK_VIRTUAL_H__
+#endif  // __HWC_DISPLAY_PRIMARY_H__
 
diff --git a/displayengine/libs/hwc/hwc_sink_external.cpp b/displayengine/libs/hwc/hwc_display_virtual.cpp
similarity index 77%
rename from displayengine/libs/hwc/hwc_sink_external.cpp
rename to displayengine/libs/hwc/hwc_display_virtual.cpp
index d506194..62e4d2f 100644
--- a/displayengine/libs/hwc/hwc_sink_external.cpp
+++ b/displayengine/libs/hwc/hwc_display_virtual.cpp
@@ -25,38 +25,38 @@
 #include <utils/constants.h>
 
 // HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSinkExternal"
+#define HWC_MODULE_NAME "HWCDisplayVirtual"
 #include "hwc_logger.h"
 
-#include "hwc_sink_external.h"
+#include "hwc_display_virtual.h"
 
 namespace sde {
 
-HWCSinkExternal::HWCSinkExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
-  : HWCSink(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
+HWCDisplayVirtual::HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
+  : HWCDisplay(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL) {
 }
 
-int HWCSinkExternal::Init() {
+int HWCDisplayVirtual::Init() {
   return 0;
 }
 
-int HWCSinkExternal::Deinit() {
+int HWCDisplayVirtual::Deinit() {
   return 0;
 }
 
-int HWCSinkExternal::Prepare(hwc_display_contents_1_t *content_list) {
+int HWCDisplayVirtual::Prepare(hwc_display_contents_1_t *content_list) {
   return 0;
 }
 
-int HWCSinkExternal::Commit(hwc_display_contents_1_t *content_list) {
+int HWCDisplayVirtual::Commit(hwc_display_contents_1_t *content_list) {
   return 0;
 }
 
-int HWCSinkExternal::PowerOn() {
+int HWCDisplayVirtual::PowerOn() {
   return 0;
 }
 
-int HWCSinkExternal::PowerOff() {
+int HWCDisplayVirtual::PowerOff() {
   return 0;
 }
 
diff --git a/displayengine/libs/hwc/hwc_sink_virtual.h b/displayengine/libs/hwc/hwc_display_virtual.h
similarity index 87%
rename from displayengine/libs/hwc/hwc_sink_virtual.h
rename to displayengine/libs/hwc/hwc_display_virtual.h
index 381c1e3..6159425 100644
--- a/displayengine/libs/hwc/hwc_sink_virtual.h
+++ b/displayengine/libs/hwc/hwc_display_virtual.h
@@ -22,16 +22,16 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __HWC_SINK_VIRTUAL_H__
-#define __HWC_SINK_VIRTUAL_H__
+#ifndef __HWC_DISPLAY_VIRTUAL_H__
+#define __HWC_DISPLAY_VIRTUAL_H__
 
-#include "hwc_sink.h"
+#include "hwc_display.h"
 
 namespace sde {
 
-class HWCSinkVirtual : public HWCSink {
+class HWCDisplayVirtual : public HWCDisplay {
  public:
-  explicit HWCSinkVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+  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);
@@ -42,5 +42,5 @@
 
 }  // namespace sde
 
-#endif  // __HWC_SINK_VIRTUAL_H__
+#endif  // __HWC_DISPLAY_VIRTUAL_H__
 
diff --git a/displayengine/libs/hwc/hwc_session.cpp b/displayengine/libs/hwc/hwc_session.cpp
index 9dfa920..9749fb1 100644
--- a/displayengine/libs/hwc/hwc_session.cpp
+++ b/displayengine/libs/hwc/hwc_session.cpp
@@ -77,24 +77,24 @@
   int status = -EINVAL;
 
   // Create and power on primary display
-  sink_primary_ = new HWCSinkPrimary(core_intf_, &hwc_procs_);
-  if (UNLIKELY(!sink_primary_)) {
+  display_primary_ = new HWCDisplayPrimary(core_intf_, &hwc_procs_);
+  if (UNLIKELY(!display_primary_)) {
     CoreInterface::DestroyCore();
     return -ENOMEM;
   }
 
-  status = sink_primary_->Init();
+  status = display_primary_->Init();
   if (UNLIKELY(status)) {
     CoreInterface::DestroyCore();
-    delete sink_primary_;
+    delete display_primary_;
     return status;
   }
 
-  status = sink_primary_->PowerOn();
+  status = display_primary_->PowerOn();
   if (UNLIKELY(status)) {
     CoreInterface::DestroyCore();
-    sink_primary_->Deinit();
-    delete sink_primary_;
+    display_primary_->Deinit();
+    delete display_primary_;
     return status;
   }
 
@@ -102,9 +102,9 @@
 }
 
 int HWCSession::Deinit() {
-  sink_primary_->PowerOff();
-  sink_primary_->Deinit();
-  delete sink_primary_;
+  display_primary_->PowerOff();
+  display_primary_->Deinit();
+  delete display_primary_;
 
   DisplayError error = CoreInterface::DestroyCore();
   if (error != kErrorNone) {
@@ -173,7 +173,7 @@
 
     switch (i) {
     case HWC_DISPLAY_PRIMARY:
-      status = hwc_session->sink_primary_->Prepare(content_list);
+      status = hwc_session->display_primary_->Prepare(content_list);
       break;
     default:
       status = -EINVAL;
@@ -207,7 +207,7 @@
 
     switch (i) {
     case HWC_DISPLAY_PRIMARY:
-      status = hwc_session->sink_primary_->Commit(content_list);
+      status = hwc_session->display_primary_->Commit(content_list);
       break;
     default:
       status = -EINVAL;
@@ -233,7 +233,7 @@
 
   switch (disp) {
   case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->sink_primary_->EventControl(event, enable);
+    status = hwc_session->display_primary_->EventControl(event, enable);
     break;
   default:
     status = -EINVAL;
@@ -254,7 +254,7 @@
 
   switch (disp) {
   case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->sink_primary_->Blank(blank);
+    status = hwc_session->display_primary_->Blank(blank);
     break;
   default:
     status = -EINVAL;
@@ -301,7 +301,7 @@
 
   switch (disp) {
   case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->sink_primary_->GetDisplayConfigs(configs, num_configs);
+    status = hwc_session->display_primary_->GetDisplayConfigs(configs, num_configs);
     break;
   default:
     status = -EINVAL;
@@ -321,7 +321,7 @@
 
   switch (disp) {
   case HWC_DISPLAY_PRIMARY:
-    status = hwc_session->sink_primary_->GetDisplayAttributes(config, attributes, values);
+    status = hwc_session->display_primary_->GetDisplayAttributes(config, attributes, values);
     break;
   default:
     status = -EINVAL;
diff --git a/displayengine/libs/hwc/hwc_session.h b/displayengine/libs/hwc/hwc_session.h
index 8390459..6b3346b 100644
--- a/displayengine/libs/hwc/hwc_session.h
+++ b/displayengine/libs/hwc/hwc_session.h
@@ -29,7 +29,7 @@
 #include <core/core_interface.h>
 #include <utils/locker.h>
 
-#include "hwc_sink_primary.h"
+#include "hwc_display_primary.h"
 
 namespace sde {
 
@@ -69,7 +69,7 @@
   static Locker locker_;
   CoreInterface *core_intf_;
   hwc_procs_t const *hwc_procs_;
-  HWCSinkPrimary *sink_primary_;
+  HWCDisplayPrimary *display_primary_;
 };
 
 }  // namespace sde
diff --git a/displayengine/libs/hwc/hwc_sink_primary.h b/displayengine/libs/hwc/hwc_sink_primary.h
deleted file mode 100644
index f16c5a6..0000000
--- a/displayengine/libs/hwc/hwc_sink_primary.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __HWC_SINK_PRIMARY_H__
-#define __HWC_SINK_PRIMARY_H__
-
-#include "hwc_sink.h"
-
-namespace sde {
-
-class HWCSinkPrimary : public HWCSink {
- public:
-  explicit HWCSinkPrimary(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 PowerOn();
-  virtual int PowerOff();
-};
-
-}  // namespace sde
-
-#endif  // __HWC_SINK_PRIMARY_H__
-
diff --git a/displayengine/libs/hwc/hwc_sink_virtual.cpp b/displayengine/libs/hwc/hwc_sink_virtual.cpp
deleted file mode 100644
index 49334a3..0000000
--- a/displayengine/libs/hwc/hwc_sink_virtual.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/constants.h>
-
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSinkVirtual"
-#include "hwc_logger.h"
-
-#include "hwc_sink_virtual.h"
-
-namespace sde {
-
-HWCSinkVirtual::HWCSinkVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
-  : HWCSink(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL) {
-}
-
-int HWCSinkVirtual::Init() {
-  return 0;
-}
-
-int HWCSinkVirtual::Deinit() {
-  return 0;
-}
-
-int HWCSinkVirtual::Prepare(hwc_display_contents_1_t *content_list) {
-  return 0;
-}
-
-int HWCSinkVirtual::Commit(hwc_display_contents_1_t *content_list) {
-  return 0;
-}
-
-int HWCSinkVirtual::PowerOn() {
-  return 0;
-}
-
-int HWCSinkVirtual::PowerOff() {
-  return 0;
-}
-
-}  // namespace sde
-
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 0a7f940..c96eb1e 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -799,6 +799,7 @@
         HWC_DISPLAY_HEIGHT,
         HWC_DISPLAY_DPI_X,
         HWC_DISPLAY_DPI_Y,
+        HWC_DISPLAY_SECURE,
         HWC_DISPLAY_NO_ATTRIBUTE,
     };
 
@@ -844,6 +845,9 @@
         case HWC_DISPLAY_DPI_Y:
             values[i] = (int32_t) (ctx->dpyAttr[disp].ydpi*1000.0);
             break;
+        case HWC_DISPLAY_SECURE:
+            values[i] = (int32_t) (ctx->dpyAttr[disp].secure);
+            break;
         default:
             ALOGE("Unknown display attribute %d",
                     attributes[i]);
diff --git a/libhwcomposer/hwc_dump_layers.cpp b/libhwcomposer/hwc_dump_layers.cpp
index e717c26..6a8feb2 100644
--- a/libhwcomposer/hwc_dump_layers.cpp
+++ b/libhwcomposer/hwc_dump_layers.cpp
@@ -319,7 +319,7 @@
         bool bResult = false;
         char dumpFilename[PATH_MAX];
         SkBitmap *tempSkBmp = new SkBitmap();
-        SkBitmap::Config tempSkBmpConfig = SkBitmap::kNo_Config;
+        SkColorType tempSkBmpColor = kUnknown_SkColorType;
         snprintf(dumpFilename, sizeof(dumpFilename),
             "%s/sfdump%03d.layer%zu.%s.png", mDumpDirPng,
             mDumpCntrPng, layerIndex, mDisplayName);
@@ -327,21 +327,24 @@
         switch (hnd->format) {
             case HAL_PIXEL_FORMAT_RGBA_8888:
             case HAL_PIXEL_FORMAT_RGBX_8888:
+                tempSkBmpColor = kRGBA_8888_SkColorType;
+                break;
             case HAL_PIXEL_FORMAT_BGRA_8888:
-                tempSkBmpConfig = SkBitmap::kARGB_8888_Config;
+                tempSkBmpColor = kBGRA_8888_SkColorType;
                 break;
             case HAL_PIXEL_FORMAT_RGB_565:
+                tempSkBmpColor = kRGB_565_SkColorType;
+                break;
             case HAL_PIXEL_FORMAT_RGBA_5551:
             case HAL_PIXEL_FORMAT_RGBA_4444:
-                tempSkBmpConfig = SkBitmap::kRGB_565_Config;
-                break;
             case HAL_PIXEL_FORMAT_RGB_888:
             default:
-                tempSkBmpConfig = SkBitmap::kNo_Config;
+                tempSkBmpColor = kUnknown_SkColorType;
                 break;
         }
-        if (SkBitmap::kNo_Config != tempSkBmpConfig) {
-            tempSkBmp->setConfig(tempSkBmpConfig, getWidth(hnd), getHeight(hnd));
+        if (kUnknown_SkColorType != tempSkBmpColor) {
+            tempSkBmp->setInfo(SkImageInfo::Make(getWidth(hnd), getHeight(hnd),
+                    tempSkBmpColor, kIgnore_SkAlphaType), 0);
             tempSkBmp->setPixels((void*)hnd->base);
             bResult = SkImageEncoder::EncodeFile(dumpFilename,
                                     *tempSkBmp, SkImageEncoder::kPNG_Type, 100);
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index d7f31da..975c195 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -46,6 +46,7 @@
 int MDPComp::sMaxPipesPerMixer = 0;
 bool MDPComp::sEnableYUVsplit = false;
 bool MDPComp::sSrcSplitEnabled = false;
+int MDPComp::sMaxSecLayers = 1;
 bool MDPComp::enablePartialUpdateForMDP3 = false;
 MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) {
     if(qdutils::MDPVersion::getInstance().isSrcSplit()) {
@@ -139,6 +140,16 @@
             sMaxPipesPerMixer = min(val, sMaxPipesPerMixer);
     }
 
+    /* Maximum layers allowed to use MDP on secondary panels. If property
+     * doesn't exist, default to 1. Using the property it can be set to 0 or
+     * more.
+     */
+    if(property_get("persist.hwc.maxseclayers", property, "1") > 0) {
+        int val = atoi(property);
+        sMaxSecLayers = (val >= 0) ? val : 1;
+        sMaxSecLayers = min(sMaxSecLayers, sMaxPipesPerMixer);
+    }
+
     if(ctx->mMDP.panel != MIPI_CMD_PANEL) {
         sIdleInvalidator = IdleInvalidator::getInstance();
         if(sIdleInvalidator->init(timeout_handler, ctx) < 0) {
@@ -733,7 +744,6 @@
                                 hwc_display_contents_1_t* list){
 
     const int numAppLayers = ctx->listStats[mDpy].numAppLayers;
-    int priDispW = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
 
     // Fall back to video only composition, if AIV video mode is enabled
     if(ctx->listStats[mDpy].mAIVVideoMode) {
@@ -770,19 +780,6 @@
         return false;
     }
 
-    MDPVersion& mdpHw = MDPVersion::getInstance();
-    if(mDpy > HWC_DISPLAY_PRIMARY &&
-            (priDispW >  (int) mdpHw.getMaxMixerWidth()) &&
-            (ctx->dpyAttr[mDpy].xres <  mdpHw.getMaxMixerWidth())) {
-        // Disable MDP comp on Secondary when the primary is highres panel and
-        // the secondary is a normal 1080p, because, MDP comp on secondary under
-        // in such usecase, decimation gets used for downscale and there will be
-        // a quality mismatch when there will be a fallback to GPU comp
-        ALOGD_IF(isDebug(), "%s: Disable MDP Compositon for Secondary Disp",
-              __FUNCTION__);
-        return false;
-    }
-
     // check for action safe flag and MDP scaling mode which requires scaling.
     if(ctx->dpyAttr[mDpy].mActionSafePresent
             || ctx->dpyAttr[mDpy].mMDPScalingMode) {
@@ -804,6 +801,7 @@
 
         //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp
         // may not need it if Gfx pre-rotation can handle all flips & rotations
+        MDPVersion& mdpHw = MDPVersion::getInstance();
         int transform = (layer->flags & HWC_COLOR_FILL) ? 0 : layer->transform;
         if( mdpHw.is8x26() && (ctx->dpyAttr[mDpy].xres > 1024) &&
                 (transform & HWC_TRANSFORM_FLIP_H) && (!isYuvBuffer(hnd)))
@@ -832,13 +830,6 @@
     if(sSimulationFlags & MDPCOMP_AVOID_FULL_MDP)
         return false;
 
-    //Will benefit presentation / secondary-only layer.
-    if((mDpy > HWC_DISPLAY_PRIMARY) &&
-            (list->numHwLayers - 1) > MAX_SEC_LAYERS) {
-        ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__);
-        return false;
-    }
-
     const int numAppLayers = ctx->listStats[mDpy].numAppLayers;
     for(int i = 0; i < numAppLayers; i++) {
         hwc_layer_1_t* layer = &list->hwLayers[i];
@@ -1041,7 +1032,7 @@
             // Update layer attributes
             hwc_rect_t srcCrop = integerizeSourceCrop(layer->sourceCropf);
             hwc_rect_t destRect = deductRect(layer->displayFrame,
-                                             overlapRect[j]);
+                        getIntersection(layer->displayFrame, overlapRect[j]));
             qhwc::calculate_crop_rects(srcCrop, layer->displayFrame, destRect,
                                        layer->transform);
             layer->sourceCropf.left = (float)srcCrop.left;
@@ -1055,8 +1046,14 @@
     mCurrentFrame.fbCount = 0;
     mCurrentFrame.fbZ = -1;
 
-    for (int j = 0; j < numAppLayers; j++)
-        mCurrentFrame.isFBComposed[j] = false;
+    for (int j = 0; j < numAppLayers; j++) {
+        if(isValidRect(list->hwLayers[j].displayFrame)) {
+            mCurrentFrame.isFBComposed[j] = false;
+        } else {
+            mCurrentFrame.mdpCount--;
+            mCurrentFrame.drop[j] = true;
+        }
+    }
 
     bool result = postHeuristicsHandling(ctx, list);
 
@@ -1154,14 +1151,6 @@
         adjustForSourceSplit(ctx, list);
     }
 
-    //Will benefit cases where a video has non-updating background.
-    if((mDpy > HWC_DISPLAY_PRIMARY) and
-            (mdpCount > MAX_SEC_LAYERS)) {
-        ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__);
-        reset(ctx);
-        return false;
-    }
-
     if(!postHeuristicsHandling(ctx, list)) {
         ALOGD_IF(isDebug(), "post heuristic handling failed");
         reset(ctx);
@@ -1813,6 +1802,14 @@
         ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__);
         return false;
     }
+
+    //Will benefit cases where a video has non-updating background.
+    if((mDpy > HWC_DISPLAY_PRIMARY) and
+            (mCurrentFrame.mdpCount > sMaxSecLayers)) {
+        ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__);
+        return false;
+    }
+
     // Init rotCount to number of rotate sessions used by other displays
     int rotCount = ctx->mRotMgr->getNumActiveSessions();
     // Count the number of rotator sessions required for current display
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index 7fa6674..8929c40 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -58,8 +58,6 @@
     static void setMaxPipesPerMixer(const uint32_t value);
 
 protected:
-    enum { MAX_SEC_LAYERS = 1 }; //TODO add property support
-
     enum ePipeType {
         MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB,
         MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG,
@@ -258,6 +256,7 @@
     static int sMaxPipesPerMixer;
     static bool sSrcSplitEnabled;
     static IdleInvalidator *sIdleInvalidator;
+    static int sMaxSecLayers;
     struct FrameInfo mCurrentFrame;
     struct LayerCache mCachedFrame;
     //Enable 4kx2k yuv layer split
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index f964212..ace0017 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -81,8 +81,8 @@
 
 namespace qhwc {
 
-//Std refresh rates for digital videos- 24p, 30p and 48p
-uint32_t stdRefreshRates[] = { 30, 24, 48 };
+// Std refresh rates for digital videos- 24p, 30p, 48p and 60p
+uint32_t stdRefreshRates[] = { 30, 24, 48, 60 };
 
 bool isValidResolution(hwc_context_t *ctx, uint32_t xres, uint32_t yres)
 {
@@ -128,6 +128,10 @@
     ctx->dpyAttr[dpy].yres = ctx->mHDMIDisplay->getHeight();
     ctx->dpyAttr[dpy].mMDPScalingMode = ctx->mHDMIDisplay->getMDPScalingMode();
     ctx->dpyAttr[dpy].vsync_period = ctx->mHDMIDisplay->getVsyncPeriod();
+    //FIXME: for now assume HDMI as secure
+    //Will need to read the HDCP status from the driver
+    //and update this accordingly
+    ctx->dpyAttr[dpy].secure = true;
     ctx->mViewFrame[dpy].left = 0;
     ctx->mViewFrame[dpy].top = 0;
     ctx->mViewFrame[dpy].right = ctx->dpyAttr[dpy].xres;
@@ -224,6 +228,7 @@
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi;
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].refreshRate = (uint32_t)fps;
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].dynRefreshRate = (uint32_t)fps;
+    ctx->dpyAttr[HWC_DISPLAY_PRIMARY].secure = true;
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period =
             (uint32_t)(1000000000l / fps);
 
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 0dd25c6..286ae22 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -89,6 +89,7 @@
     uint32_t stride;
     float xdpi;
     float ydpi;
+    bool secure;
     int fd;
     bool connected; //Applies only to pluggable disp.
     //Connected does not mean it ready to use.
diff --git a/libmemtrack/kgsl.c b/libmemtrack/kgsl.c
index 3026175..b120246 100644
--- a/libmemtrack/kgsl.c
+++ b/libmemtrack/kgsl.c
@@ -113,7 +113,7 @@
                 unaccounted_size += size;
 
         } else if (type == MEMTRACK_TYPE_GRAPHICS && strcmp(line_type, "ion") == 0) {
-            if (!is_surfaceflinger || strcmp(line_usage, "egl_image") != 0) {
+            if ( !(is_surfaceflinger == false && strcmp(line_usage, "egl_surface") == 0)) {
                 unaccounted_size += size;
             }
         }
diff --git a/liboverlay/mdpWrapper.h b/liboverlay/mdpWrapper.h
index 349b720..f689e45 100644
--- a/liboverlay/mdpWrapper.h
+++ b/liboverlay/mdpWrapper.h
@@ -72,7 +72,7 @@
 bool setOverlay(int fd, mdp_overlay& ov);
 
 /* MSMFB_OVERLAY_PREPARE */
-bool validateAndSet(const int& fd, mdp_overlay_list& list);
+int validateAndSet(const int& fd, mdp_overlay_list& list);
 
 /* MSM_ROTATOR_IOCTL_FINISH */
 bool endRotator(int fd, int sessionId);
@@ -180,7 +180,7 @@
     return true;
 }
 
-inline bool validateAndSet(const int& fd, mdp_overlay_list& list) {
+inline int validateAndSet(const int& fd, mdp_overlay_list& list) {
     ATRACE_CALL();
     uint32_t id = 0;
     if(UNLIKELY(Overlay::isDebugPipeLifecycle())) {
@@ -198,7 +198,7 @@
     if (ioctl(fd, MSMFB_OVERLAY_PREPARE, &list) < 0) {
         ALOGD_IF(IOCTL_DEBUG, "Failed to call ioctl MSMFB_OVERLAY_PREPARE "
                 "err=%s", strerror(errno));
-        return false;
+        return errno;
     }
 
     if(UNLIKELY(Overlay::isDebugPipeLifecycle())) {
@@ -209,7 +209,7 @@
         ALOGD("%s Pipe mask after OVERLAY_PREPARE 0x%04x", __FUNCTION__, id);
     }
 
-    return true;
+    return 0;
 }
 
 inline bool endRotator(int fd, uint32_t sessionId) {
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index 9320848..e9c0a13 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -97,9 +97,11 @@
     return dest;
 }
 
-eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) {
+eDest Overlay::nextPipe(eMdpPipeType type, const PipeSpecs& pipeSpecs) {
     eDest dest = OV_INVALID;
-
+    int dpy = pipeSpecs.dpy;
+    int mixer = pipeSpecs.mixer;
+    int formatType = pipeSpecs.formatClass;
     for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
         if( (type == OV_MDP_PIPE_ANY || //Pipe type match
              type == PipeBook::getPipeType((eDest)i)) &&
@@ -107,6 +109,8 @@
              mPipeBook[i].mDisplay == dpy) &&
             (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer
              mPipeBook[i].mMixer == mixer) &&
+            (mPipeBook[i].mFormatType == FORMAT_NONE || //Free or same format
+             mPipeBook[i].mFormatType == formatType) &&
             PipeBook::isNotAllocated(i) && //Free pipe
             ( (sDMAMultiplexingSupported && dpy) ||
               !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
@@ -122,6 +126,7 @@
         int index = (int)dest;
         mPipeBook[index].mDisplay = dpy;
         mPipeBook[index].mMixer = mixer;
+        mPipeBook[index].mFormatType = formatType;
         if(not mPipeBook[index].valid()) {
             mPipeBook[index].mPipe = new GenericPipe(dpy);
             mPipeBook[index].mSession = PipeBook::NONE;
@@ -146,28 +151,28 @@
 
     //The default behavior is to assume RGB and VG pipes have scalars
     if(pipeSpecs.formatClass == FORMAT_YUV) {
-        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
     } else if(pipeSpecs.fb == false) { //RGB App layers
         if(not pipeSpecs.needsScaling) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
         }
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
         }
     } else { //FB layer
-        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
         }
         //Some features can cause FB to have scaling as well.
         //If we ever come to this block with FB needing scaling,
         //the screen will be black for a frame, since the FB won't get a pipe
         //but atleast this will prevent a hang
         if(dest == OV_INVALID and (not pipeSpecs.needsScaling)) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
     }
     return dest;
@@ -178,31 +183,31 @@
     //described in a generic way
     eDest dest = OV_INVALID;
     if(pipeSpecs.formatClass == FORMAT_YUV) { //video
-        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
     } else if(pipeSpecs.fb == false) { //RGB app layers
         if((not pipeSpecs.needsScaling) and
           (not (pipeSpecs.numActiveDisplays > 1 &&
                 pipeSpecs.dpy == DPY_PRIMARY))) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
         }
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
         }
     } else { //FB layer
         //For 8x26 Secondary we use DMA always for FB for inline rotation
         if(pipeSpecs.dpy == DPY_PRIMARY) {
-            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
             if(dest == OV_INVALID) {
-                dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+                dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
             }
         }
         if(dest == OV_INVALID and (not pipeSpecs.needsScaling) and
           (not (pipeSpecs.numActiveDisplays > 1 &&
                 pipeSpecs.dpy == DPY_PRIMARY))) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
     }
     return dest;
@@ -213,16 +218,16 @@
     //and rife with assumptions
     eDest dest = OV_INVALID;
     if(pipeSpecs.formatClass == FORMAT_YUV or pipeSpecs.needsScaling) {
-        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
     } else {
         //Since this is a specific func, we can assume stuff like RGB pipe not
         //having scalar blocks
-        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
         }
     }
     return dest;
@@ -241,14 +246,14 @@
     //unused
     eDest dest = OV_INVALID;
     if(pipeSpecs.formatClass == FORMAT_YUV) {
-        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+        return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
     } else {
-        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs.dpy, pipeSpecs.mixer);
+        dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs);
         if(dest == OV_INVALID) {
-            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
         }
         if(dest == OV_INVALID and not pipeSpecs.needsScaling) {
-            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs.dpy, pipeSpecs.mixer);
+            dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
     }
     return dest;
@@ -402,48 +407,6 @@
         }
     }
 
-    if (mdpVersion < qdutils::MDSS_V5 && mdpVersion > qdutils::MDP_V3_0_5) {
-        msmfb_mixer_info_req  req;
-        mdp_mixer_info *minfo = NULL;
-        char name[64];
-        int fd = -1;
-        for(int i = 0; i < MAX_FB_DEVICES; i++) {
-            snprintf(name, 64, FB_DEVICE_TEMPLATE, i);
-            ALOGD("initoverlay:: opening the device:: %s", name);
-            fd = ::open(name, O_RDWR, 0);
-            if(fd < 0) {
-                ALOGE("cannot open framebuffer(%d)", i);
-                return -1;
-            }
-            //Get the mixer configuration */
-            req.mixer_num = i;
-            if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
-                ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
-                close(fd);
-                return -1;
-            }
-            minfo = req.info;
-            for (int j = 0; j < req.cnt; j++) {
-                ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum,
-                      minfo->z_order);
-                // except the RGB base layer with z_order of -1, clear any
-                // other pipes connected to mixer.
-                if((minfo->z_order) != -1) {
-                    int index = minfo->pndx;
-                    ALOGD("Unset overlay with index: %d at mixer %d", index, i);
-                    if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
-                        ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
-                        close(fd);
-                        return -1;
-                    }
-                }
-                minfo++;
-            }
-            close(fd);
-            fd = -1;
-        }
-    }
-
     FILE *displayDeviceFP = NULL;
     char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
     char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
@@ -567,6 +530,7 @@
     mPipe = NULL;
     mDisplay = DPY_UNUSED;
     mMixer = MIXER_UNUSED;
+    mFormatType = FORMAT_NONE;
 }
 
 void Overlay::PipeBook::destroy() {
@@ -576,6 +540,7 @@
     }
     mDisplay = DPY_UNUSED;
     mMixer = MIXER_UNUSED;
+    mFormatType = FORMAT_NONE;
     mSession = NONE;
 }
 
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index e8369ca..665e23f 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -50,7 +50,7 @@
     enum { MIXER_LEFT, MIXER_RIGHT, MIXER_UNUSED };
     enum { MIXER_DEFAULT = MIXER_LEFT, MIXER_MAX = MIXER_UNUSED };
     enum { MAX_FB_DEVICES = DPY_MAX };
-    enum { FORMAT_YUV, FORMAT_RGB };
+    enum { FORMAT_YUV, FORMAT_RGB , FORMAT_NONE };
 
     struct PipeSpecs {
         PipeSpecs() : formatClass(FORMAT_RGB), needsScaling(false), fb(false),
@@ -170,7 +170,7 @@
      * display without being garbage-collected once. To add if a pipe is
      * asisgned to a mixer within a display it cannot be reused for another
      * mixer without being UNSET once*/
-    utils::eDest nextPipe(utils::eMdpPipeType, int dpy, int mixer);
+    utils::eDest nextPipe(utils::eMdpPipeType, const PipeSpecs& pipeSpecs);
     /* Helpers that enfore target specific policies while returning pipes */
     utils::eDest getPipe_8x26(const PipeSpecs& pipeSpecs);
     utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs);
@@ -199,6 +199,8 @@
         int mDisplay;
         /* Mixer within a split display this pipe is attached to */
         int mMixer;
+        /* Format for which this pipe is attached to the mixer*/
+        int mFormatType;
 
         /* operations on bitmap */
         static bool pipeUsageUnchanged();
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index b8bb33e..4cd52a7 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -359,9 +359,12 @@
         fnProgramScale(&list);
     }
 
-    if(!mdp_wrapper::validateAndSet(fbFd, list)) {
+    // Error value is based on file errno-base.h
+    // 0 - indicates no error.
+    int errVal = mdp_wrapper::validateAndSet(fbFd, list);
+    if(errVal) {
         /* No dump for failure due to insufficient resource */
-        if(errno != E2BIG) {
+        if(errVal != E2BIG) {
             mdp_wrapper::dump("Bad ov dump: ",
                 *list.overlay_list[list.processed_overlays]);
         }