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