From f6aea5a8e3eb7b73e119242b9f54cdc9ed9315df Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Sat, 23 Oct 2021 21:06:59 +0200 Subject: [PATCH] sm7125: Import livedisplay changes from https://github.com/Grarak/android_device_samsung_a70q/commit/ca244936f71c3f6c144128993a78842f672e97ba Change-Id: Ieec97393161c77cf6b8800684fd0b4bf07c8651f --- livedisplay/DisplayModes.cpp | 6 +---- livedisplay/SunlightEnhancement.cpp | 38 +++++++++-------------------- livedisplay/SunlightEnhancement.h | 2 +- rootdir/etc/init.samsung.display.rc | 3 ++- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/livedisplay/DisplayModes.cpp b/livedisplay/DisplayModes.cpp index f14e93d..b93c825 100644 --- a/livedisplay/DisplayModes.cpp +++ b/livedisplay/DisplayModes.cpp @@ -36,12 +36,8 @@ static constexpr const char* kDefaultPath = "/data/vendor/display/.displaymodede const std::map DisplayModes::kModeMap = { // clang-format off - {0, "Dynamic"}, - {1, "Standard"}, {2, "Natural"}, - {3, "Cinema"}, - {4, "Adaptive"}, - {5, "Reading"}, + {4, "Vivid"}, // clang-format on }; diff --git a/livedisplay/SunlightEnhancement.cpp b/livedisplay/SunlightEnhancement.cpp index 077672e..055aec4 100644 --- a/livedisplay/SunlightEnhancement.cpp +++ b/livedisplay/SunlightEnhancement.cpp @@ -31,43 +31,29 @@ namespace livedisplay { namespace V2_0 { namespace samsung { -static constexpr const char* kHBMPath = "/sys/class/lcd/panel/panel/auto_brightness"; -static constexpr const char* kSREPath = "/sys/class/mdnie/mdnie/outdoor"; +static constexpr const char* kBrightnessPath = "/sys/class/backlight/panel0-backlight/brightness"; // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. bool SunlightEnhancement::isSupported() { - std::fstream sre(kSREPath, sre.in | sre.out); - std::fstream hbm(kHBMPath, hbm.in | hbm.out); - - if (hbm.good()) { - mHasHBM = true; - } - - return sre.good(); + std::fstream brightness(kBrightnessPath, brightness.in | brightness.out); + return brightness.good(); } // Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. Return SunlightEnhancement::isEnabled() { - std::string tmp; - int32_t statusSRE = 0; - int32_t statusHBM = 0; - if (ReadFileToString(kSREPath, &tmp)) { - statusSRE = std::stoi(Trim(tmp)); - } - - if (mHasHBM && ReadFileToString(kHBMPath, &tmp)) { - statusHBM = std::stoi(Trim(tmp)); - } - - return ((statusSRE == 1 && statusHBM == 6) || statusSRE == 1); + std::string brightness; + ReadFileToString(kBrightnessPath, &brightness); + return brightness == "365"; } Return SunlightEnhancement::setEnabled(bool enabled) { - if (mHasHBM) { - WriteStringToFile(enabled ? "6" : "0", kHBMPath, true); + if (enabled) { + ReadFileToString(kBrightnessPath, &previous_brightness); + return WriteStringToFile("365", kBrightnessPath, true); + } else if (!previous_brightness.empty()) { + return WriteStringToFile(previous_brightness, kBrightnessPath, true); } - - return WriteStringToFile(enabled ? "1" : "0", kSREPath, true); + return true; } } // namespace samsung diff --git a/livedisplay/SunlightEnhancement.h b/livedisplay/SunlightEnhancement.h index 44b34b9..b49975f 100644 --- a/livedisplay/SunlightEnhancement.h +++ b/livedisplay/SunlightEnhancement.h @@ -45,7 +45,7 @@ class SunlightEnhancement : public ISunlightEnhancement { // Methods from ::android::hidl::base::V1_0::IBase follow. private: - bool mHasHBM = false; + std::string previous_brightness; }; } // namespace samsung diff --git a/rootdir/etc/init.samsung.display.rc b/rootdir/etc/init.samsung.display.rc index cb410e9..693f464 100644 --- a/rootdir/etc/init.samsung.display.rc +++ b/rootdir/etc/init.samsung.display.rc @@ -40,6 +40,7 @@ on init chown system media_rw /sys/class/mdnie/mdnie/outdoor chown system system /sys/class/mdnie/mdnie/mdnie_temp chown system media_rw /sys/class/mdnie/mdnie/mode + chown system system /sys/class/mdnie/mdnie/mode_max chown system system /sys/class/mdnie/mdnie/negative chown system media_rw /sys/class/mdnie/mdnie/playspeed chown system media_rw /sys/class/mdnie/mdnie/accessibility @@ -485,4 +486,4 @@ on init chown system system /sys/class/lcd/panel/SVC_OCTA_DDI_CHIPID chmod 0440 /sys/class/lcd/panel/SVC_OCTA_DDI_CHIPID chown system system /sys/class/lcd/panel1/SVC_OCTA_DDI_CHIPID - chmod 0440 /sys/class/lcd/panel1/SVC_OCTA_DDI_CHIPID \ No newline at end of file + chmod 0440 /sys/class/lcd/panel1/SVC_OCTA_DDI_CHIPID