diff options
author | Seungchul Kim <sc377.kim@samsung.com> | 2019-03-12 16:35:29 +0900 |
---|---|---|
committer | Weizhung Ding <weizhungding@google.com> | 2021-03-19 20:12:47 +0800 |
commit | 166d1ec4bb7918e6e31d27876adde3ddacad36ce (patch) | |
tree | 1feddc0f6238144f75eab57e253dfee3342d176a | |
parent | edc066233defe2cd3572eeca8729e06b241cdca7 (diff) |
libhwc2.1: modify concept of display's type and ID
Bug: 162322019
Test: single/dual display boot to OS, and suspend/resume
Change-Id: I4926f2b30abc2a9b4ddf1c47038ac7b9573213b1
Signed-off-by: Seungchul Kim <sc377.kim@samsung.com>
Signed-off-by: HyunKyung Kim <hk310.kim@samsung.com>
19 files changed, 213 insertions, 203 deletions
diff --git a/libhwc2.1/ExynosHWC.cpp b/libhwc2.1/ExynosHWC.cpp index 50534d9..1887f59 100644 --- a/libhwc2.1/ExynosHWC.cpp +++ b/libhwc2.1/ExynosHWC.cpp @@ -238,7 +238,7 @@ int32_t exynos_createVirtualDisplay(hwc2_device_t *dev, uint32_t width, uint32_t return HWC2_ERROR_BAD_PARAMETER; ExynosDevice *exynosDevice = checkDevice(dev); - *outDisplay = HWC_DISPLAY_VIRTUAL; + *outDisplay = getDisplayId(HWC_DISPLAY_VIRTUAL, 0); if (exynosDevice) { ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, *outDisplay); @@ -1272,7 +1272,7 @@ void exynos_boot_finished(ExynosHWCCtx *dev) char val; if (read(sw_fd, &val, 1) == 1 && val == '1') { ALOGI("%s : try to reconnect displayport", __func__); - ExynosExternalDisplayModule *display = (ExynosExternalDisplayModule*)dev->device->getDisplay(HWC_DISPLAY_EXTERNAL); + ExynosExternalDisplayModule *display = (ExynosExternalDisplayModule*)dev->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); display->handleHotplugEvent(); } hwcFdClose(sw_fd); diff --git a/libhwc2.1/libdevice/ExynosDevice.cpp b/libhwc2.1/libdevice/ExynosDevice.cpp index c693e62..673e394 100644 --- a/libhwc2.1/libdevice/ExynosDevice.cpp +++ b/libhwc2.1/libdevice/ExynosDevice.cpp @@ -60,7 +60,7 @@ ExynosDevice::ExynosDevice() : mGeometryChanged(0), mVsyncFd(-1), mExtVsyncFd(-1), - mVsyncDisplay(HWC_DISPLAY_PRIMARY), + mVsyncDisplayId(getDisplayId(HWC_DISPLAY_PRIMARY, 0)), mTimestamp(0), mDisplayMode(0), mInterfaceType(INTERFACE_TYPE_FB) @@ -86,7 +86,7 @@ ExynosDevice::ExynosDevice() ALOGD("HWC2 : %s : interface type(%d)", __func__, mInterfaceType); mResourceManager = new ExynosResourceManagerModule(this); - ExynosPrimaryDisplayModule *primary_display = new ExynosPrimaryDisplayModule(HWC_DISPLAY_PRIMARY, this); + ExynosPrimaryDisplayModule *primary_display = new ExynosPrimaryDisplayModule(0, this); primary_display->mPlugState = true; ExynosMPP::mainDisplayWidth = primary_display->mXres; @@ -98,9 +98,10 @@ ExynosDevice::ExynosDevice() ExynosMPP::mainDisplayHeight = 2560; } - ExynosExternalDisplayModule *external_display = new ExynosExternalDisplayModule(HWC_DISPLAY_EXTERNAL, this); + ExynosExternalDisplayModule *external_display = new ExynosExternalDisplayModule(0, this); + + ExynosVirtualDisplayModule *virtual_display = new ExynosVirtualDisplayModule(0, this); - ExynosVirtualDisplayModule *virtual_display = new ExynosVirtualDisplayModule(HWC_DISPLAY_VIRTUAL, this); mNumVirtualDisplay = 0; mDisplays.add((ExynosDisplay*) primary_display); @@ -177,7 +178,7 @@ void ExynosDevice::initDeviceInterface(uint32_t interfaceType) ExynosDevice::~ExynosDevice() { - ExynosDisplay *primary_display = getDisplay(HWC_DISPLAY_PRIMARY); + ExynosDisplay *primary_display = getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY,0)); mDRLoopStatus = false; mDRThread.join(); @@ -188,7 +189,7 @@ ExynosDevice::~ExynosDevice() { bool ExynosDevice::isFirstValidate() { for (uint32_t i = 0; i < mDisplays.size(); i++) { - if ((mDisplays[i]->mDisplayId != HWC_DISPLAY_VIRTUAL) && + if ((mDisplays[i]->mType != HWC_DISPLAY_VIRTUAL) && (mDisplays[i]->mPowerModeState == (hwc2_power_mode_t)HWC_POWER_MODE_OFF)) continue; if ((mDisplays[i]->mPlugState == true) && @@ -205,7 +206,7 @@ bool ExynosDevice::isLastValidate(ExynosDisplay *display) for (uint32_t i = 0; i < mDisplays.size(); i++) { if (mDisplays[i] == display) continue; - if ((mDisplays[i]->mDisplayId != HWC_DISPLAY_VIRTUAL) && + if ((mDisplays[i]->mType != HWC_DISPLAY_VIRTUAL) && (mDisplays[i]->mPowerModeState == (hwc2_power_mode_t)HWC_POWER_MODE_OFF)) continue; if ((mDisplays[i]->mPlugState == true) && @@ -254,18 +255,18 @@ void ExynosDevice::dynamicRecompositionThreadCreate() void *ExynosDevice::dynamicRecompositionThreadLoop(void *data) { ExynosDevice *dev = (ExynosDevice *)data; - ExynosDisplay *display[HWC_NUM_DISPLAY_TYPES]; - uint64_t event_cnt[HWC_NUM_DISPLAY_TYPES]; + ExynosDisplay *display[dev->mDisplays.size()]; + uint64_t event_cnt[dev->mDisplays.size()]; - for (uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) { - display[i] = (ExynosDisplay *)dev->getDisplay(i); + for (uint32_t i = 0; i < dev->mDisplays.size(); i++) { + display[i] = dev->mDisplays[i]; event_cnt[i] = 0; } android_atomic_inc(&(dev->mDRThreadStatus)); while (dev->mDRLoopStatus) { uint32_t result = 0; - for (uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) + for (uint32_t i = 0; i < dev->mDisplays.size(); i++) event_cnt[i] = display[i]->mUpdateEventCnt; /* @@ -273,7 +274,7 @@ void *ExynosDevice::dynamicRecompositionThreadLoop(void *data) * If all other conditions are met, mode will be switched to 3D composition. */ usleep(100000); - for (uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) { + for (uint32_t i = 0; i < dev->mDisplays.size(); i++) { if (display[i]->mDREnable && display[i]->mPlugState == true && event_cnt[i] == display[i]->mUpdateEventCnt) { @@ -297,26 +298,20 @@ void *ExynosDevice::dynamicRecompositionThreadLoop(void *data) * @return ExynosDisplay */ ExynosDisplay* ExynosDevice::getDisplay(uint32_t display) { - uint32_t physical_display_num = HWC_NUM_DISPLAY_TYPES - 1; - if (mDisplays.isEmpty()) { ALOGE("mDisplays.size(%zu), requested display(%d)", mDisplays.size(), display); return NULL; } - if ((display <= physical_display_num) && (mDisplays[display]->mDisplayId == display)) { - return (ExynosDisplay*)mDisplays[display]; - } else { - for (size_t i = (physical_display_num + 1); i < mDisplays.size(); i++) { - if (mDisplays[i]->mDisplayId == display) { - return (ExynosDisplay*)mDisplays[i]; - } - } + for (size_t i = 0;i < mDisplays.size(); i++) { + if (mDisplays[i]->mDisplayId == display) + return (ExynosDisplay*)mDisplays[i]; } ALOGE("mDisplays.size(%zu), requested display(%d)", mDisplays.size(), display); + return NULL; } @@ -340,17 +335,11 @@ int32_t ExynosDevice::destroyVirtualDisplay(ExynosDisplay* display) { } void ExynosDevice::dump(uint32_t *outSize, char *outBuffer) { - /* TODO : Dump here */ - if (outSize == NULL) { ALOGE("%s:: outSize is null", __func__); return; } - ExynosDisplay *display = mDisplays[HWC_DISPLAY_PRIMARY]; - ExynosDisplay *external_display = mDisplays[HWC_DISPLAY_EXTERNAL]; - ExynosDisplay *virtual_display = mDisplays[HWC_DISPLAY_VIRTUAL]; - android::String8 result; result.append("\n\n"); @@ -382,14 +371,10 @@ void ExynosDevice::dump(uint32_t *outSize, char *outBuffer) { result.appendFormat("\n"); mResourceManager->dump(result); - display->dump(result); - - if (external_display->mPlugState == true) { - external_display->dump(result); - } - - if (virtual_display->mPlugState == true) { - virtual_display->dump(result); + for (size_t i = 0;i < mDisplays.size(); i++) { + ExynosDisplay *display = mDisplays[i]; + if (display->mPlugState == true) + display->dump(result); } if (outBuffer == NULL) { @@ -431,7 +416,7 @@ int32_t ExynosDevice::registerCallback ( HWC2_PFN_HOTPLUG callbackFunc = (HWC2_PFN_HOTPLUG)mCallbackInfos[descriptor].funcPointer; if (callbackFunc != NULL) - callbackFunc(callbackData, HWC_DISPLAY_PRIMARY, HWC2_CONNECTION_CONNECTED); + callbackFunc(callbackData, getDisplayId(HWC_DISPLAY_PRIMARY, 0), HWC2_CONNECTION_CONNECTED); } if (descriptor == HWC2_CALLBACK_VSYNC) @@ -446,7 +431,7 @@ void ExynosDevice::invalidate() (HWC2_PFN_REFRESH)mCallbackInfos[HWC2_CALLBACK_REFRESH].funcPointer; if (callbackFunc != NULL) callbackFunc(mCallbackInfos[HWC2_CALLBACK_REFRESH].callbackData, - HWC_DISPLAY_PRIMARY); + getDisplayId(HWC_DISPLAY_PRIMARY, 0)); else ALOGE("%s:: refresh callback is not registered", __func__); @@ -633,31 +618,34 @@ void ExynosDevice::setDynamicRecomposition(unsigned int on) exynosHWCControl.useDynamicRecomp = on; } -uint32_t ExynosDevice::checkConnection(uint32_t display) +bool ExynosDevice::checkDisplayConnection(uint32_t displayId) { - int ret = 0; - ExynosExternalDisplay *external_display = (ExynosExternalDisplay *)mDisplays[HWC_DISPLAY_EXTERNAL]; - ExynosVirtualDisplay *virtual_display = NULL; - virtual_display = (ExynosVirtualDisplay *)mDisplays[HWC_DISPLAY_VIRTUAL]; - - switch(display) { - case HWC_DISPLAY_PRIMARY: - return 1; - case HWC_DISPLAY_EXTERNAL: - if (external_display->mPlugState) - return 1; - else - return 0; - case HWC_DISPLAY_VIRTUAL: - if (virtual_display->mPlugState) - return 1; - else - return 0; - default: - return 0; + ExynosDisplay *display = getDisplay(displayId); + + if (!display) + return false; + else + return display->mPlugState; +} + +bool ExynosDevice::checkAdditionalConnection() +{ + for (uint32_t i = 0; i < mDisplays.size(); i++) { + switch(mDisplays[i]->mType) { + case HWC_DISPLAY_PRIMARY: + break; + case HWC_DISPLAY_EXTERNAL: + case HWC_DISPLAY_VIRTUAL: + if (mDisplays[i]->mPlugState) + return true; + break; + default: + break; + } } - return ret; + return false; } + void ExynosDevice::getCapabilities(uint32_t *outCount, int32_t* outCapabilities) { uint32_t capabilityNum = 0; @@ -721,12 +709,12 @@ bool ExynosDevice::canSkipValidate() if ((ret = mDisplays[i]->canSkipValidate()) != NO_ERROR) { HDEBUGLOGD(eDebugSkipValidate, "Display[%d] can't skip validate (%d), renderingState(%d), geometryChanged(0x%" PRIx64 ")", - mDisplays[i]->mType, ret, + mDisplays[i]->mDisplayId, ret, mDisplays[i]->mRenderingState, mGeometryChanged); return false; } else { HDEBUGLOGD(eDebugSkipValidate, "Display[%d] can skip validate (%d), renderingState(%d), geometryChanged(0x%" PRIx64 ")", - mDisplays[i]->mType, ret, + mDisplays[i]->mDisplayId, ret, mDisplays[i]->mRenderingState, mGeometryChanged); } } @@ -765,24 +753,23 @@ bool ExynosDevice::validateFences(ExynosDisplay *display) { } void ExynosDevice::compareVsyncPeriod() { + ExynosDisplay *primary_display = getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); + ExynosDisplay *external_display = getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); - ExynosDisplay *primary_display = mDisplays[HWC_DISPLAY_PRIMARY]; - ExynosDisplay *external_display = mDisplays[HWC_DISPLAY_EXTERNAL]; - - mVsyncDisplay = HWC_DISPLAY_PRIMARY; + mVsyncDisplayId = getDisplayId(HWC_DISPLAY_PRIMARY, 0); if (external_display->mPowerModeState == HWC2_POWER_MODE_OFF) { return; } else if (primary_display->mPowerModeState == HWC2_POWER_MODE_OFF) { - mVsyncDisplay = HWC_DISPLAY_EXTERNAL; + mVsyncDisplayId = getDisplayId(HWC_DISPLAY_EXTERNAL, 0); return; } else if (((primary_display->mPowerModeState == HWC2_POWER_MODE_DOZE) || (primary_display->mPowerModeState == HWC2_POWER_MODE_DOZE_SUSPEND)) && (external_display->mVsyncPeriod >= DOZE_VSYNC_PERIOD)) { /*30fps*/ - mVsyncDisplay = HWC_DISPLAY_EXTERNAL; + mVsyncDisplayId = getDisplayId(HWC_DISPLAY_EXTERNAL, 0); return; } else if (primary_display->mVsyncPeriod <= external_display->mVsyncPeriod) { - mVsyncDisplay = HWC_DISPLAY_EXTERNAL; + mVsyncDisplayId = getDisplayId(HWC_DISPLAY_EXTERNAL, 0); return; } diff --git a/libhwc2.1/libdevice/ExynosDevice.h b/libhwc2.1/libdevice/ExynosDevice.h index 7e869cb..bdea729 100644 --- a/libhwc2.1/libdevice/ExynosDevice.h +++ b/libhwc2.1/libdevice/ExynosDevice.h @@ -189,7 +189,12 @@ class ExynosDevice { */ int mVsyncFd; int mExtVsyncFd; - int mVsyncDisplay; + + /** + * mDisplayId of display that has the slowest fps. + * HWC uses vsync of display that has the slowest fps to main vsync. + */ + uint32_t mVsyncDisplayId; uint64_t mTimestamp; uint32_t mDisplayMode; @@ -276,7 +281,8 @@ class ExynosDevice { void getHWCFenceDebug(); void setHWCControl(uint32_t display, uint32_t ctrl, int32_t val); void setDisplayMode(uint32_t displayMode); - uint32_t checkConnection(uint32_t display); + bool checkDisplayConnection(uint32_t displayId); + bool checkAdditionalConnection(); void getCapabilities(uint32_t *outCount, int32_t* outCapabilities); void setGeometryChanged(uint64_t changedBit) { mGeometryChanged|= changedBit;}; void clearGeometryChanged(); diff --git a/libhwc2.1/libdevice/ExynosDisplay.cpp b/libhwc2.1/libdevice/ExynosDisplay.cpp index a156441..f565a36 100644 --- a/libhwc2.1/libdevice/ExynosDisplay.cpp +++ b/libhwc2.1/libdevice/ExynosDisplay.cpp @@ -306,70 +306,69 @@ String8 ExynosCompositionInfo::getTypeStr() } } -ExynosDisplay::ExynosDisplay(uint32_t type, ExynosDevice* device) - : mType(type), - mXres(1440), - mYres(2960), - mXdpi(25400), - mYdpi(25400), - mVsyncPeriod(16666666), - mIdleHint(this), - mDevice(device), - mDisplayId(HWC_DISPLAY_PRIMARY), - mDisplayName(android::String8("PrimaryDisplay")), - mPlugState(false), - mHasSingleBuffer(false), - mResourceManager(NULL), - mClientCompositionInfo(COMPOSITION_CLIENT), - mExynosCompositionInfo(COMPOSITION_EXYNOS), - mGeometryChanged(0x0), - mRenderingState(RENDERING_STATE_NONE), - mHWCRenderingState(RENDERING_STATE_NONE), - mDisplayBW(0), - mDynamicReCompMode(NO_MODE_SWITCH), - mDREnable(false), - mDRDefault(false), - mLastFpsTime(0), - mFrameCount(0), - mLastFrameCount(0), - mErrorFrameCount(0), - mUpdateEventCnt(0), - mUpdateCallCnt(0), - mDefaultDMA(MAX_DECON_DMA_TYPE), - mLastRetireFence(-1), - mWindowNumUsed(0), - mBaseWindowIndex(0), - mNumMaxPriorityAllowed(1), - mCursorIndex(-1), - mColorTransformHint(HAL_COLOR_TRANSFORM_IDENTITY), - mMaxLuminance(0), - mMaxAverageLuminance(0), - mMinLuminance(0), - mHWC1LayerList(NULL), - /* Support DDI scalser */ - mOldScalerMode(0), - mNewScaledWidth(0), - mNewScaledHeight(0), - mDeviceXres(0), - mDeviceYres(0), - mColorMode(HAL_COLOR_MODE_NATIVE), - mSkipFrame(false), - mBrightnessFd(NULL), - mMaxBrightness(0), - mVsyncPeriodChangeConstraints{systemTime(SYSTEM_TIME_MONOTONIC), 0}, - mVsyncAppliedTimeLine{false, 0, systemTime(SYSTEM_TIME_MONOTONIC)}, - mConfigRequestState(hwc_request_state_t::SET_CONFIG_STATE_NONE), - mPowerHalExtAidl(nullptr), - mRestorePrevFpsHint(false) { +ExynosDisplay::ExynosDisplay(uint32_t index, ExynosDevice *device) +: mDisplayId(HWC_DISPLAY_PRIMARY), + mType(HWC_DISPLAY_PRIMARY), + mIndex(index), + mXres(1440), + mYres(2960), + mXdpi(25400), + mYdpi(25400), + mVsyncPeriod(16666666), + mIdleHint(this), + mDevice(device), + mDisplayName(android::String8("PrimaryDisplay")), + mPlugState(false), + mHasSingleBuffer(false), + mResourceManager(NULL), + mClientCompositionInfo(COMPOSITION_CLIENT), + mExynosCompositionInfo(COMPOSITION_EXYNOS), + mGeometryChanged(0x0), + mRenderingState(RENDERING_STATE_NONE), + mHWCRenderingState(RENDERING_STATE_NONE), + mDisplayBW(0), + mDynamicReCompMode(NO_MODE_SWITCH), + mDREnable(false), + mDRDefault(false), + mLastFpsTime(0), + mFrameCount(0), + mLastFrameCount(0), + mErrorFrameCount(0), + mUpdateEventCnt(0), + mUpdateCallCnt(0), + mDefaultDMA(MAX_DECON_DMA_TYPE), + mLastRetireFence(-1), + mWindowNumUsed(0), + mBaseWindowIndex(0), + mNumMaxPriorityAllowed(1), + mCursorIndex(-1), + mColorTransformHint(HAL_COLOR_TRANSFORM_IDENTITY), + mMaxLuminance(0), + mMaxAverageLuminance(0), + mMinLuminance(0), + mHWC1LayerList(NULL), + /* Support DDI scalser */ + mOldScalerMode(0), + mNewScaledWidth(0), + mNewScaledHeight(0), + mDeviceXres(0), + mDeviceYres(0), + mColorMode(HAL_COLOR_MODE_NATIVE), + mSkipFrame(false), + mBrightnessFd(NULL), + mMaxBrightness(0), + mVsyncPeriodChangeConstraints{systemTime(SYSTEM_TIME_MONOTONIC), 0}, + mVsyncAppliedTimeLine{false, 0, systemTime(SYSTEM_TIME_MONOTONIC)}, + mConfigRequestState(hwc_request_state_t::SET_CONFIG_STATE_NONE), + mPowerHalExtAidl(nullptr), + mRestorePrevFpsHint(false) +{ mDisplayControl.enableCompositionCrop = true; mDisplayControl.enableExynosCompositionOptimization = true; mDisplayControl.enableClientCompositionOptimization = true; mDisplayControl.useMaxG2DSrc = false; mDisplayControl.handleLowFpsLayers = false; - if (mType == HWC_DISPLAY_VIRTUAL) - mDisplayControl.earlyStartMPP = false; - else - mDisplayControl.earlyStartMPP = true; + mDisplayControl.earlyStartMPP = true; mDisplayControl.adjustDisplayFrame = false; mDisplayControl.cursorSupport = false; @@ -415,7 +414,7 @@ bool ExynosDisplay::comparePreferedLayers() { return false; } -int ExynosDisplay::getDisplayId() { +int ExynosDisplay::getId() { return mDisplayId; } @@ -616,7 +615,7 @@ void ExynosDisplay::doPreProcessing() { * mCompositionType is HWC2_COMPOSITION_CLIENT * HWC should not change compositionType if it is HWC2_COMPOSITION_CLIENT */ - if (mDisplayId != HWC_DISPLAY_VIRTUAL) + if (mType != HWC_DISPLAY_VIRTUAL) mClientCompositionInfo.mEnableSkipStatic = skipStaticLayers; if (mHasSingleBuffer != hasSingleBuffer) { @@ -647,8 +646,7 @@ void ExynosDisplay::doPreProcessing() { setGeometryChanged(GEOMETRY_DEVICE_SCENARIO_CHANGED); } #ifndef HWC_SKIP_VALIDATE - if (mDevice->checkConnection(HWC_DISPLAY_EXTERNAL) || - mDevice->checkConnection(HWC_DISPLAY_VIRTUAL)) { + if (mDevice->checkAdditionalConnection()) { /* Set any flag to mGeometryChanged */ mDevice->mGeometryChanged = 0x10; } @@ -1925,9 +1923,7 @@ bool ExynosDisplay::checkConfigChanged(const exynos_dpu_data &lastConfigsData, c return true; /* HWC doesn't skip WIN_CONFIG if other display is connected */ - if (((mDevice->checkConnection(HWC_DISPLAY_EXTERNAL) == 1) || - (mDevice->checkConnection(HWC_DISPLAY_VIRTUAL) == 1)) && - (mDisplayId == HWC_DISPLAY_PRIMARY)) + if ((mDevice->checkAdditionalConnection()) && (mType == HWC_DISPLAY_PRIMARY)) return true; for (size_t i = 0; i < lastConfigsData.configs.size(); i++) { @@ -2102,7 +2098,7 @@ int ExynosDisplay::setReleaseFences() { continue; } } - if (mDisplayId == HWC_DISPLAY_VIRTUAL) + if (mType == HWC_DISPLAY_VIRTUAL) mLayers[i]->mReleaseFence = -1; else mLayers[i]->mReleaseFence = @@ -2783,7 +2779,7 @@ int32_t ExynosDisplay::presentDisplay(int32_t* outRetireFence) { } if ((mLayers.size() == 0) && - (mDisplayId != HWC_DISPLAY_VIRTUAL)) { + (mType != HWC_DISPLAY_VIRTUAL)) { clearDisplay(mDpuData.enable_readback); *outRetireFence = -1; mLastRetireFence = fence_close(mLastRetireFence, this, @@ -3556,7 +3552,7 @@ int32_t ExynosDisplay::updateVsyncAppliedTimeLine(int64_t actualChangeTime) mVsyncAppliedTimeLine.newVsyncAppliedTimeNanos); if (vsync_callbackFunc != nullptr) - vsync_callbackFunc(vsync_callbackData, getDisplayId(), + vsync_callbackFunc(vsync_callbackData, getId(), &mVsyncAppliedTimeLine); else { ALOGD("callback function is null"); diff --git a/libhwc2.1/libdevice/ExynosDisplay.h b/libhwc2.1/libdevice/ExynosDisplay.h index 0d4418b..9f28728 100644 --- a/libhwc2.1/libdevice/ExynosDisplay.h +++ b/libhwc2.1/libdevice/ExynosDisplay.h @@ -353,8 +353,9 @@ typedef struct brightnessState { class ExynosDisplay { public: - + uint32_t mDisplayId; uint32_t mType; + uint32_t mIndex; uint32_t mXres; uint32_t mYres; uint32_t mXdpi; @@ -365,7 +366,7 @@ class ExynosDisplay { int mPsrMode; /* Constructor */ - ExynosDisplay(uint32_t type, ExynosDevice *device); + ExynosDisplay(uint32_t index, ExynosDevice *device); /* Destructor */ virtual ~ExynosDisplay(); @@ -388,7 +389,6 @@ class ExynosDisplay { ExynosDevice *mDevice; - uint32_t mDisplayId; String8 mDisplayName; Mutex mDisplayMutex; @@ -534,7 +534,7 @@ class ExynosDisplay { void initDisplay(); - int getDisplayId(); + int getId(); Mutex& getDisplayMutex() {return mDisplayMutex; }; int32_t setCompositionTargetExynosImage(uint32_t targetType, exynos_image *src_img, exynos_image *dst_img); diff --git a/libhwc2.1/libdevice/ExynosLayer.cpp b/libhwc2.1/libdevice/ExynosLayer.cpp index a8db137..e3aeec4 100644 --- a/libhwc2.1/libdevice/ExynosLayer.cpp +++ b/libhwc2.1/libdevice/ExynosLayer.cpp @@ -452,7 +452,7 @@ int32_t ExynosLayer::setLayerCompositionType(int32_t /*hwc2_composition_t*/ type // FIXME: HWC2_COMPOSITION_SCREENSHOT is not defined in AOSP // HWC guys should fix this. #if 0 - if (mDisplay->mDisplayId == HWC_DISPLAY_PRIMARY) + if (mDisplay->mType == HWC_DISPLAY_PRIMARY) if (type == HWC2_COMPOSITION_SCREENSHOT) type = HWC2_COMPOSITION_DEVICE; #endif diff --git a/libhwc2.1/libdisplayinterface/ExynosDeviceDrmInterface.cpp b/libhwc2.1/libdisplayinterface/ExynosDeviceDrmInterface.cpp index 992ff4b..4ca3e8d 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDeviceDrmInterface.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDeviceDrmInterface.cpp @@ -86,12 +86,12 @@ void ExynosDeviceDrmInterface::init(ExynosDevice *exynosDevice) mExynosDrmEventHandler.init(mExynosDevice); mDrmDevice->event_listener()->RegisterHotplugHandler(static_cast<DrmEventHandler *>(&mExynosDrmEventHandler)); - ExynosDisplay *primaryDisplay = mExynosDevice->getDisplay(HWC_DISPLAY_PRIMARY); + ExynosDisplay *primaryDisplay = mExynosDevice->getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); if (primaryDisplay != NULL) { ExynosDisplayDrmInterface *displayInterface = static_cast<ExynosDisplayDrmInterface*>(primaryDisplay->mDisplayInterface.get()); displayInterface->initDrmDevice(mDrmDevice); } - ExynosDisplay *externalDisplay = mExynosDevice->getDisplay(HWC_DISPLAY_EXTERNAL); + ExynosDisplay *externalDisplay = mExynosDevice->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); if (externalDisplay != NULL) { ExynosDisplayDrmInterface *displayInterface = static_cast<ExynosDisplayDrmInterface*>(externalDisplay->mDisplayInterface.get()); displayInterface->initDrmDevice(mDrmDevice); @@ -199,7 +199,8 @@ void ExynosDeviceDrmInterface::ExynosDrmEventHandler::init(ExynosDevice *exynosD void ExynosDeviceDrmInterface::ExynosDrmEventHandler::HandleEvent(uint64_t timestamp_us) { /* TODO: Check plug status hear or ExynosExternalDisplay::handleHotplugEvent() */ - ExynosExternalDisplayModule *display = static_cast<ExynosExternalDisplayModule*>(mExynosDevice->getDisplay(HWC_DISPLAY_EXTERNAL)); + ExynosExternalDisplayModule *display = + static_cast<ExynosExternalDisplayModule*>(mExynosDevice->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0))); if (display != NULL) display->handleHotplugEvent(); } diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp index 3369257..550e6fd 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp @@ -501,7 +501,7 @@ void ExynosDisplayDrmInterface::Callback( ExynosDevice *exynosDevice = mExynosDisplay->mDevice; exynosDevice->compareVsyncPeriod(); - if (exynosDevice->mVsyncDisplay == (int)mExynosDisplay->mDisplayId) { + if (exynosDevice->mVsyncDisplayId == mExynosDisplay->mDisplayId) { auto vsync_2_4CallbackInfo = exynosDevice->mCallbackInfos[HWC2_CALLBACK_VSYNC_2_4]; if (vsync_2_4CallbackInfo.funcPointer && vsync_2_4CallbackInfo.callbackData) { diff --git a/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.cpp b/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.cpp index e1796b2..c6364a7 100644 --- a/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.cpp +++ b/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.cpp @@ -28,11 +28,15 @@ #define SKIP_FRAME_COUNT 3 extern struct exynos_hwc_control exynosHWCControl; -ExynosExternalDisplay::ExynosExternalDisplay(uint32_t __unused type, ExynosDevice *device) - : ExynosDisplay(HWC_DISPLAY_EXTERNAL, device) +ExynosExternalDisplay::ExynosExternalDisplay(uint32_t index, ExynosDevice *device) + : ExynosDisplay(index, device) { DISPLAY_LOGD(eDebugExternalDisplay, ""); + mType = HWC_DISPLAY_EXTERNAL; + mIndex = index; + mDisplayId = getDisplayId(mType, mIndex); + mDisplayControl.cursorSupport = true; mEnabled = false; @@ -43,7 +47,6 @@ ExynosExternalDisplay::ExynosExternalDisplay(uint32_t __unused type, ExynosDevic mXdpi = 0; mYdpi = 0; mVsyncPeriod = 0; - mDisplayId = HWC_DISPLAY_EXTERNAL; mSkipStartFrame = 0; mSkipFrameCount = -1; mIsSkipFrame = false; @@ -151,7 +154,7 @@ void ExynosExternalDisplay::hotplug(){ HWC2_PFN_HOTPLUG callbackFunc = (HWC2_PFN_HOTPLUG)mDevice->mCallbackInfos[HWC2_CALLBACK_HOTPLUG].funcPointer; if (callbackData != NULL && callbackFunc != NULL) - callbackFunc(callbackData, HWC_DISPLAY_EXTERNAL, mHpdStatus ? HWC2_CONNECTION_CONNECTED : HWC2_CONNECTION_DISCONNECTED); + callbackFunc(callbackData, mDisplayId, mHpdStatus ? HWC2_CONNECTION_CONNECTED : HWC2_CONNECTION_DISCONNECTED); } bool ExynosExternalDisplay::handleRotate() diff --git a/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.h b/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.h index 19cf40c..199ef4d 100644 --- a/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.h +++ b/libhwc2.1/libexternaldisplay/ExynosExternalDisplay.h @@ -28,7 +28,7 @@ class ExynosExternalDisplay : public ExynosDisplay { hwc2_config_t mActiveConfigIndex; /* Methods */ - ExynosExternalDisplay(uint32_t type, ExynosDevice *device); + ExynosExternalDisplay(uint32_t index, ExynosDevice *device); ~ExynosExternalDisplay(); virtual void init(); diff --git a/libhwc2.1/libhwcService/ExynosHWCService.cpp b/libhwc2.1/libhwcService/ExynosHWCService.cpp index 4310f1d..a8d5fa0 100644 --- a/libhwc2.1/libhwcService/ExynosHWCService.cpp +++ b/libhwc2.1/libhwcService/ExynosHWCService.cpp @@ -180,7 +180,7 @@ int ExynosHWCService::getExternalDisplayConfigs() ALOGD_IF(HWC_SERVICE_DEBUG, "%s", __func__); ExynosExternalDisplay *external_display = - (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(HWC_DISPLAY_EXTERNAL); + (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); if (external_display->mHpdStatus == true) { external_display->mDisplayInterface->dumpDisplayConfigs(); @@ -194,7 +194,7 @@ int ExynosHWCService::setExternalDisplayConfig(unsigned int index) ALOGD_IF(HWC_SERVICE_DEBUG, "%s::config=%d", __func__, index); ExynosExternalDisplay *external_display = - (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(HWC_DISPLAY_EXTERNAL); + (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); if (external_display->mHpdStatus == true) { external_display->setActiveConfig(index); @@ -207,9 +207,9 @@ int ExynosHWCService::setExternalVsyncEnabled(unsigned int index) { ALOGD_IF(HWC_SERVICE_DEBUG, "%s::config=%d", __func__, index); - mHWCCtx->device->mVsyncDisplay = index; + mHWCCtx->device->mVsyncDisplayId = index; ExynosExternalDisplay *external_display = - (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(HWC_DISPLAY_EXTERNAL); + (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); external_display->setVsyncEnabled(index); return NO_ERROR; @@ -220,7 +220,7 @@ int ExynosHWCService::getExternalHdrCapabilities() ALOGD_IF(HWC_SERVICE_DEBUG, "%s", __func__); ExynosExternalDisplay *external_display = - (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(HWC_DISPLAY_EXTERNAL); + (ExynosExternalDisplay *)mHWCCtx->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); return external_display->mExternalHdrSupported; } @@ -319,7 +319,7 @@ int ExynosHWCService::setDDIScaler(uint32_t width, uint32_t height) { ALOGD_IF(HWC_SERVICE_DEBUG, "%s, width=%d, height=%d", __func__, width, height); if (mHWCCtx) { - ExynosDisplay *display = (ExynosDisplay*)mHWCCtx->device->getDisplay(HWC_DISPLAY_PRIMARY); + ExynosDisplay *display = (ExynosDisplay*)mHWCCtx->device->getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); if (display == NULL) return -EINVAL; diff --git a/libhwc2.1/libhwchelper/ExynosHWCHelper.cpp b/libhwc2.1/libhwchelper/ExynosHWCHelper.cpp index e10f2ef..b6b3e17 100644 --- a/libhwc2.1/libhwchelper/ExynosHWCHelper.cpp +++ b/libhwc2.1/libhwchelper/ExynosHWCHelper.cpp @@ -1253,3 +1253,7 @@ int32_t writeIntToFile(const char* file, uint32_t value) { fclose(fd); return 0; } + +uint32_t getDisplayId(int32_t displayType, int32_t displayIndex) { + return (displayType << DISPLAYID_MASK_LEN) | displayIndex; +} diff --git a/libhwc2.1/libhwchelper/ExynosHWCHelper.h b/libhwc2.1/libhwchelper/ExynosHWCHelper.h index 6eab7b3..0995a11 100644 --- a/libhwc2.1/libhwchelper/ExynosHWCHelper.h +++ b/libhwc2.1/libhwchelper/ExynosHWCHelper.h @@ -57,6 +57,8 @@ #define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') #endif +#define DISPLAYID_MASK_LEN 8 + template<typename T> inline T max(T a, T b) { return (a > b) ? a : b; } template<typename T> inline T min(T a, T b) { return (a < b) ? a : b; } @@ -567,4 +569,5 @@ private: void writeFileNode(FILE *fd, int value); int32_t writeIntToFile(const char *file, uint32_t value); +uint32_t getDisplayId(int32_t displayType, int32_t displayIndex = 0); #endif diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp index 2a5ad44..0c73e69 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp @@ -62,14 +62,16 @@ static std::string loadPanelGammaCalibration(const std::string &file) { return gamma; } -ExynosPrimaryDisplay::ExynosPrimaryDisplay(uint32_t __unused type, ExynosDevice *device) - : ExynosDisplay(HWC_DISPLAY_PRIMARY, device) +ExynosPrimaryDisplay::ExynosPrimaryDisplay(uint32_t index, ExynosDevice *device) + : ExynosDisplay(index, device) { // TODO : Hard coded here mNumMaxPriorityAllowed = 5; /* Initialization */ - mDisplayId = HWC_DISPLAY_PRIMARY; + mType = HWC_DISPLAY_PRIMARY; + mIndex = index; + mDisplayId = getDisplayId(mType, mIndex); mDisplayName = android::String8("PrimaryDisplay"); // Prepare multi resolution diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h index 2bdd180..61afcb7 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h @@ -25,7 +25,7 @@ class ExynosMPPModule; class ExynosPrimaryDisplay : public ExynosDisplay { public: /* Methods */ - ExynosPrimaryDisplay(uint32_t type, ExynosDevice *device); + ExynosPrimaryDisplay(uint32_t index, ExynosDevice *device); ~ExynosPrimaryDisplay(); virtual void setDDIScalerEnable(int width, int height); virtual int getDDIScalerMode(int width, int height); diff --git a/libhwc2.1/libresource/ExynosMPP.cpp b/libhwc2.1/libresource/ExynosMPP.cpp index ee6c4df..9562526 100644 --- a/libhwc2.1/libresource/ExynosMPP.cpp +++ b/libhwc2.1/libresource/ExynosMPP.cpp @@ -2212,10 +2212,10 @@ int32_t ExynosMPP::resetAssignedState(ExynosMPPSource *mppSource) return NO_ERROR; } -int32_t ExynosMPP::reserveMPP(int32_t displayType) +int32_t ExynosMPP::reserveMPP(int32_t displayId) { mAssignedState |= MPP_ASSIGN_STATE_RESERVED; - mReservedDisplay = displayType; + mReservedDisplay = displayId; return NO_ERROR; } @@ -2319,7 +2319,7 @@ bool ExynosMPP::isAssignableState(ExynosDisplay *display, struct exynos_image &s if ((mAssignedState & MPP_ASSIGN_STATE_ASSIGNED) && (mAssignedState & MPP_ASSIGN_STATE_RESERVED)) { - if (mReservedDisplay == (int32_t)display->mType) { + if (mReservedDisplay == (int32_t)display->getId()) { if (mAssignedSources.size() < getSrcMaxBlendingNum(src, dst)) isAssignable = true; else @@ -2333,7 +2333,7 @@ bool ExynosMPP::isAssignableState(ExynosDisplay *display, struct exynos_image &s else isAssignable = false; } else if (mAssignedState & MPP_ASSIGN_STATE_RESERVED) { - if (mReservedDisplay == (int32_t)display->mType) + if (mReservedDisplay == (int32_t)display->getId()) isAssignable = true; else isAssignable = false; diff --git a/libhwc2.1/libresource/ExynosResourceManager.cpp b/libhwc2.1/libresource/ExynosResourceManager.cpp index 5f9a67b..7a5d26c 100644 --- a/libhwc2.1/libresource/ExynosResourceManager.cpp +++ b/libhwc2.1/libresource/ExynosResourceManager.cpp @@ -256,7 +256,7 @@ int32_t ExynosResourceManager::doPreProcessing() { int32_t ret = NO_ERROR; /* Assign m2mMPP's out buffers */ - ExynosDisplay *display = mDevice->getDisplay(HWC_DISPLAY_PRIMARY); + ExynosDisplay *display = mDevice->getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); if (display == NULL) return -EINVAL; ret = doAllocDstBufs(display->mXres, display->mYres); @@ -318,7 +318,7 @@ bool ExynosResourceManager::DstBufMgrThread::threadLoop() ExynosDevice *device = mExynosResourceManager->mDevice; if (device == NULL) return false; - ExynosDisplay *display = device->getDisplay(HWC_DISPLAY_PRIMARY); + ExynosDisplay *display = device->getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); if (display == NULL) return false; @@ -378,8 +378,8 @@ int32_t ExynosResourceManager::checkScenario(ExynosDisplay __unused *display) mResourceReserved = 0x0; /* Check whether camera preview is running */ ExynosDisplay *exynosDisplay = NULL; - for (uint32_t display_type = 0; display_type < HWC_NUM_DISPLAY_TYPES; display_type++) { - exynosDisplay = mDevice->getDisplay(display_type); + for (uint32_t i = 0; i < mDevice->mDisplays.size(); i++) { + exynosDisplay = mDevice->mDisplays[i]; if ((exynosDisplay != NULL) && (exynosDisplay->mPlugState == true)) { for (uint32_t i = 0; i < exynosDisplay->mLayers.size(); i++) { ExynosLayer *layer = exynosDisplay->mLayers[i]; @@ -1083,7 +1083,7 @@ int32_t ExynosResourceManager::validateLayer(uint32_t index, ExynosDisplay *disp return eDynamicRecomposition; if ((layer->mLayerBuffer != NULL) && - (display->mDisplayId == HWC_DISPLAY_PRIMARY) && + (display->mDisplayId == getDisplayId(HWC_DISPLAY_PRIMARY, 0)) && (mForceReallocState != DST_REALLOC_DONE)) { ALOGI("Device type assign skipping by dst reallocation...... "); return eReallocOnGoingForDDI; @@ -1112,7 +1112,7 @@ int32_t ExynosResourceManager::validateLayer(uint32_t index, ExynosDisplay *disp return eDimLayer; } - if (!(display->mDisplayId == HWC_DISPLAY_VIRTUAL && + if (!(display->mType == HWC_DISPLAY_VIRTUAL && ((ExynosVirtualDisplay *)display)->mIsWFDState == (int)LLWFD)) if (layer->mLayerBuffer == NULL) @@ -1305,7 +1305,8 @@ int32_t ExynosResourceManager::getCandidateM2mMPPOutImages(ExynosDisplay *displa dst_img.format = DEFAULT_MPP_DST_YUV_FORMAT; } - ExynosExternalDisplay *external_display = (ExynosExternalDisplay*)mDevice->getDisplay(HWC_DISPLAY_EXTERNAL); + ExynosExternalDisplay *external_display = + (ExynosExternalDisplay*)mDevice->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0)); /* For HDR through MSC or G2D case but dataspace is not changed */ if (hasHdrInfo(src_img)) { @@ -1324,7 +1325,7 @@ int32_t ExynosResourceManager::getCandidateM2mMPPOutImages(ExynosDisplay *displa */ if (hasHdr10Plus(dst_img) || ((external_display != NULL) && (external_display->mPlugState) && - (display->mDisplayId == HWC_DISPLAY_PRIMARY))) { + (display->mType == HWC_DISPLAY_PRIMARY))) { ExynosMPP *otfMppForHDRPlus = nullptr; auto mpp_it = std::find_if(mOtfMPPs.begin(), mOtfMPPs.end(), [](auto m) { @@ -1363,7 +1364,7 @@ int32_t ExynosResourceManager::getCandidateM2mMPPOutImages(ExynosDisplay *displa isHdrExternal = true; } - if (isHdrExternal && (display->mDisplayId == HWC_DISPLAY_EXTERNAL)) { + if (isHdrExternal && (display->mType == HWC_DISPLAY_EXTERNAL)) { dst_img.format = HAL_PIXEL_FORMAT_RGBA_1010102; dst_img.dataSpace = src_img.dataSpace; } else { @@ -1386,7 +1387,7 @@ int32_t ExynosResourceManager::getCandidateM2mMPPOutImages(ExynosDisplay *displa * if external display is connected * because G2D is used only for HDR on exernal display */ - if (!(isExternalPlugged && (display->mDisplayId == HWC_DISPLAY_PRIMARY))) { + if (!(isExternalPlugged && (display->mType == HWC_DISPLAY_PRIMARY))) { image_lists.push_back(dst_img); } } @@ -1885,14 +1886,15 @@ int32_t ExynosResourceManager::preAssignResources() HDEBUGLOGD(eDebugResourceManager, "\t%s check, dispMode(%d), 0x%8x", mOtfMPPs[i]->mName.string(), displayMode, mOtfMPPs[i]->mPreAssignDisplayList[displayMode]); ExynosDisplay *display = NULL; - for (uint32_t display_type = 0; display_type < HWC_NUM_DISPLAY_TYPES; display_type++) { - HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay_type(%d), checkBit(%d)", display_type, (mOtfMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<display_type))); - if (mOtfMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<display_type)) { - display = mDevice->getDisplay(display_type); - HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay_type(%d), display(%p)", display_type, display); + for (size_t j = 0; j < mDevice->mDisplays.size(); j++) { + display = mDevice->mDisplays[j]; + int checkBit = mOtfMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<(display->mType)); + HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay index(%zu), checkBit(%d)", j, checkBit); + if (checkBit) { + HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay index(%zu), displayId(%d), display(%p)", j, display->mDisplayId, display); if ((display != NULL) && (display->mPlugState == true)) { - HDEBUGLOGD(eDebugResourceManager, "\t\treserve to display %d", display_type); - mOtfMPPs[i]->reserveMPP(display->mType); + HDEBUGLOGD(eDebugResourceManager, "\t\treserve to display %d", display->mDisplayId); + mOtfMPPs[i]->reserveMPP(display->mDisplayId); break; } } @@ -1914,14 +1916,15 @@ int32_t ExynosResourceManager::preAssignResources() HDEBUGLOGD(eDebugResourceManager, "\t%s check, 0x%8x", mM2mMPPs[i]->mName.string(), mM2mMPPs[i]->mPreAssignDisplayList[displayMode]); if (mM2mMPPs[i]->mPreAssignDisplayList[displayMode] != 0) { ExynosDisplay *display = NULL; - for (uint32_t display_type = HWC_DISPLAY_PRIMARY; display_type < HWC_NUM_DISPLAY_TYPES; display_type++) { - HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay_type(%d), checkBit(%d)", display_type, (mM2mMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<display_type))); - if (mM2mMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<display_type)) { - display = mDevice->getDisplay(display_type); - HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay_type(%d), display(%p)", display_type, display); + for (size_t j = 0; j < mDevice->mDisplays.size(); j++) { + display = mDevice->mDisplays[j]; + int checkBit = mM2mMPPs[i]->mPreAssignDisplayList[displayMode] & (1<<(display->mType)); + HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay index(%zu), checkBit(%d)", j, checkBit); + if (checkBit) { + HDEBUGLOGD(eDebugResourceManager, "\t\tdisplay index(%zu), displayId(%d), display(%p)", j, display->mDisplayId, display); if ((display != NULL) && (display->mPlugState == true)) { - HDEBUGLOGD(eDebugResourceManager, "\t\treserve to display %d", display->mType); - mM2mMPPs[i]->reserveMPP(display->mType); + HDEBUGLOGD(eDebugResourceManager, "\t\treserve to display %d", display->mDisplayId); + mM2mMPPs[i]->reserveMPP(display->mDisplayId); break; } else { HDEBUGLOGD(eDebugResourceManager, "\t\treserve without display"); @@ -1953,12 +1956,12 @@ void ExynosResourceManager::preAssignWindows() { ExynosDisplay *display = NULL; ExynosPrimaryDisplayModule *primaryDisplay = - (ExynosPrimaryDisplayModule *)mDevice->mDisplays[HWC_DISPLAY_PRIMARY]; + (ExynosPrimaryDisplayModule *)mDevice->getDisplay(getDisplayId(HWC_DISPLAY_PRIMARY, 0)); primaryDisplay->usePreDefinedWindow(false); - for (uint32_t display_type = 1; display_type < HWC_NUM_DISPLAY_TYPES; display_type++) { - display = mDevice->getDisplay(display_type); - if ((display == NULL) || (display->mDisplayId != HWC_DISPLAY_EXTERNAL)) + for (size_t i = 1; i < mDevice->mDisplays.size(); i++) { + display = mDevice->mDisplays[i]; + if ((display == NULL) || (display->mType != HWC_DISPLAY_EXTERNAL)) continue; if (display->mPlugState == true) { primaryDisplay->usePreDefinedWindow(true); diff --git a/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.cpp b/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.cpp index 0425966..c38f648 100644 --- a/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.cpp +++ b/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.cpp @@ -28,13 +28,18 @@ using vendor::graphics::VendorGraphicBufferUsage; extern struct exynos_hwc_control exynosHWCControl; -ExynosVirtualDisplay::ExynosVirtualDisplay(uint32_t __unused type, ExynosDevice *device) - : ExynosDisplay(HWC_DISPLAY_VIRTUAL, device) +ExynosVirtualDisplay::ExynosVirtualDisplay(uint32_t index, ExynosDevice *device) + : ExynosDisplay(index, device) { /* Initialization */ - mDisplayId = HWC_DISPLAY_VIRTUAL; mDisplayName = android::String8("VirtualDisplay"); + mType = HWC_DISPLAY_VIRTUAL; + mIndex = index; + mDisplayId = getDisplayId(mType, mIndex); + + mDisplayControl.earlyStartMPP = false; + mOutputBufferAcquireFenceFd = -1; mOutputBufferReleaseFenceFd = -1; diff --git a/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.h b/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.h index 25aec8b..e33cebd 100644 --- a/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.h +++ b/libhwc2.1/libvirtualdisplay/ExynosVirtualDisplay.h @@ -46,7 +46,7 @@ public: COMPOSITION_MIXED = COMPOSITION_GLES | COMPOSITION_HWC }; - ExynosVirtualDisplay(uint32_t type, ExynosDevice *device); + ExynosVirtualDisplay(uint32_t index, ExynosDevice *device); ~ExynosVirtualDisplay(); void createVirtualDisplay(uint32_t width, uint32_t height, int32_t* format); |