Merge "Switch back from DMABUF to ION/BLOB allocator" into sc-dev
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index 87e829e..6a95618 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -133,10 +133,6 @@
# Graphics
#BOARD_USES_EXYNOS_DATASPACE_FEATURE := true
-# Storage options
-BOARD_USES_VENDORIMAGE := true
-TARGET_COPY_OUT_VENDOR := vendor
-
# Enable chain partition for system.
BOARD_AVB_VBMETA_SYSTEM := system system_ext product
BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
@@ -144,6 +140,12 @@
BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1
+# Enable chained vbmeta for boot images
+BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
+BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA2048
+BOARD_AVB_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION := 2
+
TARGET_USERIMAGES_USE_EXT4 := true
TARGET_USERIMAGES_USE_F2FS := true
BOARD_USERDATAIMAGE_PARTITION_SIZE := 11796480000
@@ -363,6 +365,9 @@
# System As Root
BOARD_BUILD_SYSTEM_ROOT_IMAGE := false
+# Vendor ramdisk image for kernel development
+BOARD_BUILD_VENDOR_RAMDISK_IMAGE := true
+
# Kernel modules
BOARD_VENDOR_KERNEL_MODULES += \
$(wildcard $(TARGET_KERNEL_DIR)/*.ko)
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 10cf0fb..1ca5183 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -72,3 +72,8 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.usb@1.3-service.slider)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.usb@1.3-service.slider.rc)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.usb@1.3-service.slider.xml)
+
+# Power Stats HAL 1.0 to AIDL
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.power.stats@1.0-service.gs101)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/vendor/etc/init/android.hardware.power.stats@1.0-service.gs101.rc)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.power.stats@1.0-service.gs101.xml)
diff --git a/compatibility_matrix.xml b/compatibility_matrix.xml
index 1938442..ed29152 100644
--- a/compatibility_matrix.xml
+++ b/compatibility_matrix.xml
@@ -80,7 +80,7 @@
</hal>
<hal format="hidl" optional="true">
<name>vendor.google.wireless_charger</name>
- <version>1.2</version>
+ <version>1.3</version>
<interface>
<name>IWirelessCharger</name>
<instance>default</instance>
diff --git a/conf/fstab.gs101 b/conf/fstab.gs101
index 8bfd58c..d649b1b 100644
--- a/conf/fstab.gs101
+++ b/conf/fstab.gs101
@@ -8,13 +8,14 @@
system_ext /system_ext ext4 ro,barrier=1 wait,slotselect,avb=vbmeta_system,logical,first_stage_mount
product /product ext4 ro,barrier=1 wait,slotselect,avb=vbmeta_system,logical,first_stage_mount
vendor /vendor ext4 ro,barrier=1 wait,slotselect,avb=vbmeta,logical,first_stage_mount
+/dev/block/platform/14700000.ufs/by-name/boot /boot emmc defaults slotselect,avb=boot,first_stage_mount
/dev/block/platform/14700000.ufs/by-name/efs /mnt/vendor/efs ext4 defaults,noatime,rw wait,check,formattable
/dev/block/platform/14700000.ufs/by-name/efs_backup /mnt/vendor/efs_backup ext4 defaults,noatime,rw wait,check,formattable
/dev/block/platform/14700000.ufs/by-name/modem_userdata /mnt/vendor/modem_userdata ext4 defaults,noatime,rw wait,check,formattable
-/dev/block/platform/14700000.ufs/by-name/modem /mnt/vendor/modem_img ext4 ro,defaults wait,slotselect
+/dev/block/platform/14700000.ufs/by-name/modem /mnt/vendor/modem_img ext4 ro,defaults,context=u:object_r:modem_img_file:s0 wait,slotselect
/dev/block/platform/14700000.ufs/by-name/misc /misc emmc defaults wait
/dev/block/platform/14700000.ufs/by-name/metadata /metadata ext4 noatime,nosuid,nodev,data=journal,commit=1 wait,check,formattable,first_stage_mount,metadata_csum
/dev/block/platform/14700000.ufs/by-name/pvmfw /pvmfw emmc defaults wait,slotselect,avb=pvmfw,first_stage_mount
-/dev/block/platform/14700000.ufs/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier,inlinecrypt,compress_extension=apk,compress_extension=apex,compress_extension=so,atgc latemount,wait,check,quota,formattable,sysfs_path=/dev/sys/block/bootdevice,checkpoint=fs,reservedsize=128M,fileencryption=aes-256-xts:aes-256-cts:v2,keydirectory=/metadata/vold/metadata_encryption,fscompress
+/dev/block/platform/14700000.ufs/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier,inlinecrypt,compress_extension=apk,compress_extension=apex,compress_extension=so,atgc,checkpoint_merge latemount,wait,check,quota,formattable,sysfs_path=/dev/sys/block/bootdevice,checkpoint=fs,reservedsize=128M,fileencryption=::inlinecrypt_optimized+wrappedkey_v0,metadata_encryption=:wrappedkey_v0,keydirectory=/metadata/vold/metadata_encryption,fscompress
/dev/block/zram0 none swap defaults zramsize=2147483648,max_comp_streams=8,zram_backingdev_size=512M
/devices/platform/11110000.usb* auto vfat defaults voldmanaged=usb:auto
diff --git a/conf/fstab.gs101.emmc b/conf/fstab.gs101.emmc
deleted file mode 100644
index 076978d..0000000
--- a/conf/fstab.gs101.emmc
+++ /dev/null
@@ -1,12 +0,0 @@
-# Android fstab file.
-#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
-# The filesystem that contains the filesystem checker binary (typically /system) cannot
-# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-
-
-#/dev/block/mmcblk0p2 /system ext4 ro wait
-/dev/block/mmcblk0p3 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait
-/dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,noauto_da_alloc,errors=panic wait
-
-# VOLD
-/devices/13d00000.dwmmc2/mmc_host/mmc1 /storage/sdcard vfat default voldmanaged=sdcard:auto
diff --git a/conf/fstab.gs101.sdboot b/conf/fstab.gs101.sdboot
deleted file mode 100644
index dd87955..0000000
--- a/conf/fstab.gs101.sdboot
+++ /dev/null
@@ -1,14 +0,0 @@
-# Android fstab file.
-#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
-# The filesystem that contains the filesystem checker binary (typically /system) cannot
-# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-
-
-#/dev/block/mmcblk1p2 /system ext4 ro wait
-/dev/block/mmcblk1p4 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait
-/dev/block/mmcblk1p3 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,noauto_da_alloc,errors=panic wait
-/dev/block/mmcblk1p8 /efs ext4 defaults,rw wait
-
-# VOLD
-/devices/10c00000.usb auto vfat default voldmanaged=usb1:auto
-/devices/10c00000.usb/10c00000.dwc3/xhci-hcd auto vfat default voldmanaged=usb2:auto
diff --git a/conf/init.gs101.rc b/conf/init.gs101.rc
index eb36739..c288888 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -17,7 +17,6 @@
on early-init
mkdir /mnt/vendor/efs 0771 radio system
mkdir /mnt/vendor/efs_backup 0771 radio system
- mkdir /mnt/vendor/modem_img 0771 radio system
mkdir /mnt/vendor/modem_userdata 0771 radio system
mkdir /mnt/vendor/persist 0771 system system
mount debugfs /sys/kernel/debug /sys/kernel/debug
@@ -30,7 +29,7 @@
# Boot time fs tuning
write /sys/block/sda/queue/iostats 0
write /sys/block/sda/queue/scheduler bfq
- write /sys/block/sda/queue/iosched/slice_idle 8
+ write /sys/block/sda/queue/iosched/slice_idle 0
write /sys/block/sda/queue/nr_requests 256
write /dev/sys/fs/by-name/userdata/data_io_flag 56
write /dev/sys/fs/by-name/userdata/node_io_flag 56
@@ -216,8 +215,6 @@
on post-fs-data
# Log data folder
- mkdir /data/log 0771 radio system
- mkdir /data/log/abox 0771 audioserver system
mkdir /data/vendor 0771 radio system
mkdir /data/vendor/log 0771 radio system
mkdir /data/vendor/log/cbd 0771 radio system
@@ -260,7 +257,6 @@
mkdir /data/vendor/misc/vpn 0771 root system
# Permissions Camera
- mkdir /data/camera 0777 root root
mkdir /data/vendor/camera 0770 system camera
chmod 0755 /sys/kernel/debug/tracing
restorecon /sys/kernel/debug/tracing/trace_marker
@@ -410,10 +406,6 @@
chown radio system /mnt/vendor/modem_userdata
restorecon_recursive /mnt/vendor/modem_userdata
- # Configure multi-bin radio
- chown radio system /mnt/vendor/modem_img
- restorecon_recursive /mnt/vendor/modem_img
-
restorecon_recursive /mnt/vendor/persist
restorecon_recursive /mnt/vendor/persist/audio
restorecon_recursive /mnt/vendor/persist/sensors
@@ -442,6 +434,27 @@
chown system system /sys/class/backlight/panel0-backlight/hbm_mode
chown system system /sys/devices/platform/exynos-drm/primary-panel/gamma
chown system system /sys/module/drm/parameters/vblankoffdelay
+ chown system system /sys/class/dqe/atc/ambient_light
+ chown system system /sys/class/dqe/atc/st
+ chown system system /sys/class/dqe/atc/en
+ chown system system /sys/class/dqe/atc/lt
+ chown system system /sys/class/dqe/atc/ns
+ chown system system /sys/class/dqe/atc/dither
+ chown system system /sys/class/dqe/atc/pl_w1
+ chown system system /sys/class/dqe/atc/pl_w2
+ chown system system /sys/class/dqe/atc/ctmode
+ chown system system /sys/class/dqe/atc/pp_en
+ chown system system /sys/class/dqe/atc/upgrade_on
+ chown system system /sys/class/dqe/atc/tdr_max
+ chown system system /sys/class/dqe/atc/tdr_min
+ chown system system /sys/class/dqe/atc/back_light
+ chown system system /sys/class/dqe/atc/dstep
+ chown system system /sys/class/dqe/atc/scale_mode
+ chown system system /sys/class/dqe/atc/threshold_1
+ chown system system /sys/class/dqe/atc/threshold_2
+ chown system system /sys/class/dqe/atc/threshold_3
+ chown system system /sys/class/dqe/atc/gain_limit
+ chown system system /sys/class/dqe/atc/lt_calc_ab_shift
# Copy DRM Key
# copy /system/app/wv.keys /factory/wv.keys
@@ -541,6 +554,7 @@
# Runtime fs tuning
write /sys/block/sda/queue/nr_requests 128
write /sys/block/sda/queue/iostats 1
+ write /sys/block/sda/queue/iosched/slice_idle 8
write /dev/sys/fs/by-name/userdata/data_io_flag 8
write /dev/sys/fs/by-name/userdata/node_io_flag 8
diff --git a/device-common.mk b/device-common.mk
index d0e4ca1..f0b2bda 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -20,3 +20,6 @@
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.telephony.carrierlock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.carrierlock.xml
+# Factory OTA
+-include vendor/google/factoryota/client/factoryota.mk
+
diff --git a/device.mk b/device.mk
index 17b0e98..9a8508e 100644
--- a/device.mk
+++ b/device.mk
@@ -57,21 +57,6 @@
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif
-LOCAL_USES_SDMMC_BOOT := false
-LOCAL_USES_UFS_BOOT := true
-LOCAL_USES_EMMC_BOOT := false
-
-# Metadata Encryption
-# Because the kernel interface to dm-default-key changed in Android R,
-# you also need to ensure that you have set the correct value for
-# PRODUCT_SHIPPING_API_LEVEL in device.mk. For example, if your device
-# launches with Android R (API level 30), device.mk should contain:
-# PRODUCT_SHIPPING_API_LEVEL := 30
-# You can also set the following system property to force the use of
-# the new dm-default-key API regardless of shipping API level:
-PRODUCT_PROPERTY_OVERRIDES += \
- ro.crypto.dm_default_key.options_format.version=2
-
# OEM Unlock reporting
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
ro.oem_unlock_supported=1
@@ -221,23 +206,12 @@
# Recovery files
PRODUCT_COPY_FILES += \
device/google/gs101/conf/init.recovery.device.rc:$(TARGET_COPY_OUT_RECOVERY)/root/init.recovery.gs101.rc
-ifeq ($(LOCAL_USES_SDMMC_BOOT),true)
-PRODUCT_COPY_FILES += \
- device/google/gs101/conf/fstab.gs101.sdboot:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.gs101 \
- device/google/gs101/conf/fstab.gs101.sdboot:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.gs101
-else
-ifeq ($(LOCAL_USES_UFS_BOOT),true)
+
+# Fstab files
PRODUCT_COPY_FILES += \
device/google/gs101/conf/fstab.gs101:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.gs101 \
- device/google/gs101/conf/fstab.gs101:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.gs101 \
device/google/gs101/conf/fstab.persist:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.persist \
device/google/gs101/conf/fstab.gs101:$(TARGET_COPY_OUT_VENDOR_RAMDISK)/first_stage_ramdisk/fstab.gs101
-else
-PRODUCT_COPY_FILES += \
- device/google/gs101/conf/fstab.gs101.emmc:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.gs101 \
- device/google/gs101/conf/fstab.gs101.emmc:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.gs101
-endif
-endif
# Shell scripts
PRODUCT_COPY_FILES += \
@@ -281,9 +255,6 @@
tune2fs.vendor_ramdisk \
resize2fs.vendor_ramdisk
-PRODUCT_PROPERTY_OVERRIDES += \
- ro.crypto.volume.filenames_mode=aes-256-cts
-
# Userdata Checkpointing OTA GC
PRODUCT_PACKAGES += \
checkpoint_gc
@@ -393,10 +364,6 @@
# PowerStats HAL
PRODUCT_PACKAGES += \
- android.hardware.power.stats@1.0-service.gs101
-
-# PowerStats AIDL HAL
-PRODUCT_PACKAGES += \
android.hardware.power.stats-service.pixel
# dumpstate HAL
@@ -831,6 +798,10 @@
# Dynamic Partitions
PRODUCT_USE_DYNAMIC_PARTITIONS := true
+# Use FUSE passthrough
+PRODUCT_PRODUCT_PROPERTIES += \
+ persist.sys.fuse.passthrough.enable=true
+
# Use /product/etc/fstab.postinstall to mount system_other
PRODUCT_PRODUCT_PROPERTIES += \
ro.postinstall.fstab.prefix=/product
@@ -978,9 +949,6 @@
Tag \
android.hardware.nfc@1.2-service.st
-PRODUCT_COPY_FILES += \
- device/google/gs101/nfc/libnfc-nci.conf:$(TARGET_COPY_OUT_PRODUCT)/etc/libnfc-nci.conf
-
# SecureElement
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.se.omapi.ese.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.se.omapi.ese.xml \
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index cd5aa6d..7d5bce8 100644
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -377,160 +377,216 @@
// Dump items related to touch
void DumpstateDevice::dumpTouchSection(int fd) {
- const char c2_spi_path[] = "/sys/class/spi_master/spi11/spi11.0";
- const char r3_spi_path[] = "/sys/devices/virtual/sec/tsp";
+ const char stm_cmd_path[4][50] = {"/sys/class/spi_master/spi11/spi11.0",
+ "/proc/fts/driver_test",
+ "/sys/class/spi_master/spi6/spi6.0",
+ "/proc/fts_ext/driver_test"};
+ const char lsi_spi_path[] = "/sys/devices/virtual/sec/tsp";
char cmd[256];
- snprintf(cmd, sizeof(cmd), "%s/appid", c2_spi_path);
- if (!access(cmd, R_OK)) {
- // Touch firmware version
- DumpFileToFd(fd, "STM touch firmware version", cmd);
+ for (int i = 0; i < 4; i+=2) {
+ snprintf(cmd, sizeof(cmd), "%s", stm_cmd_path[i + 1]);
+ if (!access(cmd, R_OK)) {
+ snprintf(cmd, sizeof(cmd), "echo A0 01 > %s", stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Force Set AP as Bus Owner",
+ {"/vendor/bin/sh", "-c", cmd});
+ }
- // Touch controller status
- snprintf(cmd, sizeof(cmd), "%s/status", c2_spi_path);
- DumpFileToFd(fd, "STM touch status", cmd);
+ snprintf(cmd, sizeof(cmd), "%s/appid", stm_cmd_path[i]);
+ if (!access(cmd, R_OK)) {
+ // Touch firmware version
+ DumpFileToFd(fd, "STM touch firmware version", cmd);
- // Mutual raw data
- snprintf(cmd, sizeof(cmd),
- "echo 13 00 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
- c2_spi_path, c2_spi_path);
- RunCommandToFd(fd, "Mutual Raw", {"/vendor/bin/sh", "-c", cmd});
+ // Touch controller status
+ snprintf(cmd, sizeof(cmd), "%s/status", stm_cmd_path[i]);
+ DumpFileToFd(fd, "STM touch status", cmd);
- // Mutual strength data
- snprintf(cmd, sizeof(cmd),
- "echo 17 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
- c2_spi_path, c2_spi_path);
- RunCommandToFd(fd, "Mutual Strength", {"/vendor/bin/sh", "-c", cmd});
+ // Mutual raw data
+ snprintf(cmd, sizeof(cmd),
+ "echo 13 00 01 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
+ stm_cmd_path[i], stm_cmd_path[i]);
+ RunCommandToFd(fd, "Mutual Raw", {"/vendor/bin/sh", "-c", cmd});
- // Self raw data
- snprintf(cmd, sizeof(cmd),
- "echo 15 00 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
- c2_spi_path, c2_spi_path);
- RunCommandToFd(fd, "Self Raw", {"/vendor/bin/sh", "-c", cmd});
+ // Mutual strength data
+ snprintf(cmd, sizeof(cmd),
+ "echo 17 01 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
+ stm_cmd_path[i], stm_cmd_path[i]);
+ RunCommandToFd(fd, "Mutual Strength", {"/vendor/bin/sh", "-c", cmd});
+
+ // Self raw data
+ snprintf(cmd, sizeof(cmd),
+ "echo 15 00 01 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
+ stm_cmd_path[i], stm_cmd_path[i]);
+ RunCommandToFd(fd, "Self Raw", {"/vendor/bin/sh", "-c", cmd});
+ }
+
+ snprintf(cmd, sizeof(cmd), "%s", stm_cmd_path[i + 1]);
+ if (!access(cmd, R_OK)) {
+ snprintf(cmd, sizeof(cmd), "echo 23 00 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Mutual Raw Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 23 03 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Mutual Baseline Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 23 02 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Mutual Strength Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 24 00 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Self Raw Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 24 03 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Self Baseline Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 24 02 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Self Strength Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 32 10 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Mutual Compensation",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 32 11 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Mutual Low Power Compensation",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 33 12 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Self Compensation",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 34 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Golden Mutual Raw Data",
+ {"/vendor/bin/sh", "-c", cmd});
+
+ snprintf(cmd, sizeof(cmd), "echo 01 FA 20 00 00 24 80 > %s",
+ stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Packaging Plant - HW reset",
+ {"/vendor/bin/sh", "-c", cmd});
+ snprintf(cmd, sizeof(cmd), "echo 01 FA 20 00 00 68 08 > %s",
+ stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Packaging Plant - Hibernate Memory",
+ {"/vendor/bin/sh", "-c", cmd});
+ snprintf(cmd, sizeof(cmd),
+ "echo 02 FB 00 04 3F D8 00 10 01 > %s && cat %s",
+ stm_cmd_path[i + 1], stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Packaging Plant - Read 16 bytes from Address 0x00041FD8",
+ {"/vendor/bin/sh", "-c", cmd});
+ }
+
+ snprintf(cmd, sizeof(cmd), "%s/stm_fts_cmd", stm_cmd_path[i]);
+ if (!access(cmd, R_OK)) {
+ // ITO raw data
+ snprintf(cmd, sizeof(cmd),
+ "echo 01 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
+ stm_cmd_path[i], stm_cmd_path[i]);
+ RunCommandToFd(fd, "ITO Raw", {"/vendor/bin/sh", "-c", cmd});
+ }
+
+ if (!access(cmd, R_OK)) {
+ snprintf(cmd, sizeof(cmd), "echo A0 00 > %s", stm_cmd_path[i + 1]);
+ RunCommandToFd(fd, "Restore Bus Owner",
+ {"/vendor/bin/sh", "-c", cmd});
+ }
}
- if (!access("/proc/fts/driver_test", R_OK)) {
- RunCommandToFd(fd, "Mutual Raw Data",
- {"/vendor/bin/sh", "-c",
- "echo 23 00 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Mutual Baseline Data",
- {"/vendor/bin/sh", "-c",
- "echo 23 03 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Mutual Strength Data",
- {"/vendor/bin/sh", "-c",
- "echo 23 02 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Self Raw Data",
- {"/vendor/bin/sh", "-c",
- "echo 24 00 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Self Baseline Data",
- {"/vendor/bin/sh", "-c",
- "echo 24 03 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Self Strength Data",
- {"/vendor/bin/sh", "-c",
- "echo 24 02 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Mutual Compensation",
- {"/vendor/bin/sh", "-c",
- "echo 32 10 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Self Compensation",
- {"/vendor/bin/sh", "-c",
- "echo 33 12 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- RunCommandToFd(fd, "Golden Mutual Raw Data",
- {"/vendor/bin/sh", "-c",
- "echo 34 > /proc/fts/driver_test && "
- "cat /proc/fts/driver_test"});
- }
- if (!access(r3_spi_path, R_OK)) {
+ if (!access(lsi_spi_path, R_OK)) {
// Enable: force touch active
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"force_touch_active,1",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Force Touch Active", {"/vendor/bin/sh", "-c", cmd});
// Firmware info
- snprintf(cmd, sizeof(cmd), "%s/fw_version", r3_spi_path);
+ snprintf(cmd, sizeof(cmd), "%s/fw_version", lsi_spi_path);
DumpFileToFd(fd, "LSI firmware version", cmd);
// Touch status
- snprintf(cmd, sizeof(cmd), "%s/status", r3_spi_path);
+ snprintf(cmd, sizeof(cmd), "%s/status", lsi_spi_path);
DumpFileToFd(fd, "LSI touch status", cmd);
// Calibration info
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"get_mis_cal_info",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Calibration info", {"/vendor/bin/sh", "-c", cmd});
// Mutual strength
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_delta_read_all",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Mutual Strength", {"/vendor/bin/sh", "-c", cmd});
// Self strength
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_self_delta_read_all",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Self Strength", {"/vendor/bin/sh", "-c", cmd});
// Raw cap
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_rawcap_read_all",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Mutual Raw Cap", {"/vendor/bin/sh", "-c", cmd});
// Self raw cap
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_self_rawcap_read_all",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Self Raw Cap", {"/vendor/bin/sh", "-c", cmd});
// TYPE_AMBIENT_DATA
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_rawdata_read_type,3",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "TYPE_AMBIENT_DATA", {"/vendor/bin/sh", "-c", cmd});
// TYPE_DECODED_DATA
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_rawdata_read_type,5",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "TYPE_DECODED_DATA", {"/vendor/bin/sh", "-c", cmd});
// TYPE_NOI_P2P_MIN
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_rawdata_read_type,30",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "TYPE_NOI_P2P_MIN", {"/vendor/bin/sh", "-c", cmd});
// TYPE_NOI_P2P_MAX
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"run_rawdata_read_type,31",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "TYPE_NOI_P2P_MAX", {"/vendor/bin/sh", "-c", cmd});
// Disable: force touch active
snprintf(cmd, sizeof(cmd),
"echo %s > %s/cmd && cat %s/cmd_result",
"force_touch_active,0",
- r3_spi_path, r3_spi_path);
+ lsi_spi_path, lsi_spi_path);
RunCommandToFd(fd, "Force Touch Active", {"/vendor/bin/sh", "-c", cmd});
}
}
diff --git a/interfaces/boot/1.2/BootControl.cpp b/interfaces/boot/1.2/BootControl.cpp
index b754404..8a24334 100644
--- a/interfaces/boot/1.2/BootControl.cpp
+++ b/interfaces/boot/1.2/BootControl.cpp
@@ -17,16 +17,15 @@
#define LOG_TAG "bootcontrolhal"
#include "BootControl.h"
-#include "GptUtils.h"
#include <android-base/file.h>
#include <android-base/unique_fd.h>
#include <bootloader_message/bootloader_message.h>
#include <cutils/properties.h>
-//#include <hardware/boot_control.h>
#include <libboot_control/libboot_control.h>
#include <log/log.h>
+#include "GptUtils.h"
namespace android {
namespace hardware {
@@ -37,12 +36,14 @@
using android::bootable::GetMiscVirtualAbMergeStatus;
using android::bootable::InitMiscVirtualAbMessageIfNeeded;
using android::bootable::SetMiscVirtualAbMergeStatus;
-using android::hardware::boot::V1_1::MergeStatus;
-using android::hardware::boot::V1_0::CommandResult;
using android::hardware::boot::V1_0::BoolResult;
+using android::hardware::boot::V1_0::CommandResult;
+using android::hardware::boot::V1_1::MergeStatus;
namespace {
+// clang-format off
+
#define BOOT_A_PATH "/dev/block/by-name/boot_a"
#define BOOT_B_PATH "/dev/block/by-name/boot_b"
@@ -59,6 +60,8 @@
#define AB_ATTR_MAX_PRIORITY 3UL
#define AB_ATTR_MAX_RETRY_COUNT 3UL
+// clang-format on
+
static std::string getDevPath(uint32_t slot) {
char real_path[PATH_MAX];
@@ -122,17 +125,17 @@
return 0;
}
-}
+} // namespace
// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
Return<uint32_t> BootControl::getNumberSlots() {
uint32_t slots = 0;
if (access(BOOT_A_PATH, F_OK) == 0)
- slots++;
+ slots++;
if (access(BOOT_B_PATH, F_OK) == 0)
- slots++;
+ slots++;
return slots;
}
@@ -189,14 +192,14 @@
return Void();
}
- std::string boot_lun_path = std::string("/sys/devices/platform/") +
- boot_dev + "/pixel/boot_lun_enabled";
+ std::string boot_lun_path =
+ std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled";
int fd = open(boot_lun_path.c_str(), O_RDWR);
if (fd < 0) {
// Try old path for kernels < 5.4
// TODO: remove once kernel 4.19 support is deprecated
- std::string boot_lun_path = std::string("/sys/devices/platform/") +
- boot_dev + "/attributes/boot_lun_enabled";
+ std::string boot_lun_path =
+ std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled";
fd = open(boot_lun_path.c_str(), O_RDWR);
if (fd < 0) {
_hidl_cb({false, "failed to open ufs attr boot_lun_enabled"});
@@ -257,7 +260,8 @@
return isSlotFlagSet(slot, AB_ATTR_UNBOOTABLE) ? BoolResult::FALSE : BoolResult::TRUE;
}
-Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotMarkedSuccessful(uint32_t slot) {
+Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotMarkedSuccessful(
+ uint32_t slot) {
if (getNumberSlots() == 0) {
// just return true so that we don't we another call trying to mark it as successful
// when there is no slots
@@ -278,7 +282,8 @@
return InitMiscVirtualAbMessageIfNeeded();
}
-Return<bool> BootControl::setSnapshotMergeStatus(::android::hardware::boot::V1_1::MergeStatus status) {
+Return<bool> BootControl::setSnapshotMergeStatus(
+ ::android::hardware::boot::V1_1::MergeStatus status) {
return SetMiscVirtualAbMergeStatus(getCurrentSlot(), status);
}
@@ -300,8 +305,7 @@
// Methods from ::android::hidl::base::V1_0::IBase follow.
-
-IBootControl* HIDL_FETCH_IBootControl(const char* /* name */) {
+IBootControl *HIDL_FETCH_IBootControl(const char * /* name */) {
auto module = new BootControl();
module->Init();
diff --git a/interfaces/boot/1.2/BootControl.h b/interfaces/boot/1.2/BootControl.h
index b601779..17b5f0f 100644
--- a/interfaces/boot/1.2/BootControl.h
+++ b/interfaces/boot/1.2/BootControl.h
@@ -26,16 +26,15 @@
namespace V1_2 {
namespace implementation {
+using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
-using ::android::sp;
struct BootControl : public IBootControl {
-
bool Init();
// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
@@ -45,22 +44,23 @@
Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override;
Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override;
Return<::android::hardware::boot::V1_0::BoolResult> isSlotBootable(uint32_t slot) override;
- Return<::android::hardware::boot::V1_0::BoolResult> isSlotMarkedSuccessful(uint32_t slot) override;
+ Return<::android::hardware::boot::V1_0::BoolResult> isSlotMarkedSuccessful(
+ uint32_t slot) override;
Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override;
// Methods from ::android::hardware::boot::V1_1::IBootControl follow.
- Return<bool> setSnapshotMergeStatus(::android::hardware::boot::V1_1::MergeStatus status) override;
+ Return<bool> setSnapshotMergeStatus(
+ ::android::hardware::boot::V1_1::MergeStatus status) override;
Return<::android::hardware::boot::V1_1::MergeStatus> getSnapshotMergeStatus() override;
// Methods from ::android::hardware::boot::V1_2::IBootControl follow.
Return<uint32_t> getActiveBootSlot() override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
-
};
// FIXME: most likely delete, this is only for passthrough implementations
-extern "C" IBootControl* HIDL_FETCH_IBootControl(const char* name);
+extern "C" IBootControl *HIDL_FETCH_IBootControl(const char *name);
} // namespace implementation
} // namespace V1_2
diff --git a/interfaces/boot/1.2/GptUtils.cpp b/interfaces/boot/1.2/GptUtils.cpp
index 514aa89..25088e7 100644
--- a/interfaces/boot/1.2/GptUtils.cpp
+++ b/interfaces/boot/1.2/GptUtils.cpp
@@ -18,10 +18,10 @@
#include "GptUtils.h"
-#include <errno.h>
-#include <log/log.h>
#include <android-base/file.h>
+#include <errno.h>
#include <linux/fs.h>
+#include <log/log.h>
#include <zlib.h>
namespace android {
@@ -32,8 +32,7 @@
namespace {
-static int ValidateGptHeader(gpt_header *gpt)
-{
+static int ValidateGptHeader(gpt_header *gpt) {
if (gpt->signature != GPT_SIGNATURE) {
ALOGE("invalid gpt signature 0x%lx\n", gpt->signature);
return -1;
@@ -52,12 +51,11 @@
return 0;
}
-}
+} // namespace
GptUtils::GptUtils(const std::string dev_path) : dev_path(dev_path), fd(0) {}
-int GptUtils::Load(void)
-{
+int GptUtils::Load(void) {
fd = open(dev_path.c_str(), O_RDWR);
if (fd < 0) {
ALOGE("failed to open block dev %s, %d\n", dev_path.c_str(), errno);
@@ -102,20 +100,19 @@
}
if (ValidateGptHeader(&gpt_backup)) {
- ALOGW("error validating gpt backup\n"); // just warn about it, not fail
+ ALOGW("error validating gpt backup\n"); // just warn about it, not fail
}
// Create map <partition name, gpt_entry pointer>
auto get_name = [](const uint16_t *efi_name) {
char name[37] = {};
- for (int i = 0; efi_name[i] && i < sizeof name - 1; ++i)
- name[i] = efi_name[i];
+ for (int i = 0; efi_name[i] && i < sizeof name - 1; ++i) name[i] = efi_name[i];
return std::string(name);
};
- for (auto const &e: entry_array) {
+ for (auto const &e : entry_array) {
if (e.name[0] == 0)
- break; // stop at the first partition with no name
+ break; // stop at the first partition with no name
std::string s = get_name(e.name);
entries[s] = const_cast<gpt_entry *>(&e);
}
@@ -123,19 +120,17 @@
return 0;
}
-gpt_entry *GptUtils::GetPartitionEntry(std::string name)
-{
- return entries.find(name) != entries.end() ? entries[name] : nullptr;
+gpt_entry *GptUtils::GetPartitionEntry(std::string name) {
+ return entries.find(name) != entries.end() ? entries[name] : nullptr;
}
-int GptUtils::Sync(void)
-{
+int GptUtils::Sync(void) {
if (!fd)
return -1;
// calculate crc and check if we need to update gpt
gpt_primary.entries_crc32 = crc32(0, reinterpret_cast<uint8_t *>(entry_array.data()),
- entry_array.size() * sizeof(gpt_entry));
+ entry_array.size() * sizeof(gpt_entry));
// save old crc
uint32_t crc = gpt_primary.crc32;
@@ -143,7 +138,7 @@
gpt_primary.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_primary), sizeof gpt_primary);
if (crc == gpt_primary.crc32)
- return 0; // nothing to do (no changes)
+ return 0; // nothing to do (no changes)
ALOGI("updating GPT\n");
@@ -161,7 +156,7 @@
return -1;
}
- //update GPT backup entries and backup
+ // update GPT backup entries and backup
lseek64(fd, block_size * gpt_backup.start_lba, SEEK_SET);
ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
if (ret < 0) {
@@ -184,8 +179,7 @@
return 0;
}
-GptUtils::~GptUtils()
-{
+GptUtils::~GptUtils() {
if (fd) {
Sync();
close(fd);
diff --git a/interfaces/boot/1.2/GptUtils.h b/interfaces/boot/1.2/GptUtils.h
index 8965118..a2bed33 100644
--- a/interfaces/boot/1.2/GptUtils.h
+++ b/interfaces/boot/1.2/GptUtils.h
@@ -16,9 +16,9 @@
#pragma once
+#include <map>
#include <string>
#include <vector>
-#include <map>
namespace android {
namespace hardware {
@@ -26,7 +26,7 @@
namespace V1_2 {
namespace implementation {
-#define GPT_SIGNATURE 0x5452415020494645UL
+#define GPT_SIGNATURE 0x5452415020494645UL
typedef struct {
uint8_t type_guid[16];
@@ -55,21 +55,21 @@
} __attribute__((packed)) gpt_header;
class GptUtils {
- public:
+ public:
GptUtils(const std::string dev_path);
int Load(void);
gpt_entry *GetPartitionEntry(std::string name);
int Sync(void);
~GptUtils();
- private:
+ private:
std::string dev_path;
int fd;
uint32_t block_size;
gpt_header gpt_primary;
gpt_header gpt_backup;
std::vector<gpt_entry> entry_array;
- std::map<std::string, gpt_entry *>entries;
+ std::map<std::string, gpt_entry *> entries;
};
} // namespace implementation
diff --git a/interfaces/boot/1.2/service.cpp b/interfaces/boot/1.2/service.cpp
index 158c456..f07682e 100644
--- a/interfaces/boot/1.2/service.cpp
+++ b/interfaces/boot/1.2/service.cpp
@@ -16,10 +16,11 @@
#define LOG_TAG "android.hardware.boot@1.2-service"
-#include <log/log.h>
+#include <android/hardware/boot/1.2/IBootControl.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/Status.h>
-#include <android/hardware/boot/1.2/IBootControl.h>
+#include <log/log.h>
+
#include "BootControl.h"
using ::android::status_t;
@@ -27,9 +28,9 @@
using ::android::hardware::boot::V1_2::IBootControl;
using ::android::hardware::boot::V1_2::implementation::BootControl;
-//using ::android::hardware::boot::implementation::BootControl;
+// using ::android::hardware::boot::implementation::BootControl;
-int main (int /* argc */, char * /* argv */ []) {
+int main(int /* argc */, char * /* argv */[]) {
// This function must be called before you join to ensure the proper
// number of threads are created. The threadpool will never exceed
// size one because of this call.
@@ -38,12 +39,12 @@
::android::sp bootctrl = new BootControl();
const status_t status = bootctrl->registerAsService();
if (status != ::android::OK) {
- return 1; // or handle error
+ return 1; // or handle error
}
// Adds this thread to the threadpool, resulting in one total
// thread in the threadpool. We could also do other things, but
// would have to specify 'false' to willJoin in configureRpcThreadpool.
::android::hardware::joinRpcThreadpool();
- return 1; // joinRpcThreadpool should never return
+ return 1; // joinRpcThreadpool should never return
}
diff --git a/manifest-gralloc3.xml b/manifest-gralloc3.xml
index 3142a99..6b5010c 100644
--- a/manifest-gralloc3.xml
+++ b/manifest-gralloc3.xml
@@ -223,7 +223,7 @@
<hal format="hidl">
<name>vendor.google.wireless_charger</name>
<transport>hwbinder</transport>
- <version>1.2</version>
+ <version>1.3</version>
<interface>
<name>IWirelessCharger</name>
<instance>default</instance>
diff --git a/manifest.xml b/manifest.xml
index 8dd4c31..2c0a308 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -223,7 +223,7 @@
<hal format="hidl">
<name>vendor.google.wireless_charger</name>
<transport>hwbinder</transport>
- <version>1.2</version>
+ <version>1.3</version>
<interface>
<name>IWirelessCharger</name>
<instance>default</instance>
diff --git a/manifest_64-gralloc3.xml b/manifest_64-gralloc3.xml
index 750dbc2..3688484 100644
--- a/manifest_64-gralloc3.xml
+++ b/manifest_64-gralloc3.xml
@@ -212,7 +212,7 @@
<hal format="hidl">
<name>vendor.google.wireless_charger</name>
<transport>hwbinder</transport>
- <version>1.2</version>
+ <version>1.3</version>
<interface>
<name>IWirelessCharger</name>
<instance>default</instance>
diff --git a/manifest_64.xml b/manifest_64.xml
index 7f38648..78f6a01 100644
--- a/manifest_64.xml
+++ b/manifest_64.xml
@@ -212,7 +212,7 @@
<hal format="hidl">
<name>vendor.google.wireless_charger</name>
<transport>hwbinder</transport>
- <version>1.2</version>
+ <version>1.3</version>
<interface>
<name>IWirelessCharger</name>
<instance>default</instance>
diff --git a/nfc/libnfc-nci.conf b/nfc/libnfc-nci.conf
deleted file mode 100644
index c475161..0000000
--- a/nfc/libnfc-nci.conf
+++ /dev/null
@@ -1,108 +0,0 @@
-###############################################################################
-# Application options
-NFC_DEBUG_ENABLED=0
-
-###############################################################################
-# File used for NFA storage
-NFA_STORAGE="/data/nfc"
-
-###############################################################################
-# Force UICC to only listen to the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | NFA_TECHNOLOGY_MASK_F
-UICC_LISTEN_TECH_MASK=0x07
-
-###############################################################################
-# AID for Empty Select command
-# If specified, this AID will be substituted when an Empty SELECT command is
-# detected. The first byte is the length of the AID. Maximum length is 16.
-AID_FOR_EMPTY_SELECT={08:A0:00:00:01:51:00:00:00}
-
-###############################################################################
-# When screen is turned off, specify the desired power state of the controller.
-# 0: power-off-sleep state; DEFAULT
-# 1: full-power state
-# 2: screen-off card-emulation (CE4/CE3/CE1 modes are used)
-SCREEN_OFF_POWER_STATE=1
-
-###############################################################################
-# Force tag polling for the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B |
-# NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 |
-# NFA_TECHNOLOGY_MASK_B_PRIME | NFA_TECHNOLOGY_MASK_KOVIO |
-# NFA_TECHNOLOGY_MASK_ACTIVE
-#
-# Notable bits:
-# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */
-# NFA_TECHNOLOGY_MASK_B 0x02 /* NFC Technology B */
-# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */
-# NFA_TECHNOLOGY_MASK_ISO15693 0x08 /* Proprietary Technology */
-# NFA_TECHNOLOGY_MASK_KOVIO 0x20 /* Proprietary Technology */
-# NFA_TECHNOLOGY_MASK_ACTIVE 0x40 /* NFC Technology Active */
-POLLING_TECH_MASK=0x2F
-
-###############################################################################
-# Force P2P to only listen for the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F |
-# NFA_TECHNOLOGY_MASK_ACTIVE
-#
-# Notable bits:
-# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */
-# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */
-# NFA_TECHNOLOGY_MASK_ACTIVE 0x40 /* NFC Technology Active */
-P2P_LISTEN_TECH_MASK=0x00
-
-PRESERVE_STORAGE=0x01
-
-###############################################################################
-# Override the stack default for NFA_EE_MAX_EE_SUPPORTED set in nfc_target.h.
-# The value is set to 3 by default as it assumes we will discover 0xF2,
-# 0xF3, and 0xF4. If a platform will exclude and SE, this value can be reduced
-# so that the stack will not wait any longer than necessary.
-# Maximum EE supported number
-# NXP PN547C2 0x02
-# NXP PN65T 0x03
-# NXP PN548C2 0x02
-# NXP PN66T 0x03
-NFA_MAX_EE_SUPPORTED=0x02
-
-###############################################################################
-# AID_MATCHING constants
-# AID_MATCHING_EXACT_ONLY 0x00
-# AID_MATCHING_EXACT_OR_PREFIX 0x01
-# AID_MATCHING_PREFIX_ONLY 0x02
-# AID_MATCHING_EXACT_OR_SUBSET_OR_PREFIX 0x03
-AID_MATCHING_MODE=0x03
-
-###############################################################################
-#Set the default Felica T3T System Code :
-#This settings will be used when application does not set this parameter
-DEFAULT_SYS_CODE={FE:FE}
-
-###############################################################################
-# Value of NIC parameter NFCC_COFNIG_CONTROL
-# 0x00 NFCC is not allowed to manage RF configuration
-# 0x01 NFCC is allowed to manage RF configuration
-NFCC_CONFIG_CONTROL=0x01
-
-###############################################################################
-#Set if the AID routing should be blocked for the power modes not supported.
-NFA_AID_BLOCK_ROUTE=1
-
-###############################################################################
-#Set the OffHost AID supported power state:
-OFFHOST_AID_ROUTE_PWR_STATE=0x3B
-
-###############################################################################
-# Mifare Tag implementation
-# 0: General implementation
-# 1: Legacy implementation
-LEGACY_MIFARE_READER=0
-
-###############################################################################
-# Nfc recovery implementation
-# 0: Crash Nfc Service
-# 1: Toggle Nfc state
-RECOVERY_OPTION=1
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 1e2628a..d2d9f0f 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -75,9 +75,6 @@
<!-- Type of the ambient tap sensor. Empty if ambient tap is not supported. -->
<string name="config_dozeTapSensorType" translatable="false">com.google.sensor.single_touch</string>
- <!-- Type of the udfps long press sensor. Empty if long press is not supported. -->
- <string name="config_dozeUdfpsLongPressSensorType" translatable="false">com.google.sensor.long_press</string>
-
<!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->
<bool name="config_unplugTurnsOnScreen">true</bool>
diff --git a/powerstats/Android.bp b/powerstats/Android.bp
index 07e16f1..7c7066c 100644
--- a/powerstats/Android.bp
+++ b/powerstats/Android.bp
@@ -23,50 +23,11 @@
}
cc_binary {
- // TODO(b/167628903) : remove this
- name: "android.hardware.power.stats@1.0-service.gs101",
- header_libs: [
- "device_kernel_headers",
- ],
- relative_install_path: "hw",
- init_rc: ["android.hardware.power.stats@1.0-service.gs101.rc"],
- vintf_fragments: ["android.hardware.power.stats@1.0-service.gs101.xml"],
- srcs: [
- "AocStateResidencyDataProvider.cpp",
- "DvfsStateResidencyDataProvider.cpp",
- "RailDataProvider.cpp",
- "service.cpp",
- "UfsStateResidencyDataProvider.cpp",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
- static_libs: [
- "libpixelpowerstats",
- ],
- shared_libs: [
- "android.hardware.power.stats@1.0",
- "pixelpowerstats_provider_aidl_interface-cpp",
- "libbase",
- "libbinder",
- "libcutils",
- "libfmq",
- "libhidlbase",
- "liblog",
- "libutils",
- ],
- vendor: true,
-}
-
-cc_binary {
name: "android.hardware.power.stats-service.pixel",
init_rc: ["android.hardware.power.stats-service.pixel.rc"],
vintf_fragments: ["android.hardware.power.stats-service.pixel.xml"],
srcs: [
- "AocStateResidencyDataProviderAidl.cpp",
- "DvfsStateResidencyDataProviderAidl.cpp",
- "serviceaidl.cpp"
+ "*.cpp",
],
cflags: [
"-Wall",
@@ -81,6 +42,7 @@
"liblog",
"libutils",
"libbinder_ndk",
+ "pixel_stateresidency_provider_aidl_interface-ndk_platform",
"android.hardware.power.stats-V1-ndk_platform",
],
relative_install_path: "hw",
diff --git a/powerstats/AocStateResidencyDataProvider.cpp b/powerstats/AocStateResidencyDataProvider.cpp
index 41c75bc..c64496d 100644
--- a/powerstats/AocStateResidencyDataProvider.cpp
+++ b/powerstats/AocStateResidencyDataProvider.cpp
@@ -13,29 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define LOG_TAG "libpixelpowerstats"
#include "AocStateResidencyDataProvider.h"
#include <android-base/logging.h>
-#include <utility>
-
+namespace aidl {
namespace android {
namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
+namespace power {
+namespace stats {
-AocStateResidencyDataProvider::AocStateResidencyDataProvider(
- std::vector<std::pair<uint32_t, std::string>> ids,
- std::vector<std::pair<std::string, std::string>> states) {
+AocStateResidencyDataProvider::AocStateResidencyDataProvider(std::vector<std::pair<std::string,
+ std::string>> ids, std::vector<std::pair<std::string, std::string>> states) {
// AoC stats are reported in ticks of 244.140625ns. The transform
// function converts ticks to milliseconds.
// 1000000 / 244.140625 = 4096.
static const uint64_t AOC_CLK = 4096;
std::function<uint64_t(uint64_t)> aocTickToMs = [](uint64_t a) { return a / AOC_CLK; };
- StateResidencyConfig config = {
+ GenericStateResidencyDataProvider::StateResidencyConfig config = {
.entryCountSupported = true,
.entryCountPrefix = "Counter:",
.totalTimeSupported = true,
@@ -45,61 +41,88 @@
.lastEntryPrefix = "Time last entered:",
.lastEntryTransform = aocTickToMs,
};
- uint32_t state_id;
- for (auto &id : ids) {
- state_id = 1;
- for (auto &state : states) {
+ for (const auto &id : ids) {
+ for (const auto &state : states) {
std::vector<std::pair<std::string, std::string>> aocStateHeaders = {
- std::make_pair(state.first, ""),
+ std::make_pair(state.first, ""),
};
+ std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
+ cfgs.emplace_back(generateGenericStateResidencyConfigs(config, aocStateHeaders),
+ id.first, "");
std::unique_ptr<GenericStateResidencyDataProvider> sdp(
- new GenericStateResidencyDataProvider(id.second + state.second));
- sdp->addEntity(id.first, PowerEntityConfig(state_id++, "",
- generateGenericStateResidencyConfigs(
- config, aocStateHeaders)));
- mProviders.push_back(std::move(sdp));
+ new GenericStateResidencyDataProvider(id.second + state.second, cfgs));
+ mProviders[id.first].push_back(std::move(sdp));
}
}
}
-bool AocStateResidencyDataProvider::getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) {
- for (auto &provider : mProviders) {
- provider->getResults(results);
- }
- return true;
-}
-
-std::vector<PowerEntityStateSpace> AocStateResidencyDataProvider::getStateSpaces() {
- // Return state spaces based on all configured providers.
+bool AocStateResidencyDataProvider::getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
// States from the same power entity are merged.
- std::map<uint32_t, PowerEntityStateSpace> stateSpaces;
- for (auto &provider : mProviders) {
- for (auto &stateSpace : provider->getStateSpaces()) {
- auto it = stateSpaces.find(stateSpace.powerEntityId);
- if (it != stateSpaces.end()) {
- auto &states = it->second.states;
- auto size = states.size();
- states.resize(size + stateSpace.states.size());
- for (uint32_t i = 0; i < stateSpace.states.size(); i++) {
- states[size + i] = stateSpace.states[i];
+ bool ret = true;
+ for (const auto &providerList : mProviders) {
+ int32_t stateId = 0;
+ std::string curEntity = providerList.first;
+ std::vector<StateResidency> stateResidencies;
+
+ // Iterate over each provider in the providerList, appending each of the states
+ for (const auto &provider : providerList.second) {
+ std::unordered_map<std::string, std::vector<StateResidency>> residency;
+ ret &= provider->getStateResidencies(&residency);
+
+ // Each provider should only return data for curEntity but checking anyway
+ if (residency.find(curEntity) != residency.end()) {
+ for (auto &r : residency.at(curEntity)) {
+ /*
+ * Modifying stateId here because we are stitching together infos from
+ * multiple GenericStateResidencyDataProviders. stateId must be modified
+ * to maintain uniqueness for a given entity
+ */
+ r.id = stateId++;
+ stateResidencies.push_back(r);
}
- } else {
- stateSpaces.insert(std::pair<uint32_t, PowerEntityStateSpace>(
- stateSpace.powerEntityId, stateSpace));
}
}
- }
- std::vector<PowerEntityStateSpace> ret;
- for (auto &stateSpace : stateSpaces) {
- ret.push_back(stateSpace.second);
+ residencies->emplace(curEntity, stateResidencies);
}
return ret;
}
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
+std::unordered_map<std::string, std::vector<State>> AocStateResidencyDataProvider::getInfo() {
+ // States from the same power entity are merged
+ std::unordered_map<std::string, std::vector<State>> infos;
+ for (const auto &providerList : mProviders) {
+ int32_t stateId = 0;
+ std::string curEntity = providerList.first;
+ std::vector<State> stateInfos;
+
+ // Iterate over each provider in the providerList, appending each of the states
+ for (const auto &provider : providerList.second) {
+ std::unordered_map<std::string, std::vector<State>> info = provider->getInfo();
+
+ // Each provider should only return data for curEntity but checking anyway
+ if (info.find(curEntity) != info.end()) {
+ for (auto &i : info.at(curEntity)) {
+ /*
+ * Modifying stateId because we are stitching together infos from
+ * multiple GenericStateResidencyDataProviders. stateId must be modified
+ * to maintain uniqueness for a given entity
+ */
+ i.id = stateId++;
+ stateInfos.push_back(i);
+ }
+ }
+ }
+
+ infos.emplace(curEntity, stateInfos);
+ }
+
+ return infos;
+}
+
+} // namespace stats
+} // namespace power
} // namespace hardware
} // namespace android
+} // namespace aidl
diff --git a/powerstats/AocStateResidencyDataProvider.h b/powerstats/AocStateResidencyDataProvider.h
index eef7ce7..5008912 100644
--- a/powerstats/AocStateResidencyDataProvider.h
+++ b/powerstats/AocStateResidencyDataProvider.h
@@ -13,35 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef HARDWARE_GOOGLE_PIXEL_POWERSTATS_AOCSTATERESIDENCYDATAPROVIDER_H
-#define HARDWARE_GOOGLE_PIXEL_POWERSTATS_AOCSTATERESIDENCYDATAPROVIDER_H
+#pragma once
-#include <pixelpowerstats/GenericStateResidencyDataProvider.h>
-#include <pixelpowerstats/PowerStats.h>
+#include <dataproviders/GenericStateResidencyDataProvider.h>
+#include <PowerStatsAidl.h>
+namespace aidl {
namespace android {
namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
+namespace power {
+namespace stats {
-class AocStateResidencyDataProvider : public IStateResidencyDataProvider {
+class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
public:
- AocStateResidencyDataProvider(std::vector<std::pair<uint32_t, std::string>> ids,
+ AocStateResidencyDataProvider(std::vector<std::pair<std::string, std::string>> ids,
std::vector<std::pair<std::string, std::string>> states);
~AocStateResidencyDataProvider() = default;
- bool getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) override;
- std::vector<PowerEntityStateSpace> getStateSpaces() override;
+ bool getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
+ std::unordered_map<std::string, std::vector<State>> getInfo() override;
private:
- std::vector<std::unique_ptr<GenericStateResidencyDataProvider>> mProviders;
+ std::unordered_map<std::string /* entity name */,
+ std::vector<std::unique_ptr<GenericStateResidencyDataProvider>> /* providers */> mProviders;
};
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
+} // namespace stats
+} // namespace power
} // namespace hardware
} // namespace android
-
-#endif // HARDWARE_GOOGLE_PIXEL_POWERSTATS_AOCSTATERESIDENCYDATAPROVIDER_H
+} // namespace aidl
\ No newline at end of file
diff --git a/powerstats/AocStateResidencyDataProviderAidl.cpp b/powerstats/AocStateResidencyDataProviderAidl.cpp
deleted file mode 100644
index 3759a66..0000000
--- a/powerstats/AocStateResidencyDataProviderAidl.cpp
+++ /dev/null
@@ -1,128 +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 "AocStateResidencyDataProviderAidl.h"
-
-#include <android-base/logging.h>
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace power {
-namespace stats {
-
-AocStateResidencyDataProvider::AocStateResidencyDataProvider(std::vector<std::pair<std::string,
- std::string>> ids, std::vector<std::pair<std::string, std::string>> states) {
- // AoC stats are reported in ticks of 244.140625ns. The transform
- // function converts ticks to milliseconds.
- // 1000000 / 244.140625 = 4096.
- static const uint64_t AOC_CLK = 4096;
- std::function<uint64_t(uint64_t)> aocTickToMs = [](uint64_t a) { return a / AOC_CLK; };
- GenericStateResidencyDataProvider::StateResidencyConfig config = {
- .entryCountSupported = true,
- .entryCountPrefix = "Counter:",
- .totalTimeSupported = true,
- .totalTimePrefix = "Cumulative time:",
- .totalTimeTransform = aocTickToMs,
- .lastEntrySupported = true,
- .lastEntryPrefix = "Time last entered:",
- .lastEntryTransform = aocTickToMs,
- };
- for (const auto &id : ids) {
- for (const auto &state : states) {
- std::vector<std::pair<std::string, std::string>> aocStateHeaders = {
- std::make_pair(state.first, ""),
- };
- std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
- cfgs.emplace_back(generateGenericStateResidencyConfigs(config, aocStateHeaders),
- id.first, "");
- std::unique_ptr<GenericStateResidencyDataProvider> sdp(
- new GenericStateResidencyDataProvider(id.second + state.second, cfgs));
- mProviders[id.first].push_back(std::move(sdp));
- }
- }
-}
-
-bool AocStateResidencyDataProvider::getStateResidencies(
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
- // States from the same power entity are merged.
- bool ret = true;
- for (const auto &providerList : mProviders) {
- int32_t stateId = 0;
- std::string curEntity = providerList.first;
- std::vector<StateResidency> stateResidencies;
-
- // Iterate over each provider in the providerList, appending each of the states
- for (const auto &provider : providerList.second) {
- std::unordered_map<std::string, std::vector<StateResidency>> residency;
- ret &= provider->getStateResidencies(&residency);
-
- // Each provider should only return data for curEntity but checking anyway
- if (residency.find(curEntity) != residency.end()) {
- for (auto &r : residency.at(curEntity)) {
- /*
- * Modifying stateId here because we are stitching together infos from
- * multiple GenericStateResidencyDataProviders. stateId must be modified
- * to maintain uniqueness for a given entity
- */
- r.id = stateId++;
- stateResidencies.push_back(r);
- }
- }
- }
-
- residencies->emplace(curEntity, stateResidencies);
- }
- return ret;
-}
-
-std::unordered_map<std::string, std::vector<State>> AocStateResidencyDataProvider::getInfo() {
- // States from the same power entity are merged
- std::unordered_map<std::string, std::vector<State>> infos;
- for (const auto &providerList : mProviders) {
- int32_t stateId = 0;
- std::string curEntity = providerList.first;
- std::vector<State> stateInfos;
-
- // Iterate over each provider in the providerList, appending each of the states
- for (const auto &provider : providerList.second) {
- std::unordered_map<std::string, std::vector<State>> info = provider->getInfo();
-
- // Each provider should only return data for curEntity but checking anyway
- if (info.find(curEntity) != info.end()) {
- for (auto &i : info.at(curEntity)) {
- /*
- * Modifying stateId because we are stitching together infos from
- * multiple GenericStateResidencyDataProviders. stateId must be modified
- * to maintain uniqueness for a given entity
- */
- i.id = stateId++;
- stateInfos.push_back(i);
- }
- }
- }
-
- infos.emplace(curEntity, stateInfos);
- }
-
- return infos;
-}
-
-} // namespace stats
-} // namespace power
-} // namespace hardware
-} // namespace android
-} // namespace aidl
diff --git a/powerstats/AocStateResidencyDataProviderAidl.h b/powerstats/AocStateResidencyDataProviderAidl.h
deleted file mode 100644
index 5008912..0000000
--- a/powerstats/AocStateResidencyDataProviderAidl.h
+++ /dev/null
@@ -1,45 +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.
- */
-#pragma once
-
-#include <dataproviders/GenericStateResidencyDataProvider.h>
-#include <PowerStatsAidl.h>
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace power {
-namespace stats {
-
-class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
- public:
- AocStateResidencyDataProvider(std::vector<std::pair<std::string, std::string>> ids,
- std::vector<std::pair<std::string, std::string>> states);
- ~AocStateResidencyDataProvider() = default;
- bool getStateResidencies(
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
- std::unordered_map<std::string, std::vector<State>> getInfo() override;
-
- private:
- std::unordered_map<std::string /* entity name */,
- std::vector<std::unique_ptr<GenericStateResidencyDataProvider>> /* providers */> mProviders;
-};
-
-} // namespace stats
-} // namespace power
-} // namespace hardware
-} // namespace android
-} // namespace aidl
\ No newline at end of file
diff --git a/powerstats/DvfsStateResidencyDataProvider.cpp b/powerstats/DvfsStateResidencyDataProvider.cpp
index 95289bd..511159e 100644
--- a/powerstats/DvfsStateResidencyDataProvider.cpp
+++ b/powerstats/DvfsStateResidencyDataProvider.cpp
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define LOG_TAG "libpixelpowerstats"
-
#include "DvfsStateResidencyDataProvider.h"
#include <android-base/logging.h>
@@ -29,97 +27,90 @@
using android::base::StartsWith;
using android::base::Trim;
+static const std::string nameSuffix = "-DVFS";
+
+namespace aidl {
namespace android {
namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
+namespace power {
+namespace stats {
-DvfsStateResidencyDataProvider::DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate)
- : mPath(std::move(path)), mClockRate(clockRate) {}
+DvfsStateResidencyDataProvider::DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate,
+ std::vector<Config> cfgs)
+ : mPath(std::move(path)), mClockRate(clockRate), mPowerEntities(std::move(cfgs)) {}
-void DvfsStateResidencyDataProvider::addEntity(
- uint32_t id, std::string name, std::vector<std::pair<std::string, std::string>> states) {
- mPowerEntities.push_back({id, name, states});
-}
-
-int32_t DvfsStateResidencyDataProvider::matchEntity(char *line) {
- for (auto const &entity : mPowerEntities) {
- if (entity.powerEntityName == Trim(std::string(line))) {
- return entity.powerEntityId;
+int32_t DvfsStateResidencyDataProvider::matchEntity(char const *line) {
+ for (int32_t i = 0; i < mPowerEntities.size(); i++) {
+ if (mPowerEntities[i].powerEntityName == Trim(std::string(line))) {
+ return i;
}
}
return -1;
}
-int32_t DvfsStateResidencyDataProvider::matchState(char *line, int32_t entityId) {
- uint32_t stateId = 0;
- for (auto const &entity : mPowerEntities) {
- if (entityId == entity.powerEntityId) {
- for (auto const &state : entity.states) {
- if (StartsWith(Trim(std::string(line)), state.second)) {
- return stateId;
- }
- stateId++;
- }
- return -1;
+int32_t DvfsStateResidencyDataProvider::matchState(char const *line, const Config& powerEntity) {
+ for (int32_t i = 0; i < powerEntity.states.size(); i++) {
+ if (StartsWith(Trim(std::string(line)), powerEntity.states[i].second)) {
+ return i;
}
}
return -1;
}
-bool DvfsStateResidencyDataProvider::parseState(char *line, uint64_t &duration, uint64_t &count) {
+bool DvfsStateResidencyDataProvider::parseState(char const *line, uint64_t *duration,
+ uint64_t *count) {
std::vector<std::string> parts = Split(line, " ");
if (parts.size() != 7) {
return false;
}
- if (!ParseUint(Trim(parts[3]), &count)) {
+ if (!ParseUint(Trim(parts[3]), count)) {
return false;
}
- if (!ParseUint(Trim(parts[6]), &duration)) {
+ if (!ParseUint(Trim(parts[6]), duration)) {
return false;
}
return true;
}
-bool DvfsStateResidencyDataProvider::getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) {
+bool DvfsStateResidencyDataProvider::getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
if (!fp) {
- PLOG(ERROR) << __func__ << ":Failed to open file " << mPath
- << " Error = " << strerror(errno);
+ PLOG(ERROR) << __func__ << ":Failed to open file " << mPath;
return false;
}
- for (auto const &stateSpace : getStateSpaces()) {
- PowerEntityStateResidencyResult result = {.powerEntityId = stateSpace.powerEntityId};
- result.stateResidencyData.resize(stateSpace.states.size());
- for (uint32_t i = 0; i < result.stateResidencyData.size(); i++) {
- result.stateResidencyData[i].powerEntityStateId =
- stateSpace.states[i].powerEntityStateId;
+ for (const Config &powerEntity : mPowerEntities) {
+ std::vector<StateResidency> stateResidency(powerEntity.states.size());
+ for (int32_t i = 0; i < stateResidency.size(); i++) {
+ stateResidency[i].id = i;
}
- results.insert(std::make_pair(stateSpace.powerEntityId, result));
+ residencies->emplace(powerEntity.powerEntityName + nameSuffix, stateResidency);
}
size_t len = 0;
char *line = nullptr;
- int32_t temp = -1, entityId = -1, stateId = -1;
+ int32_t temp, powerEntityIndex, stateId = -1;
uint64_t duration, count;
+ auto it = residencies->end();
while (getline(&line, &len, fp.get()) != -1) {
temp = matchEntity(line);
- // Assign entityId only when a new valid entity is encountered.
+ // Assign new index only when a new valid entity is encountered.
if (temp >= 0) {
- entityId = temp;
+ powerEntityIndex = temp;
+ it = residencies->find(mPowerEntities[powerEntityIndex].powerEntityName + nameSuffix);
}
- if (entityId >= 0) {
- stateId = matchState(line, entityId);
+
+ if (it != residencies->end()) {
+ stateId = matchState(line, mPowerEntities[powerEntityIndex]);
+
if (stateId >= 0) {
- if (parseState(line, duration, count)) {
- results[entityId].stateResidencyData[stateId].totalTimeInStateMs =
+ if (parseState(line, &duration, &count)) {
+ it->second[stateId].totalTimeInStateMs =
duration / mClockRate;
- results[entityId].stateResidencyData[stateId].totalStateEntryCount = count;
+ it->second[stateId].totalStateEntryCount = count;
} else {
LOG(ERROR) << "Failed to parse duration and count from [" << std::string(line)
<< "]";
@@ -134,25 +125,25 @@
return true;
}
-std::vector<PowerEntityStateSpace> DvfsStateResidencyDataProvider::getStateSpaces() {
- std::vector<PowerEntityStateSpace> stateSpaces;
- stateSpaces.reserve(mPowerEntities.size());
+std::unordered_map<std::string, std::vector<State>> DvfsStateResidencyDataProvider::getInfo() {
+ std::unordered_map<std::string, std::vector<State>> info;
for (auto const &entity : mPowerEntities) {
- PowerEntityStateSpace s = {.powerEntityId = entity.powerEntityId};
- s.states.resize(entity.states.size());
- uint32_t stateId = 0;
+ std::vector<State> stateInfo(entity.states.size());
+ int32_t stateId = 0;
for (auto const &state : entity.states) {
- s.states[stateId] = {.powerEntityStateId = stateId,
- .powerEntityStateName = state.first};
+ stateInfo[stateId] = State{
+ .id = stateId,
+ .name = state.first
+ };
stateId++;
}
- stateSpaces.emplace_back(s);
+ info.emplace(entity.powerEntityName + nameSuffix, stateInfo);
}
- return stateSpaces;
+ return info;
}
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
+} // namespace stats
+} // namespace power
} // namespace hardware
} // namespace android
+} // namespace aidl
diff --git a/powerstats/DvfsStateResidencyDataProvider.h b/powerstats/DvfsStateResidencyDataProvider.h
index ffa1414..ca8ab22 100644
--- a/powerstats/DvfsStateResidencyDataProvider.h
+++ b/powerstats/DvfsStateResidencyDataProvider.h
@@ -13,71 +13,56 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef HARDWARE_GOOGLE_PIXEL_POWERSTATS_DVFSSTATERESIDENCYDATAPROVIDER_H
-#define HARDWARE_GOOGLE_PIXEL_POWERSTATS_DVFSSTATERESIDENCYDATAPROVIDER_H
+#pragma once
-#include <pixelpowerstats/PowerStats.h>
+#include <PowerStatsAidl.h>
+namespace aidl {
namespace android {
namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
+namespace power {
+namespace stats {
-class DvfsStateResidencyDataProvider : public IStateResidencyDataProvider {
+class DvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
public:
- /*
- * path - path to dvfs sysfs node.
- * clockRate - clock rate in KHz.
- */
- DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate);
- ~DvfsStateResidencyDataProvider() = default;
-
- /*
- * id - the power entity id
- * name - the power entity name to parse from sysfs node
- * frequencies - list of pairs (frequency display name, frequency in sysfs
- * node).
- */
- void addEntity(uint32_t id, std::string name,
- std::vector<std::pair<std::string, std::string>> frequencies);
-
- /*
- * See IStateResidencyDataProvider::getResults.
- */
- bool getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) override;
-
- /*
- * See IStateResidencyDataProvider::getStateSpaces.
- */
- std::vector<PowerEntityStateSpace> getStateSpaces() override;
-
- private:
- int32_t matchEntity(char *line);
- int32_t matchState(char *line, int32_t entityId);
- bool parseState(char *line, uint64_t &duration, uint64_t &count);
-
- const std::string mPath;
- const uint64_t mClockRate;
-
- struct config {
- // Power entity id.
- uint32_t powerEntityId;
-
+ class Config {
+ public:
// Power entity name to parse.
std::string powerEntityName;
// List of state pairs (name to display, name to parse).
std::vector<std::pair<std::string, std::string>> states;
};
- std::vector<config> mPowerEntities;
+ /*
+ * path - path to dvfs sysfs node.
+ * clockRate - clock rate in KHz.
+ */
+ DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate, std::vector<Config> cfgs);
+ ~DvfsStateResidencyDataProvider() = default;
+
+ /*
+ * See IStateResidencyDataProvider::getStateResidencies
+ */
+ bool getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
+
+ /*
+ * See IStateResidencyDataProvider::getInfo
+ */
+ std::unordered_map<std::string, std::vector<State>> getInfo() override;
+
+ private:
+ int32_t matchEntity(char const *line);
+ int32_t matchState(char const *line, const Config& powerEntity);
+ bool parseState(char const *line, uint64_t *duration, uint64_t *count);
+
+ const std::string mPath;
+ const uint64_t mClockRate;
+ std::vector<Config> mPowerEntities;
};
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
+} // namespace stats
+} // namespace power
} // namespace hardware
} // namespace android
-
-#endif // HARDWARE_GOOGLE_PIXEL_POWERSTATS_DVFSSTATERESIDENCYDATAPROVIDER_H
+} // namespace aidl
diff --git a/powerstats/DvfsStateResidencyDataProviderAidl.cpp b/powerstats/DvfsStateResidencyDataProviderAidl.cpp
deleted file mode 100644
index ca6ea9a..0000000
--- a/powerstats/DvfsStateResidencyDataProviderAidl.cpp
+++ /dev/null
@@ -1,149 +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 "DvfsStateResidencyDataProviderAidl.h"
-
-#include <android-base/logging.h>
-#include <android-base/parseint.h>
-#include <android-base/strings.h>
-
-#include <string>
-#include <utility>
-
-using android::base::ParseUint;
-using android::base::Split;
-using android::base::StartsWith;
-using android::base::Trim;
-
-static const std::string nameSuffix = "-DVFS";
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace power {
-namespace stats {
-
-DvfsStateResidencyDataProvider::DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate,
- std::vector<Config> cfgs)
- : mPath(std::move(path)), mClockRate(clockRate), mPowerEntities(std::move(cfgs)) {}
-
-int32_t DvfsStateResidencyDataProvider::matchEntity(char const *line) {
- for (int32_t i = 0; i < mPowerEntities.size(); i++) {
- if (mPowerEntities[i].powerEntityName == Trim(std::string(line))) {
- return i;
- }
- }
- return -1;
-}
-
-int32_t DvfsStateResidencyDataProvider::matchState(char const *line, const Config& powerEntity) {
- for (int32_t i = 0; i < powerEntity.states.size(); i++) {
- if (StartsWith(Trim(std::string(line)), powerEntity.states[i].second)) {
- return i;
- }
- }
- return -1;
-}
-
-bool DvfsStateResidencyDataProvider::parseState(char const *line, uint64_t *duration,
- uint64_t *count) {
- std::vector<std::string> parts = Split(line, " ");
- if (parts.size() != 7) {
- return false;
- }
- if (!ParseUint(Trim(parts[3]), count)) {
- return false;
- }
- if (!ParseUint(Trim(parts[6]), duration)) {
- return false;
- }
- return true;
-}
-
-bool DvfsStateResidencyDataProvider::getStateResidencies(
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
- std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
- if (!fp) {
- PLOG(ERROR) << __func__ << ":Failed to open file " << mPath;
- return false;
- }
-
- for (const Config &powerEntity : mPowerEntities) {
- std::vector<StateResidency> stateResidency(powerEntity.states.size());
- for (int32_t i = 0; i < stateResidency.size(); i++) {
- stateResidency[i].id = i;
- }
- residencies->emplace(powerEntity.powerEntityName + nameSuffix, stateResidency);
- }
-
- size_t len = 0;
- char *line = nullptr;
-
- int32_t temp, powerEntityIndex, stateId = -1;
- uint64_t duration, count;
- auto it = residencies->end();
-
- while (getline(&line, &len, fp.get()) != -1) {
- temp = matchEntity(line);
- // Assign new index only when a new valid entity is encountered.
- if (temp >= 0) {
- powerEntityIndex = temp;
- it = residencies->find(mPowerEntities[powerEntityIndex].powerEntityName + nameSuffix);
- }
-
- if (it != residencies->end()) {
- stateId = matchState(line, mPowerEntities[powerEntityIndex]);
-
- if (stateId >= 0) {
- if (parseState(line, &duration, &count)) {
- it->second[stateId].totalTimeInStateMs =
- duration / mClockRate;
- it->second[stateId].totalStateEntryCount = count;
- } else {
- LOG(ERROR) << "Failed to parse duration and count from [" << std::string(line)
- << "]";
- return false;
- }
- }
- }
- }
-
- free(line);
-
- return true;
-}
-
-std::unordered_map<std::string, std::vector<State>> DvfsStateResidencyDataProvider::getInfo() {
- std::unordered_map<std::string, std::vector<State>> info;
- for (auto const &entity : mPowerEntities) {
- std::vector<State> stateInfo(entity.states.size());
- int32_t stateId = 0;
- for (auto const &state : entity.states) {
- stateInfo[stateId] = State{
- .id = stateId,
- .name = state.first
- };
- stateId++;
- }
- info.emplace(entity.powerEntityName + nameSuffix, stateInfo);
- }
- return info;
-}
-
-} // namespace stats
-} // namespace power
-} // namespace hardware
-} // namespace android
-} // namespace aidl
diff --git a/powerstats/DvfsStateResidencyDataProviderAidl.h b/powerstats/DvfsStateResidencyDataProviderAidl.h
deleted file mode 100644
index ca8ab22..0000000
--- a/powerstats/DvfsStateResidencyDataProviderAidl.h
+++ /dev/null
@@ -1,68 +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.
- */
-#pragma once
-
-#include <PowerStatsAidl.h>
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace power {
-namespace stats {
-
-class DvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
- public:
- class Config {
- public:
- // Power entity name to parse.
- std::string powerEntityName;
-
- // List of state pairs (name to display, name to parse).
- std::vector<std::pair<std::string, std::string>> states;
- };
- /*
- * path - path to dvfs sysfs node.
- * clockRate - clock rate in KHz.
- */
- DvfsStateResidencyDataProvider(std::string path, uint64_t clockRate, std::vector<Config> cfgs);
- ~DvfsStateResidencyDataProvider() = default;
-
- /*
- * See IStateResidencyDataProvider::getStateResidencies
- */
- bool getStateResidencies(
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
-
- /*
- * See IStateResidencyDataProvider::getInfo
- */
- std::unordered_map<std::string, std::vector<State>> getInfo() override;
-
- private:
- int32_t matchEntity(char const *line);
- int32_t matchState(char const *line, const Config& powerEntity);
- bool parseState(char const *line, uint64_t *duration, uint64_t *count);
-
- const std::string mPath;
- const uint64_t mClockRate;
- std::vector<Config> mPowerEntities;
-};
-
-} // namespace stats
-} // namespace power
-} // namespace hardware
-} // namespace android
-} // namespace aidl
diff --git a/powerstats/RailDataProvider.cpp b/powerstats/RailDataProvider.cpp
deleted file mode 100644
index d0efc17..0000000
--- a/powerstats/RailDataProvider.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#define LOG_TAG "libpixelpowerstats"
-
-#include "RailDataProvider.h"
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-#include <inttypes.h>
-#include <stdlib.h>
-
-#include <algorithm>
-#include <exception>
-#include <thread>
-
-namespace android {
-namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
-
-#define MAX_FILE_PATH_LEN 128
-#define MAX_DEVICE_NAME_LEN 64
-#define MAX_QUEUE_SIZE 8192
-
-constexpr char kIioDirRoot[] = "/sys/bus/iio/devices/";
-const char *const kDeviceNames[] = {"s2mpg10-odpm", "s2mpg11-odpm"};
-constexpr char kDeviceType[] = "iio:device";
-constexpr uint32_t MAX_SAMPLING_RATE = 10;
-constexpr uint64_t WRITE_TIMEOUT_NS = 1000000000;
-
-#define MAX_RAIL_NAME_LEN 50
-#define STR(s) #s
-#define XSTR(s) STR(s)
-
-void RailDataProvider::findIioPowerMonitorNodes() {
- struct dirent *ent;
- int fd;
- char devName[MAX_DEVICE_NAME_LEN];
- char filePath[MAX_FILE_PATH_LEN];
- DIR *iioDir = opendir(kIioDirRoot);
- if (!iioDir) {
- ALOGE("Error opening directory: %s, error: %d", kIioDirRoot, errno);
- return;
- }
- while (ent = readdir(iioDir), ent) {
- if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0 &&
- strlen(ent->d_name) > strlen(kDeviceType) &&
- strncmp(ent->d_name, kDeviceType, strlen(kDeviceType)) == 0) {
- snprintf(filePath, MAX_FILE_PATH_LEN, "%s/%s", ent->d_name, "name");
- fd = openat(dirfd(iioDir), filePath, O_RDONLY);
- if (fd < 0) {
- ALOGW("Failed to open directory: %s, error: %d", filePath, errno);
- continue;
- }
- if (read(fd, devName, MAX_DEVICE_NAME_LEN) < 0) {
- ALOGW("Failed to read device name from file: %s(%d)", filePath, fd);
- close(fd);
- continue;
- }
-
- for (const auto &kDeviceName : kDeviceNames) {
- if (strncmp(devName, kDeviceName, strlen(kDeviceName)) == 0) {
- snprintf(filePath, MAX_FILE_PATH_LEN, "%s/%s", kIioDirRoot, ent->d_name);
- mOdpm.devicePaths.push_back(filePath);
- }
- }
- close(fd);
- }
- }
- closedir(iioDir);
- return;
-}
-
-size_t RailDataProvider::parsePowerRails() {
- std::string data;
- std::string railFileName;
- std::string spsFileName;
- uint32_t index = 0;
- uint32_t samplingRate;
- for (const auto &path : mOdpm.devicePaths) {
- railFileName = path + "/enabled_rails";
- spsFileName = path + "/sampling_rate";
- if (!android::base::ReadFileToString(spsFileName, &data)) {
- ALOGW("Error reading file: %s", spsFileName.c_str());
- continue;
- }
- samplingRate = strtoul(data.c_str(), NULL, 10);
- if (!samplingRate || samplingRate == ULONG_MAX) {
- ALOGE("Error parsing: %s", spsFileName.c_str());
- break;
- }
- if (!android::base::ReadFileToString(railFileName, &data)) {
- ALOGW("Error reading file: %s", railFileName.c_str());
- continue;
- }
- std::istringstream railNames(data);
- std::string line;
- while (std::getline(railNames, line)) {
- std::vector<std::string> words = android::base::Split(line, ":][");
- if (words.size() == 4) {
- const std::string channelName = words[1];
- if (mOdpm.railsInfo.count(channelName) == 0) {
- const std::string subsysName = words[3];
- mOdpm.railsInfo.emplace(channelName, RailData{.devicePath = path,
- .index = index,
- .subsysName = subsysName,
- .samplingRate = samplingRate});
- index++;
- } else {
- ALOGW("There exists rails with the same name (not supported): %s." \
- " Only the last occurrence of rail energy will be provided.",
- channelName.c_str());
- }
- } else {
- ALOGW("Unexpected format in file: %s", railFileName.c_str());
- }
- }
- }
- return index;
-}
-
-int RailDataProvider::parseIioEnergyNodeString(const std::string &contents, OnDeviceMmt &odpm) {
- std::istringstream energyData(contents);
- std::string line;
-
- int ret = 0;
- uint64_t timestamp = 0;
- bool timestampRead = false;
-
- while (std::getline(energyData, line)) {
- bool parseLineSuccess = false;
-
- if (timestampRead == false) {
- /* Read timestamp from boot (ms) */
- if (sscanf(line.c_str(), "t=%" PRIu64, ×tamp) == 1) {
- if (timestamp == 0 || timestamp == ULLONG_MAX) {
- ALOGW("Potentially wrong timestamp: %" PRIu64, timestamp);
- }
- timestampRead = true;
- parseLineSuccess = true;
- }
-
- } else {
- /* Read rail energy */
- uint64_t energy = 0;
- char railNameRaw[MAX_RAIL_NAME_LEN + 1];
- if (sscanf(line.c_str(),
- "CH%*d(T=%*" PRIu64 ")[%" XSTR(MAX_RAIL_NAME_LEN) "[^]]], %" PRIu64,
- railNameRaw, &energy) == 2) {
- std::string railName(railNameRaw);
-
- /* If the count == 0, the rail may not be enabled */
- /* The count cannot be > 1; mChannelIds is a map */
- if (odpm.railsInfo.count(railName) == 1) {
- size_t index = odpm.railsInfo[railName].index;
- odpm.reading[index].index = index;
- odpm.reading[index].timestamp = timestamp;
- odpm.reading[index].energy = energy;
- if (odpm.reading[index].energy == ULLONG_MAX) {
- ALOGW("Potentially wrong energy value on rail: %s", railName.c_str());
- }
- }
- parseLineSuccess = true;
- }
- }
-
- if (parseLineSuccess == false) {
- ret = -1;
- break;
- }
- }
-
- return ret;
-}
-
-int RailDataProvider::parseIioEnergyNode(std::string devName) {
- int ret;
- std::string data;
- std::string fileName = devName + "/energy_value";
- if (!android::base::ReadFileToString(fileName, &data)) {
- ALOGE("Error reading file: %s", fileName.c_str());
- return -1;
- }
-
- ret = parseIioEnergyNodeString(data, mOdpm);
- if (ret != 0) {
- ALOGW("Unexpected format in file: %s", fileName.c_str());
- }
- return ret;
-}
-
-Status RailDataProvider::parseIioEnergyNodes() {
- Status ret = Status::SUCCESS;
- if (mOdpm.hwEnabled == false) {
- return Status::NOT_SUPPORTED;
- }
-
- for (const auto &devicePath : mOdpm.devicePaths) {
- if (parseIioEnergyNode(devicePath) < 0) {
- ALOGE("Error in parsing power stats");
- ret = Status::FILESYSTEM_ERROR;
- break;
- }
- }
- return ret;
-}
-
-RailDataProvider::RailDataProvider() {
- findIioPowerMonitorNodes();
- size_t numRails = parsePowerRails();
- if (mOdpm.devicePaths.empty() || numRails == 0) {
- mOdpm.hwEnabled = false;
- } else {
- mOdpm.hwEnabled = true;
- mOdpm.reading.resize(numRails);
- }
-}
-
-Return<void> RailDataProvider::getRailInfo(IPowerStats::getRailInfo_cb _hidl_cb) {
- hidl_vec<RailInfo> rInfo;
- Status ret = Status::SUCCESS;
- size_t index;
- std::lock_guard<std::mutex> _lock(mOdpm.mLock);
- if (mOdpm.hwEnabled == false) {
- ALOGI("getRailInfo not supported");
- _hidl_cb(rInfo, Status::NOT_SUPPORTED);
- return Void();
- }
- rInfo.resize(mOdpm.railsInfo.size());
- for (const auto &railData : mOdpm.railsInfo) {
- index = railData.second.index;
- rInfo[index].railName = railData.first;
- rInfo[index].subsysName = railData.second.subsysName;
- rInfo[index].index = index;
- rInfo[index].samplingRate = railData.second.samplingRate;
- }
- _hidl_cb(rInfo, ret);
- return Void();
-}
-
-Return<void> RailDataProvider::getEnergyData(const hidl_vec<uint32_t> &railIndices,
- IPowerStats::getEnergyData_cb _hidl_cb) {
- hidl_vec<EnergyData> eVal;
- std::lock_guard<std::mutex> _lock(mOdpm.mLock);
- Status ret = parseIioEnergyNodes();
-
- if (ret != Status::SUCCESS) {
- ALOGE("Failed to getEnergyData");
- _hidl_cb(eVal, ret);
- return Void();
- }
-
- if (railIndices.size() == 0) {
- eVal.resize(mOdpm.railsInfo.size());
- memcpy(&eVal[0], &mOdpm.reading[0], mOdpm.reading.size() * sizeof(EnergyData));
- } else {
- eVal.resize(railIndices.size());
- int i = 0;
- for (const auto &railIndex : railIndices) {
- if (railIndex >= mOdpm.reading.size()) {
- ret = Status::INVALID_INPUT;
- eVal.resize(0);
- break;
- }
- memcpy(&eVal[i], &mOdpm.reading[railIndex], sizeof(EnergyData));
- i++;
- }
- }
- _hidl_cb(eVal, ret);
- return Void();
-}
-
-Return<void> RailDataProvider::streamEnergyData(uint32_t timeMs, uint32_t samplingRate,
- IPowerStats::streamEnergyData_cb _hidl_cb) {
- std::lock_guard<std::mutex> _lock(mOdpm.mLock);
- if (mOdpm.fmqSynchronized != nullptr) {
- _hidl_cb(MessageQueueSync::Descriptor(), 0, 0, Status::INSUFFICIENT_RESOURCES);
- return Void();
- }
- uint32_t sps = std::min(samplingRate, MAX_SAMPLING_RATE);
- uint32_t numSamples = timeMs * sps / 1000;
- mOdpm.fmqSynchronized.reset(new (std::nothrow) MessageQueueSync(MAX_QUEUE_SIZE, true));
- if (mOdpm.fmqSynchronized == nullptr || mOdpm.fmqSynchronized->isValid() == false) {
- mOdpm.fmqSynchronized = nullptr;
- _hidl_cb(MessageQueueSync::Descriptor(), 0, 0, Status::INSUFFICIENT_RESOURCES);
- return Void();
- }
- std::thread pollThread = std::thread([this, sps, numSamples]() {
- uint64_t sleepTimeUs = 1000000 / sps;
- uint32_t currSamples = 0;
- while (currSamples < numSamples) {
- mOdpm.mLock.lock();
- if (parseIioEnergyNodes() == Status::SUCCESS) {
- mOdpm.fmqSynchronized->writeBlocking(&mOdpm.reading[0], mOdpm.reading.size(),
- WRITE_TIMEOUT_NS);
- mOdpm.mLock.unlock();
- currSamples++;
- if (usleep(sleepTimeUs) < 0) {
- ALOGW("Sleep interrupted");
- break;
- }
- } else {
- mOdpm.mLock.unlock();
- break;
- }
- }
- mOdpm.mLock.lock();
- mOdpm.fmqSynchronized = nullptr;
- mOdpm.mLock.unlock();
- return;
- });
- pollThread.detach();
- _hidl_cb(*(mOdpm.fmqSynchronized)->getDesc(), numSamples, mOdpm.reading.size(),
- Status::SUCCESS);
- return Void();
-}
-
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
-} // namespace hardware
-} // namespace android
diff --git a/powerstats/RailDataProvider.h b/powerstats/RailDataProvider.h
deleted file mode 100644
index 61313e2..0000000
--- a/powerstats/RailDataProvider.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
-#define ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
-
-#include <fmq/MessageQueue.h>
-#include <pixelpowerstats/PowerStats.h>
-
-namespace android {
-namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
-
-typedef MessageQueue<EnergyData, kSynchronizedReadWrite> MessageQueueSync;
-struct RailData {
- std::string devicePath;
- uint32_t index;
- std::string subsysName;
- uint32_t samplingRate;
-};
-
-struct OnDeviceMmt {
- std::mutex mLock;
- bool hwEnabled;
- std::vector<std::string> devicePaths;
- std::map<std::string, RailData> railsInfo;
- std::vector<EnergyData> reading;
- std::unique_ptr<MessageQueueSync> fmqSynchronized;
-};
-
-class RailDataProvider : public IRailDataProvider {
-public:
- RailDataProvider();
- // Methods from ::android::hardware::power::stats::V1_0::IPowerStats follow.
- Return<void> getRailInfo(IPowerStats::getRailInfo_cb _hidl_cb) override;
- Return<void> getEnergyData(const hidl_vec<uint32_t>& railIndices,
- IPowerStats::getEnergyData_cb _hidl_cb) override;
- Return<void> streamEnergyData(uint32_t timeMs, uint32_t samplingRate,
- IPowerStats::streamEnergyData_cb _hidl_cb) override;
- private:
- OnDeviceMmt mOdpm;
- void findIioPowerMonitorNodes();
- size_t parsePowerRails();
- int parseIioEnergyNodeString(const std::string &contents,
- OnDeviceMmt &odpm);
- int parseIioEnergyNode(std::string devName);
- Status parseIioEnergyNodes();
-};
-
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
diff --git a/powerstats/UfsStateResidencyDataProvider.cpp b/powerstats/UfsStateResidencyDataProvider.cpp
deleted file mode 100644
index 7ca6f3b..0000000
--- a/powerstats/UfsStateResidencyDataProvider.cpp
+++ /dev/null
@@ -1,90 +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.
- */
-#define LOG_TAG "libpixelpowerstats"
-
-#include "UfsStateResidencyDataProvider.h"
-
-#include <android-base/logging.h>
-#include <android-base/parseint.h>
-#include <android-base/strings.h>
-
-#include <string>
-#include <utility>
-
-using android::base::ParseUint;
-using android::base::Split;
-using android::base::StartsWith;
-using android::base::Trim;
-
-namespace android {
-namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
-
-const uint32_t HIBERNATE_STATE_ID = 0;
-
-UfsStateResidencyDataProvider::UfsStateResidencyDataProvider(uint32_t powerEntityId)
- : mPowerEntityId(powerEntityId) {}
-
-bool UfsStateResidencyDataProvider::getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) {
- PowerEntityStateResidencyResult result = {
- .powerEntityId = mPowerEntityId,
- .stateResidencyData = {{.powerEntityStateId = HIBERNATE_STATE_ID}}};
-
- // The transform function converts microseconds to milliseconds.
- std::function<uint64_t(uint64_t)> usecToMs = [](uint64_t a) { return a / 1000; };
-
- std::string prefix = "/sys/bus/platform/devices/14700000.ufs/ufs_stats/";
-
- result.stateResidencyData[0].totalTimeInStateMs =
- usecToMs(readStat(prefix + "hibern8_total_us"));
- result.stateResidencyData[0].totalStateEntryCount = readStat(prefix + "hibern8_exit_cnt");
- result.stateResidencyData[0].lastEntryTimestampMs =
- usecToMs(readStat(prefix + "last_hibern8_enter_time"));
- results.insert(std::make_pair(mPowerEntityId, result));
- return true;
-}
-
-std::vector<PowerEntityStateSpace> UfsStateResidencyDataProvider::getStateSpaces() {
- return {{.powerEntityId = mPowerEntityId,
- .states = {{.powerEntityStateId = HIBERNATE_STATE_ID,
- .powerEntityStateName = "HIBERN8"}}}};
-}
-
-uint64_t UfsStateResidencyDataProvider::readStat(std::string path) {
- std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(path.c_str(), "r"), fclose);
- if (!fp) {
- PLOG(ERROR) << __func__ << ":Failed to open file " << path
- << " Error = " << strerror(errno);
- return 0;
- }
- const size_t size = 20;
- char buf[size];
- (void)fread(&buf, sizeof(char), size, fp.get());
- uint64_t ret;
- if (!ParseUint(Trim(std::string(buf)), &ret)) {
- LOG(ERROR) << "Failed to parse uint64 from [" << std::string(buf) << "]";
- }
- return ret;
-}
-
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
-} // namespace hardware
-} // namespace android
diff --git a/powerstats/UfsStateResidencyDataProvider.h b/powerstats/UfsStateResidencyDataProvider.h
deleted file mode 100644
index 8d1ea73..0000000
--- a/powerstats/UfsStateResidencyDataProvider.h
+++ /dev/null
@@ -1,58 +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.
- */
-#ifndef HARDWARE_GOOGLE_PIXEL_POWERSTATS_UFSSTATERESIDENCYDATAPROVIDER_H
-#define HARDWARE_GOOGLE_PIXEL_POWERSTATS_UFSSTATERESIDENCYDATAPROVIDER_H
-
-#include <pixelpowerstats/PowerStats.h>
-
-namespace android {
-namespace hardware {
-namespace google {
-namespace pixel {
-namespace powerstats {
-
-class UfsStateResidencyDataProvider : public IStateResidencyDataProvider {
- public:
- /*
- * powerEntityId - id for the UFS power entity.
- */
- UfsStateResidencyDataProvider(uint32_t powerEntityId);
- ~UfsStateResidencyDataProvider() = default;
-
- /*
- * See IStateResidencyDataProvider::getResults.
- */
- bool getResults(
- std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) override;
-
- /*
- * See IStateResidencyDataProvider::getStateSpaces.
- */
- std::vector<PowerEntityStateSpace> getStateSpaces() override;
-
- private:
- uint64_t readStat(std::string path);
-
- uint32_t mPowerEntityId;
-};
-
-} // namespace powerstats
-} // namespace pixel
-} // namespace google
-} // namespace hardware
-} // namespace android
-
-#endif // HARDWARE_GOOGLE_PIXEL_POWERSTATS_UFSSTATERESIDENCYDATAPROVIDER_H
diff --git a/powerstats/android.hardware.power.stats@1.0-service.gs101.rc b/powerstats/android.hardware.power.stats@1.0-service.gs101.rc
deleted file mode 100644
index afc3580..0000000
--- a/powerstats/android.hardware.power.stats@1.0-service.gs101.rc
+++ /dev/null
@@ -1,5 +0,0 @@
-service vendor.power.stats-hal-1-0 /vendor/bin/hw/android.hardware.power.stats@1.0-service.gs101
- interface android.hardware.power.stats@1.0::IPowerStats default
- class hal
- user system
- group system
diff --git a/powerstats/android.hardware.power.stats@1.0-service.gs101.xml b/powerstats/android.hardware.power.stats@1.0-service.gs101.xml
deleted file mode 100644
index 2e9956f..0000000
--- a/powerstats/android.hardware.power.stats@1.0-service.gs101.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest version="1.0" type="device">
- <hal format="hidl">
- <name>android.hardware.power.stats</name>
- <transport>hwbinder</transport>
- <version>1.0</version>
- <interface>
- <name>IPowerStats</name>
- <instance>default</instance>
- </interface>
- </hal>
-</manifest>
diff --git a/powerstats/service.cpp b/powerstats/service.cpp
index 4cf1f35..acf4b8a 100644
--- a/powerstats/service.cpp
+++ b/powerstats/service.cpp
@@ -14,313 +14,174 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.power.stats@1.0-service.gs101"
+#define LOG_TAG "android.hardware.power.stats-service.pixel"
-#include <android/log.h>
-#include <binder/IPCThreadState.h>
-#include <binder/IServiceManager.h>
-#include <binder/ProcessState.h>
-#include <hidl/HidlTransportSupport.h>
-#include <pixelpowerstats/AidlStateResidencyDataProvider.h>
-#include <pixelpowerstats/GenericStateResidencyDataProvider.h>
-#include <pixelpowerstats/PowerStats.h>
-
+#include <PowerStatsAidl.h>
#include "AocStateResidencyDataProvider.h"
#include "DvfsStateResidencyDataProvider.h"
-#include "RailDataProvider.h"
-#include "UfsStateResidencyDataProvider.h"
+#include <dataproviders/DisplayStateResidencyDataProvider.h>
+#include <dataproviders/GenericStateResidencyDataProvider.h>
+#include <dataproviders/IioEnergyMeterDataProvider.h>
+#include <dataproviders/PowerStatsEnergyConsumer.h>
+#include <dataproviders/PowerStatsEnergyAttribution.h>
+#include <dataproviders/PixelStateResidencyDataProvider.h>
-using android::OK;
-using android::sp;
-using android::status_t;
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <log/log.h>
-// libhwbinder:
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
+using aidl::android::hardware::power::stats::AocStateResidencyDataProvider;
+using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
+using aidl::android::hardware::power::stats::DvfsStateResidencyDataProvider;
+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::PowerStats;
+using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
-// Generated HIDL files
-using android::hardware::power::stats::V1_0::IPowerStats;
-using android::hardware::power::stats::V1_0::PowerEntityType;
-using android::hardware::power::stats::V1_0::implementation::PowerStats;
+constexpr char kBootHwSoCRev[] = "ro.boot.hw.soc.rev";
-// Pixel specific
-using android::hardware::google::pixel::powerstats::AidlStateResidencyDataProvider;
-using android::hardware::google::pixel::powerstats::AocStateResidencyDataProvider;
-using android::hardware::google::pixel::powerstats::DvfsStateResidencyDataProvider;
-using android::hardware::google::pixel::powerstats::generateGenericStateResidencyConfigs;
-using android::hardware::google::pixel::powerstats::GenericStateResidencyDataProvider;
-using android::hardware::google::pixel::powerstats::PowerEntityConfig;
-using android::hardware::google::pixel::powerstats::RailDataProvider;
-using android::hardware::google::pixel::powerstats::StateResidencyConfig;
-using android::hardware::google::pixel::powerstats::UfsStateResidencyDataProvider;
-
-// A constant to represnt the number of nanoseconds in one millisecond.
-static const int NS_TO_MS = 1000000;
-
-void addAoCStats(PowerStats *const service) {
+void addAoC(std::shared_ptr<PowerStats> p) {
std::string prefix = "/sys/devices/platform/19000000.aoc/control/";
// Add AoC cores (a32, ff1, hf0, and hf1)
- std::vector<std::pair<uint32_t, std::string>> coreIds = {
- {service->addPowerEntity("AoC-A32", PowerEntityType::SUBSYSTEM), prefix + "a32_"},
- {service->addPowerEntity("AoC-FF1", PowerEntityType::SUBSYSTEM), prefix + "ff1_"},
- {service->addPowerEntity("AoC-HF1", PowerEntityType::SUBSYSTEM), prefix + "hf1_"},
- {service->addPowerEntity("AoC-HF0", PowerEntityType::SUBSYSTEM), prefix + "hf0_"},
+ 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"}};
- service->addStateResidencyDataProvider(new AocStateResidencyDataProvider(coreIds, coreStates));
+ p->addStateResidencyDataProvider(std::make_shared<AocStateResidencyDataProvider>(coreIds,
+ coreStates));
// Add AoC voltage stats
- std::vector<std::pair<uint32_t, std::string>> voltageIds = {
- {service->addPowerEntity("AoC-Voltage", PowerEntityType::SUBSYSTEM),
- prefix + "voltage_"},
+ 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"}};
- service->addStateResidencyDataProvider(
- new AocStateResidencyDataProvider(voltageIds, voltageStates));
+ p->addStateResidencyDataProvider(
+ std::make_shared<AocStateResidencyDataProvider>(voltageIds, voltageStates));
// Add AoC monitor mode
- std::vector<std::pair<uint32_t, std::string>> monitorIds = {
- {service->addPowerEntity("AoC", PowerEntityType::SUBSYSTEM), prefix + "monitor_"},
+ std::vector<std::pair<std::string, std::string>> monitorIds = {
+ {"AoC", prefix + "monitor_"},
};
std::vector<std::pair<std::string, std::string>> monitorStates = {
{"MON", "mode"},
};
- service->addStateResidencyDataProvider(
- new AocStateResidencyDataProvider(monitorIds, monitorStates));
+ p->addStateResidencyDataProvider(
+ std::make_shared<AocStateResidencyDataProvider>(monitorIds, monitorStates));
}
-void addCpuCStateStats(PowerStats *const service) {
- // CPU stats are reported in nanoseconds. The transform function
- // converts nanoseconds to milliseconds.
- std::function<uint64_t(uint64_t)> cpuNsToMs = [](uint64_t a) { return a / NS_TO_MS; };
- StateResidencyConfig cStateConfig = {
- .entryCountSupported = true,
- .entryCountPrefix = "down_count:",
- .totalTimeSupported = true,
- .totalTimePrefix = "total_down_time_ns:",
- .totalTimeTransform = cpuNsToMs,
- .lastEntrySupported = true,
- .lastEntryPrefix = "last_down_time_ns:",
- .lastEntryTransform = cpuNsToMs,
- };
+void addDvfsStats(std::shared_ptr<PowerStats> p) {
+ // A constant to represent the number of nanoseconds in one millisecond
+ const int NS_TO_MS = 1000000;
- sp<GenericStateResidencyDataProvider> cStateSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/1742048c.acpm_stats/core_stats");
- for (std::string state :
- {"CORE00", "CORE01", "CORE02", "CORE03", "CORE10", "CORE11", "CORE20", "CORE21"}) {
- cStateSdp->addEntity(service->addPowerEntity(state, PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("CORES:", generateGenericStateResidencyConfigs(
- cStateConfig,
- {std::make_pair("DOWN", state)})));
- }
- for (std::string state : {"CLUSTER0", "CLUSTER1", "CLUSTER2"}) {
- cStateSdp->addEntity(
- service->addPowerEntity(state, PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("CLUSTERS:",
- generateGenericStateResidencyConfigs(
- cStateConfig, {std::make_pair("DOWN", state)})));
- }
- service->addStateResidencyDataProvider(cStateSdp);
+ std::vector<DvfsStateResidencyDataProvider::Config> cfgs;
+
+ cfgs.push_back({"MIF", {
+ std::make_pair("3172KHz", "3172000"),
+ std::make_pair("2730KHz", "2730000"),
+ std::make_pair("2535KHz", "2535000"),
+ std::make_pair("2288KHz", "2288000"),
+ std::make_pair("2028KHz", "2028000"),
+ std::make_pair("1716KHz", "1716000"),
+ std::make_pair("1539KHz", "1539000"),
+ std::make_pair("1352KHz", "1352000"),
+ std::make_pair("1014KHz", "1014000"),
+ std::make_pair("845KHz", "845000"),
+ std::make_pair("676KHz", "676000"),
+ std::make_pair("546KHz", "546000"),
+ std::make_pair("421KHz", "421000"),
+ std::make_pair("0KHz", "0"),
+ }});
+
+ cfgs.push_back({"CL0", {
+ std::make_pair("2024KHz", "2024000"),
+ std::make_pair("1950KHz", "1950000"),
+ std::make_pair("1868KHz", "1868000"),
+ std::make_pair("1803KHz", "1803000"),
+ std::make_pair("1745KHz", "1745000"),
+ std::make_pair("1704KHz", "1704000"),
+ std::make_pair("1598KHz", "1598000"),
+ std::make_pair("1459KHz", "1459000"),
+ std::make_pair("1401KHz", "1401000"),
+ std::make_pair("1328KHz", "1328000"),
+ std::make_pair("1197KHz", "1197000"),
+ std::make_pair("1098KHz", "1098000"),
+ std::make_pair("930KHz", "930000"),
+ std::make_pair("889KHz", "889000"),
+ std::make_pair("738KHz", "738000"),
+ std::make_pair("574KHz", "574000"),
+ std::make_pair("300KHz", "300000"),
+ std::make_pair("0KHz", "0"),
+ }});
+
+ cfgs.push_back({"CL1", {
+ std::make_pair("2253KHz", "2253000"),
+ std::make_pair("2130KHz", "2130000"),
+ std::make_pair("1999KHz", "1999000"),
+ std::make_pair("1836KHz", "1836000"),
+ std::make_pair("1663KHz", "1663000"),
+ std::make_pair("1491KHz", "1491000"),
+ std::make_pair("1328KHz", "1328000"),
+ std::make_pair("1197KHz", "1197000"),
+ std::make_pair("1024KHz", "1024000"),
+ std::make_pair("910KHz", "910000"),
+ std::make_pair("799KHz", "799000"),
+ std::make_pair("696KHz", "696000"),
+ std::make_pair("533KHz", "533000"),
+ std::make_pair("400KHz", "400000"),
+ std::make_pair("0KHz", "0"),
+ }});
+
+ cfgs.push_back({"CL2", {
+ std::make_pair("2630KHz", "2630000"),
+ std::make_pair("2507KHz", "2507000"),
+ std::make_pair("2401KHz", "2401000"),
+ std::make_pair("2302KHz", "2302000"),
+ std::make_pair("2252KHz", "2252000"),
+ std::make_pair("2188KHz", "2188000"),
+ std::make_pair("2048KHz", "2048000"),
+ std::make_pair("1901KHz", "1901000"),
+ std::make_pair("1826KHz", "1826000"),
+ std::make_pair("1745KHz", "1745000"),
+ std::make_pair("1582KHz", "1582000"),
+ std::make_pair("1426KHz", "1426000"),
+ std::make_pair("1277KHz", "1277000"),
+ std::make_pair("1237KHz", "1237000"),
+ std::make_pair("1106KHz", "1106000"),
+ std::make_pair("984KHz", "984000"),
+ std::make_pair("851KHz", "851000"),
+ std::make_pair("848KHz", "848000"),
+ std::make_pair("500KHz", "500000"),
+ std::make_pair("0KHz", "0"),
+ }});
+
+ cfgs.push_back({"TPU", {
+ std::make_pair("1066MHz", "1066000000"),
+ }});
+
+ p->addStateResidencyDataProvider(std::make_shared<DvfsStateResidencyDataProvider>(
+ "/sys/devices/platform/acpm_stats/fvp_stats", NS_TO_MS, cfgs));
}
-void addDvfsStats(PowerStats *const service) {
- sp<DvfsStateResidencyDataProvider> dvfsSdp = new DvfsStateResidencyDataProvider(
- "/sys/devices/platform/1742048c.acpm_stats/fvp_stats", NS_TO_MS);
+void addSoC(std::shared_ptr<PowerStats> p) {
+ // A constant to represent the number of nanoseconds in one millisecond.
+ const int NS_TO_MS = 1000000;
- dvfsSdp->addEntity(service->addPowerEntity("MIF-DVFS", PowerEntityType::SUBSYSTEM), "MIF",
- {
- std::make_pair("3172KHz", "3172000"),
- std::make_pair("2730KHz", "2730000"),
- std::make_pair("2535KHz", "2535000"),
- std::make_pair("2288KHz", "2288000"),
- std::make_pair("2028KHz", "2028000"),
- std::make_pair("1716KHz", "1716000"),
- std::make_pair("1539KHz", "1539000"),
- std::make_pair("1352KHz", "1352000"),
- std::make_pair("1014KHz", "1014000"),
- std::make_pair("845KHz", "845000"),
- std::make_pair("676KHz", "676000"),
- std::make_pair("546KHz", "546000"),
- std::make_pair("421KHz", "421000"),
- std::make_pair("0KHz", "0"),
- });
-
- dvfsSdp->addEntity(service->addPowerEntity("CL0-DVFS", PowerEntityType::SUBSYSTEM), "CL0",
- {
- std::make_pair("2196KHz", "2196000"),
- std::make_pair("2098KHz", "2098000"),
- std::make_pair("2024KHz", "2024000"),
- std::make_pair("1950KHz", "1950000"),
- std::make_pair("1868KHz", "1868000"),
- std::make_pair("1745KHz", "1745000"),
- std::make_pair("1598KHz", "1598000"),
- std::make_pair("1459KHz", "1459000"),
- std::make_pair("1328KHz", "1328000"),
- std::make_pair("1197KHz", "1197000"),
- std::make_pair("1098KHz", "1098000"),
- std::make_pair("889KHz", "889000"),
- std::make_pair("738KHz", "738000"),
- std::make_pair("574KHz", "574000"),
- std::make_pair("300KHz", "300000"),
- std::make_pair("0KHz", "0"),
- });
-
- dvfsSdp->addEntity(service->addPowerEntity("CL1-DVFS", PowerEntityType::SUBSYSTEM), "CL1",
- {
- std::make_pair("2466KHz", "2466000"),
- std::make_pair("2393KHz", "2393000"),
- std::make_pair("2348KHz", "2348000"),
- std::make_pair("2253KHz", "2253000"),
- std::make_pair("2130KHz", "2130000"),
- std::make_pair("1999KHz", "1999000"),
- std::make_pair("1836KHz", "1836000"),
- std::make_pair("1663KHz", "1663000"),
- std::make_pair("1491KHz", "1491000"),
- std::make_pair("1328KHz", "1328000"),
- std::make_pair("1197KHz", "1197000"),
- std::make_pair("1024KHz", "1024000"),
- std::make_pair("910KHz", "910000"),
- std::make_pair("799KHz", "799000"),
- std::make_pair("696KHz", "696000"),
- std::make_pair("533KHz", "533000"),
- std::make_pair("400KHz", "400000"),
- std::make_pair("0KHz", "0"),
- });
-
- dvfsSdp->addEntity(service->addPowerEntity("CL2-DVFS", PowerEntityType::SUBSYSTEM), "CL2",
- {
- std::make_pair("3195KHz", "3195000"),
- std::make_pair("3097KHz", "3097000"),
- std::make_pair("2999KHz", "2999000"),
- std::make_pair("2900KHz", "2900000"),
- std::make_pair("2802KHz", "2802000"),
- std::make_pair("2704KHz", "2704000"),
- std::make_pair("2630KHz", "2630000"),
- std::make_pair("2507KHz", "2507000"),
- std::make_pair("2401KHz", "2401000"),
- std::make_pair("2302KHz", "2302000"),
- std::make_pair("2188KHz", "2188000"),
- std::make_pair("2048KHz", "2048000"),
- std::make_pair("1901KHz", "1901000"),
- std::make_pair("1745KHz", "1745000"),
- std::make_pair("1582KHz", "1582000"),
- std::make_pair("1426KHz", "1426000"),
- std::make_pair("1237KHz", "1237000"),
- std::make_pair("1106KHz", "1106000"),
- std::make_pair("984KHz", "984000"),
- std::make_pair("848KHz", "848000"),
- std::make_pair("500KHz", "500000"),
- std::make_pair("0KHz", "0"),
- });
-
- // TODO(sujee): Complete frequency table for TPU.
- dvfsSdp->addEntity(service->addPowerEntity("TPU-DVFS", PowerEntityType::SUBSYSTEM), "TPU",
- {
- std::make_pair("1066MHz", "1066000000"),
- });
-
- service->addStateResidencyDataProvider(dvfsSdp);
-}
-
-void addGPUStats(PowerStats *const service) {
- StateResidencyConfig gpuStateConfig = {
- .entryCountSupported = true,
- .entryCountPrefix = "count = ",
- .totalTimeSupported = true,
- .totalTimePrefix = "total_time = ",
- .lastEntrySupported = true,
- .lastEntryPrefix = "last_entry_time = ",
- };
-
- sp<GenericStateResidencyDataProvider> gpu = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/1c500000.mali/power_stats");
-
- PowerEntityConfig onOffConfig("Summary stats: (times in ms)",
- generateGenericStateResidencyConfigs(
- gpuStateConfig, {{"DOWN", "OFF:"}, {"UP", "ON:"}}));
- gpu->addEntity(service->addPowerEntity("GPU", PowerEntityType::SUBSYSTEM), onOffConfig);
-
- PowerEntityConfig DVFSConfig(
- "DVFS stats: (times in ms)",
- generateGenericStateResidencyConfigs(gpuStateConfig, {{"996MHz", "996000:"},
- {"885MHz", "885000:"},
- {"750MHz", "750000:"},
- {"434MHz", "434000:"},
- {"302MHz", "302000:"},
- {"151MHz", "151000:"}}));
- gpu->addEntity(service->addPowerEntity("GPU-DVFS", PowerEntityType::SUBSYSTEM), DVFSConfig);
- service->addStateResidencyDataProvider(gpu);
-}
-
-void addNFCStats(PowerStats *const service) {
- StateResidencyConfig nfcStateConfig = {
- .entryCountSupported = true,
- .entryCountPrefix = "Cumulative count:",
- .totalTimeSupported = true,
- .totalTimePrefix = "Cumulative duration msec:",
- .lastEntrySupported = true,
- .lastEntryPrefix = "Last entry timestamp msec:",
- };
- 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:"),
- };
-
- sp<GenericStateResidencyDataProvider> nfcSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/10960000.hsi2c/i2c-4/4-0008/power_stats");
- nfcSdp->addEntity(service->addPowerEntity("NFC", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("NFC subsystem", generateGenericStateResidencyConfigs(
- nfcStateConfig, nfcStateHeaders)));
- service->addStateResidencyDataProvider(nfcSdp);
-}
-
-void addPCIeStats(PowerStats *const service) {
- // Add PCIe power entities for Modem and WiFi
- StateResidencyConfig pcieStateConfig = {
- .entryCountSupported = true,
- .entryCountPrefix = "Cumulative count:",
- .totalTimeSupported = true,
- .totalTimePrefix = "Cumulative duration msec:",
- .lastEntrySupported = true,
- .lastEntryPrefix = "Last entry timestamp msec:",
- };
- std::vector<std::pair<std::string, std::string>> pcieStateHeaders = {
- std::make_pair("UP", "Link up:"),
- std::make_pair("DOWN", "Link down:"),
- };
-
- // Add PCIe - Modem
- sp<GenericStateResidencyDataProvider> pcieModemSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/11920000.pcie/power_stats");
- uint32_t pcieModemId = service->addPowerEntity("PCIe-Modem", PowerEntityType::SUBSYSTEM);
- pcieModemSdp->addEntity(
- pcieModemId,
- PowerEntityConfig("Version: 1", generateGenericStateResidencyConfigs(
- pcieStateConfig, pcieStateHeaders)));
- service->addStateResidencyDataProvider(pcieModemSdp);
-
- // Add PCIe - WiFi
- sp<GenericStateResidencyDataProvider> pcieWifiSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/14520000.pcie/power_stats");
- uint32_t pcieWifiId = service->addPowerEntity("PCIe-WiFi", PowerEntityType::SUBSYSTEM);
- pcieWifiSdp->addEntity(
- pcieWifiId,
- PowerEntityConfig("Version: 1", generateGenericStateResidencyConfigs(
- pcieStateConfig, pcieStateHeaders)));
- service->addStateResidencyDataProvider(pcieWifiSdp);
-}
-
-void addSocStats(PowerStats *const service) {
// 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; };
- StateResidencyConfig lpmStateConfig = {
+ const GenericStateResidencyDataProvider::StateResidencyConfig lpmStateConfig = {
.entryCountSupported = true,
.entryCountPrefix = "success_count:",
.totalTimeSupported = true,
@@ -330,7 +191,7 @@
.lastEntryPrefix = "last_entry_time_ns:",
.lastEntryTransform = acpmNsToMs,
};
- StateResidencyConfig downStateConfig = {
+ const GenericStateResidencyDataProvider::StateResidencyConfig downStateConfig = {
.entryCountSupported = true,
.entryCountPrefix = "down_count:",
.totalTimeSupported = true,
@@ -340,7 +201,7 @@
.lastEntryPrefix = "last_down_time_ns:",
.lastEntryTransform = acpmNsToMs,
};
- StateResidencyConfig reqStateConfig = {
+ const GenericStateResidencyDataProvider::StateResidencyConfig reqStateConfig = {
.entryCountSupported = true,
.entryCountPrefix = "req_up_count:",
.totalTimeSupported = true,
@@ -351,141 +212,343 @@
.lastEntryTransform = acpmNsToMs,
};
- std::vector<std::pair<std::string, std::string>> powerStateHeaders = {
+ 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("STOP", "STOP"),
};
- std::vector<std::pair<std::string, std::string>> mifReqStateHeaders = {
+ const std::vector<std::pair<std::string, std::string>> mifReqStateHeaders = {
std::make_pair("AOC", "AOC"),
std::make_pair("GSA", "GSA"),
};
- std::vector<std::pair<std::string, std::string>> slcReqStateHeaders = {
+ const std::vector<std::pair<std::string, std::string>> slcReqStateHeaders = {
std::make_pair("AOC", "AOC"),
};
- sp<GenericStateResidencyDataProvider> socSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/1742048c.acpm_stats/soc_stats");
+ 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:");
- socSdp->addEntity(service->addPowerEntity("LPM", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("LPM:", generateGenericStateResidencyConfigs(
- lpmStateConfig, powerStateHeaders)));
- socSdp->addEntity(service->addPowerEntity("MIF", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("MIF:", generateGenericStateResidencyConfigs(
- downStateConfig, powerStateHeaders)));
- socSdp->addEntity(service->addPowerEntity("MIF-REQ", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("MIF_REQ:", generateGenericStateResidencyConfigs(
- reqStateConfig, mifReqStateHeaders)));
- socSdp->addEntity(service->addPowerEntity("SLC", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("SLC:", generateGenericStateResidencyConfigs(
- downStateConfig, powerStateHeaders)));
- socSdp->addEntity(service->addPowerEntity("SLC-REQ", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig("SLC_REQ:", generateGenericStateResidencyConfigs(
- reqStateConfig, slcReqStateHeaders)));
+ auto socSdp = std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/acpm_stats/soc_stats", cfgs);
- service->addStateResidencyDataProvider(socSdp);
+ p->addStateResidencyDataProvider(socSdp);
}
-void addUfsStats(PowerStats *const service) {
- sp<UfsStateResidencyDataProvider> ufsSdp = new UfsStateResidencyDataProvider(
- service->addPowerEntity("UFS", PowerEntityType::SUBSYSTEM));
- service->addStateResidencyDataProvider(ufsSdp);
+void setEnergyMeter(std::shared_ptr<PowerStats> p) {
+ std::vector<const std::string> deviceNames { "s2mpg10-odpm", "s2mpg11-odpm" };
+ p->setEnergyMeterDataProvider(std::make_unique<IioEnergyMeterDataProvider>(deviceNames, true));
}
-void addWifiStats(PowerStats *const service) {
- sp<GenericStateResidencyDataProvider> wifiSdp =
- new GenericStateResidencyDataProvider("/sys/wifi/power_stats");
+void addDisplay(std::shared_ptr<PowerStats> p) {
+ // Add display residency stats
- // The transform function converts microseconds to milliseconds.
- std::function<uint64_t(uint64_t)> usecToMs = [](uint64_t a) { return a / 1000; };
- StateResidencyConfig stateConfig = {
+ /*
+ * TODO(b/167216667): Add complete set of display states here. Must account
+ * for ALL devices built using this source
+ */
+ std::vector<std::string> states = {
+ "Off",
+ "LP: 1440x3040@30",
+ "On: 1440x3040@60",
+ "On: 1440x3040@90",
+ "HBM: 1440x3040@60",
+ "HBM: 1440x3040@90"};
+
+ auto displaySdp =
+ std::make_shared<DisplayStateResidencyDataProvider>("Display",
+ "/sys/class/backlight/panel0-backlight/state",
+ states);
+ p->addStateResidencyDataProvider(displaySdp);
+
+ // 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. Must account for ALL devices built
+ * using this source.
+ */
+ auto displayConsumer = PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p,
+ EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display",
+ {{"LP: 1440x3040@30", 1},
+ {"On: 1440x3040@60", 2},
+ {"On: 1440x3040@90", 3}});
+
+ p->addEnergyConsumer(displayConsumer);
+}
+
+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);
+ }
+
+ auto cpuSdp = std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/acpm_stats/core_stats", cfgs);
+
+ p->addStateResidencyDataProvider(cpuSdp);
+
+ 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;
+ const int socRev = android::base::GetIntProperty(kBootHwSoCRev, 0);
+
+ // B0/B1 chips have different GPU DVFS operating points than A0/A1 SoC
+ if (socRev >= 2) {
+ stateCoeffs = {
+ {"151000", 10},
+ {"202000", 20},
+ {"251000", 30},
+ {"302000", 40},
+ {"351000", 50},
+ {"400000", 60},
+ {"471000", 70},
+ {"510000", 80},
+ {"572000", 90},
+ {"701000", 100},
+ {"762000", 110},
+ {"848000", 120}};
+ } else {
+ stateCoeffs = {
+ {"151000", 10},
+ {"302000", 20},
+ {"455000", 30},
+ {"572000", 40},
+ {"670000", 50}};
+ }
+
+ auto gpuConsumer = PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
+ EnergyConsumerType::OTHER, "GPU", {"S2S_VDD_G3D"},
+ {{UID_TIME_IN_STATE, "/sys/devices/platform/1c500000.mali/uid_time_in_state"}},
+ stateCoeffs);
+
+ p->addEnergyConsumer(gpuConsumer);
+}
+
+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 = usecToMs,
+ .totalTimeTransform = modemUsToMs,
.lastEntrySupported = true,
.lastEntryPrefix = "last_entry_timestamp_usec:",
- .lastEntryTransform = usecToMs,
+ .lastEntryTransform = modemUsToMs,
};
- StateResidencyConfig pcieStateConfig = {
- .entryCountSupported = true,
- .entryCountPrefix = "count:",
- .totalTimeSupported = true,
- .totalTimePrefix = "duration_usec:",
- .totalTimeTransform = usecToMs,
+ const std::vector<std::pair<std::string, std::string>> powerStateHeaders = {
+ std::make_pair("SLEEP", "SLEEP:"),
};
- std::vector<std::pair<std::string, std::string>> stateHeaders = {
- std::make_pair("AWAKE", "AWAKE:"),
- std::make_pair("ASLEEP", "ASLEEP:"),
- };
- 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:"),
- };
+ std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
+ cfgs.emplace_back(generateGenericStateResidencyConfigs(powerStateConfig, powerStateHeaders),
+ "MODEM", "");
- wifiSdp->addEntity(
- service->addPowerEntity("WIFI", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig(generateGenericStateResidencyConfigs(stateConfig, stateHeaders)));
- wifiSdp->addEntity(service->addPowerEntity("WIFI-PCIE", PowerEntityType::SUBSYSTEM),
- PowerEntityConfig(generateGenericStateResidencyConfigs(pcieStateConfig,
- pcieStateHeaders)));
+ p->addStateResidencyDataProvider(std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/cpif/modem/power_stats", cfgs));
- service->addStateResidencyDataProvider(wifiSdp);
+ p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
+ EnergyConsumerType::MOBILE_RADIO, "MODEM", {"VSYS_PWR_MODEM", "VSYS_PWR_RFFE"}));
}
-int main(int /* argc */, char ** /* argv */) {
- ALOGI("power.stats service 1.0 is starting.");
+void addGNSS(std::shared_ptr<PowerStats> p)
+{
+ p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
+ EnergyConsumerType::GNSS, "GPS", {"L9S_GNSS_CORE"}));
+}
- PowerStats *service = new PowerStats();
+void addNFC(std::shared_ptr<PowerStats> p) {
+ 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:"),
+ };
- // Add rail data provider
- service->setRailDataProvider(std::make_unique<RailDataProvider>());
+ std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
+ cfgs.emplace_back(generateGenericStateResidencyConfigs(nfcStateConfig, nfcStateHeaders),
+ "NFC", "NFC subsystem");
- addAoCStats(service);
- addCpuCStateStats(service);
- addDvfsStats(service);
- addGPUStats(service);
- addNFCStats(service);
- addPCIeStats(service);
- addSocStats(service);
- addUfsStats(service);
- addWifiStats(service);
+ auto nfcSdp = std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/10960000.hsi2c/i2c-3/3-0008/power_stats", cfgs);
- // Add Power Entities that require the Aidl data provider
- sp<AidlStateResidencyDataProvider> aidlSdp = new AidlStateResidencyDataProvider();
- uint32_t bluetoothId = service->addPowerEntity("Bluetooth", PowerEntityType::SUBSYSTEM);
- aidlSdp->addEntity(bluetoothId, "Bluetooth", {"Idle", "Active", "Tx", "Rx"});
- uint32_t citadelId = service->addPowerEntity("Citadel", PowerEntityType::SUBSYSTEM);
- aidlSdp->addEntity(citadelId, "Citadel", {"Last-Reset", "Active", "Deep-Sleep"});
- service->addStateResidencyDataProvider(aidlSdp);
+ p->addStateResidencyDataProvider(nfcSdp);
+}
- auto serviceStatus = android::defaultServiceManager()->addService(
- android::String16("power.stats-vendor"), aidlSdp);
- if (serviceStatus != android::OK) {
- ALOGE("Unable to register power.stats-vendor service %d", serviceStatus);
- return 1;
- }
+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:"),
+ };
- sp<android::ProcessState> ps{android::ProcessState::self()}; // Create non-HW binder threadpool
- ps->startThreadPool();
+ // Add PCIe - Modem
+ const std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> pcieModemCfgs = {
+ {generateGenericStateResidencyConfigs(pcieStateConfig, pcieStateHeaders), "PCIe-Modem",
+ "Version: 1"}
+ };
+ auto pcieModemSdp = std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/11920000.pcie/power_stats", pcieModemCfgs);
+ p->addStateResidencyDataProvider(pcieModemSdp);
- // Configure the threadpool
- configureRpcThreadpool(1, true /*callerWillJoin*/);
+ // Add PCIe - WiFi
+ const std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> pcieWifiCfgs = {
+ {generateGenericStateResidencyConfigs(pcieStateConfig, pcieStateHeaders),
+ "PCIe-WiFi", "Version: 1"}
+ };
+ auto pcieWifiSdp = std::make_shared<GenericStateResidencyDataProvider>(
+ "/sys/devices/platform/14520000.pcie/power_stats", pcieWifiCfgs);
+ p->addStateResidencyDataProvider(pcieWifiSdp);
+}
- status_t status = service->registerAsService();
- if (status != OK) {
- ALOGE("Could not register service for power.stats HAL Iface (%d), exiting.", status);
- return 1;
- }
+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,
+ };
- ALOGI("power.stats service is ready");
- joinRpcThreadpool();
+ const std::vector<std::pair<std::string, std::string>> stateHeaders = {
+ std::make_pair("AWAKE", "AWAKE:"),
+ std::make_pair("ASLEEP", "ASLEEP:"),
- // In normal operation, we don't expect the thread pool to exit
- ALOGE("power.stats service is shutting down");
- return 1;
+ };
+ 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"}
+ };
+
+ auto wifiSdp = std::make_shared<GenericStateResidencyDataProvider>("/sys/wifi/power_stats",
+ cfgs);
+ p->addStateResidencyDataProvider(wifiSdp);
+}
+
+/**
+ * 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) {
+ std::shared_ptr<PixelStateResidencyDataProvider> pixelSdp =
+ ndk::SharedRefBase::make<PixelStateResidencyDataProvider>();
+
+ pixelSdp->addEntity("Bluetooth", {{0, "Idle"}, {1, "Active"}, {2, "Tx"}, {3, "Rx"}});
+
+ pixelSdp->start();
+ p->addStateResidencyDataProvider(pixelSdp);
+}
+
+int main() {
+ LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting.";
+
+ // single thread
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+
+ std::shared_ptr<PowerStats> p = ndk::SharedRefBase::make<PowerStats>();
+
+ setEnergyMeter(p);
+
+ addPixelStateResidencyDataProvider(p);
+ addAoC(p);
+ addDisplay(p);
+ addDvfsStats(p);
+ addSoC(p);
+ addCPUclusters(p);
+ addGPU(p);
+ addMobileRadio(p);
+ addGNSS(p);
+ addNFC(p);
+ addPCIe(p);
+ addWifi(p);
+
+ const std::string instance = std::string() + PowerStats::descriptor + "/default";
+ binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());
+ LOG_ALWAYS_FATAL_IF(status != STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return EXIT_FAILURE; // should not reach
}
diff --git a/powerstats/serviceaidl.cpp b/powerstats/serviceaidl.cpp
deleted file mode 100644
index 25eb6ea..0000000
--- a/powerstats/serviceaidl.cpp
+++ /dev/null
@@ -1,392 +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.
- */
-
-#define LOG_TAG "android.hardware.power.stats-service.pixel"
-
-#include <PowerStatsAidl.h>
-#include "AocStateResidencyDataProviderAidl.h"
-#include "DvfsStateResidencyDataProviderAidl.h"
-#include <dataproviders/DisplayStateResidencyDataProvider.h>
-#include <dataproviders/GenericStateResidencyDataProvider.h>
-#include <dataproviders/IioEnergyMeterDataProvider.h>
-#include <dataproviders/PowerStatsEnergyConsumer.h>
-#include <dataproviders/PowerStatsEnergyAttribution.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::AocStateResidencyDataProvider;
-using aidl::android::hardware::power::stats::DisplayStateResidencyDataProvider;
-using aidl::android::hardware::power::stats::DvfsStateResidencyDataProvider;
-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::PowerStats;
-using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
-
-constexpr char kBootHwSoCRev[] = "ro.boot.hw.soc.rev";
-
-void addAoC(std::shared_ptr<PowerStats> p) {
- 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(new AocStateResidencyDataProvider(coreIds, coreStates));
-
- // 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(
- new AocStateResidencyDataProvider(voltageIds, voltageStates));
-
- // 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(
- new AocStateResidencyDataProvider(monitorIds, monitorStates));
-}
-
-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::vector<DvfsStateResidencyDataProvider::Config> cfgs;
-
- cfgs.push_back({"MIF", {
- std::make_pair("3172KHz", "3172000"),
- std::make_pair("2730KHz", "2730000"),
- std::make_pair("2535KHz", "2535000"),
- std::make_pair("2288KHz", "2288000"),
- std::make_pair("2028KHz", "2028000"),
- std::make_pair("1716KHz", "1716000"),
- std::make_pair("1539KHz", "1539000"),
- std::make_pair("1352KHz", "1352000"),
- std::make_pair("1014KHz", "1014000"),
- std::make_pair("845KHz", "845000"),
- std::make_pair("676KHz", "676000"),
- std::make_pair("546KHz", "546000"),
- std::make_pair("421KHz", "421000"),
- std::make_pair("0KHz", "0"),
- }});
-
- cfgs.push_back({"CL0", {
- std::make_pair("2024KHz", "2024000"),
- std::make_pair("1950KHz", "1950000"),
- std::make_pair("1868KHz", "1868000"),
- std::make_pair("1803KHz", "1803000"),
- std::make_pair("1745KHz", "1745000"),
- std::make_pair("1704KHz", "1704000"),
- std::make_pair("1598KHz", "1598000"),
- std::make_pair("1459KHz", "1459000"),
- std::make_pair("1401KHz", "1401000"),
- std::make_pair("1328KHz", "1328000"),
- std::make_pair("1197KHz", "1197000"),
- std::make_pair("1098KHz", "1098000"),
- std::make_pair("930KHz", "930000"),
- std::make_pair("889KHz", "889000"),
- std::make_pair("738KHz", "738000"),
- std::make_pair("574KHz", "574000"),
- std::make_pair("300KHz", "300000"),
- std::make_pair("0KHz", "0"),
- }});
-
- cfgs.push_back({"CL1", {
- std::make_pair("2253KHz", "2253000"),
- std::make_pair("2130KHz", "2130000"),
- std::make_pair("1999KHz", "1999000"),
- std::make_pair("1836KHz", "1836000"),
- std::make_pair("1663KHz", "1663000"),
- std::make_pair("1491KHz", "1491000"),
- std::make_pair("1328KHz", "1328000"),
- std::make_pair("1197KHz", "1197000"),
- std::make_pair("1024KHz", "1024000"),
- std::make_pair("910KHz", "910000"),
- std::make_pair("799KHz", "799000"),
- std::make_pair("696KHz", "696000"),
- std::make_pair("533KHz", "533000"),
- std::make_pair("400KHz", "400000"),
- std::make_pair("0KHz", "0"),
- }});
-
- cfgs.push_back({"CL2", {
- std::make_pair("2630KHz", "2630000"),
- std::make_pair("2507KHz", "2507000"),
- std::make_pair("2401KHz", "2401000"),
- std::make_pair("2302KHz", "2302000"),
- std::make_pair("2252KHz", "2252000"),
- std::make_pair("2188KHz", "2188000"),
- std::make_pair("2048KHz", "2048000"),
- std::make_pair("1901KHz", "1901000"),
- std::make_pair("1826KHz", "1826000"),
- std::make_pair("1745KHz", "1745000"),
- std::make_pair("1582KHz", "1582000"),
- std::make_pair("1426KHz", "1426000"),
- std::make_pair("1277KHz", "1277000"),
- std::make_pair("1237KHz", "1237000"),
- std::make_pair("1106KHz", "1106000"),
- std::make_pair("984KHz", "984000"),
- std::make_pair("851KHz", "851000"),
- std::make_pair("848KHz", "848000"),
- std::make_pair("500KHz", "500000"),
- std::make_pair("0KHz", "0"),
- }});
-
- cfgs.push_back({"TPU", {
- std::make_pair("1066MHz", "1066000000"),
- }});
-
- p->addStateResidencyDataProvider(new DvfsStateResidencyDataProvider(
- "/sys/devices/platform/1742048c.acpm_stats/fvp_stats", 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("STOP", "STOP"),
- };
- const std::vector<std::pair<std::string, std::string>> mifReqStateHeaders = {
- std::make_pair("AOC", "AOC"),
- std::make_pair("GSA", "GSA"),
- };
- 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:");
-
- android::sp<GenericStateResidencyDataProvider> socSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/1742048c.acpm_stats/soc_stats", cfgs);
-
- p->addStateResidencyDataProvider(socSdp);
-}
-
-void setEnergyMeter(std::shared_ptr<PowerStats> p) {
- std::vector<const std::string> deviceNames { "s2mpg10-odpm", "s2mpg11-odpm" };
- p->setEnergyMeterDataProvider(std::make_unique<IioEnergyMeterDataProvider>(deviceNames, true));
-}
-
-void addDisplay(std::shared_ptr<PowerStats> p) {
- // Add display residency stats
- android::sp<DisplayStateResidencyDataProvider> displaySdp =
- new DisplayStateResidencyDataProvider("Display",
- "/sys/class/backlight/panel0-backlight/state",
- /*
- * TODO(b/167216667): Add complete set of display states here. Must account
- * for ALL devices built using this source
- */
- {"Off", "LP: 1440x3040@30", "On: 1440x3040@60", "On: 1440x3040@90", "HBM: 1440x3040@60",
- "HBM: 1440x3040@90"});
- p->addStateResidencyDataProvider(displaySdp);
-
- // Add display energy consumer
- android::sp<PowerStatsEnergyConsumer> displayConsumer;
- /*
- * TODO(b/167216667): Add correct display power model here. Must read from display rail
- * and include proper coefficients for display states. Must account for ALL devices built
- * using this source.
- */
- displayConsumer = PowerStatsEnergyConsumer::createMeterAndEntityConsumer(p,
- EnergyConsumerType::DISPLAY, "display", {"PPVAR_VSYS_PWR_DISP"}, "Display",
- {{"LP: 1440x3040@30", 1},
- {"On: 1440x3040@60", 2},
- {"On: 1440x3040@90", 3}});
-
- p->addEnergyConsumer(displayConsumer);
-}
-
-void addCPUclusters(std::shared_ptr<PowerStats> p)
-{
- 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
- android::sp<PowerStatsEnergyConsumer> gpuConsumer;
- std::map<std::string, int32_t> stateCoeffs;
- const int socRev = android::base::GetIntProperty(kBootHwSoCRev, 0);
-
- // B0/B1 chips have different GPU DVFS operating points than A0/A1 SoC
- if (socRev >= 2) {
- stateCoeffs = {
- {"151000", 10},
- {"202000", 20},
- {"251000", 30},
- {"302000", 40},
- {"351000", 50},
- {"400000", 60},
- {"471000", 70},
- {"510000", 80},
- {"572000", 90},
- {"701000", 100},
- {"762000", 110},
- {"848000", 120}};
- } else {
- stateCoeffs = {
- {"151000", 10},
- {"302000", 20},
- {"455000", 30},
- {"572000", 40},
- {"670000", 50}};
- }
-
- gpuConsumer = PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
- EnergyConsumerType::OTHER, "GPU", {"S2S_VDD_G3D"},
- {{UID_TIME_IN_STATE, "/sys/devices/platform/1c500000.mali/uid_time_in_state"}},
- stateCoeffs);
-
- p->addEnergyConsumer(gpuConsumer);
-}
-
-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", "");
-
- android::sp<GenericStateResidencyDataProvider> modemSdp = new GenericStateResidencyDataProvider(
- "/sys/devices/platform/cpif/modem/power_stats", cfgs);
-
- p->addStateResidencyDataProvider(modemSdp);
-
- p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
- EnergyConsumerType::MOBILE_RADIO, "MODEM", {"VSYS_PWR_MODEM", "VSYS_PWR_RFFE"}));
-}
-
-void addGNSS(std::shared_ptr<PowerStats> p)
-{
- p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer(p,
- EnergyConsumerType::GNSS, "GPS", {"L9S_GNSS_CORE"}));
-}
-
-int main() {
- LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting.";
-
- // single thread
- ABinderProcess_setThreadPoolMaxThreadCount(0);
-
- std::shared_ptr<PowerStats> p = ndk::SharedRefBase::make<PowerStats>();
-
- setEnergyMeter(p);
-
- addAoC(p);
- addDisplay(p);
- addDvfsStats(p);
- addSoC(p);
- addCPUclusters(p);
- addGPU(p);
- addMobileRadio(p);
- addGNSS(p);
-
- const std::string instance = std::string() + PowerStats::descriptor + "/default";
- binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());
- LOG_ALWAYS_FATAL_IF(status != STATUS_OK);
-
- ABinderProcess_joinThreadPool();
- return EXIT_FAILURE; // should not reach
-}
diff --git a/rro_overlays/WifiOverlay/res/values/config.xml b/rro_overlays/WifiOverlay/res/values/config.xml
index e958aec..de8766d 100644
--- a/rro_overlays/WifiOverlay/res/values/config.xml
+++ b/rro_overlays/WifiOverlay/res/values/config.xml
@@ -114,4 +114,7 @@
<!-- Enable concurrent STA + Bridged access point (AP) support -->
<bool translatable="false" name="config_wifiStaWithBridgedSoftApConcurrencySupported">true</bool>
+
+ <!-- Enable aggregation of Wifi link layer radio stats from all radios -->
+ <bool translatable="false" name="config_config_wifiLinkLayerAllRadiosStatsAggregationEnabled">true</bool>
</resources>