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