display: Create QService binder interface.

Add QService binder interface to enable communication
to display by the mediaserver for Securing/Unsecuring start and end
notifications.

Create separate lib for external.
Clear reserved field before applying format.

Change-Id: I463c9c6deac7587bd0c4e0b84513b5d0b5dd7e98
diff --git a/libhwcomposer/Android.mk b/libhwcomposer/Android.mk
index 51f1e00..343686c 100644
--- a/libhwcomposer/Android.mk
+++ b/libhwcomposer/Android.mk
@@ -6,14 +6,15 @@
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libEGL liboverlay libgenlock \
-                                 libqdutils libhardware_legacy libdl libmemalloc
+                                 libexternal libqdutils libhardware_legacy \
+                                 libdl libmemalloc libqservice
+
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"hwcomposer\"
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := hwc.cpp          \
                                  hwc_video.cpp    \
                                  hwc_utils.cpp    \
                                  hwc_uimirror.cpp \
-                                 hwc_external.cpp \
                                  hwc_uevents.cpp  \
                                  hwc_copybit.cpp  \
                                  hwc_mdpcomp.cpp  \
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 3de74b0..a28750d 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
 #include "hwc_video.h"
 #include "hwc_uimirror.h"
 #include "hwc_copybit.h"
-#include "hwc_external.h"
+#include "external.h"
 #include "hwc_mdpcomp.h"
 #include "hwc_extonly.h"
 
@@ -81,14 +81,19 @@
     hwc_context_t* ctx = (hwc_context_t*)(dev);
     ctx->overlayInUse = false;
 
