RFC: Extending charge_type power-supply property to show valid values
<resend with Thomas who implemented the charge-behavior code added to the Cc>
Hi Sebastian,
Jelle (in the Cc) is looking into adding a UI to GNOME to allow users to enable battery long-life mode. The initial plan was to use the charge start and stop thresholds but not all laptop models support these, some only have a single toggle to turn long-life mode on/off.
At first look it seems that charge_type is the right userspace API to use for these single toggle only laptop models, offering "Standard" and "Long Life" as valid options.
However we don't want userspace to have to write charge_type just to find out which values are supported.
My proposal for this is to have a new POWER_SUPPLY_PROP_CHARGE_TYPES properties which behaves like USB_TYPE / CHARGE_BEHAVIOR, e.g. :
[hans@x1 linux]$ cat /sys/class/power_supply/ucsi-source-psy-USBC000\:001/usb_type
[C] PD PD_PPS
The idea would be to copy the charge_behavior model and add a charge_types bitmask to struct power_supply_desc mirroring the u8 charge_behaviours; bitmask. This will also allow re-using power_supply_charge_behaviour_show() turning it into a generic show function for usb_type / charge_behavior style properties.
Other then having the usb_type / charge_behavior style show() output the new charge_types which I'm suggesting would behave exactly the same as the old charge_type and drivers can use the same code paths to implement both. To get support for the new charge_types drivers just need to set a power_supply_desc.charge_types bitmap and add POWER_SUPPLY_PROP_CHARGE_TYPES to their list of supported properties.
The idea is for charge_types to basically superseed charge_type offering the same functionality while advertising which values are valid for writing, while keeping charge_type around for backward compatibility.
If this sounds good to you I can write a patch-set implementing the suggestion, + converting one or 2 drivers which already support writing charge_type atm.
Regards,
Hans
Hi,
Quoted 36 lines · Hans de Goede
<resend with Thomas who implemented the charge-behavior code added to the Cc>
Hi Sebastian,
Jelle (in the Cc) is looking into adding a UI to GNOME to allow users to enable battery long-life mode. The initial plan was to use the charge start and stop thresholds but not all laptop models support these, some only have a single toggle to turn long-life mode on/off.
At first look it seems that
charge_typeis the right userspace API to use for these single toggle only laptop models, offering "Standard" and "Long Life" as valid options.However we don't want userspace to have to write
charge_typejust to find out which values are supported.My proposal for this is to have a new
POWER_SUPPLY_PROP_CHARGE_TYPESproperties which behaves likeUSB_TYPE/CHARGE_BEHAVIOR, e.g. :[hans@x1 linux]$ cat /sys/class/power_supply/ucsi-source-psy-USBC000\:001/usb_type
[C] PDPD_PPSThe idea would be to copy the
charge_behaviormodel and add acharge_typesbitmask to structpower_supply_descmirroring the u8charge_behaviours; bitmask. This will also allow re-usingpower_supply_charge_behaviour_show()turning it into a generic show function forusb_type/charge_behaviorstyle properties.Other then having the
usb_type/charge_behaviorstyleshow()output the newcharge_typeswhich I'm suggesting would behave exactly the same as the oldcharge_typeand drivers can use the same code paths to implement both. To get support for the newcharge_typesdrivers just need to set a power_supply_desc.charge_types bitmap and addPOWER_SUPPLY_PROP_CHARGE_TYPESto their list of supported properties.
Quoted 8 lines
The idea is for
charge_typesto basically superseedcharge_typeoffering the same functionality while advertising which values are valid for writing, while keepingcharge_typearound for backward compatibility.If this sounds good to you I can write a patch-set implementing the suggestion, + converting one or 2 drivers which already support writing
charge_typeatm.
Yes, this plan sounds good to me.
-- Sebastian