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