remove unused codes and unsupported features

Bug: 16955210

Change-Id: I90ac9bbfc87a4f34a225c65fe58e0470fbd0b3f2
Signed-off-by: Andy Qiu <junhai.qiu@intel.com>
Reviewed-on: https://android.intel.com/220474
Reviewed-by: Imberton, Guilhem <guilhem.imberton@intel.com>
Tested-by: Imberton, Guilhem <guilhem.imberton@intel.com>
Signed-off-by: Andy Qiu <junhai.qiu@intel.com>
diff --git a/Android.mk b/Android.mk
index 420de3c..6543fdf 100644
--- a/Android.mk
+++ b/Android.mk
@@ -12,15 +12,92 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+ifeq ($(INTEL_HWC_MOOREFIELD),true)
+
 LOCAL_PATH := $(call my-dir)
 
-LOCAL_ROOT_PATH := $(call my-dir)
+# HAL module implemenation, not prelinked and stored in
+# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
+include $(CLEAR_VARS)
 
-ifeq ($(INTEL_HWC_MERRIFIELD),true)
-include $(LOCAL_PATH)/merrifield.mk
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
+LOCAL_CFLAGS := -Werror
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libdrm \
+                          libwsbm libutils libhardware \
+                          libva libva-tpi libva-android libsync
+
+LOCAL_SRC_FILES := \
+    common/base/Drm.cpp \
+    common/base/HwcLayer.cpp \
+    common/base/HwcLayerList.cpp \
+    common/base/Hwcomposer.cpp \
+    common/base/HwcModule.cpp \
+    common/base/DisplayAnalyzer.cpp \
+    common/buffers/BufferCache.cpp \
+    common/buffers/GraphicBuffer.cpp \
+    common/buffers/BufferManager.cpp \
+    common/devices/DummyDevice.cpp \
+    common/devices/PhysicalDevice.cpp \
+    common/devices/PrimaryDevice.cpp \
+    common/devices/ExternalDevice.cpp \
+    common/observers/UeventObserver.cpp \
+    common/observers/VsyncEventObserver.cpp \
+    common/observers/SoftVsyncObserver.cpp \
+    common/planes/DisplayPlane.cpp \
+    common/planes/DisplayPlaneManager.cpp \
+    common/utils/Dump.cpp
+
+LOCAL_SRC_FILES += \
+    ips/common/BlankControl.cpp \
+    ips/common/HdcpControl.cpp \
+    ips/common/DrmControl.cpp \
+    ips/common/VsyncControl.cpp \
+    ips/common/OverlayPlaneBase.cpp \
+    ips/common/SpritePlaneBase.cpp \
+    ips/common/PixelFormat.cpp \
+    ips/common/GrallocBufferBase.cpp \
+    ips/common/GrallocBufferMapperBase.cpp \
+    ips/common/TTMBufferMapper.cpp \
+    ips/common/DrmConfig.cpp \
+    ips/common/Wsbm.cpp \
+    ips/common/WsbmWrapper.c \
+    ips/common/RotationBufferProvider.cpp
+
+LOCAL_SRC_FILES += \
+    ips/tangier/TngGrallocBuffer.cpp \
+    ips/tangier/TngGrallocBufferMapper.cpp \
+    ips/tangier/TngDisplayQuery.cpp \
+    ips/tangier/TngDisplayContext.cpp
+
+LOCAL_SRC_FILES += \
+    ips/anniedale/AnnPlaneManager.cpp \
+    ips/anniedale/AnnOverlayPlane.cpp \
+    ips/anniedale/AnnRGBPlane.cpp \
+    ips/anniedale/PlaneCapabilities.cpp
+
+LOCAL_SRC_FILES += \
+    platforms/merrifield_plus/PlatfBufferManager.cpp \
+    platforms/merrifield_plus/PlatfPrimaryDevice.cpp \
+    platforms/merrifield_plus/PlatfExternalDevice.cpp \
+    platforms/merrifield_plus/PlatfHwcomposer.cpp
+
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include \
+    $(TARGET_OUT_HEADERS)/libdrm \
+    $(TARGET_OUT_HEADERS)/libwsbm/wsbm \
+    $(TARGET_OUT_HEADERS)/libttm \
+    frameworks/native/include/media/openmax \
+    vendor/intel/hardware/anniedale/rgx/include \
+    $(TARGET_OUT_HEADERS)/pvr/hal
+
+
+ifeq ($(TARGET_SUPPORT_HDMI_PRIMARY),true)
+   LOCAL_CFLAGS += -DINTEL_SUPPORT_HDMI_PRIMARY
 endif
 
-ifeq ($(INTEL_HWC_MOOREFIELD),true)
-include $(LOCAL_PATH)/merrifield_plus.mk
-endif
+include $(BUILD_SHARED_LIBRARY)
 
+endif
diff --git a/common/base/DisplayAnalyzer.cpp b/common/base/DisplayAnalyzer.cpp
index d3d7185..14e1968 100755
--- a/common/base/DisplayAnalyzer.cpp
+++ b/common/base/DisplayAnalyzer.cpp
@@ -15,34 +15,18 @@
 */
 
 #include <common/utils/HwcTrace.h>
-#include <IDisplayDevice.h>
-#include <DisplayQuery.h>
-#include <BufferManager.h>
-#include <DisplayPlaneManager.h>
 #include <Hwcomposer.h>
 #include <common/base/DisplayAnalyzer.h>
-#include <cutils/properties.h>
-#include <GraphicBuffer.h>
-#include <ExternalDevice.h>
 
 namespace android {
 namespace intel {
 
 DisplayAnalyzer::DisplayAnalyzer()
     : mInitialized(false),
-      mVideoExtModeEnabled(true),
-      mVideoExtModeEligible(false),
-      mVideoExtModeActive(false),
-      mBlankDevice(false),
-      mOverlayAllowed(true),
-      mActiveInputState(true),
-      mIgnoreVideoSkipFlag(false),
-      mProtectedVideoSession(false),
       mCachedNumDisplays(0),
       mCachedDisplays(0),
       mPendingEvents(),
-      mEventMutex(),
-      mEventHandledCondition()
+      mEventMutex()
 {
 }
 
@@ -52,22 +36,9 @@
 
 bool DisplayAnalyzer::initialize()
 {
-    // by default video extended mode is enabled
-    char prop[PROPERTY_VALUE_MAX];
-    if (property_get("hwc.video.extmode.enable", prop, "1") > 0) {
-        mVideoExtModeEnabled = atoi(prop) ? true : false;
-    }
-    mVideoExtModeEligible = false;
-    mVideoExtModeActive = false;
-    mBlankDevice = false;
-    mOverlayAllowed = true;
-    mActiveInputState = true;
-    mIgnoreVideoSkipFlag = false;
-    mProtectedVideoSession = false;
     mCachedNumDisplays = 0;
     mCachedDisplays = 0;
     mPendingEvents.clear();
-    mVideoStateMap.clear();
     mInitialized = true;
 
     return true;
@@ -76,7 +47,6 @@
 void DisplayAnalyzer::deinitialize()
 {
     mPendingEvents.clear();
-    mVideoStateMap.clear();
     mInitialized = false;
 }
 
@@ -88,236 +58,10 @@
     mCachedDisplays = displays;
 
     handlePendingEvents();
-
-    // FIXME: WA for ASUS Face unlock screen flicker issue
-    // If layer count exceeds plane max number, force GLES
-    hwc_display_contents_1_t *content = NULL;
-    for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-        content = mCachedDisplays[i];
-        if (content == NULL) {
-            continue;
-        }
-
-        if ((content->flags & HWC_GEOMETRY_CHANGED) &&
-            (content->numHwLayers > 5) &&
-            !hasVideoLayer(i))
-            setCompositionType(i, HWC_FORCE_FRAMEBUFFER, true);
-    }
-
-    if (mVideoExtModeEnabled) {
-        handleVideoExtMode();
-    }
-
-    if (mBlankDevice) {
-        // this will make sure device is blanked after geometry changes.
-        // blank event is only processed once
-        blankSecondaryDevice();
-    }
-}
-
-void DisplayAnalyzer::handleVideoExtMode()
-{
-    bool eligible = mVideoExtModeEligible;
-    checkVideoExtMode();
-    if (eligible == mVideoExtModeEligible) {
-        if (mVideoExtModeActive) {
-            // need to mark all layers
-            setCompositionType(0, HWC_OVERLAY, false);
-        }
-        return;
-    }
-
-    if (mVideoExtModeEligible) {
-        if (mActiveInputState) {
-            VTRACE("input is active");
-        } else {
-            enterVideoExtMode();
-        }
-    } else {
-        exitVideoExtMode();
-    }
-}
-
-void DisplayAnalyzer::checkVideoExtMode()
-{
-    if (mVideoStateMap.size() != 1) {
-        mVideoExtModeEligible = false;
-        return;
-    }
-
-    bool geometryChanged = false;
-    int activeDisplays = 0;
-
-    hwc_display_contents_1_t *content = NULL;
-    for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-        content = mCachedDisplays[i];
-        if (content == NULL) {
-            continue;
-        }
-        activeDisplays++;
-        if (content->flags & HWC_GEOMETRY_CHANGED) {
-            geometryChanged = true;
-        }
-    }
-
-    if (activeDisplays <= 1) {
-        mVideoExtModeEligible = false;
-        return;
-    }
-
-    // video state update event may come later than geometry change event.
-    // in that case, video extended mode is not detected properly.
-#if 0
-    if (geometryChanged == false) {
-        // use previous analysis result
-        return;
-    }
-#endif
-    // reset eligibility of video extended mode
-    mVideoExtModeEligible = false;
-
-    // check if there is video layer in the primary device
-    content = mCachedDisplays[0];
-    if (content == NULL) {
-        return;
-    }
-
-    uint32_t videoHandle = 0;
-    bool videoLayerExist = false;
-    bool videoFullScreenOnPrimary = false;
-    bool isVideoLayerSkipped = false;
-
-    // exclude the frame buffer target layer
-    for (int j = 0; j < (int)content->numHwLayers - 1; j++) {
-        videoLayerExist = isVideoLayer(content->hwLayers[j]);
-        if (videoLayerExist) {
-            if ((content->hwLayers[j].flags & HWC_SKIP_LAYER)) {
-                isVideoLayerSkipped = true;
-            }
-            videoHandle = (uint32_t)content->hwLayers[j].handle;
-            videoFullScreenOnPrimary = isVideoFullScreen(0, content->hwLayers[j]);
-            break;
-        }
-    }
-
-    if (videoLayerExist == false) {
-        // no video layer is found in the primary layer
-        return;
-    }
-
-    // check whether video layer exists in external device or virtual device
-    // TODO: video may exist in virtual device but no in external device or vice versa
-    // TODO: multiple video layers are not addressed here
-    for (int i = 1; i < (int)mCachedNumDisplays; i++) {
-        content = mCachedDisplays[i];
-        if (content == NULL) {
-            continue;
-        }
-
-        // exclude the frame buffer target layer
-        for (int j = 0; j < (int)content->numHwLayers - 1; j++) {
-            if ((uint32_t)content->hwLayers[j].handle == videoHandle) {
-                isVideoLayerSkipped |= (content->hwLayers[j].flags & HWC_SKIP_LAYER);
-                VTRACE("video layer exists in device %d", i);
-                if (isVideoLayerSkipped || videoFullScreenOnPrimary){
-                    VTRACE("Video ext mode eligible, %d, %d",
-                            isVideoLayerSkipped, videoFullScreenOnPrimary);
-                    mVideoExtModeEligible = true;
-                } else {
-                    mVideoExtModeEligible = isVideoFullScreen(i, content->hwLayers[j]);
-                }
-                return;
-            }
-        }
-    }
-}
-
-bool DisplayAnalyzer::isVideoExtModeActive()
-{
-    return mVideoExtModeActive;
-}
-
-bool DisplayAnalyzer::isVideoExtModeEnabled()
-{
-#if 1
-    // enable it for run-time debugging purpose.
-    char prop[PROPERTY_VALUE_MAX];
-    if (property_get("hwc.video.extmode.enable", prop, "1") > 0) {
-        mVideoExtModeEnabled = atoi(prop) ? true : false;
-    }
-    ITRACE("video extended mode enabled: %d", mVideoExtModeEnabled);
-#endif
-
-    return mVideoExtModeEnabled;
-}
-
-bool DisplayAnalyzer::isVideoLayer(hwc_layer_1_t &layer)
-{
-    bool ret = false;
-    BufferManager *bm = Hwcomposer::getInstance().getBufferManager();
-    if (!layer.handle) {
-        return false;
-    }
-    DataBuffer *buffer = bm->lockDataBuffer((uint32_t)layer.handle);
-     if (!buffer) {
-         ETRACE("failed to get buffer");
-     } else {
-        ret = DisplayQuery::isVideoFormat(buffer->getFormat());
-        bm->unlockDataBuffer(buffer);
-    }
-    return ret;
-}
-
-bool DisplayAnalyzer::isVideoFullScreen(int device, hwc_layer_1_t &layer)
-{
-    IDisplayDevice *displayDevice = Hwcomposer::getInstance().getDisplayDevice(device);
-    if (!displayDevice) {
-        return false;
-    }
-    int width = 0, height = 0;
-    if (!displayDevice->getDisplaySize(&width, &height)) {
-        return false;
-    }
-
-    VTRACE("video left %d, right %d, top %d, bottom %d, device width %d, height %d",
-        layer.displayFrame.left, layer.displayFrame.right,
-        layer.displayFrame.top, layer.displayFrame.bottom,
-        width, height);
-
-    // full-screen defintion:
-    // width of target display frame == width of target device, with 1 pixel of tolerance, or
-    // Height of target display frame == height of target device, with 1 pixel of tolerance, or
-    // width * height of display frame > 90% of width * height of display device, or
-    // any of above condition is met on either primary display or secondary display
-    int dstW = layer.displayFrame.right - layer.displayFrame.left;
-    int dstH = layer.displayFrame.bottom - layer.displayFrame.top;
-
-    if (abs(dstW - width) <= 1 &&
-        abs(dstH - height) <= 1 &&
-        dstW * dstH * 10 < width * height * 9) {
-        VTRACE("video is not full-screen");
-        return false;
-    }
-    return true;
-}
-
-bool DisplayAnalyzer::isOverlayAllowed()
-{
-    return mOverlayAllowed;
-}
-
-int DisplayAnalyzer::getVideoInstances()
-{
-    return (int)mVideoStateMap.size();
 }
 
 void DisplayAnalyzer::postHotplugEvent(bool connected)
 {
-    if (!connected) {
-        // enable vsync on the primary device immediately
-        Hwcomposer::getInstance().getVsyncManager()->enableDynamicVsync(true);
-    }
-
     // handle hotplug event (vsync switch) asynchronously
     Event e;
     e.type = HOTPLUG_EVENT;
@@ -326,56 +70,6 @@
     Hwcomposer::getInstance().invalidate();
 }
 
-void DisplayAnalyzer::postVideoEvent(int instanceID, int state)
-{
-    Event e;
-    e.type = VIDEO_EVENT;
-    e.videoEvent.instanceID = instanceID;
-    e.videoEvent.state = state;
-    postEvent(e);
-
-    if ((state == VIDEO_PLAYBACK_STARTING) ||
-        (state == VIDEO_PLAYBACK_STOPPING && mProtectedVideoSession)) {
-        Hwcomposer::getInstance().invalidate();
-        // wait for up to 100ms until overlay is disabled.
-        int loop = 0;
-        while (loop++ < 6) {
-            if (Hwcomposer::getInstance().getPlaneManager()->isOverlayPlanesDisabled())
-                break;
-            usleep(16700);
-        }
-        if (loop == 6) {
-            WTRACE("timeout disabling overlay ");
-        }
-    }
-}
-
-void DisplayAnalyzer::postBlankEvent(bool blank)
-{
-    Event e;
-    e.type = BLANK_EVENT;
-    e.bValue = blank;
-    postEvent(e);
-    Hwcomposer::getInstance().invalidate();
-}
-
-void DisplayAnalyzer::postInputEvent(bool active)
-{
-    Event e;
-    e.type = INPUT_EVENT;
-    e.bValue = active;
-    postEvent(e);
-    Hwcomposer::getInstance().invalidate();
-}
-
-void DisplayAnalyzer::postIdleEntryEvent(void)
-{
-    Event e;
-    e.type = IDLE_ENTRY_EVENT;
-    e.nValue = 0;
-    postEvent(e);
-}
-
 void DisplayAnalyzer::postEvent(Event& e)
 {
     Mutex::Autolock lock(mEventMutex);
@@ -406,30 +100,6 @@
     case HOTPLUG_EVENT:
         handleHotplugEvent(e.bValue);
         break;
-    case BLANK_EVENT:
-        handleBlankEvent(e.bValue);
-        break;
-    case VIDEO_EVENT:
-        handleVideoEvent(e.videoEvent.instanceID, e.videoEvent.state);
-        break;
-    case TIMING_EVENT:
-        handleTimingEvent();
-        break;
-    case INPUT_EVENT:
-        handleInputEvent(e.bValue);
-        break;
-    case DPMS_EVENT:
-        handleDpmsEvent(e.nValue);
-        break;
-    case IDLE_ENTRY_EVENT:
-        handleIdleEntryEvent(e.nValue);
-        break;
-    case IDLE_EXIT_EVENT:
-        handleIdleExitEvent();
-        break;
-    case VIDEO_CHECK_EVENT:
-        handleVideoCheckEvent();
-        break;
     }
 }
 
@@ -439,457 +109,9 @@
         for (int i = 0; i < mCachedNumDisplays; i++) {
             setCompositionType(i, HWC_FRAMEBUFFER, true);
         }
-        Hwcomposer::getInstance().getPowerManager()->disableIdleControl();
-    } else {
-        if (mVideoStateMap.size() == 0) {
-            Hwcomposer::getInstance().getPowerManager()->enableIdleControl();
-        } else if (mVideoStateMap.size() == 1) {
-            // Reset input state if HDMI is plug out to
-            // avoid entering extended mode immediately after HDMI is plug in
-            mActiveInputState = true;
-        }
     }
 }
 
-void DisplayAnalyzer::handleBlankEvent(bool blank)
-{
-    mBlankDevice = blank;
-    // force geometry changed in the secondary device to reset layer composition type
-    for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-        if (i == IDisplayDevice::DEVICE_PRIMARY) {
-            continue;
-        }
-        if (mCachedDisplays[i]) {
-            mCachedDisplays[i]->flags |= HWC_GEOMETRY_CHANGED;
-        }
-    }
-    blankSecondaryDevice();
-}
-
-void DisplayAnalyzer::handleTimingEvent()
-{
-    // check whether external device is connected, reset refresh rate to match video frame rate
-    // if video is in playing state or reset refresh rate to default preferred one if video is not
-    // at playing state
-    Hwcomposer *hwc = &Hwcomposer::getInstance();
-    ExternalDevice *dev = NULL;
-    dev = (ExternalDevice *)hwc->getDisplayDevice(IDisplayDevice::DEVICE_EXTERNAL);
-    if (!dev) {
-        return;
-    }
-
-    if (!dev->isConnected()) {
-        return;
-    }
-
-    if (hwc->getMultiDisplayObserver()->isExternalDeviceTimingFixed()) {
-        VTRACE("Timing of external device is fixed.");
-        return;
-    }
-
-    int hz = 0;
-    if (mVideoStateMap.size() == 1) {
-        VideoSourceInfo info;
-        int instanceID = mVideoStateMap.keyAt(0);
-        status_t err = hwc->getMultiDisplayObserver()->getVideoSourceInfo(
-                instanceID, &info);
-        if (err == NO_ERROR) {
-            hz = info.frameRate;
-        }
-    }
-
-    dev->setRefreshRate(hz);
-}
-
-void DisplayAnalyzer::handleVideoEvent(int instanceID, int state)
-{
-    mVideoStateMap.removeItem(instanceID);
-    if (state != VIDEO_PLAYBACK_STOPPED) {
-        mVideoStateMap.add(instanceID, state);
-    }
-
-    Hwcomposer *hwc = &Hwcomposer::getInstance();
-
-    // sanity check
-    if (hwc->getMultiDisplayObserver()->getVideoSessionNumber() !=
-        (int)mVideoStateMap.size()) {
-        WTRACE("session number does not match!!");
-        mVideoStateMap.clear();
-        if (state != VIDEO_PLAYBACK_STOPPED) {
-            mVideoStateMap.add(instanceID, state);
-        }
-    }
-
-    // check if composition type needs to be reset
-    bool reset = false;
-    if ((state == VIDEO_PLAYBACK_STARTING) ||
-        (state == VIDEO_PLAYBACK_STOPPING && mProtectedVideoSession)) {
-        // if video is in starting or stopping stage, overlay use is temporarily not allowed to
-        // avoid scrambed RGB overlay if video is protected.
-        mOverlayAllowed = false;
-        reset = true;
-    } else {
-        reset = !mOverlayAllowed;
-        mOverlayAllowed = true;
-    }
-
-    if (reset) {
-        hwc_display_contents_1_t *content = NULL;
-        for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-            setCompositionType(i, HWC_FRAMEBUFFER, true);
-        }
-    }
-
-    if (mVideoStateMap.size() == 0) {
-        // reset active input state after video playback stops.
-        // MDS should update input state in 5 seconds after video playback starts
-        mActiveInputState = true;
-    }
-
-    if (mVideoStateMap.size() > 0) {
-        hwc->getPowerManager()->disableIdleControl();
-    } else if (!hwc->getDrm()->isConnected(IDisplayDevice::DEVICE_EXTERNAL)) {
-         hwc->getPowerManager()->enableIdleControl();
-    }
-
-    mProtectedVideoSession = false;
-    if (state == VIDEO_PLAYBACK_STARTED) {
-        VideoSourceInfo info;
-        hwc->getMultiDisplayObserver()->getVideoSourceInfo(
-                getFirstVideoInstanceSessionID(), &info);
-        mProtectedVideoSession = info.isProtected;
-    }
-
-    // Setting timing immediately,
-    // Don't posthone to next circle
-    handleTimingEvent();
-
-    handleVideoCheckEvent();
-}
-
-void DisplayAnalyzer::blankSecondaryDevice()
-{
-    hwc_display_contents_1_t *content = NULL;
-    hwc_layer_1 *layer = NULL;
-    for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-        if (i == IDisplayDevice::DEVICE_PRIMARY) {
-            continue;
-        }
-        content = mCachedDisplays[i];
-        if (content == NULL) {
-            continue;
-        }
-
-        for (int j = 0; j < (int)content->numHwLayers - 1; j++) {
-            layer = &content->hwLayers[j];
-            if (!layer) {
-                continue;
-            }
-            if (mBlankDevice) {
-                layer->hints |= HWC_HINT_CLEAR_FB;
-                layer->flags &= ~HWC_SKIP_LAYER;
-                layer->compositionType = HWC_OVERLAY;
-            } else {
-                layer->hints &= ~HWC_HINT_CLEAR_FB;
-                layer->compositionType = HWC_FRAMEBUFFER;
-            }
-        }
-    }
-}
-
-void DisplayAnalyzer::handleInputEvent(bool active)
-{
-    if (active == mActiveInputState) {
-        WTRACE("same input state: %d", active);
-    }
-    mActiveInputState = active;
-    if (!mVideoExtModeEligible) {
-        ITRACE("not eligible for video extended mode");
-        return;
-    }
-
-    if (active) {
-        exitVideoExtMode();
-    } else {
-        enterVideoExtMode();
-    }
-}
-
-void DisplayAnalyzer::handleDpmsEvent(int delayCount)
-{
-    if (mActiveInputState || !mVideoExtModeEligible) {
-        ITRACE("aborting display power off in video extended mode");
-        return;
-    }
-
-    if (delayCount < DELAY_BEFORE_DPMS_OFF) {
-        Event e;
-        e.type = DPMS_EVENT;
-        e.nValue = delayCount + 1;
-        postEvent(e);
-        Hwcomposer::getInstance().invalidate();
-        return;
-    }
-
-    if (Hwcomposer::getInstance().getVsyncManager()->getVsyncSource() ==
-        IDisplayDevice::DEVICE_PRIMARY) {
-            Hwcomposer::getInstance().getDrm()->setDpmsMode(
-            IDisplayDevice::DEVICE_PRIMARY,
-                IDisplayDevice::DEVICE_DISPLAY_STANDBY);
-        ETRACE("primary display is source of vsync, we only dim backlight");
-        return;
-    }
-
-    // panel can't be powered off as touch panel shares the power supply with LCD.
-    DTRACE("primary display coupled with touch on Saltbay, only dim backlight");
-    Hwcomposer::getInstance().getDrm()->setDpmsMode(
-               IDisplayDevice::DEVICE_PRIMARY,
-               IDisplayDevice::DEVICE_DISPLAY_STANDBY);
-               //IDisplayDevice::DEVICE_DISPLAY_OFF);
-    return;
-}
-
-
-void DisplayAnalyzer::handleIdleEntryEvent(int count)
-{
-    DTRACE("handling idle entry event, count %d", count);
-    if (hasProtectedLayer()) {
-        ITRACE("Ignoring idle entry as protected layer exists.");
-        setCompositionType(0, HWC_FRAMEBUFFER, true);
-        return;
-    }
-
-    // stop idle entry if external device is connected
-    if (mCachedDisplays && mCachedDisplays[IDisplayDevice::DEVICE_EXTERNAL]) {
-        ITRACE("Ignoring idle entry as external device is connected.");
-        setCompositionType(0, HWC_FRAMEBUFFER, true);
-        return;
-    }
-
-    // stop idle entry if video playback is active
-    // TODO: remove this check for Annidale
-    if (mVideoStateMap.size() > 0) {
-        ITRACE("Ignoring idle entry as video session is active.");
-        setCompositionType(0, HWC_FRAMEBUFFER, true);
-        return;
-    }
-
-    setCompositionType(0, HWC_FORCE_FRAMEBUFFER, true);
-
-    IPowerManager *pm = Hwcomposer::getInstance().getPowerManager();
-    if (count == 0) {
-        // ready to enter idel mode
-        pm->setIdleReady();
-    }
-
-    if (count >= DELAY_BEFORE_IDLE_ENTRY) {
-        pm->enterIdleState();
-        // next prepare/set will exit idle state.
-        Event e;
-        e.type = IDLE_EXIT_EVENT;
-        postEvent(e);
-    } else {
-        // invalidate surface flinger again
-        Event e;
-        e.type = IDLE_ENTRY_EVENT;
-        e.nValue = count + 1;
-        postEvent(e);
-        Hwcomposer::getInstance().invalidate();
-    }
-}
-
-void DisplayAnalyzer::handleIdleExitEvent()
-{
-    DTRACE("handling idle exit event");
-
-    IPowerManager *pm = Hwcomposer::getInstance().getPowerManager();
-    pm->exitIdleState();
-    setCompositionType(0, HWC_FRAMEBUFFER, true);
-}
-
-void DisplayAnalyzer::handleVideoCheckEvent()
-{
-    // check if the first seen video layer on secondary device (HDMI/WFD) is marked as skipped
-    // it is assumed video is always skipped if the first seen video layer is skipped
-    // this is to workaround secure video layer transmitted over non secure output
-    // and HWC_SKIP_LAYER set during rotation animation.
-    mIgnoreVideoSkipFlag = false;
-
-    if (mVideoStateMap.size() != 1 ||
-        mCachedNumDisplays <= 1) {
-        return;
-    }
-
-    uint32_t videoHandles[mCachedNumDisplays];
-    for (int i = 0; i < (int)mCachedNumDisplays; i++) {
-        videoHandles[i] = 0;
-        hwc_display_contents_1_t *content = mCachedDisplays[i];
-        if (content == NULL) {
-            continue;
-        }
-        for (int j = 0; j < (int)content->numHwLayers - 1; j++) {
-            if (isVideoLayer(content->hwLayers[j])) {
-                videoHandles[i] = (uint32_t)content->hwLayers[j].handle;
-                if (i > 0) {
-                    if (videoHandles[i] == videoHandles[0]) {
-                        mIgnoreVideoSkipFlag = !(content->hwLayers[j].flags & HWC_SKIP_LAYER);
-                        ITRACE("Ignoring video HWC_SKIP_LAYER: %d on output %d", mIgnoreVideoSkipFlag, i);
-                    }
-                    return;
-                }
-                break;
-            }
-        }
-    }
-
-    if (videoHandles[0]) {
-        WTRACE("Video is on the primary panel only");
-        return;
-    }
-
-    // video state map indicates video session is active and there is secondary
-    // display, need to continue checking as video is not found in the buffers yet
-    Event e;
-    e.type = VIDEO_CHECK_EVENT;
-    postEvent(e);
-}
-
-void DisplayAnalyzer::enterVideoExtMode()
-{
-    if (mVideoExtModeActive) {
-        WTRACE("already in video extended mode.");
-        return;
-    }
-
-    ITRACE("entering video extended mode...");
-    mVideoExtModeActive = true;
-    Hwcomposer::getInstance().getVsyncManager()->resetVsyncSource();
-
-    setCompositionType(0, HWC_OVERLAY, true);
-
-    // Do not power off primary display immediately as flip is asynchronous
-    Event e;
-    e.type = DPMS_EVENT;
-    e.nValue = 0;
-    postEvent(e);
-    Hwcomposer::getInstance().invalidate();
-}
-
-void DisplayAnalyzer::exitVideoExtMode()
-{
-    if (!mVideoExtModeActive) {
-        WTRACE("Not in video extended mode");
-        return;
-    }
-
-    ITRACE("exiting video extended mode...");
-
-    mVideoExtModeActive = false;
-
-    Hwcomposer::getInstance().getDrm()->setDpmsMode(
-        IDisplayDevice::DEVICE_PRIMARY,
-        IDisplayDevice::DEVICE_DISPLAY_ON);
-
-    Hwcomposer::getInstance().getVsyncManager()->resetVsyncSource();
-
-    setCompositionType(0, HWC_FRAMEBUFFER, true);
-}
-
-bool DisplayAnalyzer::isPresentationLayer(hwc_layer_1_t &layer)
-{
-    if (layer.handle == NULL) {
-        return false;
-    }
-    if (mCachedDisplays == NULL) {
-        return false;
-    }
-    // check if the given layer exists in the primary device
-    hwc_display_contents_1_t *content = mCachedDisplays[0];
-    if (content == NULL) {
-        return false;
-    }
-    for (size_t i = 0; i < content->numHwLayers - 1; i++) {
-        if ((uint32_t)content->hwLayers[i].handle == (uint32_t)layer.handle) {
-            VTRACE("Layer exists for Primary device");
-            return false;
-        }
-    }
-    return true;
-}
-
-bool DisplayAnalyzer::hasVideoLayer(int device)
-{
-    DataBuffer * buffer = NULL;
-    hwc_display_contents_1_t *content = NULL;
-
-    if (mCachedDisplays == NULL) {
-        return false;
-    }
-
-    content = mCachedDisplays[device];
-    if (content == NULL) {
-        return false;
-    }
-
-    for (size_t i = 0; i < content->numHwLayers - 1; i++) {
-        if (isVideoLayer(content->hwLayers[i]))
-            return true;
-    }
-
-    return false;
-}
-
-bool DisplayAnalyzer::hasProtectedLayer()
-{
-    DataBuffer * buffer = NULL;
-    hwc_display_contents_1_t *content = NULL;
-    BufferManager *bm = Hwcomposer::getInstance().getBufferManager();
-
-    if (bm == NULL){
-        return false;
-    }
-
-    if (mCachedDisplays == NULL) {
-        return false;
-    }
-    // check if the given layer exists in the primary device
-    for (int index = 0; index < (int)mCachedNumDisplays; index++) {
-        content = mCachedDisplays[index];
-        if (content == NULL) {
-            continue;
-        }
-
-        for (size_t i = 0; i < content->numHwLayers - 1; i++) {
-            if (isProtectedLayer(content->hwLayers[i]))
-                return true;
-        }
-    }
-
-    return false;
-}
-
-bool DisplayAnalyzer::isProtectedLayer(hwc_layer_1_t &layer)
-{
-    if (!layer.handle) {
-        return false;
-    }
-    bool ret = false;
-    BufferManager *bm = Hwcomposer::getInstance().getBufferManager();
-    DataBuffer *buffer = bm->lockDataBuffer((uint32_t)layer.handle);
-    if (!buffer) {
-        ETRACE("failed to get buffer");
-    } else {
-        ret = GraphicBuffer::isProtectedBuffer((GraphicBuffer*)buffer);
-        bm->unlockDataBuffer(buffer);
-    }
-    return ret;
-}
-
-bool DisplayAnalyzer::ignoreVideoSkipFlag()
-{
-    return mIgnoreVideoSkipFlag;
-}
-
 void DisplayAnalyzer::setCompositionType(hwc_display_contents_1_t *display, int type)
 {
     for (size_t i = 0; i < display->numHwLayers - 1; i++) {
@@ -914,13 +136,6 @@
     setCompositionType(content, type);
 }
 
-int DisplayAnalyzer::getFirstVideoInstanceSessionID() {
-    if (mVideoStateMap.size() >= 1) {
-        return mVideoStateMap.keyAt(0);
-    }
-    return -1;
-}
-
 } // namespace intel
 } // namespace android
 
