Blacklist the C BB on devices where it cannot be used (#4989)

Either at all, or because it would impose reduced functionality.

Meaning:
* On 4bpp fb, because those are completely unsupported by the C BB
* On 24bpp fb, because it has limited support for that target format (no alpha blending).
* On 8bpp Linux eInk fb with an inverted palette (that's basically only the K4 ;)).
* On Linux eInk devices w/ no HW inversion support, as that would render NightMode inoperable.

That last point means that it's currently *always* blacklisted on PocketBook, because I don't have a PB device, so I don't know how safe HW inversion would be, meaning none of them are marked as being HW invert capable.

(I was a tiny bit hasty with https://github.com/koreader/koreader-base/pull/912 ;).)
pull/4993/head
NiLuJe 5 years ago committed by GitHub
parent bf07c44009
commit aec7594af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit b525cb490ea83e1c4be2eed9e4a2e165fa03c32e
Subproject commit 531e4bc685f099716170849a10c67dd5966c9e3a

@ -34,6 +34,7 @@ local Device = {
hasEinkScreen = yes,
canHWDither = no,
canHWInvert = no,
canUseCBB = yes, -- The C BB maintains a 1:1 feature parity with the Lua BB, except that is has NO support for BB4, and limited support for BBRGB24
hasColorScreen = no,
hasBGRFrameBuffer = no,
canToggleGSensor = no,

@ -202,6 +202,24 @@ function Kindle:ambientBrightnessLevel()
return 4
end
-- Make sure the C BB cannot be used on devices with a 4bpp fb
function Kindle:blacklistCBB()
local ffi = require("ffi")
local dummy = require("ffi/posix_h")
local C = ffi.C
-- As well as on those than can't do HW inversion, as otherwise NightMode would be ineffective.
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
local Kindle2 = Kindle:new{
model = "Kindle2",
@ -209,6 +227,7 @@ local Kindle2 = Kindle:new{
hasKeys = yes,
hasDPad = yes,
canHWInvert = no,
canUseCBB = no, -- 4bpp
}
local KindleDXG = Kindle:new{
@ -217,6 +236,7 @@ local KindleDXG = Kindle:new{
hasKeys = yes,
hasDPad = yes,
canHWInvert = no,
canUseCBB = no, -- 4bpp
}
local Kindle3 = Kindle:new{
@ -225,6 +245,7 @@ local Kindle3 = Kindle:new{
hasKeys = yes,
hasDPad = yes,
canHWInvert = no,
canUseCBB = no, -- 4bpp
}
local Kindle4 = Kindle:new{
@ -232,6 +253,8 @@ local Kindle4 = Kindle:new{
hasKeys = yes,
hasDPad = yes,
canHWInvert = no,
-- NOTE: It could *technically* use the C BB, as it's running @ 8bpp, but it's expecting an inverted palette...
canUseCBB = no,
}
local KindleTouch = Kindle:new{
@ -319,6 +342,9 @@ local KindlePaperWhite4 = Kindle:new{
}
function Kindle2:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/kindle/powerd"):new{
device = self,
@ -334,6 +360,9 @@ function Kindle2:init()
end
function KindleDXG:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/kindle/powerd"):new{
device = self,
@ -350,6 +379,9 @@ function KindleDXG:init()
end
function Kindle3:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/kindle/powerd"):new{
device = self,
@ -367,6 +399,9 @@ function Kindle3:init()
end
function Kindle4:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_einkfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/kindle/powerd"):new{
device = self,

@ -249,7 +249,29 @@ probeEvEpochTime = function(self, ev)
end
end
-- Make sure the C BB cannot be used on devices with unsafe HW inversion, as otherwise NightMode would be ineffective.
function Kobo:blacklistCBB()
local ffi = require("ffi")
local dummy = require("ffi/posix_h")
local C = ffi.C
-- NOTE: canUseCBB is never no on Kobo ;).
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 Kobo:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
if self.screen.fb_bpp == 32 then
-- Ensure we decode images properly, as our framebuffer is BGRA...

@ -62,7 +62,30 @@ local PocketBook = Generic:new{
hasWifiToggle = yes,
}
-- Make sure the C BB cannot be used on devices with a 24bpp fb
function PocketBook:blacklistCBB()
local dummy = require("ffi/posix_h")
local C = ffi.C
-- As well as on those than can't do HW inversion, as otherwise NightMode would be ineffective.
-- FIXME: Either relax the HWInvert check, or actually enable HWInvert on PB if it's safe and it works,
-- as, currently, no PB device is marked as canHWInvert, so, the C BB is essentially *always* blacklisted.
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 PocketBook:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
self.powerd = require("device/pocketbook/powerd"):new{device = self}
self.input = require("device/input"):new{
@ -292,6 +315,7 @@ local PocketBookColorLux = PocketBook:new{
hasFrontlight = yes,
hasColorScreen = yes,
has3BytesWideFrameBuffer = yes,
canUseCBB = no, -- 24bpp
isAlwaysPortrait = no,
emu_events_dev = "/var/dev/shm/emu_events",
}

Loading…
Cancel
Save