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 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 54 | static void securing(hwc_context_t *ctx, uint32_t startEnd) { |
| 55 | Locker::Autolock _sl(ctx->mDrawLock); |
Saurabh Shah | c212577 | 2013-03-15 16:49:50 -0700 | [diff] [blame] | 56 | //The only way to make this class in this process subscribe to media |
| 57 | //player's death. |
| 58 | IMediaDeathNotifier::getMediaPlayerService(); |
| 59 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 60 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 61 | //We're done securing |
| 62 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 63 | ctx->mSecureMode = true; |
| 64 | if(ctx->proc) |
| 65 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 66 | } |
| 67 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 68 | static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) { |
| 69 | Locker::Autolock _sl(ctx->mDrawLock); |
| 70 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 71 | //We're done unsecuring |
| 72 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 73 | ctx->mSecureMode = false; |
| 74 | if(ctx->proc) |
| 75 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 76 | } |
| 77 | |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 78 | void QClient::MPDeathNotifier::died() { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 79 | Locker::Autolock _sl(mHwcContext->mDrawLock); |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 80 | ALOGD_IF(QCLIENT_DEBUG, "Media Player died"); |
| 81 | mHwcContext->mSecuring = false; |
| 82 | mHwcContext->mSecureMode = false; |
| 83 | if(mHwcContext->proc) |
| 84 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 85 | } |
| 86 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 87 | static android::status_t screenRefresh(hwc_context_t *ctx) { |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 88 | status_t result = NO_INIT; |
| 89 | #ifdef QCOM_BSP |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 90 | if(ctx->proc) { |
| 91 | ctx->proc->invalidate(ctx->proc); |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 92 | result = NO_ERROR; |
| 93 | } |
| 94 | #endif |
| 95 | return result; |
| 96 | } |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 97 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 98 | static android::status_t vpuCommand(hwc_context_t *ctx, |
| 99 | uint32_t command, |
| 100 | const Parcel* inParcel, |
| 101 | Parcel* outParcel) { |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 102 | status_t result = NO_INIT; |
| 103 | #ifdef QCOM_BSP |
| 104 | #ifdef VPU_TARGET |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 105 | result = ctx->mVPUClient->processCommand(command, inParcel, outParcel); |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 106 | #endif |
| 107 | #endif |
| 108 | return result; |
| 109 | } |
| 110 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 111 | static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) { |
| 112 | ctx->mExtOrientation = orientation; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 115 | static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) { |
| 116 | ctx->mBufferMirrorMode = enable; |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 119 | status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, |
| 120 | Parcel* outParcel) { |
| 121 | |
| 122 | if (command > IQService::VPU_COMMAND_LIST_START && |
| 123 | command < IQService::VPU_COMMAND_LIST_END) { |
| 124 | return vpuCommand(mHwcContext, command, inParcel, outParcel); |
| 125 | } |
| 126 | |
| 127 | switch(command) { |
| 128 | case IQService::SECURING: |
| 129 | securing(mHwcContext, inParcel->readInt32()); |
| 130 | break; |
| 131 | case IQService::UNSECURING: |
| 132 | unsecuring(mHwcContext, inParcel->readInt32()); |
| 133 | break; |
| 134 | case IQService::SCREEN_REFRESH: |
| 135 | return screenRefresh(mHwcContext); |
| 136 | break; |
| 137 | case IQService::EXTERNAL_ORIENTATION: |
| 138 | setExtOrientation(mHwcContext, inParcel->readInt32()); |
| 139 | break; |
| 140 | case IQService::BUFFER_MIRRORMODE: |
| 141 | setBufferMirrorMode(mHwcContext, inParcel->readInt32()); |
| 142 | break; |
| 143 | default: |
| 144 | return NO_ERROR; |
| 145 | } |
| 146 | return NO_ERROR; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 151 | } |