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 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 572 | return true; |
| 573 | } |
| 574 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 575 | void MDPComp::batchLayers() { |
| 576 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 577 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 578 | * But cached ones can be marked for MDP*/ |
| 579 | |
| 580 | int maxBatchStart = -1; |
| 581 | int maxBatchCount = 0; |
| 582 | |
| 583 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 584 | if(!mCurrentFrame.fbCount) { |
| 585 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 586 | return; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 587 | } |
| 588 | if(!mCurrentFrame.mdpCount) { |
| 589 | mCurrentFrame.fbZ = 0; |
| 590 | return; |
| 591 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 592 | |
| 593 | /* Search for max number of contiguous (cached) layers */ |
| 594 | int i = 0; |
| 595 | while (i < mCurrentFrame.layerCount) { |
| 596 | int count = 0; |
| 597 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 598 | count++; i++; |
| 599 | } |
| 600 | if(count > maxBatchCount) { |
| 601 | maxBatchCount = count; |
| 602 | maxBatchStart = i - count; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 603 | mCurrentFrame.fbZ = maxBatchStart; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 604 | } |
| 605 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 606 | } |
| 607 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 608 | /* reset rest of the layers for MDP comp */ |
| 609 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 610 | if(i != maxBatchStart){ |
| 611 | mCurrentFrame.isFBComposed[i] = false; |
| 612 | } else { |
| 613 | i += maxBatchCount; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 618 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 619 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 620 | |
| 621 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 622 | mCurrentFrame.fbCount); |
| 623 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 624 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 625 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 626 | hwc_display_contents_1_t* list) { |
| 627 | |
| 628 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 629 | int numCacheableLayers = 0; |
| 630 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 631 | for(int i = 0; i < numAppLayers; i++) { |
| 632 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 633 | numCacheableLayers++; |
| 634 | mCurrentFrame.isFBComposed[i] = true; |
| 635 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 636 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 637 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 638 | } |
| 639 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 640 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 641 | mCurrentFrame.fbCount = numCacheableLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 642 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 643 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 644 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 645 | } |
| 646 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 647 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 648 | |
| 649 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 650 | if(!nYuvCount && mDpy) { |
| 651 | //Reset "No animation on external display" related parameters. |
| 652 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 653 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 654 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 655 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 656 | ctx->mPrevTransformVideo = 0; |
| 657 | return; |
| 658 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 659 | for(int index = 0;index < nYuvCount; index++){ |
| 660 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 661 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 662 | |
| 663 | if(!isYUVDoable(ctx, layer)) { |
| 664 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 665 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 666 | mCurrentFrame.fbCount++; |
| 667 | } |
| 668 | } else { |
| 669 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 670 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 671 | mCurrentFrame.fbCount--; |
| 672 | } |
| 673 | } |
| 674 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 675 | |
| 676 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 677 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 678 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 679 | mCurrentFrame.fbCount); |
| 680 | } |
| 681 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 682 | 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] | 683 | if(!allocLayerPipes(ctx, list)) { |
| 684 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 685 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 686 | } |
| 687 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 688 | bool fbBatch = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 689 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 690 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 691 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 692 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 693 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 694 | |
| 695 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 696 | cur_pipe->zOrder = mdpNextZOrder++; |
| 697 | |
| 698 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 699 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 700 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 701 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 702 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 703 | } else if(fbBatch == false) { |
| 704 | mdpNextZOrder++; |
| 705 | fbBatch = true; |
| 706 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 707 | } |
| 708 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 709 | return true; |
| 710 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 711 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 712 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 713 | if(!allocLayerPipes(ctx, list)) { |
| 714 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 715 | return false; |
| 716 | } |
| 717 | //If we are in this block, it means we have yuv + rgb layers both |
| 718 | int mdpIdx = 0; |
| 719 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 720 | if(!mCurrentFrame.isFBComposed[index]) { |
| 721 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 722 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 723 | MdpPipeInfo* cur_pipe = |
| 724 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 725 | cur_pipe->zOrder = mdpIdx++; |
| 726 | |
| 727 | if(configure(ctx, layer, |
| 728 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 729 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 730 | layer %d",__FUNCTION__, index); |
| 731 | return false; |
| 732 | } |
| 733 | } |
| 734 | } |
| 735 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | 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] | 739 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 740 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 741 | { //LOCK SCOPE BEGIN |
| 742 | Locker::Autolock _l(mMdpCompLock); |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 743 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 744 | //reset old data |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 745 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 746 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 747 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 748 | //do not cache the information for next draw cycle. |
| 749 | if(numLayers > MAX_NUM_APP_LAYERS) { |
| 750 | mCachedFrame.updateCounts(mCurrentFrame); |
| 751 | ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ", |
| 752 | __FUNCTION__); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 753 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | //Hard conditions, if not met, cannot do MDP comp |
| 757 | if(!isFrameDoable(ctx)) { |
| 758 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 759 | __FUNCTION__); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 760 | reset(numLayers, list); |
| 761 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | //Check whether layers marked for MDP Composition is actually doable. |
| 765 | if(isFullFrameDoable(ctx, list)){ |
| 766 | mCurrentFrame.map(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 767 | //Configure framebuffer first if applicable |
| 768 | if(mCurrentFrame.fbZ >= 0) { |
| 769 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 770 | mCurrentFrame.fbZ)) { |
| 771 | ALOGE("%s configure framebuffer failed", __func__); |
| 772 | reset(numLayers, list); |
| 773 | return -1; |
| 774 | } |
| 775 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 776 | //Acquire and Program MDP pipes |
| 777 | if(!programMDP(ctx, list)) { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 778 | reset(numLayers, list); |
| 779 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 780 | } else { //Success |
| 781 | //Any change in composition types needs an FB refresh |
| 782 | mCurrentFrame.needsRedraw = false; |
| 783 | if(mCurrentFrame.fbCount && |
| 784 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 785 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 786 | (mCurrentFrame.fbZ != mCachedFrame.fbZ) || |
| 787 | (!mCurrentFrame.mdpCount) || |
| 788 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 789 | isSkipPresent(ctx, mDpy) || |
| 790 | (mDpy > HWC_DISPLAY_PRIMARY))) { |
| 791 | mCurrentFrame.needsRedraw = true; |
| 792 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 793 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 794 | } else if(isOnlyVideoDoable(ctx, list)) { |
| 795 | //All layers marked for MDP comp cannot be bypassed. |
| 796 | //Try to compose atleast YUV layers through MDP comp and let |
| 797 | //all the RGB layers compose in FB |
| 798 | //Destination over |
| 799 | mCurrentFrame.fbZ = -1; |
| 800 | if(mCurrentFrame.fbCount) |
| 801 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 802 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 803 | mCurrentFrame.map(); |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 804 | |
| 805 | //Configure framebuffer first if applicable |
| 806 | if(mCurrentFrame.fbZ >= 0) { |
| 807 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 808 | ALOGE("%s configure framebuffer failed", __func__); |
| 809 | reset(numLayers, list); |
| 810 | return -1; |
| 811 | } |
| 812 | } |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 813 | if(!programYUV(ctx, list)) { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 814 | reset(numLayers, list); |
| 815 | return -1; |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 816 | } |
| 817 | } else { |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 818 | reset(numLayers, list); |
| 819 | return -1; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 820 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 821 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 822 | //UpdateLayerFlags |
| 823 | setMDPCompLayerFlags(ctx, list); |
| 824 | mCachedFrame.updateCounts(mCurrentFrame); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 825 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 826 | } //LOCK SCOPE END. dump also need this lock. |
| 827 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 828 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 829 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 830 | android::String8 sDump(""); |
| 831 | dump(sDump); |
| 832 | ALOGE("%s",sDump.string()); |
| 833 | } |
| 834 | |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 835 | return 0; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | //=============MDPCompLowRes=================================================== |
| 839 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 840 | /* |
| 841 | * Configures pipe(s) for MDP composition |
| 842 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 843 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 844 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 845 | MdpPipeInfoLowRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 846 | *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 847 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 848 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 849 | eIsFg isFg = IS_FG_OFF; |
| 850 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 851 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 852 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 853 | __FUNCTION__, layer, zOrder, dest); |
| 854 | |
| 855 | return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
| 856 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 857 | } |
| 858 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 859 | bool MDPCompLowRes::arePipesAvailable(hwc_context_t *ctx, |
| 860 | hwc_display_contents_1_t* list) { |
| 861 | overlay::Overlay& ov = *ctx->mOverlay; |
| 862 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 863 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 864 | |
| 865 | //Reserve pipe for FB |
| 866 | if(mCurrentFrame.fbCount) |
| 867 | availPipes -= 1; |
| 868 | |
| 869 | if(numPipesNeeded > availPipes) { |
| 870 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 871 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 872 | return false; |
| 873 | } |
| 874 | |
| 875 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 878 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 879 | hwc_display_contents_1_t* list) { |
| 880 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 881 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 882 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 883 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 884 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 885 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 886 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 887 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 888 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 889 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 890 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 891 | ePipeType type = MDPCOMP_OV_ANY; |
| 892 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 893 | if(isYuvBuffer(hnd)) { |
| 894 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 895 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 896 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 897 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 898 | type = MDPCOMP_OV_DMA; |
| 899 | } |
| 900 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 901 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 902 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 903 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 904 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 905 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 906 | } |
| 907 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 908 | return true; |
| 909 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 910 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 911 | 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] | 912 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 913 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 914 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 915 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 916 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 917 | |
| 918 | if(!ctx || !list) { |
| 919 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 920 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 923 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 924 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 925 | return true; |
| 926 | } |
| 927 | |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 928 | Locker::Autolock _l(mMdpCompLock); |
| 929 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 930 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 931 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 932 | idleInvalidator->markForSleep(); |
| 933 | |
| 934 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 935 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 936 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 937 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 938 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 939 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 940 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 941 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 942 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 943 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 944 | if(!hnd) { |
| 945 | ALOGE("%s handle null", __FUNCTION__); |
| 946 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 947 | } |
| 948 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 949 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 950 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 951 | MdpPipeInfoLowRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 952 | *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 953 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 954 | if(dest == ovutils::OV_INVALID) { |
| 955 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 956 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 957 | } |
| 958 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 959 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 960 | continue; |
| 961 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 962 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 963 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 964 | using pipe: %d", __FUNCTION__, layer, |
| 965 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 966 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 967 | int fd = hnd->fd; |
| 968 | uint32_t offset = hnd->offset; |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 969 | |
| 970 | if(ctx->mAD->isModeOn()) { |
| 971 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 972 | fd = ctx->mAD->getDstFd(ctx); |
| 973 | offset = ctx->mAD->getDstOffset(ctx); |
| 974 | } |
| 975 | } |
| 976 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 977 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 978 | if(rot) { |
| 979 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 980 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 981 | fd = rot->getDstMemId(); |
| 982 | offset = rot->getDstOffset(); |
| 983 | } |
| 984 | |
| 985 | if (!ov.queueBuffer(fd, offset, dest)) { |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 986 | ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 987 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 988 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 989 | |
| 990 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 991 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 992 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 993 | } |
| 994 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 995 | //=============MDPCompHighRes=================================================== |
| 996 | |
| 997 | int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 998 | hwc_display_contents_1_t* list, |
| 999 | int mixer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1000 | int pipesNeeded = 0; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1001 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1002 | |
| 1003 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1004 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1005 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 1006 | if(!mCurrentFrame.isFBComposed[i]) { |
| 1007 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 1008 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1009 | if(mixer == Overlay::MIXER_LEFT && dst.left < lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1010 | pipesNeeded++; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1011 | } else if(mixer == Overlay::MIXER_RIGHT && dst.right > lSplit) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1012 | pipesNeeded++; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1013 | } |
| 1014 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1015 | } |
| 1016 | return pipesNeeded; |
| 1017 | } |
| 1018 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1019 | bool MDPCompHighRes::arePipesAvailable(hwc_context_t *ctx, |
| 1020 | hwc_display_contents_1_t* list) { |
| 1021 | overlay::Overlay& ov = *ctx->mOverlay; |
| 1022 | |
| 1023 | for(int i = 0; i < Overlay::MIXER_MAX; i++) { |
| 1024 | int numPipesNeeded = pipesNeeded(ctx, list, i); |
| 1025 | int availPipes = ov.availablePipes(mDpy, i); |
| 1026 | |
| 1027 | //Reserve pipe(s)for FB |
| 1028 | if(mCurrentFrame.fbCount) |
| 1029 | availPipes -= 1; |
| 1030 | |
| 1031 | if(numPipesNeeded > availPipes) { |
| 1032 | ALOGD_IF(isDebug(), "%s: Insufficient pipes for " |
| 1033 | "dpy %d mixer %d needed %d, avail %d", |
| 1034 | __FUNCTION__, mDpy, i, numPipesNeeded, availPipes); |
| 1035 | return false; |
| 1036 | } |
| 1037 | } |
| 1038 | return true; |
| 1039 | } |
| 1040 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1041 | bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1042 | MdpPipeInfoHighRes& pipe_info, |
| 1043 | ePipeType type) { |
| 1044 | const int xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 1045 | const int lSplit = getLeftSplit(ctx, mDpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1046 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1047 | hwc_rect_t dst = layer->displayFrame; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1048 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 1049 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 1050 | |
| 1051 | if (dst.left < lSplit) { |
| 1052 | pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1053 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 1054 | return false; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | if(dst.right > lSplit) { |
| 1058 | pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); |
| 1059 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1060 | return false; |
| 1061 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1062 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1063 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1067 | hwc_display_contents_1_t* list) { |
| 1068 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1069 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1070 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1071 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1072 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1073 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | 0d65dbe | 2013-06-06 18:33:16 -0700 | [diff] [blame] | 1074 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 1075 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1076 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1077 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1078 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1079 | ePipeType type = MDPCOMP_OV_ANY; |
| 1080 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1081 | if(isYuvBuffer(hnd)) { |
| 1082 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 1083 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1084 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1085 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1086 | type = MDPCOMP_OV_DMA; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1087 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1088 | |
| 1089 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 1090 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", |
| 1091 | __FUNCTION__, (int) type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1092 | return false; |
| 1093 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1094 | } |
| 1095 | return true; |
| 1096 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 1097 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1098 | /* |
| 1099 | * Configures pipe(s) for MDP composition |
| 1100 | */ |
| 1101 | int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 1102 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1103 | MdpPipeInfoHighRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1104 | *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1105 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1106 | eIsFg isFg = IS_FG_OFF; |
| 1107 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1108 | eDest lDest = mdp_info.lIndex; |
| 1109 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1110 | |
| 1111 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1112 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1113 | |
| 1114 | return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
| 1115 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1119 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1120 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1121 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1122 | return true; |
| 1123 | } |
| 1124 | |
| 1125 | if(!ctx || !list) { |
| 1126 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1127 | return false; |
| 1128 | } |
| 1129 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 1130 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 1131 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 1132 | return true; |
| 1133 | } |
| 1134 | |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 1135 | Locker::Autolock _l(mMdpCompLock); |
| 1136 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1137 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1138 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1139 | idleInvalidator->markForSleep(); |
| 1140 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1141 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1142 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1143 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1144 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1145 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1146 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1147 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1148 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1149 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1150 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1151 | if(!hnd) { |
| 1152 | ALOGE("%s handle null", __FUNCTION__); |
| 1153 | return false; |
| 1154 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1155 | |
| 1156 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1157 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1158 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1159 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1160 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1161 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1162 | MdpPipeInfoHighRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1163 | *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1164 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1165 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1166 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1167 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1168 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1169 | int fd = hnd->fd; |
| 1170 | int offset = hnd->offset; |
| 1171 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1172 | if(ctx->mAD->isModeOn()) { |
| 1173 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 1174 | fd = ctx->mAD->getDstFd(ctx); |
| 1175 | offset = ctx->mAD->getDstOffset(ctx); |
| 1176 | } |
| 1177 | } |
| 1178 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1179 | if(rot) { |
| 1180 | rot->queueBuffer(fd, offset); |
| 1181 | fd = rot->getDstMemId(); |
| 1182 | offset = rot->getDstOffset(); |
| 1183 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1184 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1185 | //************* play left mixer ********** |
| 1186 | if(indexL != ovutils::OV_INVALID) { |
| 1187 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1188 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1189 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1190 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1191 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1192 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | //************* play right mixer ********** |
| 1197 | if(indexR != ovutils::OV_INVALID) { |
| 1198 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1199 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1200 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1201 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1202 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1203 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1204 | } |
| 1205 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1206 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1207 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1208 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1209 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1210 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1211 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1212 | }; //namespace |
| 1213 | |