hwc_qclient.cpp revision ef53c1c84ec55ed50f607d52b7abfbb86239408e
1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* 2ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Copyright (c) 2013, The Linux Foundation. All rights reserved. 3ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Redistribution and use in source and binary forms, with or without 5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * modification, are permitted provided that the following conditions are 6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * met: 7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Redistributions of source code must retain the above copyright 8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * notice, this list of conditions and the following disclaimer. 9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Redistributions in binary form must reproduce the above 10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * copyright notice, this list of conditions and the following 11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * disclaimer in the documentation and/or other materials provided 12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * with the distribution. 13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Neither the name of The Linux Foundation nor the names of its 14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * contributors may be used to endorse or promote products derived 15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * from this software without specific prior written permission. 16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * SUBSTITUTE GOODS OR CLIENTS; LOSS OF USE, DATA, OR PROFITS; OR 24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */ 29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <hwc_qclient.h> 31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <IQService.h> 32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <hwc_utils.h> 33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define QCLIENT_DEBUG 0 35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 36ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonusing namespace android; 37ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonusing namespace qService; 38ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonnamespace qClient { 40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson// ---------------------------------------------------------------------------- 42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonQClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx), 43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mMPDeathNotifier(new MPDeathNotifier(ctx)) 44ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson{ 45ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked"); 46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 47ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 48ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonQClient::~QClient() 49ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson{ 50ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked"); 51ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 52ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 53ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonstatus_t QClient::notifyCallback(uint32_t msg, uint32_t value) { 54ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson switch(msg) { 55ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson case IQService::SECURING: 56ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson securing(value); 57ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson break; 58ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson case IQService::UNSECURING: 59ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson unsecuring(value); 60ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson break; 61ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson case IQService::SCREEN_REFRESH: 62ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return screenRefresh(); 63ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson break; 64ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson default: 65ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return NO_ERROR; 66ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson } 67ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return NO_ERROR; 68ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 69ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 70ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonvoid QClient::securing(uint32_t startEnd) { 71ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson Locker::Autolock _sl(mHwcContext->mDrawLock); 72ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson //The only way to make this class in this process subscribe to media 73ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson //player's death. 74ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson IMediaDeathNotifier::getMediaPlayerService(); 75ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 76ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecuring = startEnd; 77ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson //We're done securing 78ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(startEnd == IQService::END) 79ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecureMode = true; 80ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(mHwcContext->proc) 81ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->proc->invalidate(mHwcContext->proc); 82ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 83ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 84ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonvoid QClient::unsecuring(uint32_t startEnd) { 85ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson Locker::Autolock _sl(mHwcContext->mDrawLock); 86ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecuring = startEnd; 87ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson //We're done unsecuring 88ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(startEnd == IQService::END) 89ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecureMode = false; 90ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(mHwcContext->proc) 91ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->proc->invalidate(mHwcContext->proc); 92ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 93ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 94ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonvoid QClient::MPDeathNotifier::died() { 95ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson Locker::Autolock _sl(mHwcContext->mDrawLock); 96ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson ALOGD_IF(QCLIENT_DEBUG, "Media Player died"); 97ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecuring = false; 98ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->mSecureMode = false; 99ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(mHwcContext->proc) 100ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->proc->invalidate(mHwcContext->proc); 101ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 102ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 103ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonandroid::status_t QClient::screenRefresh() { 104ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson status_t result = NO_INIT; 105ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if(mHwcContext->proc) { 106ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mHwcContext->proc->invalidate(mHwcContext->proc); 107ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson result = NO_ERROR; 108ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson } 109ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return result; 110ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 111ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 112