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