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