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