summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@no.no.james.local>2015-12-28 11:27:14 +0000
committerroot <root@no.no.james.local>2015-12-28 11:27:14 +0000
commit2ad7917a466655a2e8907ff73cdef4c8ea266872 (patch)
treedc45ec2cc0615b5047e0f7945146d1b537830398
parentc7cb971cd394ac9c66174a3c07e50bfc4fcd6e7a (diff)
downloadkobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.tar.gz
kobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.tar.bz2
kobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.zip
fix for different screen sizes
-rw-r--r--eink_full_monochrome.c46
-rw-r--r--eink_full_update.c52
2 files changed, 61 insertions, 37 deletions
diff --git a/eink_full_monochrome.c b/eink_full_monochrome.c
index da4ecaa..ceaaf20 100644
--- a/eink_full_monochrome.c
+++ b/eink_full_monochrome.c
@@ -4,25 +4,37 @@
#include "mxcfb.h"
#include <linux/fb.h>
-
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- struct mxcfb_update_data update_data = {
- 0, 0, 800, 600,
- WAVEFORM_MODE_AUTO,
- };
- update_data.update_mode = UPDATE_MODE_PARTIAL;
- update_data.flags = EPDC_FLAG_FORCE_MONOCHROME;
+ struct fb_var_screeninfo info = { 0 };
+ struct mxcfb_update_data update_data = { 0 };
+ int fd;
+
+ fd = open ("/dev/fb0", O_RDWR);
+ if (fd == -1) {
+ perror ("open");
+ return 1;
+ }
+
+ if (ioctl (fd, FBIOGET_VSCREENINFO, &info)) {
+ perror ("FBIOGET_VSCREENINFO");
+ return 1;
+ }
+
+ update_data.waveform_mode = WAVEFORM_MODE_AUTO,
+ update_data.update_region.width =
+ info.xres_virtual ? info.xres_virtual : info.xres;
+ update_data.update_region.height =
+ info.yres_virtual ? info.yres_virtual : info.yres;
+ update_data.update_mode = UPDATE_MODE_PARTIAL;
+ update_data.flags = EPDC_FLAG_FORCE_MONOCHROME;
- int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */
- if (framebuffer != -1)
- {
- ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE);
- ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data);
- close(framebuffer);
+ ioctl (fd, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE);
+ ioctl (fd, MXCFB_SEND_UPDATE, &update_data);
+ close (fd);
- printf("E-ink display fully updated (monochrome).\n");
- }
- return 0;
+ printf("E-ink display fully updated (monochrome).\n");
+ return 0;
}
diff --git a/eink_full_update.c b/eink_full_update.c
index 396de57..42118e2 100644
--- a/eink_full_update.c
+++ b/eink_full_update.c
@@ -1,28 +1,40 @@
#include <stdio.h>
#include <sys/ioctl.h>
-#include <fcntl.h>
+#include <fcntl.h>
#include "mxcfb.h"
#include <linux/fb.h>
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- struct mxcfb_update_data update_data = {
- 0, 0, 800, 600,
- WAVEFORM_MODE_AUTO,
- };
- update_data.update_mode = UPDATE_MODE_FULL;
-
-
- int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */
- if (framebuffer != -1)
- {
- ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE);
- ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data);
- close(framebuffer);
-
- printf("E-ink display fully updated.\n");
- }
- return 0;
-}
+ struct fb_var_screeninfo info = { 0 };
+ struct mxcfb_update_data update_data = { 0 };
+ int fd;
+
+ fd = open ("/dev/fb0", O_RDWR);
+ if (fd == -1) {
+ perror ("open");
+ return 1;
+ }
+
+ if (ioctl (fd, FBIOGET_VSCREENINFO, &info)) {
+ perror ("FBIOGET_VSCREENINFO");
+ return 1;
+ }
+
+ update_data.waveform_mode = WAVEFORM_MODE_AUTO,
+ update_data.update_region.width =
+ info.xres_virtual ? info.xres_virtual : info.xres;
+ update_data.update_region.height =
+ info.yres_virtual ? info.yres_virtual : info.yres;
+ update_data.update_mode = UPDATE_MODE_FULL;
+
+ ioctl (fd, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE);
+ ioctl (fd, MXCFB_SEND_UPDATE, &update_data);
+ close (fd);
+
+ printf ("E-ink display fully updated.\n");
+ return 0;
+}