From c7dabfd1668df51462a613ec6021dd6c259ead40 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 17:22:01 +0200 Subject: [PATCH 01/10] Play with the refresh code a bit... --- ffi/framebuffer_linux.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ffi/framebuffer_linux.lua b/ffi/framebuffer_linux.lua index 04e399639..de192cc0b 100644 --- a/ffi/framebuffer_linux.lua +++ b/ffi/framebuffer_linux.lua @@ -34,9 +34,11 @@ local function mxc_update(fb, refarea, refreshtype, waveform_mode, x, y, w, h) refarea[0].update_region.height = h or fb.vinfo.yres refarea[0].update_marker = 1 refarea[0].temp = 0x1000 + -- NOTE: lab126 uses 0x1001, Papyrus on Touch, Auto on PW2 -- TODO make the flag configurable from UI, - -- this flag invert all the pixels on display 09.01 2013 (houqp) + -- f.g., the EPDC_FLAG_ENABLE_INVERSION flag inverts all the pixels on display 09.01 2013 (houqp) refarea[0].flags = 0 + -- NOTE: related to EPDC_FLAG_USE_ALT_BUFFER? refarea[0].alt_buffer_data.phys_addr = 0 refarea[0].alt_buffer_data.width = 0 refarea[0].alt_buffer_data.height = 0 @@ -49,7 +51,7 @@ end local function k51_update(fb, refreshtype, waveform_mode, x, y, w, h) local refarea = ffi.new("struct mxcfb_update_data[1]") - -- only for Amazon's driver: + -- only for Amazon's driver (NOTE: related to debugPaint prefbw & prefgray?): refarea[0].hist_bw_waveform_mode = 0 refarea[0].hist_gray_waveform_mode = 0 @@ -176,7 +178,7 @@ function framebuffer_mt:setOrientation(mode) | | +--------------+ 0 - --]] + --]] if mode == 1 then mode = 2 elseif mode == 2 then @@ -190,6 +192,7 @@ function framebuffer_mt.__index:refresh(refreshtype, waveform_mode, x, y, w, h) w, x = BB.checkBounds(w or self.bb:getWidth(), x or 0, 0, self.bb:getWidth(), 0xFFFF) h, y = BB.checkBounds(h or self.bb:getHeight(), y or 0, 0, self.bb:getHeight(), 0xFFFF) x, y, w, h = self.bb:getPhysicalRect(x, y, w, h) + print("# fb.refresh(): mode="..refreshtype.." wvf="..waveform_mode.." x="..x.." y="..y.." w="..w.." h="..h) self:einkUpdateFunc(refreshtype, waveform_mode, x, y, w, h) end From 79183fdda984111cdb8bb48fda46869d84514bf5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:05:04 +0200 Subject: [PATCH 02/10] Kill debug --- ffi/framebuffer_linux.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ffi/framebuffer_linux.lua b/ffi/framebuffer_linux.lua index de192cc0b..7c21b40b3 100644 --- a/ffi/framebuffer_linux.lua +++ b/ffi/framebuffer_linux.lua @@ -189,10 +189,9 @@ function framebuffer_mt:setOrientation(mode) end function framebuffer_mt.__index:refresh(refreshtype, waveform_mode, x, y, w, h) - w, x = BB.checkBounds(w or self.bb:getWidth(), x or 0, 0, self.bb:getWidth(), 0xFFFF) - h, y = BB.checkBounds(h or self.bb:getHeight(), y or 0, 0, self.bb:getHeight(), 0xFFFF) + w, x = BB.checkBounds(w or self.bb:getWidth(), x or 0, 0, self.bb:getWidth(), 0xFFFF) + h, y = BB.checkBounds(h or self.bb:getHeight(), y or 0, 0, self.bb:getHeight(), 0xFFFF) x, y, w, h = self.bb:getPhysicalRect(x, y, w, h) - print("# fb.refresh(): mode="..refreshtype.." wvf="..waveform_mode.." x="..x.." y="..y.." w="..w.." h="..h) self:einkUpdateFunc(refreshtype, waveform_mode, x, y, w, h) end From a6d86c071b8b4f9a5524b1ca784ff836955a3442 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:13:04 +0200 Subject: [PATCH 03/10] That looks wrong. Yay if I make everything go 'splodey! --- ffi-cdecl/include/mxcfb-kindle.h | 3 ++- ffi-cdecl/mxcfb_kindle_decl.c | 2 -- ffi-cdecl/mxcfb_kobo_decl.c | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ffi-cdecl/include/mxcfb-kindle.h b/ffi-cdecl/include/mxcfb-kindle.h index 4805165de..e30f54f60 100644 --- a/ffi-cdecl/include/mxcfb-kindle.h +++ b/ffi-cdecl/include/mxcfb-kindle.h @@ -128,7 +128,8 @@ struct mxcfb_update_data { typedef struct mxcfb_update_data mxcfb_update_data; /* this is only used in kindle firmware 5.0, later version (5.1) has changed - * the struct to mxcfb_update_data (see above) */ + * the struct to mxcfb_update_data (see above). + * We don't actually support this, it's just kept here for shit'n giggle ;) */ struct mxcfb_update_data_50x { struct mxcfb_rect update_region; __u32 waveform_mode; diff --git a/ffi-cdecl/mxcfb_kindle_decl.c b/ffi-cdecl/mxcfb_kindle_decl.c index 386765914..9bb452694 100644 --- a/ffi-cdecl/mxcfb_kindle_decl.c +++ b/ffi-cdecl/mxcfb_kindle_decl.c @@ -10,9 +10,7 @@ typedef unsigned int uint; cdecl_struct(mxcfb_rect) cdecl_struct(mxcfb_alt_buffer_data) -cdecl_struct(mxcfb_alt_buffer_data_kobo) cdecl_struct(mxcfb_update_data) -cdecl_struct(mxcfb_update_data_kobo) cdecl_const(MXCFB_SEND_UPDATE) diff --git a/ffi-cdecl/mxcfb_kobo_decl.c b/ffi-cdecl/mxcfb_kobo_decl.c index 4f4a98b02..68f5880aa 100644 --- a/ffi-cdecl/mxcfb_kobo_decl.c +++ b/ffi-cdecl/mxcfb_kobo_decl.c @@ -10,9 +10,7 @@ typedef unsigned int uint; cdecl_struct(mxcfb_rect) cdecl_struct(mxcfb_alt_buffer_data) -cdecl_struct(mxcfb_alt_buffer_data_kobo) cdecl_struct(mxcfb_update_data) -cdecl_struct(mxcfb_update_data_kobo) cdecl_const(MXCFB_SEND_UPDATE) From 9f9ab0bc047a18edb4da12b78ae11217032c6e04 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:24:47 +0200 Subject: [PATCH 04/10] Update mxcfb-kindle.h Merge w/ latest Touch kernel (5.3.7.1). --- ffi-cdecl/include/mxcfb-kindle.h | 63 +++++++++++++++++++------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/ffi-cdecl/include/mxcfb-kindle.h b/ffi-cdecl/include/mxcfb-kindle.h index e30f54f60..ae2ef4a04 100644 --- a/ffi-cdecl/include/mxcfb-kindle.h +++ b/ffi-cdecl/include/mxcfb-kindle.h @@ -8,6 +8,8 @@ * - Modified mxcfb_alt_buffer_data struct according to include/linux/mxcfb.h * from Kindle 5.3.0 firmware. Thanks to eureka@mobileread. * http://www.mobileread.com/forums/showpost.php?p=2337118&postcount=818 + * + * - Frankensteined w/ PW2 stuff -- NiLuJe */ /* @@ -78,6 +80,8 @@ struct mxcfb_rect { #define AUTO_UPDATE_MODE_REGION_MODE 0 #define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1 +#define AUTO_UPDATE_MODE_AUTOMATIC_MODE_FULL AUTO_UPDATE_MODE_AUTOMATIC_MODE /* Lab126 */ +#define AUTO_UPDATE_MODE_AUTOMATIC_MODE_PART 2 /* Lab126 */ #define UPDATE_SCHEME_SNAPSHOT 0 #define UPDATE_SCHEME_QUEUE 1 @@ -86,25 +90,29 @@ struct mxcfb_rect { #define UPDATE_MODE_PARTIAL 0x0 #define UPDATE_MODE_FULL 0x1 -#define WAVEFORM_MODE_INIT 0x0 /* Screen goes to white (clears) */ -#define WAVEFORM_MODE_DU 0x1 /* Grey->white/grey->black */ -#define WAVEFORM_MODE_GC16 0x2 /* High fidelity (flashing) */ -#define WAVEFORM_MODE_GC4 WAVEFORM_MODE_GC16 /* For compatibility */ -#define WAVEFORM_MODE_GC16_FAST 0x3 /* Medium fidelity */ -#define WAVEFORM_MODE_A2 0x4 /* Faster but even lower fidelity */ -#define WAVEFORM_MODE_GL16 0x5 /* High fidelity from white transition */ -#define WAVEFORM_MODE_GL16_FAST 0x6 /* Medium fidelity from white transition */ +#define WAVEFORM_MODE_INIT 0x0 /* Screen goes to white (clears) */ +#define WAVEFORM_MODE_DU 0x1 /* Grey->white/grey->black */ +#define WAVEFORM_MODE_GC16 0x2 /* High fidelity (flashing) */ +#define WAVEFORM_MODE_GC4 WAVEFORM_MODE_GC16 /* For compatibility */ +#define WAVEFORM_MODE_GC16_FAST 0x3 /* Medium fidelity */ +#define WAVEFORM_MODE_A2 0x4 /* Faster but even lower fidelity */ +#define WAVEFORM_MODE_GL16 0x5 /* High fidelity from white transition */ +#define WAVEFORM_MODE_GL16_FAST 0x6 /* Medium fidelity from white transition */ +/* FW >= 5.3 */ +#define WAVEFORM_MODE_DU4 0x7 /* Medium fidelity 4 level of gray direct update */ + #define WAVEFORM_MODE_AUTO 257 #define TEMP_USE_AMBIENT 0x1000 +#define TEMP_USE_PAPYRUS 0X1001 #define EPDC_FLAG_ENABLE_INVERSION 0x01 #define EPDC_FLAG_FORCE_MONOCHROME 0x02 +#define EPDC_FLAG_USE_CMAP 0x04 #define EPDC_FLAG_USE_ALT_BUFFER 0x100 #define FB_POWERDOWN_DISABLE -1 -#define FB_TEMP_AUTO_UPDATE_DISABLE -1 struct mxcfb_alt_buffer_data { __u32 phys_addr; @@ -118,18 +126,16 @@ struct mxcfb_update_data { __u32 waveform_mode; __u32 update_mode; __u32 update_marker; - /* these two fields have been added by amazon */ - __u32 hist_bw_waveform_mode; - __u32 hist_gray_waveform_mode; + __u32 hist_bw_waveform_mode; /*Lab126: Def bw waveform for hist analysis*/ + __u32 hist_gray_waveform_mode; /*Lab126: Def gray waveform for hist analysis*/ int temp; uint flags; struct mxcfb_alt_buffer_data alt_buffer_data; }; -typedef struct mxcfb_update_data mxcfb_update_data; -/* this is only used in kindle firmware 5.0, later version (5.1) has changed +/* This is only used in kindle firmware 5.0, later version (5.1) has changed * the struct to mxcfb_update_data (see above). - * We don't actually support this, it's just kept here for shit'n giggle ;) */ + * We don't actually support this, it's just kept here for shit'n giggles ;) */ struct mxcfb_update_data_50x { struct mxcfb_rect update_region; __u32 waveform_mode; @@ -150,7 +156,13 @@ struct mxcfb_waveform_modes { int mode_gc4; int mode_gc8; int mode_gc16; + int mode_gc16_fast; int mode_gc32; + int mode_gl16; + int mode_gl16_fast; + int mode_a2; + /* FW >= 5.3 */ + int mode_du4; }; #define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t) @@ -170,20 +182,21 @@ struct mxcfb_waveform_modes { #define MXCFB_SET_WAVEFORM_MODES _IOW('F', 0x2B, struct mxcfb_waveform_modes) #define MXCFB_SET_TEMPERATURE _IOW('F', 0x2C, int32_t) #define MXCFB_SET_AUTO_UPDATE_MODE _IOW('F', 0x2D, __u32) -#define MXCFB_SEND_UPDATE_50X _IOW('F', 0x2E, struct mxcfb_update_data_50x) +#define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data) #define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOW('F', 0x2F, __u32) #define MXCFB_SET_PWRDOWN_DELAY _IOW('F', 0x30, int32_t) #define MXCFB_GET_PWRDOWN_DELAY _IOR('F', 0x31, int32_t) #define MXCFB_SET_UPDATE_SCHEME _IOW('F', 0x32, __u32) -#define MXCFB_GET_PMIC_TEMPERATURE _IOR('F', 0x32, int32_t) -#define MXCFB_SET_BORDER_MODE _IOR('F', 0x33, int32_t) -#define MXCFB_SET_EPD_PWR0_CTRL _IOR('F', 0x34, int32_t) -#define MXCFB_SET_EPD_PWR2_CTRL _IOR('F', 0x35, int32_t) -#define MXCFB_SET_TEMP_AUTO_UPDATE_PERIOD _IOR('F', 0x36, int32_t) -#define MXCFB_SET_MERGE_ON_WAVEFORM_MISMATCH _IOW('F', 0x37, int32_t) - -/* IOCTLs for E-ink panel updates, kindle firmware version >= 5.1 */ -#define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data) +#define MXCFB_SET_PAUSE _IOW('F', 0x33, __u32) +#define MXCFB_GET_PAUSE _IOW('F', 0x34, __u32) +#define MXCFB_SET_RESUME _IOW('F', 0x35, __u32) +#define MXCFB_CLEAR_UPDATE_QUEUE _IOW('F', 0x36, __u32) +#define MXCFB_WAIT_FOR_UPDATE_SUBMISSION _IOW('F', 0x37, __u32) +/* FW >= 5.3 */ +#define MXCFB_GET_TEMPERATURE _IOR('F', 0x38, int32_t) + +/* Deprecated IOCTL for E-ink panel updates, kindle firmware version == 5.0 */ +#define MXCFB_SEND_UPDATE_50X _IOW('F', 0x2E, struct mxcfb_update_data_50x) #ifdef __KERNEL__ From fa1ce15a292888c587ff09e718930f9749d3d9ad Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:36:11 +0200 Subject: [PATCH 05/10] Update mxcfb-kindle.h Frankenstein the PW2 version (5.4.3.2) in... --- ffi-cdecl/include/mxcfb-kindle.h | 107 ++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 8 deletions(-) diff --git a/ffi-cdecl/include/mxcfb-kindle.h b/ffi-cdecl/include/mxcfb-kindle.h index ae2ef4a04..dfa41912b 100644 --- a/ffi-cdecl/include/mxcfb-kindle.h +++ b/ffi-cdecl/include/mxcfb-kindle.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved. * * - Modified by houqp, added mxcfb_update_data struct from GeekMaster's * video player, refer to: @@ -39,6 +39,9 @@ #define FB_SYNC_CLK_IDLE_EN 0x10000000 #define FB_SYNC_SHARP_MODE 0x08000000 #define FB_SYNC_SWAP_RGB 0x04000000 +/* PW2 */ +#define FB_ACCEL_TRIPLE_FLAG 0x00000000 +#define FB_ACCEL_DOUBLE_FLAG 0x00000001 struct mxcfb_gbl_alpha { int enable; @@ -78,8 +81,14 @@ struct mxcfb_rect { #define GRAYSCALE_8BIT 0x1 #define GRAYSCALE_8BIT_INVERTED 0x2 +/* PW2 */ +#define GRAYSCALE_4BIT 0x3 +#define GRAYSCALE_4BIT_INVERTED 0x4 + #define AUTO_UPDATE_MODE_REGION_MODE 0 #define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1 + +/* Touch/PW1 */ #define AUTO_UPDATE_MODE_AUTOMATIC_MODE_FULL AUTO_UPDATE_MODE_AUTOMATIC_MODE /* Lab126 */ #define AUTO_UPDATE_MODE_AUTOMATIC_MODE_PART 2 /* Lab126 */ @@ -98,19 +107,42 @@ struct mxcfb_rect { #define WAVEFORM_MODE_A2 0x4 /* Faster but even lower fidelity */ #define WAVEFORM_MODE_GL16 0x5 /* High fidelity from white transition */ #define WAVEFORM_MODE_GL16_FAST 0x6 /* Medium fidelity from white transition */ + /* FW >= 5.3 */ #define WAVEFORM_MODE_DU4 0x7 /* Medium fidelity 4 level of gray direct update */ +/* PW2 */ +#define WAVEFORM_MODE_REAGL 0x8 /* Ghost compensation waveform */ +#define WAVEFORM_MODE_REAGLD 0x9 /* Ghost compensation waveform with dithering */ + #define WAVEFORM_MODE_AUTO 257 #define TEMP_USE_AMBIENT 0x1000 #define TEMP_USE_PAPYRUS 0X1001 -#define EPDC_FLAG_ENABLE_INVERSION 0x01 -#define EPDC_FLAG_FORCE_MONOCHROME 0x02 -#define EPDC_FLAG_USE_CMAP 0x04 -#define EPDC_FLAG_USE_ALT_BUFFER 0x100 +/* PW2 */ +#define TEMP_USE_AUTO 0x1001 + +#define EPDC_FLAG_ENABLE_INVERSION 0x01 +#define EPDC_FLAG_FORCE_MONOCHROME 0x02 +#define EPDC_FLAG_USE_CMAP 0x04 +#define EPDC_FLAG_USE_ALT_BUFFER 0x100 + +/* PW2 */ +#define EPDC_FLAG_TEST_COLLISION 0x200 +#define EPDC_FLAG_GROUP_UPDATE 0x400 +#define EPDC_FLAG_FORCE_Y2 0x800 +#define EPDC_FLAG_USE_REAGLD 0x1000 +#define EPDC_FLAG_USE_DITHERING_Y1 0x2000 +#define EPDC_FLAG_USE_DITHERING_Y2 0x4000 +#define EPDC_FLAG_USE_DITHERING_Y4 0x8000 + +/* PW2 */ +/* Waveform type as return by MXCFB_GET_WAVEFORM_TYPE ioctl */ +/* This indicates to user-space what is supported by the waveform */ +#define WAVEFORM_TYPE_4BIT 0x1 +#define WAVEFORM_TYPE_5BIT (WAVEFORM_TYPE_4BIT << 1) #define FB_POWERDOWN_DISABLE -1 @@ -133,6 +165,12 @@ struct mxcfb_update_data { struct mxcfb_alt_buffer_data alt_buffer_data; }; +/* PW2 */ +struct mxcfb_update_marker_data { + __u32 update_marker; + __u32 collision_test; +}; + /* This is only used in kindle firmware 5.0, later version (5.1) has changed * the struct to mxcfb_update_data (see above). * We don't actually support this, it's just kept here for shit'n giggles ;) */ @@ -163,6 +201,22 @@ struct mxcfb_waveform_modes { int mode_a2; /* FW >= 5.3 */ int mode_du4; + + /* PW2 */ + /* + * reagl_flow + */ + int mode_reagl; + int mode_reagld; +}; + +/* PW2 */ +/* + * Structure used to define a 5*3 matrix of parameters for + * setting IPU DP CSC module related to this framebuffer. + */ +struct mxcfb_csc_matrix { + int param[5][3]; }; #define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t) @@ -177,32 +231,65 @@ struct mxcfb_waveform_modes { #define MXCFB_GET_DIFMT _IOR('F', 0x2A, u_int32_t) #define MXCFB_GET_FB_BLANK _IOR('F', 0x2B, u_int32_t) #define MXCFB_SET_DIFMT _IOW('F', 0x2C, u_int32_t) +/* PW2 */ +#define MXCFB_CSC_UPDATE _IOW('F', 0x2D, struct mxcfb_csc_matrix) /* IOCTLs for E-ink panel updates */ #define MXCFB_SET_WAVEFORM_MODES _IOW('F', 0x2B, struct mxcfb_waveform_modes) #define MXCFB_SET_TEMPERATURE _IOW('F', 0x2C, int32_t) #define MXCFB_SET_AUTO_UPDATE_MODE _IOW('F', 0x2D, __u32) #define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data) -#define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOW('F', 0x2F, __u32) + +/* This evolved on the PW2... */ +#define MXCFB_WAIT_FOR_UPDATE_COMPLETE_TOUCH _IOW('F', 0x2F, __u32) +/* PW2 */ +#define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOWR('F', 0x2F, struct mxcfb_update_marker_data) + #define MXCFB_SET_PWRDOWN_DELAY _IOW('F', 0x30, int32_t) #define MXCFB_GET_PWRDOWN_DELAY _IOR('F', 0x31, int32_t) #define MXCFB_SET_UPDATE_SCHEME _IOW('F', 0x32, __u32) #define MXCFB_SET_PAUSE _IOW('F', 0x33, __u32) #define MXCFB_GET_PAUSE _IOW('F', 0x34, __u32) #define MXCFB_SET_RESUME _IOW('F', 0x35, __u32) + +/* Touch/PW1 */ #define MXCFB_CLEAR_UPDATE_QUEUE _IOW('F', 0x36, __u32) +/* PW2 */ +#define MXCFB_GET_WORK_BUFFER _IOWR('F', 0x36, unsigned long) + #define MXCFB_WAIT_FOR_UPDATE_SUBMISSION _IOW('F', 0x37, __u32) + /* FW >= 5.3 */ -#define MXCFB_GET_TEMPERATURE _IOR('F', 0x38, int32_t) +#define MXCFB_GET_TEMPERATURE _IOR('F', 0x38, int32_t) + +/* PW2 */ +#define MXCFB_GET_WAVEFORM_TYPE _IOR('F', 0x39, __u32) /* Deprecated IOCTL for E-ink panel updates, kindle firmware version == 5.0 */ #define MXCFB_SEND_UPDATE_50X _IOW('F', 0x2E, struct mxcfb_update_data_50x) #ifdef __KERNEL__ +/* PW2 */ +#define EHWFAULT 901 + extern struct fb_videomode mxcfb_modedb[]; extern int mxcfb_modedb_sz; +/* PW2 */ +enum panel_modes { + PANEL_MODE_E60_CELESTE = 0, + PANEL_MODE_EN060OC1_3CE_225, + PANEL_MODE_ED060TC1_3CE, + PANEL_MODE_COUNT, +}; + +/* PW2 */ +enum { + MXC_DISP_SPEC_DEV = 0, + MXC_DISP_DDC_DEV = 1, +}; + enum { MXCFB_REFRESH_OFF, MXCFB_REFRESH_AUTO, @@ -211,7 +298,11 @@ enum { int mxcfb_set_refresh_mode(struct fb_info *fbi, int mode, struct mxcfb_rect *update_region); - int mxc_elcdif_frame_addr_setup(dma_addr_t phys); + +/* PW2 */ +void mxcfb_elcdif_register_mode(const struct fb_videomode *modedb, + int num_modes, int dev_mode); + #endif /* __KERNEL__ */ #endif From 88e9faa5bbe756e4fca36e378a25ee8d72a42986 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:43:29 +0200 Subject: [PATCH 06/10] Try to figure out the lua ffi stuff... --- ffi-cdecl/mxcfb_kindle_decl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ffi-cdecl/mxcfb_kindle_decl.c b/ffi-cdecl/mxcfb_kindle_decl.c index 9bb452694..0d76c9cfe 100644 --- a/ffi-cdecl/mxcfb_kindle_decl.c +++ b/ffi-cdecl/mxcfb_kindle_decl.c @@ -14,3 +14,8 @@ cdecl_struct(mxcfb_update_data) cdecl_const(MXCFB_SEND_UPDATE) +/* Needed for REAGL on PW2? */ +//cdecl_struct(mxcfb_update_marker_data) +//cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) +//cdecl_const(MXCFB_WAIT_FOR_UPDATE_SUBMISSION) + From 5ca03c239ce9950f0f8d355848a93084154b25e7 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:56:55 +0200 Subject: [PATCH 07/10] Whee, refresh the ffi-cdecl stuff --- ffi-cdecl/mxcfb_kindle_decl.c | 6 +++--- ffi/mxcfb_kindle_h.lua | 8 ++++++-- ffi/mxcfb_kobo_h.lua | 4 +--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ffi-cdecl/mxcfb_kindle_decl.c b/ffi-cdecl/mxcfb_kindle_decl.c index 0d76c9cfe..b38651f84 100644 --- a/ffi-cdecl/mxcfb_kindle_decl.c +++ b/ffi-cdecl/mxcfb_kindle_decl.c @@ -15,7 +15,7 @@ cdecl_struct(mxcfb_update_data) cdecl_const(MXCFB_SEND_UPDATE) /* Needed for REAGL on PW2? */ -//cdecl_struct(mxcfb_update_marker_data) -//cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) -//cdecl_const(MXCFB_WAIT_FOR_UPDATE_SUBMISSION) +cdecl_struct(mxcfb_update_marker_data) +cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) +cdecl_const(MXCFB_WAIT_FOR_UPDATE_SUBMISSION) diff --git a/ffi/mxcfb_kindle_h.lua b/ffi/mxcfb_kindle_h.lua index 112e2af4d..404f7fad2 100644 --- a/ffi/mxcfb_kindle_h.lua +++ b/ffi/mxcfb_kindle_h.lua @@ -12,7 +12,6 @@ struct mxcfb_alt_buffer_data { unsigned int height; struct mxcfb_rect alt_update_region; }; -struct mxcfb_alt_buffer_data_kobo; struct mxcfb_update_data { struct mxcfb_rect update_region; unsigned int waveform_mode; @@ -24,6 +23,11 @@ struct mxcfb_update_data { unsigned int flags; struct mxcfb_alt_buffer_data alt_buffer_data; }; -struct mxcfb_update_data_kobo; static const int MXCFB_SEND_UPDATE = 1078478382; +struct mxcfb_update_marker_data { + unsigned int update_marker; + unsigned int collision_test; +}; +static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = -1073199569; +static const int MXCFB_WAIT_FOR_UPDATE_SUBMISSION = 1074021943; ]] diff --git a/ffi/mxcfb_kobo_h.lua b/ffi/mxcfb_kobo_h.lua index 46fd8474c..a0c0a97a0 100644 --- a/ffi/mxcfb_kobo_h.lua +++ b/ffi/mxcfb_kobo_h.lua @@ -13,7 +13,6 @@ struct mxcfb_alt_buffer_data { unsigned int height; struct mxcfb_rect alt_update_region; }; -struct mxcfb_alt_buffer_data_kobo; struct mxcfb_update_data { struct mxcfb_rect update_region; unsigned int waveform_mode; @@ -23,6 +22,5 @@ struct mxcfb_update_data { unsigned int flags; struct mxcfb_alt_buffer_data alt_buffer_data; }; -struct mxcfb_update_data_kobo; -static const int MXCFB_SEND_UPDATE = 0x4044462e; +static const int MXCFB_SEND_UPDATE = 1078216238; ]] From 4ac0712d68a5368257f48f9c1f00b2c9ba2bdd60 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 20:37:12 +0200 Subject: [PATCH 08/10] Most important commit ever. --- ffi/framebuffer_linux.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffi/framebuffer_linux.lua b/ffi/framebuffer_linux.lua index 7c21b40b3..b1240bdf8 100644 --- a/ffi/framebuffer_linux.lua +++ b/ffi/framebuffer_linux.lua @@ -36,7 +36,7 @@ local function mxc_update(fb, refarea, refreshtype, waveform_mode, x, y, w, h) refarea[0].temp = 0x1000 -- NOTE: lab126 uses 0x1001, Papyrus on Touch, Auto on PW2 -- TODO make the flag configurable from UI, - -- f.g., the EPDC_FLAG_ENABLE_INVERSION flag inverts all the pixels on display 09.01 2013 (houqp) + -- e.g., the EPDC_FLAG_ENABLE_INVERSION flag inverts all the pixels on display 09.01 2013 (houqp) refarea[0].flags = 0 -- NOTE: related to EPDC_FLAG_USE_ALT_BUFFER? refarea[0].alt_buffer_data.phys_addr = 0 From 831c2281901045bfb1e230fee934d8cfd13aac01 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 00:00:10 +0200 Subject: [PATCH 09/10] More Kindle screen refresh tweaks. Use the same temp flag as Amazon on Touch devices. --- ffi/framebuffer_linux.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ffi/framebuffer_linux.lua b/ffi/framebuffer_linux.lua index b1240bdf8..74b3baa19 100644 --- a/ffi/framebuffer_linux.lua +++ b/ffi/framebuffer_linux.lua @@ -33,8 +33,6 @@ local function mxc_update(fb, refarea, refreshtype, waveform_mode, x, y, w, h) refarea[0].update_region.width = w or fb.vinfo.xres refarea[0].update_region.height = h or fb.vinfo.yres refarea[0].update_marker = 1 - refarea[0].temp = 0x1000 - -- NOTE: lab126 uses 0x1001, Papyrus on Touch, Auto on PW2 -- TODO make the flag configurable from UI, -- e.g., the EPDC_FLAG_ENABLE_INVERSION flag inverts all the pixels on display 09.01 2013 (houqp) refarea[0].flags = 0 @@ -54,14 +52,18 @@ local function k51_update(fb, refreshtype, waveform_mode, x, y, w, h) -- only for Amazon's driver (NOTE: related to debugPaint prefbw & prefgray?): refarea[0].hist_bw_waveform_mode = 0 refarea[0].hist_gray_waveform_mode = 0 + -- TEMP_USE_PAPYRUS on Touch/PW1, TEMP_USE_AUTO on PW2 + refarea[0].temp = 0x1001 return mxc_update(fb, refarea, refreshtype, waveform_mode, x, y, w, h) end local function kobo_update(fb, refreshtype, waveform_mode, x, y, w, h) local refarea = ffi.new("struct mxcfb_update_data[1]") - -- only for Kobo driver: + -- only for Kobo's driver: refarea[0].alt_buffer_data.virt_addr = nil + -- TEMP_USE_AMBIENT + refarea[0].temp = 0x1000 return mxc_update(fb, refarea, refreshtype, waveform_mode, x, y, w, h) end From aa7f2f169b43d1a901e054d79e44e9fb928d6cd7 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 00:36:24 +0200 Subject: [PATCH 10/10] Get rid of redundant output. By checking waitpid's return value properly. --- input.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/input.c b/input.c index 083142403..dbee9a9c4 100644 --- a/input.c +++ b/input.c @@ -161,13 +161,14 @@ static int openInputDevice(lua_State *L) { if (status == -1) { err(EXIT_FAILURE, "pclose_noshell()"); } else { - printf("lipc-wait-event exited with status %d.\n", status); - - if WIFEXITED(status) { - printf("lipc-wait-event exited normally with status: %d.\n", WEXITSTATUS(status)); - } - if WIFSIGNALED(status) { - printf("lipc-wait-event terminated by signal: %d.\n", WTERMSIG(status)); + if (WIFEXITED(status)) { + printf("lipc-wait-event exited normally with status: %d\n", WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + printf("lipc-wait-event was killed by signal %d\n", WTERMSIG(status)); + } else if (WIFSTOPPED(status)) { + printf("lipc-wait-event was stopped by signal %d\n", WSTOPSIG(status)); + } else if (WIFCONTINUED(status)) { + printf("lipc-wait-event continued\n"); } } @@ -192,7 +193,7 @@ static int openInputDevice(lua_State *L) { return luaL_error(L, "cannot initialize SDL."); } SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - /* we only use inputfds[0] in emu mode, because we only have one + /* we only use inputfds[0] in emu mode, because we only have one * fake device so far. */ inputfds[0] = open(inputdevice, O_RDWR | O_NONBLOCK); if (inputfds < 0) {