powerstats: add UWB state residency
Bug: 253561559 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I54c49d0f5db4ded67ca0dfa3b3deb4aa8036198e Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
parent
cbdf2f7269
commit
2cd57aaf92
1 changed files with 36 additions and 0 deletions
|
@ -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 <DevfreqStateResidencyDataProvider.h>
|
||||
#include <Gs201CommonDataProviders.h>
|
||||
|
@ -31,6 +32,7 @@
|
|||
using aidl::android::hardware::power::stats::DevfreqStateResidencyDataProvider;
|
||||
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) {
|
||||
|
@ -85,6 +87,39 @@ void addGPUGs202(std::shared_ptr<PowerStats> p) {
|
|||
stateCoeffs));
|
||||
}
|
||||
|
||||
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.";
|
||||
|
||||
|
@ -102,6 +137,7 @@ int main() {
|
|||
addWifi(p);
|
||||
addTPU(p);
|
||||
addUfs(p);
|
||||
addUwb(p);
|
||||
addPowerDomains(p);
|
||||
addDevfreq(p);
|
||||
addGPUGs202(p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue