From 811a9ed945ba40250b0f26e3f74a3d945a73eb9e Mon Sep 17 00:00:00 2001 From: HyunKyung Kim Date: Tue, 30 Jul 2019 10:56:52 +0900 Subject: libhwc2.1: Add initial source code Change-Id: If0968db44c5c90c5bc7f0ee7a0f0be1029c5bdab Signed-off-by: HyunKyung Kim --- libhwc2.1/libresource/ExynosMPPModule.cpp | 193 +++++++++++++++++++++ libhwc2.1/libresource/ExynosMPPModule.h | 37 ++++ .../libresource/ExynosResourceManagerModule.cpp | 64 +++++++ .../libresource/ExynosResourceManagerModule.h | 27 +++ 4 files changed, 321 insertions(+) create mode 100644 libhwc2.1/libresource/ExynosMPPModule.cpp create mode 100644 libhwc2.1/libresource/ExynosMPPModule.h create mode 100644 libhwc2.1/libresource/ExynosResourceManagerModule.cpp create mode 100644 libhwc2.1/libresource/ExynosResourceManagerModule.h (limited to 'libhwc2.1/libresource') diff --git a/libhwc2.1/libresource/ExynosMPPModule.cpp b/libhwc2.1/libresource/ExynosMPPModule.cpp new file mode 100644 index 0000000..bd90414 --- /dev/null +++ b/libhwc2.1/libresource/ExynosMPPModule.cpp @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ExynosMPPModule.h" +#include "ExynosHWCDebug.h" +#include "ExynosResourceManager.h" + +ExynosMPPModule::ExynosMPPModule(ExynosResourceManager* resourceManager, + uint32_t physicalType, uint32_t logicalType, const char *name, + uint32_t physicalIndex, uint32_t logicalIndex, uint32_t preAssignInfo) + : ExynosMPP(resourceManager, physicalType, logicalType, name, physicalIndex, logicalIndex, preAssignInfo), + mChipId(0x00) +{ +} + +ExynosMPPModule::~ExynosMPPModule() +{ +} + +uint32_t ExynosMPPModule::getSrcXOffsetAlign(struct exynos_image &src) +{ + uint32_t idx = getRestrictionClassification(src); + return mSrcSizeRestrictions[idx].cropXAlign; +} + +uint32_t ExynosMPPModule::getDstWidthAlign(struct exynos_image &dst) +{ + if (((dst.format == HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_S10B) || + (dst.format == HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_S10B)) && + (mPhysicalType == MPP_MSC)) + return 4; + + return ExynosMPP::getDstWidthAlign(dst); +} + +bool ExynosMPPModule::isSupportedCompression(struct exynos_image &src) +{ + if (src.compressed) { + if (mPhysicalType == MPP_G2D) + return true; + + ExynosMPP *sharedMPP = NULL; + if (mPhysicalType == MPP_DPP_GF) { + if (mPhysicalIndex == 0) { + /* GF1 shares memory with VGF0 */ + sharedMPP = mResourceManager->getExynosMPP(MPP_DPP_VGF, 0); + } else if (mPhysicalIndex == 1) { + /* GF0 shares memory with VGRFS0 */ + sharedMPP = mResourceManager->getExynosMPP(MPP_DPP_VGRFS, 0); + } else { + MPP_LOGE("Invalid MPP_DPP_GF index(%d)", mPhysicalIndex); + return false; + } + } else if (mPhysicalType == MPP_DPP_VGF) { + /* GF1 shares memory with VGF0 */ + sharedMPP = mResourceManager->getExynosMPP(MPP_DPP_GF, 0); + } else if (mPhysicalType == MPP_DPP_VGRFS) { + /* GF0 shares memory with VGRFS0 */ + sharedMPP = mResourceManager->getExynosMPP(MPP_DPP_GF, 1); + } else { + /* Other mpp don't support decompression */ + return false; + } + + if (sharedMPP == NULL) { + MPP_LOGE("sharedMPP is NULL"); + return false; + } + + if ((sharedMPP->mAssignedState & MPP_ASSIGN_STATE_ASSIGNED) == 0) + return true; + else { + if (sharedMPP->mAssignedSources.size() == 1) { + exynos_image checkImg = sharedMPP->mAssignedSources[0]->mSrcImg; + if ((sharedMPP->mAssignedSources[0]->mSourceType == MPP_SOURCE_COMPOSITION_TARGET) || + (sharedMPP->mAssignedSources[0]->mM2mMPP != NULL)) { + checkImg = sharedMPP->mAssignedSources[0]->mMidImg; + } + if (checkImg.transform & HAL_TRANSFORM_ROT_90) + return false; + + if (checkImg.compressed == 0) + return true; + + if (checkImg.w > 2048) + return false; + else { + if (src.w < 2048) + return true; + else + return false; + } + } else { + MPP_LOGE("Invalid sharedMPP[%d, %d] mAssignedSources size(%zu)", + sharedMPP->mPhysicalType, + sharedMPP->mPhysicalIndex, + sharedMPP->mAssignedSources.size()); + } + } + return false; + } else { + return true; + } +} + +bool ExynosMPPModule::isSupportedTransform(struct exynos_image &src) +{ + ExynosMPP *sharedMPP = NULL; + switch (mPhysicalType) + { + case MPP_MSC: + case MPP_G2D: + return true; + case MPP_DPP_G: + case MPP_DPP_GF: + case MPP_DPP_VG: + case MPP_DPP_VGS: + case MPP_DPP_VGF: + case MPP_DPP_VGFS: + if ((src.transform & HAL_TRANSFORM_ROT_90) == 0) + { + if ((src.compressed == 1) && (src.transform != 0)) + return false; + return true; + } else { + return false; + } + case MPP_DPP_VGRFS: + if (isFormatYUV420(src.format)) { + /* HACK */ + if ((src.transform != 0) && isFormat10BitYUV420(src.format)) return false; + + /* GF0 shares memory with VGRFS0 */ + sharedMPP = mResourceManager->getExynosMPP(MPP_DPP_GF, 1); + if (sharedMPP == NULL) { + MPP_LOGE("sharedMPP is NULL"); + return false; + } + + if ((src.transform & HAL_TRANSFORM_ROT_90) && + (sharedMPP->mAssignedState & MPP_ASSIGN_STATE_ASSIGNED)) { + if (sharedMPP->mAssignedSources.size() != 1) { + MPP_LOGE("Invalid sharedMPP[%d, %d] mAssignedSources size(%zu)", + sharedMPP->mPhysicalType, + sharedMPP->mPhysicalIndex, + sharedMPP->mAssignedSources.size()); + return false; + } + exynos_image checkImg = sharedMPP->mAssignedSources[0]->mSrcImg; + if ((sharedMPP->mAssignedSources[0]->mSourceType == MPP_SOURCE_COMPOSITION_TARGET) || + (sharedMPP->mAssignedSources[0]->mM2mMPP != NULL)) { + checkImg = sharedMPP->mAssignedSources[0]->mMidImg; + } + if (checkImg.compressed == 1) + return false; + } + return true; + } + /* RGB case */ + if ((src.transform & HAL_TRANSFORM_ROT_90) == 0) + { + if ((src.compressed == 1) && (src.transform != 0)) + return false; + return true; + } else { + return false; + } + default: + return true; + } +} + +uint32_t ExynosMPPModule::getSrcMaxCropSize(struct exynos_image &src) +{ + if ((mPhysicalType == MPP_DPP_VGRFS) && + (src.transform & HAL_TRANSFORM_ROT_90)) + return MAX_DPP_ROT_SRC_SIZE; + else + return ExynosMPP::getSrcMaxCropSize(src); +} diff --git a/libhwc2.1/libresource/ExynosMPPModule.h b/libhwc2.1/libresource/ExynosMPPModule.h new file mode 100644 index 0000000..a48a5d6 --- /dev/null +++ b/libhwc2.1/libresource/ExynosMPPModule.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _EXYNOS_MPP_MODULE_H +#define _EXYNOS_MPP_MODULE_H + +#include "ExynosMPP.h" + +#define MAX_DPP_ROT_SRC_SIZE (3040*1440) + +class ExynosMPPModule : public ExynosMPP { + public: + ExynosMPPModule(ExynosResourceManager* resourceManager, uint32_t physicalType, uint32_t logicalType, const char *name, + uint32_t physicalIndex, uint32_t logicalIndex, uint32_t preAssignInfo); + ~ExynosMPPModule(); + virtual bool isSupportedTransform(struct exynos_image &src); + virtual bool isSupportedCompression(struct exynos_image &src); + virtual uint32_t getSrcXOffsetAlign(struct exynos_image &src); + virtual uint32_t getDstWidthAlign(struct exynos_image &dst); + virtual uint32_t getSrcMaxCropSize(struct exynos_image &src); + public: + uint32_t mChipId; +}; + +#endif diff --git a/libhwc2.1/libresource/ExynosResourceManagerModule.cpp b/libhwc2.1/libresource/ExynosResourceManagerModule.cpp new file mode 100644 index 0000000..997a5d0 --- /dev/null +++ b/libhwc2.1/libresource/ExynosResourceManagerModule.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ExynosResourceManagerModule.h" +#include "ExynosMPPModule.h" +#define CHIP_ID_PATH "/sys/devices/system/chip-id/revision" + +ExynosResourceManagerModule::ExynosResourceManagerModule(ExynosDevice* device) + : ExynosResourceManager(device) +{ + uint32_t chipid = 0x00; + int chipid_fd = open(CHIP_ID_PATH, O_RDONLY); + char buf[10]; + int err = 0; + memset(buf, 0, sizeof(buf)); + + if (chipid_fd > 0) { + err = read(chipid_fd, buf, sizeof(buf)); + if (err < 0) { + ALOGE("error reading chipid: %s", strerror(errno)); + close(chipid_fd); + return; + } + } else { + ALOGE("Fail to open chip id file"); + } + + if (!strncmp(buf, "00000000", 8)) { + chipid = 0x00; + } else if (!strncmp(buf, "00000001", 8)) { + chipid = 0x01; + } else if (!strncmp(buf, "00000011", 8)) { + chipid = 0x11; + } else { + chipid = 0x00; + } + ALOGI("chip id: %s, 0x%2x", buf, chipid); + + for (uint32_t i = 0; i < mOtfMPPs.size(); i++) { + ((ExynosMPPModule *)mOtfMPPs[i])->mChipId = chipid; + } + for (uint32_t i = 0; i < mM2mMPPs.size(); i++) { + ((ExynosMPPModule *)mM2mMPPs[i])->mChipId = chipid; + } + + if (chipid_fd > 0) + close(chipid_fd); +} + +ExynosResourceManagerModule::~ExynosResourceManagerModule() +{ +} diff --git a/libhwc2.1/libresource/ExynosResourceManagerModule.h b/libhwc2.1/libresource/ExynosResourceManagerModule.h new file mode 100644 index 0000000..19da403 --- /dev/null +++ b/libhwc2.1/libresource/ExynosResourceManagerModule.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _EXYNOS_RESOURCE_MANAGER_MODULE_H +#define _EXYNOS_RESOURCE_MANAGER_MODULE_H + +#include "ExynosResourceManager.h" + +class ExynosResourceManagerModule : public ExynosResourceManager { + public: + ExynosResourceManagerModule(ExynosDevice* device); + ~ExynosResourceManagerModule(); +}; + +#endif // _EXYNOS_RESOURCE_MANAGER_MODULE_H -- cgit v1.2.3