Better KOA2 support (#4037)

* Better KOA2 support
    * Fix FL
    * Add physical pageturn keys
    * Add accelerometer support
* Possibly better NaturalLight handling on the Clara
* Fix WiFi module name used in some(?) Mk7 Kobos
* A bunch of kodev fixes
pull/4040/head
NiLuJe 6 years ago committed by GitHub
parent f372dd752b
commit e2a0929c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit d7e8a782ab0fa1e4b7ba0f7cc68aa0202ad7e290 Subproject commit 4f182587da457b36449693e970d9e6c723656eb1

@ -517,7 +517,7 @@ function KindleOasis:init()
self.input.open("/dev/input/by-path/platform-gpiokey.0-event") self.input.open("/dev/input/by-path/platform-gpiokey.0-event")
-- get rotate dev by EV=d -- get rotate dev by EV=d
local std_out = io.popen("cat /proc/bus/input/devices | grep -e 'Handlers\\|EV=' | grep -B1 'EV=d'| grep -o 'event[0-9]'", "r") local std_out = io.popen("grep -e 'Handlers\\|EV=' /proc/bus/input/devices | grep -B1 'EV=d' | grep -o 'event[0-9]'", "r")
if std_out then if std_out then
local rotation_dev = std_out:read() local rotation_dev = std_out:read()
std_out:close() std_out:close()
@ -529,32 +529,70 @@ function KindleOasis:init()
self.input.open("fake_events") self.input.open("fake_events")
end end
-- FIXME: Should be enough for the bare minimum to work, TBC.
-- FIXME: Pageturn keys. And whatever else might be missing.
function KindleOasis2:init() function KindleOasis2:init()
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg} self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/kindle/powerd"):new{ self.powerd = require("device/kindle/powerd"):new{
device = self, device = self,
fl_intensity_file = "/sys/class/backlight/max77696-bl/brightness", fl_intensity_file = "/sys/class/backlight/max77796-bl/brightness",
batt_capacity_file = "/sys/class/power_supply/max77796-battery/capacity", batt_capacity_file = "/sys/class/power_supply/max77796-battery/capacity",
is_charging_file = "/sys/class/power_supply/max77796-charger/charging", is_charging_file = "/sys/class/power_supply/max77796-charger/charging",
} }
--[[
self.input = require("device/input"):new{ self.input = require("device/input"):new{
device = self, device = self,
-- Top, Bottom (yes, it's the reverse than on non-Oasis devices)
event_map = { event_map = {
[104] = "RPgFwd", [104] = "RPgFwd",
[109] = "RPgBack", [109] = "RPgBack",
} }
} }
--]]
local haslipc, lipc = pcall(require, "liblipclua")
if haslipc and lipc then
local lipc_handle = lipc.init("com.github.koreader.screen")
if lipc_handle then
local orientation_code = lipc_handle:get_string_property(
"com.lab126.winmgr", "accelerometer")
local rotation_mode = 0
if orientation_code then
if orientation_code == "U" then
rotation_mode = self.screen.ORIENTATION_PORTRAIT
elseif orientation_code == "R" then
rotation_mode = self.screen.ORIENTATION_LANDSCAPE
elseif orientation_code == "D" then
rotation_mode = self.screen.ORIENTATION_PORTRAIT_ROTATED
elseif orientation_code == "L" then
rotation_mode = self.screen.ORIENTATION_LANDSCAPE_ROTATED
end
end
if rotation_mode > 0 then
self.screen.native_rotation_mode = rotation_mode
self.screen.cur_rotation_mode = rotation_mode
end
lipc_handle:close()
end
end
Kindle.init(self) Kindle.init(self)
-- NOTE: Hopefully the KOA2 needs the exact same tweaks as the KOA...
self.input:registerEventAdjustHook(self.input.adjustKindleOasisOrientation)
self.input.open(self.touch_dev) self.input.open(self.touch_dev)
--self.input.open("/dev/input/by-path/platform-gpiokey.0-event") self.input.open("/dev/input/by-path/platform-gpio-keys-event")
-- Get accelerometer device by looking for EV=d
local std_out = io.popen("grep -e 'Handlers\\|EV=' /proc/bus/input/devices | grep -B1 'EV=d' | grep -o 'event[0-9]\\{1,2\\}'", "r")
if std_out then
local rotation_dev = std_out:read()
std_out:close()
if rotation_dev then
self.input.open("/dev/input/"..rotation_dev)
end
end
self.input.open("fake_events") self.input.open("fake_events")
end end

@ -179,14 +179,18 @@ local KoboPika = Kobo:new{
} }
-- Kobo Clara HD: -- Kobo Clara HD:
-- FIXME: NaturalLight doesn't exactly work right. -- FIXME: Check that NaturalLight behaves properly (c.f., #4015)
-- FIXME: Also, rebooting (?!!) might be FUBAR, too (KOReader crash, too).
local KoboNova = Kobo:new{ local KoboNova = Kobo:new{
model = "Kobo_nova", model = "Kobo_nova",
hasFrontlight = yes, hasFrontlight = yes,
touch_snow_protocol = true, touch_snow_protocol = true,
display_dpi = 300, display_dpi = 300,
hasNaturalLight = yes, hasNaturalLight = yes,
frontlight_settings = {
frontlight_white = "/sys/class/backlight/lm3630a_ledb",
frontlight_red = "/sys/class/backlight/lm3630a_leda",
frontlight_green = "/sys/class/backlight/lm3630a_led1b",
},
} }
function Kobo:init() function Kobo:init()

