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