powerstats: Add Uwb stats
Bug: 180956351 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: Ib528558b2efae9a35494bafcf2c675325cbcf6fe
This commit is contained in:
parent
2a6d256369
commit
eeaf5ea672
2 changed files with 38 additions and 0 deletions
|
@ -11,6 +11,9 @@ on init
|
|||
chown system system /d/regmap/6-0036/registers
|
||||
chown system system /sys/bus/nvmem/devices/5-00500/nvmem
|
||||
|
||||
# Power Stats HAL
|
||||
chown system system /sys/devices/platform/10d30000.spi/spi_master/spi10/spi10.0/uwb/power_stats
|
||||
|
||||
on early-boot
|
||||
# Wait for insmod_sh to finish all common modules
|
||||
wait_for_prop vendor.common.modules.ready 1
|
||||
|
|
|
@ -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 <Gs101CommonDataProviders.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) {
|
||||
|
@ -66,6 +68,38 @@ void addDisplay(std::shared_ptr<PowerStats> p) {
|
|||
{"HBM: 1440x3120@60", 8}}));
|
||||
}
|
||||
|
||||
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("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/10d30000.spi/spi_master/spi10/spi10.0/uwb/power_stats", cfgs));
|
||||
}
|
||||
|
||||
int main() {
|
||||
LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting.";
|
||||
|
||||
|
@ -76,6 +110,7 @@ int main() {
|
|||
|
||||
addGs101CommonDataProviders(p);
|
||||
addDisplay(p);
|
||||
addUwb(p);
|
||||
|
||||
const std::string instance = std::string() + PowerStats::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue