diff options
-rw-r--r-- | libhwc2.1/libdevice/BrightnessController.cpp | 23 | ||||
-rw-r--r-- | libhwc2.1/libdevice/BrightnessController.h | 2 | ||||
-rw-r--r-- | libhwc2.1/libdevice/ExynosDisplay.cpp | 8 | ||||
-rw-r--r-- | libhwc2.1/libdevice/ExynosDisplay.h | 17 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp | 12 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp | 18 |
6 files changed, 39 insertions, 41 deletions
diff --git a/libhwc2.1/libdevice/BrightnessController.cpp b/libhwc2.1/libdevice/BrightnessController.cpp index 5b91786..497889a 100644 --- a/libhwc2.1/libdevice/BrightnessController.cpp +++ b/libhwc2.1/libdevice/BrightnessController.cpp @@ -713,23 +713,12 @@ int BrightnessController::checkSysfsStatus(const char* file, char buf[16]; String8 nodeName; - if (std::strstr(file, "%d")) { - nodeName.appendFormat(file, mPanelIndex); - } else if (std::strstr(file, "%s")) { - nodeName.appendFormat(file, mPanelIndex == 0 ? "primary" - : mPanelIndex == 1 ? "secondary" : "unknown"); - } else { - nodeName = file; - } + nodeName.appendFormat(file, mPanelIndex); UniqueFd fd = open(nodeName.string(), O_RDONLY); - if (fd.get() < 0) { - ALOGE("%s failed to open sysfs %s: %s", __func__, nodeName.c_str(), strerror(errno)); - return false; - } int size = read(fd.get(), buf, sizeof(buf)); if (size <= 0) { - ALOGE("%s failed to read from %s: %s", __func__, nodeName.c_str(), strerror(errno)); + ALOGE("%s failed to read from %s", __func__, kLocalHbmModeFileNode); return false; } @@ -756,7 +745,7 @@ int BrightnessController::checkSysfsStatus(const char* file, } int pollRet = poll(&pfd, 1, ns2ms(remainTimeNs)); if (pollRet == 0) { - ALOGW("%s poll %s timeout", __func__, nodeName.c_str()); + ALOGW("%s poll timeout", __func__); // time out ret = ETIMEDOUT; break; @@ -771,8 +760,7 @@ int BrightnessController::checkSysfsStatus(const char* file, val = std::string(buf, size - 1); if (std::find(expectedValue.begin(), expectedValue.end(), val) != expectedValue.end()) { - ret = OK; - break; + ret = 0; } else { std::string values; for (auto& s : expectedValue) { @@ -783,12 +771,13 @@ int BrightnessController::checkSysfsStatus(const char* file, } ALOGE("%s read %s expected %s after notified", __func__, val.c_str(), values.c_str()); + ret = EINVAL; } } else { ret = EIO; ALOGE("%s failed to read after notified %d", __func__, errno); - break; } + break; } else { if (errno == EAGAIN || errno == EINTR) { continue; diff --git a/libhwc2.1/libdevice/BrightnessController.h b/libhwc2.1/libdevice/BrightnessController.h index 8ce7c4d..9090689 100644 --- a/libhwc2.1/libdevice/BrightnessController.h +++ b/libhwc2.1/libdevice/BrightnessController.h @@ -217,8 +217,6 @@ public: "/sys/class/backlight/panel%d-backlight/local_hbm_mode"; static constexpr const char* kDimBrightnessFileNode = "/sys/class/backlight/panel%d-backlight/dim_brightness"; - static constexpr const char* kRefreshrateFileNode = - "/sys/devices/platform/exynos-drm/%s-panel/refresh_rate"; private: // sync brightness change for mixed composition when there is more than 50% luminance change. diff --git a/libhwc2.1/libdevice/ExynosDisplay.cpp b/libhwc2.1/libdevice/ExynosDisplay.cpp index b2e42b7..f6123ba 100644 --- a/libhwc2.1/libdevice/ExynosDisplay.cpp +++ b/libhwc2.1/libdevice/ExynosDisplay.cpp @@ -4257,6 +4257,14 @@ int32_t ExynosDisplay::resetConfigRequestStateLocked(hwc2_config_t config) { __func__, mConfigRequestState); mConfigRequestState = hwc_request_state_t::SET_CONFIG_STATE_DONE; updateAppliedActiveConfig(mActiveConfig, systemTime(SYSTEM_TIME_MONOTONIC)); + + std::lock_guard<std::mutex> lock(mPeakRefreshRateMutex); + bool isPeakRefreshRate = isCurrentPeakRefreshRate(); + DISPLAY_ATRACE_INT("isPeakRefreshRate", isPeakRefreshRate); + if (isPeakRefreshRate && mNotifyPeakRefreshRate) { + mPeakRefreshRateCondition.notify_one(); + mNotifyPeakRefreshRate = false; + } } return NO_ERROR; } diff --git a/libhwc2.1/libdevice/ExynosDisplay.h b/libhwc2.1/libdevice/ExynosDisplay.h index d743b92..760eeec 100644 --- a/libhwc2.1/libdevice/ExynosDisplay.h +++ b/libhwc2.1/libdevice/ExynosDisplay.h @@ -555,6 +555,10 @@ class ExynosDisplay { hwc2_config_t mActiveConfig = UINT_MAX; + bool mNotifyPeakRefreshRate = false; + std::mutex mPeakRefreshRateMutex; + std::condition_variable mPeakRefreshRateCondition; + void initDisplay(); int getId(); @@ -1274,10 +1278,11 @@ class ExynosDisplay { // is the hint session both enabled and supported bool usePowerHintSession(); - void setPeakRefreshRate(float rr) { mPeakRefreshRate = rr; } - float getPeakRefreshRate() { - float opRate = mOperationRateManager ? mOperationRateManager->getOperationRate() : 0; - return opRate ?: mPeakRefreshRate; + void setMinDisplayVsyncPeriod(uint32_t period) { mMinDisplayVsyncPeriod = period; } + + bool isCurrentPeakRefreshRate(void) { + return ((mConfigRequestState == hwc_request_state_t::SET_CONFIG_STATE_DONE) && + (mVsyncPeriod == mMinDisplayVsyncPeriod)); } // check if there are any dimmed layers @@ -1302,8 +1307,8 @@ class ExynosDisplay { static constexpr float kHdrFullScreen = 0.5; uint32_t mHdrFullScrenAreaThreshold; - // peak refresh rate - float mPeakRefreshRate = -1.0f; + // vsync period of peak refresh rate + uint32_t mMinDisplayVsyncPeriod; // track if the last frame is a mixed composition, to detect mixed // composition to non-mixed composition transition. diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp index e436663..dbb11bd 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp @@ -920,12 +920,11 @@ int32_t ExynosDisplayDrmInterface::getDisplayConfigs( /* key: (width<<32 | height) */ std::map<uint64_t, uint32_t> groupIds; uint32_t groupId = 0; - float peakRr = -1; + uint32_t min_vsync_period = UINT_MAX; for (const DrmMode &mode : mDrmConnector->modes()) { displayConfigs_t configs; - float rr = mode.v_refresh(); - configs.vsyncPeriod = nsecsPerSec / rr; + configs.vsyncPeriod = nsecsPerSec/ mode.v_refresh(); configs.width = mode.h_display(); configs.height = mode.v_display(); uint64_t key = ((uint64_t)configs.width<<32) | configs.height; @@ -942,15 +941,14 @@ int32_t ExynosDisplayDrmInterface::getDisplayConfigs( configs.Xdpi = mm_width ? (mode.h_display() * kUmPerInch) / mm_width : -1; // Dots per 1000 inches configs.Ydpi = mm_height ? (mode.v_display() * kUmPerInch) / mm_height : -1; - // find peak rr - if (rr > peakRr) - peakRr = rr; + // find min vsync period + if (configs.vsyncPeriod <= min_vsync_period) min_vsync_period = configs.vsyncPeriod; mExynosDisplay->mDisplayConfigs.insert(std::make_pair(mode.id(), configs)); ALOGD("config group(%d), w(%d), h(%d), vsync(%d), xdpi(%d), ydpi(%d)", configs.groupId, configs.width, configs.height, configs.vsyncPeriod, configs.Xdpi, configs.Ydpi); } - mExynosDisplay->setPeakRefreshRate(peakRr); + mExynosDisplay->setMinDisplayVsyncPeriod(min_vsync_period); } uint32_t num_modes = static_cast<uint32_t>(mDrmConnector->modes().size()); diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp index b82de6b..607463a 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp @@ -538,16 +538,16 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) { } } - float peak_rr = getPeakRefreshRate(); - if (enabled && peak_rr > 0) { + if (enabled) { ATRACE_NAME("wait for peak refresh rate"); - bool succ = mBrightnessController->checkSysfsStatus( - BrightnessController::kRefreshrateFileNode, - {std::to_string(std::lround(peak_rr))}, - ms2ns(kLhbmWaitForPeakRefreshRateMs)); - if (!succ) { - ALOGE("%s: check refresh rate sysfs node failed", __func__); - return -EINVAL; + std::unique_lock<std::mutex> lock(mPeakRefreshRateMutex); + mNotifyPeakRefreshRate = true; + if (!mPeakRefreshRateCondition.wait_for(lock, + std::chrono::milliseconds( + kLhbmWaitForPeakRefreshRateMs), + [this]() { return isCurrentPeakRefreshRate(); })) { + ALOGW("setLhbmState(on) wait for peak refresh rate timeout !"); + return TIMED_OUT; } } |