diff --git a/common/base/DisplayAnalyzer.h b/common/base/DisplayAnalyzer.h
index d0a3a42..239cd0a 100755
--- a/common/base/DisplayAnalyzer.h
+++ b/common/base/DisplayAnalyzer.h
@@ -33,115 +33,35 @@
     bool initialize();
     void deinitialize();
     void analyzeContents(size_t numDisplays, hwc_display_contents_1_t** displays);
-    bool isVideoExtModeActive();
-    bool isVideoExtModeEnabled();
-    bool isVideoLayer(hwc_layer_1_t &layer);
-    bool isVideoFullScreen(int device, hwc_layer_1_t &layer);
-    bool isOverlayAllowed();
-    int  getVideoInstances();
     void postHotplugEvent(bool connected);
-    void postVideoEvent(int instanceID, int state);
-    void postInputEvent(bool active);
-    void postVideoEvent(int instances, int instanceID, bool preparing, bool playing);
-    void postBlankEvent(bool blank);
-    void postIdleEntryEvent();
-    bool isPresentationLayer(hwc_layer_1_t &layer);
-    bool isProtectedLayer(hwc_layer_1_t &layer);
-    bool ignoreVideoSkipFlag();
-    int  getFirstVideoInstanceSessionID();
 
 private:
     enum DisplayEventType {
         HOTPLUG_EVENT,
-        BLANK_EVENT,
-        VIDEO_EVENT,
-        TIMING_EVENT,
-        INPUT_EVENT,
-        DPMS_EVENT,
-        IDLE_ENTRY_EVENT,
-        IDLE_EXIT_EVENT,
-        VIDEO_CHECK_EVENT,
     };
 
     struct Event {
         int type;
 
-        struct VideoEvent {
-            int instanceID;
-            int state;
-        };
-
         union {
             bool bValue;
             int  nValue;
-            VideoEvent videoEvent;
         };
     };
     inline void postEvent(Event& e);
     inline bool getEvent(Event& e);
     void handlePendingEvents();
     void handleHotplugEvent(bool connected);
-    void handleBlankEvent(bool blank);
-    void handleVideoEvent(int instanceID, int state);
-    void handleTimingEvent();
-    void handleInputEvent(bool active);
-    void handleDpmsEvent(int delayCount);
-    void handleIdleEntryEvent(int count);
-    void handleIdleExitEvent();
-    void handleVideoCheckEvent();
-
-    void blankSecondaryDevice();
-    void handleVideoExtMode();
-    void checkVideoExtMode();
-    void enterVideoExtMode();
-    void exitVideoExtMode();
-    bool hasProtectedLayer();
-    bool hasVideoLayer(int device);
     inline void setCompositionType(hwc_display_contents_1_t *content, int type);
     inline void setCompositionType(int device, int type, bool reset);
 
-private:
-    // Video playback state, must match defintion in Multi Display Service
-    enum
-    {
-        VIDEO_PLAYBACK_IDLE,
-        VIDEO_PLAYBACK_STARTING,
-        VIDEO_PLAYBACK_STARTED,
-        VIDEO_PLAYBACK_STOPPING,
-        VIDEO_PLAYBACK_STOPPED,
-    };
-
-    enum
-    {
-        // number of idle flips before display can enter idle mode
-        // we can set maxfifo even with more than one plane is active,
-        // display controller will check whether condition is met to
-        // enter into maxfifo, so no need to delay.
-        DELAY_BEFORE_IDLE_ENTRY = 0,
-
-        // number of flips before display can be powered off in video extended mode
-        DELAY_BEFORE_DPMS_OFF = 0,
-    };
 
 private:
     bool mInitialized;
-    bool mVideoExtModeEnabled;
-    bool mVideoExtModeEligible;
-    bool mVideoExtModeActive;
-    bool mBlankDevice;
-    bool mOverlayAllowed;
-    bool mActiveInputState;
-    // workaround HWC_SKIP_LAYER set during rotation for extended video mode
-    // by default if layer has HWC_SKIP_LAYER flag it should not be processed by HWC
-    bool mIgnoreVideoSkipFlag;
-    bool mProtectedVideoSession;
-    // map video instance ID to video state
-    KeyedVector<int, int> mVideoStateMap;
     int mCachedNumDisplays;
     hwc_display_contents_1_t** mCachedDisplays;
     Vector<Event> mPendingEvents;
     Mutex mEventMutex;
-    Condition mEventHandledCondition;
 };
 
 } // namespace intel
diff --git a/common/base/HwcLayer.cpp b/common/base/HwcLayer.cpp
old mode 100644
new mode 100755
index c8216a1..2596d41
--- a/common/base/HwcLayer.cpp
+++ b/common/base/HwcLayer.cpp
@@ -276,17 +276,6 @@
     mUpdated = false;
     if (mPlane) {
         mPlane->postFlip();
-
-        // flip frame buffer target once in video extended mode to refresh screen,
-        // then mark type as LAYER_SKIPPED so it will not be flipped again.
-        // by doing this pipe for primary device can enter idle state
-        if (mDevice == IDisplayDevice::DEVICE_PRIMARY &&
-            mType == LAYER_FRAMEBUFFER_TARGET &&
-            (Hwcomposer::getInstance().getDisplayAnalyzer()->isVideoExtModeActive() ||
-            Hwcomposer::getInstance().getPowerManager()->getIdleReady())) {
-            DTRACE("Skipping frame buffer target...");
-            mType = LAYER_SKIPPED;
-        }
     }
 }
 
diff --git a/common/base/HwcLayerList.cpp b/common/base/HwcLayerList.cpp
old mode 100644
new mode 100755
index 893037d..520dc62
--- a/common/base/HwcLayerList.cpp
+++ b/common/base/HwcLayerList.cpp
@@ -154,8 +154,7 @@
             mFBLayers.add(hwcLayer);
             if (checkSupported(DisplayPlane::PLANE_SPRITE, hwcLayer)) {
                 mSpriteCandidates.add(hwcLayer);
-            } else if (hwc.getDisplayAnalyzer()->isOverlayAllowed() &&
-                checkSupported(DisplayPlane::PLANE_OVERLAY, hwcLayer)) {
+            } else if (checkSupported(DisplayPlane::PLANE_OVERLAY, hwcLayer)) {
                 mOverlayCandidates.add(hwcLayer);
             } else {
                 // noncandidate layer
diff --git a/common/base/Hwcomposer.cpp b/common/base/Hwcomposer.cpp
old mode 100644
new mode 100755
index 4191a3c..c6f0726
--- a/common/base/Hwcomposer.cpp
+++ b/common/base/Hwcomposer.cpp
@@ -30,10 +30,7 @@
       mBufferManager(0),
       mDisplayAnalyzer(0),
       mDisplayContext(0),
-      mVsyncManager(0),
-      mMultiDisplayObserver(0),
       mUeventObserver(0),
-      mPowerManager(0),
       mInitialized(false)
 {
     CTRACE();
@@ -149,7 +146,21 @@
 {
     RETURN_FALSE_IF_NOT_INIT();
     ATRACE("disp = %d, enabled = %d", disp, enabled);
-    return mVsyncManager->handleVsyncControl(disp, enabled ? true : false);
+
+    if (disp < 0 || disp >= IDisplayDevice::DEVICE_COUNT) {
+        ETRACE("invalid disp %d", disp);
+        return false;
+    }
+    if (disp >= (int) mDisplayDevices.size()) {
+        return false;
+    }
+    IDisplayDevice *device = mDisplayDevices.itemAt(disp);
+    if (!device) {
+        ETRACE("no device found");
+        return false;
+    }
+
+    return device->vsyncControl(enabled ? true : false);
 }
 
 bool Hwcomposer::blank(int disp, int blank)
@@ -253,14 +264,10 @@
     }
 }
 
-void Hwcomposer::hotplug(int disp, bool connected)
+void Hwcomposer::hotplug(__attribute__((unused))int disp, bool connected)
 {
     RETURN_VOID_IF_NOT_INIT();
 
-    // TODO: Two fake hotplug events are sent during mode setting. To avoid
-    // unnecessary audio switch, real connection status should be sent to MDS
-    mMultiDisplayObserver->notifyHotPlug(mDrm->isConnected(disp));
-
 #ifndef INTEL_SUPPORT_HDMI_PRIMARY
     if (mProcs && mProcs->hotplug) {
         DTRACE("report hotplug on disp %d, connected %d", disp, connected);
@@ -352,11 +359,6 @@
         DEINIT_AND_RETURN_FALSE("failed to create display context");
     }
 
-    mPowerManager = createPowerManager();
-    if (!mPowerManager || !mPowerManager->initialize()) {
-        DEINIT_AND_RETURN_FALSE("failed to initialize power manager");
-    }
-
     mUeventObserver = new UeventObserver();
     if (!mUeventObserver || !mUeventObserver->initialize()) {
         DEINIT_AND_RETURN_FALSE("failed to initialize uevent observer");
@@ -373,21 +375,11 @@
         mDisplayDevices.insertAt(device, i, 1);
     }
 
-    mVsyncManager = new VsyncManager(mDisplayDevices);
-    if (!mVsyncManager || !mVsyncManager->initialize()) {
-        DEINIT_AND_RETURN_FALSE("failed to create Vsync Manager");
-    }
-
     mDisplayAnalyzer = new DisplayAnalyzer();
     if (!mDisplayAnalyzer || !mDisplayAnalyzer->initialize()) {
         DEINIT_AND_RETURN_FALSE("failed to initialize display analyzer");
     }
 
-    mMultiDisplayObserver = new MultiDisplayObserver();
-    if (!mMultiDisplayObserver || !mMultiDisplayObserver->initialize()) {
-        DEINIT_AND_RETURN_FALSE("failed to initialize display observer");
-    }
-
     // all initialized, starting uevent observer
     mUeventObserver->start();
 
@@ -397,10 +389,7 @@
 
 void Hwcomposer::deinitialize()
 {
-    DEINIT_AND_DELETE_OBJ(mMultiDisplayObserver);
     DEINIT_AND_DELETE_OBJ(mDisplayAnalyzer);
-    // delete mVsyncManager first as it holds reference to display devices.
-    DEINIT_AND_DELETE_OBJ(mVsyncManager);
 
     DEINIT_AND_DELETE_OBJ(mUeventObserver);
     // destroy display devices
@@ -410,7 +399,6 @@
     }
     mDisplayDevices.clear();
 
-    DEINIT_AND_DELETE_OBJ(mPowerManager);
     DEINIT_AND_DELETE_OBJ(mDisplayContext);
     DEINIT_AND_DELETE_OBJ(mPlaneManager);
     DEINIT_AND_DELETE_OBJ(mBufferManager);
@@ -443,11 +431,6 @@
     return mDisplayAnalyzer;
 }
 
-MultiDisplayObserver* Hwcomposer::getMultiDisplayObserver()
-{
-    return mMultiDisplayObserver;
-}
-
 IDisplayDevice* Hwcomposer::getDisplayDevice(int disp)
 {
     if (disp < 0 || disp >= IDisplayDevice::DEVICE_COUNT) {
@@ -460,20 +443,11 @@
     return mDisplayDevices.itemAt(disp);
 }
 
-VsyncManager* Hwcomposer::getVsyncManager()
-{
-    return mVsyncManager;
-}
-
 UeventObserver* Hwcomposer::getUeventObserver()
 {
     return mUeventObserver;
 }
 
-IPowerManager* Hwcomposer::getPowerManager()
-{
-    return mPowerManager;
-}
 
 } // namespace intel
 } // namespace android
diff --git a/common/base/VsyncManager.cpp b/common/base/VsyncManager.cpp
deleted file mode 100644
index e2717a3..0000000
--- a/common/base/VsyncManager.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#include <common/utils/HwcTrace.h>
-#include <IDisplayDevice.h>
-#include <DisplayQuery.h>
-#include <BufferManager.h>
-#include <DisplayPlaneManager.h>
-#include <Hwcomposer.h>
-#include <common/base/VsyncManager.h>
-
-
-namespace android {
-namespace intel {
-
-VsyncManager::VsyncManager(Vector<IDisplayDevice*>& devices)
-    : mDevices(devices),
-      mInitialized(false),
-      mEnableDynamicVsync(true),
-      mEnabled(false),
-      mVsyncSource(IDisplayDevice::DEVICE_COUNT),
-      mLock()
-{
-}
-
-VsyncManager::~VsyncManager()
-{
-    WARN_IF_NOT_DEINIT();
-}
-
-bool VsyncManager::initialize()
-{
-    mEnabled = false;
-    mVsyncSource = IDisplayDevice::DEVICE_COUNT;
-    mEnableDynamicVsync = !scUsePrimaryVsyncOnly;
-    mInitialized = true;
-    return true;
-}
-
-void VsyncManager::deinitialize()
-{
-    if (mEnabled) {
-        WTRACE("vsync is still enabled");
-    }
-
-    mVsyncSource = IDisplayDevice::DEVICE_COUNT;
-    mEnabled = false;
-    mEnableDynamicVsync = !scUsePrimaryVsyncOnly;
-    mInitialized = false;
-}
-
-bool VsyncManager::handleVsyncControl(int disp, bool enabled)
-{
-    Mutex::Autolock l(mLock);
-
-    if (disp != IDisplayDevice::DEVICE_PRIMARY) {
-        WTRACE("vsync control on non-primary device %d", disp);
-        return false;
-    }
-
-    if (mEnabled == enabled) {
-        WTRACE("vsync state %d is not changed", enabled);
-        return true;
-    }
-
-    if (!enabled) {
-        disableVsync();
-        mEnabled = false;
-        return true;
-    } else {
-        mEnabled = enableVsync(getCandidate());
-        return mEnabled;
-    }
-
-    return false;
-}
-
-void VsyncManager::resetVsyncSource()
-{
-    Mutex::Autolock l(mLock);
-
-    if (!mEnableDynamicVsync) {
-        ITRACE("dynamic vsync source switch is not supported");
-        return;
-    }
-
-    if (!mEnabled) {
-        return;
-    }
-
-    int vsyncSource = getCandidate();
-    if (vsyncSource == mVsyncSource) {
-        return;
-    }
-
-    disableVsync();
-    enableVsync(vsyncSource);
-}
-
-int VsyncManager::getVsyncSource()
-{
-    return mVsyncSource;
-}
-
-void VsyncManager::enableDynamicVsync(bool enable)
-{
-    Mutex::Autolock l(mLock);
-    if (scUsePrimaryVsyncOnly) {
-        WTRACE("dynamic vsync is not supported");
-        return;
-    }
-
-    mEnableDynamicVsync = enable;
-
-    if (!mEnabled) {
-        return;
-    }
-
-    int vsyncSource = getCandidate();
-    if (vsyncSource == mVsyncSource) {
-        return;
-    }
-
-    disableVsync();
-    enableVsync(vsyncSource);
-}
-
-int VsyncManager::getCandidate()
-{
-    if (!mEnableDynamicVsync) {
-        return IDisplayDevice::DEVICE_PRIMARY;
-    }
-
-    IDisplayDevice *device = NULL;
-    // use HDMI vsync when connected
-    device = mDevices.itemAt(IDisplayDevice::DEVICE_EXTERNAL);
-    if (device && device->isConnected()) {
-        return IDisplayDevice::DEVICE_EXTERNAL;
-    }
-
-#ifdef INTEL_WIDI_MERRIFIELD
-    // use vsync from virtual display when video extended mode is entered
-    if (Hwcomposer::getInstance().getDisplayAnalyzer()->isVideoExtModeActive()) {
-        device = mDevices.itemAt(IDisplayDevice::DEVICE_VIRTUAL);
-        if (device && device->isConnected()) {
-            return IDisplayDevice::DEVICE_VIRTUAL;
-        }
-        WTRACE("Could not use vsync from secondary device");
-    }
-#endif
-    return IDisplayDevice::DEVICE_PRIMARY;
-}
-
-bool VsyncManager::enableVsync(int candidate)
-{
-    if (mVsyncSource != IDisplayDevice::DEVICE_COUNT) {
-        WTRACE("vsync has been enabled on %d", mVsyncSource);
-        return true;
-    }
-
-    IDisplayDevice *device = mDevices.itemAt(candidate);
-    if (!device) {
-        ETRACE("invalid vsync source candidate %d", candidate);
-        return false;
-    }
-
-    if (device->vsyncControl(true)) {
-        mVsyncSource = candidate;
-        return true;
-    }
-
-    if (candidate != IDisplayDevice::DEVICE_PRIMARY) {
-        WTRACE("failed to enable vsync on display %d, fall back to primary", candidate);
-        device = mDevices.itemAt(IDisplayDevice::DEVICE_PRIMARY);
-        if (device && device->vsyncControl(true)) {
-            mVsyncSource = IDisplayDevice::DEVICE_PRIMARY;
-            return true;
-        }
-    }
-    ETRACE("failed to enable vsync on the primary display");
-    return false;
-}
-
-void VsyncManager::disableVsync()
-{
-    if (mVsyncSource == IDisplayDevice::DEVICE_COUNT) {
-        WTRACE("vsync has been disabled");
-        return;
-    }
-
-    IDisplayDevice *device = mDevices.itemAt(mVsyncSource);
-    if (device && !device->vsyncControl(false)) {
-        WTRACE("failed to disable vsync on device %d", mVsyncSource);
-    }
-    mVsyncSource = IDisplayDevice::DEVICE_COUNT;
-}
-
-} // namespace intel
-} // namespace android
-
diff --git a/common/base/VsyncManager.h b/common/base/VsyncManager.h
deleted file mode 100644
index bd189dc..0000000
--- a/common/base/VsyncManager.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef VSYNC_MANAGER_H
-#define VSYNC_MANAGER_H
-
-#include <IDisplayDevice.h>
-#include <utils/threads.h>
-
-namespace android {
-namespace intel {
-
-
-class VsyncManager {
-public:
-    VsyncManager(Vector<IDisplayDevice*>& devices);
-    virtual ~VsyncManager();
-
-public:
-    bool initialize();
-    void deinitialize();
-    bool handleVsyncControl(int disp, bool enabled);
-    void resetVsyncSource();
-    int getVsyncSource();
-    void enableDynamicVsync(bool enable);
-
-private:
-    inline int getCandidate();
-    inline bool enableVsync(int candidate);
-    inline void disableVsync();
-
-private:
-    Vector<IDisplayDevice*>& mDevices;
-    bool mInitialized;
-    bool mEnableDynamicVsync;
-    bool mEnabled;
-    int  mVsyncSource;
-    Mutex mLock;
-
-private:
-    // toggle this constant to use primary vsync only or enable dynamic vsync.
-    static const bool scUsePrimaryVsyncOnly = false;
-};
-
-} // namespace intel
-} // namespace android
-
-
-
-#endif /* VSYNC_MANAGER_H */
diff --git a/common/devices/ExternalDevice.cpp b/common/devices/ExternalDevice.cpp
index 7893e82..b81b8b6 100755
--- a/common/devices/ExternalDevice.cpp
+++ b/common/devices/ExternalDevice.cpp
@@ -184,21 +184,11 @@
 
 void ExternalDevice::HdcpLinkStatusListener(bool success)
 {
-    if (!success) {
-        ETRACE("HDCP is not authenticated, disabling dynamic vsync");
-        mHwc.getVsyncManager()->enableDynamicVsync(false);
-    }
-
     if (mHotplugEventPending) {
         DTRACE("HDCP authentication status %d, sending hotplug event...", success);
         mHwc.hotplug(mType, mConnected);
         mHotplugEventPending = false;
     }
-
-    if (success) {
-        ITRACE("HDCP authenticated, enabling dynamic vsync");
-        mHwc.getVsyncManager()->enableDynamicVsync(true);
-    }
 }
 
 void ExternalDevice::hotplugEventListener(void *data)
@@ -237,7 +227,6 @@
 
     if (mConnected == false) {
         mHotplugEventPending = false;
-        mHwc.getVsyncManager()->resetVsyncSource();
         mHdcpControl->stopHdcp();
         mHwc.hotplug(mType, mConnected);
     } else {
@@ -284,15 +273,12 @@
 
     ITRACE("changing refresh rate from %d to %d", mode.vrefresh, hz);
 
-    mHwc.getVsyncManager()->enableDynamicVsync(false);
-
     mHdcpControl->stopHdcp();
 
     drm->setRefreshRate(IDisplayDevice::DEVICE_EXTERNAL, hz);
 
     mHotplugEventPending = false;
     mHdcpControl->startHdcpAsync(HdcpLinkStatusListener, this);
-    mHwc.getVsyncManager()->enableDynamicVsync(true);
 }
 
 
diff --git a/common/devices/PhysicalDevice.cpp b/common/devices/PhysicalDevice.cpp
index 497c344..e6f0aaa 100755
--- a/common/devices/PhysicalDevice.cpp
+++ b/common/devices/PhysicalDevice.cpp
@@ -27,7 +27,6 @@
       mDisplayPlaneManager(dpm),
       mActiveDisplayConfig(-1),
       mBlankControl(NULL),
-      mPrepareListener(NULL),
       mVsyncObserver(NULL),
       mLayerList(NULL),
       mConnected(false),
@@ -364,12 +363,6 @@
         DEINIT_AND_RETURN_FALSE("failed to create blank control");
     }
 
-    // create hwc prepare listener
-    mPrepareListener = createPrepareListener();
-    if (!mPrepareListener) {
-        DEINIT_AND_RETURN_FALSE("failed to create prepare listener");
-    }
-
     // create vsync event observer
     mVsyncObserver = new VsyncEventObserver(*this);
     if (!mVsyncObserver || !mVsyncObserver->initialize()) {
@@ -394,11 +387,6 @@
         mBlankControl = 0;
     }
 
-    if (mPrepareListener) {
-        delete mPrepareListener;
-        mPrepareListener = 0;
-    }
-
     // remove configs
     removeDisplayConfigs();
 
diff --git a/common/devices/PrimaryDevice.cpp b/common/devices/PrimaryDevice.cpp
old mode 100644
new mode 100755
index 8215600..62a573c
--- a/common/devices/PrimaryDevice.cpp
+++ b/common/devices/PrimaryDevice.cpp
@@ -39,16 +39,6 @@
         DEINIT_AND_RETURN_FALSE("failed to initialize physical device");
     }
 
-    UeventObserver *observer = Hwcomposer::getInstance().getUeventObserver();
-    if (observer) {
-        observer->registerListener(
-            DrmConfig::getRepeatedFrameString(),
-            repeatedFrameEventListener,
-            this);
-    } else {
-        ETRACE("Uevent observer is NULL");
-    }
-
     return true;
 }
 
@@ -57,34 +47,11 @@
     PhysicalDevice::deinitialize();
 }
 
-
-void PrimaryDevice::repeatedFrameEventListener(void *data)
-{
-    PrimaryDevice *pThis = (PrimaryDevice*)data;
-    if (pThis) {
-        pThis->repeatedFrameListener();
-    }
-}
-
-void PrimaryDevice::repeatedFrameListener()
-{
-    Hwcomposer::getInstance().getDisplayAnalyzer()->postIdleEntryEvent();
-    Hwcomposer::getInstance().invalidate();
-}
-
 bool PrimaryDevice::blank(bool blank)
 {
     if (!mConnected)
         return true;
 
-    // control of repeated frames
-    IPowerManager *pm = Hwcomposer::getInstance().getPowerManager();
-    if (!blank) {
-        pm->enableIdleControl();
-    } else {
-        pm->disableIdleControl();
-    }
-
     return PhysicalDevice::blank(blank);
 }
 
