Skip to content

Commit

Permalink
Unbreak nightmode on Cervantes (#5966)
Browse files Browse the repository at this point in the history
* Unbreak nightmode on Cervantes

Regression after koreader/koreader-base#1047 (I
thought it was already implemented).

Fix #5963

* make luacheck happy
  • Loading branch information
NiLuJe committed Mar 16, 2020
1 parent 8d8b8cd commit 4a5a2eb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions frontend/device/cervantes/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ local Cervantes = Generic:new{
-- currently only Cervantes 4 has coloured frontlight
hasNaturalLight = no,
hasNaturalLightMixer = no,

-- HW inversion is generally safe on Cervantes, except on a few boards/kernels
canHWInvert = yes,
}
-- Cervantes Touch
local CervantesTouch = Cervantes:new{
Expand All @@ -91,6 +94,7 @@ local Cervantes2013 = Cervantes:new{
model = "Cervantes2013",
display_dpi = 212,
hasMultitouch = no,
--- @fixme: Possibly requires canHWInvert = no, as it seems to be based on a similar board as the Kobo Aura...
}
-- Cervantes 3 / Fnac Touch Light 2
local Cervantes3 = Cervantes:new{
Expand Down Expand Up @@ -151,7 +155,29 @@ function Cervantes:initEventAdjustHooks()
end
end

-- Make sure the C BB cannot be used on devices with unsafe HW inversion, as otherwise NightMode would be ineffective.
function Cervantes:blacklistCBB()
local ffi = require("ffi")
local dummy = require("ffi/posix_h")
local C = ffi.C

-- NOTE: canUseCBB is never no on Cervantes ;).
if not self:canUseCBB() or not self:canHWInvert() then
logger.info("Blacklisting the C BB on this device")
if ffi.os == "Windows" then
C._putenv("KO_NO_CBB=true")
else
C.setenv("KO_NO_CBB", "true", 1)
end
-- Enforce the global setting, too, so the Dev menu is accurate...
G_reader_settings:saveSetting("dev_no_c_blitter", true)
end
end

function Cervantes:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()

self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}

-- Automagically set this so we never have to remember to do it manually ;p
Expand Down
2 changes: 1 addition & 1 deletion frontend/device/kobo/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ local Kobo = Generic:new{
-- currently only the Aura One and Forma have coloured frontlights
hasNaturalLight = no,
hasNaturalLightMixer = no,
-- HW inversion is generally safe on Kobo, except on a few baords/kernels
-- HW inversion is generally safe on Kobo, except on a few boards/kernels
canHWInvert = yes,
}

Expand Down

0 comments on commit 4a5a2eb

Please sign in to comment.