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