Skip to content
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

On Kobo, drop fb to 8bpp on startup #4637

Merged
merged 16 commits into from Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions frontend/apps/filemanager/filemanagermenu.lua
Expand Up @@ -212,8 +212,52 @@ function FileManagerMenu:setUpdateItemTable()
})
end,
},
{
text = _("Enable debug logging"),
checked_func = function()
return G_reader_settings:isTrue("debug")
end,
callback = function()
G_reader_settings:flipNilOrFalse("debug")
if G_reader_settings:isTrue("debug") then
dbg:turnOn()
else
dbg:setVerbose(false)
dbg:turnOff()
G_reader_settings:flipTrue("debug_verbose")
end
end,
},
{
text = _("Enable verbose debug logging"),
enabled_func = function()
return G_reader_settings:isTrue("debug")
end,
checked_func = function()
return G_reader_settings:isTrue("debug_verbose")
end,
callback = function()
G_reader_settings:flipNilOrFalse("debug_verbose")
if G_reader_settings:isTrue("debug_verbose") then
dbg:setVerbose(true)
else
dbg:setVerbose(false)
end
end,
},
}
}
if Device:isKobo() then
table.insert(self.menu_items.developer_options.sub_item_table, {
text = _("Disable forced 8-bit color space"),
checked_func = function()
return G_reader_settings:isTrue("dev_startup_no_fbdepth")
end,
callback = function()
G_reader_settings:flipNilOrFalse("dev_startup_no_fbdepth")
end,
})
end
self.menu_items.cloud_storage = {
text = _("Cloud storage"),
callback = function()
Expand Down
5 changes: 3 additions & 2 deletions frontend/device/kobo/device.lua
Expand Up @@ -23,7 +23,6 @@ local Kobo = Generic:new{
model = "Kobo",
isKobo = yes,
isTouchDevice = yes, -- all of them are
hasBGRFrameBuffer = yes, -- True when >16bpp (i.e., on current FW)
hasOTAUpdates = yes,
hasWifiManager = yes,

Expand Down Expand Up @@ -260,7 +259,9 @@ function Kobo:init()
if self.screen.fb_bpp == 16 then
logger.info("Enabling Kobo @ 16bpp tweaks")
jit.opt.start("loopunroll=45")
self.hasBGRFrameBuffer = no
elseif self.screen.fb_bpp == 32 then
-- Ensure we decode images properly, as our framebuffer is BGRA...
self.hasBGRFrameBuffer = yes
end
self.powerd = require("device/kobo/powerd"):new{device = self}
-- NOTE: For the Forma, with the buttons on the right, 193 is Top, 194 Bottom.
Expand Down
43 changes: 43 additions & 0 deletions platform/kobo/koreader.sh
Expand Up @@ -151,6 +151,41 @@ if [ "${PRODUCT}" = "frost" ]; then
fi
# NOTE: We don't have to restore anything on exit, nickel's startup process will take care of everything (pickel -> nickel).

# In the same vein, swap to 8bpp,
# because 16bpp is the worst idea in the history of time, as RGB565 is generally a PITA without hardware blitting,
# and 32bpp usually gains us nothing except a performance hit (we're not Qt5 with its QPainter constraints).
# The reduced size & complexity should hopefully make things snappier,
# (and hopefully prevent the JIT for going crazy on high-density screens...).
# NOTE: Even though pickel/Nickel appear to restore their preferred fb setup, we'll have to do it ourselves,
# because things are a bit wonky otherwise. Plus, we get to play nice with every launch method that way.
# So, remember the current bitdepth, so we can restore it on exit.
ORIG_FB_BPP="$(./fbdepth -g)"
# Sanity check...
case "${ORIG_FB_BPP}" in
16) ;;
32) ;;
*)
# Hu oh? Don't do anything...
unset ORIG_FB_BPP
;;
esac

