summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShiyong Li <shiyongli@google.com>2023-02-12 03:12:01 +0000
committerShiyong Li <shiyongli@google.com>2023-02-28 23:56:04 +0000
commitd379c375d0527318952e8211d4321edaf08e6a9d (patch)
treee696e1f9ad64890cd89b564991f8feb0ae8e32db
parentbc755169156c1187bf3eef3423322b34d496065e (diff)
Revert "Revert "libhwc2.1: wait for peak refresh rate via sysfs node""
This reverts commit 334e1fee2f8204c8b30714291d60c19077e6df9f. Bug: 268991972 Change-Id: Ie0d344821b407ca0c3896dc5dc2a4f6afdf68eaf Signed-off-by: Shiyong Li <shiyongli@google.com>
-rw-r--r--libhwc2.1/libdevice/BrightnessController.cpp23
-rw-r--r--libhwc2.1/libdevice/BrightnessController.h2
-rw-r--r--libhwc2.1/libdevice/ExynosDisplay.cpp8
-rw-r--r--libhwc2.1/libdevice/ExynosDisplay.h16
-rw-r--r--libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp12
-rw-r--r--libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp18
6 files changed, 40 insertions, 39 deletions
diff --git a/libhwc2.1/libdevice/BrightnessController.cpp b/libhwc2.1/libdevice/BrightnessController.cpp
index 497889a..5b91786 100644
--- a/libhwc2.1/libdevice/BrightnessController.cpp
+++ b/libhwc2.1/libdevice/BrightnessController.cpp
@@ -713,12 +713,23 @@ int BrightnessController::checkSysfsStatus(const char* file,
char buf[16];
String8 nodeName;
- nodeName.appendFormat(file, mPanelIndex);
+ 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;
+ }
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", __func__, kLocalHbmModeFileNode);
+ ALOGE("%s failed to read from %s: %s", __func__, nodeName.c_str(), strerror(errno));
return false;
}
@@ -745,7 +756,7 @@ int BrightnessController::checkSysfsStatus(const char* file,
}
int pollRet = poll(&pfd, 1, ns2ms(remainTimeNs));
if (pollRet == 0) {
- ALOGW("%s poll timeout", __func__);
+ ALOGW("%s poll %s timeout", __func__, nodeName.c_str());
// time out
ret = ETIMEDOUT;
break;
@@ -760,7 +771,8 @@ int BrightnessController::checkSysfsStatus(const char* file,
val = std::string(buf, size - 1);
if (std::find(expectedValue.begin(), expectedValue.end(), val) !=
expectedValue.end()) {
- ret = 0;
+ ret = OK;
+ break;
} else {
std::string values;
for (auto& s : expectedValue) {
@@ -771,13 +783,12 @@ 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 9090689..8ce7c4d 100644
--- a/libhwc2.1/libdevice/BrightnessController.h
+++ b/libhwc2.1/libdevice/BrightnessController.h
@@ -217,6 +217,8 @@ 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 b38f2b5..6bf1ea2 100644
--- a/libhwc2.1/libdevice/ExynosDisplay.cpp
+++ b/libhwc2.1/libdevice/ExynosDisplay.cpp
@@ -4255,14 +4255,6 @@ 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 0f12ab9..5b06cd2 100644
--- a/libhwc2.1/libdevice/ExynosDisplay.h
+++ b/libhwc2.1/libdevice/ExynosDisplay.h
@@ -555,10 +555,6 @@ class ExynosDisplay {
hwc2_config_t mActiveConfig = UINT_MAX;
- bool mNotifyPeakRefreshRate = false;
- std::mutex mPeakRefreshRateMutex;
- std::condition_variable mPeakRefreshRateCondition;
-
void initDisplay();
int getId();
@@ -1280,11 +1276,9 @@ class ExynosDisplay {
// is the hint session both enabled and supported
bool usePowerHintSession();
- void setMinDisplayVsyncPeriod(uint32_t period) { mMinDisplayVsyncPeriod = period; }
-
- bool isCurrentPeakRefreshRate(void) {
- return ((mConfigRequestState == hwc_request_state_t::SET_CONFIG_STATE_DONE) &&
- (mVsyncPeriod == mMinDisplayVsyncPeriod));
+ void setPeakRefreshRate(float rr) { mPeakRefreshRate = rr; }
+ float getPeakRefreshRate() {
+ return mPeakRefreshRate;
}
// check if there are any dimmed layers
@@ -1309,8 +1303,8 @@ class ExynosDisplay {
static constexpr float kHdrFullScreen = 0.5;
uint32_t mHdrFullScrenAreaThreshold;
- // vsync period of peak refresh rate
- uint32_t mMinDisplayVsyncPeriod;
+ // peak refresh rate
+ float mPeakRefreshRate = -1.0f;
// 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 7bbc64b..ea9a07e 100644
--- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp
+++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp
@@ -925,11 +925,12 @@ int32_t ExynosDisplayDrmInterface::getDisplayConfigs(
/* key: (width<<32 | height) */
std::map<uint64_t, uint32_t> groupIds;
uint32_t groupId = 0;
- uint32_t min_vsync_period = UINT_MAX;
+ float peakRr = -1;
for (const DrmMode &mode : mDrmConnector->modes()) {
displayConfigs_t configs;
- configs.vsyncPeriod = nsecsPerSec/ mode.v_refresh();
+ float rr = mode.v_refresh();
+ configs.vsyncPeriod = nsecsPerSec / rr;
configs.width = mode.h_display();
configs.height = mode.v_display();
uint64_t key = ((uint64_t)configs.width<<32) | configs.height;
@@ -946,14 +947,15 @@ 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 min vsync period
- if (configs.vsyncPeriod <= min_vsync_period) min_vsync_period = configs.vsyncPeriod;
+ // find peak rr
+ if (rr > peakRr)
+ peakRr = rr;
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->setMinDisplayVsyncPeriod(min_vsync_period);
+ mExynosDisplay->setPeakRefreshRate(peakRr);
}
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 9e299ee..619e55d 100644
--- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp
+++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp
@@ -546,16 +546,16 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) {
}
}
- if (enabled) {
+ float peak_rr = getPeakRefreshRate();
+ if (enabled && peak_rr > 0) {
ATRACE_NAME("wait for peak refresh rate");
- 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;
+ 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;
}
}