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