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