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