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