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
@@ -9,8 +9,9 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
||||
SPI displays: `nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler`, and `nokia-leo`.
|
||||
- The stack is X11-only: Xlibre, patched `sxmo-de-dwm`, preloaded C/C++ DWM plugins, NeoUI, `fcitx5-t9`, and Adreno 304
|
||||
Glamor/DRI3/GLX over `panel-mipi-dbi`. No Wayland compositor, backend, or viewer is shipped.
|
||||
- Design targets are keypad-first 240x320 UI, <2 ms wake latency, and <95 MB idle RAM on 512 MB devices. The pinned
|
||||
release is `a1111` / `lennon`; `scripts/version.sh` and `scripts/check-rebuild.sh` are authoritative.
|
||||
- Design targets are keypad-first 240x320 UI, <2 ms wake latency, and <95 MB idle RAM on 512 MB devices. The current
|
||||
public release is `a1111` / `lennon` and the upcoming target build is `a1114` / `carbonara`; `scripts/version.sh` and
|
||||
`scripts/check-rebuild.sh` are authoritative.
|
||||
|
||||
## Source of truth and workflow
|
||||
|
||||
@@ -29,10 +30,11 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
||||
- Rootfs/image tools are `scripts/bootstrap-rootfs.sh`, `scripts/apply-bananarchy-overlay.sh`,
|
||||
`scripts/compile-gsettings-schemas.sh`, `rebuild-image.sh`, `scripts/sync-beatles-bootfs.py --check`,
|
||||
`prepare-release.sh`, and `flash-edl.sh`.
|
||||
- Rebuild the verified release images with
|
||||
`BANANARCHY_VERSION=a1111 BANANARCHY_CODENAME=lennon ./rebuild-image.sh nokia-argon --mkinitfs` and
|
||||
`BANANARCHY_VERSION=a1111 BANANARCHY_CODENAME=lennon ./rebuild-image.sh nokia-beatles --mkinitfs`, and package release
|
||||
archives with `./prepare-release.sh nokia-argon` and `./prepare-release.sh nokia-beatles`. After a verified rebuild,
|
||||
- Rebuild the target images for upcoming build `a1114` / `carbonara` with
|
||||
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./rebuild-image.sh nokia-argon --mkinitfs` and
|
||||
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./rebuild-image.sh nokia-beatles --mkinitfs`, and package
|
||||
release archives with `BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./prepare-release.sh nokia-argon` and
|
||||
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./prepare-release.sh nokia-beatles`. After a verified rebuild,
|
||||
update the pinned hashes in `scripts/check-rebuild.sh` and `CHANGELOG.md`; verify with `e2fsck -fn`, `debugfs`, bootfs
|
||||
sync, artifact sync, and `check-rebuild.sh`.
|
||||
- Do not push to `origin` unless explicitly requested. Do not update pinned hashes or release claims without actual
|
||||
|
||||
@@ -1133,3 +1133,77 @@ domains, and the remaining periodic work is either event-driven or spaced
|
||||
policy, DDR self-refresh via lk2nd PSCI `SYSTEM_SUSPEND`, or a real
|
||||
battery-powered discharge measurement; they cannot come from more idle
|
||||
timer/sysctl trimming without hurting latency or connectivity.
|
||||
|
||||
---
|
||||
|
||||
## 19. Dual-target idle audit for upcoming build `a1114` / `carbonara` (`nokia-argon` and `nokia-beatles`)
|
||||
|
||||
After the Nokia 2720 Flip (`nokia-beatles`) lid/cover stack, Bluetooth HOGP/OBEX
|
||||
gamepad bridge, and minute-fresh dark statusbar clock landed in `a1108`--`a1111`,
|
||||
a fresh cross-target battery audit inspected every daemon, hook, DTB, kernel
|
||||
module, and sysfs power knob across both active devices for upcoming build
|
||||
`a1114` (codename `carbonara`).
|
||||
|
||||
### 19.1 Verified parity and clean subsystems
|
||||
|
||||
- **DTB and boot image parity**: `qcom-msm8905-nokia-beatles.dts` already matches
|
||||
`qcom-msm8905-nokia-argon.dts` on `cpu-opp-table` `clock-latency-ns`
|
||||
(`100000` ns), `spc` `cpu-idle-states`, peripheral `sleep` pinctrl states,
|
||||
`wakeup-source` `gpio-keys`, and identical `vmlinuz` plus patched
|
||||
`pm8916_bms_vm`, `pm8916_lbc`, and `wcn36xx` kernel modules.
|
||||
- **Target isolation**: `apply-bananarchy-overlay.sh` writes `slider` vs `flip`
|
||||
to `/usr/share/bananarchy/lid-profile` and disables all flip services, udev
|
||||
rules, and mux modules on `nokia-argon`.
|
||||
- **Desktop and drivers**: `dwm`, `dmenu`, preloaded `dwm` plugins,
|
||||
`dsds-daemon`, PipeWire/WirePlumber, `sshd-debug`, `unudhcpd`, `msm8905-cam`,
|
||||
and `leds-msm8905-torch` all rest at `0` wakeups/s when dark.
|
||||
|
||||
### 19.2 Six zero-regression optimizations implemented
|
||||
|
||||
1. **Event-driven steady state in `bananarchy-lid` (`nokia-beatles`)**:
|
||||
`bananarchy-lid.c` previously ran `poll(..., 20)` (`50 Hz` = 3,000
|
||||
wakeups/min), read `/sys/kernel/debug/gpio` to EOF at `10 Hz` (600 full SoC
|
||||
GPIO register dumps/min), and every `2 s` globbed `/dev/input/event*`,
|
||||
rewrote `/run/bananarchy/lid-state`, ran `sync_sw_lid()`, and sent
|
||||
`CLOSED`/`OPEN` to `/run/bananarchy/cover.sock` (waking
|
||||
`bananarchy-cover-idle` every 2 s). Because `hall-lid-open` (`gpio36`) and
|
||||
`hall-lid-closed` (`gpio92`) are hardware-IRQ `gpio-keys` with
|
||||
`wakeup-source`, `bananarchy-lid` now watches `/dev/input` via `inotify`,
|
||||
retains the `20 ms` (`LID_LOOP_MS` / `LID_DEBOUNCE_MS` / `HALL_EDGE_MS`)
|
||||
settle window on `EV_SW` edges plus one `+2 s` post-transition confirmation
|
||||
broadcast, and then blocks in `poll(..., -1)` at `0` steady-state wakeups/s.
|
||||
Flip-open and flip-close transitions also synchronize CPU `scaling_governor`,
|
||||
`schedutil/rate_limit_us` (`40000`), and Adreno 304 `governor` directly in C.
|
||||
2. **Event-driven `bananarchy-volume-keys` (`nokia-beatles`)**:
|
||||
`bananarchy-volume-keys.c` replaced its `1,000 ms` `poll()` loop and `2,000 ms`
|
||||
`/dev/input/event*` `glob()` with an `inotify` watch on `/dev/input` plus
|
||||
`poll(..., -1)`, eliminating ~90 wakeups/min while keeping `BANANARCHY_INPUT_GLOB`
|
||||
FIFO polling for host tests.
|
||||
3. **Adreno 304 `devfreq` `powersave` permissions and `schedutil` `rate_limit_us`
|
||||
restoration (both targets)**: `10-power-save.start` previously granted
|
||||
`video`-group write permissions (`0664`) to CPU `scaling_governor` only, so
|
||||
`sxmo_wm.sh`'s `[ -w /sys/class/devfreq/1c00000.gpu/governor ]` check failed
|
||||
silently and left the GPU in `simple_ondemand` while dark. `10-power-save.start`
|
||||
now applies `chgrp video` and `chmod 0664` to `1c00000.gpu/governor`,
|
||||
`locker_plugin.cpp` toggles `1c00000.gpu/governor` on lockscreen idle-blank
|
||||
and wake, and `bananarchy-display-power-sync` synchronizes `1c00000.gpu/governor`
|
||||
and restores `schedutil/rate_limit_us = 40000` on both forced (`FORCE=1`) and
|
||||
normal (`FORCE=0`) transitions.
|
||||
4. **Lightweight per-minute clock maintenance (both targets)**:
|
||||
`sxmo_hook_statusbar.sh` skips sourcing the 257-line `sxmo_hook_icons.sh`
|
||||
table on `time` ticks and updates `099-time` directly in-shell when the
|
||||
`sxmo_status` runtime directory already exists (avoiding spawning
|
||||
`sxmo_status.sh` and two `mkdir -p` calls every minute while dark), and
|
||||
`sxmo_status.sh` guards `mkdir -p "$ROOT"` with `[ -d "$ROOT" ]`.
|
||||
5. **Avoid redundant ext4 eMMC write and no-op `sxmo_autosuspend.sh` fork on
|
||||
blanking (both targets)**: `sxmo_wm.sh display off` now writes
|
||||
`~/.config/sxmo/brightness` on ext4 only when brightness actually changed
|
||||
(avoiding dirty-page eMMC writeback wakeups 60 s after blanking), and
|
||||
`sxmo_hook_screenoff.sh` skips spawning `sxmo_autosuspend.sh` when
|
||||
`/etc/bananarchy-no-deep-standby` is present.
|
||||
6. **Event-driven `bananarchy-bt-obex` when Bluetooth is enabled (both
|
||||
targets)**: replaced the `1.0 s` D-Bus/RFCOMM poll timeout and the `1.5--2.0 s`
|
||||
`/dev/input` gamepad polling loop with a signal self-pipe, `ctypes` `inotify`
|
||||
on `/dev/input`, and blocking `select.select(..., None)`, dropping Bluetooth
|
||||
daemon idle wakeups from ~100/min to `0`/min and reducing gamepad hotplug
|
||||
latency from `2 s` to `<5 ms`.
|
||||
@@ -10,6 +10,18 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
||||
|
||||
---
|
||||
|
||||
## Upcoming build `a1114` — codename `carbonara`
|
||||
|
||||
Upcoming release build (`a1114` / `carbonara` via `scripts/version.sh`) targeting both **Nokia 8110 4G (`nokia-argon`)** and **Nokia 2720 Flip (`nokia-beatles`)** while keeping `a1111` (`lennon`) as the current published release.
|
||||
|
||||
### Dual-target idle wakeup elimination and GPU/scheduler power sync
|
||||
|
||||
- **2720 Flip event-driven idle daemons (`nokia-beatles`)**: replaced `bananarchy-lid`'s continuous `20 ms` (`50 Hz`) `poll()` loop, `10 Hz` `/sys/kernel/debug/gpio` full SoC GPIO register dump, and `2 s` `/dev/input` `glob` + `/run/bananarchy/cover.sock` broadcast with `/dev/input` `inotify` watching plus hardware `EV_SW` IRQ sleep (`poll(..., -1)` at `0` steady-state wakeups/s after the `20 ms` edge debounce and one `+2 s` post-transition confirmation check), and synchronized CPU `scaling_governor`, `schedutil/rate_limit_us` (`40000`), and Adreno 304 `governor` directly in `on_transition()`. Replaced `bananarchy-volume-keys`'s `1 s` `poll()` + `2 s` `/dev/input` `glob` loop with `/dev/input` `inotify` + `poll(..., -1)`.
|
||||
- **Shared GPU `devfreq`, `schedutil`, statusbar, eMMC, and Bluetooth idle fixes (`nokia-argon` and `nokia-beatles`)**: granted `video`-group `0664` permissions to `/sys/class/devfreq/1c00000.gpu/governor` in `10-power-save.start`, synced `1c00000.gpu/governor` (`powersave` while dark or cover-lit, `simple_ondemand` when the main panel wakes) in `bananarchy-display-power-sync` and `locker.so`, and restored `schedutil/rate_limit_us = 40000` on `FORCE=1` transitions as well as normal udev events. `sxmo_hook_statusbar.sh` skips `sxmo_hook_icons.sh` on `time` ticks and updates `099-time` directly in-shell without spawning `sxmo_status.sh` and duplicate `mkdir -p` forks every minute; `sxmo_wm.sh display off` skips rewriting `~/.config/sxmo/brightness` on ext4 when unchanged; `sxmo_hook_screenoff.sh` skips spawning `sxmo_autosuspend.sh` when `/etc/bananarchy-no-deep-standby` is present; and `bananarchy-bt-obex` replaces its `1.0 s` D-Bus/RFCOMM poll and `1.5-2.0 s` `/dev/input` gamepad scan with a signal self-pipe, `ctypes` `inotify`, and blocking `select.select(..., None)` (`0` idle wakeups/s when Bluetooth is enabled, `<5 ms` gamepad hotplug).
|
||||
- **Image persistence and upcoming release archives**: rebuilt both `images/bananarchy-nokia-argon.img` (SHA-256 `89173379f80ca8c7a0153dd49196eed04bdf039f9a94f8f239ad12928a04abb6`) and `images/bananarchy-nokia-beatles.img` (SHA-256 `58e2df065a761e5476135971d37d3c09681621ff6c68e5e4d6f9eec852a11d74`, with standalone `images/boot-bananarchy-nokia-beatles.img` SHA-256 `199fe9a0b926e8ddf9815b0d7a901d913aa5b79be78fc4202a9ed2651ca493ac` and unchanged display lk2nd `b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d`) stamped as `a1114` / `carbonara` with `--mkinitfs`, pinned in `scripts/check-rebuild.sh`, and packaged into `bananarchy-nokia-argon-a1114-carbonara.zip` and `bananarchy-nokia-beatles-a1114-carbonara.zip`.
|
||||
|
||||
---
|
||||
|
||||
## Build `a1111` — codename `lennon` (2026-11-11)
|
||||
|
||||
This build contains all previously unreleased 2720 Flip (`nokia-beatles`) changes since `a1108`, strict per-device `lid-profile` isolation keeping `nokia-argon` on its pure `a1108` sliding-lid path, and fresh `a1111` / `lennon` images for both `nokia-argon` and `nokia-beatles`. The image and release metadata are generated by `scripts/version.sh` as `a1111` / `lennon`.
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+36
-13
@@ -372,9 +372,9 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"a93f0dc5a87d30b9084fcc8df97c78e7496ca1564e4855efe12e4696387a7d4d images/bananarchy-nokia-argon.img" \
|
||||
"7e1a24270e25beedcbc92b3fc8b7f2b314e3c7a9bf7a8e2dbffae1754d1b74c7 images/bananarchy-nokia-beatles.img" \
|
||||
"4b190404e8e9b53955a87ff211e0f706e51d08e4df11689cfa5586422e65763d images/boot-bananarchy-nokia-beatles.img" \
|
||||
"89173379f80ca8c7a0153dd49196eed04bdf039f9a94f8f239ad12928a04abb6 images/bananarchy-nokia-argon.img" \
|
||||
"58e2df065a761e5476135971d37d3c09681621ff6c68e5e4d6f9eec852a11d74 images/bananarchy-nokia-beatles.img" \
|
||||
"199fe9a0b926e8ddf9815b0d7a901d913aa5b79be78fc4202a9ed2651ca493ac images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
@@ -1128,6 +1128,24 @@ if ! grep -q 'compaction_proactiveness' \
|
||||
"$BASE_DIR/overlay/rootfs/etc/local.d/10-power-save.start"; then
|
||||
fail "10-power-save.start no longer disables proactive compaction"
|
||||
fi
|
||||
if ! grep -qF 'chgrp video /sys/class/devfreq/1c00000.gpu/governor' \
|
||||
"$BASE_DIR/overlay/rootfs/etc/local.d/10-power-save.start" || \
|
||||
! grep -qF 'GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor' \
|
||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||
! strings "$BASE_DIR/prebuilt/sxmo-x11/usr/lib/dwm/plugins/locker.so" 2>/dev/null | \
|
||||
grep -qF '1c00000.gpu/governor'; then
|
||||
fail "GPU devfreq powersave governor permissions or sync paths are missing"
|
||||
fi
|
||||
if ! grep -qF 'open_input_inotify' "$BASE_DIR/src/bananarchy-daemons/common.h" || \
|
||||
! grep -qF 'open_input_inotify' "$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c" || \
|
||||
! grep -qF 'open_input_inotify' "$BASE_DIR/src/bananarchy-daemons/bananarchy-volume-keys.c" || \
|
||||
! grep -qF 'open_input_inotify_fd' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-bt-obex"; then
|
||||
fail "idle input daemons or Bluetooth gamepad bridge reverted to periodic polling"
|
||||
fi
|
||||
if ! grep -qF '/etc/bananarchy-no-deep-standby' \
|
||||
"$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_screenoff.sh"; then
|
||||
fail "screenoff hook spawns sxmo_autosuspend.sh even when deep standby is disabled"
|
||||
fi
|
||||
|
||||
echo "[check] Abjects IRC default network..."
|
||||
IRC_SRC="$BASE_DIR/src/dwm-plugins/irc_plugin.cpp"
|
||||
@@ -1204,16 +1222,21 @@ fi
|
||||
echo "[check] Version helper..."
|
||||
# Pin the release under test so the check does not break when the wall clock
|
||||
# rolls past the release date (version.sh otherwise derives it from today).
|
||||
VERSION="$(BANANARCHY_VERSION=a1111 \
|
||||
"$BASE_DIR/scripts/version.sh" --print 2>/dev/null || true)"
|
||||
CODENAME="$(BANANARCHY_VERSION=a1111 \
|
||||
"$BASE_DIR/scripts/version.sh" --print-codename 2>/dev/null || true)"
|
||||
if [ "$VERSION" != "a1111" ]; then
|
||||
fail "scripts/version.sh --print must return a1111"
|
||||
fi
|
||||
if [ "$CODENAME" != "lennon" ]; then
|
||||
fail "scripts/version.sh --print-codename must return lennon"
|
||||
fi
|
||||
for pair in "a1114 carbonara" "a1111 lennon"; do
|
||||
set -- $pair
|
||||
want_ver=$1
|
||||
want_codename=$2
|
||||
VERSION="$(BANANARCHY_VERSION="$want_ver" BANANARCHY_CODENAME="" \
|
||||
"$BASE_DIR/scripts/version.sh" --print 2>/dev/null || true)"
|
||||
CODENAME="$(BANANARCHY_VERSION="$want_ver" BANANARCHY_CODENAME="" \
|
||||
"$BASE_DIR/scripts/version.sh" --print-codename 2>/dev/null || true)"
|
||||
if [ "$VERSION" != "$want_ver" ]; then
|
||||
fail "scripts/version.sh --print must return $want_ver"
|
||||
fi
|
||||
if [ "$CODENAME" != "$want_codename" ]; then
|
||||
fail "scripts/version.sh --print-codename must return $want_codename for $want_ver"
|
||||
fi
|
||||
done
|
||||
for f in overlay/rootfs/etc/os-release overlay/rootfs/usr/lib/os-release overlay/rootfs/etc/issue overlay/rootfs/etc/motd; do
|
||||
if [ ! -f "$BASE_DIR/$f" ]; then
|
||||
fail "missing $f"
|
||||
|
||||
@@ -16,6 +16,7 @@ YEAR_LETTER="$(printf "\\$(printf '%03o' $(( 97 + LETTER_IDX )))")"
|
||||
VERSION="${BANANARCHY_VERSION:-${YEAR_LETTER}${MONTH}${DAY}}"
|
||||
|
||||
case "$VERSION" in
|
||||
a1114) DEFAULT_CODENAME=carbonara ;;
|
||||
a1111) DEFAULT_CODENAME=lennon ;;
|
||||
a1108) DEFAULT_CODENAME=dejavu ;;
|
||||
a1105) DEFAULT_CODENAME=vendetta ;;
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
#define BA_EVIOCGSW(len) BA_IOC(2U, 'E', 0x1bU, (unsigned int)(len))
|
||||
#define COVER_MARKER "/run/bananarchy/cover-backlight"
|
||||
#define MAIN_DPMS_PATH "/sys/class/drm/card0-SPI-1/dpms"
|
||||
#define CPU_GOV "/sys/devices/system/cpu/cpufreq/policy0/scaling_governor"
|
||||
#define SCHEDUTIL_RATE "/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us"
|
||||
#define GPU_GOV "/sys/class/devfreq/1c00000.gpu/governor"
|
||||
|
||||
static char *const session_env[] = {
|
||||
(char *)"PATH=/home/user/.local/bin:/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin",
|
||||
@@ -271,6 +274,8 @@ static void on_transition(int closed)
|
||||
* which is also the gate the cover daemon uses to take the SPI bus. */
|
||||
write_text_file(BRIGHTNESS, "0");
|
||||
write_text_file(BL_POWER, "4");
|
||||
write_text_file(CPU_GOV, "powersave");
|
||||
write_text_file(GPU_GOV, "powersave");
|
||||
run_dpms("off");
|
||||
cover_send("CLOSED");
|
||||
locker_send("SCREENOFF\n");
|
||||
@@ -278,6 +283,9 @@ static void on_transition(int closed)
|
||||
} else {
|
||||
int bl = read_int_file(BRIGHTNESS_SAVE, 10);
|
||||
int kbd = read_int_file(KBD_SAVE, 1);
|
||||
write_text_file(CPU_GOV, "schedutil");
|
||||
write_text_file(SCHEDUTIL_RATE, "40000");
|
||||
write_text_file(GPU_GOV, "simple_ondemand");
|
||||
/* Release the cover's shared SPI bus before relighting the main panel.
|
||||
* The cover daemon restores the mux on this datagram; give it a moment so
|
||||
* the DPMS re-init below hits the internal panel, not the cover. */
|
||||
@@ -429,12 +437,15 @@ static void read_ready(struct watch_list *list, struct pollfd *fds, int nfds,
|
||||
int main(void)
|
||||
{
|
||||
int lock_fd;
|
||||
int inotify_fd;
|
||||
int gpio_override;
|
||||
int need_scan = 1;
|
||||
struct watch_list list;
|
||||
long long now;
|
||||
long long last_scan = 0;
|
||||
long long last_hall_poll = 0;
|
||||
long long last_transition = 0;
|
||||
long long last_broadcast = 0;
|
||||
long long reconcile_at = 0;
|
||||
long long candidate_since;
|
||||
long long fast_until = 0;
|
||||
int evdev_found = 0;
|
||||
@@ -452,6 +463,8 @@ int main(void)
|
||||
return 1;
|
||||
install_reaper();
|
||||
memset(&list, 0, sizeof(list));
|
||||
gpio_override = getenv("BANANARCHY_LID_GPIO_FILE") != NULL;
|
||||
inotify_fd = open_input_inotify();
|
||||
switch_mask = current_switch_mask(&evdev_found);
|
||||
hall = hall_state();
|
||||
hall_observed = hall;
|
||||
@@ -464,6 +477,7 @@ int main(void)
|
||||
candidate = stable_closed;
|
||||
now = now_ms();
|
||||
candidate_since = now;
|
||||
last_hall_poll = now;
|
||||
write_lid_state(stable_closed);
|
||||
if(stable_closed)
|
||||
on_transition(1);
|
||||
@@ -471,14 +485,19 @@ int main(void)
|
||||
sync_sw_lid(0);
|
||||
cover_send("OPEN");
|
||||
}
|
||||
last_broadcast = now;
|
||||
reconcile_at = now + LID_BROADCAST_MS;
|
||||
while(1) {
|
||||
struct pollfd fds[WATCH_MAX];
|
||||
struct pollfd fds[WATCH_MAX + 1];
|
||||
int nfds = 0;
|
||||
int poll_nfds;
|
||||
int timeout_ms;
|
||||
int prev_count;
|
||||
int i;
|
||||
if(now - last_scan > 2000) {
|
||||
if(need_scan ||
|
||||
((inotify_fd < 0 || list.count == 0) && now - last_scan >= 2000)) {
|
||||
scan_devices(&list, WATCH_SWITCHES);
|
||||
last_scan = now;
|
||||
need_scan = 0;
|
||||
if(list.count > 0 && !evdev_found) {
|
||||
switch_mask = current_switch_mask(&evdev_found);
|
||||
}
|
||||
@@ -489,17 +508,46 @@ int main(void)
|
||||
fds[nfds].revents = 0;
|
||||
nfds++;
|
||||
}
|
||||
if(poll(fds, (nfds_t)nfds, LID_LOOP_MS) < 0 && errno != EINTR) {
|
||||
for(i = 0; i < list.count; i++)
|
||||
poll_nfds = nfds;
|
||||
if(inotify_fd >= 0) {
|
||||
fds[poll_nfds].fd = inotify_fd;
|
||||
fds[poll_nfds].events = POLLIN;
|
||||
fds[poll_nfds].revents = 0;
|
||||
poll_nfds++;
|
||||
}
|
||||
if(gpio_override || candidate != stable_closed || now < fast_until) {
|
||||
timeout_ms = LID_LOOP_MS;
|
||||
} else if(list.count == 0) {
|
||||
timeout_ms = 500;
|
||||
} else {
|
||||
timeout_ms = -1;
|
||||
if(reconcile_at > 0) {
|
||||
long long rem = reconcile_at - now;
|
||||
timeout_ms = rem > 0 ? (int)rem : 0;
|
||||
}
|
||||
if(inotify_fd < 0 && (timeout_ms < 0 || timeout_ms > 2000))
|
||||
timeout_ms = 2000;
|
||||
}
|
||||
if(poll(fds, (nfds_t)poll_nfds, timeout_ms) < 0 && errno != EINTR) {
|
||||
for(i = list.count - 1; i >= 0; i--)
|
||||
drop_device(&list, list.devs[i].fd);
|
||||
need_scan = 1;
|
||||
}
|
||||
now = now_ms();
|
||||
edge = 0;
|
||||
prev_count = list.count;
|
||||
if(nfds > 0)
|
||||
read_ready(&list, fds, nfds, &switch_mask, &edge);
|
||||
if(list.count < prev_count)
|
||||
need_scan = 1;
|
||||
if(inotify_fd >= 0 && (fds[nfds].revents & POLLIN) &&
|
||||
drain_inotify(inotify_fd)) {
|
||||
need_scan = 1;
|
||||
}
|
||||
/* An EV_SW edge is the hardware interrupt: read the raw hall lines at
|
||||
* once instead of waiting for the next reconciliation tick. The result
|
||||
* is sticky, so a stale EV_SW mask cannot flip the candidate back. */
|
||||
* once instead of waiting for a poll tick. The result is sticky, so a
|
||||
* stale EV_SW mask cannot flip the candidate back, and steady state can
|
||||
* sleep indefinitely on hardware interrupts without debugfs polling. */
|
||||
if(edge) {
|
||||
hall = hall_state();
|
||||
hall_observed = hall >= 0 ? hall :
|
||||
@@ -508,8 +556,9 @@ int main(void)
|
||||
fast_until = now + 120;
|
||||
if(hall == 1 && !(switch_mask & (int)switch_bit(SW_LID)))
|
||||
sync_sw_lid(1);
|
||||
} else if(now - last_hall_poll >=
|
||||
(now < fast_until ? HALL_EDGE_MS : HALL_POLL_MS)) {
|
||||
} else if((now < fast_until && now - last_hall_poll >= HALL_EDGE_MS) ||
|
||||
(gpio_override && now - last_hall_poll >= HALL_POLL_MS) ||
|
||||
(reconcile_at > 0 && now >= reconcile_at)) {
|
||||
hall = hall_state();
|
||||
if(hall >= 0)
|
||||
hall_observed = hall;
|
||||
@@ -527,14 +576,16 @@ int main(void)
|
||||
stable_closed = candidate;
|
||||
last_transition = now;
|
||||
on_transition(stable_closed);
|
||||
reconcile_at = now + LID_BROADCAST_MS;
|
||||
}
|
||||
if(now - last_broadcast >= LID_BROADCAST_MS) {
|
||||
if(reconcile_at > 0 && now >= reconcile_at &&
|
||||
candidate == stable_closed) {
|
||||
reconcile_at = 0;
|
||||
write_lid_state(stable_closed);
|
||||
sync_sw_lid(stable_closed);
|
||||
if(stable_closed)
|
||||
enforce_closed_dark();
|
||||
cover_send(stable_closed ? "CLOSED" : "OPEN");
|
||||
last_broadcast = now;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -155,7 +155,11 @@ static void read_ready(struct watch_list *list, struct pollfd *fds, int nfds)
|
||||
int main(void)
|
||||
{
|
||||
const char *lock_override = getenv("BANANARCHY_VOLUME_LOCK");
|
||||
const char *glob_override = getenv("BANANARCHY_INPUT_GLOB");
|
||||
int has_glob_override = glob_override && *glob_override;
|
||||
int lock_fd;
|
||||
int inotify_fd;
|
||||
int need_scan = 1;
|
||||
struct watch_list list;
|
||||
long long last_scan = 0;
|
||||
if(is_non_flip_profile())
|
||||
@@ -166,16 +170,22 @@ int main(void)
|
||||
return 1;
|
||||
install_reaper();
|
||||
memset(&list, 0, sizeof(list));
|
||||
inotify_fd = open_input_inotify();
|
||||
while(1) {
|
||||
long long now = now_ms();
|
||||
struct pollfd fds[WATCH_MAX];
|
||||
struct pollfd fds[WATCH_MAX + 1];
|
||||
int nfds = 0;
|
||||
int poll_nfds;
|
||||
int timeout_ms;
|
||||
int prev_count;
|
||||
int i;
|
||||
if(now - last_scan > 2000) {
|
||||
if(need_scan ||
|
||||
((inotify_fd < 0 || list.count == 0) && now - last_scan >= 2000)) {
|
||||
scan_devices(&list, WATCH_VOLUME_KEYS);
|
||||
last_scan = now;
|
||||
need_scan = 0;
|
||||
}
|
||||
if(list.count == 0) {
|
||||
if(list.count == 0 && inotify_fd < 0) {
|
||||
poll(NULL, 0, 500);
|
||||
continue;
|
||||
}
|
||||
@@ -185,11 +195,33 @@ int main(void)
|
||||
fds[nfds].revents = 0;
|
||||
nfds++;
|
||||
}
|
||||
if(poll(fds, (nfds_t)nfds, 1000) < 0 && errno != EINTR) {
|
||||
for(i = 0; i < list.count; i++)
|
||||
poll_nfds = nfds;
|
||||
if(inotify_fd >= 0) {
|
||||
fds[poll_nfds].fd = inotify_fd;
|
||||
fds[poll_nfds].events = POLLIN;
|
||||
fds[poll_nfds].revents = 0;
|
||||
poll_nfds++;
|
||||
}
|
||||
if(list.count == 0)
|
||||
timeout_ms = 500;
|
||||
else if(has_glob_override || inotify_fd < 0)
|
||||
timeout_ms = 1000;
|
||||
else
|
||||
timeout_ms = -1;
|
||||
if(poll(fds, (nfds_t)poll_nfds, timeout_ms) < 0 && errno != EINTR) {
|
||||
for(i = list.count - 1; i >= 0; i--)
|
||||
drop_device(&list, list.devs[i].fd);
|
||||
need_scan = 1;
|
||||
}
|
||||
prev_count = list.count;
|
||||
if(nfds > 0)
|
||||
read_ready(&list, fds, nfds);
|
||||
if(list.count < prev_count)
|
||||
need_scan = 1;
|
||||
if(inotify_fd >= 0 && (fds[nfds].revents & POLLIN) &&
|
||||
drain_inotify(inotify_fd)) {
|
||||
need_scan = 1;
|
||||
}
|
||||
read_ready(&list, fds, nfds);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@@ -252,6 +253,34 @@ static BA_UNUSED void scan_devices(struct watch_list *list, enum watch_filter fi
|
||||
globfree(&gl);
|
||||
}
|
||||
|
||||
static BA_UNUSED int open_input_inotify(void)
|
||||
{
|
||||
const char *override = getenv("BANANARCHY_INPUT_GLOB");
|
||||
int fd;
|
||||
if(override && *override)
|
||||
return -1;
|
||||
fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||
if(fd < 0)
|
||||
return -1;
|
||||
if(inotify_add_watch(fd, "/dev/input",
|
||||
IN_CREATE | IN_DELETE | IN_ATTRIB | IN_MOVED_TO) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static BA_UNUSED int drain_inotify(int fd)
|
||||
{
|
||||
char buf[512];
|
||||
int got = 0;
|
||||
if(fd < 0)
|
||||
return 0;
|
||||
while(read(fd, buf, sizeof(buf)) > 0)
|
||||
got = 1;
|
||||
return got;
|
||||
}
|
||||
|
||||
static BA_UNUSED int is_non_flip_profile(void)
|
||||
{
|
||||
const char *override = getenv("BANANARCHY_LID_PROFILE");
|
||||
|
||||
@@ -102,6 +102,7 @@ void blankScreenBacklight() {
|
||||
readSmallFileTrimmed("/run/bananarchy/cover-backlight") == "1") {
|
||||
writeSysfsStr("/sys/class/leds/white:kbd_backlight/brightness", "0");
|
||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
||||
return;
|
||||
}
|
||||
std::string cur = readSmallFileTrimmed("/sys/class/backlight/backlight/brightness");
|
||||
@@ -113,6 +114,7 @@ void blankScreenBacklight() {
|
||||
writeSysfsStr("/sys/class/backlight/backlight/brightness", "0");
|
||||
writeSysfsStr("/sys/class/backlight/backlight/bl_power", "4");
|
||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
||||
}
|
||||
|
||||
void wakeScreenBacklight() {
|
||||
@@ -121,6 +123,7 @@ void wakeScreenBacklight() {
|
||||
return;
|
||||
}
|
||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "schedutil");
|
||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "simple_ondemand");
|
||||
std::string cur = readSmallFileTrimmed("/tmp/sxmo_saved_brightness");
|
||||
int val = std::atoi(cur.c_str());
|
||||
if (val < 1) {
|
||||
|
||||
Reference in new issue
Block a user