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