From e04673cadf62071dc46f3543b7416d8a38c93d70 Mon Sep 17 00:00:00 2001 From: Benjamin Schwartz Date: Mon, 5 Apr 2021 22:26:29 -0700 Subject: [PATCH] powerstats: Add device specific display states Bug: 167216667 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I90ea3553ababbc802fdc6f893f698b85655b1ad9 --- powerstats/oriole/service.cpp | 36 ++++++++++++++++++++++++++- powerstats/raven/service.cpp | 44 ++++++++++++++++++++++++++++++++- powerstats/slider/service.cpp | 35 +++++++++++++++++++++++++- powerstats/whitefin/service.cpp | 35 +++++++++++++++++++++++++- 4 files changed, 146 insertions(+), 4 deletions(-) diff --git a/powerstats/oriole/service.cpp b/powerstats/oriole/service.cpp index d7c7599..6da7102 100644 --- a/powerstats/oriole/service.cpp +++ b/powerstats/oriole/service.cpp @@ -16,8 +16,10 @@ #define LOG_TAG "android.hardware.power.stats-service.pixel" -#include +#include +#include #include +#include #include #include @@ -25,6 +27,37 @@ #include #include +using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; +using aidl::android::hardware::power::stats::EnergyConsumerType; +using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; + +void addDisplay(std::shared_ptr p) { + // Add display residency stats + std::vector states = { + "Off", + "LP: 1080x2400@30", + "On: 1080x2400@60", + "On: 1080x2400@90", + "HBM: 1080x2400@60", + }; + + p->addStateResidencyDataProvider(std::make_unique("Display", + "/sys/class/backlight/panel0-backlight/state", + states)); + + // Add display energy consumer + /* + * TODO(b/167216667): Add correct display power model here. Must read from display rail + * and include proper coefficients for display states. + */ + p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p, + EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display", + {{"LP: 1080x2400@30", 1}, + {"On: 1080x2400@60", 2}, + {"On: 1080x2400@90", 3}, + {"HBM: 1080x2400@60", 4}})); +} + int main() { LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; @@ -34,6 +67,7 @@ int main() { std::shared_ptr p = ndk::SharedRefBase::make(); addGs101CommonDataProviders(p); + addDisplay(p); const std::string instance = std::string() + PowerStats::descriptor + "/default"; binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str()); diff --git a/powerstats/raven/service.cpp b/powerstats/raven/service.cpp index d7c7599..8ccc616 100644 --- a/powerstats/raven/service.cpp +++ b/powerstats/raven/service.cpp @@ -16,8 +16,10 @@ #define LOG_TAG "android.hardware.power.stats-service.pixel" -#include +#include +#include #include +#include #include #include @@ -25,6 +27,45 @@ #include #include +using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; +using aidl::android::hardware::power::stats::EnergyConsumerType; +using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; + +void addDisplay(std::shared_ptr p) { + // Add display residency stats + std::vector states = { + "Off", + "LP: 1440x3120@10", + "LP: 1440x3120@30", + "On: 1440x3120@10", + "On: 1440x3120@30", + "On: 1440x3120@60", + "On: 1440x3120@90", + "On: 1440x3120@120", + "HBM: 1440x3120@60", + }; + + p->addStateResidencyDataProvider(std::make_unique("Display", + "/sys/class/backlight/panel0-backlight/state", + states)); + + // Add display energy consumer + /* + * TODO(b/167216667): Add correct display power model here. Must read from display rail + * and include proper coefficients for display states. + */ + p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p, + EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display", + {{"LP: 1440x3120@10", 1}, + {"LP: 1440x3120@30", 2}, + {"On: 1440x3120@10", 3}, + {"On: 1440x3120@30", 4}, + {"On: 1440x3120@60", 5}, + {"On: 1440x3120@90", 6}, + {"On: 1440x3120@120", 7}, + {"HBM: 1440x3120@60", 8}})); +} + int main() { LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; @@ -34,6 +75,7 @@ int main() { std::shared_ptr p = ndk::SharedRefBase::make(); addGs101CommonDataProviders(p); + addDisplay(p); const std::string instance = std::string() + PowerStats::descriptor + "/default"; binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str()); diff --git a/powerstats/slider/service.cpp b/powerstats/slider/service.cpp index d7c7599..5fe5332 100644 --- a/powerstats/slider/service.cpp +++ b/powerstats/slider/service.cpp @@ -16,8 +16,10 @@ #define LOG_TAG "android.hardware.power.stats-service.pixel" -#include +#include +#include #include +#include #include #include @@ -25,6 +27,36 @@ #include #include +using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; +using aidl::android::hardware::power::stats::EnergyConsumerType; +using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; + +void addDisplay(std::shared_ptr p) { + // Add display residency stats + std::vector states = { + "Off", + "LP: 1440x3040@30", + "On: 1440x3040@60", + "On: 1440x3040@90", + "HBM: 1440x3040@60", + "HBM: 1440x3040@90"}; + + p->addStateResidencyDataProvider(std::make_unique("Display", + "/sys/class/backlight/panel0-backlight/state", + states)); + + // Add display energy consumer + /* + * TODO(b/167216667): Add correct display power model here. Must read from display rail + * and include proper coefficients for display states. + */ + p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p, + EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display", + {{"LP: 1440x3040@30", 1}, + {"On: 1440x3040@60", 2}, + {"On: 1440x3040@90", 3}})); +} + int main() { LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; @@ -34,6 +66,7 @@ int main() { std::shared_ptr p = ndk::SharedRefBase::make(); addGs101CommonDataProviders(p); + addDisplay(p); const std::string instance = std::string() + PowerStats::descriptor + "/default"; binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str()); diff --git a/powerstats/whitefin/service.cpp b/powerstats/whitefin/service.cpp index d7c7599..2a102fa 100644 --- a/powerstats/whitefin/service.cpp +++ b/powerstats/whitefin/service.cpp @@ -16,8 +16,10 @@ #define LOG_TAG "android.hardware.power.stats-service.pixel" -#include +#include +#include #include +#include #include #include @@ -25,6 +27,36 @@ #include #include +using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider; +using aidl::android::hardware::power::stats::EnergyConsumerType; +using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; + +void addDisplay(std::shared_ptr p) { + // Add display residency stats + std::vector states = { + "Off", + "LP: 1080x2340@30", + "On: 1080x2340@60", + "On: 1080x2340@90", + "HBM: 1080x2340@60", + "HBM: 1080x2340@90"}; + + p->addStateResidencyDataProvider(std::make_unique("Display", + "/sys/class/backlight/panel0-backlight/state", + states)); + + // Add display energy consumer + /* + * TODO(b/167216667): Add correct display power model here. Must read from display rail + * and include proper coefficients for display states. + */ + p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p, + EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display", + {{"LP: 1440x3040@30", 1}, + {"On: 1440x3040@60", 2}, + {"On: 1440x3040@90", 3}})); +} + int main() { LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; @@ -34,6 +66,7 @@ int main() { std::shared_ptr p = ndk::SharedRefBase::make(); addGs101CommonDataProviders(p); + addDisplay(p); const std::string instance = std::string() + PowerStats::descriptor + "/default"; binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());