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