-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround to support new kobo firmwares (+4.0) without needing KSM8 #2731
Conversation
# to run koreader in 16bpp. Useful since FW 4.0 | ||
FB_BPP=$(cat /sys/class/graphics/fb0/bits_per_pixel) | ||
[ "$FB_BPP" -gt 16 ] && /usr/sbin/fbset -depth 16 | ||
# fix rotation issues on Kobo Aura HD (dragon) and Kobo Aura H2O (dahlia) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From KSM this actually "cause". There was some stuff about this on c2bd85b#commitcomment-12846700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? (It does with KSM.)
case "$PRODUCT" in "dragon" | "dahlia" )
cur_rotate="$(cat "/sys/class/graphics/fb0/rotate")"
echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate"
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"
;;
esac
@Frenzie: that was needed on my aura HD. After killing nickel rotation is 3. Koreader needs the same rotation to work. If the line is removed then rotation is 1 and the screen is flipped. I didn't think about the rationale of this, but in my end seems to works reliable. I didn't found that bug on KA1 but it should be safe to do on all kobo devices. |
Okay, so just this without the check? cur_rotate="$(cat "/sys/class/graphics/fb0/rotate")"
echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate"
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate" |
Yes, it works nice. But again: the last line alone does the job for all my devices (mini, aura hd and ka1) |
Actually this is still not good. This causes random rotations all around. It was working fine the way it was. :-( @NiLuJe Help? :-P As indicated in the forum this is what happens on H2O: [root@(none) ~]# cat "/sys/class/graphics/fb0/rotate"
2
[root@(none) ~]# cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0
/rotate"
[root@(none) ~]# cat "/sys/class/graphics/fb0/rotate"
0
[root@(none) ~]# cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0
/rotate"
[root@(none) ~]# cat "/sys/class/graphics/fb0/rotate"
2 I'll have to do some more testing here about when the values are what. Edit: okay, I think I tracked down the problem. [root@(none) ~]# cat "/sys/class/graphics/fb0/rotate"
2
[root@(none) ~]# /usr/sbin/fbset -depth 16
[root@(none) ~]# cat "/sys/class/graphics/fb0/rotate"
0 Edit: correction, KSM already sets it to 16-bit of course. But where does the extra rotation come from… |
this is why we change rotation after changing fb depth. @Frenzie: could you look at fbset -geometry before and after the fb depth change?: 1440x1080 vs 1080x1440. Sorry but my devices are out of home (except the KA1), I'm talking from memory :/ |
@pazos Yes, but the fb depth doesn't change anyway because KSM already sets it to 16 bit, so that's actually unrelated. (And even if it did I set the cur_rotate before the fbset.) Anyway, I've got a much simpler fix: # workaround 32-bit without KSM
if [ -z ${ksmroot+x} ]; then
# TODO: add support for 32bit framebuffer in koreader. This is a workaround
# to run koreader in 16bpp. Useful since FW 4.0
CUR_ROTATE="$(cat "/sys/class/graphics/fb0/rotate")"
FB_BPP=$(cat /sys/class/graphics/fb0/bits_per_pixel)
[ "$FB_BPP" -gt 16 ] && /usr/sbin/fbset -depth 16
# fix rotation issues on Kobo Aura HD (dragon) and Kobo Aura H2O (dahlia)
echo "${CUR_ROTATE}" > "/sys/class/graphics/fb0/rotate"
# shellcheck disable=SC2094
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"
fi
./reader.lua "${args}" >> crash.log 2>&1
RESULT=$?
# workaround 32-bit without KSM
if [ -z ${ksmroot+x} ]; then
# back to default depth in framebuffer.
[ "$FB_BPP" -gt 16 ] && /usr/sbin/fbset -depth "$FB_BPP"
fi |
@Frenzie: I don't understand your logic here. KSM doesn't use our koreader.sh script at all. So checking for KSM within the script isn't needed. KSM also handles the rotation bug in its code. |
Sorry, I should've been clearer. Your script turns KOReader upside down. My proposed fix works fine but "causes random rotations all around" in KSM, after exiting KOReader. Avoiding the non-KSM codepath also avoids all issues. |
Ahhh, ok. I'm using fmon to launch koreader. After leaving koreader.sh nickel.sh was called. This file (nickel.sh) is used by koreader with fmon or kfmon, but AFAIK Tshering forked all those files and bundle them in KSM8. Take a look on https://github.com/koreader/koreader/blob/master/platform/kobo/nickel.sh#L5 and https://github.com/koreader/koreader/blob/master/platform/kobo/nickel.sh#L89. This works for me and nickel is running fine. |
In which devices?. Did you mean with or without the product check? |
Relevant files for KSM8 are in adds/kbmenu/onstart. There are: start_koreader.sh / start_nickel.sh / start_nickel_fromloop.sh / nickelkoreaderloop.sh ... If you look at the code you'll find how the author is handling this |
What you linked (which I'm not sure why considering I already linked to it =P) is pretty much all H2O-related afaik: https://www.mobileread.com/forums/showthread.php?p=3028142#post3028142 On other devices it should be innocent repetition. CUR_ROTATE="$(cat "/sys/class/graphics/fb0/rotate")"
# this suffices on normal devices, but H2O is stupid and sets the opposite
echo "${CUR_ROTATE}" > "/sys/class/graphics/fb0/rotate"
# this therefore turns it around on H2O (and other potential idiots) and just innocently repeats on sane devices
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate" |
It's handled in a way that causes KOReader to turn upside down after exiting Nickel. (I'm sure you can draw the relevant conclusions from the fact that I never noticed.) But what's your objection to #2731 (comment) precisely? |
I thought that the if statement Sorry for the discussion overflow :P |
That was true a few years ago. It's a more of a symbiosis now, with amusing workarounds on both sides. For example, I had to add this line after $from_nickel was renamed to $FROM_NICKEL and weird things happened. # Do not delete this line because KSM detects newer versions of KOReader by the presence of the phrase 'from_nickel'. |
* Add ShellCheck and shfmt shell code quality analysis * kobo/koreader.sh: remove useless $PREFIX * kobo/koreader.sh: fix rotation issue caused by #2731 * Travis: speed up (caching Luarocks should shave a minute off install process)
Waiting for #2502. Until now only KSM8 supports new firmware and this is because it uses its own version of koreader.sh.
This forces depth to 16bpp before running koreader. It was suggested by baskerville on #2542
It also handles weird rotations that I've found on a Kobo Aura HD. AFAIK the same rotation bug happens on Kobo Aura H20 too.
Useful to run koreader from shell, fmon, kfmon...