Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 3 | * Not a Contribution, Apache license notifications and license are retained |
| 4 | * for attribution purposes only. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 19 | #include <math.h> |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 20 | #include "hwc_mdpcomp.h" |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 21 | #include <sys/ioctl.h> |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 22 | #include "external.h" |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 23 | #include "virtual.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 24 | #include "qdMetaData.h" |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 25 | #include "mdp_version.h" |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 26 | #include "hwc_fbupdate.h" |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 27 | #include "hwc_ad.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 28 | #include <overlayRotator.h> |
| 29 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 30 | using namespace overlay; |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 31 | using namespace qdutils; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 32 | using namespace overlay::utils; |
| 33 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 34 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | namespace qhwc { |
| 36 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 37 | //==============MDPComp======================================================== |
| 38 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 39 | IdleInvalidator *MDPComp::idleInvalidator = NULL; |
| 40 | bool MDPComp::sIdleFallBack = false; |
| 41 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 42 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 43 | bool MDPComp::sEnableMixedMode = true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 44 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 45 | float MDPComp::sMaxBw = 2.3f; |
| 46 | uint32_t MDPComp::sCompBytesClaimed = 0; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 47 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 48 | MDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { |
| 49 | if(isDisplaySplit(ctx, dpy)) { |
| 50 | return new MDPCompSplit(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 51 | } |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 52 | return new MDPCompNonSplit(dpy); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 55 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 56 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 57 | void MDPComp::dump(android::String8& buf) |
| 58 | { |
Jeykumar Sankaran | 3c6bb04 | 2013-08-15 14:01:04 -0700 | [diff] [blame] | 59 | if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) |
| 60 | return; |
| 61 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 62 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 63 | (mDpy == 0) ? "\"PRIMARY\"" : |
| 64 | (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 65 | dumpsys_log(buf,"PREV_FRAME: layerCount:%2d mdpCount:%2d \ |
| 66 | cacheCount:%2d \n", mCachedFrame.layerCount, |
| 67 | mCachedFrame.mdpCount, mCachedFrame.cacheCount); |
| 68 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d \ |
| 69 | fbCount:%2d \n", mCurrentFrame.layerCount, |
| 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"), |
| 81 | mCurrentFrame.layerToMDP[index], |
| 82 | (mCurrentFrame.isFBComposed[index] ? |
| 83 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE") : "MDP"), |
| 84 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 85 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 86 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | bool MDPComp::init(hwc_context_t *ctx) { |
| 90 | |
| 91 | if(!ctx) { |
| 92 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 93 | return false; |
| 94 | } |
| 95 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 96 | char property[PROPERTY_VALUE_MAX]; |
| 97 | |
| 98 | sEnabled = false; |
| 99 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 100 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 101 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 102 | sEnabled = true; |
| 103 | } |
| 104 | |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 105 | sEnableMixedMode = true; |
| 106 | if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && |
| 107 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 108 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 109 | sEnableMixedMode = false; |
| 110 | } |
| 111 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 112 | sDebugLogs = false; |
| 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 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 125 | if(property_get("debug.mdpcomp.bw", property, "0") > 0) { |
| 126 | float val = atof(property); |
| 127 | if(val > 0.0f) { |
| 128 | sMaxBw = val; |
| 129 | } |
| 130 | } |
| 131 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 132 | if(ctx->mMDP.panel != MIPI_CMD_PANEL) { |
| 133 | // Idle invalidation is not necessary on command mode panels |
| 134 | long idle_timeout = DEFAULT_IDLE_TIME; |
| 135 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 136 | if(atoi(property) != 0) |
| 137 | idle_timeout = atoi(property); |
| 138 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 139 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 140 | //create Idle Invalidator only when not disabled through property |
| 141 | if(idle_timeout != -1) |
| 142 | idleInvalidator = IdleInvalidator::getInstance(); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 143 | |
Naseer Ahmed | f40f2c8 | 2013-08-14 16:42:40 -0400 | [diff] [blame] | 144 | if(idleInvalidator == NULL) { |
| 145 | ALOGE("%s: failed to instantiate idleInvalidator object", |
| 146 | __FUNCTION__); |
| 147 | } else { |
| 148 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 149 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 150 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 151 | return true; |
| 152 | } |
| 153 | |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 154 | void MDPComp::reset(const int& numLayers, hwc_display_contents_1_t* list) { |
| 155 | mCurrentFrame.reset(numLayers); |
| 156 | mCachedFrame.cacheAll(list); |
| 157 | mCachedFrame.updateCounts(mCurrentFrame); |
| 158 | } |
| 159 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 160 | void MDPComp::timeout_handler(void *udata) { |
| 161 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
| 162 | |
| 163 | if(!ctx) { |
| 164 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 165 | return; |
| 166 | } |
| 167 | |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 168 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 169 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 170 | return; |
| 171 | } |
| 172 | sIdleFallBack = true; |
| 173 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 174 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 177 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 178 | hwc_display_contents_1_t* list) { |
| 179 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 180 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 181 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 182 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 183 | if(!mCurrentFrame.isFBComposed[index]) { |
| 184 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 185 | layer->compositionType = HWC_OVERLAY; |
| 186 | layer->hints |= HWC_HINT_CLEAR_FB; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 187 | } else { |
| 188 | if(!mCurrentFrame.needsRedraw) |
| 189 | layer->compositionType = HWC_OVERLAY; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 190 | } |
| 191 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 192 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 193 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 194 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 195 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 196 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 197 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 198 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
| 199 | for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 200 | if(mdpToLayer[i].pipeInfo) { |
| 201 | delete mdpToLayer[i].pipeInfo; |
| 202 | mdpToLayer[i].pipeInfo = NULL; |
| 203 | //We dont own the rotator |
| 204 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 205 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 206 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 207 | |
| 208 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 209 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 210 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 211 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 212 | layerCount = numLayers; |
| 213 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 214 | mdpCount = 0; |
Saurabh Shah | 2f3895f | 2013-05-02 10:13:31 -0700 | [diff] [blame] | 215 | needsRedraw = true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 216 | fbZ = 0; |
| 217 | } |
| 218 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 219 | void MDPComp::FrameInfo::map() { |
| 220 | // populate layer and MDP maps |
| 221 | int mdpIdx = 0; |
| 222 | for(int idx = 0; idx < layerCount; idx++) { |
| 223 | if(!isFBComposed[idx]) { |
| 224 | mdpToLayer[mdpIdx].listIndex = idx; |
| 225 | layerToMDP[idx] = mdpIdx++; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 230 | MDPComp::LayerCache::LayerCache() { |
| 231 | reset(); |
| 232 | } |
| 233 | |
| 234 | void MDPComp::LayerCache::reset() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 235 | memset(&hnd, 0, sizeof(hnd)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 236 | mdpCount = 0; |
| 237 | cacheCount = 0; |
| 238 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 239 | fbZ = -1; |
| 240 | } |
| 241 | |
| 242 | void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) { |
| 243 | const int numAppLayers = list->numHwLayers - 1; |
| 244 | for(int i = 0; i < numAppLayers; i++) { |
| 245 | hnd[i] = list->hwLayers[i].handle; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
| 250 | mdpCount = curFrame.mdpCount; |
| 251 | cacheCount = curFrame.fbCount; |
| 252 | layerCount = curFrame.layerCount; |
| 253 | fbZ = curFrame.fbZ; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 256 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 257 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 258 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 259 | |
| 260 | if(!hnd) { |
| 261 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 262 | return false; |
| 263 | } |
| 264 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 265 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 266 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 267 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 268 | hwc_rect_t crop = layer->sourceCrop; |
| 269 | hwc_rect_t dst = layer->displayFrame; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 270 | |
| 271 | if(dst.left < 0 || dst.top < 0 || dst.right > hw_w || dst.bottom > hw_h) { |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 272 | hwc_rect_t scissor = {0, 0, hw_w, hw_h }; |
| 273 | qhwc::calculate_crop_rects(crop, dst, scissor, layer->transform); |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 276 | int crop_w = crop.right - crop.left; |
| 277 | int crop_h = crop.bottom - crop.top; |
| 278 | int dst_w = dst.right - dst.left; |
| 279 | int dst_h = dst.bottom - dst.top; |
| 280 | float w_dscale = ceilf((float)crop_w / (float)dst_w); |
| 281 | float h_dscale = ceilf((float)crop_h / (float)dst_h); |
| 282 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 283 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 284 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 285 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame] | 286 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 287 | * Fallback to GPU if height is less than 2. |
| 288 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 289 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 290 | return false; |
| 291 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 292 | const uint32_t downscale = |
| 293 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
| 294 | if(ctx->mMDP.version >= qdutils::MDSS_V5) { |
| 295 | /* Workaround for downscales larger than 4x. |
| 296 | * Will be removed once decimator block is enabled for MDSS |
| 297 | */ |
| 298 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 299 | if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale || |
| 300 | h_dscale > downscale) |
| 301 | return false; |
| 302 | } else { |
| 303 | if(w_dscale > 64 || h_dscale > 64) |
| 304 | return false; |
| 305 | } |
| 306 | } else { //A-family |
| 307 | if(w_dscale > downscale || h_dscale > downscale) |
| 308 | return false; |
| 309 | } |
| 310 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 311 | return true; |
| 312 | } |
| 313 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 314 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 315 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 316 | overlay::Overlay& ov = *ctx->mOverlay; |
| 317 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 318 | |
| 319 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 320 | case MDPCOMP_OV_DMA: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 321 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 322 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 323 | return mdp_pipe; |
| 324 | } |
| 325 | case MDPCOMP_OV_ANY: |
| 326 | case MDPCOMP_OV_RGB: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 327 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 328 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 329 | return mdp_pipe; |
| 330 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 331 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 332 | if(type == MDPCOMP_OV_RGB) { |
| 333 | //Requested only for RGB pipe |
| 334 | break; |
| 335 | } |
| 336 | case MDPCOMP_OV_VG: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 337 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 338 | default: |
| 339 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 340 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 341 | }; |
| 342 | return ovutils::OV_INVALID; |
| 343 | } |
| 344 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 345 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 346 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 347 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 348 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 349 | if(!isEnabled()) { |
| 350 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 351 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 352 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 353 | ctx->mVideoTransFlag && ctx->mVirtualDisplay->isConnected()) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 354 | //1 Padding round to shift pipes across mixers |
| 355 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 356 | __FUNCTION__); |
| 357 | ret = false; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 358 | } else if(ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring || |
| 359 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 360 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 361 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 362 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 363 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 364 | ctx->isPaddingRound = false; |
| 365 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 366 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 367 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 368 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 372 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 373 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 374 | hwc_display_contents_1_t* list){ |
| 375 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 376 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 377 | |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 378 | if(sIdleFallBack) { |
| 379 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 380 | return false; |
| 381 | } |
| 382 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 383 | if(mDpy > HWC_DISPLAY_PRIMARY){ |
| 384 | ALOGD_IF(isDebug(), "%s: Cannot support External display(s)", |
| 385 | __FUNCTION__); |
| 386 | return false; |
| 387 | } |
| 388 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 389 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 390 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 391 | __FUNCTION__, |
| 392 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 393 | return false; |
| 394 | } |
| 395 | |
Saurabh Shah | 9f084ad | 2013-05-02 11:28:09 -0700 | [diff] [blame] | 396 | if(ctx->listStats[mDpy].needsAlphaScale |
| 397 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
| 398 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
| 399 | return false; |
| 400 | } |
| 401 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 402 | //MDP composition is not efficient if layer needs rotator. |
| 403 | for(int i = 0; i < numAppLayers; ++i) { |
| 404 | // As MDP h/w supports flip operation, use MDP comp only for |
| 405 | // 180 transforms. Fail for any transform involving 90 (90, 270). |
| 406 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 407 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 408 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 409 | if(layer->transform & HWC_TRANSFORM_ROT_90) { |
| 410 | if(!isYuvBuffer(hnd) ) { |
| 411 | ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__); |
| 412 | return false; |
| 413 | }else if(!canUseRotator(ctx, mDpy)) { |
| 414 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 415 | return false; |
| 416 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 417 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 418 | if(!isValidDimension(ctx,layer)) { |
| 419 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 420 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 421 | return false; |
| 422 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 423 | |
| 424 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 425 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
| 426 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 427 | (ctx->dpyAttr[mDpy].xres > 1024) && |
| 428 | (layer->transform & HWC_TRANSFORM_FLIP_H) && |
| 429 | (!isYuvBuffer(hnd))) |
| 430 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 431 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 432 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 433 | if(ctx->mAD->isDoable()) { |
| 434 | return false; |
| 435 | } |
| 436 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 437 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 438 | bool ret = false; |
| 439 | if(fullMDPComp(ctx, list)) { |
| 440 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 441 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 442 | ret = true; |
| 443 | } |
| 444 | return ret; |
| 445 | } |
| 446 | |
| 447 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 448 | //Setup mCurrentFrame |
| 449 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount; |
| 450 | mCurrentFrame.fbCount = 0; |
| 451 | mCurrentFrame.fbZ = -1; |
| 452 | memset(&mCurrentFrame.isFBComposed, 0, sizeof(mCurrentFrame.isFBComposed)); |
| 453 | |
| 454 | int mdpCount = mCurrentFrame.mdpCount; |
| 455 | if(mdpCount > sMaxPipesPerMixer) { |
| 456 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 457 | return false; |
| 458 | } |
| 459 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 460 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 461 | return false; |
| 462 | } |
| 463 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 464 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 465 | if(!bandwidthCheck(ctx, size)) { |
| 466 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 467 | return false; |
| 468 | } |
| 469 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 470 | return true; |
| 471 | } |
| 472 | |
| 473 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 474 | { |
| 475 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 476 | |
| 477 | if(!sEnableMixedMode) { |
| 478 | //Mixed mode is disabled. No need to even try caching. |
| 479 | return false; |
| 480 | } |
| 481 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 482 | //Setup mCurrentFrame |
| 483 | mCurrentFrame.reset(numAppLayers); |
| 484 | updateLayerCache(ctx, list); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 485 | updateYUV(ctx, list, false /*secure only*/); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 486 | batchLayers(); //sets up fbZ also |
| 487 | |
| 488 | int mdpCount = mCurrentFrame.mdpCount; |
| 489 | if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used |
| 490 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 491 | return false; |
| 492 | } |
| 493 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 494 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 495 | return false; |
| 496 | } |
| 497 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 498 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 499 | if(!bandwidthCheck(ctx, size)) { |
| 500 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 501 | return false; |
| 502 | } |
| 503 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 504 | return true; |
| 505 | } |
| 506 | |
| 507 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 508 | hwc_display_contents_1_t* list, bool secureOnly) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 509 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 510 | mCurrentFrame.reset(numAppLayers); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 511 | updateYUV(ctx, list, secureOnly); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 512 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 513 | int fbNeeded = int(mCurrentFrame.fbCount != 0); |
| 514 | |
| 515 | if(!isYuvPresent(ctx, mDpy)) { |
| 516 | return false; |
| 517 | } |
| 518 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 519 | if(!mdpCount) |
| 520 | return false; |
| 521 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 522 | if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { |
| 523 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 524 | return false; |
| 525 | } |
| 526 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 527 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 528 | return false; |
| 529 | } |
| 530 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 531 | uint32_t size = calcMDPBytesRead(ctx, list); |
| 532 | if(!bandwidthCheck(ctx, size)) { |
| 533 | ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); |
| 534 | return false; |
| 535 | } |
| 536 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 537 | return true; |
| 538 | } |
| 539 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 540 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 541 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 542 | bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 543 | |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 544 | if(isSkipLayer(layer) && !extAnimBlockFeature) { |
| 545 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 546 | return false; |
| 547 | } |
| 548 | |
Amara Venkata Mastan Manoj Kumar | 9d373c0 | 2013-08-20 14:30:09 -0700 | [diff] [blame] | 549 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { |
| 550 | ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); |
| 551 | return false; |
| 552 | } |
| 553 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 554 | if(isSecuring(ctx, layer)) { |
| 555 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 556 | return false; |
| 557 | } |
| 558 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 559 | if(!isValidDimension(ctx, layer)) { |
| 560 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 561 | __FUNCTION__); |
| 562 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 563 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 564 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 565 | if(layer->planeAlpha < 0xFF) { |
| 566 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 567 | in video only mode", |
| 568 | __FUNCTION__); |
| 569 | return false; |
| 570 | } |
| 571 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 572 | return true; |
| 573 | } |
| 574 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 575 | void MDPComp::batchLayers() { |
| 576 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 577 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 578 | * But cached ones can be marked for MDP*/ |
| 579 | |
| 580 | int maxBatchStart = -1; |
| 581 | int maxBatchCount = 0; |
| 582 | |
| 583 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 584 | if(!mCurrentFrame.fbCount) { |
| 585 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 586 | return; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 587 | } |
| 588 | if(!mCurrentFrame.mdpCount) { |
| 589 | mCurrentFrame.fbZ = 0; |
| 590 | return; |
| 591 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 592 | |
| 593 | /* Search for max number of contiguous (cached) layers */ |
| 594 | int i = 0; |
| 595 | while (i < mCurrentFrame.layerCount) { |
| 596 | int count = 0; |
| 597 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 598 | count++; i++; |
| 599 | } |
| 600 | if(count > maxBatchCount) { |
| 601 | maxBatchCount = count; |
| 602 | maxBatchStart = i - count; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 603 | mCurrentFrame.fbZ = maxBatchStart; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 604 | } |
| 605 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 606 | } |
| 607 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 608 | /* reset rest of the layers for MDP comp */ |
| 609 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 610 | if(i != maxBatchStart){ |
| 611 | mCurrentFrame.isFBComposed[i] = false; |
| 612 | } else { |
| 613 | i += maxBatchCount; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 618 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 619 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 620 | |
| 621 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 622 | mCurrentFrame.fbCount); |
| 623 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 624 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 625 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 626 | hwc_display_contents_1_t* list) { |
| 627 | |
| 628 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 629 | int numCacheableLayers = 0; |
| 630 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 631 | for(int i = 0; i < numAppLayers; i++) { |
| 632 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 633 | numCacheableLayers++; |
| 634 | mCurrentFrame.isFBComposed[i] = true; |
| 635 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 636 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 637 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 638 | } |
| 639 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 640 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 641 | mCurrentFrame.fbCount = numCacheableLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 642 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 643 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 644 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 645 | } |
| 646 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 647 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, |
| 648 | bool secureOnly) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 649 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 650 | if(!nYuvCount && mDpy) { |
| 651 | //Reset "No animation on external display" related parameters. |
| 652 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 653 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 654 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 655 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 656 | ctx->mPrevTransformVideo = 0; |
| 657 | return; |
| 658 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 659 | for(int index = 0;index < nYuvCount; index++){ |
| 660 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 661 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 662 | |
| 663 | if(!isYUVDoable(ctx, layer)) { |
| 664 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 665 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 666 | mCurrentFrame.fbCount++; |
| 667 | } |
| 668 | } else { |
| 669 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 670 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 671 | if(!secureOnly || isSecureBuffer(hnd)) { |
| 672 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 673 | mCurrentFrame.fbCount--; |
| 674 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 678 | |
| 679 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 680 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 681 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 682 | mCurrentFrame.fbCount); |
| 683 | } |
| 684 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 685 | bool MDPComp::programMDP(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 686 | if(!allocLayerPipes(ctx, list)) { |
| 687 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 688 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 689 | } |
| 690 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 691 | bool fbBatch = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 692 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 693 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 694 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 695 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 696 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 697 | |
| 698 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 699 | cur_pipe->zOrder = mdpNextZOrder++; |
| 700 | |
| 701 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 702 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 703 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 704 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 705 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 706 | } else if(fbBatch == false) { |
| 707 | mdpNextZOrder++; |
| 708 | fbBatch = true; |
| 709 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 710 | } |
| 711 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 712 | return true; |
| 713 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 714 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 715 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 716 | if(!allocLayerPipes(ctx, list)) { |
| 717 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 718 | return false; |
| 719 | } |
| 720 | //If we are in this block, it means we have yuv + rgb layers both |
| 721 | int mdpIdx = 0; |
| 722 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 723 | if(!mCurrentFrame.isFBComposed[index]) { |
| 724 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 725 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 726 | MdpPipeInfo* cur_pipe = |
| 727 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 728 | cur_pipe->zOrder = mdpIdx++; |
| 729 | |
| 730 | if(configure(ctx, layer, |
| 731 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 732 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 733 | layer %d",__FUNCTION__, index); |
| 734 | return false; |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 739 | } |
| 740 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 741 | uint32_t MDPComp::calcMDPBytesRead(hwc_context_t *ctx, |
| 742 | hwc_display_contents_1_t* list) { |
| 743 | uint32_t size = 0; |
| 744 | |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 745 | if(!qdutils::MDPVersion::getInstance().is8x74v2()) |
| 746 | return 0; |
| 747 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 748 | for (uint32_t i = 0; i < list->numHwLayers - 1; i++) { |
| 749 | if(!mCurrentFrame.isFBComposed[i]) { |
| 750 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 751 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 752 | if (hnd) { |
| 753 | hwc_rect_t crop = layer->sourceCrop; |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 754 | hwc_rect_t dst = layer->displayFrame; |
| 755 | trimLayer(ctx, mDpy, layer->transform, crop, dst); |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 756 | float bpp = ((float)hnd->size) / (hnd->width * hnd->height); |
Saurabh Shah | 9078916 | 2013-09-16 10:29:20 -0700 | [diff] [blame] | 757 | size += bpp * (crop.right - crop.left) * |
| 758 | (crop.bottom - crop.top) * |
| 759 | ctx->dpyAttr[mDpy].yres / (dst.bottom - dst.top); |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 760 | } |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 761 | } |
| 762 | } |
| 763 | |
| 764 | if(mCurrentFrame.fbCount) { |
| 765 | hwc_layer_1_t* layer = &list->hwLayers[list->numHwLayers - 1]; |
| 766 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Terence Hampson | 9cd5fa9 | 2013-09-10 17:06:37 -0400 | [diff] [blame] | 767 | if (hnd) |
| 768 | size += hnd->size; |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | return size; |
| 772 | } |
| 773 | |
| 774 | bool MDPComp::bandwidthCheck(hwc_context_t *ctx, const uint32_t& size) { |
| 775 | //Will be added for other targets if we run into bandwidth issues and when |
| 776 | //we have profiling data to set an upper limit. |
| 777 | if(qdutils::MDPVersion::getInstance().is8x74v2()) { |
| 778 | const uint32_t ONE_GIG = 1024 * 1024 * 1024; |
| 779 | double panelRefRate = |
| 780 | 1000000000.0 / ctx->dpyAttr[mDpy].vsync_period; |
| 781 | if((size + sCompBytesClaimed) > ((sMaxBw / panelRefRate) * ONE_GIG)) { |
| 782 | return false; |
| 783 | } |
| 784 | } |
| 785 | return true; |
| 786 | } |
| 787 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 788 | 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] | 789 | int ret = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 790 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 791 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 792 | //reset old data |
| 793 | mCurrentFrame.reset(numLayers); |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 794 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 795 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 796 | //do not cache the information for next draw cycle. |
| 797 | if(numLayers > MAX_NUM_APP_LAYERS) { |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 798 | mCachedFrame.updateCounts(mCurrentFrame); |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame^] | 799 | ALOGE("%s: Number of App layers exceeded the limit ", |
| 800 | __FUNCTION__); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 801 | ret = -1; |
Tatenda Chipeperekwa | 835337a | 2013-09-27 16:58:43 -0700 | [diff] [blame^] | 802 | return ret; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 803 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 804 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 805 | //Hard conditions, if not met, cannot do MDP comp |
| 806 | if(!isFrameDoable(ctx)) { |
| 807 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 808 | __FUNCTION__); |
| 809 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 810 | ret = -1; |
| 811 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | //Check whether layers marked for MDP Composition is actually doable. |
| 815 | if(isFullFrameDoable(ctx, list)) { |
| 816 | mCurrentFrame.map(); |
| 817 | //Configure framebuffer first if applicable |
| 818 | if(mCurrentFrame.fbZ >= 0) { |
| 819 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 820 | mCurrentFrame.fbZ)) { |
| 821 | ALOGE("%s configure framebuffer failed", __func__); |
| 822 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 823 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 824 | ret = -1; |
| 825 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 826 | } |
| 827 | } |
| 828 | //Acquire and Program MDP pipes |
| 829 | if(!programMDP(ctx, list)) { |
| 830 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 831 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 832 | ret = -1; |
| 833 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 834 | } else { //Success |
| 835 | //Any change in composition types needs an FB refresh |
| 836 | mCurrentFrame.needsRedraw = false; |
| 837 | if(mCurrentFrame.fbCount && |
| 838 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 839 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 840 | (mCurrentFrame.fbZ != mCachedFrame.fbZ) || |
| 841 | (!mCurrentFrame.mdpCount) || |
| 842 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 843 | isSkipPresent(ctx, mDpy) || |
| 844 | (mDpy > HWC_DISPLAY_PRIMARY))) { |
| 845 | mCurrentFrame.needsRedraw = true; |
| 846 | } |
| 847 | } |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 848 | } else if(isOnlyVideoDoable(ctx, list, false /*secure only*/) || |
| 849 | isOnlyVideoDoable(ctx, list, true /*secure only*/)) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 850 | //All layers marked for MDP comp cannot be bypassed. |
| 851 | //Try to compose atleast YUV layers through MDP comp and let |
| 852 | //all the RGB layers compose in FB |
| 853 | //Destination over |
| 854 | mCurrentFrame.fbZ = -1; |
| 855 | if(mCurrentFrame.fbCount) |
| 856 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
| 857 | |
| 858 | mCurrentFrame.map(); |
| 859 | |
| 860 | //Configure framebuffer first if applicable |
| 861 | if(mCurrentFrame.fbZ >= 0) { |
| 862 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 863 | ALOGE("%s configure framebuffer failed", __func__); |
| 864 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 865 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 866 | ret = -1; |
| 867 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 868 | } |
| 869 | } |
| 870 | if(!programYUV(ctx, list)) { |
| 871 | reset(numLayers, list); |
Saurabh Shah | 6be7c78 | 2013-08-28 15:13:52 -0700 | [diff] [blame] | 872 | ctx->mOverlay->clear(mDpy); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 873 | ret = -1; |
| 874 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 875 | } |
| 876 | } else { |
| 877 | reset(numLayers, list); |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 878 | ret = -1; |
| 879 | goto exit; |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | //UpdateLayerFlags |
| 883 | setMDPCompLayerFlags(ctx, list); |
| 884 | mCachedFrame.updateCounts(mCurrentFrame); |
| 885 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 886 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 887 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 888 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 889 | android::String8 sDump(""); |
| 890 | dump(sDump); |
| 891 | ALOGE("%s",sDump.string()); |
| 892 | } |
| 893 | |
Saurabh Shah | 8c5c852 | 2013-08-29 17:32:49 -0700 | [diff] [blame] | 894 | exit: |
| 895 | sCompBytesClaimed += calcMDPBytesRead(ctx, list); |
| 896 | return ret; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 897 | } |
| 898 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 899 | //=============MDPCompNonSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 900 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 901 | /* |
| 902 | * Configures pipe(s) for MDP composition |
| 903 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 904 | int MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 905 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 906 | MdpPipeInfoNonSplit& mdp_info = |
| 907 | *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 908 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 909 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 910 | eIsFg isFg = IS_FG_OFF; |
| 911 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 912 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 913 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 914 | __FUNCTION__, layer, zOrder, dest); |
| 915 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 916 | return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 917 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 918 | } |
| 919 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 920 | bool MDPCompNonSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 921 | hwc_display_contents_1_t* list) { |
| 922 | overlay::Overlay& ov = *ctx->mOverlay; |
| 923 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 924 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 925 | |
| 926 | //Reserve pipe for FB |
| 927 | if(mCurrentFrame.fbCount) |
| 928 | availPipes -= 1; |
| 929 | |
| 930 | if(numPipesNeeded > availPipes) { |
| 931 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 932 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 933 | return false; |
| 934 | } |
| 935 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 936 | if(not areVGPipesAvailable(ctx, list)) { |
| 937 | return false; |
| 938 | } |
| 939 | |
| 940 | return true; |
| 941 | } |
| 942 | |
| 943 | bool MDPCompNonSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 944 | hwc_display_contents_1_t* list) { |
| 945 | overlay::Overlay& ov = *ctx->mOverlay; |
| 946 | int pipesNeeded = 0; |
| 947 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 948 | if(!mCurrentFrame.isFBComposed[i]) { |
| 949 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 950 | hwc_rect_t dst = layer->displayFrame; |
| 951 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 952 | if(isYuvBuffer(hnd)) { |
| 953 | pipesNeeded++; |
| 954 | } |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 959 | if(pipesNeeded > availableVGPipes) { |
| 960 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 961 | "dpy %d needed %d, avail %d", |
| 962 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 963 | return false; |
| 964 | } |
| 965 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 966 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 967 | } |
| 968 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 969 | bool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 970 | hwc_display_contents_1_t* list) { |
| 971 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 972 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 973 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 974 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 975 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 976 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 977 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 978 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 979 | info.pipeInfo = new MdpPipeInfoNonSplit; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 980 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 981 | MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 982 | ePipeType type = MDPCOMP_OV_ANY; |
| 983 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 984 | if(isYuvBuffer(hnd)) { |
| 985 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 986 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 987 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 988 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 989 | type = MDPCOMP_OV_DMA; |
| 990 | } |
| 991 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 992 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 993 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 994 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 995 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 996 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 997 | } |
| 998 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 999 | return true; |
| 1000 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1001 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1002 | 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] | 1003 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1004 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1005 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1006 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 1007 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1008 | |
| 1009 | if(!ctx || !list) { |
| 1010 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1011 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1014 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1015 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1016 | return true; |
| 1017 | } |
| 1018 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1019 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1020 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1021 | idleInvalidator->markForSleep(); |
| 1022 | |
| 1023 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1024 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1025 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1026 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1027 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1028 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1029 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1030 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 1031 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1032 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1033 | if(!hnd) { |
| 1034 | ALOGE("%s handle null", __FUNCTION__); |
| 1035 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1038 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1039 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1040 | MdpPipeInfoNonSplit& pipe_info = |
| 1041 | *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1042 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1043 | if(dest == ovutils::OV_INVALID) { |
| 1044 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1045 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1048 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1049 | continue; |
| 1050 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1051 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1052 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1053 | using pipe: %d", __FUNCTION__, layer, |
| 1054 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1055 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1056 | int fd = hnd->fd; |
| 1057 | uint32_t offset = hnd->offset; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1058 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1059 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1060 | if(rot) { |
| 1061 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1062 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1063 | fd = rot->getDstMemId(); |
| 1064 | offset = rot->getDstOffset(); |
| 1065 | } |
| 1066 | |
| 1067 | if (!ov.queueBuffer(fd, offset, dest)) { |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1068 | ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1069 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1070 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1071 | |
| 1072 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1073 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1074 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1077 | //=============MDPCompSplit=================================================== |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1078 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1079 | int MDPCompSplit::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1080 | hwc_display_contents_1_t* list, |
| 1081 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1082 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1083 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1084 | |
| 1085 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1086 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1087 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1088 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1089 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1090 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1091 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1092 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1093 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1094 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1095 | } |
| 1096 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1097 | } |
| 1098 | return pipesNeeded; |
| 1099 | } |
| 1100 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1101 | bool MDPCompSplit::arePipesAvailable(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1102 | hwc_display_contents_1_t* list) { |
| 1103 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1104 | int totalPipesNeeded = 0; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1105 | |
| 1106 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1107 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1108 | int availPipes = ov.availablePipes(mDpy, i); |
| 1109 | |
| 1110 | //Reserve pipe(s)for FB |
| 1111 | if(mCurrentFrame.fbCount) |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1112 | numPipesNeeded += 1; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1113 | |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1114 | totalPipesNeeded += numPipesNeeded; |
| 1115 | |
| 1116 | //Per mixer check. |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1117 | if(numPipesNeeded > availPipes) { |
| 1118 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1119 | "dpy %d mixer %d needed %d, avail %d", |
| 1120 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1121 | return false; |
| 1122 | } |
| 1123 | } |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 1124 | |
| 1125 | //Per display check, since unused pipes can get counted twice. |
| 1126 | int totalPipesAvailable = ov.availablePipes(mDpy); |
| 1127 | if(totalPipesNeeded > totalPipesAvailable) { |
| 1128 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1129 | "dpy %d needed %d, avail %d", |
| 1130 | __FUNCTION__, mDpy, totalPipesNeeded, totalPipesAvailable); |
| 1131 | return false; |
| 1132 | } |
| 1133 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 1134 | if(not areVGPipesAvailable(ctx, list)) { |
| 1135 | return false; |
| 1136 | } |
| 1137 | |
| 1138 | return true; |
| 1139 | } |
| 1140 | |
| 1141 | bool MDPCompSplit::areVGPipesAvailable(hwc_context_t *ctx, |
| 1142 | hwc_display_contents_1_t* list) { |
| 1143 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1144 | int pipesNeeded = 0; |
| 1145 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 1146 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1147 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1148 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1149 | hwc_rect_t dst = layer->displayFrame; |
| 1150 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1151 | if(isYuvBuffer(hnd)) { |
| 1152 | if(dst.left < lSplit) { |
| 1153 | pipesNeeded++; |
| 1154 | } |
| 1155 | if(dst.right > lSplit) { |
| 1156 | pipesNeeded++; |
| 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | int availableVGPipes = ov.availablePipes(mDpy, ovutils::OV_MDP_PIPE_VG); |
| 1163 | if(pipesNeeded > availableVGPipes) { |
| 1164 | ALOGD_IF(isDebug(), "%s: Insufficient VG pipes for video layers" |
| 1165 | "dpy %d needed %d, avail %d", |
| 1166 | __FUNCTION__, mDpy, pipesNeeded, availableVGPipes); |
| 1167 | return false; |
| 1168 | } |
| 1169 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1170 | return true; |
| 1171 | } |
| 1172 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1173 | bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 1174 | MdpPipeInfoSplit& pipe_info, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1175 | ePipeType type) { |
| 1176 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1177 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1178 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1179 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1180 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1181 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1182 | |
| 1183 | if (dst.left < lSplit) { |
| 1184 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1185 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1186 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | if(dst.right > lSplit) { |
| 1190 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1191 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1192 | return false; |
| 1193 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1194 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1195 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1196 | } |
| 1197 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1198 | bool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1199 | hwc_display_contents_1_t* list) { |
| 1200 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1201 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1202 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1203 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1204 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1205 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1206 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1207 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1208 | info.pipeInfo = new MdpPipeInfoSplit; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1209 | info.rot = NULL; |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1210 | MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1211 | ePipeType type = MDPCOMP_OV_ANY; |
| 1212 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1213 | if(isYuvBuffer(hnd)) { |
| 1214 | type = MDPCOMP_OV_VG; |
Sushil Chauhan | 15a2ea6 | 2013-09-04 18:28:36 -0700 | [diff] [blame] | 1215 | } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1216 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1217 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1218 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1219 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1220 | |
| 1221 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1222 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1223 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1224 | return false; |
| 1225 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1226 | } |
| 1227 | return true; |
| 1228 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1229 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1230 | /* |
| 1231 | * Configures pipe(s) for MDP composition |
| 1232 | */ |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1233 | int MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1234 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1235 | MdpPipeInfoSplit& mdp_info = |
| 1236 | *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1237 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1238 | eIsFg isFg = IS_FG_OFF; |
| 1239 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1240 | eDest lDest = mdp_info.lIndex; |
| 1241 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1242 | |
| 1243 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1244 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1245 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1246 | return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1247 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1248 | } |
| 1249 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1250 | 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] | 1251 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1252 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1253 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1254 | return true; |
| 1255 | } |
| 1256 | |
| 1257 | if(!ctx || !list) { |
| 1258 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1259 | return false; |
| 1260 | } |
| 1261 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1262 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1263 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1264 | return true; |
| 1265 | } |
| 1266 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1267 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1268 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1269 | idleInvalidator->markForSleep(); |
| 1270 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1271 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1272 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1273 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1274 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1275 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1276 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1277 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1278 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1279 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1280 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1281 | if(!hnd) { |
| 1282 | ALOGE("%s handle null", __FUNCTION__); |
| 1283 | return false; |
| 1284 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1285 | |
| 1286 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1287 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1288 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1289 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1290 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1291 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 1292 | MdpPipeInfoSplit& pipe_info = |
| 1293 | *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1294 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1295 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1296 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1297 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1298 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1299 | int fd = hnd->fd; |
| 1300 | int offset = hnd->offset; |
| 1301 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1302 | if(ctx->mAD->isModeOn()) { |
| 1303 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 1304 | fd = ctx->mAD->getDstFd(ctx); |
| 1305 | offset = ctx->mAD->getDstOffset(ctx); |
| 1306 | } |
| 1307 | } |
| 1308 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1309 | if(rot) { |
| 1310 | rot->queueBuffer(fd, offset); |
| 1311 | fd = rot->getDstMemId(); |
| 1312 | offset = rot->getDstOffset(); |
| 1313 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1314 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1315 | //************* play left mixer ********** |
| 1316 | if(indexL != ovutils::OV_INVALID) { |
| 1317 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1318 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1319 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1320 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1321 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1322 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | //************* play right mixer ********** |
| 1327 | if(indexR != ovutils::OV_INVALID) { |
| 1328 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1329 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1330 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1331 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1332 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1333 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1334 | } |
| 1335 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1336 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1337 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1338 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1339 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1340 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1341 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1342 | }; //namespace |
| 1343 | |