Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR CLIENTS; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <hwc_qclient.h> |
| 31 | #include <IQService.h> |
| 32 | #include <hwc_utils.h> |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame^] | 33 | #include <hwc_vpuclient.h> |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 34 | |
| 35 | #define QCLIENT_DEBUG 0 |
| 36 | |
| 37 | using namespace android; |
| 38 | using namespace qService; |
| 39 | |
| 40 | namespace qClient { |
| 41 | |
| 42 | // ---------------------------------------------------------------------------- |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 43 | QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx), |
| 44 | mMPDeathNotifier(new MPDeathNotifier(ctx)) |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 45 | { |
| 46 | ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked"); |
| 47 | } |
| 48 | |
| 49 | QClient::~QClient() |
| 50 | { |
| 51 | ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked"); |
| 52 | } |
| 53 | |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 54 | status_t QClient::notifyCallback(uint32_t msg, uint32_t value) { |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame^] | 55 | |
| 56 | if (msg > IQService::VPU_COMMAND_LIST_START && |
| 57 | msg < IQService::VPU_COMMAND_LIST_END) { |
| 58 | return vpuCommand(msg, value); |
| 59 | } |
| 60 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 61 | switch(msg) { |
| 62 | case IQService::SECURING: |
| 63 | securing(value); |
| 64 | break; |
| 65 | case IQService::UNSECURING: |
| 66 | unsecuring(value); |
| 67 | break; |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 68 | case IQService::SCREEN_REFRESH: |
| 69 | return screenRefresh(); |
| 70 | break; |
Arun Kumar K.R | 4b79e27 | 2013-05-21 10:41:02 -0700 | [diff] [blame] | 71 | case IQService::EXTERNAL_ORIENTATION: |
| 72 | setExtOrientation(value); |
| 73 | break; |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 74 | case IQService::BUFFER_MIRRORMODE: |
| 75 | setBufferMirrorMode(value); |
| 76 | break; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 77 | default: |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 78 | return NO_ERROR; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 79 | } |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 80 | return NO_ERROR; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | void QClient::securing(uint32_t startEnd) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 84 | Locker::Autolock _sl(mHwcContext->mDrawLock); |
Saurabh Shah | c212577 | 2013-03-15 16:49:50 -0700 | [diff] [blame] | 85 | //The only way to make this class in this process subscribe to media |
| 86 | //player's death. |
| 87 | IMediaDeathNotifier::getMediaPlayerService(); |
| 88 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 89 | mHwcContext->mSecuring = startEnd; |
| 90 | //We're done securing |
| 91 | if(startEnd == IQService::END) |
| 92 | mHwcContext->mSecureMode = true; |
| 93 | if(mHwcContext->proc) |
| 94 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 95 | } |
| 96 | |
| 97 | void QClient::unsecuring(uint32_t startEnd) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 98 | Locker::Autolock _sl(mHwcContext->mDrawLock); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 99 | mHwcContext->mSecuring = startEnd; |
| 100 | //We're done unsecuring |
| 101 | if(startEnd == IQService::END) |
| 102 | mHwcContext->mSecureMode = false; |
| 103 | if(mHwcContext->proc) |
| 104 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 105 | } |
| 106 | |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 107 | void QClient::MPDeathNotifier::died() { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 108 | Locker::Autolock _sl(mHwcContext->mDrawLock); |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 109 | ALOGD_IF(QCLIENT_DEBUG, "Media Player died"); |
| 110 | mHwcContext->mSecuring = false; |
| 111 | mHwcContext->mSecureMode = false; |
| 112 | if(mHwcContext->proc) |
| 113 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 114 | } |
| 115 | |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 116 | android::status_t QClient::screenRefresh() { |
| 117 | status_t result = NO_INIT; |
| 118 | #ifdef QCOM_BSP |
| 119 | if(mHwcContext->proc) { |
| 120 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 121 | result = NO_ERROR; |
| 122 | } |
| 123 | #endif |
| 124 | return result; |
| 125 | } |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 126 | |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame^] | 127 | android::status_t QClient::vpuCommand(uint32_t command, uint32_t setting) { |
| 128 | status_t result = NO_INIT; |
| 129 | #ifdef QCOM_BSP |
| 130 | #ifdef VPU_TARGET |
| 131 | result = mHwcContext->mVPUClient->processCommand(command, setting); |
| 132 | #endif |
| 133 | #endif |
| 134 | return result; |
| 135 | } |
| 136 | |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 137 | void QClient::setExtOrientation(uint32_t orientation) { |
| 138 | mHwcContext->mExtOrientation = orientation; |
| 139 | } |
| 140 | |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 141 | void QClient::setBufferMirrorMode(uint32_t enable) { |
| 142 | mHwcContext->mBufferMirrorMode = enable; |
| 143 | } |
| 144 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 145 | } |