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> |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 33 | #include <mdp_version.h> |
Naseer Ahmed | 35a268c | 2014-06-24 19:07:13 -0400 | [diff] [blame] | 34 | #include <hwc_mdpcomp.h> |
Tatenda Chipeperekwa | 06af9cb | 2014-08-26 14:51:05 -0700 | [diff] [blame] | 35 | #include <hwc_virtual.h> |
Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 36 | #include <overlay.h> |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 37 | #include <display_config.h> |
Naseer Ahmed | 6bbd0a1 | 2015-01-23 11:57:10 -0500 | [diff] [blame] | 38 | #include <hdmi.h> |
| 39 | #include <video/msm_hdmi_modes.h> |
Zohaib Alam | 83ea46d | 2015-03-23 15:44:19 -0400 | [diff] [blame] | 40 | #include <hwc_qdcm.h> |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 41 | |
| 42 | #define QCLIENT_DEBUG 0 |
Prabhanjan Kandula | db274fa | 2015-03-30 22:35:09 +0530 | [diff] [blame] | 43 | #define FILE_MAX_MDSSBW_FLAG \ |
| 44 | "/sys/devices/virtual/graphics/fb0/mdp/bw_mode_bitmap" |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 45 | |
| 46 | using namespace android; |
| 47 | using namespace qService; |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 48 | using namespace qhwc; |
Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 49 | using namespace overlay; |
Saurabh Shah | cd01835 | 2014-11-11 13:54:19 -0800 | [diff] [blame] | 50 | using namespace qdutils; |
Zohaib Alam | 83ea46d | 2015-03-23 15:44:19 -0400 | [diff] [blame] | 51 | using namespace qQdcm; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 52 | |
| 53 | namespace qClient { |
| 54 | |
| 55 | // ---------------------------------------------------------------------------- |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 56 | QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx), |
Prabhanjan Kandula | db274fa | 2015-03-30 22:35:09 +0530 | [diff] [blame] | 57 | mMPDeathNotifier(new MPDeathNotifier(ctx)), |
| 58 | mCamDeathNotifier(new CamDeathNotifier()) |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 59 | { |
| 60 | ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked"); |
| 61 | } |
| 62 | |
| 63 | QClient::~QClient() |
| 64 | { |
| 65 | ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked"); |
| 66 | } |
| 67 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 68 | static void securing(hwc_context_t *ctx, uint32_t startEnd) { |
Saurabh Shah | c212577 | 2013-03-15 16:49:50 -0700 | [diff] [blame] | 69 | //The only way to make this class in this process subscribe to media |
| 70 | //player's death. |
| 71 | IMediaDeathNotifier::getMediaPlayerService(); |
| 72 | |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 73 | ctx->mDrawLock.lock(); |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 74 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 75 | //We're done securing |
| 76 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 77 | ctx->mSecureMode = true; |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 78 | ctx->mDrawLock.unlock(); |
| 79 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 80 | if(ctx->proc) |
| 81 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 82 | } |
| 83 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 84 | static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) { |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 85 | ctx->mDrawLock.lock(); |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 86 | ctx->mSecuring = startEnd; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 87 | //We're done unsecuring |
| 88 | if(startEnd == IQService::END) |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 89 | ctx->mSecureMode = false; |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 90 | ctx->mDrawLock.unlock(); |
| 91 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 92 | if(ctx->proc) |
| 93 | ctx->proc->invalidate(ctx->proc); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 94 | } |
| 95 | |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 96 | void QClient::MPDeathNotifier::died() { |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 97 | mHwcContext->mDrawLock.lock(); |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 98 | ALOGD_IF(QCLIENT_DEBUG, "Media Player died"); |
| 99 | mHwcContext->mSecuring = false; |
| 100 | mHwcContext->mSecureMode = false; |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 101 | mHwcContext->mDrawLock.unlock(); |
Saurabh Shah | 7128e50 | 2013-02-20 13:24:48 -0800 | [diff] [blame] | 102 | if(mHwcContext->proc) |
| 103 | mHwcContext->proc->invalidate(mHwcContext->proc); |
| 104 | } |
| 105 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 106 | static android::status_t screenRefresh(hwc_context_t *ctx) { |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 107 | status_t result = NO_INIT; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 108 | if(ctx->proc) { |
| 109 | ctx->proc->invalidate(ctx->proc); |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 110 | result = NO_ERROR; |
| 111 | } |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 112 | return result; |
| 113 | } |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 114 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 115 | static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) { |
| 116 | ctx->mExtOrientation = orientation; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 119 | static void isExternalConnected(hwc_context_t* ctx, Parcel* outParcel) { |
| 120 | int connected; |
| 121 | connected = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected ? 1 : 0; |
| 122 | outParcel->writeInt32(connected); |
| 123 | } |
| 124 | |
| 125 | static void getDisplayAttributes(hwc_context_t* ctx, const Parcel* inParcel, |
| 126 | Parcel* outParcel) { |
| 127 | int dpy = inParcel->readInt32(); |
| 128 | outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period); |
Saurabh Shah | 90c55cf | 2015-02-10 15:37:39 -0800 | [diff] [blame] | 129 | outParcel->writeInt32(ctx->dpyAttr[dpy].xres); |
| 130 | outParcel->writeInt32(ctx->dpyAttr[dpy].yres); |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 131 | outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi); |
| 132 | outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi); |
| 133 | //XXX: Need to check what to return for HDMI |
| 134 | outParcel->writeInt32(ctx->mMDP.panel); |
| 135 | } |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 136 | static void setHSIC(const Parcel* inParcel) { |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 137 | int dpy = inParcel->readInt32(); |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 138 | ALOGD_IF(0, "In %s: dpy = %d", __FUNCTION__, dpy); |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 139 | HSICData_t hsic_data; |
| 140 | hsic_data.hue = inParcel->readInt32(); |
| 141 | hsic_data.saturation = inParcel->readFloat(); |
| 142 | hsic_data.intensity = inParcel->readInt32(); |
| 143 | hsic_data.contrast = inParcel->readFloat(); |
| 144 | //XXX: Actually set the HSIC data through ABL lib |
| 145 | } |
| 146 | |
| 147 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 148 | static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) { |
| 149 | ctx->mBufferMirrorMode = enable; |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 152 | static status_t getDisplayVisibleRegion(hwc_context_t* ctx, int dpy, |
| 153 | Parcel* outParcel) { |
| 154 | // Get the info only if the dpy is valid |
| 155 | if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) { |
| 156 | Locker::Autolock _sl(ctx->mDrawLock); |
| 157 | if(dpy && (ctx->mExtOrientation || ctx->mBufferMirrorMode)) { |
| 158 | // Return the destRect on external, if external orienation |
| 159 | // is enabled |
| 160 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.left); |
| 161 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.top); |
| 162 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.right); |
| 163 | outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.bottom); |
| 164 | } else { |
| 165 | outParcel->writeInt32(ctx->mViewFrame[dpy].left); |
| 166 | outParcel->writeInt32(ctx->mViewFrame[dpy].top); |
| 167 | outParcel->writeInt32(ctx->mViewFrame[dpy].right); |
| 168 | outParcel->writeInt32(ctx->mViewFrame[dpy].bottom); |
| 169 | } |
| 170 | return NO_ERROR; |
| 171 | } else { |
| 172 | ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy); |
| 173 | return BAD_VALUE; |
| 174 | } |
| 175 | } |
| 176 | |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 177 | // USed for setting the secondary(hdmi/wfd) status |
| 178 | static void setSecondaryDisplayStatus(hwc_context_t *ctx, |
| 179 | const Parcel* inParcel) { |
| 180 | uint32_t dpy = inParcel->readInt32(); |
| 181 | uint32_t status = inParcel->readInt32(); |
| 182 | ALOGD_IF(QCLIENT_DEBUG, "%s: dpy = %d status = %s", __FUNCTION__, |
| 183 | dpy, getExternalDisplayState(status)); |
| 184 | |
| 185 | if(dpy > HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) { |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 186 | if(dpy == HWC_DISPLAY_VIRTUAL && status == qdutils::EXTERNAL_OFFLINE) { |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 187 | ctx->mWfdSyncLock.lock(); |
| 188 | ctx->mWfdSyncLock.signal(); |
| 189 | ctx->mWfdSyncLock.unlock(); |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 190 | } else if(status == qdutils::EXTERNAL_PAUSE) { |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 191 | handle_pause(ctx, dpy); |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 192 | } else if(status == qdutils::EXTERNAL_RESUME) { |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 193 | handle_resume(ctx, dpy); |
| 194 | } |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 195 | } else { |
Ramakant Singh | 8595cca | 2014-11-06 16:17:08 +0530 | [diff] [blame] | 196 | ALOGE("%s: Invalid dpy %d", __FUNCTION__, dpy); |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 197 | return; |
Raj kamal | 59fea56 | 2014-04-01 16:52:19 +0530 | [diff] [blame] | 198 | } |
| 199 | } |
| 200 | |
Ramkumar Radhakrishnan | 0a021a8 | 2014-05-19 19:53:56 -0700 | [diff] [blame] | 201 | |
| 202 | static status_t setViewFrame(hwc_context_t* ctx, const Parcel* inParcel) { |
| 203 | int dpy = inParcel->readInt32(); |
| 204 | if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) { |
| 205 | Locker::Autolock _sl(ctx->mDrawLock); |
| 206 | ctx->mViewFrame[dpy].left = inParcel->readInt32(); |
| 207 | ctx->mViewFrame[dpy].top = inParcel->readInt32(); |
| 208 | ctx->mViewFrame[dpy].right = inParcel->readInt32(); |
| 209 | ctx->mViewFrame[dpy].bottom = inParcel->readInt32(); |
| 210 | ALOGD_IF(QCLIENT_DEBUG, "%s: mViewFrame[%d] = [%d %d %d %d]", |
| 211 | __FUNCTION__, dpy, |
| 212 | ctx->mViewFrame[dpy].left, ctx->mViewFrame[dpy].top, |
| 213 | ctx->mViewFrame[dpy].right, ctx->mViewFrame[dpy].bottom); |
| 214 | return NO_ERROR; |
| 215 | } else { |
| 216 | ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy); |
| 217 | return BAD_VALUE; |
| 218 | } |
| 219 | } |
| 220 | |
Naseer Ahmed | 35a268c | 2014-06-24 19:07:13 -0400 | [diff] [blame] | 221 | static void toggleDynamicDebug(hwc_context_t* ctx, const Parcel* inParcel) { |
| 222 | int debug_type = inParcel->readInt32(); |
| 223 | bool enable = !!inParcel->readInt32(); |
| 224 | ALOGD("%s: debug_type: %d enable:%d", |
| 225 | __FUNCTION__, debug_type, enable); |
| 226 | Locker::Autolock _sl(ctx->mDrawLock); |
| 227 | switch (debug_type) { |
| 228 | //break is ignored for DEBUG_ALL to toggle all of them at once |
| 229 | case IQService::DEBUG_ALL: |
| 230 | case IQService::DEBUG_MDPCOMP: |
| 231 | qhwc::MDPComp::dynamicDebug(enable); |
| 232 | if (debug_type != IQService::DEBUG_ALL) |
| 233 | break; |
| 234 | case IQService::DEBUG_VSYNC: |
| 235 | ctx->vstate.debug = enable; |
| 236 | if (debug_type != IQService::DEBUG_ALL) |
| 237 | break; |
Tatenda Chipeperekwa | 06af9cb | 2014-08-26 14:51:05 -0700 | [diff] [blame] | 238 | case IQService::DEBUG_VD: |
Manoj Kumar AVM | 9591a5e | 2014-08-21 22:50:21 -0700 | [diff] [blame] | 239 | HWCVirtualVDS::dynamicDebug(enable); |
Tatenda Chipeperekwa | 06af9cb | 2014-08-26 14:51:05 -0700 | [diff] [blame] | 240 | if (debug_type != IQService::DEBUG_ALL) |
| 241 | break; |
Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 242 | case IQService::DEBUG_PIPE_LIFECYCLE: |
| 243 | Overlay::debugPipeLifecycle(enable); |
| 244 | if (debug_type != IQService::DEBUG_ALL) |
| 245 | break; |
Naseer Ahmed | 35a268c | 2014-06-24 19:07:13 -0400 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | |
Saurabh Shah | 59562ff | 2014-09-30 16:13:12 -0700 | [diff] [blame] | 249 | static void setIdleTimeout(hwc_context_t* ctx, const Parcel* inParcel) { |
| 250 | uint32_t timeout = (uint32_t)inParcel->readInt32(); |
| 251 | ALOGD("%s :%u ms", __FUNCTION__, timeout); |
| 252 | Locker::Autolock _sl(ctx->mDrawLock); |
| 253 | MDPComp::setIdleTimeout(timeout); |
| 254 | } |
| 255 | |
Jeykumar Sankaran | be93e27 | 2014-06-19 18:15:57 -0700 | [diff] [blame] | 256 | static void setMaxPipesPerMixer(hwc_context_t* ctx, const Parcel* inParcel) { |
| 257 | uint32_t value = (uint32_t)inParcel->readInt32(); |
| 258 | ALOGD("%s : setting MaxPipesPerMixer: %d ", __FUNCTION__, value); |
| 259 | Locker::Autolock _sl(ctx->mDrawLock); |
| 260 | MDPComp::setMaxPipesPerMixer(value); |
| 261 | } |
| 262 | |
Saurabh Shah | cd01835 | 2014-11-11 13:54:19 -0800 | [diff] [blame] | 263 | static void toggleBWC(hwc_context_t* ctx, const Parcel* inParcel) { |
| 264 | uint32_t enable = (uint32_t)inParcel->readInt32(); |
| 265 | if(MDPVersion::getInstance().supportsBWC()) { |
| 266 | Locker::Autolock _sl(ctx->mDrawLock); |
| 267 | ctx->mBWCEnabled = (bool) enable; |
| 268 | ALOGI("%s: Set BWC to %d", __FUNCTION__, enable); |
| 269 | } else { |
| 270 | ALOGI("%s: Target doesn't support BWC", __FUNCTION__); |
| 271 | } |
| 272 | } |
| 273 | |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 274 | static void configureDynRefreshRate(hwc_context_t* ctx, |
| 275 | const Parcel* inParcel) { |
| 276 | uint32_t op = (uint32_t)inParcel->readInt32(); |
| 277 | uint32_t refresh_rate = (uint32_t)inParcel->readInt32(); |
| 278 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
| 279 | uint32_t dpy = HWC_DISPLAY_PRIMARY; |
| 280 | |
| 281 | if(mdpHw.isDynFpsSupported()) { |
| 282 | Locker::Autolock _sl(ctx->mDrawLock); |
| 283 | |
| 284 | switch (op) { |
| 285 | case DISABLE_METADATA_DYN_REFRESH_RATE: |
| 286 | ctx->mUseMetaDataRefreshRate = false; |
| 287 | setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate); |
| 288 | break; |
| 289 | case ENABLE_METADATA_DYN_REFRESH_RATE: |
| 290 | ctx->mUseMetaDataRefreshRate = true; |
| 291 | setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate); |
| 292 | break; |
| 293 | case SET_BINDER_DYN_REFRESH_RATE: |
| 294 | if(ctx->mUseMetaDataRefreshRate) |
| 295 | ALOGW("%s: Ignoring binder request to change refresh-rate", |
| 296 | __FUNCTION__); |
| 297 | else { |
| 298 | uint32_t rate = roundOff(refresh_rate); |
| 299 | if((rate >= mdpHw.getMinFpsSupported() && |
| 300 | rate <= mdpHw.getMaxFpsSupported())) { |
| 301 | setRefreshRate(ctx, dpy, rate); |
| 302 | } else { |
| 303 | ALOGE("%s: Requested refresh-rate should be between \ |
| 304 | (%d) and (%d). Given (%d)", __FUNCTION__, |
| 305 | mdpHw.getMinFpsSupported(), |
| 306 | mdpHw.getMaxFpsSupported(), rate); |
| 307 | } |
| 308 | } |
| 309 | break; |
| 310 | default: |
| 311 | ALOGE("%s: Invalid op %d",__FUNCTION__,op); |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
Jeykumar Sankaran | 14d41a8 | 2015-03-11 14:13:43 -0700 | [diff] [blame] | 316 | static status_t setPartialUpdateState(hwc_context_t *ctx, uint32_t state) { |
| 317 | ALOGD("%s: state: %d", __FUNCTION__, state); |
| 318 | switch(state) { |
| 319 | case IQService::PREF_PARTIAL_UPDATE: |
| 320 | if(qhwc::MDPComp::setPartialUpdatePref(ctx, true) < 0) |
| 321 | return NO_INIT; |
| 322 | return NO_ERROR; |
| 323 | case IQService::PREF_POST_PROCESSING: |
| 324 | if(qhwc::MDPComp::setPartialUpdatePref(ctx, false) < 0) |
| 325 | return NO_INIT; |
| 326 | qhwc::MDPComp::enablePartialUpdate(false); |
| 327 | return NO_ERROR; |
| 328 | case IQService::ENABLE_PARTIAL_UPDATE: |
| 329 | qhwc::MDPComp::enablePartialUpdate(true); |
| 330 | return NO_ERROR; |
| 331 | default: |
| 332 | ALOGE("%s: Invalid state", __FUNCTION__); |
| 333 | return NO_ERROR; |
| 334 | }; |
Jeykumar Sankaran | 53b05f2 | 2014-08-05 11:27:03 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 337 | static void toggleScreenUpdate(hwc_context_t* ctx, uint32_t on) { |
| 338 | ALOGD("%s: toggle update: %d", __FUNCTION__, on); |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 339 | if (on == 0) { |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 340 | ctx->mDrawLock.lock(); |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 341 | ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = true; |
| 342 | ctx->mOverlay->configBegin(); |
| 343 | ctx->mOverlay->configDone(); |
| 344 | ctx->mRotMgr->clear(); |
| 345 | if(!Overlay::displayCommit(ctx->dpyAttr[0].fd)) { |
| 346 | ALOGE("%s: Display commit failed", __FUNCTION__); |
| 347 | } |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 348 | ctx->mDrawLock.unlock(); |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 349 | } else { |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 350 | ctx->mDrawLock.lock(); |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 351 | ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = false; |
Raj Kamal | 58b31a0 | 2014-12-16 15:53:53 +0530 | [diff] [blame] | 352 | ctx->mDrawLock.unlock(); |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 353 | ctx->proc->invalidate(ctx->proc); |
| 354 | } |
| 355 | } |
| 356 | |
Naseer Ahmed | 6bbd0a1 | 2015-01-23 11:57:10 -0500 | [diff] [blame] | 357 | static void setS3DMode(hwc_context_t* ctx, int mode) { |
| 358 | if (ctx->mHDMIDisplay) { |
| 359 | if(ctx->mHDMIDisplay->isS3DModeSupported(mode)) { |
| 360 | ALOGD("%s: Force S3D mode to %d", __FUNCTION__, mode); |
| 361 | Locker::Autolock _sl(ctx->mDrawLock); |
| 362 | ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].s3dModeForced = true; |
| 363 | setup3DMode(ctx, HWC_DISPLAY_EXTERNAL, mode); |
| 364 | } else { |
| 365 | ALOGD("%s: mode %d is not supported", __FUNCTION__, mode); |
| 366 | } |
| 367 | } else { |
| 368 | ALOGE("%s: No HDMI Display detected", __FUNCTION__); |
| 369 | } |
| 370 | } |
| 371 | |
Saurabh Shah | 90c55cf | 2015-02-10 15:37:39 -0800 | [diff] [blame] | 372 | static status_t setActiveConfig(hwc_context_t* ctx, const Parcel *inParcel, |
| 373 | Parcel *outParcel) { |
| 374 | uint32_t index = inParcel->readInt32(); |
| 375 | int dpy = inParcel->readInt32(); |
| 376 | //Currently only primary supported |
| 377 | if(dpy > HWC_DISPLAY_PRIMARY) { |
| 378 | return BAD_VALUE; |
| 379 | } |
| 380 | |
| 381 | Configs *configs = Configs::getInstance(); |
| 382 | if(configs == NULL) { |
| 383 | ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__); |
| 384 | return INVALID_OPERATION; |
| 385 | } |
| 386 | |
| 387 | if(configs->getActiveConfig() == index) { |
| 388 | ALOGI("%s(): Config %u is already set", __FUNCTION__, index); |
| 389 | return ALREADY_EXISTS; |
| 390 | } |
| 391 | |
| 392 | ctx->mDrawLock.lock(); |
| 393 | //Updates the necessary sysfs nodes and reads split info again which is |
| 394 | //needed to reinitialize composition resources. |
| 395 | if(configs->setActiveConfig(index) == false) { |
| 396 | ALOGE("%s(): Failed to set config %u", __FUNCTION__, index); |
| 397 | ctx->mDrawLock.unlock(); |
| 398 | return UNKNOWN_ERROR; |
| 399 | } |
| 400 | |
| 401 | qdutils::DisplayAttributes attr = configs->getAttributes(index); |
| 402 | |
| 403 | ctx->dpyAttr[dpy].xres = attr.xres; |
| 404 | ctx->dpyAttr[dpy].yres = attr.yres; |
| 405 | |
| 406 | ctx->dpyAttr[dpy].fbScaling = ((ctx->dpyAttr[dpy].xres != |
| 407 | ctx->dpyAttr[dpy].xresFB) || (ctx->dpyAttr[dpy].yres != |
| 408 | ctx->dpyAttr[dpy].yresFB)); |
| 409 | |
| 410 | destroyCompositionResources(ctx, dpy); |
| 411 | initCompositionResources(ctx, dpy); |
| 412 | ctx->dpyAttr[dpy].configSwitched = true; |
| 413 | ctx->mDrawLock.unlock(); |
| 414 | ctx->proc->invalidate(ctx->proc); |
| 415 | return NO_ERROR; |
| 416 | } |
| 417 | |
| 418 | static status_t getActiveConfig(hwc_context_t* ctx, const Parcel *inParcel, |
| 419 | Parcel *outParcel) { |
| 420 | Locker::Autolock _sl(ctx->mDrawLock); |
| 421 | int dpy = inParcel->readInt32(); |
| 422 | //Currently only primary supported |
| 423 | if(dpy > HWC_DISPLAY_PRIMARY) { |
| 424 | return BAD_VALUE; |
| 425 | } |
| 426 | |
| 427 | Configs *configs = Configs::getInstance(); |
| 428 | if(configs == NULL) { |
| 429 | ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__); |
| 430 | return INVALID_OPERATION; |
| 431 | } |
| 432 | |
| 433 | outParcel->writeInt32(configs->getActiveConfig()); |
| 434 | return NO_ERROR; |
| 435 | } |
| 436 | |
| 437 | static status_t getConfigCount(hwc_context_t* ctx, const Parcel *inParcel, |
| 438 | Parcel *outParcel) { |
| 439 | Locker::Autolock _sl(ctx->mDrawLock); |
| 440 | int dpy = inParcel->readInt32(); |
| 441 | //Currently only primary supported |
| 442 | if(dpy > HWC_DISPLAY_PRIMARY) { |
| 443 | return BAD_VALUE; |
| 444 | } |
| 445 | |
| 446 | Configs *configs = Configs::getInstance(); |
| 447 | if(configs == NULL) { |
| 448 | ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__); |
| 449 | return INVALID_OPERATION; |
| 450 | } |
| 451 | |
| 452 | outParcel->writeInt32(configs->getConfigCount()); |
| 453 | return NO_ERROR; |
| 454 | } |
| 455 | |
| 456 | static status_t getDisplayAttributesForConfig(hwc_context_t* ctx, |
| 457 | const Parcel *inParcel, Parcel *outParcel) { |
| 458 | Locker::Autolock _sl(ctx->mDrawLock); |
| 459 | uint32_t index = inParcel->readInt32(); |
| 460 | int dpy = inParcel->readInt32(); |
| 461 | //Currently only primary supported |
| 462 | if(dpy > HWC_DISPLAY_PRIMARY) { |
| 463 | return BAD_VALUE; |
| 464 | } |
| 465 | |
| 466 | Configs *configs = Configs::getInstance(); |
| 467 | if(configs == NULL) { |
| 468 | ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__); |
| 469 | return INVALID_OPERATION; |
| 470 | } |
| 471 | |
| 472 | //xres, yres are used from the Config class, we assume for now that the |
| 473 | //other params are the same. This might change in the future. |
| 474 | outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period); |
| 475 | |
| 476 | qdutils::DisplayAttributes attr = configs->getAttributes(index); |
| 477 | outParcel->writeInt32(attr.xres); |
| 478 | outParcel->writeInt32(attr.yres); |
| 479 | |
| 480 | outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi); |
| 481 | outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi); |
| 482 | outParcel->writeInt32(ctx->mMDP.panel); |
| 483 | |
| 484 | return NO_ERROR; |
| 485 | } |
| 486 | |
Prabhanjan Kandula | db274fa | 2015-03-30 22:35:09 +0530 | [diff] [blame] | 487 | /* register/unregister camera service */ |
| 488 | static bool setCameraDeathNotifier( |
| 489 | android::sp<QClient::CamDeathNotifier> camDeathNotifier, bool on) { |
| 490 | sp<IServiceManager> sm = defaultServiceManager(); |
| 491 | sp<IBinder> binder = sm->getService(String16("media.camera")); |
| 492 | if (binder == 0) { |
| 493 | ALOGW("%s: CameraService not published or dead...", __FUNCTION__); |
| 494 | return false; |
| 495 | } |
| 496 | if(on) { |
| 497 | binder->linkToDeath(camDeathNotifier); |
| 498 | } else { |
| 499 | binder->unlinkToDeath(camDeathNotifier); |
| 500 | } |
| 501 | return true; |
| 502 | } |
| 503 | |
| 504 | static bool updateDisplayBWCapForCam(bool on) { |
| 505 | char sysfsPath[255]; |
| 506 | char bw[64]; |
| 507 | int bw_flag = 0; // to reset to default. |
| 508 | |
| 509 | memset(sysfsPath, 0, sizeof(sysfsPath)); |
| 510 | snprintf(sysfsPath , sizeof(sysfsPath), FILE_MAX_MDSSBW_FLAG); |
| 511 | int sysfsFd = open(sysfsPath, O_RDWR); |
| 512 | if(sysfsFd < 0 ) { |
| 513 | ALOGE("%s: Status: %d Error in opening %s: %s", |
| 514 | __FUNCTION__, on, sysfsPath, strerror(errno)); |
| 515 | return false; |
| 516 | } |
| 517 | |
| 518 | if(on) { |
| 519 | bw_flag = MDSS_MAX_BW_LIMIT_CAMERA; |
| 520 | } |
| 521 | snprintf(bw, sizeof(bw), "%d", bw_flag); |
| 522 | ssize_t bytes = pwrite(sysfsFd, bw, strlen(bw), 0); |
| 523 | if(bytes < 0) { |
| 524 | ALOGE ("%s: Unable to write into %s node %s", |
| 525 | __FUNCTION__, sysfsPath, strerror(errno)); |
| 526 | close(sysfsFd); |
| 527 | return false; |
| 528 | } |
| 529 | close(sysfsFd); |
| 530 | return true; |
| 531 | } |
| 532 | |
| 533 | static void setCameraStatus(hwc_context_t* ctx, |
| 534 | android::sp<QClient::CamDeathNotifier> camDeathNotifier, uint32_t on) { |
| 535 | |
| 536 | //Currently we need this only for 8952. |
| 537 | if(!MDPVersion::getInstance().is8x52()) { |
| 538 | ALOGI("%s Not 8952?? return", __FUNCTION__); |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | if(!setCameraDeathNotifier(camDeathNotifier, on)) { |
| 543 | ALOGE("%s failed in updateCameraStatus", __FUNCTION__); |
| 544 | return; |
| 545 | } |
| 546 | |
| 547 | if(!updateDisplayBWCapForCam(on)) { |
| 548 | ALOGE("%s failed in updateDisplayBWCap", __FUNCTION__); |
| 549 | return; |
| 550 | } |
| 551 | |
| 552 | // Trigger a screen update so that our BW setting will reflect |
| 553 | // atleast by next vsync. |
| 554 | screenRefresh(ctx); |
| 555 | } |
| 556 | |
| 557 | void QClient::CamDeathNotifier::binderDied(const wp<IBinder>& who) { |
| 558 | //If Cameraservice abruptly gone, reset mdss bw caps |
| 559 | //This new cap will be applicable from next frame onwards |
| 560 | if(!updateDisplayBWCapForCam(false)) { |
| 561 | ALOGE("%s failed in updateDisplayBWCap", __FUNCTION__); |
| 562 | } |
| 563 | } |
| 564 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 565 | status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, |
| 566 | Parcel* outParcel) { |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 567 | status_t ret = NO_ERROR; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 568 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 569 | switch(command) { |
| 570 | case IQService::SECURING: |
| 571 | securing(mHwcContext, inParcel->readInt32()); |
| 572 | break; |
| 573 | case IQService::UNSECURING: |
| 574 | unsecuring(mHwcContext, inParcel->readInt32()); |
| 575 | break; |
| 576 | case IQService::SCREEN_REFRESH: |
| 577 | return screenRefresh(mHwcContext); |
| 578 | break; |
| 579 | case IQService::EXTERNAL_ORIENTATION: |
| 580 | setExtOrientation(mHwcContext, inParcel->readInt32()); |
| 581 | break; |
| 582 | case IQService::BUFFER_MIRRORMODE: |
| 583 | setBufferMirrorMode(mHwcContext, inParcel->readInt32()); |
| 584 | break; |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 585 | case IQService::GET_DISPLAY_VISIBLE_REGION: |
| 586 | ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(), |
| 587 | outParcel); |
| 588 | break; |
Naseer Ahmed | 78c952e | 2013-11-25 18:12:23 -0500 | [diff] [blame] | 589 | case IQService::CHECK_EXTERNAL_STATUS: |
| 590 | isExternalConnected(mHwcContext, outParcel); |
| 591 | break; |
| 592 | case IQService::GET_DISPLAY_ATTRIBUTES: |
| 593 | getDisplayAttributes(mHwcContext, inParcel, outParcel); |
| 594 | break; |
| 595 | case IQService::SET_HSIC_DATA: |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 596 | setHSIC(inParcel); |
Raj kamal | 59fea56 | 2014-04-01 16:52:19 +0530 | [diff] [blame] | 597 | break; |
Arun Kumar K.R | 33888f5 | 2014-10-09 15:56:33 -0700 | [diff] [blame] | 598 | case IQService::SET_SECONDARY_DISPLAY_STATUS: |
| 599 | setSecondaryDisplayStatus(mHwcContext, inParcel); |
Raj kamal | 59fea56 | 2014-04-01 16:52:19 +0530 | [diff] [blame] | 600 | break; |
Ramkumar Radhakrishnan | 0a021a8 | 2014-05-19 19:53:56 -0700 | [diff] [blame] | 601 | case IQService::SET_VIEW_FRAME: |
| 602 | setViewFrame(mHwcContext, inParcel); |
| 603 | break; |
Naseer Ahmed | 35a268c | 2014-06-24 19:07:13 -0400 | [diff] [blame] | 604 | case IQService::DYNAMIC_DEBUG: |
| 605 | toggleDynamicDebug(mHwcContext, inParcel); |
| 606 | break; |
Saurabh Shah | 59562ff | 2014-09-30 16:13:12 -0700 | [diff] [blame] | 607 | case IQService::SET_IDLE_TIMEOUT: |
| 608 | setIdleTimeout(mHwcContext, inParcel); |
| 609 | break; |
Jeykumar Sankaran | be93e27 | 2014-06-19 18:15:57 -0700 | [diff] [blame] | 610 | case IQService::SET_MAX_PIPES_PER_MIXER: |
| 611 | setMaxPipesPerMixer(mHwcContext, inParcel); |
Jeykumar Sankaran | 85ddc0c | 2014-12-17 14:39:26 -0800 | [diff] [blame] | 612 | break; |
Jeykumar Sankaran | 53b05f2 | 2014-08-05 11:27:03 -0700 | [diff] [blame] | 613 | case IQService::SET_PARTIAL_UPDATE: |
Jeykumar Sankaran | 14d41a8 | 2015-03-11 14:13:43 -0700 | [diff] [blame] | 614 | ret = setPartialUpdateState(mHwcContext, inParcel->readInt32()); |
Jeykumar Sankaran | be93e27 | 2014-06-19 18:15:57 -0700 | [diff] [blame] | 615 | break; |
Saurabh Shah | cd01835 | 2014-11-11 13:54:19 -0800 | [diff] [blame] | 616 | case IQService::TOGGLE_BWC: |
| 617 | toggleBWC(mHwcContext, inParcel); |
| 618 | break; |
Raj Kamal | 0d53fc6 | 2014-11-25 17:36:36 +0530 | [diff] [blame] | 619 | case IQService::CONFIGURE_DYN_REFRESH_RATE: |
| 620 | configureDynRefreshRate(mHwcContext, inParcel); |
| 621 | break; |
Naseer Ahmed | 78951b2 | 2014-12-10 18:19:21 -0500 | [diff] [blame] | 622 | case IQService::TOGGLE_SCREEN_UPDATE: |
| 623 | toggleScreenUpdate(mHwcContext, inParcel->readInt32()); |
| 624 | break; |
Naseer Ahmed | 6bbd0a1 | 2015-01-23 11:57:10 -0500 | [diff] [blame] | 625 | case IQService::SET_S3D_MODE: |
| 626 | setS3DMode(mHwcContext, inParcel->readInt32()); |
| 627 | break; |
Saurabh Shah | 90c55cf | 2015-02-10 15:37:39 -0800 | [diff] [blame] | 628 | case IQService::SET_ACTIVE_CONFIG: |
| 629 | ret = setActiveConfig(mHwcContext, inParcel, outParcel); |
| 630 | break; |
| 631 | case IQService::GET_ACTIVE_CONFIG: |
| 632 | ret = getActiveConfig(mHwcContext, inParcel, outParcel); |
| 633 | break; |
| 634 | case IQService::GET_CONFIG_COUNT: |
| 635 | ret = getConfigCount(mHwcContext, inParcel, outParcel); |
| 636 | break; |
| 637 | case IQService::GET_DISPLAY_ATTRIBUTES_FOR_CONFIG: |
| 638 | ret = getDisplayAttributesForConfig(mHwcContext, inParcel, |
| 639 | outParcel); |
Zohaib Alam | 83ea46d | 2015-03-23 15:44:19 -0400 | [diff] [blame] | 640 | case IQService::QDCM_SVC_CMDS: |
| 641 | qdcmCmdsHandler(mHwcContext, inParcel, outParcel); |
Saurabh Shah | 90c55cf | 2015-02-10 15:37:39 -0800 | [diff] [blame] | 642 | break; |
Prabhanjan Kandula | db274fa | 2015-03-30 22:35:09 +0530 | [diff] [blame] | 643 | case IQService::SET_CAMERA_STATUS: |
| 644 | setCameraStatus(mHwcContext, |
| 645 | mCamDeathNotifier, inParcel->readInt32()); |
| 646 | break; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 647 | default: |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 648 | ret = NO_ERROR; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 649 | } |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 650 | return ret; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 651 | } |
| 652 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 653 | } |