1 /*
2 * Copyright (C) 2019 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 #include "ExynosHWCDebug.h"
19 #include "ExynosResourceManager.h"
20 #include "ExynosPrimaryDisplayModule.h"
21
22 using namespace gs101;
23
ExynosMPPModule(ExynosResourceManager * resourceManager,uint32_t physicalType,uint32_t logicalType,const char * name,uint32_t physicalIndex,uint32_t logicalIndex,uint32_t preAssignInfo)24 ExynosMPPModule::ExynosMPPModule(ExynosResourceManager* resourceManager,
25 uint32_t physicalType, uint32_t logicalType, const char *name,
26 uint32_t physicalIndex, uint32_t logicalIndex, uint32_t preAssignInfo)
27 : ExynosMPP(resourceManager, physicalType, logicalType, name, physicalIndex, logicalIndex, preAssignInfo),
28 mChipId(0x00)
29 {
30 if (mLogicalType == MPP_LOGICAL_G2D_RGB)
31 mEnable = false;
32 }
33
~ExynosMPPModule()34 ExynosMPPModule::~ExynosMPPModule()
35 {
36 }
37
getSrcXOffsetAlign(struct exynos_image & src)38 uint32_t ExynosMPPModule::getSrcXOffsetAlign(struct exynos_image &src)
39 {
40 uint32_t idx = getRestrictionClassification(src);
41 return mSrcSizeRestrictions[idx].cropXAlign;
42 }
43
setColorConversionInfo()44 int32_t ExynosMPPModule::setColorConversionInfo()
45 {
46 if (mAssignedDisplay == nullptr) {
47 MPP_LOGE("%s: mAssignedDisplay is null", __func__);
48 return -EINVAL;
49 }
50 if (mAssignedDisplay->mType != HWC_DISPLAY_PRIMARY)
51 return NO_ERROR;
52
53 ExynosPrimaryDisplayModule* primaryDisplay =
54 (ExynosPrimaryDisplayModule*)mAssignedDisplay;
55
56 if (!primaryDisplay->hasDisplayColor()) {
57 return NO_ERROR;
58 }
59
60 for (size_t i = 0; i < mAssignedSources.size(); i++) {
61 auto mppSource = mAssignedSources[i];
62 ExynosLayer* layer = (ExynosLayer*)mppSource;
63 AcrylicLayer* mppLayer = mSrcImgs[i].mppLayer;
64 if ((mppSource == nullptr) || (layer == nullptr) ||
65 (mppLayer == nullptr)) {
66 MPP_LOGE("%s: src[%zu] source layer is null", __func__, i);
67 return -EINVAL;
68 }
69 if (mppSource->mSrcImg.dataSpace == mppSource->mMidImg.dataSpace) {
70 //set null layer data to acryl
71 mppLayer->setLayerData(nullptr, 0);
72 continue;
73 }
74 if (primaryDisplay->hasDppForLayer(layer) == false) {
75 MPP_LOGE("%s: src[%zu] need color conversion but there is no IDpp", __func__, i);
76 return -EINVAL;
77 }
78 MPP_LOGD(eDebugColorManagement,
79 "%s, src: 0x%8x", __func__, mppSource->mSrcImg.dataSpace);
80 const IDisplayColorGS101::IDpp& dpp =
81 primaryDisplay->getDppForLayer(layer);
82 mppLayer->setLayerData((void *)&dpp,
83 sizeof(IDisplayColorGS101::IDpp));
84 }
85 return NO_ERROR;
86 }
87