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