hwc_utils.cpp revision 63d668829904b49e30e2e3e53defbfda70ab23b7
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * Copyright (C) 2012-2013, The Linux Foundation All rights reserved. 4 * 5 * Not a Contribution, Apache license notifications and license are retained 6 * for attribution purposes only. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) 21#define HWC_UTILS_DEBUG 0 22#include <math.h> 23#include <sys/ioctl.h> 24#include <binder/IServiceManager.h> 25#include <EGL/egl.h> 26#include <cutils/properties.h> 27#include <utils/Trace.h> 28#include <gralloc_priv.h> 29#include <overlay.h> 30#include <overlayRotator.h> 31#include <overlayWriteback.h> 32#include "hwc_utils.h" 33#include "hwc_mdpcomp.h" 34#include "hwc_fbupdate.h" 35#include "hwc_ad.h" 36#include "mdp_version.h" 37#include "hwc_copybit.h" 38#include "external.h" 39#include "hwc_qclient.h" 40#include "QService.h" 41#include "comptype.h" 42 43using namespace qClient; 44using namespace qService; 45using namespace android; 46using namespace overlay; 47using namespace overlay::utils; 48namespace ovutils = overlay::utils; 49 50namespace qhwc { 51 52static int openFramebufferDevice(hwc_context_t *ctx) 53{ 54 struct fb_fix_screeninfo finfo; 55 struct fb_var_screeninfo info; 56 57 int fb_fd = openFb(HWC_DISPLAY_PRIMARY); 58 if(fb_fd < 0) { 59 ALOGE("%s: Error Opening FB : %s", __FUNCTION__, strerror(errno)); 60 return -errno; 61 } 62 63 if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &info) == -1) { 64 ALOGE("%s:Error in ioctl FBIOGET_VSCREENINFO: %s", __FUNCTION__, 65 strerror(errno)); 66 close(fb_fd); 67 return -errno; 68 } 69 70 if (int(info.width) <= 0 || int(info.height) <= 0) { 71 // the driver doesn't return that information 72 // default to 160 dpi 73 info.width = ((info.xres * 25.4f)/160.0f + 0.5f); 74 info.height = ((info.yres * 25.4f)/160.0f + 0.5f); 75 } 76 77 float xdpi = (info.xres * 25.4f) / info.width; 78 float ydpi = (info.yres * 25.4f) / info.height; 79 80#ifdef MSMFB_METADATA_GET 81 struct msmfb_metadata metadata; 82 memset(&metadata, 0 , sizeof(metadata)); 83 metadata.op = metadata_op_frame_rate; 84 85 if (ioctl(fb_fd, MSMFB_METADATA_GET, &metadata) == -1) { 86 ALOGE("%s:Error retrieving panel frame rate: %s", __FUNCTION__, 87 strerror(errno)); 88 close(fb_fd); 89 return -errno; 90 } 91 92 float fps = metadata.data.panel_frame_rate; 93#else 94 //XXX: Remove reserved field usage on all baselines 95 //The reserved[3] field is used to store FPS by the driver. 96 float fps = info.reserved[3] & 0xFF; 97#endif 98 99 if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo) == -1) { 100 ALOGE("%s:Error in ioctl FBIOGET_FSCREENINFO: %s", __FUNCTION__, 101 strerror(errno)); 102 close(fb_fd); 103 return -errno; 104 } 105 106 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = fb_fd; 107 //xres, yres may not be 32 aligned 108 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].stride = finfo.line_length /(info.xres/8); 109 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres = info.xres; 110 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = info.yres; 111 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = xdpi; 112 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi; 113 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period = 1000000000l / fps; 114 115 //Unblank primary on first boot 116 if(ioctl(fb_fd, FBIOBLANK,FB_BLANK_UNBLANK) < 0) { 117 ALOGE("%s: Failed to unblank display", __FUNCTION__); 118 return -errno; 119 } 120 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isActive = true; 121 122 return 0; 123} 124 125void initContext(hwc_context_t *ctx) 126{ 127 memset(&ctx->dpyAttr, 0, sizeof(ctx->dpyAttr)); 128 if(openFramebufferDevice(ctx) < 0) { 129 ALOGE("%s: failed to open framebuffer!!", __FUNCTION__); 130 } 131 132 overlay::Overlay::initOverlay(); 133 ctx->mOverlay = overlay::Overlay::getInstance(); 134 ctx->mRotMgr = new RotMgr(); 135 ctx->mMDP.version = qdutils::MDPVersion::getInstance().getMDPVersion(); 136 ctx->mMDP.hasOverlay = qdutils::MDPVersion::getInstance().hasOverlay(); 137 ctx->mMDP.panel = qdutils::MDPVersion::getInstance().getPanelType(); 138 const int rightSplit = qdutils::MDPVersion::getInstance().getRightSplit(); 139 overlay::Overlay::initOverlay(); 140 ctx->mOverlay = overlay::Overlay::getInstance(); 141 ctx->mRotMgr = new RotMgr(); 142 143 //Is created and destroyed only once for primary 144 //For external it could get created and destroyed multiple times depending 145 //on what external we connect to. 146 ctx->mFBUpdate[HWC_DISPLAY_PRIMARY] = 147 IFBUpdate::getObject(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres, 148 rightSplit, HWC_DISPLAY_PRIMARY); 149 150 // Check if the target supports copybit compostion (dyn/mdp/c2d) to 151 // decide if we need to open the copybit module. 152 int compositionType = 153 qdutils::QCCompositionType::getInstance().getCompositionType(); 154 155 if (compositionType & (qdutils::COMPOSITION_TYPE_DYN | 156 qdutils::COMPOSITION_TYPE_MDP | 157 qdutils::COMPOSITION_TYPE_C2D)) { 158 ctx->mCopyBit[HWC_DISPLAY_PRIMARY] = new CopyBit(); 159 } 160 161 ctx->mExtDisplay = new ExternalDisplay(ctx); 162 163 for (uint32_t i = 0; i < MAX_DISPLAYS; i++) { 164 ctx->mLayerRotMap[i] = new LayerRotMap(); 165 } 166 167 ctx->mMDPComp[HWC_DISPLAY_PRIMARY] = 168 MDPComp::getObject(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres, 169 rightSplit, HWC_DISPLAY_PRIMARY); 170 171 MDPComp::init(ctx); 172 ctx->mAD = new AssertiveDisplay(); 173 174 ctx->vstate.enable = false; 175 ctx->vstate.fakevsync = false; 176 177 //Right now hwc starts the service but anybody could do it, or it could be 178 //independent process as well. 179 QService::init(); 180 sp<IQClient> client = new QClient(ctx); 181 interface_cast<IQService>( 182 defaultServiceManager()->getService( 183 String16("display.qservice")))->connect(client); 184 185 ALOGI("Initializing Qualcomm Hardware Composer"); 186 ALOGI("MDP version: %d", ctx->mMDP.version); 187} 188 189void closeContext(hwc_context_t *ctx) 190{ 191 if(ctx->mOverlay) { 192 delete ctx->mOverlay; 193 ctx->mOverlay = NULL; 194 } 195 196 if(ctx->mRotMgr) { 197 delete ctx->mRotMgr; 198 ctx->mRotMgr = NULL; 199 } 200 201 for(int i = 0; i < MAX_DISPLAYS; i++) { 202 if(ctx->mCopyBit[i]) { 203 delete ctx->mCopyBit[i]; 204 ctx->mCopyBit[i] = NULL; 205 } 206 } 207 208 if(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd) { 209 close(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd); 210 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = -1; 211 } 212 213 if(ctx->mExtDisplay) { 214 delete ctx->mExtDisplay; 215 ctx->mExtDisplay = NULL; 216 } 217 218 for(int i = 0; i < MAX_DISPLAYS; i++) { 219 if(ctx->mFBUpdate[i]) { 220 delete ctx->mFBUpdate[i]; 221 ctx->mFBUpdate[i] = NULL; 222 } 223 if(ctx->mMDPComp[i]) { 224 delete ctx->mMDPComp[i]; 225 ctx->mMDPComp[i] = NULL; 226 } 227 if(ctx->mLayerRotMap[i]) { 228 delete ctx->mLayerRotMap[i]; 229 ctx->mLayerRotMap[i] = NULL; 230 } 231 } 232 233 if(ctx->mAD) { 234 delete ctx->mAD; 235 ctx->mAD = NULL; 236 } 237} 238 239 240void dumpsys_log(android::String8& buf, const char* fmt, ...) 241{ 242 va_list varargs; 243 va_start(varargs, fmt); 244 buf.appendFormatV(fmt, varargs); 245 va_end(varargs); 246} 247 248/* Calculates the destination position based on the action safe rectangle */ 249void getActionSafePosition(hwc_context_t *ctx, int dpy, uint32_t& x, 250 uint32_t& y, uint32_t& w, uint32_t& h) { 251 252 // if external supports underscan, do nothing 253 // it will be taken care in the driver 254 if(ctx->mExtDisplay->isCEUnderscanSupported()) 255 return; 256 257 char value[PROPERTY_VALUE_MAX]; 258 // Read action safe properties 259 property_get("persist.sys.actionsafe.width", value, "0"); 260 int asWidthRatio = atoi(value); 261 property_get("persist.sys.actionsafe.height", value, "0"); 262 int asHeightRatio = atoi(value); 263 264 if(!asWidthRatio && !asHeightRatio) { 265 //No action safe ratio set, return 266 return; 267 } 268 269 float wRatio = 1.0; 270 float hRatio = 1.0; 271 float xRatio = 1.0; 272 float yRatio = 1.0; 273 274 float fbWidth = ctx->dpyAttr[dpy].xres; 275 float fbHeight = ctx->dpyAttr[dpy].yres; 276 277 float asX = 0; 278 float asY = 0; 279 float asW = fbWidth; 280 float asH= fbHeight; 281 282 // based on the action safe ratio, get the Action safe rectangle 283 asW = fbWidth * (1.0f - asWidthRatio / 100.0f); 284 asH = fbHeight * (1.0f - asHeightRatio / 100.0f); 285 asX = (fbWidth - asW) / 2; 286 asY = (fbHeight - asH) / 2; 287 288 // calculate the position ratio 289 xRatio = (float)x/fbWidth; 290 yRatio = (float)y/fbHeight; 291 wRatio = (float)w/fbWidth; 292 hRatio = (float)h/fbHeight; 293 294 //Calculate the position... 295 x = (xRatio * asW) + asX; 296 y = (yRatio * asH) + asY; 297 w = (wRatio * asW); 298 h = (hRatio * asH); 299 300 return; 301} 302 303bool needsScaling(hwc_context_t* ctx, hwc_layer_1_t const* layer, 304 const int& dpy) { 305 int dst_w, dst_h, src_w, src_h; 306 307 hwc_rect_t displayFrame = layer->displayFrame; 308 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); 309 trimLayer(ctx, dpy, layer->transform, sourceCrop, displayFrame); 310 311 dst_w = displayFrame.right - displayFrame.left; 312 dst_h = displayFrame.bottom - displayFrame.top; 313 src_w = sourceCrop.right - sourceCrop.left; 314 src_h = sourceCrop.bottom - sourceCrop.top; 315 316 if(((src_w != dst_w) || (src_h != dst_h))) 317 return true; 318 319 return false; 320} 321 322bool isAlphaScaled(hwc_context_t* ctx, hwc_layer_1_t const* layer, 323 const int& dpy) { 324 if(needsScaling(ctx, layer, dpy) && isAlphaPresent(layer)) { 325 return true; 326 } 327 return false; 328} 329 330bool isAlphaPresent(hwc_layer_1_t const* layer) { 331 private_handle_t *hnd = (private_handle_t *)layer->handle; 332 if(hnd) { 333 int format = hnd->format; 334 switch(format) { 335 case HAL_PIXEL_FORMAT_RGBA_8888: 336 case HAL_PIXEL_FORMAT_BGRA_8888: 337 // In any more formats with Alpha go here.. 338 return true; 339 default : return false; 340 } 341 } 342 return false; 343} 344 345// Let CABL know we have a YUV layer 346static void setYUVProp(int yuvCount) { 347 static char property[PROPERTY_VALUE_MAX]; 348 if(yuvCount > 0) { 349 if (property_get("hw.cabl.yuv", property, NULL) > 0) { 350 if (atoi(property) != 1) { 351 property_set("hw.cabl.yuv", "1"); 352 } 353 } 354 } else { 355 if (property_get("hw.cabl.yuv", property, NULL) > 0) { 356 if (atoi(property) != 0) { 357 property_set("hw.cabl.yuv", "0"); 358 } 359 } 360 } 361} 362 363void setListStats(hwc_context_t *ctx, 364 const hwc_display_contents_1_t *list, int dpy) { 365 const int prevYuvCount = ctx->listStats[dpy].yuvCount; 366 memset(&ctx->listStats[dpy], 0, sizeof(ListStats)); 367 ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1; 368 ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1; 369 ctx->listStats[dpy].skipCount = 0; 370 ctx->listStats[dpy].needsAlphaScale = false; 371 ctx->listStats[dpy].preMultipliedAlpha = false; 372 ctx->listStats[dpy].planeAlpha = false; 373 ctx->listStats[dpy].yuvCount = 0; 374 375 for (size_t i = 0; i < (size_t)ctx->listStats[dpy].numAppLayers; i++) { 376 hwc_layer_1_t const* layer = &list->hwLayers[i]; 377 private_handle_t *hnd = (private_handle_t *)layer->handle; 378 379 // continue if number of app layers exceeds MAX_NUM_APP_LAYERS 380 if(ctx->listStats[dpy].numAppLayers > MAX_NUM_APP_LAYERS) 381 continue; 382 383 //reset yuv indices 384 ctx->listStats[dpy].yuvIndices[i] = -1; 385 386 if (isSkipLayer(&list->hwLayers[i])) { 387 ctx->listStats[dpy].skipCount++; 388 } else if (UNLIKELY(isYuvBuffer(hnd))) { 389 int& yuvCount = ctx->listStats[dpy].yuvCount; 390 ctx->listStats[dpy].yuvIndices[yuvCount] = i; 391 yuvCount++; 392 393 if((layer->transform & HWC_TRANSFORM_ROT_90) && 394 canUseRotator(ctx)) { 395 if(ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA)) { 396 ctx->isPaddingRound = true; 397 } 398 Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE); 399 } 400 } 401 if(layer->blending == HWC_BLENDING_PREMULT) 402 ctx->listStats[dpy].preMultipliedAlpha = true; 403 if(layer->planeAlpha < 0xFF) 404 ctx->listStats[dpy].planeAlpha = true; 405 if(!ctx->listStats[dpy].needsAlphaScale) 406 ctx->listStats[dpy].needsAlphaScale = 407 isAlphaScaled(ctx, layer, dpy); 408 } 409 setYUVProp(ctx->listStats[dpy].yuvCount); 410 //The marking of video begin/end is useful on some targets where we need 411 //to have a padding round to be able to shift pipes across mixers. 412 if(prevYuvCount != ctx->listStats[dpy].yuvCount) { 413 ctx->mVideoTransFlag = true; 414 } 415 if(dpy == HWC_DISPLAY_PRIMARY) { 416 ctx->mAD->markDoable(ctx, list); 417 } 418} 419 420 421static void calc_cut(double& leftCutRatio, double& topCutRatio, 422 double& rightCutRatio, double& bottomCutRatio, int orient) { 423 if(orient & HAL_TRANSFORM_FLIP_H) { 424 swap(leftCutRatio, rightCutRatio); 425 } 426 if(orient & HAL_TRANSFORM_FLIP_V) { 427 swap(topCutRatio, bottomCutRatio); 428 } 429 if(orient & HAL_TRANSFORM_ROT_90) { 430 //Anti clock swapping 431 double tmpCutRatio = leftCutRatio; 432 leftCutRatio = topCutRatio; 433 topCutRatio = rightCutRatio; 434 rightCutRatio = bottomCutRatio; 435 bottomCutRatio = tmpCutRatio; 436 } 437} 438 439bool isSecuring(hwc_context_t* ctx, hwc_layer_1_t const* layer) { 440 if((ctx->mMDP.version < qdutils::MDSS_V5) && 441 (ctx->mMDP.version > qdutils::MDP_V3_0) && 442 ctx->mSecuring) { 443 return true; 444 } 445 // On A-Family, Secure policy is applied system wide and not on 446 // buffers. 447 if (isSecureModePolicy(ctx->mMDP.version)) { 448 private_handle_t *hnd = (private_handle_t *)layer->handle; 449 if(ctx->mSecureMode) { 450 if (! isSecureBuffer(hnd)) { 451 // This code path executes for the following usecase: 452 // Some Apps in which first few seconds, framework 453 // sends non-secure buffer and with out destroying 454 // surfaces, switches to secure buffer thereby exposing 455 // vulnerability on A-family devices. Catch this situation 456 // and handle it gracefully by allowing it to be composed by 457 // GPU. 458 ALOGD_IF(HWC_UTILS_DEBUG, "%s: Handle non-secure video layer" 459 "during secure playback gracefully", __FUNCTION__); 460 return true; 461 } 462 } else { 463 if (isSecureBuffer(hnd)) { 464 // This code path executes for the following usecase: 465 // For some Apps, when User terminates playback, Framework 466 // doesnt destroy video surface and video surface still 467 // comes to Display HAL. This exposes vulnerability on 468 // A-family. Catch this situation and handle it gracefully 469 // by allowing it to be composed by GPU. 470 ALOGD_IF(HWC_UTILS_DEBUG, "%s: Handle secure video layer" 471 "during non-secure playback gracefully", __FUNCTION__); 472 return true; 473 } 474 } 475 } 476 return false; 477} 478 479bool isSecureModePolicy(int mdpVersion) { 480 if (mdpVersion < qdutils::MDSS_V5) 481 return true; 482 else 483 return false; 484} 485 486int getBlending(int blending) { 487 switch(blending) { 488 case HWC_BLENDING_NONE: 489 return overlay::utils::OVERLAY_BLENDING_OPAQUE; 490 case HWC_BLENDING_PREMULT: 491 return overlay::utils::OVERLAY_BLENDING_PREMULT; 492 case HWC_BLENDING_COVERAGE : 493 default: 494 return overlay::utils::OVERLAY_BLENDING_COVERAGE; 495 } 496} 497 498//Crops source buffer against destination and FB boundaries 499void calculate_crop_rects(hwc_rect_t& crop, hwc_rect_t& dst, 500 const hwc_rect_t& scissor, int orient) { 501 502 int& crop_l = crop.left; 503 int& crop_t = crop.top; 504 int& crop_r = crop.right; 505 int& crop_b = crop.bottom; 506 int crop_w = crop.right - crop.left; 507 int crop_h = crop.bottom - crop.top; 508 509 int& dst_l = dst.left; 510 int& dst_t = dst.top; 511 int& dst_r = dst.right; 512 int& dst_b = dst.bottom; 513 int dst_w = abs(dst.right - dst.left); 514 int dst_h = abs(dst.bottom - dst.top); 515 516 const int& sci_l = scissor.left; 517 const int& sci_t = scissor.top; 518 const int& sci_r = scissor.right; 519 const int& sci_b = scissor.bottom; 520 int sci_w = abs(sci_r - sci_l); 521 int sci_h = abs(sci_b - sci_t); 522 523 double leftCutRatio = 0.0, rightCutRatio = 0.0, topCutRatio = 0.0, 524 bottomCutRatio = 0.0; 525 526 if(dst_l < sci_l) { 527 leftCutRatio = (double)(sci_l - dst_l) / (double)dst_w; 528 dst_l = sci_l; 529 } 530 531 if(dst_r > sci_r) { 532 rightCutRatio = (double)(dst_r - sci_r) / (double)dst_w; 533 dst_r = sci_r; 534 } 535 536 if(dst_t < sci_t) { 537 topCutRatio = (double)(sci_t - dst_t) / (double)dst_h; 538 dst_t = sci_t; 539 } 540 541 if(dst_b > sci_b) { 542 bottomCutRatio = (double)(dst_b - sci_b) / (double)dst_h; 543 dst_b = sci_b; 544 } 545 546 calc_cut(leftCutRatio, topCutRatio, rightCutRatio, bottomCutRatio, orient); 547 crop_l += crop_w * leftCutRatio; 548 crop_t += crop_h * topCutRatio; 549 crop_r -= crop_w * rightCutRatio; 550 crop_b -= crop_h * bottomCutRatio; 551} 552 553void getNonWormholeRegion(hwc_display_contents_1_t* list, 554 hwc_rect_t& nwr) 555{ 556 uint32_t last = list->numHwLayers - 1; 557 hwc_rect_t fbDisplayFrame = list->hwLayers[last].displayFrame; 558 //Initiliaze nwr to first frame 559 nwr.left = list->hwLayers[0].displayFrame.left; 560 nwr.top = list->hwLayers[0].displayFrame.top; 561 nwr.right = list->hwLayers[0].displayFrame.right; 562 nwr.bottom = list->hwLayers[0].displayFrame.bottom; 563 564 for (uint32_t i = 1; i < last; i++) { 565 hwc_rect_t displayFrame = list->hwLayers[i].displayFrame; 566 nwr.left = min(nwr.left, displayFrame.left); 567 nwr.top = min(nwr.top, displayFrame.top); 568 nwr.right = max(nwr.right, displayFrame.right); 569 nwr.bottom = max(nwr.bottom, displayFrame.bottom); 570 } 571 572 //Intersect with the framebuffer 573 nwr.left = max(nwr.left, fbDisplayFrame.left); 574 nwr.top = max(nwr.top, fbDisplayFrame.top); 575 nwr.right = min(nwr.right, fbDisplayFrame.right); 576 nwr.bottom = min(nwr.bottom, fbDisplayFrame.bottom); 577 578} 579 580bool isSecondaryConfiguring(hwc_context_t* ctx) { 581 return (ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring | 582 ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring); 583} 584 585void closeAcquireFds(hwc_display_contents_1_t* list) { 586 if(LIKELY(list)) { 587 for(uint32_t i = 0; i < list->numHwLayers; i++) { 588 //Close the acquireFenceFds 589 //HWC_FRAMEBUFFER are -1 already by SF, rest we close. 590 if(list->hwLayers[i].acquireFenceFd >= 0) { 591 close(list->hwLayers[i].acquireFenceFd); 592 list->hwLayers[i].acquireFenceFd = -1; 593 } 594 } 595 } 596} 597 598int hwc_sync(hwc_context_t *ctx, hwc_display_contents_1_t* list, int dpy, 599 int fd) { 600 ATRACE_CALL(); 601 int ret = 0; 602 int acquireFd[MAX_NUM_APP_LAYERS]; 603 int count = 0; 604 int releaseFd = -1; 605 int retireFd = -1; 606 int fbFd = -1; 607 bool swapzero = false; 608 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion(); 609 610 struct mdp_buf_sync data; 611 memset(&data, 0, sizeof(data)); 612 data.acq_fen_fd = acquireFd; 613 data.rel_fen_fd = &releaseFd; 614 data.retire_fen_fd = &retireFd; 615 616 char property[PROPERTY_VALUE_MAX]; 617 if(property_get("debug.egl.swapinterval", property, "1") > 0) { 618 if(atoi(property) == 0) 619 swapzero = true; 620 } 621 622 for(uint32_t i = 0; i < ctx->mLayerRotMap[dpy]->getCount(); i++) { 623 int rotFd = ctx->mRotMgr->getRotDevFd(); 624 int rotReleaseFd = -1; 625 int rotRetireFd = -1; 626 struct mdp_buf_sync rotData; 627 memset(&rotData, 0, sizeof(rotData)); 628 rotData.acq_fen_fd = 629 &ctx->mLayerRotMap[dpy]->getLayer(i)->acquireFenceFd; 630 rotData.rel_fen_fd = &rotReleaseFd; //driver to populate this 631 rotData.retire_fen_fd = &rotRetireFd; 632 rotData.session_id = ctx->mLayerRotMap[dpy]->getRot(i)->getSessId(); 633 int ret = 0; 634 ret = ioctl(rotFd, MSMFB_BUFFER_SYNC, &rotData); 635 if(ret < 0) { 636 ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed for rot sync, err=%s", 637 __FUNCTION__, strerror(errno)); 638 } else { 639 close(ctx->mLayerRotMap[dpy]->getLayer(i)->acquireFenceFd); 640 //For MDP to wait on. 641 ctx->mLayerRotMap[dpy]->getLayer(i)->acquireFenceFd = 642 dup(rotReleaseFd); 643 //A buffer is free to be used by producer as soon as its copied to 644 //rotator 645 ctx->mLayerRotMap[dpy]->getLayer(i)->releaseFenceFd = 646 rotReleaseFd; 647 //Not used for rotator 648 close(rotRetireFd); 649 } 650 } 651 652 //Accumulate acquireFenceFds for MDP 653 for(uint32_t i = 0; i < list->numHwLayers; i++) { 654 if(list->hwLayers[i].compositionType == HWC_OVERLAY && 655 list->hwLayers[i].acquireFenceFd >= 0) { 656 if(UNLIKELY(swapzero)) 657 acquireFd[count++] = -1; 658 else 659 acquireFd[count++] = list->hwLayers[i].acquireFenceFd; 660 } 661 if(list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) { 662 if(UNLIKELY(swapzero)) 663 acquireFd[count++] = -1; 664 else if(fd >= 0) { 665 //set the acquireFD from fd - which is coming from c2d 666 acquireFd[count++] = fd; 667 // Buffer sync IOCTL should be async when using c2d fence is 668 // used 669 data.flags &= ~MDP_BUF_SYNC_FLAG_WAIT; 670 } else if(list->hwLayers[i].acquireFenceFd >= 0) 671 acquireFd[count++] = list->hwLayers[i].acquireFenceFd; 672 } 673 } 674 675 data.acq_fen_fd_cnt = count; 676 fbFd = ctx->dpyAttr[dpy].fd; 677 678 //Waits for acquire fences, returns a release fence 679 if(LIKELY(!swapzero)) { 680 uint64_t start = systemTime(); 681 ret = ioctl(fbFd, MSMFB_BUFFER_SYNC, &data); 682 ALOGD_IF(HWC_UTILS_DEBUG, "%s: time taken for MSMFB_BUFFER_SYNC IOCTL = %d", 683 __FUNCTION__, (size_t) ns2ms(systemTime() - start)); 684 } 685 686 if(ret < 0) { 687 ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed, err=%s", 688 __FUNCTION__, strerror(errno)); 689 ALOGE("%s: acq_fen_fd_cnt=%d flags=%d fd=%d dpy=%d numHwLayers=%d", 690 __FUNCTION__, data.acq_fen_fd_cnt, data.flags, fbFd, 691 dpy, list->numHwLayers); 692 } 693 694 for(uint32_t i = 0; i < list->numHwLayers; i++) { 695 if(list->hwLayers[i].compositionType == HWC_OVERLAY || 696 list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) { 697 //Populate releaseFenceFds. 698 if(UNLIKELY(swapzero)) { 699 list->hwLayers[i].releaseFenceFd = -1; 700 } else if(list->hwLayers[i].releaseFenceFd < 0) { 701 //If rotator has not already populated this field. 702 list->hwLayers[i].releaseFenceFd = dup(releaseFd); 703 } 704 } 705 } 706 707 if(fd >= 0) { 708 close(fd); 709 fd = -1; 710 } 711 712 if (ctx->mCopyBit[dpy]) 713 ctx->mCopyBit[dpy]->setReleaseFd(releaseFd); 714 715 //Signals when MDP finishes reading rotator buffers. 716 ctx->mLayerRotMap[dpy]->setReleaseFd(releaseFd); 717 close(releaseFd); 718 719 if(UNLIKELY(swapzero)) 720 list->retireFenceFd = -1; 721 else 722 list->retireFenceFd = retireFd; 723 return ret; 724} 725 726void trimLayer(hwc_context_t *ctx, const int& dpy, const int& transform, 727 hwc_rect_t& crop, hwc_rect_t& dst) { 728 int hw_w = ctx->dpyAttr[dpy].xres; 729 int hw_h = ctx->dpyAttr[dpy].yres; 730 if(dst.left < 0 || dst.top < 0 || 731 dst.right > hw_w || dst.bottom > hw_h) { 732 hwc_rect_t scissor = {0, 0, hw_w, hw_h }; 733 qhwc::calculate_crop_rects(crop, dst, scissor, transform); 734 } 735} 736 737void setMdpFlags(hwc_layer_1_t *layer, 738 ovutils::eMdpFlags &mdpFlags, 739 int rotDownscale) { 740 private_handle_t *hnd = (private_handle_t *)layer->handle; 741 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; 742 const int& transform = layer->transform; 743 744 if(layer->blending == HWC_BLENDING_PREMULT) { 745 ovutils::setMdpFlags(mdpFlags, 746 ovutils::OV_MDP_BLEND_FG_PREMULT); 747 } 748 749 if(isYuvBuffer(hnd)) { 750 if(isSecureBuffer(hnd)) { 751 ovutils::setMdpFlags(mdpFlags, 752 ovutils::OV_MDP_SECURE_OVERLAY_SESSION); 753 } 754 if(metadata && (metadata->operation & PP_PARAM_INTERLACED) && 755 metadata->interlaced) { 756 ovutils::setMdpFlags(mdpFlags, 757 ovutils::OV_MDP_DEINTERLACE); 758 } 759 //Pre-rotation will be used using rotator. 760 if(transform & HWC_TRANSFORM_ROT_90) { 761 ovutils::setMdpFlags(mdpFlags, 762 ovutils::OV_MDP_SOURCE_ROTATED_90); 763 } 764 } 765 766 //No 90 component and no rot-downscale then flips done by MDP 767 //If we use rot then it might as well do flips 768 if(!(layer->transform & HWC_TRANSFORM_ROT_90) && !rotDownscale) { 769 if(layer->transform & HWC_TRANSFORM_FLIP_H) { 770 ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_H); 771 } 772 773 if(layer->transform & HWC_TRANSFORM_FLIP_V) { 774 ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_V); 775 } 776 } 777 778 if(metadata && 779 ((metadata->operation & PP_PARAM_HSIC) 780 || (metadata->operation & PP_PARAM_IGC) 781 || (metadata->operation & PP_PARAM_SHARP2))) { 782 ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_PP_EN); 783 } 784} 785 786int configRotator(Rotator *rot, const Whf& whf, 787 hwc_rect_t& crop, const eMdpFlags& mdpFlags, 788 const eTransform& orient, const int& downscale) { 789 rot->setSource(whf); 790 791 if (qdutils::MDPVersion::getInstance().getMDPVersion() >= 792 qdutils::MDSS_V5) { 793 uint32_t crop_w = (crop.right - crop.left); 794 uint32_t crop_h = (crop.bottom - crop.top); 795 if (ovutils::isYuv(whf.format)) { 796 ovutils::normalizeCrop((uint32_t&)crop.left, crop_w); 797 ovutils::normalizeCrop((uint32_t&)crop.top, crop_h); 798 // For interlaced, crop.h should be 4-aligned 799 if ((mdpFlags & ovutils::OV_MDP_DEINTERLACE) && (crop_h % 4)) 800 crop_h = ovutils::aligndown(crop_h, 4); 801 crop.right = crop.left + crop_w; 802 crop.bottom = crop.top + crop_h; 803 } 804 Dim rotCrop(crop.left, crop.top, crop_w, crop_h); 805 rot->setCrop(rotCrop); 806 } 807 808 rot->setFlags(mdpFlags); 809 rot->setTransform(orient); 810 rot->setDownscale(downscale); 811 if(!rot->commit()) return -1; 812 return 0; 813} 814 815int configMdp(Overlay *ov, const PipeArgs& parg, 816 const eTransform& orient, const hwc_rect_t& crop, 817 const hwc_rect_t& pos, const MetaData_t *metadata, 818 const eDest& dest) { 819 ov->setSource(parg, dest); 820 ov->setTransform(orient, dest); 821 822 int crop_w = crop.right - crop.left; 823 int crop_h = crop.bottom - crop.top; 824 Dim dcrop(crop.left, crop.top, crop_w, crop_h); 825 ov->setCrop(dcrop, dest); 826 827 int posW = pos.right - pos.left; 828 int posH = pos.bottom - pos.top; 829 Dim position(pos.left, pos.top, posW, posH); 830 ov->setPosition(position, dest); 831 832 if (metadata) 833 ov->setVisualParams(*metadata, dest); 834 835 if (!ov->commit(dest)) { 836 return -1; 837 } 838 return 0; 839} 840 841void updateSource(eTransform& orient, Whf& whf, 842 hwc_rect_t& crop) { 843 Dim srcCrop(crop.left, crop.top, 844 crop.right - crop.left, 845 crop.bottom - crop.top); 846 orient = static_cast<eTransform>(ovutils::getMdpOrient(orient)); 847 preRotateSource(orient, whf, srcCrop); 848 if (qdutils::MDPVersion::getInstance().getMDPVersion() >= 849 qdutils::MDSS_V5) { 850 // Source for overlay will be the cropped (and rotated) 851 crop.left = 0; 852 crop.top = 0; 853 crop.right = srcCrop.w; 854 crop.bottom = srcCrop.h; 855 // Set width & height equal to sourceCrop w & h 856 whf.w = srcCrop.w; 857 whf.h = srcCrop.h; 858 } else { 859 crop.left = srcCrop.x; 860 crop.top = srcCrop.y; 861 crop.right = srcCrop.x + srcCrop.w; 862 crop.bottom = srcCrop.y + srcCrop.h; 863 } 864} 865 866int configureLowRes(hwc_context_t *ctx, hwc_layer_1_t *layer, 867 const int& dpy, eMdpFlags& mdpFlags, const eZorder& z, 868 const eIsFg& isFg, const eDest& dest, Rotator **rot) { 869 870 private_handle_t *hnd = (private_handle_t *)layer->handle; 871 if(!hnd) { 872 ALOGE("%s: layer handle is NULL", __FUNCTION__); 873 ctx->mLayerRotMap[dpy]->reset(); 874 return -1; 875 } 876 877 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; 878 879 hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); 880 hwc_rect_t dst = layer->displayFrame; 881 int transform = layer->transform; 882 eTransform orient = static_cast<eTransform>(transform); 883 int downscale = 0; 884 int rotFlags = ovutils::ROT_FLAGS_NONE; 885 Whf whf(getWidth(hnd), getHeight(hnd), 886 getMdpFormat(hnd->format), hnd->size); 887 888 uint32_t x = dst.left, y = dst.top; 889 uint32_t w = dst.right - dst.left; 890 uint32_t h = dst.bottom - dst.top; 891 892 if(dpy) { 893 // Calculate the actionsafe dimensions for External(dpy = 1 or 2) 894 getActionSafePosition(ctx, dpy, x, y, w, h); 895 // Convert position to hwc_rect_t 896 dst.left = x; 897 dst.top = y; 898 dst.right = w + dst.left; 899 dst.bottom = h + dst.top; 900 } 901 902 if(isYuvBuffer(hnd) && ctx->mMDP.version >= qdutils::MDP_V4_2 && 903 ctx->mMDP.version < qdutils::MDSS_V5) { 904 downscale = getDownscaleFactor( 905 crop.right - crop.left, 906 crop.bottom - crop.top, 907 dst.right - dst.left, 908 dst.bottom - dst.top); 909 if(downscale) { 910 rotFlags = ROT_DOWNSCALE_ENABLED; 911 } 912 } 913 914 setMdpFlags(layer, mdpFlags, downscale); 915 trimLayer(ctx, dpy, transform, crop, dst); 916 917 //Will do something only if feature enabled and conditions suitable 918 //hollow call otherwise 919 if(ctx->mAD->prepare(ctx, crop, whf, hnd)) { 920 overlay::Writeback *wb = overlay::Writeback::getInstance(); 921 whf.format = wb->getOutputFormat(); 922 } 923 924 if(isYuvBuffer(hnd) && //if 90 component or downscale, use rot 925 ((transform & HWC_TRANSFORM_ROT_90) || downscale)) { 926 *rot = ctx->mRotMgr->getNext(); 927 if(*rot == NULL) return -1; 928 BwcPM::setBwc(ctx, crop, dst, transform, mdpFlags); 929 //Configure rotator for pre-rotation 930 if(configRotator(*rot, whf, crop, mdpFlags, orient, downscale) < 0) { 931 ALOGE("%s: configRotator failed!", __FUNCTION__); 932 ctx->mOverlay->clear(dpy); 933 return -1; 934 } 935 ctx->mLayerRotMap[dpy]->add(layer, *rot); 936 whf.format = (*rot)->getDstFormat(); 937 updateSource(orient, whf, crop); 938 rotFlags |= ovutils::ROT_PREROTATED; 939 } 940 941 //For the mdp, since either we are pre-rotating or MDP does flips 942 orient = OVERLAY_TRANSFORM_0; 943 transform = 0; 944 945 PipeArgs parg(mdpFlags, whf, z, isFg, 946 static_cast<eRotFlags>(rotFlags), layer->planeAlpha, 947 (ovutils::eBlending) getBlending(layer->blending)); 948 949 if(configMdp(ctx->mOverlay, parg, orient, crop, dst, metadata, dest) < 0) { 950 ALOGE("%s: commit failed for low res panel", __FUNCTION__); 951 ctx->mLayerRotMap[dpy]->reset(); 952 return -1; 953 } 954 return 0; 955} 956 957int configureHighRes(hwc_context_t *ctx, hwc_layer_1_t *layer, 958 const int& dpy, eMdpFlags& mdpFlagsL, const eZorder& z, 959 const eIsFg& isFg, const eDest& lDest, const eDest& rDest, 960 Rotator **rot) { 961 private_handle_t *hnd = (private_handle_t *)layer->handle; 962 if(!hnd) { 963 ALOGE("%s: layer handle is NULL", __FUNCTION__); 964 return -1; 965 } 966 967 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; 968 969 int hw_w = ctx->dpyAttr[dpy].xres; 970 int hw_h = ctx->dpyAttr[dpy].yres; 971 hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); 972 hwc_rect_t dst = layer->displayFrame; 973 int transform = layer->transform; 974 eTransform orient = static_cast<eTransform>(transform); 975 const int downscale = 0; 976 int rotFlags = ROT_FLAGS_NONE; 977 978 Whf whf(getWidth(hnd), getHeight(hnd), 979 getMdpFormat(hnd->format), hnd->size); 980 981 setMdpFlags(layer, mdpFlagsL, 0); 982 trimLayer(ctx, dpy, transform, crop, dst); 983 984 //Will do something only if feature enabled and conditions suitable 985 //hollow call otherwise 986 if(ctx->mAD->prepare(ctx, crop, whf, hnd)) { 987 overlay::Writeback *wb = overlay::Writeback::getInstance(); 988 whf.format = wb->getOutputFormat(); 989 } 990 991 if(isYuvBuffer(hnd) && (transform & HWC_TRANSFORM_ROT_90)) { 992 (*rot) = ctx->mRotMgr->getNext(); 993 if((*rot) == NULL) return -1; 994 //Configure rotator for pre-rotation 995 if(configRotator(*rot, whf, crop, mdpFlagsL, orient, downscale) < 0) { 996 ALOGE("%s: configRotator failed!", __FUNCTION__); 997 ctx->mOverlay->clear(dpy); 998 return -1; 999 } 1000 ctx->mLayerRotMap[dpy]->add(layer, *rot); 1001 whf.format = (*rot)->getDstFormat(); 1002 updateSource(orient, whf, crop); 1003 rotFlags |= ROT_PREROTATED; 1004 } 1005 1006 eMdpFlags mdpFlagsR = mdpFlagsL; 1007 setMdpFlags(mdpFlagsR, OV_MDSS_MDP_RIGHT_MIXER); 1008 1009 hwc_rect_t tmp_cropL, tmp_dstL; 1010 hwc_rect_t tmp_cropR, tmp_dstR; 1011 1012 const int lSplit = getLeftSplit(ctx, dpy); 1013 1014 if(lDest != OV_INVALID) { 1015 tmp_cropL = crop; 1016 tmp_dstL = dst; 1017 hwc_rect_t scissor = {0, 0, lSplit, hw_h }; 1018 qhwc::calculate_crop_rects(tmp_cropL, tmp_dstL, scissor, 0); 1019 } 1020 if(rDest != OV_INVALID) { 1021 tmp_cropR = crop; 1022 tmp_dstR = dst; 1023 hwc_rect_t scissor = {lSplit, 0, hw_w, hw_h }; 1024 qhwc::calculate_crop_rects(tmp_cropR, tmp_dstR, scissor, 0); 1025 } 1026 1027 //When buffer is H-flipped, contents of mixer config also needs to swapped 1028 //Not needed if the layer is confined to one half of the screen. 1029 //If rotator has been used then it has also done the flips, so ignore them. 1030 if((orient & OVERLAY_TRANSFORM_FLIP_H) && lDest != OV_INVALID 1031 && rDest != OV_INVALID && (*rot) == NULL) { 1032 hwc_rect_t new_cropR; 1033 new_cropR.left = tmp_cropL.left; 1034 new_cropR.right = new_cropR.left + (tmp_cropR.right - tmp_cropR.left); 1035 1036 hwc_rect_t new_cropL; 1037 new_cropL.left = new_cropR.right; 1038 new_cropL.right = tmp_cropR.right; 1039 1040 tmp_cropL.left = new_cropL.left; 1041 tmp_cropL.right = new_cropL.right; 1042 1043 tmp_cropR.left = new_cropR.left; 1044 tmp_cropR.right = new_cropR.right; 1045 1046 } 1047 1048 //For the mdp, since either we are pre-rotating or MDP does flips 1049 orient = OVERLAY_TRANSFORM_0; 1050 transform = 0; 1051 1052 //configure left mixer 1053 if(lDest != OV_INVALID) { 1054 PipeArgs pargL(mdpFlagsL, whf, z, isFg, 1055 static_cast<eRotFlags>(rotFlags), layer->planeAlpha, 1056 (ovutils::eBlending) getBlending(layer->blending)); 1057 1058 if(configMdp(ctx->mOverlay, pargL, orient, 1059 tmp_cropL, tmp_dstL, metadata, lDest) < 0) { 1060 ALOGE("%s: commit failed for left mixer config", __FUNCTION__); 1061 return -1; 1062 } 1063 } 1064 1065 //configure right mixer 1066 if(rDest != OV_INVALID) { 1067 PipeArgs pargR(mdpFlagsR, whf, z, isFg, 1068 static_cast<eRotFlags>(rotFlags), layer->planeAlpha, 1069 (ovutils::eBlending) getBlending(layer->blending)); 1070 1071 tmp_dstR.right = tmp_dstR.right - lSplit; 1072 tmp_dstR.left = tmp_dstR.left - lSplit; 1073 if(configMdp(ctx->mOverlay, pargR, orient, 1074 tmp_cropR, tmp_dstR, metadata, rDest) < 0) { 1075 ALOGE("%s: commit failed for right mixer config", __FUNCTION__); 1076 return -1; 1077 } 1078 } 1079 1080 return 0; 1081} 1082 1083bool canUseRotator(hwc_context_t *ctx) { 1084 if(qdutils::MDPVersion::getInstance().is8x26() && 1085 ctx->mExtDisplay->isExternalConnected()) { 1086 return false; 1087 } 1088 if(ctx->mMDP.version == qdutils::MDP_V3_0_4) 1089 return false; 1090 return true; 1091} 1092 1093int getLeftSplit(hwc_context_t *ctx, const int& dpy) { 1094 //Default even split for all displays with high res 1095 int lSplit = ctx->dpyAttr[dpy].xres / 2; 1096 if(dpy == HWC_DISPLAY_PRIMARY && 1097 qdutils::MDPVersion::getInstance().getLeftSplit()) { 1098 //Override if split published by driver for primary 1099 lSplit = qdutils::MDPVersion::getInstance().getLeftSplit(); 1100 } 1101 return lSplit; 1102} 1103 1104void setupSecondaryObjs(hwc_context_t *ctx, const int& dpy) { 1105 const int rSplit = 0; 1106 ctx->mFBUpdate[dpy] = 1107 IFBUpdate::getObject(ctx->dpyAttr[dpy].xres, rSplit, dpy); 1108 ctx->mMDPComp[dpy] = MDPComp::getObject( 1109 ctx->dpyAttr[dpy].xres, rSplit, dpy); 1110 1111 int compositionType = 1112 qdutils::QCCompositionType::getInstance().getCompositionType(); 1113 if (compositionType & (qdutils::COMPOSITION_TYPE_DYN | 1114 qdutils::COMPOSITION_TYPE_MDP | 1115 qdutils::COMPOSITION_TYPE_C2D)) { 1116 ctx->mCopyBit[dpy] = new CopyBit(); 1117 } 1118} 1119 1120void clearSecondaryObjs(hwc_context_t *ctx, const int& dpy) { 1121 if(ctx->mFBUpdate[dpy]) { 1122 delete ctx->mFBUpdate[dpy]; 1123 ctx->mFBUpdate[dpy] = NULL; 1124 } 1125 if(ctx->mCopyBit[dpy]){ 1126 delete ctx->mCopyBit[dpy]; 1127 ctx->mCopyBit[dpy] = NULL; 1128 } 1129 if(ctx->mMDPComp[dpy]) { 1130 delete ctx->mMDPComp[dpy]; 1131 ctx->mMDPComp[dpy] = NULL; 1132 } 1133} 1134 1135void BwcPM::setBwc(hwc_context_t *ctx, const hwc_rect_t& crop, 1136 const hwc_rect_t& dst, const int& transform, 1137 ovutils::eMdpFlags& mdpFlags) { 1138 //Target doesnt support Bwc 1139 if(!qdutils::MDPVersion::getInstance().supportsBWC()) { 1140 return; 1141 } 1142 //src width > MAX mixer supported dim 1143 if((crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) { 1144 return; 1145 } 1146 //External connected 1147 if(ctx->mExtDisplay->isExternalConnected()) { 1148 return; 1149 } 1150 //Decimation necessary, cannot use BWC. H/W requirement. 1151 if(qdutils::MDPVersion::getInstance().supportsDecimation()) { 1152 int src_w = crop.right - crop.left; 1153 int src_h = crop.bottom - crop.top; 1154 int dst_w = dst.right - dst.left; 1155 int dst_h = dst.bottom - dst.top; 1156 if(transform & HAL_TRANSFORM_ROT_90) { 1157 swap(src_w, src_h); 1158 } 1159 float horDscale = 0.0f; 1160 float verDscale = 0.0f; 1161 int horzDeci = 0; 1162 int vertDeci = 0; 1163 ovutils::getDecimationFactor(src_w, src_h, dst_w, dst_h, horDscale, 1164 verDscale); 1165 //TODO Use log2f once math.h has it 1166 if((int)horDscale) 1167 horzDeci = (int)(log(horDscale) / log(2)); 1168 if((int)verDscale) 1169 vertDeci = (int)(log(verDscale) / log(2)); 1170 if(horzDeci || vertDeci) return; 1171 } 1172 //Property 1173 char value[PROPERTY_VALUE_MAX]; 1174 property_get("debug.disable.bwc", value, "0"); 1175 if(atoi(value)) return; 1176 1177 ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDSS_MDP_BWC_EN); 1178} 1179 1180void LayerRotMap::add(hwc_layer_1_t* layer, Rotator *rot) { 1181 if(mCount >= MAX_SESS) return; 1182 mLayer[mCount] = layer; 1183 mRot[mCount] = rot; 1184 mCount++; 1185} 1186 1187void LayerRotMap::reset() { 1188 for (int i = 0; i < MAX_SESS; i++) { 1189 mLayer[i] = 0; 1190 mRot[i] = 0; 1191 } 1192 mCount = 0; 1193} 1194 1195void LayerRotMap::setReleaseFd(const int& fence) { 1196 for(uint32_t i = 0; i < mCount; i++) { 1197 mRot[i]->setReleaseFd(dup(fence)); 1198 } 1199} 1200 1201};//namespace qhwc 1202