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