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