about summary refs log tree commit diff
path: root/fakefbdev/SharedBuffer.h
blob: 8c966689c0d4266b77bfe2e860decfe7f476d648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <cstdint>

constexpr int fb_width = 1404;
constexpr int fb_height = 1872;
constexpr int fb_pixel_size = sizeof(uint16_t);

// this is the number of bytes that xochitl mmaps() from the framebuffer.
// MIGHT CHANGE BETWEEN XOCHITL VERSIONS!
// the below value was extracted from xochitl 3.10.2.2063.
//
// to figure out this value, decompile xochitl using ghidra and
// - search for the string "Error writing variable information"
// - this string should be used in a call to perror() which is contained
//   in the if-part of a branch
// - look for the corresponding else-branch: the first statement should be
//   a call to mmap() with the below size.
// (of course, these instruction might become outdated if remarkable folks
// rewrite this part of xochitl :/)
constexpr int fb_size = 0x17bd800;

constexpr auto default_fb_name = "/rm2fb.01";

// TODO: use unistdpp
struct SharedFB {
  int fd = -1;
  uint16_t* mem = nullptr;

  SharedFB(const char* path);
  ~SharedFB();

  SharedFB(const SharedFB& other) = delete;
  SharedFB& operator=(const SharedFB& other) = delete;

  SharedFB(SharedFB&& other) noexcept;
  SharedFB& operator=(SharedFB&& other) noexcept;
};