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