From cf9c59a4a8cc8a36c94b7908fce530c91f9d91c2 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Thu, 9 Jul 2026 16:27:16 +0900 Subject: [PATCH] feat(reMarkable): Oxide/libblight support (#15611) Companion PR to koreader/koreader-base#2417. --- frontend/device/input.lua | 2 ++ frontend/device/remarkable/device.lua | 22 +++++++++++++++------- platform/remarkable/koreader.sh | 12 ++++++++---- platform/remarkable/spinning_zsync | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/frontend/device/input.lua b/frontend/device/input.lua index dd9df6d2b..78a75779b 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -234,6 +234,8 @@ function Input:init() self.input = require("ffi/input_pocketbook") elseif self.device:isRemarkable() and os.getenv("KO_USE_QTFB") == "1" then self.input = require("ffi/input_qtfb") + elseif self.device:isRemarkable() and os.getenv("KO_USE_BLIGHT") == "1" then + self.input = require("ffi/input_blight") else self.input = require("libs/libkoreader-input") end diff --git a/frontend/device/remarkable/device.lua b/frontend/device/remarkable/device.lua index fe8801e3b..82dd1952b 100644 --- a/frontend/device/remarkable/device.lua +++ b/frontend/device/remarkable/device.lua @@ -34,6 +34,7 @@ local is_rmppure = rm_model == "reMarkable Tatsu" local has_csl = util.which("csl") local is_qtfb_shimmed = (os.getenv("LD_PRELOAD") or ""):find("qtfb%-shim") ~= nil local is_qtfb_native = os.getenv("KO_USE_QTFB") ~= nil +local is_blight_native = os.getenv("KO_USE_BLIGHT") ~= nil if is_rmpp then screen_width = 1620 -- unscaled_size_check: ignore @@ -232,7 +233,14 @@ function Remarkable:init() -- os.execute("ps | grep $PPID") -- logger.info(string.format("parent process is oxide?: %s", parent_process_is_oxide)) - local fb_module = os.getenv("KO_USE_QTFB") and "ffi/framebuffer_qtfb" or "ffi/framebuffer_mxcfb" + local fb_module + if is_qtfb_native then + fb_module = "ffi/framebuffer_qtfb" + elseif is_blight_native then + fb_module = "ffi/framebuffer_blight" + else + fb_module = "ffi/framebuffer_mxcfb" + end self.screen = require(fb_module):new{ device = self, debug = logger.dbg, @@ -247,7 +255,7 @@ function Remarkable:init() local event_map = dofile("frontend/device/remarkable/event_map.lua") -- If we are launched while Oxide or xochitl is running, remove Power from the event map - if oxide_running or is_qtfb_shimmed or is_qtfb_native then + if oxide_running or is_qtfb_shimmed or is_qtfb_native or is_blight_native then event_map[116] = nil event_map[143] = nil event_map[20001] = nil @@ -343,7 +351,7 @@ function Remarkable:init() self.screen.native_rotation_mode = rotation_mode self.screen.cur_rotation_mode = rotation_mode - if oxide_running or is_qtfb_shimmed or is_qtfb_native then + if oxide_running or is_qtfb_shimmed or is_qtfb_native or is_blight_native then -- Disable autosuspend on this device PluginShare.pause_auto_suspend = true end @@ -487,13 +495,13 @@ function Remarkable:setEventHandlers(UIManager) end if is_rm2 then - if is_qtfb_native then return Remarkable2 end + if is_qtfb_native or is_blight_native then return Remarkable2 end if not os.getenv("RM2FB_SHIM") and not is_qtfb_shimmed then error("reMarkable 2 requires a RM2FB server and client to work (https://github.com/ddvk/remarkable2-framebuffer or https://github.com/asivery/rmpp-qtfb-shim)") end return Remarkable2 elseif is_rmpp then - if is_qtfb_native then return RemarkablePaperPro end + if is_qtfb_native or is_blight_native then return RemarkablePaperPro end if not is_qtfb_shimmed then error("reMarkable Paper Pro requires a RM2FB server and client to work (https://github.com/asivery/rm-appload)") end @@ -502,7 +510,7 @@ elseif is_rmpp then end return RemarkablePaperPro elseif is_rmppm then - if is_qtfb_native then return RemarkablePaperProMove end + if is_qtfb_native or is_blight_native then return RemarkablePaperProMove end if not is_qtfb_shimmed then error("reMarkable Paper Pro Move requires a RM2FB server and client to work (https://github.com/asivery/rm-appload)") end @@ -511,7 +519,7 @@ elseif is_rmppm then end return RemarkablePaperProMove elseif is_rmppure then - if is_qtfb_native then return RemarkablePaperPure end + if is_qtfb_native or is_blight_native then return RemarkablePaperPure end if not is_qtfb_shimmed then error("reMarkable Paper Pure requires a RM2FB server and client to work (https://github.com/asivery/rm-appload)") end diff --git a/platform/remarkable/koreader.sh b/platform/remarkable/koreader.sh index c41f16f21..3fa0e655d 100755 --- a/platform/remarkable/koreader.sh +++ b/platform/remarkable/koreader.sh @@ -20,10 +20,11 @@ fi # we're always starting from our working directory cd "${KOREADER_DIR}" || exit -# reMarkable QTFB setup -if [ -n "${KO_USE_QTFB}" ]; then +# reMarkable QTFB/Blight setup +if [ -n "${KO_USE_QTFB}" ] || [ -n "${KO_USE_BLIGHT}" ]; then export KO_DONT_GRAB_INPUT=1 export KO_DONT_SET_DEPTH=1 + export LD_LIBRARY_PATH="${KOREADER_DIR}/libs:/home/root/.vellum/lib:${LD_LIBRARY_PATH}" fi fbink_wrapped() { @@ -34,6 +35,9 @@ fbink_wrapped() { QTFB_SHIM_MODE="N_RGB565" \ QTFB_SHIM_RESPECT_FULL_REFRESH_REQUESTS="1" \ ./fbink "$@" + elif [ -n "${KO_USE_BLIGHT}" ]; then + # fbink can't do deferred rendering via blight-client (each invocation creates a separate surface) + true else ./fbink "$@" fi @@ -110,7 +114,7 @@ export STARDICT_DATA_DIR="data/dict" ORIG_FB_BPP="" ORIG_FB_ROTA="" -if [ -z "${KO_DONT_SET_DEPTH}" ] && [ -z "${KO_USE_QTFB}" ]; then +if [ -z "${KO_DONT_SET_DEPTH}" ] && [ -z "${KO_USE_QTFB}" ] && [ -z "${KO_USE_BLIGHT}" ]; then # We'll want to ensure Portrait rotation to allow us to use faster blitting codepaths @ 8bpp, # so remember the current one before fbdepth does its thing. ORIG_FB_ROTA="$(./fbdepth -o)" @@ -275,7 +279,7 @@ done # Restore original fb bitdepth if need be... # Since we also (almost) always enforce Portrait, we also have to restore the original rotation no matter what ;). -if [ -z "${KO_DONT_SET_DEPTH}" ] && [ -z "${KO_USE_QTFB}" ]; then +if [ -z "${KO_DONT_SET_DEPTH}" ] && [ -z "${KO_USE_QTFB}" ] && [ -z "${KO_USE_BLIGHT}" ]; then if [ -n "${ORIG_FB_BPP}" ]; then echo "Restoring original fb bitdepth @ ${ORIG_FB_BPP}bpp & rotation @ ${ORIG_FB_ROTA}" >>crash.log 2>&1 ./fbdepth -d "${ORIG_FB_BPP}" -r "${ORIG_FB_ROTA}" >>crash.log 2>&1 diff --git a/platform/remarkable/spinning_zsync b/platform/remarkable/spinning_zsync index 73ee2d969..638bc3cdb 100755 --- a/platform/remarkable/spinning_zsync +++ b/platform/remarkable/spinning_zsync @@ -20,6 +20,9 @@ fbink_wrapped() { QTFB_SHIM_MODE="N_RGB565" \ QTFB_SHIM_RESPECT_FULL_REFRESH_REQUESTS="1" \ ./fbink "$@" + elif [ -n "${KO_USE_BLIGHT}" ]; then + # fbink can't do deferred rendering via blight-client (each invocation creates a separate surface) + true else ./fbink "$@" fi