Skip to content

Commit

Permalink
Merge pull request #9 from spiiroin/jb40062_charging_hysteresis
Browse files Browse the repository at this point in the history
[charging] Configurable charging hysteresis. Fixes JB#40062
  • Loading branch information
spiiroin authored Feb 22, 2022
2 parents 51135ea + 632daf8 commit db5b919
Show file tree
Hide file tree
Showing 10 changed files with 1,226 additions and 11 deletions.
30 changes: 30 additions & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ builtin-gconf.o:\
mce-log.h\
mce-setting.h\
mce.h\
modules/charging.h\
modules/display.h\
modules/doubletap.h\
modules/inactivity.h\
Expand All @@ -29,6 +30,7 @@ builtin-gconf.pic.o:\
mce-log.h\
mce-setting.h\
mce.h\
modules/charging.h\
modules/display.h\
modules/doubletap.h\
modules/inactivity.h\
Expand Down Expand Up @@ -714,6 +716,32 @@ modules/camera.pic.o:\
tklock.h\
modules/camera.h\

modules/charging.o:\
modules/charging.c\
builtin-gconf.h\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-log.h\
mce-setting.h\
mce.h\
musl-compatibility.h\
modules/charging.h\

modules/charging.pic.o:\
modules/charging.c\
builtin-gconf.h\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-log.h\
mce-setting.h\
mce.h\
musl-compatibility.h\
modules/charging.h\

modules/cpu-keepalive.o:\
modules/cpu-keepalive.c\
builtin-gconf.h\
Expand Down Expand Up @@ -1512,6 +1540,7 @@ tools/mcetool.o:\
mce-dbus.h\
mce-setting.h\
mce.h\
modules/charging.h\
modules/display.h\
modules/doubletap.h\
modules/inactivity.h\
Expand All @@ -1535,6 +1564,7 @@ tools/mcetool.pic.o:\
mce-dbus.h\
mce-setting.h\
mce.h\
modules/charging.h\
modules/display.h\
modules/doubletap.h\
modules/inactivity.h\
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ MODULES += $(MODULE_DIR)/proximity.so
MODULES += $(MODULE_DIR)/keypad.so
MODULES += $(MODULE_DIR)/inactivity.so
MODULES += $(MODULE_DIR)/camera.so
MODULES += $(MODULE_DIR)/charging.so
MODULES += $(MODULE_DIR)/alarm.so
MODULES += $(MODULE_DIR)/memnotify.so
MODULES += $(MODULE_DIR)/mempressure.so
Expand Down Expand Up @@ -625,6 +626,8 @@ NORMALIZE_USES_SPC =\
modules/callstate.c\
modules/callstate.h\
modules/camera.h\
modules/charging.c\
modules/charging.h\
modules/cpu-keepalive.c\
modules/display.c\
modules/display.h\
Expand Down Expand Up @@ -726,7 +729,7 @@ PROTO_CPPFLAGS += -D_Float128x="long double"

%.q : %.c ; $(CC) -o $@ -E $< $(PROTO_CPPFLAGS)
%.p : %.q ; cproto -s < $< | prettyproto.py | tee $@
%.g : %.q ; cproto < $< | prettyproto.py | tee $@
%.g : %.q ; cproto < $< | prettyproto.py -xg_module | tee $@

protos-q: $(patsubst %.c,%.q,$(wildcard *.c modules/*.c))
protos-p: $(patsubst %.c,%.p,$(wildcard *.c modules/*.c))
Expand Down
18 changes: 17 additions & 1 deletion builtin-gconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file builtin-gconf.c
* GConf compatibility module - for dynamic mce settings
* <p>
* Copyright (C) 2012-2019 Jolla Ltd.
* Copyright (c) 2012 - 2022 Jolla Ltd.
* <p>
* @author Simo Piiroinen <[email protected]>
*
Expand Down Expand Up @@ -49,6 +49,7 @@
#include "modules/doubletap.h"
#include "modules/led.h"
#include "modules/inactivity.h"
#include "modules/charging.h"

#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -1957,6 +1958,21 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_BUTTONBACKLIGHT_OFF_DELAY),
},
{
.key = MCE_SETTING_CHARGING_MODE,
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_CHARGING_MODE),
},
{
.key = MCE_SETTING_CHARGING_LIMIT_DISABLE,
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_CHARGING_LIMIT_DISABLE),
},
{
.key = MCE_SETTING_CHARGING_LIMIT_ENABLE,
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_CHARGING_LIMIT_ENABLE),
},
{
.key = NULL,
}
Expand Down
10 changes: 5 additions & 5 deletions depend_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- encoding: utf8 -*-

# ----------------------------------------------------------------------------
Expand All @@ -13,7 +13,7 @@ def is_local(path):
return not path.startswith("/")

def print_rule(dest, srce):
print "%s\\\n" % "\\\n\t".join(["%s:" % dest] + srce)
print("%s\\\n" % "\\\n\t".join(["%s:" % dest] + srce))

def set_extension(path, ext):
return os.path.splitext(path)[0] + ext
Expand All @@ -29,7 +29,7 @@ def fix_directory(dest, srce):
if __name__ == "__main__":

data = sys.stdin.readlines()
data = map(lambda x:x.rstrip(), data)
data = list(map(lambda x:x.rstrip(), data))
data.reverse()

deps = []
Expand All @@ -52,13 +52,13 @@ def fix_directory(dest, srce):
dest = fix_directory(dest, srce)

# remove secondary deps with absolute path
temp = filter(is_local, temp)
temp = list(filter(is_local, temp))

# sort secondary sources
temp.sort()

srce = [srce] + temp
srce = map(normalize_path, srce)
srce = list(map(normalize_path, srce))

deps.append((dest,srce))

Expand Down
26 changes: 26 additions & 0 deletions inifiles/charging.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Configuration file for MCE - charging hysteresis control -*- mode: sh -*-
#
# Provided that battery kernel driver supports such operation,
# mce can be instructed for example to cease charging when battery
# level reaches 90% and restart charging when battery level drops
# below 50%.
#
# While mce side state logic and settings are generic, how charging
# is actually enabled/disabled can vary from one device type to
# another depending on hw and related kernel drivers.

[Charging]

# Devices where kernel utilizes POWER_SUPPLY_PROP_CHARGING_ENABLED
# For example: f5121 (Xperia X), l500d (Jolla C)

#ControlPath = /sys/class/power_supply/battery/charging_enabled
#EnableValue = 1
#DisableValue = 0

# Devices where kernel utilizes POWER_SUPPLY_PROP_INPUT_SUSPEND
# For example: h3113 (Xperia XA2), i4113 (Xperia 10)

#ControlPath = /sys/class/power_supply/battery/input_suspend
#EnableValue = 0
#DisableValue = 1
2 changes: 1 addition & 1 deletion inifiles/mce.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# to avoid unnecessary brightness fluctuations on mce startup
#
# Note: the name should not include the "lib"-prefix
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-udev;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;mempressure;usbmode;buttonbacklight;fingerprint;
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-udev;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;mempressure;usbmode;buttonbacklight;fingerprint;charging;

[KeyPad]

Expand Down
Loading

0 comments on commit db5b919

Please sign in to comment.