diff --git a/common/devices/VirtualDevice.cpp b/common/devices/VirtualDevice.cpp
deleted file mode 100755
index 215ca6f..0000000
--- a/common/devices/VirtualDevice.cpp
+++ /dev/null
@@ -1,1820 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <Hwcomposer.h>
-#include <DisplayPlaneManager.h>
-#include <DisplayQuery.h>
-#include <VirtualDevice.h>
-#include <common/observers/SoftVsyncObserver.h>
-
-#include <binder/IServiceManager.h>
-#include <binder/ProcessState.h>
-
-#include <hal_public.h>
-#include <sync/sw_sync.h>
-#include <sync/sync.h>
-
-#include <va/va_android.h>
-#include <va/va_vpp.h>
-#include <va/va_tpi.h>
-
-#define NUM_CSC_BUFFERS 6
-
-#define QCIF_WIDTH 176
-#define QCIF_HEIGHT 144
-
-namespace android {
-namespace intel {
-
-static const bool VSP_FOR_CLEAR_VIDEO = false; // debug feature
-
-static void my_close_fence(const char* func, const char* fenceName, int& fenceFd)
-{
-    if (fenceFd != -1) {
-        VTRACE("%s: closing fence %s (fd=%d)", func, fenceName, fenceFd);
-        int err = close(fenceFd);
-        if (err < 0) {
-            ETRACE("%s: fence %s close error %d: %s", func, fenceName, err, strerror(errno));
-        }
-        fenceFd = -1;
-    }
-}
-
-static void my_sync_wait_and_close(const char* func, const char* fenceName, int& fenceFd)
-{
-    if (fenceFd != -1) {
-        VTRACE("%s: waiting on fence %s (fd=%d)", func, fenceName, fenceFd);
-        int err = sync_wait(fenceFd, 300);
-        if (err < 0) {
-            ETRACE("%s: fence %s sync_wait error %d: %s", func, fenceName, err, strerror(errno));
-        }
-        my_close_fence(func, fenceName, fenceFd);
-    }
-}
-
-static void my_timeline_inc(const char* func, const char* timelineName, int& syncTimelineFd)
-{
-    if (syncTimelineFd != -1) {
-        VTRACE("%s: incrementing timeline %s (fd=%d)", func, timelineName, syncTimelineFd);
-        int err = sw_sync_timeline_inc(syncTimelineFd, 1);
-        if (err < 0)
-            ETRACE("%s sync timeline %s increment error %d: %s", func, timelineName, errno, strerror(errno));
-        syncTimelineFd = -1;
-    }
-}
-
-#define CLOSE_FENCE(fenceName)          my_close_fence(__func__, #fenceName, fenceName)
-#define SYNC_WAIT_AND_CLOSE(fenceName)  my_sync_wait_and_close(__func__, #fenceName, fenceName)
-#define TIMELINE_INC(timelineName)      my_timeline_inc(__func__, #timelineName, timelineName)
-
-class MappedSurface {
-public:
-    MappedSurface(VADisplay dpy, VASurfaceID surf)
-        : va_dpy(dpy),
-          ptr(NULL)
-    {
-        VAStatus va_status;
-        va_status = vaDeriveImage(va_dpy, surf, &image);
-        if (va_status != VA_STATUS_SUCCESS) {
-            ETRACE("vaDeriveImage returns %08x", va_status);
-            return;
-        }
-        va_status = vaMapBuffer(va_dpy, image.buf, (void**)&ptr);
-        if (va_status != VA_STATUS_SUCCESS) {
-            ETRACE("vaMapBuffer returns %08x", va_status);
-            vaDestroyImage(va_dpy, image.image_id);
-            return;
-        }
-    }
-    ~MappedSurface() {
-        if (ptr == NULL)
-            return;
-
-        VAStatus va_status;
-
-        va_status = vaUnmapBuffer(va_dpy, image.buf);
-        if (va_status != VA_STATUS_SUCCESS) ETRACE("vaUnmapBuffer returns %08x", va_status);
-
-        va_status = vaDestroyImage(va_dpy, image.image_id);
-        if (va_status != VA_STATUS_SUCCESS) ETRACE("vaDestroyImage returns %08x", va_status);
-    }
-    bool valid() { return ptr != NULL; }
-    uint8_t* getPtr() { return ptr; }
-private:
-    VADisplay va_dpy;
-    VAImage image;
-    uint8_t* ptr;
-};
-
-class VirtualDevice::VAMappedHandle {
-public:
-    VAMappedHandle(VADisplay dpy, buffer_handle_t handle, uint32_t stride, uint32_t height, bool rgb)
-        : va_dpy(dpy),
-          surface(0)
-    {
-        int format;
-        VASurfaceAttributeTPI attribTpi;
-        memset(&attribTpi, 0, sizeof(attribTpi));
-        VTRACE("Map gralloc %p size=%ux%u", handle, stride, height);
-        attribTpi.type = VAExternalMemoryAndroidGrallocBuffer;
-        attribTpi.width = stride;
-        attribTpi.height = height;
-        if (rgb) {
-            attribTpi.size = stride*height*4;
-            attribTpi.pixel_format = VA_FOURCC_RGBA;
-            attribTpi.luma_stride = stride;
-            attribTpi.chroma_u_stride = 0;
-            attribTpi.chroma_v_stride = 0;
-            attribTpi.luma_offset = 0;
-            attribTpi.chroma_u_offset = 0;
-            attribTpi.chroma_v_offset = 0;
-            format = VA_RT_FORMAT_RGB32;
-        }
-        else {
-            attribTpi.size = stride*height*3/2;
-            attribTpi.pixel_format = VA_FOURCC_NV12;
-            attribTpi.luma_stride = stride;
-            attribTpi.chroma_u_stride = stride;
-            attribTpi.chroma_v_stride = stride;
-            attribTpi.luma_offset = 0;
-            attribTpi.chroma_u_offset = stride*height;
-            attribTpi.chroma_v_offset = stride*height+1;
-            format = VA_RT_FORMAT_YUV420;
-        }
-        attribTpi.count = 1;
-        attribTpi.buffers = (long unsigned int*) &handle;
-
-        VAStatus va_status;
-        va_status = vaCreateSurfacesWithAttribute(va_dpy,
-                    stride,
-                    height,
-                    format,
-                    1,
-                    &surface,
-                    &attribTpi);
-        if (va_status != VA_STATUS_SUCCESS) {
-            ETRACE("vaCreateSurfacesWithAttribute returns %08x, surface = %x", va_status, surface);
-            surface = 0;
-        }
-    }
-    VAMappedHandle(VADisplay dpy, uint32_t khandle, uint32_t stride, uint32_t height)
-        : va_dpy(dpy),
-          surface(0)
-    {
-        int format;
-        VASurfaceAttributeTPI attribTpi;
-        memset(&attribTpi, 0, sizeof(attribTpi));
-        VTRACE("Map khandle 0x%x size=%ux%u", khandle, stride, height);
-        attribTpi.type = VAExternalMemoryKernelDRMBufffer;
-        attribTpi.width = stride;
-        attribTpi.height = height;
-        attribTpi.size = stride*height*3/2;
-        attribTpi.pixel_format = VA_FOURCC_NV12;
-        attribTpi.luma_stride = stride;
-        attribTpi.chroma_u_stride = stride;
-        attribTpi.chroma_v_stride = stride;
-        attribTpi.luma_offset = 0;
-        attribTpi.chroma_u_offset = stride*height;
-        attribTpi.chroma_v_offset = stride*height+1;
-        format = VA_RT_FORMAT_YUV420;
-        attribTpi.count = 1;
-        attribTpi.buffers = (long unsigned int*) &khandle;
-
-        VAStatus va_status;
-        va_status = vaCreateSurfacesWithAttribute(va_dpy,
-                    stride,
-                    height,
-                    format,
-                    1,
-                    &surface,
-                    &attribTpi);
-        if (va_status != VA_STATUS_SUCCESS) {
-            ETRACE("vaCreateSurfacesWithAttribute returns %08x", va_status);
-            surface = 0;
-        }
-    }
-    ~VAMappedHandle()
-    {
-        if (surface == 0)
-            return;
-        VAStatus va_status;
-        va_status = vaDestroySurfaces(va_dpy, &surface, 1);
-        if (va_status != VA_STATUS_SUCCESS) ETRACE("vaDestroySurfaces returns %08x", va_status);
-    }
-private:
-    VADisplay va_dpy;
-public:
-    VASurfaceID surface;
-};
-
-VirtualDevice::CachedBuffer::CachedBuffer(BufferManager *mgr, uint32_t handle)
-    : manager(mgr),
-      mapper(NULL),
-      vaMappedHandle(NULL)
-{
-    DataBuffer *buffer = manager->lockDataBuffer(handle);
-    mapper = manager->map(*buffer);
-    manager->unlockDataBuffer(buffer);
-}
-
-VirtualDevice::CachedBuffer::~CachedBuffer()
-{
-    if (vaMappedHandle != NULL)
-        delete vaMappedHandle;
-    manager->unmap(mapper);
-}
-
-VirtualDevice::HeldCscBuffer::HeldCscBuffer(const sp<VirtualDevice>& vd, uint32_t grallocHandle)
-    : vd(vd),
-      handle(grallocHandle)
-{
-}
-
-VirtualDevice::HeldCscBuffer::~HeldCscBuffer()
-{
-    Mutex::Autolock _l(vd->mCscLock);
-    BufferManager* mgr = vd->mHwc.getBufferManager();
-    DataBuffer* dataBuf = mgr->lockDataBuffer(handle);
-    uint32_t bufWidth = dataBuf->getWidth();
-    uint32_t bufHeight = dataBuf->getHeight();
-    mgr->unlockDataBuffer(dataBuf);
-    if (bufWidth == vd->mCscWidth && bufHeight == vd->mCscHeight) {
-        VTRACE("Pushing back the handle %d to mAvailableCscBuffers", handle);
-        vd->mAvailableCscBuffers.push_back(handle);
-    } else {
-        VTRACE("Deleting the gralloc buffer associated with handle (%d)", handle);
-        mgr->freeGrallocBuffer(handle);
-        vd->mCscBuffersToCreate++;
-    }
-}
-
-VirtualDevice::HeldDecoderBuffer::HeldDecoderBuffer(const sp<VirtualDevice>& vd, const android::sp<CachedBuffer>& cachedBuffer)
-    : vd(vd),
-      cachedBuffer(cachedBuffer)
-{
-    if (!vd->mPayloadManager->setRenderStatus(cachedBuffer->mapper, true)) {
-        ETRACE("Failed to set render status");
-    }
-}
-
-VirtualDevice::HeldDecoderBuffer::~HeldDecoderBuffer()
-{
-    if (!vd->mPayloadManager->setRenderStatus(cachedBuffer->mapper, false)) {
-        ETRACE("Failed to set render status");
-    }
-}
-
-struct VirtualDevice::Task : public RefBase {
-    virtual void run(VirtualDevice& vd) = 0;
-    virtual ~Task() {}
-};
-
-struct VirtualDevice::RenderTask : public VirtualDevice::Task {
-    RenderTask() : successful(false) { }
-    virtual void run(VirtualDevice& vd) = 0;
-    bool successful;
-};
-
-struct VirtualDevice::ComposeTask : public VirtualDevice::RenderTask {
-    ComposeTask()
-        : yuvAcquireFenceFd(-1),
-          rgbAcquireFenceFd(-1),
-          outbufAcquireFenceFd(-1),
-          syncTimelineFd(-1) { }
-
-    virtual ~ComposeTask() {
-        // If queueCompose() creates this object and sets up fences,
-        // but aborts before enqueuing the task, or if the task runs
-        // but errors out, make sure our acquire fences get closed
-        // and any release fences get signaled.
-        CLOSE_FENCE(yuvAcquireFenceFd);
-        CLOSE_FENCE(rgbAcquireFenceFd);
-        CLOSE_FENCE(outbufAcquireFenceFd);
-        TIMELINE_INC(syncTimelineFd);
-    }
-
-    virtual void run(VirtualDevice& vd) {
-        VASurfaceID videoInSurface;
-
-        if (vd.va_context == 0 || vd.va_video_in == 0)
-            vd.vspEnable(outWidth, outHeight);
-
-        uint32_t videoKhandle;
-        uint32_t videoWidth;
-        uint32_t videoHeight;
-        uint32_t videoStride;
-        uint32_t videoBufHeight;
-
-        if (videoMetadata.scaling_khandle != 0) {
-            videoKhandle = videoMetadata.scaling_khandle;
-            videoWidth = videoMetadata.scaling_width;
-            videoHeight = videoMetadata.scaling_height;
-            videoStride = videoMetadata.scaling_luma_stride;
-            videoBufHeight = (videoHeight+0x1f) & ~0x1f;
-        }
-        else {
-            videoKhandle = videoMetadata.kHandle;
-            videoWidth = videoMetadata.width;
-            videoHeight = videoMetadata.height;
-            videoStride = videoMetadata.lumaStride;
-            videoBufHeight = videoMetadata.height;
-        }
-
-        SYNC_WAIT_AND_CLOSE(yuvAcquireFenceFd);
-
-        if (displayFrame.left == 0 && displayFrame.top == 0 &&
-            displayFrame.right == outWidth && displayFrame.bottom == outHeight &&
-            videoStride == (uint32_t)outWidth && videoHeight == (uint32_t)outHeight) {
-            // direct use is possible
-            if (videoCachedBuffer->vaMappedHandle == NULL) {
-                videoCachedBuffer->vaMappedHandle = new VAMappedHandle(vd.va_dpy, videoKhandle, videoStride, videoBufHeight);
-            }
-            videoInSurface = videoCachedBuffer->vaMappedHandle->surface;
-        }
-        else {
-            // must copy video into the displayFrame rect of a blank buffer
-            // with the same dimensions as the RGB buffer
-            {
-                VAMappedHandle originalInputVideoHandle(vd.va_dpy, videoKhandle, videoStride, videoBufHeight);
-                MappedSurface origianlInputVideoSurface(vd.va_dpy, originalInputVideoHandle.surface);
-                uint8_t* srcPtr = origianlInputVideoSurface.getPtr();
-                if (srcPtr == NULL) {
-                    ETRACE("Couldn't map input video");
-                    return;
-                }
-                MappedSurface tmpInputVideoHandle(vd.va_dpy, vd.va_video_in);
-                uint8_t* destPtr = tmpInputVideoHandle.getPtr();
-                if (destPtr == NULL) {
-                    ETRACE("Couldn't map temp video surface");
-                    return;
-                }
-                vd.copyVideo(srcPtr, videoWidth, videoBufHeight, videoStride,
-                             destPtr, outWidth, outHeight,
-                             displayFrame.left, displayFrame.top,
-                             displayFrame.right - displayFrame.left, displayFrame.bottom - displayFrame.top);
-            }
-            vaSyncSurface(vd.va_dpy, vd.va_video_in);
-            videoInSurface = vd.va_video_in;
-        }
-        if (videoInSurface == 0) {
-            ETRACE("Couldn't map video");
-            return;
-        }
-        VTRACE("handle=%p khandle=%x va_surface=%x size=%ux%u crop=%ux%u",
-              videoHandle, videoMetadata.kHandle, videoInSurface,
-              videoMetadata.lumaStride, videoMetadata.height,
-              videoMetadata.crop_width, videoMetadata.crop_height);
-        VTRACE("scaling_khandle=%x size=%ux%u crop=%ux%u",
-              videoMetadata.scaling_khandle,
-              videoMetadata.scaling_luma_stride, videoMetadata.scaling_height,
-              videoMetadata.scaling_width, videoMetadata.scaling_height);
-
-        SYNC_WAIT_AND_CLOSE(rgbAcquireFenceFd);
-        SYNC_WAIT_AND_CLOSE(outbufAcquireFenceFd);
-
-        VAMappedHandle mappedRgbIn(vd.va_dpy, rgbHandle, outWidth, outHeight, true);
-        if (mappedRgbIn.surface == 0) {
-            ETRACE("Unable to map RGB surface");
-            return;
-        }
-        VAMappedHandle mappedVideoOut(vd.va_dpy, outputHandle, outWidth, outHeight, false);
-        if (mappedVideoOut.surface == 0) {
-            ETRACE("Unable to map outbuf");
-            return;
-        }
-
-        vd.vspCompose(videoInSurface, mappedRgbIn.surface, mappedVideoOut.surface);
-        TIMELINE_INC(syncTimelineFd);
-        successful = true;
-    }
-    buffer_handle_t videoHandle;
-    hwc_rect_t displayFrame;
-    buffer_handle_t rgbHandle;
-    buffer_handle_t outputHandle;
-    int32_t outWidth;
-    int32_t outHeight;
-    sp<CachedBuffer> videoCachedBuffer;
-    sp<RefBase> heldVideoBuffer;
-    IVideoPayloadManager::MetaData videoMetadata;
-    int yuvAcquireFenceFd;
-    int rgbAcquireFenceFd;
-    int outbufAcquireFenceFd;
-    int syncTimelineFd;
-};
-
-struct VirtualDevice::DisableVspTask : public VirtualDevice::Task {
-    virtual void run(VirtualDevice& vd) {
-        vd.vspDisable();
-    }
-};
-
-struct VirtualDevice::BlitTask : public VirtualDevice::RenderTask {
-    BlitTask()
-        : srcAcquireFenceFd(-1),
-          destAcquireFenceFd(-1) { }
-
-    virtual ~BlitTask()
-    {
-        // If queueColorConvert() creates this object and sets up fences,
-        // but aborts before enqueuing the task, or if the task runs
-        // but errors out, make sure our acquire fences get closed
-        // and any release fences get signaled.
-        CLOSE_FENCE(srcAcquireFenceFd);
-        CLOSE_FENCE(destAcquireFenceFd);
-        TIMELINE_INC(syncTimelineFd);
-    }
-
-    virtual void run(VirtualDevice& vd) {
-        SYNC_WAIT_AND_CLOSE(srcAcquireFenceFd);
-        SYNC_WAIT_AND_CLOSE(destAcquireFenceFd);
-        BufferManager* mgr = vd.mHwc.getBufferManager();
-        if (!(mgr->convertRGBToNV12((uint32_t)srcHandle, (uint32_t)destHandle, cropInfo, 0))) {
-            ETRACE("color space conversion from RGB to NV12 failed");
-        }
-        else
-            successful = true;
-        TIMELINE_INC(syncTimelineFd);
-    }
-    buffer_handle_t srcHandle;
-    buffer_handle_t destHandle;
-    int srcAcquireFenceFd;
-    int destAcquireFenceFd;
-    int syncTimelineFd;
-    crop_t cropInfo;
-};
-
-struct VirtualDevice::FrameTypeChangedTask : public VirtualDevice::Task {
-    virtual void run(VirtualDevice& vd) {
-        typeChangeListener->frameTypeChanged(inputFrameInfo);
-        ITRACE("Notify frameTypeChanged: %dx%d in %dx%d @ %d fps",
-            inputFrameInfo.contentWidth, inputFrameInfo.contentHeight,
-            inputFrameInfo.bufferWidth, inputFrameInfo.bufferHeight,
-            inputFrameInfo.contentFrameRateN);
-    }
-    sp<IFrameTypeChangeListener> typeChangeListener;
-    FrameInfo inputFrameInfo;
-};
-
-struct VirtualDevice::BufferInfoChangedTask : public VirtualDevice::Task {
-    virtual void run(VirtualDevice& vd) {
-        typeChangeListener->bufferInfoChanged(outputFrameInfo);
-        ITRACE("Notify bufferInfoChanged: %dx%d in %dx%d @ %d fps",
-            outputFrameInfo.contentWidth, outputFrameInfo.contentHeight,
-            outputFrameInfo.bufferWidth, outputFrameInfo.bufferHeight,
-            outputFrameInfo.contentFrameRateN);
-    }
-    sp<IFrameTypeChangeListener> typeChangeListener;
-    FrameInfo outputFrameInfo;
-};
-
-struct VirtualDevice::OnFrameReadyTask : public VirtualDevice::Task {
-    virtual void run(VirtualDevice& vd) {
-        if (renderTask != NULL && !renderTask->successful)
-            return;
-
-        {
-            Mutex::Autolock _l(vd.mHeldBuffersLock);
-            //Add the heldbuffer to the vector before calling onFrameReady, so that the buffer will be removed
-            //from the vector properly even if the notifyBufferReturned call acquires mHeldBuffersLock first.
-            vd.mHeldBuffers.add(handle, heldBuffer);
-        }
-
-        status_t result = frameListener->onFrameReady(handle, handleType, renderTimestamp, mediaTimestamp);
-        if (result != OK) {
-            Mutex::Autolock _l(vd.mHeldBuffersLock);
-            vd.mHeldBuffers.removeItem(handle);
-        }
-    }
-    sp<RenderTask> renderTask;
-    sp<RefBase> heldBuffer;
-    sp<IFrameListener> frameListener;
-    uint32_t handle;
-    HWCBufferHandleType handleType;
-    int64_t renderTimestamp;
-    int64_t mediaTimestamp;
-};
-
-VirtualDevice::VirtualDevice(Hwcomposer& hwc, DisplayPlaneManager& dpm)
-    : mProtectedMode(false),
-      mInitialized(false),
-      mHwc(hwc),
-      mDisplayPlaneManager(dpm),
-      mPayloadManager(NULL),
-      mVsyncObserver(NULL),
-      mOrigContentWidth(0),
-      mOrigContentHeight(0),
-      mFirstVideoFrame(true),
-      mLastConnectionStatus(false),
-      mCachedBufferCapcity(16)
-{
-    CTRACE();
-    mNextConfig.frameServerActive = false;
-}
-
-VirtualDevice::~VirtualDevice()
-{
-    WARN_IF_NOT_DEINIT();
-}
-
-sp<VirtualDevice::CachedBuffer> VirtualDevice::getMappedBuffer(uint32_t handle)
-{
-    ssize_t index = mMappedBufferCache.indexOfKey(handle);
-    sp<CachedBuffer> cachedBuffer;
-    if (index == NAME_NOT_FOUND) {
-        if (mMappedBufferCache.size() > mCachedBufferCapcity)
-            mMappedBufferCache.clear();
-
-        cachedBuffer = new CachedBuffer(mHwc.getBufferManager(), handle);
-        mMappedBufferCache.add(handle, cachedBuffer);
-    } else {
-        cachedBuffer = mMappedBufferCache[index];
-    }
-
-    return cachedBuffer;
-}
-
-bool VirtualDevice::threadLoop()
-{
-    sp<Task> task;
-    {
-        Mutex::Autolock _l(mCscLock);
-        while (mTasks.empty()) {
-            mRequestQueued.wait(mCscLock);
-        }
-        task = *mTasks.begin();
-        mTasks.erase(mTasks.begin());
-        mRequestDequeued.signal();
-    }
-    task->run(*this);
-
-    return true;
-}
-
-status_t VirtualDevice::start(sp<IFrameTypeChangeListener> typeChangeListener)
-{
-    ITRACE();
-    Mutex::Autolock _l(mConfigLock);
-    mNextConfig.typeChangeListener = typeChangeListener;
-    mNextConfig.frameListener = NULL;
-    mNextConfig.policy.scaledWidth = 0;
-    mNextConfig.policy.scaledHeight = 0;
-    mNextConfig.policy.xdpi = 96;
-    mNextConfig.policy.ydpi = 96;
-    mNextConfig.policy.refresh = 60;
-    mNextConfig.extendedModeEnabled =
-        Hwcomposer::getInstance().getDisplayAnalyzer()->isVideoExtModeEnabled();
-    mVideoFramerate = 0;
-    mFirstVideoFrame = true;
-    mNextConfig.frameServerActive = true;
-    mNextConfig.forceNotifyFrameType = true;
-    mNextConfig.forceNotifyBufferInfo = true;
-
-    return NO_ERROR;
-}
-
-status_t VirtualDevice::stop(bool isConnected)
-{
-    ITRACE();
-    Mutex::Autolock _l(mConfigLock);
-    mNextConfig.typeChangeListener = NULL;
-    mNextConfig.frameListener = NULL;
-    mNextConfig.policy.scaledWidth = 0;
-    mNextConfig.policy.scaledHeight = 0;
-    mNextConfig.policy.xdpi = 96;
-    mNextConfig.policy.ydpi = 96;
-    mNextConfig.policy.refresh = 60;
-    mNextConfig.frameServerActive = false;
-    mNextConfig.extendedModeEnabled = false;
-    mNextConfig.forceNotifyFrameType = false;
-    mNextConfig.forceNotifyBufferInfo = false;
-    {
-        Mutex::Autolock _l(mCscLock);
-        mCscWidth = 0;
-        mCscHeight = 0;
-    }
-    return NO_ERROR;
-}
-
-status_t VirtualDevice::notifyBufferReturned(int khandle)
-{
-    CTRACE();
-    Mutex::Autolock _l(mHeldBuffersLock);
-    ssize_t index = mHeldBuffers.indexOfKey(khandle);
-    if (index == NAME_NOT_FOUND) {
-        ETRACE("Couldn't find returned khandle %x", khandle);
-    } else {
-        VTRACE("Removing heldBuffer associated with handle (%d)", khandle);
-        mHeldBuffers.removeItemsAt(index, 1);
-    }
-    return NO_ERROR;
-}
-
-status_t VirtualDevice::setResolution(const FrameProcessingPolicy& policy, sp<IFrameListener> listener)
-{
-    CTRACE();
-    Mutex::Autolock _l(mConfigLock);
-    mNextConfig.frameListener = listener;
-    mNextConfig.policy = policy;
-    return NO_ERROR;
-}
-
-uint32_t VirtualDevice::getCscBuffer(uint32_t width, uint32_t height)
-{
-    if (mCscWidth != width || mCscHeight != height) {
-        ITRACE("CSC buffers changing from %dx%d to %dx%d",
-                mCscWidth, mCscHeight, width, height);
-        clearCscBuffers();
-        mCscWidth = width;
-        mCscHeight = height;
-        mCscBuffersToCreate = NUM_CSC_BUFFERS;
-    }
-
-    uint32_t bufHandle;
-    if (mAvailableCscBuffers.empty()) {
-        if (mCscBuffersToCreate <= 0) {
-            WTRACE("Out of CSC buffers, dropping frame");
-            return 0;
-        }
-        BufferManager* mgr = mHwc.getBufferManager();
-        bufHandle = mgr->allocGrallocBuffer(width,
-                                            height,
-                                            DisplayQuery::queryNV12Format(),
-                                            GRALLOC_USAGE_HW_VIDEO_ENCODER |
-                                            GRALLOC_USAGE_HW_RENDER);
-        if (bufHandle == 0){
-            ETRACE("failed to get gralloc buffer handle");
-            return 0;
-        }
-        mCscBuffersToCreate--;
-        return bufHandle;
-    }
-    else {
-        bufHandle = *mAvailableCscBuffers.begin();
-        mAvailableCscBuffers.erase(mAvailableCscBuffers.begin());
-    }
-    return bufHandle;
-}
-
-void VirtualDevice::clearCscBuffers()
-{
-    if (!mAvailableCscBuffers.empty()) {
-        // iterate the list and call freeGraphicBuffer
-        for (List<uint32_t>::iterator i = mAvailableCscBuffers.begin(); i != mAvailableCscBuffers.end(); ++i) {
-            VTRACE("Deleting the gralloc buffer associated with handle (%d)", (*i));
-            mHwc.getBufferManager()->freeGrallocBuffer(*i);
-        }
-        mAvailableCscBuffers.clear();
-    }
-}
-
-bool VirtualDevice::prePrepare(hwc_display_contents_1_t *display)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    return true;
-}
-
-bool VirtualDevice::prepare(hwc_display_contents_1_t *display)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    mRenderTimestamp = systemTime();
-    mVspInUse = false;
-    mExpectAcquireFences = false;
-
-    {
-        Mutex::Autolock _l(mConfigLock);
-        mCurrentConfig = mNextConfig;
-    }
-
-    bool shouldBeConnected = (display != NULL && (!mCurrentConfig.frameServerActive ||
-                                                  mCurrentConfig.extendedModeEnabled));
-    if (shouldBeConnected != mLastConnectionStatus) {
-        // calling this will reload the property 'hwc.video.extmode.enable'
-        Hwcomposer::getInstance().getDisplayAnalyzer()->isVideoExtModeEnabled();
-
-        Hwcomposer::getInstance().getMultiDisplayObserver()->notifyWidiConnectionStatus(shouldBeConnected);
-        mLastConnectionStatus = shouldBeConnected;
-    }
-
-    if (!display) {
-        // No image. We're done with any mappings and CSC buffers.
-        mMappedBufferCache.clear();
-        Mutex::Autolock _l(mCscLock);
-        clearCscBuffers();
-        return true;
-    }
-
-    if (!mCurrentConfig.frameServerActive) {
-        // We're done with CSC buffers, since we blit to outbuf in this mode.
-        // We want to keep mappings cached, so we don't clear mMappedBufferCache.
-        Mutex::Autolock _l(mCscLock);
-        clearCscBuffers();
-    }
-
-    // by default send the FRAMEBUFFER_TARGET layer (composited image)
-    mRgbLayer = display->numHwLayers-1;
-    mYuvLayer = -1;
-
-    DisplayAnalyzer *analyzer = mHwc.getDisplayAnalyzer();
-
-    mProtectedMode = false;
-
-    if (mCurrentConfig.typeChangeListener != NULL &&
-        !analyzer->isOverlayAllowed() &&
-        analyzer->getVideoInstances() <= 1) {
-        if (mCurrentConfig.typeChangeListener->shutdownVideo() != OK) {
-            ITRACE("Waiting for prior encoder session to shut down...");
-        }
-        /* Setting following flag to true will enable us to call bufferInfoChanged() in clone mode. */
-        mNextConfig.forceNotifyBufferInfo = true;
-        mRgbLayer = -1;
-        mYuvLayer = -1;
-        goto finish;
-    }
-
-#if 0
-    // TODO: Bring back this optimization
-    if (display->numHwLayers-1 == 1) {
-        hwc_layer_1_t& layer = display->hwLayers[0];
-        if (analyzer->isPresentationLayer(layer) && layer.transform == 0 && layer.blending == HWC_BLENDING_NONE) {
-            if (analyzer->isVideoLayer(layer))
-                mYuvLayer = 0;
-            else
-                mRgbLayer = 0;
-            VTRACE("Presentation fast path");
-        }
-        goto finish;
-    }
-#endif
-
-    for (size_t i = 0; i < display->numHwLayers-1; i++) {
-        hwc_layer_1_t& layer = display->hwLayers[i];
-        if (analyzer->isVideoLayer(layer) && (mCurrentConfig.extendedModeEnabled || VSP_FOR_CLEAR_VIDEO || analyzer->isProtectedLayer(layer))) {
-            if (mCurrentConfig.extendedModeEnabled && mCurrentConfig.frameServerActive) {
-                // If composed in surface flinger, then stream fbtarget.
-                if ((layer.flags & HWC_SKIP_LAYER) && !analyzer->ignoreVideoSkipFlag()) {
-                    continue;
-                }
-
-                /* If the resolution of the video layer is less than QCIF, then we are going to play it in clone mode only.*/
-                uint32_t vidContentWidth = layer.sourceCropf.right - layer.sourceCropf.left;
-                uint32_t vidContentHeight = layer.sourceCropf.bottom - layer.sourceCropf.top;
-                if (vidContentWidth < QCIF_WIDTH || vidContentHeight < QCIF_HEIGHT) {
-                    VTRACE("Ingoring layer %d which is too small for extended mode", i);
-                    continue;
-                }
-            }
-            mYuvLayer = i;
-            mProtectedMode = analyzer->isProtectedLayer(layer);
-            if (mCurrentConfig.extendedModeEnabled)
-                mRgbLayer = -1;
-            break;
-        }
-    }
-
-finish:
-    for (size_t i = 0; i < display->numHwLayers-1; i++) {
-        hwc_layer_1_t& layer = display->hwLayers[i];
-        if ((size_t)mRgbLayer == display->numHwLayers-1)
-            layer.compositionType = HWC_FRAMEBUFFER;
-        else
-            layer.compositionType = HWC_OVERLAY;
-    }
-    if (mYuvLayer != -1)
-        display->hwLayers[mYuvLayer].compositionType = HWC_OVERLAY;
-
-    if (mYuvLayer == -1) {
-        VTRACE("Clone mode");
-        // TODO: fix this workaround. Once metadeta has correct info.
-        mFirstVideoFrame = true;
-    }
-
-    if ((size_t)mRgbLayer == display->numHwLayers-1) {
-        // we're streaming fbtarget, so send onFramePrepare and wait for composition to happen
-        if (mCurrentConfig.frameListener != NULL)
-            mCurrentConfig.frameListener->onFramePrepare(mRenderTimestamp, -1);
-        return true;
-    }
-
-    // we don't need fbtarget, so send the frame now
-    bool result = sendToWidi(display);
-    if (result) {
-        mRgbLayer = -1;
-        mYuvLayer = -1;
-        // Extended mode is successful.
-        // Fences aren't set in prepare, and we don't need them here, but they'll
-        // be set later and we have to close them. Don't log a warning in this case.
-        mExpectAcquireFences = true;
-    } else {
-        // if error in playback file , switch to clone mode
-        WTRACE("Error, falling back to clone mode");
-        mRgbLayer = display->numHwLayers-1;
-        mYuvLayer = -1;
-        for (size_t i = 0; i < display->numHwLayers-1; i++) {
-            hwc_layer_1_t& layer = display->hwLayers[i];
-            layer.compositionType = HWC_FRAMEBUFFER;
-        }
-    }
-
-    return true;
-}
-
-bool VirtualDevice::commit(hwc_display_contents_1_t *display, IDisplayContext *context)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    if (display != NULL && (mRgbLayer != -1 || mYuvLayer != -1))
-        sendToWidi(display);
-
-    if (mVspEnabled && !mVspInUse) {
-        sp<DisableVspTask> disableVsp = new DisableVspTask();
-        Mutex::Autolock _l(mCscLock);
-        mTasks.push(disableVsp);
-        mVspEnabled = false;
-    }
-
-    if (display != NULL) {
-        // All acquire fences should be copied somewhere else or closed by now
-        // and set to -1 in these structs except in the case of extended mode.
-        // Make sure the fences are closed and log a warning if not in extended mode.
-        if (display->outbufAcquireFenceFd != -1) {
-            if (!mExpectAcquireFences)
-                WTRACE("outbuf acquire fence (fd=%d) not yet saved or closed", display->outbufAcquireFenceFd);
-            CLOSE_FENCE(display->outbufAcquireFenceFd);
-        }
-        for (size_t i = 0; i < display->numHwLayers; i++) {
-            hwc_layer_1_t& layer = display->hwLayers[i];
-            if (layer.acquireFenceFd != -1) {
-                if (!mExpectAcquireFences)
-                    WTRACE("layer %d acquire fence (fd=%d) not yet saved or closed", i, layer.acquireFenceFd);
-                CLOSE_FENCE(layer.acquireFenceFd);
-            }
-        }
-    }
-
-    return true;
-}
-
-bool VirtualDevice::sendToWidi(hwc_display_contents_1_t *display)
-{
-    VTRACE("RGB=%d, YUV=%d", mRgbLayer, mYuvLayer);
-
-    if (mYuvLayer != -1 && mRgbLayer != -1) {
-        mVspEnabled = true;
-        mVspInUse = true;
-        if (queueCompose(display))
-            return true;
-
-        return queueColorConvert(display);
-    }
-
-    if (mRgbLayer != -1)
-        return queueColorConvert(display);
-
-    if (mYuvLayer != -1) {
-        if (mCurrentConfig.frameServerActive)
-            return handleExtendedMode(display);
-        return queueVideoCopy(display);
-    }
-
-    return true;
-}
-
-bool VirtualDevice::queueCompose(hwc_display_contents_1_t *display)
-{
-    sp<ComposeTask> composeTask = new ComposeTask();
-    sp<HeldCscBuffer> heldBuffer;
-
-    composeTask->syncTimelineFd = -1;
-
-    composeTask->videoHandle = display->hwLayers[mYuvLayer].handle;
-    if (composeTask->videoHandle == NULL) {
-        ETRACE("No video handle");
-        return false;
-    }
-    composeTask->displayFrame = display->hwLayers[mYuvLayer].displayFrame;
-
-    composeTask->rgbHandle = display->hwLayers[mRgbLayer].handle;
-    if (composeTask->rgbHandle == NULL) {
-        ETRACE("No RGB handle");
-        return false;
-    }
-
-    {
-        hwc_layer_1_t& rgbLayer = display->hwLayers[mRgbLayer];
-        composeTask->outWidth = rgbLayer.sourceCropf.right - rgbLayer.sourceCropf.left;
-        composeTask->outHeight = rgbLayer.sourceCropf.bottom - rgbLayer.sourceCropf.top;
-    }
-
-    Mutex::Autolock _l(mCscLock);
-
-    if (mCurrentConfig.frameServerActive) {
-        composeTask->outputHandle = (buffer_handle_t) getCscBuffer(composeTask->outWidth, composeTask->outHeight);
-        heldBuffer = new HeldCscBuffer(this, (uint32_t) composeTask->outputHandle);
-    } else {
-        composeTask->outputHandle = display->outbuf;
-    }
-
-    if (composeTask->outputHandle == NULL) {
-        ETRACE("No outbuf");
-        return false;
-    }
-    composeTask->videoCachedBuffer = getMappedBuffer((uint32_t) composeTask->videoHandle);
-    if (composeTask->videoCachedBuffer == NULL) {
-        ETRACE("Couldn't map video handle %p", composeTask->videoHandle);
-        return false;
-    }
-    if (composeTask->videoCachedBuffer->mapper == NULL) {
-        ETRACE("Src mapper gone");
-        return false;
-    }
-    composeTask->heldVideoBuffer = new HeldDecoderBuffer(this, composeTask->videoCachedBuffer);
-    if (!mPayloadManager->getMetaData(composeTask->videoCachedBuffer->mapper, &composeTask->videoMetadata)) {
-        ETRACE("Failed to map video payload info");
-        return false;
-    }
-    if (composeTask->videoMetadata.width == 0 || composeTask->videoMetadata.height == 0) {
-        ETRACE("Bad video metadata for handle %p", composeTask->videoHandle);
-        return false;
-    }
-    if (composeTask->videoMetadata.kHandle == 0) {
-        ETRACE("Bad khandle");
-        return false;
-    }
-    uint32_t scaleWidth = composeTask->displayFrame.right - composeTask->displayFrame.left;
-    uint32_t scaleHeight = composeTask->displayFrame.bottom - composeTask->displayFrame.top;
-
-    // no upscaling exists, so don't try
-    if (scaleWidth > composeTask->videoMetadata.width)
-        scaleWidth = composeTask->videoMetadata.width;
-    if (scaleHeight > composeTask->videoMetadata.height)
-        scaleHeight = composeTask->videoMetadata.height;
-
-    scaleWidth &= ~1;
-    scaleHeight &= ~1;
-
-    if (mFirstVideoFrame || scaleWidth != mLastScaleWidth || scaleHeight != mLastScaleHeight) {
-        int sessionID = mHwc.getDisplayAnalyzer()->getFirstVideoInstanceSessionID();
-        if (sessionID >= 0) {
-            MultiDisplayObserver* mds = mHwc.getMultiDisplayObserver();
-            status_t ret = mds->setDecoderOutputResolution(sessionID, scaleWidth, scaleHeight, 0, 0, scaleWidth, scaleHeight);
-            if (ret == NO_ERROR) {
-                mLastScaleWidth = scaleWidth;
-                mLastScaleHeight = scaleHeight;
-                mFirstVideoFrame = false;
-                ITRACE("Set scaling to %ux%u", scaleWidth, scaleHeight);
-            }
-            else
-                ETRACE("Failed to set scaling to %ux%u: %x", scaleWidth, scaleHeight, ret);
-        }
-    }
-
-    composeTask->yuvAcquireFenceFd = display->hwLayers[mYuvLayer].acquireFenceFd;
-    display->hwLayers[mYuvLayer].acquireFenceFd = -1;
-
-    composeTask->rgbAcquireFenceFd = display->hwLayers[mRgbLayer].acquireFenceFd;
-    display->hwLayers[mRgbLayer].acquireFenceFd = -1;
-
-    composeTask->outbufAcquireFenceFd = display->outbufAcquireFenceFd;
-    display->outbufAcquireFenceFd = -1;
-
-    int retireFd = sw_sync_fence_create(mSyncTimelineFd, "widi_compose_retire", mNextSyncPoint);
-    display->hwLayers[mRgbLayer].releaseFenceFd = retireFd;
-    display->hwLayers[mYuvLayer].releaseFenceFd = dup(retireFd);
-    display->retireFenceFd = dup(retireFd);
-    mNextSyncPoint++;
-    composeTask->syncTimelineFd = mSyncTimelineFd;
-
-    mTasks.push_back(composeTask);
-    mRequestQueued.signal();
-
-    if (mCurrentConfig.frameServerActive) {
-        hwc_layer_1_t& layer = display->hwLayers[mRgbLayer];
-        FrameInfo inputFrameInfo;
-        memset(&inputFrameInfo, 0, sizeof(inputFrameInfo));
-        inputFrameInfo.isProtected = mProtectedMode;
-        inputFrameInfo.frameType = HWC_FRAMETYPE_FRAME_BUFFER;
-        inputFrameInfo.contentWidth = layer.sourceCropf.right - layer.sourceCropf.left;
-        inputFrameInfo.contentHeight = layer.sourceCropf.bottom - layer.sourceCropf.top;
-        inputFrameInfo.contentFrameRateN = 0;
-        inputFrameInfo.contentFrameRateD = 0;
-        FrameInfo outputFrameInfo = inputFrameInfo;
-
-        BufferManager* mgr = mHwc.getBufferManager();
-        DataBuffer* dataBuf = mgr->lockDataBuffer((uint32_t) composeTask->outputHandle);
-        outputFrameInfo.bufferWidth = dataBuf->getWidth();
-        outputFrameInfo.bufferHeight = dataBuf->getHeight();
-        outputFrameInfo.lumaUStride = dataBuf->getWidth();
-        outputFrameInfo.chromaUStride = dataBuf->getWidth();
-        outputFrameInfo.chromaVStride = dataBuf->getWidth();
-        mgr->unlockDataBuffer(dataBuf);
-
-        queueFrameTypeInfo(inputFrameInfo);
-        if (mCurrentConfig.policy.scaledWidth == 0 || mCurrentConfig.policy.scaledHeight == 0)
-            return true; // This isn't a failure, WiDi just doesn't want frames right now.
-        queueBufferInfo(outputFrameInfo);
-
-        sp<OnFrameReadyTask> frameReadyTask = new OnFrameReadyTask();
-        frameReadyTask->renderTask = composeTask;
-        frameReadyTask->heldBuffer = heldBuffer;
-        frameReadyTask->frameListener = mCurrentConfig.frameListener;
-        frameReadyTask->handle = (uint32_t) composeTask->outputHandle;
-        frameReadyTask->handleType = HWC_HANDLE_TYPE_GRALLOC;
-        frameReadyTask->renderTimestamp = mRenderTimestamp;
-        frameReadyTask->mediaTimestamp = -1;
-        if (frameReadyTask->frameListener != NULL)
-            mTasks.push_back(frameReadyTask);
-    }
-
-    return true;
-}
-
-bool VirtualDevice::queueColorConvert(hwc_display_contents_1_t *display)
-{
-    sp<RefBase> heldBuffer;
-
-    hwc_layer_1_t& layer = display->hwLayers[mRgbLayer];
-    if (layer.handle == NULL) {
-        ETRACE("RGB layer has no handle set");
-        return false;
-    }
-
-    {
-        const IMG_native_handle_t* nativeSrcHandle = reinterpret_cast<const IMG_native_handle_t*>(layer.handle);
-        const IMG_native_handle_t* nativeDestHandle = reinterpret_cast<const IMG_native_handle_t*>(display->outbuf);
-
-        if ((nativeSrcHandle->iFormat == HAL_PIXEL_FORMAT_RGBA_8888 &&
-            nativeDestHandle->iFormat == HAL_PIXEL_FORMAT_BGRA_8888) ||
-            (nativeSrcHandle->iFormat == HAL_PIXEL_FORMAT_BGRA_8888 &&
-            nativeDestHandle->iFormat == HAL_PIXEL_FORMAT_RGBA_8888))
-        {
-            SYNC_WAIT_AND_CLOSE(layer.acquireFenceFd);
-            SYNC_WAIT_AND_CLOSE(display->outbufAcquireFenceFd);
-            display->retireFenceFd = -1;
-
-            // synchronous in this case
-            colorSwap(layer.handle, display->outbuf, ((nativeSrcHandle->iWidth+31)&~31)*nativeSrcHandle->iHeight);
-            // Workaround: Don't keep cached buffers. If the VirtualDisplaySurface gets destroyed,
-            //             these would be unmapped on the next frame, after the buffers are destroyed,
-            //             which is causing heap corruption, probably due to a double-free somewhere.
-            mMappedBufferCache.clear();
-            return true;
-        }
-    }
-
-    sp<BlitTask> blitTask = new BlitTask();
-    blitTask->cropInfo.x = 0;
-    blitTask->cropInfo.y = 0;
-    blitTask->cropInfo.w = layer.sourceCropf.right - layer.sourceCropf.left;
-    blitTask->cropInfo.h = layer.sourceCropf.bottom - layer.sourceCropf.top;
-    blitTask->srcHandle = layer.handle;
-
-    Mutex::Autolock _l(mCscLock);
-
-    blitTask->srcAcquireFenceFd = layer.acquireFenceFd;
-    layer.acquireFenceFd = -1;
-
-    blitTask->syncTimelineFd = mSyncTimelineFd;
-    // Framebuffer after BlitTask::run() calls sw_sync_timeline_inc().
-    layer.releaseFenceFd = sw_sync_fence_create(mSyncTimelineFd, "widi_blit_retire", mNextSyncPoint);
-
-    if (mCurrentConfig.frameServerActive) {
-        blitTask->destHandle = (buffer_handle_t)getCscBuffer(blitTask->cropInfo.w, blitTask->cropInfo.h);
-        blitTask->destAcquireFenceFd = -1;
-
-        // we use our own buffer, so just close this fence without a wait
-        CLOSE_FENCE(display->outbufAcquireFenceFd);
-    }
-    else {
-        blitTask->destHandle = display->outbuf;
-        blitTask->destAcquireFenceFd = display->outbufAcquireFenceFd;
-        // don't let TngDisplayContext::commitEnd() close this
-        display->outbufAcquireFenceFd = -1;
-        display->retireFenceFd = dup(layer.releaseFenceFd);
-        mNextSyncPoint++;
-    }
-
-    if (blitTask->destHandle == NULL)
-        return false;
-
-    if (mCurrentConfig.frameServerActive)
-        heldBuffer = new HeldCscBuffer(this, (uint32_t)blitTask->destHandle);
-
-    mTasks.push_back(blitTask);
-    mRequestQueued.signal();
-
-    if (mCurrentConfig.frameServerActive) {
-        FrameInfo inputFrameInfo;
-        memset(&inputFrameInfo, 0, sizeof(inputFrameInfo));
-        inputFrameInfo.isProtected = mProtectedMode;
-        FrameInfo outputFrameInfo;
-
-        inputFrameInfo.frameType = HWC_FRAMETYPE_FRAME_BUFFER;
-        inputFrameInfo.contentWidth = blitTask->cropInfo.w;
-        inputFrameInfo.contentHeight = blitTask->cropInfo.h;
-        inputFrameInfo.contentFrameRateN = 0;
-        inputFrameInfo.contentFrameRateD = 0;
-        outputFrameInfo = inputFrameInfo;
-
-        BufferManager* mgr = mHwc.getBufferManager();
-        DataBuffer* dataBuf = mgr->lockDataBuffer((uint32_t)blitTask->destHandle);
-        outputFrameInfo.bufferWidth = dataBuf->getWidth();
-        outputFrameInfo.bufferHeight = dataBuf->getHeight();
-        outputFrameInfo.lumaUStride = dataBuf->getWidth();
-        outputFrameInfo.chromaUStride = dataBuf->getWidth();
-        outputFrameInfo.chromaVStride = dataBuf->getWidth();
-        mgr->unlockDataBuffer(dataBuf);
-
-        queueFrameTypeInfo(inputFrameInfo);
-        if (mCurrentConfig.policy.scaledWidth == 0 || mCurrentConfig.policy.scaledHeight == 0)
-            return true; // This isn't a failure, WiDi just doesn't want frames right now.
-        queueBufferInfo(outputFrameInfo);
-
-        sp<OnFrameReadyTask> frameReadyTask = new OnFrameReadyTask();
-        frameReadyTask->renderTask = blitTask;
-        frameReadyTask->heldBuffer = heldBuffer;
-        frameReadyTask->frameListener = mCurrentConfig.frameListener;
-        frameReadyTask->handle = (uint32_t) blitTask->destHandle;
-        frameReadyTask->handleType = HWC_HANDLE_TYPE_GRALLOC;
-        frameReadyTask->renderTimestamp = mRenderTimestamp;
-        frameReadyTask->mediaTimestamp = -1;
-        if (frameReadyTask->frameListener != NULL)
-            mTasks.push_back(frameReadyTask);
-    }
-
-    return true;
-}
-
-bool VirtualDevice::handleExtendedMode(hwc_display_contents_1_t *display)
-{
-    FrameInfo inputFrameInfo;
-    memset(&inputFrameInfo, 0, sizeof(inputFrameInfo));
-    inputFrameInfo.isProtected = mProtectedMode;
-    FrameInfo outputFrameInfo;
-
-    hwc_layer_1_t& layer = display->hwLayers[mYuvLayer];
-    uint32_t handle = (uint32_t)layer.handle;
-    if (handle == 0) {
-        ETRACE("video layer has no handle set");
-        return false;
-    }
-    sp<CachedBuffer> cachedBuffer;
-    if ((cachedBuffer = getMappedBuffer(handle)) == NULL) {
-        ETRACE("Failed to map display buffer");
-        return false;
-    }
-
-    inputFrameInfo.frameType = HWC_FRAMETYPE_VIDEO;
-    // for video mode let 30 fps be the default value.
-    inputFrameInfo.contentFrameRateN = 30;
-    inputFrameInfo.contentFrameRateD = 1;
-    //handleType = HWC_HANDLE_TYPE_KBUF;
-
-    IVideoPayloadManager::MetaData metadata;
-    if (!mPayloadManager->getMetaData(cachedBuffer->mapper, &metadata)) {
-        ETRACE("Failed to get metadata");
-        return false;
-    }
-
-    sp<RefBase> heldBuffer = new HeldDecoderBuffer(this, cachedBuffer);
-    int64_t mediaTimestamp = metadata.timestamp;
-    inputFrameInfo.contentWidth = metadata.crop_width;
-    inputFrameInfo.contentHeight = metadata.crop_height;
-    // Use the crop size if something changed derive it again..
-    // Only get video source info if frame rate has not been initialized.
-    // getVideoSourceInfo() is a fairly expensive operation. This optimization
-    // will save us a few milliseconds per frame
-    if (mFirstVideoFrame || (mOrigContentWidth != inputFrameInfo.contentWidth) ||
-        (mOrigContentHeight != inputFrameInfo.contentHeight)) {
-        mVideoFramerate = inputFrameInfo.contentFrameRateN;
-        VTRACE("VideoWidth = %d, VideoHeight = %d", metadata.crop_width, metadata.crop_height);
-        mOrigContentWidth = inputFrameInfo.contentWidth;
-        mOrigContentHeight = inputFrameInfo.contentHeight;
-
-        // For the first video session by default
-        int sessionID = Hwcomposer::getInstance().getDisplayAnalyzer()->getFirstVideoInstanceSessionID();
-        if (sessionID >= 0) {
-            ITRACE("Session id = %d", sessionID);
-            VideoSourceInfo videoInfo;
-            memset(&videoInfo, 0, sizeof(videoInfo));
-            status_t ret = mHwc.getMultiDisplayObserver()->getVideoSourceInfo(sessionID, &videoInfo);
-            if (ret == NO_ERROR) {
-                ITRACE("width = %d, height = %d, fps = %d", videoInfo.width, videoInfo.height,
-                        videoInfo.frameRate);
-                if (videoInfo.frameRate > 0) {
-                    mVideoFramerate = videoInfo.frameRate;
-                }
-            }
-        }
-        mFirstVideoFrame = false;
-    }
-    inputFrameInfo.contentFrameRateN = mVideoFramerate;
-    inputFrameInfo.contentFrameRateD = 1;
-
-
-    // skip pading bytes in rotate buffer
-    switch (metadata.transform) {
-        case HAL_TRANSFORM_ROT_90: {
-            VTRACE("HAL_TRANSFORM_ROT_90");
-            int contentWidth = inputFrameInfo.contentWidth;
-            inputFrameInfo.contentWidth = (contentWidth + 0xf) & ~0xf;
-            inputFrameInfo.cropLeft = inputFrameInfo.contentWidth - contentWidth;
-        } break;
-        case HAL_TRANSFORM_ROT_180: {
-            VTRACE("HAL_TRANSFORM_ROT_180");
-            int contentWidth = inputFrameInfo.contentWidth;
-            int contentHeight = inputFrameInfo.contentHeight;
-            inputFrameInfo.contentWidth = (contentWidth + 0xf) & ~0xf;
-            inputFrameInfo.contentHeight = (contentHeight + 0xf) & ~0xf;
-            inputFrameInfo.cropLeft = inputFrameInfo.contentWidth - contentWidth;
-            inputFrameInfo.cropTop = inputFrameInfo.contentHeight - contentHeight;
-        } break;
-        case HAL_TRANSFORM_ROT_270: {
-            VTRACE("HAL_TRANSFORM_ROT_270");
-            int contentHeight = inputFrameInfo.contentHeight;
-            inputFrameInfo.contentHeight = (contentHeight + 0xf) & ~0xf;
-            inputFrameInfo.cropTop = inputFrameInfo.contentHeight - contentHeight;
-        } break;
-        default:
-            break;
-    }
-    outputFrameInfo = inputFrameInfo;
-    outputFrameInfo.bufferFormat = metadata.format;
-
-    if (metadata.kHandle == 0) {
-        ETRACE("Couldn't get any khandle");
-        return false;
-    }
-    handle = metadata.kHandle;
-    outputFrameInfo.bufferWidth = metadata.width;
-    outputFrameInfo.bufferHeight = ((metadata.height + 0x1f) & (~0x1f));
-    outputFrameInfo.lumaUStride = metadata.lumaStride;
-    outputFrameInfo.chromaUStride = metadata.chromaUStride;
-    outputFrameInfo.chromaVStride = metadata.chromaVStride;
-    if (outputFrameInfo.bufferFormat == 0 ||
-        outputFrameInfo.bufferWidth < outputFrameInfo.contentWidth ||
-        outputFrameInfo.bufferHeight < outputFrameInfo.contentHeight ||
-        outputFrameInfo.contentWidth <= 0 || outputFrameInfo.contentHeight <= 0 ||
-        outputFrameInfo.lumaUStride <= 0 ||
-        outputFrameInfo.chromaUStride <= 0 || outputFrameInfo.chromaVStride <= 0) {
-        ITRACE("Payload cleared or inconsistent info, not sending frame");
-        ITRACE("outputFrameInfo.bufferFormat  = %d ", outputFrameInfo.bufferFormat);
-        ITRACE("outputFrameInfo.bufferWidth   = %d ", outputFrameInfo.bufferWidth);
-        ITRACE("outputFrameInfo.contentWidth  = %d ", outputFrameInfo.contentWidth);
-        ITRACE("outputFrameInfo.bufferHeight  = %d ", outputFrameInfo.bufferHeight);
-        ITRACE("outputFrameInfo.contentHeight = %d ", outputFrameInfo.contentHeight);
-        ITRACE("outputFrameInfo.lumaUStride   = %d ", outputFrameInfo.lumaUStride);
-        ITRACE("outputFrameInfo.chromaUStride = %d ", outputFrameInfo.chromaUStride);
-        ITRACE("outputFrameInfo.chromaVStride = %d ", outputFrameInfo.chromaVStride);
-        return false;
-    }
-
-    queueFrameTypeInfo(inputFrameInfo);
-    if (mCurrentConfig.policy.scaledWidth == 0 || mCurrentConfig.policy.scaledHeight == 0)
-        return true; // This isn't a failure, WiDi just doesn't want frames right now.
-    queueBufferInfo(outputFrameInfo);
-
-    if (handle == mExtLastKhandle && mediaTimestamp == mExtLastTimestamp) {
-        // Same frame again. We don't send a frame, but we return true because
-        // this isn't an error.
-        return true;
-    }
-    mExtLastKhandle = handle;
-    mExtLastTimestamp = mediaTimestamp;
-
-    sp<OnFrameReadyTask> frameReadyTask = new OnFrameReadyTask;
-    frameReadyTask->renderTask = NULL;
-    frameReadyTask->heldBuffer = heldBuffer;
-    frameReadyTask->frameListener = mCurrentConfig.frameListener;
-    frameReadyTask->handle = handle;
-    frameReadyTask->handleType = HWC_HANDLE_TYPE_KBUF;
-    frameReadyTask->renderTimestamp = mRenderTimestamp;
-    frameReadyTask->mediaTimestamp = mediaTimestamp;
-
-    Mutex::Autolock _l(mCscLock);
-    if (frameReadyTask->frameListener != NULL)
-        mTasks.push_back(frameReadyTask);
-    mRequestQueued.signal();
-
-    return true;
-}
-
-bool VirtualDevice::queueVideoCopy(hwc_display_contents_1_t *display)
-{
-    // TODO: Add path for video but no RGB layer and make this reachable
-    //       Could compose with a blank RGB layer, or copy the video to
-    //       outbuf using the CPU.
-    return true;
-}
-
-void VirtualDevice::queueFrameTypeInfo(const FrameInfo& inputFrameInfo)
-{
-    if (mCurrentConfig.forceNotifyFrameType ||
-        memcmp(&inputFrameInfo, &mLastInputFrameInfo, sizeof(inputFrameInfo)) != 0) {
-        // something changed, notify type change listener
-        mNextConfig.forceNotifyFrameType = false;
-        mLastInputFrameInfo = inputFrameInfo;
-
-        sp<FrameTypeChangedTask> notifyTask = new FrameTypeChangedTask;
-        notifyTask->typeChangeListener = mCurrentConfig.typeChangeListener;
-        notifyTask->inputFrameInfo = inputFrameInfo;
-        mTasks.push_back(notifyTask);
-    }
-}
-
-void VirtualDevice::queueBufferInfo(const FrameInfo& outputFrameInfo)
-{
-    if (mCurrentConfig.forceNotifyBufferInfo ||
-        memcmp(&outputFrameInfo, &mLastOutputFrameInfo, sizeof(outputFrameInfo)) != 0) {
-        mNextConfig.forceNotifyBufferInfo = false;
-        mLastOutputFrameInfo = outputFrameInfo;
-
-        sp<BufferInfoChangedTask> notifyTask = new BufferInfoChangedTask;
-        notifyTask->typeChangeListener = mCurrentConfig.typeChangeListener;
-        notifyTask->outputFrameInfo = outputFrameInfo;
-
-        //if (handleType == HWC_HANDLE_TYPE_GRALLOC)
-        //    mMappedBufferCache.clear(); // !
-        mTasks.push_back(notifyTask);
-    }
-}
-
-void VirtualDevice::fill(uint8_t* ptr, const ied_block& data, size_t len) {
-    for (size_t offset = 0; offset < len; offset += 16) {
-        *reinterpret_cast<ied_block*>(ptr + offset) = data;
-    }
-}
-
-void VirtualDevice::copyVideo(uint8_t* srcPtr, uint32_t srcWidth, uint32_t srcHeight, uint32_t srcStride,
-                              uint8_t* destPtr, uint32_t destWidth, uint32_t destHeight,
-                              uint32_t blitX, uint32_t blitY, uint32_t blitWidth, uint32_t blitHeight)
-{
-    if (srcPtr == NULL || destPtr == NULL) {
-        ETRACE("copyVideo: a pointer is NULL");
-        return;
-    }
-
-    if (blitWidth > srcWidth) {
-        // no upscaling yet, so center it instead
-        blitX += (blitWidth - srcWidth)/2;
-        blitWidth = srcWidth;
-    }
-    if (blitHeight > srcHeight) {
-        // no upscaling yet, so center it instead
-        blitY += (blitHeight - srcHeight)/2;
-        blitHeight = srcHeight;
-    }
-
-    blitX = (blitX+8) & ~15;
-    blitY = (blitY+1) & ~1;
-    blitWidth = blitWidth & ~15;
-
-    if (blitX + blitWidth > destWidth)
-        blitWidth = destWidth - blitX;
-    if (blitY + blitHeight > destHeight)
-        blitHeight = destHeight - blitY;
-
-    VTRACE("Copy %p (%ux%u stride=%u) -> %p (%ux%u), @%ux%u %ux%u",
-          srcPtr, srcWidth, srcHeight, srcStride,
-          destPtr, destWidth, destHeight,
-          blitX, blitY, blitWidth, blitHeight);
-    // clear top bar
-    fill(destPtr, mBlackY, blitY*destWidth);
-    fill(destPtr + destWidth*destHeight, mBlackUV, blitY*destWidth/2);
-
-    // clear bottom bar
-    fill(destPtr + (blitY+blitHeight)*destWidth, mBlackY, (destHeight-blitY-blitHeight)*destWidth);
-    fill(destPtr + destWidth*destHeight + (blitY+blitHeight)*destWidth/2, mBlackUV, (destHeight-blitY-blitHeight)*destWidth/2);
-
-    if (blitX == 0 && srcStride == destWidth) {
-        // copy whole Y plane
-        memcpy(destPtr+blitY*destWidth, srcPtr, srcStride*blitHeight);
-        // copy whole UV plane
-        memcpy(destPtr+(destHeight+blitY/2)*destWidth, srcPtr+srcStride*srcHeight, srcStride*blitHeight/2);
-    } else {
-        // clear left and right bars, Y plane
-        for (uint32_t y = 0; y < blitHeight; y++) {
-            fill(destPtr + (blitY + y)*destWidth, mBlackY, blitX);
-            fill(destPtr + (blitY + y)*destWidth+blitX+blitWidth, mBlackY, destWidth-blitX-blitWidth);
-        }
-
-        // clear left and right bars, UV plane
-        for (uint32_t y = 0; y < blitHeight/2; y++) {
-            fill(destPtr + (destHeight + blitY/2 + y)*destWidth, mBlackUV, blitX);
-            fill(destPtr + (destHeight + blitY/2 + y)*destWidth+blitX+blitWidth, mBlackUV, destWidth-blitX-blitWidth);
-        }
-
-        // copy Y plane one row at a time
-        for (uint32_t row = 0; row < blitHeight; row++)
-            memcpy(destPtr+(row+blitY)*destWidth+blitX, srcPtr + row*srcStride, blitWidth);
-        // copy UV plane one row at a time
-        for (uint32_t row = 0; row < blitHeight/2; row++)
-            memcpy(destPtr+(destHeight+row+blitY/2)*destWidth+blitX, srcPtr+(srcHeight+row)*srcStride, blitWidth);
-    }
-}
-
-void VirtualDevice::colorSwap(buffer_handle_t src, buffer_handle_t dest, uint32_t pixelCount)
-{
-    sp<CachedBuffer> srcCachedBuffer;
-    sp<CachedBuffer> destCachedBuffer;
-
-    {
-        srcCachedBuffer = getMappedBuffer((uint32_t)src);
-        if (srcCachedBuffer == NULL || srcCachedBuffer->mapper == NULL)
-            return;
-        destCachedBuffer = getMappedBuffer((uint32_t)dest);
-        if (destCachedBuffer == NULL || destCachedBuffer->mapper == NULL)
-            return;
-    }
-
-    uint8_t* srcPtr = static_cast<uint8_t*>(srcCachedBuffer->mapper->getCpuAddress(0));
-    uint8_t* destPtr = static_cast<uint8_t*>(destCachedBuffer->mapper->getCpuAddress(0));
-    if (srcPtr == NULL || destPtr == NULL)
-        return;
-    while (pixelCount > 0) {
-        destPtr[0] = srcPtr[2];
-        destPtr[1] = srcPtr[1];
-        destPtr[2] = srcPtr[0];
-        destPtr[3] = srcPtr[3];
-        srcPtr += 4;
-        destPtr += 4;
-        pixelCount--;
-    }
-}
-
-void VirtualDevice::vspEnable(uint32_t width, uint32_t height)
-{
-    ITRACE("Start VSP");
-    VAStatus va_status;
-
-    int display = 0;
-    int major_ver, minor_ver;
-    va_dpy = vaGetDisplay(&display);
-    va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaInitialize returns %08x", va_status);
-
-    VAConfigAttrib va_attr;
-    va_attr.type = VAConfigAttribRTFormat;
-    va_status = vaGetConfigAttributes(va_dpy,
-                VAProfileNone,
-                VAEntrypointVideoProc,
-                &va_attr,
-                1);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaGetConfigAttributes returns %08x", va_status);
-
-    va_status = vaCreateConfig(
-                va_dpy,
-                VAProfileNone,
-                VAEntrypointVideoProc,
-                &(va_attr),
-                1,
-                &va_config
-                );
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaCreateConfig returns %08x", va_status);
-
-    VADisplayAttribute attr;
-    attr.type = VADisplayAttribRenderMode;
-    attr.value = VA_RENDER_MODE_LOCAL_OVERLAY;
-    va_status = vaSetDisplayAttributes(va_dpy, &attr, 1);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaSetDisplayAttributes returns %08x", va_status);
-
-
-    va_status = vaCreateSurfaces(
-                va_dpy,
-                VA_RT_FORMAT_YUV420,
-                width,
-                height,
-                &va_video_in,
-                1,
-                NULL,
-                0);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaCreateSurfaces (video in) returns %08x", va_status);
-
-    va_status = vaCreateContext(
-                va_dpy,
-                va_config,
-                width,
-                height,
-                0,
-                &va_video_in /* not used by VSP, but libva checks for it */,
-                1,
-                &va_context);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaCreateContext returns %08x", va_status);
-}
-
-void VirtualDevice::vspDisable()
-{
-    ITRACE("Shut down VSP");
-
-    if (va_context == 0 && va_video_in == 0) {
-        ITRACE("Already shut down");
-        return;
-    }
-
-    VABufferID pipeline_param_id;
-    VAStatus va_status;
-    va_status = vaCreateBuffer(va_dpy,
-                va_context,
-                VAProcPipelineParameterBufferType,
-                sizeof(VAProcPipelineParameterBuffer),
-                1,
-                NULL,
-                &pipeline_param_id);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaCreateBuffer returns %08x", va_status);
-
-    VABlendState blend_state;
-    VAProcPipelineParameterBuffer *pipeline_param;
-    va_status = vaMapBuffer(va_dpy,
-                pipeline_param_id,
-                (void **)&pipeline_param);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaMapBuffer returns %08x", va_status);
-
-    memset(pipeline_param, 0, sizeof(VAProcPipelineParameterBuffer));
-    pipeline_param->pipeline_flags = VA_PIPELINE_FLAG_END;
-    pipeline_param->num_filters = 0;
-    pipeline_param->blend_state = &blend_state;
-
-    va_status = vaUnmapBuffer(va_dpy, pipeline_param_id);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaUnmapBuffer returns %08x", va_status);
-
-    va_status = vaBeginPicture(va_dpy, va_context, va_video_in /* just need some valid surface */);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaBeginPicture returns %08x", va_status);
-
-    va_status = vaRenderPicture(va_dpy, va_context, &pipeline_param_id, 1);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaRenderPicture returns %08x", va_status);
-
-    va_status = vaEndPicture(va_dpy, va_context);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaEndPicture returns %08x", va_status);
-
-    va_status = vaDestroyContext(va_dpy, va_context);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaDestroyContext returns %08x", va_status);
-    va_context = 0;
-
-    va_status = vaDestroySurfaces(va_dpy, &va_video_in, 1);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaDestroySurfaces returns %08x", va_status);
-    va_video_in = 0;
-
-    if (va_config) {
-        vaDestroyConfig(va_dpy, va_config);
-        va_config = 0;
-    }
-    if (va_dpy) {
-        vaTerminate(va_dpy);
-        va_dpy = NULL;
-    }
-}
-
-void VirtualDevice::vspCompose(VASurfaceID videoIn, VASurfaceID rgbIn, VASurfaceID videoOut)
-{
-    VAStatus va_status;
-
-    VABufferID pipeline_param_id;
-    va_status = vaCreateBuffer(va_dpy,
-                va_context,
-                VAProcPipelineParameterBufferType,
-                sizeof(VAProcPipelineParameterBuffer),
-                1,
-                NULL,
-                &pipeline_param_id);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaCreateBuffer returns %08x", va_status);
-
-    VABlendState blend_state;
-
-    VAProcPipelineParameterBuffer *pipeline_param;
-    va_status = vaMapBuffer(va_dpy,
-                pipeline_param_id,
-                (void **)&pipeline_param);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaMapBuffer returns %08x", va_status);
-
-    memset(pipeline_param, 0, sizeof(VAProcPipelineParameterBuffer));
-    pipeline_param->surface = videoIn;
-    pipeline_param->pipeline_flags = 0;
-    pipeline_param->num_filters = 0;
-    pipeline_param->blend_state = &blend_state;
-    pipeline_param->num_additional_outputs = 1;
-    pipeline_param->additional_outputs = &rgbIn;
-    pipeline_param->surface_region = NULL;
-    pipeline_param->output_region = NULL;
-
-    va_status = vaUnmapBuffer(va_dpy, pipeline_param_id);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaUnmapBuffer returns %08x", va_status);
-
-    va_status = vaBeginPicture(va_dpy, va_context, videoOut);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaBeginPicture returns %08x", va_status);
-
-    va_status = vaRenderPicture(va_dpy, va_context, &pipeline_param_id, 1);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaRenderPicture returns %08x", va_status);
-
-    va_status = vaEndPicture(va_dpy, va_context);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaEndPicture returns %08x", va_status);
-
-    va_status = vaSyncSurface(va_dpy, videoOut);
-    if (va_status != VA_STATUS_SUCCESS) ETRACE("vaSyncSurface returns %08x", va_status);
-}
-
-bool VirtualDevice::vsyncControl(bool enabled)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    return mVsyncObserver->control(enabled);
-}
-
-bool VirtualDevice::blank(bool blank)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    return true;
-}
-
-bool VirtualDevice::getDisplaySize(int *width, int *height)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    if (!width || !height) {
-        ETRACE("invalid parameters");
-        return false;
-    }
-
-    // TODO: make this platform specifc
-    *width = 1280;
-    *height = 720;
-    return true;
-}
-
-bool VirtualDevice::getDisplayConfigs(uint32_t *configs,
-                                         size_t *numConfigs)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    if (!configs || !numConfigs) {
-        ETRACE("invalid parameters");
-        return false;
-    }
-
-    *configs = 0;
-    *numConfigs = 1;
-
-    return true;
-}
-
-bool VirtualDevice::getDisplayAttributes(uint32_t configs,
-                                            const uint32_t *attributes,
-                                            int32_t *values)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    if (!attributes || !values) {
-        ETRACE("invalid parameters");
-        return false;
-    }
-
-    int i = 0;
-    while (attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE) {
-        switch (attributes[i]) {
-        case HWC_DISPLAY_VSYNC_PERIOD:
-            values[i] = 1e9 / 60;
-            break;
-        case HWC_DISPLAY_WIDTH:
-            values[i] = 1280;
-            break;
-        case HWC_DISPLAY_HEIGHT:
-            values[i] = 720;
-            break;
-        case HWC_DISPLAY_DPI_X:
-            values[i] = 0;
-            break;
-        case HWC_DISPLAY_DPI_Y:
-            values[i] = 0;
-            break;
-        default:
-            ETRACE("unknown attribute %d", attributes[i]);
-            break;
-        }
-        i++;
-    }
-
-    return true;
-}
-
-bool VirtualDevice::compositionComplete()
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    return true;
-}
-
-bool VirtualDevice::initialize()
-{
-    // Add initialization codes here. If init fails, invoke DEINIT_AND_RETURN_FALSE();
-    mNextConfig.typeChangeListener = NULL;
-    mNextConfig.policy.scaledWidth = 0;
-    mNextConfig.policy.scaledHeight = 0;
-    mNextConfig.policy.xdpi = 96;
-    mNextConfig.policy.ydpi = 96;
-    mNextConfig.policy.refresh = 60;
-    mNextConfig.extendedModeEnabled = false;
-    mNextConfig.forceNotifyFrameType = false;
-    mNextConfig.forceNotifyBufferInfo = false;
-    mCurrentConfig = mNextConfig;
-    mRgbLayer = -1;
-    mYuvLayer = -1;
-
-    mCscBuffersToCreate = NUM_CSC_BUFFERS;
-    mCscWidth = 0;
-    mCscHeight = 0;
-
-    memset(&mLastInputFrameInfo, 0, sizeof(mLastInputFrameInfo));
-    memset(&mLastOutputFrameInfo, 0, sizeof(mLastOutputFrameInfo));
-
-    mPayloadManager = createVideoPayloadManager();
-    if (!mPayloadManager) {
-        DEINIT_AND_RETURN_FALSE("Failed to create payload manager");
-    }
-
-    mVsyncObserver = new SoftVsyncObserver(*this);
-    if (!mVsyncObserver || !mVsyncObserver->initialize()) {
-        DEINIT_AND_RETURN_FALSE("Failed to create Soft Vsync Observer");
-    }
-
-    mSyncTimelineFd = sw_sync_timeline_create();
-    mNextSyncPoint = 1;
-    mExpectAcquireFences = false;
-
-    mThread = new WidiBlitThread(this);
-    mThread->run("WidiBlit", PRIORITY_URGENT_DISPLAY);
-
-    // Publish frame server service with service manager
-    status_t ret = defaultServiceManager()->addService(String16("hwc.widi"), this);
-    if (ret == NO_ERROR) {
-        ProcessState::self()->startThreadPool();
-        mInitialized = true;
-    } else {
-        ETRACE("Could not register hwc.widi with service manager, error = %d", ret);
-        deinitialize();
-    }
-
-    mLastScaleWidth = 0;
-    mLastScaleHeight = 0;
-
-    mVspEnabled = false;
-    mVspInUse = false;
-    va_dpy = NULL;
-    va_config = 0;
-    va_context = 0;
-    va_video_in = 0;
-
-    // TODO: get encrypted black when IED is armed
-    memset(mBlackY.data, 0, sizeof(mBlackY.data));
-    memset(mBlackUV.data, 0, sizeof(mBlackUV.data));
-
-    ITRACE("Init done.");
-
-    return mInitialized;
-}
-
-bool VirtualDevice::isConnected() const
-{
-    return true;
-}
-
-const char* VirtualDevice::getName() const
-{
-    return "Virtual";
-}
-
-int VirtualDevice::getType() const
-{
-    return DEVICE_VIRTUAL;
-}
-
-void VirtualDevice::onVsync(int64_t timestamp)
-{
-    mHwc.vsync(DEVICE_VIRTUAL, timestamp);
-}
-
-void VirtualDevice::dump(Dump& d)
-{
-}
-
-void VirtualDevice::deinitialize()
-{
-    VAStatus va_status;
-
-    if (mPayloadManager) {
-        delete mPayloadManager;
-        mPayloadManager = NULL;
-    }
-    DEINIT_AND_DELETE_OBJ(mVsyncObserver);
-    mInitialized = false;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/common/observers/MultiDisplayObserver.cpp b/common/observers/MultiDisplayObserver.cpp
deleted file mode 100755
index 82e41f9..0000000
--- a/common/observers/MultiDisplayObserver.cpp
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifdef TARGET_HAS_MULTIPLE_DISPLAY
-#include <common/utils/HwcTrace.h>
-#include <binder/IServiceManager.h>
-#include <Hwcomposer.h>
-#include <common/base/DisplayAnalyzer.h>
-#include <ExternalDevice.h>
-#endif
-
-#include <common/observers/MultiDisplayObserver.h>
-
-namespace android {
-namespace intel {
-
-#ifdef TARGET_HAS_MULTIPLE_DISPLAY
-
-////// MultiDisplayCallback
-
-MultiDisplayCallback::MultiDisplayCallback(MultiDisplayObserver *dispObserver)
-    : mDispObserver(dispObserver),
-      mVideoState(MDS_VIDEO_STATE_UNKNOWN)
-{
-}
-
-MultiDisplayCallback::~MultiDisplayCallback()
-{
-    CTRACE();
-    mDispObserver = NULL;
-}
-
-status_t MultiDisplayCallback::blankSecondaryDisplay(bool blank)
-{
-#ifndef INTEL_SUPPORT_HDMI_PRIMARY
-    ITRACE("blank: %d", blank);
-    mDispObserver->blankSecondaryDisplay(blank);
-#endif
-    return NO_ERROR;
-}
-
-status_t MultiDisplayCallback::updateVideoState(int sessionId, MDS_VIDEO_STATE state)
-{
-    mVideoState = state;
-    ITRACE("state: %d", state);
-    mDispObserver->updateVideoState(sessionId, state);
-    return NO_ERROR;
-}
-
-status_t MultiDisplayCallback::setHdmiTiming(const MDSHdmiTiming& timing)
-{
-    mDispObserver->setHdmiTiming(timing);
-    return NO_ERROR;
-}
-
-status_t MultiDisplayCallback::updateInputState(bool state)
-{
-    ITRACE("input state: %d", state);
-    mDispObserver->updateInputState(state);
-    return NO_ERROR;
-}
-
-status_t MultiDisplayCallback::setHdmiScalingType(MDS_SCALING_TYPE type)
-{
-    ITRACE("scaling type: %d", type);
-    // Merrifield doesn't implement this API
-    return INVALID_OPERATION;
-}
-
-status_t MultiDisplayCallback::setHdmiOverscan(int hValue, int vValue)
-{
-    ITRACE("oversacn compensation, h: %d v: %d", hValue, vValue);
-    // Merrifield doesn't implement this API
-    return INVALID_OPERATION;
-}
-
-////// MultiDisplayObserver
-
-MultiDisplayObserver::MultiDisplayObserver()
-    : mMDSCbRegistrar(NULL),
-      mMDSInfoProvider(NULL),
-      mMDSConnObserver(NULL),
-      mMDSDecoderConfig(NULL),
-      mMDSCallback(NULL),
-      mLock(),
-      mCondition(),
-      mThreadLoopCount(0),
-      mDeviceConnected(false),
-      mExternalHdmiTiming(false),
-      mInitialized(false)
-{
-    CTRACE();
-}
-
-MultiDisplayObserver::~MultiDisplayObserver()
-{
-    WARN_IF_NOT_DEINIT();
-}
-
-bool MultiDisplayObserver::isMDSRunning()
-{
-    // Check if Multi Display service is running
-    sp<IServiceManager> sm = defaultServiceManager();
-    if (sm == NULL) {
-        ETRACE("fail to get service manager!");
-        return false;
-    }
-
-    sp<IBinder> service = sm->checkService(String16(INTEL_MDS_SERVICE_NAME));
-    if (service == NULL) {
-        VTRACE("fail to get MultiDisplay service!");
-        return false;
-    }
-
-    return true;
-}
-
-bool MultiDisplayObserver::initMDSClient()
-{
-    sp<IServiceManager> sm = defaultServiceManager();
-    if (sm == NULL) {
-        ETRACE("Fail to get service manager");
-        return false;
-    }
-    sp<IMDService> mds = interface_cast<IMDService>(
-            sm->getService(String16(INTEL_MDS_SERVICE_NAME)));
-    if (mds == NULL) {
-        ETRACE("Fail to get MDS service");
-        return false;
-    }
-    mMDSCbRegistrar = mds->getCallbackRegistrar();
-    if (mMDSCbRegistrar.get() == NULL) {
-        ETRACE("failed to create mds base Client");
-        return false;
-    }
-
-    mMDSCallback = new MultiDisplayCallback(this);
-    if (mMDSCallback.get() == NULL) {
-        ETRACE("failed to create MultiDisplayCallback");
-        deinitMDSClient();
-        return false;
-    }
-    mMDSInfoProvider = mds->getInfoProvider();
-    if (mMDSInfoProvider.get() == NULL) {
-        ETRACE("failed to create mds video Client");
-        return false;
-    }
-
-    mMDSConnObserver = mds->getConnectionObserver();
-    if (mMDSConnObserver.get() == NULL) {
-        ETRACE("failed to create mds video Client");
-        return false;
-    }
-    mMDSDecoderConfig = mds->getDecoderConfig();
-    if (mMDSDecoderConfig.get() == NULL) {
-        ETRACE("failed to create mds decoder Client");
-        return false;
-    }
-
-    status_t ret = mMDSCbRegistrar->registerCallback(mMDSCallback);
-    if (ret != NO_ERROR) {
-        ETRACE("failed to register callback");
-        deinitMDSClient();
-        return false;
-    }
-
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    mDeviceConnected = drm->isConnected(IDisplayDevice::DEVICE_EXTERNAL);
-    ITRACE("MDS client is initialized");
-    return true;
-}
-
-void MultiDisplayObserver::deinitMDSClient()
-{
-    if (mMDSCallback.get() && mMDSCbRegistrar.get()) {
-        mMDSCbRegistrar->unregisterCallback(mMDSCallback);
-    }
-
-    mDeviceConnected = false;
-    mMDSCbRegistrar = NULL;
-    mMDSInfoProvider = NULL;
-    mMDSCallback = NULL;
-    mMDSConnObserver = NULL;
-    mMDSDecoderConfig = NULL;
-}
-
-bool MultiDisplayObserver::initMDSClientAsync()
-{
-    if (mThread.get()) {
-        WTRACE("working thread has been already created.");
-        return true;
-    }
-
-    mThread = new MDSClientInitThread(this);
-    if (mThread.get() == NULL) {
-        ETRACE("failed to create MDS client init thread");
-        return false;
-    }
-    mThreadLoopCount = 0;
-    // TODO: check return value
-    mThread->run("MDSClientInitThread", PRIORITY_URGENT_DISPLAY);
-    return true;
-}
-
-bool MultiDisplayObserver::initialize()
-{
-    bool ret = true;
-    Mutex::Autolock _l(mLock);
-
-    if (mInitialized) {
-        WTRACE("display observer has been initialized");
-        return true;
-    }
-
-    // initialize MDS client once. This should succeed if MDS service starts
-    // before surfaceflinger service is started.
-    // if surface flinger runs first, MDS client will be initialized asynchronously in
-    // a working thread
-    if (isMDSRunning()) {
-        if (!initMDSClient()) {
-            ETRACE("failed to initialize MDS client");
-            // FIXME: NOT a common case for system server crash.
-            // Start a working thread to initialize MDS client if exception happens
-            ret = initMDSClientAsync();
-        }
-    } else {
-        ret = initMDSClientAsync();
-    }
-
-    mInitialized = true;
-    return ret;
-}
-
-void MultiDisplayObserver::deinitialize()
-{
-    sp<MDSClientInitThread> detachedThread;
-    do {
-        Mutex::Autolock _l(mLock);
-
-        if (mThread.get()) {
-            mCondition.signal();
-            detachedThread = mThread;
-            mThread = NULL;
-        }
-        mThreadLoopCount = 0;
-        deinitMDSClient();
-        mInitialized = false;
-    } while (0);
-
-    if (detachedThread.get()) {
-        detachedThread->requestExitAndWait();
-        detachedThread = NULL;
-    }
-}
-
-bool MultiDisplayObserver::threadLoop()
-{
-    Mutex::Autolock _l(mLock);
-
-    // try to create MDS client in the working thread
-    // multiple delayed attempts are made until MDS service starts.
-
-    // Return false if MDS service is running or loop limit is reached
-    // such that thread becomes inactive.
-    if (isMDSRunning()) {
-        if (!initMDSClient()) {
-            ETRACE("failed to initialize MDS client");
-        }
-        return false;
-    }
-
-    if (mThreadLoopCount++ > THREAD_LOOP_BOUND) {
-        ETRACE("failed to initialize MDS client, loop limit reached");
-        return false;
-    }
-
-    status_t err = mCondition.waitRelative(mLock, milliseconds(THREAD_LOOP_DELAY));
-    if (err != -ETIMEDOUT) {
-        ITRACE("thread is interrupted");
-        return false;
-    }
-
-    return true; // keep trying
-}
-
-
-status_t MultiDisplayObserver::blankSecondaryDisplay(bool blank)
-{
-    // blank secondary display
-    Hwcomposer::getInstance().getDisplayAnalyzer()->postBlankEvent(blank);
-    return 0;
-}
-
-status_t MultiDisplayObserver::updateVideoState(int sessionId, MDS_VIDEO_STATE state)
-{
-    Hwcomposer::getInstance().getDisplayAnalyzer()->postVideoEvent(
-        sessionId, (int)state);
-    return 0;
-}
-
-status_t MultiDisplayObserver::setHdmiTiming(const MDSHdmiTiming& timing)
-{
-    drmModeModeInfo mode;
-    mode.hdisplay = timing.width;
-    mode.vdisplay = timing.height;
-    mode.vrefresh = timing.refresh;
-    mode.flags = timing.flags;
-    ITRACE("timing to set: %dx%d@%dHz", timing.width, timing.height, timing.refresh);
-    ExternalDevice *dev =
-        (ExternalDevice *)Hwcomposer::getInstance().getDisplayDevice(HWC_DISPLAY_EXTERNAL);
-    if (dev) {
-        dev->setDrmMode(mode);
-    }
-
-    mExternalHdmiTiming = true;
-    return 0;
-}
-
-status_t MultiDisplayObserver::updateInputState(bool active)
-{
-    Hwcomposer::getInstance().getDisplayAnalyzer()->postInputEvent(active);
-    return 0;
-}
-
-
-/// Public interfaces
-
-status_t MultiDisplayObserver::notifyHotPlug( bool connected)
-{
-    Mutex::Autolock _l(mLock);
-    if (mMDSConnObserver.get() == NULL) {
-        return NO_INIT;
-    }
-
-    if (connected == mDeviceConnected) {
-        WTRACE("hotplug event ignored");
-        return NO_ERROR;
-    }
-
-    // clear it after externel device is disconnected
-    if (!connected) mExternalHdmiTiming = false;
-
-    mDeviceConnected = connected;
-    return mMDSConnObserver->updateHdmiConnectionStatus(connected);
-}
-
-status_t MultiDisplayObserver::getVideoSourceInfo(int sessionID, VideoSourceInfo* info)
-{
-    Mutex::Autolock _l(mLock);
-    if (mMDSInfoProvider.get() == NULL) {
-        return NO_INIT;
-    }
-
-    if (info == NULL) {
-        ETRACE("invalid parameter");
-        return UNKNOWN_ERROR;
-    }
-
-    MDSVideoSourceInfo videoInfo;
-    memset(&videoInfo, 0, sizeof(MDSVideoSourceInfo));
-    status_t ret = mMDSInfoProvider->getVideoSourceInfo(sessionID, &videoInfo);
-    if (ret == NO_ERROR) {
-        info->width     = videoInfo.displayW;
-        info->height    = videoInfo.displayH;
-        info->frameRate = videoInfo.frameRate;
-        info->isProtected = videoInfo.isProtected;
-        VTRACE("Video Session[%d] source info: %dx%d@%d", sessionID,
-                info->width, info->height, info->frameRate);
-    }
-    return ret;
-}
-
-int MultiDisplayObserver::getVideoSessionNumber()
-{
-    Mutex::Autolock _l(mLock);
-    if (mMDSInfoProvider.get() == NULL) {
-        return 0;
-    }
-
-    return mMDSInfoProvider->getVideoSessionNumber();
-}
-
-bool MultiDisplayObserver::isExternalDeviceTimingFixed() const
-{
-    Mutex::Autolock _l(mLock);
-    return mExternalHdmiTiming;
-}
-
-status_t MultiDisplayObserver::notifyWidiConnectionStatus( bool connected)
-{
-    Mutex::Autolock _l(mLock);
-    if (mMDSConnObserver.get() == NULL) {
-        return NO_INIT;
-    }
-    return mMDSConnObserver->updateWidiConnectionStatus(connected);
-}
-
-status_t MultiDisplayObserver::setDecoderOutputResolution(
-        int sessionID,
-        int32_t width, int32_t height,
-        int32_t offX, int32_t offY,
-        int32_t bufWidth, int32_t bufHeight)
-{
-    Mutex::Autolock _l(mLock);
-    if (mMDSDecoderConfig.get() == NULL) {
-        return NO_INIT;
-    }
-    if (width <= 0 || height <= 0 ||
-            offX < 0 || offY < 0 ||
-            bufWidth <= 0 || bufHeight <= 0) {
-        ETRACE(" Invalid parameter: %dx%d, %dx%d, %dx%d", width, height, offX, offY, bufWidth, bufHeight);
-        return UNKNOWN_ERROR;
-    }
-
-    status_t ret = mMDSDecoderConfig->setDecoderOutputResolution(sessionID, width, height, offX, offY, bufWidth, bufHeight);
-    if (ret == NO_ERROR) {
-        ITRACE("Video Session[%d] output resolution %dx%d ", sessionID, width, height);
-    }
-    return ret;
-}
-
-
-#endif //TARGET_HAS_MULTIPLE_DISPLAY
-
-} // namespace intel
-} // namespace android
diff --git a/common/observers/MultiDisplayObserver.h b/common/observers/MultiDisplayObserver.h
deleted file mode 100755
index 3bf86d5..0000000
--- a/common/observers/MultiDisplayObserver.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef __MULTIDISPLAY_OBSERVER_H
-#define __MULTIDISPLAY_OBSERVER_H
-
-#ifdef TARGET_HAS_MULTIPLE_DISPLAY
-#include <display/MultiDisplayService.h>
-#include <common/base/SimpleThread.h>
-#else
-#include <utils/Errors.h>
-#include <string.h>
-#endif
-
-namespace android {
-namespace intel {
-
-struct VideoSourceInfo {
-    VideoSourceInfo() {
-        memset(this, 0, sizeof(VideoSourceInfo));
-    }
-    int width;
-    int height;
-    int frameRate;
-    bool isProtected;
-};
-
-
-#ifdef TARGET_HAS_MULTIPLE_DISPLAY
-
-class MultiDisplayObserver;
-
-class MultiDisplayCallback : public BnMultiDisplayCallback {
-public:
-    MultiDisplayCallback(MultiDisplayObserver *observer);
-    virtual ~MultiDisplayCallback();
-
-    status_t blankSecondaryDisplay(bool blank);
-    status_t updateVideoState(int sessionId, MDS_VIDEO_STATE state);
-    status_t setHdmiTiming(const MDSHdmiTiming& timing);
-    status_t setHdmiScalingType(MDS_SCALING_TYPE type);
-    status_t setHdmiOverscan(int hValue, int vValue);
-    status_t updateInputState(bool state);
-
-private:
-    MultiDisplayObserver *mDispObserver;
-    MDS_VIDEO_STATE mVideoState;
-};
-
-class MultiDisplayObserver {
-public:
-    MultiDisplayObserver();
-    virtual ~MultiDisplayObserver();
-
-public:
-    bool initialize();
-    void deinitialize();
-    status_t notifyHotPlug(bool connected);
-    status_t getVideoSourceInfo(int sessionID, VideoSourceInfo* info);
-    int  getVideoSessionNumber();
-    bool isExternalDeviceTimingFixed() const;
-    status_t notifyWidiConnectionStatus(bool connected);
-    status_t setDecoderOutputResolution(int sessionID,
-            int32_t width, int32_t height,
-            int32_t offX,  int32_t offY,
-            int32_t bufWidth, int32_t bufHeight);
-
-private:
-    bool isMDSRunning();
-    bool initMDSClient();
-    bool initMDSClientAsync();
-    void deinitMDSClient();
-    status_t blankSecondaryDisplay(bool blank);
-    status_t updateVideoState(int sessionId, MDS_VIDEO_STATE state);
-    status_t setHdmiTiming(const MDSHdmiTiming& timing);
-    status_t updateInputState(bool active);
-    friend class MultiDisplayCallback;
-
-private:
-    enum {
-        THREAD_LOOP_DELAY = 10, // 10 ms
-        THREAD_LOOP_BOUND = 2000, // 20s
-    };
-
-private:
-    sp<IMultiDisplayCallbackRegistrar> mMDSCbRegistrar;
-    sp<IMultiDisplayInfoProvider> mMDSInfoProvider;
-    sp<IMultiDisplayConnectionObserver> mMDSConnObserver;
-    sp<IMultiDisplayDecoderConfig> mMDSDecoderConfig;
-    sp<MultiDisplayCallback> mMDSCallback;
-    mutable Mutex mLock;
-    Condition mCondition;
-    int mThreadLoopCount;
-    bool mDeviceConnected;
-    // indicate external devices's timing is set
-    bool mExternalHdmiTiming;
-    bool mInitialized;
-
-private:
-    DECLARE_THREAD(MDSClientInitThread, MultiDisplayObserver);
-};
-
-#else
-
-// dummy declaration and implementation of MultiDisplayObserver
-class MultiDisplayObserver {
-public:
-    MultiDisplayObserver() {}
-    virtual ~MultiDisplayObserver() {}
-
-    bool initialize() { return true; }
-    void deinitialize() {}
-    status_t notifyHotPlug(bool /* connected */) { return NO_ERROR; }
-    status_t getVideoSourceInfo(int /* sessionID */, VideoSourceInfo* /* info */) { return INVALID_OPERATION; }
-    int  getVideoSessionNumber() { return 0; }
-    bool isExternalDeviceTimingFixed() const { return false; }
-    status_t notifyWidiConnectionStatus(bool /* connected */) { return NO_ERROR; }
-    status_t setDecoderOutputResolution(
-            int /* sessionID */,
-            int32_t /* width */, int32_t /* height */,
-            int32_t, int32_t, int32_t, int32_t) { return NO_ERROR; }
-};
-
-#endif //TARGET_HAS_MULTIPLE_DISPLAY
-
-} // namespace intel
-} // namespace android
-
-#endif /* __MULTIMultiDisplayObserver_H_ */
diff --git a/include/Hwcomposer.h b/include/Hwcomposer.h
old mode 100644
new mode 100755
index 22b62c8..2118f94
--- a/include/Hwcomposer.h
+++ b/include/Hwcomposer.h
@@ -26,10 +26,7 @@
 #include <common/base/Drm.h>
 #include <DisplayPlaneManager.h>
 #include <common/base/DisplayAnalyzer.h>
-#include <common/base/VsyncManager.h>
-#include <common/observers/MultiDisplayObserver.h>
 #include <UeventObserver.h>
-#include <IPowerManager.h>
 
 namespace android {
 namespace intel {
@@ -73,11 +70,8 @@
     BufferManager* getBufferManager();
     IDisplayContext* getDisplayContext();
     DisplayAnalyzer* getDisplayAnalyzer();
-    VsyncManager* getVsyncManager();
-    MultiDisplayObserver* getMultiDisplayObserver();
     IDisplayDevice* getDisplayDevice(int disp);
     UeventObserver* getUeventObserver();
-    IPowerManager* getPowerManager();
 
 protected:
     Hwcomposer();
@@ -103,7 +97,6 @@
     virtual IDisplayDevice* createDisplayDevice(int disp,
                                                  DisplayPlaneManager& dpm) = 0;
     virtual IDisplayContext* createDisplayContext() = 0;
-    virtual IPowerManager* createPowerManager() = 0;
 
 protected:
     hwc_procs_t const *mProcs;
@@ -113,10 +106,7 @@
     DisplayAnalyzer *mDisplayAnalyzer;
     Vector<IDisplayDevice*> mDisplayDevices;
     IDisplayContext *mDisplayContext;
-    VsyncManager *mVsyncManager;
-    MultiDisplayObserver *mMultiDisplayObserver;
     UeventObserver *mUeventObserver;
-    IPowerManager *mPowerManager;
     bool mInitialized;
 private:
     static Hwcomposer *sInstance;
diff --git a/include/IDisplayDevice.h b/include/IDisplayDevice.h
old mode 100644
new mode 100755
index 6c242b8..f42d222
--- a/include/IDisplayDevice.h
+++ b/include/IDisplayDevice.h
@@ -56,9 +56,7 @@
         DEVICE_DUMMY = HWC_DISPLAY_PRIMARY,
         DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY,
         DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL,
-#ifdef INTEL_WIDI_MERRIFIELD
         DEVICE_VIRTUAL = HWC_DISPLAY_VIRTUAL,
-#endif
         DEVICE_COUNT,
     };
     enum {
diff --git a/include/IPowerManager.h b/include/IPowerManager.h
deleted file mode 100644
index 8ff397d..0000000
--- a/include/IPowerManager.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef IPOWER_MANAGER_H
-#define IPOWER_MANAGER_H
-
-namespace android {
-namespace intel {
-
-class IPowerManager {
-public:
-    virtual ~IPowerManager() {}
-
-public:
-    virtual bool initialize() = 0;
-    virtual void deinitialize() = 0;
-    virtual bool isSupported() = 0;
-    virtual bool isEnabled() = 0;
-    virtual void enableIdleControl() = 0;
-    virtual void disableIdleControl() = 0;
-    virtual void enterIdleState() = 0;
-    virtual void exitIdleState() = 0;
-    virtual void setIdleReady() = 0;
-    virtual bool getIdleReady() = 0;
-    virtual void resetIdleControl() = 0;
-
-}; //class IPowerManager
-
-} // intel
-} // android
-
-#endif
diff --git a/include/IPrepareListener.h b/include/IPrepareListener.h
deleted file mode 100644
index 57dbba8..0000000
--- a/include/IPrepareListener.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef IPREPARE_LISTENER_H
-#define IPREPARE_LISTENER_H
-
-namespace android {
-namespace intel {
-
-class IPrepareListener {
-public:
-    IPrepareListener() {}
-    virtual ~IPrepareListener() {}
-public:
-    virtual void onProtectedLayerStart(int disp) = 0;
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* IPREPARE_LISTENER_H */
diff --git a/include/IVideoPayloadManager.h b/include/IVideoPayloadManager.h
deleted file mode 100644
index 13b7f7e..0000000
--- a/include/IVideoPayloadManager.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef IVIDEO_PAYLOAD_MANAGER_H
-#define IVIDEO_PAYLOAD_MANAGER_H
-
-#include <hardware/hwcomposer.h>
-
-namespace android {
-namespace intel {
-
-class BufferMapper;
-
-class IVideoPayloadManager {
-public:
-    IVideoPayloadManager() {}
-    virtual ~IVideoPayloadManager() {}
-
-public:
-    struct MetaData {
-        uint32_t kHandle;
-        uint32_t transform;
-        uint32_t width;
-        uint32_t height;
-        uint32_t format;
-        uint16_t lumaStride;
-        uint16_t chromaUStride;
-        uint16_t chromaVStride;
-        int64_t  timestamp;
-        uint32_t crop_width;
-        uint32_t crop_height;
-        // Downscaling
-        uint32_t scaling_khandle;
-        uint32_t scaling_width;
-        uint32_t scaling_height;
-        uint32_t scaling_luma_stride;
-        uint32_t scaling_chroma_u_stride;
-        uint32_t scaling_chroma_v_stride;
-    };
-
-public:
-    virtual bool getMetaData(BufferMapper *mapper, MetaData *metadata) = 0;
-    virtual bool setRenderStatus(BufferMapper *mapper, bool renderStatus) = 0;
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* IVIDEO_PAYLOAD_MANAGER_H */
diff --git a/include/PhysicalDevice.h b/include/PhysicalDevice.h
old mode 100644
new mode 100755
index c35f04f..1fb2abf
--- a/include/PhysicalDevice.h
+++ b/include/PhysicalDevice.h
@@ -19,7 +19,6 @@
 #include <DisplayPlane.h>
 #include <IVsyncControl.h>
 #include <IBlankControl.h>
-#include <IPrepareListener.h>
 #include <common/observers/VsyncEventObserver.h>
 #include <common/base/HwcLayerList.h>
 #include <common/base/Drm.h>
@@ -72,7 +71,6 @@
     bool updateDisplayConfigs();
     virtual IVsyncControl* createVsyncControl() = 0;
     virtual IBlankControl* createBlankControl() = 0;
-    virtual IPrepareListener* createPrepareListener() = 0;
     friend class VsyncEventObserver;
 
 protected:
@@ -88,7 +86,6 @@
 
 
     IBlankControl *mBlankControl;
-    IPrepareListener *mPrepareListener;
     VsyncEventObserver *mVsyncObserver;
 
     // layer list
diff --git a/include/PrimaryDevice.h b/include/PrimaryDevice.h
old mode 100644
new mode 100755
index c85451a..5ed6e93
--- a/include/PrimaryDevice.h
+++ b/include/PrimaryDevice.h
@@ -39,10 +39,6 @@
 protected:
     virtual IVsyncControl* createVsyncControl() = 0;
     virtual IBlankControl* createBlankControl() = 0;
-
-private:
-    static void repeatedFrameEventListener(void *data);
-    void repeatedFrameListener();
 };
 
 }
diff --git a/include/VirtualDevice.h b/include/VirtualDevice.h
deleted file mode 100644
index 9492ff1..0000000
--- a/include/VirtualDevice.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef VIRTUAL_DEVICE_H
-#define VIRTUAL_DEVICE_H
-
-#include <IDisplayDevice.h>
-#include <common/base/SimpleThread.h>
-#include <IVideoPayloadManager.h>
-#include <utils/Condition.h>
-#include <utils/Mutex.h>
-#include <utils/Vector.h>
-
-#include "IFrameServer.h"
-
-#include <va/va.h>
-#include <va/va_vpp.h>
-
-namespace android {
-namespace intel {
-
-class Hwcomposer;
-class DisplayPlaneManager;
-class IVideoPayloadManager;
-class SoftVsyncObserver;
-
-class VirtualDevice : public IDisplayDevice, public BnFrameServer {
-protected:
-    class VAMappedHandle;
-    struct CachedBuffer : public android::RefBase {
-        CachedBuffer(BufferManager *mgr, uint32_t handle);
-        ~CachedBuffer();
-        BufferManager *manager;
-        BufferMapper *mapper;
-        VAMappedHandle *vaMappedHandle;
-    };
-    struct HeldCscBuffer : public android::RefBase {
-        HeldCscBuffer(const android::sp<VirtualDevice>& vd, uint32_t handle);
-        virtual ~HeldCscBuffer();
-        android::sp<VirtualDevice> vd;
-        uint32_t handle;
-    };
-    struct HeldDecoderBuffer : public android::RefBase {
-        HeldDecoderBuffer(const sp<VirtualDevice>& vd, const android::sp<CachedBuffer>& cachedBuffer);
-        virtual ~HeldDecoderBuffer();
-        android::sp<VirtualDevice> vd;
-        android::sp<CachedBuffer> cachedBuffer;
-    };
-    struct Configuration {
-        sp<IFrameTypeChangeListener> typeChangeListener;
-        sp<IFrameListener> frameListener;
-        FrameProcessingPolicy policy;
-        bool frameServerActive;
-        bool extendedModeEnabled;
-        bool forceNotifyFrameType;
-        bool forceNotifyBufferInfo;
-    };
-    struct Task;
-    struct RenderTask;
-    struct ComposeTask;
-    struct DisableVspTask;
-    struct BlitTask;
-    struct FrameTypeChangedTask;
-    struct BufferInfoChangedTask;
-    struct OnFrameReadyTask;
-    struct ied_block {
-        uint8_t data[16];
-    };
-    ied_block mBlackY;
-    ied_block mBlackUV;
-
-    Mutex mConfigLock;
-    Configuration mCurrentConfig;
-    Configuration mNextConfig;
-    ssize_t mRgbLayer;
-    ssize_t mYuvLayer;
-    bool mProtectedMode;
-
-    uint32_t mExtLastKhandle;
-    int64_t mExtLastTimestamp;
-
-    int64_t mRenderTimestamp;
-
-    // colorspace conversion
-    Mutex mCscLock;
-    android::List<uint32_t> mAvailableCscBuffers;
-    int mCscBuffersToCreate;
-    uint32_t mCscWidth;
-    uint32_t mCscHeight;
-
-    // fence info
-    int mSyncTimelineFd;
-    unsigned mNextSyncPoint;
-    bool mExpectAcquireFences;
-
-    // async blit info
-    DECLARE_THREAD(WidiBlitThread, VirtualDevice);
-    Condition mRequestQueued;
-    Condition mRequestDequeued;
-    Vector< sp<Task> > mTasks;
-
-    FrameInfo mLastInputFrameInfo;
-    FrameInfo mLastOutputFrameInfo;
-
-    int32_t mVideoFramerate;
-
-    android::KeyedVector<uint32_t, android::sp<CachedBuffer> > mMappedBufferCache;
-    android::Mutex mHeldBuffersLock;
-    android::KeyedVector<uint32_t, android::sp<android::RefBase> > mHeldBuffers;
-
-    // VSP
-    bool mVspInUse;
-    bool mVspEnabled;
-    VADisplay va_dpy;
-    VAConfigID va_config;
-    VAContextID va_context;
-    VASurfaceID va_video_in;
-
-    // scaling info
-    uint32_t mLastScaleWidth;
-    uint32_t mLastScaleHeight;
-
-private:
-    uint32_t getCscBuffer(uint32_t width, uint32_t height);
-    void clearCscBuffers();
-    android::sp<CachedBuffer> getMappedBuffer(uint32_t handle);
-
-    bool sendToWidi(hwc_display_contents_1_t *display);
-    bool queueCompose(hwc_display_contents_1_t *display);
-    bool queueColorConvert(hwc_display_contents_1_t *display);
-    bool handleExtendedMode(hwc_display_contents_1_t *display);
-    bool queueVideoCopy(hwc_display_contents_1_t *display);
-
-    void queueFrameTypeInfo(const FrameInfo& inputFrameInfo);
-    void queueBufferInfo(const FrameInfo& outputFrameInfo);
-
-    static void fill(uint8_t* ptr, const ied_block& data, size_t len);
-    void copyVideo(uint8_t* srcPtr, uint32_t srcWidth, uint32_t srcHeight, uint32_t srcStride,
-                   uint8_t* destPtr, uint32_t destWidth, uint32_t destHeight,
-                   uint32_t outX, uint32_t outY, uint32_t width, uint32_t height);
-    void colorSwap(buffer_handle_t src, buffer_handle_t dest, uint32_t pixelCount);
-    void vspEnable(uint32_t width, uint32_t height);
-    void vspDisable();
-    void vspCompose(VASurfaceID videoIn, VASurfaceID rgbIn, VASurfaceID videoOut);
-
-public:
-    VirtualDevice(Hwcomposer& hwc, DisplayPlaneManager& dpm);
-    virtual ~VirtualDevice();
-
-public:
-    virtual bool prePrepare(hwc_display_contents_1_t *display);
-    virtual bool prepare(hwc_display_contents_1_t *display);
-    virtual bool commit(hwc_display_contents_1_t *display,
-                          IDisplayContext *context);
-
-    virtual bool vsyncControl(bool enabled);
-    virtual bool blank(bool blank);
-    virtual bool getDisplaySize(int *width, int *height);
-    virtual bool getDisplayConfigs(uint32_t *configs,
-                                       size_t *numConfigs);
-    virtual bool getDisplayAttributes(uint32_t config,
-                                          const uint32_t *attributes,
-                                          int32_t *values);
-    virtual bool compositionComplete();
-    virtual bool initialize();
-    virtual void deinitialize();
-    virtual bool isConnected() const;
-    virtual const char* getName() const;
-    virtual int getType() const;
-    virtual void onVsync(int64_t timestamp);
-    virtual void dump(Dump& d);
-
-    // IFrameServer methods
-    virtual android::status_t start(sp<IFrameTypeChangeListener> frameTypeChangeListener);
-    virtual android::status_t stop(bool isConnected);
-    virtual android::status_t notifyBufferReturned(int index);
-    virtual android::status_t setResolution(const FrameProcessingPolicy& policy, android::sp<IFrameListener> listener);
-protected:
-    virtual IVideoPayloadManager* createVideoPayloadManager() = 0;
-
-protected:
-    bool mInitialized;
-    Hwcomposer& mHwc;
-    DisplayPlaneManager& mDisplayPlaneManager;
-    IVideoPayloadManager *mPayloadManager;
-    SoftVsyncObserver *mVsyncObserver;
-    uint32_t mOrigContentWidth;
-    uint32_t mOrigContentHeight;
-    bool mFirstVideoFrame;
-    bool mLastConnectionStatus;
-    uint32_t mCachedBufferCapcity;
-};
-
-}
-}
-
-#endif /* VIRTUAL_DEVICE_H */
diff --git a/ips/common/PlaneCapabilities.cpp b/ips/common/PlaneCapabilities.cpp
deleted file mode 100644
index ed7fd1d..0000000
--- a/ips/common/PlaneCapabilities.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#include <common/utils/HwcTrace.h>
-#include <DisplayPlane.h>
-#include <hal_public.h>
-#include <OMX_IVCommon.h>
-#include <PlaneCapabilities.h>
-#include "OverlayHardware.h"
-#include <common/base/HwcLayer.h>
-
-#define SPRITE_PLANE_MAX_STRIDE_TILED      16384
-//FIXME: need confirmation about this stride
-#define SPRITE_PLANE_MAX_STRIDE_LINEAR     8192
-
-#define OVERLAY_PLANE_MAX_STRIDE_PACKED    4096
-#define OVERLAY_PLANE_MAX_STRIDE_LINEAR    8192
-
-namespace android {
-namespace intel {
-
-bool PlaneCapabilities::isFormatSupported(int planeType, HwcLayer *hwcLayer)
-{
-    uint32_t format = hwcLayer->getFormat();
-    uint32_t trans = hwcLayer->getLayer()->transform;
-
-    if (planeType == DisplayPlane::PLANE_SPRITE || planeType == DisplayPlane::PLANE_PRIMARY) {
-        switch (format) {
-        case HAL_PIXEL_FORMAT_BGRA_8888:
-        case HAL_PIXEL_FORMAT_BGRX_8888:
-        case HAL_PIXEL_FORMAT_RGBA_8888:
-        case HAL_PIXEL_FORMAT_RGBX_8888:
-        case HAL_PIXEL_FORMAT_RGB_565:
-            return trans ? false : true;
-        default:
-            VTRACE("unsupported format %#x", format);
-            return false;
-        }
-    } else if (planeType == DisplayPlane::PLANE_OVERLAY) {
-        switch (format) {
-        case HAL_PIXEL_FORMAT_I420:
-        case HAL_PIXEL_FORMAT_YUY2:
-        case HAL_PIXEL_FORMAT_UYVY:
-            // TODO: overlay supports 180 degree rotation
-            if (trans == HAL_TRANSFORM_ROT_180) {
-                WTRACE("180 degree rotation is not supported yet");
-            }
-            return trans ? false : true;
-        case HAL_PIXEL_FORMAT_YV12:
-            return trans ? false: true;
-        case HAL_PIXEL_FORMAT_NV12:
-        case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar:
-        case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled:
-            return true;
-        default:
-            VTRACE("unsupported format %#x", format);
-            return false;
-        }
-    } else {
-        ETRACE("invalid plane type %d", planeType);
-        return false;
-    }
-}
-
-bool PlaneCapabilities::isSizeSupported(int planeType, HwcLayer *hwcLayer)
-{
-    uint32_t format = hwcLayer->getFormat();
-    uint32_t w = hwcLayer->getBufferWidth();
-    uint32_t h = hwcLayer->getBufferHeight();
-    const stride_t& stride = hwcLayer->getBufferStride();
-
-    bool isYUVPacked;
-    uint32_t maxStride;
-
-    if (planeType == DisplayPlane::PLANE_SPRITE || planeType == DisplayPlane::PLANE_PRIMARY) {
-        switch (format) {
-        case HAL_PIXEL_FORMAT_BGRA_8888:
-        case HAL_PIXEL_FORMAT_BGRX_8888:
-        case HAL_PIXEL_FORMAT_RGBA_8888:
-        case HAL_PIXEL_FORMAT_RGBX_8888:
-        case HAL_PIXEL_FORMAT_RGB_565:
-            if (stride.rgb.stride > SPRITE_PLANE_MAX_STRIDE_LINEAR) {
-                VTRACE("too large stride %d", stride.rgb.stride);
-                return false;
-            }
-            return true;
-        default:
-            VTRACE("unsupported format %#x", format);
-            return false;
-        }
-    } else if (planeType == DisplayPlane::PLANE_OVERLAY) {
-        switch (format) {
-        case HAL_PIXEL_FORMAT_YV12:
-        case HAL_PIXEL_FORMAT_I420:
-        case HAL_PIXEL_FORMAT_NV12:
-        case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar:
-        case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled:
-            isYUVPacked = false;
-            break;
-        case HAL_PIXEL_FORMAT_YUY2:
-        case HAL_PIXEL_FORMAT_UYVY:
-            isYUVPacked = true;
-            break;
-        default:
-            VTRACE("unsupported format %#x", format);
-            return false;
-        }
-        // don't use overlay plane if stride is too big
-        maxStride = OVERLAY_PLANE_MAX_STRIDE_LINEAR;
-        if (isYUVPacked) {
-            maxStride = OVERLAY_PLANE_MAX_STRIDE_PACKED;
-        }
-
-        if (stride.yuv.yStride > maxStride) {
-            VTRACE("stride %d is too large", stride.yuv.yStride);
-            return false;
-        }
-        return true;
-    } else {
-        ETRACE("invalid plane type %d", planeType);
-        return false;
-    }
-}
-
-bool PlaneCapabilities::isBlendingSupported(int planeType, HwcLayer *hwcLayer)
-{
-    uint32_t blending = (uint32_t)hwcLayer->getLayer()->blending;
-    uint8_t planeAlpha = hwcLayer->getLayer()->planeAlpha;
-
-    if (planeType == DisplayPlane::PLANE_SPRITE || planeType == DisplayPlane::PLANE_PRIMARY) {
-        bool ret = false;
-
-        // support premultipled & none blanding
-        switch (blending) {
-        case HWC_BLENDING_NONE:
-            return true;
-        case HWC_BLENDING_PREMULT:
-            ret = false;
-            if ((planeAlpha == 0) || (planeAlpha == 255)) {
-                ret = true;
-            }
-            return ret;
-        default:
-            VTRACE("unsupported blending %#x", blending);
-            return false;
-        }
-    } else if (planeType == DisplayPlane::PLANE_OVERLAY) {
-        // overlay doesn't support blending
-        return (blending == HWC_BLENDING_NONE) ? true : false;
-    } else {
-        ETRACE("invalid plane type %d", planeType);
-        return false;
-    }
-}
-
-
-bool PlaneCapabilities::isScalingSupported(int planeType, HwcLayer *hwcLayer)
-{
-    hwc_frect_t& src = hwcLayer->getLayer()->sourceCropf;
-    hwc_rect_t& dest = hwcLayer->getLayer()->displayFrame;
-
-    int srcW, srcH;
-    int dstW, dstH;
-
-    srcW = (int)src.right - (int)src.left;
-    srcH = (int)src.bottom - (int)src.top;
-    dstW = dest.right - dest.left;
-    dstH = dest.bottom - dest.top;
-
-    if (planeType == DisplayPlane::PLANE_SPRITE || planeType == DisplayPlane::PLANE_PRIMARY) {
-        // no scaling is supported
-        return ((srcW == dstW) && (srcH == dstH)) ? true : false;
-
-    } else if (planeType == DisplayPlane::PLANE_OVERLAY) {
-        // overlay cannot support resolution that bigger than 2047x2047.
-        if ((srcW > INTEL_OVERLAY_MAX_WIDTH - 1) || (srcH > INTEL_OVERLAY_MAX_HEIGHT - 1)) {
-            return false;
-        }
-
-        if (dstW <= 1 || dstH <= 1 || srcW <= 1 || srcH <= 1) {
-            // Workaround: Overlay flip when height is 1 causes MIPI stall on TNG
-            return false;
-        }
-
-        return true;
-    } else {
-        ETRACE("invalid plane type %d", planeType);
-        return false;
-    }
-}
-
-bool PlaneCapabilities::isTransformSupported(int planeType, HwcLayer *hwcLayer)
-{
-    uint32_t trans = hwcLayer->getLayer()->transform;
-
-    if (planeType == DisplayPlane::PLANE_OVERLAY)
-        return true;
-    // don't transform any tranform
-    return trans ? false : true;
-}
-
-} // namespace intel
-} // namespace android
-
diff --git a/ips/common/PowerManager.cpp b/ips/common/PowerManager.cpp
deleted file mode 100644
index 8bfd726..0000000
--- a/ips/common/PowerManager.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <Hwcomposer.h>
-#include <ips/common/PowerManager.h>
-
-namespace android {
-namespace intel {
-
-PowerManager::PowerManager()
-    : mSupported(false),
-      mEnabled(false),
-      mIdle(false),
-      mIdleReady(false)
-{
-}
-
-PowerManager::~PowerManager()
-{
-}
-
-bool PowerManager::initialize()
-{
-    uint32_t videoMode = 0;
-    Drm* drm = Hwcomposer::getInstance().getDrm();
-    drm->readIoctl(DRM_PSB_PANEL_QUERY, &videoMode, sizeof(uint32_t));
-    if (videoMode == 1) {
-        ITRACE("Video mode panel, idle control is supported");
-        mSupported = true;
-    }
-    if (!drm->isConnected(IDisplayDevice::DEVICE_EXTERNAL)) {
-        enableIdleControl();
-    } else {
-        disableIdleControl();
-    }
-    mIdle = false;
-    return true;
-}
-
-void PowerManager::deinitialize()
-{
-    disableIdleControl();
-}
-
-bool PowerManager::isSupported()
-{
-    return mSupported;
-}
-
-bool PowerManager::isEnabled()
-{
-    return mEnabled;
-}
-
-void PowerManager::enableIdleControl()
-{
-    if (!mSupported) {
-        return;
-    }
-
-    if (mEnabled) {
-        WTRACE("idle control has been enabled");
-        return;
-    }
-
-    DTRACE("enable repeated frame interrupt");
-    struct drm_psb_idle_ctrl ctrl = {IDLE_CTRL_ENABLE, IDLE_THRESHOLD};
-    Hwcomposer::getInstance().getDrm()->writeIoctl(
-        DRM_PSB_IDLE_CTRL, &ctrl, sizeof(struct drm_psb_idle_ctrl));
-
-    mEnabled = true;
-    mIdleReady = false;
-}
-
-void PowerManager::disableIdleControl()
-{
-    if (!mEnabled) {
-        return;
-    }
-
-    DTRACE("disable repeated frame interrupt");
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    struct drm_psb_idle_ctrl ctrl = {IDLE_CTRL_DISABLE, 0};
-    Hwcomposer::getInstance().getDrm()->writeIoctl(
-        DRM_PSB_IDLE_CTRL, &ctrl, sizeof(struct drm_psb_idle_ctrl));
-
-    resetIdleControl();
-}
-
-void PowerManager::enterIdleState()
-{
-    if (!mEnabled || mIdle) {
-        WTRACE("Invalid state: enabled %d, idle %d", mEnabled, mIdle);
-        return;
-    }
-
-    DTRACE("entering s0i1 mode");
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    struct drm_psb_idle_ctrl ctrl = {IDLE_CTRL_ENTER, 0};
-    Hwcomposer::getInstance().getDrm()->writeIoctl(
-        DRM_PSB_IDLE_CTRL, &ctrl, sizeof(struct drm_psb_idle_ctrl));
-
-    mIdle = true;
-}
-
-void PowerManager::exitIdleState()
-{
-    if (!mIdle) {
-        WTRACE("invalid idle state");
-        return;
-    }
-    DTRACE("exiting s0i1 mode");
-    struct drm_psb_idle_ctrl ctrl = {IDLE_CTRL_EXIT, 0};
-    Hwcomposer::getInstance().getDrm()->writeIoctl(
-        DRM_PSB_IDLE_CTRL, &ctrl, sizeof(struct drm_psb_idle_ctrl));
-
-    mIdle = false;
-    mIdleReady = false;
-}
-
-void PowerManager::setIdleReady()
-{
-    mIdleReady = true;
-}
-
-bool PowerManager::getIdleReady()
-{
-    return mIdleReady;
-}
-
-void PowerManager::resetIdleControl()
-{
-    mEnabled = false;
-    mIdle = false;
-    mIdleReady = false;
-}
-
-}
-}
-
diff --git a/ips/common/PowerManager.h b/ips/common/PowerManager.h
deleted file mode 100644
index afb7225..0000000
--- a/ips/common/PowerManager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#ifndef POWER_MANAGER_H
-#define POWER_MANAGER_H
-
-#include <IPowerManager.h>
-
-namespace android {
-namespace intel {
-class PowerManager : public IPowerManager
-{
-public:
-    PowerManager();
-    virtual ~PowerManager();
-
-public:
-    virtual bool initialize();
-    virtual void deinitialize();
-    virtual bool isSupported();
-    virtual bool isEnabled();
-    virtual void enableIdleControl();
-    virtual void disableIdleControl();
-    virtual void enterIdleState();
-    virtual void exitIdleState();
-    virtual void setIdleReady();
-    virtual bool getIdleReady();
-    virtual void resetIdleControl();
-
-private:
-    // TODO: use property instead
-    enum {
-        IDLE_THRESHOLD = 60
-    };
-    bool mSupported;
-    bool mEnabled;
-    bool mIdle;
-    bool mIdleReady;
-};
-
-}
-}
-
-
-#endif // POWER_MANAGER_H
diff --git a/ips/common/PrepareListener.cpp b/ips/common/PrepareListener.cpp
deleted file mode 100644
index d185350..0000000
--- a/ips/common/PrepareListener.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <Hwcomposer.h>
-#include <ips/common/PrepareListener.h>
-
-namespace android {
-namespace intel {
-
-PrepareListener::PrepareListener()
-    : IPrepareListener()
-{
-}
-
-PrepareListener::~PrepareListener()
-{
-}
-
-void PrepareListener::onProtectedLayerStart(int disp)
-{
-    WTRACE("disp = %d, ignored for now", disp);
-    // need chaabi support for granular IED control
-    return;
-
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    int ret = drmCommandNone(drm->getDrmFd(), DRM_PSB_HDCP_DISPLAY_IED_ON);
-    if (ret != 0) {
-        ETRACE("failed to turn on display IED");
-    } else {
-        ITRACE("display IED is turned on");
-    }
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/common/PrepareListener.h b/ips/common/PrepareListener.h
deleted file mode 100644
index e048b92..0000000
--- a/ips/common/PrepareListener.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PREPARE_LISTENER_H
-#define PREPARE_LISTENER_H
-
-#include <IPrepareListener.h>
-
-namespace android {
-namespace intel {
-
-class PrepareListener : public IPrepareListener {
-public:
-    PrepareListener();
-    virtual ~PrepareListener();
-public:
-    virtual void onProtectedLayerStart(int disp);
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* PREPARE_LISTENER_H */
diff --git a/ips/common/VideoPayloadManager.cpp b/ips/common/VideoPayloadManager.cpp
deleted file mode 100644
index 7a48c85..0000000
--- a/ips/common/VideoPayloadManager.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#include <common/utils/HwcTrace.h>
-#include <BufferMapper.h>
-#include <ips/common/GrallocSubBuffer.h>
-#include <ips/common/VideoPayloadManager.h>
-#include <ips/common/VideoPayloadBuffer.h>
-
-namespace android {
-namespace intel {
-
-VideoPayloadManager::VideoPayloadManager()
-    : IVideoPayloadManager()
-{
-}
-
-VideoPayloadManager::~VideoPayloadManager()
-{
-}
-
-bool VideoPayloadManager::getMetaData(BufferMapper *mapper, MetaData *metadata)
-{
-    if (!mapper || !metadata) {
-        ETRACE("Null input params");
-        return false;
-    }
-
-    VideoPayloadBuffer *p = (VideoPayloadBuffer*) mapper->getCpuAddress(SUB_BUFFER1);
-    if (!p) {
-        ETRACE("Got null payload from display buffer");
-        return false;
-    }
-
-    metadata->format = p->format;
-    metadata->transform = p->metadata_transform;
-    metadata->timestamp = p->timestamp;
-    metadata->scaling_khandle = p->scaling_khandle;
-    metadata->scaling_width = p->scaling_width;
-    metadata->scaling_height = p->scaling_height;
-
-    metadata->scaling_luma_stride = p->scaling_luma_stride;
-    metadata->scaling_chroma_u_stride = p->scaling_chroma_u_stride;
-    metadata->scaling_chroma_v_stride = p->scaling_chroma_v_stride;
-
-    if (p->metadata_transform == 0) {
-        metadata->width = p->width;
-        metadata->height = p->height;
-        metadata->lumaStride = p->luma_stride;
-        metadata->chromaUStride = p->chroma_u_stride;
-        metadata->chromaVStride = p->chroma_v_stride;
-        metadata->kHandle = p->khandle;
-    } else {
-        metadata->width = p->rotated_width;
-        metadata->height = p->rotated_height;
-        metadata->lumaStride = p->rotate_luma_stride;
-        metadata->chromaUStride = p->rotate_chroma_u_stride;
-        metadata->chromaVStride = p->rotate_chroma_v_stride;
-        metadata->kHandle = p->rotated_buffer_handle;
-    }
-    if (metadata->scaling_khandle)
-        VTRACE("Scaled video buffer, %dx%d",
-                metadata->scaling_width, metadata->scaling_height);
-    if (metadata->transform != 0)
-        VTRACE("Rotated video buffer, %dx%d", metadata->width, metadata->height);
-
-    if ((p->metadata_transform == 0) || (p->metadata_transform == HAL_TRANSFORM_ROT_180)) {
-        metadata->crop_width = p->crop_width;
-        metadata->crop_height = p->crop_height;
-    } else {
-        metadata->crop_width = p->crop_height;
-        metadata->crop_height = p->crop_width;
-    }
-
-    return true;
-}
-
-bool VideoPayloadManager::setRenderStatus(BufferMapper *mapper, bool renderStatus)
-{
-    if (!mapper) {
-        ETRACE("Null mapper param");
-        return false;
-    }
-
-    VideoPayloadBuffer* p = (VideoPayloadBuffer*) mapper->getCpuAddress(SUB_BUFFER1);
-    if (!p) {
-        ETRACE("Got null payload from display buffer");
-        return false;
-    }
-
-    p->renderStatus = renderStatus ? 1 : 0;
-    return true;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/common/VideoPayloadManager.h b/ips/common/VideoPayloadManager.h
deleted file mode 100644
index 563003d..0000000
--- a/ips/common/VideoPayloadManager.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef VIDEO_PAYLOAD_MANAGER_H
-#define VIDEO_PAYLOAD_MANAGER_H
-
-#include <IVideoPayloadManager.h>
-
-namespace android {
-namespace intel {
-
-class BufferMapper;
-
-class VideoPayloadManager : public IVideoPayloadManager {
-
-public:
-    VideoPayloadManager();
-    virtual ~VideoPayloadManager();
-
-    // IVideoPayloadManager
-public:
-    virtual bool getMetaData(BufferMapper *mapper, MetaData *metadata);
-    virtual bool setRenderStatus(BufferMapper *mapper, bool renderStatus);
-
-}; // class VideoPayloadManager
-
-} // namespace intel
-} // namespace android
-
-#endif /* VIDEO_PAYLOAD_MANAGER_H */
diff --git a/ips/penwell/PnwGrallocBuffer.cpp b/ips/penwell/PnwGrallocBuffer.cpp
deleted file mode 100644
index 260391f..0000000
--- a/ips/penwell/PnwGrallocBuffer.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <penwell/PnwGrallocBuffer.h>
-
-namespace android {
-namespace intel {
-
-PnwGrallocBuffer::PnwGrallocBuffer(uint32_t handle)
-    :GrallocBufferBase(handle)
-{
-    struct PnwIMGGrallocBuffer *grallocHandle =
-        (struct PnwIMGGrallocBuffer*)handle;
-
-    CTRACE();
-
-    if (!grallocHandle) {
-        ETRACE("gralloc handle is null");
-        return;
-    }
-
-    mFormat = grallocHandle->format;
-    mWidth = grallocHandle->width;
-    mHeight = grallocHandle->height;
-    mUsage = grallocHandle->usage;
-    mKey = grallocHandle->stamp;
-    mBpp = grallocHandle->bpp;
-
-    initialize();
-}
-
-}
-}
diff --git a/ips/penwell/PnwGrallocBuffer.h b/ips/penwell/PnwGrallocBuffer.h
deleted file mode 100644
index 3a5bd76..0000000
--- a/ips/penwell/PnwGrallocBuffer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PNW_GRALLOC_BUFFER_H
-#define PNW_GRALLOC_BUFFER_H
-
-#include <ips/common/GrallocSubBuffer.h>
-#include <ips/common/GrallocBufferBase.h>
-
-namespace android {
-namespace intel {
-
-struct PnwIMGGrallocBuffer{
-    native_handle_t base;
-    int fd[SUB_BUFFER_MAX];
-    unsigned long long stamp;
-    int usage;
-    int width;
-    int height;
-    int format;
-    int bpp;
-}__attribute__((aligned(sizeof(int)),packed));
-
-
-class PnwGrallocBuffer : public GrallocBufferBase {
-public:
-    PnwGrallocBuffer(uint32_t handle);
-};
-
-} // namespace intel
-} // namespace android
-
-
-#endif /* PNW_GRALLOC_BUFFER_H */
diff --git a/ips/penwell/PnwGrallocBufferMapper.cpp b/ips/penwell/PnwGrallocBufferMapper.cpp
deleted file mode 100644
index ec8c25b..0000000
--- a/ips/penwell/PnwGrallocBufferMapper.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <Hwcomposer.h>
-#include <penwell/PnwGrallocBufferMapper.h>
-
-namespace android {
-namespace intel {
-
-PnwGrallocBufferMapper::PnwGrallocBufferMapper(DataBuffer& buffer)
-    : GrallocBufferMapperBase(buffer)
-{
-    CTRACE();
-}
-
-PnwGrallocBufferMapper::~PnwGrallocBufferMapper()
-{
-    CTRACE();
-}
-
-bool PnwGrallocBufferMapper::map()
-{
-    // TODO: implement map
-    return false;
-}
-
-bool PnwGrallocBufferMapper::unmap()
-{
-    //TODO: implement unmap
-    return false;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/penwell/PnwGrallocBufferMapper.h b/ips/penwell/PnwGrallocBufferMapper.h
deleted file mode 100644
index fef9edc..0000000
--- a/ips/penwell/PnwGrallocBufferMapper.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PNW_GRALLOC_BUFFER_MAPPER_H
-#define PNW_GRALLOC_BUFFER_MAPPER_H
-
-#include <BufferMapper.h>
-#include <hal_public.h>
-#include <ips/common/GrallocBufferMapperBase.h>
-
-namespace android {
-namespace intel {
-
-class PnwGrallocBufferMapper : public GrallocBufferMapperBase {
-public:
-    PnwGrallocBufferMapper(DataBuffer& buffer);
-    ~PnwGrallocBufferMapper();
-public:
-    bool map();
-    bool unmap();
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* TNG_GRALLOC_BUFFER_MAPPER_H */
diff --git a/ips/penwell/PnwOverlayPlane.cpp b/ips/penwell/PnwOverlayPlane.cpp
deleted file mode 100644
index f8a5302..0000000
--- a/ips/penwell/PnwOverlayPlane.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <math.h>
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <Hwcomposer.h>
-#include <penwell/PnwOverlayPlane.h>
-#include <penwell/PnwGrallocBuffer.h>
-
-namespace android {
-namespace intel {
-
-PnwOverlayPlane::PnwOverlayPlane(int index, int disp)
-    : OverlayPlaneBase(index, disp)
-{
-    CTRACE();
-}
-
-PnwOverlayPlane::~PnwOverlayPlane()
-{
-    CTRACE();
-}
-
-bool PnwOverlayPlane::flip()
-{
-    //TODO: implement flip
-    return false;
-}
-
-void* PnwOverlayPlane::getContext() const
-{
-    CTRACE();
-    //TODO: return penwell overlay context
-    return 0;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/penwell/PnwOverlayPlane.h b/ips/penwell/PnwOverlayPlane.h
deleted file mode 100644
index ea6e76b..0000000
--- a/ips/penwell/PnwOverlayPlane.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PNW_OVERLAY_PLANE_H
-#define PNW_OVERLAY_PLANE_H
-
-#include <utils/KeyedVector.h>
-#include <hal_public.h>
-#include <DisplayPlane.h>
-#include <BufferMapper.h>
-#include <ips/common/Wsbm.h>
-#include <ips/common/OverlayPlaneBase.h>
-
-namespace android {
-namespace intel {
-
-class PnwOverlayPlane : public OverlayPlaneBase {
-
-public:
-    PnwOverlayPlane(int index, int disp);
-    ~PnwOverlayPlane();
-
-    virtual bool flip();
-    virtual void* getContext() const;
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* PNW_OVERLAY_PLANE_H */
diff --git a/ips/penwell/PnwPrimaryPlane.cpp b/ips/penwell/PnwPrimaryPlane.cpp
deleted file mode 100644
index dca3b18..0000000
--- a/ips/penwell/PnwPrimaryPlane.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <penwell/PnwPrimaryPlane.h>
-#include <penwell/PnwGrallocBuffer.h>
-#include <ips/common/PixelFormat.h>
-
-namespace android {
-namespace intel {
-
-PnwPrimaryPlane::PnwPrimaryPlane(int index, int disp)
-    : PnwSpritePlane(index, disp)
-{
-    CTRACE();
-    mType = PLANE_PRIMARY;
-}
-
-PnwPrimaryPlane::~PnwPrimaryPlane()
-{
-    CTRACE();
-}
-
-void PnwPrimaryPlane::setFramebufferTarget(DataBuffer& buf)
-{
-    CTRACE();
-    //TODO: implement penwell frame buffer target flip
-}
-
-bool PnwPrimaryPlane::setDataBuffer(uint32_t handle)
-{
-    PnwGrallocBuffer tmpBuf(handle);
-    uint32_t usage;
-
-    ATRACE("handle = %#x", handle);
-
-    usage = tmpBuf.getUsage();
-    if (!handle || (GRALLOC_USAGE_HW_FB & usage)) {
-        setFramebufferTarget(tmpBuf);
-        return true;
-    }
-
-    return DisplayPlane::setDataBuffer(handle);
-}
-
-bool PnwPrimaryPlane::assignToDevice(int disp)
-{
-    return true;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/penwell/PnwPrimaryPlane.h b/ips/penwell/PnwPrimaryPlane.h
deleted file mode 100644
index 7f8b443..0000000
--- a/ips/penwell/PnwPrimaryPlane.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PNW_PRIMARY_PLANE_H
-#define PNW_PRIMARY_PLANE_H
-
-#include <penwell/PnwSpritePlane.h>
-
-namespace android {
-namespace intel {
-
-class PnwPrimaryPlane : public PnwSpritePlane {
-public:
-    PnwPrimaryPlane(int index, int disp);
-    ~PnwPrimaryPlane();
-public:
-    bool setDataBuffer(uint32_t handle);
-    bool assignToDevice(int disp);
-private:
-    void setFramebufferTarget(DataBuffer& buf);
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* TNG_PRIMARY_PLANE_H */
diff --git a/ips/penwell/PnwSpritePlane.cpp b/ips/penwell/PnwSpritePlane.cpp
deleted file mode 100644
index ed8fbdd..0000000
--- a/ips/penwell/PnwSpritePlane.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <Hwcomposer.h>
-#include <BufferManager.h>
-#include <penwell/PnwSpritePlane.h>
-#include <ips/common/PixelFormat.h>
-
-namespace android {
-namespace intel {
-
-PnwSpritePlane::PnwSpritePlane(int index, int disp)
-    : SpritePlaneBase(index, disp)
-{
-    CTRACE();
-}
-
-PnwSpritePlane::~PnwSpritePlane()
-{
-    CTRACE();
-}
-
-bool PnwSpritePlane::setDataBuffer(BufferMapper& mapper)
-{
-    // TODO: implement setDataBuffer
-    return false;
-}
-
-void* PnwSpritePlane::getContext() const
-{
-    CTRACE();
-    // TODO: return penwell sprite context
-    return 0;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/penwell/PnwSpritePlane.h b/ips/penwell/PnwSpritePlane.h
deleted file mode 100644
index aa51829..0000000
--- a/ips/penwell/PnwSpritePlane.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PNW_SPRITE_PLANE_H
-#define PNW_SPRITE_PLANE_H
-
-#include <utils/KeyedVector.h>
-#include <hal_public.h>
-#include <common/buffers/BufferCache.h>
-#include <DisplayPlane.h>
-
-#include <ips/common/SpritePlaneBase.h>
-
-namespace android {
-namespace intel {
-
-class PnwSpritePlane : public SpritePlaneBase {
-public:
-    PnwSpritePlane(int index, int disp);
-    virtual ~PnwSpritePlane();
-public:
-    virtual void* getContext() const;
-protected:
-    virtual bool setDataBuffer(BufferMapper& mapper);
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* PNW_SPRITE_PLANE_H */
diff --git a/ips/tangier/TngDisplayContext.cpp b/ips/tangier/TngDisplayContext.cpp
old mode 100644
new mode 100755
index 9e6d968..96245f2
--- a/ips/tangier/TngDisplayContext.cpp
+++ b/ips/tangier/TngDisplayContext.cpp
@@ -219,19 +219,15 @@
                  displays[i]->hwLayers[j].releaseFenceFd);
         }
 
-#ifdef INTEL_WIDI_MERRIFIELD
         // retireFence is used for SurfaceFlinger to do DispSync;
         // dup releaseFenceFd for physical displays and ignore virtual
         // display; we don't distinguish between release and retire, and all
         // physical displays are using a single releaseFence; for virtual
         // display, fencing is handled by the VirtualDisplay class
         if (i < IDisplayDevice::DEVICE_VIRTUAL) {
-#endif
             displays[i]->retireFenceFd =
                 (releaseFenceFd != -1) ? dup(releaseFenceFd) : -1;
-#ifdef INTEL_WIDI_MERRIFIELD
         }
-#endif
     }
 
     // close original release fence fd
diff --git a/ips/tangier/TngOverlayPlane.cpp b/ips/tangier/TngOverlayPlane.cpp
deleted file mode 100644
index f0b4544..0000000
--- a/ips/tangier/TngOverlayPlane.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <math.h>
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <Hwcomposer.h>
-#include <tangier/TngOverlayPlane.h>
-#include <ips/tangier/TngGrallocBuffer.h>
-
-namespace android {
-namespace intel {
-
-TngOverlayPlane::TngOverlayPlane(int index, int disp)
-    : OverlayPlaneBase(index, disp),
-      mRotationBufProvider(NULL)
-{
-    CTRACE();
-
-    memset(&mContext, 0, sizeof(mContext));
-}
-
-TngOverlayPlane::~TngOverlayPlane()
-{
-    CTRACE();
-}
-
-bool TngOverlayPlane::flip(void *ctx)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    if (!DisplayPlane::flip(ctx))
-        return false;
-
-    mContext.type = DC_OVERLAY_PLANE;
-    mContext.ctx.ov_ctx.ovadd = 0x0;
-    mContext.ctx.ov_ctx.ovadd = (mBackBuffer[mCurrent]->gttOffsetInPage << 12);
-    mContext.ctx.ov_ctx.index = mIndex;
-    mContext.ctx.ov_ctx.pipe = mDevice;
-    mContext.ctx.ov_ctx.ovadd |= mPipeConfig;
-    mContext.ctx.ov_ctx.ovadd |= 0x1;
-
-    // move to next back buffer
-    //mCurrent = (mCurrent + 1) % OVERLAY_BACK_BUFFER_COUNT;
-
-    VTRACE("ovadd = %#x, index = %d, device = %d",
-          mContext.ctx.ov_ctx.ovadd,
-          mIndex,
-          mDevice);
-
-    return true;
-}
-
-bool TngOverlayPlane::reset()
-{
-    OverlayPlaneBase::reset();
-    if (mRotationBufProvider)
-        mRotationBufProvider->reset();
-    return true;
-}
-
-void* TngOverlayPlane::getContext() const
-{
-    CTRACE();
-    return (void *)&mContext;
-}
-
-bool TngOverlayPlane::setDataBuffer(BufferMapper& mapper)
-{
-    if (OverlayPlaneBase::setDataBuffer(mapper) == false) {
-        return false;
-    }
-
-    if (mIsProtectedBuffer) {
-        // Bit 0: Decryption request, only allowed to change on a synchronous flip
-        // This request will be qualified with the separate decryption enable bit for OV
-        mBackBuffer[mCurrent]->buf->OSTART_0Y |= 0x1;
-        mBackBuffer[mCurrent]->buf->OSTART_1Y |= 0x1;
-    }
-    return true;
-}
-
-bool TngOverlayPlane::initialize(uint32_t bufferCount)
-{
-    if (!OverlayPlaneBase::initialize(bufferCount)) {
-        ETRACE("failed to initialize OverlayPlaneBase");
-        return false;
-    }
-
-    // setup rotation buffer
-    mRotationBufProvider = new RotationBufferProvider(mWsbm);
-    if (!mRotationBufProvider || !mRotationBufProvider->initialize()) {
-        DEINIT_AND_RETURN_FALSE("failed to initialize RotationBufferProvider");
-    }
-    return true;
-}
-
-void TngOverlayPlane::deinitialize()
-{
-    DEINIT_AND_DELETE_OBJ(mRotationBufProvider);
-    OverlayPlaneBase::deinitialize();
-}
-
-bool TngOverlayPlane::rotatedBufferReady(BufferMapper& mapper, BufferMapper* &rotatedMapper)
-{
-    struct VideoPayloadBuffer *payload;
-    VideoPayloadBuffer buffer_info;
-    uint32_t format;
-    // only NV12_VED has rotated buffer
-    format = mapper.getFormat();
-
-    if (format != OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar &&
-        format != OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled &&
-        format != HAL_PIXEL_FORMAT_NV12) {
-        ETRACE("Invalid video format %#x", format);
-        return false;
-    }
-
-    payload = (struct VideoPayloadBuffer *)mapper.getCpuAddress(SUB_BUFFER1);
-
-    if (payload == NULL && format == HAL_PIXEL_FORMAT_NV12) {
-         // need to populate buffer_info
-        void *p = mapper.getCpuAddress(SUB_BUFFER0);
-        if (!p) {
-            ETRACE("failed to get buffer user pointer");
-            return false;
-        }
-
-        bool ret = mRotationBufProvider->prepareBufferInfo(mapper.getWidth(),
-                                                mapper.getHeight(),
-                                                mapper.getStride().yuv.yStride,
-                                                &buffer_info, p);
-        if (ret == false) {
-            ETRACE("failed to prepare buffer info");
-            return false;
-        }
-        payload = &buffer_info;
-    }
-
-    // check payload
-    if (!payload) {
-        ETRACE("no payload found");
-        return false;
-    }
-
-    if (payload->force_output_method == FORCE_OUTPUT_GPU) {
-        ETRACE("Output method is not supported!");
-        return false;
-    }
-
-    if (payload->client_transform != mTransform) {
-        payload->hwc_timestamp = systemTime();
-        payload->layer_transform = mTransform;
-        if (!mRotationBufProvider->setupRotationBuffer(payload, mTransform)) {
-            ETRACE("failed to setup rotation buffer");
-            return false;
-        }
-    }
-
-    rotatedMapper = getTTMMapper(mapper, payload);
-
-    return true;
-}
-
-bool TngOverlayPlane::flush(uint32_t flags)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-    ATRACE("flags = %#x, type = %d, index = %d", flags, mType, mIndex);
-
-    if (!(flags & PLANE_ENABLE) && !(flags & PLANE_DISABLE))
-        return false;
-
-    struct drm_psb_register_rw_arg arg;
-    memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg));
-
-    if (flags & PLANE_DISABLE)
-        arg.plane_disable_mask = 1;
-    else if (flags & PLANE_ENABLE)
-        arg.plane_enable_mask = 1;
-
-    arg.plane.type = DC_OVERLAY_PLANE;
-    arg.plane.index = mIndex;
-    arg.plane.ctx = (mBackBuffer[mCurrent]->gttOffsetInPage << 12);
-    // pipe select
-    arg.plane.ctx |= mPipeConfig;
-
-    if (flags & PLANE_DISABLE) {
-        DTRACE("disabling overlay %d on device %d", mIndex, mDevice);
-    }
-
-    // issue ioctl
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg));
-    if (ret == false) {
-        WTRACE("overlay update failed with error code %d", ret);
-        return false;
-    }
-
-    return true;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/tangier/TngOverlayPlane.h b/ips/tangier/TngOverlayPlane.h
deleted file mode 100644
index 508e368..0000000
--- a/ips/tangier/TngOverlayPlane.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef TNG_OVERLAY_PLANE_H
-#define TNG_OVERLAY_PLANE_H
-
-#include <utils/KeyedVector.h>
-#include <hal_public.h>
-#include <DisplayPlane.h>
-#include <BufferMapper.h>
-#include <ips/common/Wsbm.h>
-#include <ips/common/OverlayPlaneBase.h>
-#include <ips/common/RotationBufferProvider.h>
-
-namespace android {
-namespace intel {
-
-class TngOverlayPlane : public OverlayPlaneBase {
-
-public:
-    TngOverlayPlane(int index, int disp);
-    virtual ~TngOverlayPlane();
-
-    virtual bool flip(void *ctx);
-    virtual bool reset();
-    virtual void* getContext() const;
-
-    virtual bool initialize(uint32_t bufferCount);
-    virtual void deinitialize();
-    virtual bool rotatedBufferReady(BufferMapper& mapper, BufferMapper* &rotatedMapper);
-protected:
-    virtual bool setDataBuffer(BufferMapper& mapper);
-    virtual bool flush(uint32_t flags);
-
-protected:
-    struct intel_dc_plane_ctx mContext;
-    RotationBufferProvider *mRotationBufProvider;
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* TNG_OVERLAY_PLANE_H */
diff --git a/ips/tangier/TngPlaneManager.cpp b/ips/tangier/TngPlaneManager.cpp
deleted file mode 100644
index cb9d0e7..0000000
--- a/ips/tangier/TngPlaneManager.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <tangier/TngPlaneManager.h>
-#include <tangier/TngPrimaryPlane.h>
-#include <tangier/TngSpritePlane.h>
-#include <tangier/TngOverlayPlane.h>
-
-namespace android {
-namespace intel {
-
-TngPlaneManager::TngPlaneManager()
-    : DisplayPlaneManager()
-{
-    memset(&mZorder, 0, sizeof(mZorder));
-}
-
-TngPlaneManager::~TngPlaneManager()
-{
-}
-
-bool TngPlaneManager::initialize()
-{
-    mSpritePlaneCount = 1;  // Sprite D
-    mOverlayPlaneCount = 2;  // Overlay A & C
-    mPrimaryPlaneCount = 3;  // Primary A, B, C
-
-    return DisplayPlaneManager::initialize();
-}
-
-void TngPlaneManager::deinitialize()
-{
-    DisplayPlaneManager::deinitialize();
-}
-
-DisplayPlane* TngPlaneManager::allocPlane(int index, int type)
-{
-    DisplayPlane *plane = 0;
-
-    switch (type) {
-    case DisplayPlane::PLANE_PRIMARY:
-        plane = new TngPrimaryPlane(index, index);
-        break;
-    case DisplayPlane::PLANE_SPRITE:
-        plane = new TngSpritePlane(index, 0);
-        break;
-    case DisplayPlane::PLANE_OVERLAY:
-        plane = new TngOverlayPlane(index, 0);
-        break;
-    default:
-        ETRACE("unsupported type %d", type);
-        break;
-    }
-    if (plane && !plane->initialize(DisplayPlane::MIN_DATA_BUFFER_COUNT)) {
-        ETRACE("failed to initialize plane.");
-        DEINIT_AND_DELETE_OBJ(plane);
-    }
-
-    return plane;
-}
-
-bool TngPlaneManager::isValidZOrder(int dsp, ZOrderConfig& config)
-{
-    // check whether it's a supported z order config
-    int firstRGB = -1;
-    int lastRGB = -1;
-    int firstOverlay = -1;
-    int lastOverlay = -1;
-
-    for (int i = 0; i < (int)config.size(); i++) {
-        const ZOrderLayer *layer = config[i];
-        switch (layer->planeType) {
-        case DisplayPlane::PLANE_PRIMARY:
-        case DisplayPlane::PLANE_SPRITE:
-            if (firstRGB == -1) {
-                firstRGB = i;
-                lastRGB = i;
-            } else {
-                lastRGB = i;
-            }
-            break;
-        case DisplayPlane::PLANE_OVERLAY:
-            if (firstOverlay == -1) {
-                firstOverlay = i;
-                lastOverlay = i;
-            } else {
-                lastOverlay = i;
-            }
-            break;
-        }
-    }
-
-    if ((lastRGB < firstOverlay) || (firstRGB > lastOverlay)) {
-        return true;
-    } else {
-        VTRACE("invalid z order config. rgb (%d, %d) yuv (%d, %d)",
-               firstRGB, lastRGB, firstOverlay, lastOverlay);
-        return false;
-    }
-}
-
-bool TngPlaneManager::assignPlanes(int dsp, ZOrderConfig& config)
-{
-    // probe if plane is available
-    int size = (int)config.size();
-    for (int i = 0; i < size; i++) {
-        const ZOrderLayer *layer = config.itemAt(i);
-        if (!getFreePlanes(dsp, layer->planeType)) {
-            DTRACE("no plane available for dsp %d, type %d", dsp, layer->planeType);
-            return false;
-        }
-    }
-
-    if (config.size() == 1 && config[0]->planeType == DisplayPlane::PLANE_SPRITE) {
-        config[0]->planeType == DisplayPlane::PLANE_PRIMARY;
-    }
-
-    // allocate planes
-    for (int i = 0; i < size; i++) {
-        ZOrderLayer *layer = config.itemAt(i);
-        layer->plane = getPlaneHelper(dsp, layer->planeType);
-        if (layer->plane == NULL) {
-            // should never happen!!
-            ETRACE("failed to assign plane for type %d", layer->planeType);
-        }
-        // sequence !!!!! enabling plane before setting zorder
-        // see TngSpritePlane::enablePlane implementation!!!!
-        layer->plane->enable();
-    }
-
-    // setup Z order
-    for (int i = 0; i < size; i++) {
-        ZOrderLayer *layer = config.itemAt(i);
-        layer->plane->setZOrderConfig(config, &mZorder);
-    }
-
-    return true;
-}
-
-void* TngPlaneManager::getZOrderConfig() const
-{
-    return (void*)&mZorder;
-}
-
-DisplayPlane* TngPlaneManager::getPlaneHelper(int dsp, int type)
-{
-    RETURN_NULL_IF_NOT_INIT();
-
-    if (dsp < 0 || dsp > IDisplayDevice::DEVICE_EXTERNAL) {
-        ETRACE("Invalid display device %d", dsp);
-        return 0;
-    }
-
-    int index = dsp == IDisplayDevice::DEVICE_PRIMARY ? 0 : 1;
-
-    if (type == DisplayPlane::PLANE_PRIMARY) {
-        return getPlane(type, index);
-    } else if (type == DisplayPlane::PLANE_SPRITE) {
-        return getAnyPlane(type);
-    } else if (type == DisplayPlane::PLANE_OVERLAY) {
-        // use overlay A for pipe A and overlay C for pipe B if possible
-        DisplayPlane *plane = getPlane(type, index);
-        if (plane == NULL) {
-            plane = getPlane(type, !index);
-        }
-        return plane;
-    } else {
-        ETRACE("invalid plane type %d", type);
-        return 0;
-    }
-}
-
-} // namespace intel
-} // namespace android
-
diff --git a/ips/tangier/TngPlaneManager.h b/ips/tangier/TngPlaneManager.h
deleted file mode 100644
index e6717bb..0000000
--- a/ips/tangier/TngPlaneManager.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef TNG_PLANE_MANAGER_H
-#define TNG_PLANE_MANAGER_H
-
-#include <DisplayPlaneManager.h>
-#include <linux/psb_drm.h>
-
-namespace android {
-namespace intel {
-
-class TngPlaneManager : public DisplayPlaneManager {
-public:
-    TngPlaneManager();
-    virtual ~TngPlaneManager();
-
-public:
-    virtual bool initialize();
-    virtual void deinitialize();
-    virtual bool isValidZOrder(int dsp, ZOrderConfig& config);
-    virtual bool assignPlanes(int dsp, ZOrderConfig& config);
-    // TODO: remove this API
-    virtual void* getZOrderConfig() const;
-
-protected:
-    DisplayPlane* allocPlane(int index, int type);
-    DisplayPlane* getPlaneHelper(int dsp, int type);
-
-private:
-    struct intel_dc_plane_zorder mZorder;
-};
-
-} // namespace intel
-} // namespace android
-
-
-#endif /* TNG_PLANE_MANAGER_H */
diff --git a/ips/tangier/TngPrimaryPlane.cpp b/ips/tangier/TngPrimaryPlane.cpp
deleted file mode 100644
index c637bdc..0000000
--- a/ips/tangier/TngPrimaryPlane.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <common/base/Drm.h>
-#include <tangier/TngPrimaryPlane.h>
-#include <ips/tangier/TngGrallocBuffer.h>
-#include <ips/common/PixelFormat.h>
-
-namespace android {
-namespace intel {
-
-TngPrimaryPlane::TngPrimaryPlane(int index, int disp)
-    : TngSpritePlane(index, disp)
-{
-    CTRACE();
-    mType = PLANE_PRIMARY;
-    mForceBottom = true;
-    mAbovePrimary = false;
-}
-
-TngPrimaryPlane::~TngPrimaryPlane()
-{
-    CTRACE();
-}
-
-void TngPrimaryPlane::setFramebufferTarget(uint32_t handle)
-{
-    CTRACE();
-
-    // do not need to update the buffer handle
-    if (mCurrentDataBuffer != handle)
-        mUpdateMasks |= PLANE_BUFFER_CHANGED;
-    else
-        mUpdateMasks &= ~PLANE_BUFFER_CHANGED;
-
-    // if no update then do Not need set data buffer
-    if (!mUpdateMasks)
-        return;
-
-    // don't need to map data buffer for primary plane
-    mContext.type = DC_PRIMARY_PLANE;
-    mContext.ctx.prim_ctx.update_mask = SPRITE_UPDATE_ALL;
-    mContext.ctx.prim_ctx.index = mIndex;
-    mContext.ctx.prim_ctx.pipe = mDevice;
-    mContext.ctx.prim_ctx.linoff = 0;
-    mContext.ctx.prim_ctx.stride = align_to((4 * align_to(mPosition.w, 32)), 64);
-    mContext.ctx.prim_ctx.pos = 0;
-    mContext.ctx.prim_ctx.size =
-        ((mPosition.h - 1) & 0xfff) << 16 | ((mPosition.w - 1) & 0xfff);
-    mContext.ctx.prim_ctx.surf = 0;
-    mContext.ctx.prim_ctx.contalpa = 0;
-
-    mContext.ctx.prim_ctx.cntr = PixelFormat::PLANE_PIXEL_FORMAT_BGRA8888;
-    mContext.ctx.prim_ctx.cntr |= 0x80000000;
-
-    mCurrentDataBuffer = handle;
-}
-
-bool TngPrimaryPlane::enablePlane(bool enabled)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    struct drm_psb_register_rw_arg arg;
-    memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg));
-    if (enabled) {
-        arg.plane_enable_mask = 1;
-    } else {
-        arg.plane_disable_mask = 1;
-    }
-    arg.plane.type = DC_PRIMARY_PLANE;
-    arg.plane.index = mIndex;
-    arg.plane.ctx = 0;
-
-    // issue ioctl
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg));
-    if (ret == false) {
-        WTRACE("primary enabling (%d) failed with error code %d", enabled, ret);
-        return false;
-    }
-
-    return true;
-
-}
-
-bool TngPrimaryPlane::setDataBuffer(uint32_t handle)
-{
-    if (!handle) {
-        setFramebufferTarget(handle);
-        return true;
-    }
-
-    TngGrallocBuffer tmpBuf(handle);
-    uint32_t usage;
-    bool ret;
-
-    ATRACE("handle = %#x", handle);
-
-    usage = tmpBuf.getUsage();
-    if (GRALLOC_USAGE_HW_FB & usage) {
-        setFramebufferTarget(handle);
-        return true;
-    }
-
-    // use primary as a sprite
-    ret = DisplayPlane::setDataBuffer(handle);
-    if (ret == false) {
-        ETRACE("failed to set data buffer");
-        return ret;
-    }
-
-    mContext.type = DC_PRIMARY_PLANE;
-    return true;
-}
-
-void TngPrimaryPlane::setZOrderConfig(ZOrderConfig& zorderConfig,
-                                           void *nativeConfig)
-{
-    if (!nativeConfig) {
-        ETRACE("Invalid parameter, no native config");
-        return;
-    }
-
-    mForceBottom = false;
-
-    int primaryIndex = -1;
-    int overlayIndex = -1;
-    // only consider force bottom when overlay is active
-    for (size_t i = 0; i < zorderConfig.size(); i++) {
-        DisplayPlane *plane = zorderConfig[i]->plane;
-        if (plane->getType() == DisplayPlane::PLANE_PRIMARY)
-            primaryIndex = i;
-        if (plane->getType() == DisplayPlane::PLANE_OVERLAY) {
-            overlayIndex = i;
-        }
-    }
-
-    // if has overlay plane which is below primary plane
-    if (overlayIndex > primaryIndex) {
-        mForceBottom = true;
-    }
-
-    struct intel_dc_plane_zorder *zorder =
-        (struct intel_dc_plane_zorder *)nativeConfig;
-    zorder->forceBottom[mIndex] = mForceBottom ? 1 : 0;
-}
-
-bool TngPrimaryPlane::assignToDevice(int disp)
-{
-    return true;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/ips/tangier/TngPrimaryPlane.h b/ips/tangier/TngPrimaryPlane.h
deleted file mode 100644
index 677e403..0000000
--- a/ips/tangier/TngPrimaryPlane.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef TNG_PRIMARY_PLANE_H
-#define TNG_PRIMARY_PLANE_H
-
-#include <tangier/TngSpritePlane.h>
-
-namespace android {
-namespace intel {
-
-class TngPrimaryPlane : public TngSpritePlane {
-public:
-    TngPrimaryPlane(int index, int disp);
-    virtual ~TngPrimaryPlane();
-public:
-    bool setDataBuffer(uint32_t handle);
-    void setZOrderConfig(ZOrderConfig& config, void *nativeConfig);
-    bool assignToDevice(int disp);
-private:
-    void setFramebufferTarget(uint32_t handle);
-    bool enablePlane(bool enabled);
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* TNG_PRIMARY_PLANE_H */
diff --git a/ips/tangier/TngSpritePlane.cpp b/ips/tangier/TngSpritePlane.cpp
deleted file mode 100644
index f334a4a..0000000
--- a/ips/tangier/TngSpritePlane.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <Hwcomposer.h>
-#include <BufferManager.h>
-#include <tangier/TngSpritePlane.h>
-#include <ips/common/PixelFormat.h>
-
-namespace android {
-namespace intel {
-
-TngSpritePlane::TngSpritePlane(int index, int disp)
-    : SpritePlaneBase(index, disp)
-{
-    CTRACE();
-    memset(&mContext, 0, sizeof(mContext));
-}
-
-TngSpritePlane::~TngSpritePlane()
-{
-    CTRACE();
-}
-
-bool TngSpritePlane::setDataBuffer(BufferMapper& mapper)
-{
-    int bpp;
-    int srcX, srcY;
-    int dstX, dstY, dstW, dstH;
-    uint32_t spriteFormat;
-    uint32_t stride;
-    uint32_t linoff;
-    uint32_t planeAlpha;
-
-    CTRACE();
-
-    // setup plane position
-    dstX = mPosition.x;
-    dstY = mPosition.y;
-    dstW = mPosition.w;
-    dstH = mPosition.h;
-
-    checkPosition(dstX, dstY, dstW, dstH);
-
-    // setup plane format
-    if (!PixelFormat::convertFormat(mapper.getFormat(), spriteFormat, bpp)) {
-        ETRACE("unsupported format %#x", mapper.getFormat());
-        return false;
-    }
-
-    // setup stride and source buffer crop
-    srcX = mapper.getCrop().x;
-    srcY = mapper.getCrop().y;
-    stride = mapper.getStride().rgb.stride;
-    linoff = srcY * stride + srcX * bpp;
-
-    // setup plane alpha
-    if ((mBlending == HWC_BLENDING_PREMULT) && (mPlaneAlpha == 0)) {
-       planeAlpha = mPlaneAlpha | 0x80000000;
-    } else {
-       // disable plane alpha to offload HW
-       planeAlpha = 0;
-    }
-
-    // unlikely happen, but still we need make sure linoff is valid
-    if (linoff > (stride * mapper.getHeight())) {
-        ETRACE("invalid source crop");
-        return false;
-    }
-
-    // update context
-    mContext.type = DC_SPRITE_PLANE;
-    mContext.ctx.sp_ctx.index = mIndex;
-    mContext.ctx.sp_ctx.pipe = mDevice;
-    mContext.ctx.sp_ctx.cntr = spriteFormat | 0x80000000;
-    mContext.ctx.sp_ctx.linoff = linoff;
-    mContext.ctx.sp_ctx.stride = stride;
-    mContext.ctx.sp_ctx.surf = mapper.getGttOffsetInPage(0) << 12;
-    mContext.ctx.sp_ctx.pos = (dstY & 0xfff) << 16 | (dstX & 0xfff);
-    mContext.ctx.sp_ctx.size =
-        ((dstH - 1) & 0xfff) << 16 | ((dstW - 1) & 0xfff);
-    mContext.ctx.sp_ctx.contalpa = planeAlpha;
-    mContext.ctx.sp_ctx.update_mask = SPRITE_UPDATE_ALL;
-
-    VTRACE("cntr = %#x, linoff = %#x, stride = %#x,"
-          "surf = %#x, pos = %#x, size = %#x, contalpa = %#x",
-          mContext.ctx.sp_ctx.cntr,
-          mContext.ctx.sp_ctx.linoff,
-          mContext.ctx.sp_ctx.stride,
-          mContext.ctx.sp_ctx.surf,
-          mContext.ctx.sp_ctx.pos,
-          mContext.ctx.sp_ctx.size,
-          mContext.ctx.sp_ctx.contalpa);
-    return true;
-}
-
-void* TngSpritePlane::getContext() const
-{
-    CTRACE();
-    return (void *)&mContext;
-}
-
-bool TngSpritePlane::enablePlane(bool enabled)
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    struct drm_psb_register_rw_arg arg;
-    memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg));
-    if (enabled) {
-        arg.plane_enable_mask = 1;
-    } else {
-        arg.plane_disable_mask = 1;
-    }
-    arg.plane.type = DC_SPRITE_PLANE;
-    arg.plane.index = mIndex;
-    arg.plane.ctx = 0;
-
-    // issue ioctl
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg));
-    if (ret == false) {
-        WTRACE("sprite enabling (%d) failed with error code %d", enabled, ret);
-        return false;
-    }
-
-    Hwcomposer& hwc = Hwcomposer::getInstance();
-    DisplayPlaneManager *pm = hwc.getPlaneManager();
-    void *config = pm->getZOrderConfig();
-    if (config != NULL) {
-        struct intel_dc_plane_zorder *zorder =  (struct intel_dc_plane_zorder *)config;
-        zorder->abovePrimary = 0;
-    }
-
-    return true;
-
-}
-
-bool TngSpritePlane::isDisabled()
-{
-    RETURN_FALSE_IF_NOT_INIT();
-
-    struct drm_psb_register_rw_arg arg;
-    memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg));
-
-    if (mType == DisplayPlane::PLANE_SPRITE)
-        arg.plane.type = DC_SPRITE_PLANE;
-    else
-        arg.plane.type = DC_PRIMARY_PLANE;
-
-    arg.get_plane_state_mask = 1;
-    arg.plane.index = mIndex;
-    arg.plane.ctx = 0;
-
-    // issue ioctl
-    Drm *drm = Hwcomposer::getInstance().getDrm();
-    bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg));
-    if (ret == false) {
-        WTRACE("plane state query failed with error code %d", ret);
-        return false;
-    }
-
-    return arg.plane.ctx == PSB_DC_PLANE_DISABLED;
-}
-
-void TngSpritePlane::setZOrderConfig(ZOrderConfig& zorderConfig,
-                                          void *nativeConfig)
-{
-    if (!nativeConfig) {
-        ETRACE("Invalid parameter, no native config");
-        return;
-    }
-
-    mAbovePrimary = false;
-
-    int primaryIndex = -1;
-    int spriteIndex = -1;
-    // only consider force bottom when overlay is active
-    for (size_t i = 0; i < zorderConfig.size(); i++) {
-        DisplayPlane *plane = zorderConfig[i]->plane;
-        if (plane->getType() == DisplayPlane::PLANE_PRIMARY)
-            primaryIndex = i;
-        if (plane->getType() == DisplayPlane::PLANE_SPRITE) {
-            spriteIndex = i;
-        }
-    }
-
-    // if has overlay plane which is below primary plane
-    if (spriteIndex > primaryIndex) {
-        mAbovePrimary = true;
-    }
-
-    struct intel_dc_plane_zorder *zorder =
-        (struct intel_dc_plane_zorder *)nativeConfig;
-    zorder->abovePrimary = mAbovePrimary ? 1 : 0;
-}
-} // namespace intel
-} // namespace android
diff --git a/ips/tangier/TngSpritePlane.h b/ips/tangier/TngSpritePlane.h
deleted file mode 100644
index b70f1d7..0000000
--- a/ips/tangier/TngSpritePlane.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef TNG_SPRITE_PLANE_H
-#define TNG_SPRITE_PLANE_H
-
-#include <utils/KeyedVector.h>
-#include <hal_public.h>
-#include <Hwcomposer.h>
-#include <common/buffers/BufferCache.h>
-#include <DisplayPlane.h>
-
-#include <ips/common/SpritePlaneBase.h>
-
-namespace android {
-namespace intel {
-
-class TngSpritePlane : public SpritePlaneBase {
-public:
-    TngSpritePlane(int index, int disp);
-    virtual ~TngSpritePlane();
-public:
-    virtual void* getContext() const;
-    virtual void setZOrderConfig(ZOrderConfig& config, void *nativeConfig);
-    virtual bool isDisabled();
-protected:
-    virtual bool setDataBuffer(BufferMapper& mapper);
-    virtual bool enablePlane(bool enabled);
-protected:
-    struct intel_dc_plane_ctx mContext;
-};
-
-} // namespace intel
-} // namespace android
-
-#endif /* TNG_SPRITE_PLANE_H */
diff --git a/merrifield.mk b/merrifield.mk
deleted file mode 100644
index b692479..0000000
--- a/merrifield.mk
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation, not prelinked and stored in
-# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
-LOCAL_CFLAGS:= -DLINUX
-
-LOCAL_SHARED_LIBRARIES := liblog libcutils libdrm \
-                          libwsbm libutils libhardware \
-                          libva libva-tpi libva-android \
-                          libhwcwidi libbinder libsync
-
-LOCAL_SRC_FILES := \
-    common/base/Drm.cpp \
-    common/base/HwcLayer.cpp \
-    common/base/HwcLayerList.cpp \
-    common/base/Hwcomposer.cpp \
-    common/base/HwcModule.cpp \
-    common/base/DisplayAnalyzer.cpp \
-    common/base/VsyncManager.cpp \
-    common/buffers/BufferCache.cpp \
-    common/buffers/GraphicBuffer.cpp \
-    common/buffers/BufferManager.cpp \
-    common/devices/PhysicalDevice.cpp \
-    common/devices/PrimaryDevice.cpp \
-    common/devices/ExternalDevice.cpp \
-    common/devices/VirtualDevice.cpp \
-    common/observers/UeventObserver.cpp \
-    common/observers/VsyncEventObserver.cpp \
-    common/observers/SoftVsyncObserver.cpp \
-    common/observers/MultiDisplayObserver.cpp \
-    common/planes/DisplayPlane.cpp \
-    common/planes/DisplayPlaneManager.cpp \
-    common/utils/Dump.cpp
-
-LOCAL_SRC_FILES += \
-    ips/common/BlankControl.cpp \
-    ips/common/PowerManager.cpp \
-    ips/common/HdcpControl.cpp \
-    ips/common/DrmControl.cpp \
-    ips/common/VsyncControl.cpp \
-    ips/common/PrepareListener.cpp \
-    ips/common/OverlayPlaneBase.cpp \
-    ips/common/SpritePlaneBase.cpp \
-    ips/common/PixelFormat.cpp \
-    ips/common/PlaneCapabilities.cpp \
-    ips/common/GrallocBufferBase.cpp \
-    ips/common/GrallocBufferMapperBase.cpp \
-    ips/common/TTMBufferMapper.cpp \
-    ips/common/DrmConfig.cpp \
-    ips/common/VideoPayloadManager.cpp \
-    ips/common/Wsbm.cpp \
-    ips/common/WsbmWrapper.c \
-    ips/common/RotationBufferProvider.cpp
-
-LOCAL_SRC_FILES += \
-    ips/tangier/TngGrallocBuffer.cpp \
-    ips/tangier/TngGrallocBufferMapper.cpp \
-    ips/tangier/TngOverlayPlane.cpp \
-    ips/tangier/TngPrimaryPlane.cpp \
-    ips/tangier/TngSpritePlane.cpp \
-    ips/tangier/TngDisplayQuery.cpp \
-    ips/tangier/TngPlaneManager.cpp \
-    ips/tangier/TngDisplayContext.cpp
-
-LOCAL_SRC_FILES += \
-    platforms/merrifield/PlatfBufferManager.cpp \
-    platforms/merrifield/PlatfPrimaryDevice.cpp \
-    platforms/merrifield/PlatfExternalDevice.cpp \
-    platforms/merrifield/PlatfVirtualDevice.cpp \
-    platforms/merrifield/PlatfHwcomposer.cpp
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(TARGET_OUT_HEADERS)/libdrm \
-    $(TARGET_OUT_HEADERS)/libwsbm/wsbm \
-    $(TARGET_OUT_HEADERS)/libttm \
-    frameworks/native/include/media/openmax \
-    vendor/intel/hardware/anniedale/rgx/include \
-    vendor/intel/hardware/PRIVATE/rgx/rogue/android/graphicshal
-
-ifeq ($(TARGET_HAS_MULTIPLE_DISPLAY),true)
-   LOCAL_SHARED_LIBRARIES += libmultidisplay libbinder
-   LOCAL_CFLAGS += -DTARGET_HAS_MULTIPLE_DISPLAY
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/merrifield_plus.mk b/merrifield_plus.mk
deleted file mode 100644
index 863b683..0000000
--- a/merrifield_plus.mk
+++ /dev/null
@@ -1,119 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation, not prelinked and stored in
-# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
-LOCAL_CFLAGS := -Werror
-
-LOCAL_SHARED_LIBRARIES := liblog libcutils libdrm \
-                          libwsbm libutils libhardware \
-                          libva libva-tpi libva-android libsync
-
-LOCAL_SRC_FILES := \
-    common/base/Drm.cpp \
-    common/base/HwcLayer.cpp \
-    common/base/HwcLayerList.cpp \
-    common/base/Hwcomposer.cpp \
-    common/base/HwcModule.cpp \
-    common/base/DisplayAnalyzer.cpp \
-    common/base/VsyncManager.cpp \
-    common/buffers/BufferCache.cpp \
-    common/buffers/GraphicBuffer.cpp \
-    common/buffers/BufferManager.cpp \
-    common/devices/DummyDevice.cpp \
-    common/devices/PhysicalDevice.cpp \
-    common/devices/PrimaryDevice.cpp \
-    common/devices/ExternalDevice.cpp \
-    common/observers/UeventObserver.cpp \
-    common/observers/VsyncEventObserver.cpp \
-    common/observers/SoftVsyncObserver.cpp \
-    common/observers/MultiDisplayObserver.cpp \
-    common/planes/DisplayPlane.cpp \
-    common/planes/DisplayPlaneManager.cpp \
-    common/utils/Dump.cpp
-
-LOCAL_SRC_FILES += \
-    ips/common/BlankControl.cpp \
-    ips/common/PowerManager.cpp \
-    ips/common/HdcpControl.cpp \
-    ips/common/DrmControl.cpp \
-    ips/common/VsyncControl.cpp \
-    ips/common/PrepareListener.cpp \
-    ips/common/OverlayPlaneBase.cpp \
-    ips/common/SpritePlaneBase.cpp \
-    ips/common/PixelFormat.cpp \
-    ips/common/GrallocBufferBase.cpp \
-    ips/common/GrallocBufferMapperBase.cpp \
-    ips/common/TTMBufferMapper.cpp \
-    ips/common/DrmConfig.cpp \
-    ips/common/VideoPayloadManager.cpp \
-    ips/common/Wsbm.cpp \
-    ips/common/WsbmWrapper.c \
-    ips/common/RotationBufferProvider.cpp
-
-LOCAL_SRC_FILES += \
-    ips/tangier/TngGrallocBuffer.cpp \
-    ips/tangier/TngGrallocBufferMapper.cpp \
-    ips/tangier/TngDisplayQuery.cpp \
-    ips/tangier/TngDisplayContext.cpp
-
-LOCAL_SRC_FILES += \
-    ips/anniedale/AnnPlaneManager.cpp \
-    ips/anniedale/AnnOverlayPlane.cpp \
-    ips/anniedale/AnnRGBPlane.cpp \
-    ips/anniedale/PlaneCapabilities.cpp
-
-LOCAL_SRC_FILES += \
-    platforms/merrifield_plus/PlatfBufferManager.cpp \
-    platforms/merrifield_plus/PlatfPrimaryDevice.cpp \
-    platforms/merrifield_plus/PlatfExternalDevice.cpp \
-    platforms/merrifield_plus/PlatfHwcomposer.cpp
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(TARGET_OUT_HEADERS)/libdrm \
-    $(TARGET_OUT_HEADERS)/libwsbm/wsbm \
-    $(TARGET_OUT_HEADERS)/libttm \
-    frameworks/native/include/media/openmax \
-    vendor/intel/moorefield/prebuilts/hardware/rgx/include \
-    vendor/intel/hardware/anniedale/rgx/include \
-    $(TARGET_OUT_HEADERS)/pvr/hal
-
-ifeq ($(INTEL_WIDI_MERRIFIELD), true)
-LOCAL_SRC_FILES += \
-    common/devices/VirtualDevice.cpp \
-    platforms/merrifield_plus/PlatfVirtualDevice.cpp
-
-    #LOCAL_SHARED_LIBRARIES += libhwcwidi libbinder
-    LOCAL_CFLAGS += -DINTEL_WIDI_MERRIFIELD
-endif
-
-ifeq ($(TARGET_HAS_MULTIPLE_DISPLAY),true)
-    LOCAL_SHARED_LIBRARIES += libmultidisplay libbinder
-    LOCAL_CFLAGS += -DTARGET_HAS_MULTIPLE_DISPLAY
-endif
-
-ifeq ($(TARGET_SUPPORT_HDMI_PRIMARY),true)
-   LOCAL_CFLAGS += -DINTEL_SUPPORT_HDMI_PRIMARY
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/platforms/merrifield/PlatfBufferManager.cpp b/platforms/merrifield/PlatfBufferManager.cpp
deleted file mode 100644
index fcff8b5..0000000
--- a/platforms/merrifield/PlatfBufferManager.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <platforms/merrifield/PlatfBufferManager.h>
-#include <ips/tangier/TngGrallocBuffer.h>
-#include <tangier/TngGrallocBufferMapper.h>
-
-namespace android {
-namespace intel {
-
-PlatfBufferManager::PlatfBufferManager()
-    : BufferManager()
-{
-
-}
-
-PlatfBufferManager::~PlatfBufferManager()
-{
-
-}
-
-bool PlatfBufferManager::initialize()
-{
-    return BufferManager::initialize();
-}
-
-void PlatfBufferManager::deinitialize()
-{
-    BufferManager::deinitialize();
-}
-
-DataBuffer* PlatfBufferManager::createDataBuffer(gralloc_module_t *module,
-                                                 uint32_t handle)
-{
-    return new TngGrallocBuffer(handle);
-}
-
-BufferMapper* PlatfBufferManager::createBufferMapper(gralloc_module_t *module,
-                                                        DataBuffer& buffer)
-{
-    if (!module)
-        return 0;
-
-    return new TngGrallocBufferMapper(*(IMG_gralloc_module_public_t*)module,
-                                        buffer);
-}
-
-bool PlatfBufferManager::convertRGBToNV12(uint32_t rgbHandle, uint32_t yuvHandle,
-                                  crop_t& srcCrop, uint32_t async)
-
-{
-    IMG_gralloc_module_public_t *imgGrallocModule = (IMG_gralloc_module_public_t *) mGrallocModule;
-    if (imgGrallocModule->Blit(imgGrallocModule, (buffer_handle_t)rgbHandle,
-                                (buffer_handle_t)yuvHandle,
-                                srcCrop.w, srcCrop.h, srcCrop.x,
-                                srcCrop.y, 0, async)) {
-        ETRACE("Blit failed");
-        return false;
-    }
-    return true;
-}
-
-} // namespace intel
-} // namespace android
diff --git a/platforms/merrifield/PlatfBufferManager.h b/platforms/merrifield/PlatfBufferManager.h
deleted file mode 100644
index 0eb8c64..0000000
--- a/platforms/merrifield/PlatfBufferManager.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_BUFFER_MANAGER_H
-#define PLATF_BUFFER_MANAGER_H
-
-#include <BufferManager.h>
-
-namespace android {
-namespace intel {
-
-class PlatfBufferManager : public BufferManager {
-public:
-    PlatfBufferManager();
-    virtual ~PlatfBufferManager();
-
-public:
-    bool initialize();
-    void deinitialize();
-
-protected:
-    DataBuffer* createDataBuffer(gralloc_module_t *module, uint32_t handle);
-    BufferMapper* createBufferMapper(gralloc_module_t *module,
-                                        DataBuffer& buffer);
-    bool convertRGBToNV12(uint32_t rgbHandle, uint32_t yuvHandle,
-                                  crop_t& srcCrop, uint32_t async);
-};
-
-}
-}
-#endif /* PLATF_BUFFER_MANAGER_H */
diff --git a/platforms/merrifield/PlatfExternalDevice.cpp b/platforms/merrifield/PlatfExternalDevice.cpp
deleted file mode 100644
index f061468..0000000
--- a/platforms/merrifield/PlatfExternalDevice.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <platforms/merrifield/PlatfExternalDevice.h>
-#include <ips/common/VsyncControl.h>
-#include <ips/common/BlankControl.h>
-#include <ips/common/HdcpControl.h>
-#include <ips/common/PrepareListener.h>
-
-
-namespace android {
-namespace intel {
-
-PlatfExternalDevice::PlatfExternalDevice(Hwcomposer& hwc,
-                                       DisplayPlaneManager& dpm)
-    : ExternalDevice(hwc, dpm)
-{
-    CTRACE();
-}
-
-PlatfExternalDevice::~PlatfExternalDevice()
-{
-    CTRACE();
-}
-
-IVsyncControl* PlatfExternalDevice::createVsyncControl()
-{
-    return new VsyncControl();
-}
-
-IBlankControl* PlatfExternalDevice::createBlankControl()
-{
-    return new BlankControl();
-}
-
-IPrepareListener* PlatfExternalDevice::createPrepareListener()
-{
-    return new PrepareListener();
-}
-
-IHdcpControl* PlatfExternalDevice::createHdcpControl()
-{
-    return new HdcpControl();
-}
-
-} // namespace intel
-} // namespace android
-
-
diff --git a/platforms/merrifield/PlatfExternalDevice.h b/platforms/merrifield/PlatfExternalDevice.h
deleted file mode 100644
index b1525aa..0000000
--- a/platforms/merrifield/PlatfExternalDevice.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_EXTERNAL_DEVICE_H
-#define PLATF_EXTERNAL_DEVICE_H
-
-#include <hal_public.h>
-#include <ExternalDevice.h>
-
-namespace android {
-namespace intel {
-
-class PlatfExternalDevice : public ExternalDevice {
-public:
-    PlatfExternalDevice(Hwcomposer& hwc,
-                        DisplayPlaneManager& dpm);
-    virtual ~PlatfExternalDevice();
-
-protected:
-    IVsyncControl* createVsyncControl();
-    IBlankControl* createBlankControl();
-    IPrepareListener* createPrepareListener();
-    IHdcpControl* createHdcpControl();
-};
-
-}
-}
-#endif /* PLATF_EXTERNAL_DEVICE_H */
diff --git a/platforms/merrifield/PlatfHwcomposer.cpp b/platforms/merrifield/PlatfHwcomposer.cpp
deleted file mode 100644
index ff18610..0000000
--- a/platforms/merrifield/PlatfHwcomposer.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <hal_public.h>
-#include <common/utils/HwcTrace.h>
-#include <ips/common/PowerManager.h>
-#include <tangier/TngDisplayContext.h>
-#include <tangier/TngPlaneManager.h>
-#include <platforms/merrifield/PlatfBufferManager.h>
-#include <IDisplayDevice.h>
-#include <platforms/merrifield/PlatfPrimaryDevice.h>
-#include <platforms/merrifield/PlatfExternalDevice.h>
-#include <platforms/merrifield/PlatfVirtualDevice.h>
-#include <platforms/merrifield/PlatfHwcomposer.h>
-
-
-
-namespace android {
-namespace intel {
-
-PlatfHwcomposer::PlatfHwcomposer()
-    : Hwcomposer()
-{
-    CTRACE();
-}
-
-PlatfHwcomposer::~PlatfHwcomposer()
-{
-    CTRACE();
-}
-
-DisplayPlaneManager* PlatfHwcomposer::createDisplayPlaneManager()
-{
-    CTRACE();
-    return (new TngPlaneManager());
-}
-
-BufferManager* PlatfHwcomposer::createBufferManager()
-{
-    CTRACE();
-    return (new PlatfBufferManager());
-}
-
-IDisplayDevice* PlatfHwcomposer::createDisplayDevice(int disp,
-                                                     DisplayPlaneManager& dpm)
-{
-    CTRACE();
-
-    switch (disp) {
-        case IDisplayDevice::DEVICE_PRIMARY:
-            return new PlatfPrimaryDevice(*this, dpm);
-        case IDisplayDevice::DEVICE_EXTERNAL:
-            return new PlatfExternalDevice(*this, dpm);
-        case IDisplayDevice::DEVICE_VIRTUAL:
-            return new PlatfVirtualDevice(*this, dpm);
-        default:
-            ETRACE("invalid display device %d", disp);
-            return NULL;
-    }
-}
-
-IDisplayContext* PlatfHwcomposer::createDisplayContext()
-{
-    CTRACE();
-    return new TngDisplayContext();
-}
-
-IPowerManager* PlatfHwcomposer::createPowerManager()
-{
-    return new PowerManager();
-}
-
-Hwcomposer* Hwcomposer::createHwcomposer()
-{
-    CTRACE();
-    return new PlatfHwcomposer();
-}
-
-} //namespace intel
-} //namespace android
diff --git a/platforms/merrifield/PlatfHwcomposer.h b/platforms/merrifield/PlatfHwcomposer.h
deleted file mode 100644
index ba19c96..0000000
--- a/platforms/merrifield/PlatfHwcomposer.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_HWCOMPOSER_H
-#define PLATF_HWCOMPOSER_H
-
-#include <hal_public.h>
-#include <Hwcomposer.h>
-
-namespace android {
-namespace intel {
-
-class PlatfHwcomposer : public Hwcomposer {
-public:
-    PlatfHwcomposer();
-    virtual ~PlatfHwcomposer();
-
-protected:
-    DisplayPlaneManager* createDisplayPlaneManager();
-    BufferManager* createBufferManager();
-    IDisplayDevice* createDisplayDevice(int disp, DisplayPlaneManager& dpm);
-    IDisplayContext* createDisplayContext();
-    IPowerManager* createPowerManager();
-};
-
-} //namespace intel
-} //namespace android
-
-#endif /* PLATF_HWCOMPOSER_H */
diff --git a/platforms/merrifield/PlatfPrimaryDevice.cpp b/platforms/merrifield/PlatfPrimaryDevice.cpp
deleted file mode 100644
index 78e3a9e..0000000
--- a/platforms/merrifield/PlatfPrimaryDevice.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <platforms/merrifield/PlatfPrimaryDevice.h>
-#include <ips/common/VsyncControl.h>
-#include <ips/common/BlankControl.h>
-#include <ips/common/PrepareListener.h>
-
-
-namespace android {
-namespace intel {
-
-PlatfPrimaryDevice::PlatfPrimaryDevice(Hwcomposer& hwc,
-                                       DisplayPlaneManager& dpm)
-    : PrimaryDevice(hwc, dpm)
-{
-    CTRACE();
-}
-
-PlatfPrimaryDevice::~PlatfPrimaryDevice()
-{
-    CTRACE();
-}
-
-IVsyncControl* PlatfPrimaryDevice::createVsyncControl()
-{
-    return new VsyncControl();
-}
-
-IBlankControl* PlatfPrimaryDevice::createBlankControl()
-{
-    return new BlankControl();
-}
-
-IPrepareListener* PlatfPrimaryDevice::createPrepareListener()
-{
-    return new PrepareListener();
-}
-
-} // namespace intel
-} // namespace android
-
-
diff --git a/platforms/merrifield/PlatfPrimaryDevice.h b/platforms/merrifield/PlatfPrimaryDevice.h
deleted file mode 100644
index bd4af4d..0000000
--- a/platforms/merrifield/PlatfPrimaryDevice.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_PRIMARY_DEVICE_H
-#define PLATF_PRIMARY_DEVICE_H
-
-#include <hal_public.h>
-#include <PrimaryDevice.h>
-
-namespace android {
-namespace intel {
-
-class PlatfPrimaryDevice : public PrimaryDevice {
-public:
-    PlatfPrimaryDevice(Hwcomposer& hwc,
-                        DisplayPlaneManager& dpm);
-    virtual ~PlatfPrimaryDevice();
-
-protected:
-    IVsyncControl* createVsyncControl();
-    IBlankControl* createBlankControl();
-    IPrepareListener* createPrepareListener();
-};
-
-}
-}
-#endif /* PLATF_PRIMARY_DEVICE_H */
diff --git a/platforms/merrifield/PlatfVirtualDevice.cpp b/platforms/merrifield/PlatfVirtualDevice.cpp
deleted file mode 100644
index b61ca11..0000000
--- a/platforms/merrifield/PlatfVirtualDevice.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <Hwcomposer.h>
-#include <DisplayPlaneManager.h>
-#include <platforms/merrifield/PlatfVirtualDevice.h>
-#include <ips/common/VideoPayloadManager.h>
-
-namespace android {
-namespace intel {
-
-PlatfVirtualDevice::PlatfVirtualDevice(Hwcomposer& hwc,
-                                       DisplayPlaneManager& dpm)
-    : VirtualDevice(hwc, dpm)
-{
-    CTRACE();
-}
-
-PlatfVirtualDevice::~PlatfVirtualDevice()
-{
-    CTRACE();
-}
-
-IVideoPayloadManager* PlatfVirtualDevice::createVideoPayloadManager()
-{
-    return new VideoPayloadManager();
-}
-
-
-} // namespace intel
-} // namespace android
-
-
diff --git a/platforms/merrifield/PlatfVirtualDevice.h b/platforms/merrifield/PlatfVirtualDevice.h
deleted file mode 100644
index 1c8ed77..0000000
--- a/platforms/merrifield/PlatfVirtualDevice.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_VIRTUAL_DEVICE_H
-#define PLATF_VIRTUAL_DEVICE_H
-
-#include <hal_public.h>
-#include <VirtualDevice.h>
-
-namespace android {
-namespace intel {
-
-class IVideoPayloadManager;
-
-class PlatfVirtualDevice : public VirtualDevice {
-public:
-    PlatfVirtualDevice(Hwcomposer& hwc,
-                        DisplayPlaneManager& dpm);
-    virtual ~PlatfVirtualDevice();
-    virtual IVideoPayloadManager* createVideoPayloadManager();
-};
-
-}
-}
-#endif /* PLATF_VIRTUAL_DEVICE_H */
diff --git a/platforms/merrifield_plus/PlatfExternalDevice.cpp b/platforms/merrifield_plus/PlatfExternalDevice.cpp
old mode 100644
new mode 100755
index 9a92f5f..8c36743
--- a/platforms/merrifield_plus/PlatfExternalDevice.cpp
+++ b/platforms/merrifield_plus/PlatfExternalDevice.cpp
@@ -18,7 +18,6 @@
 #include <ips/common/VsyncControl.h>
 #include <ips/common/BlankControl.h>
 #include <ips/common/HdcpControl.h>
-#include <ips/common/PrepareListener.h>
 
 
 namespace android {
@@ -46,11 +45,6 @@
     return new BlankControl();
 }
 
-IPrepareListener* PlatfExternalDevice::createPrepareListener()
-{
-    return new PrepareListener();
-}
-
 IHdcpControl* PlatfExternalDevice::createHdcpControl()
 {
     return new HdcpControl();
diff --git a/platforms/merrifield_plus/PlatfExternalDevice.h b/platforms/merrifield_plus/PlatfExternalDevice.h
old mode 100644
new mode 100755
index c264434..7289260
--- a/platforms/merrifield_plus/PlatfExternalDevice.h
+++ b/platforms/merrifield_plus/PlatfExternalDevice.h
@@ -30,7 +30,6 @@
 protected:
     IVsyncControl* createVsyncControl();
     IBlankControl* createBlankControl();
-    IPrepareListener* createPrepareListener();
     IHdcpControl* createHdcpControl();
 };
 
diff --git a/platforms/merrifield_plus/PlatfHwcomposer.cpp b/platforms/merrifield_plus/PlatfHwcomposer.cpp
old mode 100644
new mode 100755
index 4fdcada..9ba95f3
--- a/platforms/merrifield_plus/PlatfHwcomposer.cpp
+++ b/platforms/merrifield_plus/PlatfHwcomposer.cpp
@@ -15,16 +15,12 @@
 */
 #include <common/utils/HwcTrace.h>
 #include <ips/tangier/TngDisplayContext.h>
-#include <ips/common/PowerManager.h>
 #include <ips/anniedale/AnnPlaneManager.h>
 #include <platforms/merrifield_plus/PlatfBufferManager.h>
 #include <DummyDevice.h>
 #include <IDisplayDevice.h>
 #include <platforms/merrifield_plus/PlatfPrimaryDevice.h>
 #include <platforms/merrifield_plus/PlatfExternalDevice.h>
-#ifdef INTEL_WIDI_MERRIFIELD
-#include <platforms/merrifield_plus/PlatfVirtualDevice.h>
-#endif
 #include <platforms/merrifield_plus/PlatfHwcomposer.h>
 
 
@@ -75,10 +71,9 @@
             return new PlatfExternalDevice(*this, dpm);
 #endif
 
-#ifdef INTEL_WIDI_MERRIFIELD
         case IDisplayDevice::DEVICE_VIRTUAL:
-            return new PlatfVirtualDevice(*this, dpm);
-#endif
+            return new DummyDevice(*this);
+
         default:
             ETRACE("invalid display device %d", disp);
             return NULL;
@@ -91,11 +86,6 @@
     return new TngDisplayContext();
 }
 
-IPowerManager* PlatfHwcomposer::createPowerManager()
-{
-    return new PowerManager();
-}
-
 Hwcomposer* Hwcomposer::createHwcomposer()
 {
     CTRACE();
diff --git a/platforms/merrifield_plus/PlatfHwcomposer.h b/platforms/merrifield_plus/PlatfHwcomposer.h
old mode 100644
new mode 100755
index ba19c96..c058d66
--- a/platforms/merrifield_plus/PlatfHwcomposer.h
+++ b/platforms/merrifield_plus/PlatfHwcomposer.h
@@ -32,7 +32,6 @@
     BufferManager* createBufferManager();
     IDisplayDevice* createDisplayDevice(int disp, DisplayPlaneManager& dpm);
     IDisplayContext* createDisplayContext();
-    IPowerManager* createPowerManager();
 };
 
 } //namespace intel
diff --git a/platforms/merrifield_plus/PlatfPrimaryDevice.cpp b/platforms/merrifield_plus/PlatfPrimaryDevice.cpp
old mode 100644
new mode 100755
index e83d1b6..d819e75
--- a/platforms/merrifield_plus/PlatfPrimaryDevice.cpp
+++ b/platforms/merrifield_plus/PlatfPrimaryDevice.cpp
@@ -17,7 +17,6 @@
 #include <platforms/merrifield_plus/PlatfPrimaryDevice.h>
 #include <ips/common/VsyncControl.h>
 #include <ips/common/BlankControl.h>
-#include <ips/common/PrepareListener.h>
 
 
 namespace android {
@@ -45,11 +44,6 @@
     return new BlankControl();
 }
 
-IPrepareListener* PlatfPrimaryDevice::createPrepareListener()
-{
-    return new PrepareListener();
-}
-
 } // namespace intel
 } // namespace android
 
diff --git a/platforms/merrifield_plus/PlatfPrimaryDevice.h b/platforms/merrifield_plus/PlatfPrimaryDevice.h
old mode 100644
new mode 100755
index bd4af4d..14404d2
--- a/platforms/merrifield_plus/PlatfPrimaryDevice.h
+++ b/platforms/merrifield_plus/PlatfPrimaryDevice.h
@@ -31,7 +31,6 @@
 protected:
     IVsyncControl* createVsyncControl();
     IBlankControl* createBlankControl();
-    IPrepareListener* createPrepareListener();
 };
 
 }
diff --git a/platforms/merrifield_plus/PlatfVirtualDevice.cpp b/platforms/merrifield_plus/PlatfVirtualDevice.cpp
deleted file mode 100644
index a6c67f1..0000000
--- a/platforms/merrifield_plus/PlatfVirtualDevice.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <common/utils/HwcTrace.h>
-#include <Hwcomposer.h>
-#include <DisplayPlaneManager.h>
-#include <platforms/merrifield_plus/PlatfVirtualDevice.h>
-#include <ips/common/VideoPayloadManager.h>
-
-namespace android {
-namespace intel {
-
-PlatfVirtualDevice::PlatfVirtualDevice(Hwcomposer& hwc,
-                                       DisplayPlaneManager& dpm)
-    : VirtualDevice(hwc, dpm)
-{
-    CTRACE();
-}
-
-PlatfVirtualDevice::~PlatfVirtualDevice()
-{
-    CTRACE();
-}
-
-IVideoPayloadManager* PlatfVirtualDevice::createVideoPayloadManager()
-{
-    return new VideoPayloadManager();
-}
-
-
-} // namespace intel
-} // namespace android
-
-
diff --git a/platforms/merrifield_plus/PlatfVirtualDevice.h b/platforms/merrifield_plus/PlatfVirtualDevice.h
deleted file mode 100644
index 1c8ed77..0000000
--- a/platforms/merrifield_plus/PlatfVirtualDevice.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#ifndef PLATF_VIRTUAL_DEVICE_H
-#define PLATF_VIRTUAL_DEVICE_H
-
-#include <hal_public.h>
-#include <VirtualDevice.h>
-
-namespace android {
-namespace intel {
-
-class IVideoPayloadManager;
-
-class PlatfVirtualDevice : public VirtualDevice {
-public:
-    PlatfVirtualDevice(Hwcomposer& hwc,
-                        DisplayPlaneManager& dpm);
-    virtual ~PlatfVirtualDevice();
-    virtual IVideoPayloadManager* createVideoPayloadManager();
-};
-
-}
-}
-#endif /* PLATF_VIRTUAL_DEVICE_H */
diff --git a/test/Android.mk b/test/Android.mk
deleted file mode 100644
index b0a262e..0000000
--- a/test/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Build the unit tests,
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := nv12_ved_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
-    nv12_ved_test.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-	libEGL \
-	libGLESv2 \
-	libbinder \
-	libcutils \
-	libgui \
-	libstlport \
-	libui \
-	libutils \
-
-LOCAL_C_INCLUDES := \
-    bionic \
-    $(call include-path-for, libstdc++) \
-    $(call include-path-for, gtest) \
-    $(call include-path-for, stlport)
-
-# Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-# to integrate with auto-test framework.
-include $(BUILD_EXECUTABLE)
-
-
diff --git a/test/my_640x480.nv12 b/test/my_640x480.nv12
deleted file mode 100644
index d8a0c34..0000000
--- a/test/my_640x480.nv12
+++ /dev/null
Binary files differ
diff --git a/test/nv12_ved_test.cpp b/test/nv12_ved_test.cpp
deleted file mode 100644
index 7fb5b36..0000000
--- a/test/nv12_ved_test.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-// Copyright (c) 2014 Intel Corporation 
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-#include <gtest/gtest.h>
-
-#include <binder/IMemory.h>
-
-#include <gui/ISurfaceComposer.h>
-#include <gui/Surface.h>
-#include <gui/SurfaceComposerClient.h>
-#include <private/gui/ComposerService.h>
-
-#include <utils/String8.h>
-
-using namespace android;
-const char * filename = "/data/my_640x480.nv12";
-#define PIXEL_FORMAT_NV12 0x7FA00E00
-
-// Fill a YV12 buffer with a multi-colored checkerboard pattern
-void fillYUVBuffer(uint8_t* buf, int w, int h, int stride) {
-	const int blockWidth = w > 16 ? w / 16 : 1;
-	const int blockHeight = h > 16 ? h / 16 : 1;
-	const int yuvTexOffsetY = 0;
-	int yuvTexStrideY = stride;
-	int yuvTexOffsetV = yuvTexStrideY * h;
-	int yuvTexStrideV = (yuvTexStrideY / 2 + 0xf) & ~0xf;
-	int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * h / 2;
-	int yuvTexStrideU = yuvTexStrideV;
-	for (int x = 0; x < w; x++) {
-		for (int y = 0; y < h; y++) {
-			int parityX = (x / blockWidth) & 1;
-			int parityY = (y / blockHeight) & 1;
-			unsigned char intensity = (parityX ^ parityY) ? 63 : 191;
-			buf[yuvTexOffsetY + (y * yuvTexStrideY) + x] = intensity;
-			if (x < w / 2 && y < h / 2) {
-				buf[yuvTexOffsetU + (y * yuvTexStrideU) + x] = intensity;
-				if (x * 2 < w / 2 && y * 2 < h / 2) {
-					buf[yuvTexOffsetV + (y * 2 * yuvTexStrideV) + x * 2 + 0] =
-							buf[yuvTexOffsetV + (y * 2 * yuvTexStrideV) + x * 2
-									+ 1] =
-									buf[yuvTexOffsetV
-											+ ((y * 2 + 1) * yuvTexStrideV)
-											+ x * 2 + 0] = buf[yuvTexOffsetV
-											+ ((y * 2 + 1) * yuvTexStrideV)
-											+ x * 2 + 1] = intensity;
-				}
-			}
-		}
-	}
-}
-
-void loadYUVBufferFromFile(uint8_t* buf, int w, int h, int stride) {
-	FILE *fp = fopen(filename, "r");
-	int line = 0;
-	int offset = 0;
-	int buffer_height = h * 1.5;
-
-	if (!fp) {
-		printf("%s: failed to open %s\n", __func__, filename);
-		return;
-	}
-
-	printf("buf=%p, w=%d,h=%d,stride=%d\n", buf, w, h, stride);
-
-	for (line = 0; line < buffer_height; line++) {
-		printf("reading line %d...\n", line);
-		offset = line * stride;
-		fread(buf + offset, w, 1, fp);
-	}
-
-	fclose(fp);
-}
-
-int main(int argc, char **argv) {
-	sp < SurfaceControl > sc;
-	sp < Surface > s;
-	sp < ANativeWindow > anw;
-	ANativeWindowBuffer *anb;
-	uint8_t* img = NULL;
-	sp < SurfaceComposerClient > composerClient = new SurfaceComposerClient;
-	if (composerClient->initCheck() != NO_ERROR)
-		return 0;
-
-	sc = composerClient->createSurface(String8("FG Test Surface"), 640, 480,
-			PIXEL_FORMAT_RGBA_8888, 0);
-	if (sc == NULL)
-		return 0;;
-	if (!sc->isValid())
-		return 0;
-
-	s = sc->getSurface();
-	anw = s.get();
-	if (native_window_set_buffers_geometry(anw.get(), 640, 480,
-			PIXEL_FORMAT_NV12) != NO_ERROR)
-		return 0;
-	if (native_window_set_usage(anw.get(),
-			GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN)
-			!= NO_ERROR)
-		return 0;
-	
-	/*
-	 * load buffer 
-	 */
-	if (native_window_dequeue_buffer_and_wait(anw.get(), &anb))
-		return 0;
-	if (anb == NULL)
-		return 0;
-	sp < GraphicBuffer > buf(new GraphicBuffer(anb, false));
-	//if (anw->lockBuffer(anw.get(), buf->getNativeBuffer()) != NO_ERROR)
-	//	return 0;
-	buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**) (&img));
-	if (!img) {
-		printf("failed to lock buffer\n");
-		exit(-1);
-	}
-
-	loadYUVBufferFromFile(img, 640, 480, buf->getStride());
-	buf->unlock();
-	printf("querying buffer...\n");
-	if (anw->queueBuffer(anw.get(), buf->getNativeBuffer(), -1) != NO_ERROR)
-		return 0;
-
-	// loop it to continuously display??
-	while (1) {
-		SurfaceComposerClient::openGlobalTransaction();
-		if (sc->setLayer(INT_MAX - 1) != NO_ERROR)
-			return 0;
-		if (sc->show() != NO_ERROR)
-			return 0;
-
-		SurfaceComposerClient::closeGlobalTransaction();
-	}
-	return 0;
-}
-