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