@ -81,7 +81,7 @@ function CreDocument:engineInit()
if not _v:find("/urw/") then if not _v:find("/urw/") then
local ok, err = pcall(cre.registerFont, _v) local ok, err = pcall(cre.registerFont, _v)
if not ok then if not ok then
logger.err("failed to register crengine font", err) logger.err("failed to register crengine font:", err)
end end
end end
end end

108
kodev

@ -5,11 +5,11 @@ VERSION=$(git describe HEAD)
VERSION=${VERSION}_$(git describe HEAD | xargs git show -s --format=format:"%cd" --date=short) VERSION=${VERSION}_$(git describe HEAD | xargs git show -s --format=format:"%cd" --date=short)
# Default Android build to arm. # Default Android build to arm.
ANDROID_ARCH=${ANDROID_ARCH:-arm} ANDROID_ARCH="${ANDROID_ARCH:-arm}"
if [ -z "${ANDROID_FULL_ARCH+x}" ]; then if [ -z "${ANDROID_FULL_ARCH}" ]; then
if [ "$ANDROID_ARCH" = arm ]; then if [ "${ANDROID_ARCH}" = "arm" ]; then
ANDROID_FULL_ARCH_APK="${ANDROID_FULL_ARCH_APK:-arm-linux-androideabi}" ANDROID_FULL_ARCH_APK="${ANDROID_FULL_ARCH_APK:-arm-linux-androideabi}"
elif [ "$ANDROID_ARCH" = x86 ]; then elif [ "${ANDROID_ARCH}" = "x86" ]; then
ANDROID_FULL_ARCH_APK="${ANDROID_FULL_ARCH_APK:-i686-linux-android}" ANDROID_FULL_ARCH_APK="${ANDROID_FULL_ARCH_APK:-i686-linux-android}"
else else
ANDROID_FULL_ARCH_APK="${ANDROID_ARCH}" ANDROID_FULL_ARCH_APK="${ANDROID_ARCH}"
@ -20,9 +20,9 @@ NDKABI=${NDKABI:-14}
export NDKABI export NDKABI
function assert_ret_zero() { function assert_ret_zero() {
if [ "$1" -ne 0 ]; then if [ "${1}" -ne 0 ]; then
if [ ! -z "$2" ]; then if [ ! -z "${2}" ]; then
echo "$2" echo "${2}"
fi fi
exit 1 exit 1
fi fi
@ -94,7 +94,7 @@ EOL
function setup_env() { function setup_env() {
SETUP_ENV_GREP_COMMAND="grep -v debug" SETUP_ENV_GREP_COMMAND="grep -v debug"
if [ -n "${KODEBUG+x}" ]; then if [ -n "${KODEBUG}" ]; then
SETUP_ENV_GREP_COMMAND="grep debug" SETUP_ENV_GREP_COMMAND="grep debug"
# for android adb install # for android adb install
KODEBUG_SUFFIX=-debug KODEBUG_SUFFIX=-debug
@ -134,10 +134,10 @@ OPTIONS:
TARGET: TARGET:
${SUPPORTED_TARGETS}" ${SUPPORTED_TARGETS}"
while [[ $1 == '-'* ]]; do while [[ "${1}" == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "${1}" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "${1}" | awk -F= '{print $2}')
case $PARAM in case "${PARAM}" in
-v | --verbose) -v | --verbose)
export VERBOSE=1 export VERBOSE=1
;; ;;
@ -163,7 +163,7 @@ ${SUPPORTED_TARGETS}"
done done
check_submodules check_submodules
case $1 in case "${1}" in
kindle) kindle)
make TARGET=kindle make TARGET=kindle
assert_ret_zero $? assert_ret_zero $?
@ -181,8 +181,8 @@ ${SUPPORTED_TARGETS}"
assert_ret_zero $? assert_ret_zero $?
;; ;;
android) android)
if [ -z "${NDK+x}" ]; then if [ -z "${NDK}" ]; then
if [ -n "${ANDROID_NDK+x}" ]; then if [ -n "${ANDROID_NDK}" ]; then
# some distributions use `ANDROID_NDK` instead, fall back to it # some distributions use `ANDROID_NDK` instead, fall back to it
export NDK="${ANDROID_NDK}" export NDK="${ANDROID_NDK}"
else else
@ -220,7 +220,7 @@ ${SUPPORTED_TARGETS}"
assert_ret_zero $? assert_ret_zero $?
;; ;;
*) *)
if [ -z "${KODEBUG_NO_DEFAULT+x}" ]; then # no explicit --debug / --no-debug if [ -z "${KODEBUG_NO_DEFAULT}" ]; then # no explicit --debug / --no-debug
# builds a debug build by default, like kodev-run # builds a debug build by default, like kodev-run
export KODEBUG=1 export KODEBUG=1
fi fi
@ -238,7 +238,7 @@ usage: clean <TARGET>
TARGET: TARGET:
${SUPPORTED_TARGETS}" ${SUPPORTED_TARGETS}"
case $1 in case "${1}" in
-h | --help) -h | --help)
echo "${CLEAN_HELP_MSG}" echo "${CLEAN_HELP_MSG}"
exit 0 exit 0
@ -297,10 +297,10 @@ ${SUPPORTED_RELEASE_TARGETS}"
ignore_translation=0 ignore_translation=0
while [[ $1 == '-'* ]]; do while [[ "${1}" == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "${1}" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "${1}" | awk -F= '{print $2}')
case $PARAM in case "${PARAM}" in
--debug) --debug)
export KODEBUG=1 export KODEBUG=1
;; ;;
@ -335,7 +335,7 @@ ${SUPPORTED_RELEASE_TARGETS}"
fi fi
fi fi
case $1 in case "${1}" in
kindle) kindle)
kodev-build kindle kodev-build kindle
make TARGET=kindle update make TARGET=kindle update
@ -416,15 +416,15 @@ TARGET:
screen_width=540 screen_width=540
screen_height=720 screen_height=720
export KODEBUG=1 export KODEBUG=1
while [[ $1 == '-'* ]]; do while [[ "${1}" == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "${1}" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "${1}" | awk -F= '{print $2}')
case $PARAM in case "${PARAM}" in
--disable-touch) --disable-touch)
export DISABLE_TOUCH=1 export DISABLE_TOUCH=1
;; ;;
--no-build) --no-build)
no_build=true no_build=1
;; ;;
--no-debug) --no-debug)
export KODEBUG= export KODEBUG=
@ -453,7 +453,7 @@ TARGET:
fi fi
;; ;;
--graph) --graph)
graph_memory=true graph_memory=1
;; ;;
--valgrind) --valgrind)
if [ ! -z "${VALUE}" ]; then if [ ! -z "${VALUE}" ]; then
@ -485,7 +485,7 @@ TARGET:
;; ;;
-s | --simulate) -s | --simulate)
device_model=${VALUE} device_model=${VALUE}
case ${device_model} in case "${device_model}" in
kindle3) kindle3)
screen_width=600 screen_width=600
screen_height=800 screen_height=800
@ -518,10 +518,10 @@ TARGET:
shift shift
done done
case $1 in case "${1}" in
android) android)
command -v adb >/dev/null && { command -v adb >/dev/null && {
if [ ! ${no_build} ]; then if [ -z "${no_build}" ]; then
echo "[*] Building KOReader for Android…" echo "[*] Building KOReader for Android…"
kodev-release --ignore-translation android kodev-release --ignore-translation android
assert_ret_zero $? assert_ret_zero $?
@ -541,9 +541,13 @@ TARGET:
} || echo "Failed to find adb in PATH to interact with Android device." } || echo "Failed to find adb in PATH to interact with Android device."
;; ;;
*) *)
if [ ! ${no_build} ]; then if [ -z "${no_build}" ]; then
echo "[*] Building KOReader…" echo "[*] Building KOReader…"
kodev-build if [ -z "${KODEBUG}" ]; then
kodev-build --no-debug
else
kodev-build
fi
else else
setup_env setup_env
fi fi
@ -553,7 +557,7 @@ TARGET:
exit 1 exit 1
fi fi
if [ ${graph_memory} ]; then if [ -n "${graph_memory}" ]; then
gnuplot_wrapper "--parent $$" "reader.lua" gnuplot_wrapper "--parent $$" "reader.lua"
fi fi
@ -579,19 +583,19 @@ TARGET:
args=${CURDIR}/test args=${CURDIR}/test
else else
args="$*" args="$*"
[[ $args != /* ]] && args="${CURDIR}/${args}" [[ "${args}" != /* ]] && args="${CURDIR}/${args}"
fi fi
KOREADER_COMMAND="$KOREADER_COMMAND ${args}" KOREADER_COMMAND="$KOREADER_COMMAND ${args}"
RETURN_VALUE=85 RETURN_VALUE=85
while [ $RETURN_VALUE -eq 85 ]; do while [ "${RETURN_VALUE}" -eq 85 ]; do
EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} EMULATE_READER_DPI=${screen_dpi} \ EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} EMULATE_READER_DPI=${screen_dpi} \
${KOREADER_COMMAND} ${KOREADER_COMMAND}
RETURN_VALUE=$? RETURN_VALUE=$?
done done
} && popd || exit } && popd || exit
if [ ${graph_memory} ]; then if [ -n "${graph_memory}" ]; then
capture_ctrl_c capture_ctrl_c
fi fi
;; ;;
@ -608,12 +612,12 @@ OPTIONS:
--tags=TAGS only run tests with given tags --tags=TAGS only run tests with given tags
" "
while [[ $1 == '-'* ]]; do while [[ "${1}" == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "${1}" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "${1}" | awk -F= '{print $2}')
case $PARAM in case "${PARAM}" in
--graph) --graph)
graph_memory=true graph_memory=1
;; ;;
--tags) --tags)
opts="--tags=${VALUE}" opts="--tags=${VALUE}"
@ -635,7 +639,7 @@ OPTIONS:
echo "${TEST_HELP_MSG}" echo "${TEST_HELP_MSG}"
exit 1 exit 1
} }
[[ $1 != "front" && $1 != "base" ]] && { [[ "${1}" != "front" && "${1}" != "base" ]] && {
echo "Invalid test suite: $1!" echo "Invalid test suite: $1!"
echo "${TEST_HELP_MSG}" echo "${TEST_HELP_MSG}"
exit 1 exit 1
@ -649,7 +653,7 @@ OPTIONS:
test_path="./spec/$1/unit" test_path="./spec/$1/unit"
rm -rf "${test_path}"/data/*.sdr rm -rf "${test_path}"/data/*.sdr
if [ ! -z "$2" ]; then if [ ! -z "${2}" ]; then
test_path="${test_path}/$2" test_path="${test_path}/$2"
fi fi
@ -673,10 +677,10 @@ OPTIONS:
" "
show_full=0 show_full=0
show_previous=0 show_previous=0
while [[ $1 == '-'* ]]; do while [[ "${1}" == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "${1}" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "${1}" | awk -F= '{print $2}')
case $PARAM in case "${PARAM}" in
--full) --full)
show_full=1 show_full=1
;; ;;
@ -702,7 +706,7 @@ OPTIONS:
pushd "${EMU_DIR}" && { pushd "${EMU_DIR}" && {
target=front target=front
test_path="./spec/${target}/unit" test_path="./spec/${target}/unit"
if [ ${show_previous} -eq 0 ]; then if [ "${show_previous}" -eq 0 ]; then
echo "Running tests in" ${test_path} echo "Running tests in" ${test_path}
busted --lua="./luajit" \ busted --lua="./luajit" \
--sort-files \ --sort-files \
@ -714,7 +718,7 @@ OPTIONS:
echo "Failed to run tests!" && exit 1 echo "Failed to run tests!" && exit 1
} }
fi fi
if [ ${show_full} -eq 1 ]; then if [ "${show_full}" -eq 1 ]; then
cat luacov.report.out cat luacov.report.out
else else
LUACOV_REPORT_SUMMARY=$(grep -nm1 -e '^Summary$' luacov.report.out | cut -d: -f1) LUACOV_REPORT_SUMMARY=$(grep -nm1 -e '^Summary$' luacov.report.out | cut -d: -f1)
@ -738,7 +742,7 @@ TARGET:
exit 1 exit 1
} }
case $1 in case "${1}" in
-h | --help) -h | --help)
echo "${LOG_HELP_MSG}" echo "${LOG_HELP_MSG}"
exit 0 exit 0
@ -775,7 +779,7 @@ Supported commands:
exit 1 exit 1
} }
case $1 in case "${1}" in
activate) activate)
echo "adding ${CURDIR} to \$PATH..." echo "adding ${CURDIR} to \$PATH..."
export PATH="${PATH}:${CURDIR}" export PATH="${PATH}:${CURDIR}"

@ -4,7 +4,7 @@
killall udhcpc default.script wpa_supplicant 2>/dev/null killall udhcpc default.script wpa_supplicant 2>/dev/null
[ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" down [ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8192es" ] && wlarm_le -i "${INTERFACE}" down
ifconfig "${INTERFACE}" down ifconfig "${INTERFACE}" down
# Some sleep in between may avoid system getting hung # Some sleep in between may avoid system getting hung

@ -11,7 +11,7 @@ lsmod | grep -q "${WIFI_MODULE}" || insmod "${WIFI_MODULE_PATH}"
sleep 1 sleep 1
ifconfig "${INTERFACE}" up ifconfig "${INTERFACE}" up
[ "$WIFI_MODULE" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" up [ "$WIFI_MODULE" != "8189fs" ] && [ "${WIFI_MODULE}" != "8192es" ] && wlarm_le -i "${INTERFACE}" up
pidof wpa_supplicant >/dev/null \ pidof wpa_supplicant >/dev/null \
|| env -u LD_LIBRARY_PATH \ || env -u LD_LIBRARY_PATH \

@ -18,7 +18,7 @@ export LD_LIBRARY_PATH="/usr/local/Kobo"
# NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that. # NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that.
if lsmod | grep -q sdio_wifi_pwr; then if lsmod | grep -q sdio_wifi_pwr; then
killall udhcpc default.script wpa_supplicant 2>/dev/null killall udhcpc default.script wpa_supplicant 2>/dev/null
[ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" down [ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8192es" ] && wlarm_le -i "${INTERFACE}" down
ifconfig "${INTERFACE}" down ifconfig "${INTERFACE}" down
# NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag... # NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag...
# But since there's currently no modules.dep file being shipped, nor do they include the depmod applet, # But since there's currently no modules.dep file being shipped, nor do they include the depmod applet,

Loading…
Cancel
Save