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