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; |
Saurabh Shah | 3c1a6b0 | 2013-11-22 11:10:20 -0800 | [diff] [blame] | 47 | double MDPComp::sBwClaimed = 0.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 | |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 263 | bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame, |
| 264 | hwc_display_contents_1_t* list) { |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 265 | if(layerCount != curFrame.layerCount) |
| 266 | return false; |
| 267 | for(int i = 0; i < curFrame.layerCount; i++) { |
| 268 | if((curFrame.isFBComposed[i] != isFBComposed[i]) || |
| 269 | (curFrame.drop[i] != drop[i])) { |
| 270 | return false; |
| 271 | } |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 272 | if(curFrame.isFBComposed[i] && |
| 273 | (hnd[i] != list->hwLayers[i].handle)){ |
| 274 | return false; |
| 275 | } |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 276 | } |
| 277 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 280 | bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { |
| 281 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 282 | if((not isYuvBuffer(hnd) and has90Transform(layer)) or |
| 283 | (not isValidDimension(ctx,layer)) |
| 284 | //More conditions here, SKIP, sRGB+Blend etc |
| 285 | ) { |
| 286 | return false; |
| 287 | } |
| 288 | return true; |
| 289 | } |
| 290 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 291 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 292 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 293 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 294 | |
| 295 | if(!hnd) { |
| 296 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 297 | return false; |
| 298 | } |
| 299 | |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 300 | //XXX: Investigate doing this with pixel phase on MDSS |
Naseer Ahmed | e77f808 | 2013-10-10 13:42:48 -0400 | [diff] [blame] | 301 | if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 302 | return false; |
| 303 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 304 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 305 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 306 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 307 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 308 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 309 | int crop_w = crop.right - crop.left; |
| 310 | int crop_h = crop.bottom - crop.top; |
| 311 | int dst_w = dst.right - dst.left; |
| 312 | int dst_h = dst.bottom - dst.top; |
| 313 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 314 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 315 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 316 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 317 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 318 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 319 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 320 | * Fallback to GPU if height is less than 2. |
| 321 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 322 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 323 | return false; |
| 324 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 325 | const uint32_t downscale = |
| 326 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
| 327 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 328 | /* Workaround for downscales larger than 4x. |
| 329 | * Will be removed once decimator block is enabled for MDSS |
| 330 | */ |
| 331 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 332 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 333 | h_dscale > downscale) |
| 334 | return false; |
| 335 | } else { |
| 336 | if(w_dscale > 64 || h_dscale > 64) |
| 337 | return false; |
| 338 | } |
| 339 | } else { //A-family |
| 340 | if(w_dscale > downscale || h_dscale > downscale) |
| 341 | return false; |
| 342 | } |
| 343 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 344 | return true; |
| 345 | } |
| 346 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 347 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 348 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 349 | overlay::Overlay& ov = *ctx->mOverlay; |
| 350 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 351 | |
| 352 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 353 | case MDPCOMP_OV_DMA: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 354 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 355 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 356 | return mdp_pipe; |
| 357 | } |
| 358 | case MDPCOMP_OV_ANY: |
| 359 | case MDPCOMP_OV_RGB: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 360 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 361 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 362 | return mdp_pipe; |
| 363 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 364 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 365 | if(type == MDPCOMP_OV_RGB) { |
| 366 | //Requested only for RGB pipe |
| 367 | break; |
| 368 | } |
| 369 | case MDPCOMP_OV_VG: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 370 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 371 | default: |
| 372 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 373 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 374 | }; |
| 375 | return ovutils::OV_INVALID; |
| 376 | } |
| 377 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 378 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 379 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 380 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 381 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 382 | if(!isEnabled()) { |
| 383 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 384 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 385 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 386 | ctx->mVideoTransFlag && ctx->mVirtualDisplay->isConnected()) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 387 | //1 Padding round to shift pipes across mixers |
| 388 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 389 | __FUNCTION__); |
| 390 | ret = false; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 391 | } else if(ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring || |
| 392 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 393 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 394 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 395 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 396 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 397 | ctx->isPaddingRound = false; |
| 398 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 399 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 400 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 401 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 402 | } |
| 403 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 404 | /* |
| 405 | * 1) Identify layers that are not visible in the updating ROI and drop them |
| 406 | * from composition. |
| 407 | * 2) If we have a scaling layers which needs cropping against generated ROI. |
| 408 | * Reset ROI to full resolution. |
| 409 | */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 410 | bool MDPComp::validateAndApplyROI(hwc_context_t *ctx, |
| 411 | hwc_display_contents_1_t* list, hwc_rect_t roi) { |
| 412 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 413 | |
| 414 | if(!isValidRect(roi)) |
| 415 | return false; |
| 416 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 417 | hwc_rect_t visibleRect = roi; |
| 418 | |
| 419 | for(int i = numAppLayers - 1; i >= 0; i--){ |
| 420 | |
| 421 | if(!isValidRect(visibleRect)) { |
| 422 | mCurrentFrame.drop[i] = true; |
| 423 | mCurrentFrame.dropCount++; |
| 424 | } |
| 425 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 426 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 427 | |
| 428 | hwc_rect_t dstRect = layer->displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 429 | hwc_rect_t srcRect = integerizeSourceCrop(layer->sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 430 | int transform = layer->transform; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 431 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 432 | hwc_rect_t res = getIntersection(visibleRect, dstRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 433 | |
| 434 | int res_w = res.right - res.left; |
| 435 | int res_h = res.bottom - res.top; |
| 436 | int dst_w = dstRect.right - dstRect.left; |
| 437 | int dst_h = dstRect.bottom - dstRect.top; |
| 438 | |
| 439 | if(!isValidRect(res)) { |
| 440 | mCurrentFrame.drop[i] = true; |
| 441 | mCurrentFrame.dropCount++; |
| 442 | }else { |
| 443 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 444 | * cropping */ |
| 445 | if((res_w != dst_w || res_h != dst_h) && |
| 446 | needsScaling (ctx, layer, mDpy)) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 447 | ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 448 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 449 | mCurrentFrame.dropCount = 0; |
| 450 | return false; |
| 451 | } |
| 452 | } |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 453 | |
| 454 | if (layer->blending == HWC_BLENDING_NONE) |
| 455 | visibleRect = deductRect(visibleRect, res); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 456 | } |
| 457 | return true; |
| 458 | } |
| 459 | |
| 460 | void MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 461 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 462 | |
| 463 | if(!sEnablePartialFrameUpdate) { |
| 464 | return; |
| 465 | } |
| 466 | |
| 467 | if(mDpy || isDisplaySplit(ctx, mDpy)){ |
| 468 | ALOGE_IF(isDebug(), "%s: ROI not supported for" |
| 469 | "the (1) external / virtual display's (2) dual DSI displays", |
| 470 | __FUNCTION__); |
| 471 | return; |
| 472 | } |
| 473 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 474 | if(isSkipPresent(ctx, mDpy)) |
| 475 | return; |
| 476 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 477 | if(list->flags & HWC_GEOMETRY_CHANGED) |
| 478 | return; |
| 479 | |
| 480 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
| 481 | for(int index = 0; index < numAppLayers; index++ ) { |
| 482 | if ((mCachedFrame.hnd[index] != list->hwLayers[index].handle) || |
| 483 | isYuvBuffer((private_handle_t *)list->hwLayers[index].handle)) { |
| 484 | hwc_rect_t dstRect = list->hwLayers[index].displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 485 | hwc_rect_t srcRect = integerizeSourceCrop( |
| 486 | list->hwLayers[index].sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 487 | int transform = list->hwLayers[index].transform; |
| 488 | |
| 489 | /* Intersect against display boundaries */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 490 | roi = getUnion(roi, dstRect); |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | if(!validateAndApplyROI(ctx, list, roi)){ |
| 495 | roi = (struct hwc_rect) {0, 0, |
| 496 | (int)ctx->dpyAttr[mDpy].xres, (int)ctx->dpyAttr[mDpy].yres}; |
| 497 | } |
| 498 | |
| 499 | ctx->listStats[mDpy].roi.x = roi.left; |
| 500 | ctx->listStats[mDpy].roi.y = roi.top; |
| 501 | ctx->listStats[mDpy].roi.w = roi.right - roi.left; |
| 502 | ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; |
| 503 | |
| 504 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 505 | roi.left, roi.top, roi.right, roi.bottom); |
| 506 | } |
| 507 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 508 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 509 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 510 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 511 | hwc_display_contents_1_t* list){ |
| 512 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 513 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 514 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 515 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 516 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 517 | return false; |
| 518 | } |
| 519 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 520 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 521 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 522 | __FUNCTION__, |
| 523 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 524 | return false; |
| 525 | } |
| 526 | |
Saurabh Shah | 9f084ad | 2013-05-02 11:28:09 -0700 | [diff] [blame] | 527 | if(ctx->listStats[mDpy].needsAlphaScale |
| 528 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
| 529 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
| 530 | return false; |
| 531 | } |
| 532 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 533 | for(int i = 0; i < numAppLayers; ++i) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 534 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 535 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 536 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 537 | if(isYuvBuffer(hnd) && has90Transform(layer)) { |
| 538 | if(!canUseRotator(ctx, mDpy)) { |
| 539 | ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", |
| 540 | __FUNCTION__, mDpy); |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 541 | return false; |
| 542 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 543 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 544 | |
| 545 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 546 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
| 547 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 548 | (ctx->dpyAttr[mDpy].xres > 1024) && |
| 549 | (layer->transform & HWC_TRANSFORM_FLIP_H) && |
| 550 | (!isYuvBuffer(hnd))) |
| 551 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 552 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 553 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 554 | if(ctx->mAD->isDoable()) { |
| 555 | return false; |
| 556 | } |
| 557 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 558 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 559 | bool ret = false; |
| 560 | if(fullMDPComp(ctx, list)) { |
| 561 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 562 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 563 | ret = true; |
| 564 | } |
| 565 | return ret; |
| 566 | } |
| 567 | |
| 568 | 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] | 569 | //Will benefit presentation / secondary-only layer. |
| 570 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 571 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 572 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 573 | return false; |
| 574 | } |
| 575 | |
| 576 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 577 | for(int i = 0; i < numAppLayers; i++) { |
| 578 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 579 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 580 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 581 | return false; |
| 582 | } |
| 583 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 584 | mCurrentFrame.fbCount = 0; |
| 585 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 586 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 587 | sizeof(mCurrentFrame.isFBComposed)); |
| 588 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 589 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 590 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 591 | if(!resourceCheck(ctx, list)) { |
| 592 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 593 | return false; |
| 594 | } |
| 595 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 596 | return true; |
| 597 | } |
| 598 | |
| 599 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 600 | { |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 601 | if(!sEnableMixedMode) { |
| 602 | //Mixed mode is disabled. No need to even try caching. |
| 603 | return false; |
| 604 | } |
| 605 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 606 | bool ret = false; |
| 607 | if(isLoadBasedCompDoable(ctx, list)) { |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 608 | ret = loadBasedCompPreferGPU(ctx, list) || |
| 609 | loadBasedCompPreferMDP(ctx, list); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | if(!ret) { |
| 613 | ret = cacheBasedComp(ctx, list); |
| 614 | } |
| 615 | |
| 616 | return ret; |
| 617 | } |
| 618 | |
| 619 | bool MDPComp::cacheBasedComp(hwc_context_t *ctx, |
| 620 | hwc_display_contents_1_t* list) { |
| 621 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 622 | mCurrentFrame.reset(numAppLayers); |
| 623 | updateLayerCache(ctx, list); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 624 | |
| 625 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 626 | for(int i = 0; i < numAppLayers; i++) { |
| 627 | if(!mCurrentFrame.isFBComposed[i]) { |
| 628 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 629 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 630 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 631 | __FUNCTION__); |
| 632 | return false; |
| 633 | } |
| 634 | } |
| 635 | } |
| 636 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 637 | updateYUV(ctx, list, false /*secure only*/); |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 638 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 639 | if(!ret) { |
| 640 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
| 641 | return false; |
| 642 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 643 | |
| 644 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 645 | |
| 646 | //Will benefit cases where a video has non-updating background. |
| 647 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 648 | (mdpCount > MAX_SEC_LAYERS)) { |
| 649 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 650 | return false; |
| 651 | } |
| 652 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 653 | if(!resourceCheck(ctx, list)) { |
| 654 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 655 | return false; |
| 656 | } |
| 657 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 658 | return true; |
| 659 | } |
| 660 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 661 | bool MDPComp::loadBasedCompPreferGPU(hwc_context_t *ctx, |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 662 | hwc_display_contents_1_t* list) { |
| 663 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 664 | mCurrentFrame.reset(numAppLayers); |
| 665 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 666 | int stagesForMDP = min(sMaxPipesPerMixer, ctx->mOverlay->availablePipes( |
| 667 | mDpy, Overlay::MIXER_DEFAULT)); |
| 668 | //If MDP has X possible stages, it can take X layers. |
| 669 | const int batchSize = numAppLayers - (stagesForMDP - 1); //1 for FB |
| 670 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 671 | if(batchSize <= 0) { |
| 672 | ALOGD_IF(isDebug(), "%s: Not attempting", __FUNCTION__); |
| 673 | return false; |
| 674 | } |
| 675 | |
| 676 | int minBatchStart = -1; |
| 677 | size_t minBatchPixelCount = SIZE_MAX; |
| 678 | |
| 679 | for(int i = 0; i <= numAppLayers - batchSize; i++) { |
| 680 | uint32_t batchPixelCount = 0; |
| 681 | for(int j = i; j < i + batchSize; j++) { |
| 682 | hwc_layer_1_t* layer = &list->hwLayers[j]; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 683 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 684 | batchPixelCount += (crop.right - crop.left) * |
| 685 | (crop.bottom - crop.top); |
| 686 | } |
| 687 | |
| 688 | if(batchPixelCount < minBatchPixelCount) { |
| 689 | minBatchPixelCount = batchPixelCount; |
| 690 | minBatchStart = i; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | if(minBatchStart < 0) { |
| 695 | ALOGD_IF(isDebug(), "%s: No batch found batchSize %d numAppLayers %d", |
| 696 | __FUNCTION__, batchSize, numAppLayers); |
| 697 | return false; |
| 698 | } |
| 699 | |
| 700 | for(int i = 0; i < numAppLayers; i++) { |
| 701 | if(i < minBatchStart || i >= minBatchStart + batchSize) { |
| 702 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 703 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 704 | ALOGD_IF(isDebug(), "%s: MDP unsupported layer found at %d", |
| 705 | __FUNCTION__, i); |
| 706 | return false; |
| 707 | } |
| 708 | mCurrentFrame.isFBComposed[i] = false; |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | mCurrentFrame.fbZ = minBatchStart; |
| 713 | mCurrentFrame.fbCount = batchSize; |
| 714 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - batchSize; |
| 715 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 716 | if(!resourceCheck(ctx, list)) { |
| 717 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 718 | return false; |
| 719 | } |
| 720 | |
| 721 | ALOGD_IF(isDebug(), "%s: fbZ %d batchSize %d", |
| 722 | __FUNCTION__, mCurrentFrame.fbZ, batchSize); |
| 723 | return true; |
| 724 | } |
| 725 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 726 | bool MDPComp::loadBasedCompPreferMDP(hwc_context_t *ctx, |
| 727 | hwc_display_contents_1_t* list) { |
| 728 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 729 | //TODO get the ib from sysfs node. |
| 730 | //Full screen is from ib perspective, not actual full screen |
| 731 | const int bpp = 4; |
| 732 | double panelRefRate = |
| 733 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 734 | |
| 735 | double bwLeft = sMaxBw - sBwClaimed; |
| 736 | |
| 737 | const int fullScreenLayers = bwLeft * 1000000000 / (ctx->dpyAttr[mDpy].xres |
| 738 | * ctx->dpyAttr[mDpy].yres * bpp * panelRefRate); |
| 739 | |
| 740 | const int fbBatchSize = numAppLayers - (fullScreenLayers - 1); |
| 741 | //If batch size is not at least 2, we aren't really preferring MDP, since |
| 742 | //only 1 layer going to GPU could actually translate into an entire FB |
| 743 | //needed to be fetched by MDP, thus needing more b/w rather than less. |
| 744 | if(fbBatchSize < 2 || fbBatchSize > numAppLayers) { |
| 745 | ALOGD_IF(isDebug(), "%s: Not attempting", __FUNCTION__); |
| 746 | return false; |
| 747 | } |
| 748 | |
| 749 | //Top-most layers constitute FB batch |
| 750 | const int fbBatchStart = numAppLayers - fbBatchSize; |
| 751 | |
| 752 | //Bottom-most layers constitute MDP batch |
| 753 | for(int i = 0; i < fbBatchStart; i++) { |
| 754 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 755 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 756 | ALOGD_IF(isDebug(), "%s: MDP unsupported layer found at %d", |
| 757 | __FUNCTION__, i); |
| 758 | return false; |
| 759 | } |
| 760 | mCurrentFrame.isFBComposed[i] = false; |
| 761 | } |
| 762 | |
| 763 | mCurrentFrame.fbZ = fbBatchStart; |
| 764 | mCurrentFrame.fbCount = fbBatchSize; |
| 765 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - fbBatchSize; |
| 766 | |
| 767 | if(!resourceCheck(ctx, list)) { |
| 768 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
| 769 | return false; |
| 770 | } |
| 771 | |
| 772 | ALOGD_IF(isDebug(), "%s: FB Z %d, num app layers %d, MDP Batch Size %d", |
| 773 | __FUNCTION__, mCurrentFrame.fbZ, numAppLayers, |
| 774 | numAppLayers - fbBatchSize); |
| 775 | |
| 776 | return true; |
| 777 | } |
| 778 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 779 | bool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx, |
| 780 | hwc_display_contents_1_t* list) { |
| 781 | if(mDpy or isSecurePresent(ctx, mDpy) or |
| 782 | not (list->flags & HWC_GEOMETRY_CHANGED)) { |
| 783 | return false; |
| 784 | } |
| 785 | return true; |
| 786 | } |
| 787 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 788 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 789 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 790 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 791 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 792 | mCurrentFrame.reset(numAppLayers); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 793 | updateYUV(ctx, list, secureOnly); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 794 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 795 | |
| 796 | if(!isYuvPresent(ctx, mDpy)) { |
| 797 | return false; |
| 798 | } |
| 799 | |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 800 | /* Bail out if we are processing only secured video layers |
| 801 | * and we dont have any */ |
| 802 | if(!isSecurePresent(ctx, mDpy) && secureOnly){ |
| 803 | return false; |
| 804 | } |
| 805 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 806 | if(!mdpCount) |
| 807 | return false; |
| 808 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 809 | if(!resourceCheck(ctx, list)) { |
| 810 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 811 | return false; |
| 812 | } |
| 813 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 814 | return true; |
| 815 | } |
| 816 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 817 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 818 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 819 | bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 820 | |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 821 | if(isSkipLayer(layer) && !extAnimBlockFeature) { |
| 822 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 823 | return false; |
| 824 | } |
| 825 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 826 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 827 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 828 | return false; |
| 829 | } |
| 830 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 831 | if(isSecuring(ctx, layer)) { |
| 832 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 833 | return false; |
| 834 | } |
| 835 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 836 | if(!isValidDimension(ctx, layer)) { |
| 837 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 838 | __FUNCTION__); |
| 839 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 840 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 841 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 842 | if(layer->planeAlpha < 0xFF) { |
| 843 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 844 | in video only mode", |
| 845 | __FUNCTION__); |
| 846 | return false; |
| 847 | } |
| 848 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 849 | return true; |
| 850 | } |
| 851 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 852 | /* starts at fromIndex and check for each layer to find |
| 853 | * if it it has overlapping with any Updating layer above it in zorder |
| 854 | * till the end of the batch. returns true if it finds any intersection */ |
| 855 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 856 | int fromIndex, int toIndex) { |
| 857 | for(int i = fromIndex; i < toIndex; i++) { |
| 858 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 859 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 860 | return false; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | return true; |
| 865 | } |
| 866 | |
| 867 | /* Checks if given layer at targetLayerIndex has any |
| 868 | * intersection with all the updating layers in beween |
| 869 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 870 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 871 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 872 | for(int i = fromIndex; i <= toIndex; i++) { |
| 873 | if(!mCurrentFrame.isFBComposed[i]) { |
| 874 | if(areLayersIntersecting(&list->hwLayers[i], |
| 875 | &list->hwLayers[targetLayerIndex])) { |
| 876 | return true; |
| 877 | } |
| 878 | } |
| 879 | } |
| 880 | return false; |
| 881 | } |
| 882 | |
| 883 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 884 | int& maxBatchStart, int& maxBatchEnd, |
| 885 | int& maxBatchCount) { |
| 886 | int i = 0; |
| 887 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
| 888 | int fbZOrder =-1; |
| 889 | while (i < mCurrentFrame.layerCount) { |
| 890 | int batchCount = 0; |
| 891 | int batchStart = i; |
| 892 | int batchEnd = i; |
| 893 | int fbZ = batchStart; |
| 894 | int firstZReverseIndex = -1; |
| 895 | while(i < mCurrentFrame.layerCount) { |
| 896 | if(!mCurrentFrame.isFBComposed[i]) { |
| 897 | if(!batchCount) { |
| 898 | i++; |
| 899 | break; |
| 900 | } |
| 901 | updatingLayersAbove++; |
| 902 | i++; |
| 903 | continue; |
| 904 | } else { |
| 905 | if(mCurrentFrame.drop[i]) { |
| 906 | i++; |
| 907 | continue; |
| 908 | } else if(updatingLayersAbove <= 0) { |
| 909 | batchCount++; |
| 910 | batchEnd = i; |
| 911 | i++; |
| 912 | continue; |
| 913 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 914 | |
| 915 | // We have a valid updating layer already. If layer-i not |
| 916 | // have overlapping with all updating layers in between |
| 917 | // batch-start and i, then we can add layer i to batch. |
| 918 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 919 | batchCount++; |
| 920 | batchEnd = i; |
| 921 | i++; |
| 922 | continue; |
| 923 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 924 | //If All the non-updating layers with in this batch |
| 925 | //does not have intersection with the updating layers |
| 926 | //above in z-order, then we can safely move the batch to |
| 927 | //higher z-order. Increment fbZ as it is moving up. |
| 928 | if( firstZReverseIndex < 0) { |
| 929 | firstZReverseIndex = i; |
| 930 | } |
| 931 | batchCount++; |
| 932 | batchEnd = i; |
| 933 | fbZ += updatingLayersAbove; |
| 934 | i++; |
| 935 | updatingLayersAbove = 0; |
| 936 | continue; |
| 937 | } else { |
| 938 | //both failed.start the loop again from here. |
| 939 | if(firstZReverseIndex >= 0) { |
| 940 | i = firstZReverseIndex; |
| 941 | } |
| 942 | break; |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | } |
| 947 | if(batchCount > maxBatchCount) { |
| 948 | maxBatchCount = batchCount; |
| 949 | maxBatchStart = batchStart; |
| 950 | maxBatchEnd = batchEnd; |
| 951 | fbZOrder = fbZ; |
| 952 | } |
| 953 | } |
| 954 | return fbZOrder; |
| 955 | } |
| 956 | |
| 957 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 958 | hwc_display_contents_1_t* list) { |
| 959 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 960 | * send rest of them through MDP. This is done in 2 steps. |
| 961 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 962 | * 2. See if we can improve this batch size for caching by adding |
| 963 | * opaque layers around the batch, if they don't have |
| 964 | * any overlapping with the updating layers in between. |
| 965 | * NEVER mark an updating layer for caching. |
| 966 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 967 | |
| 968 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 969 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 970 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 971 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 972 | |
| 973 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 974 | if(!mCurrentFrame.fbCount) { |
| 975 | mCurrentFrame.fbZ = -1; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 976 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 977 | } |
| 978 | if(!mCurrentFrame.mdpCount) { |
| 979 | mCurrentFrame.fbZ = 0; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 980 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 981 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 982 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 983 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 984 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 985 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 986 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 987 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 988 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 989 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 990 | if(!mCurrentFrame.drop[i]){ |
| 991 | //If an unsupported layer is being attempted to |
| 992 | //be pulled out we should fail |
| 993 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 994 | return false; |
| 995 | } |
| 996 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 997 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 998 | } |
| 999 | } |
| 1000 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1001 | // update the frame data |
| 1002 | mCurrentFrame.fbZ = fbZ; |
| 1003 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1004 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1005 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1006 | |
| 1007 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1008 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1009 | |
| 1010 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1011 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1012 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1013 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1014 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1015 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1016 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1017 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1018 | for(int i = 0; i < numAppLayers; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1019 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1020 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1021 | if(!mCurrentFrame.drop[i]) |
| 1022 | fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1023 | mCurrentFrame.isFBComposed[i] = true; |
| 1024 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1025 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1026 | } |
| 1027 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1028 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1029 | mCurrentFrame.fbCount = fbCount; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1030 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount |
| 1031 | - mCurrentFrame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1032 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1033 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d" |
| 1034 | ,__FUNCTION__, mCurrentFrame.mdpCount, mCurrentFrame.fbCount, |
| 1035 | mCurrentFrame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1036 | } |
| 1037 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1038 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
| 1039 | bool secureOnly) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1040 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 1041 | if(!nYuvCount && mDpy) { |
| 1042 | //Reset "No animation on external display" related parameters. |
| 1043 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 1044 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 1045 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 1046 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 1047 | ctx->mPrevTransformVideo = 0; |
| 1048 | return; |
| 1049 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1050 | for(int index = 0;index < nYuvCount; index++){ |
| 1051 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 1052 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 1053 | |
| 1054 | if(!isYUVDoable(ctx, layer)) { |
| 1055 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 1056 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 1057 | mCurrentFrame.fbCount++; |
| 1058 | } |
| 1059 | } else { |
| 1060 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1061 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1062 | if(!secureOnly || isSecureBuffer(hnd)) { |
| 1063 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 1064 | mCurrentFrame.fbCount--; |
| 1065 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1066 | } |
| 1067 | } |
| 1068 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1069 | |
| 1070 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1071 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
| 1072 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1073 | mCurrentFrame.fbCount); |
| 1074 | } |
| 1075 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1076 | 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] | 1077 | if(!allocLayerPipes(ctx, list)) { |
| 1078 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1079 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1083 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1084 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1085 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1086 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1087 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1088 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 1089 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1090 | mdpNextZOrder++; |
| 1091 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1092 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1093 | cur_pipe->zOrder = mdpNextZOrder++; |
| 1094 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1095 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1096 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1097 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 1098 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1099 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1100 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1101 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1102 | } |
| 1103 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1104 | return true; |
| 1105 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1106 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1107 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1108 | if(!allocLayerPipes(ctx, list)) { |
| 1109 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 1110 | return false; |
| 1111 | } |
| 1112 | //If we are in this block, it means we have yuv + rgb layers both |
| 1113 | int mdpIdx = 0; |
| 1114 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 1115 | if(!mCurrentFrame.isFBComposed[index]) { |
| 1116 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1117 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1118 | MdpPipeInfo* cur_pipe = |
| 1119 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1120 | cur_pipe->zOrder = mdpIdx++; |
| 1121 | |
| 1122 | if(configure(ctx, layer, |
| 1123 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1124 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 1125 | layer %d",__FUNCTION__, index); |
| 1126 | return false; |
| 1127 | } |
| 1128 | } |
| 1129 | } |
| 1130 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1131 | } |
| 1132 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1133 | bool MDPComp::resourceCheck(hwc_context_t *ctx, |
| 1134 | hwc_display_contents_1_t *list) { |
| 1135 | const bool fbUsed = mCurrentFrame.fbCount; |
| 1136 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { |
| 1137 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 1138 | return false; |
| 1139 | } |
| 1140 | |
| 1141 | if(!arePipesAvailable(ctx, list)) { |
| 1142 | return false; |
| 1143 | } |
| 1144 | |
| 1145 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 1146 | if(!bandwidthCheck(ctx, size)) { |
| 1147 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 1148 | return false; |
| 1149 | } |
| 1150 | |
| 1151 | return true; |
| 1152 | } |
| 1153 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1154 | uint32_t MDPComp::calcMDPBytesRead(hwc_context_t *ctx, |
| 1155 | hwc_display_contents_1_t* list) { |
| 1156 | uint32_t size = 0; |
| 1157 | |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1158 | if(!qdutils::MDPVersion::getInstance().is8x74v2()) |
| 1159 | return 0; |
| 1160 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1161 | for (uint32_t i = 0; i < list->numHwLayers - 1; i++) { |
| 1162 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1163 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1164 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1165 | if (hnd) { |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 1166 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 1167 | hwc_rect_t dst = layer->displayFrame; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1168 | float bpp = ((float)hnd->size) / (hnd->width * hnd->height); |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 1169 | size += bpp * (crop.right - crop.left) * |
| 1170 | (crop.bottom - crop.top) * |
| 1171 | ctx->dpyAttr[mDpy].yres / (dst.bottom - dst.top); |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1172 | } |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | if(mCurrentFrame.fbCount) { |
| 1177 | hwc_layer_1_t* layer = &list->hwLayers[list->numHwLayers - 1]; |
| 1178 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1179 | if (hnd) |
| 1180 | size += hnd->size; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1181 | } |
| 1182 | |
| 1183 | return size; |
| 1184 | } |
| 1185 | |
| 1186 | bool MDPComp::bandwidthCheck(hwc_context_t *ctx, const uint32_t& size) { |
| 1187 | //Will be added for other targets if we run into bandwidth issues and when |
| 1188 | //we have profiling data to set an upper limit. |
| 1189 | if(qdutils::MDPVersion::getInstance().is8x74v2()) { |
Saurabh Shah | 3c1a6b0 | 2013-11-22 11:10:20 -0800 | [diff] [blame] | 1190 | const uint32_t ONE_GIG = 1000 * 1000 * 1000; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1191 | double panelRefRate = |
| 1192 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
Saurabh Shah | 3c1a6b0 | 2013-11-22 11:10:20 -0800 | [diff] [blame] | 1193 | if((size * panelRefRate) > ((sMaxBw - sBwClaimed) * ONE_GIG)) { |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1194 | return false; |
| 1195 | } |
| 1196 | } |
| 1197 | return true; |
| 1198 | } |
| 1199 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1200 | 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] | 1201 | int ret = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1202 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 1203 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1204 | //reset old data |
| 1205 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1206 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1207 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1208 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1209 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 1210 | //do not cache the information for next draw cycle. |
| 1211 | if(numLayers > MAX_NUM_APP_LAYERS) { |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1212 | mCachedFrame.updateCounts(mCurrentFrame); |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 1213 | ALOGI("%s: Number of App layers exceeded the limit ", |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1214 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1215 | ret = -1; |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1216 | return ret; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1217 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1218 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1219 | //Hard conditions, if not met, cannot do MDP comp |
| 1220 | if(!isFrameDoable(ctx)) { |
| 1221 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1222 | __FUNCTION__); |
| 1223 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1224 | ret = -1; |
| 1225 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1226 | } |
| 1227 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1228 | generateROI(ctx, list); |
| 1229 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1230 | //Check whether layers marked for MDP Composition is actually doable. |
| 1231 | if(isFullFrameDoable(ctx, list)) { |
| 1232 | mCurrentFrame.map(); |
| 1233 | //Configure framebuffer first if applicable |
| 1234 | if(mCurrentFrame.fbZ >= 0) { |
| 1235 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 1236 | mCurrentFrame.fbZ)) { |
| 1237 | ALOGE("%s configure framebuffer failed", __func__); |
| 1238 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1239 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1240 | ret = -1; |
| 1241 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1242 | } |
| 1243 | } |
| 1244 | //Acquire and Program MDP pipes |
| 1245 | if(!programMDP(ctx, list)) { |
| 1246 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1247 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1248 | ret = -1; |
| 1249 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1250 | } else { //Success |
| 1251 | //Any change in composition types needs an FB refresh |
| 1252 | mCurrentFrame.needsRedraw = false; |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 1253 | if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1254 | (list->flags & HWC_GEOMETRY_CHANGED) || |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 1255 | isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1256 | mCurrentFrame.needsRedraw = true; |
| 1257 | } |
| 1258 | } |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1259 | } else if(isOnlyVideoDoable(ctx, list, false /*secure only*/) || |
| 1260 | isOnlyVideoDoable(ctx, list, true /*secure only*/)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1261 | //All layers marked for MDP comp cannot be bypassed. |
| 1262 | //Try to compose atleast YUV layers through MDP comp and let |
| 1263 | //all the RGB layers compose in FB |
| 1264 | //Destination over |
| 1265 | mCurrentFrame.fbZ = -1; |
| 1266 | if(mCurrentFrame.fbCount) |
| 1267 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
| 1268 | |
| 1269 | mCurrentFrame.map(); |
| 1270 | |
| 1271 | //Configure framebuffer first if applicable |
| 1272 | if(mCurrentFrame.fbZ >= 0) { |
| 1273 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 1274 | ALOGE("%s configure framebuffer failed", __func__); |
| 1275 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1276 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1277 | ret = -1; |
| 1278 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1279 | } |
| 1280 | } |
| 1281 | if(!programYUV(ctx, list)) { |
| 1282 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1283 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1284 | ret = -1; |
| 1285 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1286 | } |
| 1287 | } else { |
| 1288 | reset(numLayers, list); |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 1289 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1290 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1291 | ret = -1; |
| 1292 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1293 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1294 | //UpdateLayerFlags |
| 1295 | setMDPCompLayerFlags(ctx, list); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1296 | mCachedFrame.cacheAll(list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1297 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1298 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1299 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1300 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1301 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1302 | android::String8 sDump(""); |
| 1303 | dump(sDump); |
| 1304 | ALOGE("%s",sDump.string()); |
| 1305 | } |
| 1306 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1307 | exit: |
Saurabh Shah | 3c1a6b0 | 2013-11-22 11:10:20 -0800 | [diff] [blame] | 1308 | //gbps (bytes / nanosec = gigabytes / sec) |
| 1309 | sBwClaimed += calcMDPBytesRead(ctx, list) / |
| 1310 | (double)ctx->dpyAttr[mDpy].vsync_period; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1311 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1312 | } |
| 1313 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1314 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1315 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1316 | /* |
| 1317 | * Configures pipe(s) for MDP composition |
| 1318 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1319 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1320 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1321 | MdpPipeInfoNonSplit& mdp_info = |
| 1322 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1323 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 1324 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1325 | eIsFg isFg = IS_FG_OFF; |
| 1326 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1327 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1328 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1329 | __FUNCTION__, layer, zOrder, dest); |
| 1330 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1331 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1332 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1333 | } |
| 1334 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1335 | bool MDPCompNonSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1336 | hwc_display_contents_1_t* list) { |
| 1337 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1338 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 1339 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 1340 | |
| 1341 | //Reserve pipe for FB |
| 1342 | if(mCurrentFrame.fbCount) |
| 1343 | availPipes -= 1; |
| 1344 | |
| 1345 | if(numPipesNeeded > availPipes) { |
| 1346 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 1347 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 1348 | return false; |
| 1349 | } |
| 1350 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1351 | if(not areVGPipesAvailable(ctx, list)) { |
| 1352 | return false; |
| 1353 | } |
| 1354 | |
| 1355 | return true; |
| 1356 | } |
| 1357 | |
| 1358 | bool MDPCompNonSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1359 | hwc_display_contents_1_t* list) { |
| 1360 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1361 | int pipesNeeded = 0; |
| 1362 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1363 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1364 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1365 | hwc_rect_t dst = layer->displayFrame; |
| 1366 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1367 | if(isYuvBuffer(hnd)) { |
| 1368 | pipesNeeded++; |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1374 | if(pipesNeeded > availableVGPipes) { |
| 1375 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1376 | "dpy %d needed %d, avail %d", |
| 1377 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1378 | return false; |
| 1379 | } |
| 1380 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1381 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1382 | } |
| 1383 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1384 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1385 | hwc_display_contents_1_t* list) { |
| 1386 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1387 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1388 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1389 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1390 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1391 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1392 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1393 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1394 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1395 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1396 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1397 | ePipeType type = MDPCOMP_OV_ANY; |
| 1398 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1399 | if(isYuvBuffer(hnd)) { |
| 1400 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 1401 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1402 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1403 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1404 | type = MDPCOMP_OV_DMA; |
| 1405 | } |
| 1406 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1407 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1408 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1409 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 1410 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1411 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1412 | } |
| 1413 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1414 | return true; |
| 1415 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1416 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1417 | 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] | 1418 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1419 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1420 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1421 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 1422 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1423 | |
| 1424 | if(!ctx || !list) { |
| 1425 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1426 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1427 | } |
| 1428 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1429 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1430 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1431 | return true; |
| 1432 | } |
| 1433 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1434 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1435 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1436 | idleInvalidator->markForSleep(); |
| 1437 | |
| 1438 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1439 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1440 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1441 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1442 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1443 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1444 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1445 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1446 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1447 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1448 | if(!hnd) { |
| 1449 | ALOGE("%s handle null", __FUNCTION__); |
| 1450 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1451 | } |
| 1452 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1453 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1454 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1455 | MdpPipeInfoNonSplit& pipe_info = |
| 1456 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1457 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1458 | if(dest == ovutils::OV_INVALID) { |
| 1459 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1460 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1461 | } |
| 1462 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1463 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1464 | continue; |
| 1465 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1466 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1467 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1468 | using pipe: %d", __FUNCTION__, layer, |
| 1469 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1470 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1471 | int fd = hnd->fd; |
| 1472 | uint32_t offset = hnd->offset; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1473 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1474 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1475 | if(rot) { |
| 1476 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1477 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1478 | fd = rot->getDstMemId(); |
| 1479 | offset = rot->getDstOffset(); |
| 1480 | } |
| 1481 | |
| 1482 | if (!ov.queueBuffer(fd, offset, dest)) { |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1483 | ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1484 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1485 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1486 | |
| 1487 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1488 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1489 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1492 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1493 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1494 | int MDPCompSplit::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1495 | hwc_display_contents_1_t* list, |
| 1496 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1497 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1498 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1499 | |
| 1500 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1501 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1502 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1503 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1504 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1505 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1506 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1507 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1508 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1509 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1510 | } |
| 1511 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1512 | } |
| 1513 | return pipesNeeded; |
| 1514 | } |
| 1515 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1516 | bool MDPCompSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1517 | hwc_display_contents_1_t* list) { |
| 1518 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1519 | int totalPipesNeeded = 0; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1520 | |
| 1521 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1522 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1523 | int availPipes = ov.availablePipes(mDpy, i); |
| 1524 | |
| 1525 | //Reserve pipe(s)for FB |
| 1526 | if(mCurrentFrame.fbCount) |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1527 | numPipesNeeded += 1; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1528 | |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1529 | totalPipesNeeded += numPipesNeeded; |
| 1530 | |
| 1531 | //Per mixer check. |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1532 | if(numPipesNeeded > availPipes) { |
| 1533 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1534 | "dpy %d mixer %d needed %d, avail %d", |
| 1535 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1536 | return false; |
| 1537 | } |
| 1538 | } |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1539 | |
| 1540 | //Per display check, since unused pipes can get counted twice. |
| 1541 | int totalPipesAvailable = ov.availablePipes(mDpy); |
| 1542 | if(totalPipesNeeded > totalPipesAvailable) { |
| 1543 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1544 | "dpy %d needed %d, avail %d", |
| 1545 | __FUNCTION__, mDpy, totalPipesNeeded, totalPipesAvailable); |
| 1546 | return false; |
| 1547 | } |
| 1548 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1549 | if(not areVGPipesAvailable(ctx, list)) { |
| 1550 | return false; |
| 1551 | } |
| 1552 | |
| 1553 | return true; |
| 1554 | } |
| 1555 | |
| 1556 | bool MDPCompSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1557 | hwc_display_contents_1_t* list) { |
| 1558 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1559 | int pipesNeeded = 0; |
| 1560 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1561 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1562 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1563 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1564 | hwc_rect_t dst = layer->displayFrame; |
| 1565 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1566 | if(isYuvBuffer(hnd)) { |
| 1567 | if(dst.left < lSplit) { |
| 1568 | pipesNeeded++; |
| 1569 | } |
| 1570 | if(dst.right > lSplit) { |
| 1571 | pipesNeeded++; |
| 1572 | } |
| 1573 | } |
| 1574 | } |
| 1575 | } |
| 1576 | |
| 1577 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1578 | if(pipesNeeded > availableVGPipes) { |
| 1579 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1580 | "dpy %d needed %d, avail %d", |
| 1581 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1582 | return false; |
| 1583 | } |
| 1584 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1585 | return true; |
| 1586 | } |
| 1587 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1588 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1589 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1590 | ePipeType type) { |
| 1591 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1592 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1593 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1594 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1595 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1596 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1597 | |
| 1598 | if (dst.left < lSplit) { |
| 1599 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1600 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1601 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1602 | } |
| 1603 | |
| 1604 | if(dst.right > lSplit) { |
| 1605 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1606 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1607 | return false; |
| 1608 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1609 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1610 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1611 | } |
| 1612 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1613 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1614 | hwc_display_contents_1_t* list) { |
| 1615 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1616 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1617 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1618 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1619 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1620 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1621 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1622 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1623 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1624 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1625 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1626 | ePipeType type = MDPCOMP_OV_ANY; |
| 1627 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1628 | if(isYuvBuffer(hnd)) { |
| 1629 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 1630 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1631 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1632 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1633 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1634 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1635 | |
| 1636 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1637 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1638 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1639 | return false; |
| 1640 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1641 | } |
| 1642 | return true; |
| 1643 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1644 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1645 | /* |
| 1646 | * Configures pipe(s) for MDP composition |
| 1647 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1648 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1649 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1650 | MdpPipeInfoSplit& mdp_info = |
| 1651 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1652 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1653 | eIsFg isFg = IS_FG_OFF; |
| 1654 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1655 | eDest lDest = mdp_info.lIndex; |
| 1656 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1657 | |
| 1658 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1659 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1660 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1661 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1662 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1663 | } |
| 1664 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1665 | 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] | 1666 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1667 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1668 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1669 | return true; |
| 1670 | } |
| 1671 | |
| 1672 | if(!ctx || !list) { |
| 1673 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1674 | return false; |
| 1675 | } |
| 1676 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1677 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1678 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1679 | return true; |
| 1680 | } |
| 1681 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1682 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1683 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1684 | idleInvalidator->markForSleep(); |
| 1685 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1686 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1687 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1688 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1689 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1690 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1691 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1692 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1693 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1694 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1695 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1696 | if(!hnd) { |
| 1697 | ALOGE("%s handle null", __FUNCTION__); |
| 1698 | return false; |
| 1699 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1700 | |
| 1701 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1702 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1703 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1704 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1705 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1706 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1707 | MdpPipeInfoSplit& pipe_info = |
| 1708 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1709 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1710 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1711 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1712 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1713 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1714 | int fd = hnd->fd; |
| 1715 | int offset = hnd->offset; |
| 1716 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1717 | if(ctx->mAD->isModeOn()) { |
| 1718 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 1719 | fd = ctx->mAD->getDstFd(ctx); |
| 1720 | offset = ctx->mAD->getDstOffset(ctx); |
| 1721 | } |
| 1722 | } |
| 1723 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1724 | if(rot) { |
| 1725 | rot->queueBuffer(fd, offset); |
| 1726 | fd = rot->getDstMemId(); |
| 1727 | offset = rot->getDstOffset(); |
| 1728 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1729 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1730 | //************* play left mixer ********** |
| 1731 | if(indexL != ovutils::OV_INVALID) { |
| 1732 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1733 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1734 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1735 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1736 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1737 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | //************* play right mixer ********** |
| 1742 | if(indexR != ovutils::OV_INVALID) { |
| 1743 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1744 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1745 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1746 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1747 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1748 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1749 | } |
| 1750 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1751 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1752 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1753 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1754 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1755 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1756 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1757 | }; //namespace |
| 1758 | |