# The actual swap is done in a function, because we can disable it in the Developer settings, and we want to honor it on restart.
ko_do_fbdepth() {
# Check if the swap has been disabled...
if grep -q '\["dev_startup_no_fbdepth"\] = true' 'settings.reader.lua' 2>/dev/null; then
# Swap back to the original bitdepth (in case this was a restart)
if [ -n "${ORIG_FB_BPP}" ]; then
./fbdepth -d "${ORIG_FB_BPP}" >>crash.log 2>&1
fi
else
# Swap to 8bpp if things looke sane
if [ -n "${ORIG_FB_BPP}" ]; then
./fbdepth -d 8 >>crash.log 2>&1
fi
fi
}

# Remount the SD card RW if it's inserted and currently RO
if awk '$4~/(^|,)ro($|,)/' /proc/mounts | grep ' /mnt/sd '; then
mount -o remount,rw /mnt/sd
Expand All @@ -166,11 +201,19 @@ RETURN_VALUE=85
while [ $RETURN_VALUE -eq 85 ]; do
# Do an update check now, so we can actually update KOReader via the "Restart KOReader" menu entry ;).
ko_update_check
# Do the fb depth switch, unless it's been disabled
ko_do_fbdepth

# shellcheck disable=SC2086
NiLuJe marked this conversation as resolved.
Show resolved Hide resolved
./reader.lua "${args}" >>crash.log 2>&1
RETURN_VALUE=$?
done

# Restore original fb bitdepth if need be...
if [ -n "${ORIG_FB_BPP}" ]; then
./fbdepth -d "${ORIG_FB_BPP}" >>crash.log 2>&1
fi

# Restore original CPUFreq governor if need be...
if [ -n "${ORIG_CPUFREQ_GOV}" ]; then
echo "${ORIG_CPUFREQ_GOV}" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
Expand Down
Binary file modified plugins/kobolight.koplugin/demo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/kobolight.koplugin/demo_ka1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion reader.lua
Expand Up @@ -62,7 +62,8 @@ end
-- should check DEBUG option in arg and turn on DEBUG before loading other
-- modules, otherwise DEBUG in some modules may not be printed.
local dbg = require("dbg")
if G_reader_settings:readSetting("debug") then dbg:turnOn() end
if G_reader_settings:isTrue("debug") then dbg:turnOn() end
if G_reader_settings:isTrue("debug") and G_reader_settings:isTrue("debug_verbose") then dbg:setVerbose(true) end

local Profiler = nil
local ARGV = arg
Expand Down
Binary file modified resources/goodreadsnophoto.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.align.auto.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.align.center.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.align.justify.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.align.left.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.align.right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.arrow.enter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.arrow.left.up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.arrow.shift.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.book.open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.cabinet.files.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.chevron.first.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.chevron.last.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.chevron.left.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.chevron.right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.chevron.up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.clear.reflect.horizontal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.column.one.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.column.three.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.column.two.large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.column.two.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.control.collapse.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.control.expand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/appbar.crop.large.png
Binary file modified resources/icons/appbar.globe.wire.png
Binary file modified resources/icons/appbar.grade.b.large.png
Binary file modified resources/icons/appbar.home.png
Binary file modified resources/icons/appbar.magnify.browse.png
Binary file modified resources/icons/appbar.page.corner.bookmark.png
Binary file modified resources/icons/appbar.page.text.png
Binary file modified resources/icons/appbar.plus.png
Binary file modified resources/icons/appbar.pokeball.png
Binary file modified resources/icons/appbar.settings.large.png
Binary file modified resources/icons/appbar.settings.png
Binary file modified resources/icons/appbar.spacer.png
Binary file modified resources/icons/appbar.text.size.large.png
Binary file modified resources/icons/appbar.tools.png
Binary file modified resources/icons/appbar.transform.rotate.right.large.png
Binary file modified resources/icons/appbar.wifi.png
Binary file modified resources/icons/dogear.png
Binary file modified resources/icons/menu-icon.png
Binary file modified resources/icons/stats.star.empty.png
Binary file modified resources/icons/stats.star.full.png
Binary file modified resources/info-aux.png
Binary file modified resources/info-bug.png
Binary file modified resources/info-confirm.png
Binary file modified resources/info-error.png
Binary file modified resources/info-i.png
Binary file modified resources/info-warn.png
Binary file modified resources/jpeg.png
Binary file modified resources/jpg.png
Binary file modified resources/kobo-touch-probe.png