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