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