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