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