Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 1 | /* |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-14, The Linux Foundation. All rights reserved. |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 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> |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 34 | #include <mdp_version.h> |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 35 | |
| 36 | #define QCLIENT_DEBUG 0 |
| 37 | |
| 38 | using namespace android; |
| 39 | using namespace qService; |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 40 | using namespace qhwc; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 41 | |
| 42 | namespace qClient { |
| 43 | |
| 44 | // ---------------------------------------------------------------------------- |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 45 | QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx), |
| 46 | mMPDeathNotifier(new MPDeathNotifier(ctx)) |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 47 | { |
| 48 | ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked"); |
| 49 | } |
| 50 | |
| 51 | QClient::~QClient() |
| 52 | { |
| 53 | ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked"); |
| 54 | } |
| 55 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 56 | static void securing(hwc_context_t *ctx, uint32_t startEnd) { |
| 57 | Locker::Autolock _sl(ctx->mDrawLock); |
Saurabh Shah | c212577 | 2013-03-15 16:49:50 -0700 | [diff] [blame] | 58 | //The only way to make this class in this process subscribe to media |
| 59 | //player's death. |
| 60 | IMediaDeathNotifier::getMediaPlayerService(); |
| 61 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 62 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 63 | //We're done securing |
| 64 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 65 | ctx->mSecureMode = true; |
| 66 | if(ctx->proc) |
| 67 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 68 | } |
| 69 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 70 | static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) { |
| 71 | Locker::Autolock _sl(ctx->mDrawLock); |
| 72 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 73 | //We're done unsecuring |
| 74 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 75 | ctx->mSecureMode = false; |
| 76 | if(ctx->proc) |
| 77 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 80 | void QClient::MPDeathNotifier::died() { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 81 | Locker::Autolock _sl(mHwcContext->mDrawLock); |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 82 | ALOGD_IF(QCLIENT_DEBUG, "Media Player died"); |
| 83 | mHwcContext->mSecuring = false; |
| 84 | mHwcContext->mSecureMode = false; |
| 85 | if(mHwcContext->proc) |
| 86 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 87 | } |
| 88 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 89 | static android::status_t screenRefresh(hwc_context_t *ctx) { |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 90 | status_t result = NO_INIT; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 91 | if(ctx->proc) { |
| 92 | ctx->proc->invalidate(ctx->proc); |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 93 | result = NO_ERROR; |
| 94 | } |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 95 | return result; |
| 96 | } |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 97 | |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 98 | #ifdef VPU_TARGET |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 99 | static android::status_t vpuCommand(hwc_context_t *ctx, |
| 100 | uint32_t command, |
| 101 | const Parcel* inParcel, |
| 102 | Parcel* outParcel) { |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 103 | status_t result = NO_INIT; |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 104 | #ifdef QCOM_BSP |
| 105 | if(qdutils::MDPVersion::getInstance().is8092()) |
| 106 | result = ctx->mVPUClient->processCommand(command, inParcel, outParcel); |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 107 | #endif |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 108 | return result; |
| 109 | } |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 110 | #endif |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 111 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 112 | static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) { |
| 113 | ctx->mExtOrientation = orientation; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 116 | static void isExternalConnected(hwc_context_t* ctx, Parcel* outParcel) { |
| 117 | int connected; |
| 118 | connected = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected ? 1 : 0; |
| 119 | outParcel->writeInt32(connected); |
| 120 | } |
| 121 | |
| 122 | static void getDisplayAttributes(hwc_context_t* ctx, const Parcel* inParcel, |
| 123 | Parcel* outParcel) { |
| 124 | int dpy = inParcel->readInt32(); |
| 125 | outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period); |
| 126 | outParcel->writeInt32(ctx->dpyAttr[dpy].xres); |
| 127 | outParcel->writeInt32(ctx->dpyAttr[dpy].yres); |
| 128 | outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi); |
| 129 | outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi); |
| 130 | //XXX: Need to check what to return for HDMI |
| 131 | outParcel->writeInt32(ctx->mMDP.panel); |
| 132 | } |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame^] | 133 | static void setHSIC(const Parcel* inParcel) { |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 134 | int dpy = inParcel->readInt32(); |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame^] | 135 | ALOGD_IF(0, "In %s: dpy = %d", __FUNCTION__, dpy); |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 136 | HSICData_t hsic_data; |
| 137 | hsic_data.hue = inParcel->readInt32(); |
| 138 | hsic_data.saturation = inParcel->readFloat(); |
| 139 | hsic_data.intensity = inParcel->readInt32(); |
| 140 | hsic_data.contrast = inParcel->readFloat(); |
| 141 | //XXX: Actually set the HSIC data through ABL lib |
| 142 | } |
| 143 | |
| 144 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 145 | static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) { |
| 146 | ctx->mBufferMirrorMode = enable; |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 149 | static status_t getDisplayVisibleRegion(hwc_context_t* ctx, int dpy, |
| 150 | Parcel* outParcel) { |
| 151 | // Get the info only if the dpy is valid |
| 152 | if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) { |
| 153 | Locker::Autolock _sl(ctx->mDrawLock); |
| 154 | if(dpy && (ctx->mExtOrientation || ctx->mBufferMirrorMode)) { |
| 155 | // Return the destRect on external, if external orienation |
| 156 | // is enabled |
| 157 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.left); |
| 158 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.top); |
| 159 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.right); |
| 160 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.bottom); |
| 161 | } else { |
| 162 | outParcel->writeInt32(ctx->mViewFrame[dpy].left); |
| 163 | outParcel->writeInt32(ctx->mViewFrame[dpy].top); |
| 164 | outParcel->writeInt32(ctx->mViewFrame[dpy].right); |
| 165 | outParcel->writeInt32(ctx->mViewFrame[dpy].bottom); |
| 166 | } |
| 167 | return NO_ERROR; |
| 168 | } else { |
| 169 | ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy); |
| 170 | return BAD_VALUE; |
| 171 | } |
| 172 | } |
| 173 | |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 174 | static void pauseWFD(hwc_context_t *ctx, uint32_t pause) { |
| 175 | int dpy = HWC_DISPLAY_VIRTUAL; |
| 176 | if(pause) { |
| 177 | //WFD Pause |
| 178 | handle_pause(ctx, dpy); |
| 179 | } else { |
| 180 | //WFD Resume |
| 181 | handle_resume(ctx, dpy); |
| 182 | } |
| 183 | } |
| 184 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 185 | status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, |
| 186 | Parcel* outParcel) { |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 187 | status_t ret = NO_ERROR; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 188 | |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 189 | #ifdef VPU_TARGET |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 190 | if (command > IQService::VPU_COMMAND_LIST_START && |
| 191 | command < IQService::VPU_COMMAND_LIST_END) { |
| 192 | return vpuCommand(mHwcContext, command, inParcel, outParcel); |
| 193 | } |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 194 | #endif |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 195 | switch(command) { |
| 196 | case IQService::SECURING: |
| 197 | securing(mHwcContext, inParcel->readInt32()); |
| 198 | break; |
| 199 | case IQService::UNSECURING: |
| 200 | unsecuring(mHwcContext, inParcel->readInt32()); |
| 201 | break; |
| 202 | case IQService::SCREEN_REFRESH: |
| 203 | return screenRefresh(mHwcContext); |
| 204 | break; |
| 205 | case IQService::EXTERNAL_ORIENTATION: |
| 206 | setExtOrientation(mHwcContext, inParcel->readInt32()); |
| 207 | break; |
| 208 | case IQService::BUFFER_MIRRORMODE: |
| 209 | setBufferMirrorMode(mHwcContext, inParcel->readInt32()); |
| 210 | break; |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 211 | case IQService::GET_DISPLAY_VISIBLE_REGION: |
| 212 | ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(), |
| 213 | outParcel); |
| 214 | break; |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 215 | case IQService::CHECK_EXTERNAL_STATUS: |
| 216 | isExternalConnected(mHwcContext, outParcel); |
| 217 | break; |
| 218 | case IQService::GET_DISPLAY_ATTRIBUTES: |
| 219 | getDisplayAttributes(mHwcContext, inParcel, outParcel); |
| 220 | break; |
| 221 | case IQService::SET_HSIC_DATA: |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame^] | 222 | setHSIC(inParcel); |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 223 | case IQService::PAUSE_WFD: |
| 224 | pauseWFD(mHwcContext, inParcel->readInt32()); |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 225 | break; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 226 | default: |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 227 | ret = NO_ERROR; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 228 | } |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 229 | return ret; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | |
| 233 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 234 | } |