From 1e9346aec6498b421b98fe65345bff92e6c52eef Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 9 Aug 2021 02:30:59 +0200 Subject: [PATCH] Fix Wi-Fi toggle on the Elipsa It turns out that the kernel needs a little push now that the dedicated wifi power control module is gone ;). Issue was only exposed if you booted KOReader while the Wi-Fi was down. --- frontend/device/kobo/ntx_io.lua | 18 ++++++++++++++++++ platform/kobo/disable-wifi.sh | 6 ++++++ platform/kobo/enable-wifi.sh | 4 ++++ platform/kobo/nickel.sh | 9 ++++++++- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 frontend/device/kobo/ntx_io.lua diff --git a/frontend/device/kobo/ntx_io.lua b/frontend/device/kobo/ntx_io.lua new file mode 100644 index 000000000..a630a5bc6 --- /dev/null +++ b/frontend/device/kobo/ntx_io.lua @@ -0,0 +1,18 @@ +-- Stupid wrapper so that we can send simple ntx_io ioctls from shell scripts... + +local ffi = require("ffi") +local bor = bit.bor +local C = ffi.C + +require("ffi/posix_h") + +assert(#arg == 2, "must pass an ioctl command & an ioctl argument") +local ioc_cmd = tonumber(arg[1]) +local ioc_arg = tonumber(arg[2]) + +local fd = C.open("/dev/ntx_io", bor(C.O_RDONLY, C.O_NONBLOCK, C.O_CLOEXEC)) +assert(fd ~= -1, "cannot open ntx_io character device") + +assert(C.ioctl(fd, ioc_cmd, ffi.cast("int", ioc_arg)) == 0, "ioctl failed") + +C.close(fd) diff --git a/platform/kobo/disable-wifi.sh b/platform/kobo/disable-wifi.sh index 6af2d5580..d35b6dc3c 100755 --- a/platform/kobo/disable-wifi.sh +++ b/platform/kobo/disable-wifi.sh @@ -58,3 +58,9 @@ if grep -q "sdio_wifi_pwr" "/proc/modules"; then usleep 250000 rmmod sdio_wifi_pwr fi + +# Poke the kernel via ioctl on platforms without the dedicated power module... +if [ ! -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then + usleep 250000 + ./luajit frontend/device/kobo/ntx_io.lua 208 0 +fi diff --git a/platform/kobo/enable-wifi.sh b/platform/kobo/enable-wifi.sh index f25457f7f..3dc807693 100755 --- a/platform/kobo/enable-wifi.sh +++ b/platform/kobo/enable-wifi.sh @@ -23,6 +23,10 @@ if ! grep -q "sdio_wifi_pwr" "/proc/modules"; then fi insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" + else + # Poke the kernel via ioctl on platforms without the dedicated power module... + # 208 is CM_WIFI_CTRL + ./luajit frontend/device/kobo/ntx_io.lua 208 1 fi fi # Moar sleep! diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 42420d8ce..3b420f710 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -13,7 +13,7 @@ export QT_GSTREAMER_PLAYBIN_AUDIOSINK=alsasink cd / unset OLDPWD unset LC_ALL TESSDATA_PREFIX STARDICT_DATA_DIR EXT_FONT_DIR -unset KOREADER_DIR KO_DONT_GRAB_INPUT +unset KO_DONT_GRAB_INPUT unset FBINK_FORCE_ROTA # Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. @@ -75,8 +75,15 @@ if grep -q "${WIFI_MODULE}" "/proc/modules"; then usleep 250000 rmmod sdio_wifi_pwr fi + + # Poke the kernel via ioctl on platforms without the dedicated power module... + if [ ! -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then + usleep 250000 + "${KOREADER_DIR}"/luajit "${KOREADER_DIR}"/frontend/device/kobo/ntx_io.lua 208 0 + fi fi +unset KOREADER_DIR unset CPUFREQ_DVFS CPUFREQ_CONSERVATIVE # Recreate Nickel's FIFO ourselves, like rcS does, because udev *will* write to it!