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 | |
Naseer Ahmed | dc61a97 | 2013-07-10 17:50:54 -0400 | [diff] [blame] | 571 | if(layer->planeAlpha < 0xFF) { |
| 572 | ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ |
| 573 | in video only mode", |
| 574 | __FUNCTION__); |
| 575 | return false; |
| 576 | } |
| 577 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 578 | return true; |
| 579 | } |
| 580 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 581 | void MDPComp::batchLayers() { |
| 582 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 583 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 584 | * But cached ones can be marked for MDP*/ |
| 585 | |
| 586 | int maxBatchStart = -1; |
| 587 | int maxBatchCount = 0; |
| 588 | |
| 589 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 590 | if(!mCurrentFrame.fbCount) { |
| 591 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 592 | return; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 593 | } |
| 594 | if(!mCurrentFrame.mdpCount) { |
| 595 | mCurrentFrame.fbZ = 0; |
| 596 | return; |
| 597 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 598 | |
| 599 | /* Search for max number of contiguous (cached) layers */ |
| 600 | int i = 0; |
| 601 | while (i < mCurrentFrame.layerCount) { |
| 602 | int count = 0; |
| 603 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 604 | count++; i++; |
| 605 | } |
| 606 | if(count > maxBatchCount) { |
| 607 | maxBatchCount = count; |
| 608 | maxBatchStart = i - count; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 609 | mCurrentFrame.fbZ = maxBatchStart; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 610 | } |
| 611 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 612 | } |
| 613 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 614 | /* reset rest of the layers for MDP comp */ |
| 615 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 616 | if(i != maxBatchStart){ |
| 617 | mCurrentFrame.isFBComposed[i] = false; |
| 618 | } else { |
| 619 | i += maxBatchCount; |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 624 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 625 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 626 | |
| 627 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 628 | mCurrentFrame.fbCount); |
| 629 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 630 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 631 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 632 | hwc_display_contents_1_t* list) { |
| 633 | |
| 634 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 635 | int numCacheableLayers = 0; |
| 636 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 637 | for(int i = 0; i < numAppLayers; i++) { |
| 638 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 639 | numCacheableLayers++; |
| 640 | mCurrentFrame.isFBComposed[i] = true; |
| 641 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 642 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 643 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 644 | } |
| 645 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 646 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 647 | mCurrentFrame.fbCount = numCacheableLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 648 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 649 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 650 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 651 | } |
| 652 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 653 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 654 | |
| 655 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 656 | if(!nYuvCount && mDpy) { |
| 657 | //Reset "No animation on external display" related parameters. |
| 658 | ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top = |
| 659 | ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0; |
| 660 | ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top = |
| 661 | ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0; |
| 662 | ctx->mPrevTransformVideo = 0; |
| 663 | return; |
| 664 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 665 | for(int index = 0;index < nYuvCount; index++){ |
| 666 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 667 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 668 | |
| 669 | if(!isYUVDoable(ctx, layer)) { |
| 670 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 671 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 672 | mCurrentFrame.fbCount++; |
| 673 | } |
| 674 | } else { |
| 675 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 676 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 677 | mCurrentFrame.fbCount--; |
| 678 | } |
| 679 | } |
| 680 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 681 | |
| 682 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 683 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 684 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 685 | mCurrentFrame.fbCount); |
| 686 | } |
| 687 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 688 | 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] | 689 | if(!allocLayerPipes(ctx, list)) { |
| 690 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 691 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 692 | } |
| 693 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 694 | bool fbBatch = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 695 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 696 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 697 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 698 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 699 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 700 | |
| 701 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 702 | cur_pipe->zOrder = mdpNextZOrder++; |
| 703 | |
| 704 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 705 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 706 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 707 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 708 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 709 | } else if(fbBatch == false) { |
| 710 | mdpNextZOrder++; |
| 711 | fbBatch = true; |
| 712 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 713 | } |
| 714 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 715 | return true; |
| 716 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 717 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 718 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 719 | if(!allocLayerPipes(ctx, list)) { |
| 720 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 721 | return false; |
| 722 | } |
| 723 | //If we are in this block, it means we have yuv + rgb layers both |
| 724 | int mdpIdx = 0; |
| 725 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 726 | if(!mCurrentFrame.isFBComposed[index]) { |
| 727 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 728 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 729 | MdpPipeInfo* cur_pipe = |
| 730 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 731 | cur_pipe->zOrder = mdpIdx++; |
| 732 | |
| 733 | if(configure(ctx, layer, |
| 734 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 735 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 736 | layer %d",__FUNCTION__, index); |
| 737 | return false; |
| 738 | } |
| 739 | } |
| 740 | } |
| 741 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | 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] | 745 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
Ramkumar Radhakrishnan | c5893f1 | 2013-06-06 19:43:53 -0700 | [diff] [blame] | 746 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 747 | //reset old data |
| 748 | mCurrentFrame.reset(numLayers); |
Prabhanjan Kandula | 088bd89 | 2013-07-02 23:47:13 +0530 | [diff] [blame] | 749 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 750 | //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU |
| 751 | //do not cache the information for next draw cycle. |
| 752 | if(numLayers > MAX_NUM_APP_LAYERS) { |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 753 | mCachedFrame.updateCounts(mCurrentFrame); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 754 | ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ", |
| 755 | __FUNCTION__); |
| 756 | return -1; |
| 757 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 758 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 759 | //Hard conditions, if not met, cannot do MDP comp |
| 760 | if(!isFrameDoable(ctx)) { |
| 761 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 762 | __FUNCTION__); |
| 763 | reset(numLayers, list); |
| 764 | return -1; |
| 765 | } |
| 766 | |
| 767 | //Check whether layers marked for MDP Composition is actually doable. |
| 768 | if(isFullFrameDoable(ctx, list)) { |
| 769 | mCurrentFrame.map(); |
| 770 | //Configure framebuffer first if applicable |
| 771 | if(mCurrentFrame.fbZ >= 0) { |
| 772 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, |
| 773 | mCurrentFrame.fbZ)) { |
| 774 | ALOGE("%s configure framebuffer failed", __func__); |
| 775 | reset(numLayers, list); |
| 776 | return -1; |
| 777 | } |
| 778 | } |
| 779 | //Acquire and Program MDP pipes |
| 780 | if(!programMDP(ctx, list)) { |
| 781 | reset(numLayers, list); |
| 782 | return -1; |
| 783 | } else { //Success |
| 784 | //Any change in composition types needs an FB refresh |
| 785 | mCurrentFrame.needsRedraw = false; |
| 786 | if(mCurrentFrame.fbCount && |
| 787 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 788 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 789 | (mCurrentFrame.fbZ != mCachedFrame.fbZ) || |
| 790 | (!mCurrentFrame.mdpCount) || |
| 791 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 792 | isSkipPresent(ctx, mDpy) || |
| 793 | (mDpy > HWC_DISPLAY_PRIMARY))) { |
| 794 | mCurrentFrame.needsRedraw = true; |
| 795 | } |
| 796 | } |
| 797 | } else if(isOnlyVideoDoable(ctx, list)) { |
| 798 | //All layers marked for MDP comp cannot be bypassed. |
| 799 | //Try to compose atleast YUV layers through MDP comp and let |
| 800 | //all the RGB layers compose in FB |
| 801 | //Destination over |
| 802 | mCurrentFrame.fbZ = -1; |
| 803 | if(mCurrentFrame.fbCount) |
| 804 | mCurrentFrame.fbZ = mCurrentFrame.mdpCount; |
| 805 | |
| 806 | mCurrentFrame.map(); |
| 807 | |
| 808 | //Configure framebuffer first if applicable |
| 809 | if(mCurrentFrame.fbZ >= 0) { |
| 810 | if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) { |
| 811 | ALOGE("%s configure framebuffer failed", __func__); |
| 812 | reset(numLayers, list); |
| 813 | return -1; |
| 814 | } |
| 815 | } |
| 816 | if(!programYUV(ctx, list)) { |
| 817 | reset(numLayers, list); |
| 818 | return -1; |
| 819 | } |
| 820 | } else { |
| 821 | reset(numLayers, list); |
| 822 | return -1; |
| 823 | } |
| 824 | |
| 825 | //UpdateLayerFlags |
| 826 | setMDPCompLayerFlags(ctx, list); |
| 827 | mCachedFrame.updateCounts(mCurrentFrame); |
| 828 | |
Prabhanjan Kandula | 25469a5 | 2013-07-12 16:19:31 +0530 | [diff] [blame] | 829 | // unlock it before calling dump function to avoid deadlock |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 830 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 831 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 832 | android::String8 sDump(""); |
| 833 | dump(sDump); |
| 834 | ALOGE("%s",sDump.string()); |
| 835 | } |
| 836 | |
Saurabh Shah | 2a4eb1b | 2013-07-22 16:33:23 -0700 | [diff] [blame] | 837 | return 0; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | //=============MDPCompLowRes=================================================== |
| 841 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 842 | /* |
| 843 | * Configures pipe(s) for MDP composition |
| 844 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 845 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 846 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 847 | MdpPipeInfoLowRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 848 | *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 849 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 850 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 851 | eIsFg isFg = IS_FG_OFF; |
| 852 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 853 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 854 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 855 | __FUNCTION__, layer, zOrder, dest); |
| 856 | |
| 857 | return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
| 858 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 859 | } |
| 860 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 861 | bool MDPCompLowRes::arePipesAvailable(hwc_context_t *ctx, |
| 862 | hwc_display_contents_1_t* list) { |
| 863 | overlay::Overlay& ov = *ctx->mOverlay; |
| 864 | int numPipesNeeded = mCurrentFrame.mdpCount; |
| 865 | int availPipes = ov.availablePipes(mDpy, Overlay::MIXER_DEFAULT); |
| 866 | |
| 867 | //Reserve pipe for FB |
| 868 | if(mCurrentFrame.fbCount) |
| 869 | availPipes -= 1; |
| 870 | |
| 871 | if(numPipesNeeded > availPipes) { |
| 872 | ALOGD_IF(isDebug(), "%s: Insufficient pipes, dpy %d needed %d, avail %d", |
| 873 | __FUNCTION__, mDpy, numPipesNeeded, availPipes); |
| 874 | return false; |
| 875 | } |
| 876 | |
| 877 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 878 | } |
| 879 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 880 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 881 | hwc_display_contents_1_t* list) { |
| 882 | for(int index = 0; index < mCurrentFrame.layerCount; index++) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 883 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 884 | if(mCurrentFrame.isFBComposed[index]) continue; |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 885 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 886 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 887 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 888 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 889 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 890 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 891 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 892 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 893 | ePipeType type = MDPCOMP_OV_ANY; |
| 894 | |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 895 | if(isYuvBuffer(hnd)) { |
| 896 | type = MDPCOMP_OV_VG; |
Saurabh Shah | 8a11793 | 2013-05-23 12:48:13 -0700 | [diff] [blame] | 897 | } else if(!qhwc::needsScaling(ctx, layer, mDpy) |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 898 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 899 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 900 | type = MDPCOMP_OV_DMA; |
| 901 | } |
| 902 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 903 | pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 904 | if(pipe_info.index == ovutils::OV_INVALID) { |
Saurabh Shah | e51f8ca | 2013-05-06 17:26:16 -0700 | [diff] [blame] | 905 | ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", |
| 906 | __FUNCTION__, (int) type); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 907 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 908 | } |
| 909 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 910 | return true; |
| 911 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 912 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 913 | 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] | 914 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 915 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 916 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 917 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 918 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 919 | |
| 920 | if(!ctx || !list) { |
| 921 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 922 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 923 | } |
| 924 | |
Prabhanjan Kandula | 08222fc | 2013-07-10 17:20:59 +0530 | [diff] [blame] | 925 | if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { |
| 926 | ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); |
| 927 | return true; |
| 928 | } |
| 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 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1135 | /* reset Invalidator */ |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 1136 | if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1137 | idleInvalidator->markForSleep(); |
| 1138 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1139 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1140 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1141 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1142 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1143 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1144 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1145 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1146 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1147 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1148 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1149 | if(!hnd) { |
| 1150 | ALOGE("%s handle null", __FUNCTION__); |
| 1151 | return false; |
| 1152 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1153 | |
| 1154 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1155 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1156 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1157 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1158 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1159 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1160 | MdpPipeInfoHighRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1161 | *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1162 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1163 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1164 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1165 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1166 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1167 | int fd = hnd->fd; |
| 1168 | int offset = hnd->offset; |
| 1169 | |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 1170 | if(ctx->mAD->isModeOn()) { |
| 1171 | if(ctx->mAD->draw(ctx, fd, offset)) { |
| 1172 | fd = ctx->mAD->getDstFd(ctx); |
| 1173 | offset = ctx->mAD->getDstOffset(ctx); |
| 1174 | } |
| 1175 | } |
| 1176 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1177 | if(rot) { |
| 1178 | rot->queueBuffer(fd, offset); |
| 1179 | fd = rot->getDstMemId(); |
| 1180 | offset = rot->getDstOffset(); |
| 1181 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1182 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1183 | //************* play left mixer ********** |
| 1184 | if(indexL != ovutils::OV_INVALID) { |
| 1185 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1186 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1187 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1188 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1189 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1190 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | //************* play right mixer ********** |
| 1195 | if(indexR != ovutils::OV_INVALID) { |
| 1196 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1197 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1198 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1199 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1200 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1201 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1202 | } |
| 1203 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1204 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1205 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1206 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1207 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1208 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1209 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1210 | }; //namespace |
| 1211 | |