From 3c78b9ed89ed44b9125b5726065fc9f9c2489c0d Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Fri, 12 Jan 2018 21:28:33 -0800 Subject: livedisplay: Support sysfs only display modes *) If SDM does not provide any display modes and yet sysfs options are available, allow them to be used and create a "standard" mode that is all sysfs based modes turned off. *) Known deficiency: the sysfs modes are still not accessible if SDM is not available. This will be addressed later (possibly by moving sysfs mode handling to lineagehw). Change-Id: If80134362db0d359aaacb6b1916dc99e41af1892 --- impl/SDM.cpp | 32 ++++++++++++++++++++++---------- impl/SDM.h | 4 ++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/impl/SDM.cpp b/impl/SDM.cpp index 1e60f63..6fc6733 100644 --- a/impl/SDM.cpp +++ b/impl/SDM.cpp @@ -234,12 +234,17 @@ int32_t SDM::getColorBalance() { return value; } -uint32_t SDM::getNumDisplayModes() { +uint32_t SDM::getNumSDMDisplayModes() { uint32_t flags = 0; int32_t count = 0; if (disp_api_get_num_display_modes(mHandle, 0, 0, &count, &flags)) { count = 0; } + return count; +} + +uint32_t SDM::getNumDisplayModes() { + int32_t count = getNumSDMDisplayModes(); if (getLocalSRGBMode() != nullptr) { count++; } @@ -258,13 +263,8 @@ status_t SDM::getDisplayModes(List>& profiles) { sp srgb = getLocalSRGBMode(); sp dci_p3 = getLocalDCIP3Mode(); - uint32_t sdm_count = count; - if (srgb != nullptr) { - sdm_count--; - } - if (dci_p3 != nullptr) { - sdm_count--; - } + + uint32_t sdm_count = getNumSDMDisplayModes(); struct sdm_mode { int32_t id; @@ -292,6 +292,13 @@ status_t SDM::getDisplayModes(List>& profiles) { } delete[] tmp; + if (sdm_count == 0) { + const sp m = new DisplayMode(STANDARD_NODE_ID, "standard", 8); + m->privFlags = PRIV_MODE_FLAG_SYSFS; + m->privData.setTo(""); + profiles.push_back(m); + } + if (srgb != nullptr) { profiles.push_back(srgb); } @@ -399,8 +406,13 @@ status_t SDM::setModeState(sp mode, bool state) { int32_t id = 0; if (mode->privFlags == PRIV_MODE_FLAG_SYSFS) { - ALOGV("sysfs node: %s state=%d", mode->privData.string(), state); - return Utils::writeInt(mode->privData.string(), state ? 1 : 0); + if (mode->id != STANDARD_NODE_ID) { + ALOGV("sysfs node: %s state=%d", mode->privData.string(), state); + return Utils::writeInt(mode->privData.string(), state ? 1 : 0); + } else { + // NOOP + return OK; + } } else if (mode->privFlags == PRIV_MODE_FLAG_SDM) { if (state) { return disp_api_set_active_display_mode(mHandle, 0, mode->id, 0); diff --git a/impl/SDM.h b/impl/SDM.h index f0d3ebe..f6db039 100644 --- a/impl/SDM.h +++ b/impl/SDM.h @@ -13,6 +13,9 @@ #define FOSS_OFF "foss:off" #define FOSS_STATUS "foss:status" +// For use when only sysfs modes are available +#define STANDARD_NODE_ID 600 + #define SRGB_NODE "/sys/class/graphics/fb0/srgb" #define SRGB_NODE_ID 601 @@ -99,6 +102,7 @@ class SDM : public LiveDisplayBackend { status_t setModeState(sp mode, bool state); status_t saveInitialDisplayMode(); uint32_t getNumDisplayModes(); + uint32_t getNumSDMDisplayModes(); int64_t mHandle; bool mCachedFOSSStatus; -- cgit v1.2.3