+    //reset for this draw round
+    VideoOverlay::reset();
+    ExtOnly::reset();
+    UIMirrorOverlay::reset();
+
+    //If securing of h/w in progress skip comp using overlay.
+    if(ctx->mSecuring == true) return 0;
+
     for (uint32_t i = 0; i < numDisplays; i++) {
         hwc_display_contents_1_t *list = displays[i];
         //XXX: Actually handle the multiple displays
         if (LIKELY(list && list->numHwLayers)) {
             ctx->dpys[i] = list->dpy;
-            //reset for this draw round
-            VideoOverlay::reset();
-            ExtOnly::reset();
 
             if(ctx->isPoweredDown)
                 ALOGW("SF called %s after a POWERDOWN", __FUNCTION__);
diff --git a/libhwcomposer/hwc_external.cpp b/libhwcomposer/hwc_external.cpp
deleted file mode 100644
index d35a622..0000000
--- a/libhwcomposer/hwc_external.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
- *
- * Not a Contribution, Apache license notifications and license are
- * retained for attribution purposes only.
- *
- * 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.
- */
-
-#define DEBUG 0
-#include <ctype.h>
-#include <fcntl.h>
-#include <media/IAudioPolicyService.h>
-#include <media/AudioSystem.h>
-#include <utils/threads.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include <linux/msm_mdp.h>
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#include <sys/poll.h>
-#include <sys/resource.h>
-#include <cutils/properties.h>
-#include "hwc_utils.h"
-#include "hwc_external.h"
-
-namespace qhwc {
-
-
-#define DEVICE_ROOT "/sys/devices/virtual/graphics"
-#define DEVICE_NODE "fb1"
-
-#define SYSFS_EDID_MODES        DEVICE_ROOT "/" DEVICE_NODE "/edid_modes"
-#define SYSFS_HPD               DEVICE_ROOT "/" DEVICE_NODE "/hpd"
-
-
-ExternalDisplay::ExternalDisplay(hwc_context_t* ctx):mFd(-1),
-    mCurrentMode(-1), mHwcContext(ctx)
-{
-    memset(&mVInfo, 0, sizeof(mVInfo));
-    //Enable HPD for HDMI
-    writeHPDOption(1);
-}
-
-ExternalDisplay::~ExternalDisplay()
-{
-    closeFrameBuffer();
-}
-
-struct disp_mode_timing_type {
-    int  video_format;
-
-    int  active_h;
-    int  active_v;
-
-    int  front_porch_h;
-    int  pulse_width_h;
-    int  back_porch_h;
-
-    int  front_porch_v;
-    int  pulse_width_v;
-    int  back_porch_v;
-
-    int  pixel_freq;
-    bool interlaced;
-
-    void set_info(struct fb_var_screeninfo &info) const;
-};
-
-void disp_mode_timing_type::set_info(struct fb_var_screeninfo &info) const
-{
-    info.reserved[0] = 0;
-    info.reserved[1] = 0;
-    info.reserved[2] = 0;
-    info.reserved[3] = info.reserved[3] | (video_format << 16);
-
-    info.xoffset = 0;
-    info.yoffset = 0;
-    info.xres = active_h;
-    info.yres = active_v;
-
-    info.pixclock = pixel_freq*1000;
-    info.vmode = interlaced ? FB_VMODE_INTERLACED : FB_VMODE_NONINTERLACED;
-
-    info.right_margin = front_porch_h;
-    info.hsync_len = pulse_width_h;
-    info.left_margin = back_porch_h;
-    info.lower_margin = front_porch_v;
-    info.vsync_len = pulse_width_v;
-    info.upper_margin = back_porch_v;
-}
-
-/* Video formates supported by the HDMI Standard */
-/* Indicates the resolution, pix clock and the aspect ratio */
-#define m640x480p60_4_3         1
-#define m720x480p60_4_3         2
-#define m720x480p60_16_9        3
-#define m1280x720p60_16_9       4
-#define m1920x1080i60_16_9      5
-#define m1440x480i60_4_3        6
-#define m1440x480i60_16_9       7
-#define m1920x1080p60_16_9      16
-#define m720x576p50_4_3         17
-#define m720x576p50_16_9        18
-#define m1280x720p50_16_9       19
-#define m1440x576i50_4_3        21
-#define m1440x576i50_16_9       22
-#define m1920x1080p50_16_9      31
-#define m1920x1080p24_16_9      32
-#define m1920x1080p25_16_9      33
-#define m1920x1080p30_16_9      34
-
-static struct disp_mode_timing_type supported_video_mode_lut[] = {
-    {m640x480p60_4_3,     640,  480,  16,  96,  48, 10, 2, 33,  25200, false},
-    {m720x480p60_4_3,     720,  480,  16,  62,  60,  9, 6, 30,  27030, false},
-    {m720x480p60_16_9,    720,  480,  16,  62,  60,  9, 6, 30,  27030, false},
-    {m1280x720p60_16_9,  1280,  720, 110,  40, 220,  5, 5, 20,  74250, false},
-    {m1920x1080i60_16_9, 1920,  540,  88,  44, 148,  2, 5,  5,  74250, false},
-    {m1440x480i60_4_3,   1440,  240,  38, 124, 114,  4, 3, 15,  27000, true},
-    {m1440x480i60_16_9,  1440,  240,  38, 124, 114,  4, 3, 15,  27000, true},
-    {m1920x1080p60_16_9, 1920, 1080,  88,  44, 148,  4, 5, 36, 148500, false},
-    {m720x576p50_4_3,     720,  576,  12,  64,  68,  5, 5, 39,  27000, false},
-    {m720x576p50_16_9,    720,  576,  12,  64,  68,  5, 5, 39,  27000, false},
-    {m1280x720p50_16_9,  1280,  720, 440,  40, 220,  5, 5, 20,  74250, false},
-    {m1440x576i50_4_3,   1440,  288,  24, 126, 138,  2, 3, 19,  27000, true},
-    {m1440x576i50_16_9,  1440,  288,  24, 126, 138,  2, 3, 19,  27000, true},
-    {m1920x1080p50_16_9, 1920, 1080, 528,  44, 148,  4, 5, 36, 148500, false},
-    {m1920x1080p24_16_9, 1920, 1080, 638,  44, 148,  4, 5, 36,  74250, false},
-    {m1920x1080p25_16_9, 1920, 1080, 528,  44, 148,  4, 5, 36,  74250, false},
-    {m1920x1080p30_16_9, 1920, 1080,  88,  44, 148,  4, 5, 36,  74250, false},
-};
-
-int ExternalDisplay::parseResolution(char* edidStr, int* edidModes)
-{
-    char delim = ',';
-    int count = 0;
-    char *start, *end;
-    // EDIDs are string delimited by ','
-    // Ex: 16,4,5,3,32,34,1
-    // Parse this string to get mode(int)
-    start = (char*) edidStr;
-    end = &delim;
-    while(*end == delim) {
-        edidModes[count] = (int) strtol(start, &end, 10);
-        start = end+1;
-        count++;
-    }
-    ALOGD_IF(DEBUG, "In %s: count = %d", __FUNCTION__, count);
-    for (int i = 0; i < count; i++)
-        ALOGD_IF(DEBUG, "Mode[%d] = %d", i, edidModes[i]);
-    return count;
-}
-
-bool ExternalDisplay::readResolution()
-{
-    int hdmiEDIDFile = open(SYSFS_EDID_MODES, O_RDONLY, 0);
-    int len = -1;
-
-    if (hdmiEDIDFile < 0) {
-        ALOGE("%s: edid_modes file '%s' not found",
-                 __FUNCTION__, SYSFS_EDID_MODES);
-        return false;
-    } else {
-        len = read(hdmiEDIDFile, mEDIDs, sizeof(mEDIDs)-1);
-        ALOGD_IF(DEBUG, "%s: EDID string: %s length = %d",
-                 __FUNCTION__, mEDIDs, len);
-        if ( len <= 0) {
-            ALOGE("%s: edid_modes file empty '%s'",
-                     __FUNCTION__, SYSFS_EDID_MODES);
-        }
-        else {
-            while (len > 1 && isspace(mEDIDs[len-1]))
-                --len;
-            mEDIDs[len] = 0;
-        }
-    }
-    close(hdmiEDIDFile);
-    if(len > 0) {
-        // GEt EDID modes from the EDID strings
-        mModeCount = parseResolution(mEDIDs, mEDIDModes);
-        ALOGD_IF(DEBUG, "%s: mModeCount = %d", __FUNCTION__,
-                 mModeCount);
-    }
-
-    return (strlen(mEDIDs) > 0);
-}
-
-bool ExternalDisplay::openFramebuffer()
-{
-    if (mFd == -1) {
-        mFd = open("/dev/graphics/fb1", O_RDWR);
-        if (mFd < 0)
-            ALOGE("%s: /dev/graphics/fb1 not available", __FUNCTION__);
-    }
-    return (mFd > 0);
-}
-
-bool ExternalDisplay::closeFrameBuffer()
-{
-    int ret = 0;
-    if(mFd > 0) {
-        ret = close(mFd);
-        mFd = -1;
-    }
-    return (ret == 0);
-}
-
-// clears the vinfo, edid, best modes
-void ExternalDisplay::resetInfo()
-{
-    memset(&mVInfo, 0, sizeof(mVInfo));
-    memset(mEDIDs, 0, sizeof(mEDIDs));
-    memset(mEDIDModes, 0, sizeof(mEDIDModes));
-    mModeCount = 0;
-    mCurrentMode = -1;
-}
-
-int ExternalDisplay::getModeOrder(int mode)
-{
-    switch (mode) {
-        default:
-        case m1440x480i60_4_3:
-            return 1; // 480i 4:3
-        case m1440x480i60_16_9:
-            return 2; // 480i 16:9
-        case m1440x576i50_4_3:
-            return 3; // i576i 4:3
-        case m1440x576i50_16_9:
-            return 4; // 576i 16:9
-        case m640x480p60_4_3:
-            return 5; // 640x480 4:3
-        case m720x480p60_4_3:
-            return 6; // 480p 4:3
-        case m720x480p60_16_9:
-            return 7; // 480p 16:9
-        case m720x576p50_4_3:
-            return 8; // 576p 4:3
-        case m720x576p50_16_9:
-            return 9; // 576p 16:9
-        case m1920x1080i60_16_9:
-            return 10; // 1080i 16:9
-        case m1280x720p50_16_9:
-            return 11; // 720p@50Hz
-        case m1280x720p60_16_9:
-            return 12; // 720p@60Hz
-        case m1920x1080p24_16_9:
-            return 13; //1080p@24Hz
-        case m1920x1080p25_16_9:
-            return 14; //108-p@25Hz
-        case m1920x1080p30_16_9:
-            return 15; //1080p@30Hz
-        case m1920x1080p50_16_9:
-            return 16; //1080p@50Hz
-        case m1920x1080p60_16_9:
-            return 17; //1080p@60Hz
-    }
-}
-
-// Get the best mode for the current HD TV
-int ExternalDisplay::getBestMode() {
-    int bestOrder = 0;
-    int bestMode = m640x480p60_4_3;
-
-    // for all the edid read, get the best mode
-    for(int i = 0; i < mModeCount; i++) {
-        int mode = mEDIDModes[i];
-        int order = getModeOrder(mode);
-        if (order > bestOrder) {
-            bestOrder = order;
-            bestMode = mode;
-        }
-    }
-    return bestMode;
-}
-
-inline bool ExternalDisplay::isValidMode(int ID)
-{
-    return ((ID >= m640x480p60_4_3) && (ID <= m1920x1080p30_16_9));
-}
-
-void ExternalDisplay::setResolution(int ID)
-{
-    struct fb_var_screeninfo info;
-    int ret = 0;
-    if (!openFramebuffer())
-        return;
-    ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-
-    ALOGD_IF(DEBUG, "%s: GET Info<ID=%d %dx%d (%d,%d,%d),"
-            "(%d,%d,%d) %dMHz>", __FUNCTION__,
-            mVInfo.reserved[3], mVInfo.xres, mVInfo.yres,
-            mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin,
-            mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin,
-            mVInfo.pixclock/1000/1000);
-    //If its a valid mode and its a new ID - update var_screeninfo
-    if ((isValidMode(ID)) && mCurrentMode != ID) {
-        const struct disp_mode_timing_type *mode =
-            &supported_video_mode_lut[0];
-        unsigned count =  sizeof(supported_video_mode_lut)/sizeof
-            (*supported_video_mode_lut);
-        for (unsigned int i = 0; i < count; ++i) {
-            const struct disp_mode_timing_type *cur =
-                &supported_video_mode_lut[i];
-            if (cur->video_format == ID)
-                mode = cur;
-        }
-        mode->set_info(mVInfo);
-        ALOGD_IF(DEBUG, "%s: SET Info<ID=%d => Info<ID=%d %dx %d"
-                 "(%d,%d,%d), (%d,%d,%d) %dMHz>", __FUNCTION__, ID,
-                 mVInfo.reserved[3], mVInfo.xres, mVInfo.yres,
-                 mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin,
-                 mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin,
-                 mVInfo.pixclock/1000/1000);
-        mVInfo.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_ALL | FB_ACTIVATE_FORCE;
-        ret = ioctl(mFd, FBIOPUT_VSCREENINFO, &mVInfo);
-        if(ret < 0) {
-            ALOGD("In %s: FBIOPUT_VSCREENINFO failed Err Str = %s",
-                                                 __FUNCTION__, strerror(errno));
-        }
-        mCurrentMode = ID;
-    }
-    //Powerup
-    ret = ioctl(mFd, FBIOBLANK, FB_BLANK_UNBLANK);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOBLANK failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-    ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-    //Pan_Display
-    ret = ioctl(mFd, FBIOPAN_DISPLAY, &mVInfo);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOPAN_DISPLAY  failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-}
-
-
-int  ExternalDisplay::getExternalDisplay() const
-{
-    return mExternalDisplay;
-}
-
-void ExternalDisplay::setExternalDisplay(int connected)
-{
-
-    hwc_context_t* ctx = mHwcContext;
-    if(ctx) {
-        ALOGD_IF(DEBUG, "%s: status = %d", __FUNCTION__,
-                 connected);
-        if(connected) {
-            readResolution();
-            //Get the best mode and set
-            // TODO: DO NOT call this for WFD
-            setResolution(getBestMode());
-            //enable hdmi vsync
-            enableHDMIVsync(connected);
-        } else {
-            // Disable the hdmi vsync
-            enableHDMIVsync(connected);
-            closeFrameBuffer();
-            resetInfo();
-        }
-        // Store the external display
-        mExternalDisplay = connected;
-        const char* prop = (connected) ? "1" : "0";
-        // set system property
-        property_set("hw.hdmiON", prop);
-        /* Trigger redraw */
-        ALOGD_IF(DEBUG, "%s: Invalidate !!", __FUNCTION__);
-        ctx->proc->invalidate(ctx->proc);
-    }
-    return;
-}
-
-bool ExternalDisplay::writeHPDOption(int userOption) const
-{
-    bool ret = true;
-    int hdmiHPDFile = open(SYSFS_HPD,O_RDWR, 0);
-    if (hdmiHPDFile < 0) {
-        ALOGE("%s: state file '%s' not found : ret%d"
-                           "err str: %s",  __FUNCTION__, SYSFS_HPD, hdmiHPDFile,
-                           strerror(errno));
-        ret = false;
-    } else {
-        int err = -1;
-        ALOGD_IF(DEBUG, "%s: option = %d", __FUNCTION__,
-                 userOption);
-        if(userOption)
-            err = write(hdmiHPDFile, "1", 2);
-        else
-            err = write(hdmiHPDFile, "0" , 2);
-        if (err <= 0) {
-            ALOGE("%s: file write failed '%s'",
-                     __FUNCTION__, SYSFS_HPD);
-            ret = false;
-        }
-        close(hdmiHPDFile);
-    }
-    return ret;
-}
-
-bool ExternalDisplay::commit()
-{
-    if(mFd == -1) {
-        return false;
-    } else if(ioctl(mFd, FBIOPUT_VSCREENINFO, &mVInfo) == -1) {
-         ALOGE("%s: FBIOPUT_VSCREENINFO failed, str: %s", __FUNCTION__,
-                                                          strerror(errno));
-         return false;
-    }
-    return true;
-}
-
-int ExternalDisplay::enableHDMIVsync(int enable)
-{
-    if(mFd > 0) {
-        int ret = ioctl(mFd, MSMFB_OVERLAY_VSYNC_CTRL, &enable);
-        if (ret<0) {
-            ALOGE("%s: enabling HDMI vsync failed, str: %s", __FUNCTION__,
-                                                            strerror(errno));
-        }
-    }
-    return -errno;
-}
-
-};
-
diff --git a/libhwcomposer/hwc_external.h b/libhwcomposer/hwc_external.h
deleted file mode 100644
index 55773c0..0000000
--- a/libhwcomposer/hwc_external.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
- *
- * Not a Contribution, Apache license notifications and license are
- * retained for attribution purposes only.
-
- * 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 HWC_EXTERNAL_DISPLAY_H
-#define HWC_EXTERNAL_DISPLAY_H
-
-#include <fb_priv.h>
-
-struct hwc_context_t;
-
-namespace qhwc {
-
-class ExternalDisplay
-{
-    //Type of external display -  OFF, HDMI, WFD
-    enum external_display_type {
-        EXT_TYPE_NONE,
-        EXT_TYPE_HDMI,
-        EXT_TYPE_WIFI
-    };
-
-    // Mirroring state
-    enum external_mirroring_state {
-        EXT_MIRRORING_OFF,
-        EXT_MIRRORING_ON,
-    };
-    public:
-    ExternalDisplay(hwc_context_t* ctx);
-    ~ExternalDisplay();
-    int getExternalDisplay() const;
-    void setExternalDisplay(int connected);
-    bool commit();
-    int enableHDMIVsync(int enable);
-
-    private:
-    bool readResolution();
-    int parseResolution(char* edidStr, int* edidModes);
-    void setResolution(int ID);
-    bool openFramebuffer();
-    bool closeFrameBuffer();
-    bool writeHPDOption(int userOption) const;
-    bool isValidMode(int ID);
-    void handleUEvent(char* str, int len);
-    int getModeOrder(int mode);
-    int getBestMode();
-    void resetInfo();
-
-    int mFd;
-    int mExternalDisplay;
-    int mCurrentMode;
-    char mEDIDs[128];
-    int mEDIDModes[64];
-    int mModeCount;
-    hwc_context_t *mHwcContext;
-    fb_var_screeninfo mVInfo;
-};
-
-}; //qhwc
-// ---------------------------------------------------------------------------
-#endif //HWC_EXTERNAL_DISPLAY_H
diff --git a/libhwcomposer/hwc_extonly.cpp b/libhwcomposer/hwc_extonly.cpp
index ab50972..bc8bfe0 100644
--- a/libhwcomposer/hwc_extonly.cpp
+++ b/libhwcomposer/hwc_extonly.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  */
 
 #include "hwc_extonly.h"
-#include "hwc_external.h"
+#include "external.h"
 #include "hwc_qbuf.h"
 
 namespace qhwc {
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 894da1f..146b6f2 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  * Not a Contribution, Apache license notifications and license are retained
  * for attribution purposes only.
  *
@@ -18,7 +18,7 @@
 
 #include "hwc_mdpcomp.h"
 #include "hwc_qbuf.h"
-#include "hwc_external.h"
+#include "external.h"
 
 #define SUPPORT_4LAYER 0
 
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index 8c833f7..f9e8a2d 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are
  * retained for attribution purposes only.
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "hwc_utils.h"
-#include "hwc_external.h"
+#include "external.h"
 
 namespace qhwc {
 
diff --git a/libhwcomposer/hwc_uimirror.cpp b/libhwcomposer/hwc_uimirror.cpp
index c5f22af..f904d69 100644
--- a/libhwcomposer/hwc_uimirror.cpp
+++ b/libhwcomposer/hwc_uimirror.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are
  * retained for attribution purposes only.
@@ -22,7 +22,7 @@
 #include <gralloc_priv.h>
 #include <fb_priv.h>
 #include "hwc_uimirror.h"
-#include "hwc_external.h"
+#include "external.h"
 
 namespace qhwc {
 
@@ -54,6 +54,10 @@
 ovutils::eOverlayState UIMirrorOverlay::sState = ovutils::OV_CLOSED;
 bool UIMirrorOverlay::sIsUiMirroringOn = false;
 
+void UIMirrorOverlay::reset() {
+    sIsUiMirroringOn = false;
+    sState = ovutils::OV_CLOSED;
+}
 
 //Prepare the overlay for the UI mirroring
 bool UIMirrorOverlay::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
@@ -101,12 +105,10 @@
             }
 
             ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE;
-            /* - TODO: Secure content
-               if (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) {
-               ovutils::setMdpFlags(mdpFlags,
-               ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
-               }
-             */
+            if(ctx->mSecureMode) {
+                ovutils::setMdpFlags(mdpFlags,
+                        ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
+            }
 
             ovutils::PipeArgs parg(mdpFlags,
                     info,
diff --git a/libhwcomposer/hwc_uimirror.h b/libhwcomposer/hwc_uimirror.h
index da03c5f..a1bf9ba 100644
--- a/libhwcomposer/hwc_uimirror.h
+++ b/libhwcomposer/hwc_uimirror.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are
  * retained for attribution purposes only.
@@ -33,6 +33,8 @@
         static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
         // Draws layer if this feature is on
         static bool draw(hwc_context_t *ctx);
+        //Reset values
+        static void reset();
     private:
         //Configures overlay
         static bool configure(hwc_context_t *ctx, hwc_display_contents_1_t *list);
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index f523856..350684b 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,9 +25,10 @@
 #include "hwc_video.h"
 #include "hwc_qbuf.h"
 #include "hwc_copybit.h"
-#include "hwc_external.h"
+#include "external.h"
 #include "hwc_mdpcomp.h"
 #include "hwc_extonly.h"
+#include "QService.h"
 
 namespace qhwc {
 
@@ -44,6 +45,7 @@
 {
     openFramebufferDevice(ctx);
     ctx->mOverlay = overlay::Overlay::getInstance();
+    ctx->mQService = qService::QService::getInstance(ctx);
     ctx->qbuf = new QueuedBufferStore();
     ctx->mMDP.version = qdutils::MDPVersion::getInstance().getMDPVersion();
     ctx->mMDP.hasOverlay = qdutils::MDPVersion::getInstance().hasOverlay();
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 9cb6e15..184d967 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,10 @@
 struct hwc_context_t;
 struct framebuffer_device_t;
 
+namespace qService {
+class QService;
+}
+
 namespace overlay {
 class Overlay;
 }
@@ -151,12 +155,21 @@
     //QueuedBufferStore to hold buffers for overlay
     qhwc::QueuedBufferStore *qbuf;
 
+    //QService object
+    qService::QService *mQService;
+
     // External display related information
     qhwc::ExternalDisplay *mExtDisplay;
 
     qhwc::MDPInfo mMDP;
 
     bool isPoweredDown;
+
+    //Securing in progress indicator
+    bool mSecuring;
+
+    //Display in secure mode indicator
+    bool mSecureMode;
 };
 
 #endif //HWC_UTILS_H
diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp
index bedd9e9..141d83b 100644
--- a/libhwcomposer/hwc_video.cpp
+++ b/libhwcomposer/hwc_video.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
 #include <overlay.h>
 #include "hwc_qbuf.h"
 #include "hwc_video.h"
-#include "hwc_external.h"
+#include "external.h"
 
 namespace qhwc {