gs201: Relocate even more things to vendor
Change-Id: Ic7872d3a7cbac2f0c2e01162697567972027389a
This commit is contained in:
86
device.mk
86
device.mk
@@ -5,17 +5,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# Voice packs for Text-To-Speech
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/gs-common/tts/ja-jp/ja-jp-x-multi-r55.zvoice:$(TARGET_COPY_OUT_PRODUCT)/tts/google/ja-jp/ja-jp-x-multi-r55.zvoice \
|
||||
device/google/gs-common/tts/fr-fr/fr-fr-x-multi-r57.zvoice:$(TARGET_COPY_OUT_PRODUCT)/tts/google/fr-fr/fr-fr-x-multi-r57.zvoice \
|
||||
device/google/gs-common/tts/de-de/de-de-x-multi-r57.zvoice:$(TARGET_COPY_OUT_PRODUCT)/tts/google/de-de/de-de-x-multi-r57.zvoice \
|
||||
device/google/gs-common/tts/it-it/it-it-x-multi-r54.zvoice:$(TARGET_COPY_OUT_PRODUCT)/tts/google/it-it/it-it-x-multi-r54.zvoice \
|
||||
device/google/gs-common/tts/es-es/es-es-x-multi-r56.zvoice:$(TARGET_COPY_OUT_PRODUCT)/tts/google/es-es/es-es-x-multi-r56.zvoice
|
||||
|
||||
PRODUCT_SOONG_NAMESPACES += \
|
||||
device/google/gs-common/powerstats
|
||||
|
||||
# Disable OMX
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
vendor.media.omx=0
|
||||
@@ -29,87 +18,39 @@ PRODUCT_COPY_FILES += \
|
||||
DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += \
|
||||
device/google/gs-common/vintf/framework_compatibility_matrix.xml
|
||||
|
||||
# Platform watchdogd
|
||||
PRODUCT_PACKAGES += gs_watchdogd
|
||||
PRODUCT_SOONG_NAMESPACES += \
|
||||
device/google/gs-common/gs_watchdogd
|
||||
|
||||
# sscoredump
|
||||
PRODUCT_PROPERTY_OVERRIDES += vendor.debug.ssrdump.type=sscoredump
|
||||
|
||||
# SoC
|
||||
PRODUCT_PACKAGES += dump_soc
|
||||
|
||||
# Modem
|
||||
ifneq ($(BOARD_WITHOUT_RADIO),true)
|
||||
PRODUCT_PACKAGES += dump_modem
|
||||
PRODUCT_PACKAGES += dump_modemlog
|
||||
endif
|
||||
|
||||
# AoC
|
||||
PRODUCT_PACKAGES += dump_aoc
|
||||
|
||||
# If AoC Daemon is not present on this build, load firmware at boot via rc
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/gs-common/aoc/conf/init.aoc.daemon.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.aoc.rc
|
||||
|
||||
# Trusty
|
||||
PRODUCT_PACKAGES += dump_trusty.sh
|
||||
|
||||
# Storage
|
||||
PRODUCT_PACKAGES += dump_storage
|
||||
|
||||
# Thermal
|
||||
PRODUCT_PACKAGES += dump_thermal.sh
|
||||
|
||||
PRODUCT_PACKAGES += android.hardware.thermal-service.pixel
|
||||
|
||||
# Thermal utils
|
||||
PRODUCT_PACKAGES += thermal_symlinks
|
||||
|
||||
# Performance
|
||||
PRODUCT_PACKAGES += dump_perf
|
||||
|
||||
# Ensure enough free space to create zram backing device
|
||||
PRODUCT_PRODUCT_PROPERTIES += \
|
||||
ro.zram_backing_device_min_free_mb=1536
|
||||
|
||||
#include device/google/gs-common/pixel_metrics/pixel_metrics.mk
|
||||
PRODUCT_PACKAGES += dump_pixel_metrics
|
||||
|
||||
#include device/google/gs-common/soc/freq.mk
|
||||
PRODUCT_PACKAGES += dump_devfreq
|
||||
|
||||
#include device/google/gs-common/display/dump_exynos_display.mk
|
||||
PRODUCT_PACKAGES += dump_exynos_display
|
||||
|
||||
#include device/google/gs-common/gear/dumpstate/aidl.mk
|
||||
PRODUCT_PACKAGES += android.hardware.dumpstate-service
|
||||
|
||||
#include device/google/gs-common/widevine/widevine.mk
|
||||
# DRM
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.drm-service.clearkey
|
||||
|
||||
#include device/google/gs-common/misc_writer/misc_writer.mk
|
||||
# misc_writer
|
||||
PRODUCT_PACKAGES += \
|
||||
misc_writer
|
||||
|
||||
#include device/google/gs-common/bootctrl/bootctrl_aidl.mk
|
||||
# Boot control
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.boot-service.default-pixel \
|
||||
android.hardware.boot-service.default_recovery-pixel
|
||||
|
||||
PRODUCT_SOONG_NAMESPACES += device/google/gs-common/bootctrl/aidl
|
||||
|
||||
#include device/google/gs-common/fingerprint/fingerprint.mk
|
||||
PRODUCT_PACKAGES += dump_fingerprint
|
||||
|
||||
# Add UmfwStat product packages.
|
||||
PRODUCT_PACKAGES += dump_umfw_stat
|
||||
PRODUCT_PACKAGES += umfw_stat_tool
|
||||
|
||||
PRODUCT_PACKAGES += dump_power
|
||||
|
||||
TARGET_BOARD_PLATFORM := gs201
|
||||
|
||||
AB_OTA_POSTINSTALL_CONFIG += \
|
||||
@@ -128,8 +69,7 @@ PRODUCT_SOONG_NAMESPACES += \
|
||||
hardware/google/av \
|
||||
hardware/google/interfaces \
|
||||
hardware/google/pixel \
|
||||
device/google/gs201 \
|
||||
device/google/gs201/powerstats
|
||||
device/google/gs201
|
||||
|
||||
# OEM Unlock reporting
|
||||
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
|
||||
@@ -221,7 +161,7 @@ include hardware/google/pixel/PixelLogger/PixelLogger.mk
|
||||
# HWUI
|
||||
TARGET_USES_VULKAN = true
|
||||
|
||||
#include device/google/gs-common/gpu/gpu.mk
|
||||
# GPU
|
||||
PRODUCT_PACKAGES += gpu_probe
|
||||
|
||||
# Install the OpenCL ICD Loader
|
||||
@@ -296,11 +236,6 @@ PRODUCT_PACKAGES += \
|
||||
fstab.gs201-fips \
|
||||
fstab.gs201-fips.vendor_ramdisk
|
||||
|
||||
# Shell scripts
|
||||
PRODUCT_PACKAGES += \
|
||||
insmod.sh \
|
||||
init.common.cfg
|
||||
|
||||
# Insmod config files
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(call find-copy-subdir-files,init.insmod.*.cfg,$(TARGET_KERNEL_DIR),$(TARGET_COPY_OUT_VENDOR_DLKM)/etc)
|
||||
@@ -381,17 +316,10 @@ PRODUCT_PROPERTY_OVERRIDES += aaudio.mmap_policy=2
|
||||
PRODUCT_PROPERTY_OVERRIDES += aaudio.mmap_exclusive_policy=2
|
||||
PRODUCT_PROPERTY_OVERRIDES += aaudio.hw_burst_min_usec=2000
|
||||
|
||||
#include device/google/gs-common/camera/lyric.mk
|
||||
# Camera
|
||||
PRODUCT_SOONG_NAMESPACES += \
|
||||
hardware/google/camera
|
||||
|
||||
# Init-time log settings for Google 3A
|
||||
PRODUCT_PACKAGES += libg3a_standalone_gabc_rc
|
||||
PRODUCT_PACKAGES += libg3a_standalone_gaf_rc
|
||||
PRODUCT_PACKAGES += libg3a_standalone_ghawb_rc
|
||||
|
||||
PRODUCT_PACKAGES += lyric_preview_dis_xml
|
||||
|
||||
DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += \
|
||||
device/google/gs-common/camera/device_framework_matrix_product.xml
|
||||
|
||||
@@ -610,8 +538,6 @@ endif
|
||||
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit_only.mk)
|
||||
|
||||
PRODUCT_PACKAGES += dump_sensors
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/gs201/default-permissions.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/default-permissions/default-permissions.xml \
|
||||
device/google/gs201/component-overrides.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sysconfig/component-overrides.xml
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "dump_power",
|
||||
srcs: ["dump_power.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libdump",
|
||||
"libdumpstateutil",
|
||||
],
|
||||
vendor: true,
|
||||
relative_install_path: "dump",
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Please refer to go/pixel-recycle to modularize your code in this space.
|
||||
@@ -1,819 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <dump/pixel_dump.h>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include "DumpstateUtil.h"
|
||||
void printTitle(const char *msg) {
|
||||
printf("\n------ %s ------\n", msg);
|
||||
}
|
||||
int getCommandOutput(const char *cmd, std::string *output) {
|
||||
char buffer[1024];
|
||||
FILE *pipe = popen(cmd, "r");
|
||||
if (!pipe) {
|
||||
return -1;
|
||||
}
|
||||
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
|
||||
*output += buffer;
|
||||
}
|
||||
pclose(pipe);
|
||||
if (output->back() == '\n')
|
||||
output->pop_back();
|
||||
return 0;
|
||||
}
|
||||
bool isValidFile(const char *file) {
|
||||
FILE *fp = fopen(file, "r");
|
||||
if (fp != NULL) {
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isValidDir(const char *directory) {
|
||||
DIR *dir = opendir(directory);
|
||||
if (dir == NULL)
|
||||
return false;
|
||||
|
||||
closedir(dir);
|
||||
return true;
|
||||
}
|
||||
bool isUserBuild() {
|
||||
return ::android::os::dumpstate::PropertiesHelper::IsUserBuild();
|
||||
}
|
||||
int getFilesInDir(const char *directory, std::vector<std::string> *files) {
|
||||
std::string content;
|
||||
struct dirent *entry;
|
||||
DIR *dir = opendir(directory);
|
||||
if (dir == NULL)
|
||||
return -1;
|
||||
files->clear();
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
files->push_back(entry->d_name);
|
||||
closedir(dir);
|
||||
sort(files->begin(), files->end());
|
||||
return 0;
|
||||
}
|
||||
void dumpPowerStatsTimes() {
|
||||
const char *title = "Power Stats Times";
|
||||
char rBuff[128];
|
||||
struct timespec rTs;
|
||||
struct sysinfo info;
|
||||
int ret;
|
||||
printTitle(title);
|
||||
sysinfo(&info);
|
||||
const time_t boottime = time(NULL) - info.uptime;
|
||||
ret = clock_gettime(CLOCK_REALTIME, &rTs);
|
||||
if (ret)
|
||||
return;
|
||||
struct tm *nowTime = std::localtime(&rTs.tv_sec);
|
||||
std::strftime(rBuff, sizeof(rBuff), "%m/%d/%Y %H:%M:%S", nowTime);
|
||||
printf("Boot: %s", ctime(&boottime));
|
||||
printf("Now: %s\n", rBuff);
|
||||
}
|
||||
int readContentsOfDir(const char* title, const char* directory, const char* strMatch,
|
||||
bool useStrMatch = false, bool printDirectory = false) {
|
||||
std::vector<std::string> files;
|
||||
std::string content;
|
||||
std::string fileLocation;
|
||||
int ret;
|
||||
ret = getFilesInDir(directory, &files);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
printTitle(title);
|
||||
for (auto &file : files) {
|
||||
if (useStrMatch && std::string::npos == std::string(file).find(strMatch)) {
|
||||
continue;
|
||||
}
|
||||
fileLocation = std::string(directory) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
if (printDirectory) {
|
||||
printf("\n\n%s\n", fileLocation.c_str());
|
||||
}
|
||||
if (content.back() == '\n')
|
||||
content.pop_back();
|
||||
printf("%s\n", content.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void dumpAcpmStats() {
|
||||
const char* acpmDir = "/sys/devices/platform/acpm_stats/";
|
||||
const char* statsSubStr = "_stats";
|
||||
const char* acpmTitle = "ACPM stats";
|
||||
readContentsOfDir(acpmTitle, acpmDir, statsSubStr, true, true);
|
||||
}
|
||||
void dumpPowerSupplyStats() {
|
||||
const char* dumpList[][2] = {
|
||||
{"CPU PM stats", "/sys/devices/system/cpu/cpupm/cpupm/time_in_state"},
|
||||
{"Power supply property battery", "/sys/class/power_supply/battery/uevent"},
|
||||
{"Power supply property dc", "/sys/class/power_supply/dc/uevent"},
|
||||
{"Power supply property gcpm", "/sys/class/power_supply/gcpm/uevent"},
|
||||
{"Power supply property gcpm_pps", "/sys/class/power_supply/gcpm_pps/uevent"},
|
||||
{"Power supply property main-charger", "/sys/class/power_supply/main-charger/uevent"},
|
||||
{"Power supply property pca94xx-mains", "/sys/class/power_supply/pca94xx-mains/uevent"},
|
||||
{"Power supply property tcpm", "/sys/class/power_supply/tcpm-source-psy-i2c-max77759tcpc/uevent"},
|
||||
{"Power supply property usb", "/sys/class/power_supply/usb/uevent"},
|
||||
{"Power supply property wireless", "/sys/class/power_supply/wireless/uevent"},
|
||||
};
|
||||
for (const auto &row : dumpList) {
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
}
|
||||
void dumpMaxFg() {
|
||||
const char *maxfgLoc = "/sys/class/power_supply/maxfg";
|
||||
const char *maxfgDualLoc = "/sys/class/power_supply/maxfg_base";
|
||||
const char *maxfg [][2] = {
|
||||
{"Power supply property maxfg", "/sys/class/power_supply/maxfg/uevent"},
|
||||
{"m5_state", "/sys/class/power_supply/maxfg/m5_model_state"},
|
||||
{"maxfg registers", "/sys/class/power_supply/maxfg/registers_dump"},
|
||||
{"maxfg logbuffer", "/dev/logbuffer_maxfg"},
|
||||
{"maxfg_monitor logbuffer", "/dev/logbuffer_maxfg_monitor"},
|
||||
};
|
||||
const char *maxfgDual [][2] = {
|
||||
{"Power supply property maxfg_base", "/sys/class/power_supply/maxfg_base/uevent"},
|
||||
{"Power supply property maxfg_secondary", "/sys/class/power_supply/maxfg_secondary/uevent"},
|
||||
{"maxfg_base registers", "/sys/class/power_supply/maxfg_base/registers_dump"},
|
||||
{"maxfg_secondary registers", "/sys/class/power_supply/maxfg_secondary/registers_dump"},
|
||||
{"m5_state", "/sys/class/power_supply/maxfg_base/m5_model_state"},
|
||||
{"maxfg_base logbuffer", "/dev/logbuffer_maxfg_base"},
|
||||
{"maxfg_secondary logbuffer", "/dev/logbuffer_maxfg_secondary"},
|
||||
{"maxfg_base logbuffer", "/dev/logbuffer_maxfg_base_monitor"},
|
||||
{"maxfg_secondary logbuffer", "/dev/logbuffer_maxfg_secondary_monitor"},
|
||||
{"dual_batt logbuffer", "/dev/logbuffer_dual_batt"},
|
||||
};
|
||||
const char *maxfgHistoryName = "Maxim FG History";
|
||||
const char *maxfgHistoryDir = "/dev/maxfg_history";
|
||||
std::string content;
|
||||
if (isValidDir(maxfgLoc)) {
|
||||
for (const auto &row : maxfg) {
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
} else if (isValidDir(maxfgDualLoc)){
|
||||
for (const auto &row : maxfgDual) {
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
if (isValidFile(maxfgHistoryDir)) {
|
||||
dumpFileContent(maxfgHistoryName, maxfgHistoryDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
void dumpPowerSupplyDock() {
|
||||
const char* powerSupplyPropertyDockTitle = "Power supply property dock";
|
||||
const char* powerSupplyPropertyDockFile = "/sys/class/power_supply/dock/uevent";
|
||||
dumpFileContent(powerSupplyPropertyDockTitle, powerSupplyPropertyDockFile);
|
||||
}
|
||||
void dumpLogBufferTcpm() {
|
||||
const char* logbufferTcpmTitle = "Logbuffer TCPM";
|
||||
const char* logbufferTcpmFile = "/dev/logbuffer_tcpm";
|
||||
const char* debugTcpmFile = "/sys/kernel/debug/tcpm";
|
||||
const char* tcpmLogTitle = "TCPM logs";
|
||||
const char* tcpmFile = "/sys/kernel/debug/tcpm";
|
||||
const char* tcpmFileAlt = "/sys/kernel/debug/usb/tcpm";
|
||||
int retCode;
|
||||
dumpFileContent(logbufferTcpmTitle, logbufferTcpmFile);
|
||||
retCode = readContentsOfDir(tcpmLogTitle, isValidFile(debugTcpmFile) ? tcpmFile : tcpmFileAlt,
|
||||
NULL);
|
||||
if (retCode < 0)
|
||||
printTitle(tcpmLogTitle);
|
||||
}
|
||||
void dumpTcpc() {
|
||||
const char* max77759TcpcHead = "TCPC Device Attributes";
|
||||
const char* directory = "/sys/class/typec/port0/device";
|
||||
const char* max77759Tcpc [] {
|
||||
"auto_discharge",
|
||||
"bc12_enabled",
|
||||
"cc_toggle_enable",
|
||||
"contaminant_detection",
|
||||
"contaminant_detection_status",
|
||||
"frs",
|
||||
"irq_hpd_count",
|
||||
"manual_disable_vbus",
|
||||
"non_compliant_reasons",
|
||||
"sbu_pullup",
|
||||
"update_sdp_enum_timeout",
|
||||
"usb_limit_accessory_current",
|
||||
"usb_limit_accessory_enable",
|
||||
"usb_limit_sink_current",
|
||||
"usb_limit_sink_enable",
|
||||
"usb_limit_source_enable",
|
||||
};
|
||||
|
||||
std::string content;
|
||||
std::string tcpcRegistersPath(std::string(directory) + "/registers");
|
||||
|
||||
dumpFileContent("TCPC Registers", tcpcRegistersPath.c_str());
|
||||
|
||||
printTitle(max77759TcpcHead);
|
||||
|
||||
for (auto& tcpcVal : max77759Tcpc) {
|
||||
std::string filename = std::string(directory) + "/" + std::string(tcpcVal);
|
||||
printf("%s: ", tcpcVal);
|
||||
android::base::ReadFileToString(filename, &content);
|
||||
if (!content.empty() && (content.back() == '\n' || content.back() == '\r'))
|
||||
content.pop_back();
|
||||
printf("%s\n", content.c_str());
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void dumpPdEngine() {
|
||||
const char* pdEngine [][3] {
|
||||
{"TCPC logbuffer", "/dev/logbuffer_usbpd"},
|
||||
{"pogo_transport logbuffer", "/dev/logbuffer_pogo_transport"},
|
||||
{"PPS-google_cpm logbuffer", "/dev/logbuffer_cpm"},
|
||||
{"PPS-pca9468 logbuffer", "/dev/logbuffer_pca9468"},
|
||||
};
|
||||
for (const auto &row : pdEngine) {
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
}
|
||||
void dumpBatteryHealth() {
|
||||
const char* batteryHealth [][2] {
|
||||
{"Battery Health", "/sys/class/power_supply/battery/health_index_stats"},
|
||||
{"Battery Health SoC Residency", "/sys/class/power_supply/battery/swelling_data"},
|
||||
{"BMS", "/dev/logbuffer_ssoc"},
|
||||
{"TTF", "/dev/logbuffer_ttf"},
|
||||
{"TTF details", "/sys/class/power_supply/battery/ttf_details"},
|
||||
{"TTF stats", "/sys/class/power_supply/battery/ttf_stats"},
|
||||
{"aacr_state", "/sys/class/power_supply/battery/aacr_state"},
|
||||
{"maxq", "/dev/logbuffer_maxq"},
|
||||
{"TEMP/DOCK-DEFEND", "/dev/logbuffer_bd"},
|
||||
};
|
||||
for (const auto &row : batteryHealth) {
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
}
|
||||
void dumpBatteryDefend() {
|
||||
const char* defendConfig [][3] {
|
||||
{"TRICKLE-DEFEND Config",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "bd_"},
|
||||
{"DWELL-DEFEND Config", "/sys/devices/platform/google,charger/", "charge_s"},
|
||||
{"TEMP-DEFEND Config", "/sys/devices/platform/google,charger/", "bd_"},
|
||||
};
|
||||
std::vector<std::string> files;
|
||||
struct dirent *entry;
|
||||
std::string content;
|
||||
std::string fileLocation;
|
||||
for (auto &config : defendConfig) {
|
||||
DIR *dir = opendir(config[1]);
|
||||
if (dir == NULL)
|
||||
continue;
|
||||
printTitle(config[0]);
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (std::string(entry->d_name).find(config[2]) != std::string::npos &&
|
||||
strncmp(config[2], entry->d_name, strlen(config[2])) == 0) {
|
||||
files.push_back(entry->d_name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
sort(files.begin(), files.end());
|
||||
for (auto &file : files) {
|
||||
fileLocation = std::string(config[1]) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content) || content.empty()) {
|
||||
content = "\n";
|
||||
}
|
||||
printf("%s: %s", file.c_str(), content.c_str());
|
||||
if (content.back() != '\n')
|
||||
printf("\n");
|
||||
}
|
||||
files.clear();
|
||||
}
|
||||
}
|
||||
void dumpBatteryCaretaker() {
|
||||
const char* aacpConfig [][3] {
|
||||
{"AACP Version",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "aacp_"},
|
||||
{"AACR Config",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "aacr_"},
|
||||
{"AAFV Config",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "aafv_"},
|
||||
{"AACT Config",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "aact_"},
|
||||
{"AACC",
|
||||
"/sys/devices/platform/google,battery/power_supply/battery/", "aacc"},
|
||||
};
|
||||
std::vector<std::string> files;
|
||||
struct dirent *entry;
|
||||
std::string content;
|
||||
std::string fileLocation;
|
||||
for (auto &config : aacpConfig) {
|
||||
DIR *dir = opendir(config[1]);
|
||||
if (dir == NULL)
|
||||
continue;
|
||||
printTitle(config[0]);
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (std::string(entry->d_name).find(config[2]) != std::string::npos &&
|
||||
strncmp(config[2], entry->d_name, strlen(config[2])) == 0) {
|
||||
files.push_back(entry->d_name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
sort(files.begin(), files.end());
|
||||
for (auto &file : files) {
|
||||
fileLocation = std::string(config[1]) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content) || content.empty()) {
|
||||
content = "\n";
|
||||
}
|
||||
printf("%s: %s", file.c_str(), content.c_str());
|
||||
if (content.back() != '\n')
|
||||
printf("\n");
|
||||
}
|
||||
files.clear();
|
||||
}
|
||||
}
|
||||
void printValuesOfDirectory(const char *directory, std::string debugfs, const char *strMatch) {
|
||||
std::vector<std::string> files;
|
||||
auto info = directory;
|
||||
std::string content;
|
||||
struct dirent *entry;
|
||||
DIR *dir = opendir(debugfs.c_str());
|
||||
if (dir == NULL)
|
||||
return;
|
||||
|
||||
printTitle((debugfs + std::string(strMatch) + "/" + std::string(info)).c_str());
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
if (std::string(entry->d_name).find(strMatch) != std::string::npos)
|
||||
files.push_back(entry->d_name);
|
||||
closedir(dir);
|
||||
|
||||
sort(files.begin(), files.end());
|
||||
|
||||
for (auto &file : files) {
|
||||
std::string fileDirectory = debugfs + file;
|
||||
std::string fileLocation = fileDirectory + "/" + std::string(info);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
content = "\n";
|
||||
}
|
||||
|
||||
printf("%s:\n%s", fileDirectory.c_str(), content.c_str());
|
||||
|
||||
if (content.back() != '\n')
|
||||
printf("\n");
|
||||
}
|
||||
files.clear();
|
||||
}
|
||||
void dumpChg() {
|
||||
const std::string pmic_bus = "/sys/devices/platform/10d60000.hsi2c/i2c-13/13-0066";
|
||||
const char* chg_reg_dump_file = "/sys/class/power_supply/main-charger/device/registers_dump";
|
||||
const std::string chg_name_cmd = "/sys/class/power_supply/main-charger/device/name";
|
||||
const std::string pmic_name_cmd = pmic_bus + "/name";
|
||||
const std::string pmic_reg_dump_file = pmic_bus + "/registers_dump";
|
||||
const std::string reg_dump_str = " registers dump";
|
||||
const char* chgConfig [][2] {
|
||||
{"DC_registers dump", "/sys/class/power_supply/pca94xx-mains/device/registers_dump"},
|
||||
};
|
||||
std::string chg_name;
|
||||
std::string pmic_name;
|
||||
|
||||
printf("\n");
|
||||
|
||||
int ret = android::base::ReadFileToString(chg_name_cmd, &chg_name);
|
||||
if (ret && !chg_name.empty()) {
|
||||
chg_name.erase(chg_name.length() - 1); // remove new line
|
||||
const std::string chg_reg_dump_title = chg_name + reg_dump_str;
|
||||
|
||||
/* CHG reg dump */
|
||||
dumpFileContent(chg_reg_dump_title.c_str(), chg_reg_dump_file);
|
||||
}
|
||||
|
||||
ret = android::base::ReadFileToString(pmic_name_cmd, &pmic_name);
|
||||
if (ret && !pmic_name.empty()) {
|
||||
pmic_name.erase(pmic_name.length() - 1); // remove new line
|
||||
const std::string pmic_reg_dump_title = pmic_name + reg_dump_str;
|
||||
|
||||
/* PMIC reg dump */
|
||||
dumpFileContent(pmic_reg_dump_title.c_str(), pmic_reg_dump_file.c_str());
|
||||
}
|
||||
|
||||
for (auto &config : chgConfig) {
|
||||
dumpFileContent(config[0], config[1]);
|
||||
}
|
||||
}
|
||||
void dumpChgUserDebug() {
|
||||
const std::string debugfs = "/d/";
|
||||
const char *maxFgDir = "/d/maxfg";
|
||||
const char *maxFgStrMatch = "maxfg";
|
||||
const char *maxBaseFgDir = "/d/maxfg_base";
|
||||
const char *maxBaseFgStrMatch = "maxfg_base";
|
||||
const char *chgTblName = "Charging table dump";
|
||||
const char *chgTblDir = "/d/google_battery/chg_raw_profile";
|
||||
|
||||
const char *maxFgInfo [] {
|
||||
"fg_model",
|
||||
"algo_ver",
|
||||
"model_ok",
|
||||
};
|
||||
|
||||
if (isUserBuild())
|
||||
return;
|
||||
|
||||
dumpFileContent(chgTblName, chgTblDir);
|
||||
|
||||
if (isValidDir(maxFgDir)) {
|
||||
for (auto & directory : maxFgInfo) {
|
||||
printValuesOfDirectory(directory, debugfs, maxFgStrMatch);
|
||||
}
|
||||
} else if (isValidDir(maxBaseFgDir)) {
|
||||
for (auto & directory : maxFgInfo) {
|
||||
printValuesOfDirectory(directory, debugfs, maxBaseFgStrMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
void dumpBatteryEeprom() {
|
||||
const char *title = "Battery EEPROM";
|
||||
const char *files[] {
|
||||
"/sys/devices/platform/10da0000.hsi2c/i2c-15/15-0050/eeprom",
|
||||
};
|
||||
std::string result;
|
||||
std::string xxdCmd;
|
||||
printTitle(title);
|
||||
for (auto &file : files) {
|
||||
if (!isValidFile(file))
|
||||
continue;
|
||||
xxdCmd = "xxd " + std::string(file);
|
||||
int ret = getCommandOutput(xxdCmd.c_str(), &result);
|
||||
if (ret < 0)
|
||||
return;
|
||||
printf("%s\n", result.c_str());
|
||||
}
|
||||
}
|
||||
void dumpChargerStats() {
|
||||
const char *chgStatsTitle = "Charger Stats";
|
||||
const char *chgStatsLocation = "/sys/class/power_supply/battery/charge_details";
|
||||
const char *chargerStats [][3] {
|
||||
{"Google Charger", "/sys/kernel/debug/google_charger/", "pps_"},
|
||||
{"Google Battery", "/sys/kernel/debug/google_battery/", "ssoc_"},
|
||||
};
|
||||
std::vector<std::string> files;
|
||||
std::string content;
|
||||
struct dirent *entry;
|
||||
dumpFileContent(chgStatsTitle, chgStatsLocation);
|
||||
if (isUserBuild())
|
||||
return;
|
||||
for (auto &stat : chargerStats) {
|
||||
DIR *dir = opendir(stat[1]);
|
||||
if (dir == NULL)
|
||||
return;
|
||||
printTitle(stat[0]);
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
if (std::string(entry->d_name).find(stat[2]) != std::string::npos)
|
||||
files.push_back(entry->d_name);
|
||||
closedir(dir);
|
||||
sort(files.begin(), files.end());
|
||||
for (auto &file : files) {
|
||||
std::string fileLocation = std::string(stat[1]) + file;
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
content = "\n";
|
||||
}
|
||||
printf("%s: %s", file.c_str(), content.c_str());
|
||||
if (content.back() != '\n')
|
||||
printf("\n");
|
||||
}
|
||||
files.clear();
|
||||
}
|
||||
}
|
||||
void dumpWlcLogs() {
|
||||
const char *dumpWlcList [][2] {
|
||||
{"WLC Logs", "/dev/logbuffer_wireless"},
|
||||
{"WLC VER", "/sys/class/power_supply/wireless/device/version"},
|
||||
{"WLC STATUS", "/sys/class/power_supply/wireless/device/status"},
|
||||
{"WLC FW Version", "/sys/class/power_supply/wireless/device/fw_rev"},
|
||||
{"RTX", "/dev/logbuffer_rtx"},
|
||||
};
|
||||
for (auto &row : dumpWlcList) {
|
||||
if (!isValidFile(row[1]))
|
||||
printTitle(row[0]);
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
}
|
||||
void dumpGvoteables() {
|
||||
const char *directory = "/sys/kernel/debug/gvotables/";
|
||||
const char *statusName = "/status";
|
||||
const char *title = "gvotables";
|
||||
std::string content;
|
||||
std::vector<std::string> files;
|
||||
int ret;
|
||||
if (isUserBuild())
|
||||
return;
|
||||
ret = getFilesInDir(directory, &files);
|
||||
if (ret < 0)
|
||||
return;
|
||||
printTitle(title);
|
||||
for (auto &file : files) {
|
||||
std::string fileLocation = std::string(directory) + file + std::string(statusName);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
printf("%s: %s", file.c_str(), content.c_str());
|
||||
if (content.back() != '\n')
|
||||
printf("\n");
|
||||
}
|
||||
files.clear();
|
||||
}
|
||||
void dumpMitigation() {
|
||||
const char *mitigationList [][2] {
|
||||
{"Lastmeal" , "/data/vendor/mitigation/lastmeal.txt"},
|
||||
{"Thismeal" , "/data/vendor/mitigation/thismeal.txt"},
|
||||
};
|
||||
for (auto &row : mitigationList) {
|
||||
if (!isValidFile(row[1]))
|
||||
printTitle(row[0]);
|
||||
dumpFileContent(row[0], row[1]);
|
||||
}
|
||||
}
|
||||
void dumpMitigationStats() {
|
||||
int ret;
|
||||
const char *directory = "/sys/devices/virtual/pmic/mitigation/last_triggered_count/";
|
||||
const char *capacityDirectory = "/sys/devices/virtual/pmic/mitigation/last_triggered_capacity/";
|
||||
const char *timestampDirectory =
|
||||
"/sys/devices/virtual/pmic/mitigation/last_triggered_timestamp/";
|
||||
const char *voltageDirectory = "/sys/devices/virtual/pmic/mitigation/last_triggered_voltage/";
|
||||
const char *capacitySuffix = "_cap";
|
||||
const char *timeSuffix = "_time";
|
||||
const char *voltageSuffix = "_volt";
|
||||
const char *countSuffix = "_count";
|
||||
const char *title = "Mitigation Stats";
|
||||
std::vector<std::string> files;
|
||||
std::string content;
|
||||
std::string fileLocation;
|
||||
std::string source;
|
||||
std::string subModuleName;
|
||||
int count;
|
||||
int soc;
|
||||
int time;
|
||||
int voltage;
|
||||
ret = getFilesInDir(directory, &files);
|
||||
if (ret < 0)
|
||||
return;
|
||||
printTitle(title);
|
||||
printf("Source\t\tCount\tSOC\tTime\tVoltage\n");
|
||||
for (auto &file : files) {
|
||||
fileLocation = std::string(directory) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
ret = atoi(android::base::Trim(content).c_str());
|
||||
if (ret == -1)
|
||||
continue;
|
||||
count = ret;
|
||||
subModuleName = std::string(file);
|
||||
subModuleName.erase(subModuleName.find(countSuffix), strlen(countSuffix));
|
||||
fileLocation = std::string(capacityDirectory) + std::string(subModuleName) +
|
||||
std::string(capacitySuffix);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
ret = atoi(android::base::Trim(content).c_str());
|
||||
if (ret == -1)
|
||||
continue;
|
||||
soc = ret;
|
||||
fileLocation = std::string(timestampDirectory) + std::string(subModuleName) +
|
||||
std::string(timeSuffix);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
ret = atoi(android::base::Trim(content).c_str());
|
||||
if (ret == -1)
|
||||
continue;
|
||||
time = ret;
|
||||
fileLocation = std::string(voltageDirectory) + std::string(subModuleName) +
|
||||
std::string(voltageSuffix);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
ret = atoi(android::base::Trim(content).c_str());
|
||||
if (ret == -1)
|
||||
continue;
|
||||
voltage = ret;
|
||||
printf("%s \t%i\t%i\t%i\t%i\n", subModuleName.c_str(), count, soc, time, voltage);
|
||||
}
|
||||
}
|
||||
void dumpMitigationDirs() {
|
||||
const int paramCount = 4;
|
||||
const char *titles[] = {
|
||||
"Clock Divider Ratio",
|
||||
"Clock Stats",
|
||||
"Triggered Level",
|
||||
"Instruction",
|
||||
};
|
||||
const char *directories[] = {
|
||||
"/sys/devices/virtual/pmic/mitigation/clock_ratio/",
|
||||
"/sys/devices/virtual/pmic/mitigation/clock_stats/",
|
||||
"/sys/devices/virtual/pmic/mitigation/triggered_lvl/",
|
||||
"/sys/devices/virtual/pmic/mitigation/instruction/",
|
||||
};
|
||||
const char *paramSuffix[] = {"_ratio", "_stats", "_lvl", ""};
|
||||
const char *titleRowVal[] = {
|
||||
"Source\t\tRatio",
|
||||
"Source\t\tStats",
|
||||
"Source\t\tLevel",
|
||||
"",
|
||||
};
|
||||
const int eraseCnt[] = {6, 6, 4, 0};
|
||||
const bool useTitleRow[] = {true, true, true, false};
|
||||
std::vector<std::string> files;
|
||||
std::string content;
|
||||
std::string fileLocation;
|
||||
std::string source;
|
||||
std::string subModuleName;
|
||||
std::string readout;
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
printTitle(titles[i]);
|
||||
if (useTitleRow[i]) {
|
||||
printf("%s\n", titleRowVal[i]);
|
||||
}
|
||||
getFilesInDir(directories[i], &files);
|
||||
for (auto &file : files) {
|
||||
fileLocation = std::string(directories[i]) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
readout = android::base::Trim(content);
|
||||
subModuleName = std::string(file);
|
||||
subModuleName.erase(subModuleName.find(paramSuffix[i]), eraseCnt[i]);
|
||||
if (useTitleRow[i]) {
|
||||
printf("%s \t%s\n", subModuleName.c_str(), readout.c_str());
|
||||
} else {
|
||||
printf("%s=%s\n", subModuleName.c_str(), readout.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void dumpIrqDurationCounts() {
|
||||
const char *title = "IRQ Duration Counts";
|
||||
const char *colNames = "Source\t\t\t\tlt_5ms_cnt\tbt_5ms_to_10ms_cnt\tgt_10ms_cnt\tCode"
|
||||
"\tCurrent Threshold (uA)\tCurrent Reading (uA)\n";
|
||||
const int nonOdpmChannelCnt = 9;
|
||||
const int odpmChCnt = 12;
|
||||
enum Duration {
|
||||
LT_5MS,
|
||||
BT_5MS_10MS,
|
||||
GT_10MS,
|
||||
DUR_MAX,
|
||||
};
|
||||
const char *irqDurDirectories[] = {
|
||||
"/sys/devices/virtual/pmic/mitigation/irq_dur_cnt/less_than_5ms_count",
|
||||
"/sys/devices/virtual/pmic/mitigation/irq_dur_cnt/between_5ms_to_10ms_count",
|
||||
"/sys/devices/virtual/pmic/mitigation/irq_dur_cnt/greater_than_10ms_count",
|
||||
};
|
||||
enum PowerWarn {
|
||||
MAIN,
|
||||
SUB,
|
||||
PWRWARN_MAX,
|
||||
};
|
||||
const char *pwrwarnDirectories[] = {
|
||||
"/sys/devices/virtual/pmic/mitigation/main_pwrwarn/",
|
||||
"/sys/devices/virtual/pmic/mitigation/sub_pwrwarn/",
|
||||
};
|
||||
const char *lpfCurrentDirs[] = {
|
||||
"/sys/devices/platform/acpm_mfd_bus@15500000/i2c-1/1-001f/s2mpg14-meter/"
|
||||
"s2mpg14-odpm/iio:device1/lpf_current",
|
||||
"/sys/devices/platform/acpm_mfd_bus@15510000/i2c-0/0-002f/s2mpg15-meter/"
|
||||
"s2mpg15-odpm/iio:device0/lpf_current",
|
||||
};
|
||||
bool titlesInitialized = false;
|
||||
std::vector<std::string> channelNames;
|
||||
std::vector<std::string> channelData[DUR_MAX];
|
||||
std::vector<std::string> pwrwarnThreshold[PWRWARN_MAX];
|
||||
std::vector<std::string> pwrwarnCode[PWRWARN_MAX];
|
||||
std::vector<std::string> lpfCurrentVals[PWRWARN_MAX];
|
||||
std::vector<std::string> files;
|
||||
std::string content;
|
||||
std::string token;
|
||||
std::string tokenCh;
|
||||
std::string fileLocation;
|
||||
for (int i = 0; i < DUR_MAX; i++) {
|
||||
if (!android::base::ReadFileToString(irqDurDirectories[i], &content)) {
|
||||
return;
|
||||
}
|
||||
std::istringstream tokenStream(content);
|
||||
while (std::getline(tokenStream, token, '\n')) {
|
||||
if (!titlesInitialized) {
|
||||
tokenCh = token;
|
||||
tokenCh.erase(tokenCh.find(':'), tokenCh.length());
|
||||
channelNames.push_back(tokenCh);
|
||||
}
|
||||
// there is a space after the ':' which needs to be removed
|
||||
token.erase(0, token.find(':') + 1);
|
||||
channelData[i].push_back(token);
|
||||
}
|
||||
if (!titlesInitialized)
|
||||
titlesInitialized = true;
|
||||
}
|
||||
for (int i = 0; i < PWRWARN_MAX; i++) {
|
||||
getFilesInDir(pwrwarnDirectories[i], &files);
|
||||
for (auto &file : files) {
|
||||
fileLocation = std::string(pwrwarnDirectories[i]) + std::string(file);
|
||||
if (!android::base::ReadFileToString(fileLocation, &content)) {
|
||||
continue;
|
||||
}
|
||||
std::string readout;
|
||||
readout = android::base::Trim(content);
|
||||
std::string readoutThreshold = readout;
|
||||
readoutThreshold.erase(0, readoutThreshold.find('=') + 1);
|
||||
std::string readoutCode = readout;
|
||||
readoutCode.erase(readoutCode.find('='), readoutCode.length());
|
||||
pwrwarnThreshold[i].push_back(readoutThreshold);
|
||||
pwrwarnCode[i].push_back(readoutCode);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PWRWARN_MAX; i++) {
|
||||
if (!android::base::ReadFileToString(lpfCurrentDirs[i], &content)) {
|
||||
continue;
|
||||
}
|
||||
std::istringstream tokenStream(content);
|
||||
bool first = true;
|
||||
while (std::getline(tokenStream, token, '\n')) {
|
||||
token.erase(0, token.find(' '));
|
||||
if (first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
lpfCurrentVals[i].push_back(token);
|
||||
}
|
||||
}
|
||||
printTitle(title);
|
||||
printf("%s", colNames);
|
||||
for (uint i = 0; i < channelNames.size(); i++) {
|
||||
std::string code = "";
|
||||
std::string threshold = "";
|
||||
std::string current = "";
|
||||
std::string ltDataMsg = "";
|
||||
std::string btDataMsg = "";
|
||||
std::string gtDataMsg = "";
|
||||
int pmicSel = 0;
|
||||
int offset = 0;
|
||||
std::string channelNameSuffix = " \t";
|
||||
if (i >= nonOdpmChannelCnt) {
|
||||
offset = nonOdpmChannelCnt;
|
||||
if (i >= (odpmChCnt + nonOdpmChannelCnt)) {
|
||||
pmicSel = 1;
|
||||
offset = odpmChCnt + nonOdpmChannelCnt;
|
||||
}
|
||||
channelNameSuffix = "";
|
||||
code = pwrwarnCode[pmicSel][i - offset];
|
||||
threshold = pwrwarnThreshold[pmicSel][i - offset];
|
||||
current = lpfCurrentVals[pmicSel][i - offset];
|
||||
}
|
||||
if (i < channelData[0].size())
|
||||
ltDataMsg = channelData[0][i];
|
||||
if (i < channelData[1].size())
|
||||
btDataMsg = channelData[1][i];
|
||||
if (i < channelData[2].size())
|
||||
gtDataMsg = channelData[2][i];
|
||||
std::string adjustedChannelName = channelNames[i] + channelNameSuffix;
|
||||
printf("%s \t%s\t\t%s\t\t\t%s\t\t%s \t%s \t\t%s\n",
|
||||
adjustedChannelName.c_str(),
|
||||
ltDataMsg.c_str(),
|
||||
btDataMsg.c_str(),
|
||||
gtDataMsg.c_str(),
|
||||
code.c_str(),
|
||||
threshold.c_str(),
|
||||
current.c_str());
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
dumpPowerStatsTimes();
|
||||
dumpAcpmStats();
|
||||
dumpPowerSupplyStats();
|
||||
dumpMaxFg();
|
||||
dumpPowerSupplyDock();
|
||||
dumpLogBufferTcpm();
|
||||
dumpTcpc();
|
||||
dumpPdEngine();
|
||||
dumpBatteryHealth();
|
||||
dumpBatteryDefend();
|
||||
dumpBatteryCaretaker();
|
||||
dumpChg();
|
||||
dumpChgUserDebug();
|
||||
dumpBatteryEeprom();
|
||||
dumpChargerStats();
|
||||
dumpWlcLogs();
|
||||
dumpGvoteables();
|
||||
dumpMitigation();
|
||||
dumpMitigationStats();
|
||||
dumpMitigationDirs();
|
||||
dumpIrqDurationCounts();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2020 The Android Open Source Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
soong_namespace {
|
||||
imports: [
|
||||
"hardware/google/pixel",
|
||||
"device/google/gs-common/powerstats",
|
||||
],
|
||||
}
|
||||
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "//device/google/gs201:device_google_gs201_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: [
|
||||
"//device/google/gs201:device_google_gs201_license",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.power.stats-impl.gs201",
|
||||
vendor_available: true,
|
||||
export_include_dirs: ["include"],
|
||||
defaults: ["powerstats_pixel_defaults"],
|
||||
|
||||
srcs: [
|
||||
"*.cpp",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"android.hardware.power.stats-impl.gs-common",
|
||||
"android.hardware.power.stats-impl.pixel",
|
||||
],
|
||||
}
|
||||
@@ -1,666 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <PowerStatsAidl.h>
|
||||
#include <Gs201CommonDataProviders.h>
|
||||
#include <AdaptiveDvfsStateResidencyDataProvider.h>
|
||||
#include <AocTimedStateResidencyDataProvider.h>
|
||||
#include <DevfreqStateResidencyDataProvider.h>
|
||||
#include <DisplayMrrStateResidencyDataProvider.h>
|
||||
#include <DvfsStateResidencyDataProvider.h>
|
||||
#include <UfsStateResidencyDataProvider.h>
|
||||
#include <dataproviders/GenericStateResidencyDataProvider.h>
|
||||
#include <dataproviders/IioEnergyMeterDataProvider.h>
|
||||
#include <dataproviders/PowerStatsEnergyConsumer.h>
|
||||
#include <dataproviders/PowerStatsEnergyAttribution.h>
|
||||
#include <dataproviders/PixelStateResidencyDataProvider.h>
|
||||
#include <dataproviders/WlanStateResidencyDataProvider.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <log/log.h>
|
||||
|
||||
using aidl::android::hardware::power::stats::AdaptiveDvfsStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::AocTimedStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::DevfreqStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::DisplayMrrStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::DvfsStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::UfsStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::EnergyConsumerType;
|
||||
using aidl::android::hardware::power::stats::GenericStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::IioEnergyMeterDataProvider;
|
||||
using aidl::android::hardware::power::stats::PixelStateResidencyDataProvider;
|
||||
using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
|
||||
using aidl::android::hardware::power::stats::WlanStateResidencyDataProvider;
|
||||
|
||||
// TODO (b/181070764) (b/182941084):
|
||||
// Remove this when Wifi/BT energy consumption models are available or revert before ship
|
||||
using aidl::android::hardware::power::stats::EnergyConsumerResult;
|
||||
using aidl::android::hardware::power::stats::Channel;
|
||||
using aidl::android::hardware::power::stats::EnergyMeasurement;
|
||||
class PlaceholderEnergyConsumer : public PowerStats::IEnergyConsumer {
|
||||
public:
|
||||
PlaceholderEnergyConsumer(std::shared_ptr<PowerStats> p, EnergyConsumerType type,
|
||||
std::string name) : kType(type), kName(name), mPowerStats(p), mChannelId(-1) {
|
||||
std::vector<Channel> channels;
|
||||
mPowerStats->getEnergyMeterInfo(&channels);
|
||||
|
||||
for (const auto &c : channels) {
|
||||
if (c.name == "VSYS_PWR_WLAN_BT") {
|
||||
mChannelId = c.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::pair<EnergyConsumerType, std::string> getInfo() override { return {kType, kName}; }
|
||||
|
||||
std::optional<EnergyConsumerResult> getEnergyConsumed(
|
||||
const std::vector<EnergyMeasurement> &energyData) override {
|
||||
int64_t totalEnergyUWs = 0;
|
||||
int64_t timestampMs = 0;
|
||||
if (mChannelId != -1) {
|
||||
int found = 0;
|
||||
for (const auto &e : energyData) {
|
||||
if (mChannelId == e.id) {
|
||||
totalEnergyUWs += e.energyUWs;
|
||||
timestampMs = e.timestampMs;
|
||||
found++;
|
||||
}
|
||||
}
|
||||
if (found == 0) {
|
||||
LOG(ERROR) << "Failed to read energy meter";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return EnergyConsumerResult{.timestampMs = timestampMs,
|
||||
.energyUWs = totalEnergyUWs>>1};
|
||||
}
|
||||
|
||||
std::string getConsumerName() override {
|
||||
return kName;
|
||||
};
|
||||
|
||||
private:
|
||||
const EnergyConsumerType kType;
|
||||
const std::string kName;
|
||||
std::shared_ptr<PowerStats> mPowerStats;
|
||||
int32_t mChannelId;
|
||||
};
|
||||
|
||||
void addPlaceholderEnergyConsumers(std::shared_ptr<PowerStats> p) {
|
||||
p->addEnergyConsumer(
|
||||
std::make_unique<PlaceholderEnergyConsumer>(p, EnergyConsumerType::WIFI, "Wifi"));
|
||||
p->addEnergyConsumer(
|
||||
std::make_unique<PlaceholderEnergyConsumer>(p, EnergyConsumerType::BLUETOOTH, "BT"));
|
||||
}
|
||||
|
||||
void addAoC(std::shared_ptr<PowerStats> p) {
|
||||
// When the given timeout is 0, the timeout will be replaced with "120ms * statesCount".
|
||||
static const uint64_t TIMEOUT_MILLIS = 0;
|
||||
// AoC clock is synced from "libaoc.c"
|
||||
static const uint64_t AOC_CLOCK = 24576;
|
||||
std::string prefix = "/sys/devices/platform/19000000.aoc/control/";
|
||||
|
||||
// Add AoC cores (a32, ff1, hf0, and hf1)
|
||||
std::vector<std::pair<std::string, std::string>> coreIds = {
|
||||
{"AoC-A32", prefix + "a32_"},
|
||||
{"AoC-FF1", prefix + "ff1_"},
|
||||
{"AoC-HF1", prefix + "hf1_"},
|
||||
{"AoC-HF0", prefix + "hf0_"},
|
||||
};
|
||||
std::vector<std::pair<std::string, std::string>> coreStates = {
|
||||
{"DWN", "off"}, {"RET", "retention"}, {"WFI", "wfi"}};
|
||||
p->addStateResidencyDataProvider(std::make_unique<AocTimedStateResidencyDataProvider>(coreIds,
|
||||
coreStates, TIMEOUT_MILLIS, AOC_CLOCK));
|
||||
|
||||
// Add AoC voltage stats
|
||||
std::vector<std::pair<std::string, std::string>> voltageIds = {
|
||||
{"AoC-Voltage", prefix + "voltage_"},
|
||||
};
|
||||
std::vector<std::pair<std::string, std::string>> voltageStates = {{"NOM", "nominal"},
|
||||
{"SUD", "super_underdrive"},
|
||||
{"UUD", "ultra_underdrive"},
|
||||
{"UD", "underdrive"}};
|
||||
p->addStateResidencyDataProvider(
|
||||
std::make_unique<AocTimedStateResidencyDataProvider>(voltageIds, voltageStates,
|
||||
TIMEOUT_MILLIS, AOC_CLOCK));
|
||||
|
||||
// Add AoC monitor mode
|
||||
std::vector<std::pair<std::string, std::string>> monitorIds = {
|
||||
{"AoC", prefix + "monitor_"},
|
||||
};
|
||||
std::vector<std::pair<std::string, std::string>> monitorStates = {
|
||||
{"MON", "mode"},
|
||||
};
|
||||
p->addStateResidencyDataProvider(
|
||||
std::make_unique<AocTimedStateResidencyDataProvider>(monitorIds, monitorStates,
|
||||
TIMEOUT_MILLIS, AOC_CLOCK));
|
||||
|
||||
// Add AoC restart count
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig restartCountConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "",
|
||||
.totalTimeSupported = false,
|
||||
.lastEntrySupported = false,
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> restartCountHeaders = {
|
||||
std::make_pair("RESTART", ""),
|
||||
};
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(
|
||||
generateGenericStateResidencyConfigs(restartCountConfig, restartCountHeaders),
|
||||
"AoC-Count", "");
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/19000000.aoc/restart_count", cfgs));
|
||||
}
|
||||
|
||||
void addDvfsStats(std::shared_ptr<PowerStats> p) {
|
||||
// A constant to represent the number of nanoseconds in one millisecond
|
||||
const int NS_TO_MS = 1000000;
|
||||
std::string path = "/sys/devices/platform/acpm_stats/fvp_stats";
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> adpCfgs = {
|
||||
std::make_pair("CL0", "/sys/devices/system/cpu/cpufreq/policy0/stats"),
|
||||
std::make_pair("CL1", "/sys/devices/system/cpu/cpufreq/policy4/stats"),
|
||||
std::make_pair("CL2", "/sys/devices/system/cpu/cpufreq/policy6/stats")
|
||||
};
|
||||
p->addStateResidencyDataProvider(std::make_unique<AdaptiveDvfsStateResidencyDataProvider>(
|
||||
path, NS_TO_MS, adpCfgs));
|
||||
|
||||
std::vector<DvfsStateResidencyDataProvider::Config> cfgs;
|
||||
|
||||
cfgs.push_back({"TPU", {
|
||||
std::make_pair("1066MHz", "1066000"),
|
||||
std::make_pair("845MHz", "845000"),
|
||||
std::make_pair("627MHz", "627000"),
|
||||
std::make_pair("401MHz", "401000"),
|
||||
std::make_pair("226MHz", "226000"),
|
||||
std::make_pair("0MHz", "0"),
|
||||
}});
|
||||
|
||||
cfgs.push_back({"AUR", {
|
||||
std::make_pair("1160MHz", "1160000"),
|
||||
std::make_pair("750MHz", "750000"),
|
||||
std::make_pair("373MHz", "373000"),
|
||||
std::make_pair("178MHz", "178000"),
|
||||
std::make_pair("0MHz", "0"),
|
||||
}});
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DvfsStateResidencyDataProvider>(
|
||||
path, NS_TO_MS, cfgs));
|
||||
}
|
||||
|
||||
void addSoC(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)> acpmNsToMs = [](uint64_t a) { return a / NS_TO_MS; };
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig lpmStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "success_count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "total_time_ns:",
|
||||
.totalTimeTransform = acpmNsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_entry_time_ns:",
|
||||
.lastEntryTransform = acpmNsToMs,
|
||||
};
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig downStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "down_count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "total_down_time_ns:",
|
||||
.totalTimeTransform = acpmNsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_down_time_ns:",
|
||||
.lastEntryTransform = acpmNsToMs,
|
||||
};
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig reqStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "req_up_count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "total_req_up_time_ns:",
|
||||
.totalTimeTransform = acpmNsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_req_up_time_ns:",
|
||||
.lastEntryTransform = acpmNsToMs,
|
||||
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> powerStateHeaders = {
|
||||
std::make_pair("SICD", "SICD"),
|
||||
std::make_pair("SLEEP", "SLEEP"),
|
||||
std::make_pair("SLEEP_SLCMON", "SLEEP_SLCMON"),
|
||||
std::make_pair("SLEEP_HSI1ON", "SLEEP_HSI1ON"),
|
||||
std::make_pair("STOP", "STOP"),
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> mifReqStateHeaders = {
|
||||
std::make_pair("AOC", "AOC"),
|
||||
std::make_pair("GSA", "GSA"),
|
||||
std::make_pair("TPU", "TPU"),
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> slcReqStateHeaders = {
|
||||
std::make_pair("AOC", "AOC"),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(lpmStateConfig, powerStateHeaders),
|
||||
"LPM", "LPM:");
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(downStateConfig, powerStateHeaders),
|
||||
"MIF", "MIF:");
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(reqStateConfig, mifReqStateHeaders),
|
||||
"MIF-REQ", "MIF_REQ:");
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(downStateConfig, powerStateHeaders),
|
||||
"SLC", "SLC:");
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(reqStateConfig, slcReqStateHeaders),
|
||||
"SLC-REQ", "SLC_REQ:");
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/acpm_stats/soc_stats", cfgs));
|
||||
}
|
||||
|
||||
void setEnergyMeter(std::shared_ptr<PowerStats> p) {
|
||||
std::vector<std::string> deviceNames { "s2mpg12-odpm", "s2mpg13-odpm" };
|
||||
p->setEnergyMeterDataProvider(std::make_unique<IioEnergyMeterDataProvider>(deviceNames, true));
|
||||
}
|
||||
|
||||
void addCPUclusters(std::shared_ptr<PowerStats> p) {
|
||||
// A constant to represent the number of nanoseconds in one millisecond.
|
||||
const int NS_TO_MS = 1000000;
|
||||
|
||||
std::function<uint64_t(uint64_t)> acpmNsToMs = [](uint64_t a) { return a / NS_TO_MS; };
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig cpuStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "down_count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "total_down_time_ns:",
|
||||
.totalTimeTransform = acpmNsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_down_time_ns:",
|
||||
.lastEntryTransform = acpmNsToMs,
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> cpuStateHeaders = {
|
||||
std::make_pair("DOWN", ""),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
for (std::string name : {"CORE00", "CORE01", "CORE02", "CORE03", "CORE10", "CORE11",
|
||||
"CORE20", "CORE21", "CLUSTER0", "CLUSTER1", "CLUSTER2"}) {
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(cpuStateConfig, cpuStateHeaders),
|
||||
name, name);
|
||||
}
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/acpm_stats/core_stats", cfgs));
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::CPU_CLUSTER, "CPUCL0", {"S4M_VDD_CPUCL0"}));
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::CPU_CLUSTER, "CPUCL1", {"S3M_VDD_CPUCL1"}));
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::CPU_CLUSTER, "CPUCL2", {"S2M_VDD_CPUCL2"}));
|
||||
}
|
||||
|
||||
void addGPU(std::shared_ptr<PowerStats> p) {
|
||||
// Add gpu energy consumer
|
||||
std::map<std::string, int32_t> stateCoeffs;
|
||||
|
||||
// TODO (b/197721618): Measuring the GPU power numbers
|
||||
stateCoeffs = {
|
||||
{"202000", 890},
|
||||
{"251000", 1102},
|
||||
{"302000", 1308},
|
||||
{"351000", 1522},
|
||||
{"400000", 1772},
|
||||
{"471000", 2105},
|
||||
{"510000", 2292},
|
||||
{"572000", 2528},
|
||||
{"701000", 3127},
|
||||
{"762000", 3452},
|
||||
{"848000", 4044}};
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
|
||||
EnergyConsumerType::OTHER, "GPU", {"S8S_VDD_G3D_L2", "S2S_VDD_G3D"},
|
||||
{{UID_TIME_IN_STATE, "/sys/devices/platform/28000000.mali/uid_time_in_state"}},
|
||||
stateCoeffs));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>("GPU",
|
||||
"/sys/devices/platform/28000000.mali"));
|
||||
}
|
||||
|
||||
void addMobileRadio(std::shared_ptr<PowerStats> p)
|
||||
{
|
||||
// A constant to represent the number of microseconds in one millisecond.
|
||||
const int US_TO_MS = 1000;
|
||||
|
||||
// modem power_stats are reported in microseconds. The transform function
|
||||
// converts microseconds to milliseconds.
|
||||
std::function<uint64_t(uint64_t)> modemUsToMs = [](uint64_t a) { return a / US_TO_MS; };
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig powerStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "duration_usec:",
|
||||
.totalTimeTransform = modemUsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_entry_timestamp_usec:",
|
||||
.lastEntryTransform = modemUsToMs,
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> powerStateHeaders = {
|
||||
std::make_pair("SLEEP", "SLEEP:"),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(powerStateConfig, powerStateHeaders),
|
||||
"MODEM", "");
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/cpif/modem/power_stats", cfgs));
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::MOBILE_RADIO, "MODEM",
|
||||
{"VSYS_PWR_MODEM", "VSYS_PWR_RFFE", "VSYS_PWR_MMWAVE"}));
|
||||
}
|
||||
|
||||
void addGNSS(std::shared_ptr<PowerStats> p)
|
||||
{
|
||||
// A constant to represent the number of microseconds in one millisecond.
|
||||
const int US_TO_MS = 1000;
|
||||
|
||||
// gnss power_stats are reported in microseconds. The transform function
|
||||
// converts microseconds to milliseconds.
|
||||
std::function<uint64_t(uint64_t)> gnssUsToMs = [](uint64_t a) { return a / US_TO_MS; };
|
||||
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig gnssStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "duration_usec:",
|
||||
.totalTimeTransform = gnssUsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_entry_timestamp_usec:",
|
||||
.lastEntryTransform = gnssUsToMs,
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> gnssStateHeaders = {
|
||||
std::make_pair("ON", "GPS_ON:"),
|
||||
std::make_pair("OFF", "GPS_OFF:"),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(gnssStateConfig, gnssStateHeaders),
|
||||
"GPS", "");
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/dev/bbd_pwrstat", cfgs));
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
|
||||
EnergyConsumerType::GNSS, "GPS", {"L9S_GNSS_CORE"}));
|
||||
}
|
||||
|
||||
void addPCIe(std::shared_ptr<PowerStats> p) {
|
||||
// Add PCIe power entities for Modem and WiFi
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig pcieStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "Cumulative count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "Cumulative duration msec:",
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "Last entry timestamp msec:",
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> pcieStateHeaders = {
|
||||
std::make_pair("UP", "Link up:"),
|
||||
std::make_pair("DOWN", "Link down:"),
|
||||
};
|
||||
|
||||
// Add PCIe - Modem
|
||||
const std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> pcieModemCfgs = {
|
||||
{generateGenericStateResidencyConfigs(pcieStateConfig, pcieStateHeaders), "PCIe-Modem",
|
||||
"Version: 1"}
|
||||
};
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/11920000.pcie/power_stats", pcieModemCfgs));
|
||||
|
||||
// Add PCIe - WiFi
|
||||
const std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> pcieWifiCfgs = {
|
||||
{generateGenericStateResidencyConfigs(pcieStateConfig, pcieStateHeaders),
|
||||
"PCIe-WiFi", "Version: 1"}
|
||||
};
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/14520000.pcie/power_stats", pcieWifiCfgs));
|
||||
}
|
||||
|
||||
void addWifi(std::shared_ptr<PowerStats> p) {
|
||||
// The transform function converts microseconds to milliseconds.
|
||||
std::function<uint64_t(uint64_t)> usecToMs = [](uint64_t a) { return a / 1000; };
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig stateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "duration_usec:",
|
||||
.totalTimeTransform = usecToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_entry_timestamp_usec:",
|
||||
.lastEntryTransform = usecToMs,
|
||||
};
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig pcieStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "duration_usec:",
|
||||
.totalTimeTransform = usecToMs,
|
||||
.lastEntrySupported = false,
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> stateHeaders = {
|
||||
std::make_pair("AWAKE", "AWAKE:"),
|
||||
std::make_pair("ASLEEP", "ASLEEP:"),
|
||||
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> pcieStateHeaders = {
|
||||
std::make_pair("L0", "L0:"),
|
||||
std::make_pair("L1", "L1:"),
|
||||
std::make_pair("L1_1", "L1_1:"),
|
||||
std::make_pair("L1_2", "L1_2:"),
|
||||
std::make_pair("L2", "L2:"),
|
||||
};
|
||||
|
||||
const std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs = {
|
||||
{generateGenericStateResidencyConfigs(stateConfig, stateHeaders), "WIFI", "WIFI"},
|
||||
{generateGenericStateResidencyConfigs(pcieStateConfig, pcieStateHeaders), "WIFI-PCIE",
|
||||
"WIFI-PCIE"}
|
||||
};
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>("/sys/wifi/power_stats",
|
||||
cfgs));
|
||||
}
|
||||
|
||||
void addWlan(std::shared_ptr<PowerStats> p) {
|
||||
p->addStateResidencyDataProvider(std::make_unique<WlanStateResidencyDataProvider>(
|
||||
"WLAN",
|
||||
"/sys/kernel/wifi/power_stats"));
|
||||
}
|
||||
|
||||
void addUfs(std::shared_ptr<PowerStats> p) {
|
||||
p->addStateResidencyDataProvider(std::make_unique<UfsStateResidencyDataProvider>("/sys/bus/platform/devices/14700000.ufs/ufs_stats/"));
|
||||
}
|
||||
|
||||
void addPowerDomains(std::shared_ptr<PowerStats> p) {
|
||||
// A constant to represent the number of nanoseconds in one millisecond.
|
||||
const int NS_TO_MS = 1000000;
|
||||
|
||||
std::function<uint64_t(uint64_t)> acpmNsToMs = [](uint64_t a) { return a / NS_TO_MS; };
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig cpuStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "on_count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "total_on_time_ns:",
|
||||
.totalTimeTransform = acpmNsToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "last_on_time_ns:",
|
||||
.lastEntryTransform = acpmNsToMs,
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> cpuStateHeaders = {
|
||||
std::make_pair("ON", ""),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
for (std::string name : {"pd-aur", "pd-tpu", "pd-bo", "pd-tnr", "pd-gdc", "pd-mcsc", "pd-itp",
|
||||
"pd-ipp", "pd-g3aa", "pd-dns", "pd-pdp", "pd-csis",
|
||||
"pd-mfc", "pd-g2d", "pd-disp", "pd-dpu", "pd-hsi0",
|
||||
"pd-g3d", "pd-embedded_g3d", "pd-eh"}) {
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(cpuStateConfig, cpuStateHeaders),
|
||||
name, name + ":");
|
||||
}
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
"/sys/devices/platform/acpm_stats/pd_stats", cfgs));
|
||||
}
|
||||
|
||||
void addDevfreq(std::shared_ptr<PowerStats> p) {
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"MIF",
|
||||
"/sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"INT",
|
||||
"/sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"INTCAM",
|
||||
"/sys/devices/platform/17000030.devfreq_intcam/devfreq/17000030.devfreq_intcam"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"DISP",
|
||||
"/sys/devices/platform/17000040.devfreq_disp/devfreq/17000040.devfreq_disp"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"CAM",
|
||||
"/sys/devices/platform/17000050.devfreq_cam/devfreq/17000050.devfreq_cam"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"TNR",
|
||||
"/sys/devices/platform/17000060.devfreq_tnr/devfreq/17000060.devfreq_tnr"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"MFC",
|
||||
"/sys/devices/platform/17000070.devfreq_mfc/devfreq/17000070.devfreq_mfc"));
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>(
|
||||
"BO",
|
||||
"/sys/devices/platform/17000080.devfreq_bo/devfreq/17000080.devfreq_bo"));
|
||||
}
|
||||
|
||||
void addTPU(std::shared_ptr<PowerStats> p) {
|
||||
std::map<std::string, int32_t> stateCoeffs;
|
||||
|
||||
stateCoeffs = {
|
||||
// TODO (b/197721618): Measuring the TPU power numbers
|
||||
{"226000", 10},
|
||||
{"627000", 20},
|
||||
{"845000", 30},
|
||||
{"1066000", 40}};
|
||||
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
|
||||
EnergyConsumerType::OTHER, "TPU", {"S10M_VDD_TPU"},
|
||||
{{UID_TIME_IN_STATE, "/sys/class/edgetpu/edgetpu-soc/device/tpu_usage"}},
|
||||
stateCoeffs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlike other data providers, which source power entity state residency data from the kernel,
|
||||
* this data provider acts as a general-purpose channel for state residency data providers
|
||||
* that live in user space. Entities are defined here and user space clients of this provider's
|
||||
* vendor service register callbacks to provide state residency data for their given pwoer entity.
|
||||
*/
|
||||
void addPixelStateResidencyDataProvider(std::shared_ptr<PowerStats> p) {
|
||||
|
||||
auto pixelSdp = std::make_unique<PixelStateResidencyDataProvider>();
|
||||
|
||||
pixelSdp->addEntity("Bluetooth", {{0, "Idle"}, {1, "Active"}, {2, "Tx"}, {3, "Rx"}});
|
||||
|
||||
pixelSdp->start();
|
||||
|
||||
p->addStateResidencyDataProvider(std::move(pixelSdp));
|
||||
}
|
||||
|
||||
void addCamera(std::shared_ptr<PowerStats> p) {
|
||||
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(
|
||||
p,
|
||||
EnergyConsumerType::CAMERA,
|
||||
"CAMERA",
|
||||
{"VSYS_PWR_CAM"}));
|
||||
}
|
||||
|
||||
void addDisplayMrrByEntity(std::shared_ptr<PowerStats> p, std::string name, std::string path) {
|
||||
p->addStateResidencyDataProvider(std::make_unique<DisplayMrrStateResidencyDataProvider>(
|
||||
name, path));
|
||||
}
|
||||
|
||||
void addDisplayMrr(std::shared_ptr<PowerStats> p) {
|
||||
addDisplayMrrByEntity(p, "Display", "/sys/class/drm/card0/device/primary-panel/");
|
||||
}
|
||||
|
||||
void addGs201CommonDataProviders(std::shared_ptr<PowerStats> p) {
|
||||
setEnergyMeter(p);
|
||||
|
||||
addPixelStateResidencyDataProvider(p);
|
||||
addAoC(p);
|
||||
addDvfsStats(p);
|
||||
addSoC(p);
|
||||
addCPUclusters(p);
|
||||
addGPU(p);
|
||||
addMobileRadio(p);
|
||||
addGNSS(p);
|
||||
addPCIe(p);
|
||||
addWifi(p);
|
||||
addUfs(p);
|
||||
addPowerDomains(p);
|
||||
addDevfreq(p);
|
||||
addTPU(p);
|
||||
addCamera(p);
|
||||
}
|
||||
|
||||
void addNFC(std::shared_ptr<PowerStats> p, const std::string& path) {
|
||||
const GenericStateResidencyDataProvider::StateResidencyConfig nfcStateConfig = {
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "Cumulative count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "Cumulative duration msec:",
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "Last entry timestamp msec:",
|
||||
};
|
||||
const std::vector<std::pair<std::string, std::string>> nfcStateHeaders = {
|
||||
std::make_pair("IDLE", "Idle mode:"),
|
||||
std::make_pair("ACTIVE", "Active mode:"),
|
||||
std::make_pair("ACTIVE-RW", "Active Reader/Writer mode:"),
|
||||
};
|
||||
|
||||
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
|
||||
cfgs.emplace_back(generateGenericStateResidencyConfigs(nfcStateConfig, nfcStateHeaders),
|
||||
"NFC", "NFC subsystem");
|
||||
|
||||
p->addStateResidencyDataProvider(std::make_unique<GenericStateResidencyDataProvider>(
|
||||
path, cfgs));
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PowerStatsAidl.h>
|
||||
|
||||
using aidl::android::hardware::power::stats::PowerStats;
|
||||
|
||||
void addAoC(std::shared_ptr<PowerStats> p);
|
||||
void addCPUclusters(std::shared_ptr<PowerStats> p);
|
||||
void addCamera(std::shared_ptr<PowerStats> p);
|
||||
void addDevfreq(std::shared_ptr<PowerStats> p);
|
||||
void addDisplayMrr(std::shared_ptr<PowerStats> p);
|
||||
void addDisplayMrrByEntity(std::shared_ptr<PowerStats> p, std::string name, std::string path);
|
||||
void addDvfsStats(std::shared_ptr<PowerStats> p);
|
||||
void addGNSS(std::shared_ptr<PowerStats> p);
|
||||
void addGs201CommonDataProviders(std::shared_ptr<PowerStats> p);
|
||||
void addMobileRadio(std::shared_ptr<PowerStats> p);
|
||||
void addNFC(std::shared_ptr<PowerStats> p, const std::string& path);
|
||||
void addPCIe(std::shared_ptr<PowerStats> p);
|
||||
void addPixelStateResidencyDataProvider(std::shared_ptr<PowerStats> p);
|
||||
void addPowerDomains(std::shared_ptr<PowerStats> p);
|
||||
void addSoC(std::shared_ptr<PowerStats> p);
|
||||
void addTPU(std::shared_ptr<PowerStats> p);
|
||||
void addUfs(std::shared_ptr<PowerStats> p);
|
||||
void addWifi(std::shared_ptr<PowerStats> p);
|
||||
void addWlan(std::shared_ptr<PowerStats> p);
|
||||
void setEnergyMeter(std::shared_ptr<PowerStats> p);
|
||||
Reference in New Issue
Block a user