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