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