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