Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 3 | * Not a Contribution, Apache license notifications and license are retained |
| 4 | * for attribution purposes only. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 19 | #include <math.h> |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 20 | #include "hwc_mdpcomp.h" |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 21 | #include <sys/ioctl.h> |
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; |
| 41 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 42 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 43 | bool MDPComp::sEnableMixedMode = true; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 44 | bool MDPComp::sEnablePartialFrameUpdate = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 45 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 46 | float MDPComp::sMaxBw = 2.3f; |
| 47 | uint32_t MDPComp::sCompBytesClaimed = 0; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 48 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 49 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
| 50 | if(isDisplaySplit(ctx, dpy)) { |
| 51 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 52 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 53 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 56 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 57 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 58 | void MDPComp::dump(android::String8& buf) |
| 59 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 60 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 61 | return; |
| 62 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 63 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 64 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 65 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 66 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " |
| 67 | "fbCount:%2d \n", mCurrentFrame.layerCount, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 68 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 69 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 70 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 71 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
| 72 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 73 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 74 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 75 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 76 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 77 | index, |
| 78 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 79 | mCurrentFrame.layerToMDP[index], |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 80 | (mCurrentFrame.isFBComposed[index] ? |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 81 | (mCurrentFrame.drop[index] ? "DROP" : |
| 82 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 83 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 84 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 85 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | bool MDPComp::init(hwc_context_t *ctx) { |
| 89 | |
| 90 | if(!ctx) { |
| 91 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 92 | return false; |
| 93 | } |
| 94 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 95 | char property[PROPERTY_VALUE_MAX]; |
| 96 | |
| 97 | sEnabled = false; |
| 98 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 99 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 100 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 101 | sEnabled = true; |
| 102 | } |
| 103 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 104 | sEnableMixedMode = true; |
| 105 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 106 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 107 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 108 | sEnableMixedMode = false; |
| 109 | } |
| 110 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 111 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 112 | if(atoi(property) != 0) |
| 113 | sDebugLogs = true; |
| 114 | } |
| 115 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 116 | if(property_get("persist.hwc.partialupdate.enable", property, NULL) > 0) { |
| 117 | if((atoi(property) != 0) && ctx->mMDP.panel == MIPI_CMD_PANEL && |
| 118 | qdutils::MDPVersion::getInstance().is8x74v2()) |
| 119 | sEnablePartialFrameUpdate = true; |
| 120 | } |
| 121 | ALOGE_IF(isDebug(), "%s: Partial Update applicable?: %d",__FUNCTION__, |
| 122 | sEnablePartialFrameUpdate); |
| 123 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 124 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 125 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 126 | int val = atoi(property); |
| 127 | if(val >= 0) |
| 128 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 129 | } |
| 130 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 131 | if(property_get("debug.mdpcomp.bw", property, "0") > 0) { |
| 132 | float val = atof(property); |
| 133 | if(val > 0.0f) { |
| 134 | sMaxBw = val; |
| 135 | } |
| 136 | } |
| 137 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 138 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 139 | // Idle invalidation is not necessary on command mode panels |
| 140 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 141 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 142 | if(atoi(property) != 0) |
| 143 | idle_timeout = atoi(property); |
| 144 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 145 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 146 | //create Idle Invalidator only when not disabled through property |
| 147 | if(idle_timeout != -1) |
| 148 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 149 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 150 | if(idleInvalidator == NULL) { |
| 151 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 152 | __FUNCTION__); |
| 153 | } else { |
| 154 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 155 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 156 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 157 | return true; |
| 158 | } |
| 159 | |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 160 | void MDPComp::reset(const int& numLayers, hwc_display_contents_1_t* list) { |
| 161 | mCurrentFrame.reset(numLayers); |
| 162 | mCachedFrame.cacheAll(list); |
| 163 | mCachedFrame.updateCounts(mCurrentFrame); |
| 164 | } |
| 165 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 166 | void MDPComp::timeout_handler(void *udata) { |
| 167 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
| 168 | |
| 169 | if(!ctx) { |
| 170 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 171 | return; |
| 172 | } |
| 173 | |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 174 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 175 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 176 | return; |
| 177 | } |
| 178 | sIdleFallBack = true; |
| 179 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 180 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 183 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 184 | hwc_display_contents_1_t* list) { |
| 185 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 186 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 187 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 188 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 189 | if(!mCurrentFrame.isFBComposed[index]) { |
| 190 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 191 | layer->compositionType = HWC_OVERLAY; |
| 192 | layer->hints |= HWC_HINT_CLEAR_FB; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 193 | } else { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 194 | /* Drop the layer when its already present in FB OR when it lies |
| 195 | * outside frame's ROI */ |
| 196 | if(!mCurrentFrame.needsRedraw || mCurrentFrame.drop[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 197 | layer->compositionType = HWC_OVERLAY; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 198 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 199 | } |
| 200 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 201 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 202 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 203 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 204 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 205 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 206 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 207 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
| 208 | for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 209 | if(mdpToLayer[i].pipeInfo) { |
| 210 | delete mdpToLayer[i].pipeInfo; |
| 211 | mdpToLayer[i].pipeInfo = NULL; |
| 212 | //We dont own the rotator |
| 213 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 214 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 215 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 216 | |
| 217 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 218 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 219 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 220 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 221 | layerCount = numLayers; |
| 222 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 223 | mdpCount = 0; |
Saurabh Shah | 2f3895f | 2013-05-02 10:13:31 -0700 | [diff] [blame] | 224 | needsRedraw = true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 225 | fbZ = 0; |
| 226 | } |
| 227 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 228 | void MDPComp::FrameInfo::map() { |
| 229 | // populate layer and MDP maps |
| 230 | int mdpIdx = 0; |
| 231 | for(int idx = 0; idx < layerCount; idx++) { |
| 232 | if(!isFBComposed[idx]) { |
| 233 | mdpToLayer[mdpIdx].listIndex = idx; |
| 234 | layerToMDP[idx] = mdpIdx++; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 239 | MDPComp::LayerCache::LayerCache() { |
| 240 | reset(); |
| 241 | } |
| 242 | |
| 243 | void MDPComp::LayerCache::reset() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 244 | memset(&hnd, 0, sizeof(hnd)); |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame^] | 245 | memset(&isFBComposed, true, sizeof(isFBComposed)); |
| 246 | memset(&drop, false, sizeof(drop)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 247 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) { |
| 251 | const int numAppLayers = list->numHwLayers - 1; |
| 252 | for(int i = 0; i < numAppLayers; i++) { |
| 253 | hnd[i] = list->hwLayers[i].handle; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 258 | layerCount = curFrame.layerCount; |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame^] | 259 | memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed)); |
| 260 | memcpy(&drop, &curFrame.drop, sizeof(drop)); |
| 261 | } |
| 262 | |
| 263 | bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame) { |
| 264 | if(layerCount != curFrame.layerCount) |
| 265 | return false; |
| 266 | for(int i = 0; i < curFrame.layerCount; i++) { |
| 267 | if((curFrame.isFBComposed[i] != isFBComposed[i]) || |
| 268 | (curFrame.drop[i] != drop[i])) { |
| 269 | return false; |
| 270 | } |
| 271 | } |
| 272 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 273 | } |
| 274 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 275 | bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { |
| 276 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 277 | if((not isYuvBuffer(hnd) and has90Transform(layer)) or |
| 278 | (not isValidDimension(ctx,layer)) |
| 279 | //More conditions here, SKIP, sRGB+Blend etc |
| 280 | ) { |
| 281 | return false; |
| 282 | } |
| 283 | return true; |
| 284 | } |
| 285 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 286 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 287 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 288 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 289 | |
| 290 | if(!hnd) { |
| 291 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 292 | return false; |
| 293 | } |
| 294 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 295 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 296 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 297 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 298 | hwc_rect_t crop = layer->sourceCrop; |
| 299 | hwc_rect_t dst = layer->displayFrame; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 300 | |
| 301 | if(dst.left < 0 || dst.top < 0 || dst.right > hw_w || dst.bottom > hw_h) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 302 | hwc_rect_t scissor = {0, 0, hw_w, hw_h }; |
| 303 | qhwc::calculate_crop_rects(crop, dst, scissor, layer->transform); |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 306 | int crop_w = crop.right - crop.left; |
| 307 | int crop_h = crop.bottom - crop.top; |
| 308 | int dst_w = dst.right - dst.left; |
| 309 | int dst_h = dst.bottom - dst.top; |
| 310 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 311 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 312 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 313 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 314 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 315 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 316 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 317 | * Fallback to GPU if height is less than 2. |
| 318 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 319 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 320 | return false; |
| 321 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 322 | const uint32_t downscale = |
| 323 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
| 324 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 325 | /* Workaround for downscales larger than 4x. |
| 326 | * Will be removed once decimator block is enabled for MDSS |
| 327 | */ |
| 328 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 329 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 330 | h_dscale > downscale) |
| 331 | return false; |
| 332 | } else { |
| 333 | if(w_dscale > 64 || h_dscale > 64) |
| 334 | return false; |
| 335 | } |
| 336 | } else { //A-family |
| 337 | if(w_dscale > downscale || h_dscale > downscale) |
| 338 | return false; |
| 339 | } |
| 340 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 341 | return true; |
| 342 | } |
| 343 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 344 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 345 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 346 | overlay::Overlay& ov = *ctx->mOverlay; |
| 347 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 348 | |
| 349 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 350 | case MDPCOMP_OV_DMA: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 351 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 352 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 353 | return mdp_pipe; |
| 354 | } |
| 355 | case MDPCOMP_OV_ANY: |
| 356 | case MDPCOMP_OV_RGB: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 357 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 358 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 359 | return mdp_pipe; |
| 360 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 361 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 362 | if(type == MDPCOMP_OV_RGB) { |
| 363 | //Requested only for RGB pipe |
| 364 | break; |
| 365 | } |
| 366 | case MDPCOMP_OV_VG: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 367 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 368 | default: |
| 369 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 370 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 371 | }; |
| 372 | return ovutils::OV_INVALID; |
| 373 | } |
| 374 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 375 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 376 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 377 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 378 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 379 | if(!isEnabled()) { |
| 380 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 381 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 382 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 383 | ctx->mVideoTransFlag && ctx->mVirtualDisplay->isConnected()) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 384 | //1 Padding round to shift pipes across mixers |
| 385 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 386 | __FUNCTION__); |
| 387 | ret = false; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 388 | } else if(ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring || |
| 389 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 390 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 391 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 392 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 393 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 394 | ctx->isPaddingRound = false; |
| 395 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 396 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 397 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 398 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 399 | } |
| 400 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 401 | bool MDPComp::validateAndApplyROI(hwc_context_t *ctx, |
| 402 | hwc_display_contents_1_t* list, hwc_rect_t roi) { |
| 403 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 404 | |
| 405 | if(!isValidRect(roi)) |
| 406 | return false; |
| 407 | |
| 408 | for(int i = 0; i < numAppLayers; i++){ |
| 409 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 410 | |
| 411 | hwc_rect_t dstRect = layer->displayFrame; |
| 412 | hwc_rect_t srcRect = layer->sourceCrop; |
| 413 | int transform = layer->transform; |
| 414 | trimLayer(ctx, mDpy, transform, srcRect, dstRect); |
| 415 | |
| 416 | hwc_rect_t res = getIntersection(roi, dstRect); |
| 417 | |
| 418 | int res_w = res.right - res.left; |
| 419 | int res_h = res.bottom - res.top; |
| 420 | int dst_w = dstRect.right - dstRect.left; |
| 421 | int dst_h = dstRect.bottom - dstRect.top; |
| 422 | |
| 423 | if(!isValidRect(res)) { |
| 424 | mCurrentFrame.drop[i] = true; |
| 425 | mCurrentFrame.dropCount++; |
| 426 | }else { |
| 427 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 428 | * cropping */ |
| 429 | if((res_w != dst_w || res_h != dst_h) && |
| 430 | needsScaling (ctx, layer, mDpy)) { |
| 431 | ALOGE("%s: Resetting ROI due to scaling", __FUNCTION__); |
| 432 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 433 | mCurrentFrame.dropCount = 0; |
| 434 | return false; |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | return true; |
| 439 | } |
| 440 | |
| 441 | void MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 442 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 443 | |
| 444 | if(!sEnablePartialFrameUpdate) { |
| 445 | return; |
| 446 | } |
| 447 | |
| 448 | if(mDpy || isDisplaySplit(ctx, mDpy)){ |
| 449 | ALOGE_IF(isDebug(), "%s: ROI not supported for" |
| 450 | "the (1) external / virtual display's (2) dual DSI displays", |
| 451 | __FUNCTION__); |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | if(list->flags & HWC_GEOMETRY_CHANGED) |
| 456 | return; |
| 457 | |
| 458 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
| 459 | for(int index = 0; index < numAppLayers; index++ ) { |
| 460 | if ((mCachedFrame.hnd[index] != list->hwLayers[index].handle) || |
| 461 | isYuvBuffer((private_handle_t *)list->hwLayers[index].handle)) { |
| 462 | hwc_rect_t dstRect = list->hwLayers[index].displayFrame; |
| 463 | hwc_rect_t srcRect = list->hwLayers[index].sourceCrop; |
| 464 | int transform = list->hwLayers[index].transform; |
| 465 | |
| 466 | /* Intersect against display boundaries */ |
| 467 | trimLayer(ctx, mDpy, transform, srcRect, dstRect); |
| 468 | roi = getUnion(roi, dstRect); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | if(!validateAndApplyROI(ctx, list, roi)){ |
| 473 | roi = (struct hwc_rect) {0, 0, |
| 474 | (int)ctx->dpyAttr[mDpy].xres, (int)ctx->dpyAttr[mDpy].yres}; |
| 475 | } |
| 476 | |
| 477 | ctx->listStats[mDpy].roi.x = roi.left; |
| 478 | ctx->listStats[mDpy].roi.y = roi.top; |
| 479 | ctx->listStats[mDpy].roi.w = roi.right - roi.left; |
| 480 | ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; |
| 481 | |
| 482 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 483 | roi.left, roi.top, roi.right, roi.bottom); |
| 484 | } |
| 485 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 486 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 487 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 488 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 489 | hwc_display_contents_1_t* list){ |
| 490 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 491 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 492 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 493 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 494 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 495 | return false; |
| 496 | } |
| 497 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 498 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 499 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 500 | __FUNCTION__, |
| 501 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 502 | return false; |
| 503 | } |
| 504 | |
Saurabh Shah | 9f084ad | 2013-05-02 11:28:09 -0700 | [diff] [blame] | 505 | if(ctx->listStats[mDpy].needsAlphaScale |
| 506 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
| 507 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
| 508 | return false; |
| 509 | } |
| 510 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 511 | for(int i = 0; i < numAppLayers; ++i) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 512 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 513 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 514 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 515 | if(isYuvBuffer(hnd) && has90Transform(layer)) { |
| 516 | if(!canUseRotator(ctx, mDpy)) { |
| 517 | ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", |
| 518 | __FUNCTION__, mDpy); |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 519 | return false; |
| 520 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 521 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 522 | |
| 523 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 524 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
| 525 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 526 | (ctx->dpyAttr[mDpy].xres > 1024) && |
| 527 | (layer->transform & HWC_TRANSFORM_FLIP_H) && |
| 528 | (!isYuvBuffer(hnd))) |
| 529 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 530 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 531 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 532 | if(ctx->mAD->isDoable()) { |
| 533 | return false; |
| 534 | } |
| 535 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 536 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 537 | bool ret = false; |
| 538 | if(fullMDPComp(ctx, list)) { |
| 539 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 540 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 541 | ret = true; |
| 542 | } |
| 543 | return ret; |
| 544 | } |
| 545 | |
| 546 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 547 | //Will benefit presentation / secondary-only layer. |
| 548 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 549 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 550 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 551 | return false; |
| 552 | } |
| 553 | |
| 554 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 555 | for(int i = 0; i < numAppLayers; i++) { |
| 556 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 557 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 558 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 559 | return false; |
| 560 | } |
| 561 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 562 | mCurrentFrame.fbCount = 0; |
| 563 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 564 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 565 | sizeof(mCurrentFrame.isFBComposed)); |
| 566 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 567 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 568 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 569 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 570 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 571 | return false; |
| 572 | } |
| 573 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 574 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 575 | return false; |
| 576 | } |
| 577 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 578 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 579 | if(!bandwidthCheck(ctx, size)) { |
| 580 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 581 | return false; |
| 582 | } |
| 583 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 584 | return true; |
| 585 | } |
| 586 | |
| 587 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 588 | { |
| 589 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 590 | |
| 591 | if(!sEnableMixedMode) { |
| 592 | //Mixed mode is disabled. No need to even try caching. |
| 593 | return false; |
| 594 | } |
| 595 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 596 | //Setup mCurrentFrame |
| 597 | mCurrentFrame.reset(numAppLayers); |
| 598 | updateLayerCache(ctx, list); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 599 | |
| 600 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 601 | for(int i = 0; i < numAppLayers; i++) { |
| 602 | if(!mCurrentFrame.isFBComposed[i]) { |
| 603 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 604 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 605 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 606 | __FUNCTION__); |
| 607 | return false; |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 612 | updateYUV(ctx, list, false /*secure only*/); |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 613 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 614 | if(!ret) { |
| 615 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
| 616 | return false; |
| 617 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 618 | |
| 619 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 620 | |
| 621 | //Will benefit cases where a video has non-updating background. |
| 622 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 623 | (mdpCount > MAX_SEC_LAYERS)) { |
| 624 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 625 | return false; |
| 626 | } |
| 627 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 628 | if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used |
| 629 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 630 | return false; |
| 631 | } |
| 632 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 633 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 634 | return false; |
| 635 | } |
| 636 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 637 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 638 | if(!bandwidthCheck(ctx, size)) { |
| 639 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 640 | return false; |
| 641 | } |
| 642 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 643 | return true; |
| 644 | } |
| 645 | |
| 646 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 647 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 648 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 649 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 650 | mCurrentFrame.reset(numAppLayers); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 651 | updateYUV(ctx, list, secureOnly); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 652 | int mdpCount = mCurrentFrame.mdpCount; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 653 | int fbNeeded = (mCurrentFrame.fbCount != 0); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 654 | |
| 655 | if(!isYuvPresent(ctx, mDpy)) { |
| 656 | return false; |
| 657 | } |
| 658 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 659 | if(!mdpCount) |
| 660 | return false; |
| 661 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 662 | if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { |
| 663 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 664 | return false; |
| 665 | } |
| 666 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 667 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 668 | return false; |
| 669 | } |
| 670 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 671 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 672 | if(!bandwidthCheck(ctx, size)) { |
| 673 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 674 | return false; |
| 675 | } |
| 676 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 677 | return true; |
| 678 | } |
| 679 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 680 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 681 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 682 | bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 683 | |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 684 | if(isSkipLayer(layer) && !extAnimBlockFeature) { |
| 685 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 686 | return false; |
| 687 | } |
| 688 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 689 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 690 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 691 | return false; |
| 692 | } |
| 693 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 694 | if(isSecuring(ctx, layer)) { |
| 695 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 696 | return false; |
| 697 | } |
| 698 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 699 | if(!isValidDimension(ctx, layer)) { |
| 700 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 701 | __FUNCTION__); |
| 702 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 703 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 704 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 705 | if(layer->planeAlpha < 0xFF) { |
| 706 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 707 | in video only mode", |
| 708 | __FUNCTION__); |
| 709 | return false; |
| 710 | } |
| 711 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 712 | return true; |
| 713 | } |
| 714 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 715 | /* starts at fromIndex and check for each layer to find |
| 716 | * if it it has overlapping with any Updating layer above it in zorder |
| 717 | * till the end of the batch. returns true if it finds any intersection */ |
| 718 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 719 | int fromIndex, int toIndex) { |
| 720 | for(int i = fromIndex; i < toIndex; i++) { |
| 721 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 722 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 723 | return false; |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | return true; |
| 728 | } |
| 729 | |
| 730 | /* Checks if given layer at targetLayerIndex has any |
| 731 | * intersection with all the updating layers in beween |
| 732 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 733 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 734 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 735 | for(int i = fromIndex; i <= toIndex; i++) { |
| 736 | if(!mCurrentFrame.isFBComposed[i]) { |
| 737 | if(areLayersIntersecting(&list->hwLayers[i], |
| 738 | &list->hwLayers[targetLayerIndex])) { |
| 739 | return true; |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | return false; |
| 744 | } |
| 745 | |
| 746 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 747 | int& maxBatchStart, int& maxBatchEnd, |
| 748 | int& maxBatchCount) { |
| 749 | int i = 0; |
| 750 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
| 751 | int fbZOrder =-1; |
| 752 | while (i < mCurrentFrame.layerCount) { |
| 753 | int batchCount = 0; |
| 754 | int batchStart = i; |
| 755 | int batchEnd = i; |
| 756 | int fbZ = batchStart; |
| 757 | int firstZReverseIndex = -1; |
| 758 | while(i < mCurrentFrame.layerCount) { |
| 759 | if(!mCurrentFrame.isFBComposed[i]) { |
| 760 | if(!batchCount) { |
| 761 | i++; |
| 762 | break; |
| 763 | } |
| 764 | updatingLayersAbove++; |
| 765 | i++; |
| 766 | continue; |
| 767 | } else { |
| 768 | if(mCurrentFrame.drop[i]) { |
| 769 | i++; |
| 770 | continue; |
| 771 | } else if(updatingLayersAbove <= 0) { |
| 772 | batchCount++; |
| 773 | batchEnd = i; |
| 774 | i++; |
| 775 | continue; |
| 776 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 777 | |
| 778 | // We have a valid updating layer already. If layer-i not |
| 779 | // have overlapping with all updating layers in between |
| 780 | // batch-start and i, then we can add layer i to batch. |
| 781 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 782 | batchCount++; |
| 783 | batchEnd = i; |
| 784 | i++; |
| 785 | continue; |
| 786 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 787 | //If All the non-updating layers with in this batch |
| 788 | //does not have intersection with the updating layers |
| 789 | //above in z-order, then we can safely move the batch to |
| 790 | //higher z-order. Increment fbZ as it is moving up. |
| 791 | if( firstZReverseIndex < 0) { |
| 792 | firstZReverseIndex = i; |
| 793 | } |
| 794 | batchCount++; |
| 795 | batchEnd = i; |
| 796 | fbZ += updatingLayersAbove; |
| 797 | i++; |
| 798 | updatingLayersAbove = 0; |
| 799 | continue; |
| 800 | } else { |
| 801 | //both failed.start the loop again from here. |
| 802 | if(firstZReverseIndex >= 0) { |
| 803 | i = firstZReverseIndex; |
| 804 | } |
| 805 | break; |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | if(batchCount > maxBatchCount) { |
| 811 | maxBatchCount = batchCount; |
| 812 | maxBatchStart = batchStart; |
| 813 | maxBatchEnd = batchEnd; |
| 814 | fbZOrder = fbZ; |
| 815 | } |
| 816 | } |
| 817 | return fbZOrder; |
| 818 | } |
| 819 | |
| 820 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 821 | hwc_display_contents_1_t* list) { |
| 822 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 823 | * send rest of them through MDP. This is done in 2 steps. |
| 824 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 825 | * 2. See if we can improve this batch size for caching by adding |
| 826 | * opaque layers around the batch, if they don't have |
| 827 | * any overlapping with the updating layers in between. |
| 828 | * NEVER mark an updating layer for caching. |
| 829 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 830 | |
| 831 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 832 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 833 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 834 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 835 | |
| 836 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 837 | if(!mCurrentFrame.fbCount) { |
| 838 | mCurrentFrame.fbZ = -1; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 839 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 840 | } |
| 841 | if(!mCurrentFrame.mdpCount) { |
| 842 | mCurrentFrame.fbZ = 0; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 843 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 844 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 845 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 846 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 847 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 848 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 849 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 850 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 851 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 852 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 853 | if(!mCurrentFrame.drop[i]){ |
| 854 | //If an unsupported layer is being attempted to |
| 855 | //be pulled out we should fail |
| 856 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 857 | return false; |
| 858 | } |
| 859 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 860 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 861 | } |
| 862 | } |
| 863 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 864 | // update the frame data |
| 865 | mCurrentFrame.fbZ = fbZ; |
| 866 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 867 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 868 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 869 | |
| 870 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 871 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 872 | |
| 873 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 874 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 875 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 876 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 877 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 878 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 879 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 880 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 881 | for(int i = 0; i < numAppLayers; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 882 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 883 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 884 | if(!mCurrentFrame.drop[i]) |
| 885 | fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 886 | mCurrentFrame.isFBComposed[i] = true; |
| 887 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 888 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 889 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 890 | } |
| 891 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 892 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 893 | mCurrentFrame.fbCount = fbCount; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 894 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount |
| 895 | - mCurrentFrame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 896 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 897 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d" |
| 898 | ,__FUNCTION__, mCurrentFrame.mdpCount, mCurrentFrame.fbCount, |
| 899 | mCurrentFrame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 900 | } |
| 901 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 902 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
| 903 | bool secureOnly) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 904 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 905 | if(!nYuvCount && mDpy) { |
| 906 | //Reset "No animation on external display" related parameters. |
| 907 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 908 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 909 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 910 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 911 | ctx->mPrevTransformVideo = 0; |
| 912 | return; |
| 913 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 914 | for(int index = 0;index < nYuvCount; index++){ |
| 915 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 916 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 917 | |
| 918 | if(!isYUVDoable(ctx, layer)) { |
| 919 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 920 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 921 | mCurrentFrame.fbCount++; |
| 922 | } |
| 923 | } else { |
| 924 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 925 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 926 | if(!secureOnly || isSecureBuffer(hnd)) { |
| 927 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 928 | mCurrentFrame.fbCount--; |
| 929 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 930 | } |
| 931 | } |
| 932 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 933 | |
| 934 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 935 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
| 936 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 937 | mCurrentFrame.fbCount); |
| 938 | } |
| 939 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 940 | bool MDPComp::programMDP(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 941 | if(!allocLayerPipes(ctx, list)) { |
| 942 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 943 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 947 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 948 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 949 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 950 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 951 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 952 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 953 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 954 | mdpNextZOrder++; |
| 955 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 956 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 957 | cur_pipe->zOrder = mdpNextZOrder++; |
| 958 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 959 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 960 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 961 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 962 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 963 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 964 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 965 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 966 | } |
| 967 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 968 | return true; |
| 969 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 970 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 971 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 972 | if(!allocLayerPipes(ctx, list)) { |
| 973 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 974 | return false; |
| 975 | } |
| 976 | //If we are in this block, it means we have yuv + rgb layers both |
| 977 | int mdpIdx = 0; |
| 978 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 979 | if(!mCurrentFrame.isFBComposed[index]) { |
| 980 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 981 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 982 | MdpPipeInfo* cur_pipe = |
| 983 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 984 | cur_pipe->zOrder = mdpIdx++; |
| 985 | |
| 986 | if(configure(ctx, layer, |
| 987 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 988 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 989 | layer %d",__FUNCTION__, index); |
| 990 | return false; |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 995 | } |
| 996 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 997 | uint32_t MDPComp::calcMDPBytesRead(hwc_context_t *ctx, |
| 998 | hwc_display_contents_1_t* list) { |
| 999 | uint32_t size = 0; |
| 1000 | |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1001 | if(!qdutils::MDPVersion::getInstance().is8x74v2()) |
| 1002 | return 0; |
| 1003 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1004 | for (uint32_t i = 0; i < list->numHwLayers - 1; i++) { |
| 1005 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1006 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1007 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1008 | if (hnd) { |
| 1009 | hwc_rect_t crop = layer->sourceCrop; |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 1010 | hwc_rect_t dst = layer->displayFrame; |
| 1011 | trimLayer(ctx, mDpy, layer->transform, crop, dst); |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1012 | float bpp = ((float)hnd->size) / (hnd->width * hnd->height); |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 1013 | size += bpp * (crop.right - crop.left) * |
| 1014 | (crop.bottom - crop.top) * |
| 1015 | ctx->dpyAttr[mDpy].yres / (dst.bottom - dst.top); |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1016 | } |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | if(mCurrentFrame.fbCount) { |
| 1021 | hwc_layer_1_t* layer = &list->hwLayers[list->numHwLayers - 1]; |
| 1022 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1023 | if (hnd) |
| 1024 | size += hnd->size; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | return size; |
| 1028 | } |
| 1029 | |
| 1030 | bool MDPComp::bandwidthCheck(hwc_context_t *ctx, const uint32_t& size) { |
| 1031 | //Will be added for other targets if we run into bandwidth issues and when |
| 1032 | //we have profiling data to set an upper limit. |
| 1033 | if(qdutils::MDPVersion::getInstance().is8x74v2()) { |
| 1034 | const uint32_t ONE_GIG = 1024 * 1024 * 1024; |
| 1035 | double panelRefRate = |
| 1036 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 1037 | if((size + sCompBytesClaimed) > ((sMaxBw / panelRefRate) * ONE_GIG)) { |
| 1038 | return false; |
| 1039 | } |
| 1040 | } |
| 1041 | return true; |
| 1042 | } |
| 1043 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1044 | 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] | 1045 | int ret = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1046 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 1047 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1048 | //reset old data |
| 1049 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1050 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1051 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1052 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1053 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 1054 | //do not cache the information for next draw cycle. |
| 1055 | if(numLayers > MAX_NUM_APP_LAYERS) { |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1056 | mCachedFrame.updateCounts(mCurrentFrame); |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1057 | ALOGE("%s: Number of App layers exceeded the limit ", |
| 1058 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1059 | ret = -1; |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1060 | return ret; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1061 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1062 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1063 | //Hard conditions, if not met, cannot do MDP comp |
| 1064 | if(!isFrameDoable(ctx)) { |
| 1065 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1066 | __FUNCTION__); |
| 1067 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1068 | ret = -1; |
| 1069 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1072 | generateROI(ctx, list); |
| 1073 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1074 | //Check whether layers marked for MDP Composition is actually doable. |
| 1075 | if(isFullFrameDoable(ctx, list)) { |
| 1076 | mCurrentFrame.map(); |
| 1077 | //Configure framebuffer first if applicable |
| 1078 | if(mCurrentFrame.fbZ >= 0) { |
| 1079 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 1080 | mCurrentFrame.fbZ)) { |
| 1081 | ALOGE("%s configure framebuffer failed", __func__); |
| 1082 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1083 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1084 | ret = -1; |
| 1085 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1086 | } |
| 1087 | } |
| 1088 | //Acquire and Program MDP pipes |
| 1089 | if(!programMDP(ctx, list)) { |
| 1090 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1091 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1092 | ret = -1; |
| 1093 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1094 | } else { //Success |
| 1095 | //Any change in composition types needs an FB refresh |
| 1096 | mCurrentFrame.needsRedraw = false; |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame^] | 1097 | if(!mCachedFrame.isSameFrame(mCurrentFrame) || |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1098 | (list->flags & HWC_GEOMETRY_CHANGED) || |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame^] | 1099 | isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1100 | mCurrentFrame.needsRedraw = true; |
| 1101 | } |
| 1102 | } |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1103 | } else if(isOnlyVideoDoable(ctx, list, false /*secure only*/) || |
| 1104 | isOnlyVideoDoable(ctx, list, true /*secure only*/)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1105 | //All layers marked for MDP comp cannot be bypassed. |
| 1106 | //Try to compose atleast YUV layers through MDP comp and let |
| 1107 | //all the RGB layers compose in FB |
| 1108 | //Destination over |
| 1109 | mCurrentFrame.fbZ = -1; |
| 1110 | if(mCurrentFrame.fbCount) |
| 1111 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
| 1112 | |
| 1113 | mCurrentFrame.map(); |
| 1114 | |
| 1115 | //Configure framebuffer first if applicable |
| 1116 | if(mCurrentFrame.fbZ >= 0) { |
| 1117 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 1118 | ALOGE("%s configure framebuffer failed", __func__); |
| 1119 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1120 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1121 | ret = -1; |
| 1122 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1123 | } |
| 1124 | } |
| 1125 | if(!programYUV(ctx, list)) { |
| 1126 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1127 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1128 | ret = -1; |
| 1129 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1130 | } |
| 1131 | } else { |
| 1132 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1133 | ret = -1; |
| 1134 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | //UpdateLayerFlags |
| 1138 | setMDPCompLayerFlags(ctx, list); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1139 | mCachedFrame.cacheAll(list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1140 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1141 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1142 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1143 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1144 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1145 | android::String8 sDump(""); |
| 1146 | dump(sDump); |
| 1147 | ALOGE("%s",sDump.string()); |
| 1148 | } |
| 1149 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1150 | exit: |
| 1151 | sCompBytesClaimed += calcMDPBytesRead(ctx, list); |
| 1152 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1153 | } |
| 1154 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1155 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1156 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1157 | /* |
| 1158 | * Configures pipe(s) for MDP composition |
| 1159 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1160 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1161 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1162 | MdpPipeInfoNonSplit& mdp_info = |
| 1163 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1164 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 1165 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1166 | eIsFg isFg = IS_FG_OFF; |
| 1167 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1168 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1169 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1170 | __FUNCTION__, layer, zOrder, dest); |
| 1171 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1172 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1173 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1176 | bool MDPCompNonSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1177 | hwc_display_contents_1_t* list) { |
| 1178 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1179 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 1180 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 1181 | |
| 1182 | //Reserve pipe for FB |
| 1183 | if(mCurrentFrame.fbCount) |
| 1184 | availPipes -= 1; |
| 1185 | |
| 1186 | if(numPipesNeeded > availPipes) { |
| 1187 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 1188 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 1189 | return false; |
| 1190 | } |
| 1191 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1192 | if(not areVGPipesAvailable(ctx, list)) { |
| 1193 | return false; |
| 1194 | } |
| 1195 | |
| 1196 | return true; |
| 1197 | } |
| 1198 | |
| 1199 | bool MDPCompNonSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1200 | hwc_display_contents_1_t* list) { |
| 1201 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1202 | int pipesNeeded = 0; |
| 1203 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1204 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1205 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1206 | hwc_rect_t dst = layer->displayFrame; |
| 1207 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1208 | if(isYuvBuffer(hnd)) { |
| 1209 | pipesNeeded++; |
| 1210 | } |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1215 | if(pipesNeeded > availableVGPipes) { |
| 1216 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1217 | "dpy %d needed %d, avail %d", |
| 1218 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1219 | return false; |
| 1220 | } |
| 1221 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1222 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1223 | } |
| 1224 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1225 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1226 | hwc_display_contents_1_t* list) { |
| 1227 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1228 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1229 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1230 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1231 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1232 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1233 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1234 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1235 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1236 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1237 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1238 | ePipeType type = MDPCOMP_OV_ANY; |
| 1239 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1240 | if(isYuvBuffer(hnd)) { |
| 1241 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 1242 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1243 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1244 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1245 | type = MDPCOMP_OV_DMA; |
| 1246 | } |
| 1247 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1248 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1249 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1250 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 1251 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1252 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1253 | } |
| 1254 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1255 | return true; |
| 1256 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1257 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1258 | 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] | 1259 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1260 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1261 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1262 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 1263 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1264 | |
| 1265 | if(!ctx || !list) { |
| 1266 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1267 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1268 | } |
| 1269 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1270 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1271 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1272 | return true; |
| 1273 | } |
| 1274 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1275 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1276 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1277 | idleInvalidator->markForSleep(); |
| 1278 | |
| 1279 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1280 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1281 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1282 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1283 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1284 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1285 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1286 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1287 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1288 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1289 | if(!hnd) { |
| 1290 | ALOGE("%s handle null", __FUNCTION__); |
| 1291 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1292 | } |
| 1293 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1294 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1295 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1296 | MdpPipeInfoNonSplit& pipe_info = |
| 1297 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1298 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1299 | if(dest == ovutils::OV_INVALID) { |
| 1300 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1301 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1304 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1305 | continue; |
| 1306 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1307 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1308 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1309 | using pipe: %d", __FUNCTION__, layer, |
| 1310 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1311 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1312 | int fd = hnd->fd; |
| 1313 | uint32_t offset = hnd->offset; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1314 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1315 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1316 | if(rot) { |
| 1317 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1318 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1319 | fd = rot->getDstMemId(); |
| 1320 | offset = rot->getDstOffset(); |
| 1321 | } |
| 1322 | |
| 1323 | if (!ov.queueBuffer(fd, offset, dest)) { |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1324 | ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1325 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1326 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1327 | |
| 1328 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1329 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1330 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1333 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1334 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1335 | int MDPCompSplit::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1336 | hwc_display_contents_1_t* list, |
| 1337 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1338 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1339 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1340 | |
| 1341 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1342 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1343 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1344 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1345 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1346 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1347 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1348 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1349 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1350 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1351 | } |
| 1352 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1353 | } |
| 1354 | return pipesNeeded; |
| 1355 | } |
| 1356 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1357 | bool MDPCompSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1358 | hwc_display_contents_1_t* list) { |
| 1359 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1360 | int totalPipesNeeded = 0; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1361 | |
| 1362 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1363 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1364 | int availPipes = ov.availablePipes(mDpy, i); |
| 1365 | |
| 1366 | //Reserve pipe(s)for FB |
| 1367 | if(mCurrentFrame.fbCount) |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1368 | numPipesNeeded += 1; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1369 | |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1370 | totalPipesNeeded += numPipesNeeded; |
| 1371 | |
| 1372 | //Per mixer check. |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1373 | if(numPipesNeeded > availPipes) { |
| 1374 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1375 | "dpy %d mixer %d needed %d, avail %d", |
| 1376 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1377 | return false; |
| 1378 | } |
| 1379 | } |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1380 | |
| 1381 | //Per display check, since unused pipes can get counted twice. |
| 1382 | int totalPipesAvailable = ov.availablePipes(mDpy); |
| 1383 | if(totalPipesNeeded > totalPipesAvailable) { |
| 1384 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1385 | "dpy %d needed %d, avail %d", |
| 1386 | __FUNCTION__, mDpy, totalPipesNeeded, totalPipesAvailable); |
| 1387 | return false; |
| 1388 | } |
| 1389 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1390 | if(not areVGPipesAvailable(ctx, list)) { |
| 1391 | return false; |
| 1392 | } |
| 1393 | |
| 1394 | return true; |
| 1395 | } |
| 1396 | |
| 1397 | bool MDPCompSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1398 | hwc_display_contents_1_t* list) { |
| 1399 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1400 | int pipesNeeded = 0; |
| 1401 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1402 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1403 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1404 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1405 | hwc_rect_t dst = layer->displayFrame; |
| 1406 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1407 | if(isYuvBuffer(hnd)) { |
| 1408 | if(dst.left < lSplit) { |
| 1409 | pipesNeeded++; |
| 1410 | } |
| 1411 | if(dst.right > lSplit) { |
| 1412 | pipesNeeded++; |
| 1413 | } |
| 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | |
| 1418 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1419 | if(pipesNeeded > availableVGPipes) { |
| 1420 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1421 | "dpy %d needed %d, avail %d", |
| 1422 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1423 | return false; |
| 1424 | } |
| 1425 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1426 | return true; |
| 1427 | } |
| 1428 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1429 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1430 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1431 | ePipeType type) { |
| 1432 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1433 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1434 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1435 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1436 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1437 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1438 | |
| 1439 | if (dst.left < lSplit) { |
| 1440 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1441 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1442 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1443 | } |
| 1444 | |
| 1445 | if(dst.right > lSplit) { |
| 1446 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1447 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1448 | return false; |
| 1449 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1450 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1451 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1452 | } |
| 1453 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1454 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1455 | hwc_display_contents_1_t* list) { |
| 1456 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1457 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1458 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1459 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1460 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1461 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1462 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1463 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1464 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1465 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1466 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1467 | ePipeType type = MDPCOMP_OV_ANY; |
| 1468 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1469 | if(isYuvBuffer(hnd)) { |
| 1470 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 1471 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1472 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1473 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1474 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1475 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1476 | |
| 1477 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1478 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1479 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1480 | return false; |
| 1481 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1482 | } |
| 1483 | return true; |
| 1484 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1485 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1486 | /* |
| 1487 | * Configures pipe(s) for MDP composition |
| 1488 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1489 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1490 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1491 | MdpPipeInfoSplit& mdp_info = |
| 1492 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1493 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1494 | eIsFg isFg = IS_FG_OFF; |
| 1495 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1496 | eDest lDest = mdp_info.lIndex; |
| 1497 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1498 | |
| 1499 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1500 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1501 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1502 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1503 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1504 | } |
| 1505 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1506 | 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] | 1507 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1508 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1509 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1510 | return true; |
| 1511 | } |
| 1512 | |
| 1513 | if(!ctx || !list) { |
| 1514 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1515 | return false; |
| 1516 | } |
| 1517 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1518 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1519 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1520 | return true; |
| 1521 | } |
| 1522 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1523 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1524 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1525 | idleInvalidator->markForSleep(); |
| 1526 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1527 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1528 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1529 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1530 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1531 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1532 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1533 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1534 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1535 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1536 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1537 | if(!hnd) { |
| 1538 | ALOGE("%s handle null", __FUNCTION__); |
| 1539 | return false; |
| 1540 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1541 | |
| 1542 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1543 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1544 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1545 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1546 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1547 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1548 | MdpPipeInfoSplit& pipe_info = |
| 1549 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1550 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1551 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1552 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1553 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1554 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1555 | int fd = hnd->fd; |
| 1556 | int offset = hnd->offset; |
| 1557 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1558 | if(ctx->mAD->isModeOn()) { |
| 1559 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 1560 | fd = ctx->mAD->getDstFd(ctx); |
| 1561 | offset = ctx->mAD->getDstOffset(ctx); |
| 1562 | } |
| 1563 | } |
| 1564 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1565 | if(rot) { |
| 1566 | rot->queueBuffer(fd, offset); |
| 1567 | fd = rot->getDstMemId(); |
| 1568 | offset = rot->getDstOffset(); |
| 1569 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1570 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1571 | //************* play left mixer ********** |
| 1572 | if(indexL != ovutils::OV_INVALID) { |
| 1573 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1574 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1575 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1576 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1577 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1578 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | //************* play right mixer ********** |
| 1583 | if(indexR != ovutils::OV_INVALID) { |
| 1584 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1585 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1586 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1587 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1588 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1589 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1590 | } |
| 1591 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1592 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1593 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1594 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1595 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1596 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1597 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1598 | }; //namespace |
| 1599 | |