diff options
author | root <root@no.no.james.local> | 2015-12-28 11:27:14 +0000 |
---|---|---|
committer | root <root@no.no.james.local> | 2015-12-28 11:27:14 +0000 |
commit | 2ad7917a466655a2e8907ff73cdef4c8ea266872 (patch) | |
tree | dc45ec2cc0615b5047e0f7945146d1b537830398 /eink_full_monochrome.c | |
parent | c7cb971cd394ac9c66174a3c07e50bfc4fcd6e7a (diff) | |
download | kobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.tar.gz kobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.tar.bz2 kobo-tools-2ad7917a466655a2e8907ff73cdef4c8ea266872.zip |
fix for different screen sizes
Diffstat (limited to 'eink_full_monochrome.c')
-rw-r--r-- | eink_full_monochrome.c | 46 |
1 files changed, 29 insertions, 17 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; } |