Skip to content

Examples

Can Selcik edited this page Mar 28, 2018 · 2 revisions

For the Rust examples you can use RUST_LOG environment variable to set the debug level. By default you will see no logs. Setting RUST_LOG=info is reasonable. debug will show you the unknown/to-be-implemented events received from input devices.

Partial Redraw Proof of Concept (poc)

Contains the proof of concept for directly interacting with the eInk display driver to perform partial updates.

The key finding here is the magic values and their usage in conjunction with the dumped mxcfb_* data structures. Simply update the framebuffer and then call ioctl on the /dev/fb0 FD with REMARKABLE_PREFIX | MXCFB_SEND_UPDATE in order to quickly the redraw region defined by data.update_region and that region only.

#define REMARKABLE_PREFIX                       0x40484600
#define MXCFB_SEND_UPDATE                       0x0000002e
#define MXCFB_WAIT_FOR_VSYNC                    0x00000020
#define MXCFB_SET_GBL_ALPHA                     0x00000021
#define MXCFB_SET_CLR_KEY                       0x00000022
#define MXCFB_SET_OVERLAY_POS                   0x00000024
#define MXCFB_GET_FB_IPU_CHAN                   0x00000025
#define MXCFB_SET_LOC_ALPHA                     0x00000026
#define MXCFB_SET_LOC_ALP_BUF                   0x00000027
#define MXCFB_SET_GAMMA                         0x00000028
#define MXCFB_GET_FB_IPU_DI                     0x00000029
#define MXCFB_GET_DIFMT                         0x0000002a
#define MXCFB_GET_FB_BLANK                      0x0000002b
#define MXCFB_SET_WAVEFORM_MODES                0x0000002b
#define MXCFB_SET_DIFMT                         0x0000002c
#define MXCFB_SET_TEMPERATURE                   0x0000002c
#define MXCFB_SET_AUTO_UPDATE_MODE              0x0000002d
#define MXCFB_WAIT_FOR_UPDATE_COMPLETE	        0x0000002f
#define MXCFB_SET_PWRDOWN_DELAY	                0x00000030
#define MXCFB_GET_PWRDOWN_DELAY	                0x00000031
#define MXCFB_SET_UPDATE_SCHEME                 0x00000032
#define MXCFB_SET_MERGE_ON_WAVEFORM_MISMATCH    0x00000037

mxcfb_update_data data;
data.update_region.top = 0;
data.update_region.left = 0;
data.update_region.width = vinfo.xres;
data.update_region.height = vinfo.yres;
data.waveform_mode = 0x0002;
data.temp = 0x1001;
data.update_mode = 0x0000;
data.update_marker = 0x002a;
data.flags = 0;
data.alt_buffer_data = NULL;
ioctl(fb, REMARKABLE_PREFIX | MXCFB_SEND_UPDATE, &data);

FrameBuffer Spy

A shared library that intercepts and displays undocumented framebuffer refresh ioctl calls for the Remarkable Paper Tablet. Usage:

$ systemctl stop xochitl
$ LD_PRELOAD=./spy.so xochitl
...
12:06.842 DebugHelperClass    	 void DocumentWorker::loadCachedPage(int) 191 ms (~DebugHelperClass() ../git/src/debug.h:16)
ioctl(3, 0x4048462e, 0x7ea2d290{
   updateRegion: x: 0
                 y: 0
                 width: 1404
                 height: 1872
   waveformMode: 3,
   updateMode:   0
   updateMarker: 45
   temp: 4096
   flags: 0000
   alt_buffer_data: 0x300f30
   ...
}) == 0
12:07.207 DebugHelperClass    	 void DocumentWorker::loadCachedPage(int) 364 ms (~DebugHelperClass() ../git/src/debug.h:16)
12:07.384 DebugHelperClass    	 void DocumentWorker::loadCachedPage(int) 175 ms (~DebugHelperClass() ../git/src/debug.h:16)
12:07.548 DebugHelperClass    	 void DocumentWorker::loadCachedPage(int) 162 ms (~DebugHelperClass() ../git/src/debug.h:16)
12:07.705 DebugHelperClass    	 void DocumentWorker::loadCachedPage(int) 155 ms (~DebugHelperClass() ../git/src/debug.h:16)
ioctl(3, 0x4048462e, 0x7ea2d290{
   updateRegion: x: 0
                 y: 0
                 width: 1404
                 height: 1872
   waveformMode: 3,
   updateMode:   0
   updateMarker: 46
   temp: 4096
   flags: 0000
   alt_buffer_data: 0x300f30
   ...
}) == 0