summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c')
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c87
1 files changed, 5 insertions, 82 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c
index 140e448630..8edc4b7758 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c
@@ -29,18 +29,14 @@
29#include "pinctrl-imx233.h" 29#include "pinctrl-imx233.h"
30#include "logf.h" 30#include "logf.h"
31 31
32extern bool lcd_on; /* lcd-memframe.c */
33
32/* Copies a rectangle from one framebuffer to another. Can be used in 34/* Copies a rectangle from one framebuffer to another. Can be used in
33 single transfer mode with width = num pixels, and height = 1 which 35 single transfer mode with width = num pixels, and height = 1 which
34 allows a full-width rectangle to be copied more efficiently. */ 36 allows a full-width rectangle to be copied more efficiently. */
35extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, 37extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
36 int width, int height); 38 int width, int height);
37 39
38static unsigned lcd_yuv_options = 0;
39
40#ifdef HAVE_LCD_ENABLE
41static bool lcd_on = true;
42#endif
43
44static enum lcd_kind_t 40static enum lcd_kind_t
45{ 41{
46 LCD_KIND_7783 = 0x7783, 42 LCD_KIND_7783 = 0x7783,
@@ -386,6 +382,8 @@ void lcd_init_device(void)
386 lcd_kind = LCD_KIND_7783; 382 lcd_kind = LCD_KIND_7783;
387 lcd_init_seq_7783(); break; 383 lcd_init_seq_7783(); break;
388 } 384 }
385
386 lcd_on = true;
389} 387}
390 388
391#ifdef HAVE_LCD_ENABLE 389#ifdef HAVE_LCD_ENABLE
@@ -469,6 +467,7 @@ void lcd_enable(bool enable)
469{ 467{
470 if(lcd_on == enable) 468 if(lcd_on == enable)
471 return; 469 return;
470
472 lcd_on = enable; 471 lcd_on = enable;
473 472
474 if(enable) 473 if(enable)
@@ -482,11 +481,6 @@ void lcd_enable(bool enable)
482 if(!enable) 481 if(!enable)
483 common_lcd_enable(false); 482 common_lcd_enable(false);
484} 483}
485
486bool lcd_active(void)
487{
488 return lcd_on;
489}
490#endif 484#endif
491 485
492void lcd_update(void) 486void lcd_update(void)
@@ -520,74 +514,3 @@ void lcd_update_rect(int x, int y, int width, int height)
520 (void) height; 514 (void) height;
521 lcd_update(); 515 lcd_update();
522} 516}
523
524void lcd_yuv_set_options(unsigned options)
525{
526 lcd_yuv_options = options;
527}
528
529/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
530extern void lcd_write_yuv420_lines(fb_data *dst,
531 unsigned char const * const src[3],
532 int width,
533 int stride);
534extern void lcd_write_yuv420_lines_odither(fb_data *dst,
535 unsigned char const * const src[3],
536 int width,
537 int stride,
538 int x_screen, /* To align dither pattern */
539 int y_screen);
540/* Performance function to blit a YUV bitmap directly to the LCD */
541/* So the LCD_WIDTH is now the height */
542void lcd_blit_yuv(unsigned char * const src[3],
543 int src_x, int src_y, int stride,
544 int x, int y, int width, int height)
545{
546 /* Caches for chroma data so it only need be recaculated every other
547 line */
548 unsigned char const * yuv_src[3];
549 off_t z;
550
551#ifdef HAVE_LCD_ENABLE
552 if (!lcd_on)
553 return;
554#endif
555
556 /* Sorry, but width and height must be >= 2 or else */
557 width &= ~1;
558 height >>= 1;
559
560 y = LCD_WIDTH - 1 - y;
561 fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + y;
562
563 z = stride*src_y;
564 yuv_src[0] = src[0] + z + src_x;
565 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
566 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
567
568 if (lcd_yuv_options & LCD_YUV_DITHER)
569 {
570 do
571 {
572 lcd_write_yuv420_lines_odither(dst, yuv_src, width, stride, y, x);
573 yuv_src[0] += stride << 1; /* Skip down two luma lines */
574 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
575 yuv_src[2] += stride >> 1;
576 dst -= 2;
577 y -= 2;
578 }
579 while (--height > 0);
580 }
581 else
582 {
583 do
584 {
585 lcd_write_yuv420_lines(dst, yuv_src, width, stride);
586 yuv_src[0] += stride << 1; /* Skip down two luma lines */
587 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
588 yuv_src[2] += stride >> 1;
589 dst -= 2;
590 }
591 while (--height > 0);
592 }
593}