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 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 341 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, |
| 342 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 343 | overlay::Overlay& ov = *ctx->mOverlay; |
| 344 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 345 | |
| 346 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 347 | case MDPCOMP_OV_DMA: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 348 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 349 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 350 | return mdp_pipe; |
| 351 | } |
| 352 | case MDPCOMP_OV_ANY: |
| 353 | case MDPCOMP_OV_RGB: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 354 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 355 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 356 | return mdp_pipe; |
| 357 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 358 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 359 | if(type == MDPCOMP_OV_RGB) { |
| 360 | //Requested only for RGB pipe |
| 361 | break; |
| 362 | } |
| 363 | case MDPCOMP_OV_VG: |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 364 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 365 | default: |
| 366 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 367 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 368 | }; |
| 369 | return ovutils::OV_INVALID; |
| 370 | } |
| 371 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 372 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 373 | bool ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 374 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 375 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 376 | if(!isEnabled()) { |
| 377 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 378 | ret = false; |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 379 | } else if(qdutils::MDPVersion::getInstance().is8x26() && |
| 380 | ctx->mVideoTransFlag && |
| 381 | ctx->mExtDisplay->isExternalConnected()) { |
| 382 | //1 Padding round to shift pipes across mixers |
| 383 | ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", |
| 384 | __FUNCTION__); |
| 385 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 386 | } else if(ctx->mExtDispConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 387 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 388 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 389 | ret = false; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 390 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 391 | ctx->isPaddingRound = false; |
| 392 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 393 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 394 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 395 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 399 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 400 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 401 | hwc_display_contents_1_t* list){ |
| 402 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 403 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 404 | |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 405 | if(sIdleFallBack) { |
| 406 | ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); |
| 407 | return false; |
| 408 | } |
| 409 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 410 | if(mDpy > HWC_DISPLAY_PRIMARY){ |
| 411 | ALOGD_IF(isDebug(), "%s: Cannot support External display(s)", |
| 412 | __FUNCTION__); |
| 413 | return false; |
| 414 | } |
| 415 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 416 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 417 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 418 | __FUNCTION__, |
| 419 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 420 | return false; |
| 421 | } |
| 422 | |
Saurabh Shah | 9f084ad | 2013-05-02 11:28:09 -0700 | [diff] [blame] | 423 | if(ctx->listStats[mDpy].needsAlphaScale |
| 424 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
| 425 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
| 426 | return false; |
| 427 | } |
| 428 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 429 | //MDP composition is not efficient if layer needs rotator. |
| 430 | for(int i = 0; i < numAppLayers; ++i) { |
| 431 | // As MDP h/w supports flip operation, use MDP comp only for |
| 432 | // 180 transforms. Fail for any transform involving 90 (90, 270). |
| 433 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 434 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 435 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 436 | if((layer->transform & HWC_TRANSFORM_ROT_90) && !isYuvBuffer(hnd)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 437 | ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__); |
| 438 | return false; |
| 439 | } |
| 440 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 441 | if(!isValidDimension(ctx,layer)) { |
| 442 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 443 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 444 | return false; |
| 445 | } |
Prabhanjan Kandula | 9fb032a | 2013-06-18 17:37:22 +0530 | [diff] [blame] | 446 | |
| 447 | //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp |
| 448 | // may not need it if Gfx pre-rotation can handle all flips & rotations |
| 449 | if(qdutils::MDPVersion::getInstance().is8x26() && |
| 450 | (ctx->dpyAttr[mDpy].xres > 1024) && |
| 451 | (layer->transform & HWC_TRANSFORM_FLIP_H) && |
| 452 | (!isYuvBuffer(hnd))) |
| 453 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 454 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 455 | |
| 456 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 457 | bool ret = false; |
| 458 | if(fullMDPComp(ctx, list)) { |
| 459 | ret = true; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 460 | } else if(partialMDPComp(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 461 | ret = true; |
| 462 | } |
| 463 | return ret; |
| 464 | } |
| 465 | |
| 466 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 467 | //Setup mCurrentFrame |
| 468 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount; |
| 469 | mCurrentFrame.fbCount = 0; |
| 470 | mCurrentFrame.fbZ = -1; |
| 471 | memset(&mCurrentFrame.isFBComposed, 0, sizeof(mCurrentFrame.isFBComposed)); |
| 472 | |
| 473 | int mdpCount = mCurrentFrame.mdpCount; |
| 474 | if(mdpCount > sMaxPipesPerMixer) { |
| 475 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 476 | return false; |
| 477 | } |
| 478 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 479 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 480 | return false; |
| 481 | } |
| 482 | |
| 483 | return true; |
| 484 | } |
| 485 | |
| 486 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 487 | { |
| 488 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 24c199d | 2013-05-24 09:40:36 -0700 | [diff] [blame] | 489 | |
| 490 | if(!sEnableMixedMode) { |
| 491 | //Mixed mode is disabled. No need to even try caching. |
| 492 | return false; |
| 493 | } |
| 494 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 495 | //Setup mCurrentFrame |
| 496 | mCurrentFrame.reset(numAppLayers); |
| 497 | updateLayerCache(ctx, list); |
| 498 | updateYUV(ctx, list); |
| 499 | batchLayers(); //sets up fbZ also |
| 500 | |
| 501 | int mdpCount = mCurrentFrame.mdpCount; |
| 502 | if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used |
| 503 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 504 | return false; |
| 505 | } |
| 506 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 507 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 508 | return false; |
| 509 | } |
| 510 | |
| 511 | return true; |
| 512 | } |
| 513 | |
| 514 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
| 515 | hwc_display_contents_1_t* list){ |
| 516 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 517 | mCurrentFrame.reset(numAppLayers); |
| 518 | updateYUV(ctx, list); |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 519 | int mdpCount = mCurrentFrame.mdpCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 520 | int fbNeeded = int(mCurrentFrame.fbCount != 0); |
| 521 | |
| 522 | if(!isYuvPresent(ctx, mDpy)) { |
| 523 | return false; |
| 524 | } |
| 525 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 526 | if(!mdpCount) |
| 527 | return false; |
| 528 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 529 | if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { |
| 530 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 531 | return false; |
| 532 | } |
| 533 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 534 | if(!arePipesAvailable(ctx, list)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 535 | return false; |
| 536 | } |
| 537 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 538 | return true; |
| 539 | } |
| 540 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 541 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 542 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 543 | bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 544 | |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 545 | if(isSkipLayer(layer) && !extAnimBlockFeature) { |
| 546 | ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 547 | return false; |
| 548 | } |
| 549 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 550 | if(isSecuring(ctx, layer)) { |
| 551 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 552 | return false; |
| 553 | } |
| 554 | |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 555 | if(!isValidDimension(ctx, layer)) { |
| 556 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", |
| 557 | __FUNCTION__); |
| 558 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 559 | } |
Saurabh Shah | 4fdde76 | 2013-04-30 18:47:33 -0700 | [diff] [blame] | 560 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 561 | return true; |
| 562 | } |
| 563 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 564 | void MDPComp::batchLayers() { |
| 565 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 566 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 567 | * But cached ones can be marked for MDP*/ |
| 568 | |
| 569 | int maxBatchStart = -1; |
| 570 | int maxBatchCount = 0; |
| 571 | |
| 572 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 573 | if(!mCurrentFrame.fbCount) { |
| 574 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 575 | return; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 576 | } |
| 577 | if(!mCurrentFrame.mdpCount) { |
| 578 | mCurrentFrame.fbZ = 0; |
| 579 | return; |
| 580 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 581 | |
| 582 | /* Search for max number of contiguous (cached) layers */ |
| 583 | int i = 0; |
| 584 | while (i < mCurrentFrame.layerCount) { |
| 585 | int count = 0; |
| 586 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 587 | count++; i++; |
| 588 | } |
| 589 | if(count > maxBatchCount) { |
| 590 | maxBatchCount = count; |
| 591 | maxBatchStart = i - count; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 592 | mCurrentFrame.fbZ = maxBatchStart; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 593 | } |
| 594 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 595 | } |
| 596 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 597 | /* reset rest of the layers for MDP comp */ |
| 598 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 599 | if(i != maxBatchStart){ |
| 600 | mCurrentFrame.isFBComposed[i] = false; |
| 601 | } else { |
| 602 | i += maxBatchCount; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 607 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 608 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 609 | |
| 610 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 611 | mCurrentFrame.fbCount); |
| 612 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 613 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 614 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 615 | hwc_display_contents_1_t* list) { |
| 616 | |
| 617 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 618 | int numCacheableLayers = 0; |
| 619 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 620 | for(int i = 0; i < numAppLayers; i++) { |
| 621 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 622 | numCacheableLayers++; |
| 623 | mCurrentFrame.isFBComposed[i] = true; |
| 624 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 625 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 626 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 627 | } |
| 628 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 629 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 630 | mCurrentFrame.fbCount = numCacheableLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 631 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 632 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 633 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 634 | } |
| 635 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 636 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 637 | |
| 638 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 639 | if(!nYuvCount && mDpy) { |
| 640 | //Reset "No animation on external display" related parameters. |
| 641 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 642 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 643 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 644 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 645 | ctx->mPrevTransformVideo = 0; |
| 646 | return; |
| 647 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 648 | for(int index = 0;index < nYuvCount; index++){ |
| 649 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 650 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 651 | |
| 652 | if(!isYUVDoable(ctx, layer)) { |
| 653 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 654 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 655 | mCurrentFrame.fbCount++; |
| 656 | } |
| 657 | } else { |
| 658 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 659 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 660 | mCurrentFrame.fbCount--; |
| 661 | } |
| 662 | } |
| 663 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 664 | |
| 665 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 666 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 667 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 668 | mCurrentFrame.fbCount); |
| 669 | } |
| 670 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 671 | 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] | 672 | if(!allocLayerPipes(ctx, list)) { |
| 673 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 674 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 675 | } |
| 676 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 677 | bool fbBatch = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 678 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 679 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 680 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 681 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 682 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 683 | |
| 684 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 685 | cur_pipe->zOrder = mdpNextZOrder++; |
| 686 | |
| 687 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 688 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 689 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 690 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 691 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 692 | } else if(fbBatch == false) { |
| 693 | mdpNextZOrder++; |
| 694 | fbBatch = true; |
| 695 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 696 | } |
| 697 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 698 | return true; |
| 699 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 700 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 701 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 702 | if(!allocLayerPipes(ctx, list)) { |
| 703 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 704 | return false; |
| 705 | } |
| 706 | //If we are in this block, it means we have yuv + rgb layers both |
| 707 | int mdpIdx = 0; |
| 708 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 709 | if(!mCurrentFrame.isFBComposed[index]) { |
| 710 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 711 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 712 | MdpPipeInfo* cur_pipe = |
| 713 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 714 | cur_pipe->zOrder = mdpIdx++; |
| 715 | |
| 716 | if(configure(ctx, layer, |
| 717 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 718 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 719 | layer %d",__FUNCTION__, index); |
| 720 | return false; |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | 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] | 728 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 729 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 730 | { //LOCK SCOPE BEGIN |
| 731 | Locker::Autolock _l(mMdpCompLock); |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 732 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 733 | //reset old data |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 734 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 735 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 736 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 737 | //do not cache the information for next draw cycle. |
| 738 | if(numLayers > MAX_NUM_APP_LAYERS) { |
| 739 | mCachedFrame.updateCounts(mCurrentFrame); |
| 740 | ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ", |
| 741 | __FUNCTION__); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 742 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | //Hard conditions, if not met, cannot do MDP comp |
| 746 | if(!isFrameDoable(ctx)) { |
| 747 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 748 | __FUNCTION__); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 749 | reset(numLayers, list); |
| 750 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | //Check whether layers marked for MDP Composition is actually doable. |
| 754 | if(isFullFrameDoable(ctx, list)){ |
| 755 | mCurrentFrame.map(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 756 | //Configure framebuffer first if applicable |
| 757 | if(mCurrentFrame.fbZ >= 0) { |
| 758 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 759 | mCurrentFrame.fbZ)) { |
| 760 | ALOGE("%s configure framebuffer failed", __func__); |
| 761 | reset(numLayers, list); |
| 762 | return -1; |
| 763 | } |
| 764 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 765 | //Acquire and Program MDP pipes |
| 766 | if(!programMDP(ctx, list)) { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 767 | reset(numLayers, list); |
| 768 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 769 | } else { //Success |
| 770 | //Any change in composition types needs an FB refresh |
| 771 | mCurrentFrame.needsRedraw = false; |
| 772 | if(mCurrentFrame.fbCount && |
| 773 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 774 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 775 | (mCurrentFrame.fbZ != mCachedFrame.fbZ) || |
| 776 | (!mCurrentFrame.mdpCount) || |
| 777 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 778 | isSkipPresent(ctx, mDpy) || |
| 779 | (mDpy > HWC_DISPLAY_PRIMARY))) { |
| 780 | mCurrentFrame.needsRedraw = true; |
| 781 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 782 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 783 | } else if(isOnlyVideoDoable(ctx, list)) { |
| 784 | //All layers marked for MDP comp cannot be bypassed. |
| 785 | //Try to compose atleast YUV layers through MDP comp and let |
| 786 | //all the RGB layers compose in FB |
| 787 | //Destination over |
| 788 | mCurrentFrame.fbZ = -1; |
| 789 | if(mCurrentFrame.fbCount) |
| 790 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 791 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 792 | mCurrentFrame.map(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 793 | |
| 794 | //Configure framebuffer first if applicable |
| 795 | if(mCurrentFrame.fbZ >= 0) { |
| 796 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 797 | ALOGE("%s configure framebuffer failed", __func__); |
| 798 | reset(numLayers, list); |
| 799 | return -1; |
| 800 | } |
| 801 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 802 | if(!programYUV(ctx, list)) { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 803 | reset(numLayers, list); |
| 804 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 805 | } |
| 806 | } else { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 807 | reset(numLayers, list); |
| 808 | return -1; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 809 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 810 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 811 | //UpdateLayerFlags |
| 812 | setMDPCompLayerFlags(ctx, list); |
| 813 | mCachedFrame.updateCounts(mCurrentFrame); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 814 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 815 | } //LOCK SCOPE END. dump also need this lock. |
| 816 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 817 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 818 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 819 | android::String8 sDump(""); |
| 820 | dump(sDump); |
| 821 | ALOGE("%s",sDump.string()); |
| 822 | } |
| 823 | |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 824 | return 0; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | //=============MDPCompLowRes=================================================== |
| 828 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 829 | /* |
| 830 | * Configures pipe(s) for MDP composition |
| 831 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 832 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 833 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 834 | MdpPipeInfoLowRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 835 | *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 836 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 837 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 838 | eIsFg isFg = IS_FG_OFF; |
| 839 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 840 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 841 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 842 | __FUNCTION__, layer, zOrder, dest); |
| 843 | |
| 844 | return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
| 845 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 846 | } |
| 847 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 848 | bool MDPCompLowRes::arePipesAvailable(hwc_context_t *ctx, |
| 849 | hwc_display_contents_1_t* list) { |
| 850 | overlay::Overlay& ov = *ctx->mOverlay; |
| 851 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 852 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 853 | |
| 854 | //Reserve pipe for FB |
| 855 | if(mCurrentFrame.fbCount) |
| 856 | availPipes -= 1; |
| 857 | |
| 858 | if(numPipesNeeded > availPipes) { |
| 859 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 860 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 861 | return false; |
| 862 | } |
| 863 | |
| 864 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 865 | } |
| 866 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 867 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 868 | hwc_display_contents_1_t* list) { |
| 869 | for(int index = 0; index < mCurrentFrame.layerCount; 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 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 872 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 873 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 874 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 875 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 876 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 877 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 878 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 879 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 880 | ePipeType type = MDPCOMP_OV_ANY; |
| 881 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 882 | if(isYuvBuffer(hnd)) { |
| 883 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 884 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 885 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 886 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 887 | type = MDPCOMP_OV_DMA; |
| 888 | } |
| 889 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 890 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 891 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 892 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 893 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 894 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 895 | } |
| 896 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 897 | return true; |
| 898 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 899 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 900 | 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] | 901 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 902 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 903 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 904 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 905 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 906 | |
| 907 | if(!ctx || !list) { |
| 908 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 909 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 912 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 913 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 914 | return true; |
| 915 | } |
| 916 | |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 917 | Locker::Autolock _l(mMdpCompLock); |
| 918 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 919 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 920 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 921 | idleInvalidator->markForSleep(); |
| 922 | |
| 923 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 924 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 925 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 926 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 927 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 928 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 929 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 930 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 931 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 932 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 933 | if(!hnd) { |
| 934 | ALOGE("%s handle null", __FUNCTION__); |
| 935 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 936 | } |
| 937 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 938 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 939 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 940 | MdpPipeInfoLowRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 941 | *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 942 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 943 | if(dest == ovutils::OV_INVALID) { |
| 944 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 945 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 946 | } |
| 947 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 948 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 949 | continue; |
| 950 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 951 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 952 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 953 | using pipe: %d", __FUNCTION__, layer, |
| 954 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 955 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 956 | int fd = hnd->fd; |
| 957 | uint32_t offset = hnd->offset; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 958 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 959 | if(rot) { |
| 960 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 961 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 962 | fd = rot->getDstMemId(); |
| 963 | offset = rot->getDstOffset(); |
| 964 | } |
| 965 | |
| 966 | if (!ov.queueBuffer(fd, offset, dest)) { |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 967 | ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 968 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 969 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 970 | |
| 971 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 972 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 973 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 976 | //=============MDPCompHighRes=================================================== |
| 977 | |
| 978 | int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 979 | hwc_display_contents_1_t* list, |
| 980 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 981 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 982 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame^] | 983 | |
| 984 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 985 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 986 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 987 | if(!mCurrentFrame.isFBComposed[i]) { |
| 988 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 989 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 990 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 991 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 992 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 993 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 994 | } |
| 995 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 996 | } |
| 997 | return pipesNeeded; |
| 998 | } |
| 999 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1000 | bool MDPCompHighRes::arePipesAvailable(hwc_context_t *ctx, |
| 1001 | hwc_display_contents_1_t* list) { |
| 1002 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1003 | |
| 1004 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1005 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1006 | int availPipes = ov.availablePipes(mDpy, i); |
| 1007 | |
| 1008 | //Reserve pipe(s)for FB |
| 1009 | if(mCurrentFrame.fbCount) |
| 1010 | availPipes -= 1; |
| 1011 | |
| 1012 | if(numPipesNeeded > availPipes) { |
| 1013 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1014 | "dpy %d mixer %d needed %d, avail %d", |
| 1015 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1016 | return false; |
| 1017 | } |
| 1018 | } |
| 1019 | return true; |
| 1020 | } |
| 1021 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 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; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame^] | 1026 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1027 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1028 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1029 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1030 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1031 | |
| 1032 | if (dst.left < lSplit) { |
| 1033 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1034 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1035 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | if(dst.right > lSplit) { |
| 1039 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1040 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1041 | return false; |
| 1042 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1043 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1044 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1045 | } |
| 1046 | |
| 1047 | bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1048 | hwc_display_contents_1_t* list) { |
| 1049 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1050 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1051 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1052 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1053 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1054 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1055 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1056 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1057 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1058 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1059 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1060 | ePipeType type = MDPCOMP_OV_ANY; |
| 1061 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1062 | if(isYuvBuffer(hnd)) { |
| 1063 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 1064 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1065 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1066 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1067 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1068 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1069 | |
| 1070 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1071 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1072 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1073 | return false; |
| 1074 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1075 | } |
| 1076 | return true; |
| 1077 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1078 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1079 | /* |
| 1080 | * Configures pipe(s) for MDP composition |
| 1081 | */ |
| 1082 | int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1083 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1084 | MdpPipeInfoHighRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1085 | *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1086 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1087 | eIsFg isFg = IS_FG_OFF; |
| 1088 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1089 | eDest lDest = mdp_info.lIndex; |
| 1090 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1091 | |
| 1092 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1093 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1094 | |
| 1095 | return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
| 1096 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1100 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1101 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1102 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1103 | return true; |
| 1104 | } |
| 1105 | |
| 1106 | if(!ctx || !list) { |
| 1107 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1108 | return false; |
| 1109 | } |
| 1110 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1111 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1112 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1113 | return true; |
| 1114 | } |
| 1115 | |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1116 | Locker::Autolock _l(mMdpCompLock); |
| 1117 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1118 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1119 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1120 | idleInvalidator->markForSleep(); |
| 1121 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1122 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1123 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1124 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1125 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1126 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1127 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1128 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1129 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1130 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1131 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1132 | if(!hnd) { |
| 1133 | ALOGE("%s handle null", __FUNCTION__); |
| 1134 | return false; |
| 1135 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1136 | |
| 1137 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1138 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1139 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1140 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1141 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1142 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1143 | MdpPipeInfoHighRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1144 | *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1145 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1146 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1147 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1148 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1149 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1150 | int fd = hnd->fd; |
| 1151 | int offset = hnd->offset; |
| 1152 | |
| 1153 | if(rot) { |
| 1154 | rot->queueBuffer(fd, offset); |
| 1155 | fd = rot->getDstMemId(); |
| 1156 | offset = rot->getDstOffset(); |
| 1157 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1158 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1159 | //************* play left mixer ********** |
| 1160 | if(indexL != ovutils::OV_INVALID) { |
| 1161 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1162 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1163 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1164 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1165 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1166 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | //************* play right mixer ********** |
| 1171 | if(indexR != ovutils::OV_INVALID) { |
| 1172 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1173 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1174 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1175 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1176 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1177 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1178 | } |
| 1179 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1180 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1181 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1182 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1183 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1184 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1185 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1186 | }; //namespace |
| 1187 | |