Hello, I'm currently working on porting KOReader to the Kobo Glo.
I've cleaned the code enough so that I think it could be integrated in mainline; as of now, I can paint the screen without problems, I still need to work on the touch screen input part.
This is the patch that adds support for painting the screen on Kobos (every model, I suppose):
diff --git a/djvulibre b/djvulibre
--- a/djvulibre
+++ b/djvulibre
@@ -1 +1 @@
-Subproject commit 01a26bed05c8f5ed36e015d16cc54e52dddcccb7
+Subproject commit 01a26bed05c8f5ed36e015d16cc54e52dddcccb7-dirty
diff --git a/einkfb.c b/einkfb.c
index a3f0755..aea8ac8 100644
--- a/einkfb.c
+++ b/einkfb.c
@@ -105,13 +105,17 @@ inline void fillMxcfbUpdateData(mxcfb_update_data *myarea, FBInfo *fb, lua_State
myarea->update_region.height = luaL_optint(L, 6, fb->vinfo.yres);
myarea->waveform_mode = 257;
myarea->update_marker = 1;
+#ifndef KOBO_PLATFORM
myarea->hist_bw_waveform_mode = 0;
myarea->hist_gray_waveform_mode = 0;
+#endif
myarea->temp = 0x1001;
/*@TODO make the flag configurable from UI,
* this flag invert all the pixels on display 09.01 2013 (houqp)*/
myarea->flags = 0;
- /*myarea->alt_buffer_data.virt_addr = NULL;*/
+#ifdef KOBO_PLATFORM
+ myarea->alt_buffer_data.virt_addr = NULL;
+#endif
myarea->alt_buffer_data.phys_addr = NULL;
myarea->alt_buffer_data.width = 0;
myarea->alt_buffer_data.height = 0;
@@ -217,8 +221,16 @@ static int openFrameBuffer(lua_State *L) {
}
/* mmap the framebuffer */
+#ifndef KOBO_PLATFORM
fb_map_address = mmap(0, fb->finfo.smem_len,
PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0);
+#else
+ /* it seems that fb->finfo.smem_len is unreliable on kobo */
+ // Figure out the size of the screen in bytes
+ fb->fb_size = (fb->vinfo.xres_virtual * fb->vinfo.yres_virtual * fb->vinfo.bits_per_pixel / 8);
+ fb_map_address = mmap(0, fb->fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0);
+#endif
if(fb_map_address == MAP_FAILED) {
return luaL_error(L, "cannot mmap framebuffer");
}
@@ -308,12 +320,22 @@ static int closeFrameBuffer(lua_State *L) {
// should be save if called twice
if(fb->buf != NULL && fb->buf->data != NULL) {
#ifndef EMULATE_READER
+#ifndef KOBO_PLATFORM
if (fb->vinfo.bits_per_pixel != 4) {
munmap(fb->real_buf->data, fb->finfo.smem_len);
free(fb->buf->data);
} else {
munmap(fb->buf->data, fb->finfo.smem_len);
}
+#else
+ if (fb->vinfo.bits_per_pixel != 4) {
+ munmap(fb->real_buf->data, fb->fb_size);
+ free(fb->buf->data);
+ } else {
+ munmap(fb->buf->data, fb->fb_size);
+ }
+#endif
+
close(fb->fd);
#else
free(fb->buf->data);
diff --git a/einkfb.h b/einkfb.h
index b9e23cb..1076e74 100644
--- a/einkfb.h
+++ b/einkfb.h
@@ -46,6 +46,9 @@ typedef struct FBInfo {
struct fb_fix_screeninfo finfo;
#endif
struct fb_var_screeninfo vinfo;
+#ifdef KOBO_PLATFORM
+ size_t fb_size;
+#endif
} FBInfo;
int luaopen_einkfb(lua_State *L);
diff --git a/include/mxcfb.h b/include/mxcfb.h
index a933ef1..095188d 100644
--- a/include/mxcfb.h
+++ b/include/mxcfb.h
@@ -99,8 +99,10 @@ struct mxcfb_rect {
#define FB_TEMP_AUTO_UPDATE_DISABLE -1
struct mxcfb_alt_buffer_data {
+#ifdef KOBO_PLATFORM
/* virt_addr is not included in amazon's source */
- /* void *virt_addr; */
+ void *virt_addr;
+#endif
__u32 phys_addr;
__u32 width; /* width of entire buffer */
__u32 height; /* height of entire buffer */
@@ -112,8 +114,11 @@ struct mxcfb_update_data {
__u32 waveform_mode;
__u32 update_mode;
__u32 update_marker;
+#ifndef KOBO_PLATFORM
+ /* these two fields have been added by amazon */
__u32 hist_bw_waveform_mode;
__u32 hist_gray_waveform_mode;
+#endif
int temp;
uint flags;
struct mxcfb_alt_buffer_data alt_buffer_data;
diff --git a/kpvcrlib/crengine b/kpvcrlib/crengine
--- a/kpvcrlib/crengine
+++ b/kpvcrlib/crengine
@@ -1 +1 @@
-Subproject commit 79ef67e1538ef431d6531a3aed5617946ed1d20f
+Subproject commit 79ef67e1538ef431d6531a3aed5617946ed1d20f-dirty
diff --git a/libk2pdfopt b/libk2pdfopt
--- a/libk2pdfopt
+++ b/libk2pdfopt
@@ -1 +1 @@
-Subproject commit 1213a24bfbc9045038cd87ffe75132ead5e94139
+Subproject commit 1213a24bfbc9045038cd87ffe75132ead5e94139-dirty
diff --git a/mupdf b/mupdf
--- a/mupdf
+++ b/mupdf
@@ -1 +1 @@
-Subproject commit 05219d086a5136ee19f643cf062bd5c0d3aef5d3
+Subproject commit 05219d086a5136ee19f643cf062bd5c0d3aef5d3-dirty
diff --git a/sdcv-0.4.2 b/sdcv-0.4.2
--- a/sdcv-0.4.2
+++ b/sdcv-0.4.2
@@ -1 +1 @@
-Subproject commit 5077101aaef1ffd9aad8db3600d9365a21b7e457
+Subproject commit 5077101aaef1ffd9aad8db3600d9365a21b7e457-dirty
(diff against current koreader-base module).
I'm not familiar with makefiles to add an option like "make kobo" that can pass the appropriate flag to define KOBO_PLATFORM, so if someone is willing to commit this and add the relevant changes to the Makefile, that would be great!