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