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