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