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