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