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