Eliminate dual-target idle wakeups and stage upcoming a1114 (carbonara) build
- Replace continuous polling in bananarchy-lid and bananarchy-volume-keys with /dev/input inotify watching and IRQ-driven poll(..., -1) steady state, and sync CPU/schedutil/GPU power knobs on flip transitions - Grant video-group write permissions to Adreno 304 devfreq governor, sync GPU powersave/simple_ondemand across bananarchy-display-power-sync and locker.so, and restore schedutil rate_limit_us on forced transitions - Trim per-minute statusbar clock forks, skip unchanged ext4 brightness rewrites and no-op sxmo_autosuspend spawns on blanking, and make bananarchy-bt-obex fully event-driven via inotify and blocking select - Register upcoming build a1114 (carbonara) in version.sh, check-rebuild.sh, CHANGELOG.md, AGENTS.md, and BATTERY-OPTIMIZATION-ANALYSIS.md while keeping a1111 (lennon) as the current public release
This commit is contained in:
1 parent
ed04da3e23
commit
e42024e90d
22 files changed
+416
-75
No files matched your search
@@ -49,6 +49,10 @@ for gov_file in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor /sys/de
|
||||
chmod 0664 "$gov_file" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
if [ -e /sys/class/devfreq/1c00000.gpu/governor ]; then
|
||||
chgrp video /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
|
||||
chmod 0664 /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Ensure rootfs pm8916_lbc and pm8916_bms_vm modules are active if initramfs loaded an older build
|
||||
if [ -r /sys/class/power_supply/pm8916-lbc-chgr/constant_charge_current ]; then
|
||||
|
||||
@@ -289,7 +289,29 @@ def handle_obex_rx_session(sock):
|
||||
pass
|
||||
|
||||
|
||||
def run_gamepad_uinput_bridge(is_running):
|
||||
def open_input_inotify_fd():
|
||||
try:
|
||||
import ctypes
|
||||
libc = ctypes.CDLL(None, use_errno=True)
|
||||
libc.inotify_init.argtypes = []
|
||||
libc.inotify_init.restype = ctypes.c_int
|
||||
libc.inotify_add_watch.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32]
|
||||
libc.inotify_add_watch.restype = ctypes.c_int
|
||||
fd = libc.inotify_init()
|
||||
if fd < 0:
|
||||
return -1
|
||||
os.set_inheritable(fd, False)
|
||||
os.set_blocking(fd, False)
|
||||
# IN_ATTRIB (0x04) | IN_MOVED_TO (0x80) | IN_CREATE (0x100) | IN_DELETE (0x200)
|
||||
if libc.inotify_add_watch(fd, b"/dev/input", 0x00000384) < 0:
|
||||
os.close(fd)
|
||||
return -1
|
||||
return fd
|
||||
except Exception:
|
||||
return -1
|
||||
|
||||
|
||||
def run_gamepad_uinput_bridge(is_running, wake_r=-1):
|
||||
ev_fmt = "llHHi"
|
||||
ev_size = struct.calcsize(ev_fmt)
|
||||
ui_set_evbit = 0x40045564
|
||||
@@ -328,6 +350,8 @@ def run_gamepad_uinput_bridge(is_running):
|
||||
gamepads = {} # path -> {"fd": int, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}}
|
||||
last_scan = 0.0
|
||||
last_input_mtime = 0
|
||||
inotify_fd = open_input_inotify_fd()
|
||||
need_scan = True
|
||||
|
||||
def ensure_uinput():
|
||||
nonlocal uinput_fd
|
||||
@@ -385,7 +409,8 @@ def run_gamepad_uinput_bridge(is_running):
|
||||
|
||||
while is_running():
|
||||
now = time.monotonic()
|
||||
if now - last_scan >= 2.0:
|
||||
if need_scan or (inotify_fd < 0 and now - last_scan >= 2.0):
|
||||
need_scan = False
|
||||
last_scan = now
|
||||
try:
|
||||
st_in = os.stat("/dev/input")
|
||||
@@ -430,17 +455,37 @@ def run_gamepad_uinput_bridge(is_running):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if not gamepads:
|
||||
fd_map = {info["fd"]: (path, info) for path, info in list(gamepads.items())}
|
||||
wait_fds = list(fd_map.keys())
|
||||
if inotify_fd >= 0:
|
||||
wait_fds.append(inotify_fd)
|
||||
if wake_r >= 0:
|
||||
wait_fds.append(wake_r)
|
||||
if not wait_fds:
|
||||
time.sleep(1.5)
|
||||
continue
|
||||
|
||||
fd_map = {info["fd"]: (path, info) for path, info in list(gamepads.items())}
|
||||
sel_timeout = None if (inotify_fd >= 0 and wake_r >= 0) else 2.0
|
||||
try:
|
||||
rlist, _, _ = select.select(list(fd_map.keys()), [], [], 1.0)
|
||||
rlist, _, _ = select.select(wait_fds, [], [], sel_timeout)
|
||||
except Exception:
|
||||
time.sleep(0.5)
|
||||
if is_running():
|
||||
time.sleep(0.5)
|
||||
continue
|
||||
|
||||
if not is_running():
|
||||
break
|
||||
|
||||
if inotify_fd >= 0 and inotify_fd in rlist:
|
||||
while True:
|
||||
try:
|
||||
if not os.read(inotify_fd, 512):
|
||||
break
|
||||
except BlockingIOError:
|
||||
break
|
||||
except OSError:
|
||||
break
|
||||
need_scan = True
|
||||
|
||||
for rfd in rlist:
|
||||
path, info = fd_map.get(rfd, (None, None))
|
||||
if not path:
|
||||
@@ -518,6 +563,11 @@ def run_gamepad_uinput_bridge(is_running):
|
||||
emit_key(108, 1)
|
||||
info["ly"] = new_dir
|
||||
|
||||
if inotify_fd >= 0:
|
||||
try:
|
||||
os.close(inotify_fd)
|
||||
except OSError:
|
||||
pass
|
||||
for info in gamepads.values():
|
||||
try:
|
||||
os.close(info["fd"])
|
||||
@@ -696,10 +746,19 @@ def run_daemon():
|
||||
notify_networks_ui()
|
||||
|
||||
running = True
|
||||
wake_r, wake_w = os.pipe()
|
||||
os.set_inheritable(wake_r, False)
|
||||
os.set_inheritable(wake_w, False)
|
||||
os.set_blocking(wake_r, False)
|
||||
os.set_blocking(wake_w, False)
|
||||
|
||||
def stop_handler(_signum, _frame):
|
||||
nonlocal running
|
||||
running = False
|
||||
try:
|
||||
os.write(wake_w, b"\x01")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
signal.signal(signal.SIGTERM, stop_handler)
|
||||
signal.signal(signal.SIGINT, stop_handler)
|
||||
@@ -737,7 +796,7 @@ def run_daemon():
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
gp_thread = threading.Thread(target=run_gamepad_uinput_bridge,
|
||||
args=(lambda: running,), daemon=True)
|
||||
args=(lambda: running, wake_r), daemon=True)
|
||||
gp_thread.start()
|
||||
|
||||
profile_path = "/org/bananarchy/obex_opp"
|
||||
@@ -776,11 +835,20 @@ def run_daemon():
|
||||
while running:
|
||||
try:
|
||||
if conn is not None:
|
||||
try:
|
||||
msg = conn.receive(timeout=1.0)
|
||||
except TimeoutError:
|
||||
msg = None
|
||||
if msg is not None:
|
||||
while running:
|
||||
try:
|
||||
msg = conn.receive(timeout=0.0)
|
||||
except TimeoutError:
|
||||
msg = None
|
||||
except (EOFError, OSError):
|
||||
try:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
conn = None
|
||||
break
|
||||
if msg is None:
|
||||
break
|
||||
if handle_agent_method_call(conn, msg, agent_path):
|
||||
pass
|
||||
elif msg.header.message_type == MessageType.method_call:
|
||||
@@ -811,20 +879,35 @@ def run_daemon():
|
||||
if iface == "org.bluez.Device1" and isinstance(changed, dict):
|
||||
if any(k in changed for k in ("Connected", "Paired", "Bonded")):
|
||||
notify_networks_ui()
|
||||
else:
|
||||
time.sleep(1.0)
|
||||
|
||||
if rfcomm_listener is not None:
|
||||
try:
|
||||
csock, _addr = rfcomm_listener.accept()
|
||||
t = threading.Thread(target=handle_obex_rx_session,
|
||||
args=(csock,), daemon=True)
|
||||
t.start()
|
||||
except BlockingIOError:
|
||||
pass
|
||||
except Exception:
|
||||
time.sleep(0.5)
|
||||
while running:
|
||||
try:
|
||||
csock, _addr = rfcomm_listener.accept()
|
||||
t = threading.Thread(target=handle_obex_rx_session,
|
||||
args=(csock,), daemon=True)
|
||||
t.start()
|
||||
except BlockingIOError:
|
||||
break
|
||||
|
||||
if not running:
|
||||
break
|
||||
|
||||
wait_fds = [wake_r]
|
||||
if conn is not None and getattr(conn, "sock", None) is not None:
|
||||
wait_fds.append(conn.sock)
|
||||
if rfcomm_listener is not None:
|
||||
wait_fds.append(rfcomm_listener)
|
||||
select.select(wait_fds, [], [], None if len(wait_fds) > 1 else 5.0)
|
||||
except Exception:
|
||||
if running:
|
||||
time.sleep(0.5)
|
||||
|
||||
for fd in (wake_r, wake_w):
|
||||
try:
|
||||
os.close(fd)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
if os.path.exists(PID_FILE):
|
||||
os.unlink(PID_FILE)
|
||||
|
||||
@@ -14,6 +14,7 @@ BR_PATH=/sys/class/backlight/backlight/brightness
|
||||
BL_POWER_PATH=/sys/class/backlight/backlight/bl_power
|
||||
KBD_PATH=/sys/class/leds/white:kbd_backlight/brightness
|
||||
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
||||
GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
|
||||
COVER_MARKER=/run/bananarchy/cover-backlight
|
||||
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
||||
STATE_CACHE=/run/bananarchy/cover-power-state
|
||||
@@ -78,15 +79,15 @@ br="$(read_value "$BR_PATH")"
|
||||
case "$br" in ''|*[!0-9]*) br=1 ;; esac
|
||||
|
||||
# Non-flip devices (e.g. nokia-argon slider) have a single panel with no cover
|
||||
# display or shared backlight: sync DRM DPMS and schedutil directly.
|
||||
# display or shared backlight: sync DRM DPMS, GPU devfreq and schedutil directly.
|
||||
if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
|
||||
if [ "$br" -eq 0 ]; then
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||
force_dpms "Off"
|
||||
else
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||
force_dpms "On"
|
||||
if [ -w "$RL_PATH" ]; then
|
||||
printf '40000\n' > "$RL_PATH" 2>/dev/null || true
|
||||
fi
|
||||
[ -w "$RL_PATH" ] && set_if_changed "$RL_PATH" "40000"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
@@ -176,14 +177,18 @@ else
|
||||
fi
|
||||
|
||||
[ -n "$DESIRED_KBD" ] && set_if_changed "$KBD_PATH" "$DESIRED_KBD"
|
||||
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||
else
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||
fi
|
||||
force_dpms "$DESIRED_DPMS"
|
||||
[ -w "$RL_PATH" ] && set_if_changed "$RL_PATH" "40000"
|
||||
|
||||
if [ "$FORCE" -eq 1 ]; then
|
||||
printf '%s\n' "$DESIRED_KEY" > "$STATE_CACHE" 2>/dev/null || true
|
||||
cleanup_force
|
||||
trap - EXIT INT TERM HUP
|
||||
elif [ "$br" -ne 0 ] && [ -w "$RL_PATH" ]; then
|
||||
printf '40000\n' > "$RL_PATH" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,7 @@
|
||||
# It watches file events to stdout new content
|
||||
|
||||
ROOT="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/${SXMO_STATUS_NAME:-default}"
|
||||
mkdir -p "$ROOT"
|
||||
[ -d "$ROOT" ] || mkdir -p "$ROOT"
|
||||
|
||||
lock_ex() {
|
||||
:
|
||||
@@ -64,7 +64,7 @@ add() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT"
|
||||
[ -d "$ROOT" ] || mkdir -p "$ROOT"
|
||||
padded_prio="$(printf '%03d' "$priority" 2>/dev/null || printf '%s' "$priority")"
|
||||
target="$ROOT/$padded_prio-$id"
|
||||
|
||||
|
||||
@@ -51,8 +51,14 @@ xorgdisplay() {
|
||||
read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
||||
if [ "${_cur_bl:-0}" -ge 1 ] 2>/dev/null; then
|
||||
printf '%s\n' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true
|
||||
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" 2>/dev/null || true
|
||||
printf '%s\n' "$_cur_bl" > "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true
|
||||
_bl_cfg_dir="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo"
|
||||
_bl_cfg_file="$_bl_cfg_dir/brightness"
|
||||
_prev_bl=""
|
||||
[ -r "$_bl_cfg_file" ] && { read -r _prev_bl < "$_bl_cfg_file" 2>/dev/null || _prev_bl=""; }
|
||||
if [ "$_prev_bl" != "$_cur_bl" ]; then
|
||||
[ -d "$_bl_cfg_dir" ] || mkdir -p "$_bl_cfg_dir" 2>/dev/null || true
|
||||
printf '%s\n' "$_cur_bl" > "$_bl_cfg_file" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -w /sys/class/backlight/backlight/brightness ]; then
|
||||
|
||||
Binary file not shown.
@@ -39,7 +39,9 @@ fi
|
||||
sxmo_jobs.sh stop idle_locker
|
||||
|
||||
# U2: enter deep standby after BANANARCHY_SUSPEND_GRACE seconds of screen-off.
|
||||
( /usr/bin/sxmo_autosuspend.sh >/dev/null 2>&1 & \
|
||||
printf '%s\n' "$!" > /tmp/bananarchy_autosuspend.pid )
|
||||
if [ ! -f /etc/bananarchy-no-deep-standby ]; then
|
||||
( /usr/bin/sxmo_autosuspend.sh >/dev/null 2>&1 & \
|
||||
printf '%s\n' "$!" > /tmp/bananarchy_autosuspend.pid )
|
||||
fi
|
||||
|
||||
wait
|
||||
@@ -16,7 +16,9 @@ fi
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||
. sxmo_hook_icons.sh
|
||||
if [ "${1:-}" != "time" ]; then
|
||||
. sxmo_hook_icons.sh
|
||||
fi
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
@@ -26,7 +28,19 @@ fi
|
||||
# right and "variable" icons (that come and go) on the left.
|
||||
|
||||
set_time() {
|
||||
sxmobar -a time 99 " $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")"
|
||||
_time_val=" $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")"
|
||||
_time_dir="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/${SXMO_STATUS_NAME:-default}"
|
||||
if [ -d "$_time_dir" ]; then
|
||||
_time_file="$_time_dir/099-time"
|
||||
_old_time=""
|
||||
[ -r "$_time_file" ] && { IFS= read -r _old_time < "$_time_file" 2>/dev/null || _old_time=""; }
|
||||
if [ "$_old_time" != "$_time_val" ]; then
|
||||
printf '%s\n' "$_time_val" > "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/.time.$$" && \
|
||||
mv -f "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/.time.$$" "$_time_file"
|
||||
fi
|
||||
else
|
||||
sxmobar -a time 99 "$_time_val"
|
||||
fi
|
||||
}
|
||||
|
||||
set_state() {
|
||||
|
||||
Reference in new issue
Block a user