1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /** 18 * Project HWC 2.0 Design 19 */ 20 21 #ifndef _EXYNOSMPP_H 22 #define _EXYNOSMPP_H 23 24 #include <utils/Thread.h> 25 #include <utils/Mutex.h> 26 #include <utils/Condition.h> 27 #include <utils/String8.h> 28 #include <utils/StrongPointer.h> 29 #include <utils/List.h> 30 #include <utils/Vector.h> 31 #include <map> 32 #include <hardware/exynos/acryl.h> 33 #include <map> 34 #include "ExynosHWCModule.h" 35 #include "ExynosHWCHelper.h" 36 #include "ExynosMPPType.h" 37 38 class ExynosDisplay; 39 class ExynosMPP; 40 class ExynosResourceManager; 41 42 #ifndef NUM_MPP_DST_BUFS 43 #define NUM_MPP_DST_BUFS_DEFAULT 3 44 /* 45 * Buffer number can be different according to type 46 * #define NUM_MPP_DST_BUFS(type) ((type == MPP_LOGICAL_G2D_RGB) ? 3:2) 47 */ 48 #define NUM_MPP_DST_BUFS(type) (3) 49 #endif 50 51 #ifndef G2D_MAX_SRC_NUM 52 #define G2D_MAX_SRC_NUM 15 53 #endif 54 55 #define G2D_JUSTIFIED_DST_ALIGN 16 56 57 #define NUM_MPP_SRC_BUFS G2D_MAX_SRC_NUM 58 59 #ifndef G2D_RESTRICTIVE_SRC_NUM 60 #define G2D_RESTRICTIVE_SRC_NUM 5 61 #endif 62 63 #ifndef G2D_BASE_PPC 64 #define G2D_BASE_PPC 2.8 65 #endif 66 #ifndef G2D_DST_BASE_PPC 67 #define G2D_DST_BASE_PPC 3.5 68 #endif 69 #ifndef G2D_DST_BASE_PPC_YUV420 70 #define G2D_DST_BASE_PPC_YUV420 2.8 71 #endif 72 #ifndef G2D_DST_BASE_PPC_ROT 73 #define G2D_DST_BASE_PPC_ROT 2.4 74 #endif 75 #ifndef G2D_BASE_PPC_COLORFILL 76 #define G2D_BASE_PPC_COLORFILL 3.8 77 #endif 78 79 #ifndef G2D_CLOCK 80 #define G2D_CLOCK 711000 81 #endif 82 83 #ifndef MSC_CLOCK 84 #define MSC_CLOCK 534000 85 #endif 86 87 #ifndef VPP_CLOCK 88 #define VPP_CLOCK 664000 89 #endif 90 #ifndef VPP_MIC_FACTOR 91 #define VPP_MIC_FACTOR 2 92 #endif 93 94 #ifndef VPP_TE_PERIOD 95 #define VPP_TE_PERIOD 63 96 #endif 97 #ifndef VPP_MARGIN 98 #define VPP_MARGIN 1.1 99 #endif 100 #ifndef VPP_BUBBLE 101 #define VPP_BUBBLE 0.06 102 #endif 103 104 #define VPP_RESOL_CLOCK_FACTOR (VPP_TE_PERIOD * VPP_MARGIN) 105 #define VPP_RESOL_MARGIN (VPP_MARGIN + VPP_BUBBLE) 106 #ifndef VPP_DISP_FACTOR 107 #define VPP_DISP_FACTOR 1.0 108 #endif 109 #ifndef VPP_PIXEL_PER_CLOCK 110 #define VPP_PIXEL_PER_CLOCK 2 111 #endif 112 113 #ifndef MPP_G2D_CAPACITY 114 #define MPP_G2D_CAPACITY 8 115 #endif 116 // G2D or MSC additional margin capacity when HDR layer is passed. 117 #ifndef MPP_HDR_MARGIN 118 #define MPP_HDR_MARGIN 1.2 119 #endif 120 121 #ifndef MPP_MSC_CAPACITY 122 #define MPP_MSC_CAPACITY 8 123 #endif 124 125 /* Currently allowed capacity percentage is over 10% */ 126 #define MPP_CAPA_OVER_THRESHOLD 1.1 127 128 #ifndef MPP_G2D_SRC_SCALED_WEIGHT 129 #define MPP_G2D_SRC_SCALED_WEIGHT 1.125 130 #endif 131 132 #ifndef MPP_G2D_DST_ROT_WEIGHT 133 #define MPP_G2D_DST_ROT_WEIGHT 2.0 134 #endif 135 136 #define MPP_DUMP_PATH "/data/vendor/log/hwc/output.dat" 137 138 using namespace android; 139 140 enum { 141 eMPPSaveCapability = 1ULL << 0, 142 eMPPStrideCrop = 1ULL << 1, 143 eMPPUnsupportedRotation = 1ULL << 2, 144 eMPPHWBusy = 1ULL << 3, 145 eMPPExeedSrcCropMax = 1ULL << 4, 146 eMPPUnsupportedColorTransform = 1ULL << 5, 147 eMPPUnsupportedBlending = 1ULL << 6, 148 eMPPUnsupportedFormat = 1ULL << 7, 149 eMPPNotAlignedDstSize = 1ULL << 8, 150 eMPPNotAlignedSrcCropPosition = 1ULL << 9, 151 eMPPNotAlignedHStride = 1ULL << 10, 152 eMPPNotAlignedVStride = 1ULL << 11, 153 eMPPExceedHStrideMaximum = 1ULL << 12, 154 eMPPExceedVStrideMaximum = 1ULL << 13, 155 eMPPExeedMaxDownScale = 1ULL << 14, 156 eMPPExeedMaxDstWidth = 1ULL << 15, 157 eMPPExeedMaxDstHeight = 1ULL << 16, 158 eMPPExeedMinSrcWidth = 1ULL << 17, 159 eMPPExeedMinSrcHeight = 1ULL << 18, 160 eMPPExeedMaxUpScale = 1ULL << 19, 161 eMPPExeedSrcWCropMax = 1ULL << 20, 162 eMPPExeedSrcHCropMax = 1ULL << 21, 163 eMPPExeedSrcWCropMin = 1ULL << 22, 164 eMPPExeedSrcHCropMin = 1ULL << 23, 165 eMPPNotAlignedCrop = 1ULL << 24, 166 eMPPNotAlignedOffset = 1ULL << 25, 167 eMPPExeedMinDstWidth = 1ULL << 26, 168 eMPPExeedMinDstHeight = 1ULL << 27, 169 eMPPUnsupportedCompression = 1ULL << 28, 170 eMPPUnsupportedCSC = 1ULL << 29, 171 eMPPUnsupportedDIMLayer = 1ULL << 30, 172 eMPPUnsupportedDRM = 1ULL << 31, 173 eMPPUnsupportedDynamicMeta = 1ULL << 32, 174 eMPPSatisfiedRestriction = 1ULL << 33, 175 eMPPExeedHWResource = 1ULL << 34, 176 }; 177 178 enum { 179 MPP_TYPE_NONE, 180 MPP_TYPE_OTF, 181 MPP_TYPE_M2M 182 }; 183 184 enum { 185 MPP_ASSIGN_STATE_FREE = 0x00000000, 186 MPP_ASSIGN_STATE_RESERVED = 0x00000001, 187 MPP_ASSIGN_STATE_ASSIGNED = 0x00000002, 188 }; 189 190 enum { 191 MPP_HW_STATE_IDLE, 192 MPP_HW_STATE_RUNNING 193 }; 194 195 enum { 196 MPP_BUFFER_NORMAL = 0, 197 MPP_BUFFER_NORMAL_DRM, 198 MPP_BUFFER_SECURE_DRM, 199 MPP_BUFFER_DUMP, 200 }; 201 202 enum { 203 MPP_MEM_MMAP = 1, 204 MPP_MEM_USERPTR, 205 MPP_MEM_OVERLAY, 206 MPP_MEM_DMABUF, 207 }; 208 209 enum { 210 MPP_SOURCE_COMPOSITION_TARGET, 211 MPP_SOURCE_LAYER, 212 MPP_SOURCE_MAX 213 }; 214 215 /* Based on multi-resolution feature */ 216 typedef enum { 217 DST_SIZE_HD = 0, 218 DST_SIZE_HD_PLUS, 219 DST_SIZE_FHD, 220 DST_SIZE_FHD_PLUS, 221 DST_SIZE_WQHD, 222 DST_SIZE_WQHD_PLUS, 223 DST_SIZE_UNKNOWN, 224 } dst_alloc_buf_size_t; 225 226 #ifndef DEFAULT_MPP_DST_FORMAT 227 #define DEFAULT_MPP_DST_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 228 #endif 229 230 /* TODO: Switch back to single-fd format, tracked in b/261356480 */ 231 #ifndef DEFAULT_MPP_DST_YUV_FORMAT 232 #define DEFAULT_MPP_DST_YUV_FORMAT HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M 233 #endif 234 #ifndef DEFAULT_MPP_DST_UNCOMP_YUV_FORMAT 235 #define DEFAULT_MPP_DST_UNCOMP_YUV_FORMAT HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M 236 #endif 237 238 typedef struct exynos_mpp_img_info { 239 buffer_handle_t bufferHandle; 240 uint32_t bufferType; 241 uint32_t format; 242 android_dataspace_t dataspace; 243 AcrylicLayer *mppLayer; 244 int acrylicAcquireFenceFd; 245 int acrylicReleaseFenceFd; 246 } exynos_mpp_img_info_t; 247 248 typedef enum { 249 PPC_SCALE_NO = 0, /* no scale */ 250 PPC_SCALE_DOWN_1_4, /* x1/1.xx ~ x1/4 */ 251 PPC_SCALE_DOWN_4_9, /* x1/4 ~ x1/9 */ 252 PPC_SCALE_DOWN_9_16, /* x1/9 ~ x1/16 */ 253 PPC_SCALE_DOWN_16_, /* x1/16 ~ */ 254 PPC_SCALE_UP_1_4, /* x1.xx ~ x4 */ 255 PPC_SCALE_UP_4_, /* x4 ~ */ 256 PPC_SCALE_MAX 257 } scaling_index_t; 258 259 typedef enum { 260 PPC_FORMAT_YUV420 = 0, 261 PPC_FORMAT_YUV422, 262 PPC_FORMAT_RGB32, 263 PPC_FORMAT_SBWC, 264 PPC_FORMAT_P010, 265 PPC_FORMAT_AFBC_RGB, 266 PPC_FORMAT_AFBC_YUV, 267 PPC_FORMAT_FORMAT_MAX 268 } format_index_t; 269 270 typedef enum { 271 PPC_ROT_NO = 0, 272 PPC_ROT, 273 PPC_ROT_MAX 274 } rot_index_t; 275 276 typedef struct ppc_list_for_scaling { 277 float ppcList[PPC_SCALE_MAX]; 278 } ppc_list_for_scaling_t; 279 280 typedef std::map<uint32_t, ppc_list_for_scaling> ppc_table; 281 282 typedef struct dstMetaInfo { 283 uint16_t minLuminance = 0; 284 uint16_t maxLuminance = 0; 285 } dstMetaInfo_t; 286 287 enum 288 { 289 NODE_NONE, 290 NODE_SRC, 291 NODE_DST 292 }; /* nodeType */ 293 294 enum 295 { 296 HAL_TRANSFORM_NONE = 0 297 }; 298 299 enum 300 { 301 HAL_PIXEL_FORMAT_NONE = 0 302 }; 303 304 #define YUV_CHROMA_H_SUBSAMPLE static_cast<uint32_t>(2) // Horizontal 305 #define YUV_CHROMA_V_SUBSAMPLE static_cast<uint32_t>(2) // Vertical 306 #define RESTRICTION_CNT_MAX 1024 307 308 typedef enum restriction_classification { 309 RESTRICTION_RGB = 0, 310 RESTRICTION_YUV, 311 RESTRICTION_MAX 312 } restriction_classification_t; 313 314 typedef struct restriction_key 315 { 316 mpp_phycal_type_t hwType; /* MPP_DPP_VG, MPP_DPP_VGFS, ... */ 317 uint32_t nodeType; /* src or dst */ 318 uint32_t format; /* HAL format */ 319 uint32_t reserved; 320 } restriction_key_t; 321 322 typedef struct restriction_size 323 { 324 static constexpr size_t kNumofRestriction = 16; 325 union { 326 std::array<uint32_t, kNumofRestriction> mData; 327 struct { 328 uint32_t maxDownScale; 329 uint32_t maxUpScale; 330 uint32_t maxFullWidth; 331 uint32_t maxFullHeight; 332 uint32_t minFullWidth; 333 uint32_t minFullHeight; 334 uint32_t fullWidthAlign; 335 uint32_t fullHeightAlign; 336 uint32_t maxCropWidth; 337 uint32_t maxCropHeight; 338 uint32_t minCropWidth; 339 uint32_t minCropHeight; 340 uint32_t cropXAlign; 341 uint32_t cropYAlign; 342 uint32_t cropWidthAlign; 343 uint32_t cropHeightAlign; 344 }; 345 }; 346 347 restriction_size() = default; restriction_sizerestriction_size348 restriction_size(std::array<uint32_t, kNumofRestriction> &&rdata) : mData(rdata){}; 349 350 bool operator==(const restriction_size &rhs) const { return rhs.mData == mData; } 351 } restriction_size_t; 352 353 typedef struct restriction_size_element 354 { 355 restriction_key_t key; 356 restriction_size_t sizeRestriction; 357 } restriction_size_element_t; 358 359 typedef struct restriction_table_element 360 { 361 uint32_t classfication_type; 362 const restriction_size_element *table; 363 uint32_t table_element_size; 364 } restriction_table_element_t; 365 /* */ 366 367 #define FORMAT_SHIFT 10 368 #define ROT_SHIFT 20 369 #define PPC_IDX(x,y,z) (x|(y<<FORMAT_SHIFT)|(z<<ROT_SHIFT)) 370 371 const std::map<uint32_t, int32_t> dataspace_standard_map = 372 { 373 {HAL_DATASPACE_STANDARD_UNSPECIFIED, 374 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 375 376 {HAL_DATASPACE_STANDARD_BT709, 377 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 378 379 {HAL_DATASPACE_STANDARD_BT601_625, 380 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 381 382 {HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED, 383 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 384 385 {HAL_DATASPACE_STANDARD_BT601_525, 386 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 387 388 {HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED, 389 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 390 391 {HAL_DATASPACE_STANDARD_BT2020, 392 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 393 394 {HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE, 395 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 396 397 {HAL_DATASPACE_STANDARD_BT470M, 398 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 399 400 {HAL_DATASPACE_STANDARD_FILM, 401 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 402 403 {HAL_DATASPACE_STANDARD_DCI_P3, 404 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 405 406 {HAL_DATASPACE_STANDARD_ADOBE_RGB, 407 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS} 408 }; 409 410 const std::map<uint32_t, int32_t> dataspace_transfer_map = 411 { 412 {HAL_DATASPACE_TRANSFER_UNSPECIFIED, 413 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 414 415 {HAL_DATASPACE_TRANSFER_LINEAR, 416 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 417 418 {HAL_DATASPACE_TRANSFER_SRGB, 419 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 420 421 {HAL_DATASPACE_TRANSFER_SMPTE_170M, 422 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 423 424 {HAL_DATASPACE_TRANSFER_GAMMA2_2, 425 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 426 427 {HAL_DATASPACE_TRANSFER_GAMMA2_6, 428 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 429 430 {HAL_DATASPACE_TRANSFER_GAMMA2_8, 431 MPP_ATTR_WCG | MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 432 433 {HAL_DATASPACE_TRANSFER_ST2084, 434 MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS}, 435 436 {HAL_DATASPACE_TRANSFER_HLG, 437 MPP_ATTR_HDR10 | MPP_ATTR_HDR10PLUS} 438 }; 439 440 void dumpExynosMPPImgInfo(uint32_t type, exynos_mpp_img_info &imgInfo); 441 442 struct ExynosMPPFrameInfo 443 { 444 uint32_t srcNum; 445 exynos_image srcInfo[NUM_MPP_SRC_BUFS]; 446 exynos_image dstInfo[NUM_MPP_SRC_BUFS]; 447 }; 448 449 class ExynosMPPSource { 450 public: 451 ExynosMPPSource(); 452 ExynosMPPSource(uint32_t sourceType, void *source); ~ExynosMPPSource()453 ~ExynosMPPSource(){}; 454 void setExynosImage(const exynos_image& src_img, const exynos_image& dst_img); 455 void setExynosMidImage(const exynos_image& mid_img); 456 457 uint32_t mSourceType; 458 void *mSource; 459 exynos_image mSrcImg; 460 exynos_image mDstImg; 461 exynos_image mMidImg; 462 463 ExynosMPP *mOtfMPP; 464 ExynosMPP *mM2mMPP; 465 466 /** 467 * SRAM/HW resource info 468 */ 469 std::unordered_map<tdm_attr_t, int32_t> mHWResourceAmount; getHWResourceAmount(tdm_attr_t attr)470 uint32_t getHWResourceAmount(tdm_attr_t attr) { return mHWResourceAmount[attr]; } 471 setHWResourceAmount(tdm_attr_t attr,uint32_t amount)472 uint32_t setHWResourceAmount(tdm_attr_t attr, uint32_t amount) { 473 mHWResourceAmount[attr] = amount; 474 return 0; 475 } 476 477 bool mNeedPreblending = false; 478 }; 479 480 bool exynosMPPSourceComp(const ExynosMPPSource* l, const ExynosMPPSource* r); 481 void dump(const restriction_size_t &restrictionSize, String8 &result); 482 483 class ExynosMPP { 484 private: 485 class ResourceManageThread: public Thread { 486 private: 487 ExynosMPP *mExynosMPP; 488 Condition mCondition; 489 List<exynos_mpp_img_info > mFreedBuffers; 490 List<int> mStateFences; 491 492 void freeBuffers(); 493 bool checkStateFences(); 494 public: 495 bool mRunning; 496 Mutex mMutex; 497 ResourceManageThread(ExynosMPP *exynosMPP); 498 ~ResourceManageThread(); 499 virtual bool threadLoop(); 500 void addFreedBuffer(exynos_mpp_img_info freedBuffer); 501 void addStateFence(int fence); 502 }; 503 504 public: 505 ExynosResourceManager *mResourceManager; 506 /** 507 * Resource type 508 * Ex: MPP_DPP_VGFS, MPP_DPP_VG, MPP_MSC, MPP_G2D 509 */ 510 uint32_t mMPPType; 511 uint32_t mPhysicalType; 512 uint32_t mLogicalType; 513 String8 mName; 514 uint32_t mPhysicalIndex; 515 uint32_t mLogicalIndex; 516 uint32_t mPreAssignDisplayInfo; 517 uint32_t mPreAssignDisplayList[DISPLAY_MODE_NUM]; 518 static int mainDisplayWidth; 519 static int mainDisplayHeight; 520 521 uint32_t mHWState; 522 int mLastStateFenceFd; 523 uint32_t mAssignedState; 524 bool mEnable; 525 526 ExynosDisplay *mAssignedDisplay; 527 528 /* Some resource can support blending feature 529 * then source can be multiple layers */ 530 Vector <ExynosMPPSource* > mAssignedSources; 531 uint32_t mMaxSrcLayerNum; 532 533 uint32_t mPrevAssignedState; 534 int32_t mPrevAssignedDisplayType; 535 int32_t mReservedDisplay; 536 537 android::sp<ResourceManageThread> mResourceManageThread; 538 float mCapacity; 539 float mUsedCapacity; 540 541 union { 542 struct { 543 float mUsedBaseCycles; 544 uint32_t mRotatedSrcCropBW; 545 uint32_t mNoRotatedSrcCropBW; 546 }; 547 }; 548 549 bool mAllocOutBufFlag; 550 bool mFreeOutBufFlag; 551 bool mHWBusyFlag; 552 /* For reuse previous frame */ 553 ExynosMPPFrameInfo mPrevFrameInfo; 554 struct exynos_mpp_img_info mSrcImgs[NUM_MPP_SRC_BUFS]; 555 struct exynos_mpp_img_info mDstImgs[NUM_MPP_DST_BUFS_DEFAULT]; 556 int32_t mCurrentDstBuf; 557 int32_t mPrivDstBuf; 558 bool mNeedCompressedTarget; 559 struct restriction_size mSrcSizeRestrictions[RESTRICTION_MAX]; 560 struct restriction_size mDstSizeRestrictions[RESTRICTION_MAX]; 561 562 // Force Dst buffer reallocation 563 dst_alloc_buf_size_t mDstAllocatedSize; 564 565 /* For libacryl */ 566 Acrylic *mAcrylicHandle; 567 568 bool mUseM2MSrcFence; 569 /* MPP's attribute bit (supported feature bit) */ 570 uint64_t mAttr; 571 572 uint32_t mAssignOrder; 573 uint32_t mAXIPortId; 574 uint32_t mHWBlockId; 575 576 bool mNeedSolidColorLayer; 577 578 ExynosMPP(ExynosResourceManager* resourceManager, 579 uint32_t physicalType, uint32_t logicalType, const char *name, 580 uint32_t physicalIndex, uint32_t logicalIndex, uint32_t preAssignInfo); 581 virtual ~ExynosMPP(); 582 583 int32_t allocOutBuf(uint32_t w, uint32_t h, uint32_t format, uint64_t usage, uint32_t index); 584 int32_t setOutBuf(buffer_handle_t outbuf, int32_t fence); 585 int32_t freeOutBuf(exynos_mpp_img_info dst); 586 int32_t doPostProcessing(struct exynos_image &src, struct exynos_image &dst); 587 int32_t doPostProcessing(uint32_t totalImags, uint32_t imageIndex, struct exynos_image &src, struct exynos_image &dst); 588 int32_t setupRestriction(); 589 int32_t getSrcReleaseFence(uint32_t srcIndex); 590 int32_t resetSrcReleaseFence(); 591 int32_t getDstImageInfo(exynos_image *img); 592 int32_t setDstAcquireFence(int releaseFence); 593 int32_t resetDstReleaseFence(); 594 int32_t requestHWStateChange(uint32_t state); 595 int32_t setHWStateFence(int32_t fence); 596 virtual int64_t isSupported(ExynosDisplay &display, struct exynos_image &src, struct exynos_image &dst); 597 598 bool isDataspaceSupportedByMPP(struct exynos_image &src, struct exynos_image &dst); 599 bool isSupportedHDR(struct exynos_image &src, struct exynos_image &dst); 600 bool isSupportedBlend(struct exynos_image &src); 601 virtual bool isSupportedTransform(struct exynos_image &src); 602 bool isSupportedCapability(ExynosDisplay &display, struct exynos_image &src); 603 bool isSupportedDRM(struct exynos_image &src); 604 virtual bool isSupportedHStrideCrop(struct exynos_image &src); 605 bool checkDownscaleCap(const float resolution, const float displayRatio_V) const; checkSpecificRestriction(const uint32_t __unused refreshRate,const struct exynos_image __unused & src,const struct exynos_image __unused & dst)606 virtual bool checkSpecificRestriction(const uint32_t __unused refreshRate, 607 const struct exynos_image __unused &src, 608 const struct exynos_image __unused &dst) { 609 return false; 610 } 611 virtual uint32_t getDownscaleRestriction(const struct exynos_image &src, 612 const struct exynos_image &dst) const; 613 virtual uint32_t getMaxDownscale(const ExynosDisplay &display, const struct exynos_image &src, 614 const struct exynos_image &dst) const; 615 virtual uint32_t getMaxUpscale(const struct exynos_image &src, 616 const struct exynos_image &dst) const; 617 uint32_t getSrcMaxWidth(struct exynos_image &src); 618 uint32_t getSrcMaxHeight(struct exynos_image &src); 619 uint32_t getSrcMinWidth(struct exynos_image &src); 620 uint32_t getSrcMinWidth(uint32_t idx); 621 uint32_t getSrcMinHeight(struct exynos_image &src); 622 uint32_t getSrcMinHeight(uint32_t idx); 623 uint32_t getSrcWidthAlign(struct exynos_image &src); 624 uint32_t getSrcHeightAlign(struct exynos_image &src); 625 uint32_t getSrcMaxCropWidth(struct exynos_image &src); 626 uint32_t getSrcMaxCropHeight(struct exynos_image &src); 627 virtual uint32_t getSrcMaxCropSize(struct exynos_image &src); 628 uint32_t getSrcMinCropWidth(struct exynos_image &src); 629 uint32_t getSrcMinCropHeight(struct exynos_image &src); 630 virtual uint32_t getSrcXOffsetAlign(struct exynos_image &src); 631 uint32_t getSrcXOffsetAlign(uint32_t idx); 632 uint32_t getSrcYOffsetAlign(struct exynos_image &src); 633 uint32_t getSrcYOffsetAlign(uint32_t idx); 634 uint32_t getSrcCropWidthAlign(const struct exynos_image &src) const; 635 uint32_t getSrcCropWidthAlign(uint32_t idx) const; 636 uint32_t getSrcCropHeightAlign(const struct exynos_image &src) const; 637 uint32_t getSrcCropHeightAlign(uint32_t idx) const; 638 virtual bool isSrcFormatSupported(struct exynos_image &src); 639 virtual bool isDimLayerSupported(); 640 int32_t isSupportThis(uint32_t mSupportAttr); 641 642 uint32_t getDstMaxWidth(struct exynos_image &dst); 643 uint32_t getDstMaxHeight(struct exynos_image &dst); 644 uint32_t getDstMinWidth(struct exynos_image &dst); 645 uint32_t getDstMinHeight(struct exynos_image &dst); 646 virtual uint32_t getDstWidthAlign(const struct exynos_image &dst) const; 647 uint32_t getDstHeightAlign(const struct exynos_image &dst) const; 648 uint32_t getDstXOffsetAlign(struct exynos_image &dst); 649 uint32_t getDstYOffsetAlign(struct exynos_image &dst); 650 uint32_t getOutBufAlign(); 651 virtual bool isDstFormatSupported(struct exynos_image &dst); 652 int32_t isSupportLayerColorTransform( 653 struct exynos_image &src, struct exynos_image &dst); 654 uint32_t getSrcMaxBlendingNum(struct exynos_image &src, struct exynos_image &dst); 655 uint32_t getAssignedSourceNum(); 656 657 /* Based on multi-resolution support */ 658 void setDstAllocSize(uint32_t width, uint32_t height); 659 dst_alloc_buf_size_t getDstAllocSize(); 660 virtual bool needPreAllocation(); 661 662 int32_t resetMPP(); 663 int32_t resetAssignedState(); 664 int32_t resetAssignedState(ExynosMPPSource *mppSource); 665 int32_t reserveMPP(int32_t displayType = -1); 666 667 bool isAssignableState(ExynosDisplay *display, struct exynos_image &src, struct exynos_image &dst); 668 bool isAssignable(ExynosDisplay *display, struct exynos_image &src, struct exynos_image &dst, 669 float totalUsedCapacity); 670 int32_t assignMPP(ExynosDisplay *display, ExynosMPPSource* mppSource); 671 672 bool hasEnoughCapa(ExynosDisplay *display, struct exynos_image &src, struct exynos_image &dst, 673 float totalUsedCapa); 674 float getRequiredCapacity(ExynosDisplay *display, struct exynos_image &src, struct exynos_image &dst); 675 int32_t updateUsedCapacity(); 676 void resetUsedCapacity(); 677 int prioritize(int priority); 678 getMPPClockKhz()679 uint32_t getMPPClockKhz() { return mClockKhz; }; 680 681 void dump(String8& result); 682 uint32_t increaseDstBuffIndex(); 683 bool canSkipProcessing(); 684 685 virtual bool isSupportedCompression(struct exynos_image &src); 686 687 void closeFences(); 688 689 void reloadResourceForHWFC(); 690 void setTargetDisplayLuminance(uint16_t min, uint16_t max); 691 void setTargetDisplayDevice(int device); 692 693 virtual bool checkRotationCondition(struct exynos_image &src); 694 void updateAttr(); 695 void updatePreassignedDisplay(uint32_t fromDisplayBit, uint32_t toDisplayBit); 696 dstMetaInfo getDstMetaInfo(android_dataspace_t dstDataspace); 697 float getAssignedCapacity(); 698 setPPC(float ppc)699 void setPPC(float ppc) { mPPC = ppc; }; setClockKhz(uint32_t clock)700 void setClockKhz(uint32_t clock) { mClockKhz = clock; }; 701 initTDMInfo(uint32_t hwBlockIndex,uint32_t axiPortIndex)702 virtual void initTDMInfo(uint32_t hwBlockIndex, uint32_t axiPortIndex) { 703 mHWBlockId = hwBlockIndex; 704 mAXIPortId = axiPortIndex; 705 } getHWBlockId()706 virtual uint32_t getHWBlockId() { return mHWBlockId; } getAXIPortId()707 virtual uint32_t getAXIPortId() { return mAXIPortId; } 708 709 protected: 710 uint32_t getBufferType(uint64_t usage); 711 uint32_t getBufferType(const buffer_handle_t handle); 712 uint64_t getBufferUsage(uint64_t usage); 713 bool needCompressDstBuf() const; 714 bool needDstBufRealloc(struct exynos_image &dst, uint32_t index); 715 bool canUsePrevFrame(); 716 int32_t setupDst(exynos_mpp_img_info *dstImgInfo); 717 virtual int32_t doPostProcessingInternal(); 718 virtual int32_t setupLayer(exynos_mpp_img_info *srcImgInfo, 719 struct exynos_image &src, struct exynos_image &dst); setColorConversionInfo()720 virtual int32_t setColorConversionInfo() { return NO_ERROR; }; 721 722 uint32_t getRestrictionClassification(const struct exynos_image &img) const; 723 724 /* 725 * getPPC for src, dst referencing mppSources in mAssignedSources and 726 * assignCheckSrc, assignCheckDst that are likely to be added to the mAssignedSources 727 */ 728 float getPPC(const struct exynos_image &src, const struct exynos_image &dst, 729 const struct exynos_image &criteria, 730 const struct exynos_image *assignCheckSrc = NULL, 731 const struct exynos_image *assignCheckDst = NULL); getPPC()732 float getPPC() { return mPPC; }; 733 734 /* format and rotation index are defined by indexImage */ 735 void getPPCIndex(const struct exynos_image &indexImage, 736 const struct exynos_image &refImage, 737 uint32_t &formatIndex, uint32_t &rotIndex, uint32_t &scaleIndex, 738 const struct exynos_image &criteria); 739 740 float getRequiredBaseCycles(struct exynos_image &src, struct exynos_image &dst); 741 bool addCapacity(ExynosMPPSource* mppSource); 742 bool removeCapacity(ExynosMPPSource* mppSource); 743 /* 744 * This should be called by isCSCSupportedByMPP() 745 * This function checks additional restriction for color space conversion 746 */ 747 virtual bool checkCSCRestriction(struct exynos_image &src, struct exynos_image &dst); 748 749 /* 750 * Check additional conditions those have a capacity exception. 751 */ 752 virtual bool isCapacityExceptionCondition(float totalUsedCapacity, float requiredCapacity, 753 struct exynos_image &src); 754 755 uint32_t mClockKhz = 0; 756 float mPPC = 0; 757 }; 758 759 #endif //_EXYNOSMPP_H 760