Skip to content

Commit 8e55e05

Browse files
NiLuJeFrenzie
authored andcommitted
Leave bitness-dependent types alone in FFI stuff (koreader#825)
* Latest Linux headers Not that we care, but, still ;p. * And MuPDF, too... * Resync Cervantes MXCFB headers w/ FBInk The SEND_UPDATE appears to have previously pointed to the Kobo ioctl?! * Duh. That's because I was using an x86_64 compiler. * Tweak that, but the header is incomplete anyway, so, don't refresh it. * And posix... * Refresh SDL 2 (2.0.9, x86_64) * And finally, zmq
1 parent 7233305 commit 8e55e05

14 files changed

+378
-85
lines changed

ffi-cdecl/include/mxcfb-cervantes.h

+255-33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/*
22
* Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved.
33
*
4-
* Unified header for BQ Cervantes/Fnac Touchlight devices.
5-
* https://github.com/bq/cervantes-qt/tree/eink-imx508/src/plugins/gfxdrivers/einkfb
4+
* Unified header for BQ Cervantes/Fnac Touchlight devices
5+
* Heavily based on mxcfb-kobo.h, with some notes from bq kernel sources.
6+
* c.f., https://blog.bq.com/es/bq-ereaders-developers-program/
7+
* When I'm not using the proper model names,
8+
* C1 means the oldest kernel, and C4 the latest.
69
*
710
* The code contained herein is licensed under the GNU Lesser General
811
* Public License. You may obtain a copy of the GNU Lesser General
@@ -19,71 +22,290 @@
1922
*
2023
* @ingroup Framebuffer
2124
*/
22-
2325
#ifndef __ASM_ARCH_MXCFB_H__
2426
#define __ASM_ARCH_MXCFB_H__
2527

28+
//#include <linux/fb.h>
29+
30+
#define FB_SYNC_OE_LOW_ACT 0x80000000
31+
#define FB_SYNC_CLK_LAT_FALL 0x40000000
32+
#define FB_SYNC_DATA_INVERT 0x20000000
33+
#define FB_SYNC_CLK_IDLE_EN 0x10000000
34+
#define FB_SYNC_SHARP_MODE 0x08000000
35+
#define FB_SYNC_SWAP_RGB 0x04000000
36+
37+
// Cervantes 2013/Fnac Touch Light and higher
38+
#define FB_ACCEL_TRIPLE_FLAG 0x00000000
39+
#define FB_ACCEL_DOUBLE_FLAG 0x00000001
40+
41+
struct mxcfb_gbl_alpha {
42+
int enable;
43+
int alpha;
44+
};
45+
46+
struct mxcfb_loc_alpha {
47+
int enable;
48+
int alpha_in_pixel;
49+
unsigned long alpha_phy_addr0;
50+
unsigned long alpha_phy_addr1;
51+
};
52+
53+
struct mxcfb_color_key {
54+
int enable;
55+
__u32 color_key;
56+
};
57+
58+
struct mxcfb_pos {
59+
__u16 x;
60+
__u16 y;
61+
};
62+
63+
struct mxcfb_gamma {
64+
int enable;
65+
int constk[16];
66+
int slopek[16];
67+
};
68+
69+
struct mxcfb_rect {
70+
__u32 top;
71+
__u32 left;
72+
__u32 width;
73+
__u32 height;
74+
};
75+
76+
#define GRAYSCALE_8BIT 0x1
77+
#define GRAYSCALE_8BIT_INVERTED 0x2
78+
// C2+
79+
#define GRAYSCALE_4BIT 0x3
80+
#define GRAYSCALE_4BIT_INVERTED 0x4
81+
82+
#define AUTO_UPDATE_MODE_REGION_MODE 0
83+
#define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1
84+
85+
#define UPDATE_SCHEME_SNAPSHOT 0
86+
#define UPDATE_SCHEME_QUEUE 1
87+
#define UPDATE_SCHEME_QUEUE_AND_MERGE 2
88+
2689
#define UPDATE_MODE_PARTIAL 0x0
2790
#define UPDATE_MODE_FULL 0x1
2891

29-
#define WAVEFORM_MODE_AUTO 257
92+
/* Those are sneaked in in drivers/video/mxc/mxc_epdc_fb.c, same as Kobo */
93+
#define NTX_WFM_MODE_INIT 0
94+
#define NTX_WFM_MODE_DU 1
95+
#define NTX_WFM_MODE_GC16 2
96+
#define NTX_WFM_MODE_GC4 3
97+
#define NTX_WFM_MODE_A2 4
98+
#define NTX_WFM_MODE_GL16 5
99+
#define NTX_WFM_MODE_GLR16 6
100+
#define NTX_WFM_MODE_GLD16 7
101+
#define NTX_WFM_MODE_TOTAL 8
30102

31-
#define TEMP_USE_AMBIENT 0x1000
103+
/* Match 'em to the Kindle ones, for sanity's sake... */
104+
#define WAVEFORM_MODE_INIT NTX_WFM_MODE_INIT
105+
#define WAVEFORM_MODE_DU NTX_WFM_MODE_DU
106+
#define WAVEFORM_MODE_GC4 NTX_WFM_MODE_GC4
107+
#define WAVEFORM_MODE_GC16 NTX_WFM_MODE_GC16
108+
#define WAVEFORM_MODE_A2 NTX_WFM_MODE_A2
109+
#define WAVEFORM_MODE_GL16 NTX_WFM_MODE_GL16
32110

33-
/* from https://github.com/bq/cervantes-qt/blob/eink-imx508/src/plugins/gfxdrivers/einkfb/einkfb.cpp */
34-
#define WAVEFORM_MODE_INIT 0 /* init mode, turn the screen white */
35-
#define WAVEFORM_MODE_DU 1 /* fast 1bit update without flashing */
36-
#define WAVEFORM_MODE_GC16 2 /* High fidelity (flashing) */
37-
#define WAVEFORM_MODE_A2 4 /* Fast page flipping at reduced contrast */
111+
// for Cervantes 2013
112+
#define WAVEFORM_MODE_REAGL NTX_WFM_MODE_GLR16
113+
#define WAVEFORM_MODE_REAGLD NTX_WFM_MODE_GLD16
38114

39-
/* new waveform modes introduced in Cervantes 2013 (from drivers/video/mxc/mxc_epdc_fb.c */
40-
#define WAVEFORM_MODE_GL16 5 /* High fidelity from white transition */
41-
#define WAVEFORM_MODE_GLR16 6 /* Ghost compensation waveform */
42-
#define WAVEFORM_MODE_GLD16 7 /* Ghost compensation waveform with dithering */
115+
// for Cervantes 3+
116+
#define WAVEFORM_MODE_AA NTX_WFM_MODE_GLR16
117+
#define WAVEFORM_MODE_GLR16 NTX_WFM_MODE_GLR16
118+
#define WAVEFORM_MODE_AAD NTX_WFM_MODE_GLD16
119+
#define WAVEFORM_MODE_GLD16 NTX_WFM_MODE_GLD16
43120

44-
/* common flags */
45-
#define EPDC_FLAG_ENABLE_INVERSION 0x01
46-
#define EPDC_FLAG_FORCE_MONOCHROME 0x02
47-
#define EPDC_FLAG_USE_ALT_BUFFER 0x100
121+
#define WAVEFORM_MODE_AUTO 257
48122

49-
/* introduced in Cervantes2013 */
123+
#define TEMP_USE_AMBIENT 0x1000
124+
125+
#define EPDC_FLAG_ENABLE_INVERSION 0x01
126+
#define EPDC_FLAG_FORCE_MONOCHROME 0x02
127+
// C2+
50128
#define EPDC_FLAG_USE_CMAP 0x04
129+
130+
#define EPDC_FLAG_USE_ALT_BUFFER 0x100
131+
// C2+
51132
#define EPDC_FLAG_TEST_COLLISION 0x200
52133
#define EPDC_FLAG_GROUP_UPDATE 0x400
53134
#define EPDC_FLAG_USE_DITHERING_Y1 0x2000
54135
#define EPDC_FLAG_USE_DITHERING_Y4 0x4000
55136

56-
/* introduced in Cervantes3 */
137+
// New stuff (2016+)
57138
#define EPDC_FLAG_USE_AAD 0x1000
58139
#define EPDC_FLAG_USE_DITHERING_NTX_D8 0x100000
59140

60-
struct mxcfb_rect {
61-
__u32 top;
62-
__u32 left;
63-
__u32 width;
64-
__u32 height;
141+
// NOTE: This is *UNSUPPORTED* on current devices!
142+
// We just happen to need these defined to build ;).
143+
enum mxcfb_dithering_mode {
144+
EPDC_FLAG_USE_DITHERING_PASSTHROUGH = 0x0,
145+
EPDC_FLAG_USE_DITHERING_FLOYD_STEINBERG,
146+
EPDC_FLAG_USE_DITHERING_ATKINSON,
147+
EPDC_FLAG_USE_DITHERING_ORDERED,
148+
EPDC_FLAG_USE_DITHERING_QUANT_ONLY,
149+
EPDC_FLAG_USE_DITHERING_MAX,
65150
};
66151

152+
#define FB_POWERDOWN_DISABLE -1
153+
67154
struct mxcfb_alt_buffer_data {
68155
void *virt_addr;
69156
__u32 phys_addr;
70157
__u32 width; /* width of entire buffer */
71158
__u32 height; /* height of entire buffer */
72-
struct mxcfb_rect alt_update_region; /* region within buffer to update */
159+
struct mxcfb_rect alt_update_region; /* region within buffer to update */
73160
};
74161

75162
struct mxcfb_update_data {
76-
struct mxcfb_rect update_region;
77-
__u32 waveform_mode;
78-
__u32 update_mode;
79-
__u32 update_marker;
80-
int temp;
81-
unsigned int flags;
82-
struct mxcfb_alt_buffer_data alt_buffer_data;
163+
struct mxcfb_rect update_region;
164+
__u32 waveform_mode;
165+
__u32 update_mode;
166+
__u32 update_marker;
167+
int temp;
168+
unsigned int flags;
169+
struct mxcfb_alt_buffer_data alt_buffer_data;
83170
};
84171

172+
// NTX Shenanigans, like on the Kobo Aura.
173+
// Apparently applies to the Cervantes 2013 & Cervantes 4, but not the Cervantes 3...
174+
// Use the Cervantes 4 nomenclature, as it matches Kobo.
175+
struct mxcfb_alt_buffer_data_org {
176+
__u32 phys_addr;
177+
__u32 width; /* width of entire buffer */
178+
__u32 height; /* height of entire buffer */
179+
struct mxcfb_rect alt_update_region; /* region within buffer to update */
180+
};
181+
182+
struct mxcfb_update_data_org {
183+
struct mxcfb_rect update_region;
184+
__u32 waveform_mode;
185+
__u32 update_mode;
186+
__u32 update_marker;
187+
int temp;
188+
unsigned int flags;
189+
struct mxcfb_alt_buffer_data_org alt_buffer_data;
190+
};
191+
192+
// C2+
193+
struct mxcfb_update_marker_data {
194+
__u32 update_marker;
195+
__u32 collision_test;
196+
};
197+
198+
/*
199+
* Structure used to define waveform modes for driver
200+
* Needed for driver to perform auto-waveform selection
201+
*/
202+
struct mxcfb_waveform_modes {
203+
int mode_init;
204+
int mode_du;
205+
int mode_gc4;
206+
int mode_gc8;
207+
int mode_gc16;
208+
int mode_gc32;
209+
int mode_aa; // was mode_reagl on Cervantes 2013/Fnac Touch Light
210+
int mode_aad; // was mode_reagld on Cervantes 2013/Fnac Touch Light
211+
int mode_gl16;
212+
int mode_a2;
213+
};
214+
215+
// Cervantes < 2013 ONLY (C1)
216+
struct mxcfb_waveform_modes_old {
217+
int mode_init;
218+
int mode_du;
219+
int mode_gc4;
220+
int mode_gc8;
221+
int mode_gc16;
222+
int mode_gc32;
223+
};
224+
225+
// C2+
226+
/*
227+
* Structure used to define a 5*3 matrix of parameters for
228+
* setting IPU DP CSC module related to this framebuffer.
229+
*/
230+
struct mxcfb_csc_matrix {
231+
int param[5][3];
232+
};
233+
234+
#define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t)
235+
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha)
236+
#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key)
237+
#define MXCFB_SET_OVERLAY_POS _IOWR('F', 0x24, struct mxcfb_pos)
238+
#define MXCFB_GET_FB_IPU_CHAN _IOR('F', 0x25, u_int32_t)
239+
#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha)
240+
#define MXCFB_SET_LOC_ALP_BUF _IOW('F', 0x27, unsigned long)
241+
#define MXCFB_SET_GAMMA _IOW('F', 0x28, struct mxcfb_gamma)
242+
#define MXCFB_GET_FB_IPU_DI _IOR('F', 0x29, u_int32_t)
243+
#define MXCFB_GET_DIFMT _IOR('F', 0x2A, u_int32_t)
244+
#define MXCFB_GET_FB_BLANK _IOR('F', 0x2B, u_int32_t)
245+
#define MXCFB_SET_DIFMT _IOW('F', 0x2C, u_int32_t)
246+
// C3+
247+
#define MXCFB_ENABLE_VSYNC_EVENT _IOW('F', 0x33, int32_t)
248+
// C2+
249+
#define MXCFB_CSC_UPDATE _IOW('F', 0x2D, struct mxcfb_csc_matrix)
250+
85251
/* IOCTLs for E-ink panel updates */
252+
#define MXCFB_SET_WAVEFORM_MODES _IOW('F', 0x2B, struct mxcfb_waveform_modes)
253+
// C1 ONLY
254+
#define MXCFB_SET_WAVEFORM_MODES_OLD _IOW('F', 0x2B, struct mxcfb_waveform_modes_old)
255+
256+
#define MXCFB_SET_TEMPERATURE _IOW('F', 0x2C, int32_t)
257+
#define MXCFB_SET_AUTO_UPDATE_MODE _IOW('F', 0x2D, __u32)
86258
#define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data)
259+
// C2 & C4 ONLY
260+
#define MXCFB_SEND_UPDATE_ORG _IOW('F', 0x2E, struct mxcfb_update_data_org)
261+
87262
#define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOW('F', 0x2F, __u32)
263+
// C2+
264+
// Default if !MX50_COMPAT
265+
#define MXCFB_WAIT_FOR_UPDATE_COMPLETE2 _IOWR('F', 0x35, struct mxcfb_update_marker_data)
266+
// C2 ONLY
267+
#define MXCFB_WAIT_FOR_UPDATE_COMPLETE3 _IOWR('F', 0x2F, struct mxcfb_update_marker_data)
268+
269+
#define MXCFB_SET_PWRDOWN_DELAY _IOW('F', 0x30, int32_t)
270+
#define MXCFB_GET_PWRDOWN_DELAY _IOR('F', 0x31, int32_t)
271+
#define MXCFB_SET_UPDATE_SCHEME _IOW('F', 0x32, __u32)
272+
// C1 ONLY
273+
#define MXCFB_SET_MERGE_ON_WAVEFORM_MISMATCH _IOW('F', 0x37, int32_t)
274+
// C2+
275+
#define MXCFB_GET_WORK_BUFFER _IOWR('F', 0x34, unsigned long)
276+
277+
#ifdef __KERNEL__
278+
279+
extern struct fb_videomode mxcfb_modedb[];
280+
extern int mxcfb_modedb_sz;
281+
282+
enum {
283+
MXC_DISP_SPEC_DEV = 0,
284+
MXC_DISP_DDC_DEV = 1,
285+
};
286+
287+
enum {
288+
MXCFB_REFRESH_OFF,
289+
MXCFB_REFRESH_AUTO,
290+
MXCFB_REFRESH_PARTIAL,
291+
};
292+
293+
int mxcfb_set_refresh_mode(struct fb_info *fbi, int mode,
294+
struct mxcfb_rect *update_region);
295+
// C1 ONLY
296+
void mxcfb_register_mode(int disp_port,
297+
const struct fb_videomode *modedb,
298+
int num_modes, int dev_mode);
299+
300+
int mxc_elcdif_frame_addr_setup(dma_addr_t phys);
301+
302+
// C2+
303+
void mxcfb_elcdif_register_mode(const struct fb_videomode *modedb,
304+
int num_modes, int dev_mode);
305+
306+
// C1 ONLY
307+
void mxcfb_register_presetup(int disp_port,
308+
int (*pre_setup)(struct fb_info *info));
88309

310+
#endif /* __KERNEL__ */
89311
#endif

ffi-cdecl/include/mxcfb-sony.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct mxcfb_update_data {
110110
__u32 update_mode;
111111
__u32 update_marker;
112112
int temp;
113-
uint flags;
113+
unsigned int flags;
114114
struct mxcfb_alt_buffer_data alt_buffer_data;
115115
};
116116

ffi-cdecl/mxcfb_cervantes_decl.c

-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ cdecl_struct(mxcfb_rect)
3434
cdecl_struct(mxcfb_alt_buffer_data)
3535
cdecl_struct(mxcfb_update_data)
3636

37-
3837
cdecl_const(MXCFB_SEND_UPDATE)
3938
cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE)

ffi-cdecl/posix_decl.c

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "ffi-cdecl.h"
1818

1919
cdecl_type(size_t)
20+
cdecl_type(ssize_t)
2021
cdecl_type(off_t)
2122

2223
cdecl_struct(timeval)

0 commit comments

Comments
 (0)