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 | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 46 | double MDPComp::sMaxBw = 0.0; |
Saurabh Shah | 3c1a6b0 | 2013-11-22 11:10:20 -0800 | [diff] [blame] | 47 | double MDPComp::sBwClaimed = 0.0; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 48 | bool MDPComp::sEnable4k2kYUVSplit = false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 49 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 50 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
| 51 | if(isDisplaySplit(ctx, dpy)) { |
| 52 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 53 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 54 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 57 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 58 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 59 | void MDPComp::dump(android::String8& buf) |
| 60 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 61 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 62 | return; |
| 63 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 64 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 65 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 66 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 67 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " |
| 68 | "fbCount:%2d \n", mCurrentFrame.layerCount, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 69 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 70 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 71 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 72 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
| 73 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 74 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 75 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 76 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 77 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 78 | index, |
| 79 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 80 | mCurrentFrame.layerToMDP[index], |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 81 | (mCurrentFrame.isFBComposed[index] ? |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 82 | (mCurrentFrame.drop[index] ? "DROP" : |
| 83 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 84 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 85 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 86 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | bool MDPComp::init(hwc_context_t *ctx) { |
| 90 | |
| 91 | if(!ctx) { |
| 92 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 93 | return false; |
| 94 | } |
| 95 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 96 | char property[PROPERTY_VALUE_MAX]; |
| 97 | |
| 98 | sEnabled = false; |
| 99 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 100 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 101 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 102 | sEnabled = true; |
| 103 | } |
| 104 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 105 | sEnableMixedMode = true; |
| 106 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 107 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 108 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 109 | sEnableMixedMode = false; |
| 110 | } |
| 111 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 112 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 113 | if(atoi(property) != 0) |
| 114 | sDebugLogs = true; |
| 115 | } |
| 116 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 117 | if(property_get("persist.hwc.partialupdate.enable", property, NULL) > 0) { |
| 118 | if((atoi(property) != 0) && ctx->mMDP.panel == MIPI_CMD_PANEL && |
| 119 | qdutils::MDPVersion::getInstance().is8x74v2()) |
| 120 | sEnablePartialFrameUpdate = true; |
| 121 | } |
| 122 | ALOGE_IF(isDebug(), "%s: Partial Update applicable?: %d",__FUNCTION__, |
| 123 | sEnablePartialFrameUpdate); |
| 124 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 125 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 126 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 127 | int val = atoi(property); |
| 128 | if(val >= 0) |
| 129 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 130 | } |
| 131 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 132 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 133 | // Idle invalidation is not necessary on command mode panels |
| 134 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 135 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 136 | if(atoi(property) != 0) |
| 137 | idle_timeout = atoi(property); |
| 138 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 139 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 140 | //create Idle Invalidator only when not disabled through property |
| 141 | if(idle_timeout != -1) |
| 142 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 143 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 144 | if(idleInvalidator == NULL) { |
| 145 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 146 | __FUNCTION__); |
| 147 | } else { |
| 148 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 149 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 150 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 151 | |
| 152 | if((property_get("debug.mdpcomp.4k2kSplit", property, "0") > 0) && |
| 153 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 154 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 155 | sEnable4k2kYUVSplit = true; |
| 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) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 296 | if (layer->flags & HWC_COLOR_FILL) { |
| 297 | // Color layer |
| 298 | return true; |
| 299 | } |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 300 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 301 | return false; |
| 302 | } |
| 303 | |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 304 | //XXX: Investigate doing this with pixel phase on MDSS |
Naseer Ahmed | e77f808 | 2013-10-10 13:42:48 -0400 | [diff] [blame] | 305 | if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) |
Naseer Ahmed | e850a80 | 2013-09-06 13:12:52 -0400 | [diff] [blame] | 306 | return false; |
| 307 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 308 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 309 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 310 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 311 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 312 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 313 | int crop_w = crop.right - crop.left; |
| 314 | int crop_h = crop.bottom - crop.top; |
| 315 | int dst_w = dst.right - dst.left; |
| 316 | int dst_h = dst.bottom - dst.top; |
| 317 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 318 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 319 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 320 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 321 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 322 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 323 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 324 | * Fallback to GPU if height is less than 2. |
| 325 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 326 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 327 | return false; |
| 328 | |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 329 | if((w_dscale > 1.0f) || (h_dscale > 1.0f)) { |
| 330 | const uint32_t downscale = |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 331 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
Jeykumar Sankaran | 1706a77 | 2013-11-27 12:55:19 -0800 | [diff] [blame] | 332 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 333 | /* Workaround for downscales larger than 4x. |
| 334 | * Will be removed once decimator block is enabled for MDSS |
| 335 | */ |
| 336 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 337 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 338 | h_dscale > downscale) |
| 339 | return false; |
| 340 | } else { |
| 341 | if(w_dscale > 64 || h_dscale > 64) |
| 342 | return false; |
| 343 | } |
| 344 | } else { //A-family |
| 345 | if(w_dscale > downscale || h_dscale > downscale) |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 346 | return false; |
| 347 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 350 | return true; |
| 351 | } |
| 352 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 353 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 354 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 355 | overlay::Overlay& ov = *ctx->mOverlay; |
| 356 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 357 | |
| 358 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 359 | case MDPCOMP_OV_DMA: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 360 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 361 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 362 | return mdp_pipe; |
| 363 | } |
| 364 | case MDPCOMP_OV_ANY: |
| 365 | case MDPCOMP_OV_RGB: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 366 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 367 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 368 | return mdp_pipe; |
| 369 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 370 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 371 | if(type == MDPCOMP_OV_RGB) { |
| 372 | //Requested only for RGB pipe |
| 373 | break; |
| 374 | } |
| 375 | case MDPCOMP_OV_VG: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 376 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 377 | default: |
| 378 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 379 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 380 | }; |
| 381 | return ovutils::OV_INVALID; |
| 382 | } |
| 383 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 384 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 385 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 386 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 387 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 388 | if(!isEnabled()) { |
| 389 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 390 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 391 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 392 | ctx->mVideoTransFlag && ctx->mVirtualDisplay->isConnected()) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 393 | //1 Padding round to shift pipes across mixers |
| 394 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 395 | __FUNCTION__); |
| 396 | ret = false; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 397 | } else if(ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring || |
| 398 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 399 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 400 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 401 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 402 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 403 | ctx->isPaddingRound = false; |
| 404 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 405 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 406 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 407 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 408 | } |
| 409 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 410 | /* |
| 411 | * 1) Identify layers that are not visible in the updating ROI and drop them |
| 412 | * from composition. |
| 413 | * 2) If we have a scaling layers which needs cropping against generated ROI. |
| 414 | * Reset ROI to full resolution. |
| 415 | */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 416 | bool MDPComp::validateAndApplyROI(hwc_context_t *ctx, |
| 417 | hwc_display_contents_1_t* list, hwc_rect_t roi) { |
| 418 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 419 | |
| 420 | if(!isValidRect(roi)) |
| 421 | return false; |
| 422 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 423 | hwc_rect_t visibleRect = roi; |
| 424 | |
| 425 | for(int i = numAppLayers - 1; i >= 0; i--){ |
| 426 | |
| 427 | if(!isValidRect(visibleRect)) { |
| 428 | mCurrentFrame.drop[i] = true; |
| 429 | mCurrentFrame.dropCount++; |
| 430 | } |
| 431 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 432 | const hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 433 | |
| 434 | hwc_rect_t dstRect = layer->displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 435 | hwc_rect_t srcRect = integerizeSourceCrop(layer->sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 436 | int transform = layer->transform; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 437 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 438 | hwc_rect_t res = getIntersection(visibleRect, dstRect); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 439 | |
| 440 | int res_w = res.right - res.left; |
| 441 | int res_h = res.bottom - res.top; |
| 442 | int dst_w = dstRect.right - dstRect.left; |
| 443 | int dst_h = dstRect.bottom - dstRect.top; |
| 444 | |
| 445 | if(!isValidRect(res)) { |
| 446 | mCurrentFrame.drop[i] = true; |
| 447 | mCurrentFrame.dropCount++; |
| 448 | }else { |
| 449 | /* Reset frame ROI when any layer which needs scaling also needs ROI |
| 450 | * cropping */ |
| 451 | if((res_w != dst_w || res_h != dst_h) && |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 452 | needsScaling (layer)) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 453 | ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 454 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 455 | mCurrentFrame.dropCount = 0; |
| 456 | return false; |
| 457 | } |
| 458 | } |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 459 | |
| 460 | if (layer->blending == HWC_BLENDING_NONE) |
| 461 | visibleRect = deductRect(visibleRect, res); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 462 | } |
| 463 | return true; |
| 464 | } |
| 465 | |
| 466 | void MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 467 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 468 | |
| 469 | if(!sEnablePartialFrameUpdate) { |
| 470 | return; |
| 471 | } |
| 472 | |
| 473 | if(mDpy || isDisplaySplit(ctx, mDpy)){ |
| 474 | ALOGE_IF(isDebug(), "%s: ROI not supported for" |
| 475 | "the (1) external / virtual display's (2) dual DSI displays", |
| 476 | __FUNCTION__); |
| 477 | return; |
| 478 | } |
| 479 | |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 480 | if(isSkipPresent(ctx, mDpy)) |
| 481 | return; |
| 482 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 483 | if(list->flags & HWC_GEOMETRY_CHANGED) |
| 484 | return; |
| 485 | |
| 486 | struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; |
| 487 | for(int index = 0; index < numAppLayers; index++ ) { |
| 488 | if ((mCachedFrame.hnd[index] != list->hwLayers[index].handle) || |
| 489 | isYuvBuffer((private_handle_t *)list->hwLayers[index].handle)) { |
| 490 | hwc_rect_t dstRect = list->hwLayers[index].displayFrame; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 491 | hwc_rect_t srcRect = integerizeSourceCrop( |
| 492 | list->hwLayers[index].sourceCropf); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 493 | int transform = list->hwLayers[index].transform; |
| 494 | |
| 495 | /* Intersect against display boundaries */ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 496 | roi = getUnion(roi, dstRect); |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | if(!validateAndApplyROI(ctx, list, roi)){ |
| 501 | roi = (struct hwc_rect) {0, 0, |
| 502 | (int)ctx->dpyAttr[mDpy].xres, (int)ctx->dpyAttr[mDpy].yres}; |
| 503 | } |
| 504 | |
| 505 | ctx->listStats[mDpy].roi.x = roi.left; |
| 506 | ctx->listStats[mDpy].roi.y = roi.top; |
| 507 | ctx->listStats[mDpy].roi.w = roi.right - roi.left; |
| 508 | ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; |
| 509 | |
| 510 | ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, |
| 511 | roi.left, roi.top, roi.right, roi.bottom); |
| 512 | } |
| 513 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 514 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 515 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 516 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 517 | hwc_display_contents_1_t* list){ |
| 518 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 519 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 520 | |
Ramkumar Radhakrishnan | ba71338 | 2013-08-30 18:41:07 -0700 | [diff] [blame] | 521 | if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 522 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 523 | return false; |
| 524 | } |
| 525 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 526 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 527 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 528 | __FUNCTION__, |
| 529 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 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 | } |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 565 | |
| 566 | if(!hwLimitationsCheck(ctx, list)) { |
| 567 | ALOGD_IF(isDebug(), "%s: HW limitations",__FUNCTION__); |
| 568 | return false; |
| 569 | } |
| 570 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 571 | return ret; |
| 572 | } |
| 573 | |
| 574 | 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] | 575 | //Will benefit presentation / secondary-only layer. |
| 576 | if((mDpy > HWC_DISPLAY_PRIMARY) && |
| 577 | (list->numHwLayers - 1) > MAX_SEC_LAYERS) { |
| 578 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 579 | return false; |
| 580 | } |
| 581 | |
| 582 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 583 | for(int i = 0; i < numAppLayers; i++) { |
| 584 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 585 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 586 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); |
| 587 | return false; |
| 588 | } |
Yang Xu | 9c1eb2b | 2013-11-26 01:28:13 +0800 | [diff] [blame] | 589 | |
| 590 | //For 8x26, if there is only one layer which needs scale for secondary |
| 591 | //while no scale for primary display, DMA pipe is occupied by primary. |
| 592 | //If need to fall back to GLES composition, virtual display lacks DMA |
| 593 | //pipe and error is reported. |
| 594 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 595 | mDpy >= HWC_DISPLAY_EXTERNAL && |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 596 | qhwc::needsScaling(layer)) |
Yang Xu | 9c1eb2b | 2013-11-26 01:28:13 +0800 | [diff] [blame] | 597 | return false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 598 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 599 | mCurrentFrame.fbCount = 0; |
| 600 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 601 | memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, |
| 602 | sizeof(mCurrentFrame.isFBComposed)); |
| 603 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - |
| 604 | mCurrentFrame.dropCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 605 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 606 | if(sEnable4k2kYUVSplit){ |
| 607 | modifymdpCountfor4k2k(ctx, list); |
| 608 | } |
| 609 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 610 | if(!resourceCheck(ctx, list)) { |
| 611 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 612 | return false; |
| 613 | } |
| 614 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 615 | return true; |
| 616 | } |
| 617 | |
| 618 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 619 | { |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 620 | if(!sEnableMixedMode) { |
| 621 | //Mixed mode is disabled. No need to even try caching. |
| 622 | return false; |
| 623 | } |
| 624 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 625 | bool ret = false; |
| 626 | if(isLoadBasedCompDoable(ctx, list)) { |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 627 | ret = loadBasedCompPreferGPU(ctx, list) || |
| 628 | loadBasedCompPreferMDP(ctx, list); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | if(!ret) { |
| 632 | ret = cacheBasedComp(ctx, list); |
| 633 | } |
| 634 | |
| 635 | return ret; |
| 636 | } |
| 637 | |
| 638 | bool MDPComp::cacheBasedComp(hwc_context_t *ctx, |
| 639 | hwc_display_contents_1_t* list) { |
| 640 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 641 | mCurrentFrame.reset(numAppLayers); |
| 642 | updateLayerCache(ctx, list); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 643 | |
| 644 | //If an MDP marked layer is unsupported cannot do partial MDP Comp |
| 645 | for(int i = 0; i < numAppLayers; i++) { |
| 646 | if(!mCurrentFrame.isFBComposed[i]) { |
| 647 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 648 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 649 | ALOGD_IF(isDebug(), "%s: Unsupported layer in list", |
| 650 | __FUNCTION__); |
| 651 | return false; |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 656 | updateYUV(ctx, list, false /*secure only*/); |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 657 | bool ret = markLayersForCaching(ctx, list); //sets up fbZ also |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 658 | if(!ret) { |
| 659 | ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); |
| 660 | return false; |
| 661 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 662 | |
| 663 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 664 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 665 | if(sEnable4k2kYUVSplit){ |
| 666 | modifymdpCountfor4k2k(ctx, list); |
| 667 | } |
| 668 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 669 | //Will benefit cases where a video has non-updating background. |
| 670 | if((mDpy > HWC_DISPLAY_PRIMARY) and |
| 671 | (mdpCount > MAX_SEC_LAYERS)) { |
| 672 | ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); |
| 673 | return false; |
| 674 | } |
| 675 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 676 | if(!resourceCheck(ctx, list)) { |
| 677 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 678 | return false; |
| 679 | } |
| 680 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 681 | return true; |
| 682 | } |
| 683 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 684 | bool MDPComp::loadBasedCompPreferGPU(hwc_context_t *ctx, |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 685 | hwc_display_contents_1_t* list) { |
| 686 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 687 | mCurrentFrame.reset(numAppLayers); |
| 688 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 689 | int stagesForMDP = min(sMaxPipesPerMixer, ctx->mOverlay->availablePipes( |
| 690 | mDpy, Overlay::MIXER_DEFAULT)); |
| 691 | //If MDP has X possible stages, it can take X layers. |
| 692 | const int batchSize = numAppLayers - (stagesForMDP - 1); //1 for FB |
| 693 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 694 | if(batchSize <= 0) { |
| 695 | ALOGD_IF(isDebug(), "%s: Not attempting", __FUNCTION__); |
| 696 | return false; |
| 697 | } |
| 698 | |
| 699 | int minBatchStart = -1; |
| 700 | size_t minBatchPixelCount = SIZE_MAX; |
| 701 | |
| 702 | for(int i = 0; i <= numAppLayers - batchSize; i++) { |
| 703 | uint32_t batchPixelCount = 0; |
| 704 | for(int j = i; j < i + batchSize; j++) { |
| 705 | hwc_layer_1_t* layer = &list->hwLayers[j]; |
Arun Kumar K.R | 91090c7 | 2013-10-28 19:40:18 -0700 | [diff] [blame] | 706 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 707 | batchPixelCount += (crop.right - crop.left) * |
| 708 | (crop.bottom - crop.top); |
| 709 | } |
| 710 | |
| 711 | if(batchPixelCount < minBatchPixelCount) { |
| 712 | minBatchPixelCount = batchPixelCount; |
| 713 | minBatchStart = i; |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | if(minBatchStart < 0) { |
| 718 | ALOGD_IF(isDebug(), "%s: No batch found batchSize %d numAppLayers %d", |
| 719 | __FUNCTION__, batchSize, numAppLayers); |
| 720 | return false; |
| 721 | } |
| 722 | |
| 723 | for(int i = 0; i < numAppLayers; i++) { |
| 724 | if(i < minBatchStart || i >= minBatchStart + batchSize) { |
| 725 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 726 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 727 | ALOGD_IF(isDebug(), "%s: MDP unsupported layer found at %d", |
| 728 | __FUNCTION__, i); |
| 729 | return false; |
| 730 | } |
| 731 | mCurrentFrame.isFBComposed[i] = false; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | mCurrentFrame.fbZ = minBatchStart; |
| 736 | mCurrentFrame.fbCount = batchSize; |
| 737 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - batchSize; |
| 738 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 739 | if(sEnable4k2kYUVSplit){ |
| 740 | modifymdpCountfor4k2k(ctx, list); |
| 741 | } |
| 742 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 743 | if(!resourceCheck(ctx, list)) { |
| 744 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 745 | return false; |
| 746 | } |
| 747 | |
| 748 | ALOGD_IF(isDebug(), "%s: fbZ %d batchSize %d", |
| 749 | __FUNCTION__, mCurrentFrame.fbZ, batchSize); |
| 750 | return true; |
| 751 | } |
| 752 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 753 | bool MDPComp::loadBasedCompPreferMDP(hwc_context_t *ctx, |
| 754 | hwc_display_contents_1_t* list) { |
| 755 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 756 | //TODO get the ib from sysfs node. |
| 757 | //Full screen is from ib perspective, not actual full screen |
| 758 | const int bpp = 4; |
| 759 | double panelRefRate = |
| 760 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 761 | |
| 762 | double bwLeft = sMaxBw - sBwClaimed; |
| 763 | |
| 764 | const int fullScreenLayers = bwLeft * 1000000000 / (ctx->dpyAttr[mDpy].xres |
| 765 | * ctx->dpyAttr[mDpy].yres * bpp * panelRefRate); |
| 766 | |
| 767 | const int fbBatchSize = numAppLayers - (fullScreenLayers - 1); |
| 768 | //If batch size is not at least 2, we aren't really preferring MDP, since |
| 769 | //only 1 layer going to GPU could actually translate into an entire FB |
| 770 | //needed to be fetched by MDP, thus needing more b/w rather than less. |
| 771 | if(fbBatchSize < 2 || fbBatchSize > numAppLayers) { |
| 772 | ALOGD_IF(isDebug(), "%s: Not attempting", __FUNCTION__); |
| 773 | return false; |
| 774 | } |
| 775 | |
| 776 | //Top-most layers constitute FB batch |
| 777 | const int fbBatchStart = numAppLayers - fbBatchSize; |
| 778 | |
| 779 | //Bottom-most layers constitute MDP batch |
| 780 | for(int i = 0; i < fbBatchStart; i++) { |
| 781 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 782 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 783 | ALOGD_IF(isDebug(), "%s: MDP unsupported layer found at %d", |
| 784 | __FUNCTION__, i); |
| 785 | return false; |
| 786 | } |
| 787 | mCurrentFrame.isFBComposed[i] = false; |
| 788 | } |
| 789 | |
| 790 | mCurrentFrame.fbZ = fbBatchStart; |
| 791 | mCurrentFrame.fbCount = fbBatchSize; |
| 792 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - fbBatchSize; |
| 793 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 794 | if(sEnable4k2kYUVSplit){ |
| 795 | modifymdpCountfor4k2k(ctx, list); |
| 796 | } |
| 797 | |
Saurabh Shah | b772ae3 | 2013-11-18 15:40:02 -0800 | [diff] [blame] | 798 | if(!resourceCheck(ctx, list)) { |
| 799 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
| 800 | return false; |
| 801 | } |
| 802 | |
| 803 | ALOGD_IF(isDebug(), "%s: FB Z %d, num app layers %d, MDP Batch Size %d", |
| 804 | __FUNCTION__, mCurrentFrame.fbZ, numAppLayers, |
| 805 | numAppLayers - fbBatchSize); |
| 806 | |
| 807 | return true; |
| 808 | } |
| 809 | |
Saurabh Shah | 8028e3b | 2013-10-15 12:27:59 -0700 | [diff] [blame] | 810 | bool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx, |
| 811 | hwc_display_contents_1_t* list) { |
| 812 | if(mDpy or isSecurePresent(ctx, mDpy) or |
| 813 | not (list->flags & HWC_GEOMETRY_CHANGED)) { |
| 814 | return false; |
| 815 | } |
| 816 | return true; |
| 817 | } |
| 818 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 819 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 820 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 821 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 822 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 823 | mCurrentFrame.reset(numAppLayers); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 824 | updateYUV(ctx, list, secureOnly); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 825 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 826 | |
| 827 | if(!isYuvPresent(ctx, mDpy)) { |
| 828 | return false; |
| 829 | } |
| 830 | |
Jeykumar Sankaran | f42f0d8 | 2013-11-08 18:09:20 -0800 | [diff] [blame] | 831 | /* Bail out if we are processing only secured video layers |
| 832 | * and we dont have any */ |
| 833 | if(!isSecurePresent(ctx, mDpy) && secureOnly){ |
| 834 | return false; |
| 835 | } |
| 836 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 837 | if(!mdpCount) |
| 838 | return false; |
| 839 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 840 | if(!resourceCheck(ctx, list)) { |
| 841 | ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 842 | return false; |
| 843 | } |
| 844 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 845 | return true; |
| 846 | } |
| 847 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 848 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 849 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 850 | bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 851 | |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 852 | if(isSkipLayer(layer) && !extAnimBlockFeature) { |
| 853 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 854 | return false; |
| 855 | } |
| 856 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 857 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 858 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 859 | return false; |
| 860 | } |
| 861 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 862 | if(isSecuring(ctx, layer)) { |
| 863 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 864 | return false; |
| 865 | } |
| 866 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 867 | if(!isValidDimension(ctx, layer)) { |
| 868 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 869 | __FUNCTION__); |
| 870 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 871 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 872 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 873 | if(layer->planeAlpha < 0xFF) { |
| 874 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 875 | in video only mode", |
| 876 | __FUNCTION__); |
| 877 | return false; |
| 878 | } |
| 879 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 880 | return true; |
| 881 | } |
| 882 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 883 | /* starts at fromIndex and check for each layer to find |
| 884 | * if it it has overlapping with any Updating layer above it in zorder |
| 885 | * till the end of the batch. returns true if it finds any intersection */ |
| 886 | bool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, |
| 887 | int fromIndex, int toIndex) { |
| 888 | for(int i = fromIndex; i < toIndex; i++) { |
| 889 | if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { |
| 890 | if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { |
| 891 | return false; |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | return true; |
| 896 | } |
| 897 | |
| 898 | /* Checks if given layer at targetLayerIndex has any |
| 899 | * intersection with all the updating layers in beween |
| 900 | * fromIndex and toIndex. Returns true if it finds intersectiion */ |
| 901 | bool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, |
| 902 | int fromIndex, int toIndex, int targetLayerIndex) { |
| 903 | for(int i = fromIndex; i <= toIndex; i++) { |
| 904 | if(!mCurrentFrame.isFBComposed[i]) { |
| 905 | if(areLayersIntersecting(&list->hwLayers[i], |
| 906 | &list->hwLayers[targetLayerIndex])) { |
| 907 | return true; |
| 908 | } |
| 909 | } |
| 910 | } |
| 911 | return false; |
| 912 | } |
| 913 | |
| 914 | int MDPComp::getBatch(hwc_display_contents_1_t* list, |
| 915 | int& maxBatchStart, int& maxBatchEnd, |
| 916 | int& maxBatchCount) { |
| 917 | int i = 0; |
| 918 | int updatingLayersAbove = 0;//Updating layer count in middle of batch |
| 919 | int fbZOrder =-1; |
| 920 | while (i < mCurrentFrame.layerCount) { |
| 921 | int batchCount = 0; |
| 922 | int batchStart = i; |
| 923 | int batchEnd = i; |
| 924 | int fbZ = batchStart; |
| 925 | int firstZReverseIndex = -1; |
| 926 | while(i < mCurrentFrame.layerCount) { |
| 927 | if(!mCurrentFrame.isFBComposed[i]) { |
| 928 | if(!batchCount) { |
| 929 | i++; |
| 930 | break; |
| 931 | } |
| 932 | updatingLayersAbove++; |
| 933 | i++; |
| 934 | continue; |
| 935 | } else { |
| 936 | if(mCurrentFrame.drop[i]) { |
| 937 | i++; |
| 938 | continue; |
| 939 | } else if(updatingLayersAbove <= 0) { |
| 940 | batchCount++; |
| 941 | batchEnd = i; |
| 942 | i++; |
| 943 | continue; |
| 944 | } else { //Layer is FBComposed, not a drop & updatingLayer > 0 |
| 945 | |
| 946 | // We have a valid updating layer already. If layer-i not |
| 947 | // have overlapping with all updating layers in between |
| 948 | // batch-start and i, then we can add layer i to batch. |
| 949 | if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { |
| 950 | batchCount++; |
| 951 | batchEnd = i; |
| 952 | i++; |
| 953 | continue; |
| 954 | } else if(canPushBatchToTop(list, batchStart, i)) { |
| 955 | //If All the non-updating layers with in this batch |
| 956 | //does not have intersection with the updating layers |
| 957 | //above in z-order, then we can safely move the batch to |
| 958 | //higher z-order. Increment fbZ as it is moving up. |
| 959 | if( firstZReverseIndex < 0) { |
| 960 | firstZReverseIndex = i; |
| 961 | } |
| 962 | batchCount++; |
| 963 | batchEnd = i; |
| 964 | fbZ += updatingLayersAbove; |
| 965 | i++; |
| 966 | updatingLayersAbove = 0; |
| 967 | continue; |
| 968 | } else { |
| 969 | //both failed.start the loop again from here. |
| 970 | if(firstZReverseIndex >= 0) { |
| 971 | i = firstZReverseIndex; |
| 972 | } |
| 973 | break; |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | if(batchCount > maxBatchCount) { |
| 979 | maxBatchCount = batchCount; |
| 980 | maxBatchStart = batchStart; |
| 981 | maxBatchEnd = batchEnd; |
| 982 | fbZOrder = fbZ; |
| 983 | } |
| 984 | } |
| 985 | return fbZOrder; |
| 986 | } |
| 987 | |
| 988 | bool MDPComp::markLayersForCaching(hwc_context_t* ctx, |
| 989 | hwc_display_contents_1_t* list) { |
| 990 | /* Idea is to keep as many non-updating(cached) layers in FB and |
| 991 | * send rest of them through MDP. This is done in 2 steps. |
| 992 | * 1. Find the maximum contiguous batch of non-updating layers. |
| 993 | * 2. See if we can improve this batch size for caching by adding |
| 994 | * opaque layers around the batch, if they don't have |
| 995 | * any overlapping with the updating layers in between. |
| 996 | * NEVER mark an updating layer for caching. |
| 997 | * But cached ones can be marked for MDP */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 998 | |
| 999 | int maxBatchStart = -1; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1000 | int maxBatchEnd = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1001 | int maxBatchCount = 0; |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1002 | int fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1003 | |
| 1004 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1005 | if(!mCurrentFrame.fbCount) { |
| 1006 | mCurrentFrame.fbZ = -1; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1007 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1008 | } |
| 1009 | if(!mCurrentFrame.mdpCount) { |
| 1010 | mCurrentFrame.fbZ = 0; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1011 | return true; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1012 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1013 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1014 | fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1015 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1016 | /* reset rest of the layers lying inside ROI for MDP comp */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1017 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1018 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1019 | if((i < maxBatchStart || i > maxBatchEnd) && |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1020 | mCurrentFrame.isFBComposed[i]){ |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1021 | if(!mCurrentFrame.drop[i]){ |
| 1022 | //If an unsupported layer is being attempted to |
| 1023 | //be pulled out we should fail |
| 1024 | if(not isSupportedForMDPComp(ctx, layer)) { |
| 1025 | return false; |
| 1026 | } |
| 1027 | mCurrentFrame.isFBComposed[i] = false; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1028 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1029 | } |
| 1030 | } |
| 1031 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1032 | // update the frame data |
| 1033 | mCurrentFrame.fbZ = fbZ; |
| 1034 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1035 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1036 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1037 | |
| 1038 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1039 | mCurrentFrame.fbCount); |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1040 | |
| 1041 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1042 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1043 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1044 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1045 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1046 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1047 | int fbCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1048 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1049 | for(int i = 0; i < numAppLayers; i++) { |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1050 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1051 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1052 | if(!mCurrentFrame.drop[i]) |
| 1053 | fbCount++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1054 | mCurrentFrame.isFBComposed[i] = true; |
| 1055 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1056 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1057 | } |
| 1058 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1059 | |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1060 | mCurrentFrame.fbCount = fbCount; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1061 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount |
| 1062 | - mCurrentFrame.dropCount; |
Saurabh Shah | e9bc60f | 2013-08-29 12:58:06 -0700 | [diff] [blame] | 1063 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1064 | ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d" |
| 1065 | ,__FUNCTION__, mCurrentFrame.mdpCount, mCurrentFrame.fbCount, |
| 1066 | mCurrentFrame.dropCount); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1067 | } |
| 1068 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1069 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
| 1070 | bool secureOnly) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1071 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 1072 | if(!nYuvCount && mDpy) { |
| 1073 | //Reset "No animation on external display" related parameters. |
| 1074 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 1075 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 1076 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 1077 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 1078 | ctx->mPrevTransformVideo = 0; |
| 1079 | return; |
| 1080 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1081 | for(int index = 0;index < nYuvCount; index++){ |
| 1082 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 1083 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 1084 | |
| 1085 | if(!isYUVDoable(ctx, layer)) { |
| 1086 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 1087 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 1088 | mCurrentFrame.fbCount++; |
| 1089 | } |
| 1090 | } else { |
| 1091 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1092 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1093 | if(!secureOnly || isSecureBuffer(hnd)) { |
| 1094 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 1095 | mCurrentFrame.fbCount--; |
| 1096 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1097 | } |
| 1098 | } |
| 1099 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1100 | |
| 1101 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1102 | mCurrentFrame.fbCount - mCurrentFrame.dropCount; |
| 1103 | ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1104 | mCurrentFrame.fbCount); |
| 1105 | } |
| 1106 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1107 | 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] | 1108 | if(!allocLayerPipes(ctx, list)) { |
| 1109 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1110 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1114 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1115 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1116 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1117 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1118 | |
Prabhanjan Kandula | 9bd5f64 | 2013-09-25 17:00:36 +0530 | [diff] [blame] | 1119 | //Leave fbZ for framebuffer. CACHE/GLES layers go here. |
| 1120 | if(mdpNextZOrder == mCurrentFrame.fbZ) { |
| 1121 | mdpNextZOrder++; |
| 1122 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1123 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1124 | cur_pipe->zOrder = mdpNextZOrder++; |
| 1125 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1126 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1127 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1128 | if(configure4k2kYuv(ctx, layer, |
| 1129 | mCurrentFrame.mdpToLayer[mdpIndex]) |
| 1130 | != 0 ){ |
| 1131 | ALOGD_IF(isDebug(), "%s: Failed to configure split pipes \ |
| 1132 | for layer %d",__FUNCTION__, index); |
| 1133 | return false; |
| 1134 | } |
| 1135 | else{ |
| 1136 | mdpNextZOrder++; |
| 1137 | } |
| 1138 | continue; |
| 1139 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1140 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 1141 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1142 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1143 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1144 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1145 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1146 | } |
| 1147 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1148 | return true; |
| 1149 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1150 | |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1151 | bool MDPComp::resourceCheck(hwc_context_t *ctx, |
| 1152 | hwc_display_contents_1_t *list) { |
| 1153 | const bool fbUsed = mCurrentFrame.fbCount; |
| 1154 | if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { |
| 1155 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 1156 | return false; |
| 1157 | } |
| 1158 | |
| 1159 | if(!arePipesAvailable(ctx, list)) { |
| 1160 | return false; |
| 1161 | } |
| 1162 | |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1163 | double size = calcMDPBytesRead(ctx, list); |
Saurabh Shah | 173f424 | 2013-11-20 09:50:12 -0800 | [diff] [blame] | 1164 | if(!bandwidthCheck(ctx, size)) { |
| 1165 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 1166 | return false; |
| 1167 | } |
| 1168 | |
| 1169 | return true; |
| 1170 | } |
| 1171 | |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1172 | double MDPComp::calcMDPBytesRead(hwc_context_t *ctx, |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1173 | hwc_display_contents_1_t* list) { |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1174 | double size = 0; |
| 1175 | const double GIG = 1000000000.0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1176 | |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1177 | //Skip for targets where no device tree value for bw is supplied |
| 1178 | if(sMaxBw <= 0.0) { |
| 1179 | return 0.0; |
| 1180 | } |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1181 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1182 | for (uint32_t i = 0; i < list->numHwLayers - 1; i++) { |
| 1183 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1184 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1185 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1186 | if (hnd) { |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 1187 | hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 1188 | hwc_rect_t dst = layer->displayFrame; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1189 | float bpp = ((float)hnd->size) / (hnd->width * hnd->height); |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1190 | size += (bpp * (crop.right - crop.left) * |
| 1191 | (crop.bottom - crop.top) * |
| 1192 | ctx->dpyAttr[mDpy].yres / (dst.bottom - dst.top)) / |
| 1193 | GIG; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 1194 | } |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | if(mCurrentFrame.fbCount) { |
| 1199 | hwc_layer_1_t* layer = &list->hwLayers[list->numHwLayers - 1]; |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1200 | int tempw, temph; |
| 1201 | size += (getBufferSizeAndDimensions( |
| 1202 | layer->displayFrame.right - layer->displayFrame.left, |
| 1203 | layer->displayFrame.bottom - layer->displayFrame.top, |
| 1204 | HAL_PIXEL_FORMAT_RGBA_8888, |
| 1205 | tempw, temph)) / GIG; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
| 1208 | return size; |
| 1209 | } |
| 1210 | |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1211 | bool MDPComp::bandwidthCheck(hwc_context_t *ctx, const double& size) { |
| 1212 | //Skip for targets where no device tree value for bw is supplied |
| 1213 | if(sMaxBw <= 0.0) { |
| 1214 | return true; |
| 1215 | } |
| 1216 | |
| 1217 | double panelRefRate = |
| 1218 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 1219 | if((size * panelRefRate) > (sMaxBw - sBwClaimed)) { |
| 1220 | return false; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1221 | } |
| 1222 | return true; |
| 1223 | } |
| 1224 | |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1225 | bool MDPComp::hwLimitationsCheck(hwc_context_t* ctx, |
| 1226 | hwc_display_contents_1_t* list) { |
| 1227 | |
| 1228 | //A-family hw limitation: |
| 1229 | //If a layer need alpha scaling, MDP can not support. |
| 1230 | if(ctx->mMDP.version < qdutils::MDSS_V5) { |
| 1231 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1232 | if(!mCurrentFrame.isFBComposed[i] && |
| 1233 | isAlphaScaled( &list->hwLayers[i])) { |
| 1234 | ALOGD_IF(isDebug(), "%s:frame needs alphaScaling",__FUNCTION__); |
| 1235 | return false; |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | // On 8x26 & 8974 hw, we have a limitation of downscaling+blending. |
| 1241 | //If multiple layers requires downscaling and also they are overlapping |
| 1242 | //fall back to GPU since MDSS can not handle it. |
| 1243 | if(qdutils::MDPVersion::getInstance().is8x74v2() || |
| 1244 | qdutils::MDPVersion::getInstance().is8x26()) { |
| 1245 | for(int i = 0; i < mCurrentFrame.layerCount-1; ++i) { |
| 1246 | hwc_layer_1_t* botLayer = &list->hwLayers[i]; |
| 1247 | if(!mCurrentFrame.isFBComposed[i] && |
| 1248 | isDownscaleRequired(botLayer)) { |
| 1249 | //if layer-i is marked for MDP and needs downscaling |
| 1250 | //check if any MDP layer on top of i & overlaps with layer-i |
| 1251 | for(int j = i+1; j < mCurrentFrame.layerCount; ++j) { |
| 1252 | hwc_layer_1_t* topLayer = &list->hwLayers[j]; |
| 1253 | if(!mCurrentFrame.isFBComposed[j] && |
| 1254 | isDownscaleRequired(topLayer)) { |
| 1255 | hwc_rect_t r = getIntersection(botLayer->displayFrame, |
| 1256 | topLayer->displayFrame); |
| 1257 | if(isValidRect(r)) |
| 1258 | return false; |
| 1259 | } |
| 1260 | } |
| 1261 | } |
| 1262 | } |
| 1263 | } |
| 1264 | return true; |
| 1265 | } |
| 1266 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1267 | 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] | 1268 | int ret = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1269 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1270 | MDPVersion& mdpVersion = qdutils::MDPVersion::getInstance(); |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 1271 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1272 | //reset old data |
| 1273 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1274 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1275 | mCurrentFrame.dropCount = 0; |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1276 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1277 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 1278 | //do not cache the information for next draw cycle. |
| 1279 | if(numLayers > MAX_NUM_APP_LAYERS) { |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1280 | mCachedFrame.updateCounts(mCurrentFrame); |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 1281 | ALOGI("%s: Number of App layers exceeded the limit ", |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1282 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1283 | ret = -1; |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame] | 1284 | return ret; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1285 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1286 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1287 | //Hard conditions, if not met, cannot do MDP comp |
| 1288 | if(!isFrameDoable(ctx)) { |
| 1289 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 1290 | __FUNCTION__); |
| 1291 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1292 | ret = -1; |
| 1293 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1294 | } |
| 1295 | |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1296 | generateROI(ctx, list); |
| 1297 | |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1298 | //Convert from kbps to gbps |
| 1299 | sMaxBw = mdpVersion.getHighBw() / 1000000.0; |
| 1300 | if (ctx->mExtDisplay->isConnected() || ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 1301 | sMaxBw = mdpVersion.getLowBw() / 1000000.0; |
| 1302 | } |
| 1303 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1304 | //Check whether layers marked for MDP Composition is actually doable. |
| 1305 | if(isFullFrameDoable(ctx, list)) { |
| 1306 | mCurrentFrame.map(); |
| 1307 | //Configure framebuffer first if applicable |
| 1308 | if(mCurrentFrame.fbZ >= 0) { |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1309 | //If 4k2k Yuv layer split is possible, and if |
| 1310 | //fbz is above 4k2k layer, increment fb zorder by 1 |
| 1311 | //as we split 4k2k layer and increment zorder for right half |
| 1312 | //of the layer |
| 1313 | if(sEnable4k2kYUVSplit){ |
| 1314 | int n4k2kYuvCount = ctx->listStats[mDpy].yuv4k2kCount; |
| 1315 | for(int index = 0; index < n4k2kYuvCount; index++){ |
| 1316 | int n4k2kYuvIndex = |
| 1317 | ctx->listStats[mDpy].yuv4k2kIndices[index]; |
| 1318 | if(mCurrentFrame.fbZ > n4k2kYuvIndex){ |
| 1319 | mCurrentFrame.fbZ += 1; |
| 1320 | } |
| 1321 | } |
| 1322 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1323 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 1324 | mCurrentFrame.fbZ)) { |
| 1325 | ALOGE("%s configure framebuffer failed", __func__); |
| 1326 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1327 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1328 | ret = -1; |
| 1329 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1330 | } |
| 1331 | } |
| 1332 | //Acquire and Program MDP pipes |
| 1333 | if(!programMDP(ctx, list)) { |
| 1334 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1335 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1336 | ret = -1; |
| 1337 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1338 | } else { //Success |
| 1339 | //Any change in composition types needs an FB refresh |
| 1340 | mCurrentFrame.needsRedraw = false; |
Jeykumar Sankaran | 988d368 | 2013-11-15 11:57:16 -0800 | [diff] [blame] | 1341 | if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1342 | (list->flags & HWC_GEOMETRY_CHANGED) || |
Prabhanjan Kandula | 2243aa6 | 2013-10-24 12:58:55 +0530 | [diff] [blame] | 1343 | isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1344 | mCurrentFrame.needsRedraw = true; |
| 1345 | } |
| 1346 | } |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1347 | } else if(isOnlyVideoDoable(ctx, list, false /*secure only*/) || |
| 1348 | isOnlyVideoDoable(ctx, list, true /*secure only*/)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1349 | //All layers marked for MDP comp cannot be bypassed. |
| 1350 | //Try to compose atleast YUV layers through MDP comp and let |
| 1351 | //all the RGB layers compose in FB |
| 1352 | //Destination over |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1353 | |
| 1354 | if(sEnable4k2kYUVSplit){ |
| 1355 | modifymdpCountfor4k2k(ctx, list); |
| 1356 | } |
| 1357 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1358 | mCurrentFrame.fbZ = -1; |
| 1359 | if(mCurrentFrame.fbCount) |
| 1360 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
| 1361 | |
| 1362 | mCurrentFrame.map(); |
| 1363 | |
| 1364 | //Configure framebuffer first if applicable |
| 1365 | if(mCurrentFrame.fbZ >= 0) { |
| 1366 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 1367 | ALOGE("%s configure framebuffer failed", __func__); |
| 1368 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1369 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1370 | ret = -1; |
| 1371 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1372 | } |
| 1373 | } |
Saurabh Shah | c7e4f1d | 2013-12-05 17:57:44 -0800 | [diff] [blame] | 1374 | if(!programMDP(ctx, list)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1375 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 1376 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1377 | ret = -1; |
| 1378 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1379 | } |
| 1380 | } else { |
| 1381 | reset(numLayers, list); |
Jeykumar Sankaran | 862d87c | 2013-11-08 16:47:26 -0800 | [diff] [blame] | 1382 | memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); |
| 1383 | mCurrentFrame.dropCount = 0; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1384 | ret = -1; |
| 1385 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1386 | } |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1387 | //UpdateLayerFlags |
| 1388 | setMDPCompLayerFlags(ctx, list); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 1389 | mCachedFrame.cacheAll(list); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 1390 | mCachedFrame.updateCounts(mCurrentFrame); |
| 1391 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 1392 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1393 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 1394 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1395 | android::String8 sDump(""); |
| 1396 | dump(sDump); |
| 1397 | ALOGE("%s",sDump.string()); |
| 1398 | } |
| 1399 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1400 | exit: |
Saurabh Shah | f5f2b13 | 2013-11-25 12:08:35 -0800 | [diff] [blame] | 1401 | double panelRefRate = |
| 1402 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 1403 | sBwClaimed += calcMDPBytesRead(ctx, list) * panelRefRate; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 1404 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1405 | } |
| 1406 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1407 | bool MDPComp::allocSplitVGPipesfor4k2k(hwc_context_t *ctx, |
| 1408 | hwc_display_contents_1_t* list, int index) { |
| 1409 | |
| 1410 | bool bRet = true; |
| 1411 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1412 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1413 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1414 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
| 1415 | info.pipeInfo = new MdpYUVPipeInfo; |
| 1416 | info.rot = NULL; |
| 1417 | MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo; |
| 1418 | ePipeType type = MDPCOMP_OV_VG; |
| 1419 | |
| 1420 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1421 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1422 | |
| 1423 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1424 | if(pipe_info.lIndex == ovutils::OV_INVALID){ |
| 1425 | bRet = false; |
| 1426 | ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed", |
| 1427 | __FUNCTION__); |
| 1428 | } |
| 1429 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
| 1430 | if(pipe_info.rIndex == ovutils::OV_INVALID){ |
| 1431 | bRet = false; |
| 1432 | ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed", |
| 1433 | __FUNCTION__); |
| 1434 | } |
| 1435 | return bRet; |
| 1436 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1437 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1438 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1439 | void MDPCompNonSplit::modifymdpCountfor4k2k(hwc_context_t *ctx, |
| 1440 | hwc_display_contents_1_t* list){ |
| 1441 | //As we split 4kx2k yuv layer and program to 2 VG pipes |
| 1442 | //(if available) increase mdpcount accordingly |
| 1443 | mCurrentFrame.mdpCount += ctx->listStats[mDpy].yuv4k2kCount; |
| 1444 | } |
| 1445 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1446 | /* |
| 1447 | * Configures pipe(s) for MDP composition |
| 1448 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1449 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1450 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1451 | MdpPipeInfoNonSplit& mdp_info = |
| 1452 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1453 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 1454 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1455 | eIsFg isFg = IS_FG_OFF; |
| 1456 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1457 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1458 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 1459 | __FUNCTION__, layer, zOrder, dest); |
| 1460 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1461 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1462 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1463 | } |
| 1464 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1465 | bool MDPCompNonSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1466 | hwc_display_contents_1_t* list) { |
| 1467 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1468 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 1469 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 1470 | |
| 1471 | //Reserve pipe for FB |
| 1472 | if(mCurrentFrame.fbCount) |
| 1473 | availPipes -= 1; |
| 1474 | |
| 1475 | if(numPipesNeeded > availPipes) { |
| 1476 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 1477 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 1478 | return false; |
| 1479 | } |
| 1480 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1481 | if(not areVGPipesAvailable(ctx, list)) { |
| 1482 | return false; |
| 1483 | } |
| 1484 | |
| 1485 | return true; |
| 1486 | } |
| 1487 | |
| 1488 | bool MDPCompNonSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1489 | hwc_display_contents_1_t* list) { |
| 1490 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1491 | int pipesNeeded = 0; |
| 1492 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1493 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1494 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1495 | hwc_rect_t dst = layer->displayFrame; |
| 1496 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1497 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1498 | pipesNeeded = pipesNeeded + 2; |
| 1499 | } |
| 1500 | else if(isYuvBuffer(hnd)) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1501 | pipesNeeded++; |
| 1502 | } |
| 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1507 | if(pipesNeeded > availableVGPipes) { |
| 1508 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1509 | "dpy %d needed %d, avail %d", |
| 1510 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1511 | return false; |
| 1512 | } |
| 1513 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1514 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1515 | } |
| 1516 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1517 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1518 | hwc_display_contents_1_t* list) { |
| 1519 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1520 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1521 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1522 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 1523 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1524 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1525 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1526 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1527 | continue; |
| 1528 | } |
| 1529 | } |
| 1530 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1531 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1532 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1533 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1534 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1535 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1536 | ePipeType type = MDPCOMP_OV_ANY; |
| 1537 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1538 | if(isYuvBuffer(hnd)) { |
| 1539 | type = MDPCOMP_OV_VG; |
Prabhanjan Kandula | 21918db | 2013-11-26 15:51:58 +0530 | [diff] [blame] | 1540 | } else if(!qhwc::needsScaling(layer) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1541 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1542 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 1543 | type = MDPCOMP_OV_DMA; |
| 1544 | } |
| 1545 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1546 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1547 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1548 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 1549 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1550 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1551 | } |
| 1552 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1553 | return true; |
| 1554 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1555 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1556 | int MDPCompNonSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 1557 | PipeLayerPair& PipeLayerPair) { |
| 1558 | MdpYUVPipeInfo& mdp_info = |
| 1559 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 1560 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1561 | eIsFg isFg = IS_FG_OFF; |
| 1562 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1563 | eDest lDest = mdp_info.lIndex; |
| 1564 | eDest rDest = mdp_info.rIndex; |
| 1565 | |
| 1566 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 1567 | lDest, rDest, &PipeLayerPair.rot); |
| 1568 | } |
| 1569 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1570 | 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] | 1571 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1572 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1573 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1574 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 1575 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1576 | |
| 1577 | if(!ctx || !list) { |
| 1578 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1579 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1580 | } |
| 1581 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1582 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1583 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1584 | return true; |
| 1585 | } |
| 1586 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1587 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1588 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1589 | idleInvalidator->markForSleep(); |
| 1590 | |
| 1591 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1592 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1593 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1594 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1595 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1596 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1597 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1598 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1599 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1600 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1601 | if(!hnd) { |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 1602 | if (!(layer->flags & HWC_COLOR_FILL)) { |
| 1603 | ALOGE("%s handle null", __FUNCTION__); |
| 1604 | return false; |
| 1605 | } |
| 1606 | // No PLAY for Color layer |
| 1607 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1608 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1609 | } |
| 1610 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1611 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1612 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1613 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 1614 | { |
| 1615 | MdpYUVPipeInfo& pipe_info = |
| 1616 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1617 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1618 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1619 | ovutils::eDest indexR = pipe_info.rIndex; |
| 1620 | int fd = hnd->fd; |
| 1621 | uint32_t offset = hnd->offset; |
| 1622 | if(rot) { |
| 1623 | rot->queueBuffer(fd, offset); |
| 1624 | fd = rot->getDstMemId(); |
| 1625 | offset = rot->getDstOffset(); |
| 1626 | } |
| 1627 | if(indexL != ovutils::OV_INVALID) { |
| 1628 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 1629 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1630 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 1631 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1632 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1633 | __FUNCTION__, mDpy); |
| 1634 | return false; |
| 1635 | } |
| 1636 | } |
| 1637 | |
| 1638 | if(indexR != ovutils::OV_INVALID) { |
| 1639 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 1640 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1641 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 1642 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1643 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1644 | __FUNCTION__, mDpy); |
| 1645 | return false; |
| 1646 | } |
| 1647 | } |
| 1648 | } |
| 1649 | else{ |
| 1650 | MdpPipeInfoNonSplit& pipe_info = |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1651 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1652 | ovutils::eDest dest = pipe_info.index; |
| 1653 | if(dest == ovutils::OV_INVALID) { |
| 1654 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1655 | return false; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1656 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1657 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1658 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1659 | continue; |
| 1660 | } |
| 1661 | |
| 1662 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1663 | using pipe: %d", __FUNCTION__, layer, |
| 1664 | hnd, dest ); |
| 1665 | |
| 1666 | int fd = hnd->fd; |
| 1667 | uint32_t offset = hnd->offset; |
| 1668 | |
| 1669 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1670 | if(rot) { |
| 1671 | if(!rot->queueBuffer(fd, offset)) |
| 1672 | return false; |
| 1673 | fd = rot->getDstMemId(); |
| 1674 | offset = rot->getDstOffset(); |
| 1675 | } |
| 1676 | |
| 1677 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 1678 | ALOGE("%s: queueBuffer failed for display:%d ", |
| 1679 | __FUNCTION__, mDpy); |
| 1680 | return false; |
| 1681 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1682 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1683 | |
| 1684 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1685 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1686 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1687 | } |
| 1688 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1689 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1690 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1691 | void MDPCompSplit::modifymdpCountfor4k2k(hwc_context_t *ctx, |
| 1692 | hwc_display_contents_1_t* list){ |
| 1693 | //if 4kx2k yuv layer is totally present in either in left half |
| 1694 | //or right half then try splitting the yuv layer to avoid decimation |
| 1695 | int n4k2kYuvCount = ctx->listStats[mDpy].yuv4k2kCount; |
| 1696 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1697 | for(int index = 0; index < n4k2kYuvCount; index++){ |
| 1698 | int n4k2kYuvIndex = ctx->listStats[mDpy].yuv4k2kIndices[index]; |
| 1699 | hwc_layer_1_t* layer = &list->hwLayers[n4k2kYuvIndex]; |
| 1700 | hwc_rect_t dst = layer->displayFrame; |
| 1701 | |
| 1702 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1703 | mCurrentFrame.mdpCount += 1; |
| 1704 | } |
| 1705 | } |
| 1706 | } |
| 1707 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1708 | int MDPCompSplit::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1709 | hwc_display_contents_1_t* list, |
| 1710 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1711 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1712 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1713 | |
| 1714 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1715 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1716 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1717 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1718 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1719 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1720 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1721 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1722 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1723 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1724 | } |
| 1725 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1726 | } |
| 1727 | return pipesNeeded; |
| 1728 | } |
| 1729 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1730 | bool MDPCompSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1731 | hwc_display_contents_1_t* list) { |
| 1732 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1733 | int totalPipesNeeded = 0; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1734 | |
| 1735 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1736 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1737 | int availPipes = ov.availablePipes(mDpy, i); |
| 1738 | |
| 1739 | //Reserve pipe(s)for FB |
| 1740 | if(mCurrentFrame.fbCount) |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1741 | numPipesNeeded += 1; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1742 | |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1743 | totalPipesNeeded += numPipesNeeded; |
| 1744 | |
| 1745 | //Per mixer check. |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1746 | if(numPipesNeeded > availPipes) { |
| 1747 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1748 | "dpy %d mixer %d needed %d, avail %d", |
| 1749 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1750 | return false; |
| 1751 | } |
| 1752 | } |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1753 | |
| 1754 | //Per display check, since unused pipes can get counted twice. |
| 1755 | int totalPipesAvailable = ov.availablePipes(mDpy); |
| 1756 | if(totalPipesNeeded > totalPipesAvailable) { |
| 1757 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1758 | "dpy %d needed %d, avail %d", |
| 1759 | __FUNCTION__, mDpy, totalPipesNeeded, totalPipesAvailable); |
| 1760 | return false; |
| 1761 | } |
| 1762 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1763 | if(not areVGPipesAvailable(ctx, list)) { |
| 1764 | return false; |
| 1765 | } |
| 1766 | |
| 1767 | return true; |
| 1768 | } |
| 1769 | |
| 1770 | bool MDPCompSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1771 | hwc_display_contents_1_t* list) { |
| 1772 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1773 | int pipesNeeded = 0; |
| 1774 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1775 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1776 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1777 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1778 | hwc_rect_t dst = layer->displayFrame; |
| 1779 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1780 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1781 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1782 | pipesNeeded = pipesNeeded + 2; |
| 1783 | continue; |
| 1784 | } |
| 1785 | } |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1786 | if(isYuvBuffer(hnd)) { |
| 1787 | if(dst.left < lSplit) { |
| 1788 | pipesNeeded++; |
| 1789 | } |
| 1790 | if(dst.right > lSplit) { |
| 1791 | pipesNeeded++; |
| 1792 | } |
| 1793 | } |
| 1794 | } |
| 1795 | } |
| 1796 | |
| 1797 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1798 | if(pipesNeeded > availableVGPipes) { |
| 1799 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1800 | "dpy %d needed %d, avail %d", |
| 1801 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1802 | return false; |
| 1803 | } |
| 1804 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1805 | return true; |
| 1806 | } |
| 1807 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1808 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1809 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1810 | ePipeType type) { |
| 1811 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1812 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1813 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1814 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1815 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1816 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1817 | |
| 1818 | if (dst.left < lSplit) { |
| 1819 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1820 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1821 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1822 | } |
| 1823 | |
| 1824 | if(dst.right > lSplit) { |
| 1825 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1826 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1827 | return false; |
| 1828 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1829 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1830 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1831 | } |
| 1832 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1833 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1834 | hwc_display_contents_1_t* list) { |
| 1835 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1836 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1837 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1838 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1839 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1840 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1841 | hwc_rect_t dst = layer->displayFrame; |
| 1842 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1843 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ |
| 1844 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1845 | if(allocSplitVGPipesfor4k2k(ctx, list, index)){ |
| 1846 | continue; |
| 1847 | } |
| 1848 | } |
| 1849 | } |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1850 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1851 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1852 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1853 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1854 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1855 | ePipeType type = MDPCOMP_OV_ANY; |
| 1856 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1857 | if(isYuvBuffer(hnd)) { |
| 1858 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 1859 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1860 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1861 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1862 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1863 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1864 | |
| 1865 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1866 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1867 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1868 | return false; |
| 1869 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1870 | } |
| 1871 | return true; |
| 1872 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1873 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1874 | int MDPCompSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 1875 | PipeLayerPair& PipeLayerPair) { |
| 1876 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1877 | hwc_rect_t dst = layer->displayFrame; |
| 1878 | if((dst.left > lSplit)||(dst.right < lSplit)){ |
| 1879 | MdpYUVPipeInfo& mdp_info = |
| 1880 | *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); |
| 1881 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1882 | eIsFg isFg = IS_FG_OFF; |
| 1883 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1884 | eDest lDest = mdp_info.lIndex; |
| 1885 | eDest rDest = mdp_info.rIndex; |
| 1886 | |
| 1887 | return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, |
| 1888 | lDest, rDest, &PipeLayerPair.rot); |
| 1889 | } |
| 1890 | else{ |
| 1891 | return configure(ctx, layer, PipeLayerPair); |
| 1892 | } |
| 1893 | } |
| 1894 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1895 | /* |
| 1896 | * Configures pipe(s) for MDP composition |
| 1897 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1898 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1899 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1900 | MdpPipeInfoSplit& mdp_info = |
| 1901 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1902 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1903 | eIsFg isFg = IS_FG_OFF; |
| 1904 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1905 | eDest lDest = mdp_info.lIndex; |
| 1906 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1907 | |
| 1908 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1909 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1910 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1911 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1912 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1913 | } |
| 1914 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1915 | 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] | 1916 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1917 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1918 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1919 | return true; |
| 1920 | } |
| 1921 | |
| 1922 | if(!ctx || !list) { |
| 1923 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1924 | return false; |
| 1925 | } |
| 1926 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1927 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1928 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1929 | return true; |
| 1930 | } |
| 1931 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1932 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1933 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1934 | idleInvalidator->markForSleep(); |
| 1935 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1936 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1937 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1938 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1939 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1940 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1941 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1942 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1943 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1944 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1945 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1946 | if(!hnd) { |
| 1947 | ALOGE("%s handle null", __FUNCTION__); |
| 1948 | return false; |
| 1949 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1950 | |
| 1951 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1952 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1953 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1954 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1955 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1956 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1957 | if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) |
| 1958 | { |
| 1959 | MdpYUVPipeInfo& pipe_info = |
| 1960 | *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1961 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
| 1962 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1963 | ovutils::eDest indexR = pipe_info.rIndex; |
| 1964 | int fd = hnd->fd; |
| 1965 | uint32_t offset = hnd->offset; |
| 1966 | if(rot) { |
| 1967 | rot->queueBuffer(fd, offset); |
| 1968 | fd = rot->getDstMemId(); |
| 1969 | offset = rot->getDstOffset(); |
| 1970 | } |
| 1971 | if(indexL != ovutils::OV_INVALID) { |
| 1972 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 1973 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1974 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 1975 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1976 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1977 | __FUNCTION__, mDpy); |
| 1978 | return false; |
| 1979 | } |
| 1980 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1981 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1982 | if(indexR != ovutils::OV_INVALID) { |
| 1983 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 1984 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 1985 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 1986 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1987 | ALOGE("%s: queueBuffer failed for display:%d", |
| 1988 | __FUNCTION__, mDpy); |
| 1989 | return false; |
| 1990 | } |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1991 | } |
| 1992 | } |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1993 | else{ |
| 1994 | MdpPipeInfoSplit& pipe_info = |
| 1995 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1996 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1997 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 1998 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1999 | ovutils::eDest indexR = pipe_info.rIndex; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2000 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2001 | int fd = hnd->fd; |
| 2002 | int offset = hnd->offset; |
| 2003 | |
| 2004 | if(ctx->mAD->isModeOn()) { |
| 2005 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 2006 | fd = ctx->mAD->getDstFd(ctx); |
| 2007 | offset = ctx->mAD->getDstOffset(ctx); |
| 2008 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2009 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2010 | |
radhakrishna | c9a6741 | 2013-09-25 17:40:42 +0530 | [diff] [blame] | 2011 | if(rot) { |
| 2012 | rot->queueBuffer(fd, offset); |
| 2013 | fd = rot->getDstMemId(); |
| 2014 | offset = rot->getDstOffset(); |
| 2015 | } |
| 2016 | |
| 2017 | //************* play left mixer ********** |
| 2018 | if(indexL != ovutils::OV_INVALID) { |
| 2019 | ovutils::eDest destL = (ovutils::eDest)indexL; |
| 2020 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2021 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 2022 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 2023 | ALOGE("%s: queueBuffer failed for left mixer", |
| 2024 | __FUNCTION__); |
| 2025 | return false; |
| 2026 | } |
| 2027 | } |
| 2028 | |
| 2029 | //************* play right mixer ********** |
| 2030 | if(indexR != ovutils::OV_INVALID) { |
| 2031 | ovutils::eDest destR = (ovutils::eDest)indexR; |
| 2032 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 2033 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 2034 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 2035 | ALOGE("%s: queueBuffer failed for right mixer", |
| 2036 | __FUNCTION__); |
| 2037 | return false; |
| 2038 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2039 | } |
| 2040 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2041 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2042 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 2043 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 2044 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2045 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2046 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 2047 | }; //namespace |
| 2048 | |