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; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 38 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 39 | MDPComp* MDPComp::getObject(const int& width) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 40 | if(width <= MAX_DISPLAY_DIM) { |
| 41 | return new MDPCompLowRes(); |
| 42 | } else { |
| 43 | return new MDPCompHighRes(); |
| 44 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void MDPComp::dump(android::String8& buf) |
| 48 | { |
| 49 | dumpsys_log(buf, " MDP Composition: "); |
| 50 | dumpsys_log(buf, "MDPCompState=%d\n", mState); |
| 51 | //XXX: Log more info |
| 52 | } |
| 53 | |
| 54 | bool MDPComp::init(hwc_context_t *ctx) { |
| 55 | |
| 56 | if(!ctx) { |
| 57 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | if(!setupBasePipe(ctx)) { |
| 62 | ALOGE("%s: Failed to setup primary base pipe", __FUNCTION__); |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | char property[PROPERTY_VALUE_MAX]; |
| 67 | |
| 68 | sEnabled = false; |
| 69 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
| 70 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 71 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 72 | sEnabled = true; |
| 73 | } |
| 74 | |
| 75 | sDebugLogs = false; |
| 76 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 77 | if(atoi(property) != 0) |
| 78 | sDebugLogs = true; |
| 79 | } |
| 80 | |
| 81 | unsigned long idle_timeout = DEFAULT_IDLE_TIME; |
| 82 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 83 | if(atoi(property) != 0) |
| 84 | idle_timeout = atoi(property); |
| 85 | } |
| 86 | |
| 87 | //create Idle Invalidator |
| 88 | idleInvalidator = IdleInvalidator::getInstance(); |
| 89 | |
| 90 | if(idleInvalidator == NULL) { |
| 91 | ALOGE("%s: failed to instantiate idleInvalidator object", __FUNCTION__); |
| 92 | } else { |
| 93 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 94 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 95 | return true; |
| 96 | } |
| 97 | |
| 98 | void MDPComp::timeout_handler(void *udata) { |
| 99 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
| 100 | |
| 101 | if(!ctx) { |
| 102 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 103 | return; |
| 104 | } |
| 105 | |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 106 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 107 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 108 | return; |
| 109 | } |
| 110 | sIdleFallBack = true; |
| 111 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 112 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 115 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
| 116 | hwc_display_contents_1_t* list) { |
| 117 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 118 | LayerProp *layerProp = ctx->layerProp[dpy]; |
| 119 | |
| 120 | for(int index = 0; index < ctx->listStats[dpy].numAppLayers; index++ ) { |
| 121 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
| 122 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 123 | layer->compositionType = HWC_OVERLAY; |
| 124 | layer->hints |= HWC_HINT_CLEAR_FB; |
Naseer Ahmed | 52ca6d2 | 2012-10-08 14:03:01 -0400 | [diff] [blame] | 125 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 128 | void MDPComp::unsetMDPCompLayerFlags(hwc_context_t* ctx, |
| 129 | hwc_display_contents_1_t* list) { |
| 130 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 131 | LayerProp *layerProp = ctx->layerProp[dpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 132 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 133 | for (int index = 0 ; |
| 134 | index < ctx->listStats[dpy].numAppLayers; index++) { |
| 135 | if(layerProp[index].mFlags & HWC_MDPCOMP) { |
| 136 | layerProp[index].mFlags &= ~HWC_MDPCOMP; |
| 137 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 138 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 139 | if(list->hwLayers[index].compositionType == HWC_OVERLAY) { |
| 140 | list->hwLayers[index].compositionType = HWC_FRAMEBUFFER; |
| 141 | } |
| 142 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 143 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 144 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 145 | /* |
| 146 | * Sets up BORDERFILL as default base pipe and detaches RGB0. |
| 147 | * Framebuffer is always updated using PLAY ioctl. |
| 148 | */ |
| 149 | bool MDPComp::setupBasePipe(hwc_context_t *ctx) { |
| 150 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 151 | int fb_stride = ctx->dpyAttr[dpy].stride; |
| 152 | int fb_width = ctx->dpyAttr[dpy].xres; |
| 153 | int fb_height = ctx->dpyAttr[dpy].yres; |
| 154 | int fb_fd = ctx->dpyAttr[dpy].fd; |
| 155 | |
| 156 | mdp_overlay ovInfo; |
| 157 | msmfb_overlay_data ovData; |
| 158 | memset(&ovInfo, 0, sizeof(mdp_overlay)); |
| 159 | memset(&ovData, 0, sizeof(msmfb_overlay_data)); |
| 160 | |
| 161 | ovInfo.src.format = MDP_RGB_BORDERFILL; |
| 162 | ovInfo.src.width = fb_width; |
| 163 | ovInfo.src.height = fb_height; |
| 164 | ovInfo.src_rect.w = fb_width; |
| 165 | ovInfo.src_rect.h = fb_height; |
| 166 | ovInfo.dst_rect.w = fb_width; |
| 167 | ovInfo.dst_rect.h = fb_height; |
| 168 | ovInfo.id = MSMFB_NEW_REQUEST; |
| 169 | |
| 170 | if (ioctl(fb_fd, MSMFB_OVERLAY_SET, &ovInfo) < 0) { |
| 171 | ALOGE("Failed to call ioctl MSMFB_OVERLAY_SET err=%s", |
| 172 | strerror(errno)); |
| 173 | return false; |
| 174 | } |
| 175 | |
| 176 | ovData.id = ovInfo.id; |
| 177 | if (ioctl(fb_fd, MSMFB_OVERLAY_PLAY, &ovData) < 0) { |
| 178 | ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY err=%s", |
| 179 | strerror(errno)); |
| 180 | return false; |
| 181 | } |
| 182 | return true; |
| 183 | } |
| 184 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 185 | void MDPComp::reset(hwc_context_t *ctx, |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 186 | hwc_display_contents_1_t* list ) { |
| 187 | //Reset flags and states |
| 188 | unsetMDPCompLayerFlags(ctx, list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 189 | if(mCurrentFrame.pipeLayer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 190 | for(int i = 0 ; i < mCurrentFrame.count; i++ ) { |
| 191 | if(mCurrentFrame.pipeLayer[i].pipeInfo) { |
| 192 | delete mCurrentFrame.pipeLayer[i].pipeInfo; |
| 193 | mCurrentFrame.pipeLayer[i].pipeInfo = NULL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 194 | //We dont own the rotator |
| 195 | mCurrentFrame.pipeLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 196 | } |
| 197 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 198 | free(mCurrentFrame.pipeLayer); |
| 199 | mCurrentFrame.pipeLayer = NULL; |
| 200 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 201 | mCurrentFrame.count = 0; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 202 | } |
| 203 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 204 | bool MDPComp::isWidthValid(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 205 | |
| 206 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 207 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 208 | |
| 209 | if(!hnd) { |
| 210 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | int hw_w = ctx->dpyAttr[dpy].xres; |
| 215 | int hw_h = ctx->dpyAttr[dpy].yres; |
| 216 | |
| 217 | hwc_rect_t sourceCrop = layer->sourceCrop; |
| 218 | hwc_rect_t displayFrame = layer->displayFrame; |
| 219 | |
| 220 | hwc_rect_t crop = sourceCrop; |
| 221 | int crop_w = crop.right - crop.left; |
| 222 | int crop_h = crop.bottom - crop.top; |
| 223 | |
| 224 | hwc_rect_t dst = displayFrame; |
| 225 | int dst_w = dst.right - dst.left; |
| 226 | int dst_h = dst.bottom - dst.top; |
| 227 | |
| 228 | if(dst.left < 0 || dst.top < 0 || dst.right > hw_w || dst.bottom > hw_h) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 229 | hwc_rect_t scissor = {0, 0, hw_w, hw_h }; |
| 230 | qhwc::calculate_crop_rects(crop, dst, scissor, layer->transform); |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 231 | crop_w = crop.right - crop.left; |
| 232 | crop_h = crop.bottom - crop.top; |
| 233 | } |
| 234 | |
| 235 | //Workaround for MDP HW limitation in DSI command mode panels where |
| 236 | //FPS will not go beyond 30 if buffers on RGB pipes are of width < 5 |
| 237 | |
| 238 | if(crop_w < 5) |
| 239 | return false; |
| 240 | |
| 241 | return true; |
| 242 | } |
| 243 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 244 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type) { |
| 245 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 246 | overlay::Overlay& ov = *ctx->mOverlay; |
| 247 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 248 | |
| 249 | switch(type) { |
| 250 | case MDPCOMP_OV_DMA: |
| 251 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, dpy); |
| 252 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 253 | return mdp_pipe; |
| 254 | } |
| 255 | case MDPCOMP_OV_ANY: |
| 256 | case MDPCOMP_OV_RGB: |
| 257 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, dpy); |
| 258 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 259 | return mdp_pipe; |
| 260 | } |
| 261 | |
| 262 | if(type == MDPCOMP_OV_RGB) { |
| 263 | //Requested only for RGB pipe |
| 264 | break; |
| 265 | } |
| 266 | case MDPCOMP_OV_VG: |
| 267 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, dpy); |
| 268 | default: |
| 269 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 270 | return ovutils::OV_INVALID; |
| 271 | }; |
| 272 | return ovutils::OV_INVALID; |
| 273 | } |
| 274 | |
| 275 | bool MDPComp::isDoable(hwc_context_t *ctx, |
| 276 | hwc_display_contents_1_t* list) { |
| 277 | //Number of layers |
| 278 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 279 | int numAppLayers = ctx->listStats[dpy].numAppLayers; |
| 280 | |
| 281 | overlay::Overlay& ov = *ctx->mOverlay; |
| 282 | int availablePipes = ov.availablePipes(dpy); |
| 283 | |
| 284 | if(numAppLayers < 1 || numAppLayers > MAX_PIPES_PER_MIXER || |
| 285 | pipesNeeded(ctx, list) > availablePipes) { |
| 286 | ALOGD_IF(isDebug(), "%s: Unsupported number of layers",__FUNCTION__); |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | if(ctx->mExtDispConfiguring) { |
| 291 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
| 292 | __FUNCTION__); |
| 293 | return false; |
| 294 | } |
| 295 | |
| 296 | if(isSecuring(ctx)) { |
| 297 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 298 | return false; |
| 299 | } |
| 300 | |
| 301 | if(ctx->mSecureMode) |
| 302 | return false; |
| 303 | |
| 304 | //Check for skip layers |
| 305 | if(isSkipPresent(ctx, dpy)) { |
| 306 | ALOGD_IF(isDebug(), "%s: Skip layers are present",__FUNCTION__); |
| 307 | return false; |
| 308 | } |
| 309 | |
| 310 | if(ctx->listStats[dpy].needsAlphaScale |
| 311 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
| 312 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | //FB composition on idle timeout |
| 317 | if(sIdleFallBack) { |
| 318 | sIdleFallBack = false; |
| 319 | ALOGD_IF(isDebug(), "%s: idle fallback",__FUNCTION__); |
| 320 | return false; |
| 321 | } |
| 322 | |
| 323 | //MDP composition is not efficient if layer needs rotator. |
| 324 | for(int i = 0; i < numAppLayers; ++i) { |
| 325 | // As MDP h/w supports flip operation, use MDP comp only for |
| 326 | // 180 transforms. Fail for any transform involving 90 (90, 270). |
| 327 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 328 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 329 | if((layer->transform & HWC_TRANSFORM_ROT_90) && (!isYuvBuffer(hnd) |
| 330 | || !canRotate())) { |
| 331 | ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__); |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | if(!isYuvBuffer(hnd) && !isWidthValid(ctx,layer)) { |
| 336 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width",__FUNCTION__); |
| 337 | return false; |
| 338 | } |
| 339 | } |
| 340 | return true; |
| 341 | } |
| 342 | |
| 343 | bool MDPComp::setup(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 344 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 345 | if(!ctx) { |
| 346 | ALOGE("%s: invalid context", __FUNCTION__); |
| 347 | return -1; |
| 348 | } |
| 349 | |
| 350 | if(!allocLayerPipes(ctx, list, mCurrentFrame)) { |
| 351 | ALOGD_IF(isDebug(), "%s: Falling back to FB", __FUNCTION__); |
| 352 | return false; |
| 353 | } |
| 354 | |
| 355 | for (int index = 0 ; index < mCurrentFrame.count; index++) { |
| 356 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 357 | if(configure(ctx, layer, mCurrentFrame.pipeLayer[index]) != 0 ) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 358 | ALOGD_IF(isDebug(), "%s: MDPComp failed to configure overlay for \ |
| 359 | layer %d",__FUNCTION__, index); |
| 360 | return false; |
| 361 | } |
| 362 | } |
| 363 | return true; |
| 364 | } |
| 365 | |
| 366 | bool MDPComp::prepare(hwc_context_t *ctx, |
| 367 | hwc_display_contents_1_t* list) { |
| 368 | if(!isEnabled()) { |
| 369 | ALOGE_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
| 370 | return false; |
| 371 | } |
| 372 | |
| 373 | overlay::Overlay& ov = *ctx->mOverlay; |
| 374 | bool isMDPCompUsed = true; |
| 375 | |
| 376 | //reset old data |
| 377 | reset(ctx, list); |
| 378 | |
| 379 | bool doable = isDoable(ctx, list); |
| 380 | if(doable) { |
| 381 | if(setup(ctx, list)) { |
| 382 | setMDPCompLayerFlags(ctx, list); |
| 383 | } else { |
| 384 | ALOGD_IF(isDebug(),"%s: MDP Comp Failed",__FUNCTION__); |
| 385 | isMDPCompUsed = false; |
| 386 | } |
| 387 | } else { |
| 388 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible[%d]",__FUNCTION__, |
| 389 | doable); |
| 390 | isMDPCompUsed = false; |
| 391 | } |
| 392 | |
| 393 | //Reset states |
| 394 | if(!isMDPCompUsed) { |
| 395 | //Reset current frame |
| 396 | reset(ctx, list); |
| 397 | } |
| 398 | |
| 399 | mState = isMDPCompUsed ? MDPCOMP_ON : MDPCOMP_OFF; |
| 400 | return isMDPCompUsed; |
| 401 | } |
| 402 | |
| 403 | //=============MDPCompLowRes=================================================== |
| 404 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 405 | /* |
| 406 | * Configures pipe(s) for MDP composition |
| 407 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 408 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 409 | PipeLayerPair& pipeLayerPair) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 410 | const int dpy = HWC_DISPLAY_PRIMARY; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 411 | MdpPipeInfoLowRes& mdp_info = |
| 412 | *(static_cast<MdpPipeInfoLowRes*>(pipeLayerPair.pipeInfo)); |
| 413 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 414 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 415 | eIsFg isFg = IS_FG_OFF; |
| 416 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 417 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 418 | return configureLowRes(ctx, layer, dpy, mdpFlags, zOrder, isFg, dest, |
| 419 | &pipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 422 | int MDPCompLowRes::pipesNeeded(hwc_context_t *ctx, |
| 423 | hwc_display_contents_1_t* list) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 424 | const int dpy = HWC_DISPLAY_PRIMARY; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 425 | return ctx->listStats[dpy].numAppLayers; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 426 | } |
| 427 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 428 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 429 | hwc_display_contents_1_t* list, |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 430 | FrameInfo& currentFrame) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 431 | const int dpy = HWC_DISPLAY_PRIMARY; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 432 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 433 | int layer_count = ctx->listStats[dpy].numAppLayers; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 434 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 435 | currentFrame.count = layer_count; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 436 | currentFrame.pipeLayer = (PipeLayerPair*) |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 437 | malloc(sizeof(PipeLayerPair) * currentFrame.count); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 438 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 439 | if(isYuvPresent(ctx, dpy)) { |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 440 | int nYuvCount = ctx->listStats[dpy].yuvCount; |
| 441 | |
| 442 | for(int index = 0; index < nYuvCount; index ++) { |
| 443 | int nYuvIndex = ctx->listStats[dpy].yuvIndices[index]; |
| 444 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 445 | PipeLayerPair& info = currentFrame.pipeLayer[nYuvIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 446 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 447 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 448 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 449 | pipe_info.index = getMdpPipe(ctx, MDPCOMP_OV_VG); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 450 | if(pipe_info.index == ovutils::OV_INVALID) { |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 451 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for Videos", |
| 452 | __FUNCTION__); |
| 453 | return false; |
| 454 | } |
| 455 | pipe_info.zOrder = nYuvIndex; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 456 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 457 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 458 | |
| 459 | for(int index = 0 ; index < layer_count ; index++ ) { |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 460 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 461 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 462 | |
| 463 | if(isYuvBuffer(hnd)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 464 | continue; |
| 465 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 466 | PipeLayerPair& info = currentFrame.pipeLayer[index]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 467 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 468 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 469 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
| 470 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 471 | pipe_info.index = getMdpPipe(ctx, MDPCOMP_OV_ANY); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 472 | if(pipe_info.index == ovutils::OV_INVALID) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 473 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 474 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 475 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 476 | pipe_info.zOrder = index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 477 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 478 | return true; |
| 479 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 480 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 481 | 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] | 482 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 483 | if(!isEnabled() || !isUsed()) { |
| 484 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 485 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 486 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 487 | |
| 488 | if(!ctx || !list) { |
| 489 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 490 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 491 | } |
| 492 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 493 | /* reset Invalidator */ |
| 494 | if(idleInvalidator) |
| 495 | idleInvalidator->markForSleep(); |
| 496 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 497 | const int dpy = HWC_DISPLAY_PRIMARY; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 498 | overlay::Overlay& ov = *ctx->mOverlay; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 499 | LayerProp *layerProp = ctx->layerProp[dpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 500 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 501 | int numHwLayers = ctx->listStats[dpy].numAppLayers; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 502 | for(int i = 0; i < numHwLayers; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 503 | { |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 504 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 505 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 506 | if(!hnd) { |
| 507 | ALOGE("%s handle null", __FUNCTION__); |
| 508 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 511 | MdpPipeInfoLowRes& pipe_info = |
| 512 | *(MdpPipeInfoLowRes*)mCurrentFrame.pipeLayer[i].pipeInfo; |
| 513 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 514 | if(dest == ovutils::OV_INVALID) { |
| 515 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 516 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 519 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 520 | continue; |
| 521 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 522 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 523 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 524 | using pipe: %d", __FUNCTION__, layer, |
| 525 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 526 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 527 | int fd = hnd->fd; |
| 528 | uint32_t offset = hnd->offset; |
| 529 | Rotator *rot = mCurrentFrame.pipeLayer[i].rot; |
| 530 | if(rot) { |
| 531 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 532 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 533 | fd = rot->getDstMemId(); |
| 534 | offset = rot->getDstOffset(); |
| 535 | } |
| 536 | |
| 537 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 538 | ALOGE("%s: queueBuffer failed for external", __FUNCTION__); |
| 539 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 540 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 541 | |
| 542 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 543 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 544 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 547 | //=============MDPCompHighRes=================================================== |
| 548 | |
| 549 | int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx, |
| 550 | hwc_display_contents_1_t* list) { |
| 551 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 552 | int numAppLayers = ctx->listStats[dpy].numAppLayers; |
| 553 | int pipesNeeded = 0; |
| 554 | |
| 555 | int hw_w = ctx->dpyAttr[dpy].xres; |
| 556 | |
| 557 | for(int i = 0; i < numAppLayers; ++i) { |
| 558 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 559 | hwc_rect_t dst = layer->displayFrame; |
| 560 | if(dst.left > hw_w/2) { |
| 561 | pipesNeeded++; |
| 562 | } else if(dst.right <= hw_w/2) { |
| 563 | pipesNeeded++; |
| 564 | } else { |
| 565 | pipesNeeded += 2; |
| 566 | } |
| 567 | } |
| 568 | return pipesNeeded; |
| 569 | } |
| 570 | |
| 571 | bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 572 | MdpPipeInfoHighRes& pipe_info, ePipeType type) { |
| 573 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 574 | int hw_w = ctx->dpyAttr[dpy].xres; |
| 575 | |
| 576 | hwc_rect_t dst = layer->displayFrame; |
| 577 | if(dst.left > hw_w/2) { |
| 578 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 579 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 580 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
| 581 | return false; |
| 582 | } else if (dst.right <= hw_w/2) { |
| 583 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 584 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 585 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 586 | return false; |
| 587 | } else { |
| 588 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 589 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 590 | if(pipe_info.rIndex == ovutils::OV_INVALID || |
| 591 | pipe_info.lIndex == ovutils::OV_INVALID) |
| 592 | return false; |
| 593 | } |
| 594 | return true; |
| 595 | } |
| 596 | |
| 597 | bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx, |
| 598 | hwc_display_contents_1_t* list, |
| 599 | FrameInfo& currentFrame) { |
| 600 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 601 | overlay::Overlay& ov = *ctx->mOverlay; |
| 602 | int layer_count = ctx->listStats[dpy].numAppLayers; |
| 603 | |
| 604 | currentFrame.count = layer_count; |
| 605 | currentFrame.pipeLayer = (PipeLayerPair*) |
| 606 | malloc(sizeof(PipeLayerPair) * currentFrame.count); |
| 607 | |
| 608 | if(isYuvPresent(ctx, dpy)) { |
| 609 | int nYuvCount = ctx->listStats[dpy].yuvCount; |
| 610 | |
| 611 | for(int index = 0; index < nYuvCount; index ++) { |
| 612 | int nYuvIndex = ctx->listStats[dpy].yuvIndices[index]; |
| 613 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 614 | PipeLayerPair& info = currentFrame.pipeLayer[nYuvIndex]; |
| 615 | info.pipeInfo = new MdpPipeInfoHighRes; |
| 616 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 617 | if(!acquireMDPPipes(ctx, layer, pipe_info,MDPCOMP_OV_VG)) { |
| 618 | ALOGD_IF(isDebug(),"%s: Unable to get pipe for videos", |
| 619 | __FUNCTION__); |
| 620 | //TODO: windback pipebook data on fail |
| 621 | return false; |
| 622 | } |
| 623 | pipe_info.zOrder = nYuvIndex; |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | for(int index = 0 ; index < layer_count ; index++ ) { |
| 628 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 629 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 630 | |
| 631 | if(isYuvBuffer(hnd)) |
| 632 | continue; |
| 633 | |
| 634 | PipeLayerPair& info = currentFrame.pipeLayer[index]; |
| 635 | info.pipeInfo = new MdpPipeInfoHighRes; |
| 636 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 637 | |
| 638 | ePipeType type = MDPCOMP_OV_ANY; |
| 639 | |
| 640 | if(!qhwc::needsScaling(layer) && !ctx->mDMAInUse |
| 641 | && ctx->mMDP.version >= qdutils::MDSS_V5) |
| 642 | type = MDPCOMP_OV_DMA; |
| 643 | |
| 644 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
| 645 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 646 | //TODO: windback pipebook data on fail |
| 647 | return false; |
| 648 | } |
| 649 | pipe_info.zOrder = index; |
| 650 | } |
| 651 | return true; |
| 652 | } |
| 653 | /* |
| 654 | * Configures pipe(s) for MDP composition |
| 655 | */ |
| 656 | int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 657 | PipeLayerPair& pipeLayerPair) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 658 | const int dpy = HWC_DISPLAY_PRIMARY; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 659 | MdpPipeInfoHighRes& mdp_info = |
| 660 | *(static_cast<MdpPipeInfoHighRes*>(pipeLayerPair.pipeInfo)); |
| 661 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 662 | eIsFg isFg = IS_FG_OFF; |
| 663 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 664 | eDest lDest = mdp_info.lIndex; |
| 665 | eDest rDest = mdp_info.rIndex; |
| 666 | return configureHighRes(ctx, layer, dpy, mdpFlagsL, zOrder, isFg, lDest, |
| 667 | rDest, &pipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 671 | |
| 672 | if(!isEnabled() || !isUsed()) { |
| 673 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 674 | return true; |
| 675 | } |
| 676 | |
| 677 | if(!ctx || !list) { |
| 678 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 679 | return false; |
| 680 | } |
| 681 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 682 | /* reset Invalidator */ |
| 683 | if(idleInvalidator) |
| 684 | idleInvalidator->markForSleep(); |
| 685 | |
| 686 | const int dpy = HWC_DISPLAY_PRIMARY; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 687 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 688 | LayerProp *layerProp = ctx->layerProp[dpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 689 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 690 | int numHwLayers = ctx->listStats[dpy].numAppLayers; |
| 691 | for(int i = 0; i < numHwLayers; i++ ) |
| 692 | { |
| 693 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 694 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 695 | if(!hnd) { |
| 696 | ALOGE("%s handle null", __FUNCTION__); |
| 697 | return false; |
| 698 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 699 | |
| 700 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 701 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 702 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 703 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 704 | MdpPipeInfoHighRes& pipe_info = |
| 705 | *(MdpPipeInfoHighRes*)mCurrentFrame.pipeLayer[i].pipeInfo; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 706 | Rotator *rot = mCurrentFrame.pipeLayer[i].rot; |
| 707 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 708 | ovutils::eDest indexL = pipe_info.lIndex; |
| 709 | ovutils::eDest indexR = pipe_info.rIndex; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 710 | int fd = hnd->fd; |
| 711 | int offset = hnd->offset; |
| 712 | |
| 713 | if(rot) { |
| 714 | rot->queueBuffer(fd, offset); |
| 715 | fd = rot->getDstMemId(); |
| 716 | offset = rot->getDstOffset(); |
| 717 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 718 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 719 | //************* play left mixer ********** |
| 720 | if(indexL != ovutils::OV_INVALID) { |
| 721 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 722 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 723 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
| 724 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 725 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 726 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
| 730 | //************* play right mixer ********** |
| 731 | if(indexR != ovutils::OV_INVALID) { |
| 732 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 733 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
| 734 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
| 735 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 736 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 737 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 738 | } |
| 739 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 740 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 741 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 742 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 743 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 744 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 745 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 746 | }; //namespace |
| 747 | |