summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-01-13 00:11:43 +0000
committerJens Arnold <amiconn@rockbox.org>2008-01-13 00:11:43 +0000
commita72499a12541fa0348e92f88662d1efe15b0ea47 (patch)
tree32a874c093616649f49f4392207b738a6f7abed7
parent43cc03457d2bda7eb3057f242ff7b23a9856408c (diff)
downloadrockbox-a72499a12541fa0348e92f88662d1efe15b0ea47.tar.gz
rockbox-a72499a12541fa0348e92f88662d1efe15b0ea47.zip
Greyscale library: Plugins can now put the management structure in IRAM for higher update speed. Use this in doom, mpegplayer, and zxbox. Made the api pointer part of the struct.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16066 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/cube.c1
-rw-r--r--apps/plugins/doom/i_video.c1
-rw-r--r--apps/plugins/fire.c1
-rw-r--r--apps/plugins/greyscale.c1
-rw-r--r--apps/plugins/jpeg.c1
-rw-r--r--apps/plugins/lib/grey.h10
-rw-r--r--apps/plugins/lib/grey_core.c113
-rw-r--r--apps/plugins/lib/grey_draw.c14
-rw-r--r--apps/plugins/lib/grey_parm.c2
-rw-r--r--apps/plugins/lib/grey_scroll.c45
-rw-r--r--apps/plugins/mandelbrot.c1
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c4
-rw-r--r--apps/plugins/plasma.c1
-rw-r--r--apps/plugins/test_fps.c4
-rw-r--r--apps/plugins/zxbox/zxbox.c1
15 files changed, 110 insertions, 90 deletions
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index 73d0630adc..187fcad1c1 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -214,6 +214,7 @@ static int y_off = LCD_HEIGHT/2;
214 214
215#if LCD_DEPTH == 1 215#if LCD_DEPTH == 1
216#define USE_GSLIB 216#define USE_GSLIB
217GREY_INFO_STRUCT
217struct my_lcd { 218struct my_lcd {
218 void (*update)(void); 219 void (*update)(void);
219 void (*clear_display)(void); 220 void (*clear_display)(void);
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index cc5036c59d..b466392319 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -118,6 +118,7 @@
118 118
119#ifndef HAVE_LCD_COLOR 119#ifndef HAVE_LCD_COLOR
120#include "../lib/grey.h" 120#include "../lib/grey.h"
121GREY_INFO_STRUCT_IRAM
121static unsigned char greybuffer[LCD_WIDTH] IBSS_ATTR; /* off screen buffer */ 122static unsigned char greybuffer[LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
122static unsigned char *gbuf; 123static unsigned char *gbuf;
123#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 124#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c
index 2d7a66ea16..ed3509c168 100644
--- a/apps/plugins/fire.c
+++ b/apps/plugins/fire.c
@@ -46,6 +46,7 @@ static unsigned char fire[LCD_HEIGHT+3][FIRE_WIDTH];
46static unsigned char cooling_map[LCD_HEIGHT][FIRE_WIDTH]; 46static unsigned char cooling_map[LCD_HEIGHT][FIRE_WIDTH];
47 47
48#ifndef HAVE_LCD_COLOR 48#ifndef HAVE_LCD_COLOR
49GREY_INFO_STRUCT
49static unsigned char *gbuf; 50static unsigned char *gbuf;
50static size_t gbuf_size = 0; 51static size_t gbuf_size = 0;
51static unsigned char draw_buffer[FIRE_WIDTH]; 52static unsigned char draw_buffer[FIRE_WIDTH];
diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c
index de90d5737f..6a574f3f6f 100644
--- a/apps/plugins/greyscale.c
+++ b/apps/plugins/greyscale.c
@@ -82,6 +82,7 @@ PLUGIN_HEADER
82#endif 82#endif
83/******************************* Globals ***********************************/ 83/******************************* Globals ***********************************/
84 84
85GREY_INFO_STRUCT
85static struct plugin_api* rb; /* global api struct pointer */ 86static struct plugin_api* rb; /* global api struct pointer */
86static char pbuf[32]; /* global printf buffer */ 87static char pbuf[32]; /* global printf buffer */
87static unsigned char *gbuf; 88static unsigned char *gbuf;
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index d14b03637b..978e1156b9 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -184,6 +184,7 @@ PLUGIN_HEADER
184/* different graphics libraries */ 184/* different graphics libraries */
185#if LCD_DEPTH < 8 185#if LCD_DEPTH < 8
186#define USEGSLIB 186#define USEGSLIB
187GREY_INFO_STRUCT
187#define MYLCD(fn) grey_ub_ ## fn 188#define MYLCD(fn) grey_ub_ ## fn
188#define MYLCD_UPDATE() 189#define MYLCD_UPDATE()
189#define MYXLCD(fn) grey_ub_ ## fn 190#define MYXLCD(fn) grey_ub_ ## fn
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
index 5bef88a89a..84b6687de3 100644
--- a/apps/plugins/lib/grey.h
+++ b/apps/plugins/lib/grey.h
@@ -36,6 +36,12 @@
36#define GREY_LIGHTGRAY GREY_BRIGHTNESS(170) 36#define GREY_LIGHTGRAY GREY_BRIGHTNESS(170)
37#define GREY_WHITE GREY_BRIGHTNESS(255) 37#define GREY_WHITE GREY_BRIGHTNESS(255)
38 38
39/* Greyscale library management structure declaration. You need one of these
40 * in every plugin using the library, depending on whether the structure should
41 * use IRAM or not. */
42#define GREY_INFO_STRUCT struct _grey_info _grey_info;
43#define GREY_INFO_STRUCT_IRAM struct _grey_info _grey_info IBSS_ATTR;
44
39/* Library initialisation and release */ 45/* Library initialisation and release */
40bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, 46bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
41 bool buffered, int width, int height, long *buf_taken); 47 bool buffered, int width, int height, long *buf_taken);
@@ -148,6 +154,7 @@ struct _grey_info
148 int bheight; /* 4-pixel or 8-pixel units */ 154 int bheight; /* 4-pixel or 8-pixel units */
149#endif 155#endif
150 unsigned long flags; /* various flags, see #defines */ 156 unsigned long flags; /* various flags, see #defines */
157 struct plugin_api *rb; /* plugin API pointer */
151#ifndef SIMULATOR 158#ifndef SIMULATOR
152 unsigned char *values; /* start of greyscale pixel values */ 159 unsigned char *values; /* start of greyscale pixel values */
153 unsigned char *phases; /* start of greyscale pixel phases */ 160 unsigned char *phases; /* start of greyscale pixel phases */
@@ -162,8 +169,7 @@ struct _grey_info
162 int curfont; /* current selected font */ 169 int curfont; /* current selected font */
163}; 170};
164 171
165/* Global variables */ 172/* Global variable, defined in the plugin */
166extern struct plugin_api *_grey_rb;
167extern struct _grey_info _grey_info; 173extern struct _grey_info _grey_info;
168 174
169#endif /* HAVE_LCD_BITMAP && (LCD_DEPTH < 4) */ 175#endif /* HAVE_LCD_BITMAP && (LCD_DEPTH < 4) */
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index 0fa7e28eb9..395a1130d5 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -30,13 +30,10 @@
30#define NEED_BOOST 30#define NEED_BOOST
31#endif 31#endif
32 32
33/* Global variables */
34struct plugin_api *_grey_rb = NULL; /* global api struct pointer */
35struct _grey_info _grey_info; /* global info structure */
36
37#ifndef SIMULATOR 33#ifndef SIMULATOR
38 34
39#if CONFIG_LCD == LCD_SSD1815 || CONFIG_LCD == LCD_IFP7XX || CONFIG_LCD == LCD_MROBE100 35#if CONFIG_LCD == LCD_SSD1815 || CONFIG_LCD == LCD_IFP7XX \
36 || CONFIG_LCD == LCD_MROBE100
40/* measured and interpolated curve */ 37/* measured and interpolated curve */
41/* TODO: check for iFP & m:robe 100 */ 38/* TODO: check for iFP & m:robe 100 */
42static const unsigned char lcdlinear[256] = { 39static const unsigned char lcdlinear[256] = {
@@ -205,16 +202,16 @@ static inline void _deferred_update(void)
205 int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT); 202 int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT);
206 203
207 if (y1 > 0) /* refresh part above overlay, full width */ 204 if (y1 > 0) /* refresh part above overlay, full width */
208 _grey_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); 205 _grey_info.rb->lcd_update_rect(0, 0, LCD_WIDTH, y1);
209 206
210 if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ 207 if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */
211 _grey_rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); 208 _grey_info.rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2);
212 209
213 if (x1 > 0) /* refresh part to the left of overlay */ 210 if (x1 > 0) /* refresh part to the left of overlay */
214 _grey_rb->lcd_update_rect(0, y1, x1, y2 - y1); 211 _grey_info.rb->lcd_update_rect(0, y1, x1, y2 - y1);
215 212
216 if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ 213 if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */
217 _grey_rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); 214 _grey_info.rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1);
218} 215}
219 216
220#ifndef SIMULATOR 217#ifndef SIMULATOR
@@ -222,18 +219,18 @@ static inline void _deferred_update(void)
222static void _timer_isr(void) 219static void _timer_isr(void)
223{ 220{
224#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 221#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
225 _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases, 222 _grey_info.rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases,
226 _grey_info.bx, _grey_info.y, 223 _grey_info.bx, _grey_info.y,
227 _grey_info.bwidth, _grey_info.height, 224 _grey_info.bwidth, _grey_info.height,
228 _grey_info.width); 225 _grey_info.width);
229#else 226#else
230 _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases, 227 _grey_info.rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases,
231 _grey_info.x, _grey_info.by, 228 _grey_info.x, _grey_info.by,
232 _grey_info.width, _grey_info.bheight, 229 _grey_info.width, _grey_info.bheight,
233 _grey_info.width); 230 _grey_info.width);
234#endif 231#endif
235 232
236 if (_grey_info.flags & _GREY_DEFERRED_UPDATE) /* lcd_update() requested? */ 233 if (_grey_info.flags & _GREY_DEFERRED_UPDATE) /* lcd_update() requested? */
237 { 234 {
238 _deferred_update(); 235 _deferred_update();
239 _grey_info.flags &= ~_GREY_DEFERRED_UPDATE; /* clear request */ 236 _grey_info.flags &= ~_GREY_DEFERRED_UPDATE; /* clear request */
@@ -246,7 +243,7 @@ static int exp_s16p16(int x)
246{ 243{
247 int t; 244 int t;
248 int y = 0x00010000; 245 int y = 0x00010000;
249 246
250 if (x < 0) x += 0xb1721, y >>= 16; 247 if (x < 0) x += 0xb1721, y >>= 16;
251 t = x - 0x58b91; if (t >= 0) x = t, y <<= 8; 248 t = x - 0x58b91; if (t >= 0) x = t, y <<= 8;
252 t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4; 249 t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4;
@@ -326,7 +323,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
326 unsigned *dst, *end; 323 unsigned *dst, *end;
327#endif 324#endif
328 325
329 _grey_rb = newrb; 326 _grey_info.rb = newrb;
330 327
331 if ((unsigned) width > LCD_WIDTH 328 if ((unsigned) width > LCD_WIDTH
332 || (unsigned) height > LCD_HEIGHT) 329 || (unsigned) height > LCD_HEIGHT)
@@ -347,10 +344,10 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
347 344
348 plane_size = _GREY_MULUQ(width, height); 345 plane_size = _GREY_MULUQ(width, height);
349#ifdef CPU_COLDFIRE 346#ifdef CPU_COLDFIRE
350 plane_size += (-plane_size) & 0xf; /* All buffers should be line aligned */ 347 plane_size += (-plane_size) & 0xf; /* All buffers should be line aligned */
351 buftaken = (-(long)gbuf) & 0xf; 348 buftaken = (-(long)gbuf) & 0xf;
352#else 349#else
353 buftaken = (-(long)gbuf) & 3; /* All buffers must be long aligned. */ 350 buftaken = (-(long)gbuf) & 3; /* All buffers must be long aligned. */
354#endif 351#endif
355 gbuf += buftaken; 352 gbuf += buftaken;
356 353
@@ -371,17 +368,17 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
371 368
372 if (buftaken > gbuf_size) 369 if (buftaken > gbuf_size)
373 return false; 370 return false;
374 371
375#ifndef SIMULATOR 372#ifndef SIMULATOR
376 /* Init to white */ 373 /* Init to white */
377 _grey_rb->memset(_grey_info.values, 0x80, plane_size); 374 _grey_info.rb->memset(_grey_info.values, 0x80, plane_size);
378 375
379 /* Init phases with random bits */ 376 /* Init phases with random bits */
380 dst = (unsigned*)(_grey_info.phases); 377 dst = (unsigned*)(_grey_info.phases);
381 end = (unsigned*)(_grey_info.phases + plane_size); 378 end = (unsigned*)(_grey_info.phases + plane_size);
382 379
383 do 380 do
384 *dst++ = _grey_rb->rand(); 381 *dst++ = _grey_info.rb->rand();
385 while (dst < end); 382 while (dst < end);
386#endif 383#endif
387 384
@@ -444,46 +441,46 @@ void grey_show(bool enable)
444 { 441 {
445 _grey_info.flags |= _GREY_RUNNING; 442 _grey_info.flags |= _GREY_RUNNING;
446#ifdef SIMULATOR 443#ifdef SIMULATOR
447 _grey_rb->sim_lcd_ex_init(129, _grey_get_pixel); 444 _grey_info.rb->sim_lcd_ex_init(129, _grey_get_pixel);
448 grey_update(); 445 grey_update();
449#else /* !SIMULATOR */ 446#else /* !SIMULATOR */
450#ifdef NEED_BOOST 447#ifdef NEED_BOOST
451 _grey_rb->cpu_boost(true); 448 _grey_info.rb->cpu_boost(true);
452#endif 449#endif
453#if CONFIG_LCD == LCD_SSD1815 450#if CONFIG_LCD == LCD_SSD1815
454 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 67, 1, _timer_isr); 451 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 67, 1, _timer_isr);
455#elif CONFIG_LCD == LCD_S1D15E06 452#elif CONFIG_LCD == LCD_S1D15E06
456 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 70, 1, _timer_isr); 453 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 70, 1, _timer_isr);
457#elif CONFIG_LCD == LCD_IPOD2BPP 454#elif CONFIG_LCD == LCD_IPOD2BPP
458#ifdef IPOD_1G2G 455#ifdef IPOD_1G2G
459 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 95, 1, _timer_isr); /* verified */ 456 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 95, 1, _timer_isr); /* verified */
460#elif defined IPOD_3G 457#elif defined IPOD_3G
461 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 87, 1, _timer_isr); /* verified */ 458 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 87, 1, _timer_isr); /* verified */
462#else 459#else
463 /* FIXME: verify value */ 460 /* FIXME: verify value */
464 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 80, 1, _timer_isr); 461 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 80, 1, _timer_isr);
465#endif 462#endif
466#elif CONFIG_LCD == LCD_IPODMINI 463#elif CONFIG_LCD == LCD_IPODMINI
467 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 88, 1, _timer_isr); 464 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 88, 1, _timer_isr);
468#elif CONFIG_LCD == LCD_IFP7XX 465#elif CONFIG_LCD == LCD_IFP7XX
469 _grey_rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); 466 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr);
470#endif /* CONFIG_LCD */ 467#endif /* CONFIG_LCD */
471#endif /* !SIMULATOR */ 468#endif /* !SIMULATOR */
472 _grey_rb->screen_dump_set_hook(grey_screendump_hook); 469 _grey_info.rb->screen_dump_set_hook(grey_screendump_hook);
473 } 470 }
474 else if (!enable && (_grey_info.flags & _GREY_RUNNING)) 471 else if (!enable && (_grey_info.flags & _GREY_RUNNING))
475 { 472 {
476#ifdef SIMULATOR 473#ifdef SIMULATOR
477 _grey_rb->sim_lcd_ex_init(0, NULL); 474 _grey_info.rb->sim_lcd_ex_init(0, NULL);
478#else 475#else
479 _grey_rb->timer_unregister(); 476 _grey_info.rb->timer_unregister();
480#ifdef NEED_BOOST 477#ifdef NEED_BOOST
481 _grey_rb->cpu_boost(false); 478 _grey_info.rb->cpu_boost(false);
482#endif 479#endif
483#endif 480#endif
484 _grey_info.flags &= ~_GREY_RUNNING; 481 _grey_info.flags &= ~_GREY_RUNNING;
485 _grey_rb->screen_dump_set_hook(NULL); 482 _grey_info.rb->screen_dump_set_hook(NULL);
486 _grey_rb->lcd_update(); /* restore whatever there was before */ 483 _grey_info.rb->lcd_update(); /* restore whatever there was before */
487 } 484 }
488} 485}
489 486
@@ -512,7 +509,7 @@ void grey_update_rect(int x, int y, int width, int height)
512 if (y + height > LCD_HEIGHT) 509 if (y + height > LCD_HEIGHT)
513 height = LCD_HEIGHT - y; 510 height = LCD_HEIGHT - y;
514 511
515 _grey_rb->sim_lcd_ex_update_rect(x, y, width, height); 512 _grey_info.rb->sim_lcd_ex_update_rect(x, y, width, height);
516} 513}
517 514
518#else /* !SIMULATOR */ 515#else /* !SIMULATOR */
@@ -523,20 +520,20 @@ void grey_update_rect(int x, int y, int width, int height)
523 520
524 if ((width <= 0) || (height <= 0)) 521 if ((width <= 0) || (height <= 0))
525 return; /* nothing to do */ 522 return; /* nothing to do */
526 523
527 if (y + height > _grey_info.height) 524 if (y + height > _grey_info.height)
528 height = _grey_info.height - y; 525 height = _grey_info.height - y;
529 if (x + width > _grey_info.width) 526 if (x + width > _grey_info.width)
530 width = _grey_info.width - x; 527 width = _grey_info.width - x;
531 528
532 src = _grey_info.buffer + _GREY_MULUQ(_grey_info.width, y) + x; 529 src = _grey_info.buffer + _GREY_MULUQ(_grey_info.width, y) + x;
533 530
534#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 531#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
535 dst = _grey_info.values + _GREY_MULUQ(_grey_info.width, y) + x; 532 dst = _grey_info.values + _GREY_MULUQ(_grey_info.width, y) + x;
536 533
537 do 534 do
538 { 535 {
539 _grey_rb->memcpy(dst, src, width); 536 _grey_info.rb->memcpy(dst, src, width);
540 dst += _grey_info.width; 537 dst += _grey_info.width;
541 src += _grey_info.width; 538 src += _grey_info.width;
542 } 539 }
@@ -557,7 +554,7 @@ void grey_update_rect(int x, int y, int width, int height)
557 dst += _GREY_BSIZE; 554 dst += _GREY_BSIZE;
558 } 555 }
559 while (src_row < src_end); 556 while (src_row < src_end);
560 557
561 y++; 558 y++;
562 src += _grey_info.width; 559 src += _grey_info.width;
563 } 560 }
@@ -587,7 +584,7 @@ void grey_deferred_lcd_update(void)
587#endif 584#endif
588 } 585 }
589 else 586 else
590 _grey_rb->lcd_update(); 587 _grey_info.rb->lcd_update();
591} 588}
592 589
593/*** Screenshot ***/ 590/*** Screenshot ***/
@@ -662,10 +659,10 @@ static void grey_screendump_hook(int fd)
662 unsigned char *clut_entry; 659 unsigned char *clut_entry;
663 unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; 660 unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)];
664 661
665 _grey_rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ 662 _grey_info.rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */
666 663
667 /* build clut */ 664 /* build clut */
668 _grey_rb->memset(linebuf, 0, 4*BMP_VARCOLORS); 665 _grey_info.rb->memset(linebuf, 0, 4*BMP_VARCOLORS);
669 clut_entry = linebuf; 666 clut_entry = linebuf;
670 667
671 for (i = 0; i <= 128; i++) 668 for (i = 0; i <= 128; i++)
@@ -675,17 +672,17 @@ static void grey_screendump_hook(int fd)
675 *clut_entry++ = _GREY_MULUQ(BMP_RED, i) >> 7; 672 *clut_entry++ = _GREY_MULUQ(BMP_RED, i) >> 7;
676 clut_entry++; 673 clut_entry++;
677 } 674 }
678 _grey_rb->write(fd, linebuf, 4*BMP_VARCOLORS); 675 _grey_info.rb->write(fd, linebuf, 4*BMP_VARCOLORS);
679 676
680 /* BMP image goes bottom -> top */ 677 /* BMP image goes bottom -> top */
681 for (y = LCD_HEIGHT - 1; y >= 0; y--) 678 for (y = LCD_HEIGHT - 1; y >= 0; y--)
682 { 679 {
683 _grey_rb->memset(linebuf, 0, BMP_LINESIZE); 680 _grey_info.rb->memset(linebuf, 0, BMP_LINESIZE);
684 681
685 gy = y - _grey_info.y; 682 gy = y - _grey_info.y;
686#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 683#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
687#if LCD_DEPTH == 2 684#if LCD_DEPTH == 2
688 lcdptr = _grey_rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); 685 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y);
689 686
690 for (x = 0; x < LCD_WIDTH; x += 4) 687 for (x = 0; x < LCD_WIDTH; x += 4)
691 { 688 {
@@ -718,7 +715,7 @@ static void grey_screendump_hook(int fd)
718#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 715#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
719#if LCD_DEPTH == 1 716#if LCD_DEPTH == 1
720 mask = 1 << (y & 7); 717 mask = 1 << (y & 7);
721 lcdptr = _grey_rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); 718 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
722 719
723 for (x = 0; x < LCD_WIDTH; x++) 720 for (x = 0; x < LCD_WIDTH; x++)
724 { 721 {
@@ -734,8 +731,8 @@ static void grey_screendump_hook(int fd)
734#else 731#else
735 linebuf[x] = BMP_FIXEDCOLORS 732 linebuf[x] = BMP_FIXEDCOLORS
736 + _grey_info.values[_GREY_MULUQ(_grey_info.width, 733 + _grey_info.values[_GREY_MULUQ(_grey_info.width,
737 gy & ~_GREY_BMASK) 734 gy & ~_GREY_BMASK)
738 + (gx << _GREY_BSHIFT) 735 + (gx << _GREY_BSHIFT)
739 + (~gy & _GREY_BMASK)]; 736 + (~gy & _GREY_BMASK)];
740#endif 737#endif
741 } 738 }
@@ -747,7 +744,7 @@ static void grey_screendump_hook(int fd)
747 } 744 }
748#elif LCD_DEPTH == 2 745#elif LCD_DEPTH == 2
749 shift = 2 * (y & 3); 746 shift = 2 * (y & 3);
750 lcdptr = _grey_rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); 747 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2);
751 748
752 for (x = 0; x < LCD_WIDTH; x++) 749 for (x = 0; x < LCD_WIDTH; x++)
753 { 750 {
@@ -777,6 +774,6 @@ static void grey_screendump_hook(int fd)
777#endif /* LCD_DEPTH */ 774#endif /* LCD_DEPTH */
778#endif /* LCD_PIXELFORMAT */ 775#endif /* LCD_PIXELFORMAT */
779 776
780 _grey_rb->write(fd, linebuf, BMP_LINESIZE); 777 _grey_info.rb->write(fd, linebuf, BMP_LINESIZE);
781 } 778 }
782} 779}
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c
index 683793129e..9b8acd4c37 100644
--- a/apps/plugins/lib/grey_draw.c
+++ b/apps/plugins/lib/grey_draw.c
@@ -61,8 +61,8 @@ void grey_clear_display(void)
61 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 61 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
62 _grey_info.fg_val : _grey_info.bg_val; 62 _grey_info.fg_val : _grey_info.bg_val;
63 63
64 _grey_rb->memset(_grey_info.buffer, value, 64 _grey_info.rb->memset(_grey_info.buffer, value,
65 _GREY_MULUQ(_grey_info.width, _grey_info.height)); 65 _GREY_MULUQ(_grey_info.width, _grey_info.height));
66} 66}
67 67
68/* Set a single pixel */ 68/* Set a single pixel */
@@ -194,7 +194,7 @@ void grey_hline(int x1, int x2, int y)
194 dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x1]; 194 dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x1];
195 195
196 if (fillopt) 196 if (fillopt)
197 _grey_rb->memset(dst, value, x2 - x1 + 1); 197 _grey_info.rb->memset(dst, value, x2 - x1 + 1);
198 else 198 else
199 { 199 {
200 unsigned char *dst_end = dst + x2 - x1; 200 unsigned char *dst_end = dst + x2 - x1;
@@ -379,7 +379,7 @@ void grey_fillrect(int x, int y, int width, int height)
379 do 379 do
380 { 380 {
381 if (fillopt) 381 if (fillopt)
382 _grey_rb->memset(dst, value, width); 382 _grey_info.rb->memset(dst, value, width);
383 else 383 else
384 { 384 {
385 unsigned char *dst_row = dst; 385 unsigned char *dst_row = dst;
@@ -539,7 +539,7 @@ void grey_gray_bitmap(const unsigned char *src, int x, int y, int width,
539void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) 539void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str)
540{ 540{
541 int ch; 541 int ch;
542 struct font* pf = _grey_rb->font_get(_grey_info.curfont); 542 struct font* pf = _grey_info.rb->font_get(_grey_info.curfont);
543 543
544 while ((ch = *str++) != '\0' && x < _grey_info.width) 544 while ((ch = *str++) != '\0' && x < _grey_info.width)
545 { 545 {
@@ -603,8 +603,8 @@ void grey_ub_clear_display(void)
603 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 603 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
604 _grey_info.fg_val : _grey_info.bg_val; 604 _grey_info.fg_val : _grey_info.bg_val;
605 605
606 _grey_rb->memset(_grey_info.values, value, 606 _grey_info.rb->memset(_grey_info.values, value,
607 _GREY_MULUQ(_grey_info.width, _grey_info.height)); 607 _GREY_MULUQ(_grey_info.width, _grey_info.height));
608} 608}
609 609
610/* Draw a partial greyscale bitmap, canonical format */ 610/* Draw a partial greyscale bitmap, canonical format */
diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c
index 6d605059f8..e2accee518 100644
--- a/apps/plugins/lib/grey_parm.c
+++ b/apps/plugins/lib/grey_parm.c
@@ -112,5 +112,5 @@ void grey_setfont(int newfont)
112/* Get width and height of a text when printed with the current font */ 112/* Get width and height of a text when printed with the current font */
113int grey_getstringsize(const unsigned char *str, int *w, int *h) 113int grey_getstringsize(const unsigned char *str, int *w, int *h)
114{ 114{
115 return _grey_rb->font_getstringsize(str, w, h, _grey_info.curfont); 115 return _grey_info.rb->font_getstringsize(str, w, h, _grey_info.curfont);
116} 116}
diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c
index 0e88655c89..5040dd4c74 100644
--- a/apps/plugins/lib/grey_scroll.c
+++ b/apps/plugins/lib/grey_scroll.c
@@ -45,9 +45,9 @@ void grey_scroll_left(int count)
45 45
46 do 46 do
47 { 47 {
48 _grey_rb->memmove(data, data + count, length); 48 _grey_info.rb->memmove(data, data + count, length);
49 data += length; 49 data += length;
50 _grey_rb->memset(data, blank, count); 50 _grey_info.rb->memset(data, blank, count);
51 data += count; 51 data += count;
52 } 52 }
53 while (data < data_end); 53 while (data < data_end);
@@ -70,8 +70,8 @@ void grey_scroll_right(int count)
70 70
71 do 71 do
72 { 72 {
73 _grey_rb->memmove(data + count, data, length); 73 _grey_info.rb->memmove(data + count, data, length);
74 _grey_rb->memset(data, blank, count); 74 _grey_info.rb->memset(data, blank, count);
75 data += _grey_info.width; 75 data += _grey_info.width;
76 } 76 }
77 while (data < data_end); 77 while (data < data_end);
@@ -91,8 +91,9 @@ void grey_scroll_up(int count)
91 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 91 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
92 _grey_info.fg_val : _grey_info.bg_val; 92 _grey_info.fg_val : _grey_info.bg_val;
93 93
94 _grey_rb->memmove(_grey_info.buffer, _grey_info.buffer + shift, length); 94 _grey_info.rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
95 _grey_rb->memset(_grey_info.buffer + length, blank, shift); 95 length);
96 _grey_info.rb->memset(_grey_info.buffer + length, blank, shift);
96} 97}
97 98
98/* Scroll down */ 99/* Scroll down */
@@ -109,8 +110,9 @@ void grey_scroll_down(int count)
109 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 110 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
110 _grey_info.fg_val : _grey_info.bg_val; 111 _grey_info.fg_val : _grey_info.bg_val;
111 112
112 _grey_rb->memmove(_grey_info.buffer + shift, _grey_info.buffer, length); 113 _grey_info.rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
113 _grey_rb->memset(_grey_info.buffer, blank, shift); 114 length);
115 _grey_info.rb->memset(_grey_info.buffer, blank, shift);
114} 116}
115 117
116/*** Unbuffered scrolling functions ***/ 118/*** Unbuffered scrolling functions ***/
@@ -155,7 +157,7 @@ void grey_ub_scroll_left(int count)
155 157
156 if ((unsigned)count >= (unsigned)_grey_info.width) 158 if ((unsigned)count >= (unsigned)_grey_info.width)
157 return; 159 return;
158 160
159 data = _grey_info.values; 161 data = _grey_info.values;
160 data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); 162 data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
161 length = (_grey_info.width - count) << _GREY_BSHIFT; 163 length = (_grey_info.width - count) << _GREY_BSHIFT;
@@ -165,9 +167,9 @@ void grey_ub_scroll_left(int count)
165 167
166 do 168 do
167 { 169 {
168 _grey_rb->memmove(data, data + count, length); 170 _grey_info.rb->memmove(data, data + count, length);
169 data += length; 171 data += length;
170 _grey_rb->memset(data, blank, count); 172 _grey_info.rb->memset(data, blank, count);
171 data += count; 173 data += count;
172 } 174 }
173 while (data < data_end); 175 while (data < data_end);
@@ -181,7 +183,7 @@ void grey_ub_scroll_right(int count)
181 183
182 if ((unsigned)count >= (unsigned)_grey_info.width) 184 if ((unsigned)count >= (unsigned)_grey_info.width)
183 return; 185 return;
184 186
185 data = _grey_info.values; 187 data = _grey_info.values;
186 data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); 188 data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
187 length = (_grey_info.width - count) << _GREY_BSHIFT; 189 length = (_grey_info.width - count) << _GREY_BSHIFT;
@@ -191,8 +193,8 @@ void grey_ub_scroll_right(int count)
191 193
192 do 194 do
193 { 195 {
194 _grey_rb->memmove(data + count, data, length); 196 _grey_info.rb->memmove(data + count, data, length);
195 _grey_rb->memset(data, blank, count); 197 _grey_info.rb->memset(data, blank, count);
196 data += _grey_info.width << _GREY_BSHIFT; 198 data += _grey_info.width << _GREY_BSHIFT;
197 } 199 }
198 while (data < data_end); 200 while (data < data_end);
@@ -206,7 +208,7 @@ void grey_ub_scroll_up(int count)
206 208
207 if ((unsigned)count >= (unsigned)_grey_info.height) 209 if ((unsigned)count >= (unsigned)_grey_info.height)
208 return; 210 return;
209 211
210 dst = _grey_info.values; 212 dst = _grey_info.values;
211 end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width); 213 end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
212 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 214 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
@@ -258,10 +260,10 @@ void grey_ub_scroll_up(int count)
258 int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); 260 int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);
259 261
260 src = dst + _GREY_MULUQ(count, _grey_info.width); 262 src = dst + _GREY_MULUQ(count, _grey_info.width);
261 _grey_rb->memmove(dst, src, blen); 263 _grey_info.rb->memmove(dst, src, blen);
262 dst += blen; 264 dst += blen;
263 } 265 }
264 _grey_rb->memset(dst, blank, end - dst); /* Fill remainder at once. */ 266 _grey_info.rb->memset(dst, blank, end - dst); /* Fill remainder at once. */
265} 267}
266 268
267/* Scroll down */ 269/* Scroll down */
@@ -272,7 +274,7 @@ void grey_ub_scroll_down(int count)
272 274
273 if ((unsigned)count >= (unsigned)_grey_info.height) 275 if ((unsigned)count >= (unsigned)_grey_info.height)
274 return; 276 return;
275 277
276 start = _grey_info.values; 278 start = _grey_info.values;
277 dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width); 279 dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
278 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 280 blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
@@ -304,7 +306,7 @@ void grey_ub_scroll_down(int count)
304 } 306 }
305 while (dst < line_end); 307 while (dst < line_end);
306 } 308 }
307 for (; ~yd & _GREY_BMASK; yd--) /* Fill remainder of current block. */ 309 for (; ~yd & _GREY_BMASK; yd--) /* Fill remainder of current block. */
308 { 310 {
309 dst = _grey_info.values 311 dst = _grey_info.values
310 + _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK) 312 + _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK)
@@ -325,9 +327,10 @@ void grey_ub_scroll_down(int count)
325 int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); 327 int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);
326 328
327 dst -= blen; 329 dst -= blen;
328 _grey_rb->memmove(dst, start, blen); 330 _grey_info.rb->memmove(dst, start, blen);
329 } 331 }
330 _grey_rb->memset(start, blank, dst - start); /* Fill remainder at once. */ 332 _grey_info.rb->memset(start, blank, dst - start);
333 /* Fill remainder at once. */
331} 334}
332 335
333#endif /* !SIMULATOR */ 336#endif /* !SIMULATOR */
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index 76c5030874..11f4d34eea 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -211,6 +211,7 @@ static int step_log2;
211static unsigned max_iter; 211static unsigned max_iter;
212 212
213#ifdef USEGSLIB 213#ifdef USEGSLIB
214GREY_INFO_STRUCT
214static unsigned char *gbuf; 215static unsigned char *gbuf;
215static size_t gbuf_size = 0; 216static size_t gbuf_size = 0;
216static unsigned char imgbuffer[LCD_HEIGHT]; 217static unsigned char imgbuffer[LCD_HEIGHT];
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c
index b164254dd7..53b5631879 100644
--- a/apps/plugins/mpegplayer/stream_mgr.c
+++ b/apps/plugins/mpegplayer/stream_mgr.c
@@ -23,6 +23,10 @@
23#include "grey.h" 23#include "grey.h"
24#include "mpeg_settings.h" 24#include "mpeg_settings.h"
25 25
26#ifndef HAVE_LCD_COLOR
27GREY_INFO_STRUCT_IRAM
28#endif
29
26static struct event_queue stream_mgr_queue NOCACHEBSS_ATTR; 30static struct event_queue stream_mgr_queue NOCACHEBSS_ATTR;
27static struct queue_sender_list stream_mgr_queue_send NOCACHEBSS_ATTR; 31static struct queue_sender_list stream_mgr_queue_send NOCACHEBSS_ATTR;
28static uint32_t stream_mgr_thread_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)]; 32static uint32_t stream_mgr_thread_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)];
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index 4f5fc39eb2..ce2af5c87b 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -44,6 +44,7 @@ static int redfactor = 1, greenfactor = 2, bluefactor = 3;
44static int redphase = 0, greenphase = 50, bluephase = 100; 44static int redphase = 0, greenphase = 50, bluephase = 100;
45 /* lower chance of gray at regular intervals */ 45 /* lower chance of gray at regular intervals */
46#else 46#else
47GREY_INFO_STRUCT
47static unsigned char colours[256]; /* Smooth transition of shades */ 48static unsigned char colours[256]; /* Smooth transition of shades */
48static unsigned char greybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */ 49static unsigned char greybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */
49static unsigned char *gbuf; 50static unsigned char *gbuf;
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index fd1ee2a89b..37a93cc489 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -257,6 +257,8 @@ static void time_remote_update(void)
257#endif 257#endif
258 258
259#if LCD_DEPTH < 4 259#if LCD_DEPTH < 4
260
261GREY_INFO_STRUCT
260static unsigned char greydata[LCD_HEIGHT][LCD_WIDTH]; 262static unsigned char greydata[LCD_HEIGHT][LCD_WIDTH];
261 263
262static void make_grey_rect(int width, int height) 264static void make_grey_rect(int width, int height)
@@ -312,7 +314,7 @@ static void time_greyscale(void)
312 314
313 grey_release(); 315 grey_release();
314 fps = calc_tenth_fps(frames_2, time_2); 316 fps = calc_tenth_fps(frames_2, time_2);
315 load = 100 - (100* frames_2 * time_1) / (frames_1 * time_2); 317 load = 100 - (100 * frames_2 * time_1) / (frames_1 * time_2);
316 rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10); 318 rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10);
317 log_text(str); 319 log_text(str);
318 320
diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c
index ebb689ce9c..3d395986af 100644
--- a/apps/plugins/zxbox/zxbox.c
+++ b/apps/plugins/zxbox/zxbox.c
@@ -51,6 +51,7 @@ unsigned char image_array [ HEIGHT * WIDTH ];
51static int previous_state; 51static int previous_state;
52 52
53#ifdef USE_GREY 53#ifdef USE_GREY
54GREY_INFO_STRUCT_IRAM
54static unsigned char *gbuf; 55static unsigned char *gbuf;
55static size_t gbuf_size = 0; 56static size_t gbuf_size = 0;
56#endif 57#endif