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