Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 3 | * Not a Contribution, Apache license notifications and license are retained |
| 4 | * for attribution purposes only. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 19 | #include <math.h> |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 20 | #include "hwc_mdpcomp.h" |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 21 | #include <sys/ioctl.h> |
Tatenda Chipeperekwa | 12f41c9 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 22 | #include "hdmi.h" |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 23 | #include "virtual.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 24 | #include "qdMetaData.h" |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 25 | #include "mdp_version.h" |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 26 | #include "hwc_fbupdate.h" |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 27 | #include "hwc_ad.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 28 | #include <overlayRotator.h> |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 29 | #include "hwc_copybit.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 30 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 31 | using namespace overlay; |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 32 | using namespace qdutils; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 33 | using namespace overlay::utils; |
| 34 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 36 | namespace qhwc { |
| 37 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 38 | //==============MDPComp======================================================== |
| 39 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 40 | IdleInvalidator *MDPComp::idleInvalidator = NULL; |
| 41 | bool MDPComp::sIdleFallBack = false; |
| 42 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 43 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 44 | bool MDPComp::sEnableMixedMode = true; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 45 | bool MDPComp::sEnablePartialFrameUpdate = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 46 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 47 | bool MDPComp::sEnable4k2kYUVSplit = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 48 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 49 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
| 50 | if(isDisplaySplit(ctx, dpy)) { |
| 51 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 52 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 53 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 56 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 57 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 58 | void MDPComp::dump(android::String8& buf) |
| 59 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 60 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 61 | return; |
| 62 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 63 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 64 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 65 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 66 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " |
| 67 | "fbCount:%2d \n", mCurrentFrame.layerCount, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 68 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 69 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 70 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 71 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
| 72 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 73 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 74 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 75 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 76 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 77 | index, |
| 78 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 79 | mCurrentFrame.layerToMDP[index], |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 80 | (mCurrentFrame.isFBComposed[index] ? |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 81 | (mCurrentFrame.drop[index] ? "DROP" : |
| 82 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 83 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 84 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 85 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | bool MDPComp::init(hwc_context_t *ctx) { |
| 89 | |
| 90 | if(!ctx) { |
| 91 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 92 | return false; |
| 93 | } |
| 94 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 95 | char property[PROPERTY_VALUE_MAX]; |
| 96 | |
| 97 | sEnabled = false; |
| 98 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 99 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 100 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 101 | sEnabled = true; |
| 102 | } |
| 103 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 104 | sEnableMixedMode = true; |
| 105 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 106 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 107 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 108 | sEnableMixedMode = false; |
| 109 | } |
| 110 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 111 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 112 | if(atoi(property) != 0) |
| 113 | sDebugLogs = true; |
| 114 | } |
| 115 | |
Prabhanjan Kandula | 30696ee | 2014-04-21 12:12:38 +0530 | [diff] [blame] | 116 | // We read from drivers if panel supports partial updating |
| 117 | // and we enable partial update computations if supported. |
| 118 | // Keeping this property to disable partial update for |
| 119 | // debugging by setting below property to 0 & only 0. |
| 120 | property_get("persist.hwc.partialupdate", property, "-1"); |
| 121 | if((atoi(property) != 0) && |
| 122 | qdutils::MDPVersion::getInstance().isPartialUpdateEnabled()) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 123 | sEnablePartialFrameUpdate = true; |
| 124 | } |
| 125 | ALOGE_IF(isDebug(), "%s: Partial Update applicable?: %d",__FUNCTION__, |
| 126 | sEnablePartialFrameUpdate); |
| 127 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 128 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 129 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 130 | int val = atoi(property); |
| 131 | if(val >= 0) |
| 132 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 133 | } |
| 134 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 135 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 136 | // Idle invalidation is not necessary on command mode panels |
| 137 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 138 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 139 | if(atoi(property) != 0) |
| 140 | idle_timeout = atoi(property); |
| 141 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 142 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 143 | //create Idle Invalidator only when not disabled through property |
| 144 | if(idle_timeout != -1) |
| 145 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 146 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 147 | if(idleInvalidator == NULL) { |
| 148 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 149 | __FUNCTION__); |
| 150 | } else { |
| 151 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 152 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 153 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 154 | |
| 155 | if((property_get("debug.mdpcomp.4k2kSplit", property, "0") > 0) && |
| 156 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 157 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 158 | sEnable4k2kYUVSplit = true; |
| 159 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 160 | |
| 161 | if ((property_get("persist.hwc.ptor.enable", property, NULL) > 0) && |
| 162 | ((!strncasecmp(property, "true", PROPERTY_VALUE_MAX )) || |
| 163 | (!strncmp(property, "1", PROPERTY_VALUE_MAX )))) { |
| 164 | ctx->mCopyBit[HWC_DISPLAY_PRIMARY] = new CopyBit(ctx, |
| 165 | HWC_DISPLAY_PRIMARY); |
| 166 | } |
| 167 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 168 | return true; |
| 169 | } |
| 170 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 171 | void MDPComp::reset(hwc_context_t *ctx) { |
| 172 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 173 | mCurrentFrame.reset(numLayers); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 174 | ctx->mOverlay->clear(mDpy); |
| 175 | ctx->mLayerRotMap[mDpy]->clear(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 178 | void MDPComp::reset() { |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 179 | mPrevModeOn = mModeOn; |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 180 | mModeOn = false; |
| 181 | } |
| 182 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 183 | void MDPComp::timeout_handler(void *udata) { |
| 184 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 185 | bool handleTimeout = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 186 | |
| 187 | if(!ctx) { |
| 188 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 189 | return; |
| 190 | } |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 191 | |
Ramkumar Radhakrishnan | d8595ae | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 192 | Locker::Autolock _l(ctx->mDrawLock); |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 193 | |
| 194 | /* Handle timeout event only if the previous composition |
| 195 | on any display is MDP or MIXED*/ |
| 196 | for(int i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) { |
| 197 | if(ctx->mMDPComp[i]) |
| 198 | handleTimeout = |
| 199 | ctx->mMDPComp[i]->isMDPComp() || handleTimeout; |
| 200 | } |
| 201 | |
| 202 | if(!handleTimeout) { |
Ramkumar Radhakrishnan | d8595ae | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 203 | ALOGD_IF(isDebug(), "%s:Do not handle this timeout", __FUNCTION__); |
| 204 | return; |
| 205 | } |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 206 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 207 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 208 | return; |
| 209 | } |
| 210 | sIdleFallBack = true; |
| 211 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 212 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 215 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 216 | hwc_display_contents_1_t* list) { |
| 217 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 218 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 219 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 220 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 221 | if(!mCurrentFrame.isFBComposed[index]) { |
| 222 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 223 | layer->compositionType = HWC_OVERLAY; |
| 224 | layer->hints |= HWC_HINT_CLEAR_FB; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 225 | } else { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 226 | /* Drop the layer when its already present in FB OR when it lies |
| 227 | * outside frame's ROI */ |
| 228 | if(!mCurrentFrame.needsRedraw || mCurrentFrame.drop[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 229 | layer->compositionType = HWC_OVERLAY; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 230 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 231 | } |
| 232 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 233 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 234 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 235 | void MDPComp::setRedraw(hwc_context_t *ctx, |
| 236 | hwc_display_contents_1_t* list) { |
| 237 | mCurrentFrame.needsRedraw = false; |
| 238 | if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || |
| 239 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 240 | isSkipPresent(ctx, mDpy)) { |
| 241 | mCurrentFrame.needsRedraw = true; |
| 242 | } |
| 243 | } |
| 244 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 245 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | 8d09ba3 | 2014-08-14 10:11:36 -0700 | [diff] [blame] | 246 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 247 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 248 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 249 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 250 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
Saurabh Shah | 8d09ba3 | 2014-08-14 10:11:36 -0700 | [diff] [blame] | 251 | for(int i = 0; i < MAX_PIPES_PER_MIXER; i++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 252 | if(mdpToLayer[i].pipeInfo) { |
| 253 | delete mdpToLayer[i].pipeInfo; |
| 254 | mdpToLayer[i].pipeInfo = NULL; |
| 255 | //We dont own the rotator |
| 256 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 257 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 258 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 259 | |
| 260 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 261 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 262 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 263 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 264 | layerCount = numLayers; |
| 265 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 266 | mdpCount = 0; |
Saurabh Shah | 2f3895f | 2013-05-02 10:13:31 -0700 | [diff] [blame] | 267 | needsRedraw = true; |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 268 | fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 271 | void MDPComp::FrameInfo::map() { |
| 272 | // populate layer and MDP maps |
| 273 | int mdpIdx = 0; |
| 274 | for(int idx = 0; idx < layerCount; idx++) { |
| 275 | if(!isFBComposed[idx]) { |
| 276 | mdpToLayer[mdpIdx].listIndex = idx; |
| 277 | layerToMDP[idx] = mdpIdx++; |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 282 | MDPComp::LayerCache::LayerCache() { |
| 283 | reset(); |
| 284 | } |
| 285 | |
| 286 | void MDPComp::LayerCache::reset() { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 287 | memset(&isFBComposed, true, sizeof(isFBComposed)); |
| 288 | memset(&drop, false, sizeof(drop)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 289 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 292 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 293 | layerCount = curFrame.layerCount; |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 294 | memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed)); |
| 295 | memcpy(&drop, &curFrame.drop, sizeof(drop)); |
| 296 | } |
| 297 | |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 298 | bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame, |
| 299 | hwc_display_contents_1_t* list) { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 300 | if(layerCount != curFrame.layerCount) |
| 301 | return false; |
| 302 | for(int i = 0; i < curFrame.layerCount; i++) { |
| 303 | if((curFrame.isFBComposed[i] != isFBComposed[i]) || |
| 304 | (curFrame.drop[i] != drop[i])) { |
| 305 | return false; |
| 306 | } |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 307 | hwc_layer_1_t const* layer = &list->hwLayers[i]; |
| 308 | if(curFrame.isFBComposed[i] && layerUpdating(layer)) { |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 309 | return false; |
| 310 | } |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 311 | } |
| 312 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 313 | } |
| 314 | |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 315 | bool MDPComp::LayerCache::isSameFrame(hwc_context_t *ctx, int dpy, |
| 316 | hwc_display_contents_1_t* list) { |
| 317 | |
| 318 | if(layerCount != ctx->listStats[dpy].numAppLayers) |
| 319 | return false; |
| 320 | |
| 321 | if((list->flags & HWC_GEOMETRY_CHANGED) || |
| 322 | isSkipPresent(ctx, dpy)) { |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | for(int i = 0; i < layerCount; i++) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 327 | hwc_layer_1_t const* layer = &list->hwLayers[i]; |
| 328 | if(layerUpdating(layer)) |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 329 | return false; |
| 330 | } |
| 331 | |
| 332 | return true; |
| 333 | } |
| 334 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 335 | bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { |
| 336 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 337 | if((not isYuvBuffer(hnd) and has90Transform(layer)) or |
Raj Kamal | 81cab69 | 2014-10-28 15:31:35 +0530 | [diff] [blame] | 338 | (not isValidDimension(ctx,layer)) || |
| 339 | isSkipLayer(layer)) { |
| 340 | //More conditions here, sRGB+Blend etc |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 341 | return false; |
| 342 | } |
| 343 | return true; |
| 344 | } |
| 345 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 346 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 347 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 348 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 349 | |
| 350 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 351 | if (layer->flags & HWC_COLOR_FILL) { |
| 352 | // Color layer |
| 353 | return true; |
| 354 | } |
Steve Kondik | c44491f | 2015-04-14 23:31:16 -0700 | [diff] [blame^] | 355 | ALOGD_IF(isDebug(), "%s: layer handle is NULL", __FUNCTION__); |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 356 | return false; |
| 357 | } |
| 358 | |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 359 | //XXX: Investigate doing this with pixel phase on MDSS |
Naseer Ahmed | e77f808 | 2013-10-10 13:42:48 -0400 | [diff] [blame] | 360 | if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 361 | return false; |
| 362 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 363 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 364 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 365 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 366 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 367 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 368 | int crop_w = crop.right - crop.left; |
| 369 | int crop_h = crop.bottom - crop.top; |
| 370 | int dst_w = dst.right - dst.left; |
| 371 | int dst_h = dst.bottom - dst.top; |
| 372 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 373 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 374 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 375 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 376 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 377 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 378 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 379 | * Fallback to GPU if height is less than 2. |
| 380 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 381 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 382 | return false; |
| 383 | |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 384 | if((w_dscale > 1.0f) || (h_dscale > 1.0f)) { |
| 385 | const uint32_t downscale = |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 386 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 387 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 388 | /* Workaround for downscales larger than 4x. |
| 389 | * Will be removed once decimator block is enabled for MDSS |
| 390 | */ |
| 391 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 392 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 393 | h_dscale > downscale) |
| 394 | return false; |
| 395 | } else { |
| 396 | if(w_dscale > 64 || h_dscale > 64) |
| 397 | return false; |
| 398 | } |
| 399 | } else { //A-family |
| 400 | if(w_dscale > downscale || h_dscale > downscale) |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 401 | return false; |
| 402 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 405 | return true; |
| 406 | } |
| 407 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 408 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 409 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 410 | overlay::Overlay& ov = *ctx->mOverlay; |
| 411 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 412 | |
| 413 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 414 | case MDPCOMP_OV_DMA: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 415 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer, |
| 416 | Overlay::FORMAT_RGB); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 417 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 418 | return mdp_pipe; |
| 419 | } |
| 420 | case MDPCOMP_OV_ANY: |
| 421 | case MDPCOMP_OV_RGB: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 422 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer, |
| 423 | Overlay::FORMAT_RGB); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 424 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 425 | return mdp_pipe; |
| 426 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 427 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 428 | if(type == MDPCOMP_OV_RGB) { |
| 429 | //Requested only for RGB pipe |
| 430 | break; |
| 431 | } |
| 432 | case MDPCOMP_OV_VG: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 433 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer, |
| 434 | Overlay::FORMAT_YUV); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 435 | default: |
| 436 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 437 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 438 | }; |
| 439 | return ovutils::OV_INVALID; |
| 440 | } |
| 441 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 442 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 443 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 444 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 445 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 446 | if(!isEnabled()) { |
| 447 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 448 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 449 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Tatenda Chipeperekwa | 75a4181 | 2014-04-01 12:54:13 -0700 | [diff] [blame] | 450 | ctx->mVideoTransFlag && |
| 451 | isSecondaryConnected(ctx)) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 452 | //1 Padding round to shift pipes across mixers |
| 453 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 454 | __FUNCTION__); |
| 455 | ret = false; |
Raj Kamal | 2a18d6d | 2015-03-17 20:53:14 +0530 | [diff] [blame] | 456 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
| 457 | !mDpy && isSecondaryAnimating(ctx) && |
| 458 | (isYuvPresent(ctx,HWC_DISPLAY_EXTERNAL) || |
| 459 | isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL))) { |
| 460 | ALOGD_IF(isDebug(),"%s: Display animation in progress", |
| 461 | __FUNCTION__); |
| 462 | ret = false; |
Ramkumar Radhakrishnan | 0f95261 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 463 | } else if(isSecondaryConfiguring(ctx)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 464 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 465 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 466 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 467 | } else if(ctx->isPaddingRound) { |
Raj Kamal | fc5b922 | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 468 | ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d", |
| 469 | __FUNCTION__,mDpy); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 470 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 471 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 472 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 473 | } |
| 474 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 475 | /* |
| 476 | * 1) Identify layers that are not visible in the updating ROI and drop them |
| 477 | * from composition. |
| 478 | * 2) If we have a scaling layers which needs cropping against generated ROI. |
| 479 | * Reset ROI to full resolution. |
| 480 | */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 481 | bool MDPComp::validateAndApplyROI(hwc_context_t *ctx, |
| 482 | hwc_display_contents_1_t* list, hwc_rect_t roi) { |
| 483 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 484 | |
| 485 | if(!isValidRect(roi)) |
| 486 | return false; |
| 487 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 488 | hwc_rect_t visibleRect = roi; |
| 489 | |
| 490 | for(int i = numAppLayers - 1; i >= 0; i--){ |
| 491 | |
| 492 | if(!isValidRect(visibleRect)) { |
| 493 | mCurrentFrame.drop[i] = true; |
| 494 | mCurrentFrame.dropCount++; |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 495 | continue; |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 496 | } |
| 497 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 498 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 499 | |
| 500 | hwc_rect_t dstRect = layer->displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 501 | hwc_rect_t srcRect = integerizeSourceCrop(layer->sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 502 | int transform = layer->transform; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 503 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 504 | hwc_rect_t res = getIntersection(visibleRect, dstRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 505 | |
| 506 | int res_w = res.right - res.left; |
| 507 | int res_h = res.bottom - res.top; |
| 508 | int dst_w = dstRect.right - dstRect.left; |
| 509 | int dst_h = dstRect.bottom - dstRect.top; |
| 510 | |
| 511 | if(!isValidRect(res)) { |
| 512 | mCurrentFrame.drop[i] = true; |
| 513 | mCurrentFrame.dropCount++; |
| 514 | }else { |
| 515 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 516 | * cropping */ |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 517 | if((res_w != dst_w || res_h != dst_h) && needsScaling (layer)) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 518 | ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 519 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 520 | mCurrentFrame.dropCount = 0; |
| 521 | return false; |
| 522 | } |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 523 | |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 524 | /* deduct any opaque region from visibleRect */ |
radhakrishna | 3185893 | 2014-11-03 13:19:27 +0530 | [diff] [blame] | 525 | if (layer->blending == HWC_BLENDING_NONE && |
| 526 | layer->planeAlpha == 0xFF) |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 527 | visibleRect = deductRect(visibleRect, res); |
| 528 | } |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 529 | } |
| 530 | return true; |
| 531 | } |
| 532 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 533 | bool MDPComp::canDoPartialUpdate(hwc_context_t *ctx, |
| 534 | hwc_display_contents_1_t* list){ |
| 535 | if(!qdutils::MDPVersion::getInstance().isPartialUpdateEnabled() || mDpy || |
| 536 | isSkipPresent(ctx, mDpy) || (list->flags & HWC_GEOMETRY_CHANGED)|| |
| 537 | isDisplaySplit(ctx, mDpy)) { |
| 538 | return false; |
| 539 | } |
Jeykumar Sankaran | b582a0e | 2014-07-02 12:23:09 -0700 | [diff] [blame] | 540 | |
| 541 | if(ctx->listStats[mDpy].secureUI) |
| 542 | return false; |
| 543 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 544 | return true; |
| 545 | } |
| 546 | |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 547 | /* Calculate ROI for the frame by accounting all the layer's dispalyFrame which |
| 548 | * are updating. If DirtyRegion is applicable, calculate it by accounting all |
| 549 | * the changing layer's dirtyRegion. */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 550 | void MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 551 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 552 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 553 | if(!canDoPartialUpdate(ctx, list)) |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 554 | return; |
| 555 | |
| 556 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 557 | hwc_rect fullFrame = (struct hwc_rect) {0, 0,(int)ctx->dpyAttr[mDpy].xres, |
| 558 | (int)ctx->dpyAttr[mDpy].yres}; |
| 559 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 560 | for(int index = 0; index < numAppLayers; index++ ) { |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 561 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 562 | if (layerUpdating(layer) || |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 563 | isYuvBuffer((private_handle_t *)layer->handle)) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 564 | hwc_rect_t updatingRect = layer->displayFrame; |
| 565 | if(!needsScaling(layer) && !layer->transform && |
| 566 | (!isYuvBuffer((private_handle_t *)layer->handle))) |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 567 | { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 568 | updatingRect = calculateDirtyRect(layer, fullFrame); |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 569 | } |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 570 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 571 | roi = getUnion(roi, updatingRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 572 | } |
| 573 | } |
| 574 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 575 | // Align ROI coordinates to panel restrictions |
| 576 | roi = sanitizeROI(roi, fullFrame); |
| 577 | |
| 578 | if(!validateAndApplyROI(ctx, list, roi)) |
| 579 | roi = fullFrame; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 580 | |
| 581 | ctx->listStats[mDpy].roi.x = roi.left; |
| 582 | ctx->listStats[mDpy].roi.y = roi.top; |
| 583 | ctx->listStats[mDpy].roi.w = roi.right - roi.left; |
| 584 | ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; |
| 585 | |
| 586 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 587 | roi.left, roi.top, roi.right, roi.bottom); |
| 588 | } |
| 589 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 590 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 591 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 592 | bool MDPComp::tryFullFrame(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 593 | hwc_display_contents_1_t* list){ |
| 594 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 595 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 596 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 597 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 598 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 599 | return false; |
| 600 | } |
| 601 | |
Raj Kamal | 2a18d6d | 2015-03-17 20:53:14 +0530 | [diff] [blame] | 602 | if(!mDpy && isSecondaryAnimating(ctx) && |
| 603 | (isYuvPresent(ctx,HWC_DISPLAY_EXTERNAL) || |
| 604 | isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL)) ) { |
| 605 | ALOGD_IF(isDebug(),"%s: Display animation in progress", |
| 606 | __FUNCTION__); |
| 607 | return false; |
| 608 | } |
| 609 | |
Ramkumar Radhakrishnan | 4af1ef0 | 2013-12-12 11:53:08 -0800 | [diff] [blame] | 610 | // check for action safe flag and downscale mode which requires scaling. |
| 611 | if(ctx->dpyAttr[mDpy].mActionSafePresent |
| 612 | || ctx->dpyAttr[mDpy].mDownScaleMode) { |
| 613 | ALOGD_IF(isDebug(), "%s: Scaling needed for this frame",__FUNCTION__); |
| 614 | return false; |
| 615 | } |
| 616 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 617 | for(int i = 0; i < numAppLayers; ++i) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 618 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 619 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 620 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 621 | if(isYuvBuffer(hnd) && has90Transform(layer)) { |
| 622 | if(!canUseRotator(ctx, mDpy)) { |
| 623 | ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", |
| 624 | __FUNCTION__, mDpy); |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 625 | return false; |
| 626 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 627 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 628 | |
| 629 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 630 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
Sushil Chauhan | d8ef93f | 2014-03-20 11:08:41 -0700 | [diff] [blame] | 631 | int transform = (layer->flags & HWC_COLOR_FILL) ? 0 : layer->transform; |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 632 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 633 | (ctx->dpyAttr[mDpy].xres > 1024) && |
Sushil Chauhan | d8ef93f | 2014-03-20 11:08:41 -0700 | [diff] [blame] | 634 | (transform & HWC_TRANSFORM_FLIP_H) && |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 635 | (!isYuvBuffer(hnd))) |
| 636 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 637 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 638 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 639 | if(ctx->mAD->isDoable()) { |
| 640 | return false; |
| 641 | } |
| 642 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 643 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 644 | bool ret = false; |
| 645 | if(fullMDPComp(ctx, list)) { |
| 646 | ret = true; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 647 | } else if(fullMDPCompWithPTOR(ctx, list)) { |
| 648 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 649 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 650 | ret = true; |
| 651 | } |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 652 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 653 | return ret; |
| 654 | } |
| 655 | |
| 656 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 657 | //Will benefit presentation / secondary-only layer. |
| 658 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 659 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 660 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 661 | return false; |
| 662 | } |
| 663 | |
| 664 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 665 | for(int i = 0; i < numAppLayers; i++) { |
| 666 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 667 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 668 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 669 | return false; |
| 670 | } |
| 671 | } |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 672 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 673 | mCurrentFrame.fbCount = 0; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 674 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 675 | sizeof(mCurrentFrame.isFBComposed)); |
| 676 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 677 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 678 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 679 | if(sEnable4k2kYUVSplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 680 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 681 | } |
| 682 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 683 | if(!postHeuristicsHandling(ctx, list)) { |
| 684 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 685 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 686 | return false; |
| 687 | } |
| 688 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 689 | return true; |
| 690 | } |
| 691 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 692 | /* Full MDP Composition with Peripheral Tiny Overlap Removal. |
| 693 | * MDP bandwidth limitations can be avoided, if the overlap region |
| 694 | * covered by the smallest layer at a higher z-order, gets composed |
| 695 | * by Copybit on a render buffer, which can be queued to MDP. |
| 696 | */ |
| 697 | bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, |
| 698 | hwc_display_contents_1_t* list) { |
| 699 | |
| 700 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 701 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 702 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
| 703 | |
| 704 | // Hard checks where we cannot use this mode |
Justin Philip | b1906f7 | 2014-10-30 14:14:19 +0530 | [diff] [blame] | 705 | if (mDpy || !ctx->mCopyBit[mDpy] || !ctx->mIsPTOREnabled) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 706 | ALOGD_IF(isDebug(), "%s: Feature not supported!", __FUNCTION__); |
| 707 | return false; |
| 708 | } |
| 709 | |
| 710 | // Frame level checks |
| 711 | if ((numAppLayers > stagesForMDP) || isSkipPresent(ctx, mDpy) || |
| 712 | isYuvPresent(ctx, mDpy) || mCurrentFrame.dropCount || |
| 713 | isSecurePresent(ctx, mDpy)) { |
| 714 | ALOGD_IF(isDebug(), "%s: Frame not supported!", __FUNCTION__); |
| 715 | return false; |
| 716 | } |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 717 | // MDP comp checks |
| 718 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 719 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 720 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 721 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 722 | return false; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 726 | /* We cannot use this composition mode, if: |
| 727 | 1. A below layer needs scaling. |
| 728 | 2. Overlap is not peripheral to display. |
| 729 | 3. Overlap or a below layer has 90 degree transform. |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 730 | 4. Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 731 | */ |
| 732 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 733 | int minLayerIndex[MAX_PTOR_LAYERS] = { -1, -1}; |
| 734 | hwc_rect_t overlapRect[MAX_PTOR_LAYERS]; |
| 735 | memset(overlapRect, 0, sizeof(overlapRect)); |
| 736 | int layerPixelCount, minPixelCount = 0; |
| 737 | int numPTORLayersFound = 0; |
| 738 | for (int i = numAppLayers-1; (i >= 0 && |
| 739 | numPTORLayersFound < MAX_PTOR_LAYERS); i--) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 740 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 741 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 742 | hwc_rect_t dispFrame = layer->displayFrame; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 743 | layerPixelCount = (crop.right - crop.left) * (crop.bottom - crop.top); |
| 744 | // PTOR layer should be peripheral and cannot have transform |
| 745 | if (!isPeripheral(dispFrame, ctx->mViewFrame[mDpy]) || |
| 746 | has90Transform(layer)) { |
| 747 | continue; |
| 748 | } |
| 749 | if((3 * (layerPixelCount + minPixelCount)) > |
| 750 | ((int)ctx->dpyAttr[mDpy].xres * (int)ctx->dpyAttr[mDpy].yres)) { |
| 751 | // Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
| 752 | continue; |
| 753 | } |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 754 | bool found = false; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 755 | for (int j = i-1; j >= 0; j--) { |
| 756 | // Check if the layers below this layer qualifies for PTOR comp |
| 757 | hwc_layer_1_t* layer = &list->hwLayers[j]; |
| 758 | hwc_rect_t disFrame = layer->displayFrame; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 759 | // Layer below PTOR is intersecting and has 90 degree transform or |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 760 | // needs scaling cannot be supported. |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 761 | if (isValidRect(getIntersection(dispFrame, disFrame))) { |
| 762 | if (has90Transform(layer) || needsScaling(layer)) { |
| 763 | found = false; |
| 764 | break; |
| 765 | } |
| 766 | found = true; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | // Store the minLayer Index |
| 770 | if(found) { |
| 771 | minLayerIndex[numPTORLayersFound] = i; |
| 772 | overlapRect[numPTORLayersFound] = list->hwLayers[i].displayFrame; |
| 773 | minPixelCount += layerPixelCount; |
| 774 | numPTORLayersFound++; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 775 | } |
| 776 | } |
| 777 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 778 | // No overlap layers |
| 779 | if (!numPTORLayersFound) |
| 780 | return false; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 781 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 782 | // Store the displayFrame and the sourceCrops of the layers |
| 783 | hwc_rect_t displayFrame[numAppLayers]; |
| 784 | hwc_rect_t sourceCrop[numAppLayers]; |
| 785 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 786 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 787 | displayFrame[i] = layer->displayFrame; |
| 788 | sourceCrop[i] = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 789 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 790 | |
Prabhanjan Kandula | bb1f6be | 2014-09-04 21:50:35 +0530 | [diff] [blame] | 791 | /** |
| 792 | * It's possible that 2 PTOR layers might have overlapping. |
| 793 | * In such case, remove the intersection(again if peripheral) |
| 794 | * from the lower PTOR layer to avoid overlapping. |
| 795 | * If intersection is not on peripheral then compromise |
| 796 | * by reducing number of PTOR layers. |
| 797 | **/ |
| 798 | hwc_rect_t commonRect = getIntersection(overlapRect[0], overlapRect[1]); |
| 799 | if(isValidRect(commonRect)) { |
| 800 | overlapRect[1] = deductRect(overlapRect[1], commonRect); |
| 801 | list->hwLayers[minLayerIndex[1]].displayFrame = overlapRect[1]; |
| 802 | } |
| 803 | |
| 804 | ctx->mPtorInfo.count = numPTORLayersFound; |
| 805 | for(int i = 0; i < MAX_PTOR_LAYERS; i++) { |
| 806 | ctx->mPtorInfo.layerIndex[i] = minLayerIndex[i]; |
| 807 | } |
| 808 | |
| 809 | if (!ctx->mCopyBit[mDpy]->prepareOverlap(ctx, list)) { |
| 810 | // reset PTOR |
| 811 | ctx->mPtorInfo.count = 0; |
| 812 | if(isValidRect(commonRect)) { |
| 813 | // If PTORs are intersecting restore displayframe of PTOR[1] |
| 814 | // before returning, as we have modified it above. |
| 815 | list->hwLayers[minLayerIndex[1]].displayFrame = |
| 816 | displayFrame[minLayerIndex[1]]; |
| 817 | } |
| 818 | return false; |
| 819 | } |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 820 | private_handle_t *renderBuf = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
| 821 | Whf layerWhf[numPTORLayersFound]; // To store w,h,f of PTOR layers |
| 822 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 823 | // Store the blending mode, planeAlpha, and transform of PTOR layers |
| 824 | int32_t blending[numPTORLayersFound]; |
| 825 | uint8_t planeAlpha[numPTORLayersFound]; |
| 826 | uint32_t transform[numPTORLayersFound]; |
| 827 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 828 | for(int j = 0; j < numPTORLayersFound; j++) { |
| 829 | int index = ctx->mPtorInfo.layerIndex[j]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 830 | |
| 831 | // Update src crop of PTOR layer |
| 832 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 833 | layer->sourceCropf.left = (float)ctx->mPtorInfo.displayFrame[j].left; |
| 834 | layer->sourceCropf.top = (float)ctx->mPtorInfo.displayFrame[j].top; |
| 835 | layer->sourceCropf.right = (float)ctx->mPtorInfo.displayFrame[j].right; |
| 836 | layer->sourceCropf.bottom =(float)ctx->mPtorInfo.displayFrame[j].bottom; |
| 837 | |
| 838 | // Store & update w, h, format of PTOR layer |
| 839 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 840 | Whf whf(hnd->width, hnd->height, hnd->format, hnd->size); |
| 841 | layerWhf[j] = whf; |
| 842 | hnd->width = renderBuf->width; |
| 843 | hnd->height = renderBuf->height; |
| 844 | hnd->format = renderBuf->format; |
| 845 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 846 | // Store & update blending mode, planeAlpha and transform of PTOR layer |
| 847 | blending[j] = layer->blending; |
| 848 | planeAlpha[j] = layer->planeAlpha; |
| 849 | transform[j] = layer->transform; |
| 850 | layer->blending = HWC_BLENDING_NONE; |
| 851 | layer->planeAlpha = 0xFF; |
| 852 | layer->transform = 0; |
| 853 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 854 | // Remove overlap from crop & displayFrame of below layers |
| 855 | for (int i = 0; i < index && index !=-1; i++) { |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 856 | layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 857 | if(!isValidRect(getIntersection(layer->displayFrame, |
| 858 | overlapRect[j]))) { |
| 859 | continue; |
| 860 | } |
| 861 | // Update layer attributes |
| 862 | hwc_rect_t srcCrop = integerizeSourceCrop(layer->sourceCropf); |
| 863 | hwc_rect_t destRect = deductRect(layer->displayFrame, |
Dileep Kumar Reddi | cc32af0 | 2014-11-11 16:03:03 +0530 | [diff] [blame] | 864 | getIntersection(layer->displayFrame, overlapRect[j])); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 865 | qhwc::calculate_crop_rects(srcCrop, layer->displayFrame, destRect, |
| 866 | layer->transform); |
| 867 | layer->sourceCropf.left = (float)srcCrop.left; |
| 868 | layer->sourceCropf.top = (float)srcCrop.top; |
| 869 | layer->sourceCropf.right = (float)srcCrop.right; |
| 870 | layer->sourceCropf.bottom = (float)srcCrop.bottom; |
| 871 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | mCurrentFrame.mdpCount = numAppLayers; |
| 875 | mCurrentFrame.fbCount = 0; |
| 876 | mCurrentFrame.fbZ = -1; |
| 877 | |
Dileep Kumar Reddi | cc32af0 | 2014-11-11 16:03:03 +0530 | [diff] [blame] | 878 | for (int j = 0; j < numAppLayers; j++) { |
| 879 | if(isValidRect(list->hwLayers[j].displayFrame)) { |
| 880 | mCurrentFrame.isFBComposed[j] = false; |
| 881 | } else { |
| 882 | mCurrentFrame.mdpCount--; |
| 883 | mCurrentFrame.drop[j] = true; |
| 884 | } |
| 885 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 886 | |
| 887 | bool result = postHeuristicsHandling(ctx, list); |
| 888 | |
| 889 | // Restore layer attributes |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 890 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 891 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 892 | layer->displayFrame = displayFrame[i]; |
| 893 | layer->sourceCropf.left = (float)sourceCrop[i].left; |
| 894 | layer->sourceCropf.top = (float)sourceCrop[i].top; |
| 895 | layer->sourceCropf.right = (float)sourceCrop[i].right; |
| 896 | layer->sourceCropf.bottom = (float)sourceCrop[i].bottom; |
| 897 | } |
| 898 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 899 | // Restore w,h,f, blending attributes, and transform of PTOR layers |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 900 | for (int i = 0; i < numPTORLayersFound; i++) { |
| 901 | int idx = ctx->mPtorInfo.layerIndex[i]; |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 902 | hwc_layer_1_t* layer = &list->hwLayers[idx]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 903 | private_handle_t *hnd = (private_handle_t *)list->hwLayers[idx].handle; |
| 904 | hnd->width = layerWhf[i].w; |
| 905 | hnd->height = layerWhf[i].h; |
| 906 | hnd->format = layerWhf[i].format; |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 907 | layer->blending = blending[i]; |
| 908 | layer->planeAlpha = planeAlpha[i]; |
| 909 | layer->transform = transform[i]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 912 | if (!result) { |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 913 | // reset PTOR |
| 914 | ctx->mPtorInfo.count = 0; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 915 | reset(ctx); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 916 | } else { |
| 917 | ALOGD_IF(isDebug(), "%s: PTOR Indexes: %d and %d", __FUNCTION__, |
| 918 | ctx->mPtorInfo.layerIndex[0], ctx->mPtorInfo.layerIndex[1]); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 919 | } |
| 920 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 921 | ALOGD_IF(isDebug(), "%s: Postheuristics %s!", __FUNCTION__, |
| 922 | (result ? "successful" : "failed")); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 923 | return result; |
| 924 | } |
| 925 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 926 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 927 | { |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 928 | if(!sEnableMixedMode) { |
| 929 | //Mixed mode is disabled. No need to even try caching. |
| 930 | return false; |
| 931 | } |
| 932 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 933 | bool ret = false; |
Raj Kamal | 81cab69 | 2014-10-28 15:31:35 +0530 | [diff] [blame] | 934 | if(isSkipPresent(ctx, mDpy) or list->flags & HWC_GEOMETRY_CHANGED) { |
| 935 | //Try load based first |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 936 | ret = loadBasedComp(ctx, list) or |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 937 | cacheBasedComp(ctx, list); |
| 938 | } else { |
| 939 | ret = cacheBasedComp(ctx, list) or |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 940 | loadBasedComp(ctx, list); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 941 | } |
| 942 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 943 | return ret; |
| 944 | } |
| 945 | |
| 946 | bool MDPComp::cacheBasedComp(hwc_context_t *ctx, |
| 947 | hwc_display_contents_1_t* list) { |
| 948 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 949 | mCurrentFrame.reset(numAppLayers); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 950 | updateLayerCache(ctx, list, mCurrentFrame); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 951 | |
| 952 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 953 | for(int i = 0; i < numAppLayers; i++) { |
| 954 | if(!mCurrentFrame.isFBComposed[i]) { |
| 955 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 956 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 957 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 958 | __FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 959 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 960 | return false; |
| 961 | } |
| 962 | } |
| 963 | } |
| 964 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 965 | updateYUV(ctx, list, false /*secure only*/, mCurrentFrame); |
| 966 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 967 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 968 | if(!ret) { |
| 969 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 970 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 971 | return false; |
| 972 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 973 | |
| 974 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 975 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 976 | if(sEnable4k2kYUVSplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 977 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 978 | } |
| 979 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 980 | //Will benefit cases where a video has non-updating background. |
| 981 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 982 | (mdpCount > MAX_SEC_LAYERS)) { |
| 983 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 984 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 985 | return false; |
| 986 | } |
| 987 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 988 | if(!postHeuristicsHandling(ctx, list)) { |
| 989 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 990 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 991 | return false; |
| 992 | } |
| 993 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 994 | return true; |
| 995 | } |
| 996 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 997 | bool MDPComp::loadBasedComp(hwc_context_t *ctx, |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 998 | hwc_display_contents_1_t* list) { |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 999 | if(not isLoadBasedCompDoable(ctx, list)) { |
| 1000 | return false; |
| 1001 | } |
| 1002 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1003 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1004 | const int numNonDroppedLayers = numAppLayers - mCurrentFrame.dropCount; |
| 1005 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 1006 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1007 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1008 | int mdpBatchSize = stagesForMDP - 1; //1 stage for FB |
| 1009 | int fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
| 1010 | int lastMDPSupportedIndex = numAppLayers; |
| 1011 | int dropCount = 0; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1012 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1013 | //Find the minimum MDP batch size |
| 1014 | for(int i = 0; i < numAppLayers;i++) { |
| 1015 | if(mCurrentFrame.drop[i]) { |
| 1016 | dropCount++; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1017 | continue; |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1018 | } |
| 1019 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1020 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1021 | lastMDPSupportedIndex = i; |
| 1022 | mdpBatchSize = min(i - dropCount, stagesForMDP - 1); |
| 1023 | fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1024 | break; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1025 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1026 | } |
| 1027 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1028 | ALOGD_IF(isDebug(), "%s:Before optimizing fbBatch, mdpbatch %d, fbbatch %d " |
| 1029 | "dropped %d", __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1030 | mCurrentFrame.dropCount); |
| 1031 | |
| 1032 | //Start at a point where the fb batch should at least have 2 layers, for |
| 1033 | //this mode to be justified. |
| 1034 | while(fbBatchSize < 2) { |
| 1035 | ++fbBatchSize; |
| 1036 | --mdpBatchSize; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1037 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1038 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1039 | //If there are no layers for MDP, this mode doesnt make sense. |
| 1040 | if(mdpBatchSize < 1) { |
| 1041 | ALOGD_IF(isDebug(), "%s: No MDP layers after optimizing for fbBatch", |
| 1042 | __FUNCTION__); |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1043 | return false; |
| 1044 | } |
| 1045 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1046 | mCurrentFrame.reset(numAppLayers); |
| 1047 | |
| 1048 | //Try with successively smaller mdp batch sizes until we succeed or reach 1 |
| 1049 | while(mdpBatchSize > 0) { |
| 1050 | //Mark layers for MDP comp |
| 1051 | int mdpBatchLeft = mdpBatchSize; |
| 1052 | for(int i = 0; i < lastMDPSupportedIndex and mdpBatchLeft; i++) { |
| 1053 | if(mCurrentFrame.drop[i]) { |
| 1054 | continue; |
| 1055 | } |
| 1056 | mCurrentFrame.isFBComposed[i] = false; |
| 1057 | --mdpBatchLeft; |
| 1058 | } |
| 1059 | |
| 1060 | mCurrentFrame.fbZ = mdpBatchSize; |
| 1061 | mCurrentFrame.fbCount = fbBatchSize; |
| 1062 | mCurrentFrame.mdpCount = mdpBatchSize; |
| 1063 | |
| 1064 | ALOGD_IF(isDebug(), "%s:Trying with: mdpbatch %d fbbatch %d dropped %d", |
| 1065 | __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1066 | mCurrentFrame.dropCount); |
| 1067 | |
| 1068 | if(postHeuristicsHandling(ctx, list)) { |
| 1069 | ALOGD_IF(isDebug(), "%s: Postheuristics handling succeeded", |
| 1070 | __FUNCTION__); |
| 1071 | return true; |
| 1072 | } |
| 1073 | |
| 1074 | reset(ctx); |
| 1075 | --mdpBatchSize; |
| 1076 | ++fbBatchSize; |
| 1077 | } |
| 1078 | |
| 1079 | return false; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1080 | } |
| 1081 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1082 | bool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx, |
| 1083 | hwc_display_contents_1_t* list) { |
Prabhanjan Kandula | 3dbbd88 | 2013-12-11 14:43:46 +0530 | [diff] [blame] | 1084 | if(mDpy or isSecurePresent(ctx, mDpy) or |
| 1085 | isYuvPresent(ctx, mDpy)) { |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1086 | return false; |
| 1087 | } |
| 1088 | return true; |
| 1089 | } |
| 1090 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1091 | bool MDPComp::tryVideoOnly(hwc_context_t *ctx, |
| 1092 | hwc_display_contents_1_t* list) { |
| 1093 | const bool secureOnly = true; |
| 1094 | return videoOnlyComp(ctx, list, not secureOnly) or |
| 1095 | videoOnlyComp(ctx, list, secureOnly); |
| 1096 | } |
| 1097 | |
| 1098 | bool MDPComp::videoOnlyComp(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1099 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1100 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1101 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1102 | mCurrentFrame.reset(numAppLayers); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1103 | updateYUV(ctx, list, secureOnly, mCurrentFrame); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1104 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1105 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1106 | if(!isYuvPresent(ctx, mDpy) or (mdpCount == 0)) { |
| 1107 | reset(ctx); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1108 | return false; |
| 1109 | } |
| 1110 | |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1111 | /* Bail out if we are processing only secured video layers |
| 1112 | * and we dont have any */ |
| 1113 | if(!isSecurePresent(ctx, mDpy) && secureOnly){ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1114 | reset(ctx); |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1115 | return false; |
| 1116 | } |
| 1117 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1118 | if(mCurrentFrame.fbCount) |
| 1119 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1120 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1121 | if(sEnable4k2kYUVSplit){ |
| 1122 | adjustForSourceSplit(ctx, list); |
| 1123 | } |
| 1124 | |
| 1125 | if(!postHeuristicsHandling(ctx, list)) { |
| 1126 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
Justin Philip | c990732 | 2015-01-06 11:55:12 +0530 | [diff] [blame] | 1127 | if(errno == ENOBUFS) { |
| 1128 | ALOGD_IF(isDebug(), "SMP Allocation failed"); |
| 1129 | //On SMP allocation failure in video only comp add padding round |
| 1130 | ctx->isPaddingRound = true; |
| 1131 | } |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1132 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1133 | return false; |
| 1134 | } |
| 1135 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1136 | return true; |
| 1137 | } |
| 1138 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1139 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 1140 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1141 | if(isSkipLayer(layer)) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 1142 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1143 | return false; |
| 1144 | } |
| 1145 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 1146 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 1147 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 1148 | return false; |
| 1149 | } |
| 1150 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1151 | if(isSecuring(ctx, layer)) { |
| 1152 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 1153 | return false; |
| 1154 | } |
| 1155 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1156 | if(!isValidDimension(ctx, layer)) { |
| 1157 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 1158 | __FUNCTION__); |
| 1159 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1160 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1161 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 1162 | if(layer->planeAlpha < 0xFF) { |
| 1163 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 1164 | in video only mode", |
| 1165 | __FUNCTION__); |
| 1166 | return false; |
| 1167 | } |
| 1168 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1169 | return true; |
| 1170 | } |
| 1171 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1172 | /* starts at fromIndex and check for each layer to find |
| 1173 | * if it it has overlapping with any Updating layer above it in zorder |
| 1174 | * till the end of the batch. returns true if it finds any intersection */ |
| 1175 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 1176 | int fromIndex, int toIndex) { |
| 1177 | for(int i = fromIndex; i < toIndex; i++) { |
| 1178 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 1179 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 1180 | return false; |
| 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | return true; |
| 1185 | } |
| 1186 | |
| 1187 | /* Checks if given layer at targetLayerIndex has any |
| 1188 | * intersection with all the updating layers in beween |
| 1189 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 1190 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 1191 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 1192 | for(int i = fromIndex; i <= toIndex; i++) { |
| 1193 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1194 | if(areLayersIntersecting(&list->hwLayers[i], |
| 1195 | &list->hwLayers[targetLayerIndex])) { |
| 1196 | return true; |
| 1197 | } |
| 1198 | } |
| 1199 | } |
| 1200 | return false; |
| 1201 | } |
| 1202 | |
| 1203 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 1204 | int& maxBatchStart, int& maxBatchEnd, |
| 1205 | int& maxBatchCount) { |
| 1206 | int i = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1207 | int fbZOrder =-1; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1208 | int droppedLayerCt = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1209 | while (i < mCurrentFrame.layerCount) { |
| 1210 | int batchCount = 0; |
| 1211 | int batchStart = i; |
| 1212 | int batchEnd = i; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1213 | /* Adjust batch Z order with the dropped layers so far */ |
| 1214 | int fbZ = batchStart - droppedLayerCt; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1215 | int firstZReverseIndex = -1; |
Prabhanjan Kandula | 0ed2cc9 | 2013-12-06 12:39:04 +0530 | [diff] [blame] | 1216 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1217 | while(i < mCurrentFrame.layerCount) { |
| 1218 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1219 | if(!batchCount) { |
| 1220 | i++; |
| 1221 | break; |
| 1222 | } |
| 1223 | updatingLayersAbove++; |
| 1224 | i++; |
| 1225 | continue; |
| 1226 | } else { |
| 1227 | if(mCurrentFrame.drop[i]) { |
| 1228 | i++; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1229 | droppedLayerCt++; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1230 | continue; |
| 1231 | } else if(updatingLayersAbove <= 0) { |
| 1232 | batchCount++; |
| 1233 | batchEnd = i; |
| 1234 | i++; |
| 1235 | continue; |
| 1236 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 1237 | |
| 1238 | // We have a valid updating layer already. If layer-i not |
| 1239 | // have overlapping with all updating layers in between |
| 1240 | // batch-start and i, then we can add layer i to batch. |
| 1241 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 1242 | batchCount++; |
| 1243 | batchEnd = i; |
| 1244 | i++; |
| 1245 | continue; |
| 1246 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 1247 | //If All the non-updating layers with in this batch |
| 1248 | //does not have intersection with the updating layers |
| 1249 | //above in z-order, then we can safely move the batch to |
| 1250 | //higher z-order. Increment fbZ as it is moving up. |
| 1251 | if( firstZReverseIndex < 0) { |
| 1252 | firstZReverseIndex = i; |
| 1253 | } |
| 1254 | batchCount++; |
| 1255 | batchEnd = i; |
| 1256 | fbZ += updatingLayersAbove; |
| 1257 | i++; |
| 1258 | updatingLayersAbove = 0; |
| 1259 | continue; |
| 1260 | } else { |
| 1261 | //both failed.start the loop again from here. |
| 1262 | if(firstZReverseIndex >= 0) { |
| 1263 | i = firstZReverseIndex; |
| 1264 | } |
| 1265 | break; |
| 1266 | } |
| 1267 | } |
| 1268 | } |
| 1269 | } |
| 1270 | if(batchCount > maxBatchCount) { |
| 1271 | maxBatchCount = batchCount; |
| 1272 | maxBatchStart = batchStart; |
| 1273 | maxBatchEnd = batchEnd; |
| 1274 | fbZOrder = fbZ; |
| 1275 | } |
| 1276 | } |
| 1277 | return fbZOrder; |
| 1278 | } |
| 1279 | |
| 1280 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 1281 | hwc_display_contents_1_t* list) { |
| 1282 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 1283 | * send rest of them through MDP. This is done in 2 steps. |
| 1284 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 1285 | * 2. See if we can improve this batch size for caching by adding |
| 1286 | * opaque layers around the batch, if they don't have |
| 1287 | * any overlapping with the updating layers in between. |
| 1288 | * NEVER mark an updating layer for caching. |
| 1289 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1290 | |
| 1291 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1292 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1293 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1294 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1295 | |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1296 | /* Nothing is cached. No batching needed */ |
| 1297 | if(mCurrentFrame.fbCount == 0) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1298 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1299 | } |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1300 | |
| 1301 | /* No MDP comp layers, try to use other comp modes */ |
| 1302 | if(mCurrentFrame.mdpCount == 0) { |
| 1303 | return false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1304 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1305 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1306 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1307 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1308 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1309 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1310 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1311 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1312 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1313 | if(!mCurrentFrame.drop[i]){ |
| 1314 | //If an unsupported layer is being attempted to |
| 1315 | //be pulled out we should fail |
| 1316 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1317 | return false; |
| 1318 | } |
| 1319 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1320 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1321 | } |
| 1322 | } |
| 1323 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1324 | // update the frame data |
| 1325 | mCurrentFrame.fbZ = fbZ; |
| 1326 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1327 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1328 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1329 | |
| 1330 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1331 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1332 | |
| 1333 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1334 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1335 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1336 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1337 | hwc_display_contents_1_t* list, FrameInfo& frame) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1338 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1339 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1340 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1341 | for(int i = 0; i < numAppLayers; i++) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 1342 | hwc_layer_1_t * layer = &list->hwLayers[i]; |
| 1343 | if (!layerUpdating(layer)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1344 | if(!frame.drop[i]) |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1345 | fbCount++; |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1346 | frame.isFBComposed[i] = true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1347 | } else { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1348 | frame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1349 | } |
| 1350 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1351 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1352 | frame.fbCount = fbCount; |
| 1353 | frame.mdpCount = frame.layerCount - frame.fbCount |
| 1354 | - frame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1355 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1356 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d", |
| 1357 | __FUNCTION__, frame.mdpCount, frame.fbCount, frame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1358 | } |
| 1359 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1360 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1361 | bool secureOnly, FrameInfo& frame) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1362 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
| 1363 | for(int index = 0;index < nYuvCount; index++){ |
| 1364 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 1365 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 1366 | |
| 1367 | if(!isYUVDoable(ctx, layer)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1368 | if(!frame.isFBComposed[nYuvIndex]) { |
| 1369 | frame.isFBComposed[nYuvIndex] = true; |
| 1370 | frame.fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1371 | } |
| 1372 | } else { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1373 | if(frame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1374 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1375 | if(!secureOnly || isSecureBuffer(hnd)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1376 | frame.isFBComposed[nYuvIndex] = false; |
| 1377 | frame.fbCount--; |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1378 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1379 | } |
| 1380 | } |
| 1381 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1382 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1383 | frame.mdpCount = frame.layerCount - frame.fbCount - frame.dropCount; |
| 1384 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, frame.fbCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1385 | } |
| 1386 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1387 | bool MDPComp::postHeuristicsHandling(hwc_context_t *ctx, |
| 1388 | hwc_display_contents_1_t* list) { |
| 1389 | |
| 1390 | //Capability checks |
| 1391 | if(!resourceCheck(ctx, list)) { |
| 1392 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
| 1393 | return false; |
| 1394 | } |
| 1395 | |
| 1396 | //Limitations checks |
| 1397 | if(!hwLimitationsCheck(ctx, list)) { |
| 1398 | ALOGD_IF(isDebug(), "%s: HW limitations",__FUNCTION__); |
| 1399 | return false; |
| 1400 | } |
| 1401 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1402 | //Configure framebuffer first if applicable |
| 1403 | if(mCurrentFrame.fbZ >= 0) { |
| 1404 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 1405 | ALOGD_IF(isDebug(), "%s configure framebuffer failed", |
| 1406 | __FUNCTION__); |
| 1407 | return false; |
| 1408 | } |
| 1409 | } |
| 1410 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1411 | mCurrentFrame.map(); |
| 1412 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1413 | if(!allocLayerPipes(ctx, list)) { |
| 1414 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1415 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1419 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1420 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1421 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1422 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1423 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1424 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 1425 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1426 | mdpNextZOrder++; |
| 1427 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1428 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1429 | cur_pipe->zOrder = mdpNextZOrder++; |
| 1430 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1431 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1432 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1433 | if(configure4k2kYuv(ctx, layer, |
| 1434 | mCurrentFrame.mdpToLayer[mdpIndex]) |
| 1435 | != 0 ){ |
| 1436 | ALOGD_IF(isDebug(), "%s: Failed to configure split pipes \ |
| 1437 | for layer %d",__FUNCTION__, index); |
| 1438 | return false; |
| 1439 | } |
| 1440 | else{ |
| 1441 | mdpNextZOrder++; |
| 1442 | } |
| 1443 | continue; |
| 1444 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1445 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1446 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1447 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1448 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1449 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1450 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1451 | } |
| 1452 | |
Saurabh Shah | 450ac97 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 1453 | if(!ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd)) { |
| 1454 | ALOGD_IF(isDebug(), "%s: Failed to validate and set overlay for dpy %d" |
| 1455 | ,__FUNCTION__, mDpy); |
| 1456 | return false; |
| 1457 | } |
| 1458 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1459 | setRedraw(ctx, list); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1460 | return true; |
| 1461 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1462 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1463 | bool MDPComp::resourceCheck(hwc_context_t *ctx, |
| 1464 | hwc_display_contents_1_t *list) { |
| 1465 | const bool fbUsed = mCurrentFrame.fbCount; |
| 1466 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { |
| 1467 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 1468 | return false; |
| 1469 | } |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1470 | return true; |
| 1471 | } |
| 1472 | |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1473 | bool MDPComp::hwLimitationsCheck(hwc_context_t* ctx, |
| 1474 | hwc_display_contents_1_t* list) { |
| 1475 | |
| 1476 | //A-family hw limitation: |
| 1477 | //If a layer need alpha scaling, MDP can not support. |
| 1478 | if(ctx->mMDP.version < qdutils::MDSS_V5) { |
| 1479 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1480 | if(!mCurrentFrame.isFBComposed[i] && |
| 1481 | isAlphaScaled( &list->hwLayers[i])) { |
| 1482 | ALOGD_IF(isDebug(), "%s:frame needs alphaScaling",__FUNCTION__); |
| 1483 | return false; |
| 1484 | } |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | // On 8x26 & 8974 hw, we have a limitation of downscaling+blending. |
| 1489 | //If multiple layers requires downscaling and also they are overlapping |
| 1490 | //fall back to GPU since MDSS can not handle it. |
| 1491 | if(qdutils::MDPVersion::getInstance().is8x74v2() || |
| 1492 | qdutils::MDPVersion::getInstance().is8x26()) { |
| 1493 | for(int i = 0; i < mCurrentFrame.layerCount-1; ++i) { |
| 1494 | hwc_layer_1_t* botLayer = &list->hwLayers[i]; |
| 1495 | if(!mCurrentFrame.isFBComposed[i] && |
| 1496 | isDownscaleRequired(botLayer)) { |
| 1497 | //if layer-i is marked for MDP and needs downscaling |
| 1498 | //check if any MDP layer on top of i & overlaps with layer-i |
| 1499 | for(int j = i+1; j < mCurrentFrame.layerCount; ++j) { |
| 1500 | hwc_layer_1_t* topLayer = &list->hwLayers[j]; |
| 1501 | if(!mCurrentFrame.isFBComposed[j] && |
| 1502 | isDownscaleRequired(topLayer)) { |
| 1503 | hwc_rect_t r = getIntersection(botLayer->displayFrame, |
| 1504 | topLayer->displayFrame); |
| 1505 | if(isValidRect(r)) |
| 1506 | return false; |
| 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | } |
| 1512 | return true; |
| 1513 | } |
| 1514 | |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1515 | void MDPComp::setDynRefreshRate(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1516 | //For primary display, set the dynamic refreshrate |
| 1517 | if(!mDpy && qdutils::MDPVersion::getInstance().isDynFpsSupported() && |
| 1518 | ctx->mUseMetaDataRefreshRate) { |
| 1519 | FrameInfo frame; |
| 1520 | frame.reset(mCurrentFrame.layerCount); |
| 1521 | memset(&frame.drop, 0, sizeof(frame.drop)); |
| 1522 | frame.dropCount = 0; |
| 1523 | ALOGD_IF(isDebug(), "%s: Update Cache and YUVInfo for Dyn Refresh Rate", |
| 1524 | __FUNCTION__); |
| 1525 | updateLayerCache(ctx, list, frame); |
| 1526 | updateYUV(ctx, list, false /*secure only*/, frame); |
| 1527 | uint32_t refreshRate = ctx->dpyAttr[mDpy].refreshRate; |
| 1528 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
| 1529 | if(sIdleFallBack) { |
| 1530 | //Set minimum panel refresh rate during idle timeout |
| 1531 | refreshRate = mdpHw.getMinFpsSupported(); |
| 1532 | } else if((ctx->listStats[mDpy].yuvCount == frame.mdpCount) || |
| 1533 | (frame.layerCount == 1)) { |
| 1534 | //Set the new fresh rate, if there is only one updating YUV layer |
| 1535 | //or there is one single RGB layer with this request |
| 1536 | refreshRate = ctx->listStats[mDpy].refreshRateRequest; |
| 1537 | } |
| 1538 | setRefreshRate(ctx, mDpy, refreshRate); |
| 1539 | } |
| 1540 | } |
| 1541 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1542 | int MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1543 | int ret = 0; |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1544 | |
| 1545 | if(!ctx || !list) { |
| 1546 | ALOGE("%s: Invalid context or list",__FUNCTION__); |
| 1547 | mCachedFrame.reset(); |
| 1548 | return -1; |
| 1549 | } |
| 1550 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1551 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1552 | MDPVersion& mdpVersion = qdutils::MDPVersion::getInstance(); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1553 | |
| 1554 | // reset PTOR |
| 1555 | if(!mDpy) |
| 1556 | memset(&(ctx->mPtorInfo), 0, sizeof(ctx->mPtorInfo)); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1557 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1558 | //reset old data |
| 1559 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1560 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1561 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1562 | |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1563 | //Do not cache the information for next draw cycle. |
| 1564 | if(numLayers > MAX_NUM_APP_LAYERS or (!numLayers)) { |
| 1565 | ALOGI("%s: Unsupported layer count for mdp composition", |
| 1566 | __FUNCTION__); |
| 1567 | mCachedFrame.reset(); |
| 1568 | #ifdef DYNAMIC_FPS |
| 1569 | setDynRefreshRate(ctx, list); |
| 1570 | #endif |
| 1571 | return -1; |
| 1572 | } |
| 1573 | |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1574 | // Detect the start of animation and fall back to GPU only once to cache |
| 1575 | // all the layers in FB and display FB content untill animation completes. |
| 1576 | if(ctx->listStats[mDpy].isDisplayAnimating) { |
| 1577 | mCurrentFrame.needsRedraw = false; |
| 1578 | if(ctx->mAnimationState[mDpy] == ANIMATION_STOPPED) { |
| 1579 | mCurrentFrame.needsRedraw = true; |
| 1580 | ctx->mAnimationState[mDpy] = ANIMATION_STARTED; |
| 1581 | } |
| 1582 | setMDPCompLayerFlags(ctx, list); |
| 1583 | mCachedFrame.updateCounts(mCurrentFrame); |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1584 | #ifdef DYNAMIC_FPS |
| 1585 | setDynRefreshRate(ctx, list); |
| 1586 | #endif |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1587 | ret = -1; |
| 1588 | return ret; |
| 1589 | } else { |
| 1590 | ctx->mAnimationState[mDpy] = ANIMATION_STOPPED; |
| 1591 | } |
| 1592 | |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 1593 | if(!mDpy and !isSecondaryConnected(ctx) and !mPrevModeOn and |
| 1594 | mCachedFrame.isSameFrame(ctx,mDpy,list)) { |
| 1595 | ALOGD_IF(isDebug(),"%s: Avoid new composition",__FUNCTION__); |
| 1596 | mCurrentFrame.needsRedraw = false; |
| 1597 | setMDPCompLayerFlags(ctx, list); |
| 1598 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1599 | return -1; |
| 1600 | |
| 1601 | } |
| 1602 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1603 | //Hard conditions, if not met, cannot do MDP comp |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1604 | if(isFrameDoable(ctx)) { |
| 1605 | generateROI(ctx, list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1606 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1607 | mModeOn = tryFullFrame(ctx, list) || tryVideoOnly(ctx, list); |
| 1608 | if(mModeOn) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1609 | setMDPCompLayerFlags(ctx, list); |
| 1610 | } else { |
| 1611 | reset(ctx); |
| 1612 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1613 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1614 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1615 | } |
| 1616 | } else { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1617 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1618 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1619 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1620 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1621 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1622 | if(isDebug()) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1623 | ALOGD("GEOMETRY change: %d", |
| 1624 | (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1625 | android::String8 sDump(""); |
| 1626 | dump(sDump); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1627 | ALOGD("%s",sDump.string()); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1628 | } |
| 1629 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1630 | #ifdef DYNAMIC_FPS |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1631 | setDynRefreshRate(ctx, list); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1632 | #endif |
| 1633 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1634 | mCachedFrame.updateCounts(mCurrentFrame); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1635 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1636 | } |
| 1637 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1638 | bool MDPComp::allocSplitVGPipesfor4k2k(hwc_context_t *ctx, |
| 1639 | hwc_display_contents_1_t* list, int index) { |
| 1640 | |
| 1641 | bool bRet = true; |
| 1642 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1643 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1644 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1645 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
| 1646 | info.pipeInfo = new MdpYUVPipeInfo; |
| 1647 | info.rot = NULL; |
| 1648 | MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo; |
| 1649 | ePipeType type = MDPCOMP_OV_VG; |
| 1650 | |
| 1651 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1652 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1653 | |
| 1654 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1655 | if(pipe_info.lIndex == ovutils::OV_INVALID){ |
| 1656 | bRet = false; |
| 1657 | ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed", |
| 1658 | __FUNCTION__); |
| 1659 | } |
| 1660 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1661 | if(pipe_info.rIndex == ovutils::OV_INVALID){ |
| 1662 | bRet = false; |
| 1663 | ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed", |
| 1664 | __FUNCTION__); |
| 1665 | } |
| 1666 | return bRet; |
| 1667 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1668 | |
| 1669 | int MDPComp::drawOverlap(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1670 | int fd = -1; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1671 | if (ctx->mPtorInfo.isActive()) { |
| 1672 | fd = ctx->mCopyBit[mDpy]->drawOverlap(ctx, list); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1673 | if (fd < 0) { |
| 1674 | ALOGD_IF(isDebug(),"%s: failed", __FUNCTION__); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1675 | } |
| 1676 | } |
| 1677 | return fd; |
| 1678 | } |
| 1679 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1680 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1681 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1682 | void MDPCompNonSplit::adjustForSourceSplit(hwc_context_t *ctx, |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1683 | hwc_display_contents_1_t* list){ |
| 1684 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1685 | //(if available) increase mdpcount accordingly |
| 1686 | mCurrentFrame.mdpCount += ctx->listStats[mDpy].yuv4k2kCount; |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1687 | |
| 1688 | //If 4k2k Yuv layer split is possible, and if |
| 1689 | //fbz is above 4k2k layer, increment fb zorder by 1 |
| 1690 | //as we split 4k2k layer and increment zorder for right half |
| 1691 | //of the layer |
| 1692 | if(mCurrentFrame.fbZ >= 0) { |
Dileep Kumar Reddi | 2268dd7 | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1693 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 1694 | index++) { |
| 1695 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1696 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1697 | mdpNextZOrder++; |
| 1698 | } |
| 1699 | mdpNextZOrder++; |
| 1700 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1701 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1702 | if(is4kx2kYuvBuffer(hnd)) { |
| 1703 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 1704 | mCurrentFrame.fbZ += 1; |
| 1705 | mdpNextZOrder++; |
| 1706 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1707 | //(if available) increase mdpcount by 1. |
| 1708 | mCurrentFrame.mdpCount++; |
| 1709 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1710 | } |
| 1711 | } |
| 1712 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1713 | } |
| 1714 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1715 | /* |
| 1716 | * Configures pipe(s) for MDP composition |
| 1717 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1718 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1719 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1720 | MdpPipeInfoNonSplit& mdp_info = |
| 1721 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 1722 | eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1723 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1724 | eIsFg isFg = IS_FG_OFF; |
| 1725 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1726 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1727 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1728 | __FUNCTION__, layer, zOrder, dest); |
| 1729 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1730 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1731 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1734 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1735 | hwc_display_contents_1_t* list) { |
| 1736 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1737 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1738 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1739 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1740 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1741 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1742 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1743 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1744 | continue; |
| 1745 | } |
| 1746 | } |
| 1747 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1748 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1749 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1750 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1751 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1752 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1753 | ePipeType type = MDPCOMP_OV_ANY; |
| 1754 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1755 | if(isYuvBuffer(hnd)) { |
| 1756 | type = MDPCOMP_OV_VG; |
Prabhanjan Kandula | 5b8913e | 2014-01-22 23:01:45 +0530 | [diff] [blame] | 1757 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
| 1758 | (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024)) { |
| 1759 | if(qhwc::needsScaling(layer)) |
| 1760 | type = MDPCOMP_OV_RGB; |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1761 | } else if(!qhwc::needsScaling(layer) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1762 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1763 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1764 | type = MDPCOMP_OV_DMA; |
| 1765 | } |
| 1766 | |
Xu Yang | 5c2b3af | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 1767 | // for 8x26, never allow primary display occupy DMA pipe |
| 1768 | // when external display is connected |
| 1769 | if(qdutils::MDPVersion::getInstance().is8x26() |
| 1770 | && ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive |
| 1771 | && ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected |
| 1772 | && !ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isPause |
| 1773 | && mDpy == HWC_DISPLAY_PRIMARY |
| 1774 | && type == MDPCOMP_OV_DMA) { |
| 1775 | type = MDPCOMP_OV_RGB; |
| 1776 | } |
| 1777 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1778 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1779 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1780 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 1781 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1782 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1783 | } |
| 1784 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1785 | return true; |
| 1786 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1787 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1788 | int MDPCompNonSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 1789 | PipeLayerPair& PipeLayerPair) { |
| 1790 | MdpYUVPipeInfo& mdp_info = |
| 1791 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 1792 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1793 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 1794 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1795 | eDest lDest = mdp_info.lIndex; |
| 1796 | eDest rDest = mdp_info.rIndex; |
| 1797 | |
| 1798 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 1799 | lDest, rDest, &PipeLayerPair.rot); |
| 1800 | } |
| 1801 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1802 | bool MDPCompNonSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1803 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1804 | if(!isEnabled() or !mModeOn) { |
| 1805 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1806 | return true; |
| 1807 | } |
| 1808 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1809 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1810 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1811 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1812 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1813 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1814 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1815 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1816 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1817 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1818 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1819 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 1820 | if (!(layer->flags & HWC_COLOR_FILL)) { |
| 1821 | ALOGE("%s handle null", __FUNCTION__); |
| 1822 | return false; |
| 1823 | } |
| 1824 | // No PLAY for Color layer |
| 1825 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1826 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1827 | } |
| 1828 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1829 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1830 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1831 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 1832 | { |
| 1833 | MdpYUVPipeInfo& pipe_info = |
| 1834 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1835 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1836 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1837 | ovutils::eDest indexR = pipe_info.rIndex; |
| 1838 | int fd = hnd->fd; |
| 1839 | uint32_t offset = hnd->offset; |
| 1840 | if(rot) { |
| 1841 | rot->queueBuffer(fd, offset); |
| 1842 | fd = rot->getDstMemId(); |
| 1843 | offset = rot->getDstOffset(); |
| 1844 | } |
| 1845 | if(indexL != ovutils::OV_INVALID) { |
| 1846 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 1847 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1848 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 1849 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1850 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1851 | __FUNCTION__, mDpy); |
| 1852 | return false; |
| 1853 | } |
| 1854 | } |
| 1855 | |
| 1856 | if(indexR != ovutils::OV_INVALID) { |
| 1857 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 1858 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1859 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 1860 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1861 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1862 | __FUNCTION__, mDpy); |
| 1863 | return false; |
| 1864 | } |
| 1865 | } |
| 1866 | } |
| 1867 | else{ |
| 1868 | MdpPipeInfoNonSplit& pipe_info = |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1869 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1870 | ovutils::eDest dest = pipe_info.index; |
| 1871 | if(dest == ovutils::OV_INVALID) { |
| 1872 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1873 | return false; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1874 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1875 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1876 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1877 | continue; |
| 1878 | } |
| 1879 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1880 | int fd = hnd->fd; |
| 1881 | uint32_t offset = (uint32_t)hnd->offset; |
| 1882 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 1883 | if (!mDpy && (index != -1)) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1884 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1885 | fd = hnd->fd; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 1886 | offset = 0; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1887 | } |
| 1888 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1889 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1890 | using pipe: %d", __FUNCTION__, layer, |
| 1891 | hnd, dest ); |
| 1892 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1893 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1894 | if(rot) { |
| 1895 | if(!rot->queueBuffer(fd, offset)) |
| 1896 | return false; |
| 1897 | fd = rot->getDstMemId(); |
| 1898 | offset = rot->getDstOffset(); |
| 1899 | } |
| 1900 | |
| 1901 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 1902 | ALOGE("%s: queueBuffer failed for display:%d ", |
| 1903 | __FUNCTION__, mDpy); |
| 1904 | return false; |
| 1905 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1906 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1907 | |
| 1908 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1909 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1910 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1911 | } |
| 1912 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1913 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1914 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1915 | void MDPCompSplit::adjustForSourceSplit(hwc_context_t *ctx, |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1916 | hwc_display_contents_1_t* list){ |
| 1917 | //if 4kx2k yuv layer is totally present in either in left half |
| 1918 | //or right half then try splitting the yuv layer to avoid decimation |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1919 | const int lSplit = getLeftSplit(ctx, mDpy); |
Dileep Kumar Reddi | 2268dd7 | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1920 | if(mCurrentFrame.fbZ >= 0) { |
| 1921 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 1922 | index++) { |
| 1923 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1924 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1925 | mdpNextZOrder++; |
| 1926 | } |
| 1927 | mdpNextZOrder++; |
| 1928 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1929 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1930 | if(is4kx2kYuvBuffer(hnd)) { |
| 1931 | hwc_rect_t dst = layer->displayFrame; |
| 1932 | if((dst.left > lSplit) || (dst.right < lSplit)) { |
| 1933 | mCurrentFrame.mdpCount += 1; |
| 1934 | } |
| 1935 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 1936 | mCurrentFrame.fbZ += 1; |
| 1937 | mdpNextZOrder++; |
| 1938 | } |
| 1939 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1940 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1941 | } |
| 1942 | } |
| 1943 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1944 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1945 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1946 | ePipeType type) { |
| 1947 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1948 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1949 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1950 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1951 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1952 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1953 | |
| 1954 | if (dst.left < lSplit) { |
| 1955 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1956 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1957 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1958 | } |
| 1959 | |
| 1960 | if(dst.right > lSplit) { |
| 1961 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1962 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1963 | return false; |
| 1964 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1965 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1966 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1967 | } |
| 1968 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1969 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1970 | hwc_display_contents_1_t* list) { |
| 1971 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1972 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1973 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1974 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1975 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1976 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1977 | hwc_rect_t dst = layer->displayFrame; |
| 1978 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1979 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1980 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1981 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1982 | continue; |
| 1983 | } |
| 1984 | } |
| 1985 | } |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1986 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1987 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1988 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1989 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1990 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1991 | ePipeType type = MDPCOMP_OV_ANY; |
| 1992 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1993 | if(isYuvBuffer(hnd)) { |
| 1994 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 1995 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1996 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1997 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1998 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1999 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2000 | |
| 2001 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2002 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 2003 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2004 | return false; |
| 2005 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2006 | } |
| 2007 | return true; |
| 2008 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2009 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2010 | int MDPCompSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 2011 | PipeLayerPair& PipeLayerPair) { |
| 2012 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 2013 | hwc_rect_t dst = layer->displayFrame; |
| 2014 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 2015 | MdpYUVPipeInfo& mdp_info = |
| 2016 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 2017 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2018 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 2019 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2020 | eDest lDest = mdp_info.lIndex; |
| 2021 | eDest rDest = mdp_info.rIndex; |
| 2022 | |
| 2023 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 2024 | lDest, rDest, &PipeLayerPair.rot); |
| 2025 | } |
| 2026 | else{ |
| 2027 | return configure(ctx, layer, PipeLayerPair); |
| 2028 | } |
| 2029 | } |
| 2030 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2031 | /* |
| 2032 | * Configures pipe(s) for MDP composition |
| 2033 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2034 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 2035 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2036 | MdpPipeInfoSplit& mdp_info = |
| 2037 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2038 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2039 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 2040 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2041 | eDest lDest = mdp_info.lIndex; |
| 2042 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2043 | |
| 2044 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 2045 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 2046 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2047 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2048 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2049 | } |
| 2050 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2051 | bool MDPCompSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2052 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 2053 | if(!isEnabled() or !mModeOn) { |
| 2054 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 2055 | return true; |
| 2056 | } |
| 2057 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 2058 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2059 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2060 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2061 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 2062 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2063 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2064 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 2065 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2066 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2067 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 2068 | if(!hnd) { |
| 2069 | ALOGE("%s handle null", __FUNCTION__); |
| 2070 | return false; |
| 2071 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2072 | |
| 2073 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 2074 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2075 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2076 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2077 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 2078 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2079 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 2080 | { |
| 2081 | MdpYUVPipeInfo& pipe_info = |
| 2082 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2083 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 2084 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2085 | ovutils::eDest indexR = pipe_info.rIndex; |
| 2086 | int fd = hnd->fd; |
| 2087 | uint32_t offset = hnd->offset; |
| 2088 | if(rot) { |
| 2089 | rot->queueBuffer(fd, offset); |
| 2090 | fd = rot->getDstMemId(); |
| 2091 | offset = rot->getDstOffset(); |
| 2092 | } |
| 2093 | if(indexL != ovutils::OV_INVALID) { |
| 2094 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2095 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2096 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2097 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2098 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2099 | __FUNCTION__, mDpy); |
| 2100 | return false; |
| 2101 | } |
| 2102 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2103 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2104 | if(indexR != ovutils::OV_INVALID) { |
| 2105 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2106 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2107 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2108 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2109 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2110 | __FUNCTION__, mDpy); |
| 2111 | return false; |
| 2112 | } |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2113 | } |
| 2114 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2115 | else{ |
| 2116 | MdpPipeInfoSplit& pipe_info = |
| 2117 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2118 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2119 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2120 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2121 | ovutils::eDest indexR = pipe_info.rIndex; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2122 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2123 | int fd = hnd->fd; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2124 | uint32_t offset = (uint32_t)hnd->offset; |
| 2125 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 2126 | if (!mDpy && (index != -1)) { |
| 2127 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
| 2128 | fd = hnd->fd; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 2129 | offset = 0; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2130 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2131 | |
Tatenda Chipeperekwa | 2f8cd2b | 2014-04-14 10:36:06 -0700 | [diff] [blame] | 2132 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 2133 | fd = ctx->mAD->getDstFd(ctx); |
| 2134 | offset = ctx->mAD->getDstOffset(ctx); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2135 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2136 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2137 | if(rot) { |
| 2138 | rot->queueBuffer(fd, offset); |
| 2139 | fd = rot->getDstMemId(); |
| 2140 | offset = rot->getDstOffset(); |
| 2141 | } |
| 2142 | |
| 2143 | //************* play left mixer ********** |
| 2144 | if(indexL != ovutils::OV_INVALID) { |
| 2145 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2146 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2147 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2148 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2149 | ALOGE("%s: queueBuffer failed for left mixer", |
| 2150 | __FUNCTION__); |
| 2151 | return false; |
| 2152 | } |
| 2153 | } |
| 2154 | |
| 2155 | //************* play right mixer ********** |
| 2156 | if(indexR != ovutils::OV_INVALID) { |
| 2157 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2158 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2159 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2160 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2161 | ALOGE("%s: queueBuffer failed for right mixer", |
| 2162 | __FUNCTION__); |
| 2163 | return false; |
| 2164 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2165 | } |
| 2166 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2167 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2168 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 2169 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2170 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2171 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2172 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2173 | }; //namespace |
| 2174 | |