Skip to content
Snippets Groups Projects
Commit 06d9ad09 authored by Darren Hsu's avatar Darren Hsu Committed by TreeHugger Robot
Browse files

powerstats: add UWB state residency


Bug: 206566167
Test: dumpsys android.hardware.power.stats.IPowerStats/default
Change-Id: Iced632ccb403d82df609d4f2ac3a486f223feceb
Signed-off-by: default avatarDarren Hsu <darrenhsu@google.com>
parent 1f6f0e64
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@
#define LOG_TAG "android.hardware.power.stats-service.pixel"
#include <dataproviders/DisplayStateResidencyDataProvider.h>
#include <dataproviders/GenericStateResidencyDataProvider.h>
#include <dataproviders/PowerStatsEnergyConsumer.h>
#include <Gs201CommonDataProviders.h>
#include <PowerStatsAidl.h>
......@@ -29,6 +30,7 @@
using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
using aidl::android::hardware::power::stats::EnergyConsumerType;
using aidl::android::hardware::power::stats::GenericStateResidencyDataProvider;
using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
void addDisplay(std::shared_ptr<PowerStats> p) {
......@@ -64,6 +66,39 @@ void addDisplay(std::shared_ptr<PowerStats> p) {
{"HBM: 1440x3120@120", 9}}));
}
void addUwb(std::shared_ptr<PowerStats> p) {
// A constant to represent the number of nanoseconds in one millisecond.
const int NS_TO_MS = 1000000;
// ACPM stats are reported in nanoseconds. The transform function
// converts nanoseconds to milliseconds.
std::function<uint64_t(uint64_t)> uwbNsToMs = [](uint64_t a) { return a / NS_TO_MS; };
const GenericStateResidencyDataProvider::StateResidencyConfig stateConfig = {
.entryCountSupported = true,
.entryCountPrefix = "count:",
.totalTimeSupported = true,
.totalTimePrefix = "dur ns:",
.totalTimeTransform = uwbNsToMs,
.lastEntrySupported = false,
};
const std::vector<std::pair<std::string, std::string>> stateHeaders = {
std::make_pair("Off", "Off state:"),
std::make_pair("Deep sleep", "Deep sleep state:"),
std::make_pair("Run", "Run state:"),
std::make_pair("Idle", "Idle state:"),
std::make_pair("Tx", "Tx state:"),
std::make_pair("Rx", "Rx state:"),
};
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
cfgs.emplace_back(generateGenericStateResidencyConfigs(stateConfig, stateHeaders),
"UWB", "");
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
"/sys/devices/platform/10db0000.spi/spi_master/spi16/spi16.0/uwb/power_stats", cfgs));
}
int main() {
LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting.";
......@@ -74,7 +109,7 @@ int main() {
addGs201CommonDataProviders(p);
addDisplay(p);
// TODO(b/206566167): Add UWB state residency
addUwb(p);
addNFC(p, "/sys/devices/platform/10970000.hsi2c/i2c-4/i2c-st21nfc/power_stats");
const std::string instance = std::string() + PowerStats::descriptor + "/default";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment