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