Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2013, 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 | 12f41c9 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 22 | #include "hdmi.h" |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 23 | #include "virtual.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 24 | #include "qdMetaData.h" |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 25 | #include "mdp_version.h" |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 26 | #include "hwc_fbupdate.h" |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 27 | #include "hwc_ad.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 28 | #include <overlayRotator.h> |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 29 | #include "hwc_copybit.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 30 | |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 31 | #include <utils/Vector.h> |
| 32 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 33 | using namespace overlay; |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 34 | using namespace qdutils; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 35 | using namespace overlay::utils; |
| 36 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 37 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 38 | namespace qhwc { |
| 39 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 40 | //==============MDPComp======================================================== |
| 41 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 42 | IdleInvalidator *MDPComp::idleInvalidator = NULL; |
| 43 | bool MDPComp::sIdleFallBack = false; |
| 44 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 45 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 46 | bool MDPComp::sEnableMixedMode = true; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 47 | bool MDPComp::sEnablePartialFrameUpdate = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 48 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 49 | bool MDPComp::sEnable4k2kYUVSplit = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 50 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 51 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
| 52 | if(isDisplaySplit(ctx, dpy)) { |
| 53 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 54 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 55 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 56 | } |
| 57 | |
Saurabh Shah | 49c6ec8 | 2015-05-21 18:56:58 -0700 | [diff] [blame] | 58 | MDPComp::MDPComp(int dpy) : mDpy(dpy), mModeOn(false), mPrevModeOn(false) { |
| 59 | }; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 60 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 61 | void MDPComp::dump(android::String8& buf) |
| 62 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 63 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 64 | return; |
| 65 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 66 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 67 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 68 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 69 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " |
| 70 | "fbCount:%2d \n", mCurrentFrame.layerCount, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 71 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 72 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 73 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 74 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
| 75 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 76 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 77 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 78 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 79 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 80 | index, |
| 81 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 82 | mCurrentFrame.layerToMDP[index], |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 83 | (mCurrentFrame.isFBComposed[index] ? |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 84 | (mCurrentFrame.drop[index] ? "DROP" : |
| 85 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 86 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 87 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 88 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | bool MDPComp::init(hwc_context_t *ctx) { |
| 92 | |
| 93 | if(!ctx) { |
| 94 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 95 | return false; |
| 96 | } |
| 97 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 98 | char property[PROPERTY_VALUE_MAX]; |
| 99 | |
| 100 | sEnabled = false; |
| 101 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 102 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 103 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 104 | sEnabled = true; |
| 105 | } |
| 106 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 107 | sEnableMixedMode = true; |
| 108 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 109 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 110 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 111 | sEnableMixedMode = false; |
| 112 | } |
| 113 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 114 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 115 | if(atoi(property) != 0) |
| 116 | sDebugLogs = true; |
| 117 | } |
| 118 | |
Prabhanjan Kandula | 30696ee | 2014-04-21 12:12:38 +0530 | [diff] [blame] | 119 | // We read from drivers if panel supports partial updating |
| 120 | // and we enable partial update computations if supported. |
| 121 | // Keeping this property to disable partial update for |
| 122 | // debugging by setting below property to 0 & only 0. |
| 123 | property_get("persist.hwc.partialupdate", property, "-1"); |
| 124 | if((atoi(property) != 0) && |
| 125 | qdutils::MDPVersion::getInstance().isPartialUpdateEnabled()) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 126 | sEnablePartialFrameUpdate = true; |
| 127 | } |
| 128 | ALOGE_IF(isDebug(), "%s: Partial Update applicable?: %d",__FUNCTION__, |
| 129 | sEnablePartialFrameUpdate); |
| 130 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 131 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 132 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 133 | int val = atoi(property); |
| 134 | if(val >= 0) |
| 135 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 138 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 139 | // Idle invalidation is not necessary on command mode panels |
| 140 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 141 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 142 | if(atoi(property) != 0) |
| 143 | idle_timeout = atoi(property); |
| 144 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 145 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 146 | //create Idle Invalidator only when not disabled through property |
| 147 | if(idle_timeout != -1) |
| 148 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 149 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 150 | if(idleInvalidator == NULL) { |
| 151 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 152 | __FUNCTION__); |
| 153 | } else { |
| 154 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 155 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 156 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 157 | |
| 158 | if((property_get("debug.mdpcomp.4k2kSplit", property, "0") > 0) && |
| 159 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 160 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 161 | sEnable4k2kYUVSplit = true; |
| 162 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 163 | |
| 164 | if ((property_get("persist.hwc.ptor.enable", property, NULL) > 0) && |
| 165 | ((!strncasecmp(property, "true", PROPERTY_VALUE_MAX )) || |
| 166 | (!strncmp(property, "1", PROPERTY_VALUE_MAX )))) { |
| 167 | ctx->mCopyBit[HWC_DISPLAY_PRIMARY] = new CopyBit(ctx, |
| 168 | HWC_DISPLAY_PRIMARY); |
| 169 | } |
| 170 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 171 | return true; |
| 172 | } |
| 173 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 174 | void MDPComp::reset(hwc_context_t *ctx) { |
| 175 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 176 | mCurrentFrame.reset(numLayers); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 177 | ctx->mOverlay->clear(mDpy); |
| 178 | ctx->mLayerRotMap[mDpy]->clear(); |
Dileep Kumar Reddi | f4051ae | 2014-12-31 18:01:19 +0530 | [diff] [blame] | 179 | ctx->listStats[mDpy].roi.x = 0; |
| 180 | ctx->listStats[mDpy].roi.y = 0; |
| 181 | ctx->listStats[mDpy].roi.w = (int)ctx->dpyAttr[mDpy].xres; |
| 182 | ctx->listStats[mDpy].roi.h = (int)ctx->dpyAttr[mDpy].yres; |
| 183 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 184 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 187 | void MDPComp::reset() { |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 188 | mPrevModeOn = mModeOn; |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 189 | mModeOn = false; |
| 190 | } |
| 191 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 192 | void MDPComp::timeout_handler(void *udata) { |
| 193 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 194 | bool handleTimeout = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 195 | |
| 196 | if(!ctx) { |
| 197 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 198 | return; |
| 199 | } |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 200 | |
Ramkumar Radhakrishnan | d8595ae | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 201 | Locker::Autolock _l(ctx->mDrawLock); |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 202 | |
| 203 | /* Handle timeout event only if the previous composition |
| 204 | on any display is MDP or MIXED*/ |
| 205 | for(int i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) { |
| 206 | if(ctx->mMDPComp[i]) |
| 207 | handleTimeout = |
| 208 | ctx->mMDPComp[i]->isMDPComp() || handleTimeout; |
| 209 | } |
| 210 | |
| 211 | if(!handleTimeout) { |
Ramkumar Radhakrishnan | d8595ae | 2014-02-06 21:31:29 -0800 | [diff] [blame] | 212 | ALOGD_IF(isDebug(), "%s:Do not handle this timeout", __FUNCTION__); |
| 213 | return; |
| 214 | } |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 215 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 216 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 217 | return; |
| 218 | } |
| 219 | sIdleFallBack = true; |
| 220 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 221 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 224 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 225 | hwc_display_contents_1_t* list) { |
| 226 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 227 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 228 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 229 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 230 | if(!mCurrentFrame.isFBComposed[index]) { |
| 231 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 232 | layer->compositionType = HWC_OVERLAY; |
| 233 | layer->hints |= HWC_HINT_CLEAR_FB; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 234 | } else { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 235 | /* Drop the layer when its already present in FB OR when it lies |
| 236 | * outside frame's ROI */ |
| 237 | if(!mCurrentFrame.needsRedraw || mCurrentFrame.drop[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 238 | layer->compositionType = HWC_OVERLAY; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 239 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 240 | } |
| 241 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 242 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 243 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 244 | void MDPComp::setRedraw(hwc_context_t *ctx, |
| 245 | hwc_display_contents_1_t* list) { |
| 246 | mCurrentFrame.needsRedraw = false; |
| 247 | if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || |
| 248 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 249 | isSkipPresent(ctx, mDpy)) { |
| 250 | mCurrentFrame.needsRedraw = true; |
| 251 | } |
| 252 | } |
| 253 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 254 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | 8d09ba3 | 2014-08-14 10:11:36 -0700 | [diff] [blame] | 255 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 256 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 257 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 258 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 259 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
Saurabh Shah | 8d09ba3 | 2014-08-14 10:11:36 -0700 | [diff] [blame] | 260 | for(int i = 0; i < MAX_PIPES_PER_MIXER; i++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 261 | if(mdpToLayer[i].pipeInfo) { |
| 262 | delete mdpToLayer[i].pipeInfo; |
| 263 | mdpToLayer[i].pipeInfo = NULL; |
| 264 | //We dont own the rotator |
| 265 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 266 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 267 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 268 | |
| 269 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 270 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 271 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 272 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 273 | layerCount = numLayers; |
| 274 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 275 | mdpCount = 0; |
Saurabh Shah | 2f3895f | 2013-05-02 10:13:31 -0700 | [diff] [blame] | 276 | needsRedraw = true; |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 277 | fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 280 | void MDPComp::FrameInfo::map() { |
| 281 | // populate layer and MDP maps |
| 282 | int mdpIdx = 0; |
| 283 | for(int idx = 0; idx < layerCount; idx++) { |
| 284 | if(!isFBComposed[idx]) { |
| 285 | mdpToLayer[mdpIdx].listIndex = idx; |
| 286 | layerToMDP[idx] = mdpIdx++; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 291 | MDPComp::LayerCache::LayerCache() { |
| 292 | reset(); |
| 293 | } |
| 294 | |
| 295 | void MDPComp::LayerCache::reset() { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 296 | memset(&isFBComposed, true, sizeof(isFBComposed)); |
| 297 | memset(&drop, false, sizeof(drop)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 298 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 301 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 302 | layerCount = curFrame.layerCount; |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 303 | memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed)); |
| 304 | memcpy(&drop, &curFrame.drop, sizeof(drop)); |
| 305 | } |
| 306 | |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 307 | bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame, |
| 308 | hwc_display_contents_1_t* list) { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 309 | if(layerCount != curFrame.layerCount) |
| 310 | return false; |
| 311 | for(int i = 0; i < curFrame.layerCount; i++) { |
| 312 | if((curFrame.isFBComposed[i] != isFBComposed[i]) || |
| 313 | (curFrame.drop[i] != drop[i])) { |
| 314 | return false; |
| 315 | } |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 316 | hwc_layer_1_t const* layer = &list->hwLayers[i]; |
| 317 | if(curFrame.isFBComposed[i] && layerUpdating(layer)) { |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 318 | return false; |
| 319 | } |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 320 | } |
| 321 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 324 | bool MDPComp::LayerCache::isSameFrame(hwc_context_t *ctx, int dpy, |
| 325 | hwc_display_contents_1_t* list) { |
| 326 | |
| 327 | if(layerCount != ctx->listStats[dpy].numAppLayers) |
| 328 | return false; |
| 329 | |
| 330 | if((list->flags & HWC_GEOMETRY_CHANGED) || |
| 331 | isSkipPresent(ctx, dpy)) { |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | for(int i = 0; i < layerCount; i++) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 336 | hwc_layer_1_t const* layer = &list->hwLayers[i]; |
| 337 | if(layerUpdating(layer)) |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 338 | return false; |
| 339 | } |
| 340 | |
| 341 | return true; |
| 342 | } |
| 343 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 344 | bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { |
| 345 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 346 | if((not isYuvBuffer(hnd) and has90Transform(layer)) or |
Raj Kamal | 81cab69 | 2014-10-28 15:31:35 +0530 | [diff] [blame] | 347 | (not isValidDimension(ctx,layer)) || |
| 348 | isSkipLayer(layer)) { |
| 349 | //More conditions here, sRGB+Blend etc |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 350 | return false; |
| 351 | } |
| 352 | return true; |
| 353 | } |
| 354 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 355 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 356 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 357 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 358 | |
| 359 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 360 | if (layer->flags & HWC_COLOR_FILL) { |
| 361 | // Color layer |
| 362 | return true; |
| 363 | } |
Steve Kondik | c44491f | 2015-04-14 23:31:16 -0700 | [diff] [blame] | 364 | ALOGD_IF(isDebug(), "%s: layer handle is NULL", __FUNCTION__); |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 365 | return false; |
| 366 | } |
| 367 | |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 368 | //XXX: Investigate doing this with pixel phase on MDSS |
Naseer Ahmed | e77f808 | 2013-10-10 13:42:48 -0400 | [diff] [blame] | 369 | if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 370 | return false; |
| 371 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 372 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 373 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 374 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 375 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 376 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 377 | int crop_w = crop.right - crop.left; |
| 378 | int crop_h = crop.bottom - crop.top; |
| 379 | int dst_w = dst.right - dst.left; |
| 380 | int dst_h = dst.bottom - dst.top; |
| 381 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 382 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 383 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 384 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 385 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 386 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 387 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 388 | * Fallback to GPU if height is less than 2. |
| 389 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 390 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 391 | return false; |
| 392 | |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 393 | if((w_dscale > 1.0f) || (h_dscale > 1.0f)) { |
| 394 | const uint32_t downscale = |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 395 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 396 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 397 | /* Workaround for downscales larger than 4x. |
| 398 | * Will be removed once decimator block is enabled for MDSS |
| 399 | */ |
| 400 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 401 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 402 | h_dscale > downscale) |
| 403 | return false; |
| 404 | } else { |
| 405 | if(w_dscale > 64 || h_dscale > 64) |
| 406 | return false; |
| 407 | } |
| 408 | } else { //A-family |
| 409 | if(w_dscale > downscale || h_dscale > downscale) |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 410 | return false; |
| 411 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 414 | return true; |
| 415 | } |
| 416 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 417 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 418 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 419 | overlay::Overlay& ov = *ctx->mOverlay; |
| 420 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 421 | |
| 422 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 423 | case MDPCOMP_OV_DMA: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 424 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer, |
| 425 | Overlay::FORMAT_RGB); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 426 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 427 | return mdp_pipe; |
| 428 | } |
| 429 | case MDPCOMP_OV_ANY: |
| 430 | case MDPCOMP_OV_RGB: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 431 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer, |
| 432 | Overlay::FORMAT_RGB); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 433 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 434 | return mdp_pipe; |
| 435 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 436 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 437 | if(type == MDPCOMP_OV_RGB) { |
| 438 | //Requested only for RGB pipe |
| 439 | break; |
| 440 | } |
| 441 | case MDPCOMP_OV_VG: |
Baldev Sahu | 5cbb546 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 442 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer, |
| 443 | Overlay::FORMAT_YUV); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 444 | default: |
| 445 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 446 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 447 | }; |
| 448 | return ovutils::OV_INVALID; |
| 449 | } |
| 450 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 451 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 452 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 453 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 454 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 455 | if(!isEnabled()) { |
| 456 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 457 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 458 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Tatenda Chipeperekwa | 75a4181 | 2014-04-01 12:54:13 -0700 | [diff] [blame] | 459 | ctx->mVideoTransFlag && |
| 460 | isSecondaryConnected(ctx)) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 461 | //1 Padding round to shift pipes across mixers |
| 462 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 463 | __FUNCTION__); |
| 464 | ret = false; |
Raj Kamal | 2a18d6d | 2015-03-17 20:53:14 +0530 | [diff] [blame] | 465 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
| 466 | !mDpy && isSecondaryAnimating(ctx) && |
| 467 | (isYuvPresent(ctx,HWC_DISPLAY_EXTERNAL) || |
| 468 | isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL))) { |
| 469 | ALOGD_IF(isDebug(),"%s: Display animation in progress", |
| 470 | __FUNCTION__); |
| 471 | ret = false; |
Ramkumar Radhakrishnan | 0f95261 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 472 | } else if(isSecondaryConfiguring(ctx)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 473 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 474 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 475 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 476 | } else if(ctx->isPaddingRound) { |
Raj Kamal | fc5b922 | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 477 | ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d", |
| 478 | __FUNCTION__,mDpy); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 479 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 480 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 481 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 482 | } |
| 483 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 484 | /* |
| 485 | * 1) Identify layers that are not visible in the updating ROI and drop them |
| 486 | * from composition. |
| 487 | * 2) If we have a scaling layers which needs cropping against generated ROI. |
| 488 | * Reset ROI to full resolution. |
| 489 | */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 490 | bool MDPComp::validateAndApplyROI(hwc_context_t *ctx, |
| 491 | hwc_display_contents_1_t* list, hwc_rect_t roi) { |
| 492 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 493 | |
| 494 | if(!isValidRect(roi)) |
| 495 | return false; |
| 496 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 497 | hwc_rect_t visibleRect = roi; |
| 498 | |
| 499 | for(int i = numAppLayers - 1; i >= 0; i--){ |
| 500 | |
| 501 | if(!isValidRect(visibleRect)) { |
| 502 | mCurrentFrame.drop[i] = true; |
| 503 | mCurrentFrame.dropCount++; |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 504 | continue; |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 505 | } |
| 506 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 507 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 508 | |
| 509 | hwc_rect_t dstRect = layer->displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 510 | hwc_rect_t srcRect = integerizeSourceCrop(layer->sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 511 | int transform = layer->transform; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 512 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 513 | hwc_rect_t res = getIntersection(visibleRect, dstRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 514 | |
| 515 | int res_w = res.right - res.left; |
| 516 | int res_h = res.bottom - res.top; |
| 517 | int dst_w = dstRect.right - dstRect.left; |
| 518 | int dst_h = dstRect.bottom - dstRect.top; |
| 519 | |
| 520 | if(!isValidRect(res)) { |
| 521 | mCurrentFrame.drop[i] = true; |
| 522 | mCurrentFrame.dropCount++; |
| 523 | }else { |
| 524 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 525 | * cropping */ |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 526 | if((res_w != dst_w || res_h != dst_h) && needsScaling (layer)) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 527 | ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 528 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 529 | mCurrentFrame.dropCount = 0; |
| 530 | return false; |
| 531 | } |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 532 | |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 533 | /* deduct any opaque region from visibleRect */ |
radhakrishna | 3185893 | 2014-11-03 13:19:27 +0530 | [diff] [blame] | 534 | if (layer->blending == HWC_BLENDING_NONE && |
| 535 | layer->planeAlpha == 0xFF) |
Jeykumar Sankaran | 65bc802 | 2014-01-21 17:26:12 -0800 | [diff] [blame] | 536 | visibleRect = deductRect(visibleRect, res); |
| 537 | } |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 538 | } |
| 539 | return true; |
| 540 | } |
| 541 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 542 | bool MDPComp::canDoPartialUpdate(hwc_context_t *ctx, |
| 543 | hwc_display_contents_1_t* list){ |
| 544 | if(!qdutils::MDPVersion::getInstance().isPartialUpdateEnabled() || mDpy || |
| 545 | isSkipPresent(ctx, mDpy) || (list->flags & HWC_GEOMETRY_CHANGED)|| |
| 546 | isDisplaySplit(ctx, mDpy)) { |
| 547 | return false; |
| 548 | } |
Jeykumar Sankaran | b582a0e | 2014-07-02 12:23:09 -0700 | [diff] [blame] | 549 | |
| 550 | if(ctx->listStats[mDpy].secureUI) |
| 551 | return false; |
| 552 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 553 | return true; |
| 554 | } |
| 555 | |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 556 | /* Calculate ROI for the frame by accounting all the layer's dispalyFrame which |
| 557 | * are updating. If DirtyRegion is applicable, calculate it by accounting all |
| 558 | * the changing layer's dirtyRegion. */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 559 | void MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 560 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 561 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 562 | if(!canDoPartialUpdate(ctx, list)) |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 563 | return; |
| 564 | |
| 565 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 566 | hwc_rect fullFrame = (struct hwc_rect) {0, 0,(int)ctx->dpyAttr[mDpy].xres, |
| 567 | (int)ctx->dpyAttr[mDpy].yres}; |
| 568 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 569 | for(int index = 0; index < numAppLayers; index++ ) { |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 570 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 571 | if (layerUpdating(layer) || |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 572 | isYuvBuffer((private_handle_t *)layer->handle)) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 573 | hwc_rect_t updatingRect = layer->displayFrame; |
| 574 | if(!needsScaling(layer) && !layer->transform && |
| 575 | (!isYuvBuffer((private_handle_t *)layer->handle))) |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 576 | { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 577 | updatingRect = calculateDirtyRect(layer, fullFrame); |
Jeykumar Sankaran | 7889342 | 2014-05-07 16:23:14 -0700 | [diff] [blame] | 578 | } |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 579 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 580 | roi = getUnion(roi, updatingRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | |
Jeykumar Sankaran | 4d76a38 | 2014-02-26 18:26:58 -0800 | [diff] [blame] | 584 | // Align ROI coordinates to panel restrictions |
| 585 | roi = sanitizeROI(roi, fullFrame); |
| 586 | |
| 587 | if(!validateAndApplyROI(ctx, list, roi)) |
| 588 | roi = fullFrame; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 589 | |
| 590 | ctx->listStats[mDpy].roi.x = roi.left; |
| 591 | ctx->listStats[mDpy].roi.y = roi.top; |
| 592 | ctx->listStats[mDpy].roi.w = roi.right - roi.left; |
| 593 | ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; |
| 594 | |
| 595 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 596 | roi.left, roi.top, roi.right, roi.bottom); |
| 597 | } |
| 598 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 599 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 600 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 601 | bool MDPComp::tryFullFrame(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 602 | hwc_display_contents_1_t* list){ |
| 603 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 604 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 605 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 606 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 607 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 608 | return false; |
| 609 | } |
| 610 | |
Raj Kamal | 2a18d6d | 2015-03-17 20:53:14 +0530 | [diff] [blame] | 611 | if(!mDpy && isSecondaryAnimating(ctx) && |
| 612 | (isYuvPresent(ctx,HWC_DISPLAY_EXTERNAL) || |
| 613 | isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL)) ) { |
| 614 | ALOGD_IF(isDebug(),"%s: Display animation in progress", |
| 615 | __FUNCTION__); |
| 616 | return false; |
| 617 | } |
| 618 | |
Ramkumar Radhakrishnan | 4af1ef0 | 2013-12-12 11:53:08 -0800 | [diff] [blame] | 619 | // check for action safe flag and downscale mode which requires scaling. |
| 620 | if(ctx->dpyAttr[mDpy].mActionSafePresent |
| 621 | || ctx->dpyAttr[mDpy].mDownScaleMode) { |
| 622 | ALOGD_IF(isDebug(), "%s: Scaling needed for this frame",__FUNCTION__); |
| 623 | return false; |
| 624 | } |
| 625 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 626 | for(int i = 0; i < numAppLayers; ++i) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 627 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 628 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 629 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 630 | if(isYuvBuffer(hnd) && has90Transform(layer)) { |
| 631 | if(!canUseRotator(ctx, mDpy)) { |
| 632 | ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", |
| 633 | __FUNCTION__, mDpy); |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 634 | return false; |
| 635 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 636 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 637 | |
| 638 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 639 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
Sushil Chauhan | d8ef93f | 2014-03-20 11:08:41 -0700 | [diff] [blame] | 640 | int transform = (layer->flags & HWC_COLOR_FILL) ? 0 : layer->transform; |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 641 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 642 | (ctx->dpyAttr[mDpy].xres > 1024) && |
Sushil Chauhan | d8ef93f | 2014-03-20 11:08:41 -0700 | [diff] [blame] | 643 | (transform & HWC_TRANSFORM_FLIP_H) && |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 644 | (!isYuvBuffer(hnd))) |
| 645 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 646 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 647 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 648 | if(ctx->mAD->isDoable()) { |
| 649 | return false; |
| 650 | } |
| 651 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 652 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 653 | bool ret = false; |
| 654 | if(fullMDPComp(ctx, list)) { |
| 655 | ret = true; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 656 | } else if(fullMDPCompWithPTOR(ctx, list)) { |
| 657 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 658 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 659 | ret = true; |
| 660 | } |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 661 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 662 | return ret; |
| 663 | } |
| 664 | |
| 665 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 666 | //Will benefit presentation / secondary-only layer. |
| 667 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 668 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 669 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 670 | return false; |
| 671 | } |
| 672 | |
| 673 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 674 | for(int i = 0; i < numAppLayers; i++) { |
| 675 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 676 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 677 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 678 | return false; |
| 679 | } |
| 680 | } |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 681 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 682 | mCurrentFrame.fbCount = 0; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 683 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 684 | sizeof(mCurrentFrame.isFBComposed)); |
| 685 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 686 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 687 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 688 | if(sEnable4k2kYUVSplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 689 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 690 | } |
| 691 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 692 | if(!postHeuristicsHandling(ctx, list)) { |
| 693 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 694 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 695 | return false; |
| 696 | } |
| 697 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 698 | return true; |
| 699 | } |
| 700 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 701 | /* Full MDP Composition with Peripheral Tiny Overlap Removal. |
| 702 | * MDP bandwidth limitations can be avoided, if the overlap region |
| 703 | * covered by the smallest layer at a higher z-order, gets composed |
| 704 | * by Copybit on a render buffer, which can be queued to MDP. |
| 705 | */ |
| 706 | bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, |
| 707 | hwc_display_contents_1_t* list) { |
| 708 | |
| 709 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 710 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 711 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
| 712 | |
| 713 | // Hard checks where we cannot use this mode |
Justin Philip | b1906f7 | 2014-10-30 14:14:19 +0530 | [diff] [blame] | 714 | if (mDpy || !ctx->mCopyBit[mDpy] || !ctx->mIsPTOREnabled) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 715 | ALOGD_IF(isDebug(), "%s: Feature not supported!", __FUNCTION__); |
| 716 | return false; |
| 717 | } |
| 718 | |
| 719 | // Frame level checks |
| 720 | if ((numAppLayers > stagesForMDP) || isSkipPresent(ctx, mDpy) || |
| 721 | isYuvPresent(ctx, mDpy) || mCurrentFrame.dropCount || |
| 722 | isSecurePresent(ctx, mDpy)) { |
| 723 | ALOGD_IF(isDebug(), "%s: Frame not supported!", __FUNCTION__); |
| 724 | return false; |
| 725 | } |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 726 | // MDP comp checks |
| 727 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 728 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 729 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 730 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 731 | return false; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 732 | } |
| 733 | } |
| 734 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 735 | /* We cannot use this composition mode, if: |
| 736 | 1. A below layer needs scaling. |
| 737 | 2. Overlap is not peripheral to display. |
| 738 | 3. Overlap or a below layer has 90 degree transform. |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 739 | 4. Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 740 | */ |
| 741 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 742 | int minLayerIndex[MAX_PTOR_LAYERS] = { -1, -1}; |
| 743 | hwc_rect_t overlapRect[MAX_PTOR_LAYERS]; |
| 744 | memset(overlapRect, 0, sizeof(overlapRect)); |
| 745 | int layerPixelCount, minPixelCount = 0; |
| 746 | int numPTORLayersFound = 0; |
| 747 | for (int i = numAppLayers-1; (i >= 0 && |
| 748 | numPTORLayersFound < MAX_PTOR_LAYERS); i--) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 749 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 750 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 751 | hwc_rect_t dispFrame = layer->displayFrame; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 752 | layerPixelCount = (crop.right - crop.left) * (crop.bottom - crop.top); |
| 753 | // PTOR layer should be peripheral and cannot have transform |
| 754 | if (!isPeripheral(dispFrame, ctx->mViewFrame[mDpy]) || |
| 755 | has90Transform(layer)) { |
| 756 | continue; |
| 757 | } |
| 758 | if((3 * (layerPixelCount + minPixelCount)) > |
| 759 | ((int)ctx->dpyAttr[mDpy].xres * (int)ctx->dpyAttr[mDpy].yres)) { |
| 760 | // Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. |
| 761 | continue; |
| 762 | } |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 763 | bool found = false; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 764 | for (int j = i-1; j >= 0; j--) { |
| 765 | // Check if the layers below this layer qualifies for PTOR comp |
| 766 | hwc_layer_1_t* layer = &list->hwLayers[j]; |
| 767 | hwc_rect_t disFrame = layer->displayFrame; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 768 | // Layer below PTOR is intersecting and has 90 degree transform or |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 769 | // needs scaling cannot be supported. |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 770 | if (isValidRect(getIntersection(dispFrame, disFrame))) { |
| 771 | if (has90Transform(layer) || needsScaling(layer)) { |
| 772 | found = false; |
| 773 | break; |
| 774 | } |
| 775 | found = true; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 776 | } |
| 777 | } |
| 778 | // Store the minLayer Index |
| 779 | if(found) { |
| 780 | minLayerIndex[numPTORLayersFound] = i; |
| 781 | overlapRect[numPTORLayersFound] = list->hwLayers[i].displayFrame; |
| 782 | minPixelCount += layerPixelCount; |
| 783 | numPTORLayersFound++; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 784 | } |
| 785 | } |
| 786 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 787 | // No overlap layers |
| 788 | if (!numPTORLayersFound) |
| 789 | return false; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 790 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 791 | // Store the displayFrame and the sourceCrops of the layers |
| 792 | hwc_rect_t displayFrame[numAppLayers]; |
| 793 | hwc_rect_t sourceCrop[numAppLayers]; |
| 794 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 795 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 796 | displayFrame[i] = layer->displayFrame; |
| 797 | sourceCrop[i] = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 798 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 799 | |
Prabhanjan Kandula | bb1f6be | 2014-09-04 21:50:35 +0530 | [diff] [blame] | 800 | /** |
| 801 | * It's possible that 2 PTOR layers might have overlapping. |
| 802 | * In such case, remove the intersection(again if peripheral) |
| 803 | * from the lower PTOR layer to avoid overlapping. |
| 804 | * If intersection is not on peripheral then compromise |
| 805 | * by reducing number of PTOR layers. |
| 806 | **/ |
| 807 | hwc_rect_t commonRect = getIntersection(overlapRect[0], overlapRect[1]); |
| 808 | if(isValidRect(commonRect)) { |
| 809 | overlapRect[1] = deductRect(overlapRect[1], commonRect); |
| 810 | list->hwLayers[minLayerIndex[1]].displayFrame = overlapRect[1]; |
| 811 | } |
| 812 | |
| 813 | ctx->mPtorInfo.count = numPTORLayersFound; |
| 814 | for(int i = 0; i < MAX_PTOR_LAYERS; i++) { |
| 815 | ctx->mPtorInfo.layerIndex[i] = minLayerIndex[i]; |
| 816 | } |
| 817 | |
| 818 | if (!ctx->mCopyBit[mDpy]->prepareOverlap(ctx, list)) { |
| 819 | // reset PTOR |
| 820 | ctx->mPtorInfo.count = 0; |
| 821 | if(isValidRect(commonRect)) { |
| 822 | // If PTORs are intersecting restore displayframe of PTOR[1] |
| 823 | // before returning, as we have modified it above. |
| 824 | list->hwLayers[minLayerIndex[1]].displayFrame = |
| 825 | displayFrame[minLayerIndex[1]]; |
| 826 | } |
| 827 | return false; |
| 828 | } |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 829 | private_handle_t *renderBuf = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 830 | Vector<Whf> layerWhf; // To store w,h,f of PTOR layers |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 831 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 832 | // Store the blending mode, planeAlpha, and transform of PTOR layers |
| 833 | int32_t blending[numPTORLayersFound]; |
| 834 | uint8_t planeAlpha[numPTORLayersFound]; |
| 835 | uint32_t transform[numPTORLayersFound]; |
| 836 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 837 | for(int j = 0; j < numPTORLayersFound; j++) { |
| 838 | int index = ctx->mPtorInfo.layerIndex[j]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 839 | |
| 840 | // Update src crop of PTOR layer |
| 841 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 842 | layer->sourceCropf.left = (float)ctx->mPtorInfo.displayFrame[j].left; |
| 843 | layer->sourceCropf.top = (float)ctx->mPtorInfo.displayFrame[j].top; |
| 844 | layer->sourceCropf.right = (float)ctx->mPtorInfo.displayFrame[j].right; |
| 845 | layer->sourceCropf.bottom =(float)ctx->mPtorInfo.displayFrame[j].bottom; |
| 846 | |
| 847 | // Store & update w, h, format of PTOR layer |
| 848 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 849 | Whf whf(hnd->width, hnd->height, hnd->format, hnd->size); |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 850 | layerWhf.insertAt(whf, j); |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 851 | hnd->width = renderBuf->width; |
| 852 | hnd->height = renderBuf->height; |
| 853 | hnd->format = renderBuf->format; |
| 854 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 855 | // Store & update blending mode, planeAlpha and transform of PTOR layer |
| 856 | blending[j] = layer->blending; |
| 857 | planeAlpha[j] = layer->planeAlpha; |
| 858 | transform[j] = layer->transform; |
| 859 | layer->blending = HWC_BLENDING_NONE; |
| 860 | layer->planeAlpha = 0xFF; |
| 861 | layer->transform = 0; |
| 862 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 863 | // Remove overlap from crop & displayFrame of below layers |
| 864 | for (int i = 0; i < index && index !=-1; i++) { |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 865 | layer = &list->hwLayers[i]; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 866 | if(!isValidRect(getIntersection(layer->displayFrame, |
| 867 | overlapRect[j]))) { |
| 868 | continue; |
| 869 | } |
| 870 | // Update layer attributes |
| 871 | hwc_rect_t srcCrop = integerizeSourceCrop(layer->sourceCropf); |
| 872 | hwc_rect_t destRect = deductRect(layer->displayFrame, |
Dileep Kumar Reddi | cc32af0 | 2014-11-11 16:03:03 +0530 | [diff] [blame] | 873 | getIntersection(layer->displayFrame, overlapRect[j])); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 874 | qhwc::calculate_crop_rects(srcCrop, layer->displayFrame, destRect, |
| 875 | layer->transform); |
| 876 | layer->sourceCropf.left = (float)srcCrop.left; |
| 877 | layer->sourceCropf.top = (float)srcCrop.top; |
| 878 | layer->sourceCropf.right = (float)srcCrop.right; |
| 879 | layer->sourceCropf.bottom = (float)srcCrop.bottom; |
| 880 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | mCurrentFrame.mdpCount = numAppLayers; |
| 884 | mCurrentFrame.fbCount = 0; |
| 885 | mCurrentFrame.fbZ = -1; |
| 886 | |
Dileep Kumar Reddi | cc32af0 | 2014-11-11 16:03:03 +0530 | [diff] [blame] | 887 | for (int j = 0; j < numAppLayers; j++) { |
| 888 | if(isValidRect(list->hwLayers[j].displayFrame)) { |
| 889 | mCurrentFrame.isFBComposed[j] = false; |
| 890 | } else { |
| 891 | mCurrentFrame.mdpCount--; |
| 892 | mCurrentFrame.drop[j] = true; |
| 893 | } |
| 894 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 895 | |
| 896 | bool result = postHeuristicsHandling(ctx, list); |
| 897 | |
| 898 | // Restore layer attributes |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 899 | for(int i = 0; i < numAppLayers; i++) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 900 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 901 | layer->displayFrame = displayFrame[i]; |
| 902 | layer->sourceCropf.left = (float)sourceCrop[i].left; |
| 903 | layer->sourceCropf.top = (float)sourceCrop[i].top; |
| 904 | layer->sourceCropf.right = (float)sourceCrop[i].right; |
| 905 | layer->sourceCropf.bottom = (float)sourceCrop[i].bottom; |
| 906 | } |
| 907 | |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 908 | // Restore w,h,f, blending attributes, and transform of PTOR layers |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 909 | for (int i = 0; i < numPTORLayersFound; i++) { |
| 910 | int idx = ctx->mPtorInfo.layerIndex[i]; |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 911 | hwc_layer_1_t* layer = &list->hwLayers[idx]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 912 | private_handle_t *hnd = (private_handle_t *)list->hwLayers[idx].handle; |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 913 | Whf whf = layerWhf.itemAt(i); |
| 914 | hnd->width = whf.w; |
| 915 | hnd->height = whf.h; |
| 916 | hnd->format = whf.format; |
Xu Yang | 645cb1f | 2014-07-30 21:57:21 +0800 | [diff] [blame] | 917 | layer->blending = blending[i]; |
| 918 | layer->planeAlpha = planeAlpha[i]; |
| 919 | layer->transform = transform[i]; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 922 | if (!result) { |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 923 | // reset PTOR |
| 924 | ctx->mPtorInfo.count = 0; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 925 | reset(ctx); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 926 | } else { |
| 927 | ALOGD_IF(isDebug(), "%s: PTOR Indexes: %d and %d", __FUNCTION__, |
| 928 | ctx->mPtorInfo.layerIndex[0], ctx->mPtorInfo.layerIndex[1]); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 931 | ALOGD_IF(isDebug(), "%s: Postheuristics %s!", __FUNCTION__, |
| 932 | (result ? "successful" : "failed")); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 933 | return result; |
| 934 | } |
| 935 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 936 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 937 | { |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 938 | if(!sEnableMixedMode) { |
| 939 | //Mixed mode is disabled. No need to even try caching. |
| 940 | return false; |
| 941 | } |
| 942 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 943 | bool ret = false; |
Raj Kamal | 81cab69 | 2014-10-28 15:31:35 +0530 | [diff] [blame] | 944 | if(isSkipPresent(ctx, mDpy) or list->flags & HWC_GEOMETRY_CHANGED) { |
| 945 | //Try load based first |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 946 | ret = loadBasedComp(ctx, list) or |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 947 | cacheBasedComp(ctx, list); |
| 948 | } else { |
| 949 | ret = cacheBasedComp(ctx, list) or |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 950 | loadBasedComp(ctx, list); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 951 | } |
| 952 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 953 | return ret; |
| 954 | } |
| 955 | |
| 956 | bool MDPComp::cacheBasedComp(hwc_context_t *ctx, |
| 957 | hwc_display_contents_1_t* list) { |
| 958 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 959 | mCurrentFrame.reset(numAppLayers); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 960 | updateLayerCache(ctx, list, mCurrentFrame); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 961 | |
| 962 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 963 | for(int i = 0; i < numAppLayers; i++) { |
| 964 | if(!mCurrentFrame.isFBComposed[i]) { |
| 965 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 966 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 967 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 968 | __FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 969 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 970 | return false; |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 975 | updateYUV(ctx, list, false /*secure only*/, mCurrentFrame); |
| 976 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 977 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 978 | if(!ret) { |
| 979 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 980 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 981 | return false; |
| 982 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 983 | |
| 984 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 985 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 986 | if(sEnable4k2kYUVSplit){ |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 987 | adjustForSourceSplit(ctx, list); |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 988 | } |
| 989 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 990 | //Will benefit cases where a video has non-updating background. |
| 991 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 992 | (mdpCount > MAX_SEC_LAYERS)) { |
| 993 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 994 | reset(ctx); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 995 | return false; |
| 996 | } |
| 997 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 998 | if(!postHeuristicsHandling(ctx, list)) { |
| 999 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
| 1000 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1001 | return false; |
| 1002 | } |
| 1003 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1004 | return true; |
| 1005 | } |
| 1006 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1007 | bool MDPComp::loadBasedComp(hwc_context_t *ctx, |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1008 | hwc_display_contents_1_t* list) { |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1009 | if(not isLoadBasedCompDoable(ctx, list)) { |
| 1010 | return false; |
| 1011 | } |
| 1012 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1013 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1014 | const int numNonDroppedLayers = numAppLayers - mCurrentFrame.dropCount; |
| 1015 | const int stagesForMDP = min(sMaxPipesPerMixer, |
| 1016 | ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); |
Saurabh Shah | f2de00f | 2013-12-11 17:52:53 -0800 | [diff] [blame] | 1017 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1018 | int mdpBatchSize = stagesForMDP - 1; //1 stage for FB |
| 1019 | int fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
| 1020 | int lastMDPSupportedIndex = numAppLayers; |
| 1021 | int dropCount = 0; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1022 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1023 | //Find the minimum MDP batch size |
| 1024 | for(int i = 0; i < numAppLayers;i++) { |
| 1025 | if(mCurrentFrame.drop[i]) { |
| 1026 | dropCount++; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1027 | continue; |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1028 | } |
| 1029 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1030 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1031 | lastMDPSupportedIndex = i; |
| 1032 | mdpBatchSize = min(i - dropCount, stagesForMDP - 1); |
| 1033 | fbBatchSize = numNonDroppedLayers - mdpBatchSize; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1034 | break; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1035 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1036 | } |
| 1037 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1038 | ALOGD_IF(isDebug(), "%s:Before optimizing fbBatch, mdpbatch %d, fbbatch %d " |
| 1039 | "dropped %d", __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1040 | mCurrentFrame.dropCount); |
| 1041 | |
| 1042 | //Start at a point where the fb batch should at least have 2 layers, for |
| 1043 | //this mode to be justified. |
| 1044 | while(fbBatchSize < 2) { |
| 1045 | ++fbBatchSize; |
| 1046 | --mdpBatchSize; |
Jeykumar Sankaran | 6279bc3 | 2014-01-23 21:59:58 -0800 | [diff] [blame] | 1047 | } |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1048 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1049 | //If there are no layers for MDP, this mode doesnt make sense. |
| 1050 | if(mdpBatchSize < 1) { |
| 1051 | ALOGD_IF(isDebug(), "%s: No MDP layers after optimizing for fbBatch", |
| 1052 | __FUNCTION__); |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1053 | return false; |
| 1054 | } |
| 1055 | |
Saurabh Shah | 6e8ab77 | 2014-02-20 16:18:45 -0800 | [diff] [blame] | 1056 | mCurrentFrame.reset(numAppLayers); |
| 1057 | |
| 1058 | //Try with successively smaller mdp batch sizes until we succeed or reach 1 |
| 1059 | while(mdpBatchSize > 0) { |
| 1060 | //Mark layers for MDP comp |
| 1061 | int mdpBatchLeft = mdpBatchSize; |
| 1062 | for(int i = 0; i < lastMDPSupportedIndex and mdpBatchLeft; i++) { |
| 1063 | if(mCurrentFrame.drop[i]) { |
| 1064 | continue; |
| 1065 | } |
| 1066 | mCurrentFrame.isFBComposed[i] = false; |
| 1067 | --mdpBatchLeft; |
| 1068 | } |
| 1069 | |
| 1070 | mCurrentFrame.fbZ = mdpBatchSize; |
| 1071 | mCurrentFrame.fbCount = fbBatchSize; |
| 1072 | mCurrentFrame.mdpCount = mdpBatchSize; |
| 1073 | |
| 1074 | ALOGD_IF(isDebug(), "%s:Trying with: mdpbatch %d fbbatch %d dropped %d", |
| 1075 | __FUNCTION__, mdpBatchSize, fbBatchSize, |
| 1076 | mCurrentFrame.dropCount); |
| 1077 | |
| 1078 | if(postHeuristicsHandling(ctx, list)) { |
| 1079 | ALOGD_IF(isDebug(), "%s: Postheuristics handling succeeded", |
| 1080 | __FUNCTION__); |
| 1081 | return true; |
| 1082 | } |
| 1083 | |
| 1084 | reset(ctx); |
| 1085 | --mdpBatchSize; |
| 1086 | ++fbBatchSize; |
| 1087 | } |
| 1088 | |
| 1089 | return false; |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 1090 | } |
| 1091 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1092 | bool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx, |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 1093 | hwc_display_contents_1_t* /*list*/) { |
Jeykumar Sankaran | faada4f | 2015-05-14 11:54:58 -0700 | [diff] [blame] | 1094 | if(mDpy or isSecurePresent(ctx, mDpy)) { |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 1095 | return false; |
| 1096 | } |
| 1097 | return true; |
| 1098 | } |
| 1099 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1100 | bool MDPComp::tryVideoOnly(hwc_context_t *ctx, |
| 1101 | hwc_display_contents_1_t* list) { |
| 1102 | const bool secureOnly = true; |
| 1103 | return videoOnlyComp(ctx, list, not secureOnly) or |
| 1104 | videoOnlyComp(ctx, list, secureOnly); |
| 1105 | } |
| 1106 | |
| 1107 | bool MDPComp::videoOnlyComp(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1108 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1109 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1110 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1111 | mCurrentFrame.reset(numAppLayers); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1112 | updateYUV(ctx, list, secureOnly, mCurrentFrame); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1113 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1114 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1115 | if(!isYuvPresent(ctx, mDpy) or (mdpCount == 0)) { |
| 1116 | reset(ctx); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1117 | return false; |
| 1118 | } |
| 1119 | |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1120 | /* Bail out if we are processing only secured video layers |
| 1121 | * and we dont have any */ |
| 1122 | if(!isSecurePresent(ctx, mDpy) && secureOnly){ |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1123 | reset(ctx); |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 1124 | return false; |
| 1125 | } |
| 1126 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1127 | if(mCurrentFrame.fbCount) |
| 1128 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1129 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1130 | if(sEnable4k2kYUVSplit){ |
| 1131 | adjustForSourceSplit(ctx, list); |
| 1132 | } |
| 1133 | |
| 1134 | if(!postHeuristicsHandling(ctx, list)) { |
| 1135 | ALOGD_IF(isDebug(), "post heuristic handling failed"); |
Justin Philip | c990732 | 2015-01-06 11:55:12 +0530 | [diff] [blame] | 1136 | if(errno == ENOBUFS) { |
| 1137 | ALOGD_IF(isDebug(), "SMP Allocation failed"); |
| 1138 | //On SMP allocation failure in video only comp add padding round |
| 1139 | ctx->isPaddingRound = true; |
| 1140 | } |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1141 | reset(ctx); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1142 | return false; |
| 1143 | } |
| 1144 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1145 | return true; |
| 1146 | } |
| 1147 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1148 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 1149 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1150 | if(isSkipLayer(layer)) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 1151 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1152 | return false; |
| 1153 | } |
| 1154 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 1155 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 1156 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 1157 | return false; |
| 1158 | } |
| 1159 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1160 | if(isSecuring(ctx, layer)) { |
| 1161 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 1162 | return false; |
| 1163 | } |
| 1164 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1165 | if(!isValidDimension(ctx, layer)) { |
| 1166 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 1167 | __FUNCTION__); |
| 1168 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1169 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 1170 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 1171 | if(layer->planeAlpha < 0xFF) { |
| 1172 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 1173 | in video only mode", |
| 1174 | __FUNCTION__); |
| 1175 | return false; |
| 1176 | } |
| 1177 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1178 | return true; |
| 1179 | } |
| 1180 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1181 | /* starts at fromIndex and check for each layer to find |
| 1182 | * if it it has overlapping with any Updating layer above it in zorder |
| 1183 | * till the end of the batch. returns true if it finds any intersection */ |
| 1184 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 1185 | int fromIndex, int toIndex) { |
| 1186 | for(int i = fromIndex; i < toIndex; i++) { |
| 1187 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 1188 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 1189 | return false; |
| 1190 | } |
| 1191 | } |
| 1192 | } |
| 1193 | return true; |
| 1194 | } |
| 1195 | |
| 1196 | /* Checks if given layer at targetLayerIndex has any |
| 1197 | * intersection with all the updating layers in beween |
| 1198 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 1199 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 1200 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 1201 | for(int i = fromIndex; i <= toIndex; i++) { |
| 1202 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1203 | if(areLayersIntersecting(&list->hwLayers[i], |
| 1204 | &list->hwLayers[targetLayerIndex])) { |
| 1205 | return true; |
| 1206 | } |
| 1207 | } |
| 1208 | } |
| 1209 | return false; |
| 1210 | } |
| 1211 | |
| 1212 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 1213 | int& maxBatchStart, int& maxBatchEnd, |
| 1214 | int& maxBatchCount) { |
| 1215 | int i = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1216 | int fbZOrder =-1; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1217 | int droppedLayerCt = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1218 | while (i < mCurrentFrame.layerCount) { |
| 1219 | int batchCount = 0; |
| 1220 | int batchStart = i; |
| 1221 | int batchEnd = i; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1222 | /* Adjust batch Z order with the dropped layers so far */ |
| 1223 | int fbZ = batchStart - droppedLayerCt; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1224 | int firstZReverseIndex = -1; |
Prabhanjan Kandula | 0ed2cc9 | 2013-12-06 12:39:04 +0530 | [diff] [blame] | 1225 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1226 | while(i < mCurrentFrame.layerCount) { |
| 1227 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1228 | if(!batchCount) { |
| 1229 | i++; |
| 1230 | break; |
| 1231 | } |
| 1232 | updatingLayersAbove++; |
| 1233 | i++; |
| 1234 | continue; |
| 1235 | } else { |
| 1236 | if(mCurrentFrame.drop[i]) { |
| 1237 | i++; |
Jeykumar Sankaran | 5a495da | 2014-01-20 12:25:32 -0800 | [diff] [blame] | 1238 | droppedLayerCt++; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1239 | continue; |
| 1240 | } else if(updatingLayersAbove <= 0) { |
| 1241 | batchCount++; |
| 1242 | batchEnd = i; |
| 1243 | i++; |
| 1244 | continue; |
| 1245 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 1246 | |
| 1247 | // We have a valid updating layer already. If layer-i not |
| 1248 | // have overlapping with all updating layers in between |
| 1249 | // batch-start and i, then we can add layer i to batch. |
| 1250 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 1251 | batchCount++; |
| 1252 | batchEnd = i; |
| 1253 | i++; |
| 1254 | continue; |
| 1255 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 1256 | //If All the non-updating layers with in this batch |
| 1257 | //does not have intersection with the updating layers |
| 1258 | //above in z-order, then we can safely move the batch to |
| 1259 | //higher z-order. Increment fbZ as it is moving up. |
| 1260 | if( firstZReverseIndex < 0) { |
| 1261 | firstZReverseIndex = i; |
| 1262 | } |
| 1263 | batchCount++; |
| 1264 | batchEnd = i; |
| 1265 | fbZ += updatingLayersAbove; |
| 1266 | i++; |
| 1267 | updatingLayersAbove = 0; |
| 1268 | continue; |
| 1269 | } else { |
| 1270 | //both failed.start the loop again from here. |
| 1271 | if(firstZReverseIndex >= 0) { |
| 1272 | i = firstZReverseIndex; |
| 1273 | } |
| 1274 | break; |
| 1275 | } |
| 1276 | } |
| 1277 | } |
| 1278 | } |
| 1279 | if(batchCount > maxBatchCount) { |
| 1280 | maxBatchCount = batchCount; |
| 1281 | maxBatchStart = batchStart; |
| 1282 | maxBatchEnd = batchEnd; |
| 1283 | fbZOrder = fbZ; |
| 1284 | } |
| 1285 | } |
| 1286 | return fbZOrder; |
| 1287 | } |
| 1288 | |
| 1289 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 1290 | hwc_display_contents_1_t* list) { |
| 1291 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 1292 | * send rest of them through MDP. This is done in 2 steps. |
| 1293 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 1294 | * 2. See if we can improve this batch size for caching by adding |
| 1295 | * opaque layers around the batch, if they don't have |
| 1296 | * any overlapping with the updating layers in between. |
| 1297 | * NEVER mark an updating layer for caching. |
| 1298 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1299 | |
| 1300 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1301 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1302 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1303 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1304 | |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1305 | /* Nothing is cached. No batching needed */ |
| 1306 | if(mCurrentFrame.fbCount == 0) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1307 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1308 | } |
Saurabh Shah | ce18845 | 2014-02-05 10:17:43 -0800 | [diff] [blame] | 1309 | |
| 1310 | /* No MDP comp layers, try to use other comp modes */ |
| 1311 | if(mCurrentFrame.mdpCount == 0) { |
| 1312 | return false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1313 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1314 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1315 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1316 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1317 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1318 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1319 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1320 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1321 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1322 | if(!mCurrentFrame.drop[i]){ |
| 1323 | //If an unsupported layer is being attempted to |
| 1324 | //be pulled out we should fail |
| 1325 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1326 | return false; |
| 1327 | } |
| 1328 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1329 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1330 | } |
| 1331 | } |
| 1332 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1333 | // update the frame data |
| 1334 | mCurrentFrame.fbZ = fbZ; |
| 1335 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1336 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1337 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1338 | |
| 1339 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1340 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1341 | |
| 1342 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1343 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1344 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1345 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1346 | hwc_display_contents_1_t* list, FrameInfo& frame) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1347 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1348 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1349 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1350 | for(int i = 0; i < numAppLayers; i++) { |
Arun Kumar K.R | dff18b8 | 2015-07-27 16:00:02 +0530 | [diff] [blame] | 1351 | hwc_layer_1_t * layer = &list->hwLayers[i]; |
| 1352 | if (!layerUpdating(layer)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1353 | if(!frame.drop[i]) |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1354 | fbCount++; |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1355 | frame.isFBComposed[i] = true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1356 | } else { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1357 | frame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1358 | } |
| 1359 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1360 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1361 | frame.fbCount = fbCount; |
| 1362 | frame.mdpCount = frame.layerCount - frame.fbCount |
| 1363 | - frame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1364 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1365 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d", |
| 1366 | __FUNCTION__, frame.mdpCount, frame.fbCount, frame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1367 | } |
| 1368 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1369 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1370 | bool secureOnly, FrameInfo& frame) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1371 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
| 1372 | for(int index = 0;index < nYuvCount; index++){ |
| 1373 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 1374 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 1375 | |
| 1376 | if(!isYUVDoable(ctx, layer)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1377 | if(!frame.isFBComposed[nYuvIndex]) { |
| 1378 | frame.isFBComposed[nYuvIndex] = true; |
| 1379 | frame.fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1380 | } |
| 1381 | } else { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1382 | if(frame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1383 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1384 | if(!secureOnly || isSecureBuffer(hnd)) { |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1385 | frame.isFBComposed[nYuvIndex] = false; |
| 1386 | frame.fbCount--; |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1387 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1388 | } |
| 1389 | } |
| 1390 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1391 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1392 | frame.mdpCount = frame.layerCount - frame.fbCount - frame.dropCount; |
| 1393 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, frame.fbCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1394 | } |
| 1395 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1396 | bool MDPComp::postHeuristicsHandling(hwc_context_t *ctx, |
| 1397 | hwc_display_contents_1_t* list) { |
| 1398 | |
| 1399 | //Capability checks |
| 1400 | if(!resourceCheck(ctx, list)) { |
| 1401 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
| 1402 | return false; |
| 1403 | } |
| 1404 | |
| 1405 | //Limitations checks |
| 1406 | if(!hwLimitationsCheck(ctx, list)) { |
| 1407 | ALOGD_IF(isDebug(), "%s: HW limitations",__FUNCTION__); |
| 1408 | return false; |
| 1409 | } |
| 1410 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1411 | //Configure framebuffer first if applicable |
| 1412 | if(mCurrentFrame.fbZ >= 0) { |
| 1413 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 1414 | ALOGD_IF(isDebug(), "%s configure framebuffer failed", |
| 1415 | __FUNCTION__); |
| 1416 | return false; |
| 1417 | } |
| 1418 | } |
| 1419 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1420 | mCurrentFrame.map(); |
| 1421 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1422 | if(!allocLayerPipes(ctx, list)) { |
| 1423 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1424 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1428 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1429 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1430 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1431 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1432 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1433 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 1434 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1435 | mdpNextZOrder++; |
| 1436 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1437 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1438 | cur_pipe->zOrder = mdpNextZOrder++; |
| 1439 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1440 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1441 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1442 | if(configure4k2kYuv(ctx, layer, |
| 1443 | mCurrentFrame.mdpToLayer[mdpIndex]) |
| 1444 | != 0 ){ |
| 1445 | ALOGD_IF(isDebug(), "%s: Failed to configure split pipes \ |
| 1446 | for layer %d",__FUNCTION__, index); |
| 1447 | return false; |
| 1448 | } |
| 1449 | else{ |
| 1450 | mdpNextZOrder++; |
| 1451 | } |
| 1452 | continue; |
| 1453 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1454 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1455 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1456 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1457 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1458 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1459 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1460 | } |
| 1461 | |
Saurabh Shah | 450ac97 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 1462 | if(!ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd)) { |
| 1463 | ALOGD_IF(isDebug(), "%s: Failed to validate and set overlay for dpy %d" |
| 1464 | ,__FUNCTION__, mDpy); |
| 1465 | return false; |
| 1466 | } |
| 1467 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1468 | setRedraw(ctx, list); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1469 | return true; |
| 1470 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1471 | |
Steve Kondik | 5164dda | 2015-11-01 02:51:41 -0800 | [diff] [blame] | 1472 | bool MDPComp::resourceCheck(hwc_context_t * /*ctx*/, |
| 1473 | hwc_display_contents_1_t * /*list*/) { |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1474 | const bool fbUsed = mCurrentFrame.fbCount; |
| 1475 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { |
| 1476 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 1477 | return false; |
| 1478 | } |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1479 | return true; |
| 1480 | } |
| 1481 | |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1482 | bool MDPComp::hwLimitationsCheck(hwc_context_t* ctx, |
| 1483 | hwc_display_contents_1_t* list) { |
| 1484 | |
| 1485 | //A-family hw limitation: |
| 1486 | //If a layer need alpha scaling, MDP can not support. |
| 1487 | if(ctx->mMDP.version < qdutils::MDSS_V5) { |
| 1488 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1489 | if(!mCurrentFrame.isFBComposed[i] && |
| 1490 | isAlphaScaled( &list->hwLayers[i])) { |
| 1491 | ALOGD_IF(isDebug(), "%s:frame needs alphaScaling",__FUNCTION__); |
| 1492 | return false; |
| 1493 | } |
| 1494 | } |
| 1495 | } |
| 1496 | |
| 1497 | // On 8x26 & 8974 hw, we have a limitation of downscaling+blending. |
| 1498 | //If multiple layers requires downscaling and also they are overlapping |
| 1499 | //fall back to GPU since MDSS can not handle it. |
| 1500 | if(qdutils::MDPVersion::getInstance().is8x74v2() || |
| 1501 | qdutils::MDPVersion::getInstance().is8x26()) { |
| 1502 | for(int i = 0; i < mCurrentFrame.layerCount-1; ++i) { |
| 1503 | hwc_layer_1_t* botLayer = &list->hwLayers[i]; |
| 1504 | if(!mCurrentFrame.isFBComposed[i] && |
| 1505 | isDownscaleRequired(botLayer)) { |
| 1506 | //if layer-i is marked for MDP and needs downscaling |
| 1507 | //check if any MDP layer on top of i & overlaps with layer-i |
| 1508 | for(int j = i+1; j < mCurrentFrame.layerCount; ++j) { |
| 1509 | hwc_layer_1_t* topLayer = &list->hwLayers[j]; |
| 1510 | if(!mCurrentFrame.isFBComposed[j] && |
| 1511 | isDownscaleRequired(topLayer)) { |
| 1512 | hwc_rect_t r = getIntersection(botLayer->displayFrame, |
| 1513 | topLayer->displayFrame); |
| 1514 | if(isValidRect(r)) |
| 1515 | return false; |
| 1516 | } |
| 1517 | } |
| 1518 | } |
| 1519 | } |
| 1520 | } |
| 1521 | return true; |
| 1522 | } |
| 1523 | |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1524 | void MDPComp::setDynRefreshRate(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1525 | //For primary display, set the dynamic refreshrate |
| 1526 | if(!mDpy && qdutils::MDPVersion::getInstance().isDynFpsSupported() && |
| 1527 | ctx->mUseMetaDataRefreshRate) { |
| 1528 | FrameInfo frame; |
| 1529 | frame.reset(mCurrentFrame.layerCount); |
| 1530 | memset(&frame.drop, 0, sizeof(frame.drop)); |
| 1531 | frame.dropCount = 0; |
| 1532 | ALOGD_IF(isDebug(), "%s: Update Cache and YUVInfo for Dyn Refresh Rate", |
| 1533 | __FUNCTION__); |
| 1534 | updateLayerCache(ctx, list, frame); |
| 1535 | updateYUV(ctx, list, false /*secure only*/, frame); |
| 1536 | uint32_t refreshRate = ctx->dpyAttr[mDpy].refreshRate; |
| 1537 | MDPVersion& mdpHw = MDPVersion::getInstance(); |
| 1538 | if(sIdleFallBack) { |
| 1539 | //Set minimum panel refresh rate during idle timeout |
| 1540 | refreshRate = mdpHw.getMinFpsSupported(); |
| 1541 | } else if((ctx->listStats[mDpy].yuvCount == frame.mdpCount) || |
| 1542 | (frame.layerCount == 1)) { |
| 1543 | //Set the new fresh rate, if there is only one updating YUV layer |
| 1544 | //or there is one single RGB layer with this request |
| 1545 | refreshRate = ctx->listStats[mDpy].refreshRateRequest; |
| 1546 | } |
| 1547 | setRefreshRate(ctx, mDpy, refreshRate); |
| 1548 | } |
| 1549 | } |
| 1550 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1551 | 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] | 1552 | int ret = 0; |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1553 | |
| 1554 | if(!ctx || !list) { |
| 1555 | ALOGE("%s: Invalid context or list",__FUNCTION__); |
| 1556 | mCachedFrame.reset(); |
| 1557 | return -1; |
| 1558 | } |
| 1559 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1560 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1561 | MDPVersion& mdpVersion = qdutils::MDPVersion::getInstance(); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1562 | |
| 1563 | // reset PTOR |
| 1564 | if(!mDpy) |
| 1565 | memset(&(ctx->mPtorInfo), 0, sizeof(ctx->mPtorInfo)); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1566 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1567 | //reset old data |
| 1568 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1569 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1570 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1571 | |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1572 | //Do not cache the information for next draw cycle. |
| 1573 | if(numLayers > MAX_NUM_APP_LAYERS or (!numLayers)) { |
| 1574 | ALOGI("%s: Unsupported layer count for mdp composition", |
| 1575 | __FUNCTION__); |
| 1576 | mCachedFrame.reset(); |
| 1577 | #ifdef DYNAMIC_FPS |
| 1578 | setDynRefreshRate(ctx, list); |
| 1579 | #endif |
| 1580 | return -1; |
| 1581 | } |
| 1582 | |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1583 | // Detect the start of animation and fall back to GPU only once to cache |
| 1584 | // all the layers in FB and display FB content untill animation completes. |
| 1585 | if(ctx->listStats[mDpy].isDisplayAnimating) { |
| 1586 | mCurrentFrame.needsRedraw = false; |
| 1587 | if(ctx->mAnimationState[mDpy] == ANIMATION_STOPPED) { |
| 1588 | mCurrentFrame.needsRedraw = true; |
| 1589 | ctx->mAnimationState[mDpy] = ANIMATION_STARTED; |
| 1590 | } |
| 1591 | setMDPCompLayerFlags(ctx, list); |
| 1592 | mCachedFrame.updateCounts(mCurrentFrame); |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1593 | #ifdef DYNAMIC_FPS |
| 1594 | setDynRefreshRate(ctx, list); |
| 1595 | #endif |
Ramkumar Radhakrishnan | a70981a | 2013-08-28 11:33:53 -0700 | [diff] [blame] | 1596 | ret = -1; |
| 1597 | return ret; |
| 1598 | } else { |
| 1599 | ctx->mAnimationState[mDpy] = ANIMATION_STOPPED; |
| 1600 | } |
| 1601 | |
Raj Kamal | 46dc44f | 2015-03-16 21:59:25 +0530 | [diff] [blame] | 1602 | if(!mDpy and !isSecondaryConnected(ctx) and !mPrevModeOn and |
| 1603 | mCachedFrame.isSameFrame(ctx,mDpy,list)) { |
| 1604 | ALOGD_IF(isDebug(),"%s: Avoid new composition",__FUNCTION__); |
| 1605 | mCurrentFrame.needsRedraw = false; |
| 1606 | setMDPCompLayerFlags(ctx, list); |
| 1607 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1608 | return -1; |
| 1609 | |
| 1610 | } |
| 1611 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1612 | //Hard conditions, if not met, cannot do MDP comp |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1613 | if(isFrameDoable(ctx)) { |
| 1614 | generateROI(ctx, list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1615 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1616 | mModeOn = tryFullFrame(ctx, list) || tryVideoOnly(ctx, list); |
| 1617 | if(mModeOn) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1618 | setMDPCompLayerFlags(ctx, list); |
| 1619 | } else { |
| 1620 | reset(ctx); |
| 1621 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1622 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1623 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1624 | } |
| 1625 | } else { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1626 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1627 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1628 | ret = -1; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1629 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1630 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1631 | if(isDebug()) { |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1632 | ALOGD("GEOMETRY change: %d", |
| 1633 | (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1634 | android::String8 sDump(""); |
| 1635 | dump(sDump); |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1636 | ALOGD("%s",sDump.string()); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1637 | } |
| 1638 | |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1639 | #ifdef DYNAMIC_FPS |
Praveena Pachipulusu | ab89fcf | 2014-11-25 18:47:54 +0530 | [diff] [blame] | 1640 | setDynRefreshRate(ctx, list); |
Arun Kumar K.R | 1d4bbd2 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 1641 | #endif |
| 1642 | |
Saurabh Shah | df4741d | 2013-12-12 16:40:28 -0800 | [diff] [blame] | 1643 | mCachedFrame.updateCounts(mCurrentFrame); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1644 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1645 | } |
| 1646 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1647 | bool MDPComp::allocSplitVGPipesfor4k2k(hwc_context_t *ctx, |
| 1648 | hwc_display_contents_1_t* list, int index) { |
| 1649 | |
| 1650 | bool bRet = true; |
| 1651 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1652 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1653 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1654 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
| 1655 | info.pipeInfo = new MdpYUVPipeInfo; |
| 1656 | info.rot = NULL; |
| 1657 | MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo; |
| 1658 | ePipeType type = MDPCOMP_OV_VG; |
| 1659 | |
| 1660 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1661 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1662 | |
| 1663 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1664 | if(pipe_info.lIndex == ovutils::OV_INVALID){ |
| 1665 | bRet = false; |
| 1666 | ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed", |
| 1667 | __FUNCTION__); |
| 1668 | } |
| 1669 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1670 | if(pipe_info.rIndex == ovutils::OV_INVALID){ |
| 1671 | bRet = false; |
| 1672 | ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed", |
| 1673 | __FUNCTION__); |
| 1674 | } |
| 1675 | return bRet; |
| 1676 | } |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1677 | |
| 1678 | int MDPComp::drawOverlap(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1679 | int fd = -1; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1680 | if (ctx->mPtorInfo.isActive()) { |
| 1681 | fd = ctx->mCopyBit[mDpy]->drawOverlap(ctx, list); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1682 | if (fd < 0) { |
| 1683 | ALOGD_IF(isDebug(),"%s: failed", __FUNCTION__); |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1684 | } |
| 1685 | } |
| 1686 | return fd; |
| 1687 | } |
| 1688 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1689 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1690 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1691 | void MDPCompNonSplit::adjustForSourceSplit(hwc_context_t *ctx, |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1692 | hwc_display_contents_1_t* list){ |
| 1693 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1694 | //(if available) increase mdpcount accordingly |
| 1695 | mCurrentFrame.mdpCount += ctx->listStats[mDpy].yuv4k2kCount; |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1696 | |
| 1697 | //If 4k2k Yuv layer split is possible, and if |
| 1698 | //fbz is above 4k2k layer, increment fb zorder by 1 |
| 1699 | //as we split 4k2k layer and increment zorder for right half |
| 1700 | //of the layer |
| 1701 | if(mCurrentFrame.fbZ >= 0) { |
Dileep Kumar Reddi | 2268dd7 | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1702 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 1703 | index++) { |
| 1704 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1705 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1706 | mdpNextZOrder++; |
| 1707 | } |
| 1708 | mdpNextZOrder++; |
| 1709 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1710 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1711 | if(is4kx2kYuvBuffer(hnd)) { |
| 1712 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 1713 | mCurrentFrame.fbZ += 1; |
| 1714 | mdpNextZOrder++; |
| 1715 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1716 | //(if available) increase mdpcount by 1. |
| 1717 | mCurrentFrame.mdpCount++; |
| 1718 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1719 | } |
| 1720 | } |
| 1721 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1722 | } |
| 1723 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1724 | /* |
| 1725 | * Configures pipe(s) for MDP composition |
| 1726 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1727 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1728 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1729 | MdpPipeInfoNonSplit& mdp_info = |
| 1730 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 1731 | eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1732 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1733 | eIsFg isFg = IS_FG_OFF; |
| 1734 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1735 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1736 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1737 | __FUNCTION__, layer, zOrder, dest); |
| 1738 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1739 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1740 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1743 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1744 | hwc_display_contents_1_t* list) { |
| 1745 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1746 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1747 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1748 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1749 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1750 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1751 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1752 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1753 | continue; |
| 1754 | } |
| 1755 | } |
| 1756 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1757 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1758 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1759 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1760 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1761 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1762 | ePipeType type = MDPCOMP_OV_ANY; |
| 1763 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1764 | if(isYuvBuffer(hnd)) { |
| 1765 | type = MDPCOMP_OV_VG; |
Prabhanjan Kandula | 5b8913e | 2014-01-22 23:01:45 +0530 | [diff] [blame] | 1766 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
| 1767 | (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024)) { |
| 1768 | if(qhwc::needsScaling(layer)) |
| 1769 | type = MDPCOMP_OV_RGB; |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1770 | } else if(!qhwc::needsScaling(layer) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1771 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1772 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1773 | type = MDPCOMP_OV_DMA; |
| 1774 | } |
| 1775 | |
Xu Yang | 5c2b3af | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 1776 | // for 8x26, never allow primary display occupy DMA pipe |
| 1777 | // when external display is connected |
| 1778 | if(qdutils::MDPVersion::getInstance().is8x26() |
| 1779 | && ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive |
| 1780 | && ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected |
| 1781 | && !ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isPause |
| 1782 | && mDpy == HWC_DISPLAY_PRIMARY |
| 1783 | && type == MDPCOMP_OV_DMA) { |
| 1784 | type = MDPCOMP_OV_RGB; |
| 1785 | } |
| 1786 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1787 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1788 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1789 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 1790 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1791 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1792 | } |
| 1793 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1794 | return true; |
| 1795 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1796 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1797 | int MDPCompNonSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 1798 | PipeLayerPair& PipeLayerPair) { |
| 1799 | MdpYUVPipeInfo& mdp_info = |
| 1800 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 1801 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1802 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 1803 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1804 | eDest lDest = mdp_info.lIndex; |
| 1805 | eDest rDest = mdp_info.rIndex; |
| 1806 | |
| 1807 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 1808 | lDest, rDest, &PipeLayerPair.rot); |
| 1809 | } |
| 1810 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1811 | 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] | 1812 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 1813 | if(!isEnabled() or !mModeOn) { |
| 1814 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1815 | return true; |
| 1816 | } |
| 1817 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1818 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1819 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1820 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1821 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1822 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1823 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1824 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1825 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1826 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1827 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1828 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 1829 | if (!(layer->flags & HWC_COLOR_FILL)) { |
| 1830 | ALOGE("%s handle null", __FUNCTION__); |
| 1831 | return false; |
| 1832 | } |
| 1833 | // No PLAY for Color layer |
| 1834 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1835 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1836 | } |
| 1837 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1838 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1839 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1840 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 1841 | { |
| 1842 | MdpYUVPipeInfo& pipe_info = |
| 1843 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1844 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1845 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1846 | ovutils::eDest indexR = pipe_info.rIndex; |
| 1847 | int fd = hnd->fd; |
| 1848 | uint32_t offset = hnd->offset; |
| 1849 | if(rot) { |
| 1850 | rot->queueBuffer(fd, offset); |
| 1851 | fd = rot->getDstMemId(); |
| 1852 | offset = rot->getDstOffset(); |
| 1853 | } |
| 1854 | if(indexL != ovutils::OV_INVALID) { |
| 1855 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 1856 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1857 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 1858 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1859 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1860 | __FUNCTION__, mDpy); |
| 1861 | return false; |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | if(indexR != ovutils::OV_INVALID) { |
| 1866 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 1867 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1868 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 1869 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1870 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1871 | __FUNCTION__, mDpy); |
| 1872 | return false; |
| 1873 | } |
| 1874 | } |
| 1875 | } |
| 1876 | else{ |
| 1877 | MdpPipeInfoNonSplit& pipe_info = |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1878 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1879 | ovutils::eDest dest = pipe_info.index; |
| 1880 | if(dest == ovutils::OV_INVALID) { |
| 1881 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1882 | return false; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1883 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1884 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1885 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1886 | continue; |
| 1887 | } |
| 1888 | |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1889 | int fd = hnd->fd; |
| 1890 | uint32_t offset = (uint32_t)hnd->offset; |
| 1891 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 1892 | if (!mDpy && (index != -1)) { |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1893 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 1894 | fd = hnd->fd; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 1895 | offset = 0; |
Sushil Chauhan | 4259d87 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 1896 | } |
| 1897 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1898 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1899 | using pipe: %d", __FUNCTION__, layer, |
| 1900 | hnd, dest ); |
| 1901 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1902 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1903 | if(rot) { |
| 1904 | if(!rot->queueBuffer(fd, offset)) |
| 1905 | return false; |
| 1906 | fd = rot->getDstMemId(); |
| 1907 | offset = rot->getDstOffset(); |
| 1908 | } |
| 1909 | |
| 1910 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 1911 | ALOGE("%s: queueBuffer failed for display:%d ", |
| 1912 | __FUNCTION__, mDpy); |
| 1913 | return false; |
| 1914 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1915 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1916 | |
| 1917 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1918 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1919 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1920 | } |
| 1921 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1922 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1923 | |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1924 | void MDPCompSplit::adjustForSourceSplit(hwc_context_t *ctx, |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1925 | hwc_display_contents_1_t* list){ |
| 1926 | //if 4kx2k yuv layer is totally present in either in left half |
| 1927 | //or right half then try splitting the yuv layer to avoid decimation |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1928 | const int lSplit = getLeftSplit(ctx, mDpy); |
Dileep Kumar Reddi | 2268dd7 | 2014-05-22 22:24:53 +0530 | [diff] [blame] | 1929 | if(mCurrentFrame.fbZ >= 0) { |
| 1930 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 1931 | index++) { |
| 1932 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1933 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1934 | mdpNextZOrder++; |
| 1935 | } |
| 1936 | mdpNextZOrder++; |
| 1937 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1938 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1939 | if(is4kx2kYuvBuffer(hnd)) { |
| 1940 | hwc_rect_t dst = layer->displayFrame; |
| 1941 | if((dst.left > lSplit) || (dst.right < lSplit)) { |
| 1942 | mCurrentFrame.mdpCount += 1; |
| 1943 | } |
| 1944 | if(mdpNextZOrder <= mCurrentFrame.fbZ) |
| 1945 | mCurrentFrame.fbZ += 1; |
| 1946 | mdpNextZOrder++; |
| 1947 | } |
| 1948 | } |
Saurabh Shah | 3d4b804 | 2013-12-10 15:19:17 -0800 | [diff] [blame] | 1949 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1950 | } |
| 1951 | } |
| 1952 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1953 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1954 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1955 | ePipeType type) { |
| 1956 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1957 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1958 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1959 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1960 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1961 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1962 | |
| 1963 | if (dst.left < lSplit) { |
| 1964 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1965 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1966 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | if(dst.right > lSplit) { |
| 1970 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1971 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1972 | return false; |
| 1973 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1974 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1975 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1976 | } |
| 1977 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1978 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1979 | hwc_display_contents_1_t* list) { |
| 1980 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1981 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1982 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1983 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1984 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1985 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1986 | hwc_rect_t dst = layer->displayFrame; |
| 1987 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1988 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1989 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1990 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1991 | continue; |
| 1992 | } |
| 1993 | } |
| 1994 | } |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1995 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1996 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1997 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1998 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1999 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2000 | ePipeType type = MDPCOMP_OV_ANY; |
| 2001 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2002 | if(isYuvBuffer(hnd)) { |
| 2003 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 2004 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 2005 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2006 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2007 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2008 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2009 | |
| 2010 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 2011 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 2012 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2013 | return false; |
| 2014 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2015 | } |
| 2016 | return true; |
| 2017 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 2018 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2019 | int MDPCompSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 2020 | PipeLayerPair& PipeLayerPair) { |
| 2021 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 2022 | hwc_rect_t dst = layer->displayFrame; |
| 2023 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 2024 | MdpYUVPipeInfo& mdp_info = |
| 2025 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 2026 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2027 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 2028 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2029 | eDest lDest = mdp_info.lIndex; |
| 2030 | eDest rDest = mdp_info.rIndex; |
| 2031 | |
| 2032 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 2033 | lDest, rDest, &PipeLayerPair.rot); |
| 2034 | } |
| 2035 | else{ |
| 2036 | return configure(ctx, layer, PipeLayerPair); |
| 2037 | } |
| 2038 | } |
| 2039 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2040 | /* |
| 2041 | * Configures pipe(s) for MDP composition |
| 2042 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2043 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 2044 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2045 | MdpPipeInfoSplit& mdp_info = |
| 2046 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2047 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 2048 | eIsFg isFg = IS_FG_OFF; |
Justin Philip | 2320051 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 2049 | eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2050 | eDest lDest = mdp_info.lIndex; |
| 2051 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2052 | |
| 2053 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 2054 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 2055 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2056 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2057 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2058 | } |
| 2059 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 2060 | 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] | 2061 | |
Raj Kamal | 5166b31 | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 2062 | if(!isEnabled() or !mModeOn) { |
| 2063 | ALOGD_IF(isDebug(),"%s: MDP Comp not enabled/configured", __FUNCTION__); |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 2064 | return true; |
| 2065 | } |
| 2066 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 2067 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2068 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2069 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2070 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 2071 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2072 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2073 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 2074 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2075 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2076 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 2077 | if(!hnd) { |
| 2078 | ALOGE("%s handle null", __FUNCTION__); |
| 2079 | return false; |
| 2080 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2081 | |
| 2082 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 2083 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2084 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2085 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 2086 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 2087 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2088 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 2089 | { |
| 2090 | MdpYUVPipeInfo& pipe_info = |
| 2091 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2092 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 2093 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2094 | ovutils::eDest indexR = pipe_info.rIndex; |
| 2095 | int fd = hnd->fd; |
| 2096 | uint32_t offset = hnd->offset; |
| 2097 | if(rot) { |
| 2098 | rot->queueBuffer(fd, offset); |
| 2099 | fd = rot->getDstMemId(); |
| 2100 | offset = rot->getDstOffset(); |
| 2101 | } |
| 2102 | if(indexL != ovutils::OV_INVALID) { |
| 2103 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2104 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2105 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2106 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2107 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2108 | __FUNCTION__, mDpy); |
| 2109 | return false; |
| 2110 | } |
| 2111 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2112 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2113 | if(indexR != ovutils::OV_INVALID) { |
| 2114 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2115 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2116 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2117 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2118 | ALOGE("%s: queueBuffer failed for display:%d", |
| 2119 | __FUNCTION__, mDpy); |
| 2120 | return false; |
| 2121 | } |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2122 | } |
| 2123 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2124 | else{ |
| 2125 | MdpPipeInfoSplit& pipe_info = |
| 2126 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 2127 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 2128 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2129 | ovutils::eDest indexL = pipe_info.lIndex; |
| 2130 | ovutils::eDest indexR = pipe_info.rIndex; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2131 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2132 | int fd = hnd->fd; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2133 | uint32_t offset = (uint32_t)hnd->offset; |
| 2134 | int index = ctx->mPtorInfo.getPTORArrayIndex(i); |
| 2135 | if (!mDpy && (index != -1)) { |
| 2136 | hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); |
| 2137 | fd = hnd->fd; |
Sushil Chauhan | e1474bf | 2014-07-25 12:20:23 -0700 | [diff] [blame] | 2138 | offset = 0; |
Arun Kumar K.R | bad65ab | 2014-06-03 11:54:10 -0700 | [diff] [blame] | 2139 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2140 | |
Tatenda Chipeperekwa | 2f8cd2b | 2014-04-14 10:36:06 -0700 | [diff] [blame] | 2141 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 2142 | fd = ctx->mAD->getDstFd(ctx); |
| 2143 | offset = ctx->mAD->getDstOffset(ctx); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2144 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2145 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2146 | if(rot) { |
| 2147 | rot->queueBuffer(fd, offset); |
| 2148 | fd = rot->getDstMemId(); |
| 2149 | offset = rot->getDstOffset(); |
| 2150 | } |
| 2151 | |
| 2152 | //************* play left mixer ********** |
| 2153 | if(indexL != ovutils::OV_INVALID) { |
| 2154 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2155 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2156 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2157 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2158 | ALOGE("%s: queueBuffer failed for left mixer", |
| 2159 | __FUNCTION__); |
| 2160 | return false; |
| 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | //************* play right mixer ********** |
| 2165 | if(indexR != ovutils::OV_INVALID) { |
| 2166 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2167 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2168 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2169 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2170 | ALOGE("%s: queueBuffer failed for right mixer", |
| 2171 | __FUNCTION__); |
| 2172 | return false; |
| 2173 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2174 | } |
| 2175 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2176 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2177 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 2178 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2179 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2180 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2181 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2182 | }; //namespace |
| 2183 | |