Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[battery-udev] Add battery tracker that utilizes udev. Fixes JB#43282
Reading battery information from virtual filesystem provided by statefs has problems that vary from one device type to another. Implementing udev based battery and charger tracking bypasses problematic statefs interfaces and also allows suspend proofing input processing in more robust manner. The battery-udev plugin enumerates all power_supply devices via libudev on startup and then subscribes to change notifications. Properties exposed via udev are mapped into battery / charger information in the format expected by mce and then broadcast internally within mce via relevant aatapipes and externally on D-Bus. If some power_supply devices are producing false positives or otherwise causing problems for the heuristics, they can be excluded from evaluation via blacklist block in mce configuration files. [BatteryUDevDeviceBlacklist] <device1 sysname>=TRUE <device2 sysname>=TRUE Sample config file at: inifiles/battery-udev-devices.ini When debugging (porting to new platform etc) the plugin can be instructed to track also changes in power_supply properties that should not be relevant for battery / charger state evaluation via config block like: [BatteryUDevPropertyBlacklist] <property name>=TRUE # property changes are not shown <property name>=FALSE # property changes are shown # properties not mentioned in blacklist are show Sample config file at: inifiles/battery-udev-properties.ini Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
- Loading branch information
Showing
7 changed files
with
1,475 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Configuration file for MCE - udev battery plugin | ||
|
||
[BatteryUDevDeviceBlacklist] | ||
|
||
# By default mce tracks all power supply devices via udev to evaluate | ||
# current battery capacity, charging status and whether any charger | ||
# devices are in active state. Should there be misclassification or | ||
# other hiccups, mce can be instructed to ignore some devices by | ||
# adding a lines with content: | ||
# <device sysname>=TRUE | ||
|
||
# Sony Xperia XA2 has "pc_port" charger power supply device | ||
# occasionally gets stuck to POWER_SUPPLY_ONLINE=1 state - which | ||
# makes it look like charger cable never gets disconnected. | ||
# Blacklisting the charger device means charger connection state | ||
# is deduced from battery charging status rather than potentially | ||
# misreported charger device state. | ||
pc_port=TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# Configuration file for MCE - udev battery plugin | ||
|
||
[BatteryUDevPropertyBlacklist] | ||
|
||
# If "BatteryUDevPropertyBlacklist" config block does not exist, | ||
# mce will track and process only udev properties that are needed | ||
# for battery/charger state evaluation. | ||
|
||
# If "BatteryUDevPropertyBlacklist" config block does exist, mce | ||
# will still ignore properties with TRUE value, but emits diagnostic | ||
# logging when undefined / properties set to FALSE change value. | ||
|
||
# Thus the idea is that when device is functioning as expected, | ||
# a config file like this is not required at all. But when debugging | ||
# problems, it can be used to gain visibility on select power | ||
# supply device property changes. | ||
|
||
# Note: Values that are needed for state evaluation (and thus can't | ||
# be blacklisted) are as follows: | ||
# | ||
# POWER_SUPPLY_PRESENT | ||
# POWER_SUPPLY_ONLINE | ||
# POWER_SUPPLY_CAPACITY | ||
# POWER_SUPPLY_STATUS | ||
|
||
# Generic device properties | ||
bootdevice=TRUE | ||
ACTION=TRUE | ||
DEVPATH=TRUE | ||
PLATFORM_DEVICE=TRUE | ||
PLATFORM_FOLDER=TRUE | ||
SEQNUM=TRUE | ||
SUBSYSTEM=TRUE | ||
USEC_INITIALIZED=TRUE | ||
|
||
# "Uninteresting" power supply device specific properties seen | ||
# on already supported hardwares. | ||
POWER_SUPPLY_ALLOW_HVDCP3=TRUE | ||
POWER_SUPPLY_BATTERY_CHARGING_ENABLED=TRUE | ||
#POWER_SUPPLY_BATTERY_TYPE=TRUE | ||
POWER_SUPPLY_BATT_AGING=TRUE | ||
POWER_SUPPLY_BOOST_CURRENT=TRUE | ||
POWER_SUPPLY_CABLE_TYPE | ||
POWER_SUPPLY_CAPACITY_RAW=TRUE | ||
POWER_SUPPLY_CC_STEP=TRUE | ||
POWER_SUPPLY_CC_STEP_SEL=TRUE | ||
POWER_SUPPLY_CHARGER_DISABLE | ||
POWER_SUPPLY_CHARGER_TEMP=TRUE | ||
POWER_SUPPLY_CHARGER_TEMP_MAX=TRUE | ||
POWER_SUPPLY_CHARGE_CONTROL_LIMIT | ||
POWER_SUPPLY_CHARGE_CONTROL_LIMIT_MAX | ||
POWER_SUPPLY_CHARGE_COUNTER=TRUE | ||
POWER_SUPPLY_CHARGE_CURRENT | ||
POWER_SUPPLY_CHARGE_DONE=TRUE | ||
POWER_SUPPLY_CHARGE_FULL=TRUE | ||
POWER_SUPPLY_CHARGE_FULL_DESIGN=TRUE | ||
POWER_SUPPLY_CHARGE_NOW=TRUE | ||
POWER_SUPPLY_CHARGE_NOW_ERROR=TRUE | ||
POWER_SUPPLY_CHARGE_NOW_RAW=TRUE | ||
POWER_SUPPLY_CHARGE_TERM_CUR | ||
#POWER_SUPPLY_CHARGE_TYPE=TRUE | ||
POWER_SUPPLY_CHARGE_VOLTAGE | ||
POWER_SUPPLY_CHARGING_ENABLED=TRUE | ||
POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE=TRUE | ||
POWER_SUPPLY_CTM_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_CURRENT_AVG | ||
POWER_SUPPLY_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_CURRENT_NOW=TRUE | ||
POWER_SUPPLY_CURRENT_QNOVO=TRUE | ||
POWER_SUPPLY_CYCLE_COUNT=TRUE | ||
POWER_SUPPLY_CYCLE_COUNT_ID=TRUE | ||
POWER_SUPPLY_DEBUG_BATTERY=TRUE | ||
POWER_SUPPLY_DIE_HEALTH=TRUE | ||
POWER_SUPPLY_DP_DM=TRUE | ||
POWER_SUPPLY_ENABLE_CHARGER | ||
POWER_SUPPLY_ENABLE_CHARGING | ||
POWER_SUPPLY_ENABLE_SHUTDOWN_AT_LOW_BATTERY=TRUE | ||
POWER_SUPPLY_ENERGY_EMPTY | ||
POWER_SUPPLY_ENERGY_EMPTY_DESIGN | ||
POWER_SUPPLY_ENERGY_FULL | ||
POWER_SUPPLY_ENERGY_FULL_DESIGN | ||
POWER_SUPPLY_ENERGY_NOW | ||
POWER_SUPPLY_ESR_COUNT=TRUE | ||
POWER_SUPPLY_FCC_DELTA=TRUE | ||
POWER_SUPPLY_FLASH_ACTIVE=TRUE | ||
POWER_SUPPLY_FLASH_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_FLASH_TRIGGER=TRUE | ||
POWER_SUPPLY_FV_CFG=TRUE | ||
POWER_SUPPLY_FV_CMP_CFG=TRUE | ||
POWER_SUPPLY_HEALTH=TRUE | ||
POWER_SUPPLY_HI_POWER | ||
POWER_SUPPLY_HW_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_INPUT_CURRENT_LIMITED=TRUE | ||
POWER_SUPPLY_INPUT_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_INPUT_CURRENT_NOW=TRUE | ||
POWER_SUPPLY_INPUT_CURRENT_SETTLED=TRUE | ||
POWER_SUPPLY_INPUT_CUR_LIMIT | ||
POWER_SUPPLY_INPUT_SUSPEND=TRUE | ||
POWER_SUPPLY_INPUT_VOLTAGE_SETTLED=TRUE | ||
POWER_SUPPLY_INT_CLD=TRUE | ||
POWER_SUPPLY_LOW_POWER | ||
POWER_SUPPLY_LRC_ENABLE=TRUE | ||
POWER_SUPPLY_LRC_NOT_STARTUP=TRUE | ||
POWER_SUPPLY_LRC_SOCMAX=TRUE | ||
POWER_SUPPLY_LRC_SOCMIN=TRUE | ||
POWER_SUPPLY_MAX_CHARGE_CURRENT | ||
POWER_SUPPLY_MAX_CHARGE_VOLTAGE | ||
POWER_SUPPLY_MAX_TEMP | ||
POWER_SUPPLY_MIN_TEMP | ||
POWER_SUPPLY_MODEL_NAME | ||
POWER_SUPPLY_NAME=TRUE | ||
POWER_SUPPLY_PARALLEL_DISABLE=TRUE | ||
POWER_SUPPLY_PARALLEL_MODE=TRUE | ||
POWER_SUPPLY_PD_ACTIVE=TRUE | ||
POWER_SUPPLY_PD_ALLOWED=TRUE | ||
POWER_SUPPLY_PD_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_PD_VOLTAGE_MAX=TRUE | ||
POWER_SUPPLY_PD_VOLTAGE_MIN=TRUE | ||
POWER_SUPPLY_PE_START=TRUE | ||
POWER_SUPPLY_PR_SWAP=TRUE | ||
#POWER_SUPPLY_REAL_TYPE=TRUE | ||
POWER_SUPPLY_RERUN_AICL=TRUE | ||
POWER_SUPPLY_RESISTANCE=TRUE | ||
POWER_SUPPLY_RESISTANCE_CAPACITIVE | ||
POWER_SUPPLY_RESISTANCE_ID=TRUE | ||
POWER_SUPPLY_RESISTANCE_NOW | ||
POWER_SUPPLY_RESTRICTED_CHARGING=TRUE | ||
POWER_SUPPLY_SAFETY_TIMER_ENABLED=TRUE | ||
POWER_SUPPLY_SCOPE=TRUE | ||
POWER_SUPPLY_SDP_CURRENT_MAX=TRUE | ||
POWER_SUPPLY_SET_SHIP_MODE=TRUE | ||
POWER_SUPPLY_SOC_REPORTING_READY=TRUE | ||
POWER_SUPPLY_STEP_CHARGING_ENABLED=TRUE | ||
#POWER_SUPPLY_SUB_TYPE=TRUE | ||
POWER_SUPPLY_SW_JEITA_ENABLED=TRUE | ||
POWER_SUPPLY_SYSTEM_TEMP_LEVEL=TRUE | ||
POWER_SUPPLY_TECHNOLOGY=TRUE | ||
POWER_SUPPLY_TEMP=TRUE | ||
POWER_SUPPLY_TEMP_COOL=TRUE | ||
POWER_SUPPLY_TEMP_WARM=TRUE | ||
POWER_SUPPLY_TIME_TO_EMPTY_AVG=TRUE | ||
POWER_SUPPLY_TIME_TO_FULL_AVG=TRUE | ||
#POWER_SUPPLY_TYPE=TRUE | ||
POWER_SUPPLY_TYPEC_CC_ORIENTATION=TRUE | ||
POWER_SUPPLY_TYPEC_MODE=TRUE | ||
POWER_SUPPLY_TYPEC_POWER_ROLE=TRUE | ||
POWER_SUPPLY_UPDATE_NOW=TRUE | ||
POWER_SUPPLY_USB_OTG=TRUE | ||
POWER_SUPPLY_VOLTAGE_MAX=TRUE | ||
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=TRUE | ||
POWER_SUPPLY_VOLTAGE_MIN=TRUE | ||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN | ||
POWER_SUPPLY_VOLTAGE_NOW=TRUE | ||
POWER_SUPPLY_VOLTAGE_OCV=TRUE | ||
POWER_SUPPLY_VOLTAGE_QNOVO=TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.