1 /*
2  * Copyright (C) 2022 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 #include "ExynosMPPModule.h"
18 
19 #include "ExynosHWCDebug.h"
20 #include "ExynosPrimaryDisplayModule.h"
21 #include "ExynosResourceManager.h"
22 
23 using namespace gs201;
24 
ExynosMPPModule(ExynosResourceManager * resourceManager,uint32_t physicalType,uint32_t logicalType,const char * name,uint32_t physicalIndex,uint32_t logicalIndex,uint32_t preAssignInfo)25 ExynosMPPModule::ExynosMPPModule(ExynosResourceManager *resourceManager, uint32_t physicalType,
26                                  uint32_t logicalType, const char *name, uint32_t physicalIndex,
27                                  uint32_t logicalIndex, uint32_t preAssignInfo)
28       : gs101::ExynosMPPModule(resourceManager, physicalType, logicalType, name, physicalIndex,
29                                logicalIndex, preAssignInfo) {}
30 
~ExynosMPPModule()31 ExynosMPPModule::~ExynosMPPModule() {}
32 
33 /* This function is used to restrict case that current MIF voting can't cover
34  * it. Once a solution is ready, the restriction need to be removed.
35  */
checkSpecificRestriction(const uint32_t refreshRate,const struct exynos_image & src,const struct exynos_image & dst)36 bool ExynosMPPModule::checkSpecificRestriction(const uint32_t refreshRate,
37                                                const struct exynos_image &src,
38                                                const struct exynos_image &dst) {
39     /* additional restriction for composer in high refresh rate */
40     if (mPhysicalType < MPP_DPP_NUM && refreshRate >= 90) {
41         VendorGraphicBufferMeta gmeta(src.bufferHandle);
42 
43         if (isFormatYUV(gmeta.format)) {
44             // 16:9 4k or large YUV layer
45             if (src.w >= 3584 && src.h >= 1600) {
46                 return true;
47             }
48             // 9:16 4k or large YUV layer
49             if (src.h >= 2600 && src.w >= 1450 && src.h > dst.h && (dst.h * 100 / src.h) < 67) {
50                 return true;
51             }
52         } else if (src.w >= 1680 && src.h > dst.h && (dst.h * 100 / src.h) < 60) {
53             // vertical downscale RGB layer
54             return true;
55         }
56     }
57 
58     return ExynosMPP::checkSpecificRestriction(refreshRate, src, dst);
59 }
60 
isSupported(ExynosDisplay & display,struct exynos_image & src,struct exynos_image & dst)61 int64_t ExynosMPPModule::isSupported(ExynosDisplay &display,
62                                      struct exynos_image &src,
63                                      struct exynos_image &dst) {
64     if (mPhysicalType < MPP_DPP_NUM && src.bufferHandle != nullptr) {
65         const uint32_t refreshRate = display.getBtsRefreshRate();
66 
67         if (checkSpecificRestriction(refreshRate, src, dst)) {
68             return -eMPPSatisfiedRestriction;
69         }
70     }
71 
72     return ExynosMPP::isSupported(display, src, dst);
73 }
74