|
1 | 1 | /*
|
2 | 2 | * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved.
|
3 | 3 | *
|
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. |
6 | 9 | *
|
7 | 10 | * The code contained herein is licensed under the GNU Lesser General
|
8 | 11 | * Public License. You may obtain a copy of the GNU Lesser General
|
|
19 | 22 | *
|
20 | 23 | * @ingroup Framebuffer
|
21 | 24 | */
|
22 |
| - |
23 | 25 | #ifndef __ASM_ARCH_MXCFB_H__
|
24 | 26 | #define __ASM_ARCH_MXCFB_H__
|
25 | 27 |
|
| 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 | + |
26 | 89 | #define UPDATE_MODE_PARTIAL 0x0
|
27 | 90 | #define UPDATE_MODE_FULL 0x1
|
28 | 91 |
|
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 |
30 | 102 |
|
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 |
32 | 110 |
|
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 |
38 | 114 |
|
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 |
43 | 120 |
|
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 |
48 | 122 |
|
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+ |
50 | 128 | #define EPDC_FLAG_USE_CMAP 0x04
|
| 129 | + |
| 130 | +#define EPDC_FLAG_USE_ALT_BUFFER 0x100 |
| 131 | +// C2+ |
51 | 132 | #define EPDC_FLAG_TEST_COLLISION 0x200
|
52 | 133 | #define EPDC_FLAG_GROUP_UPDATE 0x400
|
53 | 134 | #define EPDC_FLAG_USE_DITHERING_Y1 0x2000
|
54 | 135 | #define EPDC_FLAG_USE_DITHERING_Y4 0x4000
|
55 | 136 |
|
56 |
| -/* introduced in Cervantes3 */ |
| 137 | +// New stuff (2016+) |
57 | 138 | #define EPDC_FLAG_USE_AAD 0x1000
|
58 | 139 | #define EPDC_FLAG_USE_DITHERING_NTX_D8 0x100000
|
59 | 140 |
|
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, |
65 | 150 | };
|
66 | 151 |
|
| 152 | +#define FB_POWERDOWN_DISABLE -1 |
| 153 | + |
67 | 154 | struct mxcfb_alt_buffer_data {
|
68 | 155 | void *virt_addr;
|
69 | 156 | __u32 phys_addr;
|
70 | 157 | __u32 width; /* width of entire buffer */
|
71 | 158 | __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 */ |
73 | 160 | };
|
74 | 161 |
|
75 | 162 | 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; |
83 | 170 | };
|
84 | 171 |
|
| 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 | + |
85 | 251 | /* 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) |
86 | 258 | #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 | + |
87 | 262 | #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)); |
88 | 309 |
|
| 310 | +#endif /* __KERNEL__ */ |
89 | 311 | #endif
|
0 commit comments