From 5a86443eb1d9069715f1bca98b33d9f46ec2b068 Mon Sep 17 00:00:00 2001 From: ezdiy Date: Thu, 22 Oct 2020 13:23:09 +0200 Subject: [PATCH] Pocketbook: waveform presets (#6794) On pocketbook, update modes are not as clear cut due to overall chipset and kernel version mess. Inkview solves this by always using the slowest (and safe) GC16 waveform. We now do that too by default. Slow updates suck though, so there's now a menu entry to configure it for speed (with mild artifacts at best, kernel panic at worst). This is a generic interface (any eink Screen can announce support). The driver may interpret the slow/fast range however they want. --- base | 2 +- frontend/device/pocketbook/device.lua | 24 ++++++------- .../elements/screen_eink_opt_menu_table.lua | 3 ++ frontend/ui/elements/waveform_level.lua | 36 +++++++++++++++++++ 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 frontend/ui/elements/waveform_level.lua diff --git a/base b/base index 78204b02f..5f9e9b7eb 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 78204b02feb4e7b00d110626634eb8c00e1d503b +Subproject commit 5f9e9b7eb39fc98cdacba52d081fe2b559fcfb33 diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index 9f26cfe7c..798bd44fe 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -74,13 +74,6 @@ local function tryOpenBook() end end -local function isB288(fb) - -- No real header exists for this, see https://github.com/koreader/koreader-base/issues/1202/ - local B288_POLL_FOR_UPDATE_COMPLETE = 0x80044655 - -- On NXT that has a real MXC driver, it returns -EINVAL - return C.ioctl(fb.fd, B288_POLL_FOR_UPDATE_COMPLETE, ffi.new("uint32_t[1]")) == 0 -end - function PocketBook:init() local raw_input = self.raw_input local touch_rotation = raw_input and raw_input.touch_rotation or 0 @@ -88,17 +81,24 @@ function PocketBook:init() self.screen = require("ffi/framebuffer_mxcfb"):new { device = self, debug = logger.dbg, + wf_level = G_reader_settings:readSetting("wf_level") or 0, fbinfoOverride = function(fb, finfo, vinfo) -- Device model caps *can* set both to indicate that either will work to get correct orientation. -- But for FB backend, the flags are mutually exclusive, so we nuke one of em later. fb.is_always_portrait = self.isAlwaysPortrait() fb.forced_rotation = self.usingForcedRotation() - -- Tweak combination of alwaysPortrait/hwRot/hwInvert flags depending on probed HW. - if isB288(fb) then - logger.dbg("mxcfb: Detected B288 chipset, disabling HW rotation and invert") - fb.forced_rotation = nil + -- Tweak combination of alwaysPortrait/hwRot/hwInvert flags depending on probed HW and wf settings. + if fb:isB288() then + logger.dbg("mxcfb: Disabling hwinvert on B288 chipset") self.canHWInvert = no - elseif fb.forced_rotation then + -- GL16 glitches with hwrot + if fb.wf_level == 3 then + logger.dbg("mxcfb: Disabling hwrot on fast waveforms (B288 glitch)") + fb.forced_rotation = nil + end + end + -- if hwrot is still on, nuke swrot + if fb.forced_rotation then fb.is_always_portrait = false end return self._fb_init(fb, finfo, vinfo) diff --git a/frontend/ui/elements/screen_eink_opt_menu_table.lua b/frontend/ui/elements/screen_eink_opt_menu_table.lua index ae92c73b1..5d1e7c11e 100644 --- a/frontend/ui/elements/screen_eink_opt_menu_table.lua +++ b/frontend/ui/elements/screen_eink_opt_menu_table.lua @@ -27,6 +27,9 @@ local eink_settings_table = { if Device:hasEinkScreen() then table.insert(eink_settings_table.sub_item_table, 1, require("ui/elements/refresh_menu_table")) + if (Screen.wf_level_max or 0) > 0 then + table.insert(eink_settings_table.sub_item_table, require("ui/elements/waveform_level")) + end end return eink_settings_table diff --git a/frontend/ui/elements/waveform_level.lua b/frontend/ui/elements/waveform_level.lua new file mode 100644 index 000000000..3e9b96714 --- /dev/null +++ b/frontend/ui/elements/waveform_level.lua @@ -0,0 +1,36 @@ +local _ = require("gettext") +local Device = require("device") +local InfoMessage = require("ui/widget/infomessage") +local UIManager = require("ui/uimanager") +local Screen = Device.screen +local T = require("ffi/util").template + +local items = {} +for i=0, Screen.wf_level_max do + local info + if i == 0 then + info = _("Level 0: high quality, slowest") + elseif i == Screen.wf_level_max then + info = T(_("Level %1: low quality, fastest"), i) + else + info = T(_("Level %1"), i) + end + + table.insert(items, { + text = info, + checked_func = function() return Screen.wf_level == i end, + callback = function() + Screen.wf_level = i + G_reader_settings:saveSetting("wf_level", i) + UIManager:show(InfoMessage:new{ + text = _("This will take effect on next restart."), + }) + end, + }) +end + +return { + text = _("Refresh speed/fidelity"), + sub_item_table = items, +} +