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