android_hardware_qcom_display/libhwcomposer/hwc_service.cpp
Amara Venkata Mastan Manoj Kumar a4b0340e0f hwcomposer: Add secure intents to support Secure Playback
Add OPEN_SECURE_START, OPEN_SECURE_END, CLOSE_SECURE_START
   and CLOSE_SECURE_END secure intents for Securing/Unsecuring
   start and end notifications.

   1. On Open Secure Start and Close Secure End events, hwc_prepare
      close the current overlay state and composition will be
      done by GPU. This will teardown the exisiting Rotator session.
   2. On Open Secure End, secure configuration is enabled and
      subsequent hwc_prepare will allocate secure memory for Rotator.
   3. On Close Secure End, secure configuration is disabled and
      subsequent hwc_prepare calls will allocate non-secure memory
      for Rotator.

Change-Id: Ia81b21d19f8084f218ae16eb8e69bb62937afa26

Conflicts:
	libhwcomposer/hwc_utils.h
2012-10-14 15:47:48 -07:00

191 lines
6.7 KiB
C++

/*
* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hwc_service.h>
#include <hwc_utils.h>
#define HWC_SERVICE_DEBUG 0
using namespace android;
namespace hwcService {
HWComposerService* HWComposerService::sHwcService = NULL;
// ----------------------------------------------------------------------------
HWComposerService::HWComposerService():mHwcContext(0)
{
ALOGD_IF(HWC_SERVICE_DEBUG, "HWComposerService Constructor invoked");
}
HWComposerService::~HWComposerService()
{
ALOGD_IF(HWC_SERVICE_DEBUG,"HWComposerService Destructor invoked");
}
status_t HWComposerService::setHPDStatus(int hpdStatus) {
ALOGD_IF(HWC_SERVICE_DEBUG, "hpdStatus=%d", hpdStatus);
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
externalDisplay->setHPDStatus(hpdStatus);
return NO_ERROR;
}
status_t HWComposerService::setResolutionMode(int resMode) {
ALOGD_IF(HWC_SERVICE_DEBUG, "resMode=%d", resMode);
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
if(externalDisplay->getExternalDisplay()) {
externalDisplay->setEDIDMode(resMode);
} else {
ALOGE("External Display not connected");
}
return NO_ERROR;
}
status_t HWComposerService::setActionSafeDimension(int w, int h) {
ALOGD_IF(HWC_SERVICE_DEBUG, "w=%d h=%d", w, h);
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
if((w > MAX_ACTIONSAFE_WIDTH) && (h > MAX_ACTIONSAFE_HEIGHT)) {
ALOGE_IF(HWC_SERVICE_DEBUG,
"ActionSafe Width and Height exceeded the limit! w=%d h=%d", w, h);
return NO_ERROR;
}
if(externalDisplay->getExternalDisplay()) {
externalDisplay->setActionSafeDimension(w, h);
} else {
ALOGE("External Display not connected");
}
return NO_ERROR;
}
status_t HWComposerService::setOpenSecureStart( ) {
mHwcContext->mSecureConfig = true;
//Invalidate
hwc_procs* proc = (hwc_procs*)mHwcContext->device.reserved_proc[0];
if(!proc) {
ALOGE("%s: HWC proc not registered", __FUNCTION__);
} else {
/* Trigger redraw */
ALOGD_IF(HWC_SERVICE_DEBUG, "%s: Invalidate !!", __FUNCTION__);
proc->invalidate(proc);
}
return NO_ERROR;
}
status_t HWComposerService::setOpenSecureEnd( ) {
mHwcContext->mSecure = true;
mHwcContext->mSecureConfig = false;
//Invalidate
hwc_procs* proc = (hwc_procs*)mHwcContext->device.reserved_proc[0];
if(!proc) {
ALOGE("%s: HWC proc not registered", __FUNCTION__);
} else {
/* Trigger redraw */
ALOGD_IF(HWC_SERVICE_DEBUG, "%s: Invalidate !!", __FUNCTION__);
proc->invalidate(proc);
}
return NO_ERROR;
}
status_t HWComposerService::setCloseSecureStart( ) {
mHwcContext->mSecureConfig = true;
//Invalidate
hwc_procs* proc = (hwc_procs*)mHwcContext->device.reserved_proc[0];
if(!proc) {
ALOGE("%s: HWC proc not registered", __FUNCTION__);
} else {
/* Trigger redraw */
ALOGD_IF(HWC_SERVICE_DEBUG, "%s: Invalidate !!", __FUNCTION__);
proc->invalidate(proc);
}
return NO_ERROR;
}
status_t HWComposerService::setCloseSecureEnd( ) {
mHwcContext->mSecure = false;
mHwcContext->mSecureConfig = false;
//Invalidate
hwc_procs* proc = (hwc_procs*)mHwcContext->device.reserved_proc[0];
if(!proc) {
ALOGE("%s: HWC proc not registered", __FUNCTION__);
} else {
/* Trigger redraw */
ALOGD_IF(HWC_SERVICE_DEBUG, "%s: Invalidate !!", __FUNCTION__);
proc->invalidate(proc);
}
return NO_ERROR;
}
status_t HWComposerService::getResolutionModeCount(int *resModeCount) {
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
if(externalDisplay->getExternalDisplay()) {
*resModeCount = externalDisplay->getModeCount();
} else {
ALOGE("External Display not connected");
}
ALOGD_IF(HWC_SERVICE_DEBUG, "resModeCount=%d", *resModeCount);
return NO_ERROR;
}
status_t HWComposerService::getResolutionModes(int *resModes, int count) {
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
if(externalDisplay->getExternalDisplay()) {
externalDisplay->getEDIDModes(resModes);
} else {
ALOGE("External Display not connected");
}
return NO_ERROR;
}
status_t HWComposerService::getExternalDisplay(int *dispType) {
qhwc::ExternalDisplay *externalDisplay = mHwcContext->mExtDisplay;
*dispType = externalDisplay->getExternalDisplay();
ALOGD_IF(HWC_SERVICE_DEBUG, "dispType=%d", *dispType);
return NO_ERROR;
}
HWComposerService* HWComposerService::getInstance()
{
if(!sHwcService) {
sHwcService = new HWComposerService();
sp<IServiceManager> sm = defaultServiceManager();
sm->addService(String16("display.hwcservice"), sHwcService);
if(sm->checkService(String16("display.hwcservice")) != NULL)
ALOGD_IF(HWC_SERVICE_DEBUG, "adding display.hwcservice succeeded");
else
ALOGD_IF(HWC_SERVICE_DEBUG, "adding display.hwcservice failed");
}
return sHwcService;
}
void HWComposerService::setHwcContext(hwc_context_t *hwcCtx) {
ALOGD_IF(HWC_SERVICE_DEBUG, "hwcCtx=0x%x", (int)hwcCtx);
if(hwcCtx) {
mHwcContext = hwcCtx;
}
}
}