diff --git a/.gitignore b/.gitignore index 1aedea1..23bbe50 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ *.tar.xz *.tar.zst *.zip +/zi[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z] # Private SSH keys, credentials, and local agent configs /keys/phone_id_* diff --git a/CHANGELOG.md b/CHANGELOG.md index fa899db..c7965fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,9 +32,9 @@ Upcoming release build (`a1114` / `carbonara` via `scripts/version.sh`) targetin ### 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)`. +- **2720 Flip event-driven idle daemons and dynamic TLMM `gpiochip` resolution (`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)`. Updated `bananarchy-cover-idle` (`gpiochip_device = auto` via `BA_GPIO_GET_CHIPINFO` / `hw_ensure_gpiochip()`) and `bananarchy-cover-diagnose.sh` to resolve MSM8909 TLMM (`1000000.pinctrl`, e.g. `/dev/gpiochip2`) dynamically across `/dev/gpiochip*` so PMIC/TLMM probe-order shifts from strict `fw_devlink` + `qcom,mpm` no longer leave external cover button wakes in `backend=none`. - **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 `77a1201a2a93a076a8dd9a6f11c8ceb5f69b94b2ca7abb3dfeba5354b83c034c`) and `images/bananarchy-nokia-beatles.img` (SHA-256 `c027c3151f3cf45e7a067beed77d77ff4a1954ababda6f1a2eba5a02b2414b24`, with standalone `images/boot-bananarchy-nokia-beatles.img` SHA-256 `5a7a391aff3fc8fc95b07b532eedce1ee17991574fb45ca4359c0504aeb82324` 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` (`a721506d9fd5d50a4f47afa6dc2d24c8bc2335e39bfd6d0873c6d30f4892a8f7`) and `bananarchy-nokia-beatles-a1114-carbonara.zip` (`5bb987e264b684c2afdb2f6d60c4d47864aa772c763ad7527dc6f3fb51b5eb85`). +- **Image persistence and upcoming release archives**: rebuilt both `images/bananarchy-nokia-argon.img` (SHA-256 `0d25b08a23c0f736877731ba634cec942fd8580215f6067dc3c2f63d07c58264`) and `images/bananarchy-nokia-beatles.img` (SHA-256 `e7fe1e3dde98e1be28b1593a94925c2820e4bfe35016cb3e09759a7e017a3aba`, with standalone `images/boot-bananarchy-nokia-beatles.img` SHA-256 `5a7a391aff3fc8fc95b07b532eedce1ee17991574fb45ca4359c0504aeb82324` 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` (`3d1896278b0e829fc358e0dcf22fd54164ef644c67a9177e52e330b17892470f`) and `bananarchy-nokia-beatles-a1114-carbonara.zip` (`e16cedb2fec8dbcc369b898cba7a8637c328d0d6a7ef287236c25ed2cb147ba0`). --- diff --git a/overlay/rootfs/etc/bananarchy/cover-display.conf b/overlay/rootfs/etc/bananarchy/cover-display.conf index 90d0a8d..45db15a 100644 --- a/overlay/rootfs/etc/bananarchy/cover-display.conf +++ b/overlay/rootfs/etc/bananarchy/cover-display.conf @@ -31,7 +31,9 @@ kernel_backlight_invert = 0 kernel_internal_sleep = 0 fb_device = /dev/fb1 spidev_device = /dev/spidev0.1 -gpiochip_device = /dev/gpiochip0 +# "auto" locates MSM8909 TLMM (1000000.pinctrl) across /dev/gpiochip* so probe +# order changes between SPMI PMIC GPIOs/MPPs and TLMM never break cover muxing. +gpiochip_device = auto panel_firmware = /lib/firmware/nokia,beatles-gc9305-ext-panel.bin socket_path = /run/bananarchy/cover.sock theme_file = /home/user/.Xresources @@ -41,7 +43,7 @@ input_dir = /dev/input mux_gpio = 13 reset_gpio = 23 # gpio110 is the shared D/C line owned by panel-mipi-dbi-spi; the daemon -# cannot request it through gpiochip0. -1 lets the legacy spidev backend open +# cannot request it through gpiochip. -1 lets the legacy spidev backend open # without fighting the kernel driver. Set it back to 110 only with a DT where # spi-mux owns both panels. dc_gpio = -1 diff --git a/overlay/rootfs/usr/bin/bananarchy-cover-diagnose.sh b/overlay/rootfs/usr/bin/bananarchy-cover-diagnose.sh index 74e5752..c425766 100755 --- a/overlay/rootfs/usr/bin/bananarchy-cover-diagnose.sh +++ b/overlay/rootfs/usr/bin/bananarchy-cover-diagnose.sh @@ -6,7 +6,20 @@ set -u FB=/dev/fb1 SYSFS=/sys/class/graphics/fb1 SPI=/dev/spidev0.1 -GPIOCHIP=/dev/gpiochip0 +resolve_tlmm_gpiochip() { + for dev in /sys/bus/gpio/devices/gpiochip*; do + [ -e "$dev" ] || continue + target="$(readlink -f "$dev" 2>/dev/null || true)" + case "$target" in + *pinctrl*|*tlmm*) + printf '/dev/%s\n' "${dev##*/}" + return 0 + ;; + esac + done + printf '/dev/gpiochip0\n' +} +GPIOCHIP="$(resolve_tlmm_gpiochip)" FW=/lib/firmware/nokia,beatles-gc9305-ext-panel.bin CMD=/sys/kernel/debug/dri/0/command BL=/sys/class/backlight/backlight/brightness diff --git a/overlay/rootfs/usr/bin/bananarchy-cover-idle b/overlay/rootfs/usr/bin/bananarchy-cover-idle index 4e12dcb..337b9ba 100755 Binary files a/overlay/rootfs/usr/bin/bananarchy-cover-idle and b/overlay/rootfs/usr/bin/bananarchy-cover-idle differ diff --git a/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle b/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle index 4e12dcb..337b9ba 100755 Binary files a/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle and b/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle differ diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index 81c06d5..a41d2b5 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -378,8 +378,8 @@ fi echo "[check] Known-good flashable image set..." for pair in \ - "77a1201a2a93a076a8dd9a6f11c8ceb5f69b94b2ca7abb3dfeba5354b83c034c images/bananarchy-nokia-argon.img" \ - "c027c3151f3cf45e7a067beed77d77ff4a1954ababda6f1a2eba5a02b2414b24 images/bananarchy-nokia-beatles.img" \ + "0d25b08a23c0f736877731ba634cec942fd8580215f6067dc3c2f63d07c58264 images/bananarchy-nokia-argon.img" \ + "e7fe1e3dde98e1be28b1593a94925c2820e4bfe35016cb3e09759a7e017a3aba images/bananarchy-nokia-beatles.img" \ "5a7a391aff3fc8fc95b07b532eedce1ee17991574fb45ca4359c0504aeb82324 images/boot-bananarchy-nokia-beatles.img" \ "b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do set -- $pair @@ -1710,6 +1710,7 @@ for token in 'backend = kernel' 'main_fb_device = /dev/fb0' \ 'kernel_backlight_level = 14' \ 'kernel_backlight_invert = 0' \ 'kernel_internal_sleep = 0' \ + 'gpiochip_device = auto' \ 'spi_device = /dev/spidev0.1' \ 'spi_mux_gpio = 13' 'spi_dc_gpio = 21' 'spi_reset_gpio = 23' \ 'mux_closed_level = 1' 'mux_open_level = 0' \ @@ -1731,7 +1732,8 @@ for token in 'cover_kernel_draw' 'cover_kernel_command' \ 'cover_kernel_marker' 'cover_kernel_power_sync' \ 'cover_kernel_restore_internal' \ 'cover_kernel_display_off' 'kernel_bl_invert' \ - 'KERNEL_REDRAW_MS 1000' 'cover_main_panel_is_off'; do + 'KERNEL_REDRAW_MS 1000' 'cover_main_panel_is_off' \ + 'BA_GPIO_GET_CHIPINFO' 'hw_ensure_gpiochip'; do if ! grep -qF "$token" "$COVER_SRC"; then fail "the kernel-owned cover backend lost $token" fi diff --git a/scripts/test-cover-kernel.py b/scripts/test-cover-kernel.py index ec67868..18b452f 100755 --- a/scripts/test-cover-kernel.py +++ b/scripts/test-cover-kernel.py @@ -112,7 +112,8 @@ def main(): "kernel_backlight_marker = /run/bananarchy/cover-backlight", "kernel_backlight_level = 14", "kernel_backlight_invert = 0", - "kernel_internal_sleep = 0"): + "kernel_internal_sleep = 0", + "gpiochip_device = auto"): if token not in conf: return fail("shipping config lost %s" % token) helper = HELPER.read_text(encoding="utf-8") @@ -126,7 +127,8 @@ def main(): "cover_kernel_power_sync", "cover_kernel_restore_internal", "cover_bus_release", "cover_main_panel_is_off", "KERNEL_REDRAW_MS 1000", - "kernel_bl_invert", "reinit"): + "kernel_bl_invert", "reinit", + "BA_GPIO_GET_CHIPINFO", "hw_ensure_gpiochip"): if token not in source: return fail("cover daemon lost the kernel backend: %s" % token) firmware = FIRMWARE.read_bytes() diff --git a/src/bananarchy-daemons/bananarchy-cover-idle.c b/src/bananarchy-daemons/bananarchy-cover-idle.c index 3c53935..ed405ae 100644 --- a/src/bananarchy-daemons/bananarchy-cover-idle.c +++ b/src/bananarchy-daemons/bananarchy-cover-idle.c @@ -67,6 +67,7 @@ * fixed by the kernel ABI; a compile-time size check guards the cross build. */ #define BA_GPIO_IOC_MAGIC 0xb4u #define BA_IOC_WR 1u +#define BA_IOC_RD 2u #define BA_IOC_RDWR 3u #define BA_IOC(dir, type, nr, size) \ (((unsigned int)(dir) << 30) | ((unsigned int)(type) << 8) | \ @@ -76,11 +77,18 @@ #define BA_SPI_IOC_WR_MODE BA_IOC(BA_IOC_WR, 'k', 1u, 1u) #define BA_SPI_IOC_WR_BITS BA_IOC(BA_IOC_WR, 'k', 3u, 1u) #define BA_SPI_IOC_WR_SPEED BA_IOC(BA_IOC_WR, 'k', 4u, 4u) +#define BA_GPIO_GET_CHIPINFO BA_IOC(BA_IOC_RD, BA_GPIO_IOC_MAGIC, 1u, 68u) #define BA_GPIO_GET_LINEHANDLE BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 3u, 364u) #define BA_GPIO_GET_VALUES BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 8u, 64u) #define BA_GPIO_SET_VALUES BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 9u, 64u) #define BA_GPIOHANDLE_REQUEST_OUTPUT (1u << 1) +struct ba_gpiochip_info { + char name[32]; + char label[32]; + uint32_t lines; +}; + struct ba_gpiohandle_request { uint32_t lineoffsets[64]; uint32_t flags; @@ -108,6 +116,8 @@ struct ba_spi_ioc_transfer { uint8_t pad; }; +_Static_assert(sizeof(struct ba_gpiochip_info) == 68, + "gpiochip v1 chipinfo ABI size"); _Static_assert(sizeof(struct ba_gpiohandle_request) == 364, "gpiochip v1 linehandle ABI size"); _Static_assert(sizeof(struct ba_spi_ioc_transfer) == 32, @@ -670,6 +680,79 @@ static int hw_gpio_set(struct cover_hw *hw, int fd, return ioctl(fd, BA_GPIO_SET_VALUES, &data) >= 0; } +static int hw_ensure_gpiochip(struct cover_hw *hw) +{ + unsigned int min_lines; + glob_t gl; + size_t i; + int best_fd = -1; + char best_path[128] = ""; + if(hw->sim || hw->fd_chip >= 0) + return 1; + min_lines = (hw->mux_gpio > hw->reset_gpio ? + hw->mux_gpio : hw->reset_gpio) + 1; + if(hw->word_bits != 9 && hw->dc_gpio < 1024 && hw->dc_gpio + 1 > min_lines) + min_lines = hw->dc_gpio + 1; + if(hw->gpio_path[0] && strcasecmp(hw->gpio_path, "auto") != 0) { + int fd = open(hw->gpio_path, O_RDWR | O_CLOEXEC); + if(fd >= 0) { + struct ba_gpiochip_info info; + memset(&info, 0, sizeof(info)); + if(ioctl(fd, BA_GPIO_GET_CHIPINFO, &info) == 0) { + info.label[sizeof(info.label) - 1] = '\0'; + if(info.lines >= min_lines && + (strstr(info.label, "pinctrl") != NULL || + strstr(info.label, "tlmm") != NULL)) { + hw->fd_chip = fd; + return 1; + } + close(fd); + } else if(errno == ENOTTY) { + hw->fd_chip = fd; + return 1; + } else { + close(fd); + } + } + } + if(glob("/dev/gpiochip*", 0, NULL, &gl) == 0) { + for(i = 0; i < gl.gl_pathc; i++) { + struct ba_gpiochip_info info; + int fd = open(gl.gl_pathv[i], O_RDWR | O_CLOEXEC); + if(fd < 0) + continue; + memset(&info, 0, sizeof(info)); + if(ioctl(fd, BA_GPIO_GET_CHIPINFO, &info) == 0 && + info.lines >= min_lines) { + info.label[sizeof(info.label) - 1] = '\0'; + if(strstr(info.label, "pinctrl") != NULL || + strstr(info.label, "tlmm") != NULL) { + if(best_fd >= 0) + close(best_fd); + best_fd = fd; + safe_copy(best_path, sizeof(best_path), gl.gl_pathv[i]); + fd = -1; + break; + } + if(best_fd < 0) { + best_fd = fd; + safe_copy(best_path, sizeof(best_path), gl.gl_pathv[i]); + fd = -1; + } + } + if(fd >= 0) + close(fd); + } + globfree(&gl); + } + if(best_fd >= 0) { + hw->fd_chip = best_fd; + safe_copy(hw->gpio_path, sizeof(hw->gpio_path), best_path); + return 1; + } + return 0; +} + static int hw_gpio_request(struct cover_hw *hw, const unsigned int *offsets, const unsigned char *defaults, unsigned int count) { @@ -679,7 +762,7 @@ static int hw_gpio_request(struct cover_hw *hw, const unsigned int *offsets, hw_event(hw, "claim"); return 1; } - if(hw->fd_chip < 0) + if(!hw_ensure_gpiochip(hw)) return -1; memset(&req, 0, sizeof(req)); for(i = 0; i < count && i < 64; i++) { @@ -824,11 +907,8 @@ static int hw_activate(struct cover_hw *hw) int fd; if(!hw->spi_enabled) return 0; - if(!hw->sim && hw->fd_chip < 0) { - hw->fd_chip = open(hw->gpio_path, O_RDWR | O_CLOEXEC); - if(hw->fd_chip < 0) - return 0; - } + if(!hw_ensure_gpiochip(hw)) + return 0; if(!hw->mux_claimed) { mux_offset[0] = hw->mux_gpio; mux_default[0] = (unsigned char)hw->mux_open_level; @@ -1906,7 +1986,7 @@ static void cover_hw_init(struct cover_hw *hw) hw->kernel_lit = -1; hw->kernel_restored = 0; safe_copy(hw->spi_path, sizeof(hw->spi_path), "/dev/spidev0.1"); - safe_copy(hw->gpio_path, sizeof(hw->gpio_path), "/dev/gpiochip0"); + safe_copy(hw->gpio_path, sizeof(hw->gpio_path), "auto"); safe_copy(hw->firmware, sizeof(hw->firmware), "/lib/firmware/nokia,beatles-gc9305-ext-panel.bin"); safe_copy(hw->kernel_fb, sizeof(hw->kernel_fb), "/dev/fb0"); @@ -2094,11 +2174,8 @@ static void read_config(const char *path, char *socket_path, size_t splen, if(strcmp(hw->backend, "none") == 0 || strcmp(hw->backend, "fb") == 0 || !hw->spi_path[0] || !hw->gpio_path[0] || !hw->firmware[0]) return; - if(!hw->sim) { - hw->fd_chip = open(hw->gpio_path, O_RDWR | O_CLOEXEC); - if(hw->fd_chip < 0) - return; - } + if(!hw_ensure_gpiochip(hw)) + return; hw->spi_enabled = 1; } @@ -2270,7 +2347,8 @@ static void handle_command(char *buffer, struct state *state, safe_copy(hw->backend, sizeof(hw->backend), value); hw->spi_enabled = strcmp(hw->backend, "none") != 0 && strcmp(hw->backend, "fb") != 0 && - hw->spi_path[0] && hw->gpio_path[0] && hw->firmware[0]; + hw->spi_path[0] && hw->gpio_path[0] && hw->firmware[0] && + hw_ensure_gpiochip(hw); } else if(strcmp(key, "mux_closed_level") == 0) hw->mux_closed_level = config_level(value, hw->mux_closed_level); else if(strcmp(key, "mux_open_level") == 0)