Kobo: Clara 2E fixes (#9559)

* Handle the power button input device
* Handle the charging LED properly
* Handle the new Wi-Fi chip properly
* Handle frontlight warmth adjustments
* Handle the battery gauge properly
* Bump base (a lot of third-party updates) [https://github.com/koreader/koreader-base/pull/1523]
* Bump android-luajit-launcher to match the LuaJIT update [https://github.com/koreader/android-luajit-launcher/pull/386]

Fix #9552 (many thanks to @Bartvelp for bearing with my stupid tests ;)).
reviewable/pr9571/r1
NiLuJe 2 years ago committed by GitHub
parent 2420557085
commit 8fcc712c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 2ed9aba5de31e5e60f18bf451df735fe91ddde3a Subproject commit 9e4e7e899e06853305d0a2e4b1f103d2a0840068

@ -364,6 +364,7 @@ local KoboEuropa = Kobo:new{
isSunxi = yes, isSunxi = yes,
hasEclipseWfm = yes, hasEclipseWfm = yes,
canToggleChargingLED = yes, canToggleChargingLED = yes,
led_uses_channel_3 = true,
hasFrontlight = yes, hasFrontlight = yes,
hasGSensor = yes, hasGSensor = yes,
canToggleGSensor = yes, canToggleGSensor = yes,
@ -383,6 +384,7 @@ local KoboCadmus = Kobo:new{
isSunxi = yes, isSunxi = yes,
hasEclipseWfm = yes, hasEclipseWfm = yes,
canToggleChargingLED = yes, canToggleChargingLED = yes,
led_uses_channel_3 = true,
hasFrontlight = yes, hasFrontlight = yes,
hasKeys = yes, hasKeys = yes,
hasGSensor = yes, hasGSensor = yes,
@ -447,17 +449,19 @@ local KoboGoldfinch = Kobo:new{
isMk7 = yes, isMk7 = yes,
hasEclipseWfm = yes, hasEclipseWfm = yes,
canToggleChargingLED = yes, canToggleChargingLED = yes,
led_uses_channel_3 = true,
hasFrontlight = yes, hasFrontlight = yes,
display_dpi = 300, display_dpi = 300,
--- @fixme: to be confirmed!
hasNaturalLight = yes, hasNaturalLight = yes,
frontlight_settings = { frontlight_settings = {
frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness", frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
frontlight_mixer = "/sys/class/backlight/lm3630a_led/color", frontlight_mixer = "/sys/class/leds/aw99703-bl_FL1/color",
nl_min = 0, nl_min = 0,
nl_max = 10, nl_max = 10,
nl_inverted = true, nl_inverted = true,
}, },
battery_sysfs = "/sys/class/power_supply/battery",
power_dev = "/dev/input/by-path/platform-bd71828-pwrkey-event",
} }
function Kobo:setupChargingLED() function Kobo:setupChargingLED()
@ -1155,13 +1159,13 @@ function Kobo:toggleChargingLED(toggle)
return false return false
end end
-- c.f., strace -fittvyy -e trace=ioctl,file,signal,ipc,desc -s 256 -o /tmp/nickel.log -p $(pidof -s nickel) & -- c.f., strace -fittTvyy -e trace=ioctl,file,signal,ipc,desc -s 256 -o /tmp/nickel.log -p $(pidof -s nickel) &
-- This was observed on a Forma, so I'm mildly hopeful that it's safe on other Mk. 7 devices ;). -- This was observed on a Forma, so I'm mildly hopeful that it's safe on other Mk. 7 devices ;).
-- NOTE: ch stands for channel, cur for current, dc for duty cycle. c.f., the driver source. -- NOTE: ch stands for channel, cur for current, dc for duty cycle. c.f., the driver source.
if toggle == true then if toggle == true then
-- NOTE: Technically, Nickel forces a toggle off before that, too. -- NOTE: Technically, Nickel forces a toggle off before that, too.
-- But since we do that on startup, it shouldn't be necessary here... -- But since we do that on startup, it shouldn't be necessary here...
if self:isSunxi() then if self.led_uses_channel_3 then
f:write("ch 3") f:write("ch 3")
f:flush() f:flush()
f:write("cur 1") f:write("cur 1")

@ -1 +1 @@
Subproject commit ee4cca8b81b4bd9cf3a299edb920d41cbfcd5a5a Subproject commit 76ba5446108112a81de38b2aad9a271440eace2c

@ -33,7 +33,7 @@ else
rm -f "/tmp/resolv.ko" rm -f "/tmp/resolv.ko"
fi fi
wpa_cli terminate wpa_cli -i "${INTERFACE}" terminate
[ "${WIFI_MODULE}" = "dhd" ] && wlarm_le -i "${INTERFACE}" down [ "${WIFI_MODULE}" = "dhd" ] && wlarm_le -i "${INTERFACE}" down
ifconfig "${INTERFACE}" down ifconfig "${INTERFACE}" down
@ -44,23 +44,45 @@ if grep -q "^${WIFI_MODULE}" "/proc/modules"; then
usleep 250000 usleep 250000
rmmod "${WIFI_MODULE}" rmmod "${WIFI_MODULE}"
fi fi
if grep -q "^sdio_wifi_pwr" "/proc/modules"; then
# Handle the shitty DVFS switcheroo... # Handle dependencies, if any
if [ -n "${CPUFREQ_DVFS}" ]; then WIFI_DEP_MOD=""
echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable" SKIP_SDIO_PWR_MODULE=""
if [ -n "${CPUFREQ_CONSERVATIVE}" ]; then case "${WIFI_MODULE}" in
echo "conservative" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" "moal")
else WIFI_DEP_MOD="mlan"
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" SKIP_SDIO_PWR_MODULE="1"
cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" ;;
fi esac
if [ -n "${WIFI_DEP_MOD}" ]; then
if grep -q "^${WIFI_DEP_MOD}" "/proc/modules"; then
usleep 250000
rmmod "${WIFI_DEP_MOD}"
fi fi
usleep 250000
rmmod sdio_wifi_pwr
fi fi
# Poke the kernel via ioctl on platforms without the dedicated power module... if [ -n "${SKIP_SDIO_PWR_MODULE}" ]; then
if [ ! -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then
usleep 250000 usleep 250000
./luajit frontend/device/kobo/ntx_io.lua 208 0 ./luajit frontend/device/kobo/ntx_io.lua 208 0
else
if grep -q "^sdio_wifi_pwr" "/proc/modules"; then
# Handle the shitty DVFS switcheroo...
if [ -n "${CPUFREQ_DVFS}" ]; then
echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable"
if [ -n "${CPUFREQ_CONSERVATIVE}" ]; then
echo "conservative" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
else
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
fi
fi
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
fi fi

@ -13,24 +13,42 @@ for fd in /proc/"$$"/fd/*; do
fi fi
done done
# Load wifi modules and enable wifi. # Some platforms do *NOT* use sdio_wifi_pwr, even when it is physically there...
if ! grep -q "^sdio_wifi_pwr" "/proc/modules"; then SKIP_SDIO_PWR_MODULE=""
if [ -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then # We also want to choose the wpa_supplicant driver depending on the module...
# Handle the shitty DVFS switcheroo... WPA_SUPPLICANT_DRIVER="wext"
if [ -n "${CPUFREQ_DVFS}" ]; then case "${WIFI_MODULE}" in
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" "moal")
echo "1" >"/sys/devices/platform/mxc_dvfs_core.0/enable" SKIP_SDIO_PWR_MODULE="1"
fi WPA_SUPPLICANT_DRIVER="nl80211"
;;
esac
# Power up WiFi chip
if [ -n "${SKIP_SDIO_PWR_MODULE}" ]; then
# 208 is CM_WIFI_CTRL
./luajit frontend/device/kobo/ntx_io.lua 208 1
else
if ! grep -q "^sdio_wifi_pwr" "/proc/modules"; then
if [ -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then
# Handle the shitty DVFS switcheroo...
if [ -n "${CPUFREQ_DVFS}" ]; then
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
echo "1" >"/sys/devices/platform/mxc_dvfs_core.0/enable"
fi
insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko"
else else
# Poke the kernel via ioctl on platforms without the dedicated power module... # Poke the kernel via ioctl on platforms without the dedicated power module...
# 208 is CM_WIFI_CTRL # 208 is CM_WIFI_CTRL
./luajit frontend/device/kobo/ntx_io.lua 208 1 ./luajit frontend/device/kobo/ntx_io.lua 208 1
fi
fi fi
fi fi
# Moar sleep! # Moar sleep!
usleep 250000 usleep 250000
# Load WiFi modules
# NOTE: Used to be exported in WIFI_MODULE_PATH before FW 4.23 # NOTE: Used to be exported in WIFI_MODULE_PATH before FW 4.23
if ! grep -q "^${WIFI_MODULE}" "/proc/modules"; then if ! grep -q "^${WIFI_MODULE}" "/proc/modules"; then
# Set the Wi-Fi regulatory domain properly if necessary... # Set the Wi-Fi regulatory domain properly if necessary...
@ -42,30 +60,81 @@ if ! grep -q "^${WIFI_MODULE}" "/proc/modules"; then
"8821cs") "8821cs")
WIFI_COUNTRY_CODE_PARM="rtw_country_code=${WIFI_COUNTRY_CODE}" WIFI_COUNTRY_CODE_PARM="rtw_country_code=${WIFI_COUNTRY_CODE}"
;; ;;
"moal")
WIFI_COUNTRY_CODE_PARM="reg_alpha2=${WIFI_COUNTRY_CODE}"
;;
esac esac
fi fi
VENDOR_WIFI_PARM=""
case "${WIFI_MODULE}" in
"moal")
# NXP's driver for the Marvell 88W8987 RF SoC needs to be told what to choose between client, AP & WiFi DIRECT mode.
VENDOR_WIFI_PARM="mod_para=nxp/wifi_mod_para_sd8987.conf"
# And, of course, it requires a submodule...
WIFI_DEP_MOD="mlan"
if [ -e "/drivers/${PLATFORM}/wifi/${WIFI_DEP_MOD}.ko" ]; then
insmod "/drivers/${PLATFORM}/wifi/${WIFI_DEP_MOD}.ko"
elif [ -e "/drivers/${PLATFORM}/${WIFI_DEP_MOD}.ko" ]; then
insmod "/drivers/${PLATFORM}/${WIFI_DEP_MOD}.ko"
fi
# NOTE: Nickel sleeps for two whole seconds after each module loading.
# Let's try our usual timing instead...
usleep 250000
;;
esac
WIFI_PARM=""
if [ -n "${WIFI_COUNTRY_CODE_PARM}" ]; then
if [ -n "${WIFI_PARM}" ]; then
WIFI_PARM="${WIFI_PARM} ${WIFI_COUNTRY_CODE_PARM}"
else
WIFI_PARM="${WIFI_COUNTRY_CODE_PARM}"
fi
fi
if [ -n "${VENDOR_WIFI_PARM}" ]; then
if [ -n "${WIFI_PARM}" ]; then
WIFI_PARM="${WIFI_PARM} ${VENDOR_WIFI_PARM}"
else
WIFI_PARM="${VENDOR_WIFI_PARM}"
fi
fi
if [ -e "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" ]; then if [ -e "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" ]; then
if [ -n "${WIFI_COUNTRY_CODE_PARM}" ]; then if [ -n "${WIFI_PARM}" ]; then
insmod "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" "${WIFI_COUNTRY_CODE_PARM}" # shellcheck disable=SC2086
insmod "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" ${WIFI_PARM}
else else
insmod "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" insmod "/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko"
fi fi
elif [ -e "/drivers/${PLATFORM}/${WIFI_MODULE}.ko" ]; then elif [ -e "/drivers/${PLATFORM}/${WIFI_MODULE}.ko" ]; then
# NOTE: Modules are unsorted on Mk. 8 # NOTE: Modules are unsorted on Mk. 8
if [ -n "${WIFI_COUNTRY_CODE_PARM}" ]; then if [ -n "${WIFI_PARM}" ]; then
insmod "/drivers/${PLATFORM}/${WIFI_MODULE}.ko" "${WIFI_COUNTRY_CODE_PARM}" # shellcheck disable=SC2086
insmod "/drivers/${PLATFORM}/${WIFI_MODULE}.ko" ${WIFI_PARM}
else else
insmod "/drivers/${PLATFORM}/${WIFI_MODULE}.ko" insmod "/drivers/${PLATFORM}/${WIFI_MODULE}.ko"
fi fi
fi fi
fi fi
# Race-y as hell, don't try to optimize this! # Race-y as hell, don't try to optimize this!
sleep 1 # NOTE: We're after a module insert, meaning Nickel may sleep for two whole seconds here.
case "${WIFI_MODULE}" in
"moal")
# NOTE: Bringup may be genuinely slower than usual with this chip, so, mimic Nickel's sleep patterns.
sleep 2
;;
*)
sleep 1
;;
esac
# Bring the network interface up & setup WiFi
ifconfig "${INTERFACE}" up ifconfig "${INTERFACE}" up
[ "${WIFI_MODULE}" = "dhd" ] && wlarm_le -i "${INTERFACE}" up [ "${WIFI_MODULE}" = "dhd" ] && wlarm_le -i "${INTERFACE}" up
pkill -0 wpa_supplicant || pkill -0 wpa_supplicant ||
env -u LD_LIBRARY_PATH \ env -u LD_LIBRARY_PATH \
wpa_supplicant -D wext -s -i "${INTERFACE}" -c /etc/wpa_supplicant/wpa_supplicant.conf -O /var/run/wpa_supplicant -B wpa_supplicant -D "${WPA_SUPPLICANT_DRIVER}" -s -i "${INTERFACE}" -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -B

@ -191,6 +191,7 @@ if [ "${VIA_NICKEL}" = "true" ]; then
# If bluetooth is enabled, kill it. # If bluetooth is enabled, kill it.
if [ -e "/sys/devices/platform/bt/rfkill/rfkill0/state" ]; then if [ -e "/sys/devices/platform/bt/rfkill/rfkill0/state" ]; then
# That's on sunxi, at least
IFS= read -r bt_state <"/sys/devices/platform/bt/rfkill/rfkill0/state" IFS= read -r bt_state <"/sys/devices/platform/bt/rfkill/rfkill0/state"
if [ "${bt_state}" = "1" ]; then if [ "${bt_state}" = "1" ]; then
echo "0" >"/sys/devices/platform/bt/rfkill/rfkill0/state" echo "0" >"/sys/devices/platform/bt/rfkill/rfkill0/state"
@ -199,6 +200,10 @@ if [ "${VIA_NICKEL}" = "true" ]; then
./luajit frontend/device/kobo/ntx_io.lua 126 0 ./luajit frontend/device/kobo/ntx_io.lua 126 0
fi fi
fi fi
if grep -q "^sdio_bt_pwr" "/proc/modules"; then
# And that's on NXP SoCs
rmmod sdio_bt_pwr
fi
# Flush disks, might help avoid trashing nickel's DB... # Flush disks, might help avoid trashing nickel's DB...
sync sync

@ -66,21 +66,41 @@ if grep -q "^${WIFI_MODULE}" "/proc/modules"; then
usleep 250000 usleep 250000
rmmod "${WIFI_MODULE}" rmmod "${WIFI_MODULE}"
if grep -q "^sdio_wifi_pwr" "/proc/modules"; then WIFI_DEP_MOD=""
if [ -n "${CPUFREQ_DVFS}" ]; then SKIP_SDIO_PWR_MODULE=""
echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable" case "${WIFI_MODULE}" in
# Leave Nickel in its usual state, don't try to use conservative "moal")
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" WIFI_DEP_MOD="mlan"
cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" SKIP_SDIO_PWR_MODULE="1"
;;
esac
if [ -n "${WIFI_DEP_MOD}" ]; then
if grep -q "^${WIFI_DEP_MOD}" "/proc/modules"; then
usleep 250000
rmmod "${WIFI_DEP_MOD}"
fi fi
usleep 250000
rmmod sdio_wifi_pwr
fi fi
# Poke the kernel via ioctl on platforms without the dedicated power module... if [ -n "${SKIP_SDIO_PWR_MODULE}" ]; then
if [ ! -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then
usleep 250000 usleep 250000
"${KOREADER_DIR}"/luajit "${KOREADER_DIR}"/frontend/device/kobo/ntx_io.lua 208 0 "${KOREADER_DIR}"/luajit "${KOREADER_DIR}"/frontend/device/kobo/ntx_io.lua 208 0
else
if grep -q "^sdio_wifi_pwr" "/proc/modules"; then
if [ -n "${CPUFREQ_DVFS}" ]; then
echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable"
# Leave Nickel in its usual state, don't try to use conservative
echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
fi
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 fi
fi fi

Loading…
Cancel
Save