-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Sony PRS-T* #724
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,10 +38,13 @@ $(TURBOJPEG_LIB) $(JPEG_LIB): $(THIRDPARTY_DIR)/libjpeg-turbo/CMakeLists.txt | |
cd $(JPEG_BUILD_DIR) && \ | ||
$(CMAKE) \ | ||
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF \ | ||
$(if $(findstring armv6, $(ARM_ARCH)),-DWITHOUT_SIMD:BOOL=ON,) \ | ||
$(if $(findstring arm, $(ARM_ARCH)),-DWITHOUT_SIMD:BOOL=ON,) \ | ||
-DCHOST="$(CHOST)" \ | ||
-DCFLAGS="$(CFLAGS)" \ | ||
-DLDFLAGS="$(LDFLAGS)" \ | ||
-DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, libjpeg-turbo is C only, we shouldn't need that. If CMake complains, you have a CMake toolchain setup snafu somewhere earlier ;). |
||
-DCMAKE_CXX_COMPILER_LAUNCHER="$(CMAKE_CXX_COMPILER_LAUNCHER)" \ | ||
-DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \ | ||
-DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \ | ||
-DCMAKE_C_COMPILER_LAUNCHER="$(CMAKE_C_COMPILER_LAUNCHER)" \ | ||
-DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
/* | ||
* Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved. | ||
*/ | ||
|
||
/* | ||
* The code contained herein is licensed under the GNU Lesser General | ||
* Public License. You may obtain a copy of the GNU Lesser General | ||
* Public License Version 2.1 or later at the following locations: | ||
* | ||
* http://www.opensource.org/licenses/lgpl-license.html | ||
* http://www.gnu.org/copyleft/lgpl.html | ||
*/ | ||
|
||
/* | ||
* @file arch-mxc/ mxcfb.h | ||
* | ||
* @brief Global header file for the MXC Frame buffer | ||
* | ||
* @ingroup Framebuffer | ||
*/ | ||
#ifndef __ASM_ARCH_MXCFB_H__ | ||
#define __ASM_ARCH_MXCFB_H__ | ||
|
||
#include <linux/fb.h> | ||
|
||
#define FB_SYNC_OE_LOW_ACT 0x80000000 | ||
#define FB_SYNC_CLK_LAT_FALL 0x40000000 | ||
#define FB_SYNC_DATA_INVERT 0x20000000 | ||
#define FB_SYNC_CLK_IDLE_EN 0x10000000 | ||
#define FB_SYNC_SHARP_MODE 0x08000000 | ||
#define FB_SYNC_SWAP_RGB 0x04000000 | ||
|
||
struct mxcfb_gbl_alpha { | ||
int enable; | ||
int alpha; | ||
}; | ||
|
||
struct mxcfb_loc_alpha { | ||
int enable; | ||
int alpha_in_pixel; | ||
unsigned long alpha_phy_addr0; | ||
unsigned long alpha_phy_addr1; | ||
}; | ||
|
||
struct mxcfb_color_key { | ||
int enable; | ||
__u32 color_key; | ||
}; | ||
|
||
struct mxcfb_pos { | ||
__u16 x; | ||
__u16 y; | ||
}; | ||
|
||
struct mxcfb_gamma { | ||
int enable; | ||
int constk[16]; | ||
int slopek[16]; | ||
}; | ||
|
||
struct mxcfb_rect { | ||
__u32 top; | ||
__u32 left; | ||
__u32 width; | ||
__u32 height; | ||
}; | ||
|
||
#define GRAYSCALE_8BIT 0x1 | ||
#define GRAYSCALE_8BIT_INVERTED 0x2 | ||
|
||
#define AUTO_UPDATE_MODE_REGION_MODE 0 | ||
#define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1 | ||
|
||
#define UPDATE_SCHEME_SNAPSHOT 0 | ||
#define UPDATE_SCHEME_QUEUE 1 | ||
#define UPDATE_SCHEME_QUEUE_AND_MERGE 2 | ||
|
||
#define UPDATE_MODE_PARTIAL 0x0 | ||
#define UPDATE_MODE_FULL 0x1 | ||
|
||
#define WAVEFORM_MODE_AUTO 257 | ||
|
||
#define TEMP_USE_AMBIENT 0x1000 | ||
|
||
#define EPDC_FLAG_ENABLE_INVERSION 0x01 | ||
#define EPDC_FLAG_FORCE_MONOCHROME 0x02 | ||
#define EPDC_FLAG_USE_ALT_BUFFER 0x100 | ||
|
||
#define EPDC_FLAG_SP1_1 0x10000 | ||
#define EPDC_FLAG_SP1_2 0x20000 | ||
|
||
#define FB_POWERDOWN_DISABLE -1 | ||
|
||
/* 2011/03/30 FY11 : Defined max marker value for user process. */ | ||
/* (The value larger than this is for driver.)*/ | ||
#define UPDATE_MARKER_MAX 0x80000000 | ||
|
||
struct mxcfb_alt_buffer_data { | ||
void *virt_addr; | ||
__u32 phys_addr; | ||
__u32 width; /* width of entire buffer */ | ||
__u32 height; /* height of entire buffer */ | ||
struct mxcfb_rect alt_update_region; /* region within buffer to update */ | ||
}; | ||
|
||
struct mxcfb_update_data { | ||
struct mxcfb_rect update_region; | ||
__u32 waveform_mode; | ||
__u32 update_mode; | ||
__u32 update_marker; | ||
int temp; | ||
uint flags; | ||
struct mxcfb_alt_buffer_data alt_buffer_data; | ||
}; | ||
|
||
/* | ||
* Structure used to define waveform modes for driver | ||
* Needed for driver to perform auto-waveform selection | ||
*/ | ||
struct mxcfb_waveform_modes { | ||
int mode_init; | ||
int mode_du; | ||
int mode_gc4; | ||
int mode_gc8; | ||
int mode_gc16; | ||
int mode_gc32; | ||
int mode_a2; /* 2011/03/05 FY11 : Supported A2 mode limitations. */ | ||
}; | ||
|
||
|
||
/* 2011/2/24 FY11 : Added waveform version struct. */ | ||
#define WF_VER_LEN 10 | ||
struct mxcfb_waveform_version { | ||
__u8 version[WF_VER_LEN]; | ||
}; | ||
|
||
|
||
/* 2011/03/08 FY11 : Supported to write waveform. */ | ||
struct mxcfb_waveform_data | ||
{ | ||
__u32 uiSize; | ||
__u8 *pcData; | ||
}; | ||
|
||
|
||
#define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t) | ||
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha) | ||
#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key) | ||
#define MXCFB_SET_OVERLAY_POS _IOWR('F', 0x24, struct mxcfb_pos) | ||
#define MXCFB_GET_FB_IPU_CHAN _IOR('F', 0x25, u_int32_t) | ||
#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha) | ||
#define MXCFB_SET_LOC_ALP_BUF _IOW('F', 0x27, unsigned long) | ||
#define MXCFB_SET_GAMMA _IOW('F', 0x28, struct mxcfb_gamma) | ||
#define MXCFB_GET_FB_IPU_DI _IOR('F', 0x29, u_int32_t) | ||
#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) | ||
|
||
/* 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) | ||
#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', 0x33, int32_t) | ||
#define MXCFB_SET_BORDER_MODE _IOR('F', 0x34, int32_t) | ||
#define MXCFB_SET_EPD_PWR0_CTRL _IOR('F', 0x35, int32_t) | ||
#define MXCFB_SET_EPD_PWR2_CTRL _IOR('F', 0x36, int32_t) | ||
|
||
/* 2011/1/19 FY11 : Added commands to read/write VCOM. */ | ||
#define MXCFB_SET_VCOM _IOW('F', 0x37, __u32) | ||
#define MXCFB_GET_VCOM _IOR('F', 0x38, __u32) | ||
|
||
/* 2011/2/24 FY11 : Added commands to read waveform version. */ | ||
#define MXCFB_GET_WF_VERSION _IOR('F', 0x39, struct mxcfb_waveform_version) | ||
/* 2011/03/08 FY11 : Supported to write waveform. */ | ||
#define MXCFB_WRITE_WF _IOW('F', 0x3A, struct mxcfb_waveform_data) | ||
/* 2011/03/30 FY11 : Supported to write standby screen image. */ | ||
#define MXCFB_WRITE_SSCREEN _IOW('F', 0x3B, __u8*) | ||
/* 2011/04/12 FY11 : Supported to write panel init flag. */ | ||
#define MXCFB_SET_PANELINIT _IOW('F', 0x3C, __u8) | ||
|
||
/* 2012/02/03 : Add pending function. */ | ||
#define MXCFB_SET_PENDING _IOW('F', 0x3E, __u8) | ||
|
||
#ifdef __KERNEL__ | ||
|
||
extern struct fb_videomode mxcfb_modedb[]; | ||
extern int mxcfb_modedb_sz; | ||
|
||
enum { | ||
MXCFB_REFRESH_OFF, | ||
MXCFB_REFRESH_AUTO, | ||
MXCFB_REFRESH_PARTIAL, | ||
}; | ||
|
||
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); | ||
|
||
#endif /* __KERNEL__ */ | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// standard Linux framebuffer headers | ||
#include <linux/fb.h> | ||
|
||
#include <linux/ioctl.h> | ||
// specialized eink framebuffer headers | ||
#include "include/mxcfb-sony.h" | ||
|
||
#include "ffi-cdecl.h" | ||
|
||
cdecl_const(UPDATE_MODE_PARTIAL) | ||
cdecl_const(UPDATE_MODE_FULL) | ||
|
||
cdecl_const(WAVEFORM_MODE_AUTO) | ||
cdecl_const(TEMP_USE_AMBIENT) | ||
|
||
cdecl_const(EPDC_FLAG_ENABLE_INVERSION) | ||
cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) | ||
cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) | ||
cdecl_const(EPDC_FLAG_SP1_1) | ||
cdecl_const(EPDC_FLAG_SP1_2) | ||
|
||
cdecl_struct(mxcfb_rect) | ||
cdecl_struct(mxcfb_alt_buffer_data) | ||
cdecl_struct(mxcfb_update_data) | ||
|
||
cdecl_const(MXCFB_SEND_UPDATE) | ||
|
||
cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,12 @@ local function pocketbook_mxc_wait_for_update_complete(fb, marker) | |
return C.ioctl(fb.fd, C.MXCFB_WAIT_FOR_UPDATE_COMPLETE, ffi.new("uint32_t[1]", marker)) | ||
end | ||
|
||
-- Sony PRS MXCFB_WAIT_FOR_UPDATE_COMPLETE | ||
local function prst_mxc_wait_for_update_complete(fb, marker) | ||
-- Wait for the previous update to be completed | ||
return C.ioctl(fb.fd, C.MXCFB_WAIT_FOR_UPDATE_COMPLETE, ffi.new("uint32_t[1]", marker)) | ||
end | ||
|
||
-- Kindle's MXCFB_WAIT_FOR_UPDATE_COMPLETE == 0xc008462f | ||
local function kindle_carta_mxc_wait_for_update_complete(fb, marker, collision_test) | ||
-- Wait for the previous update to be completed | ||
|
@@ -343,6 +349,12 @@ local function refresh_pocketbook(fb, refreshtype, waveform_mode, x, y, w, h) | |
return mxc_update(fb, C.MXCFB_SEND_UPDATE, refarea, refreshtype, waveform_mode, x, y, w, h) | ||
end | ||
|
||
local function refresh_prst(fb, refreshtype, waveform_mode, x, y, w, h) | ||
local refarea = ffi.new("struct mxcfb_update_data[1]") | ||
refarea[0].temp = C.TEMP_USE_AMBIENT | ||
return mxc_update(fb, C.MXCFB_SEND_UPDATE, refarea, refreshtype, waveform_mode, x, y, w, h) | ||
end | ||
|
||
--[[ framebuffer API ]]-- | ||
|
||
function framebuffer:refreshPartialImp(x, y, w, h) | ||
|
@@ -502,6 +514,17 @@ function framebuffer:init() | |
self.waveform_flashui = self.waveform_ui | ||
self.waveform_full = C.WAVEFORM_MODE_GC16 | ||
self.waveform_partial = C.WAVEFORM_MODE_GC16 | ||
elseif self.device:isPRST() then | ||
require("ffi/mxcfb_sony_h") | ||
|
||
self.mech_refresh = refresh_prst | ||
self.mech_wait_update_complete = prst_mxc_wait_for_update_complete | ||
|
||
self.waveform_fast = C.WAVEFORM_MODE_DU | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless there's a platform-specific issue with A2 (like there is on REAGL), we usually go with A2 instead of DU for that ;). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I remember A2 being slower than DU, but I can re-check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, it should be the fastest you can go, at the expense of quality (being basically pure B & W). DU is more lenient, it handles a few shades of gray, and as such should be a tiny bit slower. Since we only use this for pure B&W elements (mainly menu/button highlights), if A2 works, that's better. In practice, there's a few cases where A2 doesn't behave as expected, but that's usually limited to REAGL screens, which I think the T2 predates, so that shouldn't be the case here ;). |
||
self.waveform_ui = C.WAVEFORM_MODE_AUTO | ||
self.waveform_flashui = C.WAVEFORM_MODE_GC16 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the same vein, unless there's a specific platform issue where AUTO doesn't always honor UPDATE_FULL, this should be AUTO too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EDIT: answered above comment here ok, i will change to AUTO. |
||
self.waveform_full = C.WAVEFORM_MODE_GC16 | ||
self.waveform_partial = C.WAVEFORM_MODE_AUTO | ||
else | ||
error("unknown device type") | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
local ffi = require("ffi") | ||
|
||
ffi.cdef[[ | ||
struct mxcfb_rect { | ||
unsigned int top; | ||
unsigned int left; | ||
unsigned int width; | ||
unsigned int height; | ||
}; | ||
|
||
struct mxcfb_alt_buffer_data { | ||
void* virt_addr; | ||
unsigned int phys_addr; | ||
unsigned int width; | ||
unsigned int height; | ||
struct mxcfb_rect alt_update_region; | ||
}; | ||
|
||
struct mxcfb_update_data { | ||
struct mxcfb_rect update_region; | ||
unsigned int waveform_mode; | ||
unsigned int update_mode; | ||
unsigned int update_marker; | ||
int temp; | ||
unsigned int flags; | ||
struct mxcfb_alt_buffer_data alt_buffer_data; | ||
}; | ||
|
||
static const int UPDATE_MODE_PARTIAL = 0; | ||
static const int UPDATE_MODE_FULL = 1; | ||
|
||
static const int WAVEFORM_MODE_INIT = 0; | ||
static const int WAVEFORM_MODE_DU = 1; | ||
static const int WAVEFORM_MODE_GC16 = 2; | ||
static const int WAVEFORM_MODE_GC4 = 3; | ||
static const int WAVEFORM_MODE_A2 = 4; | ||
static const int WAVEFORM_MODE_AUTO = 257; | ||
static const int TEMP_USE_AMBIENT = 4096; | ||
static const int TEMP_USE_AUTO = 4097; // this does not exist, simply use a value different than above | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure I follow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean the comment? I meant there's no actual AUTO constant for temperature in the headers, but looking at the code, if it doesn't receive a AMBIENT setting it will use the temperature sensor. Thus, I simply used a different value for that constant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, thanks! :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, that's interesting ;). I'd add the matching 0x1001 define in the header like we do on Kobo/Kindle, just so that it doesn't get zapped if someone decides to re-run gcc-lua one day ;). |
||
static const int EPDC_FLAG_ENABLE_INVERSION = 1; | ||
static const int EPDC_FLAG_FORCE_MONOCHROME = 2; | ||
static const int EPDC_FLAG_USE_ALT_BUFFER = 256; | ||
|
||
static const int MXCFB_SEND_UPDATE = 1078216238; | ||
static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = 1074021935; | ||
]] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
KOReader: Sony PRST input abstraction for Lua | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef _KO_INPUT_PRST_H | ||
#define _KO_INPUT_PRST_H | ||
|
||
void generateFakeEvent(int pipefd[2]) { | ||
return; | ||
} | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I want SIMD enabled on armv7 ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you had a build issue related to ARM detection, that's to be addressed in the crappy CMakeFile for libjpeg-turbo (there's a bunch of eInk & Android specific cases, it should be somewhat obvious, ping me if that looks too arcane ;)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namely, you probably need to add PRST the ginormous ENV(...) branch ;).