diff options
Diffstat (limited to 'apps/plugins/lib/grey_core.c')
-rw-r--r-- | apps/plugins/lib/grey_core.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index c4eb0fc080..c73f0cdf52 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -336,16 +336,16 @@ static inline void _deferred_update(void) | |||
336 | int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT); | 336 | int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT); |
337 | 337 | ||
338 | if (y1 > 0) /* refresh part above overlay, full width */ | 338 | if (y1 > 0) /* refresh part above overlay, full width */ |
339 | _grey_info.rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); | 339 | rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); |
340 | 340 | ||
341 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ | 341 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ |
342 | _grey_info.rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); | 342 | rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); |
343 | 343 | ||
344 | if (x1 > 0) /* refresh part to the left of overlay */ | 344 | if (x1 > 0) /* refresh part to the left of overlay */ |
345 | _grey_info.rb->lcd_update_rect(0, y1, x1, y2 - y1); | 345 | rb->lcd_update_rect(0, y1, x1, y2 - y1); |
346 | 346 | ||
347 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ | 347 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ |
348 | _grey_info.rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); | 348 | rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); |
349 | } | 349 | } |
350 | 350 | ||
351 | #ifdef SIMULATOR | 351 | #ifdef SIMULATOR |
@@ -373,7 +373,7 @@ static unsigned long _grey_get_pixel(int x, int y) | |||
373 | static void _timer_isr(void) | 373 | static void _timer_isr(void) |
374 | { | 374 | { |
375 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | 375 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) |
376 | unsigned long check = _grey_info.rb->is_backlight_on(true) | 376 | unsigned long check = rb->is_backlight_on(true) |
377 | ? 0 : _GREY_BACKLIGHT_ON; | 377 | ? 0 : _GREY_BACKLIGHT_ON; |
378 | 378 | ||
379 | if ((_grey_info.flags & (_GREY_BACKLIGHT_ON|GREY_RAWMAPPED)) == check) | 379 | if ((_grey_info.flags & (_GREY_BACKLIGHT_ON|GREY_RAWMAPPED)) == check) |
@@ -384,12 +384,12 @@ static void _timer_isr(void) | |||
384 | } | 384 | } |
385 | #endif | 385 | #endif |
386 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 386 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
387 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, | 387 | rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, |
388 | _grey_info.bx, _grey_info.y, | 388 | _grey_info.bx, _grey_info.y, |
389 | _grey_info.bwidth, _grey_info.height, | 389 | _grey_info.bwidth, _grey_info.height, |
390 | _grey_info.width); | 390 | _grey_info.width); |
391 | #else /* vertical packing or vertical interleaved */ | 391 | #else /* vertical packing or vertical interleaved */ |
392 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, | 392 | rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, |
393 | _grey_info.x, _grey_info.by, | 393 | _grey_info.x, _grey_info.by, |
394 | _grey_info.width, _grey_info.bheight, | 394 | _grey_info.width, _grey_info.bheight, |
395 | _grey_info.width); | 395 | _grey_info.width); |
@@ -501,7 +501,7 @@ static void fill_gvalues(void) | |||
501 | 501 | ||
502 | The function is authentic regarding memory usage on the simulator, even | 502 | The function is authentic regarding memory usage on the simulator, even |
503 | if it doesn't use all of the allocated memory. */ | 503 | if it doesn't use all of the allocated memory. */ |
504 | bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 504 | bool grey_init(unsigned char *gbuf, long gbuf_size, |
505 | unsigned features, int width, int height, long *buf_taken) | 505 | unsigned features, int width, int height, long *buf_taken) |
506 | { | 506 | { |
507 | int bdim, i; | 507 | int bdim, i; |
@@ -511,8 +511,6 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
511 | unsigned *dst, *end; | 511 | unsigned *dst, *end; |
512 | #endif | 512 | #endif |
513 | 513 | ||
514 | _grey_info.rb = newrb; | ||
515 | |||
516 | if ((unsigned) width > LCD_WIDTH | 514 | if ((unsigned) width > LCD_WIDTH |
517 | || (unsigned) height > LCD_HEIGHT) | 515 | || (unsigned) height > LCD_HEIGHT) |
518 | return false; | 516 | return false; |
@@ -559,7 +557,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
559 | return false; | 557 | return false; |
560 | 558 | ||
561 | /* Init to white */ | 559 | /* Init to white */ |
562 | _grey_info.rb->memset(_grey_info.values, 0x80, plane_size); | 560 | rb->memset(_grey_info.values, 0x80, plane_size); |
563 | 561 | ||
564 | #ifndef SIMULATOR | 562 | #ifndef SIMULATOR |
565 | /* Init phases with random bits */ | 563 | /* Init phases with random bits */ |
@@ -567,7 +565,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
567 | end = (unsigned*)(_grey_info.phases + plane_size); | 565 | end = (unsigned*)(_grey_info.phases + plane_size); |
568 | 566 | ||
569 | do | 567 | do |
570 | *dst++ = _grey_info.rb->rand(); | 568 | *dst++ = rb->rand(); |
571 | while (dst < end); | 569 | while (dst < end); |
572 | #endif | 570 | #endif |
573 | 571 | ||
@@ -601,7 +599,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
601 | else | 599 | else |
602 | { | 600 | { |
603 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | 601 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) |
604 | if (_grey_info.rb->is_backlight_on(true)) | 602 | if (rb->is_backlight_on(true)) |
605 | _grey_info.flags |= _GREY_BACKLIGHT_ON; | 603 | _grey_info.flags |= _GREY_BACKLIGHT_ON; |
606 | #endif | 604 | #endif |
607 | fill_gvalues(); | 605 | fill_gvalues(); |
@@ -636,40 +634,40 @@ void grey_show(bool enable) | |||
636 | { | 634 | { |
637 | _grey_info.flags |= _GREY_RUNNING; | 635 | _grey_info.flags |= _GREY_RUNNING; |
638 | #ifdef SIMULATOR | 636 | #ifdef SIMULATOR |
639 | _grey_info.rb->sim_lcd_ex_init(129, _grey_get_pixel); | 637 | rb->sim_lcd_ex_init(129, _grey_get_pixel); |
640 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 638 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
641 | _grey_info.width, _grey_info.height); | 639 | _grey_info.width, _grey_info.height); |
642 | #else /* !SIMULATOR */ | 640 | #else /* !SIMULATOR */ |
643 | #ifdef NEED_BOOST | 641 | #ifdef NEED_BOOST |
644 | _grey_info.rb->cpu_boost(true); | 642 | rb->cpu_boost(true); |
645 | #endif | 643 | #endif |
646 | #if NUM_CORES > 1 | 644 | #if NUM_CORES > 1 |
647 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, | 645 | rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, |
648 | 1, _timer_isr, | 646 | 1, _timer_isr, |
649 | (_grey_info.flags & GREY_ON_COP) ? COP : CPU); | 647 | (_grey_info.flags & GREY_ON_COP) ? COP : CPU); |
650 | #else | 648 | #else |
651 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, | 649 | rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, |
652 | _timer_isr); | 650 | _timer_isr); |
653 | #endif | 651 | #endif |
654 | #endif /* !SIMULATOR */ | 652 | #endif /* !SIMULATOR */ |
655 | _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); | 653 | rb->screen_dump_set_hook(grey_screendump_hook); |
656 | } | 654 | } |
657 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) | 655 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) |
658 | { | 656 | { |
659 | #ifdef SIMULATOR | 657 | #ifdef SIMULATOR |
660 | _grey_info.rb->sim_lcd_ex_init(0, NULL); | 658 | rb->sim_lcd_ex_init(0, NULL); |
661 | #else /* !SIMULATOR */ | 659 | #else /* !SIMULATOR */ |
662 | _grey_info.rb->timer_unregister(); | 660 | rb->timer_unregister(); |
663 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ | 661 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ |
664 | _grey_info.rb->sleep(HZ/100); | 662 | rb->sleep(HZ/100); |
665 | #endif | 663 | #endif |
666 | #ifdef NEED_BOOST | 664 | #ifdef NEED_BOOST |
667 | _grey_info.rb->cpu_boost(false); | 665 | rb->cpu_boost(false); |
668 | #endif | 666 | #endif |
669 | #endif /* !SIMULATOR */ | 667 | #endif /* !SIMULATOR */ |
670 | _grey_info.flags &= ~_GREY_RUNNING; | 668 | _grey_info.flags &= ~_GREY_RUNNING; |
671 | _grey_info.rb->screen_dump_set_hook(NULL); | 669 | rb->screen_dump_set_hook(NULL); |
672 | _grey_info.rb->lcd_update(); /* restore whatever there was before */ | 670 | rb->lcd_update(); /* restore whatever there was before */ |
673 | } | 671 | } |
674 | } | 672 | } |
675 | 673 | ||
@@ -699,7 +697,7 @@ void grey_deferred_lcd_update(void) | |||
699 | #endif | 697 | #endif |
700 | } | 698 | } |
701 | else | 699 | else |
702 | _grey_info.rb->lcd_update(); | 700 | rb->lcd_update(); |
703 | } | 701 | } |
704 | 702 | ||
705 | /*** Screenshot ***/ | 703 | /*** Screenshot ***/ |
@@ -786,10 +784,10 @@ static void grey_screendump_hook(int fd) | |||
786 | unsigned char *clut_entry; | 784 | unsigned char *clut_entry; |
787 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; | 785 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; |
788 | 786 | ||
789 | _grey_info.rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ | 787 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ |
790 | 788 | ||
791 | /* build clut */ | 789 | /* build clut */ |
792 | _grey_info.rb->memset(linebuf, 0, 4*BMP_VARCOLORS); | 790 | rb->memset(linebuf, 0, 4*BMP_VARCOLORS); |
793 | clut_entry = linebuf; | 791 | clut_entry = linebuf; |
794 | 792 | ||
795 | for (i = 0; i <= 128; i++) | 793 | for (i = 0; i <= 128; i++) |
@@ -808,17 +806,17 @@ static void grey_screendump_hook(int fd) | |||
808 | #endif | 806 | #endif |
809 | clut_entry++; | 807 | clut_entry++; |
810 | } | 808 | } |
811 | _grey_info.rb->write(fd, linebuf, 4*BMP_VARCOLORS); | 809 | rb->write(fd, linebuf, 4*BMP_VARCOLORS); |
812 | 810 | ||
813 | /* BMP image goes bottom -> top */ | 811 | /* BMP image goes bottom -> top */ |
814 | for (y = LCD_HEIGHT - 1; y >= 0; y--) | 812 | for (y = LCD_HEIGHT - 1; y >= 0; y--) |
815 | { | 813 | { |
816 | _grey_info.rb->memset(linebuf, 0, BMP_LINESIZE); | 814 | rb->memset(linebuf, 0, BMP_LINESIZE); |
817 | 815 | ||
818 | gy = y - _grey_info.y; | 816 | gy = y - _grey_info.y; |
819 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 817 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
820 | #if LCD_DEPTH == 2 | 818 | #if LCD_DEPTH == 2 |
821 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); | 819 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); |
822 | 820 | ||
823 | for (x = 0; x < LCD_WIDTH; x += 4) | 821 | for (x = 0; x < LCD_WIDTH; x += 4) |
824 | { | 822 | { |
@@ -846,7 +844,7 @@ static void grey_screendump_hook(int fd) | |||
846 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING | 844 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING |
847 | #if LCD_DEPTH == 1 | 845 | #if LCD_DEPTH == 1 |
848 | mask = 1 << (y & 7); | 846 | mask = 1 << (y & 7); |
849 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 847 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
850 | 848 | ||
851 | for (x = 0; x < LCD_WIDTH; x++) | 849 | for (x = 0; x < LCD_WIDTH; x++) |
852 | { | 850 | { |
@@ -869,7 +867,7 @@ static void grey_screendump_hook(int fd) | |||
869 | } | 867 | } |
870 | #elif LCD_DEPTH == 2 | 868 | #elif LCD_DEPTH == 2 |
871 | shift = 2 * (y & 3); | 869 | shift = 2 * (y & 3); |
872 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); | 870 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); |
873 | 871 | ||
874 | for (x = 0; x < LCD_WIDTH; x++) | 872 | for (x = 0; x < LCD_WIDTH; x++) |
875 | { | 873 | { |
@@ -894,7 +892,7 @@ static void grey_screendump_hook(int fd) | |||
894 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED | 892 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED |
895 | #if LCD_DEPTH == 2 | 893 | #if LCD_DEPTH == 2 |
896 | shift = y & 7; | 894 | shift = y & 7; |
897 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 895 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
898 | 896 | ||
899 | for (x = 0; x < LCD_WIDTH; x++) | 897 | for (x = 0; x < LCD_WIDTH; x++) |
900 | { | 898 | { |
@@ -919,6 +917,6 @@ static void grey_screendump_hook(int fd) | |||
919 | #endif /* LCD_DEPTH */ | 917 | #endif /* LCD_DEPTH */ |
920 | #endif /* LCD_PIXELFORMAT */ | 918 | #endif /* LCD_PIXELFORMAT */ |
921 | 919 | ||
922 | _grey_info.rb->write(fd, linebuf, BMP_LINESIZE); | 920 | rb->write(fd, linebuf, BMP_LINESIZE); |
923 | } | 921 | } |
924 | } | 922 | } |