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> |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 29 | #include "hwc_copybit.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 30 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 31 | using namespace overlay; |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 32 | using namespace qdutils; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 33 | using namespace overlay::utils; |
| 34 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 36 | namespace qhwc { |
| 37 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 38 | //==============MDPComp======================================================== |
| 39 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 40 | IdleInvalidator *MDPComp::idleInvalidator = NULL; |
| 41 | bool MDPComp::sIdleFallBack = false; |
Ramkumar Radhakrishnan | 92abb4f | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 42 | bool MDPComp::sHandleTimeout = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 43 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 44 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 45 | bool MDPComp::sEnableMixedMode = true; |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 46 | int MDPComp::sSimulationFlags = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 47 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 48 | bool MDPComp::sEnableYUVsplit = false; |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 49 | bool MDPComp::sSrcSplitEnabled = false; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 50 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
Saurabh Shah | 60e8bde | 2014-04-30 14:46:03 -0700 | [diff] [blame] | 51 | if(qdutils::MDPVersion::getInstance().isSrcSplit()) { |
| 52 | sSrcSplitEnabled = true; |
| 53 | return new MDPCompSrcSplit(dpy); |
| 54 | } else if(isDisplaySplit(ctx, dpy)) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 55 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 56 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 57 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 58 | } |
| 59 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 60 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 61 | |
Jeykumar Sankaran | 6850ac6 | 2014-05-27 10:07:26 -0700 | [diff] [blame] | 62 | void MDPComp::dump(android::String8& buf, hwc_context_t *ctx) |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 63 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 64 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 65 | return; |
| 66 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 67 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 68 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 69 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 70 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " |
| 71 | "fbCount:%2d \n", mCurrentFrame.layerCount, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 72 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 73 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 74 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 75 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
Jeykumar Sankaran | 6850ac6 | 2014-05-27 10:07:26 -0700 | [diff] [blame] | 76 | if(isDisplaySplit(ctx, mDpy)) { |
| 77 | dumpsys_log(buf, "Programmed ROI's: Left: [%d, %d, %d, %d] " |
| 78 | "Right: [%d, %d, %d, %d] \n", |
| 79 | ctx->listStats[mDpy].lRoi.left, ctx->listStats[mDpy].lRoi.top, |
| 80 | ctx->listStats[mDpy].lRoi.right, |
| 81 | ctx->listStats[mDpy].lRoi.bottom, |
| 82 | ctx->listStats[mDpy].rRoi.left,ctx->listStats[mDpy].rRoi.top, |
| 83 | ctx->listStats[mDpy].rRoi.right, |
| 84 | ctx->listStats[mDpy].rRoi.bottom); |
| 85 | } else { |
| 86 | dumpsys_log(buf, "Programmed ROI: [%d, %d, %d, %d] \n", |
| 87 | ctx->listStats[mDpy].lRoi.left,ctx->listStats[mDpy].lRoi.top, |
| 88 | ctx->listStats[mDpy].lRoi.right, |
| 89 | ctx->listStats[mDpy].lRoi.bottom); |
| 90 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 91 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 92 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 93 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 94 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 95 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 96 | index, |
| 97 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 98 | mCurrentFrame.layerToMDP[index], |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 99 | (mCurrentFrame.isFBComposed[index] ? |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 100 | (mCurrentFrame.drop[index] ? "DROP" : |
| 101 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 102 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 103 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 104 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | bool MDPComp::init(hwc_context_t *ctx) { |
| 108 | |
| 109 | if(!ctx) { |
| 110 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 111 | return false; |
| 112 | } |
| 113 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 114 | char property[PROPERTY_VALUE_MAX]; |
| 115 | |
| 116 | sEnabled = false; |
| 117 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 118 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 119 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 120 | sEnabled = true; |
| 121 | } |
| 122 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 123 | sEnableMixedMode = true; |
| 124 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 125 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 126 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 127 | sEnableMixedMode = false; |
| 128 | } |
| 129 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 130 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 131 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 132 | int val = atoi(property); |
| 133 | if(val >= 0) |
| 134 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 135 | } |
| 136 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 137 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 138 | // Idle invalidation is not necessary on command mode panels |
| 139 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 140 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 141 | if(atoi(property) != 0) |
| 142 | idle_timeout = atoi(property); |
| 143 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 144 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 145 | //create Idle Invalidator only when not disabled through property |
| 146 | if(idle_timeout != -1) |
| 147 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 148 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 149 | if(idleInvalidator == NULL) { |
| 150 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 151 | __FUNCTION__); |
| 152 | } else { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 153 | idleInvalidator->init(timeout_handler, ctx, |
| 154 | (unsigned int)idle_timeout); |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 155 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 156 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 157 | |
Saurabh Shah | 7c72764 | 2014-06-02 15:47:14 -0700 | [diff] [blame] | 158 | if(!qdutils::MDPVersion::getInstance().isSrcSplit() && |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 159 | !qdutils::MDPVersion::getInstance().isRotDownscaleEnabled() && |
Saurabh Shah | 7c72764 | 2014-06-02 15:47:14 -0700 | [diff] [blame] | 160 | property_get("persist.mdpcomp.4k2kSplit", property, "0") > 0 && |
| 161 | (!strncmp(property, "1", PROPERTY_VALUE_MAX) || |
| 162 | !strncasecmp(property,"true", PROPERTY_VALUE_MAX))) { |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 163 | sEnableYUVsplit = true; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 164 | } |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 165 | |
| 166 | if ((property_get("persist.hwc.ptor.enable", property, NULL) > 0) && |
| 167 | ((!strncasecmp(property, "true", PROPERTY_VALUE_MAX )) || |
| 168 | (!strncmp(property, "1", PROPERTY_VALUE_MAX )))) { |
| 169 | ctx->mCopyBit[HWC_DISPLAY_PRIMARY] = new CopyBit(ctx, |
| 170 | HWC_DISPLAY_PRIMARY); |
| 171 | } |
| 172 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 173 | return true; |
| 174 | } |
| 175 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 176 | void MDPComp::reset(hwc_context_t *ctx) { |
| 177 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 178 | mCurrentFrame.reset(numLayers); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 179 | ctx->mOverlay->clear(mDpy); |
| 180 | ctx->mLayerRotMap[mDpy]->clear(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 183 | void MDPComp::reset() { |
| 184 | sHandleTimeout = false; |
| 185 | mModeOn = false; |
| 186 | } |
| 187 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 188 | void MDPComp::timeout_handler(void *udata) { |
| 189 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
| 190 | |
| 191 | if(!ctx) { |
| 192 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 193 | return; |
| 194 | } |
Ramkumar Radhakrishnan | 92abb4f | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 195 | Locker::Autolock _l(ctx->mDrawLock); |
| 196 | // Handle timeout event only if the previous composition is MDP or MIXED. |
| 197 | if(!sHandleTimeout) { |
| 198 | ALOGD_IF(isDebug(), "%s:Do not handle this timeout", __FUNCTION__); |
| 199 | return; |
| 200 | } |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 201 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 202 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 203 | return; |
| 204 | } |
| 205 | sIdleFallBack = true; |
| 206 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 207 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 210 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 211 | hwc_display_contents_1_t* list) { |
| 212 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 213 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 214 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 215 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 216 | if(!mCurrentFrame.isFBComposed[index]) { |
| 217 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 218 | layer->compositionType = HWC_OVERLAY; |
| 219 | layer->hints |= HWC_HINT_CLEAR_FB; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 220 | } else { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 221 | /* Drop the layer when its already present in FB OR when it lies |
| 222 | * outside frame's ROI */ |
| 223 | if(!mCurrentFrame.needsRedraw || mCurrentFrame.drop[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 224 | layer->compositionType = HWC_OVERLAY; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 225 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 226 | } |
| 227 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 228 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 229 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 230 | void MDPComp::setRedraw(hwc_context_t *ctx, |
| 231 | hwc_display_contents_1_t* list) { |
| 232 | mCurrentFrame.needsRedraw = false; |
| 233 | if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || |
| 234 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 235 | isSkipPresent(ctx, mDpy)) { |
| 236 | mCurrentFrame.needsRedraw = true; |
| 237 | } |
| 238 | } |
| 239 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 240 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 241 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 242 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 243 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 244 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
| 245 | for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 246 | if(mdpToLayer[i].pipeInfo) { |
| 247 | delete mdpToLayer[i].pipeInfo; |
| 248 | mdpToLayer[i].pipeInfo = NULL; |
| 249 | //We dont own the rotator |
| 250 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 251 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 252 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 253 | |
| 254 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 255 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 256 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 257 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 258 | layerCount = numLayers; |
| 259 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 260 | mdpCount = 0; |
Saurabh Shah | 2f3895f | 2013-05-02 10:13:31 -0700 | [diff] [blame] | 261 | needsRedraw = true; |
Saurabh Shah | d53bc5f | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 262 | fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 263 | } |
| 264 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 265 | void MDPComp::FrameInfo::map() { |
| 266 | // populate layer and MDP maps |
| 267 | int mdpIdx = 0; |
| 268 | for(int idx = 0; idx < layerCount; idx++) { |
| 269 | if(!isFBComposed[idx]) { |
| 270 | mdpToLayer[mdpIdx].listIndex = idx; |
| 271 | layerToMDP[idx] = mdpIdx++; |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 276 | MDPComp::LayerCache::LayerCache() { |
| 277 | reset(); |
| 278 | } |
| 279 | |
| 280 | void MDPComp::LayerCache::reset() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 281 | memset(&hnd, 0, sizeof(hnd)); |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 282 | memset(&isFBComposed, true, sizeof(isFBComposed)); |
| 283 | memset(&drop, false, sizeof(drop)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 284 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 288 | const int numAppLayers = (int)list->numHwLayers - 1; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 289 | for(int i = 0; i < numAppLayers; i++) { |
| 290 | hnd[i] = list->hwLayers[i].handle; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 295 | layerCount = curFrame.layerCount; |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 296 | memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed)); |
| 297 | memcpy(&drop, &curFrame.drop, sizeof(drop)); |
| 298 | } |
| 299 | |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 300 | bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame, |
| 301 | hwc_display_contents_1_t* list) { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 302 | if(layerCount != curFrame.layerCount) |
| 303 | return false; |
| 304 | for(int i = 0; i < curFrame.layerCount; i++) { |
| 305 | if((curFrame.isFBComposed[i] != isFBComposed[i]) || |
| 306 | (curFrame.drop[i] != drop[i])) { |
| 307 | return false; |
| 308 | } |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 309 | if(curFrame.isFBComposed[i] && |
| 310 | (hnd[i] != list->hwLayers[i].handle)){ |
| 311 | return false; |
| 312 | } |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 313 | } |
| 314 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 317 | bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { |
| 318 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 319 | if((has90Transform(layer) and (not isRotationDoable(ctx, hnd))) || |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 320 | (not isValidDimension(ctx,layer)) |
| 321 | //More conditions here, SKIP, sRGB+Blend etc |
| 322 | ) { |
| 323 | return false; |
| 324 | } |
| 325 | return true; |
| 326 | } |
| 327 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 328 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 329 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 330 | |
| 331 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 332 | if (layer->flags & HWC_COLOR_FILL) { |
| 333 | // Color layer |
| 334 | return true; |
| 335 | } |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 336 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 337 | return false; |
| 338 | } |
| 339 | |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 340 | //XXX: Investigate doing this with pixel phase on MDSS |
Naseer Ahmed | e77f808 | 2013-10-10 13:42:48 -0400 | [diff] [blame] | 341 | if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 342 | return false; |
| 343 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 344 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 345 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | b6810df | 2014-06-17 16:00:22 -0700 | [diff] [blame] | 346 | bool rotated90 = (bool)(layer->transform & HAL_TRANSFORM_ROT_90); |
Saurabh Shah | e28a402 | 2014-06-13 11:41:13 -0700 | [diff] [blame] | 347 | int crop_w = rotated90 ? crop.bottom - crop.top : crop.right - crop.left; |
| 348 | int crop_h = rotated90 ? crop.right - crop.left : crop.bottom - crop.top; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 349 | int dst_w = dst.right - dst.left; |
| 350 | int dst_h = dst.bottom - dst.top; |
Jeykumar Sankaran | 6cd8e7e | 2014-01-13 16:01:05 -0800 | [diff] [blame] | 351 | float w_scale = ((float)crop_w / (float)dst_w); |
| 352 | float h_scale = ((float)crop_h / (float)dst_h); |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 353 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 354 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 355 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 356 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 357 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 358 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 359 | * Fallback to GPU if height is less than 2. |
| 360 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 361 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 362 | return false; |
| 363 | |
Jeykumar Sankaran | 6cd8e7e | 2014-01-13 16:01:05 -0800 | [diff] [blame] | 364 | if((w_scale > 1.0f) || (h_scale > 1.0f)) { |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 365 | const uint32_t maxMDPDownscale = mdpHw.getMaxMDPDownscale(); |
Jeykumar Sankaran | 6cd8e7e | 2014-01-13 16:01:05 -0800 | [diff] [blame] | 366 | const float w_dscale = w_scale; |
| 367 | const float h_dscale = h_scale; |
| 368 | |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 369 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 370 | |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 371 | if(!mdpHw.supportsDecimation()) { |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 372 | /* On targets that doesnt support Decimation (eg.,8x26) |
| 373 | * maximum downscale support is overlay pipe downscale. |
| 374 | */ |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 375 | if(crop_w > mdpHw.getMaxMixerWidth() || |
| 376 | w_dscale > maxMDPDownscale || |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 377 | h_dscale > maxMDPDownscale) |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 378 | return false; |
| 379 | } else { |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 380 | // Decimation on macrotile format layers is not supported. |
| 381 | if(isTileRendered(hnd)) { |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 382 | /* Bail out if |
| 383 | * 1. Src crop > Mixer limit on nonsplit MDPComp |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 384 | * 2. exceeds maximum downscale limit |
| 385 | */ |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 386 | if(((crop_w > mdpHw.getMaxMixerWidth()) && |
| 387 | !sSrcSplitEnabled) || |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 388 | w_dscale > maxMDPDownscale || |
| 389 | h_dscale > maxMDPDownscale) { |
| 390 | return false; |
| 391 | } |
| 392 | } else if(w_dscale > 64 || h_dscale > 64) |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 393 | return false; |
| 394 | } |
| 395 | } else { //A-family |
Manoj Kumar AVM | 8cbbf7c | 2014-03-11 01:15:31 -0700 | [diff] [blame] | 396 | if(w_dscale > maxMDPDownscale || h_dscale > maxMDPDownscale) |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 397 | return false; |
| 398 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Jeykumar Sankaran | 6cd8e7e | 2014-01-13 16:01:05 -0800 | [diff] [blame] | 401 | if((w_scale < 1.0f) || (h_scale < 1.0f)) { |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 402 | const uint32_t upscale = mdpHw.getMaxMDPUpscale(); |
Jeykumar Sankaran | 6cd8e7e | 2014-01-13 16:01:05 -0800 | [diff] [blame] | 403 | const float w_uscale = 1.0f / w_scale; |
| 404 | const float h_uscale = 1.0f / h_scale; |
| 405 | |
| 406 | if(w_uscale > upscale || h_uscale > upscale) |
| 407 | return false; |
| 408 | } |
| 409 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 410 | return true; |
| 411 | } |
| 412 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 413 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 414 | bool ret = true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 415 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 416 | if(!isEnabled()) { |
| 417 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 418 | ret = false; |
Raj Kamal | 068f457 | 2014-04-14 16:14:06 +0530 | [diff] [blame] | 419 | } else if((qdutils::MDPVersion::getInstance().is8x26() || |
Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 420 | qdutils::MDPVersion::getInstance().is8x16() || |
| 421 | qdutils::MDPVersion::getInstance().is8x39()) && |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 422 | ctx->mVideoTransFlag && |
| 423 | isSecondaryConnected(ctx)) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 424 | //1 Padding round to shift pipes across mixers |
| 425 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 426 | __FUNCTION__); |
| 427 | ret = false; |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 428 | } else if(isSecondaryConfiguring(ctx)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 429 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 430 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 431 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 432 | } else if(ctx->isPaddingRound) { |
Raj Kamal | 9ed3d6b | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 433 | ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d", |
| 434 | __FUNCTION__,mDpy); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 435 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 436 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 437 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 438 | } |
| 439 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 440 | void MDPCompNonSplit::trimAgainstROI(hwc_context_t *ctx, hwc_rect_t& fbRect) { |
| 441 | hwc_rect_t roi = ctx->listStats[mDpy].lRoi; |
| 442 | fbRect = getIntersection(fbRect, roi); |
| 443 | } |
| 444 | |
| 445 | /* 1) Identify layers that are not visible or lying outside the updating ROI and |
| 446 | * drop them from composition. |
| 447 | * 2) If we have a scaling layer which needs cropping against generated |
| 448 | * ROI, reset ROI to full resolution. */ |
| 449 | bool MDPCompNonSplit::validateAndApplyROI(hwc_context_t *ctx, |
| 450 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 451 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 452 | hwc_rect_t visibleRect = ctx->listStats[mDpy].lRoi; |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 453 | |
| 454 | for(int i = numAppLayers - 1; i >= 0; i--){ |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 455 | if(!isValidRect(visibleRect)) { |
| 456 | mCurrentFrame.drop[i] = true; |
| 457 | mCurrentFrame.dropCount++; |
Jeykumar Sankaran | 0b96145 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 458 | continue; |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 459 | } |
| 460 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 461 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 462 | hwc_rect_t dstRect = layer->displayFrame; |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 463 | hwc_rect_t res = getIntersection(visibleRect, dstRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 464 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 465 | if(!isValidRect(res)) { |
| 466 | mCurrentFrame.drop[i] = true; |
| 467 | mCurrentFrame.dropCount++; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 468 | } else { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 469 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 470 | * cropping */ |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 471 | if(!isSameRect(res, dstRect) && needsScaling (layer)) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 472 | ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 473 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 474 | mCurrentFrame.dropCount = 0; |
| 475 | return false; |
| 476 | } |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 477 | |
Jeykumar Sankaran | 0b96145 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 478 | /* deduct any opaque region from visibleRect */ |
| 479 | if (layer->blending == HWC_BLENDING_NONE) |
| 480 | visibleRect = deductRect(visibleRect, res); |
| 481 | } |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 482 | } |
| 483 | return true; |
| 484 | } |
| 485 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 486 | /* Calculate ROI for the frame by accounting all the layer's dispalyFrame which |
| 487 | * are updating. If DirtyRegion is applicable, calculate it by accounting all |
| 488 | * the changing layer's dirtyRegion. */ |
| 489 | void MDPCompNonSplit::generateROI(hwc_context_t *ctx, |
| 490 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 491 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 492 | if(!canPartialUpdate(ctx, list)) |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 493 | return; |
| 494 | |
| 495 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 496 | hwc_rect fullFrame = (struct hwc_rect) {0, 0,(int)ctx->dpyAttr[mDpy].xres, |
| 497 | (int)ctx->dpyAttr[mDpy].yres}; |
| 498 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 499 | for(int index = 0; index < numAppLayers; index++ ) { |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 500 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 501 | if ((mCachedFrame.hnd[index] != layer->handle) || |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 502 | isYuvBuffer((private_handle_t *)layer->handle)) { |
Jeykumar Sankaran | 455678c | 2014-05-30 10:22:38 -0700 | [diff] [blame] | 503 | hwc_rect_t dst = layer->displayFrame; |
| 504 | hwc_rect_t updatingRect = dst; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 505 | |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 506 | #ifdef QCOM_BSP |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 507 | if(!needsScaling(layer) && !layer->transform) |
Jeykumar Sankaran | 455678c | 2014-05-30 10:22:38 -0700 | [diff] [blame] | 508 | { |
| 509 | hwc_rect_t src = integerizeSourceCrop(layer->sourceCropf); |
| 510 | int x_off = dst.left - src.left; |
| 511 | int y_off = dst.top - src.top; |
| 512 | updatingRect = moveRect(layer->dirtyRect, x_off, y_off); |
| 513 | } |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 514 | #endif |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 515 | |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 516 | roi = getUnion(roi, updatingRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 520 | /* No layer is updating. Still SF wants a refresh.*/ |
| 521 | if(!isValidRect(roi)) |
| 522 | return; |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 523 | |
| 524 | // Align ROI coordinates to panel restrictions |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 525 | roi = getSanitizeROI(roi, fullFrame); |
Jeykumar Sankaran | 7c85238 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 526 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 527 | ctx->listStats[mDpy].lRoi = roi; |
| 528 | if(!validateAndApplyROI(ctx, list)) |
| 529 | resetROI(ctx, mDpy); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 530 | |
| 531 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 532 | ctx->listStats[mDpy].lRoi.left, ctx->listStats[mDpy].lRoi.top, |
| 533 | ctx->listStats[mDpy].lRoi.right, ctx->listStats[mDpy].lRoi.bottom); |
| 534 | } |
| 535 | |
| 536 | void MDPCompSplit::trimAgainstROI(hwc_context_t *ctx, hwc_rect_t& fbRect) { |
| 537 | hwc_rect l_roi = ctx->listStats[mDpy].lRoi; |
| 538 | hwc_rect r_roi = ctx->listStats[mDpy].rRoi; |
| 539 | |
| 540 | hwc_rect_t l_fbRect = getIntersection(fbRect, l_roi); |
| 541 | hwc_rect_t r_fbRect = getIntersection(fbRect, r_roi); |
| 542 | fbRect = getUnion(l_fbRect, r_fbRect); |
| 543 | } |
| 544 | /* 1) Identify layers that are not visible or lying outside BOTH the updating |
| 545 | * ROI's and drop them from composition. If a layer is spanning across both |
| 546 | * the halves of the screen but needed by only ROI, the non-contributing |
| 547 | * half will not be programmed for MDP. |
| 548 | * 2) If we have a scaling layer which needs cropping against generated |
| 549 | * ROI, reset ROI to full resolution. */ |
| 550 | bool MDPCompSplit::validateAndApplyROI(hwc_context_t *ctx, |
| 551 | hwc_display_contents_1_t* list) { |
| 552 | |
| 553 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 554 | |
| 555 | hwc_rect_t visibleRectL = ctx->listStats[mDpy].lRoi; |
| 556 | hwc_rect_t visibleRectR = ctx->listStats[mDpy].rRoi; |
| 557 | |
| 558 | for(int i = numAppLayers - 1; i >= 0; i--){ |
| 559 | if(!isValidRect(visibleRectL) && !isValidRect(visibleRectR)) |
| 560 | { |
| 561 | mCurrentFrame.drop[i] = true; |
| 562 | mCurrentFrame.dropCount++; |
| 563 | continue; |
| 564 | } |
| 565 | |
| 566 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 567 | hwc_rect_t dstRect = layer->displayFrame; |
| 568 | |
| 569 | hwc_rect_t l_res = getIntersection(visibleRectL, dstRect); |
| 570 | hwc_rect_t r_res = getIntersection(visibleRectR, dstRect); |
| 571 | hwc_rect_t res = getUnion(l_res, r_res); |
| 572 | |
| 573 | if(!isValidRect(l_res) && !isValidRect(r_res)) { |
| 574 | mCurrentFrame.drop[i] = true; |
| 575 | mCurrentFrame.dropCount++; |
| 576 | } else { |
| 577 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 578 | * cropping */ |
| 579 | if(!isSameRect(res, dstRect) && needsScaling (layer)) { |
| 580 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 581 | mCurrentFrame.dropCount = 0; |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | if (layer->blending == HWC_BLENDING_NONE) { |
| 586 | visibleRectL = deductRect(visibleRectL, l_res); |
| 587 | visibleRectR = deductRect(visibleRectR, r_res); |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | return true; |
| 592 | } |
| 593 | /* Calculate ROI for the frame by accounting all the layer's dispalyFrame which |
| 594 | * are updating. If DirtyRegion is applicable, calculate it by accounting all |
| 595 | * the changing layer's dirtyRegion. */ |
| 596 | void MDPCompSplit::generateROI(hwc_context_t *ctx, |
| 597 | hwc_display_contents_1_t* list) { |
| 598 | if(!canPartialUpdate(ctx, list)) |
| 599 | return; |
| 600 | |
| 601 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 602 | int lSplit = getLeftSplit(ctx, mDpy); |
| 603 | |
| 604 | int hw_h = (int)ctx->dpyAttr[mDpy].yres; |
| 605 | int hw_w = (int)ctx->dpyAttr[mDpy].xres; |
| 606 | |
| 607 | struct hwc_rect l_frame = (struct hwc_rect){0, 0, lSplit, hw_h}; |
| 608 | struct hwc_rect r_frame = (struct hwc_rect){lSplit, 0, hw_w, hw_h}; |
| 609 | |
| 610 | struct hwc_rect l_roi = (struct hwc_rect){0, 0, 0, 0}; |
| 611 | struct hwc_rect r_roi = (struct hwc_rect){0, 0, 0, 0}; |
| 612 | |
| 613 | for(int index = 0; index < numAppLayers; index++ ) { |
| 614 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 615 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 616 | if ((mCachedFrame.hnd[index] != layer->handle) || |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 617 | isYuvBuffer(hnd)) { |
Jeykumar Sankaran | 71e597c | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 618 | hwc_rect_t dst = layer->displayFrame; |
| 619 | hwc_rect_t updatingRect = dst; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 620 | |
| 621 | #ifdef QCOM_BSP |
| 622 | if(!needsScaling(layer) && !layer->transform) |
Jeykumar Sankaran | 71e597c | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 623 | { |
| 624 | hwc_rect_t src = integerizeSourceCrop(layer->sourceCropf); |
| 625 | int x_off = dst.left - src.left; |
| 626 | int y_off = dst.top - src.top; |
| 627 | updatingRect = moveRect(layer->dirtyRect, x_off, y_off); |
| 628 | } |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 629 | #endif |
| 630 | |
| 631 | hwc_rect_t l_dst = getIntersection(l_frame, updatingRect); |
| 632 | if(isValidRect(l_dst)) |
| 633 | l_roi = getUnion(l_roi, l_dst); |
| 634 | |
| 635 | hwc_rect_t r_dst = getIntersection(r_frame, updatingRect); |
| 636 | if(isValidRect(r_dst)) |
| 637 | r_roi = getUnion(r_roi, r_dst); |
| 638 | } |
| 639 | } |
| 640 | |
Jeykumar Sankaran | a40a934 | 2014-04-25 09:37:10 -0700 | [diff] [blame] | 641 | /* For panels that cannot accept commands in both the interfaces, we cannot |
| 642 | * send two ROI's (for each half). We merge them into single ROI and split |
| 643 | * them across lSplit for MDP mixer use. The ROI's will be merged again |
| 644 | * finally before udpating the panel in the driver. */ |
| 645 | if(qdutils::MDPVersion::getInstance().needsROIMerge()) { |
| 646 | hwc_rect_t temp_roi = getUnion(l_roi, r_roi); |
| 647 | l_roi = getIntersection(temp_roi, l_frame); |
| 648 | r_roi = getIntersection(temp_roi, r_frame); |
| 649 | } |
| 650 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 651 | /* No layer is updating. Still SF wants a refresh. */ |
| 652 | if(!isValidRect(l_roi) && !isValidRect(r_roi)) |
| 653 | return; |
| 654 | |
| 655 | l_roi = getSanitizeROI(l_roi, l_frame); |
| 656 | r_roi = getSanitizeROI(r_roi, r_frame); |
| 657 | |
| 658 | ctx->listStats[mDpy].lRoi = l_roi; |
| 659 | ctx->listStats[mDpy].rRoi = r_roi; |
| 660 | |
| 661 | if(!validateAndApplyROI(ctx, list)) |
| 662 | resetROI(ctx, mDpy); |
| 663 | |
| 664 | ALOGD_IF(isDebug(),"%s: generated L_ROI: [%d, %d, %d, %d]" |
| 665 | "R_ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 666 | ctx->listStats[mDpy].lRoi.left, ctx->listStats[mDpy].lRoi.top, |
| 667 | ctx->listStats[mDpy].lRoi.right, ctx->listStats[mDpy].lRoi.bottom, |
| 668 | ctx->listStats[mDpy].rRoi.left, ctx->listStats[mDpy].rRoi.top, |
| 669 | ctx->listStats[mDpy].rRoi.right, ctx->listStats[mDpy].rRoi.bottom); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 670 | } |
| 671 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 672 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 673 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 674 | bool MDPComp::tryFullFrame(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 675 | hwc_display_contents_1_t* list){ |
| 676 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 677 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Arun Kumar K.R | 2e2871c | 2014-01-10 12:47:06 -0800 | [diff] [blame] | 678 | int priDispW = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 679 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 680 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 681 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 682 | return false; |
| 683 | } |
| 684 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 685 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 686 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 687 | __FUNCTION__, |
| 688 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 689 | return false; |
| 690 | } |
| 691 | |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 692 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
| 693 | if(mDpy > HWC_DISPLAY_PRIMARY && |
| 694 | (priDispW > mdpHw.getMaxMixerWidth()) && |
| 695 | (ctx->dpyAttr[mDpy].xres < mdpHw.getMaxMixerWidth())) { |
Arun Kumar K.R | 2e2871c | 2014-01-10 12:47:06 -0800 | [diff] [blame] | 696 | // Disable MDP comp on Secondary when the primary is highres panel and |
| 697 | // the secondary is a normal 1080p, because, MDP comp on secondary under |
| 698 | // in such usecase, decimation gets used for downscale and there will be |
| 699 | // a quality mismatch when there will be a fallback to GPU comp |
| 700 | ALOGD_IF(isDebug(), "%s: Disable MDP Compositon for Secondary Disp", |
| 701 | __FUNCTION__); |
| 702 | return false; |
| 703 | } |
| 704 | |
Ramkumar Radhakrishnan | 4af1ef0 | 2013-12-12 11:53:08 -0800 | [diff] [blame] | 705 | // check for action safe flag and downscale mode which requires scaling. |
| 706 | if(ctx->dpyAttr[mDpy].mActionSafePresent |
| 707 | || ctx->dpyAttr[mDpy].mDownScaleMode) { |
| 708 | ALOGD_IF(isDebug(), "%s: Scaling needed for this frame",__FUNCTION__); |
| 709 | return false; |
| 710 | } |
| 711 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 712 | for(int i = 0; i < numAppLayers; ++i) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 713 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 714 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 715 | |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 716 | if(has90Transform(layer) && isRotationDoable(ctx, hnd)) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 717 | if(!canUseRotator(ctx, mDpy)) { |
| 718 | ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", |
| 719 | __FUNCTION__, mDpy); |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 720 | return false; |
| 721 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 722 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 723 | |
| 724 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 725 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
Sushil Chauhan | fda00fc | 2014-03-20 11:08:41 -0700 | [diff] [blame] | 726 | int transform = (layer->flags & HWC_COLOR_FILL) ? 0 : layer->transform; |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 727 | if( mdpHw.is8x26() && (ctx->dpyAttr[mDpy].xres > 1024) && |
| 728 | (transform & HWC_TRANSFORM_FLIP_H) && (!isYuvBuffer(hnd))) |
| 729 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 730 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 731 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 732 | if(ctx->mAD->isDoable()) { |
| 733 | return false; |
| 734 | } |
| 735 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 736 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 737 | bool ret = false; |
| 738 | if(fullMDPComp(ctx, list)) { |
| 739 | ret = true; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 740 | } else if(fullMDPCompWithPTOR(ctx, list)) { |
| 741 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 742 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 743 | ret = true; |
| 744 | } |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 745 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 746 | return ret; |
| 747 | } |
| 748 | |
| 749 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 750 | |
| 751 | if(sSimulationFlags & MDPCOMP_AVOID_FULL_MDP) |
| 752 | return false; |
| 753 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 754 | //Will benefit presentation / secondary-only layer. |
| 755 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 756 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 757 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 758 | return false; |
| 759 | } |
| 760 | |
| 761 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 762 | for(int i = 0; i < numAppLayers; i++) { |
| 763 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 880da83 | 2014-04-18 10:22:35 -0700 | [diff] [blame] | 764 | if(not mCurrentFrame.drop[i] and |
| 765 | not isSupportedForMDPComp(ctx, layer)) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 766 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 767 | return false; |
| 768 | } |
| 769 | } |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 770 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 771 | mCurrentFrame.fbCount = 0; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 772 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 773 | sizeof(mCurrentFrame.isFBComposed)); |
| 774 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 775 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 776 | |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 777 | if(sEnableYUVsplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 778 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 779 | } |
| 780 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 781 | if(!postHeuristicsHandling(ctx, list)) { |
| 782 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 783 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 784 | return false; |
| 785 | } |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 786 | ALOGD_IF(sSimulationFlags,"%s: FULL_MDP_COMP SUCCEEDED", |
| 787 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 788 | return true; |
| 789 | } |
| 790 | |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 791 | /* Full MDP Composition with Peripheral Tiny Overlap Removal. |
| 792 | * MDP bandwidth limitations can be avoided, if the overlap region |
| 793 | * covered by the smallest layer at a higher z-order, gets composed |
| 794 | * by Copybit on a render buffer, which can be queued to MDP. |
| 795 | */ |
| 796 | bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, |
| 797 | hwc_display_contents_1_t* list) { |
| 798 | |
| 799 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 800 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 801 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
| 802 | |
| 803 | // Hard checks where we cannot use this mode |
Sushil Chauhan | bfc2de0 | 2014-07-24 11:52:58 -0700 | [diff] [blame] | 804 | if (mDpy || !ctx->mCopyBit[mDpy]) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 805 | ALOGD_IF(isDebug(), "%s: Feature not supported!", __FUNCTION__); |
| 806 | return false; |
| 807 | } |
| 808 | |
| 809 | // Frame level checks |
| 810 | if ((numAppLayers > stagesForMDP) || isSkipPresent(ctx, mDpy) || |
| 811 | isYuvPresent(ctx, mDpy) || mCurrentFrame.dropCount || |
| 812 | isSecurePresent(ctx, mDpy)) { |
| 813 | ALOGD_IF(isDebug(), "%s: Frame not supported!", __FUNCTION__); |
| 814 | return false; |
| 815 | } |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 816 | // MDP comp checks |
| 817 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 818 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 819 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 820 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 821 | return false; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 822 | } |
| 823 | } |
| 824 | |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 825 | /* We cannot use this composition mode, if: |
| 826 | 1. A below layer needs scaling. |
| 827 | 2. Overlap is not peripheral to display. |
| 828 | 3. Overlap or a below layer has 90 degree transform. |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 829 | 4. Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 830 | */ |
| 831 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 832 | int minLayerIndex[MAX_PTOR_LAYERS] = { -1, -1}; |
| 833 | hwc_rect_t overlapRect[MAX_PTOR_LAYERS]; |
| 834 | memset(overlapRect, 0, sizeof(overlapRect)); |
| 835 | int layerPixelCount, minPixelCount = 0; |
| 836 | int numPTORLayersFound = 0; |
| 837 | for (int i = numAppLayers-1; (i >= 0 && |
| 838 | numPTORLayersFound < MAX_PTOR_LAYERS); i--) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 839 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 840 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 841 | hwc_rect_t dispFrame = layer->displayFrame; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 842 | layerPixelCount = (crop.right - crop.left) * (crop.bottom - crop.top); |
| 843 | // PTOR layer should be peripheral and cannot have transform |
| 844 | if (!isPeripheral(dispFrame, ctx->mViewFrame[mDpy]) || |
| 845 | has90Transform(layer)) { |
| 846 | continue; |
| 847 | } |
| 848 | if((3 * (layerPixelCount + minPixelCount)) > |
| 849 | ((int)ctx->dpyAttr[mDpy].xres * (int)ctx->dpyAttr[mDpy].yres)) { |
| 850 | // Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
| 851 | continue; |
| 852 | } |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 853 | bool found = false; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 854 | for (int j = i-1; j >= 0; j--) { |
| 855 | // Check if the layers below this layer qualifies for PTOR comp |
| 856 | hwc_layer_1_t* layer = &list->hwLayers[j]; |
| 857 | hwc_rect_t disFrame = layer->displayFrame; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 858 | // Layer below PTOR is intersecting and has 90 degree transform or |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 859 | // needs scaling cannot be supported. |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 860 | if (isValidRect(getIntersection(dispFrame, disFrame))) { |
| 861 | if (has90Transform(layer) || needsScaling(layer)) { |
| 862 | found = false; |
| 863 | break; |
| 864 | } |
| 865 | found = true; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 866 | } |
| 867 | } |
| 868 | // Store the minLayer Index |
| 869 | if(found) { |
| 870 | minLayerIndex[numPTORLayersFound] = i; |
| 871 | overlapRect[numPTORLayersFound] = list->hwLayers[i].displayFrame; |
| 872 | minPixelCount += layerPixelCount; |
| 873 | numPTORLayersFound++; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 874 | } |
| 875 | } |
| 876 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 877 | if(isValidRect(getIntersection(overlapRect[0], overlapRect[1]))) { |
| 878 | ALOGD_IF(isDebug(), "%s: Ignore Rect2 its intersects with Rect1", |
| 879 | __FUNCTION__); |
| 880 | // reset second minLayerIndex[1]; |
| 881 | minLayerIndex[1] = -1; |
| 882 | numPTORLayersFound--; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 885 | // No overlap layers |
| 886 | if (!numPTORLayersFound) |
| 887 | return false; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 888 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 889 | ctx->mPtorInfo.count = numPTORLayersFound; |
| 890 | for(int i = 0; i < MAX_PTOR_LAYERS; i++) { |
| 891 | ctx->mPtorInfo.layerIndex[i] = minLayerIndex[i]; |
| 892 | } |
| 893 | |
| 894 | if (!ctx->mCopyBit[mDpy]->prepareOverlap(ctx, list)) { |
| 895 | // reset PTOR |
| 896 | ctx->mPtorInfo.count = 0; |
| 897 | return false; |
| 898 | } |
| 899 | // Store the displayFrame and the sourceCrops of the layers |
| 900 | hwc_rect_t displayFrame[numAppLayers]; |
| 901 | hwc_rect_t sourceCrop[numAppLayers]; |
| 902 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 903 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 904 | displayFrame[i] = layer->displayFrame; |
| 905 | sourceCrop[i] = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 906 | } |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 907 | |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 908 | private_handle_t *renderBuf = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
| 909 | Whf layerWhf[numPTORLayersFound]; // To store w,h,f of PTOR layers |
| 910 | |
Xu Yang | cda012c | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 911 | // Store the blending mode, planeAlpha, and transform of PTOR layers |
| 912 | int32_t blending[numPTORLayersFound]; |
| 913 | uint8_t planeAlpha[numPTORLayersFound]; |
| 914 | uint32_t transform[numPTORLayersFound]; |
| 915 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 916 | for(int j = 0; j < numPTORLayersFound; j++) { |
| 917 | int index = ctx->mPtorInfo.layerIndex[j]; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 918 | |
| 919 | // Update src crop of PTOR layer |
| 920 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 921 | layer->sourceCropf.left = (float)ctx->mPtorInfo.displayFrame[j].left; |
| 922 | layer->sourceCropf.top = (float)ctx->mPtorInfo.displayFrame[j].top; |
| 923 | layer->sourceCropf.right = (float)ctx->mPtorInfo.displayFrame[j].right; |
| 924 | layer->sourceCropf.bottom =(float)ctx->mPtorInfo.displayFrame[j].bottom; |
| 925 | |
| 926 | // Store & update w, h, format of PTOR layer |
| 927 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 928 | Whf whf(hnd->width, hnd->height, hnd->format, hnd->size); |
| 929 | layerWhf[j] = whf; |
| 930 | hnd->width = renderBuf->width; |
| 931 | hnd->height = renderBuf->height; |
| 932 | hnd->format = renderBuf->format; |
| 933 | |
Xu Yang | cda012c | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 934 | // Store & update blending mode, planeAlpha and transform of PTOR layer |
| 935 | blending[j] = layer->blending; |
| 936 | planeAlpha[j] = layer->planeAlpha; |
| 937 | transform[j] = layer->transform; |
| 938 | layer->blending = HWC_BLENDING_NONE; |
| 939 | layer->planeAlpha = 0xFF; |
| 940 | layer->transform = 0; |
| 941 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 942 | // Remove overlap from crop & displayFrame of below layers |
| 943 | for (int i = 0; i < index && index !=-1; i++) { |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 944 | layer = &list->hwLayers[i]; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 945 | if(!isValidRect(getIntersection(layer->displayFrame, |
| 946 | overlapRect[j]))) { |
| 947 | continue; |
| 948 | } |
| 949 | // Update layer attributes |
| 950 | hwc_rect_t srcCrop = integerizeSourceCrop(layer->sourceCropf); |
| 951 | hwc_rect_t destRect = deductRect(layer->displayFrame, |
| 952 | overlapRect[j]); |
| 953 | qhwc::calculate_crop_rects(srcCrop, layer->displayFrame, destRect, |
| 954 | layer->transform); |
| 955 | layer->sourceCropf.left = (float)srcCrop.left; |
| 956 | layer->sourceCropf.top = (float)srcCrop.top; |
| 957 | layer->sourceCropf.right = (float)srcCrop.right; |
| 958 | layer->sourceCropf.bottom = (float)srcCrop.bottom; |
| 959 | } |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | mCurrentFrame.mdpCount = numAppLayers; |
| 963 | mCurrentFrame.fbCount = 0; |
| 964 | mCurrentFrame.fbZ = -1; |
| 965 | |
| 966 | for (int j = 0; j < numAppLayers; j++) |
| 967 | mCurrentFrame.isFBComposed[j] = false; |
| 968 | |
| 969 | bool result = postHeuristicsHandling(ctx, list); |
| 970 | |
| 971 | // Restore layer attributes |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 972 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 973 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 974 | layer->displayFrame = displayFrame[i]; |
| 975 | layer->sourceCropf.left = (float)sourceCrop[i].left; |
| 976 | layer->sourceCropf.top = (float)sourceCrop[i].top; |
| 977 | layer->sourceCropf.right = (float)sourceCrop[i].right; |
| 978 | layer->sourceCropf.bottom = (float)sourceCrop[i].bottom; |
| 979 | } |
| 980 | |
Xu Yang | cda012c | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 981 | // Restore w,h,f, blending attributes, and transform of PTOR layers |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 982 | for (int i = 0; i < numPTORLayersFound; i++) { |
| 983 | int idx = ctx->mPtorInfo.layerIndex[i]; |
Xu Yang | cda012c | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 984 | hwc_layer_1_t* layer = &list->hwLayers[idx]; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 985 | private_handle_t *hnd = (private_handle_t *)list->hwLayers[idx].handle; |
| 986 | hnd->width = layerWhf[i].w; |
| 987 | hnd->height = layerWhf[i].h; |
| 988 | hnd->format = layerWhf[i].format; |
Xu Yang | cda012c | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 989 | layer->blending = blending[i]; |
| 990 | layer->planeAlpha = planeAlpha[i]; |
| 991 | layer->transform = transform[i]; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 992 | } |
| 993 | |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 994 | if (!result) { |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 995 | // reset PTOR |
| 996 | ctx->mPtorInfo.count = 0; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 997 | reset(ctx); |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 998 | } else { |
| 999 | ALOGD_IF(isDebug(), "%s: PTOR Indexes: %d and %d", __FUNCTION__, |
| 1000 | ctx->mPtorInfo.layerIndex[0], ctx->mPtorInfo.layerIndex[1]); |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1001 | } |
| 1002 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1003 | ALOGD_IF(isDebug(), "%s: Postheuristics %s!", __FUNCTION__, |
| 1004 | (result ? "successful" : "failed")); |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1005 | return result; |
| 1006 | } |
| 1007 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1008 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 1009 | { |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 1010 | if(!sEnableMixedMode) { |
| 1011 | //Mixed mode is disabled. No need to even try caching. |
| 1012 | return false; |
| 1013 | } |
| 1014 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1015 | bool ret = false; |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1016 | if(list->flags & HWC_GEOMETRY_CHANGED) { //Try load based first |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1017 | ret = loadBasedComp(ctx, list) or |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1018 | cacheBasedComp(ctx, list); |
| 1019 | } else { |
| 1020 | ret = cacheBasedComp(ctx, list) or |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1021 | loadBasedComp(ctx, list); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1024 | return ret; |
| 1025 | } |
| 1026 | |
| 1027 | bool MDPComp::cacheBasedComp(hwc_context_t *ctx, |
| 1028 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1029 | if(sSimulationFlags & MDPCOMP_AVOID_CACHE_MDP) |
| 1030 | return false; |
| 1031 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1032 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1033 | mCurrentFrame.reset(numAppLayers); |
| 1034 | updateLayerCache(ctx, list); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1035 | |
| 1036 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 1037 | for(int i = 0; i < numAppLayers; i++) { |
| 1038 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1039 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1040 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1041 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 1042 | __FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1043 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1044 | return false; |
| 1045 | } |
| 1046 | } |
| 1047 | } |
| 1048 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1049 | updateYUV(ctx, list, false /*secure only*/); |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1050 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1051 | if(!ret) { |
| 1052 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1053 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1054 | return false; |
| 1055 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1056 | |
| 1057 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1058 | |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1059 | if(sEnableYUVsplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1060 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1061 | } |
| 1062 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1063 | //Will benefit cases where a video has non-updating background. |
| 1064 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 1065 | (mdpCount > MAX_SEC_LAYERS)) { |
| 1066 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1067 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1068 | return false; |
| 1069 | } |
| 1070 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1071 | if(!postHeuristicsHandling(ctx, list)) { |
| 1072 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 1073 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1074 | return false; |
| 1075 | } |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1076 | ALOGD_IF(sSimulationFlags,"%s: CACHE_MDP_COMP SUCCEEDED", |
| 1077 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1078 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1079 | return true; |
| 1080 | } |
| 1081 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1082 | bool MDPComp::loadBasedComp(hwc_context_t *ctx, |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1083 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1084 | if(sSimulationFlags & MDPCOMP_AVOID_LOAD_MDP) |
| 1085 | return false; |
| 1086 | |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 1087 | if(not isLoadBasedCompDoable(ctx)) { |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1088 | return false; |
| 1089 | } |
| 1090 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1091 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1092 | const int numNonDroppedLayers = numAppLayers - mCurrentFrame.dropCount; |
| 1093 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 1094 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1095 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1096 | int mdpBatchSize = stagesForMDP - 1; //1 stage for FB |
| 1097 | int fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
| 1098 | int lastMDPSupportedIndex = numAppLayers; |
| 1099 | int dropCount = 0; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1100 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1101 | //Find the minimum MDP batch size |
| 1102 | for(int i = 0; i < numAppLayers;i++) { |
| 1103 | if(mCurrentFrame.drop[i]) { |
| 1104 | dropCount++; |
Jeykumar Sankaran | 846e279 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1105 | continue; |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1106 | } |
| 1107 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1108 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1109 | lastMDPSupportedIndex = i; |
| 1110 | mdpBatchSize = min(i - dropCount, stagesForMDP - 1); |
| 1111 | fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
Jeykumar Sankaran | 846e279 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1112 | break; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1113 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1114 | } |
| 1115 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1116 | ALOGD_IF(isDebug(), "%s:Before optimizing fbBatch, mdpbatch %d, fbbatch %d " |
| 1117 | "dropped %d", __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1118 | mCurrentFrame.dropCount); |
| 1119 | |
| 1120 | //Start at a point where the fb batch should at least have 2 layers, for |
| 1121 | //this mode to be justified. |
| 1122 | while(fbBatchSize < 2) { |
| 1123 | ++fbBatchSize; |
| 1124 | --mdpBatchSize; |
Jeykumar Sankaran | 846e279 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1125 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1126 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1127 | //If there are no layers for MDP, this mode doesnt make sense. |
| 1128 | if(mdpBatchSize < 1) { |
| 1129 | ALOGD_IF(isDebug(), "%s: No MDP layers after optimizing for fbBatch", |
| 1130 | __FUNCTION__); |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1131 | return false; |
| 1132 | } |
| 1133 | |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1134 | mCurrentFrame.reset(numAppLayers); |
| 1135 | |
| 1136 | //Try with successively smaller mdp batch sizes until we succeed or reach 1 |
| 1137 | while(mdpBatchSize > 0) { |
| 1138 | //Mark layers for MDP comp |
| 1139 | int mdpBatchLeft = mdpBatchSize; |
| 1140 | for(int i = 0; i < lastMDPSupportedIndex and mdpBatchLeft; i++) { |
| 1141 | if(mCurrentFrame.drop[i]) { |
| 1142 | continue; |
| 1143 | } |
| 1144 | mCurrentFrame.isFBComposed[i] = false; |
| 1145 | --mdpBatchLeft; |
| 1146 | } |
| 1147 | |
| 1148 | mCurrentFrame.fbZ = mdpBatchSize; |
| 1149 | mCurrentFrame.fbCount = fbBatchSize; |
| 1150 | mCurrentFrame.mdpCount = mdpBatchSize; |
| 1151 | |
| 1152 | ALOGD_IF(isDebug(), "%s:Trying with: mdpbatch %d fbbatch %d dropped %d", |
| 1153 | __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1154 | mCurrentFrame.dropCount); |
| 1155 | |
| 1156 | if(postHeuristicsHandling(ctx, list)) { |
| 1157 | ALOGD_IF(isDebug(), "%s: Postheuristics handling succeeded", |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1158 | __FUNCTION__); |
| 1159 | ALOGD_IF(sSimulationFlags,"%s: LOAD_MDP_COMP SUCCEEDED", |
| 1160 | __FUNCTION__); |
Saurabh Shah | be7bd32 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1161 | return true; |
| 1162 | } |
| 1163 | |
| 1164 | reset(ctx); |
| 1165 | --mdpBatchSize; |
| 1166 | ++fbBatchSize; |
| 1167 | } |
| 1168 | |
| 1169 | return false; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1170 | } |
| 1171 | |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 1172 | bool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx) { |
Prabhanjan Kandula | 3dbbd88 | 2013-12-11 14:43:46 +0530 | [diff] [blame] | 1173 | if(mDpy or isSecurePresent(ctx, mDpy) or |
| 1174 | isYuvPresent(ctx, mDpy)) { |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1175 | return false; |
| 1176 | } |
| 1177 | return true; |
| 1178 | } |
| 1179 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1180 | bool MDPComp::canPartialUpdate(hwc_context_t *ctx, |
| 1181 | hwc_display_contents_1_t* list){ |
| 1182 | if(!qdutils::MDPVersion::getInstance().isPartialUpdateEnabled() || |
| 1183 | isSkipPresent(ctx, mDpy) || (list->flags & HWC_GEOMETRY_CHANGED) || |
| 1184 | mDpy ) { |
| 1185 | return false; |
| 1186 | } |
Jeykumar Sankaran | 4dd10ab | 2014-07-02 12:23:09 -0700 | [diff] [blame] | 1187 | if(ctx->listStats[mDpy].secureUI) |
| 1188 | return false; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1189 | return true; |
| 1190 | } |
| 1191 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1192 | bool MDPComp::tryVideoOnly(hwc_context_t *ctx, |
| 1193 | hwc_display_contents_1_t* list) { |
| 1194 | const bool secureOnly = true; |
| 1195 | return videoOnlyComp(ctx, list, not secureOnly) or |
| 1196 | videoOnlyComp(ctx, list, secureOnly); |
| 1197 | } |
| 1198 | |
| 1199 | bool MDPComp::videoOnlyComp(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1200 | hwc_display_contents_1_t* list, bool secureOnly) { |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1201 | if(sSimulationFlags & MDPCOMP_AVOID_VIDEO_ONLY) |
| 1202 | return false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1203 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1204 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1205 | mCurrentFrame.reset(numAppLayers); |
Jeykumar Sankaran | eb3a5e2 | 2014-04-08 16:07:55 -0700 | [diff] [blame] | 1206 | mCurrentFrame.fbCount -= mCurrentFrame.dropCount; |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1207 | updateYUV(ctx, list, secureOnly); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1208 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1209 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1210 | if(!isYuvPresent(ctx, mDpy) or (mdpCount == 0)) { |
| 1211 | reset(ctx); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1212 | return false; |
| 1213 | } |
| 1214 | |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1215 | /* Bail out if we are processing only secured video layers |
| 1216 | * and we dont have any */ |
| 1217 | if(!isSecurePresent(ctx, mDpy) && secureOnly){ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1218 | reset(ctx); |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1219 | return false; |
| 1220 | } |
| 1221 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1222 | if(mCurrentFrame.fbCount) |
| 1223 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1224 | |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1225 | if(sEnableYUVsplit){ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1226 | adjustForSourceSplit(ctx, list); |
| 1227 | } |
| 1228 | |
| 1229 | if(!postHeuristicsHandling(ctx, list)) { |
| 1230 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 1231 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1232 | return false; |
| 1233 | } |
| 1234 | |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1235 | ALOGD_IF(sSimulationFlags,"%s: VIDEO_ONLY_COMP SUCCEEDED", |
| 1236 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1237 | return true; |
| 1238 | } |
| 1239 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1240 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 1241 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1242 | if(isSkipLayer(layer)) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 1243 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1244 | return false; |
| 1245 | } |
| 1246 | |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 1247 | if(has90Transform(layer) && !canUseRotator(ctx, mDpy)) { |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 1248 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 1249 | return false; |
| 1250 | } |
| 1251 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1252 | if(isSecuring(ctx, layer)) { |
| 1253 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 1254 | return false; |
| 1255 | } |
| 1256 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1257 | if(!isValidDimension(ctx, layer)) { |
| 1258 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 1259 | __FUNCTION__); |
| 1260 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1261 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1262 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 1263 | if(layer->planeAlpha < 0xFF) { |
| 1264 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 1265 | in video only mode", |
| 1266 | __FUNCTION__); |
| 1267 | return false; |
| 1268 | } |
| 1269 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1270 | return true; |
| 1271 | } |
| 1272 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1273 | /* starts at fromIndex and check for each layer to find |
| 1274 | * if it it has overlapping with any Updating layer above it in zorder |
| 1275 | * till the end of the batch. returns true if it finds any intersection */ |
| 1276 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 1277 | int fromIndex, int toIndex) { |
| 1278 | for(int i = fromIndex; i < toIndex; i++) { |
| 1279 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 1280 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 1281 | return false; |
| 1282 | } |
| 1283 | } |
| 1284 | } |
| 1285 | return true; |
| 1286 | } |
| 1287 | |
| 1288 | /* Checks if given layer at targetLayerIndex has any |
| 1289 | * intersection with all the updating layers in beween |
| 1290 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 1291 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 1292 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 1293 | for(int i = fromIndex; i <= toIndex; i++) { |
| 1294 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1295 | if(areLayersIntersecting(&list->hwLayers[i], |
| 1296 | &list->hwLayers[targetLayerIndex])) { |
| 1297 | return true; |
| 1298 | } |
| 1299 | } |
| 1300 | } |
| 1301 | return false; |
| 1302 | } |
| 1303 | |
| 1304 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 1305 | int& maxBatchStart, int& maxBatchEnd, |
| 1306 | int& maxBatchCount) { |
| 1307 | int i = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1308 | int fbZOrder =-1; |
Jeykumar Sankaran | 9502f35 | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1309 | int droppedLayerCt = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1310 | while (i < mCurrentFrame.layerCount) { |
| 1311 | int batchCount = 0; |
| 1312 | int batchStart = i; |
| 1313 | int batchEnd = i; |
Jeykumar Sankaran | 9502f35 | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1314 | /* Adjust batch Z order with the dropped layers so far */ |
| 1315 | int fbZ = batchStart - droppedLayerCt; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1316 | int firstZReverseIndex = -1; |
Prabhanjan Kandula | 0ed2cc9 | 2013-12-06 12:39:04 +0530 | [diff] [blame] | 1317 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1318 | while(i < mCurrentFrame.layerCount) { |
| 1319 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1320 | if(!batchCount) { |
| 1321 | i++; |
| 1322 | break; |
| 1323 | } |
| 1324 | updatingLayersAbove++; |
| 1325 | i++; |
| 1326 | continue; |
| 1327 | } else { |
| 1328 | if(mCurrentFrame.drop[i]) { |
| 1329 | i++; |
Jeykumar Sankaran | 9502f35 | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1330 | droppedLayerCt++; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1331 | continue; |
| 1332 | } else if(updatingLayersAbove <= 0) { |
| 1333 | batchCount++; |
| 1334 | batchEnd = i; |
| 1335 | i++; |
| 1336 | continue; |
| 1337 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 1338 | |
| 1339 | // We have a valid updating layer already. If layer-i not |
| 1340 | // have overlapping with all updating layers in between |
| 1341 | // batch-start and i, then we can add layer i to batch. |
| 1342 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 1343 | batchCount++; |
| 1344 | batchEnd = i; |
| 1345 | i++; |
| 1346 | continue; |
| 1347 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 1348 | //If All the non-updating layers with in this batch |
| 1349 | //does not have intersection with the updating layers |
| 1350 | //above in z-order, then we can safely move the batch to |
| 1351 | //higher z-order. Increment fbZ as it is moving up. |
| 1352 | if( firstZReverseIndex < 0) { |
| 1353 | firstZReverseIndex = i; |
| 1354 | } |
| 1355 | batchCount++; |
| 1356 | batchEnd = i; |
| 1357 | fbZ += updatingLayersAbove; |
| 1358 | i++; |
| 1359 | updatingLayersAbove = 0; |
| 1360 | continue; |
| 1361 | } else { |
| 1362 | //both failed.start the loop again from here. |
| 1363 | if(firstZReverseIndex >= 0) { |
| 1364 | i = firstZReverseIndex; |
| 1365 | } |
| 1366 | break; |
| 1367 | } |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | if(batchCount > maxBatchCount) { |
| 1372 | maxBatchCount = batchCount; |
| 1373 | maxBatchStart = batchStart; |
| 1374 | maxBatchEnd = batchEnd; |
| 1375 | fbZOrder = fbZ; |
| 1376 | } |
| 1377 | } |
| 1378 | return fbZOrder; |
| 1379 | } |
| 1380 | |
| 1381 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 1382 | hwc_display_contents_1_t* list) { |
| 1383 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 1384 | * send rest of them through MDP. This is done in 2 steps. |
| 1385 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 1386 | * 2. See if we can improve this batch size for caching by adding |
| 1387 | * opaque layers around the batch, if they don't have |
| 1388 | * any overlapping with the updating layers in between. |
| 1389 | * NEVER mark an updating layer for caching. |
| 1390 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1391 | |
| 1392 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1393 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1394 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1395 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1396 | |
Saurabh Shah | d53bc5f | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1397 | /* Nothing is cached. No batching needed */ |
| 1398 | if(mCurrentFrame.fbCount == 0) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1399 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1400 | } |
Saurabh Shah | d53bc5f | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1401 | |
| 1402 | /* No MDP comp layers, try to use other comp modes */ |
| 1403 | if(mCurrentFrame.mdpCount == 0) { |
| 1404 | return false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1405 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1406 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1407 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1408 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1409 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1410 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1411 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1412 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1413 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1414 | if(!mCurrentFrame.drop[i]){ |
| 1415 | //If an unsupported layer is being attempted to |
| 1416 | //be pulled out we should fail |
| 1417 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1418 | return false; |
| 1419 | } |
| 1420 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1421 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1422 | } |
| 1423 | } |
| 1424 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1425 | // update the frame data |
| 1426 | mCurrentFrame.fbZ = fbZ; |
| 1427 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1428 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1429 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1430 | |
| 1431 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1432 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1433 | |
| 1434 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1435 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1436 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1437 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1438 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1439 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1440 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1441 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1442 | for(int i = 0; i < numAppLayers; i++) { |
| 1443 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1444 | if(!mCurrentFrame.drop[i]) |
| 1445 | fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1446 | mCurrentFrame.isFBComposed[i] = true; |
| 1447 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1448 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1449 | } |
| 1450 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1451 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1452 | mCurrentFrame.fbCount = fbCount; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1453 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount |
| 1454 | - mCurrentFrame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1455 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1456 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d" |
| 1457 | ,__FUNCTION__, mCurrentFrame.mdpCount, mCurrentFrame.fbCount, |
| 1458 | mCurrentFrame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1459 | } |
| 1460 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1461 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
| 1462 | bool secureOnly) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1463 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
| 1464 | for(int index = 0;index < nYuvCount; index++){ |
| 1465 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 1466 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 1467 | |
| 1468 | if(!isYUVDoable(ctx, layer)) { |
| 1469 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 1470 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 1471 | mCurrentFrame.fbCount++; |
| 1472 | } |
| 1473 | } else { |
| 1474 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1475 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1476 | if(!secureOnly || isSecureBuffer(hnd)) { |
| 1477 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 1478 | mCurrentFrame.fbCount--; |
| 1479 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1480 | } |
| 1481 | } |
| 1482 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1483 | |
| 1484 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1485 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
| 1486 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1487 | mCurrentFrame.fbCount); |
| 1488 | } |
| 1489 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1490 | hwc_rect_t MDPComp::getUpdatingFBRect(hwc_context_t *ctx, |
| 1491 | hwc_display_contents_1_t* list){ |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 1492 | hwc_rect_t fbRect = (struct hwc_rect){0, 0, 0, 0}; |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 1493 | |
| 1494 | /* Update only the region of FB needed for composition */ |
| 1495 | for(int i = 0; i < mCurrentFrame.layerCount; i++ ) { |
| 1496 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 1497 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1498 | hwc_rect_t dst = layer->displayFrame; |
| 1499 | fbRect = getUnion(fbRect, dst); |
| 1500 | } |
| 1501 | } |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1502 | trimAgainstROI(ctx, fbRect); |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 1503 | return fbRect; |
| 1504 | } |
| 1505 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1506 | bool MDPComp::postHeuristicsHandling(hwc_context_t *ctx, |
| 1507 | hwc_display_contents_1_t* list) { |
| 1508 | |
| 1509 | //Capability checks |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 1510 | if(!resourceCheck(ctx, list)) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1511 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
| 1512 | return false; |
| 1513 | } |
| 1514 | |
| 1515 | //Limitations checks |
| 1516 | if(!hwLimitationsCheck(ctx, list)) { |
| 1517 | ALOGD_IF(isDebug(), "%s: HW limitations",__FUNCTION__); |
| 1518 | return false; |
| 1519 | } |
| 1520 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1521 | //Configure framebuffer first if applicable |
| 1522 | if(mCurrentFrame.fbZ >= 0) { |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1523 | hwc_rect_t fbRect = getUpdatingFBRect(ctx, list); |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 1524 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, fbRect, mCurrentFrame.fbZ)) |
| 1525 | { |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1526 | ALOGD_IF(isDebug(), "%s configure framebuffer failed", |
| 1527 | __FUNCTION__); |
| 1528 | return false; |
| 1529 | } |
| 1530 | } |
| 1531 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1532 | mCurrentFrame.map(); |
| 1533 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1534 | if(!allocLayerPipes(ctx, list)) { |
| 1535 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1536 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1537 | } |
| 1538 | |
| 1539 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1540 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1541 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1542 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1543 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1544 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1545 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 1546 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1547 | mdpNextZOrder++; |
| 1548 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1549 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1550 | cur_pipe->zOrder = mdpNextZOrder++; |
| 1551 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1552 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1553 | if(isYUVSplitNeeded(hnd) && sEnableYUVsplit){ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1554 | if(configure4k2kYuv(ctx, layer, |
| 1555 | mCurrentFrame.mdpToLayer[mdpIndex]) |
| 1556 | != 0 ){ |
| 1557 | ALOGD_IF(isDebug(), "%s: Failed to configure split pipes \ |
| 1558 | for layer %d",__FUNCTION__, index); |
| 1559 | return false; |
| 1560 | } |
| 1561 | else{ |
| 1562 | mdpNextZOrder++; |
| 1563 | } |
| 1564 | continue; |
| 1565 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1566 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1567 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1568 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1569 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1570 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1571 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1572 | } |
| 1573 | |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 1574 | if(!ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd)) { |
| 1575 | ALOGD_IF(isDebug(), "%s: Failed to validate and set overlay for dpy %d" |
| 1576 | ,__FUNCTION__, mDpy); |
| 1577 | return false; |
| 1578 | } |
| 1579 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1580 | setRedraw(ctx, list); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1581 | return true; |
| 1582 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1583 | |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 1584 | bool MDPComp::resourceCheck(hwc_context_t* ctx, |
| 1585 | hwc_display_contents_1_t* list) { |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1586 | const bool fbUsed = mCurrentFrame.fbCount; |
| 1587 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { |
| 1588 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 1589 | return false; |
| 1590 | } |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 1591 | // Init rotCount to number of rotate sessions used by other displays |
| 1592 | int rotCount = ctx->mRotMgr->getNumActiveSessions(); |
| 1593 | // Count the number of rotator sessions required for current display |
| 1594 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 1595 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1596 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1597 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1598 | if(has90Transform(layer) && isRotationDoable(ctx, hnd)) { |
| 1599 | rotCount++; |
| 1600 | } |
| 1601 | } |
| 1602 | } |
| 1603 | // if number of layers to rotate exceeds max rotator sessions, bail out. |
| 1604 | if(rotCount > RotMgr::MAX_ROT_SESS) { |
| 1605 | ALOGD_IF(isDebug(), "%s: Exceeds max rotator sessions %d", |
| 1606 | __FUNCTION__, mDpy); |
| 1607 | return false; |
| 1608 | } |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1609 | return true; |
| 1610 | } |
| 1611 | |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1612 | bool MDPComp::hwLimitationsCheck(hwc_context_t* ctx, |
| 1613 | hwc_display_contents_1_t* list) { |
| 1614 | |
| 1615 | //A-family hw limitation: |
| 1616 | //If a layer need alpha scaling, MDP can not support. |
| 1617 | if(ctx->mMDP.version < qdutils::MDSS_V5) { |
| 1618 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1619 | if(!mCurrentFrame.isFBComposed[i] && |
| 1620 | isAlphaScaled( &list->hwLayers[i])) { |
| 1621 | ALOGD_IF(isDebug(), "%s:frame needs alphaScaling",__FUNCTION__); |
| 1622 | return false; |
| 1623 | } |
| 1624 | } |
| 1625 | } |
| 1626 | |
| 1627 | // On 8x26 & 8974 hw, we have a limitation of downscaling+blending. |
| 1628 | //If multiple layers requires downscaling and also they are overlapping |
| 1629 | //fall back to GPU since MDSS can not handle it. |
| 1630 | if(qdutils::MDPVersion::getInstance().is8x74v2() || |
| 1631 | qdutils::MDPVersion::getInstance().is8x26()) { |
| 1632 | for(int i = 0; i < mCurrentFrame.layerCount-1; ++i) { |
| 1633 | hwc_layer_1_t* botLayer = &list->hwLayers[i]; |
| 1634 | if(!mCurrentFrame.isFBComposed[i] && |
| 1635 | isDownscaleRequired(botLayer)) { |
| 1636 | //if layer-i is marked for MDP and needs downscaling |
| 1637 | //check if any MDP layer on top of i & overlaps with layer-i |
| 1638 | for(int j = i+1; j < mCurrentFrame.layerCount; ++j) { |
| 1639 | hwc_layer_1_t* topLayer = &list->hwLayers[j]; |
| 1640 | if(!mCurrentFrame.isFBComposed[j] && |
| 1641 | isDownscaleRequired(topLayer)) { |
| 1642 | hwc_rect_t r = getIntersection(botLayer->displayFrame, |
| 1643 | topLayer->displayFrame); |
| 1644 | if(isValidRect(r)) |
| 1645 | return false; |
| 1646 | } |
| 1647 | } |
| 1648 | } |
| 1649 | } |
| 1650 | } |
| 1651 | return true; |
| 1652 | } |
| 1653 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1654 | 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] | 1655 | int ret = 0; |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1656 | char property[PROPERTY_VALUE_MAX]; |
| 1657 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1658 | if(!ctx || !list) { |
| 1659 | ALOGE("%s: Invalid context or list",__FUNCTION__); |
| 1660 | mCachedFrame.reset(); |
| 1661 | return -1; |
| 1662 | } |
| 1663 | |
| 1664 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
| 1665 | |
Jeykumar Sankaran | 0ad97c4 | 2014-03-09 23:00:53 -0700 | [diff] [blame] | 1666 | if(property_get("debug.hwc.simulate", property, NULL) > 0) { |
| 1667 | int currentFlags = atoi(property); |
| 1668 | if(currentFlags != sSimulationFlags) { |
| 1669 | sSimulationFlags = currentFlags; |
| 1670 | ALOGE("%s: Simulation Flag read: 0x%x (%d)", __FUNCTION__, |
| 1671 | sSimulationFlags, sSimulationFlags); |
| 1672 | } |
| 1673 | } |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1674 | // reset PTOR |
| 1675 | if(!mDpy) |
| 1676 | memset(&(ctx->mPtorInfo), 0, sizeof(ctx->mPtorInfo)); |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 1677 | |
Raj Kamal | 9ed3d6b | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 1678 | //Do not cache the information for next draw cycle. |
| 1679 | if(numLayers > MAX_NUM_APP_LAYERS or (!numLayers)) { |
| 1680 | ALOGI("%s: Unsupported layer count for mdp composition", |
| 1681 | __FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1682 | mCachedFrame.reset(); |
| 1683 | return -1; |
| 1684 | } |
| 1685 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1686 | //reset old data |
| 1687 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1688 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1689 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1690 | |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1691 | // Detect the start of animation and fall back to GPU only once to cache |
| 1692 | // all the layers in FB and display FB content untill animation completes. |
| 1693 | if(ctx->listStats[mDpy].isDisplayAnimating) { |
| 1694 | mCurrentFrame.needsRedraw = false; |
| 1695 | if(ctx->mAnimationState[mDpy] == ANIMATION_STOPPED) { |
| 1696 | mCurrentFrame.needsRedraw = true; |
| 1697 | ctx->mAnimationState[mDpy] = ANIMATION_STARTED; |
| 1698 | } |
| 1699 | setMDPCompLayerFlags(ctx, list); |
| 1700 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1701 | ret = -1; |
| 1702 | return ret; |
| 1703 | } else { |
| 1704 | ctx->mAnimationState[mDpy] = ANIMATION_STOPPED; |
| 1705 | } |
| 1706 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1707 | //Hard conditions, if not met, cannot do MDP comp |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1708 | if(isFrameDoable(ctx)) { |
| 1709 | generateROI(ctx, list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1710 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1711 | mModeOn = tryFullFrame(ctx, list) || tryVideoOnly(ctx, list); |
| 1712 | if(mModeOn) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1713 | setMDPCompLayerFlags(ctx, list); |
| 1714 | } else { |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 1715 | resetROI(ctx, mDpy); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1716 | reset(ctx); |
| 1717 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1718 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1719 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1720 | } |
| 1721 | } else { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1722 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1723 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1724 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1725 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1726 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1727 | if(isDebug()) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1728 | ALOGD("GEOMETRY change: %d", |
| 1729 | (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1730 | android::String8 sDump(""); |
Jeykumar Sankaran | 6850ac6 | 2014-05-27 10:07:26 -0700 | [diff] [blame] | 1731 | dump(sDump, ctx); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1732 | ALOGD("%s",sDump.string()); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1733 | } |
| 1734 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1735 | mCachedFrame.cacheAll(list); |
| 1736 | mCachedFrame.updateCounts(mCurrentFrame); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1737 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1738 | } |
| 1739 | |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 1740 | bool MDPComp::allocSplitVGPipesfor4k2k(hwc_context_t *ctx, int index) { |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1741 | |
| 1742 | bool bRet = true; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1743 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1744 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
| 1745 | info.pipeInfo = new MdpYUVPipeInfo; |
| 1746 | info.rot = NULL; |
| 1747 | MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1748 | |
| 1749 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1750 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1751 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 1752 | Overlay::PipeSpecs pipeSpecs; |
| 1753 | pipeSpecs.formatClass = Overlay::FORMAT_YUV; |
| 1754 | pipeSpecs.needsScaling = true; |
| 1755 | pipeSpecs.dpy = mDpy; |
| 1756 | pipeSpecs.fb = false; |
| 1757 | |
| 1758 | pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1759 | if(pipe_info.lIndex == ovutils::OV_INVALID){ |
| 1760 | bRet = false; |
| 1761 | ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed", |
| 1762 | __FUNCTION__); |
| 1763 | } |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 1764 | pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1765 | if(pipe_info.rIndex == ovutils::OV_INVALID){ |
| 1766 | bRet = false; |
| 1767 | ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed", |
| 1768 | __FUNCTION__); |
| 1769 | } |
| 1770 | return bRet; |
| 1771 | } |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1772 | |
| 1773 | int MDPComp::drawOverlap(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1774 | int fd = -1; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1775 | if (ctx->mPtorInfo.isActive()) { |
| 1776 | fd = ctx->mCopyBit[mDpy]->drawOverlap(ctx, list); |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1777 | if (fd < 0) { |
| 1778 | ALOGD_IF(isDebug(),"%s: failed", __FUNCTION__); |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1779 | } |
| 1780 | } |
| 1781 | return fd; |
| 1782 | } |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 1783 | //=============MDPCompNonSplit================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1784 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1785 | void MDPCompNonSplit::adjustForSourceSplit(hwc_context_t *ctx, |
Dileep Kumar Reddi | 190dc1c | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1786 | hwc_display_contents_1_t* list) { |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1787 | //If 4k2k Yuv layer split is possible, and if |
| 1788 | //fbz is above 4k2k layer, increment fb zorder by 1 |
| 1789 | //as we split 4k2k layer and increment zorder for right half |
| 1790 | //of the layer |
Shalaj Jain | a70b435 | 2014-06-15 13:47:47 -0700 | [diff] [blame] | 1791 | if(!ctx) |
| 1792 | return; |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1793 | if(mCurrentFrame.fbZ >= 0) { |
Dileep Kumar Reddi | 190dc1c | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1794 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 1795 | index++) { |
| 1796 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1797 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1798 | mdpNextZOrder++; |
| 1799 | } |
| 1800 | mdpNextZOrder++; |
| 1801 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1802 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1803 | if(isYUVSplitNeeded(hnd)) { |
Dileep Kumar Reddi | 190dc1c | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1804 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 1805 | mCurrentFrame.fbZ += 1; |
| 1806 | mdpNextZOrder++; |
| 1807 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1808 | //(if available) increase mdpcount by 1. |
| 1809 | mCurrentFrame.mdpCount++; |
| 1810 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1811 | } |
| 1812 | } |
| 1813 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1814 | } |
| 1815 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1816 | /* |
| 1817 | * Configures pipe(s) for MDP composition |
| 1818 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1819 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1820 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1821 | MdpPipeInfoNonSplit& mdp_info = |
| 1822 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1823 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 1824 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1825 | eIsFg isFg = IS_FG_OFF; |
| 1826 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1827 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1828 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1829 | __FUNCTION__, layer, zOrder, dest); |
| 1830 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1831 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1832 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1833 | } |
| 1834 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1835 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1836 | hwc_display_contents_1_t* list) { |
| 1837 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1838 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1839 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1840 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1841 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1842 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1843 | if(isYUVSplitNeeded(hnd) && sEnableYUVsplit){ |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 1844 | if(allocSplitVGPipesfor4k2k(ctx, index)){ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1845 | continue; |
| 1846 | } |
| 1847 | } |
| 1848 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1849 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1850 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1851 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1852 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1853 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1854 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 1855 | Overlay::PipeSpecs pipeSpecs; |
| 1856 | pipeSpecs.formatClass = isYuvBuffer(hnd) ? |
| 1857 | Overlay::FORMAT_YUV : Overlay::FORMAT_RGB; |
| 1858 | pipeSpecs.needsScaling = qhwc::needsScaling(layer) or |
| 1859 | (qdutils::MDPVersion::getInstance().is8x26() and |
| 1860 | ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024); |
| 1861 | pipeSpecs.dpy = mDpy; |
| 1862 | pipeSpecs.fb = false; |
Xu Yang | 1e686f6 | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 1863 | pipeSpecs.numActiveDisplays = ctx->numActiveDisplays; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1864 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 1865 | pipe_info.index = ctx->mOverlay->getPipe(pipeSpecs); |
| 1866 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1867 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 1868 | ALOGD_IF(isDebug(), "%s: Unable to get pipe", __FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1869 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1870 | } |
| 1871 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1872 | return true; |
| 1873 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1874 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1875 | int MDPCompNonSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 1876 | PipeLayerPair& PipeLayerPair) { |
| 1877 | MdpYUVPipeInfo& mdp_info = |
| 1878 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 1879 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1880 | eIsFg isFg = IS_FG_OFF; |
| 1881 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1882 | eDest lDest = mdp_info.lIndex; |
| 1883 | eDest rDest = mdp_info.rIndex; |
| 1884 | |
| 1885 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 1886 | lDest, rDest, &PipeLayerPair.rot); |
| 1887 | } |
| 1888 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1889 | 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] | 1890 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1891 | if(!isEnabled() or !mModeOn) { |
| 1892 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1893 | return true; |
| 1894 | } |
| 1895 | |
Ramkumar Radhakrishnan | 92abb4f | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 1896 | // Set the Handle timeout to true for MDP or MIXED composition. |
| 1897 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) { |
| 1898 | sHandleTimeout = true; |
| 1899 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1900 | |
| 1901 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1902 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1903 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1904 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1905 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1906 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1907 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1908 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1909 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1910 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1911 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 1912 | if (!(layer->flags & HWC_COLOR_FILL)) { |
| 1913 | ALOGE("%s handle null", __FUNCTION__); |
| 1914 | return false; |
| 1915 | } |
| 1916 | // No PLAY for Color layer |
| 1917 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1918 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1919 | } |
| 1920 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1921 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1922 | |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 1923 | if(isYUVSplitNeeded(hnd) && sEnableYUVsplit) |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1924 | { |
| 1925 | MdpYUVPipeInfo& pipe_info = |
| 1926 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1927 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1928 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1929 | ovutils::eDest indexR = pipe_info.rIndex; |
| 1930 | int fd = hnd->fd; |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 1931 | uint32_t offset = (uint32_t)hnd->offset; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1932 | if(rot) { |
| 1933 | rot->queueBuffer(fd, offset); |
| 1934 | fd = rot->getDstMemId(); |
| 1935 | offset = rot->getDstOffset(); |
| 1936 | } |
| 1937 | if(indexL != ovutils::OV_INVALID) { |
| 1938 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 1939 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1940 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 1941 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1942 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1943 | __FUNCTION__, mDpy); |
| 1944 | return false; |
| 1945 | } |
| 1946 | } |
| 1947 | |
| 1948 | if(indexR != ovutils::OV_INVALID) { |
| 1949 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 1950 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1951 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 1952 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1953 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1954 | __FUNCTION__, mDpy); |
| 1955 | return false; |
| 1956 | } |
| 1957 | } |
| 1958 | } |
| 1959 | else{ |
| 1960 | MdpPipeInfoNonSplit& pipe_info = |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1961 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1962 | ovutils::eDest dest = pipe_info.index; |
| 1963 | if(dest == ovutils::OV_INVALID) { |
| 1964 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1965 | return false; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1966 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1967 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1968 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1969 | continue; |
| 1970 | } |
| 1971 | |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1972 | int fd = hnd->fd; |
| 1973 | uint32_t offset = (uint32_t)hnd->offset; |
| 1974 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 1975 | if (!mDpy && (index != -1)) { |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1976 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1977 | fd = hnd->fd; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 1978 | offset = 0; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1979 | } |
| 1980 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1981 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1982 | using pipe: %d", __FUNCTION__, layer, |
| 1983 | hnd, dest ); |
| 1984 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1985 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1986 | if(rot) { |
| 1987 | if(!rot->queueBuffer(fd, offset)) |
| 1988 | return false; |
| 1989 | fd = rot->getDstMemId(); |
| 1990 | offset = rot->getDstOffset(); |
| 1991 | } |
| 1992 | |
| 1993 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 1994 | ALOGE("%s: queueBuffer failed for display:%d ", |
| 1995 | __FUNCTION__, mDpy); |
| 1996 | return false; |
| 1997 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1998 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1999 | |
| 2000 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2001 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 2002 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2003 | } |
| 2004 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2005 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2006 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 2007 | void MDPCompSplit::adjustForSourceSplit(hwc_context_t *ctx, |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2008 | hwc_display_contents_1_t* list){ |
| 2009 | //if 4kx2k yuv layer is totally present in either in left half |
| 2010 | //or right half then try splitting the yuv layer to avoid decimation |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2011 | const int lSplit = getLeftSplit(ctx, mDpy); |
Dileep Kumar Reddi | 190dc1c | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 2012 | if(mCurrentFrame.fbZ >= 0) { |
| 2013 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 2014 | index++) { |
| 2015 | if(!mCurrentFrame.isFBComposed[index]) { |
| 2016 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 2017 | mdpNextZOrder++; |
| 2018 | } |
| 2019 | mdpNextZOrder++; |
| 2020 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 2021 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 2022 | if(isYUVSplitNeeded(hnd)) { |
Dileep Kumar Reddi | 190dc1c | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 2023 | hwc_rect_t dst = layer->displayFrame; |
| 2024 | if((dst.left > lSplit) || (dst.right < lSplit)) { |
| 2025 | mCurrentFrame.mdpCount += 1; |
| 2026 | } |
| 2027 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 2028 | mCurrentFrame.fbZ += 1; |
| 2029 | mdpNextZOrder++; |
| 2030 | } |
| 2031 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 2032 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2036 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2037 | MdpPipeInfoSplit& pipe_info) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2038 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2039 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 2040 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2041 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2042 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 2043 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 2044 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2045 | Overlay::PipeSpecs pipeSpecs; |
| 2046 | pipeSpecs.formatClass = isYuvBuffer(hnd) ? |
| 2047 | Overlay::FORMAT_YUV : Overlay::FORMAT_RGB; |
| 2048 | pipeSpecs.needsScaling = qhwc::needsScalingWithSplit(ctx, layer, mDpy); |
| 2049 | pipeSpecs.dpy = mDpy; |
| 2050 | pipeSpecs.mixer = Overlay::MIXER_LEFT; |
| 2051 | pipeSpecs.fb = false; |
| 2052 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 2053 | // Acquire pipe only for the updating half |
| 2054 | hwc_rect_t l_roi = ctx->listStats[mDpy].lRoi; |
| 2055 | hwc_rect_t r_roi = ctx->listStats[mDpy].rRoi; |
| 2056 | |
| 2057 | if (dst.left < lSplit && isValidRect(getIntersection(dst, l_roi))) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2058 | pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2059 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 2060 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2061 | } |
| 2062 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 2063 | if(dst.right > lSplit && isValidRect(getIntersection(dst, r_roi))) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2064 | pipeSpecs.mixer = Overlay::MIXER_RIGHT; |
| 2065 | pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs); |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2066 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2067 | return false; |
| 2068 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2069 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2070 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2071 | } |
| 2072 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2073 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2074 | hwc_display_contents_1_t* list) { |
| 2075 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2076 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2077 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2078 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2079 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 2080 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2081 | hwc_rect_t dst = layer->displayFrame; |
| 2082 | const int lSplit = getLeftSplit(ctx, mDpy); |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 2083 | if(isYUVSplitNeeded(hnd) && sEnableYUVsplit){ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2084 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 2085 | if(allocSplitVGPipesfor4k2k(ctx, index)){ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2086 | continue; |
| 2087 | } |
| 2088 | } |
| 2089 | } |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 2090 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 2091 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2092 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 2093 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2094 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2095 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2096 | if(!acquireMDPPipes(ctx, layer, pipe_info)) { |
| 2097 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type", |
| 2098 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2099 | return false; |
| 2100 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2101 | } |
| 2102 | return true; |
| 2103 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2104 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2105 | int MDPCompSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 2106 | PipeLayerPair& PipeLayerPair) { |
| 2107 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 2108 | hwc_rect_t dst = layer->displayFrame; |
| 2109 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 2110 | MdpYUVPipeInfo& mdp_info = |
| 2111 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 2112 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2113 | eIsFg isFg = IS_FG_OFF; |
| 2114 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 2115 | eDest lDest = mdp_info.lIndex; |
| 2116 | eDest rDest = mdp_info.rIndex; |
| 2117 | |
| 2118 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 2119 | lDest, rDest, &PipeLayerPair.rot); |
| 2120 | } |
| 2121 | else{ |
| 2122 | return configure(ctx, layer, PipeLayerPair); |
| 2123 | } |
| 2124 | } |
| 2125 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2126 | /* |
| 2127 | * Configures pipe(s) for MDP composition |
| 2128 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2129 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 2130 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2131 | MdpPipeInfoSplit& mdp_info = |
| 2132 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2133 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2134 | eIsFg isFg = IS_FG_OFF; |
| 2135 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 2136 | eDest lDest = mdp_info.lIndex; |
| 2137 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2138 | |
| 2139 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 2140 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 2141 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2142 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2143 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2144 | } |
| 2145 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2146 | 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] | 2147 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 2148 | if(!isEnabled() or !mModeOn) { |
| 2149 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 2150 | return true; |
| 2151 | } |
| 2152 | |
Ramkumar Radhakrishnan | 92abb4f | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 2153 | // Set the Handle timeout to true for MDP or MIXED composition. |
| 2154 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) { |
| 2155 | sHandleTimeout = true; |
| 2156 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2157 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 2158 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2159 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2160 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2161 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 2162 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2163 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2164 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 2165 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2166 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2167 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 2168 | if(!hnd) { |
| 2169 | ALOGE("%s handle null", __FUNCTION__); |
| 2170 | return false; |
| 2171 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2172 | |
| 2173 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 2174 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2175 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2176 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2177 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 2178 | |
Raj Kamal | 389d6e3 | 2014-08-04 14:43:24 +0530 | [diff] [blame] | 2179 | if(isYUVSplitNeeded(hnd) && sEnableYUVsplit) |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2180 | { |
| 2181 | MdpYUVPipeInfo& pipe_info = |
| 2182 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2183 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 2184 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2185 | ovutils::eDest indexR = pipe_info.rIndex; |
| 2186 | int fd = hnd->fd; |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 2187 | uint32_t offset = (uint32_t)hnd->offset; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2188 | if(rot) { |
| 2189 | rot->queueBuffer(fd, offset); |
| 2190 | fd = rot->getDstMemId(); |
| 2191 | offset = rot->getDstOffset(); |
| 2192 | } |
| 2193 | if(indexL != ovutils::OV_INVALID) { |
| 2194 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2195 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2196 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2197 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2198 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2199 | __FUNCTION__, mDpy); |
| 2200 | return false; |
| 2201 | } |
| 2202 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2203 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2204 | if(indexR != ovutils::OV_INVALID) { |
| 2205 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2206 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2207 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2208 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2209 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2210 | __FUNCTION__, mDpy); |
| 2211 | return false; |
| 2212 | } |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2213 | } |
| 2214 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2215 | else{ |
| 2216 | MdpPipeInfoSplit& pipe_info = |
| 2217 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2218 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2219 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2220 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2221 | ovutils::eDest indexR = pipe_info.rIndex; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2222 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2223 | int fd = hnd->fd; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2224 | uint32_t offset = (uint32_t)hnd->offset; |
| 2225 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 2226 | if (!mDpy && (index != -1)) { |
| 2227 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
| 2228 | fd = hnd->fd; |
Sushil Chauhan | 875a92e | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 2229 | offset = 0; |
Arun Kumar K.R | b2a03b1 | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2230 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2231 | |
Tatenda Chipeperekwa | 88fe635 | 2014-04-14 10:36:06 -0700 | [diff] [blame] | 2232 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 2233 | fd = ctx->mAD->getDstFd(); |
| 2234 | offset = ctx->mAD->getDstOffset(); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2235 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2236 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2237 | if(rot) { |
| 2238 | rot->queueBuffer(fd, offset); |
| 2239 | fd = rot->getDstMemId(); |
| 2240 | offset = rot->getDstOffset(); |
| 2241 | } |
| 2242 | |
| 2243 | //************* play left mixer ********** |
| 2244 | if(indexL != ovutils::OV_INVALID) { |
| 2245 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2246 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2247 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2248 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2249 | ALOGE("%s: queueBuffer failed for left mixer", |
| 2250 | __FUNCTION__); |
| 2251 | return false; |
| 2252 | } |
| 2253 | } |
| 2254 | |
| 2255 | //************* play right mixer ********** |
| 2256 | if(indexR != ovutils::OV_INVALID) { |
| 2257 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2258 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2259 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2260 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2261 | ALOGE("%s: queueBuffer failed for right mixer", |
| 2262 | __FUNCTION__); |
| 2263 | return false; |
| 2264 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2265 | } |
| 2266 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2267 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2268 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 2269 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2270 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2271 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2272 | } |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2273 | |
| 2274 | //================MDPCompSrcSplit============================================== |
| 2275 | bool MDPCompSrcSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2276 | MdpPipeInfoSplit& pipe_info) { |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2277 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 2278 | hwc_rect_t dst = layer->displayFrame; |
| 2279 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
| 2280 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 2281 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 2282 | |
| 2283 | //If 2 pipes are staged on a single stage of a mixer, then the left pipe |
| 2284 | //should have a higher priority than the right one. Pipe priorities are |
| 2285 | //starting with VG0, VG1 ... , RGB0 ..., DMA1 |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2286 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2287 | Overlay::PipeSpecs pipeSpecs; |
| 2288 | pipeSpecs.formatClass = isYuvBuffer(hnd) ? |
| 2289 | Overlay::FORMAT_YUV : Overlay::FORMAT_RGB; |
| 2290 | pipeSpecs.needsScaling = qhwc::needsScaling(layer); |
| 2291 | pipeSpecs.dpy = mDpy; |
| 2292 | pipeSpecs.fb = false; |
| 2293 | |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2294 | //1 pipe by default for a layer |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2295 | pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2296 | if(pipe_info.lIndex == ovutils::OV_INVALID) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2297 | return false; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2298 | } |
| 2299 | |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 2300 | /* Use 2 pipes IF |
| 2301 | a) Layer's crop width is > 2048 or |
| 2302 | b) Layer's dest width > 2048 or |
| 2303 | c) On primary, driver has indicated with caps to split always. This is |
| 2304 | based on an empirically derived value of panel height. Applied only |
| 2305 | if the layer's width is > mixer's width |
| 2306 | */ |
| 2307 | |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 2308 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 2309 | bool primarySplitAlways = (mDpy == HWC_DISPLAY_PRIMARY) and |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 2310 | mdpHw.isSrcSplitAlways(); |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 2311 | int lSplit = getLeftSplit(ctx, mDpy); |
| 2312 | int dstWidth = dst.right - dst.left; |
| 2313 | int cropWidth = crop.right - crop.left; |
| 2314 | |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2315 | //TODO Even if a 4k video is going to be rot-downscaled to dimensions under |
| 2316 | //pipe line length, we are still using 2 pipes. This is fine just because |
| 2317 | //this is source split where destination doesn't matter. Evaluate later to |
| 2318 | //see if going through all the calcs to save a pipe is worth it |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 2319 | if(dstWidth > mdpHw.getMaxMixerWidth() or |
| 2320 | cropWidth > mdpHw.getMaxMixerWidth() or |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 2321 | (primarySplitAlways and (cropWidth > lSplit))) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2322 | pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2323 | if(pipe_info.rIndex == ovutils::OV_INVALID) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 2324 | return false; |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 2325 | } |
| 2326 | |
| 2327 | // Return values |
| 2328 | // 1 Left pipe is higher priority, do nothing. |
| 2329 | // 0 Pipes of same priority. |
| 2330 | //-1 Right pipe is of higher priority, needs swap. |
| 2331 | if(ctx->mOverlay->comparePipePriority(pipe_info.lIndex, |
| 2332 | pipe_info.rIndex) == -1) { |
| 2333 | qhwc::swap(pipe_info.lIndex, pipe_info.rIndex); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2334 | } |
| 2335 | } |
| 2336 | |
| 2337 | return true; |
| 2338 | } |
| 2339 | |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2340 | int MDPCompSrcSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 2341 | PipeLayerPair& PipeLayerPair) { |
| 2342 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 2343 | if(!hnd) { |
| 2344 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 2345 | return -1; |
| 2346 | } |
| 2347 | MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; |
| 2348 | MdpPipeInfoSplit& mdp_info = |
| 2349 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
| 2350 | Rotator **rot = &PipeLayerPair.rot; |
| 2351 | eZorder z = static_cast<eZorder>(mdp_info.zOrder); |
| 2352 | eIsFg isFg = IS_FG_OFF; |
| 2353 | eDest lDest = mdp_info.lIndex; |
| 2354 | eDest rDest = mdp_info.rIndex; |
| 2355 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
| 2356 | hwc_rect_t dst = layer->displayFrame; |
| 2357 | int transform = layer->transform; |
| 2358 | eTransform orient = static_cast<eTransform>(transform); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2359 | int rotFlags = ROT_FLAGS_NONE; |
| 2360 | uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd)); |
| 2361 | Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size); |
| 2362 | |
| 2363 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 2364 | "dest_pipeR: %d",__FUNCTION__, layer, z, lDest, rDest); |
| 2365 | |
| 2366 | // Handle R/B swap |
| 2367 | if (layer->flags & HWC_FORMAT_RB_SWAP) { |
| 2368 | if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888) |
| 2369 | whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888); |
| 2370 | else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888) |
| 2371 | whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888); |
| 2372 | } |
| 2373 | |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2374 | int downscale = getRotDownscale(ctx, layer); |
Saurabh Shah | 97e2d80 | 2014-04-14 18:03:54 -0700 | [diff] [blame] | 2375 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2376 | setMdpFlags(ctx, layer, mdpFlags, downscale, transform); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2377 | |
| 2378 | if(lDest != OV_INVALID && rDest != OV_INVALID) { |
| 2379 | //Enable overfetch |
Saurabh Shah | 97e2d80 | 2014-04-14 18:03:54 -0700 | [diff] [blame] | 2380 | setMdpFlags(mdpFlags, OV_MDSS_MDP_DUAL_PIPE); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2381 | } |
| 2382 | |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2383 | if((has90Transform(layer) or downscale) and isRotationDoable(ctx, hnd)) { |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2384 | (*rot) = ctx->mRotMgr->getNext(); |
| 2385 | if((*rot) == NULL) return -1; |
Saurabh Shah | 39240c9 | 2014-03-31 10:31:42 -0700 | [diff] [blame] | 2386 | ctx->mLayerRotMap[mDpy]->add(layer, *rot); |
Saurabh Shah | 1bd5b6f | 2014-05-19 12:23:13 -0700 | [diff] [blame] | 2387 | //If the video is using a single pipe, enable BWC |
| 2388 | if(rDest == OV_INVALID) { |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2389 | BwcPM::setBwc(crop, dst, transform, downscale, mdpFlags); |
Saurabh Shah | 1bd5b6f | 2014-05-19 12:23:13 -0700 | [diff] [blame] | 2390 | } |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2391 | //Configure rotator for pre-rotation |
Saurabh Shah | 97e2d80 | 2014-04-14 18:03:54 -0700 | [diff] [blame] | 2392 | if(configRotator(*rot, whf, crop, mdpFlags, orient, downscale) < 0) { |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2393 | ALOGE("%s: configRotator failed!", __FUNCTION__); |
| 2394 | return -1; |
| 2395 | } |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 2396 | updateSource(orient, whf, crop, *rot); |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 2397 | rotFlags |= ovutils::ROT_PREROTATED; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2398 | } |
| 2399 | |
| 2400 | //If 2 pipes being used, divide layer into half, crop and dst |
| 2401 | hwc_rect_t cropL = crop; |
| 2402 | hwc_rect_t cropR = crop; |
| 2403 | hwc_rect_t dstL = dst; |
| 2404 | hwc_rect_t dstR = dst; |
| 2405 | if(lDest != OV_INVALID && rDest != OV_INVALID) { |
| 2406 | cropL.right = (crop.right + crop.left) / 2; |
| 2407 | cropR.left = cropL.right; |
| 2408 | sanitizeSourceCrop(cropL, cropR, hnd); |
| 2409 | |
| 2410 | //Swap crops on H flip since 2 pipes are being used |
| 2411 | if((orient & OVERLAY_TRANSFORM_FLIP_H) && (*rot) == NULL) { |
| 2412 | hwc_rect_t tmp = cropL; |
| 2413 | cropL = cropR; |
| 2414 | cropR = tmp; |
| 2415 | } |
| 2416 | |
| 2417 | dstL.right = (dst.right + dst.left) / 2; |
| 2418 | dstR.left = dstL.right; |
| 2419 | } |
| 2420 | |
| 2421 | //For the mdp, since either we are pre-rotating or MDP does flips |
| 2422 | orient = OVERLAY_TRANSFORM_0; |
| 2423 | transform = 0; |
| 2424 | |
| 2425 | //configure left pipe |
| 2426 | if(lDest != OV_INVALID) { |
Saurabh Shah | 97e2d80 | 2014-04-14 18:03:54 -0700 | [diff] [blame] | 2427 | PipeArgs pargL(mdpFlags, whf, z, isFg, |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2428 | static_cast<eRotFlags>(rotFlags), layer->planeAlpha, |
| 2429 | (ovutils::eBlending) getBlending(layer->blending)); |
| 2430 | |
| 2431 | if(configMdp(ctx->mOverlay, pargL, orient, |
| 2432 | cropL, dstL, metadata, lDest) < 0) { |
| 2433 | ALOGE("%s: commit failed for left mixer config", __FUNCTION__); |
| 2434 | return -1; |
| 2435 | } |
| 2436 | } |
| 2437 | |
| 2438 | //configure right pipe |
| 2439 | if(rDest != OV_INVALID) { |
Saurabh Shah | 97e2d80 | 2014-04-14 18:03:54 -0700 | [diff] [blame] | 2440 | PipeArgs pargR(mdpFlags, whf, z, isFg, |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 2441 | static_cast<eRotFlags>(rotFlags), |
| 2442 | layer->planeAlpha, |
| 2443 | (ovutils::eBlending) getBlending(layer->blending)); |
| 2444 | if(configMdp(ctx->mOverlay, pargR, orient, |
| 2445 | cropR, dstR, metadata, rDest) < 0) { |
| 2446 | ALOGE("%s: commit failed for right mixer config", __FUNCTION__); |
| 2447 | return -1; |
| 2448 | } |
| 2449 | } |
| 2450 | |
| 2451 | return 0; |
| 2452 | } |
| 2453 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2454 | }; //namespace |
| 2455 | |