summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-10-07 02:01:35 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-10-26 12:28:48 -0400
commit3237ae4a4ff9296a377ff9194a11038da161208f (patch)
treeaf4338c78467b9b0845d76c39da1fbe10f25e23e /firmware/export
parent12f3ed1699d6bef25bed90ba95cbcc1a6bb4934a (diff)
downloadrockbox-3237ae4a4ff9296a377ff9194a11038da161208f.tar.gz
rockbox-3237ae4a4ff9296a377ff9194a11038da161208f.zip
LCD core move buf ptr and address look up function viewport struct
I'm currently running up against the limitations of the lcd_draw functions I want these functions to be able to be used on any size buffer not just buffers with a stride matching the underlying device [DONE] allow the framebuffer to be decoupled from the device framebuffer [DONE need examples] allow for some simple blit like transformations [DONE] remove the device framebuffer from the plugin api [DONE}ditto remote framebuffer [DONE] remove _viewport_get_framebuffer you can call struct *vp = lcd_set_viewport(NULL) and vp->buffer->fb_ptr while remote lcds may compile (and work in the sim) its not been tested on targets [FIXED] backdrops need work to be screen agnostic [FIXED] screen statusbar is not being combined into the main viewport correctly yet [FIXED] screen elements are displayed incorrectly after switch to void* [FIXED] core didn't restore proper viewport on splash etc. [NEEDS TESTING] remote lcd garbled data [FIXED] osd lib garbled screen on bmp_part [FIXED] grey_set_vp needs to return old viewport like lcd_set_viewport [FIXED] Viewport update now handles viewports with differing buffers/strides by copying to the main buffer [FIXED] splash on top of WPS leaves old framebuffer data (doesn't redraw) [UPDATE] refined this a bit more to have clear_viewport set the clean bit and have skin_render do its own screen clear scrolling viewports no longer trigger wps refresh also fixed a bug where guisyncyesno was displaying and then disappearing [ADDED!] New LCD macros that allow you to create properly size frame buffers in you desired size without wasting bytes (LCD_ and LCD_REMOTE_) LCD_STRIDE(w, h) same as STRIDE_MAIN LCD_FBSTRIDE(w, h) returns target specific stride for a buffer W x H LCD_NBELEMS(w, h) returns the number of fb_data sized elemenst needed for a buffer W x H LCD_NATIVE_STRIDE(s) conversion between rockbox native vertical and lcd native stride (2bitH) test_viewports.c has an example of usage [FIXED!!] 2bit targets don't respect non-native strides [FIXED] Few define snags Change-Id: I0d04c3834e464eca84a5a715743a297a0cefd0af
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/lcd-remote.h74
-rw-r--r--firmware/export/lcd.h271
2 files changed, 208 insertions, 137 deletions
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index 1819a4de72..030b01c736 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -34,29 +34,12 @@
34#define REMOTETYPE_H100_LCD 1 34#define REMOTETYPE_H100_LCD 1
35#define REMOTETYPE_H300_LCD 2 35#define REMOTETYPE_H300_LCD 2
36#define REMOTETYPE_H300_NONLCD 3 36#define REMOTETYPE_H300_NONLCD 3
37int remote_type(void); 37 int remote_type(void);
38#endif
39
40#if LCD_REMOTE_DEPTH <= 8
41#if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
42 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
43typedef unsigned short fb_remote_data;
44#define FB_RDATA_SZ 2
45#else
46typedef unsigned char fb_remote_data;
47#define FB_RDATA_SZ 1
48#endif
49#elif LCD_DEPTH <= 16
50typedef unsigned short fb_remote_data;
51#define FB_RDATA_SZ 2
52#else
53typedef unsigned long fb_remote_data;
54#define FB_RDATA_SZ 4
55#endif 38#endif
56 39
57#if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */ 40#if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
58#ifdef HAVE_LCD_COLOR 41#ifdef HAVE_LCD_COLOR
59extern unsigned lcd_remote_color_to_native(unsigned color); 42 extern unsigned lcd_remote_color_to_native(unsigned color);
60#endif 43#endif
61 44
62#define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1) 45#define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
@@ -77,12 +60,19 @@ extern unsigned lcd_remote_color_to_native(unsigned color);
77 60
78/* Frame buffer dimensions (format checks only cover existing targets!) */ 61/* Frame buffer dimensions (format checks only cover existing targets!) */
79#if LCD_REMOTE_DEPTH == 1 62#if LCD_REMOTE_DEPTH == 1
80#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) 63#define LCD_REMOTE_STRIDE(w, h) (h)
64#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8)
65#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT)
66#define LCD_REMOTE_NBELEMS(w, h) (((w*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data))
81#elif LCD_REMOTE_DEPTH == 2 67#elif LCD_REMOTE_DEPTH == 2
82#if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED 68#if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
83#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) 69#define LCD_REMOTE_STRIDE(w, h) (h)
70#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8)
71#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT)
72#define LCD_REMOTE_NBELEMS(w, h) (((w*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data))
84#endif 73#endif
85#endif /* LCD_REMOTE_DEPTH */ 74#endif /* LCD_REMOTE_DEPTH */
75
86/* Set defaults if not defined different yet. The defaults apply to both 76/* Set defaults if not defined different yet. The defaults apply to both
87 * dimensions for LCD_REMOTE_DEPTH >= 8 */ 77 * dimensions for LCD_REMOTE_DEPTH >= 8 */
88#ifndef LCD_REMOTE_FBWIDTH 78#ifndef LCD_REMOTE_FBWIDTH
@@ -92,11 +82,20 @@ extern unsigned lcd_remote_color_to_native(unsigned color);
92#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT 82#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
93#endif 83#endif
94 84
95/* The actual framebuffer */ 85#ifndef LCD_REMOTE_NBELEMS
96extern fb_remote_data *lcd_remote_framebuffer; 86/* At this time (2020) known remote screens only have vertical stride */
97extern fb_remote_data lcd_remote_static_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; 87#define LCD_REMOTE_NBELEMS(w, h) ((w*STRIDE_REMOTE(w, h)) + h) / sizeof(fb_remote_data))
98#define FBREMOTEADDR(x, y) (lcd_remote_framebuffer + ((y) * LCD_REMOTE_FBWIDTH) + (x)) 88#define LCD_REMOTE_STRIDE(w, h) STRIDE_REMOTE(w, h)
99#define FRAMEBUFFER_REMOTE_SIZE (sizeof(lcd_remote_static_framebuffer)) 89#define LCD_REMOTE_FBSTRIDE(w, h) STRIDE_REMOTE(w, h)
90#endif
91
92#ifndef LCD_REMOTE_NATIVE_STRIDE
93#define LCD_REMOTE_NATIVE_STRIDE(s) (s)
94#endif
95
96extern struct viewport* lcd_remote_current_viewport;
97#define FBREMOTEADDR(x,y) (fb_remote_data *)(lcd_remote_current_viewport->buffer->get_address_fn(x, y))
98#define FRAMEBUFFER_REMOTE_SIZE (sizeof(fb_remote_data)*LCD_REMOTE_FBWIDTH*LCD_REMOTE_FBHEIGHT)
100 99
101#if LCD_REMOTE_DEPTH > 1 100#if LCD_REMOTE_DEPTH > 1
102extern void lcd_remote_set_foreground(unsigned foreground); 101extern void lcd_remote_set_foreground(unsigned foreground);
@@ -112,13 +111,13 @@ extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x,
112 int src_y, int stride, int x, int y, 111 int src_y, int stride, int x, int y,
113 int width, int height); 112 int width, int height);
114extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y, 113extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
115 int width, int height); 114 int width, int height);
116extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src, 115extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src,
117 int src_x, int src_y, 116 int src_x, int src_y,
118 int stride, int x, int y, 117 int stride, int x, int y,
119 int width, int height); 118 int width, int height);
120extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x, 119extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
121 int y, int width, int height); 120 int y, int width, int height);
122#else /* LCD_REMOTE_DEPTH == 1 */ 121#else /* LCD_REMOTE_DEPTH == 1 */
123#define lcd_remote_mono_bitmap lcd_remote_bitmap 122#define lcd_remote_mono_bitmap lcd_remote_bitmap
124#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part 123#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
@@ -137,7 +136,7 @@ extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
137extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y, 136extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
138 int width, int height); 137 int width, int height);
139extern void lcd_remote_nine_segment_bmp(const struct bitmap* bm, int x, int y, 138extern void lcd_remote_nine_segment_bmp(const struct bitmap* bm, int x, int y,
140 int width, int height); 139 int width, int height);
141 140
142/* Low-level drawing function types */ 141/* Low-level drawing function types */
143typedef void lcd_remote_pixelfunc_type(int x, int y); 142typedef void lcd_remote_pixelfunc_type(int x, int y);
@@ -146,17 +145,17 @@ typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask,
146 145
147/* low level drawing function pointer arrays */ 146/* low level drawing function pointer arrays */
148#if LCD_REMOTE_DEPTH > 1 147#if LCD_REMOTE_DEPTH > 1
149extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs; 148 extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
150extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs; 149 extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
151#else 150#else
152extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8]; 151 extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
153extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8]; 152 extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
154#endif 153#endif
155 154
156#endif /* HAVE_LCD_REMOTE */ 155#endif /* HAVE_LCD_REMOTE */
157 156
158#ifdef HAVE_REMOTE_LCD_TICKING 157#ifdef HAVE_REMOTE_LCD_TICKING
159void lcd_remote_emireduce(bool state); 158 void lcd_remote_emireduce(bool state);
160#endif 159#endif
161 160
162void lcd_remote_init_device(void); 161void lcd_remote_init_device(void);
@@ -170,7 +169,10 @@ extern void lcd_remote_init(void);
170extern int lcd_remote_default_contrast(void); 169extern int lcd_remote_default_contrast(void);
171extern void lcd_remote_set_contrast(int val); 170extern void lcd_remote_set_contrast(int val);
172 171
173extern void lcd_remote_set_viewport(struct viewport* vp); 172extern struct viewport* lcd_remote_init_viewport(struct viewport* vp);
173extern struct viewport* lcd_remote_set_viewport(struct viewport* vp);
174extern struct viewport* lcd_remote_set_viewport_ex(struct viewport* vp, int flags);
175
174extern void lcd_remote_clear_display(void); 176extern void lcd_remote_clear_display(void);
175extern void lcd_remote_clear_viewport(void); 177extern void lcd_remote_clear_viewport(void);
176extern void lcd_remote_puts(int x, int y, const unsigned char *str); 178extern void lcd_remote_puts(int x, int y, const unsigned char *str);
@@ -212,7 +214,7 @@ extern void lcd_remote_bidir_scroll(int threshold);
212extern void lcd_remote_scroll_step(int pixels); 214extern void lcd_remote_scroll_step(int pixels);
213 215
214extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y, 216extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y,
215 int x, int y, int width, int height); 217 int x, int y, int width, int height);
216extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y); 218extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y);
217 219
218#endif /* __LCD_REMOTE_H__ */ 220#endif /* __LCD_REMOTE_H__ */
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index ae06307dca..af734da913 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -23,30 +23,11 @@
23#define __LCD_H__ 23#define __LCD_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include <stddef.h>
26#include "cpu.h" 27#include "cpu.h"
27#include "config.h" 28#include "config.h"
28#include "events.h" 29#include "events.h"
29 30
30#define VP_FLAG_ALIGN_RIGHT 0x01
31#define VP_FLAG_ALIGN_CENTER 0x02
32
33#define VP_FLAG_ALIGNMENT_MASK \
34 (VP_FLAG_ALIGN_RIGHT|VP_FLAG_ALIGN_CENTER)
35
36#define VP_IS_RTL(vp) (((vp)->flags & VP_FLAG_ALIGNMENT_MASK) == VP_FLAG_ALIGN_RIGHT)
37
38struct viewport {
39 int x;
40 int y;
41 int width;
42 int height;
43 int flags;
44 int font;
45 int drawmode;
46 /* needed for even for mono displays to support greylib */
47 unsigned fg_pattern;
48 unsigned bg_pattern;
49};
50 31
51/* Frame buffer stride 32/* Frame buffer stride
52 * 33 *
@@ -101,7 +82,7 @@ enum screen_type {
101 82
102struct scrollinfo; 83struct scrollinfo;
103 84
104#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE 85#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
105#define STRIDE_MAIN(w, h) (h) 86#define STRIDE_MAIN(w, h) (h)
106#else 87#else
107#define STRIDE_MAIN(w, h) (w) 88#define STRIDE_MAIN(w, h) (w)
@@ -115,46 +96,105 @@ struct scrollinfo;
115#if LCD_DEPTH <=8 96#if LCD_DEPTH <=8
116#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \ 97#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \
117 || (LCD_PIXELFORMAT == HORIZONTAL_INTERLEAVED) 98 || (LCD_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
118typedef unsigned short fb_data; 99 typedef unsigned short fb_data;
119#define FB_DATA_SZ 2 100#define FB_DATA_SZ 2
120#else 101#else
121typedef unsigned char fb_data; 102 typedef unsigned char fb_data;
122#define FB_DATA_SZ 1 103#define FB_DATA_SZ 1
123#endif 104#endif
124#elif LCD_DEPTH <= 16 105#elif LCD_DEPTH <= 16
125typedef unsigned short fb_data; 106 typedef unsigned short fb_data;
126#define FB_DATA_SZ 2 107#define FB_DATA_SZ 2
127#elif LCD_DEPTH <= 24 108#elif LCD_DEPTH <= 24
128struct _fb_pixel { 109 struct _fb_pixel {
129 unsigned char b, g, r; 110 unsigned char b, g, r;
130}; 111 };
131typedef struct _fb_pixel fb_data; 112 typedef struct _fb_pixel fb_data;
132#define FB_DATA_SZ 3 113#define FB_DATA_SZ 3
133#else /* LCD_DEPTH > 24 */ 114#else /* LCD_DEPTH > 24 */
134#if (LCD_PIXELFORMAT == XRGB8888) 115#if (LCD_PIXELFORMAT == XRGB8888)
135struct _fb_pixel { 116 struct _fb_pixel {
136 unsigned char b, g, r, x; 117 unsigned char b, g, r, x;
137}; 118 };
138typedef struct _fb_pixel fb_data; 119 typedef struct _fb_pixel fb_data;
139#else 120#else
140typedef unsigned long fb_data; 121 typedef unsigned long fb_data;
141#endif 122#endif
142#define FB_DATA_SZ 4 123#define FB_DATA_SZ 4
143#endif /* LCD_DEPTH */ 124#endif /* LCD_DEPTH */
144 125
126#ifdef HAVE_REMOTE_LCD
127#if LCD_REMOTE_DEPTH <= 8
128#if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
129 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
130 typedef unsigned short fb_remote_data;
131#define FB_RDATA_SZ 2
132#else
133 typedef unsigned char fb_remote_data;
134#define FB_RDATA_SZ 1
135#endif
136#elif LCD_DEPTH <= 16
137 typedef unsigned short fb_remote_data;
138#define FB_RDATA_SZ 2
139#else
140 typedef unsigned long fb_remote_data;
141#define FB_RDATA_SZ 4
142#endif
143#endif
144
145#if defined(HAVE_LCD_MODES) 145#if defined(HAVE_LCD_MODES)
146void lcd_set_mode(int mode); 146 void lcd_set_mode(int mode);
147#define LCD_MODE_RGB565 0x00000001 147#define LCD_MODE_RGB565 0x00000001
148#define LCD_MODE_YUV 0x00000002 148#define LCD_MODE_YUV 0x00000002
149#define LCD_MODE_PAL256 0x00000004 149#define LCD_MODE_PAL256 0x00000004
150 150
151#if HAVE_LCD_MODES & LCD_MODE_PAL256 151#if HAVE_LCD_MODES & LCD_MODE_PAL256
152 void lcd_blit_pal256(unsigned char *src, int src_x, int src_y, int x, int y, 152 void lcd_blit_pal256(unsigned char *src, int src_x, int src_y, int x, int y,
153 int width, int height); 153 int width, int height);
154 void lcd_pal256_update_pal(fb_data *palette); 154 void lcd_pal256_update_pal(fb_data *palette);
155#endif 155#endif
156#endif 156#endif
157 157
158struct frame_buffer_t {
159 union
160 {
161 void *data;
162 char *ch_ptr;
163 fb_data *fb_ptr;
164#ifdef HAVE_REMOTE_LCD
165 fb_remote_data *fb_remote_ptr;
166#endif
167 };
168 void *(*get_address_fn)(int x, int y);
169 ptrdiff_t stride;
170 size_t elems;
171};
172
173#define VP_FLAG_ALIGN_RIGHT 0x01
174#define VP_FLAG_ALIGN_CENTER 0x02
175
176#define VP_FLAG_ALIGNMENT_MASK \
177 (VP_FLAG_ALIGN_RIGHT|VP_FLAG_ALIGN_CENTER)
178
179#define VP_IS_RTL(vp) (((vp)->flags & VP_FLAG_ALIGNMENT_MASK) == VP_FLAG_ALIGN_RIGHT)
180
181#define VP_FLAG_VP_DIRTY 0x4000
182#define VP_FLAG_CLEAR_FLAG 0x8000
183#define VP_FLAG_VP_SET_CLEAN (VP_FLAG_CLEAR_FLAG | VP_FLAG_VP_DIRTY)
184
185struct viewport {
186 int x;
187 int y;
188 int width;
189 int height;
190 int flags;
191 int font;
192 int drawmode;
193 struct frame_buffer_t *buffer;
194 /* needed for even for mono displays to support greylib */
195 unsigned fg_pattern;
196 unsigned bg_pattern;
197};
158 198
159/* common functions */ 199/* common functions */
160extern void lcd_write_command(int byte); 200extern void lcd_write_command(int byte);
@@ -171,7 +211,10 @@ extern int lcd_getwidth(void);
171extern int lcd_getheight(void); 211extern int lcd_getheight(void);
172extern int lcd_getstringsize(const unsigned char *str, int *w, int *h); 212extern int lcd_getstringsize(const unsigned char *str, int *w, int *h);
173 213
174extern void lcd_set_viewport(struct viewport* vp); 214extern struct viewport* lcd_init_viewport(struct viewport* vp);
215extern struct viewport* lcd_set_viewport(struct viewport* vp);
216extern struct viewport* lcd_set_viewport_ex(struct viewport* vp, int flags);
217
175extern void lcd_update(void); 218extern void lcd_update(void);
176extern void lcd_update_viewport(void); 219extern void lcd_update_viewport(void);
177extern void lcd_update_viewport_rect(int x, int y, int width, int height); 220extern void lcd_update_viewport_rect(int x, int y, int width, int height);
@@ -193,15 +236,15 @@ extern bool lcd_putsxy_scroll_func(int x, int y, const unsigned char *string,
193#if defined(HAVE_LCD_COLOR) 236#if defined(HAVE_LCD_COLOR)
194#if MEMORYSIZE > 2 237#if MEMORYSIZE > 2
195#define LCD_YUV_DITHER 0x1 238#define LCD_YUV_DITHER 0x1
196extern void lcd_yuv_set_options(unsigned options); 239 extern void lcd_yuv_set_options(unsigned options);
197extern void lcd_blit_yuv(unsigned char * const src[3], 240 extern void lcd_blit_yuv(unsigned char * const src[3],
198 int src_x, int src_y, int stride, 241 int src_x, int src_y, int stride,
199 int x, int y, int width, int height); 242 int x, int y, int width, int height);
200#endif /* MEMORYSIZE > 2 */ 243#endif /* MEMORYSIZE > 2 */
201#else 244#else
202extern void lcd_blit_mono(const unsigned char *data, int x, int by, int width, 245 extern void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
203 int bheight, int stride); 246 int bheight, int stride);
204extern void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, 247 extern void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
205 int bx, int by, int bwidth, int bheight, 248 int bx, int by, int bwidth, int bheight,
206 int stride); 249 int stride);
207#endif 250#endif
@@ -211,9 +254,9 @@ extern void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
211extern void lcd_update_rect(int x, int y, int width, int height); 254extern void lcd_update_rect(int x, int y, int width, int height);
212 255
213#ifdef HAVE_REMOTE_LCD 256#ifdef HAVE_REMOTE_LCD
214extern void lcd_remote_update(void); 257 extern void lcd_remote_update(void);
215/* update a fraction of the screen */ 258 /* update a fraction of the screen */
216extern void lcd_remote_update_rect(int x, int y, int width, int height); 259 extern void lcd_remote_update_rect(int x, int y, int width, int height);
217#endif /* HAVE_REMOTE_LCD */ 260#endif /* HAVE_REMOTE_LCD */
218 261
219/* Bitmap formats */ 262/* Bitmap formats */
@@ -239,13 +282,13 @@ enum
239typedef void lcd_pixelfunc_type(int x, int y); 282typedef void lcd_pixelfunc_type(int x, int y);
240typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits); 283typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits);
241#if LCD_DEPTH >= 8 284#if LCD_DEPTH >= 8
242typedef void lcd_fastpixelfunc_type(fb_data *address); 285 typedef void lcd_fastpixelfunc_type(fb_data *address);
243#endif 286#endif
244 287
245#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && \ 288#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && \
246 LCD_REMOTE_DEPTH > 1 289 LCD_REMOTE_DEPTH > 1
247/* Just return color for screens use */ 290/* Just return color for screens use */
248static inline unsigned lcd_color_to_native(unsigned color) 291 static inline unsigned lcd_color_to_native(unsigned color)
249 { return color; } 292 { return color; }
250#define SCREEN_COLOR_TO_NATIVE(screen, color) (screen)->color_to_native(color) 293#define SCREEN_COLOR_TO_NATIVE(screen, color) (screen)->color_to_native(color)
251#else 294#else
@@ -286,7 +329,7 @@ static inline unsigned lcd_color_to_native(unsigned color)
286 (((b) >> 3) << 8) ) 329 (((b) >> 3) << 8) )
287/* swap color once - not currenly used in static inits */ 330/* swap color once - not currenly used in static inits */
288#define _SWAPUNPACK(x, _unp_) \ 331#define _SWAPUNPACK(x, _unp_) \
289 ({ typeof (x) _x_ = swap16(x); _unp_(_x_); }) 332 ({ typeof (x) _x_ = swap16(x); _unp_(_x_); })
290#define RGB_UNPACK_RED(x) _SWAPUNPACK((x), _RGB_UNPACK_RED) 333#define RGB_UNPACK_RED(x) _SWAPUNPACK((x), _RGB_UNPACK_RED)
291#define RGB_UNPACK_GREEN(x) _SWAPUNPACK((x), _RGB_UNPACK_GREEN) 334#define RGB_UNPACK_GREEN(x) _SWAPUNPACK((x), _RGB_UNPACK_GREEN)
292#define RGB_UNPACK_BLUE(x) _SWAPUNPACK((x), _RGB_UNPACK_BLUE) 335#define RGB_UNPACK_BLUE(x) _SWAPUNPACK((x), _RGB_UNPACK_BLUE)
@@ -374,16 +417,16 @@ static inline unsigned lcd_color_to_native(unsigned color)
374 * format, so it's the reverse of FB_SCALARPACK_LCD 417 * format, so it's the reverse of FB_SCALARPACK_LCD
375 */ 418 */
376#if LCD_DEPTH >= 24 419#if LCD_DEPTH >= 24
377static inline fb_data scalar_to_fb(unsigned p) 420 static inline fb_data scalar_to_fb(unsigned p)
378{ 421 {
379 union { fb_data st; unsigned sc; } convert; 422 union { fb_data st; unsigned sc; } convert;
380 convert.sc = p; return convert.st; 423 convert.sc = p; return convert.st;
381} 424 }
382static inline unsigned fb_to_scalar(fb_data p) 425 static inline unsigned fb_to_scalar(fb_data p)
383{ 426 {
384 union { fb_data st; unsigned sc; } convert; 427 union { fb_data st; unsigned sc; } convert;
385 convert.st = p; return convert.sc; 428 convert.st = p; return convert.sc;
386} 429 }
387#define FB_RGBPACK(r_, g_, b_) ((fb_data){.r = r_, .g = g_, .b = b_}) 430#define FB_RGBPACK(r_, g_, b_) ((fb_data){.r = r_, .g = g_, .b = b_})
388#define FB_RGBPACK_LCD(r_, g_, b_) FB_RGBPACK(r_, g_, b_) 431#define FB_RGBPACK_LCD(r_, g_, b_) FB_RGBPACK(r_, g_, b_)
389#define FB_UNPACK_RED(fb) ((fb).r) 432#define FB_UNPACK_RED(fb) ((fb).r)
@@ -411,17 +454,28 @@ static inline unsigned fb_to_scalar(fb_data p)
411/* Frame buffer dimensions */ 454/* Frame buffer dimensions */
412#if LCD_DEPTH == 1 455#if LCD_DEPTH == 1
413#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 456#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
414#define LCD_FBWIDTH ((LCD_WIDTH+7)/8) 457#define LCD_FBSTRIDE(w, h) ((w+7)/8)
458#define LCD_FBWIDTH LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
459#define LCD_NBELEMS(w, h) (((h*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
415#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 460#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
416#define LCD_FBHEIGHT ((LCD_HEIGHT+7)/8) 461#define LCD_FBSTRIDE(w, h) ((h+7)/8)
462#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
463#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
417#endif /* LCD_PIXELFORMAT */ 464#endif /* LCD_PIXELFORMAT */
418#elif LCD_DEPTH == 2 465#elif LCD_DEPTH == 2
419#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 466#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
420#define LCD_FBWIDTH ((LCD_WIDTH+3)/4) 467#define LCD_FBSTRIDE(w, h) ((w+3)>>2)
468#define LCD_NATIVE_STRIDE(s) LCD_FBSTRIDE(s, s)
469#define LCD_FBWIDTH LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
470#define LCD_NBELEMS(w, h) (((h*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
421#elif LCD_PIXELFORMAT == VERTICAL_PACKING 471#elif LCD_PIXELFORMAT == VERTICAL_PACKING
422#define LCD_FBHEIGHT ((LCD_HEIGHT+3)/4) 472#define LCD_FBSTRIDE(w, h) ((h+3)/4)
473#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
474#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
423#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED 475#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
424#define LCD_FBHEIGHT ((LCD_HEIGHT+7)/8) 476#define LCD_FBSTRIDE(w, h) ((h+7)/8)
477#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
478#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
425#endif /* LCD_PIXELFORMAT */ 479#endif /* LCD_PIXELFORMAT */
426#endif /* LCD_DEPTH */ 480#endif /* LCD_DEPTH */
427/* Set defaults if not defined different yet. The defaults apply to both 481/* Set defaults if not defined different yet. The defaults apply to both
@@ -432,13 +486,29 @@ static inline unsigned fb_to_scalar(fb_data p)
432#ifndef LCD_FBHEIGHT 486#ifndef LCD_FBHEIGHT
433#define LCD_FBHEIGHT LCD_HEIGHT 487#define LCD_FBHEIGHT LCD_HEIGHT
434#endif 488#endif
435/* The actual framebuffer */ 489
436extern fb_data *lcd_framebuffer; 490#ifndef LCD_NATIVE_STRIDE
491/* 2-bit Horz is the only display that actually defines this */
492#define LCD_NATIVE_STRIDE(s) (s)
493#endif
494
495#ifndef LCD_NBELEMS
437#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE 496#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
438#define FBADDR(x, y) (lcd_framebuffer + ((x) * LCD_FBHEIGHT) + (y)) 497#define LCD_NBELEMS(w, h) ((w*STRIDE_MAIN(w, h)) + h)
439#else 498#else
440#define FBADDR(x, y) (lcd_framebuffer + ((y) * LCD_FBWIDTH) + (x)) 499#define LCD_NBELEMS(w, h) ((h*STRIDE_MAIN(w, h)) + w)
441#endif 500#endif
501#define LCD_FBSTRIDE(w, h) STRIDE_MAIN(w, h)
502#endif
503
504#ifndef LCD_STRIDE
505 #define LCD_STRIDE(w, h) STRIDE_MAIN(w, h)
506#endif
507
508extern struct viewport* lcd_current_viewport;
509
510#define FBADDR(x,y) ((fb_data*) lcd_current_viewport->buffer->get_address_fn(x, y))
511
442#define FRAMEBUFFER_SIZE (sizeof(fb_data)*LCD_FBWIDTH*LCD_FBHEIGHT) 512#define FRAMEBUFFER_SIZE (sizeof(fb_data)*LCD_FBWIDTH*LCD_FBHEIGHT)
443 513
444/** Port-specific functions. Enable in port config file. **/ 514/** Port-specific functions. Enable in port config file. **/
@@ -499,7 +569,7 @@ struct bitmap {
499 569
500extern void lcd_set_invert_display(bool yesno); 570extern void lcd_set_invert_display(bool yesno);
501#ifdef HAVE_BACKLIGHT_INVERSION 571#ifdef HAVE_BACKLIGHT_INVERSION
502extern void lcd_set_backlight_inversion(bool yesno); 572 extern void lcd_set_backlight_inversion(bool yesno);
503#endif /* HAVE_BACKLIGHT_INVERSION */ 573#endif /* HAVE_BACKLIGHT_INVERSION */
504extern void lcd_set_flip(bool yesno); 574extern void lcd_set_flip(bool yesno);
505 575
@@ -510,13 +580,13 @@ extern int lcd_getfont(void);
510 580
511/* low level drawing function pointer arrays */ 581/* low level drawing function pointer arrays */
512#if LCD_DEPTH >= 8 582#if LCD_DEPTH >= 8
513extern lcd_fastpixelfunc_type* const *lcd_fastpixelfuncs; 583 extern lcd_fastpixelfunc_type* const *lcd_fastpixelfuncs;
514#elif LCD_DEPTH > 1 584#elif LCD_DEPTH > 1
515extern lcd_pixelfunc_type* const *lcd_pixelfuncs; 585 extern lcd_pixelfunc_type* const *lcd_pixelfuncs;
516extern lcd_blockfunc_type* const *lcd_blockfuncs; 586 extern lcd_blockfunc_type* const *lcd_blockfuncs;
517#else /* LCD_DEPTH == 1*/ 587#else /* LCD_DEPTH == 1*/
518extern lcd_pixelfunc_type* const lcd_pixelfuncs[8]; 588 extern lcd_pixelfunc_type* const lcd_pixelfuncs[8];
519extern lcd_blockfunc_type* const lcd_blockfuncs[8]; 589 extern lcd_blockfunc_type* const lcd_blockfuncs[8];
520#endif /* LCD_DEPTH */ 590#endif /* LCD_DEPTH */
521 591
522extern void lcd_drawpixel(int x, int y); 592extern void lcd_drawpixel(int x, int y);
@@ -526,45 +596,44 @@ extern void lcd_vline(int x, int y1, int y2);
526extern void lcd_drawrect(int x, int y, int width, int height); 596extern void lcd_drawrect(int x, int y, int width, int height);
527extern void lcd_fillrect(int x, int y, int width, int height); 597extern void lcd_fillrect(int x, int y, int width, int height);
528extern void lcd_gradient_fillrect(int x, int y, int width, int height, 598extern void lcd_gradient_fillrect(int x, int y, int width, int height,
529 unsigned start_rgb, unsigned end_rgb); 599 unsigned start_rgb, unsigned end_rgb);
530extern void lcd_gradient_fillrect_part(int x, int y, int width, int height, 600extern void lcd_gradient_fillrect_part(int x, int y, int width, int height,
531 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip); 601 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip);
532extern void lcd_draw_border_viewport(void); 602extern void lcd_draw_border_viewport(void);
533extern void lcd_fill_viewport(void); 603extern void lcd_fill_viewport(void);
534extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 604extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
535 int stride, int x, int y, int width, int height); 605 int stride, int x, int y, int width, int height);
536extern void lcd_bitmap(const fb_data *src, int x, int y, int width, 606extern void lcd_bitmap(const fb_data *src, int x, int y, int width,
537 int height); 607 int height);
538extern void lcd_set_framebuffer(fb_data *fb);
539 608
540extern void lcd_scroll_step(int pixels); 609extern void lcd_scroll_step(int pixels);
541 610
542#if LCD_DEPTH > 1 611#if LCD_DEPTH > 1
543extern void lcd_set_foreground(unsigned foreground); 612 extern void lcd_set_foreground(unsigned foreground);
544extern unsigned lcd_get_foreground(void); 613 extern unsigned lcd_get_foreground(void);
545extern void lcd_set_background(unsigned background); 614 extern void lcd_set_background(unsigned background);
546extern unsigned lcd_get_background(void); 615 extern unsigned lcd_get_background(void);
547#ifdef HAVE_LCD_COLOR 616#ifdef HAVE_LCD_COLOR
548extern void lcd_set_selector_start(unsigned selector); 617 extern void lcd_set_selector_start(unsigned selector);
549extern void lcd_set_selector_end(unsigned selector); 618 extern void lcd_set_selector_end(unsigned selector);
550extern void lcd_set_selector_text(unsigned selector_text); 619 extern void lcd_set_selector_text(unsigned selector_text);
551#endif 620#endif
552extern void lcd_set_drawinfo(int mode, unsigned foreground, 621 extern void lcd_set_drawinfo(int mode, unsigned foreground,
553 unsigned background); 622 unsigned background);
554void lcd_set_backdrop(fb_data* backdrop); 623 void lcd_set_backdrop(fb_data* backdrop);
555 624
556fb_data* lcd_get_backdrop(void); 625 fb_data* lcd_get_backdrop(void);
557 626
558extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, 627 extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
559 int stride, int x, int y, int width, int height); 628 int stride, int x, int y, int width, int height);
560extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, 629 extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,
561 int height); 630 int height);
562extern void lcd_bitmap_transparent_part(const fb_data *src, 631 extern void lcd_bitmap_transparent_part(const fb_data *src,
563 int src_x, int src_y, 632 int src_x, int src_y,
564 int stride, int x, int y, int width, 633 int stride, int x, int y, int width,
565 int height); 634 int height);
566extern void lcd_bitmap_transparent(const fb_data *src, int x, int y, 635 extern void lcd_bitmap_transparent(const fb_data *src, int x, int y,
567 int width, int height); 636 int width, int height);
568#else /* LCD_DEPTH == 1 */ 637#else /* LCD_DEPTH == 1 */
569#define lcd_mono_bitmap lcd_bitmap 638#define lcd_mono_bitmap lcd_bitmap
570#define lcd_mono_bitmap_part lcd_bitmap_part 639#define lcd_mono_bitmap_part lcd_bitmap_part
@@ -577,10 +646,10 @@ extern void lcd_nine_segment_bmp(const struct bitmap* bm, int x, int y,
577 646
578/* TODO: Impement this for remote displays if ever needed */ 647/* TODO: Impement this for remote displays if ever needed */
579#if defined(LCD_DPI) && (LCD_DPI > 0) 648#if defined(LCD_DPI) && (LCD_DPI > 0)
580/* returns the pixel density of the display */ 649 /* returns the pixel density of the display */
581static inline int lcd_get_dpi(void) { return LCD_DPI; } 650 static inline int lcd_get_dpi(void) { return LCD_DPI; }
582#else 651#else
583extern int lcd_get_dpi(void); 652 extern int lcd_get_dpi(void);
584#endif /* LCD_DPI */ 653#endif /* LCD_DPI */
585 654
586#endif /* __LCD_H__ */ 655#endif /* __LCD_H__ */