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