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