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