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