Add support for rm2fb

This commit is contained in:
Dan Shick 2021-01-04 20:54:20 -05:00
parent 3187c03e88
commit 42f0dd116d
2 changed files with 24 additions and 14 deletions

View File

@ -98,10 +98,16 @@ case "$rm_version" in
pixel_format="rgb565le" pixel_format="rgb565le"
;; ;;
"reMarkable 2.0") "reMarkable 2.0")
pixel_format="gray8" if ssh_cmd "[ -f /dev/shm/swtfb.01 ]"; then
width=1872 width=1404
height=1404 height=1872
video_filters="$video_filters,transpose=2" pixel_format="rgb565le"
else
width=1872
height=1404
pixel_format="gray8"
video_filters="$video_filters,transpose=2"
fi
;; ;;
*) *)
echo "Unsupported reMarkable version: $rm_version." echo "Unsupported reMarkable version: $rm_version."
@ -123,7 +129,7 @@ if ! lz4 -V >/dev/null; then
fi fi
# check if restream binay is present on remarkable # check if restream binay is present on remarkable
if ssh_cmd "[ ! -f ~/restream ]"; then if ssh_cmd "[ ! -f ~/restream ] && [ ! -f /opt/bin/restream ]"; then
echo "The restream binary is not installed on your reMarkable." echo "The restream binary is not installed on your reMarkable."
echo "Please install it using the instruction in the README:" echo "Please install it using the instruction in the README:"
echo "https://github.com/rien/reStream/#installation" echo "https://github.com/rien/reStream/#installation"
@ -180,7 +186,7 @@ fi
set -e # stop if an error occurs set -e # stop if an error occurs
# shellcheck disable=SC2086 # shellcheck disable=SC2086
ssh_cmd "./restream" \ ssh_cmd 'PATH="$PATH:/opt/bin/:." restream' \
| $decompress \ | $decompress \
| $host_passthrough \ | $host_passthrough \
| "$output_cmd" \ | "$output_cmd" \

View File

@ -7,25 +7,29 @@ use lz_fear::CompressionSettings;
use std::default::Default; use std::default::Default;
use std::fs::File; use std::fs::File;
use std::path::Path;
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom}; use std::io::{BufRead, BufReader, Read, Seek, SeekFrom};
use std::process::Command; use std::process::Command;
fn main() -> Result<()> { fn main() -> Result<()> {
let version = remarkable_version()?; let version = remarkable_version()?;
let height = 1872;
let streamer = if version == "reMarkable 1.0\n" { let streamer = if version == "reMarkable 1.0\n" {
let width = 1408; let width = 1408;
let height = 1872;
let bytes_per_pixel = 2; let bytes_per_pixel = 2;
ReStreamer::init("/dev/fb0", 0, width, height, bytes_per_pixel)? ReStreamer::init("/dev/fb0", 0, width, height, bytes_per_pixel)?
} else if version == "reMarkable 2.0\n" { } else if version == "reMarkable 2.0\n" {
let width = 1404; let width = 1404;
let height = 1872; if Path::new("/dev/shm/swtfb.01").exists() {
let bytes_per_pixel = 1; let bytes_per_pixel = 2;
ReStreamer::init("/dev/shm/swtfb.01", 0, width, height, bytes_per_pixel)?
let pid = xochitl_pid()?; } else {
let offset = rm2_fb_offset(pid)?; let bytes_per_pixel = 1;
let mem = format!("/proc/{}/mem", pid); let pid = xochitl_pid()?;
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)? let offset = rm2_fb_offset(pid)?;
let mem = format!("/proc/{}/mem", pid);
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)?
}
} else { } else {
Err(anyhow!( Err(anyhow!(
"Unknown reMarkable version: {}\nPlease open a feature request to support your device.", "Unknown reMarkable version: {}\nPlease open a feature request to support your device.",