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