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